brustjs 0.1.36-alpha → 0.1.38-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/example/pokedex/app.css +11 -0
- package/example/pokedex/components/AppLayout.tsx +3 -1
- package/example/pokedex/components/TeamBuilder.module.css +47 -0
- package/example/pokedex/components/TeamBuilder.tsx +11 -2
- package/example/pokedex/components/ThemeToggle.tsx +7 -5
- package/example/pokedex/lib/loaders.ts +26 -11
- package/example/pokedex/lib/types.ts +1 -0
- package/example/pokedex/pages/TypeChart.tsx +17 -13
- package/package.json +7 -7
- package/runtime/cli/build.ts +65 -35
- package/runtime/cli/native-routes-emit.ts +22 -1
- package/runtime/cli/templates/minimal/package.json.tmpl +1 -0
- package/runtime/cli/templates.ts +1 -0
- package/runtime/css/component-build.ts +13 -5
- package/runtime/css/route-deps.ts +26 -11
- package/runtime/css-modules.d.ts +17 -0
- package/runtime/index.js +52 -52
- package/runtime/index.ts +68 -12
- package/runtime/islands/bootstrap.ts +16 -1
- package/runtime/islands/build.ts +68 -17
- package/runtime/islands/chunk-id.ts +17 -0
- package/runtime/islands/island.tsx +18 -1
- package/runtime/routes.ts +16 -0
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.38-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.38-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.38-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.38-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.38-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.38-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.38-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.38-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.38-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.38-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.38-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.38-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.38-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.38-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.38-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.38-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.38-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.38-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.38-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.38-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.38-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.38-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.38-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.38-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.38-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.38-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.38-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.38-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.38-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.38-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.38-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.38-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.38-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.38-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.38-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.38-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.38-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.38-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.38-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.38-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.38-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.38-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.38-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.38-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.38-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.38-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.38-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.38-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.38-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.38-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.38-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.38-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
|
@@ -372,11 +372,13 @@ export const brust = {
|
|
|
372
372
|
console.log(`[brust] main: spawning ${workers} worker threads`)
|
|
373
373
|
if (cacheMaxEntries !== undefined) this.configureCache({ maxEntries: cacheMaxEntries })
|
|
374
374
|
|
|
375
|
-
// Component CSS pipeline.
|
|
376
|
-
//
|
|
377
|
-
//
|
|
378
|
-
//
|
|
379
|
-
// (
|
|
375
|
+
// Component CSS pipeline. Build the manifest + capture the loader plugin
|
|
376
|
+
// BEFORE buildIslands and pass it EXPLICITLY below (global Bun.plugin()
|
|
377
|
+
// does NOT reach Bun.build) — otherwise Bun's default loader emits
|
|
378
|
+
// .module.css as a separate asset and collides when an island and its
|
|
379
|
+
// module share a basename (Counter.tsx + Counter.module.css → both
|
|
380
|
+
// want to emit Counter.js).
|
|
381
|
+
const cssBuildPlugins: import('bun').BunPlugin[] = []
|
|
380
382
|
{
|
|
381
383
|
const { readComponentCssManifest } = await import('./css/manifest.ts')
|
|
382
384
|
const { cssLoaderPlugin } = await import('./css/component-loader.ts')
|
|
@@ -390,9 +392,19 @@ export const brust = {
|
|
|
390
392
|
const scan = await scanCssImports(scanRoot)
|
|
391
393
|
if (scan.size > 0) {
|
|
392
394
|
const { buildComponentCss } = await import('./css/component-build.ts')
|
|
395
|
+
const { scanImports } = await import('./cli/native-routes-emit.ts')
|
|
396
|
+
const routesFile = path.join(scanRoot, 'routes.tsx')
|
|
397
|
+
const idents = existsSync(routesFile)
|
|
398
|
+
? scanImports(routesFile)
|
|
399
|
+
: new Map<string, string>()
|
|
393
400
|
const routeForCss = opts.routes.map((r) => ({
|
|
394
401
|
fullPath: r.fullPath,
|
|
395
|
-
|
|
402
|
+
// Resolve the route's component chain (layout → leaf) to source
|
|
403
|
+
// files; computeRouteChunks BFS-walks each subtree for CSS deps.
|
|
404
|
+
componentSources: r.chain
|
|
405
|
+
.map((node) => (node as { Component?: { name?: string } }).Component?.name)
|
|
406
|
+
.map((name) => (name ? idents.get(name) : undefined))
|
|
407
|
+
.filter((p): p is string => typeof p === 'string'),
|
|
396
408
|
}))
|
|
397
409
|
const cssOutDir = path.join(process.cwd(), '.brust', 'css')
|
|
398
410
|
manifest = await buildComponentCss({
|
|
@@ -408,7 +420,9 @@ export const brust = {
|
|
|
408
420
|
}
|
|
409
421
|
|
|
410
422
|
if (manifest) {
|
|
411
|
-
|
|
423
|
+
const plugin = cssLoaderPlugin(manifest)
|
|
424
|
+
Bun.plugin(plugin) // runtime/SSR resolution of .module.css in the worker isolate
|
|
425
|
+
cssBuildPlugins.push(plugin) // explicit resolution for island Bun.build
|
|
412
426
|
for (const [routePath, hrefs] of Object.entries(manifest.routeChunks)) {
|
|
413
427
|
configureCssHrefsForRoute(routePath, hrefs)
|
|
414
428
|
}
|
|
@@ -429,7 +443,7 @@ export const brust = {
|
|
|
429
443
|
const islandMap = scanIslandChunks(routesPath)
|
|
430
444
|
let islandsDir: string | undefined
|
|
431
445
|
if (islandMap.size > 0) {
|
|
432
|
-
const islands = await build(islandMap)
|
|
446
|
+
const islands = await build(islandMap, { plugins: cssBuildPlugins })
|
|
433
447
|
islandsDir = islands.outDir
|
|
434
448
|
console.log(`[brust] main: built ${islands.islandCount} island chunk(s)`)
|
|
435
449
|
}
|
|
@@ -640,9 +654,17 @@ export const brust = {
|
|
|
640
654
|
if (scan.size === 0) return
|
|
641
655
|
const { buildComponentCss } = await import('./css/component-build.ts')
|
|
642
656
|
const { cssLoaderPlugin } = await import('./css/component-loader.ts')
|
|
657
|
+
const { scanImports } = await import('./cli/native-routes-emit.ts')
|
|
658
|
+
const routesFile = pathModule.join(scanRoot, 'routes.tsx')
|
|
659
|
+
const idents = existsSync(routesFile)
|
|
660
|
+
? scanImports(routesFile)
|
|
661
|
+
: new Map<string, string>()
|
|
643
662
|
const routeForCss = opts.routes.map((r) => ({
|
|
644
663
|
fullPath: r.fullPath,
|
|
645
|
-
|
|
664
|
+
componentSources: r.chain
|
|
665
|
+
.map((node) => (node as { Component?: { name?: string } }).Component?.name)
|
|
666
|
+
.map((name) => (name ? idents.get(name) : undefined))
|
|
667
|
+
.filter((p): p is string => typeof p === 'string'),
|
|
646
668
|
}))
|
|
647
669
|
const cssOutDir = pathModule.join(process.cwd(), '.brust', 'css')
|
|
648
670
|
const manifest = await buildComponentCss({
|
|
@@ -744,9 +766,10 @@ export const brust = {
|
|
|
744
766
|
}
|
|
745
767
|
|
|
746
768
|
// Worker: register the component CSS Bun.plugin so .module.css imports
|
|
747
|
-
// resolve to the same hash map main saw
|
|
748
|
-
//
|
|
749
|
-
//
|
|
769
|
+
// resolve to the same hash map main saw, AND seed the per-route CSS hrefs.
|
|
770
|
+
// The streaming renderer (render/stream.ts) runs HERE in the worker and
|
|
771
|
+
// reads getCssHrefsForRoute to inject the <link> before </head> — so the
|
|
772
|
+
// route→chunk map must be configured in the worker, not just on main.
|
|
750
773
|
{
|
|
751
774
|
const { readComponentCssManifest } = await import('./css/manifest.ts')
|
|
752
775
|
const { cssLoaderPlugin } = await import('./css/component-loader.ts')
|
|
@@ -756,6 +779,39 @@ export const brust = {
|
|
|
756
779
|
const manifest = await readComponentCssManifest(manifestPath)
|
|
757
780
|
if (manifest) {
|
|
758
781
|
Bun.plugin(cssLoaderPlugin(manifest))
|
|
782
|
+
for (const [routePath, hrefs] of Object.entries(manifest.routeChunks)) {
|
|
783
|
+
configureCssHrefsForRoute(routePath, hrefs)
|
|
784
|
+
}
|
|
785
|
+
}
|
|
786
|
+
}
|
|
787
|
+
|
|
788
|
+
// Worker: seed island.tsx's Component→id registry so a React `<Island>`
|
|
789
|
+
// marker carries the content-addressed id (`<Name>_<hash>`) — same-name
|
|
790
|
+
// parity for the React render path, mirroring the native jinja rewrite.
|
|
791
|
+
// Keyed by component IDENTITY (the imported default export), so two
|
|
792
|
+
// same-named components from different files get distinct markers/chunks.
|
|
793
|
+
{
|
|
794
|
+
const { configureIslandIdRegistry } = await import('./islands/island.tsx')
|
|
795
|
+
const islandsDir = prebuilt
|
|
796
|
+
? path.join(distDir!, 'islands')
|
|
797
|
+
: path.join(process.cwd(), '.brust', 'islands')
|
|
798
|
+
const srcManifest = path.join(islandsDir, '_island-sources.json')
|
|
799
|
+
if (existsSync(srcManifest)) {
|
|
800
|
+
try {
|
|
801
|
+
const sources = JSON.parse(await Bun.file(srcManifest).text()) as Record<string, string>
|
|
802
|
+
const entries: Array<[unknown, string]> = []
|
|
803
|
+
for (const [id, rel] of Object.entries(sources)) {
|
|
804
|
+
try {
|
|
805
|
+
const mod = await import(path.resolve(process.cwd(), rel))
|
|
806
|
+
if (mod.default) entries.push([mod.default, id])
|
|
807
|
+
} catch {
|
|
808
|
+
// Unreadable source — skip; the marker falls back to Component.name.
|
|
809
|
+
}
|
|
810
|
+
}
|
|
811
|
+
configureIslandIdRegistry(entries)
|
|
812
|
+
} catch {
|
|
813
|
+
// Malformed manifest — skip (markers fall back to Component.name).
|
|
814
|
+
}
|
|
759
815
|
}
|
|
760
816
|
}
|
|
761
817
|
|
|
@@ -84,6 +84,20 @@ function registerTrigger(el: HTMLElement, trigger: Trigger, fire: () => void): v
|
|
|
84
84
|
// Exported for unit testing — the public entry is hydrateMarkersIn, but the
|
|
85
85
|
// createRoot/hydrateRoot auto-detect branch is cleanest to assert by driving
|
|
86
86
|
// hydrateOne directly (the `load` trigger fires it as a detached microtask).
|
|
87
|
+
// id → content-addressed chunk URL, emitted by buildIslands as _islands.js.
|
|
88
|
+
// Loaded once (memoized). On any failure the map is empty and resolution falls
|
|
89
|
+
// back to the legacy `/_brust/islands/<id>.js` URL, so an older build still works.
|
|
90
|
+
let chunkMapPromise: Promise<Record<string, string>> | null = null
|
|
91
|
+
function islandChunkMap(): Promise<Record<string, string>> {
|
|
92
|
+
if (!chunkMapPromise) {
|
|
93
|
+
const url = '/_brust/islands/_islands.js' // variable specifier → runtime import, not bundled
|
|
94
|
+
chunkMapPromise = import(url)
|
|
95
|
+
.then((m) => (m.default ?? {}) as Record<string, string>)
|
|
96
|
+
.catch(() => ({}))
|
|
97
|
+
}
|
|
98
|
+
return chunkMapPromise
|
|
99
|
+
}
|
|
100
|
+
|
|
87
101
|
export async function hydrateOne(el: HTMLElement): Promise<void> {
|
|
88
102
|
const id = el.getAttribute('data-brust-island')
|
|
89
103
|
if (!id) return
|
|
@@ -96,7 +110,8 @@ export async function hydrateOne(el: HTMLElement): Promise<void> {
|
|
|
96
110
|
return
|
|
97
111
|
}
|
|
98
112
|
try {
|
|
99
|
-
const
|
|
113
|
+
const url = (await islandChunkMap())[id] ?? `/_brust/islands/${id}.js`
|
|
114
|
+
const mod = await import(url)
|
|
100
115
|
const Component = (mod.default ?? mod) as React.ComponentType<Record<string, unknown>>
|
|
101
116
|
if (typeof Component !== 'function') {
|
|
102
117
|
console.error(`[brust] island "${id}": chunk has no default-exported component`)
|
package/runtime/islands/build.ts
CHANGED
|
@@ -1,18 +1,29 @@
|
|
|
1
1
|
import { readFileSync } from 'node:fs'
|
|
2
|
-
import { mkdir, rm } from 'node:fs/promises'
|
|
3
|
-
import { isAbsolute, resolve } from 'node:path'
|
|
2
|
+
import { mkdir, rm, writeFile } from 'node:fs/promises'
|
|
3
|
+
import { isAbsolute, relative, resolve } from 'node:path'
|
|
4
|
+
import type { BunPlugin } from 'bun'
|
|
4
5
|
import { scanImports } from '../cli/native-routes-emit.ts'
|
|
6
|
+
import { islandChunkBasename } from './chunk-id.ts'
|
|
5
7
|
|
|
6
8
|
export interface IslandsBuildResult {
|
|
7
9
|
/** Absolute path to the output directory passed to brust's Rust side. */
|
|
8
10
|
outDir: string
|
|
9
11
|
/** Number of island chunks emitted (excludes runtime + bootstrap). */
|
|
10
12
|
islandCount: number
|
|
13
|
+
/** id → content-addressed chunk URL (`/_brust/islands/<id>_<hash>.js`). Also
|
|
14
|
+
* written to `_islands.js` for the client bootstrap to resolve at runtime. */
|
|
15
|
+
chunks: Record<string, string>
|
|
11
16
|
}
|
|
12
17
|
|
|
13
18
|
export interface BuildIslandsOptions {
|
|
14
19
|
/** Override the output directory. Default: `<cwd>/.brust/islands`. */
|
|
15
20
|
outDir?: string
|
|
21
|
+
/** Build plugins passed straight to `Bun.build` for the per-island chunks.
|
|
22
|
+
* Needed for the component-CSS loader: global `Bun.plugin()` registrations do
|
|
23
|
+
* NOT apply to `Bun.build`, so an island that `import`s a `.module.css` must
|
|
24
|
+
* get the resolver here or Bun emits the CSS as a separate asset and collides
|
|
25
|
+
* on the output filename (X.module.css + X.tsx → both X.js). */
|
|
26
|
+
plugins?: BunPlugin[]
|
|
16
27
|
}
|
|
17
28
|
|
|
18
29
|
/** Scan a routes entry file for `<Island component={X} />` usage and derive the
|
|
@@ -24,8 +35,12 @@ export interface BuildIslandsOptions {
|
|
|
24
35
|
* `component={Ident}`. A tag with no `component` is a hard error (F3:
|
|
25
36
|
* never silently skip an island).
|
|
26
37
|
* 3. Resolve each captured ident through that page's OWN imports.
|
|
27
|
-
* 4.
|
|
28
|
-
*
|
|
38
|
+
* 4. Key by the content-addressed {@link islandChunkBasename} (`<Name>_<hash>`),
|
|
39
|
+
* NOT the bare name — so two DIFFERENT files exporting a same-named component
|
|
40
|
+
* produce two distinct chunks. Same name + same file dedups (same id). The
|
|
41
|
+
* marker carries this same id (native: reconcileIslandManifest rewrite;
|
|
42
|
+
* React: the Component→id registry seeded at worker boot), so there is no
|
|
43
|
+
* app-unique-name requirement.
|
|
29
44
|
*/
|
|
30
45
|
export function scanIslandChunks(routesEntryFile: string): Map<string, string> {
|
|
31
46
|
const chunks = new Map<string, string>()
|
|
@@ -70,16 +85,10 @@ export function scanIslandChunks(routesEntryFile: string): Map<string, string> {
|
|
|
70
85
|
`(expected \`import ${ident} from "..."\`)`,
|
|
71
86
|
)
|
|
72
87
|
}
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
throw new Error(
|
|
78
|
-
`island component name "${ident}" is used by two different files ` +
|
|
79
|
-
`(${existing} and ${src}); island component names must be app-unique`,
|
|
80
|
-
)
|
|
81
|
-
}
|
|
82
|
-
// existing === src → same component reused; dedupe (skip).
|
|
88
|
+
// Key by the content-addressed id: same name + same file → one chunk
|
|
89
|
+
// (dedup); same name + DIFFERENT file → two distinct ids → two chunks.
|
|
90
|
+
// Collisions are impossible (the id embeds a hash of the source path).
|
|
91
|
+
chunks.set(islandChunkBasename(ident, src), src)
|
|
83
92
|
}
|
|
84
93
|
}
|
|
85
94
|
|
|
@@ -109,8 +118,17 @@ export async function buildIslands(
|
|
|
109
118
|
// 2. react-dom/client (react external; consumes _react.js via importmap).
|
|
110
119
|
await buildOne([`${entriesDir}/react-dom.ts`], outDir, '_react-dom.js', ['react'])
|
|
111
120
|
|
|
112
|
-
// 3. Per-island chunks (all 3 runtime specifiers external).
|
|
121
|
+
// 3. Per-island chunks (all 3 runtime specifiers external). Island sources may
|
|
122
|
+
// `import styles from './X.module.css'`, so the component-CSS plugins resolve
|
|
123
|
+
// those imports to the scoped name map (otherwise Bun emits the CSS as an asset).
|
|
113
124
|
const externals = ['react', 'react/jsx-runtime', 'react-dom/client']
|
|
125
|
+
const plugins = options.plugins ?? []
|
|
126
|
+
// The map is keyed by the content-addressed id (scanIslandChunks), which IS the
|
|
127
|
+
// chunk basename — the data-brust-island marker carries that same id, so the
|
|
128
|
+
// bootstrap loads the right chunk directly.
|
|
129
|
+
const chunks: Record<string, string> = {}
|
|
130
|
+
const sources: Record<string, string> = {}
|
|
131
|
+
const urlsByName = new Map<string, string[]>()
|
|
114
132
|
let count = 0
|
|
115
133
|
for (const [id, entry] of islands) {
|
|
116
134
|
if (!isValidIslandId(id)) {
|
|
@@ -119,15 +137,46 @@ export async function buildIslands(
|
|
|
119
137
|
`allowed: [A-Za-z0-9_-]+ (matches the server's filename safety check)`,
|
|
120
138
|
)
|
|
121
139
|
}
|
|
122
|
-
|
|
140
|
+
const file = `${id}.js`
|
|
141
|
+
await buildOne([entry], outDir, file, externals, plugins)
|
|
142
|
+
const url = `/_brust/islands/${file}`
|
|
143
|
+
chunks[id] = url
|
|
144
|
+
// PROJECT-RELATIVE source path (no leaked abs build path); the worker
|
|
145
|
+
// rehydrates it against cwd to build the Component→id registry.
|
|
146
|
+
sources[id] = relative(process.cwd(), entry).replaceAll('\\', '/')
|
|
147
|
+
const name = id.replace(/_[a-f0-9]{8}$/, '')
|
|
148
|
+
const list = urlsByName.get(name)
|
|
149
|
+
if (list) list.push(url)
|
|
150
|
+
else urlsByName.set(name, [url])
|
|
123
151
|
count++
|
|
124
152
|
}
|
|
153
|
+
// Also expose each chunk by its plain Component name when that name is
|
|
154
|
+
// UNAMBIGUOUS (one source) — a defensive fallback for a marker that carries
|
|
155
|
+
// the bare name (e.g. the registry wasn't seeded). Ambiguous names are omitted:
|
|
156
|
+
// those markers carry the unique id (native rewrite / React registry).
|
|
157
|
+
for (const [name, urls] of urlsByName) {
|
|
158
|
+
if (urls.length === 1 && !(name in chunks)) chunks[name] = urls[0]!
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
// id → chunk URL map, served at /_brust/islands/_islands.js. The bootstrap
|
|
162
|
+
// loads it once and resolves a marker's id to its chunk (legacy
|
|
163
|
+
// `/_brust/islands/<id>.js` fallback). ESM default export.
|
|
164
|
+
await writeFile(
|
|
165
|
+
resolve(outDir, '_islands.js'),
|
|
166
|
+
`export default ${JSON.stringify(chunks)}\n`,
|
|
167
|
+
'utf-8',
|
|
168
|
+
)
|
|
169
|
+
|
|
170
|
+
// id → project-relative source path. The worker imports each at boot and maps
|
|
171
|
+
// the default export (component fn) → id, seeding island.tsx's registry so the
|
|
172
|
+
// React render path emits the content-addressed marker (same-name parity).
|
|
173
|
+
await writeFile(resolve(outDir, '_island-sources.json'), JSON.stringify(sources), 'utf-8')
|
|
125
174
|
|
|
126
175
|
// 4. Bootstrap (react + react-dom/client external; uses importmap).
|
|
127
176
|
const bootstrapSrc = resolve(import.meta.dir, 'bootstrap.ts')
|
|
128
177
|
await buildOne([bootstrapSrc], outDir, '_bootstrap.js', externals)
|
|
129
178
|
|
|
130
|
-
return { outDir, islandCount: count }
|
|
179
|
+
return { outDir, islandCount: count, chunks }
|
|
131
180
|
}
|
|
132
181
|
|
|
133
182
|
async function buildOne(
|
|
@@ -135,6 +184,7 @@ async function buildOne(
|
|
|
135
184
|
outdir: string,
|
|
136
185
|
naming: string,
|
|
137
186
|
external: string[],
|
|
187
|
+
plugins: BunPlugin[] = [],
|
|
138
188
|
): Promise<void> {
|
|
139
189
|
const result = await Bun.build({
|
|
140
190
|
entrypoints,
|
|
@@ -144,6 +194,7 @@ async function buildOne(
|
|
|
144
194
|
target: 'browser',
|
|
145
195
|
external,
|
|
146
196
|
minify: true,
|
|
197
|
+
plugins,
|
|
147
198
|
define: {
|
|
148
199
|
'process.env.NODE_ENV': '"production"',
|
|
149
200
|
},
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { createHash } from 'node:crypto'
|
|
2
|
+
import { relative } from 'node:path'
|
|
3
|
+
|
|
4
|
+
/** Content-addressed island id / chunk basename = `<Name>_<8hex(sha256
|
|
5
|
+
* cwd-relative source path)>`. The SINGLE name contract (mirrors the directive
|
|
6
|
+
* chunk scheme): the chunk filename, the `data-brust-island` marker (native
|
|
7
|
+
* rewrite in reconcileIslandManifest + the React island-id onLoad plugin), and
|
|
8
|
+
* the bootstrap import all derive from this — so two same-named components from
|
|
9
|
+
* different files get distinct ids and never collide.
|
|
10
|
+
*
|
|
11
|
+
* Lives in its own module (no `scanImports` dep) so both `islands/build.ts` and
|
|
12
|
+
* `cli/native-routes-emit.ts` can import it without a circular dependency. */
|
|
13
|
+
export function islandChunkBasename(name: string, absSourcePath: string): string {
|
|
14
|
+
const rel = relative(process.cwd(), absSourcePath).replaceAll('\\', '/')
|
|
15
|
+
const hash = createHash('sha256').update(rel).digest('hex').slice(0, 8)
|
|
16
|
+
return `${name}_${hash}`
|
|
17
|
+
}
|