create-zenbu-app 0.0.4 → 0.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +50 -3
- package/dist/index.mjs +439 -36
- package/package.json +9 -6
- package/templates/plugin/_gitignore +3 -0
- package/templates/plugin/package.json +24 -0
- package/templates/plugin/src/main/services/{{projectName}}.ts.tmpl +9 -0
- package/templates/plugin/tsconfig.json +14 -0
- package/templates/plugin/zenbu.plugin.ts.tmpl +6 -0
- package/{template → templates/tailwind}/_gitignore +3 -0
- package/templates/tailwind/package.json +47 -0
- package/templates/tailwind/src/main/schema.ts.tmpl +13 -0
- package/templates/tailwind/src/main/services/init.ts.tmpl +11 -0
- package/templates/tailwind/src/main/services/repo.ts.tmpl +11 -0
- package/templates/tailwind/src/renderer/App.tsx.tmpl +100 -0
- package/{template → templates/tailwind}/src/renderer/app.css +3 -0
- package/templates/tailwind/src/renderer/installing.html +118 -0
- package/{template → templates/tailwind}/src/renderer/main.tsx.tmpl +3 -3
- package/templates/tailwind/vite.config.ts.tmpl +17 -0
- package/{template → templates/tailwind}/zenbu.config.ts.tmpl +12 -8
- package/templates/vanilla/_gitignore +8 -0
- package/templates/vanilla/electron-builder.json +12 -0
- package/{template → templates/vanilla}/package.json +1 -1
- package/templates/vanilla/src/main/schema.ts.tmpl +13 -0
- package/templates/vanilla/src/main/services/init.ts.tmpl +11 -0
- package/templates/vanilla/src/main/services/repo.ts.tmpl +11 -0
- package/templates/vanilla/src/renderer/App.tsx.tmpl +83 -0
- package/templates/vanilla/src/renderer/app.css +143 -0
- package/templates/vanilla/src/renderer/index.html +12 -0
- package/templates/vanilla/src/renderer/installing.html +118 -0
- package/templates/vanilla/src/renderer/main.tsx.tmpl +10 -0
- package/templates/vanilla/src/renderer/splash.html +22 -0
- package/templates/vanilla/tsconfig.json.tmpl +18 -0
- package/templates/vanilla/zenbu.config.ts.tmpl +56 -0
- package/LICENSE +0 -11
- package/template/src/main/services/app.ts.tmpl +0 -14
- package/template/src/renderer/App.tsx.tmpl +0 -43
- /package/{template → templates/tailwind}/electron-builder.json +0 -0
- /package/{template → templates/tailwind}/src/renderer/index.html +0 -0
- /package/{template → templates/tailwind}/src/renderer/splash.html +0 -0
- /package/{template → templates/tailwind}/tsconfig.json.tmpl +0 -0
- /package/{template → templates/vanilla}/vite.config.ts.tmpl +0 -0
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "{{projectName}}",
|
|
3
|
+
"private": true,
|
|
4
|
+
"type": "module",
|
|
5
|
+
"main": "node_modules/@zenbujs/core/dist/setup-gate.mjs",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"dev": "zen dev",
|
|
8
|
+
"build:source": "zen build:source",
|
|
9
|
+
"build:electron": "zen build:electron",
|
|
10
|
+
"publish:source": "zen publish:source",
|
|
11
|
+
"link": "zen link",
|
|
12
|
+
"db:generate": "zen db generate"
|
|
13
|
+
},
|
|
14
|
+
"dependencies": {
|
|
15
|
+
"@zenbujs/core": "^0.0.12",
|
|
16
|
+
"@tailwindcss/vite": "^4.2.0",
|
|
17
|
+
"@vitejs/plugin-react": "^5.0.0",
|
|
18
|
+
"react": "^19.0.0",
|
|
19
|
+
"react-dom": "^19.0.0",
|
|
20
|
+
"tailwindcss": "^4.2.0",
|
|
21
|
+
"vite": "^6.0.0",
|
|
22
|
+
"zod": "^4.0.0"
|
|
23
|
+
},
|
|
24
|
+
"devDependencies": {
|
|
25
|
+
"@types/node": "^22.0.0",
|
|
26
|
+
"@types/react": "^19.0.0",
|
|
27
|
+
"@types/react-dom": "^19.0.0",
|
|
28
|
+
"electron": "^42.0.0",
|
|
29
|
+
"electron-builder": "^26.0.0"
|
|
30
|
+
},
|
|
31
|
+
"repository": {
|
|
32
|
+
"type": "git",
|
|
33
|
+
"url": ""
|
|
34
|
+
},
|
|
35
|
+
"zenbu": {
|
|
36
|
+
"host": ">=0.0.0 <0.1.0"
|
|
37
|
+
},
|
|
38
|
+
"pnpm": {
|
|
39
|
+
"onlyBuiltDependencies": [
|
|
40
|
+
"@parcel/watcher",
|
|
41
|
+
"dugite",
|
|
42
|
+
"electron",
|
|
43
|
+
"electron-winstaller",
|
|
44
|
+
"esbuild"
|
|
45
|
+
]
|
|
46
|
+
}
|
|
47
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Service } from "@zenbujs/core/runtime"
|
|
2
|
+
import { WindowService } from "@zenbujs/core/services"
|
|
3
|
+
|
|
4
|
+
export class InitService extends Service.create({
|
|
5
|
+
key: "init",
|
|
6
|
+
deps: { window: WindowService },
|
|
7
|
+
}) {
|
|
8
|
+
async evaluate() {
|
|
9
|
+
await this.ctx.window.openView({ type: "entrypoint" })
|
|
10
|
+
}
|
|
11
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Service } from "@zenbujs/core/runtime"
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Sample RPC service. Methods on the class are callable from the renderer
|
|
5
|
+
* via `useRpc()` — see `src/renderer/App.tsx`.
|
|
6
|
+
*/
|
|
7
|
+
export class Repo extends Service.create({ key: "repo" }) {
|
|
8
|
+
async getCwd() {
|
|
9
|
+
return process.cwd()
|
|
10
|
+
}
|
|
11
|
+
}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { useDb, useDbClient, useRpc } from "@zenbujs/core/react"
|
|
2
|
+
import { useState } from "react"
|
|
3
|
+
|
|
4
|
+
function Titlebar() {
|
|
5
|
+
return (
|
|
6
|
+
<div
|
|
7
|
+
className="h-10 flex items-center justify-end px-3 pl-[72px] shrink-0"
|
|
8
|
+
// @ts-expect-error webkit property
|
|
9
|
+
style={{ WebkitAppRegion: "drag" }}
|
|
10
|
+
/>
|
|
11
|
+
)
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
function Home() {
|
|
15
|
+
const db = useDb()
|
|
16
|
+
const client = useDbClient()
|
|
17
|
+
const rpc = useRpc()
|
|
18
|
+
const [cwd, setCwd] = useState<string | null>(null)
|
|
19
|
+
|
|
20
|
+
const issues = db.app.issues
|
|
21
|
+
|
|
22
|
+
return (
|
|
23
|
+
<main className="flex-1 px-8 pb-8 font-sans text-[#e5e5e5]">
|
|
24
|
+
<h1 className="text-2xl font-bold mb-2">Welcome to Zenbu</h1>
|
|
25
|
+
<p className="text-[#888] mb-6">
|
|
26
|
+
Edit <code>src/renderer/App.tsx</code> to get started.
|
|
27
|
+
</p>
|
|
28
|
+
|
|
29
|
+
<form
|
|
30
|
+
className="flex flex-col gap-3 bg-[#18181b] rounded-xl p-4 max-w-md mb-6"
|
|
31
|
+
onSubmit={(e) => {
|
|
32
|
+
e.preventDefault()
|
|
33
|
+
const form = e.currentTarget
|
|
34
|
+
const title = (form.elements.namedItem("title") as HTMLInputElement).value
|
|
35
|
+
if (!title.trim()) return
|
|
36
|
+
client.update((db) => {
|
|
37
|
+
db.app.issues.push({
|
|
38
|
+
id: crypto.randomUUID(),
|
|
39
|
+
title,
|
|
40
|
+
createdAt: Date.now(),
|
|
41
|
+
})
|
|
42
|
+
})
|
|
43
|
+
form.reset()
|
|
44
|
+
}}
|
|
45
|
+
>
|
|
46
|
+
<input
|
|
47
|
+
name="title"
|
|
48
|
+
placeholder="New issue title"
|
|
49
|
+
autoComplete="off"
|
|
50
|
+
className="px-3 py-2 rounded bg-[#222] border border-[#333] outline-none focus:border-indigo-500"
|
|
51
|
+
/>
|
|
52
|
+
<button
|
|
53
|
+
type="submit"
|
|
54
|
+
className="bg-indigo-600 hover:bg-indigo-700 transition text-white font-semibold px-4 py-2 rounded"
|
|
55
|
+
>
|
|
56
|
+
+ add
|
|
57
|
+
</button>
|
|
58
|
+
</form>
|
|
59
|
+
|
|
60
|
+
<div className="max-w-md mb-6">
|
|
61
|
+
{issues.length === 0 ? (
|
|
62
|
+
<div className="text-[#888] italic">No issues yet — try adding one.</div>
|
|
63
|
+
) : (
|
|
64
|
+
issues.map((issue) => (
|
|
65
|
+
<div
|
|
66
|
+
key={issue.id}
|
|
67
|
+
className="mb-2 p-3 rounded-lg bg-[#222] border border-[#2a2a2a] flex items-center justify-between"
|
|
68
|
+
>
|
|
69
|
+
<span>{issue.title}</span>
|
|
70
|
+
<span className="text-xs text-[#666]">
|
|
71
|
+
{new Date(issue.createdAt).toLocaleTimeString()}
|
|
72
|
+
</span>
|
|
73
|
+
</div>
|
|
74
|
+
))
|
|
75
|
+
)}
|
|
76
|
+
</div>
|
|
77
|
+
|
|
78
|
+
<button
|
|
79
|
+
className="bg-zinc-800 hover:bg-zinc-700 px-4 py-2 rounded text-sm"
|
|
80
|
+
onClick={async () => setCwd(await rpc.repo.getCwd())}
|
|
81
|
+
>
|
|
82
|
+
rpc → main process cwd
|
|
83
|
+
</button>
|
|
84
|
+
{cwd && (
|
|
85
|
+
<div className="mt-2 p-2 rounded bg-[#232328] text-[#b0b0b0] w-fit text-xs">
|
|
86
|
+
{cwd}
|
|
87
|
+
</div>
|
|
88
|
+
)}
|
|
89
|
+
</main>
|
|
90
|
+
)
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
export function App() {
|
|
94
|
+
return (
|
|
95
|
+
<div className="flex flex-col min-h-screen">
|
|
96
|
+
<Titlebar />
|
|
97
|
+
<Home />
|
|
98
|
+
</div>
|
|
99
|
+
)
|
|
100
|
+
}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html>
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8">
|
|
5
|
+
<meta name="zenbu-bg" content="#111">
|
|
6
|
+
<title>Installing</title>
|
|
7
|
+
<style>
|
|
8
|
+
html, body {
|
|
9
|
+
height: 100%;
|
|
10
|
+
margin: 0;
|
|
11
|
+
padding: 0;
|
|
12
|
+
background: #111;
|
|
13
|
+
color: #ddd;
|
|
14
|
+
font: 13px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
|
|
15
|
+
-webkit-app-region: drag;
|
|
16
|
+
user-select: none;
|
|
17
|
+
}
|
|
18
|
+
body {
|
|
19
|
+
display: flex;
|
|
20
|
+
flex-direction: column;
|
|
21
|
+
align-items: center;
|
|
22
|
+
justify-content: center;
|
|
23
|
+
gap: 18px;
|
|
24
|
+
padding: 32px;
|
|
25
|
+
box-sizing: border-box;
|
|
26
|
+
}
|
|
27
|
+
.label {
|
|
28
|
+
font-size: 14px;
|
|
29
|
+
color: #f0f0f0;
|
|
30
|
+
letter-spacing: 0.2px;
|
|
31
|
+
min-height: 1.4em;
|
|
32
|
+
text-align: center;
|
|
33
|
+
}
|
|
34
|
+
.bar {
|
|
35
|
+
width: min(360px, 70%);
|
|
36
|
+
height: 4px;
|
|
37
|
+
background: #2a2a2a;
|
|
38
|
+
border-radius: 2px;
|
|
39
|
+
overflow: hidden;
|
|
40
|
+
position: relative;
|
|
41
|
+
}
|
|
42
|
+
.bar-fill {
|
|
43
|
+
position: absolute;
|
|
44
|
+
inset: 0 auto 0 0;
|
|
45
|
+
width: 0%;
|
|
46
|
+
background: #f0f0f0;
|
|
47
|
+
transition: width 180ms ease-out;
|
|
48
|
+
}
|
|
49
|
+
.bar.indeterminate .bar-fill {
|
|
50
|
+
width: 30%;
|
|
51
|
+
animation: slide 1.2s ease-in-out infinite;
|
|
52
|
+
}
|
|
53
|
+
@keyframes slide {
|
|
54
|
+
0% { transform: translateX(-100%); }
|
|
55
|
+
100% { transform: translateX(366%); }
|
|
56
|
+
}
|
|
57
|
+
.message {
|
|
58
|
+
font-size: 11px;
|
|
59
|
+
color: #888;
|
|
60
|
+
font-family: "SF Mono", Menlo, Consolas, monospace;
|
|
61
|
+
max-width: min(420px, 90%);
|
|
62
|
+
text-align: center;
|
|
63
|
+
overflow: hidden;
|
|
64
|
+
text-overflow: ellipsis;
|
|
65
|
+
white-space: nowrap;
|
|
66
|
+
min-height: 1.4em;
|
|
67
|
+
}
|
|
68
|
+
</style>
|
|
69
|
+
</head>
|
|
70
|
+
<body>
|
|
71
|
+
<div class="label" id="label">Starting…</div>
|
|
72
|
+
<div class="bar indeterminate" id="bar"><div class="bar-fill" id="fill"></div></div>
|
|
73
|
+
<div class="message" id="message"></div>
|
|
74
|
+
<script>
|
|
75
|
+
// The framework's built-in preload exposes `window.zenbuInstall` with
|
|
76
|
+
// `.on(event, cb)` returning an unsubscribe function. Events:
|
|
77
|
+
// step: { id: "clone" | "fetch" | "install" | "handoff", label }
|
|
78
|
+
// message: { text }
|
|
79
|
+
// progress: { phase?, loaded?, total?, ratio? }
|
|
80
|
+
// done: { id }
|
|
81
|
+
// error: { id?, message }
|
|
82
|
+
const api = window.zenbuInstall;
|
|
83
|
+
const labelEl = document.getElementById("label");
|
|
84
|
+
const messageEl = document.getElementById("message");
|
|
85
|
+
const barEl = document.getElementById("bar");
|
|
86
|
+
const fillEl = document.getElementById("fill");
|
|
87
|
+
if (api) {
|
|
88
|
+
api.on("step", (p) => {
|
|
89
|
+
if (p && p.label) labelEl.textContent = p.label;
|
|
90
|
+
barEl.classList.add("indeterminate");
|
|
91
|
+
fillEl.style.width = "";
|
|
92
|
+
});
|
|
93
|
+
api.on("message", (p) => {
|
|
94
|
+
if (p && p.text) messageEl.textContent = p.text;
|
|
95
|
+
});
|
|
96
|
+
api.on("progress", (p) => {
|
|
97
|
+
const ratio = p && typeof p.ratio === "number" ? p.ratio : null;
|
|
98
|
+
if (ratio != null && ratio >= 0) {
|
|
99
|
+
barEl.classList.remove("indeterminate");
|
|
100
|
+
fillEl.style.width = Math.max(2, Math.min(100, ratio * 100)) + "%";
|
|
101
|
+
} else {
|
|
102
|
+
barEl.classList.add("indeterminate");
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
api.on("done", () => {
|
|
106
|
+
messageEl.textContent = "";
|
|
107
|
+
});
|
|
108
|
+
api.on("error", (p) => {
|
|
109
|
+
labelEl.textContent = "Failed";
|
|
110
|
+
if (p && p.message) messageEl.textContent = p.message;
|
|
111
|
+
barEl.classList.remove("indeterminate");
|
|
112
|
+
fillEl.style.width = "100%";
|
|
113
|
+
fillEl.style.background = "#d04444";
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
</script>
|
|
117
|
+
</body>
|
|
118
|
+
</html>
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { StrictMode } from "react"
|
|
2
1
|
import { createRoot } from "react-dom/client"
|
|
2
|
+
import { ZenbuProvider } from "@zenbujs/core/react"
|
|
3
3
|
import { App } from "./App"
|
|
4
4
|
import "./app.css"
|
|
5
5
|
|
|
6
6
|
createRoot(document.getElementById("root")!).render(
|
|
7
|
-
<
|
|
7
|
+
<ZenbuProvider>
|
|
8
8
|
<App />
|
|
9
|
-
</
|
|
9
|
+
</ZenbuProvider>,
|
|
10
10
|
)
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import path from "node:path"
|
|
2
|
+
import { fileURLToPath } from "node:url"
|
|
3
|
+
import { defineConfig } from "vite"
|
|
4
|
+
import react from "@vitejs/plugin-react"
|
|
5
|
+
import tailwindcss from "@tailwindcss/vite"
|
|
6
|
+
|
|
7
|
+
const __dirname = path.dirname(fileURLToPath(import.meta.url))
|
|
8
|
+
|
|
9
|
+
export default defineConfig({
|
|
10
|
+
root: path.resolve(__dirname, "src", "renderer"),
|
|
11
|
+
plugins: [react(), tailwindcss()],
|
|
12
|
+
resolve: {
|
|
13
|
+
alias: {
|
|
14
|
+
"@": path.resolve(__dirname, "src", "renderer"),
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
})
|
|
@@ -2,9 +2,7 @@ import {
|
|
|
2
2
|
defineConfig,
|
|
3
3
|
definePlugin,
|
|
4
4
|
defineBuildConfig,
|
|
5
|
-
|
|
6
|
-
dropFiles,
|
|
7
|
-
} from "@zenbujs/core/config";
|
|
5
|
+
} from "@zenbujs/core/config"
|
|
8
6
|
|
|
9
7
|
export default defineConfig({
|
|
10
8
|
// Where the kyju database lives (relative to this file).
|
|
@@ -19,6 +17,7 @@ export default defineConfig({
|
|
|
19
17
|
definePlugin({
|
|
20
18
|
name: "app",
|
|
21
19
|
services: ["./src/main/services/*.ts"],
|
|
20
|
+
schema: "./src/main/schema.ts",
|
|
22
21
|
}),
|
|
23
22
|
],
|
|
24
23
|
|
|
@@ -26,10 +25,19 @@ export default defineConfig({
|
|
|
26
25
|
// `zen build:electron` (signed .app via electron-builder). Set
|
|
27
26
|
// `mirror.target` to "<owner>/<repo>" before shipping.
|
|
28
27
|
build: defineBuildConfig({
|
|
28
|
+
// {{packageManager}}
|
|
29
|
+
// The .app's "host version" comes from `package.json#version` —
|
|
30
|
+
// read at build time and baked into <bundle>/host.json. Bump
|
|
31
|
+
// `package.json#version` every time you ship a new .app build.
|
|
32
|
+
// Each commit's `package.json#zenbu.host` semver range is checked
|
|
33
|
+
// against that value at launch (and from `UpdaterService.update()`);
|
|
34
|
+
// incompatible commits are skipped, so older .apps stay pinned to
|
|
35
|
+
// source they can actually run.
|
|
29
36
|
source: ".",
|
|
30
37
|
out: ".zenbu/build/source",
|
|
31
38
|
include: [
|
|
32
39
|
"src/**/*",
|
|
40
|
+
".gitignore",
|
|
33
41
|
"package.json",
|
|
34
42
|
"pnpm-lock.yaml",
|
|
35
43
|
"tsconfig.json",
|
|
@@ -43,10 +51,6 @@ export default defineConfig({
|
|
|
43
51
|
"src/**/*.spec.tsx",
|
|
44
52
|
"src/dev-only/**",
|
|
45
53
|
],
|
|
46
|
-
transforms: [
|
|
47
|
-
stripIfDisabled({ FLAG_BETA: false }),
|
|
48
|
-
dropFiles(/\.stories\.tsx?$/),
|
|
49
|
-
],
|
|
50
54
|
// mirror: { target: "{{owner}}/{{repo}}", branch: "main" },
|
|
51
55
|
}),
|
|
52
|
-
})
|
|
56
|
+
})
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Service } from "@zenbujs/core/runtime"
|
|
2
|
+
import { WindowService } from "@zenbujs/core/services"
|
|
3
|
+
|
|
4
|
+
export class InitService extends Service.create({
|
|
5
|
+
key: "init",
|
|
6
|
+
deps: { window: WindowService },
|
|
7
|
+
}) {
|
|
8
|
+
async evaluate() {
|
|
9
|
+
await this.ctx.window.openView({ type: "entrypoint" })
|
|
10
|
+
}
|
|
11
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Service } from "@zenbujs/core/runtime"
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Sample RPC service. Methods on the class are callable from the renderer
|
|
5
|
+
* via `useRpc()` — see `src/renderer/App.tsx`.
|
|
6
|
+
*/
|
|
7
|
+
export class Repo extends Service.create({ key: "repo" }) {
|
|
8
|
+
async getCwd() {
|
|
9
|
+
return process.cwd()
|
|
10
|
+
}
|
|
11
|
+
}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { useDb, useDbClient, useRpc } from "@zenbujs/core/react"
|
|
2
|
+
import { useState } from "react"
|
|
3
|
+
|
|
4
|
+
function Titlebar() {
|
|
5
|
+
return (
|
|
6
|
+
<div
|
|
7
|
+
className="titlebar"
|
|
8
|
+
// @ts-expect-error webkit property
|
|
9
|
+
style={{ WebkitAppRegion: "drag" }}
|
|
10
|
+
/>
|
|
11
|
+
)
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
function Home() {
|
|
15
|
+
const db = useDb()
|
|
16
|
+
const client = useDbClient()
|
|
17
|
+
const rpc = useRpc()
|
|
18
|
+
const [cwd, setCwd] = useState<string | null>(null)
|
|
19
|
+
|
|
20
|
+
const issues = db.app.issues
|
|
21
|
+
|
|
22
|
+
return (
|
|
23
|
+
<main className="home">
|
|
24
|
+
<h1>Welcome to Zenbu</h1>
|
|
25
|
+
<p className="lede">
|
|
26
|
+
Edit <code>src/renderer/App.tsx</code> to get started.
|
|
27
|
+
</p>
|
|
28
|
+
|
|
29
|
+
<form
|
|
30
|
+
className="add-form"
|
|
31
|
+
onSubmit={(e) => {
|
|
32
|
+
e.preventDefault()
|
|
33
|
+
const form = e.currentTarget
|
|
34
|
+
const title = (form.elements.namedItem("title") as HTMLInputElement).value
|
|
35
|
+
if (!title.trim()) return
|
|
36
|
+
client.update((db) => {
|
|
37
|
+
db.app.issues.push({
|
|
38
|
+
id: crypto.randomUUID(),
|
|
39
|
+
title,
|
|
40
|
+
createdAt: Date.now(),
|
|
41
|
+
})
|
|
42
|
+
})
|
|
43
|
+
form.reset()
|
|
44
|
+
}}
|
|
45
|
+
>
|
|
46
|
+
<input name="title" placeholder="New issue title" autoComplete="off" />
|
|
47
|
+
<button type="submit">+ add</button>
|
|
48
|
+
</form>
|
|
49
|
+
|
|
50
|
+
<div className="issues">
|
|
51
|
+
{issues.length === 0 ? (
|
|
52
|
+
<div className="issues-empty">No issues yet — try adding one.</div>
|
|
53
|
+
) : (
|
|
54
|
+
issues.map((issue) => (
|
|
55
|
+
<div key={issue.id} className="issue">
|
|
56
|
+
<span>{issue.title}</span>
|
|
57
|
+
<span className="issue-time">
|
|
58
|
+
{new Date(issue.createdAt).toLocaleTimeString()}
|
|
59
|
+
</span>
|
|
60
|
+
</div>
|
|
61
|
+
))
|
|
62
|
+
)}
|
|
63
|
+
</div>
|
|
64
|
+
|
|
65
|
+
<button
|
|
66
|
+
className="rpc-button"
|
|
67
|
+
onClick={async () => setCwd(await rpc.repo.getCwd())}
|
|
68
|
+
>
|
|
69
|
+
rpc → main process cwd
|
|
70
|
+
</button>
|
|
71
|
+
{cwd && <div className="rpc-result">{cwd}</div>}
|
|
72
|
+
</main>
|
|
73
|
+
)
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export function App() {
|
|
77
|
+
return (
|
|
78
|
+
<div className="app">
|
|
79
|
+
<Titlebar />
|
|
80
|
+
<Home />
|
|
81
|
+
</div>
|
|
82
|
+
)
|
|
83
|
+
}
|