@brickkit/cli 0.12.0 → 0.13.1
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-B-bZRtNV.js → api-reference-mT9VNcPb.js} +69 -69
- package/dashboard-dist/app.css +1 -1
- package/dashboard-dist/app.js +12 -13
- package/dashboard-dist/{client-BJJtVSVr.js → client-CwATkLJa.js} +1 -1
- package/dashboard-dist/{core-Z7NJFk0K.js → core-BEUWp6B5.js} +1 -1
- package/dashboard-dist/docs-BRrtyxDB.js +4 -0
- package/dashboard-dist/kit.js +1 -1
- package/dashboard-dist/popover-Bj9x-88h.js +1 -0
- package/dist/bin.js +154 -217
- package/dist/bin.js.map +1 -1
- package/dist/build.js +463 -0
- package/dist/build.js.map +1 -0
- package/dist/client-contract-file.js +356 -1
- package/dist/client-contract-file.js.map +1 -0
- package/dist/compiler.d.ts +12 -2
- package/dist/compiler2.js +12 -5
- package/dist/compiler2.js.map +1 -1
- package/dist/config.d.ts +3 -0
- package/dist/config.js +1 -250
- package/dist/config2.d.ts +122 -0
- package/dist/config2.js +207 -0
- package/dist/config2.js.map +1 -0
- package/dist/dashboard-extension.d.ts +3 -0
- package/dist/{dev-telemetry-store.js → dashboard-host.js} +1533 -1574
- package/dist/dashboard-host.js.map +1 -0
- package/dist/dashboard-protocol.js +189 -0
- package/dist/dashboard-protocol.js.map +1 -0
- package/dist/dashboard.d.ts +4 -1
- package/dist/definitions.js +33 -0
- package/dist/definitions.js.map +1 -0
- package/dist/dev-application.js +34 -0
- package/dist/dev-application.js.map +1 -0
- package/dist/dev-protocol.js +21 -0
- package/dist/dev-protocol.js.map +1 -0
- package/dist/dev-reporter.js +2 -1
- package/dist/dev-reporter.js.map +1 -1
- package/dist/dev-telemetry.js +5 -20
- package/dist/dev-telemetry.js.map +1 -1
- package/dist/dev-worker.js +79 -19
- package/dist/dev-worker.js.map +1 -1
- package/dist/index.d.ts +15 -74
- package/dist/index.js +12 -5
- package/dist/index.js.map +1 -0
- package/dist/lint/oxlint.js +5 -3
- package/dist/lint/oxlint.js.map +1 -1
- package/dist/own-module.js +7 -0
- package/dist/own-module.js.map +1 -0
- package/dist/plugin.d.ts +6 -5
- package/dist/plugin.js +5 -39
- package/dist/plugin.js.map +1 -1
- package/dist/production-dashboard.d.ts +2 -0
- package/dist/production-dashboard.js +51 -0
- package/dist/production-dashboard.js.map +1 -0
- package/dist/production-dashboard2.d.ts +34 -0
- package/dist/{presets.js → project.js} +104 -106
- package/dist/project.js.map +1 -0
- package/dist/serve.d.ts +24 -0
- package/dist/serve.js +1 -0
- package/dist/serve2.js +49 -0
- package/dist/serve2.js.map +1 -0
- package/dist/vite.js +26 -47
- package/dist/vite.js.map +1 -1
- package/dist/workflows.d.ts +2 -2
- package/dist/workflows2.js +59 -37
- package/dist/workflows2.js.map +1 -1
- package/inspector-dist/client/assets/app-CeSwVsRm.css +2 -0
- package/inspector-dist/client/assets/{highlighted-body-B3W2YXNL-DYVdwGy2.js → highlighted-body-B3W2YXNL-CfRnuITN.js} +1 -1
- package/inspector-dist/client/assets/{home-CyjkvtII.js → home-hwPlkNhv.js} +1529 -378
- package/inspector-dist/client/assets/manifest-0e76e9ac.js +1 -0
- package/inspector-dist/client/assets/mermaid-3ZIDBTTL-ZDR2PNY_.js +1 -0
- package/inspector-dist/client/assets/root-ChBNTZd2.css +2 -0
- package/inspector-dist/client/assets/{root-DX9wtogx.js → root-SLeEf-sT.js} +17 -29
- package/inspector-dist/client/assets/{run-detail-C69EJGql.js → run-detail-DYbVkIFH.js} +398 -76
- package/inspector-dist/client/assets/{tabs-B6B88IjT.js → tabs-CaJisoyb.js} +189 -2130
- package/inspector-dist/client/assets/{zstd-browser-decoder-ByUgcY9H.js → zstd-browser-decoder-D94wmfAU.js} +1 -1
- package/inspector-dist/server/assets/{app-WoDoT62X.js → app-DGlfWVUI.js} +69783 -70608
- package/inspector-dist/server/assets/{chunk-RLXIAIE6-CbvDIAEa.js → chunk-RLXIAIE6-F0SJZlei.js} +4 -6
- package/inspector-dist/server/assets/{dist-qR-969AD.js → dist-BCbwm6jl.js} +2 -4
- package/inspector-dist/server/assets/{dist-CQnQcIJg.js → dist-CG2aVufI.js} +0 -2
- package/inspector-dist/server/assets/{dist-BRxZSWUN.js → dist-Ce0I2PUv.js} +2 -5
- package/inspector-dist/server/assets/{dist-DqRd9pyS.js → dist-DY0UlahA.js} +0 -2
- package/inspector-dist/server/assets/{encryption-_PuklZNX.js → encryption-DdQgC8Rk.js} +2 -4
- package/inspector-dist/server/assets/{event-metadata-BVakQJ_y.js → event-metadata-n7E4zEmT.js} +0 -2
- package/inspector-dist/server/assets/{functions-CImcpqNl.js → functions-CNVQtbgg.js} +2 -4
- package/inspector-dist/server/assets/{global-singleton-CPirHxFh.js → global-singleton-D8sIN5du.js} +0 -2
- package/inspector-dist/server/assets/{highlighted-body-B3W2YXNL-fPMB_t7F.js → highlighted-body-B3W2YXNL-CWRzMxYD.js} +2 -4
- package/inspector-dist/server/assets/mermaid-3ZIDBTTL-D0v0ngVr.js +1 -0
- package/inspector-dist/server/assets/{parse-D9Vvgzt9.js → parse-Begau9cA.js} +0 -2
- package/inspector-dist/server/assets/{rolldown-runtime-CLg409Sh.js → rolldown-runtime-C1I3wEg2.js} +1 -2
- package/inspector-dist/server/assets/{serialization-format-DDtsVTU1.js → serialization-format-BbuGfHog.js} +6 -8
- package/inspector-dist/server/assets/{token-BW4GdQZh.js → token-BgMmJNP5.js} +2 -4
- package/inspector-dist/server/assets/{token-D6FXdkJT.js → token-BrUX0bxz.js} +2 -4
- package/inspector-dist/server/assets/{token-util-BoNmi-wE.js → token-util-DZN32qmT.js} +1 -3
- package/inspector-dist/server/assets/{wrapper-wiqsGXcE.js → wrapper-CIC3w0oC.js} +1 -3
- package/inspector-dist/server/assets/{ws-transport-DV7oG4mL.js → ws-transport-CxTYB11n.js} +24094 -24096
- package/inspector-dist/server/assets/{zstd-browser-decoder-Cswf0KO6.js → zstd-browser-decoder-D7bCXbGg.js} +2 -4
- package/inspector-dist/server/index.js +1 -3
- package/package.json +12 -2
- package/dashboard-dist/docs-Dpfc0wJb.js +0 -4
- package/dashboard-dist/popover-BzejBolB.js +0 -1
- package/dist/app-entry.js +0 -1
- package/dist/app-entry2.js +0 -18
- package/dist/app-entry2.js.map +0 -1
- package/dist/client-contract-file2.js +0 -33
- package/dist/client-contract-file2.js.map +0 -1
- package/dist/client-contract.js +0 -1
- package/dist/client-contract2.js +0 -296
- package/dist/client-contract2.js.map +0 -1
- package/dist/config.js.map +0 -1
- package/dist/dev-telemetry-store.js.map +0 -1
- package/dist/emit.d.ts +0 -5
- package/dist/presets.js.map +0 -1
- package/dist/runner.js +0 -519
- package/dist/runner.js.map +0 -1
- package/inspector-dist/client/assets/app-CCzpuUz_.css +0 -2
- package/inspector-dist/client/assets/manifest-ba30b52d.js +0 -1
- package/inspector-dist/client/assets/mermaid-3ZIDBTTL-Dy6IVqPy.js +0 -1
- package/inspector-dist/client/assets/root-8BMab1lL.css +0 -2
- package/inspector-dist/client/assets/world-config-context-C3BqXPIv.js +0 -30
- package/inspector-dist/server/assets/mermaid-3ZIDBTTL-bADXySE3.js +0 -3
package/dist/dev-worker.js
CHANGED
|
@@ -1,7 +1,71 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { s as ROUTES } from "./dashboard-protocol.js";
|
|
2
|
+
import { t as startDevApplication } from "./dev-application.js";
|
|
3
|
+
import { t as sendToSupervisor } from "./dev-protocol.js";
|
|
4
|
+
import { n as installWorkerTelemetry, r as reportWorkerError } from "./dev-telemetry.js";
|
|
5
|
+
import { existsSync, statSync } from "node:fs";
|
|
6
|
+
import { join, resolve, sep } from "node:path";
|
|
4
7
|
import { getGlobalRegistry, stopAllEvents } from "@brickkit/core";
|
|
8
|
+
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
9
|
+
import { randomBytes } from "node:crypto";
|
|
10
|
+
// src/dev-inspector.ts
|
|
11
|
+
const INSPECTOR_PATH = ROUTES.workflows.path;
|
|
12
|
+
/** The built inspector, next to `src/` in the repo and next to `dist/` when published. */
|
|
13
|
+
const INSPECTOR_DIRECTORY = fileURLToPath(new URL("../inspector-dist/", import.meta.url));
|
|
14
|
+
/** Whether a path is a regular file; any failure to find out (not a directory, name too long) says no. */
|
|
15
|
+
function isFile(path) {
|
|
16
|
+
try {
|
|
17
|
+
return statSync(path).isFile();
|
|
18
|
+
} catch {
|
|
19
|
+
return false;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* A file of the inspector's browser build. Its names carry a hash of their
|
|
24
|
+
* content, so a browser may keep them for good. Anything else under `assets/`
|
|
25
|
+
* is a plain 404: the page would answer with HTML. `undefined` for requests
|
|
26
|
+
* outside `assets/`, which are the page's to answer.
|
|
27
|
+
*/
|
|
28
|
+
function browserAsset(request, client) {
|
|
29
|
+
if (request.method !== "GET" && request.method !== "HEAD") return void 0;
|
|
30
|
+
const { pathname } = new URL(request.url);
|
|
31
|
+
if (!pathname.startsWith(`${INSPECTOR_PATH}/assets/`)) return void 0;
|
|
32
|
+
const file = resolve(client, pathname.slice(INSPECTOR_PATH.length + 1));
|
|
33
|
+
if (!file.startsWith(client + sep) || !isFile(file)) return new Response("Not found", { status: 404 });
|
|
34
|
+
return new Response(Bun.file(file), { headers: { "cache-control": "public, max-age=31536000, immutable" } });
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Serve the Workflow inspector (the Workflow SDK's observability UI, built into
|
|
38
|
+
* this package) for the app's world, on a loopback port of its own. The
|
|
39
|
+
* dashboard proxies it at `/workflows`; it is the only caller that knows the
|
|
40
|
+
* token. The UI can cancel runs and resume hooks, so nothing else may reach it,
|
|
41
|
+
* and it exists only under `brick dev`.
|
|
42
|
+
*
|
|
43
|
+
* @param app - The loaded app, running in this process.
|
|
44
|
+
* @param directory - The inspector's build; this package's own by default.
|
|
45
|
+
* @returns The inspector, or `undefined` when the app runs no workflows.
|
|
46
|
+
* @throws When the inspector's build is missing.
|
|
47
|
+
*/
|
|
48
|
+
async function startInspector(app, directory = INSPECTOR_DIRECTORY) {
|
|
49
|
+
const target = app.events?.workflows;
|
|
50
|
+
if (!target) return void 0;
|
|
51
|
+
const entry = join(directory, "server", "index.js");
|
|
52
|
+
if (!existsSync(entry)) throw new Error("The workflow inspector is not built. Build it with: bun run --filter @brickkit/cli build");
|
|
53
|
+
const { createFetchHandler } = await import(pathToFileURL(entry).href);
|
|
54
|
+
const page = createFetchHandler(INSPECTOR_PATH, { world: target.world });
|
|
55
|
+
const client = join(directory, "client");
|
|
56
|
+
const token = randomBytes(16).toString("hex");
|
|
57
|
+
const server = Bun.serve({
|
|
58
|
+
hostname: "127.0.0.1",
|
|
59
|
+
port: 0,
|
|
60
|
+
idleTimeout: 0,
|
|
61
|
+
fetch: (request) => request.headers.get("x-brick-inspector") === token ? browserAsset(request, client) ?? page(request) : new Response("Forbidden", { status: 403 })
|
|
62
|
+
});
|
|
63
|
+
return {
|
|
64
|
+
port: server.port,
|
|
65
|
+
token,
|
|
66
|
+
stop: () => void server.stop(true)
|
|
67
|
+
};
|
|
68
|
+
}
|
|
5
69
|
// src/dev-worker.ts
|
|
6
70
|
let stopping = false;
|
|
7
71
|
const stop = () => {
|
|
@@ -14,7 +78,8 @@ if (process.connected && typeof process.send === "function") {
|
|
|
14
78
|
process.on("SIGINT", () => {});
|
|
15
79
|
process.on("disconnect", stop);
|
|
16
80
|
} else process.on("SIGINT", stop);
|
|
17
|
-
const
|
|
81
|
+
const options = JSON.parse(process.argv[2]);
|
|
82
|
+
const { telemetry } = options;
|
|
18
83
|
let startupComplete = false;
|
|
19
84
|
let reported = false;
|
|
20
85
|
async function reportOnce(phase, error) {
|
|
@@ -37,11 +102,11 @@ if (telemetry) {
|
|
|
37
102
|
exitAfterFailure(startupComplete ? "unhandled-rejection" : "startup", reason);
|
|
38
103
|
});
|
|
39
104
|
}
|
|
40
|
-
|
|
105
|
+
{
|
|
41
106
|
const files = /* @__PURE__ */ new Set();
|
|
42
107
|
try {
|
|
43
108
|
await Bun.build({
|
|
44
|
-
entrypoints: [
|
|
109
|
+
entrypoints: [options.entry],
|
|
45
110
|
target: "bun",
|
|
46
111
|
packages: "external",
|
|
47
112
|
plugins: [{
|
|
@@ -54,19 +119,14 @@ if (process.argv[2]) {
|
|
|
54
119
|
}]
|
|
55
120
|
});
|
|
56
121
|
} finally {
|
|
57
|
-
|
|
122
|
+
await sendToSupervisor({
|
|
58
123
|
type: "brick:dependencies",
|
|
59
124
|
files: [...files]
|
|
60
125
|
});
|
|
61
126
|
}
|
|
62
127
|
}
|
|
63
128
|
try {
|
|
64
|
-
const app = await startDevApplication(
|
|
65
|
-
entry: process.argv[2],
|
|
66
|
-
port: parsePort(process.argv[3] || void 0, process.env.PORT),
|
|
67
|
-
prefix: process.argv[4] || void 0,
|
|
68
|
-
clientOutput: process.argv[5] || void 0
|
|
69
|
-
});
|
|
129
|
+
const app = await startDevApplication(options);
|
|
70
130
|
startupComplete = true;
|
|
71
131
|
if (telemetry) {
|
|
72
132
|
sendToSupervisor({
|
|
@@ -81,13 +141,13 @@ try {
|
|
|
81
141
|
type: "brick:api-documents",
|
|
82
142
|
documents
|
|
83
143
|
}), (error) => console.warn(`[Brick-TS] Could not load the API documents: ${error instanceof Error ? error.message : String(error)}`));
|
|
144
|
+
startInspector(app).then((inspector) => inspector && sendToSupervisor({
|
|
145
|
+
type: "brick:inspector",
|
|
146
|
+
port: inspector.port,
|
|
147
|
+
token: inspector.token
|
|
148
|
+
}), (error) => console.warn(`[Brick-TS] Could not start the workflow inspector: ${error instanceof Error ? error.message : String(error)}`));
|
|
149
|
+
if (!app.definition.telemetry) console.warn("[Brick-TS] The dashboard shows no requests: pass { telemetry: true } to brick() in your app entry.");
|
|
84
150
|
}
|
|
85
|
-
if (telemetry) startInspector(app).then((inspector) => inspector && sendToSupervisor({
|
|
86
|
-
type: "brick:inspector",
|
|
87
|
-
port: inspector.port,
|
|
88
|
-
token: inspector.token
|
|
89
|
-
}), (error) => console.warn(`[Brick-TS] Could not start the workflow inspector: ${error instanceof Error ? error.message : String(error)}`));
|
|
90
|
-
if (telemetry && !app.definition.telemetry) console.warn("[Brick-TS] The dashboard shows no requests: pass { telemetry: true } to brick() in your app entry.");
|
|
91
151
|
} catch (error) {
|
|
92
152
|
await reportOnce("startup", error);
|
|
93
153
|
throw error;
|
package/dist/dev-worker.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dev-worker.js","names":[],"sources":["../src/dev-worker.ts"],"sourcesContent":["import { getGlobalRegistry, stopAllEvents } from \"@brickkit/core\";\nimport { startInspector } from \"./dev-inspector\";\nimport { startDevApplication } from \"./runner\";\nimport { parsePort } from \"./port-utils\";\nimport {\n installWorkerTelemetry,\n reportWorkerError,\n sendToSupervisor,\n} from \"./dev-telemetry\";\nimport type { WorkerErrorPhase } from \"./dev-telemetry\";\n\nlet stopping = false;\n// A reload stops this process. Deliveries cut off would stay claimed, and wait\n// a minute (claimTimeoutMs) before the next process takes them. Stop every\n// started hub: an event emitted while the entry still loads starts one.\nconst stop = () => {\n if (stopping) return;\n stopping = true;\n void Promise.race([stopAllEvents(), Bun.sleep(3000)])\n .catch((error: unknown) =>\n console.error(\n `[Brick-TS] Could not stop the events: ${error instanceof Error ? error.message : String(error)}`,\n ),\n )\n .finally(() => process.exit(0));\n};\nprocess.on(\"SIGTERM\", stop);\nif (process.connected && typeof process.send === \"function\") {\n // The terminal also signals the supervisor, which sends SIGTERM and waits for us.\n process.on(\"SIGINT\", () => {});\n process.on(\"disconnect\", stop);\n} else {\n process.on(\"SIGINT\", stop);\n}\n\n// argv[6] is \"1\" when the supervisor serves the dashboard and needs spans.\nconst telemetry = process.argv[6] === \"1\";\nlet startupComplete = false;\nlet reported = false;\n\nasync function reportOnce(phase: WorkerErrorPhase, error: unknown) {\n if (!telemetry || reported) return;\n reported = true;\n await reportWorkerError(phase, error);\n}\n\nasync function exitAfterFailure(phase: WorkerErrorPhase, error: unknown) {\n await reportOnce(phase, error);\n console.error(error);\n process.exit(1);\n}\n\nif (telemetry) {\n installWorkerTelemetry();\n // Failures before the app is listening are startup failures, not crashes.\n const phaseOf = (): WorkerErrorPhase =>\n startupComplete ? \"uncaught\" : \"startup\";\n process.on(\"uncaughtException\", (error) => {\n void exitAfterFailure(phaseOf(), error);\n });\n process.on(\"unhandledRejection\", (reason) => {\n void exitAfterFailure(\n startupComplete ? \"unhandled-rejection\" : \"startup\",\n reason,\n );\n });\n}\n\n// Scan local imports so dependencies outside the app directory are watched too.\nif (process.argv[2]) {\n const files = new Set<string>();\n try {\n await Bun.build({\n entrypoints: [process.argv[2]],\n target: \"bun\",\n packages: \"external\",\n plugins: [\n {\n name: \"brick:dependencies\",\n setup(build) {\n build.onLoad({ filter: /./ }, (args) => {\n files.add(args.path);\n return undefined;\n });\n },\n },\n ],\n });\n } finally {\n process.send?.({ type: \"brick:dependencies\", files: [...files] });\n }\n}\n\ntry {\n const app = await startDevApplication({\n entry: process.argv[2],\n port: parsePort(process.argv[3] || undefined, process.env.PORT),\n prefix: process.argv[4] || undefined,\n clientOutput: process.argv[5] || undefined,\n });\n startupComplete = true;\n if (telemetry) {\n void sendToSupervisor({\n type: \"brick:architecture\",\n architecture: getGlobalRegistry().exportArchitecture(app.definition),\n });\n void sendToSupervisor({\n type: \"brick:documentation\",\n documentation: app.definition.documentation,\n });\n void app.referenceDocuments().then(\n (documents) =>\n sendToSupervisor({ type: \"brick:api-documents\", documents }),\n (error: unknown) =>\n console.warn(\n `[Brick-TS] Could not load the API documents: ${error instanceof Error ? error.message : String(error)}`,\n ),\n );\n }\n if (telemetry) {\n void startInspector(app).then(\n (inspector) =>\n inspector &&\n sendToSupervisor({\n type: \"brick:inspector\",\n port: inspector.port,\n token: inspector.token,\n }),\n (error: unknown) =>\n console.warn(\n `[Brick-TS] Could not start the workflow inspector: ${error instanceof Error ? error.message : String(error)}`,\n ),\n );\n }\n if (telemetry && !app.definition.telemetry) {\n console.warn(\n \"[Brick-TS] The dashboard shows no requests: pass { telemetry: true } to brick() in your app entry.\",\n );\n }\n} catch (error) {\n await reportOnce(\"startup\", error);\n throw error;\n}\n"],"mappings":"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"}
|
|
1
|
+
{"version":3,"file":"dev-worker.js","names":[],"sources":["../src/dev-inspector.ts","../src/dev-worker.ts"],"sourcesContent":["import { randomBytes } from \"node:crypto\";\nimport { existsSync, statSync } from \"node:fs\";\nimport { join, resolve, sep } from \"node:path\";\nimport { fileURLToPath, pathToFileURL } from \"node:url\";\nimport type { BrickApp } from \"@brickkit/core\";\nimport type { CreateFetchHandler } from \"../../workflow-inspector/server/handler\";\nimport { INSPECTOR_TOKEN_HEADER, ROUTES } from \"./dashboard-protocol\";\n\nconst INSPECTOR_PATH = ROUTES.workflows.path;\n\nexport interface Inspector {\n readonly port: number;\n /** Every request must carry it in `INSPECTOR_TOKEN_HEADER`. */\n readonly token: string;\n stop(): void;\n}\n\n/** The built inspector, next to `src/` in the repo and next to `dist/` when published. */\nconst INSPECTOR_DIRECTORY = fileURLToPath(\n new URL(\"../inspector-dist/\", import.meta.url),\n);\n\n/** Whether a path is a regular file; any failure to find out (not a directory, name too long) says no. */\nfunction isFile(path: string): boolean {\n try {\n return statSync(path).isFile();\n } catch {\n return false;\n }\n}\n\n/**\n * A file of the inspector's browser build. Its names carry a hash of their\n * content, so a browser may keep them for good. Anything else under `assets/`\n * is a plain 404: the page would answer with HTML. `undefined` for requests\n * outside `assets/`, which are the page's to answer.\n */\nfunction browserAsset(request: Request, client: string): Response | undefined {\n if (request.method !== \"GET\" && request.method !== \"HEAD\") return undefined;\n const { pathname } = new URL(request.url);\n if (!pathname.startsWith(`${INSPECTOR_PATH}/assets/`)) return undefined;\n const file = resolve(client, pathname.slice(INSPECTOR_PATH.length + 1));\n if (!file.startsWith(client + sep) || !isFile(file))\n return new Response(\"Not found\", { status: 404 });\n return new Response(Bun.file(file), {\n headers: { \"cache-control\": \"public, max-age=31536000, immutable\" },\n });\n}\n\n/**\n * Serve the Workflow inspector (the Workflow SDK's observability UI, built into\n * this package) for the app's world, on a loopback port of its own. The\n * dashboard proxies it at `/workflows`; it is the only caller that knows the\n * token. The UI can cancel runs and resume hooks, so nothing else may reach it,\n * and it exists only under `brick dev`.\n *\n * @param app - The loaded app, running in this process.\n * @param directory - The inspector's build; this package's own by default.\n * @returns The inspector, or `undefined` when the app runs no workflows.\n * @throws When the inspector's build is missing.\n */\nexport async function startInspector(\n app: BrickApp,\n directory = INSPECTOR_DIRECTORY,\n): Promise<Inspector | undefined> {\n const target = app.events?.workflows;\n if (!target) return undefined;\n const entry = join(directory, \"server\", \"index.js\");\n if (!existsSync(entry))\n throw new Error(\n \"The workflow inspector is not built. Build it with: bun run --filter @brickkit/cli build\",\n );\n const { createFetchHandler } = (await import(pathToFileURL(entry).href)) as {\n createFetchHandler: CreateFetchHandler;\n };\n const page = createFetchHandler(INSPECTOR_PATH, {\n // Core types only the parts of the world it calls; the world is a whole Workflow SDK World.\n world: target.world as Parameters<CreateFetchHandler>[1][\"world\"],\n });\n const client = join(directory, \"client\");\n const token = randomBytes(16).toString(\"hex\");\n const server = Bun.serve({\n hostname: \"127.0.0.1\",\n port: 0,\n // The UI streams a run's output and holds the connection open.\n idleTimeout: 0,\n fetch: (request) =>\n request.headers.get(INSPECTOR_TOKEN_HEADER) === token\n ? (browserAsset(request, client) ?? page(request))\n : new Response(\"Forbidden\", { status: 403 }),\n });\n return { port: server.port!, token, stop: () => void server.stop(true) };\n}\n","import { getGlobalRegistry, stopAllEvents } from \"@brickkit/core\";\nimport { startInspector } from \"./dev-inspector\";\nimport { startDevApplication } from \"./dev-application\";\nimport type { WorkerErrorPhase } from \"./dashboard-protocol\";\nimport { sendToSupervisor, type WorkerOptions } from \"./dev-protocol\";\nimport { installWorkerTelemetry, reportWorkerError } from \"./dev-telemetry\";\n\nlet stopping = false;\n// A reload stops this process. Deliveries cut off would stay claimed, and wait\n// a minute (claimTimeoutMs) before the next process takes them. Stop every\n// started hub: an event emitted while the entry still loads starts one.\nconst stop = () => {\n if (stopping) return;\n stopping = true;\n void Promise.race([stopAllEvents(), Bun.sleep(3000)])\n .catch((error: unknown) =>\n console.error(\n `[Brick-TS] Could not stop the events: ${error instanceof Error ? error.message : String(error)}`,\n ),\n )\n .finally(() => process.exit(0));\n};\nprocess.on(\"SIGTERM\", stop);\nif (process.connected && typeof process.send === \"function\") {\n // The terminal also signals the supervisor, which sends SIGTERM and waits for us.\n process.on(\"SIGINT\", () => {});\n process.on(\"disconnect\", stop);\n} else {\n process.on(\"SIGINT\", stop);\n}\n\nconst options: WorkerOptions = JSON.parse(process.argv[2]!);\nconst { telemetry } = options;\nlet startupComplete = false;\nlet reported = false;\n\nasync function reportOnce(phase: WorkerErrorPhase, error: unknown) {\n if (!telemetry || reported) return;\n reported = true;\n await reportWorkerError(phase, error);\n}\n\nasync function exitAfterFailure(phase: WorkerErrorPhase, error: unknown) {\n await reportOnce(phase, error);\n console.error(error);\n process.exit(1);\n}\n\nif (telemetry) {\n installWorkerTelemetry();\n // Failures before the app is listening are startup failures, not crashes.\n const phaseOf = (): WorkerErrorPhase =>\n startupComplete ? \"uncaught\" : \"startup\";\n process.on(\"uncaughtException\", (error) => {\n void exitAfterFailure(phaseOf(), error);\n });\n process.on(\"unhandledRejection\", (reason) => {\n void exitAfterFailure(\n startupComplete ? \"unhandled-rejection\" : \"startup\",\n reason,\n );\n });\n}\n\n// Scan local imports so dependencies outside the app directory are watched too.\n{\n const files = new Set<string>();\n try {\n await Bun.build({\n entrypoints: [options.entry],\n target: \"bun\",\n packages: \"external\",\n plugins: [\n {\n name: \"brick:dependencies\",\n setup(build) {\n build.onLoad({ filter: /./ }, (args) => {\n files.add(args.path);\n return undefined;\n });\n },\n },\n ],\n });\n } finally {\n // Awaited: a build error ends this process, and the list must arrive first.\n await sendToSupervisor({ type: \"brick:dependencies\", files: [...files] });\n }\n}\n\ntry {\n const app = await startDevApplication(options);\n startupComplete = true;\n if (telemetry) {\n void sendToSupervisor({\n type: \"brick:architecture\",\n architecture: getGlobalRegistry().exportArchitecture(app.definition),\n });\n void sendToSupervisor({\n type: \"brick:documentation\",\n documentation: app.definition.documentation,\n });\n void app.referenceDocuments().then(\n (documents) =>\n sendToSupervisor({ type: \"brick:api-documents\", documents }),\n (error: unknown) =>\n console.warn(\n `[Brick-TS] Could not load the API documents: ${error instanceof Error ? error.message : String(error)}`,\n ),\n );\n void startInspector(app).then(\n (inspector) =>\n inspector &&\n sendToSupervisor({\n type: \"brick:inspector\",\n port: inspector.port,\n token: inspector.token,\n }),\n (error: unknown) =>\n console.warn(\n `[Brick-TS] Could not start the workflow inspector: ${error instanceof Error ? error.message : String(error)}`,\n ),\n );\n if (!app.definition.telemetry)\n console.warn(\n \"[Brick-TS] The dashboard shows no requests: pass { telemetry: true } to brick() in your app entry.\",\n );\n }\n} catch (error) {\n await reportOnce(\"startup\", error);\n throw error;\n}\n"],"mappings":";;;;;;;;;;AAQA,MAAM,iBAAiB,OAAO,UAAU;;AAUxC,MAAM,sBAAsB,cAC1B,IAAI,IAAI,sBAAsB,YAAY,GAAG,CAC/C;;AAGA,SAAS,OAAO,MAAuB;CACrC,IAAI;EACF,OAAO,SAAS,IAAI,CAAC,CAAC,OAAO;CAC/B,QAAQ;EACN,OAAO;CACT;AACF;;;;;;;AAQA,SAAS,aAAa,SAAkB,QAAsC;CAC5E,IAAI,QAAQ,WAAW,SAAS,QAAQ,WAAW,QAAQ,OAAO,KAAA;CAClE,MAAM,EAAE,aAAa,IAAI,IAAI,QAAQ,GAAG;CACxC,IAAI,CAAC,SAAS,WAAW,GAAG,eAAe,SAAS,GAAG,OAAO,KAAA;CAC9D,MAAM,OAAO,QAAQ,QAAQ,SAAS,MAAM,eAAe,SAAS,CAAC,CAAC;CACtE,IAAI,CAAC,KAAK,WAAW,SAAS,GAAG,KAAK,CAAC,OAAO,IAAI,GAChD,OAAO,IAAI,SAAS,aAAa,EAAE,QAAQ,IAAI,CAAC;CAClD,OAAO,IAAI,SAAS,IAAI,KAAK,IAAI,GAAG,EAClC,SAAS,EAAE,iBAAiB,sCAAsC,EACpE,CAAC;AACH;;;;;;;;;;;;;AAcA,eAAsB,eACpB,KACA,YAAY,qBACoB;CAChC,MAAM,SAAS,IAAI,QAAQ;CAC3B,IAAI,CAAC,QAAQ,OAAO,KAAA;CACpB,MAAM,QAAQ,KAAK,WAAW,UAAU,UAAU;CAClD,IAAI,CAAC,WAAW,KAAK,GACnB,MAAM,IAAI,MACR,0FACF;CACF,MAAM,EAAE,uBAAwB,MAAM,OAAO,cAAc,KAAK,CAAC,CAAC;CAGlE,MAAM,OAAO,mBAAmB,gBAAgB,EAE9C,OAAO,OAAO,MAChB,CAAC;CACD,MAAM,SAAS,KAAK,WAAW,QAAQ;CACvC,MAAM,QAAQ,YAAY,EAAE,CAAC,CAAC,SAAS,KAAK;CAC5C,MAAM,SAAS,IAAI,MAAM;EACvB,UAAU;EACV,MAAM;EAEN,aAAa;EACb,QAAQ,YACN,QAAQ,QAAQ,IAAA,mBAA0B,MAAM,QAC3C,aAAa,SAAS,MAAM,KAAK,KAAK,OAAO,IAC9C,IAAI,SAAS,aAAa,EAAE,QAAQ,IAAI,CAAC;CACjD,CAAC;CACD,OAAO;EAAE,MAAM,OAAO;EAAO;EAAO,YAAY,KAAK,OAAO,KAAK,IAAI;CAAE;AACzE;;ACrFA,IAAI,WAAW;AAIf,MAAM,aAAa;CACjB,IAAI,UAAU;CACd,WAAW;CACX,QAAa,KAAK,CAAC,cAAc,GAAG,IAAI,MAAM,GAAI,CAAC,CAAC,CAAC,CAClD,OAAO,UACN,QAAQ,MACN,yCAAyC,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK,GAChG,CACF,CAAC,CACA,cAAc,QAAQ,KAAK,CAAC,CAAC;AAClC;AACA,QAAQ,GAAG,WAAW,IAAI;AAC1B,IAAI,QAAQ,aAAa,OAAO,QAAQ,SAAS,YAAY;CAE3D,QAAQ,GAAG,gBAAgB,CAAC,CAAC;CAC7B,QAAQ,GAAG,cAAc,IAAI;AAC/B,OACE,QAAQ,GAAG,UAAU,IAAI;AAG3B,MAAM,UAAyB,KAAK,MAAM,QAAQ,KAAK,EAAG;AAC1D,MAAM,EAAE,cAAc;AACtB,IAAI,kBAAkB;AACtB,IAAI,WAAW;AAEf,eAAe,WAAW,OAAyB,OAAgB;CACjE,IAAI,CAAC,aAAa,UAAU;CAC5B,WAAW;CACX,MAAM,kBAAkB,OAAO,KAAK;AACtC;AAEA,eAAe,iBAAiB,OAAyB,OAAgB;CACvE,MAAM,WAAW,OAAO,KAAK;CAC7B,QAAQ,MAAM,KAAK;CACnB,QAAQ,KAAK,CAAC;AAChB;AAEA,IAAI,WAAW;CACb,uBAAuB;CAEvB,MAAM,gBACJ,kBAAkB,aAAa;CACjC,QAAQ,GAAG,sBAAsB,UAAU;EACzC,iBAAsB,QAAQ,GAAG,KAAK;CACxC,CAAC;CACD,QAAQ,GAAG,uBAAuB,WAAW;EAC3C,iBACE,kBAAkB,wBAAwB,WAC1C,MACF;CACF,CAAC;AACH;AAGA;CACE,MAAM,wBAAQ,IAAI,IAAY;CAC9B,IAAI;EACF,MAAM,IAAI,MAAM;GACd,aAAa,CAAC,QAAQ,KAAK;GAC3B,QAAQ;GACR,UAAU;GACV,SAAS,CACP;IACE,MAAM;IACN,MAAM,OAAO;KACX,MAAM,OAAO,EAAE,QAAQ,IAAI,IAAI,SAAS;MACtC,MAAM,IAAI,KAAK,IAAI;KAErB,CAAC;IACH;GACF,CACF;EACF,CAAC;CACH,UAAU;EAER,MAAM,iBAAiB;GAAE,MAAM;GAAsB,OAAO,CAAC,GAAG,KAAK;EAAE,CAAC;CAC1E;AACF;AAEA,IAAI;CACF,MAAM,MAAM,MAAM,oBAAoB,OAAO;CAC7C,kBAAkB;CAClB,IAAI,WAAW;EACb,iBAAsB;GACpB,MAAM;GACN,cAAc,kBAAkB,CAAC,CAAC,mBAAmB,IAAI,UAAU;EACrE,CAAC;EACD,iBAAsB;GACpB,MAAM;GACN,eAAe,IAAI,WAAW;EAChC,CAAC;EACD,IAAS,mBAAmB,CAAC,CAAC,MAC3B,cACC,iBAAiB;GAAE,MAAM;GAAuB;EAAU,CAAC,IAC5D,UACC,QAAQ,KACN,gDAAgD,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK,GACvG,CACJ;EACA,eAAoB,GAAG,CAAC,CAAC,MACtB,cACC,aACA,iBAAiB;GACf,MAAM;GACN,MAAM,UAAU;GAChB,OAAO,UAAU;EACnB,CAAC,IACF,UACC,QAAQ,KACN,sDAAsD,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK,GAC7G,CACJ;EACA,IAAI,CAAC,IAAI,WAAW,WAClB,QAAQ,KACN,oGACF;CACJ;AACF,SAAS,OAAO;CACd,MAAM,WAAW,WAAW,KAAK;CACjC,MAAM;AACR"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
import { n as DashboardTheme, t as DashboardExtensionOptions } from "./dashboard-extension.js";
|
|
2
|
-
import {
|
|
2
|
+
import { l as LintPreset, p as defineConfig$1, t as BrickConfig, u as LintSeverity } from "./config2.js";
|
|
3
3
|
import { BrickApp } from "@brickkit/core";
|
|
4
4
|
interface DevServerOptions {
|
|
5
5
|
port?: number;
|
|
6
6
|
entry?: string;
|
|
7
|
+
/**
|
|
8
|
+
* @deprecated Only used without an `entry`; an exported app sets its own
|
|
9
|
+
* prefix in `brick({ prefix })`.
|
|
10
|
+
*/
|
|
7
11
|
prefix?: string;
|
|
8
12
|
/** Generate a browser contract before starting the backend and frontend. */
|
|
9
13
|
clientOutput?: string;
|
|
@@ -11,10 +15,9 @@ interface DevServerOptions {
|
|
|
11
15
|
frontend?: string;
|
|
12
16
|
/**
|
|
13
17
|
* Local dashboard with live requests, traces, errors, and reloads. Needs an
|
|
14
|
-
* entry. `port`
|
|
15
|
-
* requests are kept on disk
|
|
16
|
-
* `
|
|
17
|
-
* `brick start` reads only those two, for the production dashboard.
|
|
18
|
+
* entry. `port` is where it listens and `historyDays` how long finished
|
|
19
|
+
* requests are kept on disk; zero keeps live data only. `extension` and
|
|
20
|
+
* `theme` customise it (see `DashboardExtensionOptions`).
|
|
18
21
|
*/
|
|
19
22
|
dashboard?: ({
|
|
20
23
|
port?: number;
|
|
@@ -42,7 +45,7 @@ interface DevServerOptions {
|
|
|
42
45
|
*/
|
|
43
46
|
export declare function startWorker(options: {
|
|
44
47
|
entry: string;
|
|
45
|
-
}): Promise<BrickApp>;
|
|
48
|
+
}): Promise<import("@brickkit/core").BrickApp>;
|
|
46
49
|
/**
|
|
47
50
|
* What `brick dev` runs: start the application, restart it when its files
|
|
48
51
|
* change, and serve the dashboard beside it. With an `entry`, the app runs in
|
|
@@ -60,7 +63,7 @@ export declare function startWorker(options: {
|
|
|
60
63
|
*/
|
|
61
64
|
export declare function startDevServer(options?: DevServerOptions): Promise<{
|
|
62
65
|
stop: () => void;
|
|
63
|
-
} | BrickApp>;
|
|
66
|
+
} | import("@brickkit/core").BrickApp>;
|
|
64
67
|
interface BuildApplicationOptions {
|
|
65
68
|
/** A module whose default export is a BrickApp, without starting a server. */
|
|
66
69
|
entry: string;
|
|
@@ -75,81 +78,19 @@ interface BuildApplicationOptions {
|
|
|
75
78
|
*/
|
|
76
79
|
dashboard?: DashboardExtensionOptions;
|
|
77
80
|
}
|
|
78
|
-
/** Bundle an exported BrickApp with
|
|
81
|
+
/** Bundle an exported BrickApp with its compiled IR and its original configuration. */
|
|
79
82
|
export declare function buildApplication(options: BuildApplicationOptions): Promise<{
|
|
80
83
|
outdir: string;
|
|
81
84
|
entry: string;
|
|
82
85
|
ir: import("@brickkit/core").BrickIR;
|
|
83
|
-
/** The built dashboard extension's folder, when there is one. */
|
|
84
86
|
dashboard: string | undefined;
|
|
85
87
|
}>;
|
|
86
88
|
/** Generate browser metadata and transport types from the app's selected services. */
|
|
87
89
|
export declare function generateClientContract(app: BrickApp): string;
|
|
88
|
-
type LintSeverity = "error" | "warn" | "off";
|
|
89
|
-
type LintPreset = "recommended" | "layout" | "strict" | "plugin";
|
|
90
|
-
/**
|
|
91
|
-
* Project and tooling settings read by the `brick` CLI and its lint rules.
|
|
92
|
-
* Paths are relative to the folder that holds `brick.config.ts`. Runtime
|
|
93
|
-
* behaviour (prefix, docs, telemetry, events, sockets) stays in `brick()`.
|
|
94
|
-
*/
|
|
95
|
-
interface BrickConfig {
|
|
96
|
-
/** App entry whose default export is the BrickApp (default `src/app.ts`). */
|
|
97
|
-
entry?: string;
|
|
98
|
-
/** Folder scanned for definition files (default `src/services`). */
|
|
99
|
-
services?: string;
|
|
100
|
-
/** Folder for `services.gen.ts` and the default contract (default `_brick`). */
|
|
101
|
-
generated?: string;
|
|
102
|
-
client?: {
|
|
103
|
-
output?: string;
|
|
104
|
-
};
|
|
105
|
-
openapi?: {
|
|
106
|
-
output?: string;
|
|
107
|
-
};
|
|
108
|
-
dev?: {
|
|
109
|
-
port?: number;
|
|
110
|
-
/** Frontend command, started once the client contract exists. Needs `client.output`. */
|
|
111
|
-
frontend?: string;
|
|
112
|
-
dashboard?: {
|
|
113
|
-
port?: number;
|
|
114
|
-
historyDays?: number;
|
|
115
|
-
} | false;
|
|
116
|
-
};
|
|
117
|
-
build?: {
|
|
118
|
-
outdir?: string;
|
|
119
|
-
aot?: boolean;
|
|
120
|
-
requestLogging?: boolean;
|
|
121
|
-
};
|
|
122
|
-
dashboard?: DashboardExtensionOptions;
|
|
123
|
-
lint?: {
|
|
124
|
-
presets?: LintPreset[];
|
|
125
|
-
rules?: Record<string, LintSeverity>;
|
|
126
|
-
ignore?: string[];
|
|
127
|
-
};
|
|
128
|
-
}
|
|
129
|
-
/** Types the config file in the editor; the CLI validates it at load. */
|
|
130
|
-
export declare function defineConfig(config: BrickConfig): BrickConfig;
|
|
131
|
-
interface LoadedConfig {
|
|
132
|
-
/** Absolute path of the config file. */
|
|
133
|
-
file: string;
|
|
134
|
-
/** Folder the config's paths are relative to. */
|
|
135
|
-
root: string;
|
|
136
|
-
config: BrickConfig;
|
|
137
|
-
/** Absolute paths with defaults applied. */
|
|
138
|
-
entry: string;
|
|
139
|
-
services: string;
|
|
140
|
-
generated: string;
|
|
141
|
-
}
|
|
142
90
|
/**
|
|
143
|
-
*
|
|
144
|
-
*
|
|
91
|
+
* @deprecated Import it from `@brickkit/cli/config`, which loads less. This
|
|
92
|
+
* one keeps everything index reaches loadable under Node.
|
|
145
93
|
*/
|
|
146
|
-
export declare
|
|
147
|
-
|
|
148
|
-
export declare function renderManifest(services: string, generated: string): string;
|
|
149
|
-
/** Write `<generated>/services.gen.ts`, leaving it untouched when nothing changed. */
|
|
150
|
-
export declare function writeServiceManifest(options: {
|
|
151
|
-
services: string;
|
|
152
|
-
generated: string;
|
|
153
|
-
}): Promise<string>;
|
|
154
|
-
export { type BrickConfig, type BuildApplicationOptions, type DashboardExtensionOptions, type DashboardTheme, type DevServerOptions, type LintPreset, type LintSeverity, type LoadedConfig, emitCompiledApplication, emitHandlerFactory };
|
|
94
|
+
export declare const defineConfig: typeof defineConfig$1;
|
|
95
|
+
export type { BrickConfig, BuildApplicationOptions, DashboardExtensionOptions, DashboardTheme, DevServerOptions, LintPreset, LintSeverity };
|
|
155
96
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import { i as startWorker, n as startDevServer, t as buildApplication } from "./build.js";
|
|
2
|
+
import { a as generateClientContract } from "./client-contract-file.js";
|
|
3
|
+
import { c as defineConfig$1 } from "./config2.js";
|
|
4
|
+
// src/index.ts
|
|
5
|
+
/**
|
|
6
|
+
* @deprecated Import it from `@brickkit/cli/config`, which loads less. This
|
|
7
|
+
* one keeps everything index reaches loadable under Node.
|
|
8
|
+
*/
|
|
9
|
+
const defineConfig = defineConfig$1;
|
|
10
|
+
export { buildApplication, defineConfig, generateClientContract, startDevServer, startWorker };
|
|
11
|
+
|
|
12
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":["defineProjectConfig"],"sources":["../src/index.ts"],"sourcesContent":["export { startDevServer, startWorker, type DevServerOptions } from \"./runner\";\nexport { buildApplication, type BuildApplicationOptions } from \"./build\";\nexport type {\n DashboardExtensionOptions,\n DashboardTheme,\n} from \"./dashboard-extension\";\nexport { generateClientContract } from \"./client-contract\";\nimport { defineConfig as defineProjectConfig } from \"./config\";\nexport type { BrickConfig, LintPreset, LintSeverity } from \"./config\";\n/**\n * @deprecated Import it from `@brickkit/cli/config`, which loads less. This\n * one keeps everything index reaches loadable under Node.\n */\nexport const defineConfig = defineProjectConfig;\n"],"mappings":";;;;;;;;AAaA,MAAa,eAAeA"}
|
package/dist/lint/oxlint.js
CHANGED
|
@@ -1,14 +1,16 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { p as resolveProject } from "../config2.js";
|
|
2
|
+
import { t as projectRules } from "../project.js";
|
|
3
|
+
import { t as brick } from "../plugin.js";
|
|
2
4
|
// src/lint/oxlint.ts
|
|
3
5
|
/** Presets, rule settings, ignores and paths from brick.config.ts, as the fields of an oxlint config. */
|
|
4
6
|
async function fromProject(options = {}) {
|
|
5
|
-
const { rules, settings, ignore } = await
|
|
7
|
+
const { rules, settings, ignore } = projectRules(await resolveProject(options.config, options.cwd));
|
|
6
8
|
return {
|
|
7
9
|
jsPlugins: [{
|
|
8
10
|
name: "brick",
|
|
9
11
|
specifier: "@brickkit/cli/lint/oxlint"
|
|
10
12
|
}],
|
|
11
|
-
settings,
|
|
13
|
+
settings: { brick: settings },
|
|
12
14
|
rules,
|
|
13
15
|
ignorePatterns: ignore
|
|
14
16
|
};
|
package/dist/lint/oxlint.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"oxlint.js","names":[],"sources":["../../src/lint/oxlint.ts"],"sourcesContent":["// @brickkit/cli/lint/oxlint: the plugin for oxlint's jsPlugins, plus a config from brick.config.ts.\nimport type { Severity } from \"./presets\";\nimport { projectRules } from \"./
|
|
1
|
+
{"version":3,"file":"oxlint.js","names":[],"sources":["../../src/lint/oxlint.ts"],"sourcesContent":["// @brickkit/cli/lint/oxlint: the plugin for oxlint's jsPlugins, plus a config from brick.config.ts.\nimport type { Severity } from \"./presets\";\nimport { resolveProject } from \"../config\";\nimport { projectRules } from \"./project\";\n\nexport { brick as default } from \"./plugin\";\n\nexport interface OxlintConfig {\n jsPlugins: { name: string; specifier: string }[];\n settings: Record<string, unknown>;\n rules: Record<string, Severity>;\n ignorePatterns: string[];\n}\n\n/** Presets, rule settings, ignores and paths from brick.config.ts, as the fields of an oxlint config. */\nexport async function fromProject(\n options: { cwd?: string; config?: string } = {},\n): Promise<OxlintConfig> {\n const { rules, settings, ignore } = projectRules(\n await resolveProject(options.config, options.cwd),\n );\n return {\n jsPlugins: [{ name: \"brick\", specifier: \"@brickkit/cli/lint/oxlint\" }],\n settings: { brick: settings },\n rules,\n ignorePatterns: ignore,\n };\n}\n"],"mappings":";;;;;AAeA,eAAsB,YACpB,UAA6C,CAAC,GACvB;CACvB,MAAM,EAAE,OAAO,UAAU,WAAW,aAClC,MAAM,eAAe,QAAQ,QAAQ,QAAQ,GAAG,CAClD;CACA,OAAO;EACL,WAAW,CAAC;GAAE,MAAM;GAAS,WAAW;EAA4B,CAAC;EACrE,UAAU,EAAE,OAAO,SAAS;EAC5B;EACA,gBAAgB;CAClB;AACF"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { fileURLToPath } from "node:url";
|
|
2
|
+
// src/own-module.ts
|
|
3
|
+
/** The path of a module of this package beside this one: its source, or its build in dist. */
|
|
4
|
+
const ownModule = (name) => fileURLToPath(new URL(`./${name}${import.meta.url.endsWith(".ts") ? ".ts" : ".js"}`, import.meta.url));
|
|
5
|
+
export { ownModule as t };
|
|
6
|
+
|
|
7
|
+
//# sourceMappingURL=own-module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"own-module.js","names":[],"sources":["../src/own-module.ts"],"sourcesContent":["import { fileURLToPath } from \"node:url\";\n\n/** The path of a module of this package beside this one: its source, or its build in dist. */\nexport const ownModule = (name: string): string =>\n fileURLToPath(\n new URL(\n `./${name}${import.meta.url.endsWith(\".ts\") ? \".ts\" : \".js\"}`,\n import.meta.url,\n ),\n );\n"],"mappings":";;;AAGA,MAAa,aAAa,SACxB,cACE,IAAI,IACF,KAAK,OAAO,YAAY,IAAI,SAAS,KAAK,IAAI,QAAQ,SACtD,YAAY,GACd,CACF"}
|
package/dist/plugin.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { l as LintPreset, u as LintSeverity } from "./config2.js";
|
|
1
2
|
type Node = any;
|
|
2
3
|
interface RuleContext {
|
|
3
4
|
filename: string;
|
|
@@ -38,11 +39,9 @@ interface BrickSettings {
|
|
|
38
39
|
services: string;
|
|
39
40
|
entry: string;
|
|
40
41
|
generated: string;
|
|
41
|
-
/** Browser code folder, which may import only the client and the contract. */
|
|
42
|
-
web: string;
|
|
43
42
|
}
|
|
44
|
-
type Severity =
|
|
45
|
-
type PresetName =
|
|
43
|
+
type Severity = LintSeverity;
|
|
44
|
+
type PresetName = LintPreset;
|
|
46
45
|
interface FlatConfig {
|
|
47
46
|
name: string;
|
|
48
47
|
files?: string[];
|
|
@@ -56,7 +55,9 @@ declare const brick: {
|
|
|
56
55
|
meta: {
|
|
57
56
|
name: string;
|
|
58
57
|
};
|
|
59
|
-
rules:
|
|
58
|
+
rules: {
|
|
59
|
+
[x: string]: Rule;
|
|
60
|
+
};
|
|
60
61
|
configs: Record<PresetName, FlatConfig> & {
|
|
61
62
|
/** Presets, rule settings, ignores and paths from brick.config.ts, as an ESLint flat-config array. */
|
|
62
63
|
fromProject: typeof fromProject;
|
package/dist/plugin.js
CHANGED
|
@@ -1,29 +1,5 @@
|
|
|
1
|
-
import { a as rules, i as resolveRules, n as PRESETS, r as fileRules } from "./
|
|
2
|
-
import {
|
|
3
|
-
import { dirname, join, resolve } from "node:path";
|
|
4
|
-
import { existsSync } from "node:fs";
|
|
5
|
-
// src/lint/project.ts
|
|
6
|
-
/** Read the nearest brick.config.ts (or `config`), with Brick's default paths. */
|
|
7
|
-
async function readProject(options = {}) {
|
|
8
|
-
const cwd = resolve(options.cwd ?? process.cwd());
|
|
9
|
-
let file = options.config ? resolve(cwd, options.config) : void 0;
|
|
10
|
-
for (let dir = cwd; !file; dir = dirname(dir)) if (existsSync(join(dir, "brick.config.ts"))) file = join(dir, "brick.config.ts");
|
|
11
|
-
else if (dirname(dir) === dir) break;
|
|
12
|
-
const config = file ? (await import(pathToFileURL(file).href)).default ?? {} : {};
|
|
13
|
-
const root = file ? dirname(file) : cwd;
|
|
14
|
-
return {
|
|
15
|
-
root,
|
|
16
|
-
file,
|
|
17
|
-
config,
|
|
18
|
-
settings: {
|
|
19
|
-
root,
|
|
20
|
-
services: config.services ?? "src/services",
|
|
21
|
-
entry: config.entry ?? "src/app.ts",
|
|
22
|
-
generated: config.generated ?? "_brick",
|
|
23
|
-
web: "web"
|
|
24
|
-
}
|
|
25
|
-
};
|
|
26
|
-
}
|
|
1
|
+
import { a as rules, i as resolveRules, n as PRESETS, r as fileRules, t as projectRules } from "./project.js";
|
|
2
|
+
import { p as resolveProject } from "./config2.js";
|
|
27
3
|
// src/lint/plugin.ts
|
|
28
4
|
const FILES = ["**/*.{ts,tsx,mts,cts,js,jsx,mjs,cjs}"];
|
|
29
5
|
/** The ESLint flat-config plugin; oxlint loads the same object through `jsPlugins`. */
|
|
@@ -37,28 +13,18 @@ for (const name of Object.keys(PRESETS)) brick.configs[name] = {
|
|
|
37
13
|
plugins: { brick },
|
|
38
14
|
rules: fileRules(resolveRules([name]))
|
|
39
15
|
};
|
|
40
|
-
/** Rules, settings and ignores from brick.config.ts, shared by both linters. */
|
|
41
|
-
async function projectRules(options) {
|
|
42
|
-
const project = await readProject(options);
|
|
43
|
-
const lint = project.config.lint ?? {};
|
|
44
|
-
return {
|
|
45
|
-
rules: fileRules(resolveRules(lint.presets, lint.rules)),
|
|
46
|
-
settings: { brick: project.settings },
|
|
47
|
-
ignore: [...lint.ignore ?? [], `${project.settings.generated.replace(/\/$/, "")}/**`]
|
|
48
|
-
};
|
|
49
|
-
}
|
|
50
16
|
async function fromProject(options = {}) {
|
|
51
|
-
const { rules, settings, ignore } = await
|
|
17
|
+
const { rules, settings, ignore } = projectRules(await resolveProject(options.config, options.cwd));
|
|
52
18
|
return [{
|
|
53
19
|
name: "brick/project",
|
|
54
20
|
files: FILES,
|
|
55
21
|
ignores: ignore,
|
|
56
22
|
plugins: { brick },
|
|
57
|
-
settings,
|
|
23
|
+
settings: { brick: settings },
|
|
58
24
|
rules
|
|
59
25
|
}];
|
|
60
26
|
}
|
|
61
27
|
brick.configs.fromProject = fromProject;
|
|
62
|
-
export {
|
|
28
|
+
export { brick as t };
|
|
63
29
|
|
|
64
30
|
//# sourceMappingURL=plugin.js.map
|
package/dist/plugin.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.js","names":[],"sources":["../src/lint/
|
|
1
|
+
{"version":3,"file":"plugin.js","names":[],"sources":["../src/lint/plugin.ts"],"sourcesContent":["import {\n fileRules,\n PRESETS,\n resolveRules,\n rules,\n type PresetName,\n type Severity,\n} from \"./presets\";\nimport { resolveProject } from \"../config\";\nimport { projectRules } from \"./project\";\n\nconst FILES = [\"**/*.{ts,tsx,mts,cts,js,jsx,mjs,cjs}\"];\n\ninterface FlatConfig {\n name: string;\n files?: string[];\n ignores?: string[];\n plugins: Record<string, unknown>;\n settings?: Record<string, unknown>;\n rules: Record<string, Severity>;\n}\n\n/** The ESLint flat-config plugin; oxlint loads the same object through `jsPlugins`. */\nexport const brick = {\n meta: { name: \"brick\" },\n rules,\n configs: {} as Record<PresetName, FlatConfig> & {\n /** Presets, rule settings, ignores and paths from brick.config.ts, as an ESLint flat-config array. */\n fromProject: typeof fromProject;\n },\n};\n\nfor (const name of Object.keys(PRESETS) as PresetName[])\n brick.configs[name] = {\n name: `brick/${name}`,\n plugins: { brick },\n rules: fileRules(resolveRules([name])),\n };\n\nasync function fromProject(\n options: { cwd?: string; config?: string } = {},\n): Promise<FlatConfig[]> {\n const { rules, settings, ignore } = projectRules(\n await resolveProject(options.config, options.cwd),\n );\n return [\n {\n name: \"brick/project\",\n files: FILES,\n ignores: ignore,\n plugins: { brick },\n settings: { brick: settings },\n rules,\n },\n ];\n}\nbrick.configs.fromProject = fromProject;\n"],"mappings":";;;AAWA,MAAM,QAAQ,CAAC,sCAAsC;;AAYrD,MAAa,QAAQ;CACnB,MAAM,EAAE,MAAM,QAAQ;CACtB;CACA,SAAS,CAAC;AAIZ;AAEA,KAAK,MAAM,QAAQ,OAAO,KAAK,OAAO,GACpC,MAAM,QAAQ,QAAQ;CACpB,MAAM,SAAS;CACf,SAAS,EAAE,MAAM;CACjB,OAAO,UAAU,aAAa,CAAC,IAAI,CAAC,CAAC;AACvC;AAEF,eAAe,YACb,UAA6C,CAAC,GACvB;CACvB,MAAM,EAAE,OAAO,UAAU,WAAW,aAClC,MAAM,eAAe,QAAQ,QAAQ,QAAQ,GAAG,CAClD;CACA,OAAO,CACL;EACE,MAAM;EACN,OAAO;EACP,SAAS;EACT,SAAS,EAAE,MAAM;EACjB,UAAU,EAAE,OAAO,SAAS;EAC5B;CACF,CACF;AACF;AACA,MAAM,QAAQ,cAAc"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { t as openDashboard } from "./dashboard-host.js";
|
|
2
|
+
import { t as installTracing } from "./dev-telemetry.js";
|
|
3
|
+
import { getGlobalRegistry } from "@brickkit/core";
|
|
4
|
+
// src/production-dashboard.ts
|
|
5
|
+
/**
|
|
6
|
+
* Serve the monitoring dashboard an app asks for with `brick({ dashboard })`,
|
|
7
|
+
* in the process that serves the app. It listens on a port of its own, so it
|
|
8
|
+
* stays up when the app's routes do not answer, and its `/_health` tells an
|
|
9
|
+
* uptime monitor whether the app does. From here on `ctx.logger` and `console`
|
|
10
|
+
* lines written during a request go to the dashboard, not the console.
|
|
11
|
+
*
|
|
12
|
+
* Call it before the app starts listening. Returns undefined when the app
|
|
13
|
+
* asks for no dashboard, or when it cannot start (the app runs on without it,
|
|
14
|
+
* and says so). A configuration that would leave the dashboard open to others
|
|
15
|
+
* throws instead: the app must not start unprotected.
|
|
16
|
+
*/
|
|
17
|
+
async function startProductionDashboard(app, options) {
|
|
18
|
+
const config = app.definition.dashboard;
|
|
19
|
+
if (!config) return void 0;
|
|
20
|
+
const warn = options.warn ?? ((message) => console.warn(message));
|
|
21
|
+
const host = config.host ?? "127.0.0.1";
|
|
22
|
+
const started = await openDashboard({
|
|
23
|
+
directory: options.directory ?? process.cwd(),
|
|
24
|
+
historyDays: config.historyDays ?? 0,
|
|
25
|
+
warn,
|
|
26
|
+
port: config.port,
|
|
27
|
+
host,
|
|
28
|
+
mode: "production",
|
|
29
|
+
portHint: "Set dashboard.port in brick() to another.",
|
|
30
|
+
auth: config.auth,
|
|
31
|
+
dashboard: options.dashboard,
|
|
32
|
+
plugins: app.definition.plugins,
|
|
33
|
+
appUrl: `http://127.0.0.1:${options.appPort}`,
|
|
34
|
+
probe: async () => {
|
|
35
|
+
return (await fetch(`http://127.0.0.1:${options.appPort}/_health`, { signal: AbortSignal.timeout(2e3) })).ok;
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
if (!started) return void 0;
|
|
39
|
+
const { store } = started;
|
|
40
|
+
if (!installTracing((records) => store.ingest(records, store.latestGeneration))) warn("[Brick-TS] Another tracer provider is already registered, so the dashboard will show no requests or logs.");
|
|
41
|
+
const generation = store.startGeneration("application started");
|
|
42
|
+
store.setArchitecture(getGlobalRegistry().exportArchitecture(app.definition), generation);
|
|
43
|
+
return {
|
|
44
|
+
host,
|
|
45
|
+
port: started.port,
|
|
46
|
+
stop: () => started.stop()
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
export { startProductionDashboard };
|
|
50
|
+
|
|
51
|
+
//# sourceMappingURL=production-dashboard.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"production-dashboard.js","names":[],"sources":["../src/production-dashboard.ts"],"sourcesContent":["import { getGlobalRegistry, type BrickApp } from \"@brickkit/core\";\nimport type { DashboardExtensionOptions } from \"./dashboard-extension\";\nimport { openDashboard } from \"./dashboard-host\";\nimport { installTracing } from \"./dev-telemetry\";\n\nexport interface ProductionDashboard {\n readonly host: string;\n readonly port: number;\n stop(): void;\n}\n\n/**\n * Serve the monitoring dashboard an app asks for with `brick({ dashboard })`,\n * in the process that serves the app. It listens on a port of its own, so it\n * stays up when the app's routes do not answer, and its `/_health` tells an\n * uptime monitor whether the app does. From here on `ctx.logger` and `console`\n * lines written during a request go to the dashboard, not the console.\n *\n * Call it before the app starts listening. Returns undefined when the app\n * asks for no dashboard, or when it cannot start (the app runs on without it,\n * and says so). A configuration that would leave the dashboard open to others\n * throws instead: the app must not start unprotected.\n */\nexport async function startProductionDashboard(\n app: BrickApp,\n options: {\n /** The port the app listens on, for the health probe. */\n appPort: number;\n /** Where `.brick/` history is kept; the working folder by default. */\n directory?: string;\n warn?: (message: string) => void;\n /**\n * The project's extension (source, or the folder `brick build` wrote) and\n * theme. The app's plugins' extensions join it, from source or as the\n * folder holds them. Only pages marked `production: true` are shown.\n */\n dashboard?: DashboardExtensionOptions;\n },\n): Promise<ProductionDashboard | undefined> {\n const config = app.definition.dashboard;\n if (!config) return undefined;\n const warn = options.warn ?? ((message) => console.warn(message));\n const host = config.host ?? \"127.0.0.1\";\n const started = await openDashboard({\n directory: options.directory ?? process.cwd(),\n historyDays: config.historyDays ?? 0,\n warn,\n port: config.port,\n host,\n mode: \"production\",\n portHint: \"Set dashboard.port in brick() to another.\",\n auth: config.auth,\n dashboard: options.dashboard,\n plugins: app.definition.plugins,\n appUrl: `http://127.0.0.1:${options.appPort}`,\n probe: async () => {\n const response = await fetch(\n `http://127.0.0.1:${options.appPort}/_health`,\n { signal: AbortSignal.timeout(2000) },\n );\n return response.ok;\n },\n });\n if (!started) return undefined;\n const { store } = started;\n\n const registered = installTracing((records) =>\n store.ingest(records, store.latestGeneration),\n );\n if (!registered) {\n warn(\n \"[Brick-TS] Another tracer provider is already registered, so the dashboard will show no requests or logs.\",\n );\n }\n const generation = store.startGeneration(\"application started\");\n store.setArchitecture(\n getGlobalRegistry().exportArchitecture(app.definition),\n generation,\n );\n return { host, port: started.port, stop: () => started.stop() };\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAuBA,eAAsB,yBACpB,KACA,SAa0C;CAC1C,MAAM,SAAS,IAAI,WAAW;CAC9B,IAAI,CAAC,QAAQ,OAAO,KAAA;CACpB,MAAM,OAAO,QAAQ,UAAU,YAAY,QAAQ,KAAK,OAAO;CAC/D,MAAM,OAAO,OAAO,QAAQ;CAC5B,MAAM,UAAU,MAAM,cAAc;EAClC,WAAW,QAAQ,aAAa,QAAQ,IAAI;EAC5C,aAAa,OAAO,eAAe;EACnC;EACA,MAAM,OAAO;EACb;EACA,MAAM;EACN,UAAU;EACV,MAAM,OAAO;EACb,WAAW,QAAQ;EACnB,SAAS,IAAI,WAAW;EACxB,QAAQ,oBAAoB,QAAQ;EACpC,OAAO,YAAY;GAKjB,QAAO,MAJgB,MACrB,oBAAoB,QAAQ,QAAQ,WACpC,EAAE,QAAQ,YAAY,QAAQ,GAAI,EAAE,CACtC,EAAA,CACgB;EAClB;CACF,CAAC;CACD,IAAI,CAAC,SAAS,OAAO,KAAA;CACrB,MAAM,EAAE,UAAU;CAKlB,IAAI,CAHe,gBAAgB,YACjC,MAAM,OAAO,SAAS,MAAM,gBAAgB,CAEhC,GACZ,KACE,2GACF;CAEF,MAAM,aAAa,MAAM,gBAAgB,qBAAqB;CAC9D,MAAM,gBACJ,kBAAkB,CAAC,CAAC,mBAAmB,IAAI,UAAU,GACrD,UACF;CACA,OAAO;EAAE;EAAM,MAAM,QAAQ;EAAM,YAAY,QAAQ,KAAK;CAAE;AAChE"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { t as DashboardExtensionOptions } from "./dashboard-extension.js";
|
|
2
|
+
import { BrickApp } from "@brickkit/core";
|
|
3
|
+
interface ProductionDashboard {
|
|
4
|
+
readonly host: string;
|
|
5
|
+
readonly port: number;
|
|
6
|
+
stop(): void;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Serve the monitoring dashboard an app asks for with `brick({ dashboard })`,
|
|
10
|
+
* in the process that serves the app. It listens on a port of its own, so it
|
|
11
|
+
* stays up when the app's routes do not answer, and its `/_health` tells an
|
|
12
|
+
* uptime monitor whether the app does. From here on `ctx.logger` and `console`
|
|
13
|
+
* lines written during a request go to the dashboard, not the console.
|
|
14
|
+
*
|
|
15
|
+
* Call it before the app starts listening. Returns undefined when the app
|
|
16
|
+
* asks for no dashboard, or when it cannot start (the app runs on without it,
|
|
17
|
+
* and says so). A configuration that would leave the dashboard open to others
|
|
18
|
+
* throws instead: the app must not start unprotected.
|
|
19
|
+
*/
|
|
20
|
+
declare function startProductionDashboard(app: BrickApp, options: {
|
|
21
|
+
/** The port the app listens on, for the health probe. */
|
|
22
|
+
appPort: number;
|
|
23
|
+
/** Where `.brick/` history is kept; the working folder by default. */
|
|
24
|
+
directory?: string;
|
|
25
|
+
warn?: (message: string) => void;
|
|
26
|
+
/**
|
|
27
|
+
* The project's extension (source, or the folder `brick build` wrote) and
|
|
28
|
+
* theme. The app's plugins' extensions join it, from source or as the
|
|
29
|
+
* folder holds them. Only pages marked `production: true` are shown.
|
|
30
|
+
*/
|
|
31
|
+
dashboard?: DashboardExtensionOptions;
|
|
32
|
+
}): Promise<ProductionDashboard | undefined>;
|
|
33
|
+
export { startProductionDashboard as n, ProductionDashboard as t };
|
|
34
|
+
//# sourceMappingURL=production-dashboard2.d.ts.map
|