@brickkit/cli 0.3.0-beta.1 → 0.3.0-beta.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -1,72 +1,12 @@
1
- import { _ as EndpointMethod, d as RouteIR, g as EndpointLogger, h as EndpointDefinition, i as compileBrickApplication, m as EndpointContext, o as emitCompiledApplication, p as BrickApp, r as bindCompiledApplication, t as CompiledApplication, u as BrickIR } from "./compiler.js";
2
- import { Elysia } from "elysia";
3
- import { CompiledRoutePlan, SecretSource, Service } from "@brickkit/core";
4
- //#region src/request-logger.d.ts
5
- interface RequestLoggingOptions {
6
- enabled?: boolean;
7
- logger?: (msg: string) => void;
8
- }
9
- /**
10
- * Elysia plugin that logs each request as `METHOD path → status (elapsedms)`.
11
- * Timing is tracked per-Request via a WeakMap. The onError hook only logs and
12
- * returns undefined so existing error mapping is preserved. Logging only —
13
- * no CORS headers are set here.
14
- *
15
- * Hooks are registered with the "global" scope so they propagate to the
16
- * parent app when mounted via `app.use(...)` — Elysia scopes plain instance
17
- * hooks to the plugin's own routes. Timing is captured in beforeHandle
18
- * because request hooks are not propagated from a
19
- * used instance. Unmatched routes (no beforeHandle) fall back to Date.now().
20
- */
21
- export declare function requestLoggingPlugin(opts?: RequestLoggingOptions): Elysia;
22
- //#endregion
23
- //#region src/docs.d.ts
24
- interface ReferenceOptions {
25
- path?: string;
26
- title?: string;
27
- specUrl?: string;
28
- }
29
- /** Renders the Scalar API reference page for the given OpenAPI URL. */
30
- export declare function scalarDocsHTML(specUrl: string, title: string): string;
31
- /** Standalone Elysia plugin serving GET <path> with the Scalar HTML page. */
32
- export declare function referencePlugin(opts?: ReferenceOptions): Elysia;
33
- /** Mounts the Scalar reference route onto an existing app. */
34
- export declare function registerReferenceRoute(app: Elysia, opts?: ReferenceOptions): Elysia;
35
- //#endregion
36
- //#region src/server.d.ts
37
- interface CreateServerOptions {
38
- port?: number;
39
- /** Generate specialized handlers once at startup (default true). */
40
- compiler?: boolean;
41
- /** Ahead-of-time handlers already bound to the supplied services. */
42
- compilation?: CompiledApplication;
43
- services?: Service<any, any>[];
44
- prefix?: string;
45
- title?: string;
46
- version?: string;
47
- description?: string;
48
- docs?: boolean;
49
- openApiPath?: string;
50
- docsPath?: string;
51
- swaggerPath?: string;
52
- requestLogging?: boolean | RequestLoggingOptions;
53
- reference?: boolean | ReferenceOptions;
54
- secrets?: {
55
- source?: SecretSource;
56
- validate?: boolean;
57
- };
58
- /** Raw endpoints (outside the JSON action mesh), mounted at startup. */
59
- endpoints?: EndpointDefinition[];
60
- }
61
- export declare function brick(options?: CreateServerOptions): BrickApp;
62
- //#endregion
1
+ import { n as emitHandlerFactory, t as emitCompiledApplication } from "./emit.js";
2
+ import { BrickApp, BrickApp as BrickApp$1, BrickIR, CompiledApplication, CompiledHandler, CompiledRoute, CreateServerOptions, EndpointContext, EndpointDefinition, EndpointLogger, EndpointMethod, HandlerFactory, ReferenceOptions, RequestLoggingOptions, RouteIR, RouteMethod, bindCompiledApplication, brick, compileBrickApplication, loadCompiledBrickApp, referencePlugin, registerReferenceRoute, requestLoggingPlugin, scalarDocsHTML } from "@brickkit/core";
63
3
  //#region src/runner.d.ts
64
4
  interface DevServerOptions {
65
5
  port?: number;
66
6
  entry?: string;
67
7
  prefix?: string;
68
8
  }
69
- export declare function startDevServer(options?: DevServerOptions): Promise<BrickApp>;
9
+ export declare function startDevServer(options?: DevServerOptions): Promise<import("@brickkit/core").BrickApp>;
70
10
  //#endregion
71
11
  //#region src/build.d.ts
72
12
  interface BuildApplicationOptions {
@@ -81,12 +21,12 @@ interface BuildApplicationOptions {
81
21
  export declare function buildApplication(options: BuildApplicationOptions): Promise<{
82
22
  outdir: string;
83
23
  entry: string;
84
- ir: BrickIR;
24
+ ir: import("@brickkit/core").BrickIR;
85
25
  }>;
86
26
  //#endregion
87
27
  //#region src/client-contract.d.ts
88
28
  /** Generate browser metadata and transport types from the app's selected services. */
89
- export declare function generateClientContract(app: BrickApp): string;
29
+ export declare function generateClientContract(app: BrickApp$1): string;
90
30
  //#endregion
91
- export { type BrickApp, type BrickIR, type BuildApplicationOptions, type CompiledApplication, type CreateServerOptions, type DevServerOptions, type EndpointContext, type EndpointDefinition, type EndpointLogger, type EndpointMethod, type ReferenceOptions, type RequestLoggingOptions, type RouteIR, bindCompiledApplication, compileBrickApplication, emitCompiledApplication };
31
+ export { type BrickApp, type BrickIR, type BuildApplicationOptions, type CompiledApplication, type CompiledHandler, type CompiledRoute, type CreateServerOptions, type DevServerOptions, type EndpointContext, type EndpointDefinition, type EndpointLogger, type EndpointMethod, type HandlerFactory, type ReferenceOptions, type RequestLoggingOptions, type RouteIR, type RouteMethod, bindCompiledApplication, brick, compileBrickApplication, emitCompiledApplication, emitHandlerFactory, loadCompiledBrickApp, referencePlugin, registerReferenceRoute, requestLoggingPlugin, scalarDocsHTML };
92
32
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","names":["_$__endpoints0.BrickApp","_$__compiler0.BrickIR"],"sources":["../src/request-logger.ts","../src/docs.ts","../src/server.ts","../src/runner.ts","../src/build.ts","../src/client-contract.ts"],"mappings":";;;;UAEiB;EACf;EACA,UAAU;;;;;;;;;;;;;;wBAoCI,qBAAqB,OAAM,wBAA6B;;;UCtCvD;EACf;EACA;EACA;;;wBAIc,eAAe,iBAAiB;;wBAwBhC,gBAAgB,OAAM,mBAAwB;;wBAa9C,uBACd,KAAK,QACL,OAAM,mBACL;;;UCvBc;EACf;;EAEA;;EAEA,cAAc;EACd,WAAW;EACX;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA,2BAA2B;EAC3B,sBAAsB;EACtB;IAAY,SAAS;IAAc;;;EAEnC,YAAY;;wBASE,MAAM,UAAS,sBAA2B;;;UCjDzC;EACf;EACA;EACA;;wBAGoB,eAAe,UAAS,mBAAqB,QAArBA;;;UCL7B;;EAEf;EACA;EACA;;EAEA;;;wBAIoB,iBAAiB,SAAS,0BAAuB;;;MAAvBC;;;;;wBCVhC,uBAAuB,KAAK"}
1
+ {"version":3,"file":"index.d.ts","names":["BrickApp"],"sources":["../src/runner.ts","../src/build.ts","../src/client-contract.ts"],"mappings":";;;UAIiB;EACf;EACA;EACA;;wBAGoB,eAAe,UAAS,mBAAqB,iCAAA;;;UCJlD;;EAEf;EACA;EACA;;EAEA;;;wBAIoB,iBAAiB,SAAS,0BAAuB;;;;;;;;wBCVvD,uBAAuB,KAAKA"}
package/dist/index.js CHANGED
@@ -1,4 +1,5 @@
1
- import { a as emitCompiledApplication, n as compileBrickApplication, t as bindCompiledApplication } from "./compiler2.js";
2
- import { a as registerReferenceRoute, i as referencePlugin, n as startDevServer, o as scalarDocsHTML, r as brick, s as requestLoggingPlugin, t as buildApplication } from "./build.js";
1
+ import { r as startDevServer, t as buildApplication } from "./build.js";
2
+ import { a as emitHandlerFactory, i as emitCompiledApplication } from "./compiler2.js";
3
3
  import { t as generateClientContract } from "./client-contract.js";
4
- export { bindCompiledApplication, brick, buildApplication, compileBrickApplication, emitCompiledApplication, generateClientContract, referencePlugin, registerReferenceRoute, requestLoggingPlugin, scalarDocsHTML, startDevServer };
4
+ import { bindCompiledApplication, brick, compileBrickApplication, loadCompiledBrickApp, referencePlugin, registerReferenceRoute, requestLoggingPlugin, scalarDocsHTML } from "@brickkit/core";
5
+ export { bindCompiledApplication, brick, buildApplication, compileBrickApplication, emitCompiledApplication, emitHandlerFactory, generateClientContract, loadCompiledBrickApp, referencePlugin, registerReferenceRoute, requestLoggingPlugin, scalarDocsHTML, startDevServer };
package/dist/vite.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { t as generateClientContract } from "./client-contract.js";
2
- import { dirname, resolve } from "node:path";
3
2
  import { mkdir, readFile, writeFile } from "node:fs/promises";
3
+ import { dirname, resolve } from "node:path";
4
4
  import { createServer, isRunnableDevEnvironment, normalizePath } from "vite";
5
5
  import { ModuleRunner } from "vite/module-runner";
6
6
  //#region src/vite.ts
package/dist/vite.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"vite.js","names":[],"sources":["../src/vite.ts"],"sourcesContent":["import { resolve, dirname } from \"node:path\";\nimport { mkdir, readFile, writeFile } from \"node:fs/promises\";\nimport {\n createServer,\n isRunnableDevEnvironment,\n normalizePath,\n type Plugin,\n type ResolvedConfig,\n type EnvironmentModuleNode,\n} from \"vite\";\nimport { generateClientContract } from \"./client-contract\";\nimport type { BrickApp } from \"./endpoints\";\nimport { ModuleRunner } from \"vite/module-runner\";\n\nexport interface BrickClientPluginOptions {\n /** Any module whose default export is a BrickApp; do not call listen() there. */\n entry: string;\n /** Generated browser contract, relative to the Vite root (default _brick/contract.ts). */\n output?: string;\n}\n\n/** Load a BrickApp through Vite's server module graph, including dependency HMR. */\nexport function brickClient(options: BrickClientPluginOptions): Plugin {\n const virtualId = \"virtual:brick-app\";\n const resolvedId = \"\\0\" + virtualId;\n let entry: string;\n let output: string;\n let config: ResolvedConfig;\n let buildGeneration: Promise<void> | undefined;\n let runner: ModuleRunner | undefined;\n let reload = Promise.resolve();\n const dependencies = new Set<string>();\n\n async function writeContract(value: unknown) {\n if (\n !value ||\n typeof (value as BrickApp).endpoint !== \"function\" ||\n !(value as BrickApp).definition\n ) {\n throw new Error(\n \"Brick: the entry module must default-export a BrickApp created by brick().\",\n );\n }\n const source = generateClientContract(value as BrickApp);\n const previous = await readFile(output, \"utf8\").catch((error) => {\n if (error.code !== \"ENOENT\") throw error;\n return undefined;\n });\n if (previous === source) return;\n await mkdir(dirname(output), { recursive: true });\n await writeFile(output, source);\n }\n\n function collectDependencies(\n node: EnvironmentModuleNode | undefined,\n seen = new Set<EnvironmentModuleNode>(),\n ) {\n if (!node || seen.has(node)) return;\n seen.add(node);\n if (node.file) dependencies.add(node.file);\n for (const imported of node.importedModules)\n collectDependencies(imported, seen);\n }\n\n return {\n name: \"brick:client\",\n enforce: \"pre\",\n configResolved(resolved) {\n config = resolved;\n entry = normalizePath(resolve(config.root, options.entry));\n output = normalizePath(\n resolve(config.root, options.output ?? \"_brick/contract.ts\"),\n );\n if (entry === output)\n throw new Error(\n \"Brick: contract output must not overwrite the app entry.\",\n );\n },\n async configureServer(server) {\n const environment = server.environments.ssr;\n if (!environment)\n throw new Error(\n \"Brick: client generation requires a Vite SSR environment.\",\n );\n // Frameworks such as Start own their SSR runner. Use an independent runner\n // on the same transform graph to read app metadata without changing theirs.\n runner = new ModuleRunner({\n hmr: false,\n transport: {\n invoke: (payload) => environment.hot.handleInvoke(payload),\n },\n });\n await writeContract((await runner.import(entry)).default);\n dependencies.clear();\n collectDependencies(environment.moduleGraph.getModuleById(entry));\n dependencies.add(entry);\n },\n async hotUpdate(context) {\n if (\n this.environment.name !== \"ssr\" ||\n !dependencies.has(context.file) ||\n context.file === output\n )\n return;\n if (!runner) return;\n const currentRunner = runner;\n reload = reload\n .catch(() => {})\n .then(async () => {\n for (const module of context.modules)\n this.environment.moduleGraph.invalidateModule(module);\n currentRunner.clearCache();\n await writeContract((await currentRunner.import(entry)).default);\n dependencies.clear();\n collectDependencies(\n this.environment.moduleGraph.getModuleById(entry),\n );\n dependencies.add(entry);\n });\n await reload;\n },\n async closeBundle() {\n await runner?.close();\n },\n async buildStart() {\n if (config.command !== \"build\") return;\n buildGeneration ??= (async () => {\n // Evaluate the server entry through Vite's TS/alias resolver before client compilation.\n // This loader has no app plugins, so it cannot recursively trigger generation.\n const loader = await createServer({\n configFile: false,\n root: config.root,\n mode: config.mode,\n envDir: config.envDir,\n base: config.base,\n define: config.define,\n logLevel: \"silent\",\n resolve: { alias: config.resolve.alias },\n ssr: config.ssr,\n server: { middlewareMode: true, watch: null },\n });\n try {\n const environment = loader.environments.ssr;\n if (!environment || !isRunnableDevEnvironment(environment))\n throw new Error(\"Brick: missing build-time SSR loader.\");\n await writeContract((await environment.runner.import(entry)).default);\n } finally {\n await loader.close();\n }\n })();\n await buildGeneration;\n },\n resolveId(id) {\n if (id !== virtualId) return;\n if (this.environment.config.consumer === \"client\") {\n throw new Error(\n \"Brick: virtual:brick-app is server-only; never import the backend app in the browser.\",\n );\n }\n return resolvedId;\n },\n load(id) {\n if (id !== resolvedId) return;\n return `import app from ${JSON.stringify(entry)};\nif (!app || typeof app.fetch !== \"function\" || typeof app.endpoint !== \"function\") {\n throw new Error(\"Brick: the entry module must default-export a BrickApp created by brick().\");\n}\nexport default app;\n`;\n },\n };\n}\n"],"mappings":";;;;;;;AAsBA,SAAgB,YAAY,SAA2C;CACrE,MAAM,YAAY;CAClB,MAAM,aAAa,OAAO;CAC1B,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI,SAAS,QAAQ,QAAQ;CAC7B,MAAM,+BAAe,IAAI,IAAY;CAErC,eAAe,cAAc,OAAgB;EAC3C,IACE,CAAC,SACD,OAAQ,MAAmB,aAAa,cACxC,CAAE,MAAmB,YAErB,MAAM,IAAI,MACR,4EACF;EAEF,MAAM,SAAS,uBAAuB,KAAiB;EAKvD,IAAI,MAJmB,SAAS,QAAQ,MAAM,CAAC,CAAC,OAAO,UAAU;GAC/D,IAAI,MAAM,SAAS,UAAU,MAAM;EAErC,CAAC,MACgB,QAAQ;EACzB,MAAM,MAAM,QAAQ,MAAM,GAAG,EAAE,WAAW,KAAK,CAAC;EAChD,MAAM,UAAU,QAAQ,MAAM;CAChC;CAEA,SAAS,oBACP,MACA,uBAAO,IAAI,IAA2B,GACtC;EACA,IAAI,CAAC,QAAQ,KAAK,IAAI,IAAI,GAAG;EAC7B,KAAK,IAAI,IAAI;EACb,IAAI,KAAK,MAAM,aAAa,IAAI,KAAK,IAAI;EACzC,KAAK,MAAM,YAAY,KAAK,iBAC1B,oBAAoB,UAAU,IAAI;CACtC;CAEA,OAAO;EACL,MAAM;EACN,SAAS;EACT,eAAe,UAAU;GACvB,SAAS;GACT,QAAQ,cAAc,QAAQ,OAAO,MAAM,QAAQ,KAAK,CAAC;GACzD,SAAS,cACP,QAAQ,OAAO,MAAM,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,KAAK,OAAO;KACZ,QAAQ;MAAE,gBAAgB;MAAM,OAAO;KAAK;IAC9C,CAAC;IACD,IAAI;KACF,MAAM,cAAc,OAAO,aAAa;KACxC,IAAI,CAAC,eAAe,CAAC,yBAAyB,WAAW,GACvD,MAAM,IAAI,MAAM,uCAAuC;KACzD,MAAM,eAAe,MAAM,YAAY,OAAO,OAAO,KAAK,EAAA,CAAG,OAAO;IACtE,UAAU;KACR,MAAM,OAAO,MAAM;IACrB;GACF,EAAA,CAAG;GACH,MAAM;EACR;EACA,UAAU,IAAI;GACZ,IAAI,OAAO,WAAW;GACtB,IAAI,KAAK,YAAY,OAAO,aAAa,UACvC,MAAM,IAAI,MACR,uFACF;GAEF,OAAO;EACT;EACA,KAAK,IAAI;GACP,IAAI,OAAO,YAAY;GACvB,OAAO,mBAAmB,KAAK,UAAU,KAAK,EAAE;;;;;;EAMlD;CACF;AACF"}
1
+ {"version":3,"file":"vite.js","names":[],"sources":["../src/vite.ts"],"sourcesContent":["import { resolve, dirname } from \"node:path\";\nimport { mkdir, readFile, writeFile } from \"node:fs/promises\";\nimport {\n createServer,\n isRunnableDevEnvironment,\n normalizePath,\n type Plugin,\n type ResolvedConfig,\n type EnvironmentModuleNode,\n} from \"vite\";\nimport { generateClientContract } from \"./client-contract\";\nimport type { BrickApp } from \"@brickkit/core\";\nimport { ModuleRunner } from \"vite/module-runner\";\n\nexport interface BrickClientPluginOptions {\n /** Any module whose default export is a BrickApp; do not call listen() there. */\n entry: string;\n /** Generated browser contract, relative to the Vite root (default _brick/contract.ts). */\n output?: string;\n}\n\n/** Load a BrickApp through Vite's server module graph, including dependency HMR. */\nexport function brickClient(options: BrickClientPluginOptions): Plugin {\n const virtualId = \"virtual:brick-app\";\n const resolvedId = \"\\0\" + virtualId;\n let entry: string;\n let output: string;\n let config: ResolvedConfig;\n let buildGeneration: Promise<void> | undefined;\n let runner: ModuleRunner | undefined;\n let reload = Promise.resolve();\n const dependencies = new Set<string>();\n\n async function writeContract(value: unknown) {\n if (\n !value ||\n typeof (value as BrickApp).endpoint !== \"function\" ||\n !(value as BrickApp).definition\n ) {\n throw new Error(\n \"Brick: the entry module must default-export a BrickApp created by brick().\",\n );\n }\n const source = generateClientContract(value as BrickApp);\n const previous = await readFile(output, \"utf8\").catch((error) => {\n if (error.code !== \"ENOENT\") throw error;\n return undefined;\n });\n if (previous === source) return;\n await mkdir(dirname(output), { recursive: true });\n await writeFile(output, source);\n }\n\n function collectDependencies(\n node: EnvironmentModuleNode | undefined,\n seen = new Set<EnvironmentModuleNode>(),\n ) {\n if (!node || seen.has(node)) return;\n seen.add(node);\n if (node.file) dependencies.add(node.file);\n for (const imported of node.importedModules)\n collectDependencies(imported, seen);\n }\n\n return {\n name: \"brick:client\",\n enforce: \"pre\",\n configResolved(resolved) {\n config = resolved;\n entry = normalizePath(resolve(config.root, options.entry));\n output = normalizePath(\n resolve(config.root, options.output ?? \"_brick/contract.ts\"),\n );\n if (entry === output)\n throw new Error(\n \"Brick: contract output must not overwrite the app entry.\",\n );\n },\n async configureServer(server) {\n const environment = server.environments.ssr;\n if (!environment)\n throw new Error(\n \"Brick: client generation requires a Vite SSR environment.\",\n );\n // Frameworks such as Start own their SSR runner. Use an independent runner\n // on the same transform graph to read app metadata without changing theirs.\n runner = new ModuleRunner({\n hmr: false,\n transport: {\n invoke: (payload) => environment.hot.handleInvoke(payload),\n },\n });\n await writeContract((await runner.import(entry)).default);\n dependencies.clear();\n collectDependencies(environment.moduleGraph.getModuleById(entry));\n dependencies.add(entry);\n },\n async hotUpdate(context) {\n if (\n this.environment.name !== \"ssr\" ||\n !dependencies.has(context.file) ||\n context.file === output\n )\n return;\n if (!runner) return;\n const currentRunner = runner;\n reload = reload\n .catch(() => {})\n .then(async () => {\n for (const module of context.modules)\n this.environment.moduleGraph.invalidateModule(module);\n currentRunner.clearCache();\n await writeContract((await currentRunner.import(entry)).default);\n dependencies.clear();\n collectDependencies(\n this.environment.moduleGraph.getModuleById(entry),\n );\n dependencies.add(entry);\n });\n await reload;\n },\n async closeBundle() {\n await runner?.close();\n },\n async buildStart() {\n if (config.command !== \"build\") return;\n buildGeneration ??= (async () => {\n // Evaluate the server entry through Vite's TS/alias resolver before client compilation.\n // This loader has no app plugins, so it cannot recursively trigger generation.\n const loader = await createServer({\n configFile: false,\n root: config.root,\n mode: config.mode,\n envDir: config.envDir,\n base: config.base,\n define: config.define,\n logLevel: \"silent\",\n resolve: { alias: config.resolve.alias },\n ssr: config.ssr,\n server: { middlewareMode: true, watch: null },\n });\n try {\n const environment = loader.environments.ssr;\n if (!environment || !isRunnableDevEnvironment(environment))\n throw new Error(\"Brick: missing build-time SSR loader.\");\n await writeContract((await environment.runner.import(entry)).default);\n } finally {\n await loader.close();\n }\n })();\n await buildGeneration;\n },\n resolveId(id) {\n if (id !== virtualId) return;\n if (this.environment.config.consumer === \"client\") {\n throw new Error(\n \"Brick: virtual:brick-app is server-only; never import the backend app in the browser.\",\n );\n }\n return resolvedId;\n },\n load(id) {\n if (id !== resolvedId) return;\n return `import app from ${JSON.stringify(entry)};\nif (!app || typeof app.fetch !== \"function\" || typeof app.endpoint !== \"function\") {\n throw new Error(\"Brick: the entry module must default-export a BrickApp created by brick().\");\n}\nexport default app;\n`;\n },\n };\n}\n"],"mappings":";;;;;;;AAsBA,SAAgB,YAAY,SAA2C;CACrE,MAAM,YAAY;CAClB,MAAM,aAAa,OAAO;CAC1B,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI,SAAS,QAAQ,QAAQ;CAC7B,MAAM,+BAAe,IAAI,IAAY;CAErC,eAAe,cAAc,OAAgB;EAC3C,IACE,CAAC,SACD,OAAQ,MAAmB,aAAa,cACxC,CAAE,MAAmB,YAErB,MAAM,IAAI,MACR,4EACF;EAEF,MAAM,SAAS,uBAAuB,KAAiB;EAKvD,IAAI,MAJmB,SAAS,QAAQ,MAAM,CAAC,CAAC,OAAO,UAAU;GAC/D,IAAI,MAAM,SAAS,UAA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,YAAY,iBAAiB,MAAM;IACtD,cAAc,WAAW;IACzB,MAAM,eAAe,MAAM,cAAc,OAAO,KAAK,EAAA,CAAG,OAAO;IAC/D,aAAa,MAAM;IACnB,oBACE,KAAK,YAAY,YAAY,cAAc,KAAK,CAClD;IACA,aAAa,IAAI,KAAK;GACxB,CAAC;GACH,MAAM;EACR;EACA,MAAM,cAAc;GAClB,MAAM,QAAQ,MAAM;EACtB;EACA,MAAM,aAAa;GACjB,IAAI,OAAO,YAAY,SAAS;GAChC,qBAAqB,YAAY;IAG/B,MAAM,SAAS,MAAM,aAAa;KAChC,YAAY;KACZ,MAAM,OAAO;KACb,MAAM,OAAO;KACb,QAAQ,OAAO;KACf,MAAM,OAAO;KACb,QAAQ,OAAO;KACf,UAAU;KACV,SAAS,EAAE,OAAO,OAAO,QAAQ,MAAM;KACvC,KAAK,OAAO;KACZ,QAAQ;MAAE,gBAAgB;MAAM,OAAO;KAAK;IAC9C,CAAC;IACD,IAAI;KACF,MAAM,cAAc,OAAO,aAAa;KACxC,IAAI,CAAC,eAAe,CAAC,yBAAyB,WAAW,GACvD,MAAM,IAAI,MAAM,uCAAuC;KACzD,MAAM,eAAe,MAAM,YAAY,OAAO,OAAO,KAAK,EAAA,CAAG,OAAO;IACtE,UAAU;KACR,MAAM,OAAO,MAAM;IACrB;GACF,EAAA,CAAG;GACH,MAAM;EACR;EACA,UAAU,IAAI;GACZ,IAAI,OAAO,WAAW;GACtB,IAAI,KAAK,YAAY,OAAO,aAAa,UACvC,MAAM,IAAI,MACR,uFACF;GAEF,OAAO;EACT;EACA,KAAK,IAAI;GACP,IAAI,OAAO,YAAY;GACvB,OAAO,mBAAmB,KAAK,UAAU,KAAK,EAAE;;;;;;EAMlD;CACF;AACF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@brickkit/cli",
3
- "version": "0.3.0-beta.1",
3
+ "version": "0.3.0-beta.3",
4
4
  "description": "CLI and server engine for Brick-TS",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -49,7 +49,7 @@
49
49
  "format:check": "oxfmt --check ."
50
50
  },
51
51
  "dependencies": {
52
- "@brickkit/core": "^0.3.0-beta.1",
52
+ "@brickkit/core": "^0.3.0-beta.3",
53
53
  "@sinclair/typebox": "^0.34.0",
54
54
  "elysia": "2.0.0-beta.29"
55
55
  },
@@ -1 +0,0 @@
1
- {"version":3,"file":"compiler.d.ts","names":["_$__endpoints0.BrickApp"],"sources":["../src/endpoints.ts","../src/compiler/ir.ts","../src/compiler/runtime.ts","../src/compiler/emit.ts","../src/compiler.ts"],"mappings":";;;KAIY;;UAGK;EACf,UAAU;EACV,UAAU;EACV,WAAW;EACX,WAAW;;;UAII;EACf,QAAQ;EACR,OAAO;EACP;EACA,SAAS;EACT,SAAS;;EAET;IAAO;IAAiB,SAAS;;;EAEjC;EACA,QAAQ;EACR;EACA;;UAGe;EACf,QAAQ;;EAER;EACA,UAAU,KAAK,8BAA8B;;EAE7C,UAAU;;EAEV,WAAW;EACX;EACA;EACA;;;KA6HU,WAAW;;WAEZ;aACE,mBAAmB;aACnB;;;EAGX,SAAS,KAAK;;EAEd,iBAAiB;;;;KCxKP;UACK;WACN,QAAQ;WACR;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;aACE;aACA;;;WAGF;WACA;;UAEM;WACN;WACA;WACA;WACA;WACA,iBAAiB;WACjB,gBAAgB;WAChB;;;;KC5BC,mBAAmB,2BAA2B;KAC9C,kBACV,SAAS,mBACT,gBAAgB,oBACb;;iBAaI,WAAW,YAAY,aAAa;iBAWpC,SACP,OAAO,YAAY,oCACnB,gBACA,gBACA;iBAeO,SAAS,UAAU;;;;;;;;;;;;;;;;cAaf,iBAAe;;;;;;;EAON,aAAA;EAEL,OAAA;;;;;iBCxED,mBAAmB,OAAO;;iBA0E1B,wBACd,IAAI,SACJ;;;KC3DG,qBAAqB,UAAU,wBAAwB;;iBAWtC,qBACpB,YAAY;EAAU;IACtB,IAAI,SACJ,MAAM,oBAAiB,QAAjBA;UAqBS;WACN,IAAI;WACJ,SAAS;;UAEH;WACN,IAAI;WACJ,iBAAiB;;;iBAsBZ,wBAAwB;EACtC,UAAU;EACV;EACA;IACE;;iBA0BY,wBACd,IAAI,SACJ,UAAU,qBACV,oBAAoB,mBACnB"}
@@ -1,2 +0,0 @@
1
- import { a as loadCompiledBrickApp, c as CompiledHandler, d as RouteIR, f as RouteMethod, i as compileBrickApplication, l as HandlerFactory, n as CompiledRoute, o as emitCompiledApplication, r as bindCompiledApplication, s as emitHandlerFactory, t as CompiledApplication, u as BrickIR } from "./compiler.js";
2
- export { type BrickIR, CompiledApplication, type CompiledHandler, CompiledRoute, type HandlerFactory, type RouteIR, type RouteMethod, bindCompiledApplication, compileBrickApplication, emitCompiledApplication, emitHandlerFactory, loadCompiledBrickApp };