{"draft":null,"from":111,"to":318,"files":[{"path":"scripts/build-client.mjs","added":61,"removed":0,"diff":"--- /dev/null\n+++ b/scripts/build-client.mjs\n@@ -0,0 +1,61 @@\n+// Builds client/bin/abso.mjs: the whole client, client/abso.ts and everything it imports (yaml included),\n+// as one plain-JS file for Node 20 or later. Node 20 can't run the .ts files themselves (it has no type\n+// stripping), so this file is how a checkout runs on it:\n+//\n+//   npm ci && npm run build\n+//   node client/bin/abso.mjs help\n+//\n+// The file isn't committed (.gitignore leaves client/bin/ out); build it again after pulling. It sits one\n+// folder under client/, so the client's own folder (client-version.ts) is still client/. scripts/pack-npm.mjs\n+// puts the same build in the npm package.\n+//\n+// Plain JS on purpose: it runs before anything is built.\n+import { mkdirSync, writeFileSync } from \"node:fs\";\n+import { createRequire } from \"node:module\";\n+import { dirname, join, resolve } from \"node:path\";\n+import { fileURLToPath } from \"node:url\";\n+\n+const root = resolve(dirname(fileURLToPath(import.meta.url)), \"..\");\n+const OUT = \"client/bin/abso.mjs\";\n+\n+/** The bundle's text, built in memory. `banner` adds lines at its top (the npm package stamps its version). */\n+export function buildClient(banner = []) {\n+\tconst esbuild = createRequire(import.meta.url)(\"esbuild\");\n+\tconst result = esbuild.buildSync({\n+\t\tabsWorkingDir: root,\n+\t\tentryPoints: [\"client/abso.ts\"],\n+\t\tbundle: true,\n+\t\tplatform: \"node\",\n+\t\tformat: \"esm\",\n+\t\ttarget: \"node20\",\n+\t\twrite: false,\n+\t\toutfile: OUT,\n+\t\tlogLevel: \"warning\",\n+\t\t// Local projects run the open server's code in the client (client/src/local-store.ts); its Durable Object\n+\t\t// base class comes from the Workers runtime, so the bundle gets the client's stand-in.\n+\t\talias: { \"cloudflare:workers\": \"./client/src/durable-object-stand-in.ts\" },\n+\t\t// A bundled CommonJS package (yaml) calls require(\"process\") lazily, which an ES module bundle\n+\t\t// can't do without a real require.\n+\t\tbanner: {\n+\t\t\tjs: [\n+\t\t\t\t\"// Built from client/abso.ts by scripts/build-client.mjs (npm run build). Don't edit it by hand.\",\n+\t\t\t\t'import { createRequire as __absoCreateRequire } from \"node:module\";',\n+\t\t\t\t\"const require = __absoCreateRequire(import.meta.url);\",\n+\t\t\t\t...banner,\n+\t\t\t].join(\"\\n\"),\n+\t\t},\n+\t});\n+\t// esbuild leaves control characters in string literals as they are (yaml's lexer has \\x02, \\x18 and \\x1f).\n+\t// Escaped, the file is plain text that every tool shows and stores as it is.\n+\treturn result.outputFiles[0].text.replace(\n+\t\t/[\\x00-\\x08\\x0b\\x0c\\x0e-\\x1f\\x7f]/g,\n+\t\t(c) => `\\\\x${c.charCodeAt(0).toString(16).padStart(2, \"0\")}`,\n+\t);\n+}\n+\n+if (process.argv[1] && resolve(process.argv[1]) === fileURLToPath(import.meta.url)) {\n+\tconst path = join(root, OUT);\n+\tmkdirSync(dirname(path), { recursive: true });\n+\twriteFileSync(path, buildClient());\n+\tprocess.stdout.write(`Built ${OUT}: node ${OUT} help\\n`);\n+}"}],"unmatched":[]}