@brust/core 2.0.0-alpha.23 → 2.0.0-alpha.25
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/native/index.js +54 -54
- package/package.json +11 -9
- package/src/build/compile.ts +149 -2
- package/src/build/features.ts +3 -0
- package/src/build/server-only.ts +23 -0
- package/src/worker.ts +2 -1
package/native/index.js
CHANGED
|
@@ -89,8 +89,8 @@ function requireNative() {
|
|
|
89
89
|
try {
|
|
90
90
|
const binding = require('@brust/native-android-arm64')
|
|
91
91
|
const bindingPackageVersion = require('@brust/native-android-arm64/package.json').version
|
|
92
|
-
if (bindingPackageVersion !== '2.0.0-alpha.
|
|
93
|
-
throw new Error(`Native binding package version mismatch, expected 2.0.0-alpha.
|
|
92
|
+
if (bindingPackageVersion !== '2.0.0-alpha.25' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
93
|
+
throw new Error(`Native binding package version mismatch, expected 2.0.0-alpha.25 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
94
94
|
}
|
|
95
95
|
return binding
|
|
96
96
|
} catch (e) {
|
|
@@ -105,8 +105,8 @@ function requireNative() {
|
|
|
105
105
|
try {
|
|
106
106
|
const binding = require('@brust/native-android-arm-eabi')
|
|
107
107
|
const bindingPackageVersion = require('@brust/native-android-arm-eabi/package.json').version
|
|
108
|
-
if (bindingPackageVersion !== '2.0.0-alpha.
|
|
109
|
-
throw new Error(`Native binding package version mismatch, expected 2.0.0-alpha.
|
|
108
|
+
if (bindingPackageVersion !== '2.0.0-alpha.25' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
109
|
+
throw new Error(`Native binding package version mismatch, expected 2.0.0-alpha.25 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
110
110
|
}
|
|
111
111
|
return binding
|
|
112
112
|
} catch (e) {
|
|
@@ -126,8 +126,8 @@ function requireNative() {
|
|
|
126
126
|
try {
|
|
127
127
|
const binding = require('@brust/native-win32-x64-gnu')
|
|
128
128
|
const bindingPackageVersion = require('@brust/native-win32-x64-gnu/package.json').version
|
|
129
|
-
if (bindingPackageVersion !== '2.0.0-alpha.
|
|
130
|
-
throw new Error(`Native binding package version mismatch, expected 2.0.0-alpha.
|
|
129
|
+
if (bindingPackageVersion !== '2.0.0-alpha.25' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
130
|
+
throw new Error(`Native binding package version mismatch, expected 2.0.0-alpha.25 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
131
131
|
}
|
|
132
132
|
return binding
|
|
133
133
|
} catch (e) {
|
|
@@ -142,8 +142,8 @@ function requireNative() {
|
|
|
142
142
|
try {
|
|
143
143
|
const binding = require('@brust/native-win32-x64-msvc')
|
|
144
144
|
const bindingPackageVersion = require('@brust/native-win32-x64-msvc/package.json').version
|
|
145
|
-
if (bindingPackageVersion !== '2.0.0-alpha.
|
|
146
|
-
throw new Error(`Native binding package version mismatch, expected 2.0.0-alpha.
|
|
145
|
+
if (bindingPackageVersion !== '2.0.0-alpha.25' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
146
|
+
throw new Error(`Native binding package version mismatch, expected 2.0.0-alpha.25 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
147
147
|
}
|
|
148
148
|
return binding
|
|
149
149
|
} catch (e) {
|
|
@@ -159,8 +159,8 @@ function requireNative() {
|
|
|
159
159
|
try {
|
|
160
160
|
const binding = require('@brust/native-win32-ia32-msvc')
|
|
161
161
|
const bindingPackageVersion = require('@brust/native-win32-ia32-msvc/package.json').version
|
|
162
|
-
if (bindingPackageVersion !== '2.0.0-alpha.
|
|
163
|
-
throw new Error(`Native binding package version mismatch, expected 2.0.0-alpha.
|
|
162
|
+
if (bindingPackageVersion !== '2.0.0-alpha.25' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
163
|
+
throw new Error(`Native binding package version mismatch, expected 2.0.0-alpha.25 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
164
164
|
}
|
|
165
165
|
return binding
|
|
166
166
|
} catch (e) {
|
|
@@ -175,8 +175,8 @@ function requireNative() {
|
|
|
175
175
|
try {
|
|
176
176
|
const binding = require('@brust/native-win32-arm64-msvc')
|
|
177
177
|
const bindingPackageVersion = require('@brust/native-win32-arm64-msvc/package.json').version
|
|
178
|
-
if (bindingPackageVersion !== '2.0.0-alpha.
|
|
179
|
-
throw new Error(`Native binding package version mismatch, expected 2.0.0-alpha.
|
|
178
|
+
if (bindingPackageVersion !== '2.0.0-alpha.25' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
179
|
+
throw new Error(`Native binding package version mismatch, expected 2.0.0-alpha.25 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
180
180
|
}
|
|
181
181
|
return binding
|
|
182
182
|
} catch (e) {
|
|
@@ -194,8 +194,8 @@ function requireNative() {
|
|
|
194
194
|
try {
|
|
195
195
|
const binding = require('@brust/native-darwin-universal')
|
|
196
196
|
const bindingPackageVersion = require('@brust/native-darwin-universal/package.json').version
|
|
197
|
-
if (bindingPackageVersion !== '2.0.0-alpha.
|
|
198
|
-
throw new Error(`Native binding package version mismatch, expected 2.0.0-alpha.
|
|
197
|
+
if (bindingPackageVersion !== '2.0.0-alpha.25' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
198
|
+
throw new Error(`Native binding package version mismatch, expected 2.0.0-alpha.25 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
199
199
|
}
|
|
200
200
|
return binding
|
|
201
201
|
} catch (e) {
|
|
@@ -210,8 +210,8 @@ function requireNative() {
|
|
|
210
210
|
try {
|
|
211
211
|
const binding = require('@brust/native-darwin-x64')
|
|
212
212
|
const bindingPackageVersion = require('@brust/native-darwin-x64/package.json').version
|
|
213
|
-
if (bindingPackageVersion !== '2.0.0-alpha.
|
|
214
|
-
throw new Error(`Native binding package version mismatch, expected 2.0.0-alpha.
|
|
213
|
+
if (bindingPackageVersion !== '2.0.0-alpha.25' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
214
|
+
throw new Error(`Native binding package version mismatch, expected 2.0.0-alpha.25 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
215
215
|
}
|
|
216
216
|
return binding
|
|
217
217
|
} catch (e) {
|
|
@@ -226,8 +226,8 @@ function requireNative() {
|
|
|
226
226
|
try {
|
|
227
227
|
const binding = require('@brust/native-darwin-arm64')
|
|
228
228
|
const bindingPackageVersion = require('@brust/native-darwin-arm64/package.json').version
|
|
229
|
-
if (bindingPackageVersion !== '2.0.0-alpha.
|
|
230
|
-
throw new Error(`Native binding package version mismatch, expected 2.0.0-alpha.
|
|
229
|
+
if (bindingPackageVersion !== '2.0.0-alpha.25' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
230
|
+
throw new Error(`Native binding package version mismatch, expected 2.0.0-alpha.25 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
231
231
|
}
|
|
232
232
|
return binding
|
|
233
233
|
} catch (e) {
|
|
@@ -246,8 +246,8 @@ function requireNative() {
|
|
|
246
246
|
try {
|
|
247
247
|
const binding = require('@brust/native-freebsd-x64')
|
|
248
248
|
const bindingPackageVersion = require('@brust/native-freebsd-x64/package.json').version
|
|
249
|
-
if (bindingPackageVersion !== '2.0.0-alpha.
|
|
250
|
-
throw new Error(`Native binding package version mismatch, expected 2.0.0-alpha.
|
|
249
|
+
if (bindingPackageVersion !== '2.0.0-alpha.25' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
250
|
+
throw new Error(`Native binding package version mismatch, expected 2.0.0-alpha.25 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
251
251
|
}
|
|
252
252
|
return binding
|
|
253
253
|
} catch (e) {
|
|
@@ -262,8 +262,8 @@ function requireNative() {
|
|
|
262
262
|
try {
|
|
263
263
|
const binding = require('@brust/native-freebsd-arm64')
|
|
264
264
|
const bindingPackageVersion = require('@brust/native-freebsd-arm64/package.json').version
|
|
265
|
-
if (bindingPackageVersion !== '2.0.0-alpha.
|
|
266
|
-
throw new Error(`Native binding package version mismatch, expected 2.0.0-alpha.
|
|
265
|
+
if (bindingPackageVersion !== '2.0.0-alpha.25' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
266
|
+
throw new Error(`Native binding package version mismatch, expected 2.0.0-alpha.25 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
267
267
|
}
|
|
268
268
|
return binding
|
|
269
269
|
} catch (e) {
|
|
@@ -283,8 +283,8 @@ function requireNative() {
|
|
|
283
283
|
try {
|
|
284
284
|
const binding = require('@brust/native-linux-x64-musl')
|
|
285
285
|
const bindingPackageVersion = require('@brust/native-linux-x64-musl/package.json').version
|
|
286
|
-
if (bindingPackageVersion !== '2.0.0-alpha.
|
|
287
|
-
throw new Error(`Native binding package version mismatch, expected 2.0.0-alpha.
|
|
286
|
+
if (bindingPackageVersion !== '2.0.0-alpha.25' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
287
|
+
throw new Error(`Native binding package version mismatch, expected 2.0.0-alpha.25 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
288
288
|
}
|
|
289
289
|
return binding
|
|
290
290
|
} catch (e) {
|
|
@@ -299,8 +299,8 @@ function requireNative() {
|
|
|
299
299
|
try {
|
|
300
300
|
const binding = require('@brust/native-linux-x64-gnu')
|
|
301
301
|
const bindingPackageVersion = require('@brust/native-linux-x64-gnu/package.json').version
|
|
302
|
-
if (bindingPackageVersion !== '2.0.0-alpha.
|
|
303
|
-
throw new Error(`Native binding package version mismatch, expected 2.0.0-alpha.
|
|
302
|
+
if (bindingPackageVersion !== '2.0.0-alpha.25' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
303
|
+
throw new Error(`Native binding package version mismatch, expected 2.0.0-alpha.25 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
304
304
|
}
|
|
305
305
|
return binding
|
|
306
306
|
} catch (e) {
|
|
@@ -317,8 +317,8 @@ function requireNative() {
|
|
|
317
317
|
try {
|
|
318
318
|
const binding = require('@brust/native-linux-arm64-musl')
|
|
319
319
|
const bindingPackageVersion = require('@brust/native-linux-arm64-musl/package.json').version
|
|
320
|
-
if (bindingPackageVersion !== '2.0.0-alpha.
|
|
321
|
-
throw new Error(`Native binding package version mismatch, expected 2.0.0-alpha.
|
|
320
|
+
if (bindingPackageVersion !== '2.0.0-alpha.25' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
321
|
+
throw new Error(`Native binding package version mismatch, expected 2.0.0-alpha.25 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
322
322
|
}
|
|
323
323
|
return binding
|
|
324
324
|
} catch (e) {
|
|
@@ -333,8 +333,8 @@ function requireNative() {
|
|
|
333
333
|
try {
|
|
334
334
|
const binding = require('@brust/native-linux-arm64-gnu')
|
|
335
335
|
const bindingPackageVersion = require('@brust/native-linux-arm64-gnu/package.json').version
|
|
336
|
-
if (bindingPackageVersion !== '2.0.0-alpha.
|
|
337
|
-
throw new Error(`Native binding package version mismatch, expected 2.0.0-alpha.
|
|
336
|
+
if (bindingPackageVersion !== '2.0.0-alpha.25' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
337
|
+
throw new Error(`Native binding package version mismatch, expected 2.0.0-alpha.25 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
338
338
|
}
|
|
339
339
|
return binding
|
|
340
340
|
} catch (e) {
|
|
@@ -351,8 +351,8 @@ function requireNative() {
|
|
|
351
351
|
try {
|
|
352
352
|
const binding = require('@brust/native-linux-arm-musleabihf')
|
|
353
353
|
const bindingPackageVersion = require('@brust/native-linux-arm-musleabihf/package.json').version
|
|
354
|
-
if (bindingPackageVersion !== '2.0.0-alpha.
|
|
355
|
-
throw new Error(`Native binding package version mismatch, expected 2.0.0-alpha.
|
|
354
|
+
if (bindingPackageVersion !== '2.0.0-alpha.25' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
355
|
+
throw new Error(`Native binding package version mismatch, expected 2.0.0-alpha.25 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
356
356
|
}
|
|
357
357
|
return binding
|
|
358
358
|
} catch (e) {
|
|
@@ -367,8 +367,8 @@ function requireNative() {
|
|
|
367
367
|
try {
|
|
368
368
|
const binding = require('@brust/native-linux-arm-gnueabihf')
|
|
369
369
|
const bindingPackageVersion = require('@brust/native-linux-arm-gnueabihf/package.json').version
|
|
370
|
-
if (bindingPackageVersion !== '2.0.0-alpha.
|
|
371
|
-
throw new Error(`Native binding package version mismatch, expected 2.0.0-alpha.
|
|
370
|
+
if (bindingPackageVersion !== '2.0.0-alpha.25' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
371
|
+
throw new Error(`Native binding package version mismatch, expected 2.0.0-alpha.25 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
372
372
|
}
|
|
373
373
|
return binding
|
|
374
374
|
} catch (e) {
|
|
@@ -385,8 +385,8 @@ function requireNative() {
|
|
|
385
385
|
try {
|
|
386
386
|
const binding = require('@brust/native-linux-loong64-musl')
|
|
387
387
|
const bindingPackageVersion = require('@brust/native-linux-loong64-musl/package.json').version
|
|
388
|
-
if (bindingPackageVersion !== '2.0.0-alpha.
|
|
389
|
-
throw new Error(`Native binding package version mismatch, expected 2.0.0-alpha.
|
|
388
|
+
if (bindingPackageVersion !== '2.0.0-alpha.25' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
389
|
+
throw new Error(`Native binding package version mismatch, expected 2.0.0-alpha.25 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
390
390
|
}
|
|
391
391
|
return binding
|
|
392
392
|
} catch (e) {
|
|
@@ -401,8 +401,8 @@ function requireNative() {
|
|
|
401
401
|
try {
|
|
402
402
|
const binding = require('@brust/native-linux-loong64-gnu')
|
|
403
403
|
const bindingPackageVersion = require('@brust/native-linux-loong64-gnu/package.json').version
|
|
404
|
-
if (bindingPackageVersion !== '2.0.0-alpha.
|
|
405
|
-
throw new Error(`Native binding package version mismatch, expected 2.0.0-alpha.
|
|
404
|
+
if (bindingPackageVersion !== '2.0.0-alpha.25' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
405
|
+
throw new Error(`Native binding package version mismatch, expected 2.0.0-alpha.25 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
406
406
|
}
|
|
407
407
|
return binding
|
|
408
408
|
} catch (e) {
|
|
@@ -419,8 +419,8 @@ function requireNative() {
|
|
|
419
419
|
try {
|
|
420
420
|
const binding = require('@brust/native-linux-riscv64-musl')
|
|
421
421
|
const bindingPackageVersion = require('@brust/native-linux-riscv64-musl/package.json').version
|
|
422
|
-
if (bindingPackageVersion !== '2.0.0-alpha.
|
|
423
|
-
throw new Error(`Native binding package version mismatch, expected 2.0.0-alpha.
|
|
422
|
+
if (bindingPackageVersion !== '2.0.0-alpha.25' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
423
|
+
throw new Error(`Native binding package version mismatch, expected 2.0.0-alpha.25 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
424
424
|
}
|
|
425
425
|
return binding
|
|
426
426
|
} catch (e) {
|
|
@@ -435,8 +435,8 @@ function requireNative() {
|
|
|
435
435
|
try {
|
|
436
436
|
const binding = require('@brust/native-linux-riscv64-gnu')
|
|
437
437
|
const bindingPackageVersion = require('@brust/native-linux-riscv64-gnu/package.json').version
|
|
438
|
-
if (bindingPackageVersion !== '2.0.0-alpha.
|
|
439
|
-
throw new Error(`Native binding package version mismatch, expected 2.0.0-alpha.
|
|
438
|
+
if (bindingPackageVersion !== '2.0.0-alpha.25' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
439
|
+
throw new Error(`Native binding package version mismatch, expected 2.0.0-alpha.25 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
440
440
|
}
|
|
441
441
|
return binding
|
|
442
442
|
} catch (e) {
|
|
@@ -452,8 +452,8 @@ function requireNative() {
|
|
|
452
452
|
try {
|
|
453
453
|
const binding = require('@brust/native-linux-ppc64-gnu')
|
|
454
454
|
const bindingPackageVersion = require('@brust/native-linux-ppc64-gnu/package.json').version
|
|
455
|
-
if (bindingPackageVersion !== '2.0.0-alpha.
|
|
456
|
-
throw new Error(`Native binding package version mismatch, expected 2.0.0-alpha.
|
|
455
|
+
if (bindingPackageVersion !== '2.0.0-alpha.25' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
456
|
+
throw new Error(`Native binding package version mismatch, expected 2.0.0-alpha.25 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
457
457
|
}
|
|
458
458
|
return binding
|
|
459
459
|
} catch (e) {
|
|
@@ -468,8 +468,8 @@ function requireNative() {
|
|
|
468
468
|
try {
|
|
469
469
|
const binding = require('@brust/native-linux-s390x-gnu')
|
|
470
470
|
const bindingPackageVersion = require('@brust/native-linux-s390x-gnu/package.json').version
|
|
471
|
-
if (bindingPackageVersion !== '2.0.0-alpha.
|
|
472
|
-
throw new Error(`Native binding package version mismatch, expected 2.0.0-alpha.
|
|
471
|
+
if (bindingPackageVersion !== '2.0.0-alpha.25' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
472
|
+
throw new Error(`Native binding package version mismatch, expected 2.0.0-alpha.25 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
473
473
|
}
|
|
474
474
|
return binding
|
|
475
475
|
} catch (e) {
|
|
@@ -488,8 +488,8 @@ function requireNative() {
|
|
|
488
488
|
try {
|
|
489
489
|
const binding = require('@brust/native-openharmony-arm64')
|
|
490
490
|
const bindingPackageVersion = require('@brust/native-openharmony-arm64/package.json').version
|
|
491
|
-
if (bindingPackageVersion !== '2.0.0-alpha.
|
|
492
|
-
throw new Error(`Native binding package version mismatch, expected 2.0.0-alpha.
|
|
491
|
+
if (bindingPackageVersion !== '2.0.0-alpha.25' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
492
|
+
throw new Error(`Native binding package version mismatch, expected 2.0.0-alpha.25 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
493
493
|
}
|
|
494
494
|
return binding
|
|
495
495
|
} catch (e) {
|
|
@@ -504,8 +504,8 @@ function requireNative() {
|
|
|
504
504
|
try {
|
|
505
505
|
const binding = require('@brust/native-openharmony-x64')
|
|
506
506
|
const bindingPackageVersion = require('@brust/native-openharmony-x64/package.json').version
|
|
507
|
-
if (bindingPackageVersion !== '2.0.0-alpha.
|
|
508
|
-
throw new Error(`Native binding package version mismatch, expected 2.0.0-alpha.
|
|
507
|
+
if (bindingPackageVersion !== '2.0.0-alpha.25' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
508
|
+
throw new Error(`Native binding package version mismatch, expected 2.0.0-alpha.25 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
509
509
|
}
|
|
510
510
|
return binding
|
|
511
511
|
} catch (e) {
|
|
@@ -520,8 +520,8 @@ function requireNative() {
|
|
|
520
520
|
try {
|
|
521
521
|
const binding = require('@brust/native-openharmony-arm')
|
|
522
522
|
const bindingPackageVersion = require('@brust/native-openharmony-arm/package.json').version
|
|
523
|
-
if (bindingPackageVersion !== '2.0.0-alpha.
|
|
524
|
-
throw new Error(`Native binding package version mismatch, expected 2.0.0-alpha.
|
|
523
|
+
if (bindingPackageVersion !== '2.0.0-alpha.25' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
524
|
+
throw new Error(`Native binding package version mismatch, expected 2.0.0-alpha.25 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
525
525
|
}
|
|
526
526
|
return binding
|
|
527
527
|
} catch (e) {
|
|
@@ -661,8 +661,8 @@ if (!nativeBinding || forceWasi) {
|
|
|
661
661
|
if (!candidateFailed) {
|
|
662
662
|
if (process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
663
663
|
const bindingPackageVersion = require('@brust/native-wasm32-wasi/package.json').version
|
|
664
|
-
if (bindingPackageVersion !== '2.0.0-alpha.
|
|
665
|
-
throw new Error(`WASI binding package version mismatch, expected 2.0.0-alpha.
|
|
664
|
+
if (bindingPackageVersion !== '2.0.0-alpha.25') {
|
|
665
|
+
throw new Error(`WASI binding package version mismatch, expected 2.0.0-alpha.25 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
666
666
|
}
|
|
667
667
|
}
|
|
668
668
|
wasiBinding = require('@brust/native-wasm32-wasi')
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@brust/core",
|
|
3
|
-
"version": "2.0.0-alpha.
|
|
3
|
+
"version": "2.0.0-alpha.25",
|
|
4
4
|
"description": "brust v2 — React components compiled to Rust-rendered templates",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://brust.dev",
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
]
|
|
56
56
|
},
|
|
57
57
|
"dependencies": {
|
|
58
|
-
"@brust/runtime-dom": "2.0.0-alpha.
|
|
58
|
+
"@brust/runtime-dom": "2.0.0-alpha.25",
|
|
59
59
|
"tsconfig-paths": "4.2.0"
|
|
60
60
|
},
|
|
61
61
|
"peerDependencies": {
|
|
@@ -76,6 +76,8 @@
|
|
|
76
76
|
"@elysia/eden": "2.0.0-rc.0",
|
|
77
77
|
"@napi-rs/cli": "^3.0.0",
|
|
78
78
|
"@radix-ui/react-collection": "1.2.0",
|
|
79
|
+
"@radix-ui/react-id": "1.1.4",
|
|
80
|
+
"@radix-ui/react-use-layout-effect": "1.1.4",
|
|
79
81
|
"@radix-ui/react-presence": "1.1.11",
|
|
80
82
|
"@radix-ui/react-slot": "1.5.0",
|
|
81
83
|
"@types/bun": "^1.4.0",
|
|
@@ -97,12 +99,12 @@
|
|
|
97
99
|
"access": "public"
|
|
98
100
|
},
|
|
99
101
|
"optionalDependencies": {
|
|
100
|
-
"@brust/native-darwin-x64": "2.0.0-alpha.
|
|
101
|
-
"@brust/native-darwin-arm64": "2.0.0-alpha.
|
|
102
|
-
"@brust/native-linux-x64-gnu": "2.0.0-alpha.
|
|
103
|
-
"@brust/native-linux-arm64-gnu": "2.0.0-alpha.
|
|
104
|
-
"@brust/native-linux-x64-musl": "2.0.0-alpha.
|
|
105
|
-
"@brust/native-linux-arm64-musl": "2.0.0-alpha.
|
|
106
|
-
"@brust/core-cf": "2.0.0-alpha.
|
|
102
|
+
"@brust/native-darwin-x64": "2.0.0-alpha.25",
|
|
103
|
+
"@brust/native-darwin-arm64": "2.0.0-alpha.25",
|
|
104
|
+
"@brust/native-linux-x64-gnu": "2.0.0-alpha.25",
|
|
105
|
+
"@brust/native-linux-arm64-gnu": "2.0.0-alpha.25",
|
|
106
|
+
"@brust/native-linux-x64-musl": "2.0.0-alpha.25",
|
|
107
|
+
"@brust/native-linux-arm64-musl": "2.0.0-alpha.25",
|
|
108
|
+
"@brust/core-cf": "2.0.0-alpha.25"
|
|
107
109
|
}
|
|
108
110
|
}
|
package/src/build/compile.ts
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
// `compileTree` (analysis + lowering of its whole tree). `Err` = build error; fallback and
|
|
3
3
|
// warning diagnostics are logged; `outlet-outside-layout` is raised here (contract 5).
|
|
4
4
|
// A component several trees reach keeps one compile, chosen by role, not by route order (F75).
|
|
5
|
-
import { realpathSync } from 'node:fs'
|
|
6
|
-
import { relative, sep } from 'node:path'
|
|
5
|
+
import { readFileSync, realpathSync } from 'node:fs'
|
|
6
|
+
import { dirname, relative, sep } from 'node:path'
|
|
7
7
|
import { type CompiledComponent, type CompiledTree, compileTree, scanLoadWrites } from '../../native/index.js'
|
|
8
8
|
import type { FlatRoute, Route } from '../routes'
|
|
9
9
|
import { BuildError } from './errors'
|
|
@@ -253,5 +253,152 @@ export function compileApp(opts: {
|
|
|
253
253
|
`${route.Component!.name || rootId} renders <Outlet/> but route ${routeId} has no children`,
|
|
254
254
|
)
|
|
255
255
|
}
|
|
256
|
+
checkLayoutContexts(leaves, compiled, routeComponent)
|
|
256
257
|
return { compiled, routeComponent }
|
|
257
258
|
}
|
|
259
|
+
|
|
260
|
+
/** Script modules only (`.ts/.tsx/.js/.jsx/.mjs/.cjs/.mts/.cts`), judged on the RESOLVED file (a dotted basename like `./theme.context`
|
|
261
|
+
* resolves to theme.context.tsx; a stylesheet, JSON or asset resolves to itself): those never read a context. */
|
|
262
|
+
const SCRIPT = /\.[cm]?[jt]sx?$/
|
|
263
|
+
|
|
264
|
+
let importScanner: InstanceType<typeof Bun.Transpiler> | undefined
|
|
265
|
+
/** The module specifiers `file` imports or re-exports (`undefined`: unreadable or unparsable). */
|
|
266
|
+
function moduleSpecs(file: string): string[] | undefined {
|
|
267
|
+
try {
|
|
268
|
+
importScanner ??= new Bun.Transpiler({ loader: 'tsx' })
|
|
269
|
+
return importScanner.scanImports(readFileSync(file, 'utf8')).map((i) => i.path)
|
|
270
|
+
} catch {
|
|
271
|
+
return undefined
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
/**
|
|
276
|
+
* F437 (module-level rule): whether the island `file` imports ANY binding (a hook, the context, a helper) from a module that
|
|
277
|
+
* declares a context a layout above provides, directly or through re-exporting modules (followed transitively, each app file
|
|
278
|
+
* once). A relative specifier that cannot be resolved, or a barrel that cannot be read, is refused too.
|
|
279
|
+
*/
|
|
280
|
+
function importsProvidedModule(
|
|
281
|
+
file: string,
|
|
282
|
+
provided: { file: string; layout: string; contexts: string[] }[],
|
|
283
|
+
): { spec: string; via?: string; hit: { file: string; layout: string; contexts: string[] } } | undefined {
|
|
284
|
+
const real = (f: string) => {
|
|
285
|
+
try {
|
|
286
|
+
return realpathSync(f)
|
|
287
|
+
} catch {
|
|
288
|
+
return f
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
const resolve = (spec: string, from: string) => {
|
|
292
|
+
try {
|
|
293
|
+
return real(Bun.resolveSync(spec, dirname(from)))
|
|
294
|
+
} catch {
|
|
295
|
+
return undefined
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
const unfollowable = { file: '', layout: '(unresolved re-export)', contexts: ['?'] }
|
|
299
|
+
type Hit = { file: string; layout: string; contexts: string[] }
|
|
300
|
+
// The app modules `from` imports or re-exports, followed transitively (a barrel behind barrels) with a visited set.
|
|
301
|
+
const reach = (from: string, visited: Set<string>): { hit: Hit; via: string } | undefined => {
|
|
302
|
+
const specs = moduleSpecs(from)
|
|
303
|
+
if (specs === undefined) return { hit: unfollowable, via: from }
|
|
304
|
+
for (const spec of specs) {
|
|
305
|
+
const target = resolve(spec, from)
|
|
306
|
+
if (target === undefined) {
|
|
307
|
+
if (spec.startsWith('.')) return { hit: unfollowable, via: from }
|
|
308
|
+
continue
|
|
309
|
+
}
|
|
310
|
+
if (!SCRIPT.test(target)) continue
|
|
311
|
+
const hit = provided.find((p) => p.file === target)
|
|
312
|
+
if (hit) return { hit, via: from }
|
|
313
|
+
if (target.includes(`${sep}node_modules${sep}`) || visited.has(target)) continue
|
|
314
|
+
visited.add(target)
|
|
315
|
+
const deeper = reach(target, visited)
|
|
316
|
+
if (deeper) return deeper
|
|
317
|
+
}
|
|
318
|
+
return undefined
|
|
319
|
+
}
|
|
320
|
+
for (const spec of moduleSpecs(file) ?? []) {
|
|
321
|
+
const target = resolve(spec, file)
|
|
322
|
+
if (target === undefined) {
|
|
323
|
+
if (spec.startsWith('.')) return { spec, hit: unfollowable }
|
|
324
|
+
continue
|
|
325
|
+
}
|
|
326
|
+
if (!SCRIPT.test(target)) continue
|
|
327
|
+
const direct = provided.find((p) => p.file === target)
|
|
328
|
+
if (direct) return { spec, hit: direct }
|
|
329
|
+
if (target.includes(`${sep}node_modules${sep}`)) continue
|
|
330
|
+
const found = reach(target, new Set([file, target]))
|
|
331
|
+
if (found) return { spec, via: relative(dirname(file), target), hit: found.hit }
|
|
332
|
+
}
|
|
333
|
+
return undefined
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
/**
|
|
337
|
+
* F437: a component the compiler refused to lower because it reads a context imported from another module
|
|
338
|
+
* (`useContext(Ctx)`, `ir.foreign_ctx_reads`) ships as a React island, and an island's SSR and `hydrateRoot` render it
|
|
339
|
+
* alone, without the Providers a layout above its route renders: it would paint the `createContext` default where React
|
|
340
|
+
* paints the layout's value. Refused here, by name, conservatively: a Provider anywhere in the layout's compiled tree
|
|
341
|
+
* (`ir.provides` of the layout or of any component it renders) declared in a file counts as providing every context that
|
|
342
|
+
* file declares, so a read of ANY binding imported from that file is refused (an alias, `export { A as B }`, a re-export of
|
|
343
|
+
* the file's own context cannot slip by). A context nobody provides still reads its default, which is React's own answer.
|
|
344
|
+
* Native resolution of an imported context is F439.
|
|
345
|
+
*/
|
|
346
|
+
function checkLayoutContexts(leaves: FlatRoute[], compiled: Map<string, Compiled>, routeComponent: Map<string, string>): void {
|
|
347
|
+
const real = (f: string) => {
|
|
348
|
+
try {
|
|
349
|
+
return realpathSync(f)
|
|
350
|
+
} catch {
|
|
351
|
+
return f
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
for (const leaf of leaves) {
|
|
355
|
+
const provided: { file: string; layout: string; contexts: string[] }[] = []
|
|
356
|
+
for (const id of leaf.chainIds) {
|
|
357
|
+
const rootId = routeComponent.get(id)
|
|
358
|
+
const root = rootId === undefined ? undefined : compiled.get(rootId)
|
|
359
|
+
if (!root) continue
|
|
360
|
+
// The tree of this route's component: the layouts above it provided `provided` so far.
|
|
361
|
+
if (provided.length > 0) {
|
|
362
|
+
const stack = [root.id]
|
|
363
|
+
const done = new Set<string>()
|
|
364
|
+
while (stack.length > 0) {
|
|
365
|
+
const c = compiled.get(stack.pop()!)
|
|
366
|
+
if (!c || done.has(c.id)) continue
|
|
367
|
+
done.add(c.id)
|
|
368
|
+
for (const [src, name] of (c.ir.foreign_ctx_reads ?? []) as [string, string][]) {
|
|
369
|
+
let from: string
|
|
370
|
+
try {
|
|
371
|
+
from = real(Bun.resolveSync(src, dirname(c.file)))
|
|
372
|
+
} catch {
|
|
373
|
+
continue
|
|
374
|
+
}
|
|
375
|
+
const hit = provided.find((p) => p.file === from)
|
|
376
|
+
if (hit)
|
|
377
|
+
throw new BuildError(
|
|
378
|
+
'island-layout-context',
|
|
379
|
+
`${c.ir.source} reads the context \`${name}\` (useContext) that the layout ${hit.layout} provides, but this component renders as a React island, and an island does not see its layout's Provider (it would paint the createContext default). Workaround: pass the value to the page through its loader (a prop), or render the Provider inside this component's own tree. Native resolution of an imported context is F439.`,
|
|
380
|
+
)
|
|
381
|
+
}
|
|
382
|
+
const viaModule = c.ir.tier && typeof c.ir.tier === 'object' && 'React' in c.ir.tier ? importsProvidedModule(c.file, provided) : undefined
|
|
383
|
+
if (viaModule)
|
|
384
|
+
throw new BuildError(
|
|
385
|
+
'island-layout-context',
|
|
386
|
+
`${c.ir.source} renders as a React island and imports ${viaModule.spec}${viaModule.via ? ` (through ${viaModule.via})` : ''}, a module that declares the context \`${viaModule.hit.contexts.join('`, `')}\` which the layout ${viaModule.hit.layout} provides: an island does not see its layout's Provider (it would paint the createContext default), and a hook or helper of that module may read it. Workaround: pass the value to the page through its loader (a prop), or render the Provider inside this component's own tree. Native resolution of an imported context is F439.`,
|
|
387
|
+
)
|
|
388
|
+
for (const ch of (c.ir.children ?? []) as { id: string | null }[]) if (ch.id) stack.push(ch.id)
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
// Every Provider the layout's compiled tree renders (the layout itself or a component it calls), by declaring file.
|
|
392
|
+
const stack = [root.id]
|
|
393
|
+
const done = new Set<string>()
|
|
394
|
+
while (stack.length > 0) {
|
|
395
|
+
const c = compiled.get(stack.pop()!)
|
|
396
|
+
if (!c || done.has(c.id)) continue
|
|
397
|
+
done.add(c.id)
|
|
398
|
+
if ((c.ir.provides ?? []).length > 0)
|
|
399
|
+
provided.push({ file: real(c.file), layout: root.ir.source, contexts: (c.ir.provides as { context: string }[]).map((p) => p.context.replace(/_m[0-9a-f]{8}$/, '')) })
|
|
400
|
+
for (const ch of (c.ir.children ?? []) as { id: string | null }[]) if (ch.id) stack.push(ch.id)
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
}
|
package/src/build/features.ts
CHANGED
|
@@ -22,6 +22,9 @@ export function featureOfAttr(attr: string): RuntimeFeature | null | undefined {
|
|
|
22
22
|
case 'x-show':
|
|
23
23
|
case 'x-ref':
|
|
24
24
|
return 'basics'
|
|
25
|
+
// F288 phase B: a branch's callback ref, attached and detached by the x-if binder's module
|
|
26
|
+
case 'x-cref':
|
|
27
|
+
return 'if'
|
|
25
28
|
case 'x-if':
|
|
26
29
|
case 'x-for':
|
|
27
30
|
case 'x-model':
|
package/src/build/server-only.ts
CHANGED
|
@@ -37,3 +37,26 @@ export function installServerOnlyRuntime(): void {
|
|
|
37
37
|
},
|
|
38
38
|
})
|
|
39
39
|
}
|
|
40
|
+
|
|
41
|
+
let jsxDevInstalled = false
|
|
42
|
+
/** F425: Bun picks the dev JSX transform (`jsxDEV` from `react/jsx-dev-runtime`) for modules the process imports directly
|
|
43
|
+
* when NODE_ENV is unset as Bun boots (a plain shell `brust start`), but React's production `react/jsx-dev-runtime` has no
|
|
44
|
+
* `jsxDEV`, and run.ts sets NODE_ENV=production for the workers afterwards. A module that builds a JSX element at import
|
|
45
|
+
* time (`export const el = <b/>`) then died with "jsxDEV_… is not a function". In production, `react/jsx-dev-runtime` is the
|
|
46
|
+
* production `jsx`/`jsxs` (resolved from the app, so it is the app's one React) with a `jsxDEV` over them; dev keeps React's own. */
|
|
47
|
+
export function installProductionJsxDev(appDir: string): void {
|
|
48
|
+
if (jsxDevInstalled || process.env.NODE_ENV !== 'production') return
|
|
49
|
+
jsxDevInstalled = true
|
|
50
|
+
Bun.plugin({
|
|
51
|
+
name: 'brust-jsx-dev-production',
|
|
52
|
+
setup(b) {
|
|
53
|
+
b.module('react/jsx-dev-runtime', async () => {
|
|
54
|
+
const rt = await import(Bun.resolveSync('react/jsx-runtime', appDir))
|
|
55
|
+
return {
|
|
56
|
+
exports: { Fragment: rt.Fragment, jsx: rt.jsx, jsxs: rt.jsxs, jsxDEV: (type: unknown, props: unknown, key: unknown, isStatic: boolean) => (isStatic ? rt.jsxs : rt.jsx)(type, props, key) },
|
|
57
|
+
loader: 'object',
|
|
58
|
+
}
|
|
59
|
+
})
|
|
60
|
+
},
|
|
61
|
+
})
|
|
62
|
+
}
|
package/src/worker.ts
CHANGED
|
@@ -10,7 +10,7 @@ import { type CacheBridgeDeps, runCache } from './cache-adapter/bridge'
|
|
|
10
10
|
import type { CacheManifest } from './cache-adapter/load'
|
|
11
11
|
import { type Handlers, type JobsModule, type ManifestLike, makeHandlers, type SsgRecord, toJson } from './handlers'
|
|
12
12
|
import { cacheClear, cacheL2Count, cacheReplay, planJobs, planJobsBuf, putFetchReply, registerWorker, takeFetchBody } from './native'
|
|
13
|
-
import { installServerOnlyRuntime } from './build/server-only'
|
|
13
|
+
import { installProductionJsxDev, installServerOnlyRuntime } from './build/server-only'
|
|
14
14
|
import { flattenRoutes, type Route } from './routes'
|
|
15
15
|
|
|
16
16
|
export * from './handlers'
|
|
@@ -190,6 +190,7 @@ export async function startWorker(opts: StartWorkerOptions = {}): Promise<number
|
|
|
190
190
|
let routes: Route[] | undefined = []
|
|
191
191
|
if (!manifest.actions_only) {
|
|
192
192
|
installServerOnlyRuntime()
|
|
193
|
+
installProductionJsxDev(dirname(resolve(entry)))
|
|
193
194
|
const app = await import(resolve(entry))
|
|
194
195
|
routes = (app.routes ?? app.default) as Route[] | undefined
|
|
195
196
|
}
|