brustjs 0.1.64-alpha → 0.1.65-alpha
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/README.md +6 -0
- package/package.json +7 -7
- package/runtime/ai/actions.ts +271 -0
- package/runtime/ai/index.ts +90 -0
- package/runtime/ai/manifest.ts +68 -0
- package/runtime/ai/navigate.ts +157 -0
- package/runtime/ai/pages.ts +49 -0
- package/runtime/ai/refs.ts +87 -0
- package/runtime/ai/struct.ts +168 -0
- package/runtime/cli/build.ts +43 -4
- package/runtime/cli/dev.ts +6 -1
- package/runtime/cli/help.ts +8 -0
- package/runtime/cli/native-routes-emit.ts +33 -9
- package/runtime/config.ts +3 -0
- package/runtime/generator.ts +14 -0
- package/runtime/index.js +52 -52
- package/runtime/index.ts +88 -3
- package/runtime/islands/build.ts +42 -1
- package/runtime/md/emit.ts +5 -1
- package/runtime/render/inject-ai-client.ts +38 -0
- package/runtime/render/stream.ts +9 -3
- package/types/ai/manifest.d.ts +17 -0
- package/types/cli/native-routes-emit.d.ts +5 -1
- package/types/config.d.ts +2 -0
- package/types/generator.d.ts +5 -0
- package/types/index.d.ts +2 -0
- package/types/islands/build.d.ts +9 -0
- package/types/md/emit.d.ts +3 -0
- package/types/render/inject-ai-client.d.ts +6 -0
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { FlatRoute } from '../routes.ts';
|
|
2
|
+
export interface AiPageEntry {
|
|
3
|
+
path: string;
|
|
4
|
+
params: string[];
|
|
5
|
+
catchAll: boolean;
|
|
6
|
+
kind: 'react' | 'native' | 'md';
|
|
7
|
+
shellId: string;
|
|
8
|
+
title?: string;
|
|
9
|
+
description?: string;
|
|
10
|
+
}
|
|
11
|
+
export interface AiManifest {
|
|
12
|
+
version: 1;
|
|
13
|
+
pages: AiPageEntry[];
|
|
14
|
+
}
|
|
15
|
+
export declare function extractAiManifest(routes: FlatRoute[]): AiManifest;
|
|
16
|
+
export declare function writeManifest(cwd: string, manifest: AiManifest): Promise<void>;
|
|
17
|
+
export declare function readManifest(cwd: string): Promise<AiManifest | null>;
|
|
@@ -71,7 +71,11 @@ export declare function countMainTags(template: string): number;
|
|
|
71
71
|
*
|
|
72
72
|
* Exported for the md emit step (runtime/md/emit.ts), which bakes the same tag
|
|
73
73
|
* under its `withDevClient` option — md pages render Rust-side too, so without
|
|
74
|
-
* it they never auto-reload in dev.
|
|
74
|
+
* it they never auto-reload in dev.
|
|
75
|
+
*
|
|
76
|
+
* The AI runtime script is injected here as well when BRUST_AI=1. The tag is
|
|
77
|
+
* document-only: the compiler emits a head anchor for full documents, while
|
|
78
|
+
* fragment templates (no head) are left unchanged. */
|
|
75
79
|
export declare function injectDevClientIntoTemplate(template: string): string;
|
|
76
80
|
/** Bake the directive runtime loader into a native template iff it uses any
|
|
77
81
|
* x-data directive. Idempotent. Wrapped in {% raw %} for symmetry with the islands
|
package/types/config.d.ts
CHANGED
|
@@ -10,6 +10,8 @@ export interface BrustConfig {
|
|
|
10
10
|
cacheMaxEntries?: number;
|
|
11
11
|
/** L2 page-cache capacity (entries). Undefined → Rust default of 1000. */
|
|
12
12
|
cachePageMaxEntries?: number;
|
|
13
|
+
/** AI runtime toggle from BRUST_AI. Dev mode enables it separately. */
|
|
14
|
+
ai?: boolean;
|
|
13
15
|
/** R9 cross-process cache invalidation: redis/dragonfly URL. Absent →
|
|
14
16
|
* feature disabled (current single-process behavior). */
|
|
15
17
|
cacheSyncUrl?: string;
|
package/types/generator.d.ts
CHANGED
|
@@ -4,6 +4,11 @@ export interface GeneratorStrings {
|
|
|
4
4
|
/** X-Powered-By value, e.g. `brust/0.1.48-alpha` */
|
|
5
5
|
header: string;
|
|
6
6
|
}
|
|
7
|
+
/** Full browser entry tag for the AI runtime chunk. */
|
|
8
|
+
export declare function aiScriptTag(): string;
|
|
9
|
+
/** Insert the AI runtime tag immediately before the first `</head>`.
|
|
10
|
+
* Document-only: fragment templates with no head are left unchanged. */
|
|
11
|
+
export declare function injectAiScriptIntoTemplate(template: string): string;
|
|
7
12
|
/** Build the resolved strings. Version comes from the brustjs package.json
|
|
8
13
|
* (readVersion never throws — "unknown" degrades to name-only, never a crash).
|
|
9
14
|
* The version is sanitized to attr/header-safe bytes; semver chars only. */
|
package/types/index.d.ts
CHANGED
|
@@ -183,6 +183,8 @@ export declare const brust: {
|
|
|
183
183
|
/** Optional global CORS policy — see {@link CorsOptions}. Threaded to
|
|
184
184
|
* serve() like `actionPrefix`. */
|
|
185
185
|
cors?: CorsOptions;
|
|
186
|
+
/** AI runtime toggle. Dev mode enables it automatically. */
|
|
187
|
+
ai?: boolean;
|
|
186
188
|
/** Overrides merged into the underlying `serve()` call (main thread). */
|
|
187
189
|
serve?: Partial<Omit<ServeOptions, "entry" | "actions" | "mcp">>;
|
|
188
190
|
/** Per-worker SAB size in bytes. Default 256 KB. */
|
package/types/islands/build.d.ts
CHANGED
|
@@ -18,6 +18,14 @@ export interface BuildIslandsOptions {
|
|
|
18
18
|
* on the output filename (X.module.css + X.tsx → both X.js). */
|
|
19
19
|
plugins?: BunPlugin[];
|
|
20
20
|
}
|
|
21
|
+
export interface BuildAiRuntimeOptions {
|
|
22
|
+
/** Override the output directory. Default: `<cwd>/.brust/islands`. */
|
|
23
|
+
outDir?: string;
|
|
24
|
+
/** Override the browser entry file. Default: `runtime/ai/index.ts`. */
|
|
25
|
+
entryFile?: string;
|
|
26
|
+
/** Build plugins passed straight to `Bun.build` for the AI runtime chunk. */
|
|
27
|
+
plugins?: BunPlugin[];
|
|
28
|
+
}
|
|
21
29
|
/** Scan a routes entry file for `<Island component={X} />` usage and derive the
|
|
22
30
|
* island chunk list (componentName → absolute source path). Replaces the old
|
|
23
31
|
* static config-file lookup — the chunk set is derived from source.
|
|
@@ -46,4 +54,5 @@ export declare function scanIslandChunks(routesEntryFile: string, extraIslands?:
|
|
|
46
54
|
/** Build the runtime chunks + all island chunks + bootstrap. Returns the
|
|
47
55
|
* absolute output directory; caller passes it to `brust.configureIslandsDir`. */
|
|
48
56
|
export declare function buildIslands(islands: Map<string, string>, options?: BuildIslandsOptions): Promise<IslandsBuildResult>;
|
|
57
|
+
export declare function buildAiRuntime(options?: BuildAiRuntimeOptions): Promise<string | null>;
|
|
49
58
|
export declare function buildOne(entrypoints: string[], outdir: string, naming: string, external: string[], plugins?: BunPlugin[]): Promise<void>;
|
package/types/md/emit.d.ts
CHANGED
|
@@ -27,6 +27,9 @@ export interface MdEmitOpts {
|
|
|
27
27
|
* BRUST_DEV injection — md pages render Rust-side and never pass through the
|
|
28
28
|
* React renderer's dev-client injection). */
|
|
29
29
|
withDevClient?: boolean;
|
|
30
|
+
/** Bake the AI runtime tag into document-style md templates. Fragments skip
|
|
31
|
+
* the injection entirely. */
|
|
32
|
+
aiEnabled?: boolean;
|
|
30
33
|
/** What to do when a route's md file no longer exists on disk (deleted after
|
|
31
34
|
* the route table was built). emitMdTemplates serves BOTH `brust build` and
|
|
32
35
|
* the dev re-emit, and the two must diverge here:
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/** Splice `snippet` into `body` immediately before the first `</head>`
|
|
2
|
+
* (case-insensitive on the four ASCII letters only). Returns the original body
|
|
3
|
+
* untouched if `snippet` is null/empty or if `</head>` is absent.
|
|
4
|
+
*
|
|
5
|
+
* AI pages are document-only: fragment templates skip this injection entirely. */
|
|
6
|
+
export declare function injectAiClient(body: Uint8Array, snippet: string | null): Uint8Array;
|