mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-03-26 11:21:16 +01:00
Refactor desktop app into separate client and proxy apps
This commit is contained in:
12
apps/yaak-proxy/index.html
Normal file
12
apps/yaak-proxy/index.html
Normal file
@@ -0,0 +1,12 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>Yaak Proxy</title>
|
||||
</head>
|
||||
<body>
|
||||
<div id="root"></div>
|
||||
<script type="module" src="/main.tsx"></script>
|
||||
</body>
|
||||
</html>
|
||||
95
apps/yaak-proxy/main.css
Normal file
95
apps/yaak-proxy/main.css
Normal file
@@ -0,0 +1,95 @@
|
||||
:root {
|
||||
color: #f4efe7;
|
||||
background:
|
||||
radial-gradient(circle at top, rgba(217, 119, 6, 0.35), transparent 45%),
|
||||
linear-gradient(180deg, #18212b 0%, #0f141a 100%);
|
||||
font-family: "IBM Plex Sans", "Segoe UI", sans-serif;
|
||||
}
|
||||
|
||||
* {
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
html,
|
||||
body,
|
||||
#root {
|
||||
margin: 0;
|
||||
min-height: 100%;
|
||||
}
|
||||
|
||||
body {
|
||||
min-height: 100vh;
|
||||
}
|
||||
|
||||
.app-shell {
|
||||
min-height: 100vh;
|
||||
display: grid;
|
||||
place-items: center;
|
||||
padding: 24px;
|
||||
}
|
||||
|
||||
.hero-card {
|
||||
width: min(680px, 100%);
|
||||
padding: 40px;
|
||||
border: 1px solid rgba(244, 239, 231, 0.12);
|
||||
border-radius: 28px;
|
||||
background: rgba(9, 12, 16, 0.7);
|
||||
box-shadow: 0 24px 80px rgba(0, 0, 0, 0.35);
|
||||
backdrop-filter: blur(18px);
|
||||
}
|
||||
|
||||
.eyebrow {
|
||||
margin: 0 0 12px;
|
||||
font-size: 12px;
|
||||
letter-spacing: 0.24em;
|
||||
text-transform: uppercase;
|
||||
color: #f6ad55;
|
||||
}
|
||||
|
||||
h1 {
|
||||
margin: 0;
|
||||
font-size: clamp(44px, 8vw, 84px);
|
||||
line-height: 0.95;
|
||||
}
|
||||
|
||||
.lede {
|
||||
margin: 20px 0 0;
|
||||
max-width: 48ch;
|
||||
font-size: 18px;
|
||||
line-height: 1.6;
|
||||
color: rgba(244, 239, 231, 0.78);
|
||||
}
|
||||
|
||||
.controls {
|
||||
margin-top: 28px;
|
||||
display: flex;
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
.btn {
|
||||
border: 0;
|
||||
border-radius: 10px;
|
||||
padding: 10px 14px;
|
||||
background: #f6ad55;
|
||||
color: #111;
|
||||
font-weight: 700;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.btn.ghost {
|
||||
background: rgba(255, 255, 255, 0.12);
|
||||
color: #f4efe7;
|
||||
}
|
||||
|
||||
.btn:disabled {
|
||||
opacity: 0.6;
|
||||
cursor: default;
|
||||
}
|
||||
|
||||
.status {
|
||||
margin-top: 14px;
|
||||
display: flex;
|
||||
gap: 16px;
|
||||
color: rgba(244, 239, 231, 0.88);
|
||||
font-size: 14px;
|
||||
}
|
||||
77
apps/yaak-proxy/main.tsx
Normal file
77
apps/yaak-proxy/main.tsx
Normal file
@@ -0,0 +1,77 @@
|
||||
import "./main.css";
|
||||
import { invoke } from "@tauri-apps/api/core";
|
||||
import { StrictMode } from "react";
|
||||
import { useState } from "react";
|
||||
import { createRoot } from "react-dom/client";
|
||||
|
||||
type ProxyStartResult = {
|
||||
port: number;
|
||||
alreadyRunning: boolean;
|
||||
};
|
||||
|
||||
function App() {
|
||||
const [status, setStatus] = useState("Idle");
|
||||
const [port, setPort] = useState<number | null>(null);
|
||||
const [busy, setBusy] = useState(false);
|
||||
|
||||
async function startProxy() {
|
||||
setBusy(true);
|
||||
setStatus("Starting...");
|
||||
try {
|
||||
const result = await invoke<ProxyStartResult>("proxy_start", {
|
||||
port: 9090,
|
||||
});
|
||||
setPort(result.port);
|
||||
setStatus(result.alreadyRunning ? "Already running" : "Running");
|
||||
} catch (err) {
|
||||
setStatus(`Failed: ${String(err)}`);
|
||||
} finally {
|
||||
setBusy(false);
|
||||
}
|
||||
}
|
||||
|
||||
async function stopProxy() {
|
||||
setBusy(true);
|
||||
setStatus("Stopping...");
|
||||
try {
|
||||
const stopped = await invoke<boolean>("proxy_stop");
|
||||
setPort(null);
|
||||
setStatus(stopped ? "Stopped" : "Not running");
|
||||
} catch (err) {
|
||||
setStatus(`Failed: ${String(err)}`);
|
||||
} finally {
|
||||
setBusy(false);
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<main className="app-shell">
|
||||
<section className="hero-card">
|
||||
<p className="eyebrow">Monorepo Smoke Test</p>
|
||||
<h1>Yaak Proxy</h1>
|
||||
<p className="lede">
|
||||
This is a minimal proxy app stub running on the new `apps/yaak-proxy`
|
||||
and `crates-tauri/yaak-app-proxy` structure.
|
||||
</p>
|
||||
<div className="controls">
|
||||
<button className="btn" disabled={busy} onClick={startProxy}>
|
||||
Start Proxy
|
||||
</button>
|
||||
<button className="btn ghost" disabled={busy} onClick={stopProxy}>
|
||||
Stop Proxy
|
||||
</button>
|
||||
</div>
|
||||
<div className="status">
|
||||
<span>Status: {status}</span>
|
||||
{port != null ? <span>Port: {port}</span> : null}
|
||||
</div>
|
||||
</section>
|
||||
</main>
|
||||
);
|
||||
}
|
||||
|
||||
createRoot(document.getElementById("root") as HTMLElement).render(
|
||||
<StrictMode>
|
||||
<App />
|
||||
</StrictMode>,
|
||||
);
|
||||
23
apps/yaak-proxy/package.json
Normal file
23
apps/yaak-proxy/package.json
Normal file
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"name": "@yaakapp/yaak-proxy",
|
||||
"private": true,
|
||||
"version": "1.0.0",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "vite dev --force",
|
||||
"build": "vite build",
|
||||
"lint": "tsc --noEmit"
|
||||
},
|
||||
"dependencies": {
|
||||
"@tauri-apps/api": "^2.9.1",
|
||||
"react": "^19.1.0",
|
||||
"react-dom": "^19.1.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/react": "^19.1.8",
|
||||
"@types/react-dom": "^19.1.6",
|
||||
"@vitejs/plugin-react": "^4.6.0",
|
||||
"typescript": "^5.8.3",
|
||||
"vite": "^7.0.8"
|
||||
}
|
||||
}
|
||||
22
apps/yaak-proxy/tsconfig.json
Normal file
22
apps/yaak-proxy/tsconfig.json
Normal file
@@ -0,0 +1,22 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"target": "es2021",
|
||||
"lib": ["DOM", "DOM.Iterable", "ESNext"],
|
||||
"useDefineForClassFields": true,
|
||||
"allowJs": false,
|
||||
"skipLibCheck": true,
|
||||
"allowSyntheticDefaultImports": true,
|
||||
"strict": true,
|
||||
"noUncheckedIndexedAccess": true,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"module": "ESNext",
|
||||
"moduleResolution": "Node",
|
||||
"resolveJsonModule": true,
|
||||
"isolatedModules": true,
|
||||
"noEmit": true,
|
||||
"jsx": "react-jsx"
|
||||
},
|
||||
"include": ["."],
|
||||
"exclude": ["vite.config.ts"],
|
||||
"references": [{ "path": "./tsconfig.node.json" }]
|
||||
}
|
||||
10
apps/yaak-proxy/tsconfig.node.json
Normal file
10
apps/yaak-proxy/tsconfig.node.json
Normal file
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"composite": true,
|
||||
"module": "ESNext",
|
||||
"moduleResolution": "Node",
|
||||
"allowSyntheticDefaultImports": true,
|
||||
"noUncheckedIndexedAccess": true
|
||||
},
|
||||
"include": ["vite.config.ts"]
|
||||
}
|
||||
1
apps/yaak-proxy/vite-env.d.ts
vendored
Normal file
1
apps/yaak-proxy/vite-env.d.ts
vendored
Normal file
@@ -0,0 +1 @@
|
||||
/// <reference types="vite/client" />
|
||||
Reference in New Issue
Block a user