@bitcobblers/wod-wiki-tools 0.36.2133 → 0.36.2134
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/dist/bin/wod.cjs +14 -3
- package/dist/bin/wod.cjs.map +1 -1
- package/dist/bin/wod.mjs +13 -3
- package/dist/bin/wod.mjs.map +1 -1
- package/dist/{chunk-DZESCGCM.mjs → chunk-32FASQP5.mjs} +3 -3
- package/dist/{chunk-DZESCGCM.mjs.map → chunk-32FASQP5.mjs.map} +1 -1
- package/dist/{chunk-OZI2FYPF.mjs → chunk-B3QJYJVI.mjs} +5 -5
- package/dist/{chunk-OZI2FYPF.mjs.map → chunk-B3QJYJVI.mjs.map} +1 -1
- package/dist/index.cjs +3 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +2 -2
- package/dist/{server-Z2T7IGZX.mjs → server-3TJZDKQC.mjs} +3 -3
- package/dist/{server-Z2T7IGZX.mjs.map → server-3TJZDKQC.mjs.map} +1 -1
- package/dist/web/playground/assets/{main-Bh_mthqc.js → main-Bj_mxNMk.js} +4 -4
- package/dist/web/playground/assets/{statementBuilderFlow-gvzmxfiE.js → statementBuilderFlow-DXlHS86r.js} +2 -2
- package/dist/web/playground/index.html +1 -1
- package/dist/web/playground/seed/core/chunks/{canvas.d2a5e6e7.json → canvas.054cd7db.json} +1 -1
- package/dist/web/playground/seed/core/manifest.json +5 -5
- package/dist/web/playground/seed/core/report.html +9 -9
- package/dist/web/server/assets/{main-CPRFCrjV.js → main-CfAVkURA.js} +4 -4
- package/dist/web/server/assets/{statementBuilderFlow-DT1tyXgc.js → statementBuilderFlow-CXugzTXB.js} +2 -2
- package/dist/web/server/index.html +1 -1
- package/dist/web/server/seed/core/chunks/{canvas.d2a5e6e7.json → canvas.054cd7db.json} +1 -1
- package/dist/web/server/seed/core/manifest.json +5 -5
- package/dist/web/server/seed/core/report.html +10 -10
- package/package.json +6 -6
package/dist/bin/wod.mjs
CHANGED
|
@@ -1,14 +1,24 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { createRequire } from 'module';
|
|
3
|
-
import { cliMain } from '../chunk-
|
|
3
|
+
import { cliMain } from '../chunk-B3QJYJVI.mjs';
|
|
4
4
|
import '../chunk-EUQWEX6Z.mjs';
|
|
5
5
|
import '../chunk-6L5ZDZJ7.mjs';
|
|
6
|
+
import { spawnSync } from 'child_process';
|
|
7
|
+
import { fileURLToPath } from 'url';
|
|
6
8
|
|
|
7
9
|
if (typeof globalThis.require === 'undefined') {
|
|
8
10
|
try { globalThis.require = createRequire(import.meta.url); } catch {}
|
|
9
11
|
}
|
|
10
|
-
|
|
11
|
-
|
|
12
|
+
var isBun = typeof globalThis.Bun !== "undefined";
|
|
13
|
+
if (!isBun) {
|
|
14
|
+
const check = spawnSync("bun", ["--version"], { stdio: "ignore" });
|
|
15
|
+
if (check.status === 0) {
|
|
16
|
+
const res = spawnSync("bun", ["--no-env-file", fileURLToPath(import.meta.url), ...process.argv.slice(2)], {
|
|
17
|
+
stdio: "inherit"
|
|
18
|
+
});
|
|
19
|
+
process.exit(res.status ?? 0);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
12
22
|
void (async () => {
|
|
13
23
|
const exitCode = await cliMain(process.argv.slice(2));
|
|
14
24
|
process.exitCode = exitCode;
|
package/dist/bin/wod.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/bin/wod.ts"],"names":[],"mappings":";;;;;;;;;;;AAYA,KAAA,CAAM,YAAY;AAChB,EAAA,MAAM,WAAW,MAAM,OAAA,CAAQ,QAAQ,IAAA,CAAK,KAAA,CAAM,CAAC,CAAC,CAAA;AACpD,EAAA,OAAA,CAAQ,QAAA,GAAW,QAAA;AACrB,CAAA,GAAG","file":"wod.mjs","sourcesContent":["#!/usr/bin/env node\n/**\n * wod CLI Entry Point\n *\n * Dispatches to cliMain(process.argv.slice(2)).\n * Runs under Node or Bun: SQLite/Postgres/Turso commands (init, parse, run,\n * query, import, export, build, seed) run on both runtimes; server/playground\n * hosting commands require Bun.\n */\n\nimport { cliMain } from '../cli/runner';\n\nvoid (async () => {\n const exitCode = await cliMain(process.argv.slice(2));\n process.exitCode = exitCode;\n})();\n"]}
|
|
1
|
+
{"version":3,"sources":["../../src/bin/wod.ts"],"names":[],"mappings":";;;;;;;;;;;AAYA,IAAM,KAAA,GAAQ,OAAQ,UAAA,CAAiC,GAAA,KAAQ,WAAA;AAC/D,IAAI,CAAC,KAAA,EAAO;AAEV,EAAA,MAAM,KAAA,GAAQ,UAAU,KAAA,EAAO,CAAC,WAAW,CAAA,EAAG,EAAE,KAAA,EAAO,QAAA,EAAU,CAAA;AACjE,EAAA,IAAI,KAAA,CAAM,WAAW,CAAA,EAAG;AACtB,IAAA,MAAM,GAAA,GAAM,SAAA,CAAU,KAAA,EAAO,CAAC,iBAAiB,aAAA,CAAc,MAAA,CAAA,IAAA,CAAY,GAAG,CAAA,EAAG,GAAG,OAAA,CAAQ,IAAA,CAAK,KAAA,CAAM,CAAC,CAAC,CAAA,EAAG;AAAA,MACxG,KAAA,EAAO;AAAA,KACR,CAAA;AACD,IAAA,OAAA,CAAQ,IAAA,CAAK,GAAA,CAAI,MAAA,IAAU,CAAC,CAAA;AAAA,EAC9B;AACF;AAIA,KAAA,CAAM,YAAY;AAChB,EAAA,MAAM,WAAW,MAAM,OAAA,CAAQ,QAAQ,IAAA,CAAK,KAAA,CAAM,CAAC,CAAC,CAAA;AACpD,EAAA,OAAA,CAAQ,QAAA,GAAW,QAAA;AACrB,CAAA,GAAG","file":"wod.mjs","sourcesContent":["#!/usr/bin/env node\n/**\n * wod CLI Entry Point\n *\n * Dispatches to cliMain(process.argv.slice(2)).\n * Runs under Node or Bun: SQLite/Postgres/Turso commands (init, parse, run,\n * query, import, export, build, seed) run on both runtimes; server/playground\n * hosting commands require Bun.\n */\nimport { spawnSync } from 'node:child_process';\nimport { fileURLToPath } from 'node:url';\n\nconst isBun = typeof (globalThis as { Bun?: unknown }).Bun !== 'undefined';\nif (!isBun) {\n // If invoked via Node but Bun is installed, re-exec with Bun so server/playground work out of the box.\n const check = spawnSync('bun', ['--version'], { stdio: 'ignore' });\n if (check.status === 0) {\n const res = spawnSync('bun', ['--no-env-file', fileURLToPath(import.meta.url), ...process.argv.slice(2)], {\n stdio: 'inherit',\n });\n process.exit(res.status ?? 0);\n }\n}\n\nimport { cliMain } from '../cli/runner';\n\nvoid (async () => {\n const exitCode = await cliMain(process.argv.slice(2));\n process.exitCode = exitCode;\n})();\n"]}
|
|
@@ -10,7 +10,7 @@ if (typeof globalThis.require === 'undefined') {
|
|
|
10
10
|
function bun() {
|
|
11
11
|
const b = globalThis.Bun;
|
|
12
12
|
if (!b) {
|
|
13
|
-
throw new Error("wod server/playground requires the Bun runtime
|
|
13
|
+
throw new Error("wod server/playground requires the Bun runtime (https://bun.sh)");
|
|
14
14
|
}
|
|
15
15
|
return b;
|
|
16
16
|
}
|
|
@@ -119,5 +119,5 @@ async function runCliServer(mode, options, writeOut) {
|
|
|
119
119
|
}
|
|
120
120
|
|
|
121
121
|
export { runCliServer };
|
|
122
|
-
//# sourceMappingURL=chunk-
|
|
123
|
-
//# sourceMappingURL=chunk-
|
|
122
|
+
//# sourceMappingURL=chunk-32FASQP5.mjs.map
|
|
123
|
+
//# sourceMappingURL=chunk-32FASQP5.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/cli/server.ts"],"names":["dist"],"mappings":";;;;;;;;;AAyCA,SAAS,GAAA,GAAqB;AAG5B,EAAA,MAAM,IAAK,UAAA,CAAuC,GAAA;AAClD,EAAA,IAAI,CAAC,CAAA,EAAG;AACN,IAAA,MAAM,IAAI,MAAM,kFAA6E,CAAA;AAAA,EAC/F;AACA,EAAA,OAAO,CAAA;AACT;AAQA,SAAS,SAAA,GAAoB;AAC3B,EAAA,MAAM,IAAI,QAAA,EAAS;AACnB,EAAA,MAAM,IAAA,GAAyC,MAA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,UAAU,IAAA,EAAM,KAAA,EAAO,SAAS,CAAA;AAC/D,IAAA,IAAI,SAAS,QAAA,EAAU;AACrB,MAAA,QAAA,CAAS,CAAA,mBAAA,EAAsB,IAAI,CAAA,CAAA,EAAI,IAAI,WAAM,OAAO,CAAA,WAAA,EAAW,IAAI,CAAA,CAAE,CAAA;AAAA,IAC3E,CAAA,MAAO;AACL,MAAA,QAAA,CAAS,0BAA0B,IAAI,CAAA,CAAA,EAAI,IAAI,CAAA,mDAAA,EAA8C,IAAI,CAAA,CAAE,CAAA;AAAA,IACrG;AAAA,EACF,SAAS,CAAA,EAAG;AACV,IAAA,IAAI,EAAA,EAAI,MAAM,EAAA,CAAG,KAAA,EAAM;AACvB,IAAA,MAAM,CAAA;AAAA,EACR;AAEA,EAAA,IAAI,OAAA,GAAU,KAAA;AACd,EAAA,MAAM,WAAW,YAA2B;AAC1C,IAAA,IAAI,OAAA,EAAS,OAAA,CAAQ,IAAA,CAAK,CAAC,CAAA;AAC3B,IAAA,OAAA,GAAU,IAAA;AACV,IAAA,IAAI;AACF,MAAA,MAAM,OAAO,IAAA,EAAK;AAAA,IACpB,CAAA,SAAE;AACA,MAAA,IAAI,EAAA,EAAI,MAAM,EAAA,CAAG,KAAA,EAAM;AACvB,MAAA,OAAA,CAAQ,KAAK,CAAC,CAAA;AAAA,IAChB;AAAA,EACF,CAAA;AACA,EAAA,OAAA,CAAQ,EAAA,CAAG,UAAU,MAAM;AAAE,IAAA,KAAK,QAAA,EAAS;AAAA,EAAG,CAAC,CAAA;AAC/C,EAAA,OAAA,CAAQ,EAAA,CAAG,WAAW,MAAM;AAAE,IAAA,KAAK,QAAA,EAAS;AAAA,EAAG,CAAC,CAAA;AAGhD,EAAA,MAAM,IAAI,QAAe,MAAM;AAAA,EAAC,CAAC,CAAA;AACnC","file":"chunk-DZESCGCM.mjs","sourcesContent":["/**\n * server.ts — `wod server` (alias `serve`) / `wod playground` (Bun-only front\n * door).\n *\n * Serves the packaged engine stack: the shared fetch handler shipped in this\n * package (the same code the Docker image serves) plus the frontend build\n * packaged under the engine's dist/web/ — no repository checkout, no runtime\n * build.\n *\n * server probes the configured database first (never creates schema —\n * that's `wod init`), then serves API + SPA.\n * playground serves the browser-storage SPA build and never opens a database\n * (every /api request answers 404).\n *\n * Retains the event loop until SIGINT/SIGTERM; shutdown drains in-flight\n * requests before closing the database.\n */\n\nimport { openCliDb, nodeFs, nodePath } from './db';\nimport type { CliDatabaseConfig } from './config';\nimport type { CliDb } from './db';\nimport { createHandler } from '../server/app';\ntype WriteOut = (text: string) => void;\n\nexport type CliServerMode = 'server' | 'playground';\n\nexport interface CliServerOptions {\n /** Resolved database configuration. REQUIRED for 'server'; ignored — never\n * opened or validated — for 'playground'. */\n database?: CliDatabaseConfig;\n host?: string;\n port?: string;\n /** Explicit dist directory (flag or PLAYGROUND_DIST); must already exist. */\n dist?: string;\n /** Merged CLI environment (process env + .env). */\n env: Record<string, string | undefined>;\n}\n\ninterface BunServerLike { stop(): Promise<void> }\ninterface BunGlobalLike { serve(options: { port: number; hostname: string; fetch: (request: Request) => Promise<Response> }): BunServerLike }\n\nfunction bun(): BunGlobalLike {\n // Bun-specific global, absent from the ambient TS lib shapes on purpose\n // (engine stays Node-compilable); the access chain is proven at runtime.\n const b = (globalThis as { Bun?: BunGlobalLike }).Bun;\n if (!b) {\n throw new Error('wod server/playground requires the Bun runtime — start with: bun wod server');\n }\n return b;\n}\n\n/**\n * This module's directory, robust across shipped layouts: ESM via\n * import.meta.url (works under node and Bun; esbuild shims it in CJS too) and\n * Bun's import.meta.dir. ESM code splitting may relocate this module to a\n * chunk at dist/ root, so never assume dist/cli.\n */\nfunction moduleDir(): string {\n const p = nodePath();\n const meta: { dir?: unknown; url?: unknown } = import.meta; // Bun adds `dir`; the TS lib knows neither.\n if (typeof meta.dir === 'string') return p.resolve(meta.dir);\n if (typeof meta.url === 'string' && meta.url.startsWith('file:')) {\n return p.resolve(p.dirname(decodeURIComponent(new URL('.', meta.url).pathname)));\n }\n throw new Error('wod server/playground: cannot determine the installed engine module directory');\n}\n\n/**\n * The installed engine package root: nearest enclosing package.json belonging\n * to this package, walking up from the executing module (dist/cli, a split\n * chunk at dist/ root, dist/bin, or src/cli in a checkout).\n */\nfunction engineRoot(): string {\n const p = nodePath();\n const fs = nodeFs();\n for (let dir = moduleDir(); ; dir = p.dirname(dir)) {\n try {\n if (JSON.parse(fs.readFileSync(p.resolve(dir, 'package.json'), 'utf8')).name === '@bitcobblers/wod-wiki-tools') return dir;\n } catch { /* no manifest here — keep walking */ }\n const parent = p.dirname(dir);\n if (parent === dir) break;\n }\n throw new Error('wod server/playground: cannot locate the installed @bitcobblers/wod-wiki-tools package');\n}\n\n/**\n * Resolve the frontend dist directory. The packaged default lives inside the\n * installed engine module (dist/web/server or dist/web/playground); an\n * explicit --dist/PLAYGROUND_DIST is cwd-relative and must already contain a\n * built SPA (index.html). Nothing is built at runtime.\n */\nfunction resolveDist(mode: CliServerMode, options: CliServerOptions): string {\n const p = nodePath();\n const explicit = options.dist?.trim() || options.env.PLAYGROUND_DIST?.trim() || undefined;\n if (explicit) {\n const dist = p.resolve(explicit); // cwd-relative override\n if (!nodeFs().existsSync(p.resolve(dist, 'index.html'))) {\n throw new Error(\n `wod ${mode}: no built frontend (index.html) at ${dist} — --dist/PLAYGROUND_DIST must `\n + 'point at an already-built directory (the CLI never builds frontends at runtime)',\n );\n }\n return dist;\n }\n const dist = p.resolve(engineRoot(), 'dist', 'web', mode === 'playground' ? 'playground' : 'server');\n if (!nodeFs().existsSync(p.resolve(dist, 'index.html'))) {\n throw new Error(\n `wod ${mode}: packaged frontend missing — expected ${dist}/index.html. `\n + 'Reinstall @bitcobblers/wod-wiki-tools (bun add @bitcobblers/wod-wiki-tools), '\n + 'or rebuild the release assets from a checkout (bun run build:cli) and reinstall the package.',\n );\n }\n return dist;\n}\n\n/** Validate bind address first: flag > HOST/PORT env > loopback:3000. */\nfunction resolveBind(mode: CliServerMode, options: CliServerOptions): { host: string; port: number } {\n const host = options.host?.trim() || options.env.HOST?.trim() || '127.0.0.1';\n const rawPort = options.port?.trim() || options.env.PORT?.trim() || '3000';\n const port = Number(rawPort);\n if (!Number.isInteger(port) || port < 1 || port > 65535) {\n throw new Error(`wod ${mode}: invalid port ${JSON.stringify(rawPort)} (need integer 1..65535)`);\n }\n return { host, port };\n}\n\n/**\n * Start the shared server for `wod server` / `wod playground`. Throws on any\n * startup failure; on success it never returns until SIGINT/SIGTERM (drain,\n * close database, exit 0).\n */\nexport async function runCliServer(\n mode: CliServerMode,\n options: CliServerOptions,\n writeOut: WriteOut,\n): Promise<void> {\n const runtime = bun(); // Fail before any side effect when not under Bun.\n const { host, port } = resolveBind(mode, options); // Validate bind before opening anything.\n\n // Server probes the database BEFORE binding a socket: a missing/uninitialized\n // database refuses with `wod init` guidance.\n let db: CliDb | undefined;\n let dbLabel = 'no database';\n if (mode === 'server') {\n const database = options.database; // hoisted so the guard's narrowing sticks\n if (!database) {\n throw new Error('wod server: no database configuration resolved — this is a runner bug (expected resolveDatabaseConfig output)');\n }\n try {\n db = await openCliDb(database, { initialize: false });\n } catch (e) {\n const message = e instanceof Error ? e.message : String(e);\n throw new Error(`wod server: database not ready — run \\`wod init\\` first. ${message}`, { cause: e });\n }\n dbLabel = db.path;\n }\n\n let server: BunServerLike;\n try {\n const dist = resolveDist(mode, options);\n // Bundled server handler\n const handler = createHandler(db?.db ?? null, { playgroundDist: dist });\n // Playground: no database exists to close — createHandler(null) answers\n server = runtime.serve({ port, hostname: host, fetch: handler });\n if (mode === 'server') {\n writeOut(`wod server: http://${host}:${port} — ${dbLabel} · dist ${dist}`);\n } else {\n writeOut(`wod playground: http://${host}:${port} — in-browser storage (no database) · dist ${dist}`);\n }\n } catch (e) {\n if (db) await db.close(); // never leak the probe connection when startup fails\n throw e;\n }\n\n let closing = false;\n const shutdown = async (): Promise<void> => {\n if (closing) process.exit(0); // second signal forces the exit\n closing = true;\n try {\n await server.stop();\n } finally {\n if (db) await db.close();\n process.exit(0);\n }\n };\n process.on('SIGINT', () => { void shutdown(); });\n process.on('SIGTERM', () => { void shutdown(); });\n\n // Park until a signal handler exits the process.\n await new Promise<never>(() => {});\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/cli/server.ts"],"names":["dist"],"mappings":";;;;;;;;;AAyCA,SAAS,GAAA,GAAqB;AAG5B,EAAA,MAAM,IAAK,UAAA,CAAuC,GAAA;AAClD,EAAA,IAAI,CAAC,CAAA,EAAG;AACN,IAAA,MAAM,IAAI,MAAM,iEAAiE,CAAA;AAAA,EACnF;AACA,EAAA,OAAO,CAAA;AACT;AAQA,SAAS,SAAA,GAAoB;AAC3B,EAAA,MAAM,IAAI,QAAA,EAAS;AACnB,EAAA,MAAM,IAAA,GAAyC,MAAA,CAAA,IAAA;AAC/C,EAAA,IAAI,OAAO,KAAK,GAAA,KAAQ,QAAA,SAAiB,CAAA,CAAE,OAAA,CAAQ,KAAK,GAAG,CAAA;AAC3D,EAAA,IAAI,OAAO,KAAK,GAAA,KAAQ,QAAA,IAAY,KAAK,GAAA,CAAI,UAAA,CAAW,OAAO,CAAA,EAAG;AAChE,IAAA,OAAO,CAAA,CAAE,OAAA,CAAQ,CAAA,CAAE,OAAA,CAAQ,kBAAA,CAAmB,IAAI,GAAA,CAAI,GAAA,EAAK,IAAA,CAAK,GAAG,CAAA,CAAE,QAAQ,CAAC,CAAC,CAAA;AAAA,EACjF;AACA,EAAA,MAAM,IAAI,MAAM,+EAA+E,CAAA;AACjG;AAOA,SAAS,UAAA,GAAqB;AAC5B,EAAA,MAAM,IAAI,QAAA,EAAS;AACnB,EAAA,MAAM,KAAK,MAAA,EAAO;AAClB,EAAA,KAAA,IAAS,MAAM,SAAA,EAAU,IAAK,MAAM,CAAA,CAAE,OAAA,CAAQ,GAAG,CAAA,EAAG;AAClD,IAAA,IAAI;AACF,MAAA,IAAI,IAAA,CAAK,KAAA,CAAM,EAAA,CAAG,YAAA,CAAa,EAAE,OAAA,CAAQ,GAAA,E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A,CAAG,KAAA,EAAM;AACvB,MAAA,OAAA,CAAQ,KAAK,CAAC,CAAA;AAAA,IAChB;AAAA,EACF,CAAA;AACA,EAAA,OAAA,CAAQ,EAAA,CAAG,UAAU,MAAM;AAAE,IAAA,KAAK,QAAA,EAAS;AAAA,EAAG,CAAC,CAAA;AAC/C,EAAA,OAAA,CAAQ,EAAA,CAAG,WAAW,MAAM;AAAE,IAAA,KAAK,QAAA,EAAS;AAAA,EAAG,CAAC,CAAA;AAGhD,EAAA,MAAM,IAAI,QAAe,MAAM;AAAA,EAAC,CAAC,CAAA;AACnC","file":"chunk-32FASQP5.mjs","sourcesContent":["/**\n * server.ts — `wod server` (alias `serve`) / `wod playground` (Bun-only front\n * door).\n *\n * Serves the packaged engine stack: the shared fetch handler shipped in this\n * package (the same code the Docker image serves) plus the frontend build\n * packaged under the engine's dist/web/ — no repository checkout, no runtime\n * build.\n *\n * server probes the configured database first (never creates schema —\n * that's `wod init`), then serves API + SPA.\n * playground serves the browser-storage SPA build and never opens a database\n * (every /api request answers 404).\n *\n * Retains the event loop until SIGINT/SIGTERM; shutdown drains in-flight\n * requests before closing the database.\n */\n\nimport { openCliDb, nodeFs, nodePath } from './db';\nimport type { CliDatabaseConfig } from './config';\nimport type { CliDb } from './db';\nimport { createHandler } from '../server/app';\ntype WriteOut = (text: string) => void;\n\nexport type CliServerMode = 'server' | 'playground';\n\nexport interface CliServerOptions {\n /** Resolved database configuration. REQUIRED for 'server'; ignored — never\n * opened or validated — for 'playground'. */\n database?: CliDatabaseConfig;\n host?: string;\n port?: string;\n /** Explicit dist directory (flag or PLAYGROUND_DIST); must already exist. */\n dist?: string;\n /** Merged CLI environment (process env + .env). */\n env: Record<string, string | undefined>;\n}\n\ninterface BunServerLike { stop(): Promise<void> }\ninterface BunGlobalLike { serve(options: { port: number; hostname: string; fetch: (request: Request) => Promise<Response> }): BunServerLike }\n\nfunction bun(): BunGlobalLike {\n // Bun-specific global, absent from the ambient TS lib shapes on purpose\n // (engine stays Node-compilable); the access chain is proven at runtime.\n const b = (globalThis as { Bun?: BunGlobalLike }).Bun;\n if (!b) {\n throw new Error('wod server/playground requires the Bun runtime (https://bun.sh)');\n }\n return b;\n}\n\n/**\n * This module's directory, robust across shipped layouts: ESM via\n * import.meta.url (works under node and Bun; esbuild shims it in CJS too) and\n * Bun's import.meta.dir. ESM code splitting may relocate this module to a\n * chunk at dist/ root, so never assume dist/cli.\n */\nfunction moduleDir(): string {\n const p = nodePath();\n const meta: { dir?: unknown; url?: unknown } = import.meta; // Bun adds `dir`; the TS lib knows neither.\n if (typeof meta.dir === 'string') return p.resolve(meta.dir);\n if (typeof meta.url === 'string' && meta.url.startsWith('file:')) {\n return p.resolve(p.dirname(decodeURIComponent(new URL('.', meta.url).pathname)));\n }\n throw new Error('wod server/playground: cannot determine the installed engine module directory');\n}\n\n/**\n * The installed engine package root: nearest enclosing package.json belonging\n * to this package, walking up from the executing module (dist/cli, a split\n * chunk at dist/ root, dist/bin, or src/cli in a checkout).\n */\nfunction engineRoot(): string {\n const p = nodePath();\n const fs = nodeFs();\n for (let dir = moduleDir(); ; dir = p.dirname(dir)) {\n try {\n if (JSON.parse(fs.readFileSync(p.resolve(dir, 'package.json'), 'utf8')).name === '@bitcobblers/wod-wiki-tools') return dir;\n } catch { /* no manifest here — keep walking */ }\n const parent = p.dirname(dir);\n if (parent === dir) break;\n }\n throw new Error('wod server/playground: cannot locate the installed @bitcobblers/wod-wiki-tools package');\n}\n\n/**\n * Resolve the frontend dist directory. The packaged default lives inside the\n * installed engine module (dist/web/server or dist/web/playground); an\n * explicit --dist/PLAYGROUND_DIST is cwd-relative and must already contain a\n * built SPA (index.html). Nothing is built at runtime.\n */\nfunction resolveDist(mode: CliServerMode, options: CliServerOptions): string {\n const p = nodePath();\n const explicit = options.dist?.trim() || options.env.PLAYGROUND_DIST?.trim() || undefined;\n if (explicit) {\n const dist = p.resolve(explicit); // cwd-relative override\n if (!nodeFs().existsSync(p.resolve(dist, 'index.html'))) {\n throw new Error(\n `wod ${mode}: no built frontend (index.html) at ${dist} — --dist/PLAYGROUND_DIST must `\n + 'point at an already-built directory (the CLI never builds frontends at runtime)',\n );\n }\n return dist;\n }\n const dist = p.resolve(engineRoot(), 'dist', 'web', mode === 'playground' ? 'playground' : 'server');\n if (!nodeFs().existsSync(p.resolve(dist, 'index.html'))) {\n throw new Error(\n `wod ${mode}: packaged frontend missing — expected ${dist}/index.html. `\n + 'Reinstall @bitcobblers/wod-wiki-tools (bun add @bitcobblers/wod-wiki-tools), '\n + 'or rebuild the release assets from a checkout (bun run build:cli) and reinstall the package.',\n );\n }\n return dist;\n}\n\n/** Validate bind address first: flag > HOST/PORT env > loopback:3000. */\nfunction resolveBind(mode: CliServerMode, options: CliServerOptions): { host: string; port: number } {\n const host = options.host?.trim() || options.env.HOST?.trim() || '127.0.0.1';\n const rawPort = options.port?.trim() || options.env.PORT?.trim() || '3000';\n const port = Number(rawPort);\n if (!Number.isInteger(port) || port < 1 || port > 65535) {\n throw new Error(`wod ${mode}: invalid port ${JSON.stringify(rawPort)} (need integer 1..65535)`);\n }\n return { host, port };\n}\n\n/**\n * Start the shared server for `wod server` / `wod playground`. Throws on any\n * startup failure; on success it never returns until SIGINT/SIGTERM (drain,\n * close database, exit 0).\n */\nexport async function runCliServer(\n mode: CliServerMode,\n options: CliServerOptions,\n writeOut: WriteOut,\n): Promise<void> {\n const runtime = bun(); // Fail before any side effect when not under Bun.\n const { host, port } = resolveBind(mode, options); // Validate bind before opening anything.\n\n // Server probes the database BEFORE binding a socket: a missing/uninitialized\n // database refuses with `wod init` guidance.\n let db: CliDb | undefined;\n let dbLabel = 'no database';\n if (mode === 'server') {\n const database = options.database; // hoisted so the guard's narrowing sticks\n if (!database) {\n throw new Error('wod server: no database configuration resolved — this is a runner bug (expected resolveDatabaseConfig output)');\n }\n try {\n db = await openCliDb(database, { initialize: false });\n } catch (e) {\n const message = e instanceof Error ? e.message : String(e);\n throw new Error(`wod server: database not ready — run \\`wod init\\` first. ${message}`, { cause: e });\n }\n dbLabel = db.path;\n }\n\n let server: BunServerLike;\n try {\n const dist = resolveDist(mode, options);\n // Bundled server handler\n const handler = createHandler(db?.db ?? null, { playgroundDist: dist });\n // Playground: no database exists to close — createHandler(null) answers\n server = runtime.serve({ port, hostname: host, fetch: handler });\n if (mode === 'server') {\n writeOut(`wod server: http://${host}:${port} — ${dbLabel} · dist ${dist}`);\n } else {\n writeOut(`wod playground: http://${host}:${port} — in-browser storage (no database) · dist ${dist}`);\n }\n } catch (e) {\n if (db) await db.close(); // never leak the probe connection when startup fails\n throw e;\n }\n\n let closing = false;\n const shutdown = async (): Promise<void> => {\n if (closing) process.exit(0); // second signal forces the exit\n closing = true;\n try {\n await server.stop();\n } finally {\n if (db) await db.close();\n process.exit(0);\n }\n };\n process.on('SIGINT', () => { void shutdown(); });\n process.on('SIGTERM', () => { void shutdown(); });\n\n // Park until a signal handler exits the process.\n await new Promise<never>(() => {});\n}\n"]}
|
|
@@ -1240,7 +1240,7 @@ function defaultSeedDirs(cwd) {
|
|
|
1240
1240
|
}
|
|
1241
1241
|
|
|
1242
1242
|
// src/version.ts
|
|
1243
|
-
var VERSION = "0.36.
|
|
1243
|
+
var VERSION = "0.36.2134";
|
|
1244
1244
|
|
|
1245
1245
|
// src/cli/runner.ts
|
|
1246
1246
|
function getFs2() {
|
|
@@ -2026,12 +2026,12 @@ async function cliMain(argv = process.argv.slice(2), io = {}) {
|
|
|
2026
2026
|
if (parsed.subcommand === "server" || parsed.subcommand === "serve" || parsed.subcommand === "playground") {
|
|
2027
2027
|
if (!("Bun" in globalThis)) {
|
|
2028
2028
|
writeErr(
|
|
2029
|
-
`[wod ${parsed.subcommand}] Error: hosting requires the Bun runtime (https://bun.sh)
|
|
2029
|
+
`[wod ${parsed.subcommand}] Error: hosting requires the Bun runtime (https://bun.sh). Install Bun to host: https://bun.sh`
|
|
2030
2030
|
);
|
|
2031
2031
|
return 1;
|
|
2032
2032
|
}
|
|
2033
2033
|
const mode = parsed.subcommand === "playground" ? "playground" : "server";
|
|
2034
|
-
const { runCliServer } = await import('./server-
|
|
2034
|
+
const { runCliServer } = await import('./server-3TJZDKQC.mjs');
|
|
2035
2035
|
const options = { env: cliEnv() };
|
|
2036
2036
|
if (mode === "server") options.database = cliDb();
|
|
2037
2037
|
if (parsed.host !== void 0) options.host = parsed.host;
|
|
@@ -2057,5 +2057,5 @@ async function cliMain(argv = process.argv.slice(2), io = {}) {
|
|
|
2057
2057
|
}
|
|
2058
2058
|
|
|
2059
2059
|
export { PackLoadError, ParseSyntaxError, WqlSyntaxError, cliMain, formatExecutionOutput, formatParseOutput, formatQueryOutput, loadCliEnvironment, loadLanguagePack, loadQueryData, parseCliArgs, readStdin, resolveDatabaseConfig, runExecution, runParse, runQueryCli };
|
|
2060
|
-
//# sourceMappingURL=chunk-
|
|
2061
|
-
//# sourceMappingURL=chunk-
|
|
2060
|
+
//# sourceMappingURL=chunk-B3QJYJVI.mjs.map
|
|
2061
|
+
//# sourceMappingURL=chunk-B3QJYJVI.mjs.map
|