@brust/core 2.0.0-alpha.34 → 2.0.0-alpha.36

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 CHANGED
@@ -131,7 +131,8 @@ A loader or job call that has not settled within `BRUST_CALL_TIMEOUT_MS` answers
131
131
  slot stays claimed until the call settles (the late result is discarded), so a stuck call costs one
132
132
  slot, never a frozen worker. Waiting for a free slot is the separate 503 "all workers busy".
133
133
  `GET /_brust/cache/stats` reports L1/job cache counters plus `loader_calls` / `job_calls` /
134
- `timed_out_calls`.
134
+ `timed_out_calls`. It is off by default (404): set `[server] stats` to `"public"` or `"token"` (`stats_token = "env:NAME"`)
135
+ to read it; `brust dev` serves it.
135
136
 
136
137
  ## Worker wire (contract 7, `crates/brust-server/src/protocol.rs`)
137
138
 
package/native/index.d.ts CHANGED
@@ -25,7 +25,7 @@ export declare function cacheClear(): number
25
25
  */
26
26
  export declare function cacheExprReads(src: string): Array<string>
27
27
 
28
- /** `cache.invalidate({ key?, tags?, path?, method? })` (spec §5). */
28
+ /** `cache.invalidate({ key?, tags?, path?, method?, prefix? })` (spec §5). */
29
29
  export declare function cacheInvalidate(args: NapiInvalidateArgs): NapiInvalidateResult
30
30
 
31
31
  /**
@@ -43,6 +43,8 @@ export declare function cacheReplay(args: NapiInvalidateArgs, seq?: number | und
43
43
  /** `/_brust/cache/stats` JSON (snake_case keys, as the server serialises it). */
44
44
  export declare function cacheStats(): string
45
45
 
46
+ export declare function checkRoutePatterns(patterns: Array<string>): RoutePatternConflict | null
47
+
46
48
  /** A module a chunk imports by name, shared with other chunks (`<name>.js` beside it, R34.124). */
47
49
  export interface ClientModule {
48
50
  name: string
@@ -140,6 +142,8 @@ export interface NapiInvalidateArgs {
140
142
  tags?: Array<string>
141
143
  path?: string
142
144
  method?: string
145
+ /** F493: narrow the page invalidation to this exact key prefix. */
146
+ prefix?: string
143
147
  }
144
148
 
145
149
  export interface NapiInvalidateResult {
@@ -201,6 +205,20 @@ export declare function putFetchReply(slot: number, body: Uint8Array): boolean
201
205
  */
202
206
  export declare function registerWorker(buf: Uint8Array, slots: number, f: (arg0: string, arg1: string, arg2: number) => Promise<number>): number
203
207
 
208
+ /**
209
+ * F496: the first route pattern the server's router refuses (a conflict such as `/{*rest}` next to `/{slug}`, or an
210
+ * invalid pattern), or `None`. `brust build` runs it over the flattened patterns (catch-all `*` routes left out, as
211
+ * the server does) so the failure shows at build, with the router's own message. Needs no running server.
212
+ */
213
+ export interface RoutePatternConflict {
214
+ /** Index into the `patterns` given of the pattern the router refused. */
215
+ index: number
216
+ /** Index of the earlier pattern it conflicts with, when there is one. */
217
+ withIndex?: number
218
+ /** The router's refusal, as `brust start` would print it. */
219
+ message: string
220
+ }
221
+
204
222
  /**
205
223
  * F230: scans the app modules the build loads (`modules`, relative to `root`) for writes into another app module's
206
224
  * exports; the JSON result goes to every `compile_tree` of the build as `loadWrites`. `path_aliases` as for
@@ -245,6 +263,13 @@ export interface StartOptions {
245
263
  l2?: NapiL2Options
246
264
  /** `brust dev` only (L14): a request carrying this token in `x-brust-dev-token` is traced. Absent in production. */
247
265
  devToken?: string
266
+ /** F507: who may read `/_brust/cache/stats`: `"off"` (the default when absent), `"public"` or `"token"`. */
267
+ stats?: string
268
+ /**
269
+ * F507: the secret `stats = "token"` compares `Authorization: Bearer` with (resolved from its env reference by the
270
+ * JS side); never logged. Boot error `stats: …` for a mode and token that do not go together.
271
+ */
272
+ statsToken?: string
248
273
  }
249
274
 
250
275
  /**
package/native/index.js CHANGED
@@ -89,8 +89,8 @@ function requireNative() {
89
89
  try {
90
90
  const binding = require('@brust/native-android-arm64')
91
91
  const bindingPackageVersion = require('@brust/native-android-arm64/package.json').version
92
- if (bindingPackageVersion !== '2.0.0-alpha.34' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
93
- throw new Error(`Native binding package version mismatch, expected 2.0.0-alpha.34 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
92
+ if (bindingPackageVersion !== '2.0.0-alpha.36' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
93
+ throw new Error(`Native binding package version mismatch, expected 2.0.0-alpha.36 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
94
94
  }
95
95
  return binding
96
96
  } catch (e) {
@@ -105,8 +105,8 @@ function requireNative() {
105
105
  try {
106
106
  const binding = require('@brust/native-android-arm-eabi')
107
107
  const bindingPackageVersion = require('@brust/native-android-arm-eabi/package.json').version
108
- if (bindingPackageVersion !== '2.0.0-alpha.34' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
109
- throw new Error(`Native binding package version mismatch, expected 2.0.0-alpha.34 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
108
+ if (bindingPackageVersion !== '2.0.0-alpha.36' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
109
+ throw new Error(`Native binding package version mismatch, expected 2.0.0-alpha.36 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
110
110
  }
111
111
  return binding
112
112
  } catch (e) {
@@ -126,8 +126,8 @@ function requireNative() {
126
126
  try {
127
127
  const binding = require('@brust/native-win32-x64-gnu')
128
128
  const bindingPackageVersion = require('@brust/native-win32-x64-gnu/package.json').version
129
- if (bindingPackageVersion !== '2.0.0-alpha.34' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
130
- throw new Error(`Native binding package version mismatch, expected 2.0.0-alpha.34 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
129
+ if (bindingPackageVersion !== '2.0.0-alpha.36' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
130
+ throw new Error(`Native binding package version mismatch, expected 2.0.0-alpha.36 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
131
131
  }
132
132
  return binding
133
133
  } catch (e) {
@@ -142,8 +142,8 @@ function requireNative() {
142
142
  try {
143
143
  const binding = require('@brust/native-win32-x64-msvc')
144
144
  const bindingPackageVersion = require('@brust/native-win32-x64-msvc/package.json').version
145
- if (bindingPackageVersion !== '2.0.0-alpha.34' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
146
- throw new Error(`Native binding package version mismatch, expected 2.0.0-alpha.34 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
145
+ if (bindingPackageVersion !== '2.0.0-alpha.36' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
146
+ throw new Error(`Native binding package version mismatch, expected 2.0.0-alpha.36 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
147
147
  }
148
148
  return binding
149
149
  } catch (e) {
@@ -159,8 +159,8 @@ function requireNative() {
159
159
  try {
160
160
  const binding = require('@brust/native-win32-ia32-msvc')
161
161
  const bindingPackageVersion = require('@brust/native-win32-ia32-msvc/package.json').version
162
- if (bindingPackageVersion !== '2.0.0-alpha.34' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
163
- throw new Error(`Native binding package version mismatch, expected 2.0.0-alpha.34 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
162
+ if (bindingPackageVersion !== '2.0.0-alpha.36' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
163
+ throw new Error(`Native binding package version mismatch, expected 2.0.0-alpha.36 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
164
164
  }
165
165
  return binding
166
166
  } catch (e) {
@@ -175,8 +175,8 @@ function requireNative() {
175
175
  try {
176
176
  const binding = require('@brust/native-win32-arm64-msvc')
177
177
  const bindingPackageVersion = require('@brust/native-win32-arm64-msvc/package.json').version
178
- if (bindingPackageVersion !== '2.0.0-alpha.34' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
179
- throw new Error(`Native binding package version mismatch, expected 2.0.0-alpha.34 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
178
+ if (bindingPackageVersion !== '2.0.0-alpha.36' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
179
+ throw new Error(`Native binding package version mismatch, expected 2.0.0-alpha.36 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
180
180
  }
181
181
  return binding
182
182
  } catch (e) {
@@ -194,8 +194,8 @@ function requireNative() {
194
194
  try {
195
195
  const binding = require('@brust/native-darwin-universal')
196
196
  const bindingPackageVersion = require('@brust/native-darwin-universal/package.json').version
197
- if (bindingPackageVersion !== '2.0.0-alpha.34' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
198
- throw new Error(`Native binding package version mismatch, expected 2.0.0-alpha.34 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
197
+ if (bindingPackageVersion !== '2.0.0-alpha.36' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
198
+ throw new Error(`Native binding package version mismatch, expected 2.0.0-alpha.36 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
199
199
  }
200
200
  return binding
201
201
  } catch (e) {
@@ -210,8 +210,8 @@ function requireNative() {
210
210
  try {
211
211
  const binding = require('@brust/native-darwin-x64')
212
212
  const bindingPackageVersion = require('@brust/native-darwin-x64/package.json').version
213
- if (bindingPackageVersion !== '2.0.0-alpha.34' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
214
- throw new Error(`Native binding package version mismatch, expected 2.0.0-alpha.34 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
213
+ if (bindingPackageVersion !== '2.0.0-alpha.36' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
214
+ throw new Error(`Native binding package version mismatch, expected 2.0.0-alpha.36 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
215
215
  }
216
216
  return binding
217
217
  } catch (e) {
@@ -226,8 +226,8 @@ function requireNative() {
226
226
  try {
227
227
  const binding = require('@brust/native-darwin-arm64')
228
228
  const bindingPackageVersion = require('@brust/native-darwin-arm64/package.json').version
229
- if (bindingPackageVersion !== '2.0.0-alpha.34' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
230
- throw new Error(`Native binding package version mismatch, expected 2.0.0-alpha.34 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
229
+ if (bindingPackageVersion !== '2.0.0-alpha.36' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
230
+ throw new Error(`Native binding package version mismatch, expected 2.0.0-alpha.36 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
231
231
  }
232
232
  return binding
233
233
  } catch (e) {
@@ -246,8 +246,8 @@ function requireNative() {
246
246
  try {
247
247
  const binding = require('@brust/native-freebsd-x64')
248
248
  const bindingPackageVersion = require('@brust/native-freebsd-x64/package.json').version
249
- if (bindingPackageVersion !== '2.0.0-alpha.34' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
250
- throw new Error(`Native binding package version mismatch, expected 2.0.0-alpha.34 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
249
+ if (bindingPackageVersion !== '2.0.0-alpha.36' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
250
+ throw new Error(`Native binding package version mismatch, expected 2.0.0-alpha.36 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
251
251
  }
252
252
  return binding
253
253
  } catch (e) {
@@ -262,8 +262,8 @@ function requireNative() {
262
262
  try {
263
263
  const binding = require('@brust/native-freebsd-arm64')
264
264
  const bindingPackageVersion = require('@brust/native-freebsd-arm64/package.json').version
265
- if (bindingPackageVersion !== '2.0.0-alpha.34' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
266
- throw new Error(`Native binding package version mismatch, expected 2.0.0-alpha.34 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
265
+ if (bindingPackageVersion !== '2.0.0-alpha.36' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
266
+ throw new Error(`Native binding package version mismatch, expected 2.0.0-alpha.36 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
267
267
  }
268
268
  return binding
269
269
  } catch (e) {
@@ -283,8 +283,8 @@ function requireNative() {
283
283
  try {
284
284
  const binding = require('@brust/native-linux-x64-musl')
285
285
  const bindingPackageVersion = require('@brust/native-linux-x64-musl/package.json').version
286
- if (bindingPackageVersion !== '2.0.0-alpha.34' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
287
- throw new Error(`Native binding package version mismatch, expected 2.0.0-alpha.34 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
286
+ if (bindingPackageVersion !== '2.0.0-alpha.36' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
287
+ throw new Error(`Native binding package version mismatch, expected 2.0.0-alpha.36 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
288
288
  }
289
289
  return binding
290
290
  } catch (e) {
@@ -299,8 +299,8 @@ function requireNative() {
299
299
  try {
300
300
  const binding = require('@brust/native-linux-x64-gnu')
301
301
  const bindingPackageVersion = require('@brust/native-linux-x64-gnu/package.json').version
302
- if (bindingPackageVersion !== '2.0.0-alpha.34' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
303
- throw new Error(`Native binding package version mismatch, expected 2.0.0-alpha.34 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
302
+ if (bindingPackageVersion !== '2.0.0-alpha.36' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
303
+ throw new Error(`Native binding package version mismatch, expected 2.0.0-alpha.36 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
304
304
  }
305
305
  return binding
306
306
  } catch (e) {
@@ -317,8 +317,8 @@ function requireNative() {
317
317
  try {
318
318
  const binding = require('@brust/native-linux-arm64-musl')
319
319
  const bindingPackageVersion = require('@brust/native-linux-arm64-musl/package.json').version
320
- if (bindingPackageVersion !== '2.0.0-alpha.34' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
321
- throw new Error(`Native binding package version mismatch, expected 2.0.0-alpha.34 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
320
+ if (bindingPackageVersion !== '2.0.0-alpha.36' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
321
+ throw new Error(`Native binding package version mismatch, expected 2.0.0-alpha.36 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
322
322
  }
323
323
  return binding
324
324
  } catch (e) {
@@ -333,8 +333,8 @@ function requireNative() {
333
333
  try {
334
334
  const binding = require('@brust/native-linux-arm64-gnu')
335
335
  const bindingPackageVersion = require('@brust/native-linux-arm64-gnu/package.json').version
336
- if (bindingPackageVersion !== '2.0.0-alpha.34' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
337
- throw new Error(`Native binding package version mismatch, expected 2.0.0-alpha.34 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
336
+ if (bindingPackageVersion !== '2.0.0-alpha.36' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
337
+ throw new Error(`Native binding package version mismatch, expected 2.0.0-alpha.36 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
338
338
  }
339
339
  return binding
340
340
  } catch (e) {
@@ -351,8 +351,8 @@ function requireNative() {
351
351
  try {
352
352
  const binding = require('@brust/native-linux-arm-musleabihf')
353
353
  const bindingPackageVersion = require('@brust/native-linux-arm-musleabihf/package.json').version
354
- if (bindingPackageVersion !== '2.0.0-alpha.34' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
355
- throw new Error(`Native binding package version mismatch, expected 2.0.0-alpha.34 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
354
+ if (bindingPackageVersion !== '2.0.0-alpha.36' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
355
+ throw new Error(`Native binding package version mismatch, expected 2.0.0-alpha.36 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
356
356
  }
357
357
  return binding
358
358
  } catch (e) {
@@ -367,8 +367,8 @@ function requireNative() {
367
367
  try {
368
368
  const binding = require('@brust/native-linux-arm-gnueabihf')
369
369
  const bindingPackageVersion = require('@brust/native-linux-arm-gnueabihf/package.json').version
370
- if (bindingPackageVersion !== '2.0.0-alpha.34' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
371
- throw new Error(`Native binding package version mismatch, expected 2.0.0-alpha.34 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
370
+ if (bindingPackageVersion !== '2.0.0-alpha.36' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
371
+ throw new Error(`Native binding package version mismatch, expected 2.0.0-alpha.36 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
372
372
  }
373
373
  return binding
374
374
  } catch (e) {
@@ -385,8 +385,8 @@ function requireNative() {
385
385
  try {
386
386
  const binding = require('@brust/native-linux-loong64-musl')
387
387
  const bindingPackageVersion = require('@brust/native-linux-loong64-musl/package.json').version
388
- if (bindingPackageVersion !== '2.0.0-alpha.34' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
389
- throw new Error(`Native binding package version mismatch, expected 2.0.0-alpha.34 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
388
+ if (bindingPackageVersion !== '2.0.0-alpha.36' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
389
+ throw new Error(`Native binding package version mismatch, expected 2.0.0-alpha.36 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
390
390
  }
391
391
  return binding
392
392
  } catch (e) {
@@ -401,8 +401,8 @@ function requireNative() {
401
401
  try {
402
402
  const binding = require('@brust/native-linux-loong64-gnu')
403
403
  const bindingPackageVersion = require('@brust/native-linux-loong64-gnu/package.json').version
404
- if (bindingPackageVersion !== '2.0.0-alpha.34' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
405
- throw new Error(`Native binding package version mismatch, expected 2.0.0-alpha.34 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
404
+ if (bindingPackageVersion !== '2.0.0-alpha.36' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
405
+ throw new Error(`Native binding package version mismatch, expected 2.0.0-alpha.36 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
406
406
  }
407
407
  return binding
408
408
  } catch (e) {
@@ -419,8 +419,8 @@ function requireNative() {
419
419
  try {
420
420
  const binding = require('@brust/native-linux-riscv64-musl')
421
421
  const bindingPackageVersion = require('@brust/native-linux-riscv64-musl/package.json').version
422
- if (bindingPackageVersion !== '2.0.0-alpha.34' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
423
- throw new Error(`Native binding package version mismatch, expected 2.0.0-alpha.34 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
422
+ if (bindingPackageVersion !== '2.0.0-alpha.36' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
423
+ throw new Error(`Native binding package version mismatch, expected 2.0.0-alpha.36 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
424
424
  }
425
425
  return binding
426
426
  } catch (e) {
@@ -435,8 +435,8 @@ function requireNative() {
435
435
  try {
436
436
  const binding = require('@brust/native-linux-riscv64-gnu')
437
437
  const bindingPackageVersion = require('@brust/native-linux-riscv64-gnu/package.json').version
438
- if (bindingPackageVersion !== '2.0.0-alpha.34' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
439
- throw new Error(`Native binding package version mismatch, expected 2.0.0-alpha.34 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
438
+ if (bindingPackageVersion !== '2.0.0-alpha.36' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
439
+ throw new Error(`Native binding package version mismatch, expected 2.0.0-alpha.36 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
440
440
  }
441
441
  return binding
442
442
  } catch (e) {
@@ -452,8 +452,8 @@ function requireNative() {
452
452
  try {
453
453
  const binding = require('@brust/native-linux-ppc64-gnu')
454
454
  const bindingPackageVersion = require('@brust/native-linux-ppc64-gnu/package.json').version
455
- if (bindingPackageVersion !== '2.0.0-alpha.34' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
456
- throw new Error(`Native binding package version mismatch, expected 2.0.0-alpha.34 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
455
+ if (bindingPackageVersion !== '2.0.0-alpha.36' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
456
+ throw new Error(`Native binding package version mismatch, expected 2.0.0-alpha.36 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
457
457
  }
458
458
  return binding
459
459
  } catch (e) {
@@ -468,8 +468,8 @@ function requireNative() {
468
468
  try {
469
469
  const binding = require('@brust/native-linux-s390x-gnu')
470
470
  const bindingPackageVersion = require('@brust/native-linux-s390x-gnu/package.json').version
471
- if (bindingPackageVersion !== '2.0.0-alpha.34' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
472
- throw new Error(`Native binding package version mismatch, expected 2.0.0-alpha.34 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
471
+ if (bindingPackageVersion !== '2.0.0-alpha.36' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
472
+ throw new Error(`Native binding package version mismatch, expected 2.0.0-alpha.36 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
473
473
  }
474
474
  return binding
475
475
  } catch (e) {
@@ -488,8 +488,8 @@ function requireNative() {
488
488
  try {
489
489
  const binding = require('@brust/native-openharmony-arm64')
490
490
  const bindingPackageVersion = require('@brust/native-openharmony-arm64/package.json').version
491
- if (bindingPackageVersion !== '2.0.0-alpha.34' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
492
- throw new Error(`Native binding package version mismatch, expected 2.0.0-alpha.34 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
491
+ if (bindingPackageVersion !== '2.0.0-alpha.36' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
492
+ throw new Error(`Native binding package version mismatch, expected 2.0.0-alpha.36 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
493
493
  }
494
494
  return binding
495
495
  } catch (e) {
@@ -504,8 +504,8 @@ function requireNative() {
504
504
  try {
505
505
  const binding = require('@brust/native-openharmony-x64')
506
506
  const bindingPackageVersion = require('@brust/native-openharmony-x64/package.json').version
507
- if (bindingPackageVersion !== '2.0.0-alpha.34' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
508
- throw new Error(`Native binding package version mismatch, expected 2.0.0-alpha.34 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
507
+ if (bindingPackageVersion !== '2.0.0-alpha.36' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
508
+ throw new Error(`Native binding package version mismatch, expected 2.0.0-alpha.36 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
509
509
  }
510
510
  return binding
511
511
  } catch (e) {
@@ -520,8 +520,8 @@ function requireNative() {
520
520
  try {
521
521
  const binding = require('@brust/native-openharmony-arm')
522
522
  const bindingPackageVersion = require('@brust/native-openharmony-arm/package.json').version
523
- if (bindingPackageVersion !== '2.0.0-alpha.34' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
524
- throw new Error(`Native binding package version mismatch, expected 2.0.0-alpha.34 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
523
+ if (bindingPackageVersion !== '2.0.0-alpha.36' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
524
+ throw new Error(`Native binding package version mismatch, expected 2.0.0-alpha.36 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
525
525
  }
526
526
  return binding
527
527
  } catch (e) {
@@ -661,8 +661,8 @@ if (!nativeBinding || forceWasi) {
661
661
  if (!candidateFailed) {
662
662
  if (process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
663
663
  const bindingPackageVersion = require('@brust/native-wasm32-wasi/package.json').version
664
- if (bindingPackageVersion !== '2.0.0-alpha.34') {
665
- throw new Error(`WASI binding package version mismatch, expected 2.0.0-alpha.34 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
664
+ if (bindingPackageVersion !== '2.0.0-alpha.36') {
665
+ throw new Error(`WASI binding package version mismatch, expected 2.0.0-alpha.36 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
666
666
  }
667
667
  }
668
668
  wasiBinding = require('@brust/native-wasm32-wasi')
@@ -785,6 +785,7 @@ module.exports.cacheInvalidate = nativeBinding.cacheInvalidate
785
785
  module.exports.cacheL2Count = nativeBinding.cacheL2Count
786
786
  module.exports.cacheReplay = nativeBinding.cacheReplay
787
787
  module.exports.cacheStats = nativeBinding.cacheStats
788
+ module.exports.checkRoutePatterns = nativeBinding.checkRoutePatterns
788
789
  module.exports.compileTree = nativeBinding.compileTree
789
790
  module.exports.localAddr = nativeBinding.localAddr
790
791
  module.exports.planJobs = nativeBinding.planJobs
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@brust/core",
3
- "version": "2.0.0-alpha.34",
3
+ "version": "2.0.0-alpha.36",
4
4
  "description": "brust v2 — React components compiled to Rust-rendered templates",
5
5
  "license": "MIT",
6
6
  "homepage": "https://brust.dev",
@@ -57,7 +57,7 @@
57
57
  ]
58
58
  },
59
59
  "dependencies": {
60
- "@brust/runtime-dom": "2.0.0-alpha.34",
60
+ "@brust/runtime-dom": "2.0.0-alpha.36",
61
61
  "tsconfig-paths": "4.2.0"
62
62
  },
63
63
  "peerDependencies": {
@@ -101,13 +101,13 @@
101
101
  "access": "public"
102
102
  },
103
103
  "optionalDependencies": {
104
- "@brust/native-darwin-x64": "2.0.0-alpha.34",
105
- "@brust/native-darwin-arm64": "2.0.0-alpha.34",
106
- "@brust/native-linux-x64-gnu": "2.0.0-alpha.34",
107
- "@brust/native-linux-arm64-gnu": "2.0.0-alpha.34",
108
- "@brust/native-linux-x64-musl": "2.0.0-alpha.34",
109
- "@brust/native-linux-arm64-musl": "2.0.0-alpha.34",
110
- "@brust/native-win32-x64-msvc": "2.0.0-alpha.34",
111
- "@brust/core-cf": "2.0.0-alpha.34"
104
+ "@brust/native-darwin-x64": "2.0.0-alpha.36",
105
+ "@brust/native-darwin-arm64": "2.0.0-alpha.36",
106
+ "@brust/native-linux-x64-gnu": "2.0.0-alpha.36",
107
+ "@brust/native-linux-arm64-gnu": "2.0.0-alpha.36",
108
+ "@brust/native-linux-x64-musl": "2.0.0-alpha.36",
109
+ "@brust/native-linux-arm64-musl": "2.0.0-alpha.36",
110
+ "@brust/native-win32-x64-msvc": "2.0.0-alpha.36",
111
+ "@brust/core-cf": "2.0.0-alpha.36"
112
112
  }
113
113
  }
@@ -46,10 +46,9 @@ const page = () => globalThis as PageGlobals
46
46
  export function resolvePrefix(opts?: { prefix?: string; baseUrl?: string }): string {
47
47
  if (opts?.prefix) return opts.prefix
48
48
  if (opts?.baseUrl !== undefined) return DEFAULT_ACTION_PREFIX
49
- return (
50
- (globalThis as { __BRUST_ACTION_PREFIX__?: string }).__BRUST_ACTION_PREFIX__ ??
51
- DEFAULT_ACTION_PREFIX
52
- )
49
+ // F495: an app under a base path serves the default prefix below it; the page says where (`__BRUST_BASE_PATH__`).
50
+ const g = globalThis as { __BRUST_ACTION_PREFIX__?: string; __BRUST_BASE_PATH__?: string }
51
+ return g.__BRUST_ACTION_PREFIX__ ?? `${g.__BRUST_BASE_PATH__ ?? ''}${DEFAULT_ACTION_PREFIX}`
53
52
  }
54
53
 
55
54
  /** 0.1.x runtime/treaty.ts:95-106; message names `client`. */
package/src/browser.ts CHANGED
@@ -5,6 +5,9 @@
5
5
  // config, no napi addon — a react island may import `cache` from the package root.
6
6
  import { cacheComponent } from './cache-core'
7
7
  export { buildTime } from './build-time'
8
+
9
+ /** F495 `[server] base_path` (see index.ts): the page's `__BRUST_BASE_PATH__` global, `''` at the root. */
10
+ export const basePath: string = (globalThis as { __BRUST_BASE_PATH__?: string }).__BRUST_BASE_PATH__ ?? ''
8
11
  export { clearNavigationCache, navigate } from './navigate-browser'
9
12
  export type { NavErrorDetail, NavLoadDetail, NavigateOptions, NavSuccessDetail, NavTrigger } from './navigate'
10
13
  import type { InvalidateArgs, InvalidateResult } from './native'
@@ -47,8 +47,9 @@ export async function runActionsOnly(o: {
47
47
  components: {},
48
48
  assets: { runtime: '', features: {} },
49
49
  jobs_module: 'jobs.js',
50
- actions: { entry: await buildActions(tmp, entry), prefix: actions.prefix, maxBodyBytes: actions.maxBodyBytes, maxResponseBytes: actions.maxResponseBytes, crossSite: actions.crossSite, ...actions.stream },
50
+ actions: { entry: await buildActions(tmp, entry, undefined, config.basePath), prefix: actions.prefix, maxBodyBytes: actions.maxBodyBytes, maxResponseBytes: actions.maxResponseBytes, crossSite: actions.crossSite, ...actions.stream },
51
51
  actions_only: true,
52
+ ...(config.basePath !== '' ? { base_path: config.basePath } : {}),
52
53
  }
53
54
  mkdirSync(join(tmp, 'jinja'), { recursive: true })
54
55
  writeFileSync(join(tmp, 'jobs.js'), '// generated by `brust build --actions-only`: no pages, so no jobs\nexport default {}\n')
@@ -54,9 +54,35 @@ export interface BrowserCtx {
54
54
  clientDir?: string
55
55
  /** F480: load-time writers shipped into an island chunk (F230), by real path: why each is there. A server-only import
56
56
  * reached through one names that chain in `server-only-in-client`. */
57
- loadWriters?: Map<string, string>
57
+ loadWriters?: Map<string, LoadWriter>
58
+ /** F495 `[server] base_path`: every `/_brust/…` URL a bundle names carries it (`/portal/_brust/…`); absent or `''` = the root. */
59
+ basePath?: string
58
60
  }
59
61
 
62
+ /** F480/F481: a load writer shipped into island chunks (F230): its path, every island whose chunk carries it, and the modules it is judged to write. */
63
+ export interface LoadWriter {
64
+ rel: string
65
+ islands: string[]
66
+ writes: string[]
67
+ }
68
+
69
+ /** F481: `a, b, c and 2 more`: at most `cap` names, in sorted order, then the rest as a count. */
70
+ export function namedCapped(names: Iterable<string>, cap = 3): string {
71
+ const all = [...new Set(names)].sort()
72
+ return all.length <= cap ? all.join(', ') : `${all.slice(0, cap).join(', ')} and ${all.length - cap} more`
73
+ }
74
+
75
+ /** The sentence a server-only refusal carries for the load writers it reached: every writer and every island, capped. */
76
+ export function loadWriterReason(writers: LoadWriter[]): string {
77
+ const one = (w: LoadWriter) => `${w.rel} is loaded into the React ${w.islands.length > 1 ? 'islands' : 'island'} ${namedCapped(w.islands)} because it is judged to write ${namedCapped(w.writes, 99)} when it loads: F230 load writes`
78
+ const sorted = [...writers].sort((a, b) => (a.rel < b.rel ? -1 : a.rel > b.rel ? 1 : 0))
79
+ const shown = sorted.slice(0, 3).map(one).join('; ')
80
+ return sorted.length > 3 ? `${shown}; and ${sorted.length - 3} more load writers` : shown
81
+ }
82
+
83
+ /** F495: brust's own URL prefix for a build, `/_brust` or `<base>/_brust`. */
84
+ export const brustRoot = (ctx: { basePath?: string }): string => `${ctx.basePath ?? ''}/_brust`
85
+
60
86
  /** `file` sits under `root`. */
61
87
  const inside = (root: string, file: string): boolean => file === root || file.startsWith(root.endsWith(sep) ? root : root + sep)
62
88
 
@@ -181,9 +207,9 @@ function isServerOnly(spec: string, importer: string, ctx: BrowserCtx): boolean
181
207
  * offending import is stubbed so the bundler gets as far as it can; `browserBuild` then throws
182
208
  * `server-only-in-client` naming every `<importer> imports <spec>`. */
183
209
  function serverOnlyPlugin(ctx: BrowserCtx, violations: string[]): BunPlugin {
184
- const writers = ctx.loadWriters ?? new Map<string, string>()
185
- // F480: who first imported each file (real paths), kept only while a load writer ships, to name the writer chain.
186
- const importerOf = new Map<string, string>()
210
+ const writers = ctx.loadWriters ?? new Map<string, LoadWriter>()
211
+ // F480/F481: who imports each file (real paths; every importer, not the first), kept only while a load writer ships, to name the writer chain.
212
+ const importersOf = new Map<string, Set<string>>()
187
213
  const real = (f: string) => {
188
214
  try {
189
215
  return realpathSync(f)
@@ -195,23 +221,34 @@ function serverOnlyPlugin(ctx: BrowserCtx, violations: string[]): BunPlugin {
195
221
  const from = real(ctx.sourceOf.get(importer) ?? importer)
196
222
  try {
197
223
  const file = real(isAbsolute(spec) ? spec : Bun.resolveSync(spec, dirname(from)))
198
- if (!importerOf.has(file)) importerOf.set(file, from)
224
+ let set = importersOf.get(file)
225
+ if (!set) importersOf.set(file, (set = new Set()))
226
+ set.add(from)
199
227
  } catch {}
200
228
  }
229
+ /** Every load writer a module is reached through (a walk up all its importers, stopping at a writer), as the refusal's reason. */
201
230
  const writerChain = (importer: string): string => {
202
231
  const seen = new Set<string>()
203
- for (let f: string | undefined = real(ctx.sourceOf.get(importer) ?? importer); f !== undefined && !seen.has(f); f = importerOf.get(f)) {
232
+ const found: LoadWriter[] = []
233
+ const stack = [real(ctx.sourceOf.get(importer) ?? importer)]
234
+ while (stack.length > 0) {
235
+ const f = stack.pop()!
236
+ if (seen.has(f)) continue
204
237
  seen.add(f)
205
- const why = writers.get(f)
206
- if (why !== undefined) return ` (${why})`
238
+ const w = writers.get(f)
239
+ if (w !== undefined) {
240
+ found.push(w)
241
+ continue
242
+ }
243
+ stack.push(...(importersOf.get(f) ?? []))
207
244
  }
208
- return ''
245
+ return found.length > 0 ? ` (${loadWriterReason(found)})` : ''
209
246
  }
210
247
  return {
211
248
  name: 'brust-server-only',
212
249
  setup(b) {
213
250
  b.onResolve({ filter: /.*/ }, (a) => {
214
- if (!a.importer || a.path.startsWith('/_brust/')) return undefined
251
+ if (!a.importer || a.path.startsWith(`${brustRoot(ctx)}/`)) return undefined
215
252
  if (a.path === '@brust/core') return { path: BROWSER_ENTRY }
216
253
  if (!isServerOnly(a.path, a.importer, ctx)) {
217
254
  if (writers.size > 0) noteImport(a.path, a.importer)
@@ -247,7 +284,7 @@ async function browserBuild(
247
284
  try {
248
285
  res = await Bun.build({
249
286
  ...config,
250
- plugins: [serverOnlyPlugin(ctx, violations), cssPlugin(ctx.cssMaps ?? new Map(), ctx.clientDir), ...(config.plugins ?? [])],
287
+ plugins: [serverOnlyPlugin(ctx, violations), cssPlugin(ctx.cssMaps ?? new Map(), ctx.clientDir, ctx.basePath), ...(config.plugins ?? [])],
251
288
  target: 'browser',
252
289
  format: 'esm',
253
290
  minify: true,
@@ -333,7 +370,7 @@ export async function buildRuntime(dist: string, ctx: BrowserCtx): Promise<Runti
333
370
  })
334
371
  ).get('runtime')!
335
372
  // Features import the core's API (`core-api`, and `core` for the store's re-exports) from the core file by URL.
336
- const coreUrl = `/_brust/${core}`
373
+ const coreUrl = `${brustRoot(ctx)}/${core}`
337
374
  const coreFiles = new Set(['core-api', 'core'].map((f) => join(dir, f)))
338
375
  const names = [...RUNTIME_FEATURES, 'store'] as const
339
376
  const entries = names.map((n) => {
@@ -391,7 +428,7 @@ export async function buildClientChunks(dist: string, compiled: Map<string, Comp
391
428
  return browserBuild(dist, 'client chunks', ctx, {
392
429
  entrypoints,
393
430
  splitting: true,
394
- external: ['/_brust/*'],
431
+ external: [`${brustRoot(ctx)}/*`],
395
432
  plugins: [runtimeAliasPlugin(runtimeUrl), specModulePlugin(join(dist, '.stage', 'client')), sourceDirPlugin(ctx.sourceOf, ctx.appRoot, [], 'browser')],
396
433
  })
397
434
  }
@@ -429,11 +466,11 @@ export async function projectionFallbacks(dist: string, compiled: Map<string, Co
429
466
  const res = await Bun.build({
430
467
  entrypoints,
431
468
  splitting: true,
432
- external: ['/_brust/*'],
469
+ external: [`${brustRoot(ctx)}/*`],
433
470
  target: 'browser',
434
471
  format: 'esm',
435
472
  metafile: true,
436
- plugins: [serverOnlyPlugin(ctx, []), cssPlugin(ctx.cssMaps ?? new Map(), ctx.clientDir), runtimeAliasPlugin(runtimeUrl), specModulePlugin(probeDir), sourceDirPlugin(ctx.sourceOf, ctx.appRoot, [], 'browser')],
473
+ plugins: [serverOnlyPlugin(ctx, []), cssPlugin(ctx.cssMaps ?? new Map(), ctx.clientDir, ctx.basePath), runtimeAliasPlugin(runtimeUrl), specModulePlugin(probeDir), sourceDirPlugin(ctx.sourceOf, ctx.appRoot, [], 'browser')],
437
474
  })
438
475
  if (!res.success || !res.metafile) throw new BuildError('bundle', `client chunks (projection probe): ${res.logs.map(String).join('\n')}`)
439
476
  const loaded = new Set(Object.keys(res.metafile.inputs).map((k) => real(resolve(k))))
@@ -685,7 +722,7 @@ export async function buildReactChunks(
685
722
  const out = await browserBuild(dist, 'react islands', ctx, {
686
723
  entrypoints,
687
724
  splitting: true,
688
- external: ['/_brust/*'],
725
+ external: [`${brustRoot(ctx)}/*`],
689
726
  plugins: [runtimeAliasPlugin(runtimeUrl), sourceDirPlugin(ctx.sourceOf, ctx.appRoot, [], 'browser'), exposePlugin(compiled)],
690
727
  })
691
728
  return new Map([...out].map(([stem, path]) => [stem.slice('react-'.length), path]))
@@ -721,8 +758,8 @@ const ACTIONS_EXTERNALS = [...JOBS_EXTERNALS, 'elysia', 'elysia/*', '@elysia/*']
721
758
 
722
759
  /** `dist/actions.js` (M3-F E1): the actions entry for the worker (`target: 'bun'`). No `define`: Elysia
723
760
  * and app code read NODE_ENV at runtime (run.ts sets production). */
724
- export async function buildActions(dist: string, entry: string, cssMaps: Map<string, Record<string, string>> = new Map()): Promise<string> {
725
- const res = await Bun.build({ entrypoints: [entry], target: 'bun', format: 'esm', external: ACTIONS_EXTERNALS, plugins: [serverOnlyEmptyPlugin(), cssPlugin(cssMaps, join(dist, 'client')), workerStorePlugin] })
761
+ export async function buildActions(dist: string, entry: string, cssMaps: Map<string, Record<string, string>> = new Map(), basePath = ''): Promise<string> {
762
+ const res = await Bun.build({ entrypoints: [entry], target: 'bun', format: 'esm', external: ACTIONS_EXTERNALS, plugins: [serverOnlyEmptyPlugin(), cssPlugin(cssMaps, join(dist, 'client'), basePath), workerStorePlugin] })
726
763
  if (!res.success) throw new BuildError('bundle', `actions: ${res.logs.map(String).join('\n')}`)
727
764
  write(join(dist, 'actions.js'), await res.outputs[0]!.text())
728
765
  return 'actions.js'
@@ -769,6 +806,8 @@ export async function buildJobs(
769
806
  reached?: { planned: ReadonlySet<string>; ssr: ReadonlySet<string> },
770
807
  /** F230: app modules that write another module's exports when they load: imported first (see `islandShim`). */
771
808
  writers: string[] = [],
809
+ /** F495: `[server] base_path`: an imported asset's URL carries it. */
810
+ basePath = '',
772
811
  ): Promise<void> {
773
812
  const imports: string[] = [writerImports(writers).trimEnd(), "import { createElement } from 'react'", "import { renderToString } from 'react-dom/server'"].filter((l) => l !== '')
774
813
  const entries: string[] = []
@@ -830,7 +869,7 @@ export async function buildJobs(
830
869
  (importer) => jobFiles.has(importer),
831
870
  ),
832
871
  serverOnlyEmptyPlugin(),
833
- cssPlugin(cssMaps, join(dist, 'client')),
872
+ cssPlugin(cssMaps, join(dist, 'client'), basePath),
834
873
  workerStorePlugin,
835
874
  sourceDirPlugin(sourceOf, appRoot, JOBS_EXTERNALS),
836
875
  exposePlugin(compiled),