brustjs 0.1.60-alpha → 0.1.61-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/index.js +52 -52
- package/runtime/islands/bootstrap.ts +105 -20
- package/runtime/islands/island.tsx +12 -1
- package/types/islands/island.d.ts +5 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "brustjs",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.61-alpha",
|
|
4
4
|
"description": "Bun + Rust SSR framework — React on the server, Rust everywhere else (napi cdylib + per-worker SharedArrayBuffer).",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -41,12 +41,12 @@
|
|
|
41
41
|
"typescript": "^6.0.3"
|
|
42
42
|
},
|
|
43
43
|
"optionalDependencies": {
|
|
44
|
-
"brustjs-darwin-x64": "0.1.
|
|
45
|
-
"brustjs-darwin-arm64": "0.1.
|
|
46
|
-
"brustjs-linux-x64-gnu": "0.1.
|
|
47
|
-
"brustjs-linux-arm64-gnu": "0.1.
|
|
48
|
-
"brustjs-linux-x64-musl": "0.1.
|
|
49
|
-
"brustjs-linux-arm64-musl": "0.1.
|
|
44
|
+
"brustjs-darwin-x64": "0.1.61-alpha",
|
|
45
|
+
"brustjs-darwin-arm64": "0.1.61-alpha",
|
|
46
|
+
"brustjs-linux-x64-gnu": "0.1.61-alpha",
|
|
47
|
+
"brustjs-linux-arm64-gnu": "0.1.61-alpha",
|
|
48
|
+
"brustjs-linux-x64-musl": "0.1.61-alpha",
|
|
49
|
+
"brustjs-linux-arm64-musl": "0.1.61-alpha"
|
|
50
50
|
},
|
|
51
51
|
"peerDependencies": {
|
|
52
52
|
"react": "^19.2.6",
|
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.61-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.61-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.61-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.61-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.61-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.61-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.61-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.61-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.61-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.61-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.61-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.61-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.61-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.61-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.61-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.61-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.61-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.61-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.61-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.61-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.61-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.61-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.61-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.61-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.61-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.61-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.61-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.61-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.61-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.61-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.61-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.61-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.61-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.61-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.61-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.61-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.61-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.61-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.61-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.61-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.61-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.61-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.61-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.61-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.61-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.61-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.61-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.61-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.61-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.61-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.61-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.61-alpha but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
513
513
|
}
|
|
514
514
|
return binding
|
|
515
515
|
} catch (e) {
|
|
@@ -45,57 +45,103 @@ import { withViewTransition } from './view-transition.ts'
|
|
|
45
45
|
// out from under a live root causes React's scheduler to keep posting
|
|
46
46
|
// work to a detached subtree, which manifests as a hung tab.
|
|
47
47
|
const islandRoots = new WeakMap<HTMLElement, Root>()
|
|
48
|
+
const islandTriggerCleanups = new WeakMap<HTMLElement, () => void>()
|
|
49
|
+
const canceledIslandMarkers = new WeakSet<HTMLElement>()
|
|
48
50
|
|
|
49
51
|
type Trigger = 'load' | 'idle' | 'visible' | 'interaction'
|
|
50
52
|
|
|
51
|
-
function registerTrigger(el: HTMLElement, trigger: Trigger, fire: () => void): void {
|
|
53
|
+
function registerTrigger(el: HTMLElement, trigger: Trigger, fire: () => void): () => void {
|
|
52
54
|
switch (trigger) {
|
|
53
55
|
case 'load': {
|
|
54
56
|
fire()
|
|
55
|
-
return
|
|
57
|
+
return () => {}
|
|
56
58
|
}
|
|
57
59
|
case 'idle': {
|
|
58
|
-
const
|
|
59
|
-
|
|
60
|
+
const idleGlobal = globalThis as {
|
|
61
|
+
requestIdleCallback?: (cb: () => void) => number
|
|
62
|
+
cancelIdleCallback?: (handle: number) => void
|
|
63
|
+
}
|
|
64
|
+
let active = true
|
|
65
|
+
const run = () => {
|
|
66
|
+
if (!active) return
|
|
67
|
+
active = false
|
|
68
|
+
islandTriggerCleanups.delete(el)
|
|
69
|
+
fire()
|
|
70
|
+
}
|
|
71
|
+
const rIC = idleGlobal.requestIdleCallback
|
|
60
72
|
if (typeof rIC === 'function') {
|
|
61
|
-
rIC(
|
|
73
|
+
const handle = rIC(run)
|
|
74
|
+
return () => {
|
|
75
|
+
if (!active) return
|
|
76
|
+
active = false
|
|
77
|
+
idleGlobal.cancelIdleCallback?.(handle)
|
|
78
|
+
}
|
|
62
79
|
} else {
|
|
63
|
-
setTimeout(
|
|
80
|
+
const handle = setTimeout(run, 0)
|
|
81
|
+
return () => {
|
|
82
|
+
if (!active) return
|
|
83
|
+
active = false
|
|
84
|
+
clearTimeout(handle)
|
|
85
|
+
}
|
|
64
86
|
}
|
|
65
|
-
return
|
|
66
87
|
}
|
|
67
88
|
case 'visible': {
|
|
68
89
|
if (typeof IntersectionObserver === 'undefined') {
|
|
69
90
|
fire()
|
|
70
|
-
return
|
|
91
|
+
return () => {}
|
|
71
92
|
}
|
|
93
|
+
let active = true
|
|
72
94
|
const io = new IntersectionObserver((entries, obs) => {
|
|
95
|
+
if (!active) return
|
|
73
96
|
for (const e of entries) {
|
|
74
97
|
if (e.isIntersecting) {
|
|
98
|
+
active = false
|
|
75
99
|
obs.disconnect()
|
|
100
|
+
islandTriggerCleanups.delete(el)
|
|
76
101
|
fire()
|
|
77
102
|
return
|
|
78
103
|
}
|
|
79
104
|
}
|
|
80
105
|
})
|
|
81
106
|
io.observe(el)
|
|
82
|
-
return
|
|
107
|
+
return () => {
|
|
108
|
+
if (!active) return
|
|
109
|
+
active = false
|
|
110
|
+
io.disconnect()
|
|
111
|
+
}
|
|
83
112
|
}
|
|
84
113
|
case 'interaction': {
|
|
114
|
+
let active = true
|
|
85
115
|
const onceFire = () => {
|
|
116
|
+
if (!active) return
|
|
117
|
+
active = false
|
|
86
118
|
el.removeEventListener('pointerdown', onceFire)
|
|
87
119
|
el.removeEventListener('keydown', onceFire)
|
|
88
120
|
el.removeEventListener('focusin', onceFire)
|
|
121
|
+
islandTriggerCleanups.delete(el)
|
|
89
122
|
fire()
|
|
90
123
|
}
|
|
91
124
|
el.addEventListener('pointerdown', onceFire, { once: false })
|
|
92
125
|
el.addEventListener('keydown', onceFire, { once: false })
|
|
93
126
|
el.addEventListener('focusin', onceFire, { once: false })
|
|
94
|
-
return
|
|
127
|
+
return () => {
|
|
128
|
+
if (!active) return
|
|
129
|
+
active = false
|
|
130
|
+
el.removeEventListener('pointerdown', onceFire)
|
|
131
|
+
el.removeEventListener('keydown', onceFire)
|
|
132
|
+
el.removeEventListener('focusin', onceFire)
|
|
133
|
+
}
|
|
95
134
|
}
|
|
96
135
|
}
|
|
97
136
|
}
|
|
98
137
|
|
|
138
|
+
function cleanupIslandTrigger(el: HTMLElement): void {
|
|
139
|
+
const cleanup = islandTriggerCleanups.get(el)
|
|
140
|
+
if (!cleanup) return
|
|
141
|
+
islandTriggerCleanups.delete(el)
|
|
142
|
+
cleanup()
|
|
143
|
+
}
|
|
144
|
+
|
|
99
145
|
// Exported for unit testing — the public entry is hydrateMarkersIn, but the
|
|
100
146
|
// createRoot/hydrateRoot auto-detect branch is cleanest to assert by driving
|
|
101
147
|
// hydrateOne directly (the `load` trigger fires it as a detached microtask).
|
|
@@ -113,7 +159,13 @@ function islandChunkMap(): Promise<Record<string, string>> {
|
|
|
113
159
|
return chunkMapPromise
|
|
114
160
|
}
|
|
115
161
|
|
|
116
|
-
export async function hydrateOne(
|
|
162
|
+
export async function hydrateOne(
|
|
163
|
+
el: HTMLElement,
|
|
164
|
+
importer: (url: string) => Promise<Record<string, unknown>> = (url) => import(url),
|
|
165
|
+
chunkMapLoader: () => Promise<Record<string, string>> = islandChunkMap,
|
|
166
|
+
): Promise<void> {
|
|
167
|
+
if (canceledIslandMarkers.has(el)) return
|
|
168
|
+
cleanupIslandTrigger(el)
|
|
117
169
|
const id = el.getAttribute('data-brust-island')
|
|
118
170
|
if (!id) return
|
|
119
171
|
const propsJson = el.getAttribute('data-brust-props') ?? '{}'
|
|
@@ -125,23 +177,34 @@ export async function hydrateOne(el: HTMLElement): Promise<void> {
|
|
|
125
177
|
return
|
|
126
178
|
}
|
|
127
179
|
try {
|
|
128
|
-
const
|
|
129
|
-
|
|
180
|
+
const chunkMap = await chunkMapLoader()
|
|
181
|
+
if (canceledIslandMarkers.has(el)) return
|
|
182
|
+
const url = chunkMap[id] ?? `/_brust/islands/${id}.js`
|
|
183
|
+
const mod = await importer(url)
|
|
184
|
+
if (canceledIslandMarkers.has(el)) return
|
|
130
185
|
const Component = (mod.default ?? mod) as React.ComponentType<Record<string, unknown>>
|
|
131
186
|
if (typeof Component !== 'function') {
|
|
132
187
|
console.error(`[brust] island "${id}": chunk has no default-exported component`)
|
|
133
188
|
return
|
|
134
189
|
}
|
|
190
|
+
if (canceledIslandMarkers.has(el)) return
|
|
135
191
|
let root: Root
|
|
136
192
|
if (el.hasAttribute('data-brust-csr')) {
|
|
137
|
-
// Client-only island:
|
|
138
|
-
//
|
|
139
|
-
//
|
|
193
|
+
// Client-only island: discard any server placeholder only after the
|
|
194
|
+
// component chunk is known-good, immediately before taking over with a
|
|
195
|
+
// fresh client root. Descendant islands may already be mounted or awaiting
|
|
196
|
+
// their own chunks, so cancel/unmount them before their DOM is removed.
|
|
197
|
+
// hydrateRoot would mismatch against the fallback.
|
|
198
|
+
unmountIslandsIn(el)
|
|
199
|
+
if (canceledIslandMarkers.has(el)) return
|
|
200
|
+
while (el.firstChild) el.removeChild(el.firstChild)
|
|
201
|
+
if (canceledIslandMarkers.has(el)) return
|
|
140
202
|
root = createRoot(el)
|
|
141
203
|
root.render(createElement(Component, props))
|
|
142
204
|
} else {
|
|
143
205
|
// Server island (or React-path island): server markup is present in the
|
|
144
206
|
// mount, so hydrate it in place to attach handlers without re-rendering.
|
|
207
|
+
if (canceledIslandMarkers.has(el)) return
|
|
145
208
|
root = hydrateRoot(el, createElement(Component, props))
|
|
146
209
|
}
|
|
147
210
|
// createRoot and hydrateRoot both return a Root with .unmount(), so
|
|
@@ -157,16 +220,26 @@ export async function hydrateOne(el: HTMLElement): Promise<void> {
|
|
|
157
220
|
* posting work to detached nodes and the tab hangs. Exported for unit
|
|
158
221
|
* testing the createRoot/hydrateRoot unmount parity. */
|
|
159
222
|
export function unmountIslandsIn(root: ParentNode): void {
|
|
160
|
-
const markers = root.querySelectorAll<HTMLElement>('[data-brust-island]')
|
|
161
|
-
|
|
223
|
+
const markers = Array.from(root.querySelectorAll<HTMLElement>('[data-brust-island]'))
|
|
224
|
+
// Cancel every marker and trigger FIRST. An unmount can run arbitrary React
|
|
225
|
+
// cleanup code, so no pending descendant may be able to resume re-entrantly.
|
|
226
|
+
for (const el of markers) {
|
|
227
|
+
canceledIslandMarkers.add(el)
|
|
228
|
+
cleanupIslandTrigger(el)
|
|
229
|
+
}
|
|
230
|
+
// A parent root may remove its descendants while unmounting. Dispose deepest
|
|
231
|
+
// roots first, and delete the tracking entry before calling user/React cleanup
|
|
232
|
+
// so a re-entrant disposal remains idempotent.
|
|
233
|
+
markers.sort((a, b) => markerDepth(b, root) - markerDepth(a, root))
|
|
234
|
+
for (const el of markers) {
|
|
162
235
|
const r = islandRoots.get(el)
|
|
163
236
|
if (r) {
|
|
237
|
+
islandRoots.delete(el)
|
|
164
238
|
try {
|
|
165
239
|
r.unmount()
|
|
166
240
|
} catch (e) {
|
|
167
241
|
console.warn('[brust] island unmount failed', e)
|
|
168
242
|
}
|
|
169
|
-
islandRoots.delete(el)
|
|
170
243
|
}
|
|
171
244
|
}
|
|
172
245
|
// Client-takeover roots (fallback: 'client' SSG pages) live in fallback.ts's
|
|
@@ -175,6 +248,16 @@ export function unmountIslandsIn(root: ParentNode): void {
|
|
|
175
248
|
unmountFallbackRootsIn(root)
|
|
176
249
|
}
|
|
177
250
|
|
|
251
|
+
function markerDepth(el: HTMLElement, root: ParentNode): number {
|
|
252
|
+
let depth = 0
|
|
253
|
+
let cursor: ParentNode | null = el.parentNode
|
|
254
|
+
while (cursor && cursor !== root) {
|
|
255
|
+
depth++
|
|
256
|
+
cursor = cursor.parentNode
|
|
257
|
+
}
|
|
258
|
+
return depth
|
|
259
|
+
}
|
|
260
|
+
|
|
178
261
|
/** Scan `root` for un-hydrated island markers and register their hydration
|
|
179
262
|
* triggers. Exposed so the navigation interceptor can call it on the
|
|
180
263
|
* freshly-swapped <main> subtree after a SPA navigation. The
|
|
@@ -185,11 +268,13 @@ export function hydrateMarkersIn(root: ParentNode = document.body): void {
|
|
|
185
268
|
'[data-brust-island]:not([data-brust-hydrated])',
|
|
186
269
|
)
|
|
187
270
|
for (const el of Array.from(markers)) {
|
|
271
|
+
if (canceledIslandMarkers.has(el)) continue
|
|
188
272
|
el.setAttribute('data-brust-hydrated', '1')
|
|
189
273
|
const trig = (el.getAttribute('data-brust-hydrate') ?? 'load') as Trigger
|
|
190
|
-
registerTrigger(el, trig, () => {
|
|
274
|
+
const cleanup = registerTrigger(el, trig, () => {
|
|
191
275
|
void hydrateOne(el)
|
|
192
276
|
})
|
|
277
|
+
islandTriggerCleanups.set(el, cleanup)
|
|
193
278
|
}
|
|
194
279
|
}
|
|
195
280
|
|
|
@@ -1,4 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
createContext,
|
|
3
|
+
createElement,
|
|
4
|
+
useContext,
|
|
5
|
+
type ComponentType,
|
|
6
|
+
type ReactElement,
|
|
7
|
+
type ReactNode,
|
|
8
|
+
} from 'react'
|
|
2
9
|
import type { IsrConfig } from './isr-jsx.ts'
|
|
3
10
|
|
|
4
11
|
/** Triggers that activate hydration of an island marker. */
|
|
@@ -24,6 +31,10 @@ export interface IslandProps<P> {
|
|
|
24
31
|
* the loader crossing) so its markup ships in the HTML, then hydrate. Ignored
|
|
25
32
|
* on the React path (the whole tree already SSRs there). Default false. */
|
|
26
33
|
ssr?: boolean
|
|
34
|
+
/** Native/Jinja client-only islands only: server-rendered placeholder shown
|
|
35
|
+
* until the client chunk is ready. The React render path ignores this and
|
|
36
|
+
* renders the real component as usual. */
|
|
37
|
+
fallback?: ReactElement
|
|
27
38
|
/**
|
|
28
39
|
* Optional ISR (incremental static regeneration) cache for an `ssr` island on
|
|
29
40
|
* a native-jinja route. When present, the island's `renderToString` runs ONCE
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type ComponentType, type ReactNode } from 'react';
|
|
1
|
+
import { type ComponentType, type ReactElement, type ReactNode } from 'react';
|
|
2
2
|
import type { IsrConfig } from './isr-jsx.ts';
|
|
3
3
|
/** Triggers that activate hydration of an island marker. */
|
|
4
4
|
export type HydrateTrigger = 'load' | 'idle' | 'visible' | 'interaction';
|
|
@@ -22,6 +22,10 @@ export interface IslandProps<P> {
|
|
|
22
22
|
* the loader crossing) so its markup ships in the HTML, then hydrate. Ignored
|
|
23
23
|
* on the React path (the whole tree already SSRs there). Default false. */
|
|
24
24
|
ssr?: boolean;
|
|
25
|
+
/** Native/Jinja client-only islands only: server-rendered placeholder shown
|
|
26
|
+
* until the client chunk is ready. The React render path ignores this and
|
|
27
|
+
* renders the real component as usual. */
|
|
28
|
+
fallback?: ReactElement;
|
|
25
29
|
/**
|
|
26
30
|
* Optional ISR (incremental static regeneration) cache for an `ssr` island on
|
|
27
31
|
* a native-jinja route. When present, the island's `renderToString` runs ONCE
|