brustjs 0.1.45-alpha → 0.1.47-alpha
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +7 -7
- package/runtime/cli/build.ts +113 -8
- package/runtime/cli/ssg.ts +321 -10
- package/runtime/index.js +52 -52
- package/runtime/islands/bootstrap.ts +283 -11
- package/runtime/islands/build.ts +1 -1
- package/runtime/islands/fallback.ts +198 -0
- package/runtime/islands/page-cache.ts +108 -0
- package/runtime/render/stream.ts +5 -1
- package/runtime/routes.ts +97 -13
package/runtime/index.js
CHANGED
|
@@ -77,8 +77,8 @@ function requireNative() {
|
|
|
77
77
|
try {
|
|
78
78
|
const binding = require('brustjs-android-arm64')
|
|
79
79
|
const bindingPackageVersion = require('brustjs-android-arm64/package.json').version
|
|
80
|
-
if (bindingPackageVersion !== '0.1.
|
|
81
|
-
throw new Error(`Native binding package version mismatch, expected 0.1.
|
|
80
|
+
if (bindingPackageVersion !== '0.1.47-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.47-alpha but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
82
82
|
}
|
|
83
83
|
return binding
|
|
84
84
|
} catch (e) {
|
|
@@ -93,8 +93,8 @@ function requireNative() {
|
|
|
93
93
|
try {
|
|
94
94
|
const binding = require('brustjs-android-arm-eabi')
|
|
95
95
|
const bindingPackageVersion = require('brustjs-android-arm-eabi/package.json').version
|
|
96
|
-
if (bindingPackageVersion !== '0.1.
|
|
97
|
-
throw new Error(`Native binding package version mismatch, expected 0.1.
|
|
96
|
+
if (bindingPackageVersion !== '0.1.47-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.47-alpha but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
98
98
|
}
|
|
99
99
|
return binding
|
|
100
100
|
} catch (e) {
|
|
@@ -114,8 +114,8 @@ function requireNative() {
|
|
|
114
114
|
try {
|
|
115
115
|
const binding = require('brustjs-win32-x64-gnu')
|
|
116
116
|
const bindingPackageVersion = require('brustjs-win32-x64-gnu/package.json').version
|
|
117
|
-
if (bindingPackageVersion !== '0.1.
|
|
118
|
-
throw new Error(`Native binding package version mismatch, expected 0.1.
|
|
117
|
+
if (bindingPackageVersion !== '0.1.47-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.47-alpha but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
119
119
|
}
|
|
120
120
|
return binding
|
|
121
121
|
} catch (e) {
|
|
@@ -130,8 +130,8 @@ function requireNative() {
|
|
|
130
130
|
try {
|
|
131
131
|
const binding = require('brustjs-win32-x64-msvc')
|
|
132
132
|
const bindingPackageVersion = require('brustjs-win32-x64-msvc/package.json').version
|
|
133
|
-
if (bindingPackageVersion !== '0.1.
|
|
134
|
-
throw new Error(`Native binding package version mismatch, expected 0.1.
|
|
133
|
+
if (bindingPackageVersion !== '0.1.47-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.47-alpha but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
135
135
|
}
|
|
136
136
|
return binding
|
|
137
137
|
} catch (e) {
|
|
@@ -147,8 +147,8 @@ function requireNative() {
|
|
|
147
147
|
try {
|
|
148
148
|
const binding = require('brustjs-win32-ia32-msvc')
|
|
149
149
|
const bindingPackageVersion = require('brustjs-win32-ia32-msvc/package.json').version
|
|
150
|
-
if (bindingPackageVersion !== '0.1.
|
|
151
|
-
throw new Error(`Native binding package version mismatch, expected 0.1.
|
|
150
|
+
if (bindingPackageVersion !== '0.1.47-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.47-alpha but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
152
152
|
}
|
|
153
153
|
return binding
|
|
154
154
|
} catch (e) {
|
|
@@ -163,8 +163,8 @@ function requireNative() {
|
|
|
163
163
|
try {
|
|
164
164
|
const binding = require('brustjs-win32-arm64-msvc')
|
|
165
165
|
const bindingPackageVersion = require('brustjs-win32-arm64-msvc/package.json').version
|
|
166
|
-
if (bindingPackageVersion !== '0.1.
|
|
167
|
-
throw new Error(`Native binding package version mismatch, expected 0.1.
|
|
166
|
+
if (bindingPackageVersion !== '0.1.47-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.47-alpha but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
168
168
|
}
|
|
169
169
|
return binding
|
|
170
170
|
} catch (e) {
|
|
@@ -182,8 +182,8 @@ function requireNative() {
|
|
|
182
182
|
try {
|
|
183
183
|
const binding = require('brustjs-darwin-universal')
|
|
184
184
|
const bindingPackageVersion = require('brustjs-darwin-universal/package.json').version
|
|
185
|
-
if (bindingPackageVersion !== '0.1.
|
|
186
|
-
throw new Error(`Native binding package version mismatch, expected 0.1.
|
|
185
|
+
if (bindingPackageVersion !== '0.1.47-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.47-alpha but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
187
187
|
}
|
|
188
188
|
return binding
|
|
189
189
|
} catch (e) {
|
|
@@ -198,8 +198,8 @@ function requireNative() {
|
|
|
198
198
|
try {
|
|
199
199
|
const binding = require('brustjs-darwin-x64')
|
|
200
200
|
const bindingPackageVersion = require('brustjs-darwin-x64/package.json').version
|
|
201
|
-
if (bindingPackageVersion !== '0.1.
|
|
202
|
-
throw new Error(`Native binding package version mismatch, expected 0.1.
|
|
201
|
+
if (bindingPackageVersion !== '0.1.47-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.47-alpha but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
203
203
|
}
|
|
204
204
|
return binding
|
|
205
205
|
} catch (e) {
|
|
@@ -214,8 +214,8 @@ function requireNative() {
|
|
|
214
214
|
try {
|
|
215
215
|
const binding = require('brustjs-darwin-arm64')
|
|
216
216
|
const bindingPackageVersion = require('brustjs-darwin-arm64/package.json').version
|
|
217
|
-
if (bindingPackageVersion !== '0.1.
|
|
218
|
-
throw new Error(`Native binding package version mismatch, expected 0.1.
|
|
217
|
+
if (bindingPackageVersion !== '0.1.47-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.47-alpha but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
219
219
|
}
|
|
220
220
|
return binding
|
|
221
221
|
} catch (e) {
|
|
@@ -234,8 +234,8 @@ function requireNative() {
|
|
|
234
234
|
try {
|
|
235
235
|
const binding = require('brustjs-freebsd-x64')
|
|
236
236
|
const bindingPackageVersion = require('brustjs-freebsd-x64/package.json').version
|
|
237
|
-
if (bindingPackageVersion !== '0.1.
|
|
238
|
-
throw new Error(`Native binding package version mismatch, expected 0.1.
|
|
237
|
+
if (bindingPackageVersion !== '0.1.47-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.47-alpha but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
239
239
|
}
|
|
240
240
|
return binding
|
|
241
241
|
} catch (e) {
|
|
@@ -250,8 +250,8 @@ function requireNative() {
|
|
|
250
250
|
try {
|
|
251
251
|
const binding = require('brustjs-freebsd-arm64')
|
|
252
252
|
const bindingPackageVersion = require('brustjs-freebsd-arm64/package.json').version
|
|
253
|
-
if (bindingPackageVersion !== '0.1.
|
|
254
|
-
throw new Error(`Native binding package version mismatch, expected 0.1.
|
|
253
|
+
if (bindingPackageVersion !== '0.1.47-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.47-alpha but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
255
255
|
}
|
|
256
256
|
return binding
|
|
257
257
|
} catch (e) {
|
|
@@ -271,8 +271,8 @@ function requireNative() {
|
|
|
271
271
|
try {
|
|
272
272
|
const binding = require('brustjs-linux-x64-musl')
|
|
273
273
|
const bindingPackageVersion = require('brustjs-linux-x64-musl/package.json').version
|
|
274
|
-
if (bindingPackageVersion !== '0.1.
|
|
275
|
-
throw new Error(`Native binding package version mismatch, expected 0.1.
|
|
274
|
+
if (bindingPackageVersion !== '0.1.47-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.47-alpha but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
276
276
|
}
|
|
277
277
|
return binding
|
|
278
278
|
} catch (e) {
|
|
@@ -287,8 +287,8 @@ function requireNative() {
|
|
|
287
287
|
try {
|
|
288
288
|
const binding = require('brustjs-linux-x64-gnu')
|
|
289
289
|
const bindingPackageVersion = require('brustjs-linux-x64-gnu/package.json').version
|
|
290
|
-
if (bindingPackageVersion !== '0.1.
|
|
291
|
-
throw new Error(`Native binding package version mismatch, expected 0.1.
|
|
290
|
+
if (bindingPackageVersion !== '0.1.47-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.47-alpha but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
292
292
|
}
|
|
293
293
|
return binding
|
|
294
294
|
} catch (e) {
|
|
@@ -305,8 +305,8 @@ function requireNative() {
|
|
|
305
305
|
try {
|
|
306
306
|
const binding = require('brustjs-linux-arm64-musl')
|
|
307
307
|
const bindingPackageVersion = require('brustjs-linux-arm64-musl/package.json').version
|
|
308
|
-
if (bindingPackageVersion !== '0.1.
|
|
309
|
-
throw new Error(`Native binding package version mismatch, expected 0.1.
|
|
308
|
+
if (bindingPackageVersion !== '0.1.47-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.47-alpha but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
310
310
|
}
|
|
311
311
|
return binding
|
|
312
312
|
} catch (e) {
|
|
@@ -321,8 +321,8 @@ function requireNative() {
|
|
|
321
321
|
try {
|
|
322
322
|
const binding = require('brustjs-linux-arm64-gnu')
|
|
323
323
|
const bindingPackageVersion = require('brustjs-linux-arm64-gnu/package.json').version
|
|
324
|
-
if (bindingPackageVersion !== '0.1.
|
|
325
|
-
throw new Error(`Native binding package version mismatch, expected 0.1.
|
|
324
|
+
if (bindingPackageVersion !== '0.1.47-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.47-alpha but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
326
326
|
}
|
|
327
327
|
return binding
|
|
328
328
|
} catch (e) {
|
|
@@ -339,8 +339,8 @@ function requireNative() {
|
|
|
339
339
|
try {
|
|
340
340
|
const binding = require('brustjs-linux-arm-musleabihf')
|
|
341
341
|
const bindingPackageVersion = require('brustjs-linux-arm-musleabihf/package.json').version
|
|
342
|
-
if (bindingPackageVersion !== '0.1.
|
|
343
|
-
throw new Error(`Native binding package version mismatch, expected 0.1.
|
|
342
|
+
if (bindingPackageVersion !== '0.1.47-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.47-alpha but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
344
344
|
}
|
|
345
345
|
return binding
|
|
346
346
|
} catch (e) {
|
|
@@ -355,8 +355,8 @@ function requireNative() {
|
|
|
355
355
|
try {
|
|
356
356
|
const binding = require('brustjs-linux-arm-gnueabihf')
|
|
357
357
|
const bindingPackageVersion = require('brustjs-linux-arm-gnueabihf/package.json').version
|
|
358
|
-
if (bindingPackageVersion !== '0.1.
|
|
359
|
-
throw new Error(`Native binding package version mismatch, expected 0.1.
|
|
358
|
+
if (bindingPackageVersion !== '0.1.47-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.47-alpha but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
360
360
|
}
|
|
361
361
|
return binding
|
|
362
362
|
} catch (e) {
|
|
@@ -373,8 +373,8 @@ function requireNative() {
|
|
|
373
373
|
try {
|
|
374
374
|
const binding = require('brustjs-linux-loong64-musl')
|
|
375
375
|
const bindingPackageVersion = require('brustjs-linux-loong64-musl/package.json').version
|
|
376
|
-
if (bindingPackageVersion !== '0.1.
|
|
377
|
-
throw new Error(`Native binding package version mismatch, expected 0.1.
|
|
376
|
+
if (bindingPackageVersion !== '0.1.47-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.47-alpha but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
378
378
|
}
|
|
379
379
|
return binding
|
|
380
380
|
} catch (e) {
|
|
@@ -389,8 +389,8 @@ function requireNative() {
|
|
|
389
389
|
try {
|
|
390
390
|
const binding = require('brustjs-linux-loong64-gnu')
|
|
391
391
|
const bindingPackageVersion = require('brustjs-linux-loong64-gnu/package.json').version
|
|
392
|
-
if (bindingPackageVersion !== '0.1.
|
|
393
|
-
throw new Error(`Native binding package version mismatch, expected 0.1.
|
|
392
|
+
if (bindingPackageVersion !== '0.1.47-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.47-alpha but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
394
394
|
}
|
|
395
395
|
return binding
|
|
396
396
|
} catch (e) {
|
|
@@ -407,8 +407,8 @@ function requireNative() {
|
|
|
407
407
|
try {
|
|
408
408
|
const binding = require('brustjs-linux-riscv64-musl')
|
|
409
409
|
const bindingPackageVersion = require('brustjs-linux-riscv64-musl/package.json').version
|
|
410
|
-
if (bindingPackageVersion !== '0.1.
|
|
411
|
-
throw new Error(`Native binding package version mismatch, expected 0.1.
|
|
410
|
+
if (bindingPackageVersion !== '0.1.47-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.47-alpha but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
412
412
|
}
|
|
413
413
|
return binding
|
|
414
414
|
} catch (e) {
|
|
@@ -423,8 +423,8 @@ function requireNative() {
|
|
|
423
423
|
try {
|
|
424
424
|
const binding = require('brustjs-linux-riscv64-gnu')
|
|
425
425
|
const bindingPackageVersion = require('brustjs-linux-riscv64-gnu/package.json').version
|
|
426
|
-
if (bindingPackageVersion !== '0.1.
|
|
427
|
-
throw new Error(`Native binding package version mismatch, expected 0.1.
|
|
426
|
+
if (bindingPackageVersion !== '0.1.47-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.47-alpha but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
428
428
|
}
|
|
429
429
|
return binding
|
|
430
430
|
} catch (e) {
|
|
@@ -440,8 +440,8 @@ function requireNative() {
|
|
|
440
440
|
try {
|
|
441
441
|
const binding = require('brustjs-linux-ppc64-gnu')
|
|
442
442
|
const bindingPackageVersion = require('brustjs-linux-ppc64-gnu/package.json').version
|
|
443
|
-
if (bindingPackageVersion !== '0.1.
|
|
444
|
-
throw new Error(`Native binding package version mismatch, expected 0.1.
|
|
443
|
+
if (bindingPackageVersion !== '0.1.47-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.47-alpha but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
445
445
|
}
|
|
446
446
|
return binding
|
|
447
447
|
} catch (e) {
|
|
@@ -456,8 +456,8 @@ function requireNative() {
|
|
|
456
456
|
try {
|
|
457
457
|
const binding = require('brustjs-linux-s390x-gnu')
|
|
458
458
|
const bindingPackageVersion = require('brustjs-linux-s390x-gnu/package.json').version
|
|
459
|
-
if (bindingPackageVersion !== '0.1.
|
|
460
|
-
throw new Error(`Native binding package version mismatch, expected 0.1.
|
|
459
|
+
if (bindingPackageVersion !== '0.1.47-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.47-alpha but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
461
461
|
}
|
|
462
462
|
return binding
|
|
463
463
|
} catch (e) {
|
|
@@ -476,8 +476,8 @@ function requireNative() {
|
|
|
476
476
|
try {
|
|
477
477
|
const binding = require('brustjs-openharmony-arm64')
|
|
478
478
|
const bindingPackageVersion = require('brustjs-openharmony-arm64/package.json').version
|
|
479
|
-
if (bindingPackageVersion !== '0.1.
|
|
480
|
-
throw new Error(`Native binding package version mismatch, expected 0.1.
|
|
479
|
+
if (bindingPackageVersion !== '0.1.47-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.47-alpha but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
481
481
|
}
|
|
482
482
|
return binding
|
|
483
483
|
} catch (e) {
|
|
@@ -492,8 +492,8 @@ function requireNative() {
|
|
|
492
492
|
try {
|
|
493
493
|
const binding = require('brustjs-openharmony-x64')
|
|
494
494
|
const bindingPackageVersion = require('brustjs-openharmony-x64/package.json').version
|
|
495
|
-
if (bindingPackageVersion !== '0.1.
|
|
496
|
-
throw new Error(`Native binding package version mismatch, expected 0.1.
|
|
495
|
+
if (bindingPackageVersion !== '0.1.47-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.47-alpha but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
497
497
|
}
|
|
498
498
|
return binding
|
|
499
499
|
} catch (e) {
|
|
@@ -508,8 +508,8 @@ function requireNative() {
|
|
|
508
508
|
try {
|
|
509
509
|
const binding = require('brustjs-openharmony-arm')
|
|
510
510
|
const bindingPackageVersion = require('brustjs-openharmony-arm/package.json').version
|
|
511
|
-
if (bindingPackageVersion !== '0.1.
|
|
512
|
-
throw new Error(`Native binding package version mismatch, expected 0.1.
|
|
511
|
+
if (bindingPackageVersion !== '0.1.47-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.47-alpha but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
513
513
|
}
|
|
514
514
|
return binding
|
|
515
515
|
} catch (e) {
|
|
@@ -24,6 +24,20 @@ import {
|
|
|
24
24
|
registerNavigator,
|
|
25
25
|
} from '../navigation/store.ts'
|
|
26
26
|
import { installActiveNav } from '../navigation/active-nav.ts'
|
|
27
|
+
import {
|
|
28
|
+
pageCacheKey,
|
|
29
|
+
getCachedPage,
|
|
30
|
+
fetchPagePayload,
|
|
31
|
+
inflightPage,
|
|
32
|
+
prefetchPage,
|
|
33
|
+
type PagePayload,
|
|
34
|
+
} from './page-cache.ts'
|
|
35
|
+
import {
|
|
36
|
+
matchFallback,
|
|
37
|
+
loadFallbackManifest,
|
|
38
|
+
takeover,
|
|
39
|
+
unmountFallbackRootsIn,
|
|
40
|
+
} from './fallback.ts'
|
|
27
41
|
|
|
28
42
|
// Track React roots created by hydrateOne so we can unmount them before
|
|
29
43
|
// removing their DOM in swapMainContent. Without this, removing the DOM
|
|
@@ -154,6 +168,10 @@ export function unmountIslandsIn(root: ParentNode): void {
|
|
|
154
168
|
islandRoots.delete(el)
|
|
155
169
|
}
|
|
156
170
|
}
|
|
171
|
+
// Client-takeover roots (fallback: 'client' SSG pages) live in fallback.ts's
|
|
172
|
+
// own WeakMap — delegate so navigating away from a client-rendered page
|
|
173
|
+
// disposes its React root too (same detached-root hazard as islands).
|
|
174
|
+
unmountFallbackRootsIn(root)
|
|
157
175
|
}
|
|
158
176
|
|
|
159
177
|
/** Scan `root` for un-hydrated island markers and register their hydration
|
|
@@ -242,22 +260,158 @@ export function isFullDocumentPayload(html: string): boolean {
|
|
|
242
260
|
|
|
243
261
|
let inFlight: AbortController | null = null
|
|
244
262
|
|
|
263
|
+
// scrollY of each page we navigated away from (keyed pathname+search), so
|
|
264
|
+
// back/forward restores the reading position instead of jumping to top.
|
|
265
|
+
const scrollPositions = new Map<string, number>()
|
|
266
|
+
// The page currently in the DOM. Tracked here (set at boot + on every commit)
|
|
267
|
+
// instead of read from `location` at save time, because popstate updates
|
|
268
|
+
// `location` to the DESTINATION before the event fires — reading it there
|
|
269
|
+
// would record the leaving page's scroll under the wrong key.
|
|
270
|
+
let currentPageKey = ''
|
|
271
|
+
|
|
272
|
+
/** SPA-navigate onto a `fallback: 'client'` SSG route on a static host.
|
|
273
|
+
*
|
|
274
|
+
* Called from navigate() when the normal payload fetch fails: a
|
|
275
|
+
* non-prerendered dynamic path has no `/_brust/page/...` file on a static
|
|
276
|
+
* host, so the fetch 404s. Match the path against the export's fallback
|
|
277
|
+
* manifest, fetch the route's placeholder-shell payload from the manifest's
|
|
278
|
+
* `payload` URL (`/_brust/fallback-page/...` — the only payload that exists
|
|
279
|
+
* for such a path on a static host), swap it into `<main>` with the SAME
|
|
280
|
+
* post-swap sequence the normal path uses, then client-render the real page
|
|
281
|
+
* via takeover().
|
|
282
|
+
*
|
|
283
|
+
* The payload is intentionally NOT stored in the page cache: client-rendered
|
|
284
|
+
* data must be fresh per visit (clientLoader owns freshness), and replaying
|
|
285
|
+
* the bare placeholder shell would be useless anyway.
|
|
286
|
+
*
|
|
287
|
+
* Returns false when this navigation cannot be handled here (no manifest
|
|
288
|
+
* match, payload missing/invalid, no `<main>`) — the caller rethrows into
|
|
289
|
+
* the existing full-reload fallback. Supersession (the AbortController was
|
|
290
|
+
* aborted by a newer navigation) also returns false WITHOUT touching the DOM
|
|
291
|
+
* or committing; the caller checks `signal.aborted` before rethrowing. */
|
|
292
|
+
async function attemptClientFallback(
|
|
293
|
+
url: URL,
|
|
294
|
+
mode: 'push' | 'replace' | 'none',
|
|
295
|
+
signal?: AbortSignal,
|
|
296
|
+
): Promise<boolean> {
|
|
297
|
+
const entries = await loadFallbackManifest()
|
|
298
|
+
const entry = entries.find((e) => matchFallback(e.pattern, url.pathname) !== null)
|
|
299
|
+
if (!entry) return false
|
|
300
|
+
let html: string
|
|
301
|
+
let title: string | undefined
|
|
302
|
+
try {
|
|
303
|
+
const resp = await fetch(entry.payload, { headers: { Accept: 'application/json' } })
|
|
304
|
+
if (!resp.ok) return false
|
|
305
|
+
const payload = (await resp.json()) as { html?: unknown; title?: unknown }
|
|
306
|
+
if (typeof payload.html !== 'string') return false
|
|
307
|
+
html = payload.html
|
|
308
|
+
title = typeof payload.title === 'string' ? payload.title : undefined
|
|
309
|
+
} catch {
|
|
310
|
+
return false
|
|
311
|
+
}
|
|
312
|
+
// Superseded while fetching → a newer navigation owns the DOM; do nothing.
|
|
313
|
+
if (signal?.aborted) return false
|
|
314
|
+
// Same full-document guard as the normal path: a standalone-route shell
|
|
315
|
+
// cannot be swapped into the current <main> — authoritative full load.
|
|
316
|
+
if (isFullDocumentPayload(html)) {
|
|
317
|
+
location.href = url.href
|
|
318
|
+
return true
|
|
319
|
+
}
|
|
320
|
+
const main = document.querySelector('main')
|
|
321
|
+
if (!main) return false
|
|
322
|
+
// From here down: the SAME post-swap sequence navigate()'s normal path runs.
|
|
323
|
+
scrollPositions.set(currentPageKey, window.scrollY)
|
|
324
|
+
unmountIslandsIn(main as HTMLElement)
|
|
325
|
+
swapMainContent(main as HTMLElement, html)
|
|
326
|
+
if (title) document.title = title
|
|
327
|
+
// History BEFORE takeover: takeover derives params from location.pathname,
|
|
328
|
+
// so the URL bar must already show the destination.
|
|
329
|
+
if (mode === 'push') history.pushState({}, '', url.href)
|
|
330
|
+
else if (mode === 'replace') history.replaceState({}, '', url.href)
|
|
331
|
+
if (mode === 'none') window.scrollTo(0, scrollPositions.get(pageCacheKey(url)) ?? 0)
|
|
332
|
+
else window.scrollTo(0, 0)
|
|
333
|
+
currentPageKey = pageCacheKey(url)
|
|
334
|
+
const container = main.querySelector<HTMLElement>('[data-brust-fallback-root]')
|
|
335
|
+
if (!container) {
|
|
336
|
+
// A fallback payload without its marker is a build bug — log it, but
|
|
337
|
+
// commit the swap so navigation doesn't brick (the shell IS on screen).
|
|
338
|
+
console.warn(
|
|
339
|
+
'[brust] fallback payload has no [data-brust-fallback-root] marker — client takeover skipped',
|
|
340
|
+
)
|
|
341
|
+
hydrateMarkersIn(main as HTMLElement)
|
|
342
|
+
__navCommit(url.pathname, url.search)
|
|
343
|
+
return true
|
|
344
|
+
}
|
|
345
|
+
// Superseded while the payload was loading → the newer navigation owns the
|
|
346
|
+
// DOM from here; handing the container to takeover would let its render
|
|
347
|
+
// land in a subtree the newer swap is about to (or already did) remove.
|
|
348
|
+
if (signal?.aborted) return true
|
|
349
|
+
// ORDER: takeover BEFORE hydrateMarkersIn. The container was JUST swapped
|
|
350
|
+
// in, so nothing inside it is hydrated yet; hydrating first would register
|
|
351
|
+
// placeholder-island triggers whose async mounts race takeover's child
|
|
352
|
+
// removal (a live root on removed DOM hangs the tab). Running takeover
|
|
353
|
+
// first means the container's children are either removed before any
|
|
354
|
+
// trigger is registered (success) or hydrated exactly once afterwards
|
|
355
|
+
// (failure keeps the placeholder, which then becomes interactive). Either
|
|
356
|
+
// way a placeholder island can never double-mount.
|
|
357
|
+
// takeover gets the SIGNAL so a supersession mid-clientLoader can't mount
|
|
358
|
+
// a React root into a container the newer navigation already detached.
|
|
359
|
+
await takeover(container, signal)
|
|
360
|
+
// Superseded during takeover → skip hydration/commit; the newer navigation
|
|
361
|
+
// owns the DOM and the nav store from here.
|
|
362
|
+
if (signal?.aborted) return true
|
|
363
|
+
hydrateMarkersIn(main as HTMLElement)
|
|
364
|
+
// Commit only after takeover resolves: phase 'loading' covers the client
|
|
365
|
+
// data fetch, so NavPreloader stays honest about in-flight work.
|
|
366
|
+
__navCommit(url.pathname, url.search)
|
|
367
|
+
return true
|
|
368
|
+
}
|
|
369
|
+
|
|
245
370
|
export async function navigate(url: URL, mode: 'push' | 'replace' | 'none'): Promise<void> {
|
|
246
371
|
inFlight?.abort()
|
|
247
372
|
const ac = new AbortController()
|
|
248
373
|
inFlight = ac
|
|
249
374
|
try {
|
|
250
375
|
__navStart(url.pathname, url.search)
|
|
251
|
-
const
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
376
|
+
const key = pageCacheKey(url)
|
|
377
|
+
// Visited pages are served from the in-memory cache — no refetch. Forward
|
|
378
|
+
// navigations respect PAGE_STALE_MS (default max age); back/forward reuses
|
|
379
|
+
// any entry regardless of age, like the browser's bfcache.
|
|
380
|
+
const cached = getCachedPage(key, mode === 'none' ? Number.POSITIVE_INFINITY : undefined)
|
|
381
|
+
let payload: PagePayload
|
|
382
|
+
if (cached) {
|
|
383
|
+
payload = cached
|
|
384
|
+
} else {
|
|
385
|
+
try {
|
|
386
|
+
// A hover prefetch may already have this page in flight — await it
|
|
387
|
+
// instead of double-fetching; if it failed, fall back to a direct fetch.
|
|
388
|
+
const pre = inflightPage(key)
|
|
389
|
+
if (pre) {
|
|
390
|
+
try {
|
|
391
|
+
payload = await pre
|
|
392
|
+
} catch {
|
|
393
|
+
payload = await fetchPagePayload(url, ac.signal)
|
|
394
|
+
}
|
|
395
|
+
} else {
|
|
396
|
+
payload = await fetchPagePayload(url, ac.signal)
|
|
397
|
+
}
|
|
398
|
+
} catch (err) {
|
|
399
|
+
// Static-host miss: a non-prerendered `fallback: 'client'` path has
|
|
400
|
+
// no payload file, so the fetch 404s. Try the client takeover before
|
|
401
|
+
// the full-reload fallback. Abort keeps its existing meaning
|
|
402
|
+
// (supersession) and must reach the outer catch untouched.
|
|
403
|
+
if ((err as Error).name === 'AbortError') throw err
|
|
404
|
+
if (await attemptClientFallback(url, mode, ac.signal)) return
|
|
405
|
+
// Superseded during the fallback attempt → a newer navigation owns
|
|
406
|
+
// the DOM; bail without committing OR full-reloading.
|
|
407
|
+
if (ac.signal.aborted) return
|
|
408
|
+
throw err
|
|
409
|
+
}
|
|
410
|
+
// The prefetch promise isn't tied to our AbortController, so an abort
|
|
411
|
+
// during that await doesn't throw — check for supersession explicitly.
|
|
412
|
+
if (ac.signal.aborted) return
|
|
260
413
|
}
|
|
414
|
+
const { html, title, store } = payload
|
|
261
415
|
// A standalone (no-<main>) route ships its FULL document here. We can't swap
|
|
262
416
|
// that into the current shell's <main> without nesting a second document
|
|
263
417
|
// (duplicate chrome — the classic two-topbars artifact), and the current
|
|
@@ -269,14 +423,20 @@ export async function navigate(url: URL, mode: 'push' | 'replace' | 'none'): Pro
|
|
|
269
423
|
}
|
|
270
424
|
const main = document.querySelector('main')
|
|
271
425
|
if (!main) throw new Error('navigation: no <main> element')
|
|
426
|
+
scrollPositions.set(currentPageKey, window.scrollY)
|
|
272
427
|
unmountIslandsIn(main as HTMLElement)
|
|
273
428
|
swapMainContent(main as HTMLElement, html)
|
|
274
|
-
|
|
429
|
+
// Only a FRESH payload re-applies the server store snapshot: replaying a
|
|
430
|
+
// cached (stale) snapshot would roll back live client store state the user
|
|
431
|
+
// changed since the page was first fetched.
|
|
432
|
+
if (!cached && store) applyStoreSnapshot(store)
|
|
275
433
|
if (title) document.title = title
|
|
276
434
|
if (mode === 'push') history.pushState({}, '', url.href)
|
|
277
435
|
else if (mode === 'replace') history.replaceState({}, '', url.href)
|
|
278
|
-
window.scrollTo(0, 0)
|
|
436
|
+
if (mode === 'none') window.scrollTo(0, scrollPositions.get(key) ?? 0)
|
|
437
|
+
else window.scrollTo(0, 0)
|
|
279
438
|
hydrateMarkersIn(main as HTMLElement)
|
|
439
|
+
currentPageKey = key
|
|
280
440
|
__navCommit(url.pathname, url.search)
|
|
281
441
|
} catch (err) {
|
|
282
442
|
if ((err as Error).name === 'AbortError') return
|
|
@@ -288,7 +448,76 @@ export async function navigate(url: URL, mode: 'push' | 'replace' | 'none'): Pro
|
|
|
288
448
|
}
|
|
289
449
|
}
|
|
290
450
|
|
|
451
|
+
/** Resolve an <a> to a prefetchable in-app URL, or null when prefetch must not
|
|
452
|
+
* run: not ours (cross-origin, target, download, /_brust/), explicitly opted
|
|
453
|
+
* out (data-brust-no-intercept disables SPA handling entirely;
|
|
454
|
+
* data-brust-no-prefetch keeps the SPA click but skips the speculative fetch),
|
|
455
|
+
* or the page we are already on. Exported for unit testing. */
|
|
456
|
+
export function prefetchUrlFor(a: HTMLAnchorElement): URL | null {
|
|
457
|
+
if (a.target && a.target !== '_self') return null
|
|
458
|
+
if (a.hasAttribute('download')) return null
|
|
459
|
+
if (a.dataset.brustNoIntercept !== undefined) return null
|
|
460
|
+
if (a.dataset.brustNoPrefetch !== undefined) return null
|
|
461
|
+
if (!a.getAttribute('href')) return null
|
|
462
|
+
const url = new URL(a.href, location.href)
|
|
463
|
+
if (url.origin !== location.origin) return null
|
|
464
|
+
if (url.pathname.startsWith('/_brust/')) return null
|
|
465
|
+
if (url.pathname === location.pathname && url.search === location.search) return null
|
|
466
|
+
return url
|
|
467
|
+
}
|
|
468
|
+
|
|
469
|
+
// Hover-intent delay: long enough that a cursor sweeping across a nav list
|
|
470
|
+
// doesn't fire a fetch per link, short enough to beat the click (~200-300ms
|
|
471
|
+
// between hover and press for a deliberate click).
|
|
472
|
+
const HOVER_DELAY_MS = 80
|
|
473
|
+
|
|
474
|
+
/** Hover/touch prefetch: pointer rests on an internal link for HOVER_DELAY_MS
|
|
475
|
+
* (or a touch starts — the tap commits within ~100ms anyway) → fetch its nav
|
|
476
|
+
* payload into the page cache so the eventual click swaps instantly.
|
|
477
|
+
* prefetchPage dedupes in-flight fetches and respects Save-Data/2g. */
|
|
478
|
+
function installPrefetch(): void {
|
|
479
|
+
const timers = new WeakMap<HTMLAnchorElement, ReturnType<typeof setTimeout>>()
|
|
480
|
+
document.addEventListener('pointerover', (e) => {
|
|
481
|
+
const a = (e.target as HTMLElement | null)?.closest('a') as HTMLAnchorElement | null
|
|
482
|
+
if (!a || timers.has(a)) return
|
|
483
|
+
const url = prefetchUrlFor(a)
|
|
484
|
+
if (!url) return
|
|
485
|
+
timers.set(
|
|
486
|
+
a,
|
|
487
|
+
setTimeout(() => {
|
|
488
|
+
timers.delete(a)
|
|
489
|
+
void prefetchPage(url)
|
|
490
|
+
}, HOVER_DELAY_MS),
|
|
491
|
+
)
|
|
492
|
+
})
|
|
493
|
+
document.addEventListener('pointerout', (e) => {
|
|
494
|
+
const a = (e.target as HTMLElement | null)?.closest('a') as HTMLAnchorElement | null
|
|
495
|
+
if (!a) return
|
|
496
|
+
// Moving between children of the same link is not a leave.
|
|
497
|
+
if (e.relatedTarget instanceof Node && a.contains(e.relatedTarget)) return
|
|
498
|
+
const t = timers.get(a)
|
|
499
|
+
if (t !== undefined) {
|
|
500
|
+
clearTimeout(t)
|
|
501
|
+
timers.delete(a)
|
|
502
|
+
}
|
|
503
|
+
})
|
|
504
|
+
document.addEventListener(
|
|
505
|
+
'touchstart',
|
|
506
|
+
(e) => {
|
|
507
|
+
const a = (e.target as HTMLElement | null)?.closest('a') as HTMLAnchorElement | null
|
|
508
|
+
if (!a) return
|
|
509
|
+
const url = prefetchUrlFor(a)
|
|
510
|
+
if (url) void prefetchPage(url)
|
|
511
|
+
},
|
|
512
|
+
{ passive: true },
|
|
513
|
+
)
|
|
514
|
+
}
|
|
515
|
+
|
|
291
516
|
function installInterceptor(): void {
|
|
517
|
+
// We restore scroll ourselves on popstate (the page cache makes back/forward
|
|
518
|
+
// an instant in-place swap); stop the browser's automatic restoration from
|
|
519
|
+
// fighting the swap.
|
|
520
|
+
if ('scrollRestoration' in history) history.scrollRestoration = 'manual'
|
|
292
521
|
document.addEventListener('click', (e) => {
|
|
293
522
|
const target = e.target as HTMLElement | null
|
|
294
523
|
const a = target?.closest('a') as HTMLAnchorElement | null
|
|
@@ -307,19 +536,62 @@ function installInterceptor(): void {
|
|
|
307
536
|
})
|
|
308
537
|
}
|
|
309
538
|
|
|
539
|
+
/** Boot-path takeover for a DIRECT hit on a non-prerendered fallback path:
|
|
540
|
+
* the static host served 404.html, which stashed the real URL in
|
|
541
|
+
* sessionStorage and redirected to the route's fallback shell document. If
|
|
542
|
+
* this document carries a fallback container, restore the real URL via
|
|
543
|
+
* replaceState BEFORE takeover starts (the user sees their URL while the
|
|
544
|
+
* placeholder loads, and takeover derives params from location.pathname),
|
|
545
|
+
* then hand the container to the client-render runtime. */
|
|
546
|
+
function bootFallbackTakeover(): void {
|
|
547
|
+
const el = document.querySelector<HTMLElement>('[data-brust-fallback-root]')
|
|
548
|
+
if (!el) return
|
|
549
|
+
let saved: string | null = null
|
|
550
|
+
try {
|
|
551
|
+
saved = sessionStorage.getItem('brust:fallback-path')
|
|
552
|
+
if (saved !== null) sessionStorage.removeItem('brust:fallback-path')
|
|
553
|
+
} catch {
|
|
554
|
+
// sessionStorage unavailable (privacy mode) — 404.html couldn't have
|
|
555
|
+
// stashed a path either; takeover proceeds on the shell's own URL.
|
|
556
|
+
}
|
|
557
|
+
// Only a same-origin absolute PATH is acceptable: the value transits
|
|
558
|
+
// sessionStorage (writable by any same-origin script), so reject anything
|
|
559
|
+
// shaped like a scheme or protocol-relative URL before handing it to
|
|
560
|
+
// replaceState.
|
|
561
|
+
if (saved?.startsWith('/') && !saved.startsWith('//')) {
|
|
562
|
+
history.replaceState({}, '', saved)
|
|
563
|
+
currentPageKey = location.pathname + location.search
|
|
564
|
+
// Re-seed the nav store: __navInit ran before this with the SHELL
|
|
565
|
+
// document's URL — without the re-init, useNav()/getNavState() would
|
|
566
|
+
// report the /_brust/fallback/... path until the first SPA commit.
|
|
567
|
+
__navInit(location.pathname, location.search)
|
|
568
|
+
}
|
|
569
|
+
// Per takeover's contract: unmount any island roots inside the container
|
|
570
|
+
// first. At boot this is belt-and-braces — hydrateMarkersIn(document.body)
|
|
571
|
+
// ran just above, but its `load`-trigger mounts are detached microtasks
|
|
572
|
+
// that haven't created roots yet at this synchronous point.
|
|
573
|
+
unmountIslandsIn(el)
|
|
574
|
+
void takeover(el)
|
|
575
|
+
}
|
|
576
|
+
|
|
310
577
|
if (typeof document !== 'undefined') {
|
|
311
578
|
registerNavigator((url, replace) => navigate(url, replace ? 'replace' : 'push'))
|
|
579
|
+
currentPageKey = location.pathname + location.search
|
|
312
580
|
if (document.readyState === 'loading') {
|
|
313
581
|
document.addEventListener('DOMContentLoaded', () => {
|
|
314
582
|
__navInit(location.pathname, location.search)
|
|
315
583
|
installActiveNav()
|
|
316
584
|
hydrateMarkersIn(document.body)
|
|
317
585
|
installInterceptor()
|
|
586
|
+
installPrefetch()
|
|
587
|
+
bootFallbackTakeover()
|
|
318
588
|
})
|
|
319
589
|
} else {
|
|
320
590
|
__navInit(location.pathname, location.search)
|
|
321
591
|
installActiveNav()
|
|
322
592
|
hydrateMarkersIn(document.body)
|
|
323
593
|
installInterceptor()
|
|
594
|
+
installPrefetch()
|
|
595
|
+
bootFallbackTakeover()
|
|
324
596
|
}
|
|
325
597
|
}
|