brustjs 0.1.34-alpha → 0.1.36-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/README.md +18 -13
- package/example/pokedex/components/AddToTeamButton.tsx +1 -1
- package/example/pokedex/components/Breadcrumb.tsx +1 -1
- package/example/pokedex/components/DexFilter.tsx +1 -1
- package/example/pokedex/components/HeroSearch.tsx +0 -1
- package/example/pokedex/components/NavLink.tsx +0 -1
- package/example/pokedex/components/ThemeToggle.tsx +0 -1
- package/example/pokedex/lib/pokeapi.ts +45 -15
- package/package.json +7 -7
- package/runtime/cli/native-routes-emit.ts +17 -1
- package/runtime/index.d.ts +46 -5
- package/runtime/index.js +53 -52
- package/runtime/index.ts +51 -11
- package/runtime/islands/island.tsx +26 -11
- package/runtime/native/build.ts +15 -9
- package/runtime/render/stream.ts +36 -18
- package/runtime/routes.ts +167 -82
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.36-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.36-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.36-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.36-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.36-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.36-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.36-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.36-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.36-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.36-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.36-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.36-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.36-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.36-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.36-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.36-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.36-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.36-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.36-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.36-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.36-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.36-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.36-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.36-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.36-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.36-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.36-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.36-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.36-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.36-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.36-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.36-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.36-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.36-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.36-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.36-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.36-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.36-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.36-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.36-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.36-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.36-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.36-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.36-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.36-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.36-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.36-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.36-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.36-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.36-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.36-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.36-alpha but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
513
513
|
}
|
|
514
514
|
return binding
|
|
515
515
|
} catch (e) {
|
|
@@ -576,6 +576,7 @@ if (!nativeBinding) {
|
|
|
576
576
|
}
|
|
577
577
|
|
|
578
578
|
module.exports = nativeBinding
|
|
579
|
+
module.exports.beginDrain = nativeBinding.beginDrain
|
|
579
580
|
module.exports.beginServe = nativeBinding.beginServe
|
|
580
581
|
module.exports.compileJsx = nativeBinding.compileJsx
|
|
581
582
|
module.exports.configureCache = nativeBinding.configureCache
|
package/runtime/index.ts
CHANGED
|
@@ -49,6 +49,15 @@ export interface ServeOptions {
|
|
|
49
49
|
/** Max ms a render waits for a free worker before 503 (AllBusy queues
|
|
50
50
|
* instead of failing fast). Default 10000. */
|
|
51
51
|
claimTimeoutMs?: number
|
|
52
|
+
/** tokio I/O runtime worker-thread count for the hyper server. Runs inside
|
|
53
|
+
* Bun (which has its own threads + render workers), so this is NOT
|
|
54
|
+
* one-per-core. Default `min(availableParallelism, 4)` (fallback 2). */
|
|
55
|
+
workerThreads?: number
|
|
56
|
+
/** Render slots per Bun worker — concurrent in-flight renders per isolate.
|
|
57
|
+
* Default 1 (byte-identical to single in-flight render per worker). The
|
|
58
|
+
* count is propagated to each worker via the `BRUST_RENDER_SLOTS` env var
|
|
59
|
+
* and scales the per-worker SAB so each slot keeps the single-slot capacity. */
|
|
60
|
+
renderSlots?: number
|
|
52
61
|
}
|
|
53
62
|
}
|
|
54
63
|
|
|
@@ -56,10 +65,11 @@ export interface ServeOptions {
|
|
|
56
65
|
// (the worker wrote `[meta_len][meta][body]` into the SAB; Rust reads it
|
|
57
66
|
// directly), `0` → the worker used the chunk channel via
|
|
58
67
|
// `napi.renderChunk(workerId, len)` (React Suspense streaming) or owns the
|
|
59
|
-
// socket independently (SSE/WS). The argument is
|
|
60
|
-
// `{ route_id, path, params }` produced by Rust's route table
|
|
68
|
+
// socket independently (SSE/WS). The argument is the INLINE JSON envelope
|
|
69
|
+
// `{ route_id, path, params }` produced by Rust's route table (the request
|
|
70
|
+
// always crosses as a string — SAB-request is closed) — see
|
|
61
71
|
// runtime/routes.ts::RouteCall.
|
|
62
|
-
export type RenderFn = (
|
|
72
|
+
export type RenderFn = (envelopeJson: string, slot: number) => Promise<number>
|
|
63
73
|
|
|
64
74
|
// Bun Workers run in the same OS process as the main thread; the `env` option
|
|
65
75
|
// only patches the JS-visible process.env, not the native OS environment that
|
|
@@ -127,7 +137,16 @@ export const brust = {
|
|
|
127
137
|
// leaving the prefix at its default — which broke custom-prefix routing.
|
|
128
138
|
actionPrefix: opts.actionPrefix,
|
|
129
139
|
})
|
|
130
|
-
|
|
140
|
+
// Render slots per worker. Propagated to each worker via env (Bun Workers
|
|
141
|
+
// share the OS process, so the worker reads it from process.env at
|
|
142
|
+
// registerRenderer time). Precedence: explicit `tuning.renderSlots`, else the
|
|
143
|
+
// `BRUST_RENDER_SLOTS` env (so it's configurable like BRUST_WORKERS without
|
|
144
|
+
// per-app wiring), else 1 — byte-identical single in-flight render.
|
|
145
|
+
const renderSlots = Math.max(
|
|
146
|
+
1,
|
|
147
|
+
opts.tuning?.renderSlots ?? (Number(process.env.BRUST_RENDER_SLOTS) || 1),
|
|
148
|
+
)
|
|
149
|
+
const baseEnv = { ...process.env, BRUST_RENDER_SLOTS: String(renderSlots) }
|
|
131
150
|
const workersArr: Worker[] = []
|
|
132
151
|
for (let i = 0; i < opts.workers; i++) {
|
|
133
152
|
// Bun.Worker requires the JS entry (post-bundling). For the skeleton,
|
|
@@ -142,9 +161,25 @@ export const brust = {
|
|
|
142
161
|
const { registerInitialPool } = await import('./dev/worker-registry.ts')
|
|
143
162
|
registerInitialPool(workersArr, opts.entry, opts.workers, baseEnv as Record<string, string>)
|
|
144
163
|
}
|
|
145
|
-
// Bun Workers intercept SIGINT before Rust's ctrl_c() handler fires
|
|
146
|
-
//
|
|
147
|
-
|
|
164
|
+
// Bun Workers intercept SIGINT before Rust's ctrl_c() handler fires, so a
|
|
165
|
+
// JS-level handler owns process exit. GRACEFUL DRAIN: stop accepting new
|
|
166
|
+
// connections, let in-flight renders/streams finish (bounded by the drain
|
|
167
|
+
// timeout), THEN exit — so a slow stream isn't cut off mid-response (the
|
|
168
|
+
// teardown that produced spurious `split_meta` errors under load). A second
|
|
169
|
+
// signal (impatient Ctrl-C) forces an immediate exit. SIGTERM too, for
|
|
170
|
+
// container orchestrators (Docker/k8s send SIGTERM on stop).
|
|
171
|
+
let draining = false
|
|
172
|
+
const drainTimeoutMs = Number(process.env.BRUST_DRAIN_TIMEOUT_MS) || 10_000
|
|
173
|
+
const gracefulExit = (code: number) => {
|
|
174
|
+
if (draining) process.exit(code)
|
|
175
|
+
draining = true
|
|
176
|
+
;(native as any)
|
|
177
|
+
.beginDrain(drainTimeoutMs)
|
|
178
|
+
.catch(() => {})
|
|
179
|
+
.finally(() => process.exit(0))
|
|
180
|
+
}
|
|
181
|
+
process.on('SIGINT', () => gracefulExit(130))
|
|
182
|
+
process.on('SIGTERM', () => gracefulExit(143))
|
|
148
183
|
await (native as any).untilReady(opts.bootTimeoutMs ?? 5000)
|
|
149
184
|
await (native as any).untilShutdown()
|
|
150
185
|
},
|
|
@@ -247,8 +282,8 @@ export const brust = {
|
|
|
247
282
|
// (or any ArrayBuffer the worker keeps rooted) — Rust captures the backing-store
|
|
248
283
|
// pointer once here and reuses it for every render call. The buffer is held alive
|
|
249
284
|
// by the worker's module scope; do not let it go out of scope.
|
|
250
|
-
registerRenderer(buf: Uint8Array, fn: RenderFn): number {
|
|
251
|
-
return (native as any).registerRenderer(buf, fn)
|
|
285
|
+
registerRenderer(buf: Uint8Array, slots: number, fn: RenderFn): number {
|
|
286
|
+
return (native as any).registerRenderer(buf, slots, fn)
|
|
252
287
|
},
|
|
253
288
|
|
|
254
289
|
/**
|
|
@@ -724,7 +759,11 @@ export const brust = {
|
|
|
724
759
|
}
|
|
725
760
|
}
|
|
726
761
|
|
|
727
|
-
|
|
762
|
+
// Render slots for this worker (set in serve() via the worker env). The
|
|
763
|
+
// SAB scales with the slot count so each slot's disjoint sub-region keeps
|
|
764
|
+
// the single-slot capacity; at K=1 this is byte-identical to before.
|
|
765
|
+
const renderSlots = Math.max(1, Number(process.env.BRUST_RENDER_SLOTS ?? 1) || 1)
|
|
766
|
+
const sab = new SharedArrayBuffer((opts.sabBytes ?? 256 * 1024) * renderSlots)
|
|
728
767
|
const view = new Uint8Array(sab)
|
|
729
768
|
|
|
730
769
|
let mcpManifest: import('./mcp/manifest.ts').McpManifest | null
|
|
@@ -766,8 +805,9 @@ export const brust = {
|
|
|
766
805
|
actions: endpoints,
|
|
767
806
|
getWorkerId: () => wid,
|
|
768
807
|
mcp: mcpServer,
|
|
808
|
+
slots: renderSlots,
|
|
769
809
|
})
|
|
770
|
-
wid = this.registerRenderer(view, renderer)
|
|
810
|
+
wid = this.registerRenderer(view, renderSlots, renderer)
|
|
771
811
|
}
|
|
772
812
|
},
|
|
773
813
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { createElement, type ComponentType, type ReactNode } from 'react'
|
|
1
|
+
import { createContext, createElement, useContext, type ComponentType, type ReactNode } from 'react'
|
|
2
2
|
import type { IsrConfig } from './isr-jsx.ts'
|
|
3
3
|
|
|
4
4
|
/** Triggers that activate hydration of an island marker. */
|
|
@@ -44,18 +44,30 @@ export interface IslandProps<P> {
|
|
|
44
44
|
isr?: IsrConfig
|
|
45
45
|
}
|
|
46
46
|
|
|
47
|
-
/**
|
|
48
|
-
*
|
|
49
|
-
*
|
|
50
|
-
|
|
47
|
+
/** Per-render box tracking whether any `<Island>` rendered. Created fresh per
|
|
48
|
+
* render and provided through {@link IslandUsedContext}; the renderer reads
|
|
49
|
+
* `box.used` once at the end to decide whether to prepend the importmap +
|
|
50
|
+
* bootstrap script.
|
|
51
|
+
*
|
|
52
|
+
* This is REQUEST-SCOPED (not a module-scope flag) so concurrent renders in one
|
|
53
|
+
* isolate (renderSlots>1) never cross-contaminate: React restores each render's
|
|
54
|
+
* context stack across Suspense resumption, so an interleaved peer setting its
|
|
55
|
+
* own box never flips ours. A module `let` could not give that guarantee. */
|
|
56
|
+
export interface IslandUsedBox {
|
|
57
|
+
used: boolean
|
|
58
|
+
}
|
|
51
59
|
|
|
52
|
-
/**
|
|
53
|
-
export function
|
|
54
|
-
|
|
55
|
-
__used = false
|
|
56
|
-
return v
|
|
60
|
+
/** Fresh per-render box. */
|
|
61
|
+
export function createIslandUsedBox(): IslandUsedBox {
|
|
62
|
+
return { used: false }
|
|
57
63
|
}
|
|
58
64
|
|
|
65
|
+
/** Carries the per-render {@link IslandUsedBox} down to every `<Island>`. The
|
|
66
|
+
* renderer wraps the tree in a Provider with a fresh box; an `<Island>` rendered
|
|
67
|
+
* with no Provider (e.g. a standalone `renderToString` outside the React render
|
|
68
|
+
* path) reads `null` and is a no-op. */
|
|
69
|
+
export const IslandUsedContext = createContext<IslandUsedBox | null>(null)
|
|
70
|
+
|
|
59
71
|
// Constraint is `object`, NOT `Record<string, unknown>`: a TS `interface` has no
|
|
60
72
|
// implicit index signature, so it does NOT satisfy `extends Record<string, unknown>`
|
|
61
73
|
// — that made `P` fall back to the constraint and rejected any component whose
|
|
@@ -67,7 +79,10 @@ export function Island<P extends object>({
|
|
|
67
79
|
props,
|
|
68
80
|
hydrate = 'load',
|
|
69
81
|
}: IslandProps<P>): ReactNode {
|
|
70
|
-
|
|
82
|
+
// Request-scoped: flip THIS render's box (see IslandUsedContext). No-op if
|
|
83
|
+
// rendered without a Provider (standalone renderToString).
|
|
84
|
+
const usedBox = useContext(IslandUsedContext)
|
|
85
|
+
if (usedBox) usedBox.used = true
|
|
71
86
|
const resolvedId = Component.name
|
|
72
87
|
if (!resolvedId) {
|
|
73
88
|
throw new Error(
|
package/runtime/native/build.ts
CHANGED
|
@@ -1,18 +1,24 @@
|
|
|
1
|
+
import { createHash } from 'node:crypto'
|
|
1
2
|
import { mkdirSync, readFileSync, rmSync, writeFileSync } from 'node:fs'
|
|
2
|
-
import { basename, extname, isAbsolute, resolve } from 'node:path'
|
|
3
|
+
import { basename, extname, isAbsolute, relative, resolve } from 'node:path'
|
|
3
4
|
import { scanImports } from '../cli/native-routes-emit.ts'
|
|
4
5
|
|
|
5
6
|
const BEHAVIOR_RE = /export\s+const\s+behavior\b/
|
|
6
7
|
|
|
7
|
-
/**
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
/** Deterministic, app-unique directive name = camelCase(basename) + "_" + 8 hex of
|
|
9
|
+
* sha256(cwd-relative path). The SINGLE name contract: chunk filename, runtime
|
|
10
|
+
* registry key, and the compiler-emitted `x-data` all derive from this. */
|
|
11
|
+
export function directiveName(absPath: string, projectRoot: string): string {
|
|
12
|
+
const base = basename(absPath, extname(absPath))
|
|
13
|
+
const camel = base.length > 0 ? base[0]!.toLowerCase() + base.slice(1) : base
|
|
14
|
+
const rel = relative(projectRoot, absPath).replaceAll('\\', '/')
|
|
15
|
+
const hash = createHash('sha256').update(rel).digest('hex').slice(0, 8)
|
|
16
|
+
return `${camel}_${hash}`
|
|
11
17
|
}
|
|
12
18
|
|
|
13
|
-
/** BFS the local import graph from the routes entry; return
|
|
19
|
+
/** BFS the local import graph from the routes entry; return directiveName →
|
|
14
20
|
* absolute sourcePath for every file that has `export const behavior`. Throws on
|
|
15
|
-
* two distinct files deriving the same
|
|
21
|
+
* two distinct files deriving the same directive name (path-hashed, collision-resistant). */
|
|
16
22
|
export function scanDirectiveComponents(routesEntryFile: string): Map<string, string> {
|
|
17
23
|
const found = new Map<string, string>()
|
|
18
24
|
const visited = new Set<string>()
|
|
@@ -31,11 +37,11 @@ export function scanDirectiveComponents(routesEntryFile: string): Map<string, st
|
|
|
31
37
|
if (!visited.has(dep)) queue.push(dep)
|
|
32
38
|
}
|
|
33
39
|
if (BEHAVIOR_RE.test(src)) {
|
|
34
|
-
const name =
|
|
40
|
+
const name = directiveName(filePath, process.cwd())
|
|
35
41
|
const existing = found.get(name)
|
|
36
42
|
if (existing && existing !== filePath) {
|
|
37
43
|
throw new Error(
|
|
38
|
-
`directive component name "${name}" derives from two files (${existing} and ${filePath});
|
|
44
|
+
`directive component name "${name}" (path-hashed) derives from two files (${existing} and ${filePath}); this should be impossible — please report a bug`,
|
|
39
45
|
)
|
|
40
46
|
}
|
|
41
47
|
found.set(name, filePath)
|