// The todo app's start: what the app decides itself, given to the kit's `startServer`: its name and data directory, // its API, its facet kinds, its principals, its one worker kind (a list), its page and its terminal client. The kit // does the rest. The examples call `startTodo` with a copy of `plugins/` they may edit; a real app's start script calls // it with the data directory from its command line and prints the owner link. import { cp, mkdtemp } from "node:fs/promises"; import { tmpdir } from "node:os"; import { join } from "node:path"; import { fileURLToPath } from "node:url"; import * as v1 from "@todo/app/v1"; import * as v1server from "@todo/app/v1/server"; import type { Context } from "../../../src/context/index.ts"; import { type App, startServer } from "../../../src/node/app/index.ts"; import { type PageAssets, pageScripts } from "../../../src/node/surfaces/index.ts"; import type { TodoPrincipal } from "./src/principals.ts"; /** The app's API: its name, its versions (newest first), and this process's instances of its modules. */ export const API = { name: "@todo/app", versions: ["v1"], modules: { "@todo/app/v1": v1, "@todo/app/v1/server": v1server }, }; /** The app's facet kinds: a plugin has one file per kind it runs on (`server.ts`, `worker.ts`, `web.ts`, `tui.ts`). */ export const KINDS = { server: { platform: "node" }, worker: { platform: "node" }, web: { platform: "browser", packages: { react: {}, "react/jsx-runtime": {} } }, tui: { platform: "node" }, } as const; /** The page: the app's own HTML around the assets the kit made (the base bundle, the plugins' scripts and styles). */ function page(request: { readonly nonce: string }, assets: PageAssets): string { return `