@brust/core 2.0.0-alpha.28 → 2.0.0-alpha.29
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 +9 -9
- package/src/actions/client.ts +26 -4
- package/src/actions/load.ts +22 -0
- package/src/build/index.ts +7 -3
- package/src/build/static.ts +4 -3
- package/src/handlers.ts +12 -5
- package/src/worker.ts +6 -2
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.29' && 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.29 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.29' && 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.29 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.29' && 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.29 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.29' && 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.29 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.29' && 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.29 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.29' && 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.29 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.29' && 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.29 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.29' && 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.29 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.29' && 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.29 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.29' && 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.29 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.29' && 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.29 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.29' && 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.29 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.29' && 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.29 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.29' && 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.29 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.29' && 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.29 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.29' && 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.29 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.29' && 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.29 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.29' && 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.29 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.29' && 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.29 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.29' && 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.29 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.29' && 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.29 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.29' && 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.29 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.29' && 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.29 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.29' && 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.29 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.29' && 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.29 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.29' && 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.29 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.29') {
|
|
665
|
+
throw new Error(`WASI binding package version mismatch, expected 2.0.0-alpha.29 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.29",
|
|
4
4
|
"description": "brust v2 — React components compiled to Rust-rendered templates",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://brust.dev",
|
|
@@ -56,7 +56,7 @@
|
|
|
56
56
|
]
|
|
57
57
|
},
|
|
58
58
|
"dependencies": {
|
|
59
|
-
"@brust/runtime-dom": "2.0.0-alpha.
|
|
59
|
+
"@brust/runtime-dom": "2.0.0-alpha.29",
|
|
60
60
|
"tsconfig-paths": "4.2.0"
|
|
61
61
|
},
|
|
62
62
|
"peerDependencies": {
|
|
@@ -100,12 +100,12 @@
|
|
|
100
100
|
"access": "public"
|
|
101
101
|
},
|
|
102
102
|
"optionalDependencies": {
|
|
103
|
-
"@brust/native-darwin-x64": "2.0.0-alpha.
|
|
104
|
-
"@brust/native-darwin-arm64": "2.0.0-alpha.
|
|
105
|
-
"@brust/native-linux-x64-gnu": "2.0.0-alpha.
|
|
106
|
-
"@brust/native-linux-arm64-gnu": "2.0.0-alpha.
|
|
107
|
-
"@brust/native-linux-x64-musl": "2.0.0-alpha.
|
|
108
|
-
"@brust/native-linux-arm64-musl": "2.0.0-alpha.
|
|
109
|
-
"@brust/core-cf": "2.0.0-alpha.
|
|
103
|
+
"@brust/native-darwin-x64": "2.0.0-alpha.29",
|
|
104
|
+
"@brust/native-darwin-arm64": "2.0.0-alpha.29",
|
|
105
|
+
"@brust/native-linux-x64-gnu": "2.0.0-alpha.29",
|
|
106
|
+
"@brust/native-linux-arm64-gnu": "2.0.0-alpha.29",
|
|
107
|
+
"@brust/native-linux-x64-musl": "2.0.0-alpha.29",
|
|
108
|
+
"@brust/native-linux-arm64-musl": "2.0.0-alpha.29",
|
|
109
|
+
"@brust/core-cf": "2.0.0-alpha.29"
|
|
110
110
|
}
|
|
111
111
|
}
|
package/src/actions/client.ts
CHANGED
|
@@ -8,6 +8,15 @@ import { type ActionCredentials, DEFAULT_ACTION_PREFIX } from './prefix'
|
|
|
8
8
|
export { DEFAULT_ACTION_PREFIX }
|
|
9
9
|
export type { Treaty }
|
|
10
10
|
|
|
11
|
+
/** One link of the request chain (F471). `next` sends `req` (or a request you build from it) to the next link, or to
|
|
12
|
+
* the transport after the last one. Call it zero times (answer yourself), once, or many times (renew a token, then
|
|
13
|
+
* send the same request again). Every `next(r)` sends its own copy of `r`: `r` itself is never consumed, so a
|
|
14
|
+
* retry sends the same body again. Read a body through `req.clone()`. */
|
|
15
|
+
export type ActionMiddleware = (
|
|
16
|
+
req: Request,
|
|
17
|
+
next: (req: Request) => Promise<Response>,
|
|
18
|
+
) => Promise<Response> | Response
|
|
19
|
+
|
|
11
20
|
export interface ClientOptions<Head extends Record<string, unknown> = {}>
|
|
12
21
|
extends Omit<Treaty.Config<Head>, 'keepDomain' | 'fetcher' | 'fetch'> {
|
|
13
22
|
/** Mount point of the actions app. Default: see resolvePrefix. */
|
|
@@ -18,6 +27,9 @@ export interface ClientOptions<Head extends Record<string, unknown> = {}>
|
|
|
18
27
|
fetch?: typeof fetch
|
|
19
28
|
/** RequestInit defaults for every call (Eden's `fetch` option), e.g. `{ credentials: 'include' }`. */
|
|
20
29
|
init?: Treaty.Config<Head>['fetch']
|
|
30
|
+
/** F471: links between Eden and the transport; `middleware[0]` is the outermost. They see the request Eden built
|
|
31
|
+
* (URL, body, `headers`, `onRequest`) and return the Response Eden parses. A throw is a network failure (503). */
|
|
32
|
+
middleware?: ActionMiddleware[]
|
|
21
33
|
}
|
|
22
34
|
|
|
23
35
|
interface PageGlobals {
|
|
@@ -55,7 +67,7 @@ export function resolveBaseUrl(opts?: { baseUrl?: string }): string {
|
|
|
55
67
|
export function client<const App extends AnyElysia, Head extends Record<string, unknown> = {}>(
|
|
56
68
|
opts: ClientOptions<Head> = {},
|
|
57
69
|
): Treaty.Instance<App, Head> {
|
|
58
|
-
const { prefix: _p, baseUrl: _b, fetch: fetcher, init, ...rest } = opts
|
|
70
|
+
const { prefix: _p, baseUrl: _b, fetch: fetcher, init, middleware, ...rest } = opts
|
|
59
71
|
// R16.2: the page's credentials default (`opts.init` wins); only when it differs from the browser default.
|
|
60
72
|
const creds = page().__BRUST_ACTION_CREDENTIALS__
|
|
61
73
|
const defaults = creds !== undefined && creds !== 'same-origin' && typeof init !== 'function' ? { credentials: creds } : undefined
|
|
@@ -64,11 +76,21 @@ export function client<const App extends AnyElysia, Head extends Record<string,
|
|
|
64
76
|
const base = resolveBaseUrl(opts)
|
|
65
77
|
const prefix = resolvePrefix(opts)
|
|
66
78
|
// SPA navigation design §10.1: a mutation clears the page cache, so no page read after it is served from before it
|
|
67
|
-
const
|
|
79
|
+
const transport = async (url: RequestInfo | URL, req?: RequestInit) => {
|
|
68
80
|
const res = await (fetcher ?? fetch)(url, req)
|
|
69
|
-
if (!/^(GET|HEAD)$/i.test(req?.method ?? 'GET')) clearNavigationCache()
|
|
81
|
+
if (!/^(GET|HEAD)$/i.test(req?.method ?? (url instanceof Request ? url.method : 'GET'))) clearNavigationCache()
|
|
70
82
|
return res
|
|
71
|
-
}
|
|
83
|
+
}
|
|
84
|
+
// F471: Eden calls `send(url, init)`; the chain works on a Request. `next` clones what it is given, so the caller's
|
|
85
|
+
// request stays unread and can be sent again.
|
|
86
|
+
const chain = middleware?.length ? middleware : undefined
|
|
87
|
+
const send = (chain
|
|
88
|
+
? async (url: RequestInfo | URL, init?: RequestInit) => {
|
|
89
|
+
const run = (i: number, req: Request): Promise<Response> =>
|
|
90
|
+
i < chain.length ? Promise.resolve(chain[i]!(req, (r) => run(i + 1, r.clone()))) : transport(req)
|
|
91
|
+
return run(0, new Request(url, init))
|
|
92
|
+
}
|
|
93
|
+
: transport) as typeof fetch
|
|
72
94
|
return treaty<App, Head>(base !== '' && prefix === '/' ? base : base + prefix, {
|
|
73
95
|
...rest,
|
|
74
96
|
keepDomain: true,
|
package/src/actions/load.ts
CHANGED
|
@@ -21,3 +21,25 @@ export function mountActions(app: unknown, prefix: string, what = 'actions entry
|
|
|
21
21
|
export async function loadActionsApp(file: string, prefix: string): Promise<AnyElysia> {
|
|
22
22
|
return mountActions((await import(file)).default, prefix, file)
|
|
23
23
|
}
|
|
24
|
+
|
|
25
|
+
/** One path segment of each side matches the other: equal, or either is a parameter (`:x`, `{x}`, `*`). */
|
|
26
|
+
const segMatch = (a: string, b: string) => a === b || /^(:|\{|\*)/.test(a) || /^(:|\{|\*)/.test(b)
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* F470: the GET actions a page or loader route under the prefix shadows (a GET there is the route's), as
|
|
30
|
+
* `GET <action path> (route <pattern>)`. Best effort, for a boot warning: segments compared, a parameter matches any.
|
|
31
|
+
*/
|
|
32
|
+
export function shadowedGetActions(app: AnyElysia, patterns: string[], prefix: string): string[] {
|
|
33
|
+
const under = patterns.filter((p) => p.startsWith(`${prefix}/`))
|
|
34
|
+
const out: string[] = []
|
|
35
|
+
for (const r of app.routes) {
|
|
36
|
+
if (r.method !== 'GET') continue
|
|
37
|
+
const a = r.path.split('/')
|
|
38
|
+
const hit = under.find((p) => {
|
|
39
|
+
const b = p.split('/')
|
|
40
|
+
return a.length === b.length && a.every((s, i) => segMatch(s, b[i]!))
|
|
41
|
+
})
|
|
42
|
+
if (hit) out.push(`GET ${r.path} (route ${hit})`)
|
|
43
|
+
}
|
|
44
|
+
return out
|
|
45
|
+
}
|
package/src/build/index.ts
CHANGED
|
@@ -137,12 +137,16 @@ export async function runBuild(opts: {
|
|
|
137
137
|
if (isAbsolute(actions.entry) || rel === '..' || rel.startsWith('../') || isAbsolute(rel) || !statOk(actionsEntry)) {
|
|
138
138
|
throw new BuildError('actions-entry', `actions.entry ${actions.entry} is not a file inside the app`)
|
|
139
139
|
}
|
|
140
|
-
//
|
|
140
|
+
// F470: a route under the prefix answers GET and HEAD of its own paths, the actions app everything else there. The
|
|
141
|
+
// prefix itself stays the actions app's mount point, and a {*rest} route would take every GET under it.
|
|
141
142
|
for (const l of leaves) {
|
|
142
|
-
if (l.pattern
|
|
143
|
+
if (l.pattern === actions.prefix) {
|
|
144
|
+
throw new BuildError('actions-prefix', `route ${l.id} (${l.pattern}) is the actions prefix ${actions.prefix}: that path is the actions app's mount point`)
|
|
145
|
+
}
|
|
146
|
+
if (l.pattern.startsWith(`${actions.prefix}/`) && l.pattern.includes('{*')) {
|
|
143
147
|
throw new BuildError(
|
|
144
148
|
'actions-prefix',
|
|
145
|
-
`route ${l.id} (${l.pattern})
|
|
149
|
+
`route ${l.id} (${l.pattern}) is a catch-all under the actions prefix ${actions.prefix}: it would take every GET there from the actions app`,
|
|
146
150
|
)
|
|
147
151
|
}
|
|
148
152
|
}
|
package/src/build/static.ts
CHANGED
|
@@ -80,8 +80,9 @@ type SsgRecord =
|
|
|
80
80
|
| { kind: 'read'; routeId: string; path: string; field: string; key: string }
|
|
81
81
|
| { kind: 'headers'; routeId: string; path: string; names: string[] }
|
|
82
82
|
|
|
83
|
-
|
|
84
|
-
|
|
83
|
+
// F468: like every page the build renders, the default 404 carries `<meta name="generator" content="brust/<version>">`.
|
|
84
|
+
const default404 = (version: string) =>
|
|
85
|
+
`<!doctype html>\n<html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1"><title>404 Not Found</title><meta name="generator" content="brust/${version.replace(/[&"<>]/g, (c) => `&#${c.charCodeAt(0)};`)}"></head><body><h1>404 Not Found</h1></body></html>\n`
|
|
85
86
|
|
|
86
87
|
/** A `_redirects` source as Cloudflare Pages matches it (review N4): the decoded path, with only what
|
|
87
88
|
* the file format or the decoding needs escaped (whitespace and control characters, and `%`, so a
|
|
@@ -222,7 +223,7 @@ export async function writeStatic(
|
|
|
222
223
|
throw new BuildError('ssg-render', `${where}: status ${r.status}, want 200 (or a redirect()): ${excerpt(text(r))}`)
|
|
223
224
|
})
|
|
224
225
|
if (o.plan.defaultNotFound) {
|
|
225
|
-
write('404.html', Buffer.from(
|
|
226
|
+
write('404.html', Buffer.from(default404(o.version)))
|
|
226
227
|
warn("[brust] warning ssg-404 no '*' route: wrote a default 404.html (without one, Cloudflare Pages serves every unknown path as the home page)")
|
|
227
228
|
}
|
|
228
229
|
writeFileSync(join(dir, '_redirects'), report.redirects.map((r) => `${redirectSource(r.from)} ${r.to} ${r.status}\n`).join(''))
|
package/src/handlers.ts
CHANGED
|
@@ -27,7 +27,7 @@ export type LoaderResponse =
|
|
|
27
27
|
| { ok: true; data: Record<string, unknown>; headers?: HeaderPairs; store?: StoreSnapshot | null }
|
|
28
28
|
| { verdict: 'notFound'; data: unknown; headers?: HeaderPairs; store?: StoreSnapshot | null }
|
|
29
29
|
| { verdict: 'redirect'; location: string; status: number; headers?: HeaderPairs }
|
|
30
|
-
| { verdict: 'httpError'; status: number; body: string; headers?: HeaderPairs }
|
|
30
|
+
| { verdict: 'httpError'; status: number; body: string; contentType: string; headers?: HeaderPairs }
|
|
31
31
|
| { error: string }
|
|
32
32
|
|
|
33
33
|
export type JobKind = 'precompute' | 'ssr'
|
|
@@ -140,6 +140,9 @@ function withStore<T extends LoaderResponse>(r: T): T {
|
|
|
140
140
|
/** Names the server owns: the framing, the page's type, and a redirect's target (`redirect()`). */
|
|
141
141
|
const REFUSED_HEADERS = new Set(['content-type', 'content-length', 'transfer-encoding', 'connection', 'location'])
|
|
142
142
|
|
|
143
|
+
const refusedMessage = (name: string) =>
|
|
144
|
+
`a loader cannot set "${name}" (the server sets it${name.trim().toLowerCase() === 'location' ? '; use redirect()' : ''})`
|
|
145
|
+
|
|
143
146
|
/** `res.headers`: a `Headers` that refuses the server's names, by a throw in dev (the loader fails with a 500 that
|
|
144
147
|
* names it) and by a warning in production (the call does nothing). */
|
|
145
148
|
class LoaderHeaders extends Headers {
|
|
@@ -148,7 +151,7 @@ class LoaderHeaders extends Headers {
|
|
|
148
151
|
}
|
|
149
152
|
private allowed(name: string): boolean {
|
|
150
153
|
if (!REFUSED_HEADERS.has(name.trim().toLowerCase())) return true
|
|
151
|
-
const msg = `res.headers:
|
|
154
|
+
const msg = `res.headers: ${refusedMessage(name)}`
|
|
152
155
|
if (this.dev) throw new Error(msg)
|
|
153
156
|
console.warn(`[brust] warning ${msg}; dropped`)
|
|
154
157
|
return false
|
|
@@ -304,9 +307,13 @@ export function makeHandlers(opts: {
|
|
|
304
307
|
r = await node.loader({ params: req.params, path: req.path, req: lreq, res })
|
|
305
308
|
} catch (e) {
|
|
306
309
|
if (isHttpErrorTrigger(e)) {
|
|
307
|
-
// httpError's own `headers` option adds to what the chain set
|
|
308
|
-
|
|
309
|
-
|
|
310
|
+
// httpError's own `headers` option adds to what the chain set. A refused name is dropped with a warning
|
|
311
|
+
// in dev too: a throw here would hide the error the loader meant to send (F466).
|
|
312
|
+
for (const [k, v] of Object.entries(e.headers ?? {})) {
|
|
313
|
+
if (REFUSED_HEADERS.has(k.trim().toLowerCase())) console.warn(`[brust] warning httpError headers: ${refusedMessage(k)}; dropped`)
|
|
314
|
+
else res.headers.append(k, v)
|
|
315
|
+
}
|
|
316
|
+
return out({ verdict: 'httpError', status: e.status, body: e.body, contentType: e.contentType } as LoaderResponse)
|
|
310
317
|
}
|
|
311
318
|
throw e
|
|
312
319
|
}
|
package/src/worker.ts
CHANGED
|
@@ -199,8 +199,12 @@ export async function startWorker(opts: StartWorkerOptions = {}): Promise<number
|
|
|
199
199
|
const jobs = (jobsMod.default ?? jobsMod) as JobsModule
|
|
200
200
|
if (manifest.actions) {
|
|
201
201
|
// Lazy: elysia is an optional peer, so an app without [actions] must boot without it installed (R7).
|
|
202
|
-
const { loadActionsApp } = await import('./actions/load')
|
|
203
|
-
|
|
202
|
+
const { loadActionsApp, shadowedGetActions } = await import('./actions/load')
|
|
203
|
+
const actionsApp = await loadActionsApp(join(dist, manifest.actions.entry), manifest.actions.prefix)
|
|
204
|
+
setActionsApp(actionsApp)
|
|
205
|
+
// F470: a GET under the prefix that a route there matches is the route's; say which GET actions that hides (once)
|
|
206
|
+
const shadowed = env.BRUST_WORKER_ID && env.BRUST_WORKER_ID !== '0' ? [] : shadowedGetActions(actionsApp, flattenRoutes(routes).leaves.map((l) => l.pattern), manifest.actions.prefix)
|
|
207
|
+
if (shadowed.length) console.warn(`[brust] warning: a route under the actions prefix answers GET there, so these GET actions are never reached: ${shadowed.join(', ')}`)
|
|
204
208
|
setActionsLimits({ maxResponseBytes: manifest.actions.maxResponseBytes ?? DEFAULT_MAX_RESPONSE_BYTES })
|
|
205
209
|
}
|
|
206
210
|
loaderCap = Number.parseInt(env.BRUST_MAX_LOADER_RESPONSE_BYTES ?? '', 10) || DEFAULT_MAX_LOADER_RESPONSE_BYTES
|