brustjs 0.1.50-alpha → 0.1.52-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/package.json +39 -15
- package/runtime/cache-sync.ts +291 -0
- package/runtime/cache.ts +4 -0
- package/runtime/cli/dev.ts +7 -0
- package/runtime/cli/native-routes-emit.ts +147 -1
- package/runtime/config.ts +42 -0
- package/runtime/index.d.ts +63 -0
- package/runtime/index.js +57 -52
- package/runtime/index.ts +108 -9
- package/runtime/native/runtime.ts +220 -7
- package/runtime/render/fragment.ts +87 -0
- package/runtime/routes.ts +225 -48
- package/runtime/templates.ts +47 -0
- package/runtime/treaty.ts +24 -1
- package/types/action-error.d.ts +18 -0
- package/types/cache-sync.d.ts +42 -0
- package/types/cache.d.ts +20 -0
- package/types/cli/help.d.ts +28 -0
- package/types/cli/jinja-staleness.d.ts +14 -0
- package/types/cli/native-routes-emit.d.ts +217 -0
- package/types/cli/new.d.ts +30 -0
- package/types/cli/templates.d.ts +39 -0
- package/types/client/index.d.ts +14 -0
- package/types/config.d.ts +42 -0
- package/types/cookies.d.ts +25 -0
- package/types/create.d.ts +1 -0
- package/types/css/build.d.ts +11 -0
- package/types/css/component-build.d.ts +17 -0
- package/types/css/component-loader.d.ts +8 -0
- package/types/css/manifest.d.ts +21 -0
- package/types/css/process-modules.d.ts +31 -0
- package/types/css/route-deps.d.ts +20 -0
- package/types/css/scan-imports.d.ts +13 -0
- package/types/css.d.ts +16 -0
- package/types/define-actions.d.ts +133 -0
- package/types/dev/client.d.ts +8 -0
- package/types/dev/coordinator.d.ts +33 -0
- package/types/dev/inject.d.ts +6 -0
- package/types/dev/jinja-reload.d.ts +7 -0
- package/types/dev/tui.d.ts +35 -0
- package/types/dev/watcher.d.ts +34 -0
- package/types/dev/worker-registry.d.ts +17 -0
- package/types/dev/ws-channel.d.ts +39 -0
- package/types/generator.d.ts +23 -0
- package/types/index.d.ts +222 -0
- package/types/islands/brust-page.d.ts +74 -0
- package/types/islands/build.d.ts +49 -0
- package/types/islands/chunk-id.d.ts +10 -0
- package/types/islands/importmap.d.ts +2 -0
- package/types/islands/island.d.ts +65 -0
- package/types/islands/isr-jsx.d.ts +31 -0
- package/types/islands/native-render.d.ts +89 -0
- package/types/loader-cache.d.ts +18 -0
- package/types/mcp/extractor.d.ts +14 -0
- package/types/mcp/manifest.d.ts +23 -0
- package/types/mcp/schema.d.ts +19 -0
- package/types/mcp/server.d.ts +15 -0
- package/types/md/emit.d.ts +72 -0
- package/types/md/render.d.ts +80 -0
- package/types/md/routes.d.ts +119 -0
- package/types/md/scan.d.ts +34 -0
- package/types/md/slug.d.ts +1 -0
- package/types/native/build.d.ts +30 -0
- package/types/native/index.d.ts +2 -0
- package/types/native/runtime.d.ts +52 -0
- package/types/navigation/active-nav.d.ts +2 -0
- package/types/navigation/index.d.ts +5 -0
- package/types/navigation/navigate.d.ts +14 -0
- package/types/navigation/react.d.ts +15 -0
- package/types/navigation/store.d.ts +44 -0
- package/types/render/fragment.d.ts +20 -0
- package/types/render/inject-action-prefix.d.ts +9 -0
- package/types/render/inject-css-link.d.ts +8 -0
- package/types/render/inject-dev-client.d.ts +6 -0
- package/types/render/inject-generator.d.ts +7 -0
- package/types/render/inject-store.d.ts +9 -0
- package/types/render/stream.d.ts +45 -0
- package/types/request-context.d.ts +16 -0
- package/types/routes.d.ts +506 -0
- package/types/sse/handler.d.ts +22 -0
- package/types/standard-schema.d.ts +31 -0
- package/types/store/define-store.d.ts +31 -0
- package/types/store/index.d.ts +5 -0
- package/types/store/react.d.ts +2 -0
- package/types/store/serialize.d.ts +5 -0
- package/types/store/server-context.d.ts +4 -0
- package/types/store/signal.d.ts +18 -0
- package/types/templates.d.ts +18 -0
- package/types/treaty.d.ts +70 -0
- package/types/ws/handler.d.ts +26 -0
package/runtime/index.d.ts
CHANGED
|
@@ -75,6 +75,38 @@ export interface NapiCompiledJsx {
|
|
|
75
75
|
warnings: Array<string>
|
|
76
76
|
}
|
|
77
77
|
|
|
78
|
+
/**
|
|
79
|
+
* Global CORS policy (maps onto `brust_core::CorsConfig`). napi-rs camelCases
|
|
80
|
+
* the fields, so the TS runtime sends `origins`, `methods`, `headers`,
|
|
81
|
+
* `exposeHeaders`, `credentials`, `maxAgeSeconds`.
|
|
82
|
+
*/
|
|
83
|
+
export interface NapiCorsOptions {
|
|
84
|
+
/**
|
|
85
|
+
* Allowed origins (exact scheme+host+port match). `['*']` — or any list
|
|
86
|
+
* CONTAINING `'*'` — allows every origin (echoed as the literal `*`).
|
|
87
|
+
*/
|
|
88
|
+
origins: Array<string>
|
|
89
|
+
/**
|
|
90
|
+
* Preflight `Access-Control-Allow-Methods`. Omit for the default
|
|
91
|
+
* `GET,POST,PUT,PATCH,DELETE,OPTIONS`.
|
|
92
|
+
*/
|
|
93
|
+
methods?: Array<string>
|
|
94
|
+
/**
|
|
95
|
+
* Preflight `Access-Control-Allow-Headers`. Omit to echo the request's
|
|
96
|
+
* `Access-Control-Request-Headers`.
|
|
97
|
+
*/
|
|
98
|
+
headers?: Array<string>
|
|
99
|
+
/** `Access-Control-Expose-Headers` on actual responses. Omit for none. */
|
|
100
|
+
exposeHeaders?: Array<string>
|
|
101
|
+
/**
|
|
102
|
+
* Emit `Access-Control-Allow-Credentials: true`. INVALID with a wildcard
|
|
103
|
+
* origin — serve() throws at boot.
|
|
104
|
+
*/
|
|
105
|
+
credentials?: boolean
|
|
106
|
+
/** Preflight `Access-Control-Max-Age` seconds. Omit for 600. */
|
|
107
|
+
maxAgeSeconds?: number
|
|
108
|
+
}
|
|
109
|
+
|
|
78
110
|
/**
|
|
79
111
|
* Dev-mode: broadcast one JSON control frame (building / reload / css-update /
|
|
80
112
|
* error / ok) to every connected `/_brust/dev` client. Called from the main
|
|
@@ -87,6 +119,12 @@ export interface NapiCompiledJsx {
|
|
|
87
119
|
*/
|
|
88
120
|
export declare function napiDevBroadcast(json: string): void
|
|
89
121
|
|
|
122
|
+
/** R1 — true when `name` resolves in either tier (dynamic first, then boot). */
|
|
123
|
+
export declare function napiHasTemplate(name: string): boolean
|
|
124
|
+
|
|
125
|
+
/** R1 — names of runtime-registered templates (dynamic tier only). */
|
|
126
|
+
export declare function napiListDynamicTemplates(): Array<string>
|
|
127
|
+
|
|
90
128
|
/**
|
|
91
129
|
* Sub-project J — boot-time listing of registered minijinja templates.
|
|
92
130
|
* JS dispatcher uses this to validate every `native: true` route's
|
|
@@ -110,6 +148,13 @@ export declare function napiLoadJinjaTemplates(dir: string): Array<string>
|
|
|
110
148
|
*/
|
|
111
149
|
export declare function napiRegisterSsePaths(paths: Array<string>): NapiResult<undefined>
|
|
112
150
|
|
|
151
|
+
/**
|
|
152
|
+
* R1 dynamic template registry — register (or replace) a runtime template.
|
|
153
|
+
* Errors (name validation / jinja syntax) surface as a thrown JS Error with
|
|
154
|
+
* the minijinja message (includes line info).
|
|
155
|
+
*/
|
|
156
|
+
export declare function napiRegisterTemplate(name: string, source: string): NapiResult<undefined>
|
|
157
|
+
|
|
113
158
|
/**
|
|
114
159
|
* Boot-time registry of literal WS paths. Mirror of napi_register_sse_paths.
|
|
115
160
|
* Call once before begin_serve; exact-match only (parameterized routes are a
|
|
@@ -117,6 +162,12 @@ export declare function napiRegisterSsePaths(paths: Array<string>): NapiResult<u
|
|
|
117
162
|
*/
|
|
118
163
|
export declare function napiRegisterWsPaths(paths: Array<string>): NapiResult<undefined>
|
|
119
164
|
|
|
165
|
+
/**
|
|
166
|
+
* R1 — remove a runtime-registered template. Returns whether it existed.
|
|
167
|
+
* Boot-tier (directory-loaded) templates are not removable.
|
|
168
|
+
*/
|
|
169
|
+
export declare function napiRemoveTemplate(name: string): boolean
|
|
170
|
+
|
|
120
171
|
/**
|
|
121
172
|
* Worker-driven render chunk delivery. Worker calls this once per chunk
|
|
122
173
|
* it wants to emit; final call uses `len = 0` to close the channel.
|
|
@@ -177,6 +228,13 @@ export declare function napiRenderChunkFinal(workerId: number, slot: number, len
|
|
|
177
228
|
*/
|
|
178
229
|
export declare function napiRenderJinja(workerId: number, slot: number, dataLen: number, templateName: string, status?: number | undefined | null): NapiResult<number>
|
|
179
230
|
|
|
231
|
+
/**
|
|
232
|
+
* R1 — render a template (either tier) to an HTML string. NOT the request
|
|
233
|
+
* hot path (allocates a JS string per call; the fast lane is
|
|
234
|
+
* napi_render_jinja via SAB) — intended for handlers/loaders/tooling.
|
|
235
|
+
*/
|
|
236
|
+
export declare function napiRenderTemplate(name: string, dataJson: string): NapiResult<string>
|
|
237
|
+
|
|
180
238
|
/**
|
|
181
239
|
* Drop the connection's sender, which signals the per-conn task to exit
|
|
182
240
|
* and close the TCP socket. Idempotent — a missing conn is a no-op.
|
|
@@ -300,6 +358,11 @@ export interface ServeOptions {
|
|
|
300
358
|
* configured (cert + key present). An unrecognized value is rejected.
|
|
301
359
|
*/
|
|
302
360
|
tlsMinVersion?: string
|
|
361
|
+
/**
|
|
362
|
+
* Optional global CORS policy. Omit to keep CORS disabled (byte-identical
|
|
363
|
+
* default behavior: no `Access-Control-*` headers, OPTIONS still 405).
|
|
364
|
+
*/
|
|
365
|
+
cors?: NapiCorsOptions
|
|
303
366
|
}
|
|
304
367
|
|
|
305
368
|
/**
|
package/runtime/index.js
CHANGED
|
@@ -77,8 +77,8 @@ function requireNative() {
|
|
|
77
77
|
try {
|
|
78
78
|
const binding = require('brustjs-android-arm64')
|
|
79
79
|
const bindingPackageVersion = require('brustjs-android-arm64/package.json').version
|
|
80
|
-
if (bindingPackageVersion !== '0.1.
|
|
81
|
-
throw new Error(`Native binding package version mismatch, expected 0.1.
|
|
80
|
+
if (bindingPackageVersion !== '0.1.52-alpha' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
81
|
+
throw new Error(`Native binding package version mismatch, expected 0.1.52-alpha but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
82
82
|
}
|
|
83
83
|
return binding
|
|
84
84
|
} catch (e) {
|
|
@@ -93,8 +93,8 @@ function requireNative() {
|
|
|
93
93
|
try {
|
|
94
94
|
const binding = require('brustjs-android-arm-eabi')
|
|
95
95
|
const bindingPackageVersion = require('brustjs-android-arm-eabi/package.json').version
|
|
96
|
-
if (bindingPackageVersion !== '0.1.
|
|
97
|
-
throw new Error(`Native binding package version mismatch, expected 0.1.
|
|
96
|
+
if (bindingPackageVersion !== '0.1.52-alpha' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
97
|
+
throw new Error(`Native binding package version mismatch, expected 0.1.52-alpha but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
98
98
|
}
|
|
99
99
|
return binding
|
|
100
100
|
} catch (e) {
|
|
@@ -114,8 +114,8 @@ function requireNative() {
|
|
|
114
114
|
try {
|
|
115
115
|
const binding = require('brustjs-win32-x64-gnu')
|
|
116
116
|
const bindingPackageVersion = require('brustjs-win32-x64-gnu/package.json').version
|
|
117
|
-
if (bindingPackageVersion !== '0.1.
|
|
118
|
-
throw new Error(`Native binding package version mismatch, expected 0.1.
|
|
117
|
+
if (bindingPackageVersion !== '0.1.52-alpha' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
118
|
+
throw new Error(`Native binding package version mismatch, expected 0.1.52-alpha but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
119
119
|
}
|
|
120
120
|
return binding
|
|
121
121
|
} catch (e) {
|
|
@@ -130,8 +130,8 @@ function requireNative() {
|
|
|
130
130
|
try {
|
|
131
131
|
const binding = require('brustjs-win32-x64-msvc')
|
|
132
132
|
const bindingPackageVersion = require('brustjs-win32-x64-msvc/package.json').version
|
|
133
|
-
if (bindingPackageVersion !== '0.1.
|
|
134
|
-
throw new Error(`Native binding package version mismatch, expected 0.1.
|
|
133
|
+
if (bindingPackageVersion !== '0.1.52-alpha' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
134
|
+
throw new Error(`Native binding package version mismatch, expected 0.1.52-alpha but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
135
135
|
}
|
|
136
136
|
return binding
|
|
137
137
|
} catch (e) {
|
|
@@ -147,8 +147,8 @@ function requireNative() {
|
|
|
147
147
|
try {
|
|
148
148
|
const binding = require('brustjs-win32-ia32-msvc')
|
|
149
149
|
const bindingPackageVersion = require('brustjs-win32-ia32-msvc/package.json').version
|
|
150
|
-
if (bindingPackageVersion !== '0.1.
|
|
151
|
-
throw new Error(`Native binding package version mismatch, expected 0.1.
|
|
150
|
+
if (bindingPackageVersion !== '0.1.52-alpha' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
151
|
+
throw new Error(`Native binding package version mismatch, expected 0.1.52-alpha but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
152
152
|
}
|
|
153
153
|
return binding
|
|
154
154
|
} catch (e) {
|
|
@@ -163,8 +163,8 @@ function requireNative() {
|
|
|
163
163
|
try {
|
|
164
164
|
const binding = require('brustjs-win32-arm64-msvc')
|
|
165
165
|
const bindingPackageVersion = require('brustjs-win32-arm64-msvc/package.json').version
|
|
166
|
-
if (bindingPackageVersion !== '0.1.
|
|
167
|
-
throw new Error(`Native binding package version mismatch, expected 0.1.
|
|
166
|
+
if (bindingPackageVersion !== '0.1.52-alpha' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
167
|
+
throw new Error(`Native binding package version mismatch, expected 0.1.52-alpha but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
168
168
|
}
|
|
169
169
|
return binding
|
|
170
170
|
} catch (e) {
|
|
@@ -182,8 +182,8 @@ function requireNative() {
|
|
|
182
182
|
try {
|
|
183
183
|
const binding = require('brustjs-darwin-universal')
|
|
184
184
|
const bindingPackageVersion = require('brustjs-darwin-universal/package.json').version
|
|
185
|
-
if (bindingPackageVersion !== '0.1.
|
|
186
|
-
throw new Error(`Native binding package version mismatch, expected 0.1.
|
|
185
|
+
if (bindingPackageVersion !== '0.1.52-alpha' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
186
|
+
throw new Error(`Native binding package version mismatch, expected 0.1.52-alpha but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
187
187
|
}
|
|
188
188
|
return binding
|
|
189
189
|
} catch (e) {
|
|
@@ -198,8 +198,8 @@ function requireNative() {
|
|
|
198
198
|
try {
|
|
199
199
|
const binding = require('brustjs-darwin-x64')
|
|
200
200
|
const bindingPackageVersion = require('brustjs-darwin-x64/package.json').version
|
|
201
|
-
if (bindingPackageVersion !== '0.1.
|
|
202
|
-
throw new Error(`Native binding package version mismatch, expected 0.1.
|
|
201
|
+
if (bindingPackageVersion !== '0.1.52-alpha' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
202
|
+
throw new Error(`Native binding package version mismatch, expected 0.1.52-alpha but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
203
203
|
}
|
|
204
204
|
return binding
|
|
205
205
|
} catch (e) {
|
|
@@ -214,8 +214,8 @@ function requireNative() {
|
|
|
214
214
|
try {
|
|
215
215
|
const binding = require('brustjs-darwin-arm64')
|
|
216
216
|
const bindingPackageVersion = require('brustjs-darwin-arm64/package.json').version
|
|
217
|
-
if (bindingPackageVersion !== '0.1.
|
|
218
|
-
throw new Error(`Native binding package version mismatch, expected 0.1.
|
|
217
|
+
if (bindingPackageVersion !== '0.1.52-alpha' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
218
|
+
throw new Error(`Native binding package version mismatch, expected 0.1.52-alpha but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
219
219
|
}
|
|
220
220
|
return binding
|
|
221
221
|
} catch (e) {
|
|
@@ -234,8 +234,8 @@ function requireNative() {
|
|
|
234
234
|
try {
|
|
235
235
|
const binding = require('brustjs-freebsd-x64')
|
|
236
236
|
const bindingPackageVersion = require('brustjs-freebsd-x64/package.json').version
|
|
237
|
-
if (bindingPackageVersion !== '0.1.
|
|
238
|
-
throw new Error(`Native binding package version mismatch, expected 0.1.
|
|
237
|
+
if (bindingPackageVersion !== '0.1.52-alpha' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
238
|
+
throw new Error(`Native binding package version mismatch, expected 0.1.52-alpha but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
239
239
|
}
|
|
240
240
|
return binding
|
|
241
241
|
} catch (e) {
|
|
@@ -250,8 +250,8 @@ function requireNative() {
|
|
|
250
250
|
try {
|
|
251
251
|
const binding = require('brustjs-freebsd-arm64')
|
|
252
252
|
const bindingPackageVersion = require('brustjs-freebsd-arm64/package.json').version
|
|
253
|
-
if (bindingPackageVersion !== '0.1.
|
|
254
|
-
throw new Error(`Native binding package version mismatch, expected 0.1.
|
|
253
|
+
if (bindingPackageVersion !== '0.1.52-alpha' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
254
|
+
throw new Error(`Native binding package version mismatch, expected 0.1.52-alpha but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
255
255
|
}
|
|
256
256
|
return binding
|
|
257
257
|
} catch (e) {
|
|
@@ -271,8 +271,8 @@ function requireNative() {
|
|
|
271
271
|
try {
|
|
272
272
|
const binding = require('brustjs-linux-x64-musl')
|
|
273
273
|
const bindingPackageVersion = require('brustjs-linux-x64-musl/package.json').version
|
|
274
|
-
if (bindingPackageVersion !== '0.1.
|
|
275
|
-
throw new Error(`Native binding package version mismatch, expected 0.1.
|
|
274
|
+
if (bindingPackageVersion !== '0.1.52-alpha' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
275
|
+
throw new Error(`Native binding package version mismatch, expected 0.1.52-alpha but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
276
276
|
}
|
|
277
277
|
return binding
|
|
278
278
|
} catch (e) {
|
|
@@ -287,8 +287,8 @@ function requireNative() {
|
|
|
287
287
|
try {
|
|
288
288
|
const binding = require('brustjs-linux-x64-gnu')
|
|
289
289
|
const bindingPackageVersion = require('brustjs-linux-x64-gnu/package.json').version
|
|
290
|
-
if (bindingPackageVersion !== '0.1.
|
|
291
|
-
throw new Error(`Native binding package version mismatch, expected 0.1.
|
|
290
|
+
if (bindingPackageVersion !== '0.1.52-alpha' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
291
|
+
throw new Error(`Native binding package version mismatch, expected 0.1.52-alpha but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
292
292
|
}
|
|
293
293
|
return binding
|
|
294
294
|
} catch (e) {
|
|
@@ -305,8 +305,8 @@ function requireNative() {
|
|
|
305
305
|
try {
|
|
306
306
|
const binding = require('brustjs-linux-arm64-musl')
|
|
307
307
|
const bindingPackageVersion = require('brustjs-linux-arm64-musl/package.json').version
|
|
308
|
-
if (bindingPackageVersion !== '0.1.
|
|
309
|
-
throw new Error(`Native binding package version mismatch, expected 0.1.
|
|
308
|
+
if (bindingPackageVersion !== '0.1.52-alpha' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
309
|
+
throw new Error(`Native binding package version mismatch, expected 0.1.52-alpha but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
310
310
|
}
|
|
311
311
|
return binding
|
|
312
312
|
} catch (e) {
|
|
@@ -321,8 +321,8 @@ function requireNative() {
|
|
|
321
321
|
try {
|
|
322
322
|
const binding = require('brustjs-linux-arm64-gnu')
|
|
323
323
|
const bindingPackageVersion = require('brustjs-linux-arm64-gnu/package.json').version
|
|
324
|
-
if (bindingPackageVersion !== '0.1.
|
|
325
|
-
throw new Error(`Native binding package version mismatch, expected 0.1.
|
|
324
|
+
if (bindingPackageVersion !== '0.1.52-alpha' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
325
|
+
throw new Error(`Native binding package version mismatch, expected 0.1.52-alpha but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
326
326
|
}
|
|
327
327
|
return binding
|
|
328
328
|
} catch (e) {
|
|
@@ -339,8 +339,8 @@ function requireNative() {
|
|
|
339
339
|
try {
|
|
340
340
|
const binding = require('brustjs-linux-arm-musleabihf')
|
|
341
341
|
const bindingPackageVersion = require('brustjs-linux-arm-musleabihf/package.json').version
|
|
342
|
-
if (bindingPackageVersion !== '0.1.
|
|
343
|
-
throw new Error(`Native binding package version mismatch, expected 0.1.
|
|
342
|
+
if (bindingPackageVersion !== '0.1.52-alpha' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
343
|
+
throw new Error(`Native binding package version mismatch, expected 0.1.52-alpha but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
344
344
|
}
|
|
345
345
|
return binding
|
|
346
346
|
} catch (e) {
|
|
@@ -355,8 +355,8 @@ function requireNative() {
|
|
|
355
355
|
try {
|
|
356
356
|
const binding = require('brustjs-linux-arm-gnueabihf')
|
|
357
357
|
const bindingPackageVersion = require('brustjs-linux-arm-gnueabihf/package.json').version
|
|
358
|
-
if (bindingPackageVersion !== '0.1.
|
|
359
|
-
throw new Error(`Native binding package version mismatch, expected 0.1.
|
|
358
|
+
if (bindingPackageVersion !== '0.1.52-alpha' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
359
|
+
throw new Error(`Native binding package version mismatch, expected 0.1.52-alpha but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
360
360
|
}
|
|
361
361
|
return binding
|
|
362
362
|
} catch (e) {
|
|
@@ -373,8 +373,8 @@ function requireNative() {
|
|
|
373
373
|
try {
|
|
374
374
|
const binding = require('brustjs-linux-loong64-musl')
|
|
375
375
|
const bindingPackageVersion = require('brustjs-linux-loong64-musl/package.json').version
|
|
376
|
-
if (bindingPackageVersion !== '0.1.
|
|
377
|
-
throw new Error(`Native binding package version mismatch, expected 0.1.
|
|
376
|
+
if (bindingPackageVersion !== '0.1.52-alpha' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
377
|
+
throw new Error(`Native binding package version mismatch, expected 0.1.52-alpha but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
378
378
|
}
|
|
379
379
|
return binding
|
|
380
380
|
} catch (e) {
|
|
@@ -389,8 +389,8 @@ function requireNative() {
|
|
|
389
389
|
try {
|
|
390
390
|
const binding = require('brustjs-linux-loong64-gnu')
|
|
391
391
|
const bindingPackageVersion = require('brustjs-linux-loong64-gnu/package.json').version
|
|
392
|
-
if (bindingPackageVersion !== '0.1.
|
|
393
|
-
throw new Error(`Native binding package version mismatch, expected 0.1.
|
|
392
|
+
if (bindingPackageVersion !== '0.1.52-alpha' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
393
|
+
throw new Error(`Native binding package version mismatch, expected 0.1.52-alpha but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
394
394
|
}
|
|
395
395
|
return binding
|
|
396
396
|
} catch (e) {
|
|
@@ -407,8 +407,8 @@ function requireNative() {
|
|
|
407
407
|
try {
|
|
408
408
|
const binding = require('brustjs-linux-riscv64-musl')
|
|
409
409
|
const bindingPackageVersion = require('brustjs-linux-riscv64-musl/package.json').version
|
|
410
|
-
if (bindingPackageVersion !== '0.1.
|
|
411
|
-
throw new Error(`Native binding package version mismatch, expected 0.1.
|
|
410
|
+
if (bindingPackageVersion !== '0.1.52-alpha' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
411
|
+
throw new Error(`Native binding package version mismatch, expected 0.1.52-alpha but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
412
412
|
}
|
|
413
413
|
return binding
|
|
414
414
|
} catch (e) {
|
|
@@ -423,8 +423,8 @@ function requireNative() {
|
|
|
423
423
|
try {
|
|
424
424
|
const binding = require('brustjs-linux-riscv64-gnu')
|
|
425
425
|
const bindingPackageVersion = require('brustjs-linux-riscv64-gnu/package.json').version
|
|
426
|
-
if (bindingPackageVersion !== '0.1.
|
|
427
|
-
throw new Error(`Native binding package version mismatch, expected 0.1.
|
|
426
|
+
if (bindingPackageVersion !== '0.1.52-alpha' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
427
|
+
throw new Error(`Native binding package version mismatch, expected 0.1.52-alpha but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
428
428
|
}
|
|
429
429
|
return binding
|
|
430
430
|
} catch (e) {
|
|
@@ -440,8 +440,8 @@ function requireNative() {
|
|
|
440
440
|
try {
|
|
441
441
|
const binding = require('brustjs-linux-ppc64-gnu')
|
|
442
442
|
const bindingPackageVersion = require('brustjs-linux-ppc64-gnu/package.json').version
|
|
443
|
-
if (bindingPackageVersion !== '0.1.
|
|
444
|
-
throw new Error(`Native binding package version mismatch, expected 0.1.
|
|
443
|
+
if (bindingPackageVersion !== '0.1.52-alpha' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
444
|
+
throw new Error(`Native binding package version mismatch, expected 0.1.52-alpha but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
445
445
|
}
|
|
446
446
|
return binding
|
|
447
447
|
} catch (e) {
|
|
@@ -456,8 +456,8 @@ function requireNative() {
|
|
|
456
456
|
try {
|
|
457
457
|
const binding = require('brustjs-linux-s390x-gnu')
|
|
458
458
|
const bindingPackageVersion = require('brustjs-linux-s390x-gnu/package.json').version
|
|
459
|
-
if (bindingPackageVersion !== '0.1.
|
|
460
|
-
throw new Error(`Native binding package version mismatch, expected 0.1.
|
|
459
|
+
if (bindingPackageVersion !== '0.1.52-alpha' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
460
|
+
throw new Error(`Native binding package version mismatch, expected 0.1.52-alpha but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
461
461
|
}
|
|
462
462
|
return binding
|
|
463
463
|
} catch (e) {
|
|
@@ -476,8 +476,8 @@ function requireNative() {
|
|
|
476
476
|
try {
|
|
477
477
|
const binding = require('brustjs-openharmony-arm64')
|
|
478
478
|
const bindingPackageVersion = require('brustjs-openharmony-arm64/package.json').version
|
|
479
|
-
if (bindingPackageVersion !== '0.1.
|
|
480
|
-
throw new Error(`Native binding package version mismatch, expected 0.1.
|
|
479
|
+
if (bindingPackageVersion !== '0.1.52-alpha' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
480
|
+
throw new Error(`Native binding package version mismatch, expected 0.1.52-alpha but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
481
481
|
}
|
|
482
482
|
return binding
|
|
483
483
|
} catch (e) {
|
|
@@ -492,8 +492,8 @@ function requireNative() {
|
|
|
492
492
|
try {
|
|
493
493
|
const binding = require('brustjs-openharmony-x64')
|
|
494
494
|
const bindingPackageVersion = require('brustjs-openharmony-x64/package.json').version
|
|
495
|
-
if (bindingPackageVersion !== '0.1.
|
|
496
|
-
throw new Error(`Native binding package version mismatch, expected 0.1.
|
|
495
|
+
if (bindingPackageVersion !== '0.1.52-alpha' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
496
|
+
throw new Error(`Native binding package version mismatch, expected 0.1.52-alpha but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
497
497
|
}
|
|
498
498
|
return binding
|
|
499
499
|
} catch (e) {
|
|
@@ -508,8 +508,8 @@ function requireNative() {
|
|
|
508
508
|
try {
|
|
509
509
|
const binding = require('brustjs-openharmony-arm')
|
|
510
510
|
const bindingPackageVersion = require('brustjs-openharmony-arm/package.json').version
|
|
511
|
-
if (bindingPackageVersion !== '0.1.
|
|
512
|
-
throw new Error(`Native binding package version mismatch, expected 0.1.
|
|
511
|
+
if (bindingPackageVersion !== '0.1.52-alpha' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
512
|
+
throw new Error(`Native binding package version mismatch, expected 0.1.52-alpha but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
513
513
|
}
|
|
514
514
|
return binding
|
|
515
515
|
} catch (e) {
|
|
@@ -590,13 +590,18 @@ module.exports.islandCacheInvalidate = nativeBinding.islandCacheInvalidate
|
|
|
590
590
|
module.exports.islandCacheSet = nativeBinding.islandCacheSet
|
|
591
591
|
module.exports.isWorker = nativeBinding.isWorker
|
|
592
592
|
module.exports.napiDevBroadcast = nativeBinding.napiDevBroadcast
|
|
593
|
+
module.exports.napiHasTemplate = nativeBinding.napiHasTemplate
|
|
594
|
+
module.exports.napiListDynamicTemplates = nativeBinding.napiListDynamicTemplates
|
|
593
595
|
module.exports.napiListNativeTemplates = nativeBinding.napiListNativeTemplates
|
|
594
596
|
module.exports.napiLoadJinjaTemplates = nativeBinding.napiLoadJinjaTemplates
|
|
595
597
|
module.exports.napiRegisterSsePaths = nativeBinding.napiRegisterSsePaths
|
|
598
|
+
module.exports.napiRegisterTemplate = nativeBinding.napiRegisterTemplate
|
|
596
599
|
module.exports.napiRegisterWsPaths = nativeBinding.napiRegisterWsPaths
|
|
600
|
+
module.exports.napiRemoveTemplate = nativeBinding.napiRemoveTemplate
|
|
597
601
|
module.exports.napiRenderChunk = nativeBinding.napiRenderChunk
|
|
598
602
|
module.exports.napiRenderChunkFinal = nativeBinding.napiRenderChunkFinal
|
|
599
603
|
module.exports.napiRenderJinja = nativeBinding.napiRenderJinja
|
|
604
|
+
module.exports.napiRenderTemplate = nativeBinding.napiRenderTemplate
|
|
600
605
|
module.exports.napiSseClose = nativeBinding.napiSseClose
|
|
601
606
|
module.exports.napiSseRegisterAbort = nativeBinding.napiSseRegisterAbort
|
|
602
607
|
module.exports.napiSseSignalOpen = nativeBinding.napiSseSignalOpen
|
package/runtime/index.ts
CHANGED
|
@@ -21,6 +21,45 @@ function defaultRenderSlots(): number {
|
|
|
21
21
|
return Math.min(Math.max(cores, 1), 16)
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
+
/** Global CORS policy (one policy for the whole deployment — pages, actions,
|
|
25
|
+
* static assets alike; brust has no per-route CORS). Opt-in: omit to keep CORS
|
|
26
|
+
* disabled (byte-identical default — no `Access-Control-*` headers, OPTIONS
|
|
27
|
+
* still 405). Threaded into Rust, which answers preflights before the render
|
|
28
|
+
* pipeline and stamps actual responses at a single chokepoint. */
|
|
29
|
+
export interface CorsOptions {
|
|
30
|
+
/** Allowed origins, exact scheme+host+port match (no wildcard subdomains).
|
|
31
|
+
* A list CONTAINING `'*'` is treated as wildcard: every origin allowed,
|
|
32
|
+
* echoed as the literal `*`. */
|
|
33
|
+
origins: string[]
|
|
34
|
+
/** Preflight `Access-Control-Allow-Methods`. Default: GET,POST,PUT,PATCH,DELETE,OPTIONS. */
|
|
35
|
+
methods?: string[]
|
|
36
|
+
/** Preflight `Access-Control-Allow-Headers`. Default: echo the request's
|
|
37
|
+
* `Access-Control-Request-Headers`. */
|
|
38
|
+
headers?: string[]
|
|
39
|
+
/** `Access-Control-Expose-Headers` on actual responses. Default: none. */
|
|
40
|
+
exposeHeaders?: string[]
|
|
41
|
+
/** Emit `Access-Control-Allow-Credentials: true`. INVALID combined with a
|
|
42
|
+
* wildcard origin — serve() throws at boot (browsers silently reject
|
|
43
|
+
* `Allow-Credentials` with `Allow-Origin: *`; we make it loud). */
|
|
44
|
+
credentials?: boolean
|
|
45
|
+
/** Preflight `Access-Control-Max-Age` seconds. Default 600. */
|
|
46
|
+
maxAgeSeconds?: number
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/** Fail-fast CORS validation, mirroring Rust's `CorsConfig::validate` so a bad
|
|
50
|
+
* config throws in TS before the native call (clearer stack, same message
|
|
51
|
+
* shape). Exported for unit testing. */
|
|
52
|
+
export function validateCorsOptions(cors: CorsOptions): void {
|
|
53
|
+
if (!Array.isArray(cors.origins) || cors.origins.length === 0) {
|
|
54
|
+
throw new Error('cors.origins must be non-empty')
|
|
55
|
+
}
|
|
56
|
+
if (cors.origins.includes('*') && cors.credentials) {
|
|
57
|
+
throw new Error(
|
|
58
|
+
"cors.credentials cannot be combined with a wildcard origin '*' — browsers reject Access-Control-Allow-Credentials with Access-Control-Allow-Origin: *",
|
|
59
|
+
)
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
24
63
|
export interface ServeOptions {
|
|
25
64
|
/** Host/address to bind on. A hostname (e.g. `localhost`, resolved Rust-side)
|
|
26
65
|
* or a literal IP such as `0.0.0.0` / `127.0.0.1`. */
|
|
@@ -36,6 +75,10 @@ export interface ServeOptions {
|
|
|
36
75
|
/** URL prefix the action router mounts under (e.g. `/_actions`). Threaded
|
|
37
76
|
* into Rust's ServeOptions.action_prefix. */
|
|
38
77
|
actionPrefix?: string
|
|
78
|
+
/** Optional global CORS policy — see {@link CorsOptions}. Validated at boot
|
|
79
|
+
* (TS first, Rust mirrors): `origins` non-empty; `credentials` + wildcard
|
|
80
|
+
* origin throws. */
|
|
81
|
+
cors?: CorsOptions
|
|
39
82
|
/** MCP support — pass a manifest built via brust.buildMcpManifest. brust.serve
|
|
40
83
|
* does NOT auto-wire MCP into workers; the worker branch of the entry file must
|
|
41
84
|
* call brust.loadMcpManifest() + makeMcpServer() itself and pass the McpServer
|
|
@@ -148,6 +191,9 @@ async function readManifestFromPath(
|
|
|
148
191
|
|
|
149
192
|
export const brust = {
|
|
150
193
|
async serve(opts: ServeOptions): Promise<void> {
|
|
194
|
+
// Fail fast on a bad CORS config BEFORE touching native state (Rust
|
|
195
|
+
// re-validates in begin_serve — same rules, second line of defense).
|
|
196
|
+
if (opts.cors) validateCorsOptions(opts.cors)
|
|
151
197
|
if (opts.actions) {
|
|
152
198
|
// Register endpoint method/path with Rust. The router keys each by its
|
|
153
199
|
// registration index; the worker dispatches on that same index string.
|
|
@@ -167,6 +213,9 @@ export const brust = {
|
|
|
167
213
|
// `actionPrefix` (not snake_case). A snake_case key is silently dropped,
|
|
168
214
|
// leaving the prefix at its default — which broke custom-prefix routing.
|
|
169
215
|
actionPrefix: opts.actionPrefix,
|
|
216
|
+
// Optional global CORS policy (camelCase fields — napi-rs maps them onto
|
|
217
|
+
// NapiCorsOptions' snake_case Rust fields).
|
|
218
|
+
cors: opts.cors,
|
|
170
219
|
// X-Powered-By value from the build's generator.json (stashed by view
|
|
171
220
|
// boot; artifact fallback covers any ordering edge). Single word — no
|
|
172
221
|
// napi case-mapping trap possible.
|
|
@@ -208,6 +257,11 @@ export const brust = {
|
|
|
208
257
|
const gracefulExit = (code: number) => {
|
|
209
258
|
if (draining) process.exit(code)
|
|
210
259
|
draining = true
|
|
260
|
+
// R9: stop cache-sync (close redis clients, cancel backoff timers) so a
|
|
261
|
+
// retry can't fire between drain and exit. Best-effort and PARALLEL to
|
|
262
|
+
// the drain — it must never delay exit (the dynamic import resolves from
|
|
263
|
+
// cache when sync was configured, and is a no-op module load otherwise).
|
|
264
|
+
import('./cache-sync.ts').then((m) => m.stopCacheSync()).catch(() => {})
|
|
211
265
|
;(native as any)
|
|
212
266
|
.beginDrain(drainTimeoutMs)
|
|
213
267
|
.catch(() => {})
|
|
@@ -261,9 +315,16 @@ export const brust = {
|
|
|
261
315
|
// before any traffic hits.
|
|
262
316
|
const expected = routes.filter((r) => r.nativeTemplate).map((r) => r.nativeTemplate!)
|
|
263
317
|
if (expected.length > 0) {
|
|
264
|
-
|
|
318
|
+
// Dual-tier check (boot env + R1 dynamic registry). `napiHasTemplate`
|
|
319
|
+
// may be absent on a stale addon — fall back to the boot-tier list.
|
|
320
|
+
const hasTemplate: (name: string) => boolean = (native as any).napiHasTemplate
|
|
321
|
+
? (name) => (native as any).napiHasTemplate(name)
|
|
322
|
+
: (() => {
|
|
323
|
+
const registered = new Set<string>((native as any).napiListNativeTemplates() ?? [])
|
|
324
|
+
return (name) => registered.has(name)
|
|
325
|
+
})()
|
|
265
326
|
for (const name of expected) {
|
|
266
|
-
if (!
|
|
327
|
+
if (!hasTemplate(name)) {
|
|
267
328
|
console.warn(
|
|
268
329
|
`[brust] native: true route expects template "${name}.jinja" but it's not registered (boot warning — request will 500)`,
|
|
269
330
|
)
|
|
@@ -378,6 +439,9 @@ export const brust = {
|
|
|
378
439
|
actions?: import('./define-actions.ts').ActionsBuilder
|
|
379
440
|
/** URL prefix the action router mounts under. Threaded to serve(). */
|
|
380
441
|
actionPrefix?: string
|
|
442
|
+
/** Optional global CORS policy — see {@link CorsOptions}. Threaded to
|
|
443
|
+
* serve() like `actionPrefix`. */
|
|
444
|
+
cors?: CorsOptions
|
|
381
445
|
/** Overrides merged into the underlying `serve()` call (main thread). */
|
|
382
446
|
serve?: Partial<Omit<ServeOptions, 'entry' | 'actions' | 'mcp'>>
|
|
383
447
|
/** Per-worker SAB size in bytes. Default 256 KB. */
|
|
@@ -425,13 +489,18 @@ export const brust = {
|
|
|
425
489
|
const endpoints: EndpointDef[] = opts.actions?.endpoints ?? []
|
|
426
490
|
|
|
427
491
|
if (!isWorker) {
|
|
428
|
-
const {
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
492
|
+
const {
|
|
493
|
+
host,
|
|
494
|
+
port,
|
|
495
|
+
workers,
|
|
496
|
+
cacheMaxEntries,
|
|
497
|
+
cachePageMaxEntries,
|
|
498
|
+
cacheSyncUrl,
|
|
499
|
+
cacheSyncChannel,
|
|
500
|
+
} = await loadConfig(process.cwd(), {
|
|
501
|
+
host: opts.address,
|
|
502
|
+
port: opts.port,
|
|
503
|
+
})
|
|
435
504
|
console.log(`[brust] main: spawning ${workers} worker threads`)
|
|
436
505
|
if (cacheMaxEntries !== undefined || cachePageMaxEntries !== undefined)
|
|
437
506
|
this.configureCache({
|
|
@@ -439,6 +508,23 @@ export const brust = {
|
|
|
439
508
|
pageMaxEntries: cachePageMaxEntries ?? 1000,
|
|
440
509
|
})
|
|
441
510
|
|
|
511
|
+
if (cacheSyncUrl) {
|
|
512
|
+
// R9 cross-process invalidation. Env is set BEFORE serve() spawns
|
|
513
|
+
// workers (baseEnv = { ...process.env }) so worker isolates can
|
|
514
|
+
// publish from loaders/actions; the subscriber lives HERE in the main
|
|
515
|
+
// isolate only (the NAPI caches are process-global, so workers see
|
|
516
|
+
// applied invalidations implicitly). The sender token identifies this
|
|
517
|
+
// process so the subscriber skips its own published messages.
|
|
518
|
+
const cacheSync = await import('./cache-sync.ts')
|
|
519
|
+
process.env.BRUST_CACHE_SYNC_URL = cacheSyncUrl
|
|
520
|
+
// Always write the RESOLVED channel: a TOML-only channel would
|
|
521
|
+
// otherwise reach the subscriber here but not the workers' env —
|
|
522
|
+
// publishers and subscriber would silently split onto two channels.
|
|
523
|
+
process.env.BRUST_CACHE_SYNC_CHANNEL = cacheSyncChannel ?? cacheSync.CHANNEL_DEFAULT
|
|
524
|
+
process.env.BRUST_CACHE_SYNC_SENDER ??= crypto.randomUUID()
|
|
525
|
+
cacheSync.startCacheSync({ url: cacheSyncUrl, channel: cacheSyncChannel })
|
|
526
|
+
}
|
|
527
|
+
|
|
442
528
|
// md routes present? (leaf carries `__mdSource`, attached by mdRoutes()).
|
|
443
529
|
// Checked inline — no md-module import — so md-free apps never load the
|
|
444
530
|
// markdown pipeline. Gates the md emits below AND in the dev coordinator.
|
|
@@ -863,6 +949,7 @@ export const brust = {
|
|
|
863
949
|
entry: opts.entry,
|
|
864
950
|
actions: opts.actions,
|
|
865
951
|
actionPrefix: opts.actionPrefix,
|
|
952
|
+
cors: opts.cors,
|
|
866
953
|
...(mcpManifest ? { mcp: { manifest: mcpManifest } } : {}),
|
|
867
954
|
...opts.serve,
|
|
868
955
|
})
|
|
@@ -1025,6 +1112,8 @@ export {
|
|
|
1025
1112
|
notFound,
|
|
1026
1113
|
redirect,
|
|
1027
1114
|
isNativeVerdict,
|
|
1115
|
+
httpError,
|
|
1116
|
+
isHttpErrorTrigger,
|
|
1028
1117
|
} from './routes.ts'
|
|
1029
1118
|
export type {
|
|
1030
1119
|
Route,
|
|
@@ -1036,6 +1125,8 @@ export type {
|
|
|
1036
1125
|
RouteResponse,
|
|
1037
1126
|
Middleware,
|
|
1038
1127
|
NativeVerdict,
|
|
1128
|
+
HttpErrorOpts,
|
|
1129
|
+
HttpErrorTrigger,
|
|
1039
1130
|
} from './routes.ts'
|
|
1040
1131
|
|
|
1041
1132
|
export { defineActions, isValidEndpointPath } from './define-actions.ts'
|
|
@@ -1078,12 +1169,20 @@ export type { StoreHandle, Snapshot, Signal, Computed } from './store/index.ts'
|
|
|
1078
1169
|
// exported.
|
|
1079
1170
|
export { dedupe, cachedFetch } from './loader-cache.ts'
|
|
1080
1171
|
|
|
1172
|
+
// R4 — public fragment rendering: a React component → static HTML string with
|
|
1173
|
+
// the request/store/loader-cache contexts scoped per call (no island hydration;
|
|
1174
|
+
// native/jinja fragments are `templates.render`).
|
|
1175
|
+
export { renderFragment } from './render/fragment.ts'
|
|
1176
|
+
export type { RenderFragmentOpts } from './render/fragment.ts'
|
|
1177
|
+
|
|
1081
1178
|
export { buildIslands } from './islands/build.ts'
|
|
1082
1179
|
export type { IslandsBuildResult, BuildIslandsOptions } from './islands/build.ts'
|
|
1083
1180
|
|
|
1084
1181
|
export { cache } from './cache.ts'
|
|
1085
1182
|
export type { InvalidateArgs } from './cache.ts'
|
|
1086
1183
|
|
|
1184
|
+
export { templates } from './templates.ts'
|
|
1185
|
+
|
|
1087
1186
|
export { getRequestContext } from './request-context.ts'
|
|
1088
1187
|
export { cookies } from './cookies.ts'
|
|
1089
1188
|
export type { CookieOptions } from './cookies.ts'
|