brustjs 0.1.46-alpha → 0.1.48-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 +134 -9
- package/runtime/cli/dev.ts +14 -2
- package/runtime/cli/help.ts +8 -0
- package/runtime/cli/native-routes-emit.ts +9 -1
- package/runtime/cli/ssg.ts +321 -10
- package/runtime/generator.ts +76 -0
- package/runtime/index.d.ts +6 -0
- package/runtime/index.js +52 -52
- package/runtime/index.ts +27 -0
- package/runtime/islands/bootstrap.ts +170 -9
- package/runtime/islands/build.ts +1 -1
- package/runtime/islands/fallback.ts +198 -0
- package/runtime/md/emit.ts +11 -1
- package/runtime/render/inject-generator.ts +71 -0
- package/runtime/render/stream.ts +11 -3
- 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.48-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.48-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.48-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.48-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.48-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.48-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.48-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.48-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.48-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.48-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.48-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.48-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.48-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.48-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.48-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.48-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.48-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.48-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.48-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.48-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.48-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.48-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.48-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.48-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.48-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.48-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.48-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.48-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.48-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.48-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.48-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.48-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.48-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.48-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.48-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.48-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.48-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.48-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.48-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.48-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.48-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.48-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.48-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.48-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.48-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.48-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.48-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.48-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.48-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.48-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.48-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.48-alpha but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
513
513
|
}
|
|
514
514
|
return binding
|
|
515
515
|
} catch (e) {
|
package/runtime/index.ts
CHANGED
|
@@ -115,6 +115,13 @@ function loadJinjaOnce(dir: string): void {
|
|
|
115
115
|
_jinjaLoaded = true
|
|
116
116
|
}
|
|
117
117
|
|
|
118
|
+
// Resolved generator strings, set by the main-isolate view boot (which runs
|
|
119
|
+
// before serve() binds the listener). serve() falls back to resolving the
|
|
120
|
+
// artifact itself when boot hasn't stashed one (defensive — ordering holds in
|
|
121
|
+
// every real entry: view registration precedes serve).
|
|
122
|
+
// Main-isolate-only: the worker path resolves the artifact itself.
|
|
123
|
+
let resolvedGeneratorStrings: import('./generator.ts').GeneratorStrings | null = null
|
|
124
|
+
|
|
118
125
|
function registerActionsInternal(endpoints: Array<{ method: string; path: string }>): number {
|
|
119
126
|
return (native as any).registerActions(endpoints.map((e) => ({ method: e.method, path: e.path })))
|
|
120
127
|
}
|
|
@@ -146,6 +153,10 @@ export const brust = {
|
|
|
146
153
|
// registration index; the worker dispatches on that same index string.
|
|
147
154
|
registerActionsInternal(opts.actions.endpoints)
|
|
148
155
|
}
|
|
156
|
+
const { resolveGenerator } = await import('./generator.ts')
|
|
157
|
+
const path = await import('node:path')
|
|
158
|
+
const gen =
|
|
159
|
+
resolvedGeneratorStrings ?? resolveGenerator(path.resolve(process.cwd(), '.brust/jinja'))
|
|
149
160
|
;(native as any).beginServe({
|
|
150
161
|
host: opts.host,
|
|
151
162
|
port: opts.port,
|
|
@@ -156,6 +167,10 @@ export const brust = {
|
|
|
156
167
|
// `actionPrefix` (not snake_case). A snake_case key is silently dropped,
|
|
157
168
|
// leaving the prefix at its default — which broke custom-prefix routing.
|
|
158
169
|
actionPrefix: opts.actionPrefix,
|
|
170
|
+
// X-Powered-By value from the build's generator.json (stashed by view
|
|
171
|
+
// boot; artifact fallback covers any ordering edge). Single word — no
|
|
172
|
+
// napi case-mapping trap possible.
|
|
173
|
+
generator: gen.header,
|
|
159
174
|
})
|
|
160
175
|
// Render slots per worker. Propagated to each worker via env (Bun Workers
|
|
161
176
|
// share the OS process, so the worker reads it from process.env at
|
|
@@ -632,6 +647,13 @@ export const brust = {
|
|
|
632
647
|
}
|
|
633
648
|
|
|
634
649
|
configureJinjaDir(jinjaDir)
|
|
650
|
+
{
|
|
651
|
+
const { resolveGenerator } = await import('./generator.ts')
|
|
652
|
+
const gen = resolveGenerator(jinjaDir)
|
|
653
|
+
resolvedGeneratorStrings = gen
|
|
654
|
+
const { configureGeneratorMeta } = await import('./render/inject-generator.ts')
|
|
655
|
+
configureGeneratorMeta(gen.meta)
|
|
656
|
+
}
|
|
635
657
|
loadJinjaOnce(jinjaDir)
|
|
636
658
|
if (prebuilt && existsSync(jinjaDir)) {
|
|
637
659
|
console.log(`[brust] main: using pre-built jinja at ${jinjaDir}`)
|
|
@@ -971,6 +993,11 @@ export const brust = {
|
|
|
971
993
|
? path.join(distDir!, 'jinja')
|
|
972
994
|
: path.resolve(process.cwd(), '.brust/jinja')
|
|
973
995
|
configureJinjaDir(workerJinjaDir)
|
|
996
|
+
{
|
|
997
|
+
const { resolveGenerator } = await import('./generator.ts')
|
|
998
|
+
const { configureGeneratorMeta } = await import('./render/inject-generator.ts')
|
|
999
|
+
configureGeneratorMeta(resolveGenerator(workerJinjaDir).meta)
|
|
1000
|
+
}
|
|
974
1001
|
|
|
975
1002
|
const { makeRenderer: make } = await import('./routes.ts')
|
|
976
1003
|
let wid: number | null = null
|
|
@@ -32,6 +32,12 @@ import {
|
|
|
32
32
|
prefetchPage,
|
|
33
33
|
type PagePayload,
|
|
34
34
|
} from './page-cache.ts'
|
|
35
|
+
import {
|
|
36
|
+
matchFallback,
|
|
37
|
+
loadFallbackManifest,
|
|
38
|
+
takeover,
|
|
39
|
+
unmountFallbackRootsIn,
|
|
40
|
+
} from './fallback.ts'
|
|
35
41
|
|
|
36
42
|
// Track React roots created by hydrateOne so we can unmount them before
|
|
37
43
|
// removing their DOM in swapMainContent. Without this, removing the DOM
|
|
@@ -162,6 +168,10 @@ export function unmountIslandsIn(root: ParentNode): void {
|
|
|
162
168
|
islandRoots.delete(el)
|
|
163
169
|
}
|
|
164
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)
|
|
165
175
|
}
|
|
166
176
|
|
|
167
177
|
/** Scan `root` for un-hydrated island markers and register their hydration
|
|
@@ -259,6 +269,104 @@ const scrollPositions = new Map<string, number>()
|
|
|
259
269
|
// would record the leaving page's scroll under the wrong key.
|
|
260
270
|
let currentPageKey = ''
|
|
261
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
|
+
|
|
262
370
|
export async function navigate(url: URL, mode: 'push' | 'replace' | 'none'): Promise<void> {
|
|
263
371
|
inFlight?.abort()
|
|
264
372
|
const ac = new AbortController()
|
|
@@ -274,17 +382,30 @@ export async function navigate(url: URL, mode: 'push' | 'replace' | 'none'): Pro
|
|
|
274
382
|
if (cached) {
|
|
275
383
|
payload = cached
|
|
276
384
|
} else {
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
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 {
|
|
284
396
|
payload = await fetchPagePayload(url, ac.signal)
|
|
285
397
|
}
|
|
286
|
-
}
|
|
287
|
-
|
|
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
|
|
288
409
|
}
|
|
289
410
|
// The prefetch promise isn't tied to our AbortController, so an abort
|
|
290
411
|
// during that await doesn't throw — check for supersession explicitly.
|
|
@@ -415,6 +536,44 @@ function installInterceptor(): void {
|
|
|
415
536
|
})
|
|
416
537
|
}
|
|
417
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
|
+
|
|
418
577
|
if (typeof document !== 'undefined') {
|
|
419
578
|
registerNavigator((url, replace) => navigate(url, replace ? 'replace' : 'push'))
|
|
420
579
|
currentPageKey = location.pathname + location.search
|
|
@@ -425,6 +584,7 @@ if (typeof document !== 'undefined') {
|
|
|
425
584
|
hydrateMarkersIn(document.body)
|
|
426
585
|
installInterceptor()
|
|
427
586
|
installPrefetch()
|
|
587
|
+
bootFallbackTakeover()
|
|
428
588
|
})
|
|
429
589
|
} else {
|
|
430
590
|
__navInit(location.pathname, location.search)
|
|
@@ -432,5 +592,6 @@ if (typeof document !== 'undefined') {
|
|
|
432
592
|
hydrateMarkersIn(document.body)
|
|
433
593
|
installInterceptor()
|
|
434
594
|
installPrefetch()
|
|
595
|
+
bootFallbackTakeover()
|
|
435
596
|
}
|
|
436
597
|
}
|
package/runtime/islands/build.ts
CHANGED