@brust/core 2.0.0-alpha.26 → 2.0.0-alpha.28
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/native/index.js +54 -54
- package/package.json +10 -9
- package/src/actions/client.ts +8 -1
- package/src/browser.ts +1 -1
- package/src/build/bundle.ts +5 -0
- package/src/build/manifest.ts +16 -2
- package/src/cache-adapter/types.ts +1 -1
- package/src/handlers.ts +72 -12
- package/src/index.ts +1 -1
- package/src/navigate-browser.ts +9 -3
- package/src/navigate.ts +3 -0
- package/src/navigation.ts +91 -0
- package/src/routes.ts +10 -0
- package/src/shadcn/init.ts +1 -1
- package/src/store/builtin.ts +4 -0
- package/src/worker.ts +1 -0
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.
|
|
93
|
-
throw new Error(`Native binding package version mismatch, expected 2.0.0-alpha.
|
|
92
|
+
if (bindingPackageVersion !== '2.0.0-alpha.28' && 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.28 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.
|
|
109
|
-
throw new Error(`Native binding package version mismatch, expected 2.0.0-alpha.
|
|
108
|
+
if (bindingPackageVersion !== '2.0.0-alpha.28' && 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.28 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.
|
|
130
|
-
throw new Error(`Native binding package version mismatch, expected 2.0.0-alpha.
|
|
129
|
+
if (bindingPackageVersion !== '2.0.0-alpha.28' && 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.28 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.
|
|
146
|
-
throw new Error(`Native binding package version mismatch, expected 2.0.0-alpha.
|
|
145
|
+
if (bindingPackageVersion !== '2.0.0-alpha.28' && 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.28 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.
|
|
163
|
-
throw new Error(`Native binding package version mismatch, expected 2.0.0-alpha.
|
|
162
|
+
if (bindingPackageVersion !== '2.0.0-alpha.28' && 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.28 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.
|
|
179
|
-
throw new Error(`Native binding package version mismatch, expected 2.0.0-alpha.
|
|
178
|
+
if (bindingPackageVersion !== '2.0.0-alpha.28' && 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.28 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.
|
|
198
|
-
throw new Error(`Native binding package version mismatch, expected 2.0.0-alpha.
|
|
197
|
+
if (bindingPackageVersion !== '2.0.0-alpha.28' && 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.28 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.
|
|
214
|
-
throw new Error(`Native binding package version mismatch, expected 2.0.0-alpha.
|
|
213
|
+
if (bindingPackageVersion !== '2.0.0-alpha.28' && 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.28 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.
|
|
230
|
-
throw new Error(`Native binding package version mismatch, expected 2.0.0-alpha.
|
|
229
|
+
if (bindingPackageVersion !== '2.0.0-alpha.28' && 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.28 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.
|
|
250
|
-
throw new Error(`Native binding package version mismatch, expected 2.0.0-alpha.
|
|
249
|
+
if (bindingPackageVersion !== '2.0.0-alpha.28' && 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.28 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.
|
|
266
|
-
throw new Error(`Native binding package version mismatch, expected 2.0.0-alpha.
|
|
265
|
+
if (bindingPackageVersion !== '2.0.0-alpha.28' && 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.28 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.
|
|
287
|
-
throw new Error(`Native binding package version mismatch, expected 2.0.0-alpha.
|
|
286
|
+
if (bindingPackageVersion !== '2.0.0-alpha.28' && 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.28 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.
|
|
303
|
-
throw new Error(`Native binding package version mismatch, expected 2.0.0-alpha.
|
|
302
|
+
if (bindingPackageVersion !== '2.0.0-alpha.28' && 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.28 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.
|
|
321
|
-
throw new Error(`Native binding package version mismatch, expected 2.0.0-alpha.
|
|
320
|
+
if (bindingPackageVersion !== '2.0.0-alpha.28' && 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.28 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.
|
|
337
|
-
throw new Error(`Native binding package version mismatch, expected 2.0.0-alpha.
|
|
336
|
+
if (bindingPackageVersion !== '2.0.0-alpha.28' && 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.28 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.
|
|
355
|
-
throw new Error(`Native binding package version mismatch, expected 2.0.0-alpha.
|
|
354
|
+
if (bindingPackageVersion !== '2.0.0-alpha.28' && 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.28 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.
|
|
371
|
-
throw new Error(`Native binding package version mismatch, expected 2.0.0-alpha.
|
|
370
|
+
if (bindingPackageVersion !== '2.0.0-alpha.28' && 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.28 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.
|
|
389
|
-
throw new Error(`Native binding package version mismatch, expected 2.0.0-alpha.
|
|
388
|
+
if (bindingPackageVersion !== '2.0.0-alpha.28' && 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.28 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.
|
|
405
|
-
throw new Error(`Native binding package version mismatch, expected 2.0.0-alpha.
|
|
404
|
+
if (bindingPackageVersion !== '2.0.0-alpha.28' && 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.28 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.
|
|
423
|
-
throw new Error(`Native binding package version mismatch, expected 2.0.0-alpha.
|
|
422
|
+
if (bindingPackageVersion !== '2.0.0-alpha.28' && 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.28 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.
|
|
439
|
-
throw new Error(`Native binding package version mismatch, expected 2.0.0-alpha.
|
|
438
|
+
if (bindingPackageVersion !== '2.0.0-alpha.28' && 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.28 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.
|
|
456
|
-
throw new Error(`Native binding package version mismatch, expected 2.0.0-alpha.
|
|
455
|
+
if (bindingPackageVersion !== '2.0.0-alpha.28' && 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.28 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.
|
|
472
|
-
throw new Error(`Native binding package version mismatch, expected 2.0.0-alpha.
|
|
471
|
+
if (bindingPackageVersion !== '2.0.0-alpha.28' && 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.28 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.
|
|
492
|
-
throw new Error(`Native binding package version mismatch, expected 2.0.0-alpha.
|
|
491
|
+
if (bindingPackageVersion !== '2.0.0-alpha.28' && 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.28 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.
|
|
508
|
-
throw new Error(`Native binding package version mismatch, expected 2.0.0-alpha.
|
|
507
|
+
if (bindingPackageVersion !== '2.0.0-alpha.28' && 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.28 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.
|
|
524
|
-
throw new Error(`Native binding package version mismatch, expected 2.0.0-alpha.
|
|
523
|
+
if (bindingPackageVersion !== '2.0.0-alpha.28' && 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.28 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.
|
|
665
|
-
throw new Error(`WASI binding package version mismatch, expected 2.0.0-alpha.
|
|
664
|
+
if (bindingPackageVersion !== '2.0.0-alpha.28') {
|
|
665
|
+
throw new Error(`WASI binding package version mismatch, expected 2.0.0-alpha.28 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
666
666
|
}
|
|
667
667
|
}
|
|
668
668
|
wasiBinding = require('@brust/native-wasm32-wasi')
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@brust/core",
|
|
3
|
-
"version": "2.0.0-alpha.
|
|
3
|
+
"version": "2.0.0-alpha.28",
|
|
4
4
|
"description": "brust v2 — React components compiled to Rust-rendered templates",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://brust.dev",
|
|
@@ -31,6 +31,7 @@
|
|
|
31
31
|
"./cache-adapter/conformance": "./src/cache-adapter/conformance.ts",
|
|
32
32
|
"./store": "./src/store/index.ts",
|
|
33
33
|
"./store/react": "./src/store/react.ts",
|
|
34
|
+
"./navigation": "./src/navigation.ts",
|
|
34
35
|
"./elysia": "./src/actions/elysia.ts",
|
|
35
36
|
"./client": "./src/actions/client.ts",
|
|
36
37
|
"./native": "./native/index.js"
|
|
@@ -55,7 +56,7 @@
|
|
|
55
56
|
]
|
|
56
57
|
},
|
|
57
58
|
"dependencies": {
|
|
58
|
-
"@brust/runtime-dom": "2.0.0-alpha.
|
|
59
|
+
"@brust/runtime-dom": "2.0.0-alpha.28",
|
|
59
60
|
"tsconfig-paths": "4.2.0"
|
|
60
61
|
},
|
|
61
62
|
"peerDependencies": {
|
|
@@ -99,12 +100,12 @@
|
|
|
99
100
|
"access": "public"
|
|
100
101
|
},
|
|
101
102
|
"optionalDependencies": {
|
|
102
|
-
"@brust/native-darwin-x64": "2.0.0-alpha.
|
|
103
|
-
"@brust/native-darwin-arm64": "2.0.0-alpha.
|
|
104
|
-
"@brust/native-linux-x64-gnu": "2.0.0-alpha.
|
|
105
|
-
"@brust/native-linux-arm64-gnu": "2.0.0-alpha.
|
|
106
|
-
"@brust/native-linux-x64-musl": "2.0.0-alpha.
|
|
107
|
-
"@brust/native-linux-arm64-musl": "2.0.0-alpha.
|
|
108
|
-
"@brust/core-cf": "2.0.0-alpha.
|
|
103
|
+
"@brust/native-darwin-x64": "2.0.0-alpha.28",
|
|
104
|
+
"@brust/native-darwin-arm64": "2.0.0-alpha.28",
|
|
105
|
+
"@brust/native-linux-x64-gnu": "2.0.0-alpha.28",
|
|
106
|
+
"@brust/native-linux-arm64-gnu": "2.0.0-alpha.28",
|
|
107
|
+
"@brust/native-linux-x64-musl": "2.0.0-alpha.28",
|
|
108
|
+
"@brust/native-linux-arm64-musl": "2.0.0-alpha.28",
|
|
109
|
+
"@brust/core-cf": "2.0.0-alpha.28"
|
|
109
110
|
}
|
|
110
111
|
}
|
package/src/actions/client.ts
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
// elysia is type-only here. Differences from 0.1.x runtime/treaty.ts: docs/actions.md "The client".
|
|
3
3
|
import { type Treaty, treaty } from '@elysia/eden/treaty2'
|
|
4
4
|
import type { AnyElysia } from 'elysia'
|
|
5
|
+
import { clearNavigationCache } from '../navigate-browser'
|
|
5
6
|
import { type ActionCredentials, DEFAULT_ACTION_PREFIX } from './prefix'
|
|
6
7
|
|
|
7
8
|
export { DEFAULT_ACTION_PREFIX }
|
|
@@ -62,10 +63,16 @@ export function client<const App extends AnyElysia, Head extends Record<string,
|
|
|
62
63
|
// The root prefix (an actions-only deployment) adds nothing to the base: `https://api.example.com/team`, not `//team`.
|
|
63
64
|
const base = resolveBaseUrl(opts)
|
|
64
65
|
const prefix = resolvePrefix(opts)
|
|
66
|
+
// SPA navigation design §10.1: a mutation clears the page cache, so no page read after it is served from before it
|
|
67
|
+
const send = (async (url: RequestInfo | URL, req?: RequestInit) => {
|
|
68
|
+
const res = await (fetcher ?? fetch)(url, req)
|
|
69
|
+
if (!/^(GET|HEAD)$/i.test(req?.method ?? 'GET')) clearNavigationCache()
|
|
70
|
+
return res
|
|
71
|
+
}) as typeof fetch
|
|
65
72
|
return treaty<App, Head>(base !== '' && prefix === '/' ? base : base + prefix, {
|
|
66
73
|
...rest,
|
|
67
74
|
keepDomain: true,
|
|
68
|
-
|
|
75
|
+
fetcher: send,
|
|
69
76
|
...(init || defaults ? { fetch: typeof init === 'function' ? init : { ...defaults, ...init } } : {}),
|
|
70
77
|
})
|
|
71
78
|
}
|
package/src/browser.ts
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
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
|
-
export { navigate } from './navigate-browser'
|
|
8
|
+
export { clearNavigationCache, navigate } from './navigate-browser'
|
|
9
9
|
export type { NavErrorDetail, NavLoadDetail, NavigateOptions, NavSuccessDetail, NavTrigger } from './navigate'
|
|
10
10
|
import type { InvalidateArgs, InvalidateResult } from './native'
|
|
11
11
|
|
package/src/build/bundle.ts
CHANGED
|
@@ -18,6 +18,7 @@ import { isServerOnlyMarker, serverOnlyEmptyPlugin } from './server-only'
|
|
|
18
18
|
import { RUNTIME_FEATURES } from './features'
|
|
19
19
|
import { RELATIVE_SPEC, type ResolveTarget, resolveNative } from './esm-resolve'
|
|
20
20
|
import { packageDirOf } from './pkg-src'
|
|
21
|
+
import { BUILTIN_STORE_MODULES } from '../store/builtin'
|
|
21
22
|
|
|
22
23
|
const REACT_EXTERNALS = ['react', 'react/*', 'react-dom', 'react-dom/*']
|
|
23
24
|
/** Production React (and the production JSX transform: `react/jsx-runtime`, never `jsxDEV`). `brust dev` builds set
|
|
@@ -741,6 +742,10 @@ export async function buildJobs(
|
|
|
741
742
|
const entries: string[] = []
|
|
742
743
|
const storePaths = [...new Set(stores)].sort()
|
|
743
744
|
for (const [i, p] of storePaths.entries()) {
|
|
745
|
+
if (BUILTIN_STORE_MODULES.includes(p)) {
|
|
746
|
+
imports.push(`import * as S${i} from ${JSON.stringify(p)}`) // a package module, external in jobs.js
|
|
747
|
+
continue
|
|
748
|
+
}
|
|
744
749
|
if (isAbsolute(p) || p.split('/').includes('..') || !isFile(resolve(appRoot, p))) {
|
|
745
750
|
throw new BuildError('store-module', `store module ${p} is not a file inside the app (${appRoot})`)
|
|
746
751
|
}
|
package/src/build/manifest.ts
CHANGED
|
@@ -102,10 +102,24 @@ export interface ManifestJson {
|
|
|
102
102
|
|
|
103
103
|
/** F165 (R40.1): whether any request can call a worker. Workers answer four kinds of call
|
|
104
104
|
* (worker.ts): `loader`, `jobs` (precompute and SSR), `fetch` (the local actions app) and `cache`
|
|
105
|
-
* (the adapter). Only the jobs a request can plan count (`reachedJobs`, F183). */
|
|
105
|
+
* (the adapter). Only the jobs a request can plan count (`reachedJobs`, F183); a store read counts too (`readsStores`). */
|
|
106
106
|
export function needsWorkers(m: Pick<ManifestJson, 'routes' | 'components' | 'actions' | 'cache'>): boolean {
|
|
107
107
|
const planned = [...reachedJobs(m).planned].some((id) => (m.components[id]?.jobs.length ?? 0) > 0)
|
|
108
|
-
return planned || m.routes.some((r) => r.loaders.length > 0) || m.actions !== null || m.cache !== undefined
|
|
108
|
+
return planned || m.routes.some((r) => r.loaders.length > 0) || readsStores(m) || m.actions !== null || m.cache !== undefined
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/** A route whose chain reads a store (its components, their children and job targets, transitively) gets a loader call
|
|
112
|
+
* from brust-core even with no loader of its own: the worker builds the `__store` snapshot (pipeline.rs `reads_store`).
|
|
113
|
+
* Without a pool that call answers 503. */
|
|
114
|
+
function readsStores(m: Pick<ManifestJson, 'routes' | 'components'>): boolean {
|
|
115
|
+
const seen = new Set<string>()
|
|
116
|
+
const reads = (id: string): boolean => {
|
|
117
|
+
if (seen.has(id)) return false
|
|
118
|
+
seen.add(id)
|
|
119
|
+
const c = m.components[id]
|
|
120
|
+
return !!c && (c.stores.length > 0 || c.children.some((k) => reads(k.id)) || c.jobs.some((j) => j.target !== undefined && reads(j.target)))
|
|
121
|
+
}
|
|
122
|
+
return m.routes.some((r) => r.chain.some(reads))
|
|
109
123
|
}
|
|
110
124
|
|
|
111
125
|
/** F183: the jobs a request can call, as brust-core plans them (`collect_jobs`, pipeline.rs): every job of each
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// The cache adapter contract (
|
|
1
|
+
// The cache adapter contract (cache adapter design §3.1): a shared second
|
|
2
2
|
// tier behind brust's in-process cache. An adapter has two optional capabilities — a `store` of
|
|
3
3
|
// rendered pages and a `broadcast` of invalidations (push `subscribe` or pull `since`) — so a store
|
|
4
4
|
// without a channel (KV) can be composed with another adapter's broadcast (DO).
|
package/src/handlers.ts
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
// `worker.ts` re-exports everything here, so existing importers are unchanged.
|
|
4
4
|
import { installServerResolver, type StoreSnapshot } from './store/core-adapter'
|
|
5
5
|
import { collectSnapshot, getServerInstance, runInStoreContext, touchStores } from './store/server-context'
|
|
6
|
+
import { NAVIGATION_MODULE } from './store/builtin'
|
|
6
7
|
import { type FlatRoute, isHttpErrorTrigger, isVerdict, type LoaderReq, type Route, type Verdict } from './routes'
|
|
7
8
|
|
|
8
9
|
installServerResolver(getServerInstance)
|
|
@@ -19,11 +20,14 @@ export interface LoaderRequest {
|
|
|
19
20
|
plan?: boolean
|
|
20
21
|
}
|
|
21
22
|
|
|
23
|
+
/** Response headers as `[name, value]` pairs: a repeated name (`set-cookie`) stays repeated. */
|
|
24
|
+
export type HeaderPairs = [string, string][]
|
|
25
|
+
|
|
22
26
|
export type LoaderResponse =
|
|
23
|
-
| { ok: true; data: Record<string, unknown>; headers?:
|
|
24
|
-
| { verdict: 'notFound'; data: unknown; store?: StoreSnapshot | null }
|
|
25
|
-
| { verdict: 'redirect'; location: string; status: number }
|
|
26
|
-
| { verdict: 'httpError'; status: number; body: string }
|
|
27
|
+
| { ok: true; data: Record<string, unknown>; headers?: HeaderPairs; store?: StoreSnapshot | null }
|
|
28
|
+
| { verdict: 'notFound'; data: unknown; headers?: HeaderPairs; store?: StoreSnapshot | null }
|
|
29
|
+
| { verdict: 'redirect'; location: string; status: number; headers?: HeaderPairs }
|
|
30
|
+
| { verdict: 'httpError'; status: number; body: string; headers?: HeaderPairs }
|
|
27
31
|
| { error: string }
|
|
28
32
|
|
|
29
33
|
export type JobKind = 'precompute' | 'ssr'
|
|
@@ -131,6 +135,47 @@ function withStore<T extends LoaderResponse>(r: T): T {
|
|
|
131
135
|
|
|
132
136
|
// ---- handlers ----
|
|
133
137
|
|
|
138
|
+
// ---- response headers (F464) ----
|
|
139
|
+
|
|
140
|
+
/** Names the server owns: the framing, the page's type, and a redirect's target (`redirect()`). */
|
|
141
|
+
const REFUSED_HEADERS = new Set(['content-type', 'content-length', 'transfer-encoding', 'connection', 'location'])
|
|
142
|
+
|
|
143
|
+
/** `res.headers`: a `Headers` that refuses the server's names, by a throw in dev (the loader fails with a 500 that
|
|
144
|
+
* names it) and by a warning in production (the call does nothing). */
|
|
145
|
+
class LoaderHeaders extends Headers {
|
|
146
|
+
constructor(private readonly dev: boolean) {
|
|
147
|
+
super()
|
|
148
|
+
}
|
|
149
|
+
private allowed(name: string): boolean {
|
|
150
|
+
if (!REFUSED_HEADERS.has(name.trim().toLowerCase())) return true
|
|
151
|
+
const msg = `res.headers: a loader cannot set "${name}" (the server sets it${name.trim().toLowerCase() === 'location' ? '; use redirect()' : ''})`
|
|
152
|
+
if (this.dev) throw new Error(msg)
|
|
153
|
+
console.warn(`[brust] warning ${msg}; dropped`)
|
|
154
|
+
return false
|
|
155
|
+
}
|
|
156
|
+
override set(name: string, value: string): void {
|
|
157
|
+
if (this.allowed(name)) super.set(name, value)
|
|
158
|
+
}
|
|
159
|
+
override append(name: string, value: string): void {
|
|
160
|
+
if (this.allowed(name)) super.append(name, value)
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
/** The wire pairs, absent when empty. `Set-Cookie` one pair per cookie (iteration would join them). */
|
|
165
|
+
function headerPairs(h: Headers): HeaderPairs | undefined {
|
|
166
|
+
const out: HeaderPairs = []
|
|
167
|
+
for (const [k, v] of h) if (k !== 'set-cookie') out.push([k, v])
|
|
168
|
+
for (const c of h.getSetCookie()) out.push(['set-cookie', c])
|
|
169
|
+
return out.length > 0 ? out : undefined
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
/** `r` with `headers` set when there are any. */
|
|
173
|
+
function withHeaders<T extends LoaderResponse>(r: T, h: Headers): T {
|
|
174
|
+
const pairs = headerPairs(h)
|
|
175
|
+
if (pairs) (r as { headers?: HeaderPairs }).headers = pairs
|
|
176
|
+
return r
|
|
177
|
+
}
|
|
178
|
+
|
|
134
179
|
/** `parent`: the data the chain merged before the verdict. A notFound renders the route's
|
|
135
180
|
* template (layouts included), so the layouts' data stays under the verdict's own keys. */
|
|
136
181
|
function verdictJson(v: Verdict, parent: Record<string, unknown>): LoaderResponse {
|
|
@@ -189,6 +234,8 @@ export function makeHandlers(opts: {
|
|
|
189
234
|
stores?: Record<string, object>
|
|
190
235
|
/** Static output (R9.5): loaders see `ssgRequest`, and what a static file drops is recorded. */
|
|
191
236
|
ssg?: (r: SsgRecord) => void
|
|
237
|
+
/** `brust dev`: a refused `res.headers` name throws instead of being dropped with a warning (F464). */
|
|
238
|
+
dev?: boolean
|
|
192
239
|
}): Handlers {
|
|
193
240
|
const byId = new Map(opts.leaves.map((l) => [l.id, l]))
|
|
194
241
|
const literals = literalsIndex(opts.manifest)
|
|
@@ -234,29 +281,42 @@ export function makeHandlers(opts: {
|
|
|
234
281
|
// loader's data is assigned as data, as the spread copied it.
|
|
235
282
|
return runInStoreContext(async () => {
|
|
236
283
|
const merged: Record<string, unknown> = Object.create(null)
|
|
284
|
+
const res = { headers: new LoaderHeaders(opts.dev === true) }
|
|
285
|
+
// R9.5: a static file carries no headers; the build warns, naming them.
|
|
286
|
+
const out = <T extends LoaderResponse>(r: T): T => {
|
|
287
|
+
withHeaders(r, res.headers)
|
|
288
|
+
const names = (r as { headers?: HeaderPairs }).headers?.map(([n]) => n)
|
|
289
|
+
if (opts.ssg && names) opts.ssg({ kind: 'headers', routeId: req.routeId, path: req.path, names: [...new Set(names)] })
|
|
290
|
+
return r
|
|
291
|
+
}
|
|
237
292
|
try {
|
|
238
293
|
const touch = storeIdx.get(req.routeId)
|
|
239
|
-
if (touch)
|
|
294
|
+
if (touch) {
|
|
295
|
+
touchStores(touch, storeTable)
|
|
296
|
+
// The built-in `navigation` store (design §11) paints the request's path + search on first paint.
|
|
297
|
+
if (touch.includes(NAVIGATION_MODULE)) (storeTable[NAVIGATION_MODULE] as { navigation?: { hydrate(s: object): void } } | undefined)?.navigation?.hydrate({ url: req.req.url })
|
|
298
|
+
}
|
|
240
299
|
for (const node of leaf.chain) {
|
|
241
300
|
if (!node.loader) continue
|
|
242
301
|
let r: unknown
|
|
243
302
|
try {
|
|
244
303
|
const lreq = opts.ssg ? ssgRequest(req.req, req.routeId, req.path, opts.ssg) : req.req
|
|
245
|
-
r = await node.loader({ params: req.params, path: req.path, req: lreq })
|
|
304
|
+
r = await node.loader({ params: req.params, path: req.path, req: lreq, res })
|
|
246
305
|
} catch (e) {
|
|
247
|
-
if (isHttpErrorTrigger(e))
|
|
306
|
+
if (isHttpErrorTrigger(e)) {
|
|
307
|
+
// httpError's own `headers` option adds to what the chain set
|
|
308
|
+
for (const [k, v] of Object.entries(e.headers ?? {})) res.headers.append(k, v)
|
|
309
|
+
return out({ verdict: 'httpError', status: e.status, body: e.body } as LoaderResponse)
|
|
310
|
+
}
|
|
248
311
|
throw e
|
|
249
312
|
}
|
|
250
313
|
if (isVerdict(r)) {
|
|
251
|
-
const v = verdictJson(r, merged)
|
|
314
|
+
const v = out(verdictJson(r, merged))
|
|
252
315
|
return 'verdict' in v && v.verdict === 'notFound' ? withStore(v) : v
|
|
253
316
|
}
|
|
254
317
|
if (r && typeof r === 'object') Object.assign(merged, r)
|
|
255
318
|
}
|
|
256
|
-
|
|
257
|
-
const headers = (ok as { headers?: Record<string, string> }).headers
|
|
258
|
-
if (opts.ssg && headers && Object.keys(headers).length > 0) opts.ssg({ kind: 'headers', routeId: req.routeId, path: req.path, names: Object.keys(headers) })
|
|
259
|
-
return ok
|
|
319
|
+
return out(withStore({ ok: true, data: merged } as LoaderResponse))
|
|
260
320
|
} catch (e) {
|
|
261
321
|
return { error: String(e) } as LoaderResponse
|
|
262
322
|
}
|
package/src/index.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
/// <reference path="./assets.d.ts" />
|
|
3
3
|
// `@brust/core`: the app-facing API.
|
|
4
4
|
export { buildTime } from './build-time'
|
|
5
|
-
export { navigate } from './navigate'
|
|
5
|
+
export { clearNavigationCache, navigate } from './navigate'
|
|
6
6
|
export type { NavErrorDetail, NavLoadDetail, NavigateOptions, NavSuccessDetail, NavTrigger } from './navigate'
|
|
7
7
|
export { cache } from './cache'
|
|
8
8
|
export { type BrustConfig, BrustConfigError, loadConfig } from './config'
|
package/src/navigate-browser.ts
CHANGED
|
@@ -2,12 +2,18 @@
|
|
|
2
2
|
// cross-chunk pattern as `brust.stores`) and resolves after `success` or `error`. Without `nav` it is a full load.
|
|
3
3
|
import type { NavigateOptions } from './navigate'
|
|
4
4
|
|
|
5
|
-
type Bridge = { navigate(url: string, opts?: NavigateOptions): Promise<void
|
|
5
|
+
type Bridge = { navigate(url: string, opts?: NavigateOptions): Promise<void>; clearCache(): void }
|
|
6
|
+
const bridge = () => (globalThis as { [k: symbol]: Bridge | undefined })[Symbol.for('brust.nav')]
|
|
6
7
|
|
|
7
8
|
export function navigate(url: string, opts?: NavigateOptions): Promise<void> {
|
|
8
|
-
const
|
|
9
|
-
if (
|
|
9
|
+
const b = bridge()
|
|
10
|
+
if (b) return b.navigate(url, opts)
|
|
10
11
|
if (opts?.replace) location.replace(url)
|
|
11
12
|
else location.assign(url)
|
|
12
13
|
return Promise.resolve()
|
|
13
14
|
}
|
|
15
|
+
|
|
16
|
+
/** Drop every page the SPA navigation cache holds (design §10.1), e.g. after a mutation made outside `client()`. */
|
|
17
|
+
export function clearNavigationCache(): void {
|
|
18
|
+
bridge()?.clearCache()
|
|
19
|
+
}
|
package/src/navigate.ts
CHANGED
|
@@ -14,3 +14,6 @@ export interface NavErrorDetail extends NavLoadDetail { status?: number; error?:
|
|
|
14
14
|
export function navigate(_url: string, _opts?: NavigateOptions): Promise<void> {
|
|
15
15
|
throw new Error('navigate is browser-only (call it from a component or island running in the browser)')
|
|
16
16
|
}
|
|
17
|
+
|
|
18
|
+
/** The page cache lives in the browser: nothing to clear on the server. */
|
|
19
|
+
export function clearNavigationCache(): void {}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
// The built-in `navigation` store (SPA navigation design §11): the `brust:nav:*` events as
|
|
2
|
+
// signals, so a component reads navigation state through `useStore(navigation)` like any other store. Browser-safe and
|
|
3
|
+
// React-free, like `@brust/core/store`. The name is reserved (the compiler refuses a user `defineStore('navigation')`).
|
|
4
|
+
//
|
|
5
|
+
// Server: the factory paints `idle` and the loader seeds `url` with the request's path + search (handlers.ts), so the first
|
|
6
|
+
// paint is right and hydration matches. Browser: this module listens to the four events once and `batch`-sets the signals.
|
|
7
|
+
import { batch, defineStore, signal } from '@brust/runtime-dom/store'
|
|
8
|
+
|
|
9
|
+
export type NavigationTrigger = 'link' | 'navigate' | 'popstate'
|
|
10
|
+
|
|
11
|
+
const at = (): string => (typeof location === 'undefined' ? '/' : location.pathname + location.search)
|
|
12
|
+
|
|
13
|
+
/** `new URL(href).pathname + search`, the way the store spells a page; `href` itself when it does not parse. */
|
|
14
|
+
const path = (href: unknown): string => {
|
|
15
|
+
try {
|
|
16
|
+
const u = new URL(String(href), typeof location === 'undefined' ? 'http://x' : location.href)
|
|
17
|
+
return u.pathname + u.search
|
|
18
|
+
} catch {
|
|
19
|
+
return String(href)
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
declare const __BRUST_DEV__: boolean | undefined
|
|
24
|
+
|
|
25
|
+
// Instances this module's factory made: a record under the name that is not one belongs to someone else's defineStore.
|
|
26
|
+
const made = new WeakSet<object>()
|
|
27
|
+
|
|
28
|
+
export const navigation = defineStore('navigation', () => {
|
|
29
|
+
const store = {
|
|
30
|
+
/** `'loading'` from `brust:nav:load` until `success` / `error`. */
|
|
31
|
+
state: signal<'idle' | 'loading'>('idle'),
|
|
32
|
+
/** Path + search of the page on screen: updated at `success`, and at `error` when the page was swapped in. */
|
|
33
|
+
url: signal<string>(at()),
|
|
34
|
+
/** Path + search being loaded, else `null`. */
|
|
35
|
+
to: signal<string | null>(null),
|
|
36
|
+
/** Of the current or last navigation. */
|
|
37
|
+
trigger: signal<NavigationTrigger | null>(null),
|
|
38
|
+
/** HTTP status of the last navigation. */
|
|
39
|
+
status: signal<number | null>(null),
|
|
40
|
+
/** Message of the last failed navigation; cleared at the next `load`. */
|
|
41
|
+
error: signal<string | null>(null),
|
|
42
|
+
/** The last navigation id (0 before any). */
|
|
43
|
+
id: signal<number>(0),
|
|
44
|
+
}
|
|
45
|
+
made.add(store)
|
|
46
|
+
return store
|
|
47
|
+
})
|
|
48
|
+
|
|
49
|
+
// One subscription per tab, whichever chunk evaluates this module first (the store registry is shared the same way).
|
|
50
|
+
const BOUND = Symbol.for('brust.navigation')
|
|
51
|
+
if (typeof document !== 'undefined' && !(globalThis as { [BOUND]?: true })[BOUND]) {
|
|
52
|
+
;(globalThis as { [BOUND]?: true })[BOUND] = true
|
|
53
|
+
// A user `defineStore('navigation', …)` outside a component is not seen by the compiler (`store-name-reserved`); it
|
|
54
|
+
// would share this record by name, so say so in dev.
|
|
55
|
+
if (typeof __BRUST_DEV__ !== 'undefined' && __BRUST_DEV__ && !made.has(navigation()))
|
|
56
|
+
console.warn("[brust] the store name 'navigation' is reserved for @brust/core/navigation, but another defineStore('navigation') made the record in use; rename yours")
|
|
57
|
+
const on = (name: string, apply: (d: Record<string, unknown>) => void) =>
|
|
58
|
+
document.addEventListener(`brust:nav:${name}`, (e) => apply((e as CustomEvent).detail ?? {}))
|
|
59
|
+
on('load', (d) =>
|
|
60
|
+
batch(() => {
|
|
61
|
+
navigation.state.set('loading')
|
|
62
|
+
navigation.to.set(path(d.url))
|
|
63
|
+
navigation.trigger.set(d.trigger as NavigationTrigger)
|
|
64
|
+
navigation.error.set(null)
|
|
65
|
+
navigation.id.set(d.id as number)
|
|
66
|
+
}),
|
|
67
|
+
)
|
|
68
|
+
on('success', (d) =>
|
|
69
|
+
batch(() => {
|
|
70
|
+
navigation.state.set('idle')
|
|
71
|
+
navigation.url.set(path(d.url))
|
|
72
|
+
navigation.to.set(null)
|
|
73
|
+
navigation.trigger.set(d.trigger as NavigationTrigger)
|
|
74
|
+
navigation.status.set(d.status as number)
|
|
75
|
+
navigation.error.set(null)
|
|
76
|
+
navigation.id.set(d.id as number)
|
|
77
|
+
}),
|
|
78
|
+
)
|
|
79
|
+
on('error', (d) =>
|
|
80
|
+
batch(() => {
|
|
81
|
+
navigation.state.set('idle')
|
|
82
|
+
// A swapped error page (404, 500) is on screen; a failed swap leaves the old page where it was.
|
|
83
|
+
if (d.swapped) navigation.url.set(path(d.url))
|
|
84
|
+
navigation.to.set(null)
|
|
85
|
+
navigation.trigger.set(d.trigger as NavigationTrigger)
|
|
86
|
+
navigation.status.set((d.status as number | undefined) || null) // 0: no response
|
|
87
|
+
navigation.error.set(d.error instanceof Error ? d.error.message : d.error != null ? String(d.error) : `HTTP ${d.status}`)
|
|
88
|
+
navigation.id.set(d.id as number)
|
|
89
|
+
}),
|
|
90
|
+
)
|
|
91
|
+
}
|
package/src/routes.ts
CHANGED
|
@@ -25,10 +25,20 @@ export interface LoaderReq {
|
|
|
25
25
|
search: Record<string, string>
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
+
/** The response a loader shapes (F464). One per request, shared by every loader in the chain in chain order:
|
|
29
|
+
* `set` replaces, `append` adds (repeated `Set-Cookie` survive). The headers go on whatever the chain answers:
|
|
30
|
+
* the page, `notFound()`, `redirect()` and an `httpError()`. `Content-Type`, `Content-Length`,
|
|
31
|
+
* `Transfer-Encoding`, `Connection` and `Location` are the server's (a redirect's comes from `redirect()`):
|
|
32
|
+
* setting one throws in dev and is dropped with a warning in production. */
|
|
33
|
+
export interface LoaderRes {
|
|
34
|
+
headers: Headers
|
|
35
|
+
}
|
|
36
|
+
|
|
28
37
|
export interface LoaderCtx<P = Record<string, string>> {
|
|
29
38
|
params: P
|
|
30
39
|
path: string
|
|
31
40
|
req: LoaderReq
|
|
41
|
+
res: LoaderRes
|
|
32
42
|
}
|
|
33
43
|
|
|
34
44
|
/** `brust build --target static` (gaps round R9.2): `params` lists the values of a dynamic route's
|
package/src/shadcn/init.ts
CHANGED
|
@@ -16,7 +16,7 @@ export const SHADCN_VERSION = '4.21.4'
|
|
|
16
16
|
|
|
17
17
|
/**
|
|
18
18
|
* The packages the components import (R41.5), each pinned to the exact version the transcript ran
|
|
19
|
-
* (`
|
|
19
|
+
* (`website/test/fixtures/shadcn-transcripts/shadcn-init-guide.md`, F181). They move together with `SHADCN_VERSION`: a release that moves one
|
|
20
20
|
* re-runs the transcript. A package the project already depends on, at any version, is left alone.
|
|
21
21
|
*/
|
|
22
22
|
export const SHADCN_DEP_PINS = {
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
// Store modules brust ships. The compiler names them by package specifier (`StoreRef.module`) instead of an app-relative
|
|
2
|
+
// path, so the manifest's `stores`, the `jobs.js` stores table and the loader's `touchStores` all use this spelling.
|
|
3
|
+
export const NAVIGATION_MODULE = '@brust/core/navigation'
|
|
4
|
+
export const BUILTIN_STORE_MODULES: readonly string[] = [NAVIGATION_MODULE]
|
package/src/worker.ts
CHANGED
|
@@ -215,6 +215,7 @@ export async function startWorker(opts: StartWorkerOptions = {}): Promise<number
|
|
|
215
215
|
manifest,
|
|
216
216
|
stores: (jobsMod.stores ?? {}) as Record<string, object>,
|
|
217
217
|
...(env.BRUST_SSG === '1' && env.BRUST_SSG_LOG ? { ssg: ssgLog(env.BRUST_SSG_LOG) } : {}),
|
|
218
|
+
dev: env.NODE_ENV === 'development',
|
|
218
219
|
})
|
|
219
220
|
const id = registerWorker(view, slots, makeDispatch(handlers, view, slots))
|
|
220
221
|
if (l2 && env.BRUST_WORKER_ID === '0') {
|