1/**2 * Every source-controlled file copied from the validated reference app into a3 * new project, by its path relative to both the reference app and the generated4 * project. The contents are read at runtime (see {@link readStarterFile}) rather5 * than imported with `type: "text"`, which JSR does not support when publishing.6 */7export const STARTER_FILES: readonly string[] = [8 "deno.json",9 "tsconfig.json",10 "public/favicon.svg",11 "public/apple-touch-icon.png",12 "public/icon-192.png",13 "public/icon-512.png",14 "public/icon-maskable-512.png",15 "public/icon-monochrome.svg",16 "public/screenshot-narrow.png",17 "public/screenshot-wide.png",18 "public/manifest.webmanifest",19 "src/app.ts",20 "src/env.d.ts",21 "src/permissions.ts",22 "src/schema.ts",23 "src/pages/index.astro",24 "src/styles/global.css",25 "src/islands/AccountGate.tsx",26 "src/islands/TaskList.tsx",27 "src/islands/use-tasks.ts",28 "src/layouts/Shell.astro",29 "tests/auth_e2e_test.ts",30 "tests/author-boundary_test.ts",31 "tests/backup_migration_e2e_test.ts",32 "tests/convergence_e2e_test.ts",33 "tests/testing-contract_test.ts",34];3536/**37 * TypeScript starter files are read from a verbatim `.txt` mirror under38 * `package/starter/` instead of the reference app itself. Publishing rewrites39 * the specifiers inside every module in the package — which would hand40 * generated projects direct `jsr:`/`npm:` imports that bypass their pinned41 * import map and break their formatting — but leaves non-module files alone.42 * The mirror is kept byte-identical to the reference app by43 * `create_core_test.ts`.44 */45function starterFileUrl(relativePath: string): URL {46 if (/\.tsx?$/.test(relativePath)) {47 return new URL(`./starter/${relativePath}.txt`, import.meta.url);48 }49 return new URL(`../apps/reference/${relativePath}`, import.meta.url);50}5152/**53 * Reads a starter file's contents, resolving it relative to the reference app.54 * Works both from a source checkout (a `file:` URL read from disk) and from the55 * published package (an `https:` JSR URL fetched over the network).56 */57export async function readStarterFile(relativePath: string): Promise<Uint8Array> {58 const url = starterFileUrl(relativePath);59 if (url.protocol === "file:") return await Deno.readFile(url);60 const response = await fetch(url);61 if (!response.ok) {62 throw new Error(`failed to read starter file ${relativePath}: HTTP ${response.status}`);63 }64 return new Uint8Array(await response.arrayBuffer());65}