@brickkit/cli 0.13.3 → 0.14.0
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/dashboard-dist/{api-reference-mT9VNcPb.js → api-reference-lLhahVJi.js} +4 -4
- package/dashboard-dist/app.js +10 -10
- package/dashboard-dist/{client-CwATkLJa.js → client-DRtkFydB.js} +1 -1
- package/dashboard-dist/{core-BEUWp6B5.js → core-BSTqZqMg.js} +1 -1
- package/dashboard-dist/{docs-BRrtyxDB.js → docs-Cye2p0fM.js} +2 -2
- package/dashboard-dist/kit.js +1 -1
- package/dashboard-dist/{popover-Bj9x-88h.js → popover-CKxhB1QI.js} +1 -1
- package/dist/bin.js +44 -1
- package/dist/bin.js.map +1 -1
- package/dist/build.js +8 -5
- package/dist/build.js.map +1 -1
- package/dist/dashboard-host.js +9 -7
- package/dist/dashboard-host.js.map +1 -1
- package/dist/dashboard-protocol.js +21 -1
- package/dist/dashboard-protocol.js.map +1 -1
- package/dist/dashboard.d.ts +1 -1
- package/dist/definitions.js +1 -0
- package/dist/definitions.js.map +1 -1
- package/dist/dev-protocol.js.map +1 -1
- package/dist/dev-worker.js +51 -12
- package/dist/dev-worker.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/project.js +4 -2
- package/dist/project.js.map +1 -1
- package/package.json +2 -2
package/dist/build.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build.js","names":[],"sources":["../src/manifest.ts","../src/runner.ts","../src/compiler/aot.ts","../src/build.ts"],"sourcesContent":["import { existsSync } from \"node:fs\";\nimport { join, relative, sep } from \"node:path\";\nimport { writeFileIfChanged } from \"./client-contract-file\";\n\nimport {\n DEFINITION_EXTENSIONS,\n DEFINITION_FILE,\n DEFINITION_KINDS,\n MANIFEST_FILE,\n type DefinitionKind,\n} from \"./definitions\";\n\n/** Services register before the resources that join them; every other kind after. */\nconst FIRST: readonly DefinitionKind[] = [\"service\", \"resource\"];\n\nfunction rank(file: string) {\n const index = FIRST.indexOf(\n DEFINITION_FILE.exec(file)?.[2] as DefinitionKind,\n );\n return index === -1 ? FIRST.length : index;\n}\n\n/** Definition files under `services`: service files first, then resources, then the rest, each by path. */\nexport function scanDefinitionFiles(services: string): string[] {\n if (!existsSync(services)) return [];\n // Built per call: index.ts imports this module (through runner) and still\n // exports defineConfig, so Node may load it (ESLint reading brick.config.ts).\n const glob = new Bun.Glob(\n `**/*.{${DEFINITION_KINDS.join(\",\")}}.{${DEFINITION_EXTENSIONS.join(\",\")}}`,\n );\n const files = [...glob.scanSync({ cwd: services, onlyFiles: true })]\n .map((file) => file.split(sep).join(\"/\"))\n .filter((file) => !file.split(\"/\").includes(\"node_modules\"));\n return files.sort(\n (a, b) => rank(a) - rank(b) || (a < b ? -1 : a > b ? 1 : 0),\n );\n}\n\n/** The source of `services.gen.ts`, which imports every definition file so each registers itself. */\nexport function renderManifest(services: string, generated: string): string {\n const imports = scanDefinitionFiles(services).map((file) => {\n let specifier = relative(generated, join(services, file))\n .split(sep)\n .join(\"/\")\n .replace(DEFINITION_FILE, \"$1.$2\");\n if (!specifier.startsWith(\".\")) specifier = `./${specifier}`;\n return `import ${JSON.stringify(specifier)};\\n`;\n });\n return `// Generated by Brick. Do not edit.\n// Imports every definition file under the services folder, so each one\n// registers itself on its service. The app entry imports this file.\n${imports.join(\"\")}\nexport {};\n`;\n}\n\n/** Write `<generated>/services.gen.ts`, leaving it untouched when nothing changed. */\nexport async function writeServiceManifest(options: {\n services: string;\n generated: string;\n}): Promise<string> {\n const output = join(options.generated, MANIFEST_FILE);\n await writeFileIfChanged(\n output,\n renderManifest(options.services, options.generated),\n );\n return output;\n}\n","import { existsSync, watch } from \"node:fs\";\nimport { basename, dirname, join, resolve, sep } from \"node:path\";\nimport { brick, isBrickApp } from \"@brickkit/core\";\nimport { importEntry } from \"./app-entry\";\nimport { TEMPORARY_FILE_PREFIX } from \"./client-contract-file\";\nimport {\n ConfigError,\n CONTRACT_FILE,\n DEFAULT_DASHBOARD_PORT,\n PROJECT_DEFAULTS,\n resolvePort,\n} from \"./config\";\nimport { openDashboard } from \"./dashboard-host\";\nimport { ownModule } from \"./own-module\";\nimport type { DashboardExtensionOptions } from \"./dashboard-extension\";\nimport { startDevApplication } from \"./dev-application\";\nimport type { WorkerMessage, WorkerOptions } from \"./dev-protocol\";\nimport { writeServiceManifest } from \"./manifest\";\nimport { printBanner, serveApp, shutdownOnSignal } from \"./serve\";\nimport { buildAppWorkflows } from \"./workflows\";\n\nexport interface DevServerOptions {\n port?: number;\n entry?: string;\n /**\n * @deprecated Only used without an `entry`; an exported app sets its own\n * prefix in `brick({ prefix })`.\n */\n prefix?: string;\n /** Generate a browser contract before starting the backend and frontend. */\n clientOutput?: string;\n /** Frontend command, launched once after the first successful generation. */\n frontend?: string;\n /**\n * Local dashboard with live requests, traces, errors, and reloads. Needs an\n * entry. `port` is where it listens and `historyDays` how long finished\n * requests are kept on disk; zero keeps live data only. `extension` and\n * `theme` customise it (see `DashboardExtensionOptions`).\n */\n dashboard?:\n | ({ port?: number; historyDays?: number } & DashboardExtensionOptions)\n | false;\n /**\n * Keep `<generated>/services.gen.ts` importing every definition file under\n * `services`: written before the app starts and again when files change.\n */\n manifest?: { services: string; generated: string };\n}\n\n/**\n * What `brick start` runs: serve the entry's default-exported app as it built\n * it (else one with the registered services), with the monitoring dashboard\n * it asks for, until SIGINT or SIGTERM.\n */\nexport async function startProdServer(options: {\n entry?: string;\n port?: number;\n /** The production dashboard's extension and theme. */\n dashboard?: DashboardExtensionOptions;\n}) {\n let exported: unknown;\n if (options.entry) {\n console.log(\n `[Brick-TS] Loading application entry: ${resolve(options.entry)}`,\n );\n exported = await importEntry(options.entry, { run: true });\n }\n const port = resolvePort(options.port);\n const app = isBrickApp(exported) ? exported : brick();\n await buildAppWorkflows(app);\n const dashboard = await serveApp(app, {\n port,\n dashboard: options.dashboard,\n });\n shutdownOnSignal(app);\n printBanner(app, { label: \"Production\", port, dashboard });\n return app;\n}\n\n/**\n * What `brick worker` runs: load the app and deliver its events from this\n * process, without serving HTTP. Run it beside API processes that only record\n * events (`events: { dispatch: false }`), or alone for an app with no routes.\n * Workflow listeners run here too: the world starts and the steps of every run\n * in it execute in this process.\n *\n * @param options - `entry`: the app file, which must default-export a `brick()` app.\n * @returns The app.\n * @throws When the entry is missing, has no `events`, or only records events.\n */\nexport async function startWorker(options: { entry: string }) {\n console.log(\n `[Brick-TS] Loading application entry: ${resolve(options.entry)}`,\n );\n const app = await importEntry(options.entry, { run: true });\n if (!isBrickApp(app))\n throw new ConfigError(\n \"Brick: a worker needs an entry that default-exports a BrickApp.\",\n );\n if (!app.events)\n throw new ConfigError(\n \"Brick: this app has no events, so a worker has nothing to deliver.\",\n );\n if (!app.events.describe().dispatch)\n throw new ConfigError(\n \"Brick: this app only records events (events.dispatch is false), so a worker would deliver nothing. Enable dispatch for the worker process.\",\n );\n await buildAppWorkflows(app);\n await app.start();\n app.events.start();\n shutdownOnSignal(app);\n const listeners = app.events.describe().listeners;\n console.log(`\\n🧱 Brick-TS Worker`);\n console.log(\n ` Delivering events to ${listeners.length} ${listeners.length === 1 ? \"listener\" : \"listeners\"}: ${listeners.map((l) => l.name).join(\", \") || \"none\"}\\n`,\n );\n return app;\n}\n\n/**\n * What `brick dev` runs: start the application, restart it when its files\n * change, and serve the dashboard beside it. With an `entry`, the app runs in\n * a worker process that restarts on every change to the entry or the files it\n * imports, and reports its requests to the dashboard; without one, a server\n * with the registered services starts in this process.\n *\n * @param options - `entry`, `port` (else `PORT`, else 4000), `prefix`,\n * `clientOutput` to regenerate the typed client's contract on each start,\n * `frontend` to launch a frontend command once, and `dashboard` (`port` and\n * `historyDays`, or `false`).\n * @returns The application, when started in this process.\n * @throws When `frontend` is given without `clientOutput`, or the dashboard\n * would use the app's port.\n */\nexport async function startDevServer(options: DevServerOptions = {}) {\n const entry = options.entry;\n if (!entry && (options.clientOutput || options.frontend))\n throw new ConfigError(\n \"Brick: --client and --frontend require an app entry.\",\n );\n if (options.frontend && !options.clientOutput)\n throw new ConfigError(\"Brick: --frontend requires --client <file>.\");\n const port = resolvePort(options.port);\n if (!entry) return startDevApplication({ port, prefix: options.prefix });\n const resolvedEntry = resolve(entry);\n if (!existsSync(resolvedEntry))\n throw new ConfigError(\n `[Brick-TS] Error: Entry file not found: ${resolvedEntry}`,\n );\n\n if (\n options.dashboard &&\n (options.dashboard.port ?? DEFAULT_DASHBOARD_PORT) === port\n )\n throw new ConfigError(\n \"Brick: dashboard port must differ from the API port. Use --dashboard-port <number>.\",\n );\n const manifest = options.manifest;\n if (manifest) await writeServiceManifest(manifest);\n const contract = resolve(\n options.clientOutput ??\n join(manifest?.generated ?? PROJECT_DEFAULTS.generated, CONTRACT_FILE),\n );\n const workerOptions: WorkerOptions = {\n entry: resolvedEntry,\n port,\n prefix: options.prefix,\n clientOutput: options.clientOutput && contract,\n telemetry: Boolean(options.dashboard),\n };\n // Bind the dashboard before the first worker starts, so the worker's spans\n // have somewhere to go.\n const dashboard = options.dashboard\n ? await openDashboard({\n port: options.dashboard.port,\n directory: process.cwd(),\n historyDays: options.dashboard.historyDays,\n warn: (message) => console.warn(message),\n docs: true,\n dashboard: {\n extension: options.dashboard.extension,\n theme: options.dashboard.theme,\n },\n restart: () => {\n void restart(\"dashboard\");\n },\n portHint: \"Use --dashboard-port <number> or --no-dashboard.\",\n })\n : undefined;\n const telemetry = dashboard?.store;\n let frontend: ReturnType<typeof Bun.spawn> | undefined;\n const dependencyFiles = new Set<string>();\n const dependencyWatchers = new Map<string, ReturnType<typeof watch>>();\n let stopped = false;\n const intentionalExits = new WeakSet<ReturnType<typeof Bun.spawn>>();\n const receive = (message: WorkerMessage, generation: number) => {\n switch (message.type) {\n case \"brick:telemetry\":\n telemetry?.ingest(message.records, generation);\n return;\n case \"brick:error\":\n telemetry?.recordWorkerError(message.phase, message.error, generation);\n return;\n case \"brick:contract-ready\":\n if (options.frontend && !frontend && !stopped)\n frontend = Bun.spawn(\n [process.env.SHELL ?? \"/bin/sh\", \"-c\", options.frontend],\n {\n detached: true,\n cwd: process.cwd(),\n stdout: \"inherit\",\n stderr: \"inherit\",\n },\n );\n telemetry?.recordReload({\n kind: \"contract-ready\",\n generation,\n detail: \"browser contract generated\",\n });\n return;\n case \"brick:architecture\":\n telemetry?.setArchitecture(message.architecture, generation);\n void dashboard?.setPluginExtensions(message.architecture.plugins ?? []);\n return;\n case \"brick:inspector\":\n if (generation === telemetry?.latestGeneration)\n telemetry.setInspector({ port: message.port, token: message.token });\n return;\n case \"brick:documentation\":\n void dashboard?.docs?.configure(\n dirname(resolvedEntry),\n message.documentation,\n );\n return;\n case \"brick:api-documents\":\n telemetry?.setApiDocuments(\n message.documents,\n `http://localhost:${port}`,\n );\n return;\n case \"brick:dependencies\":\n for (const file of message.files) {\n if (file === contract) continue;\n dependencyFiles.add(file);\n const directory = dirname(file);\n if (!dependencyWatchers.has(directory))\n dependencyWatchers.set(\n directory,\n watch(directory, (_event, filename) => {\n if (\n !filename ||\n !dependencyFiles.has(resolve(directory, filename))\n )\n return;\n scheduleRestart();\n }),\n );\n }\n return;\n }\n };\n const launch = () => {\n // The new process serves its own inspector once it is up.\n telemetry?.setInspector(undefined);\n const generation = telemetry?.startGeneration() ?? 0;\n const application = Bun.spawn(\n [\n process.execPath,\n ownModule(\"dev-worker\"),\n JSON.stringify(workerOptions),\n ],\n {\n cwd: process.cwd(),\n stdout: \"inherit\",\n stderr: \"inherit\",\n ipc: (message: WorkerMessage) => receive(message, generation),\n },\n );\n void application.exited.then((code) => {\n if (generation === telemetry?.latestGeneration)\n telemetry.setInspector(undefined);\n if (!stopped && !intentionalExits.has(application)) {\n console.error(\n `[Brick-TS] Application process exited with code ${code}. Waiting for changes to restart.`,\n );\n telemetry?.recordReload({\n kind: \"exited\",\n generation,\n detail: `exit code ${code}`,\n });\n }\n telemetry?.interruptGeneration(generation);\n });\n return application;\n };\n if (dashboard) {\n console.log(`📊 Dev dashboard: http://127.0.0.1:${dashboard.port}`);\n }\n let child = launch();\n // The worker reports the other files the entry imports (brick:dependencies).\n const watchDirs = [\n ...new Set([\n dirname(resolvedEntry),\n ...(manifest ? [manifest.services] : []),\n ]),\n ].filter(existsSync);\n let pending: ReturnType<typeof setTimeout> | undefined;\n let restarting = false;\n let dirty = false;\n\n async function restart(trigger: \"changes\" | \"dashboard\" = \"changes\") {\n dirty = true;\n if (restarting || stopped) return;\n restarting = true;\n try {\n while (dirty && !stopped) {\n dirty = false;\n console.log(\n trigger === \"changes\"\n ? \"\\n📝 Changes detected. Restarting server...\"\n : \"\\n🔄 Restart requested from the dashboard. Restarting server...\",\n );\n telemetry?.recordReload({\n kind: \"restarting\",\n generation: telemetry.latestGeneration,\n detail:\n trigger === \"changes\" ? \"source changed\" : \"restart from dashboard\",\n });\n intentionalExits.add(child);\n child.kill();\n await child.exited;\n if (!stopped) child = launch();\n }\n } finally {\n restarting = false;\n }\n }\n\n function scheduleRestart() {\n clearTimeout(pending);\n pending = setTimeout(() => {\n void restart();\n }, 100);\n }\n const extension = options.dashboard && options.dashboard.extension;\n const extensionDir =\n extension && !watchDirs.includes(dirname(resolve(extension)))\n ? `${dirname(resolve(extension))}${sep}`\n : undefined;\n const watchers = watchDirs.map((dir) =>\n watch(dir, { recursive: true }, (_event, filename) => {\n if (!filename || filename.split(/[\\\\/]/).includes(\"node_modules\")) return;\n const file = resolve(dir, filename);\n if (\n file === contract ||\n basename(file).startsWith(TEMPORARY_FILE_PREFIX) ||\n // The dashboard rebuilds its extension itself; the app restarts only\n // for the files it imports.\n (extensionDir !== undefined &&\n file.startsWith(extensionDir) &&\n !dependencyFiles.has(file))\n )\n return;\n // A definition file was added or removed: refresh the import list first.\n if (manifest && file.startsWith(manifest.services + sep)) {\n void writeServiceManifest(manifest)\n .catch((error: unknown) =>\n console.error(\"[Brick-TS] Could not write services.gen.ts:\", error),\n )\n .finally(scheduleRestart);\n return;\n }\n scheduleRestart();\n }),\n );\n const stop = () => {\n if (stopped) return;\n stopped = true;\n clearTimeout(pending);\n for (const watcher of watchers) watcher.close();\n for (const watcher of dependencyWatchers.values()) watcher.close();\n if (frontend) {\n if (process.platform === \"win32\") {\n Bun.spawnSync([\"taskkill\", \"/pid\", String(frontend.pid), \"/t\", \"/f\"]);\n } else {\n try {\n process.kill(-frontend.pid, \"SIGTERM\");\n } catch (error) {\n if (\n !(\n error instanceof Error &&\n \"code\" in error &&\n error.code === \"ESRCH\"\n )\n )\n throw error;\n }\n }\n }\n dashboard?.stop();\n child.kill();\n process.off(\"SIGINT\", onSignal);\n process.off(\"SIGTERM\", onSignal);\n process.off(\"exit\", stop);\n };\n const onSignal = (signal: NodeJS.Signals) => {\n if (stopped) {\n child.kill(\"SIGKILL\");\n process.exit(signal === \"SIGINT\" ? 130 : 143);\n }\n stop();\n process.on(\"SIGINT\", onSignal);\n process.on(\"SIGTERM\", onSignal);\n void child.exited.then(() => process.exit(0));\n };\n process.on(\"SIGINT\", onSignal);\n process.on(\"SIGTERM\", onSignal);\n process.on(\"exit\", stop);\n console.log(`\\n👀 Watching for changes in: ${watchDirs.join(\", \")}`);\n return { stop };\n}\n","import { aot } from \"elysia/plugin/aot/bun\";\nimport type { BunPlugin } from \"bun\";\n\n/** Keep the pinned Elysia beta's incomplete stripping from breaking builds. */\nexport function brickAot(entry: string, keep: boolean): BunPlugin {\n // `keep`: WS routes still need cookie setup during reconstruction in beta.29,\n // and shipped workflows mount their webhook route only when a world is set at\n // run time. Retain those modules while continuing to precompile HTTP handlers.\n if (keep) return aot(entry, { target: \"bun\", strip: false });\n return {\n name: \"brick-elysia-aot\",\n async setup(build) {\n await aot(entry, { target: \"bun\", strip: true }).setup({\n ...build,\n onLoad(options, callback) {\n return build.onLoad(options, async (args) => {\n const result = await callback(args);\n if (\n !result ||\n !(\"contents\" in result) ||\n typeof result.contents !== \"string\"\n )\n return result;\n let contents = result.contents;\n if (\n /[/\\\\]elysia[/\\\\]dist[/\\\\]ws[/\\\\]route\\.m?js$/.test(args.path) &&\n contents.includes(\n \"[elysia-aot] WebSocket route builder was stripped\",\n )\n ) {\n for (const name of [\"resolveWSOptions\", \"accumulateWSOptions\"]) {\n if (!contents.includes(`export function ${name}`))\n contents += `\\nexport function ${name}() { throw new Error(\"WebSocket support was stripped\"); }\\n`;\n }\n }\n return contents === result.contents\n ? result\n : { ...result, contents };\n });\n },\n });\n },\n };\n}\n","import { mkdtemp, mkdir, rename, rm } from \"node:fs/promises\";\nimport { dirname, join, resolve } from \"node:path\";\nimport { compileBrickApplication, WORKFLOW_BUNDLE } from \"@brickkit/core\";\nimport type { BunPlugin } from \"bun\";\nimport { emitCompiledApplication } from \"./compiler\";\nimport { brickAot } from \"./compiler/aot\";\nimport { loadBrickApp } from \"./app-entry\";\nimport { ownModule } from \"./own-module\";\nimport { DEFAULT_OUTDIR, resolvePort } from \"./config\";\nimport { shipWorkflows, workflowTransformPlugin } from \"./workflows\";\nimport {\n themeCss,\n writeDashboardExtension,\n type DashboardExtensionOptions,\n} from \"./dashboard-extension\";\n\nexport interface BuildApplicationOptions {\n /** A module whose default export is a BrickApp, without starting a server. */\n entry: string;\n outdir?: string;\n port?: number;\n /** Precompile Elysia's HTTP handlers at build time (default true). */\n aot?: boolean;\n /**\n * The dashboard's extension, built into `<outdir>/dashboard` with those of\n * the app's plugins for the production dashboard to serve; its theme is\n * checked here too.\n */\n dashboard?: DashboardExtensionOptions;\n}\n\n/**\n * The production dashboard stays out of the bundle: it serves files that ship\n * with @brickkit/cli, so a built server whose app asks for it imports it from\n * there at run time. Without a dashboard the bundle needs nothing installed.\n */\nconst productionDashboardAtRunTime: BunPlugin = {\n name: \"brick:production-dashboard\",\n setup(build) {\n build.onResolve({ filter: /^\\.\\/production-dashboard(\\.[jt]s)?$/ }, () => ({\n path: \"@brickkit/cli/production-dashboard\",\n external: true,\n }));\n },\n};\n\n/** The files `brick build` writes to the output folder, `server.js` last. */\nconst OUTPUTS = [\"routes.js\", \"brick-ir.json\", \"server.js.map\", \"server.js\"];\n\n/** Bundle an exported BrickApp with its compiled IR and its original configuration. */\nexport async function buildApplication(options: BuildApplicationOptions) {\n const entry = resolve(options.entry);\n if (!(await Bun.file(entry).exists()))\n throw new Error(`Brick compiler: entry not found: ${entry}`);\n const outdir = resolve(options.outdir ?? DEFAULT_OUTDIR);\n if (OUTPUTS.some((name) => entry === join(outdir, name)))\n throw new Error(\n \"Brick compiler: output would overwrite the application entry\",\n );\n const port = resolvePort(options.port, undefined, \"\");\n themeCss(options.dashboard?.theme);\n const extension = options.dashboard?.extension\n ? resolve(options.dashboard.extension)\n : undefined;\n if (extension && !(await Bun.file(extension).exists()))\n throw new Error(\n `Brick compiler: dashboard extension not found: ${extension}`,\n );\n const app = await loadBrickApp(entry);\n const root = app.events?.workflows?.root ?? process.cwd();\n const services = [...app.definition.services];\n const compilation = compileBrickApplication({\n services,\n prefix: app.definition.prefix,\n });\n await mkdir(dirname(outdir), { recursive: true });\n const staging = await mkdtemp(join(dirname(outdir), \".brick-build-\"));\n try {\n await Bun.write(\n join(staging, \"routes.js\"),\n emitCompiledApplication(compilation.ir),\n );\n const dashboard = (await writeDashboardExtension(\n extension,\n app.definition.plugins ?? [],\n join(staging, \"dashboard\"),\n ))\n ? join(outdir, \"dashboard\")\n : undefined;\n const theme = JSON.stringify(options.dashboard?.theme);\n const source = `import { existsSync } from \"node:fs\";\nimport { fileURLToPath } from \"node:url\";\nimport { loadCompiledBrickApp } from \"@brickkit/core\";\nimport { resolvePort } from ${JSON.stringify(ownModule(\"config\"))};\nimport { serveApp, shutdownOnSignal } from ${JSON.stringify(ownModule(\"serve\"))};\nconst workflows = fileURLToPath(new URL(${JSON.stringify(`./${WORKFLOW_BUNDLE.dir}`)}, import.meta.url));\nexport const app = await loadCompiledBrickApp(() => import(${JSON.stringify(entry)}), undefined, {\n workflows: existsSync(workflows) ? workflows : undefined,\n});\nexport default app;\nif (import.meta.main) {\n await serveApp(app, {\n port: resolvePort(undefined, ${port}),\n dashboard: { extension: ${dashboard ? 'fileURLToPath(new URL(\"./dashboard\", import.meta.url))' : \"undefined\"}, theme: ${theme} },\n });\n console.log(\"Brick compiled server listening on http://localhost:\" + app.server.port);\n shutdownOnSignal(app);\n}\n`;\n await Bun.write(join(staging, \"entry.ts\"), source);\n // Whether to ship workflows depends on the files the bundle holds, not on\n // the env: an app may declare its workflow listeners only at run time.\n let directives = false;\n const transform = await workflowTransformPlugin(root, () => {\n directives = true;\n });\n const result = await Bun.build({\n entrypoints: [join(staging, \"entry.ts\")],\n target: \"bun\",\n format: \"esm\",\n outdir: staging,\n naming: \"server.js\",\n sourcemap: \"external\",\n // AOT first: the workflow plugin loads every project file it sees, so after\n // it the AOT plugin would never get to transform the entry.\n plugins: [\n ...(options.aot === false\n ? []\n : [\n brickAot(\n join(staging, \"entry.ts\"),\n app.definition.sockets.length > 0 || transform !== undefined,\n ),\n ]),\n ...(transform ? [transform] : []),\n productionDashboardAtRunTime,\n ],\n });\n if (!result.success)\n throw new AggregateError(result.logs, \"Brick compiler: bundling failed\");\n const workflows =\n (directives || Boolean(app.events?.workflows)) &&\n (await shipWorkflows(root, staging, Boolean(app.events?.workflows)));\n await Bun.write(\n join(staging, \"brick-ir.json\"),\n JSON.stringify(compilation.ir, null, 2) + \"\\n\",\n );\n await mkdir(outdir, { recursive: true });\n for (const name of OUTPUTS)\n await rename(join(staging, name), join(outdir, name));\n // Only the bundle is ours: other files under .well-known stay.\n const bundle = join(outdir, WORKFLOW_BUNDLE.dir);\n await rm(bundle, { recursive: true, force: true });\n if (workflows) {\n await mkdir(dirname(bundle), { recursive: true });\n await rename(join(staging, WORKFLOW_BUNDLE.dir), bundle);\n }\n if (dashboard) {\n await rm(dashboard, { recursive: true, force: true });\n await rename(join(staging, \"dashboard\"), dashboard);\n }\n return {\n outdir,\n entry: join(outdir, \"server.js\"),\n ir: compilation.ir,\n dashboard,\n workflows: workflows ? join(outdir, WORKFLOW_BUNDLE.dir) : undefined,\n };\n } finally {\n await rm(staging, { recursive: true, force: true });\n }\n}\n"],"mappings":";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B,MAAM,OAAO,KAAK,SAAS,IAAI,GAAG,KAAK,QAAQ,IAAI,CAAC;EAEtD,MAAM,SAAS,KAAK,QAAQ,gBAAgB,GAAG;EAC/C,MAAM,GAAG,QAAQ;GAAE,WAAW;GAAM,OAAO;EAAK,CAAC;EACjD,IAAI,WAAW;GACb,MAAM,MAAM,QAAQ,MAAM,GAAG,EAAE,WAAW,KAAK,CAAC;GAChD,MAAM,OAAO,KAAK,SAAS,gBAAgB,GAAG,GAAG,MAAM;EACzD;EACA,IAAI,WAAW;GACb,MAAM,GAAG,WAAW;IAAE,WAAW;IAAM,OAAO;GAAK,CAAC;GACpD,MAAM,OAAO,KAAK,SAAS,WAAW,GAAG,SAAS;EACpD;EACA,OAAO;GACL;GACA,OAAO,KAAK,QAAQ,WAAW;GAC/B,IAAI,YAAY;GAChB;GACA,WAAW,YAAY,KAAK,QAAQ,gBAAgB,GAAG,IAAI,KAAA;EAC7D;CACF,UAAU;EACR,MAAM,GAAG,SAAS;GAAE,WAAW;GAAM,OAAO;EAAK,CAAC;CACpD;AACF"}
|
|
1
|
+
{"version":3,"file":"build.js","names":[],"sources":["../src/manifest.ts","../src/runner.ts","../src/compiler/aot.ts","../src/build.ts"],"sourcesContent":["import { existsSync } from \"node:fs\";\nimport { join, relative, sep } from \"node:path\";\nimport { writeFileIfChanged } from \"./client-contract-file\";\n\nimport {\n DEFINITION_EXTENSIONS,\n DEFINITION_FILE,\n DEFINITION_KINDS,\n MANIFEST_FILE,\n type DefinitionKind,\n} from \"./definitions\";\n\n/** Services register before the resources that join them; every other kind after. */\nconst FIRST: readonly DefinitionKind[] = [\"service\", \"resource\"];\n\nfunction rank(file: string) {\n const index = FIRST.indexOf(\n DEFINITION_FILE.exec(file)?.[2] as DefinitionKind,\n );\n return index === -1 ? FIRST.length : index;\n}\n\n/** Definition files under `services`: service files first, then resources, then the rest, each by path. */\nexport function scanDefinitionFiles(services: string): string[] {\n if (!existsSync(services)) return [];\n // Built per call: index.ts imports this module (through runner) and still\n // exports defineConfig, so Node may load it (ESLint reading brick.config.ts).\n const glob = new Bun.Glob(\n `**/*.{${DEFINITION_KINDS.join(\",\")}}.{${DEFINITION_EXTENSIONS.join(\",\")}}`,\n );\n const files = [...glob.scanSync({ cwd: services, onlyFiles: true })]\n .map((file) => file.split(sep).join(\"/\"))\n .filter((file) => !file.split(\"/\").includes(\"node_modules\"));\n return files.sort(\n (a, b) => rank(a) - rank(b) || (a < b ? -1 : a > b ? 1 : 0),\n );\n}\n\n/** The source of `services.gen.ts`, which imports every definition file so each registers itself. */\nexport function renderManifest(services: string, generated: string): string {\n const imports = scanDefinitionFiles(services).map((file) => {\n let specifier = relative(generated, join(services, file))\n .split(sep)\n .join(\"/\")\n .replace(DEFINITION_FILE, \"$1.$2\");\n if (!specifier.startsWith(\".\")) specifier = `./${specifier}`;\n return `import ${JSON.stringify(specifier)};\\n`;\n });\n return `// Generated by Brick. Do not edit.\n// Imports every definition file under the services folder, so each one\n// registers itself on its service. The app entry imports this file.\n${imports.join(\"\")}\nexport {};\n`;\n}\n\n/** Write `<generated>/services.gen.ts`, leaving it untouched when nothing changed. */\nexport async function writeServiceManifest(options: {\n services: string;\n generated: string;\n}): Promise<string> {\n const output = join(options.generated, MANIFEST_FILE);\n await writeFileIfChanged(\n output,\n renderManifest(options.services, options.generated),\n );\n return output;\n}\n","import { existsSync, watch } from \"node:fs\";\nimport { basename, dirname, join, resolve, sep } from \"node:path\";\nimport { brick, isBrickApp } from \"@brickkit/core\";\nimport { importEntry } from \"./app-entry\";\nimport { TEMPORARY_FILE_PREFIX } from \"./client-contract-file\";\nimport {\n ConfigError,\n CONTRACT_FILE,\n DEFAULT_DASHBOARD_PORT,\n PROJECT_DEFAULTS,\n resolvePort,\n} from \"./config\";\nimport { openDashboard } from \"./dashboard-host\";\nimport { ownModule } from \"./own-module\";\nimport type { DashboardExtensionOptions } from \"./dashboard-extension\";\nimport { startDevApplication } from \"./dev-application\";\nimport type { WorkerMessage, WorkerOptions } from \"./dev-protocol\";\nimport { writeServiceManifest } from \"./manifest\";\nimport { printBanner, serveApp, shutdownOnSignal } from \"./serve\";\nimport { buildAppWorkflows } from \"./workflows\";\n\nexport interface DevServerOptions {\n port?: number;\n entry?: string;\n /**\n * @deprecated Only used without an `entry`; an exported app sets its own\n * prefix in `brick({ prefix })`.\n */\n prefix?: string;\n /** Generate a browser contract before starting the backend and frontend. */\n clientOutput?: string;\n /** Frontend command, launched once after the first successful generation. */\n frontend?: string;\n /**\n * Local dashboard with live requests, traces, errors, and reloads. Needs an\n * entry. `port` is where it listens and `historyDays` how long finished\n * requests are kept on disk; zero keeps live data only. `extension` and\n * `theme` customise it (see `DashboardExtensionOptions`).\n */\n dashboard?:\n | ({ port?: number; historyDays?: number } & DashboardExtensionOptions)\n | false;\n /**\n * Keep `<generated>/services.gen.ts` importing every definition file under\n * `services`: written before the app starts and again when files change.\n */\n manifest?: { services: string; generated: string };\n}\n\n/**\n * What `brick start` runs: serve the entry's default-exported app as it built\n * it (else one with the registered services), with the monitoring dashboard\n * it asks for, until SIGINT or SIGTERM.\n */\nexport async function startProdServer(options: {\n entry?: string;\n port?: number;\n /** The production dashboard's extension and theme. */\n dashboard?: DashboardExtensionOptions;\n}) {\n let exported: unknown;\n if (options.entry) {\n console.log(\n `[Brick-TS] Loading application entry: ${resolve(options.entry)}`,\n );\n exported = await importEntry(options.entry, { run: true });\n }\n const port = resolvePort(options.port);\n const app = isBrickApp(exported) ? exported : brick();\n await buildAppWorkflows(app);\n const dashboard = await serveApp(app, {\n port,\n dashboard: options.dashboard,\n });\n shutdownOnSignal(app);\n printBanner(app, { label: \"Production\", port, dashboard });\n return app;\n}\n\n/**\n * What `brick worker` runs: load the app, deliver its events and run its\n * schedules from this process, without serving HTTP. Run it beside API processes that only record\n * events (`events: { dispatch: false }`), or alone for an app with no routes.\n * Workflow listeners run here too: the world starts and the steps of every run\n * in it execute in this process.\n *\n * @param options - `entry`: the app file, which must default-export a `brick()` app.\n * @returns The app.\n * @throws When the entry is missing, has no `events`, or only records events.\n */\nexport async function startWorker(options: { entry: string }) {\n console.log(\n `[Brick-TS] Loading application entry: ${resolve(options.entry)}`,\n );\n const app = await importEntry(options.entry, { run: true });\n if (!isBrickApp(app))\n throw new ConfigError(\n \"Brick: a worker needs an entry that default-exports a BrickApp.\",\n );\n if (!app.events)\n throw new ConfigError(\n \"Brick: this app has no events, so a worker has nothing to deliver.\",\n );\n if (!app.events.describe().dispatch)\n throw new ConfigError(\n \"Brick: this app only records events (events.dispatch is false), so a worker would deliver nothing. Enable dispatch for the worker process.\",\n );\n await buildAppWorkflows(app);\n await app.start();\n app.events.start();\n shutdownOnSignal(app);\n const { listeners, schedules = [] } = app.events.describe();\n console.log(`\\n🧱 Brick-TS Worker`);\n console.log(\n ` Delivering events to ${listeners.length} ${listeners.length === 1 ? \"listener\" : \"listeners\"}: ${listeners.map((l) => l.name).join(\", \") || \"none\"}`,\n );\n if (schedules.length)\n console.log(\n ` Running ${schedules.length} ${schedules.length === 1 ? \"schedule\" : \"schedules\"}: ${schedules.map((s) => s.name).join(\", \")}`,\n );\n console.log(\"\");\n return app;\n}\n\n/**\n * What `brick dev` runs: start the application, restart it when its files\n * change, and serve the dashboard beside it. With an `entry`, the app runs in\n * a worker process that restarts on every change to the entry or the files it\n * imports, and reports its requests to the dashboard; without one, a server\n * with the registered services starts in this process.\n *\n * @param options - `entry`, `port` (else `PORT`, else 4000), `prefix`,\n * `clientOutput` to regenerate the typed client's contract on each start,\n * `frontend` to launch a frontend command once, and `dashboard` (`port` and\n * `historyDays`, or `false`).\n * @returns The application, when started in this process.\n * @throws When `frontend` is given without `clientOutput`, or the dashboard\n * would use the app's port.\n */\nexport async function startDevServer(options: DevServerOptions = {}) {\n const entry = options.entry;\n if (!entry && (options.clientOutput || options.frontend))\n throw new ConfigError(\n \"Brick: --client and --frontend require an app entry.\",\n );\n if (options.frontend && !options.clientOutput)\n throw new ConfigError(\"Brick: --frontend requires --client <file>.\");\n const port = resolvePort(options.port);\n if (!entry) return startDevApplication({ port, prefix: options.prefix });\n const resolvedEntry = resolve(entry);\n if (!existsSync(resolvedEntry))\n throw new ConfigError(\n `[Brick-TS] Error: Entry file not found: ${resolvedEntry}`,\n );\n\n if (\n options.dashboard &&\n (options.dashboard.port ?? DEFAULT_DASHBOARD_PORT) === port\n )\n throw new ConfigError(\n \"Brick: dashboard port must differ from the API port. Use --dashboard-port <number>.\",\n );\n const manifest = options.manifest;\n if (manifest) await writeServiceManifest(manifest);\n const contract = resolve(\n options.clientOutput ??\n join(manifest?.generated ?? PROJECT_DEFAULTS.generated, CONTRACT_FILE),\n );\n const workerOptions: WorkerOptions = {\n entry: resolvedEntry,\n port,\n prefix: options.prefix,\n clientOutput: options.clientOutput && contract,\n telemetry: Boolean(options.dashboard),\n };\n // Bind the dashboard before the first worker starts, so the worker's spans\n // have somewhere to go.\n const dashboard = options.dashboard\n ? await openDashboard({\n port: options.dashboard.port,\n directory: process.cwd(),\n historyDays: options.dashboard.historyDays,\n warn: (message) => console.warn(message),\n docs: true,\n dashboard: {\n extension: options.dashboard.extension,\n theme: options.dashboard.theme,\n },\n restart: () => {\n void restart(\"dashboard\");\n },\n portHint: \"Use --dashboard-port <number> or --no-dashboard.\",\n })\n : undefined;\n const telemetry = dashboard?.store;\n let frontend: ReturnType<typeof Bun.spawn> | undefined;\n const dependencyFiles = new Set<string>();\n const dependencyWatchers = new Map<string, ReturnType<typeof watch>>();\n let stopped = false;\n const intentionalExits = new WeakSet<ReturnType<typeof Bun.spawn>>();\n const receive = (message: WorkerMessage, generation: number) => {\n switch (message.type) {\n case \"brick:telemetry\":\n telemetry?.ingest(message.records, generation);\n return;\n case \"brick:error\":\n telemetry?.recordWorkerError(message.phase, message.error, generation);\n return;\n case \"brick:contract-ready\":\n if (options.frontend && !frontend && !stopped)\n frontend = Bun.spawn(\n [process.env.SHELL ?? \"/bin/sh\", \"-c\", options.frontend],\n {\n detached: true,\n cwd: process.cwd(),\n stdout: \"inherit\",\n stderr: \"inherit\",\n },\n );\n telemetry?.recordReload({\n kind: \"contract-ready\",\n generation,\n detail: \"browser contract generated\",\n });\n return;\n case \"brick:architecture\":\n telemetry?.setArchitecture(message.architecture, generation);\n void dashboard?.setPluginExtensions(message.architecture.plugins ?? []);\n return;\n case \"brick:inspector\":\n if (generation === telemetry?.latestGeneration)\n telemetry.setInspector({\n port: message.port,\n token: message.token,\n workflows: message.workflows,\n });\n return;\n case \"brick:documentation\":\n void dashboard?.docs?.configure(\n dirname(resolvedEntry),\n message.documentation,\n );\n return;\n case \"brick:api-documents\":\n telemetry?.setApiDocuments(\n message.documents,\n `http://localhost:${port}`,\n );\n return;\n case \"brick:dependencies\":\n for (const file of message.files) {\n if (file === contract) continue;\n dependencyFiles.add(file);\n const directory = dirname(file);\n if (!dependencyWatchers.has(directory))\n dependencyWatchers.set(\n directory,\n watch(directory, (_event, filename) => {\n if (\n !filename ||\n !dependencyFiles.has(resolve(directory, filename))\n )\n return;\n scheduleRestart();\n }),\n );\n }\n return;\n }\n };\n const launch = () => {\n // The new process serves its own inspector once it is up.\n telemetry?.setInspector(undefined);\n const generation = telemetry?.startGeneration() ?? 0;\n const application = Bun.spawn(\n [\n process.execPath,\n ownModule(\"dev-worker\"),\n JSON.stringify(workerOptions),\n ],\n {\n cwd: process.cwd(),\n stdout: \"inherit\",\n stderr: \"inherit\",\n ipc: (message: WorkerMessage) => receive(message, generation),\n },\n );\n void application.exited.then((code) => {\n if (generation === telemetry?.latestGeneration)\n telemetry.setInspector(undefined);\n if (!stopped && !intentionalExits.has(application)) {\n console.error(\n `[Brick-TS] Application process exited with code ${code}. Waiting for changes to restart.`,\n );\n telemetry?.recordReload({\n kind: \"exited\",\n generation,\n detail: `exit code ${code}`,\n });\n }\n telemetry?.interruptGeneration(generation);\n });\n return application;\n };\n if (dashboard) {\n console.log(`📊 Dev dashboard: http://127.0.0.1:${dashboard.port}`);\n }\n let child = launch();\n // The worker reports the other files the entry imports (brick:dependencies).\n const watchDirs = [\n ...new Set([\n dirname(resolvedEntry),\n ...(manifest ? [manifest.services] : []),\n ]),\n ].filter(existsSync);\n let pending: ReturnType<typeof setTimeout> | undefined;\n let restarting = false;\n let dirty = false;\n\n async function restart(trigger: \"changes\" | \"dashboard\" = \"changes\") {\n dirty = true;\n if (restarting || stopped) return;\n restarting = true;\n try {\n while (dirty && !stopped) {\n dirty = false;\n console.log(\n trigger === \"changes\"\n ? \"\\n📝 Changes detected. Restarting server...\"\n : \"\\n🔄 Restart requested from the dashboard. Restarting server...\",\n );\n telemetry?.recordReload({\n kind: \"restarting\",\n generation: telemetry.latestGeneration,\n detail:\n trigger === \"changes\" ? \"source changed\" : \"restart from dashboard\",\n });\n intentionalExits.add(child);\n child.kill();\n await child.exited;\n if (!stopped) child = launch();\n }\n } finally {\n restarting = false;\n }\n }\n\n function scheduleRestart() {\n clearTimeout(pending);\n pending = setTimeout(() => {\n void restart();\n }, 100);\n }\n const extension = options.dashboard && options.dashboard.extension;\n const extensionDir =\n extension && !watchDirs.includes(dirname(resolve(extension)))\n ? `${dirname(resolve(extension))}${sep}`\n : undefined;\n const watchers = watchDirs.map((dir) =>\n watch(dir, { recursive: true }, (_event, filename) => {\n if (!filename || filename.split(/[\\\\/]/).includes(\"node_modules\")) return;\n const file = resolve(dir, filename);\n if (\n file === contract ||\n basename(file).startsWith(TEMPORARY_FILE_PREFIX) ||\n // The dashboard rebuilds its extension itself; the app restarts only\n // for the files it imports.\n (extensionDir !== undefined &&\n file.startsWith(extensionDir) &&\n !dependencyFiles.has(file))\n )\n return;\n // A definition file was added or removed: refresh the import list first.\n if (manifest && file.startsWith(manifest.services + sep)) {\n void writeServiceManifest(manifest)\n .catch((error: unknown) =>\n console.error(\"[Brick-TS] Could not write services.gen.ts:\", error),\n )\n .finally(scheduleRestart);\n return;\n }\n scheduleRestart();\n }),\n );\n const stop = () => {\n if (stopped) return;\n stopped = true;\n clearTimeout(pending);\n for (const watcher of watchers) watcher.close();\n for (const watcher of dependencyWatchers.values()) watcher.close();\n if (frontend) {\n if (process.platform === \"win32\") {\n Bun.spawnSync([\"taskkill\", \"/pid\", String(frontend.pid), \"/t\", \"/f\"]);\n } else {\n try {\n process.kill(-frontend.pid, \"SIGTERM\");\n } catch (error) {\n if (\n !(\n error instanceof Error &&\n \"code\" in error &&\n error.code === \"ESRCH\"\n )\n )\n throw error;\n }\n }\n }\n dashboard?.stop();\n child.kill();\n process.off(\"SIGINT\", onSignal);\n process.off(\"SIGTERM\", onSignal);\n process.off(\"exit\", stop);\n };\n const onSignal = (signal: NodeJS.Signals) => {\n if (stopped) {\n child.kill(\"SIGKILL\");\n process.exit(signal === \"SIGINT\" ? 130 : 143);\n }\n stop();\n process.on(\"SIGINT\", onSignal);\n process.on(\"SIGTERM\", onSignal);\n void child.exited.then(() => process.exit(0));\n };\n process.on(\"SIGINT\", onSignal);\n process.on(\"SIGTERM\", onSignal);\n process.on(\"exit\", stop);\n console.log(`\\n👀 Watching for changes in: ${watchDirs.join(\", \")}`);\n return { stop };\n}\n","import { aot } from \"elysia/plugin/aot/bun\";\nimport type { BunPlugin } from \"bun\";\n\n/** Keep the pinned Elysia beta's incomplete stripping from breaking builds. */\nexport function brickAot(entry: string, keep: boolean): BunPlugin {\n // `keep`: WS routes still need cookie setup during reconstruction in beta.29,\n // and shipped workflows mount their webhook route only when a world is set at\n // run time. Retain those modules while continuing to precompile HTTP handlers.\n if (keep) return aot(entry, { target: \"bun\", strip: false });\n return {\n name: \"brick-elysia-aot\",\n async setup(build) {\n await aot(entry, { target: \"bun\", strip: true }).setup({\n ...build,\n onLoad(options, callback) {\n return build.onLoad(options, async (args) => {\n const result = await callback(args);\n if (\n !result ||\n !(\"contents\" in result) ||\n typeof result.contents !== \"string\"\n )\n return result;\n let contents = result.contents;\n if (\n /[/\\\\]elysia[/\\\\]dist[/\\\\]ws[/\\\\]route\\.m?js$/.test(args.path) &&\n contents.includes(\n \"[elysia-aot] WebSocket route builder was stripped\",\n )\n ) {\n for (const name of [\"resolveWSOptions\", \"accumulateWSOptions\"]) {\n if (!contents.includes(`export function ${name}`))\n contents += `\\nexport function ${name}() { throw new Error(\"WebSocket support was stripped\"); }\\n`;\n }\n }\n return contents === result.contents\n ? result\n : { ...result, contents };\n });\n },\n });\n },\n };\n}\n","import { mkdtemp, mkdir, rename, rm } from \"node:fs/promises\";\nimport { dirname, join, resolve } from \"node:path\";\nimport { compileBrickApplication, WORKFLOW_BUNDLE } from \"@brickkit/core\";\nimport type { BunPlugin } from \"bun\";\nimport { emitCompiledApplication } from \"./compiler\";\nimport { brickAot } from \"./compiler/aot\";\nimport { loadBrickApp } from \"./app-entry\";\nimport { ownModule } from \"./own-module\";\nimport { DEFAULT_OUTDIR, resolvePort } from \"./config\";\nimport { shipWorkflows, workflowTransformPlugin } from \"./workflows\";\nimport {\n themeCss,\n writeDashboardExtension,\n type DashboardExtensionOptions,\n} from \"./dashboard-extension\";\n\nexport interface BuildApplicationOptions {\n /** A module whose default export is a BrickApp, without starting a server. */\n entry: string;\n outdir?: string;\n port?: number;\n /** Precompile Elysia's HTTP handlers at build time (default true). */\n aot?: boolean;\n /**\n * The dashboard's extension, built into `<outdir>/dashboard` with those of\n * the app's plugins for the production dashboard to serve; its theme is\n * checked here too.\n */\n dashboard?: DashboardExtensionOptions;\n}\n\n/**\n * The production dashboard stays out of the bundle: it serves files that ship\n * with @brickkit/cli, so a built server whose app asks for it imports it from\n * there at run time. Without a dashboard the bundle needs nothing installed.\n */\nconst productionDashboardAtRunTime: BunPlugin = {\n name: \"brick:production-dashboard\",\n setup(build) {\n build.onResolve({ filter: /^\\.\\/production-dashboard(\\.[jt]s)?$/ }, () => ({\n path: \"@brickkit/cli/production-dashboard\",\n external: true,\n }));\n },\n};\n\n/** The files `brick build` writes to the output folder, `server.js` last. */\nconst OUTPUTS = [\"routes.js\", \"brick-ir.json\", \"server.js.map\", \"server.js\"];\n\n/** Bundle an exported BrickApp with its compiled IR and its original configuration. */\nexport async function buildApplication(options: BuildApplicationOptions) {\n const entry = resolve(options.entry);\n if (!(await Bun.file(entry).exists()))\n throw new Error(`Brick compiler: entry not found: ${entry}`);\n const outdir = resolve(options.outdir ?? DEFAULT_OUTDIR);\n if (OUTPUTS.some((name) => entry === join(outdir, name)))\n throw new Error(\n \"Brick compiler: output would overwrite the application entry\",\n );\n const port = resolvePort(options.port, undefined, \"\");\n themeCss(options.dashboard?.theme);\n const extension = options.dashboard?.extension\n ? resolve(options.dashboard.extension)\n : undefined;\n if (extension && !(await Bun.file(extension).exists()))\n throw new Error(\n `Brick compiler: dashboard extension not found: ${extension}`,\n );\n const app = await loadBrickApp(entry);\n const root = app.events?.workflows?.root ?? process.cwd();\n const services = [...app.definition.services];\n const compilation = compileBrickApplication({\n services,\n prefix: app.definition.prefix,\n });\n await mkdir(dirname(outdir), { recursive: true });\n const staging = await mkdtemp(join(dirname(outdir), \".brick-build-\"));\n try {\n await Bun.write(\n join(staging, \"routes.js\"),\n emitCompiledApplication(compilation.ir),\n );\n const dashboard = (await writeDashboardExtension(\n extension,\n app.definition.plugins ?? [],\n join(staging, \"dashboard\"),\n ))\n ? join(outdir, \"dashboard\")\n : undefined;\n const theme = JSON.stringify(options.dashboard?.theme);\n const source = `import { existsSync } from \"node:fs\";\nimport { fileURLToPath } from \"node:url\";\nimport { loadCompiledBrickApp } from \"@brickkit/core\";\nimport { resolvePort } from ${JSON.stringify(ownModule(\"config\"))};\nimport { serveApp, shutdownOnSignal } from ${JSON.stringify(ownModule(\"serve\"))};\nconst workflows = fileURLToPath(new URL(${JSON.stringify(`./${WORKFLOW_BUNDLE.dir}`)}, import.meta.url));\nexport const app = await loadCompiledBrickApp(() => import(${JSON.stringify(entry)}), undefined, {\n workflows: existsSync(workflows) ? workflows : undefined,\n});\nexport default app;\nif (import.meta.main) {\n await serveApp(app, {\n port: resolvePort(undefined, ${port}),\n dashboard: { extension: ${dashboard ? 'fileURLToPath(new URL(\"./dashboard\", import.meta.url))' : \"undefined\"}, theme: ${theme} },\n });\n console.log(\"Brick compiled server listening on http://localhost:\" + app.server.port);\n shutdownOnSignal(app);\n}\n`;\n await Bun.write(join(staging, \"entry.ts\"), source);\n // Whether to ship workflows depends on the files the bundle holds, not on\n // the env: an app may declare its workflow listeners only at run time.\n let directives = false;\n const transform = await workflowTransformPlugin(root, () => {\n directives = true;\n });\n const result = await Bun.build({\n entrypoints: [join(staging, \"entry.ts\")],\n target: \"bun\",\n format: \"esm\",\n outdir: staging,\n naming: \"server.js\",\n sourcemap: \"external\",\n // AOT first: the workflow plugin loads every project file it sees, so after\n // it the AOT plugin would never get to transform the entry.\n plugins: [\n ...(options.aot === false\n ? []\n : [\n brickAot(\n join(staging, \"entry.ts\"),\n app.definition.sockets.length > 0 || transform !== undefined,\n ),\n ]),\n ...(transform ? [transform] : []),\n productionDashboardAtRunTime,\n ],\n });\n if (!result.success)\n throw new AggregateError(result.logs, \"Brick compiler: bundling failed\");\n const workflows =\n (directives || Boolean(app.events?.workflows)) &&\n (await shipWorkflows(root, staging, Boolean(app.events?.workflows)));\n await Bun.write(\n join(staging, \"brick-ir.json\"),\n JSON.stringify(compilation.ir, null, 2) + \"\\n\",\n );\n await mkdir(outdir, { recursive: true });\n for (const name of OUTPUTS)\n await rename(join(staging, name), join(outdir, name));\n // Only the bundle is ours: other files under .well-known stay.\n const bundle = join(outdir, WORKFLOW_BUNDLE.dir);\n await rm(bundle, { recursive: true, force: true });\n if (workflows) {\n await mkdir(dirname(bundle), { recursive: true });\n await rename(join(staging, WORKFLOW_BUNDLE.dir), bundle);\n }\n if (dashboard) {\n await rm(dashboard, { recursive: true, force: true });\n await rename(join(staging, \"dashboard\"), dashboard);\n }\n return {\n outdir,\n entry: join(outdir, \"server.js\"),\n ir: compilation.ir,\n dashboard,\n workflows: workflows ? join(outdir, WORKFLOW_BUNDLE.dir) : undefined,\n };\n } finally {\n await rm(staging, { recursive: true, force: true });\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAaA,MAAM,QAAmC,CAAC,WAAW,UAAU;AAE/D,SAA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Ae,GAC7B,KAAK,UAAU,YAAY,IAAI,MAAM,CAAC,IAAI,IAC5C;EACA,MAAM,MAAM,QAAQ,EAAE,WAAW,KAAK,CAAC;EACvC,KAAK,MAAM,QAAQ,SACjB,MAAM,OAAO,KAAK,SAAS,IAAI,GAAG,KAAK,QAAQ,IAAI,CAAC;EAEtD,MAAM,SAAS,KAAK,QAAQ,gBAAgB,GAAG;EAC/C,MAAM,GAAG,QAAQ;GAAE,WAAW;GAAM,OAAO;EAAK,CAAC;EACjD,IAAI,WAAW;GACb,MAAM,MAAM,QAAQ,MAAM,GAAG,EAAE,WAAW,KAAK,CAAC;GAChD,MAAM,OAAO,KAAK,SAAS,gBAAgB,GAAG,GAAG,MAAM;EACzD;EACA,IAAI,WAAW;GACb,MAAM,GAAG,WAAW;IAAE,WAAW;IAAM,OAAO;GAAK,CAAC;GACpD,MAAM,OAAO,KAAK,SAAS,WAAW,GAAG,SAAS;EACpD;EACA,OAAO;GACL;GACA,OAAO,KAAK,QAAQ,WAAW;GAC/B,IAAI,YAAY;GAChB;GACA,WAAW,YAAY,KAAK,QAAQ,gBAAgB,GAAG,IAAI,KAAA;EAC7D;CACF,UAAU;EACR,MAAM,GAAG,SAAS;GAAE,WAAW;GAAM,OAAO;EAAK,CAAC;CACpD;AACF"}
|
package/dist/dashboard-host.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { n as ConfigError, r as DEFAULT_DASHBOARD_PORT } from "./config2.js";
|
|
2
|
-
import { a as INSPECTOR_TOKEN_HEADER, c as SHARED_MODULES, d as assetUrl, f as decode, g as
|
|
2
|
+
import { _ as matchRoute, a as INSPECTOR_TOKEN_HEADER, c as SHARED_MODULES, d as assetUrl, f as decode, g as isExternalHref, h as docsHref, i as DOCS_PATHS, l as SPAN, m as docsFileUrl, n as ATTR, o as LIVE_LIMITS, s as ROUTES, t as ASSETS, u as THEME_STORAGE_KEY } from "./dashboard-protocol.js";
|
|
3
3
|
import { createRequire } from "node:module";
|
|
4
4
|
import { existsSync, mkdirSync, watch, writeFileSync } from "node:fs";
|
|
5
5
|
import { basename, dirname, extname, join, posix, relative, resolve, sep } from "node:path";
|
|
@@ -1365,6 +1365,7 @@ function startDevDashboard(options) {
|
|
|
1365
1365
|
frameOnlyHere(response);
|
|
1366
1366
|
return inspector(request, response, url);
|
|
1367
1367
|
},
|
|
1368
|
+
schedules: (request, response, url) => inspector(request, response, url),
|
|
1368
1369
|
ingest,
|
|
1369
1370
|
restart(request, response) {
|
|
1370
1371
|
if (!options.restart) {
|
|
@@ -1460,7 +1461,7 @@ function startDevDashboard(options) {
|
|
|
1460
1461
|
async function inspector(request, response, url) {
|
|
1461
1462
|
const target = options.store.inspectorTarget();
|
|
1462
1463
|
if (!target) {
|
|
1463
|
-
send(response, 503, "The workflow inspector
|
|
1464
|
+
send(response, 503, "The workflow inspector and schedules are not being served. The app may be restarting, or it may have neither workflows nor schedules.", { "content-type": "text/plain; charset=utf-8" });
|
|
1464
1465
|
return;
|
|
1465
1466
|
}
|
|
1466
1467
|
if (!isBodyless(request) && !fromOwnPage(request)) {
|
|
@@ -2194,17 +2195,18 @@ var DevTelemetryStore = class {
|
|
|
2194
2195
|
});
|
|
2195
2196
|
}
|
|
2196
2197
|
/**
|
|
2197
|
-
* Set where the app serves its workflow inspector, or
|
|
2198
|
-
* stops. The address stays here: the snapshot says only
|
|
2198
|
+
* Set where the app serves its workflow inspector and schedules, or
|
|
2199
|
+
* `undefined` when it stops. The address stays here: the snapshot says only
|
|
2200
|
+
* whether there is a workflow inspector.
|
|
2199
2201
|
*/
|
|
2200
2202
|
setInspector(target) {
|
|
2201
2203
|
this.#inspector = target;
|
|
2202
2204
|
this.#emit({
|
|
2203
2205
|
type: "inspector",
|
|
2204
|
-
inspector: Boolean(target)
|
|
2206
|
+
inspector: Boolean(target?.workflows)
|
|
2205
2207
|
});
|
|
2206
2208
|
}
|
|
2207
|
-
/** Where the dashboard proxies the workflow inspector, when the app serves
|
|
2209
|
+
/** Where the dashboard proxies the workflow inspector and schedules, when the app serves them. */
|
|
2208
2210
|
inspectorTarget() {
|
|
2209
2211
|
return this.#inspector;
|
|
2210
2212
|
}
|
|
@@ -2224,7 +2226,7 @@ var DevTelemetryStore = class {
|
|
|
2224
2226
|
architecture: this.#architecture,
|
|
2225
2227
|
api: this.#api,
|
|
2226
2228
|
docs: this.#docs,
|
|
2227
|
-
inspector: Boolean(this.#inspector)
|
|
2229
|
+
inspector: Boolean(this.#inspector?.workflows)
|
|
2228
2230
|
};
|
|
2229
2231
|
}
|
|
2230
2232
|
subscribe(listener) {
|