brustjs 0.1.49-alpha → 0.1.51-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.
Files changed (93) hide show
  1. package/package.json +39 -15
  2. package/runtime/cache-sync.ts +291 -0
  3. package/runtime/cache.ts +4 -0
  4. package/runtime/cli/build.ts +7 -0
  5. package/runtime/cli/dev.ts +7 -0
  6. package/runtime/cli/native-routes-emit.ts +147 -1
  7. package/runtime/cli/ssg.ts +94 -23
  8. package/runtime/config.ts +42 -0
  9. package/runtime/index.d.ts +63 -0
  10. package/runtime/index.js +57 -52
  11. package/runtime/index.ts +114 -9
  12. package/runtime/islands/page-cache.ts +32 -2
  13. package/runtime/native/runtime.ts +220 -7
  14. package/runtime/render/fragment.ts +87 -0
  15. package/runtime/routes.ts +482 -95
  16. package/runtime/templates.ts +47 -0
  17. package/runtime/treaty.ts +24 -1
  18. package/types/action-error.d.ts +18 -0
  19. package/types/cache-sync.d.ts +42 -0
  20. package/types/cache.d.ts +20 -0
  21. package/types/cli/help.d.ts +28 -0
  22. package/types/cli/jinja-staleness.d.ts +14 -0
  23. package/types/cli/native-routes-emit.d.ts +217 -0
  24. package/types/cli/new.d.ts +30 -0
  25. package/types/cli/templates.d.ts +39 -0
  26. package/types/client/index.d.ts +14 -0
  27. package/types/config.d.ts +42 -0
  28. package/types/cookies.d.ts +25 -0
  29. package/types/create.d.ts +1 -0
  30. package/types/css/build.d.ts +11 -0
  31. package/types/css/component-build.d.ts +17 -0
  32. package/types/css/component-loader.d.ts +8 -0
  33. package/types/css/manifest.d.ts +21 -0
  34. package/types/css/process-modules.d.ts +31 -0
  35. package/types/css/route-deps.d.ts +20 -0
  36. package/types/css/scan-imports.d.ts +13 -0
  37. package/types/css.d.ts +16 -0
  38. package/types/define-actions.d.ts +133 -0
  39. package/types/dev/client.d.ts +8 -0
  40. package/types/dev/coordinator.d.ts +33 -0
  41. package/types/dev/inject.d.ts +6 -0
  42. package/types/dev/jinja-reload.d.ts +7 -0
  43. package/types/dev/tui.d.ts +35 -0
  44. package/types/dev/watcher.d.ts +34 -0
  45. package/types/dev/worker-registry.d.ts +17 -0
  46. package/types/dev/ws-channel.d.ts +39 -0
  47. package/types/generator.d.ts +23 -0
  48. package/types/index.d.ts +222 -0
  49. package/types/islands/brust-page.d.ts +74 -0
  50. package/types/islands/build.d.ts +49 -0
  51. package/types/islands/chunk-id.d.ts +10 -0
  52. package/types/islands/importmap.d.ts +2 -0
  53. package/types/islands/island.d.ts +65 -0
  54. package/types/islands/isr-jsx.d.ts +31 -0
  55. package/types/islands/native-render.d.ts +89 -0
  56. package/types/loader-cache.d.ts +18 -0
  57. package/types/mcp/extractor.d.ts +14 -0
  58. package/types/mcp/manifest.d.ts +23 -0
  59. package/types/mcp/schema.d.ts +19 -0
  60. package/types/mcp/server.d.ts +15 -0
  61. package/types/md/emit.d.ts +72 -0
  62. package/types/md/render.d.ts +80 -0
  63. package/types/md/routes.d.ts +119 -0
  64. package/types/md/scan.d.ts +34 -0
  65. package/types/md/slug.d.ts +1 -0
  66. package/types/native/build.d.ts +30 -0
  67. package/types/native/index.d.ts +2 -0
  68. package/types/native/runtime.d.ts +52 -0
  69. package/types/navigation/active-nav.d.ts +2 -0
  70. package/types/navigation/index.d.ts +5 -0
  71. package/types/navigation/navigate.d.ts +14 -0
  72. package/types/navigation/react.d.ts +15 -0
  73. package/types/navigation/store.d.ts +44 -0
  74. package/types/render/fragment.d.ts +20 -0
  75. package/types/render/inject-action-prefix.d.ts +9 -0
  76. package/types/render/inject-css-link.d.ts +8 -0
  77. package/types/render/inject-dev-client.d.ts +6 -0
  78. package/types/render/inject-generator.d.ts +7 -0
  79. package/types/render/inject-store.d.ts +9 -0
  80. package/types/render/stream.d.ts +45 -0
  81. package/types/request-context.d.ts +16 -0
  82. package/types/routes.d.ts +506 -0
  83. package/types/sse/handler.d.ts +22 -0
  84. package/types/standard-schema.d.ts +31 -0
  85. package/types/store/define-store.d.ts +31 -0
  86. package/types/store/index.d.ts +5 -0
  87. package/types/store/react.d.ts +2 -0
  88. package/types/store/serialize.d.ts +5 -0
  89. package/types/store/server-context.d.ts +4 -0
  90. package/types/store/signal.d.ts +18 -0
  91. package/types/templates.d.ts +18 -0
  92. package/types/treaty.d.ts +70 -0
  93. package/types/ws/handler.d.ts +26 -0
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.49-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.49-alpha but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
80
+ if (bindingPackageVersion !== '0.1.51-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.51-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.49-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.49-alpha but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
96
+ if (bindingPackageVersion !== '0.1.51-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.51-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.49-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.49-alpha but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
117
+ if (bindingPackageVersion !== '0.1.51-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.51-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.49-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.49-alpha but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
133
+ if (bindingPackageVersion !== '0.1.51-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.51-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.49-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.49-alpha but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
150
+ if (bindingPackageVersion !== '0.1.51-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.51-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.49-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.49-alpha but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
166
+ if (bindingPackageVersion !== '0.1.51-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.51-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.49-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.49-alpha but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
185
+ if (bindingPackageVersion !== '0.1.51-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.51-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.49-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.49-alpha but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
201
+ if (bindingPackageVersion !== '0.1.51-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.51-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.49-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.49-alpha but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
217
+ if (bindingPackageVersion !== '0.1.51-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.51-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.49-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.49-alpha but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
237
+ if (bindingPackageVersion !== '0.1.51-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.51-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.49-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.49-alpha but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
253
+ if (bindingPackageVersion !== '0.1.51-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.51-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.49-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.49-alpha but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
274
+ if (bindingPackageVersion !== '0.1.51-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.51-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.49-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.49-alpha but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
290
+ if (bindingPackageVersion !== '0.1.51-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.51-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.49-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.49-alpha but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
308
+ if (bindingPackageVersion !== '0.1.51-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.51-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.49-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.49-alpha but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
324
+ if (bindingPackageVersion !== '0.1.51-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.51-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.49-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.49-alpha but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
342
+ if (bindingPackageVersion !== '0.1.51-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.51-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.49-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.49-alpha but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
358
+ if (bindingPackageVersion !== '0.1.51-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.51-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.49-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.49-alpha but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
376
+ if (bindingPackageVersion !== '0.1.51-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.51-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.49-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.49-alpha but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
392
+ if (bindingPackageVersion !== '0.1.51-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.51-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.49-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.49-alpha but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
410
+ if (bindingPackageVersion !== '0.1.51-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.51-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.49-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.49-alpha but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
426
+ if (bindingPackageVersion !== '0.1.51-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.51-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.49-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.49-alpha but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
443
+ if (bindingPackageVersion !== '0.1.51-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.51-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.49-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.49-alpha but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
459
+ if (bindingPackageVersion !== '0.1.51-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.51-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.49-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.49-alpha but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
479
+ if (bindingPackageVersion !== '0.1.51-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.51-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.49-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.49-alpha but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
495
+ if (bindingPackageVersion !== '0.1.51-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.51-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.49-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.49-alpha but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
511
+ if (bindingPackageVersion !== '0.1.51-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.51-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(() => {})
@@ -245,6 +299,12 @@ export const brust = {
245
299
  }
246
300
  : null,
247
301
  nativeTemplate: r.nativeTemplate ?? null,
302
+ // Catch-all (`{ path: '*' }`) markers. Rust reads these via serde
303
+ // rename (`notFound` / `notFoundPrefix`) in a later task to skip the
304
+ // matchit insert + register the not-found fallback table entry.
305
+ // Emitting them now is harmless before Rust consumes them.
306
+ notFound: r.notFound === true,
307
+ notFoundPrefix: r.notFoundPrefix ?? '',
248
308
  }),
249
309
  )
250
310
  const result = (native as any).registerRoutes(configs)
@@ -255,9 +315,16 @@ export const brust = {
255
315
  // before any traffic hits.
256
316
  const expected = routes.filter((r) => r.nativeTemplate).map((r) => r.nativeTemplate!)
257
317
  if (expected.length > 0) {
258
- const registered = new Set<string>((native as any).napiListNativeTemplates() ?? [])
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
+ })()
259
326
  for (const name of expected) {
260
- if (!registered.has(name)) {
327
+ if (!hasTemplate(name)) {
261
328
  console.warn(
262
329
  `[brust] native: true route expects template "${name}.jinja" but it's not registered (boot warning — request will 500)`,
263
330
  )
@@ -372,6 +439,9 @@ export const brust = {
372
439
  actions?: import('./define-actions.ts').ActionsBuilder
373
440
  /** URL prefix the action router mounts under. Threaded to serve(). */
374
441
  actionPrefix?: string
442
+ /** Optional global CORS policy — see {@link CorsOptions}. Threaded to
443
+ * serve() like `actionPrefix`. */
444
+ cors?: CorsOptions
375
445
  /** Overrides merged into the underlying `serve()` call (main thread). */
376
446
  serve?: Partial<Omit<ServeOptions, 'entry' | 'actions' | 'mcp'>>
377
447
  /** Per-worker SAB size in bytes. Default 256 KB. */
@@ -419,13 +489,18 @@ export const brust = {
419
489
  const endpoints: EndpointDef[] = opts.actions?.endpoints ?? []
420
490
 
421
491
  if (!isWorker) {
422
- const { host, port, workers, cacheMaxEntries, cachePageMaxEntries } = await loadConfig(
423
- process.cwd(),
424
- {
425
- host: opts.address,
426
- port: opts.port,
427
- },
428
- )
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
+ })
429
504
  console.log(`[brust] main: spawning ${workers} worker threads`)
430
505
  if (cacheMaxEntries !== undefined || cachePageMaxEntries !== undefined)
431
506
  this.configureCache({
@@ -433,6 +508,23 @@ export const brust = {
433
508
  pageMaxEntries: cachePageMaxEntries ?? 1000,
434
509
  })
435
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
+
436
528
  // md routes present? (leaf carries `__mdSource`, attached by mdRoutes()).
437
529
  // Checked inline — no md-module import — so md-free apps never load the
438
530
  // markdown pipeline. Gates the md emits below AND in the dev coordinator.
@@ -857,6 +949,7 @@ export const brust = {
857
949
  entry: opts.entry,
858
950
  actions: opts.actions,
859
951
  actionPrefix: opts.actionPrefix,
952
+ cors: opts.cors,
860
953
  ...(mcpManifest ? { mcp: { manifest: mcpManifest } } : {}),
861
954
  ...opts.serve,
862
955
  })
@@ -1019,6 +1112,8 @@ export {
1019
1112
  notFound,
1020
1113
  redirect,
1021
1114
  isNativeVerdict,
1115
+ httpError,
1116
+ isHttpErrorTrigger,
1022
1117
  } from './routes.ts'
1023
1118
  export type {
1024
1119
  Route,
@@ -1030,6 +1125,8 @@ export type {
1030
1125
  RouteResponse,
1031
1126
  Middleware,
1032
1127
  NativeVerdict,
1128
+ HttpErrorOpts,
1129
+ HttpErrorTrigger,
1033
1130
  } from './routes.ts'
1034
1131
 
1035
1132
  export { defineActions, isValidEndpointPath } from './define-actions.ts'
@@ -1072,12 +1169,20 @@ export type { StoreHandle, Snapshot, Signal, Computed } from './store/index.ts'
1072
1169
  // exported.
1073
1170
  export { dedupe, cachedFetch } from './loader-cache.ts'
1074
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
+
1075
1178
  export { buildIslands } from './islands/build.ts'
1076
1179
  export type { IslandsBuildResult, BuildIslandsOptions } from './islands/build.ts'
1077
1180
 
1078
1181
  export { cache } from './cache.ts'
1079
1182
  export type { InvalidateArgs } from './cache.ts'
1080
1183
 
1184
+ export { templates } from './templates.ts'
1185
+
1081
1186
  export { getRequestContext } from './request-context.ts'
1082
1187
  export { cookies } from './cookies.ts'
1083
1188
  export type { CookieOptions } from './cookies.ts'
@@ -9,7 +9,12 @@
9
9
  export interface PagePayload {
10
10
  html: string
11
11
  title: string
12
- store?: Record<string, Record<string, unknown>>
12
+ store?: Record<string, Record<string, unknown>> | null
13
+ /** True when this payload was delivered at HTTP 404 (a rendered catch-all
14
+ * page, NOT a transport error). The caller swaps it in-place like any other
15
+ * payload but must NOT cache it — a 404 is not a stable, re-servable entry,
16
+ * and caching it would poison a later real navigation to the same path. */
17
+ notFound?: boolean
13
18
  }
14
19
 
15
20
  /** Bound the cache so a long session can't grow memory unbounded (LRU evict). */
@@ -60,7 +65,32 @@ export async function fetchPagePayload(url: URL, signal?: AbortSignal): Promise<
60
65
  signal,
61
66
  headers: { Accept: 'application/json' },
62
67
  })
63
- if (!resp.ok) throw new Error(`navigation: status ${resp.status}`)
68
+ // A 404 carrying a rendered page payload (the framework's catch-all 404 page)
69
+ // is renderable, NOT a transport error: parse it, tag it `notFound`, and hand
70
+ // it to the caller to swap in-place. Anything else that isn't 2xx (5xx, other
71
+ // statuses) is a real transport failure → throw so the caller full-reloads or
72
+ // tries the `fallback:'client'` takeover. A 404 whose body is empty / not a
73
+ // valid `{ html }` payload is ALSO a transport failure (no page to render):
74
+ // the json()/shape check below throws and is caught here.
75
+ if (!resp.ok) {
76
+ if (resp.status === 404) {
77
+ try {
78
+ const payload = (await resp.json()) as PagePayload
79
+ // `html` is the SOLE discriminator: its presence means "a renderable
80
+ // page came back" (vs a bare transport 404). `title`/`store` are NOT
81
+ // required — title may legitimately be empty, and `store` is null for a
82
+ // native catch-all; both have downstream guards (bootstrap applies the
83
+ // snapshot only when truthy, same contract as the 200 path). Requiring
84
+ // them here would spuriously full-reload valid 404 pages.
85
+ if (payload && typeof payload.html === 'string') {
86
+ return { ...payload, notFound: true }
87
+ }
88
+ } catch {
89
+ // empty / non-JSON 404 body → fall through to the transport-error throw
90
+ }
91
+ }
92
+ throw new Error(`navigation: status ${resp.status}`)
93
+ }
64
94
  const payload = (await resp.json()) as PagePayload
65
95
  setCachedPage(pageCacheKey(url), payload)
66
96
  return payload