@brust/core 2.0.0-alpha.32 → 2.0.0-alpha.34

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 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.32' && 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.32 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
92
+ if (bindingPackageVersion !== '2.0.0-alpha.34' && 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.34 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.32' && 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.32 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
108
+ if (bindingPackageVersion !== '2.0.0-alpha.34' && 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.34 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.32' && 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.32 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
129
+ if (bindingPackageVersion !== '2.0.0-alpha.34' && 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.34 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.32' && 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.32 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
145
+ if (bindingPackageVersion !== '2.0.0-alpha.34' && 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.34 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.32' && 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.32 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
162
+ if (bindingPackageVersion !== '2.0.0-alpha.34' && 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.34 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.32' && 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.32 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
178
+ if (bindingPackageVersion !== '2.0.0-alpha.34' && 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.34 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.32' && 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.32 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
197
+ if (bindingPackageVersion !== '2.0.0-alpha.34' && 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.34 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.32' && 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.32 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
213
+ if (bindingPackageVersion !== '2.0.0-alpha.34' && 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.34 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.32' && 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.32 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
229
+ if (bindingPackageVersion !== '2.0.0-alpha.34' && 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.34 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.32' && 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.32 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
249
+ if (bindingPackageVersion !== '2.0.0-alpha.34' && 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.34 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.32' && 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.32 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
265
+ if (bindingPackageVersion !== '2.0.0-alpha.34' && 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.34 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.32' && 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.32 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
286
+ if (bindingPackageVersion !== '2.0.0-alpha.34' && 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.34 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.32' && 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.32 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
302
+ if (bindingPackageVersion !== '2.0.0-alpha.34' && 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.34 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.32' && 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.32 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
320
+ if (bindingPackageVersion !== '2.0.0-alpha.34' && 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.34 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.32' && 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.32 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
336
+ if (bindingPackageVersion !== '2.0.0-alpha.34' && 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.34 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.32' && 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.32 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
354
+ if (bindingPackageVersion !== '2.0.0-alpha.34' && 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.34 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.32' && 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.32 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
370
+ if (bindingPackageVersion !== '2.0.0-alpha.34' && 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.34 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.32' && 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.32 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
388
+ if (bindingPackageVersion !== '2.0.0-alpha.34' && 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.34 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.32' && 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.32 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
404
+ if (bindingPackageVersion !== '2.0.0-alpha.34' && 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.34 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.32' && 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.32 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
422
+ if (bindingPackageVersion !== '2.0.0-alpha.34' && 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.34 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.32' && 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.32 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
438
+ if (bindingPackageVersion !== '2.0.0-alpha.34' && 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.34 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.32' && 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.32 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
455
+ if (bindingPackageVersion !== '2.0.0-alpha.34' && 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.34 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.32' && 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.32 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
471
+ if (bindingPackageVersion !== '2.0.0-alpha.34' && 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.34 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.32' && 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.32 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
491
+ if (bindingPackageVersion !== '2.0.0-alpha.34' && 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.34 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.32' && 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.32 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
507
+ if (bindingPackageVersion !== '2.0.0-alpha.34' && 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.34 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.32' && 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.32 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
523
+ if (bindingPackageVersion !== '2.0.0-alpha.34' && 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.34 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.32') {
665
- throw new Error(`WASI binding package version mismatch, expected 2.0.0-alpha.32 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
664
+ if (bindingPackageVersion !== '2.0.0-alpha.34') {
665
+ throw new Error(`WASI binding package version mismatch, expected 2.0.0-alpha.34 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.32",
3
+ "version": "2.0.0-alpha.34",
4
4
  "description": "brust v2 — React components compiled to Rust-rendered templates",
5
5
  "license": "MIT",
6
6
  "homepage": "https://brust.dev",
@@ -52,11 +52,12 @@
52
52
  "x86_64-unknown-linux-gnu",
53
53
  "aarch64-unknown-linux-gnu",
54
54
  "x86_64-unknown-linux-musl",
55
- "aarch64-unknown-linux-musl"
55
+ "aarch64-unknown-linux-musl",
56
+ "x86_64-pc-windows-msvc"
56
57
  ]
57
58
  },
58
59
  "dependencies": {
59
- "@brust/runtime-dom": "2.0.0-alpha.32",
60
+ "@brust/runtime-dom": "2.0.0-alpha.34",
60
61
  "tsconfig-paths": "4.2.0"
61
62
  },
62
63
  "peerDependencies": {
@@ -100,12 +101,13 @@
100
101
  "access": "public"
101
102
  },
102
103
  "optionalDependencies": {
103
- "@brust/native-darwin-x64": "2.0.0-alpha.32",
104
- "@brust/native-darwin-arm64": "2.0.0-alpha.32",
105
- "@brust/native-linux-x64-gnu": "2.0.0-alpha.32",
106
- "@brust/native-linux-arm64-gnu": "2.0.0-alpha.32",
107
- "@brust/native-linux-x64-musl": "2.0.0-alpha.32",
108
- "@brust/native-linux-arm64-musl": "2.0.0-alpha.32",
109
- "@brust/core-cf": "2.0.0-alpha.32"
104
+ "@brust/native-darwin-x64": "2.0.0-alpha.34",
105
+ "@brust/native-darwin-arm64": "2.0.0-alpha.34",
106
+ "@brust/native-linux-x64-gnu": "2.0.0-alpha.34",
107
+ "@brust/native-linux-arm64-gnu": "2.0.0-alpha.34",
108
+ "@brust/native-linux-x64-musl": "2.0.0-alpha.34",
109
+ "@brust/native-linux-arm64-musl": "2.0.0-alpha.34",
110
+ "@brust/native-win32-x64-msvc": "2.0.0-alpha.34",
111
+ "@brust/core-cf": "2.0.0-alpha.34"
110
112
  }
111
113
  }
@@ -2,12 +2,14 @@
2
2
  // the same Rust admission (method gate, body caps, `Content-Encoding`, the cross-site guard, CORS), every other
3
3
  // path a 404 problem+json. With `--target cloudflare` it also writes `<out>/cf/`: a Worker serving only actions
4
4
  // (no Static Assets). The routes entry is neither read nor required.
5
- import { existsSync, mkdirSync, renameSync, rmSync, writeFileSync } from 'node:fs'
5
+ import { mkdirSync, rmSync, writeFileSync } from 'node:fs'
6
6
  import { basename, dirname, isAbsolute, join, relative, resolve } from 'node:path'
7
7
  import { buildActions } from './bundle'
8
8
  import { type CfPrepared, buildCloudflare, prepareCloudflare } from './cloudflare'
9
9
  import type { ActionsBuildConfig, BuildConfig } from './config'
10
10
  import { BuildError } from './errors'
11
+ import { escapes } from './posix'
12
+ import { swapDist } from './swap'
11
13
  import { MANIFEST_VERSION, type ManifestJson } from './manifest'
12
14
 
13
15
  const MARKER = '.brust'
@@ -28,7 +30,7 @@ export async function runActionsOnly(o: {
28
30
  if (o.target === 'static') throw new BuildError('actions-only', '--actions-only builds no pages: it cannot be combined with --target static')
29
31
  const entry = resolve(appRoot, actions.entry)
30
32
  const rel = relative(appRoot, entry)
31
- if (isAbsolute(actions.entry) || rel === '..' || rel.startsWith('../') || isAbsolute(rel) || !o.statOk(entry))
33
+ if (isAbsolute(actions.entry) || escapes(rel) || !o.statOk(entry))
32
34
  throw new BuildError('actions-entry', `actions.entry ${actions.entry} is not a file inside the app`)
33
35
  o.assertSafeOutDir(dist, appRoot, [entry])
34
36
  if (config.cache) o.log('[brust] actions-only: [cache] and route options do not apply (ignored)')
@@ -72,13 +74,7 @@ export async function runActionsOnly(o: {
72
74
  for (const w of warnings) o.log(w)
73
75
  }
74
76
  rmSync(join(tmp, '.stage'), { recursive: true, force: true })
75
- if (existsSync(dist)) {
76
- const old = join(dirname(dist), `.${basename(dist)}.brust-old`)
77
- rmSync(old, { recursive: true, force: true })
78
- renameSync(dist, old)
79
- renameSync(tmp, dist)
80
- rmSync(old, { recursive: true, force: true })
81
- } else renameSync(tmp, dist)
77
+ swapDist(tmp, dist)
82
78
  } catch (e) {
83
79
  rmSync(tmp, { recursive: true, force: true })
84
80
  throw e
@@ -10,6 +10,7 @@ import { createHash } from 'node:crypto'
10
10
  import { existsSync, mkdirSync, realpathSync, statSync, writeFileSync } from 'node:fs'
11
11
  import { builtinModules } from 'node:module'
12
12
  import { basename, dirname, isAbsolute, join, relative, resolve, sep } from 'node:path'
13
+ import { escapes, inServerOnlyPrefix, posixOf, relPosix } from './posix'
13
14
  import type { BunPlugin } from 'bun'
14
15
  import type { Compiled } from './compile'
15
16
  import { cssPlugin } from './css'
@@ -51,6 +52,9 @@ export interface BrowserCtx {
51
52
  cssMaps?: Map<string, Record<string, string>>
52
53
  /** F411: `<dist>/client`, where an imported asset is written (see `cssPlugin`). */
53
54
  clientDir?: string
55
+ /** F480: load-time writers shipped into an island chunk (F230), by real path: why each is there. A server-only import
56
+ * reached through one names that chain in `server-only-in-client`. */
57
+ loadWriters?: Map<string, string>
54
58
  }
55
59
 
56
60
  /** `file` sits under `root`. */
@@ -169,8 +173,7 @@ function isServerOnly(spec: string, importer: string, ctx: BrowserCtx): boolean
169
173
  try {
170
174
  if (ctx.serverFiles?.includes(realpathSync(file))) return true
171
175
  } catch {}
172
- const rel = relative(ctx.appRoot, file)
173
- return !rel.startsWith('..') && !isAbsolute(rel) && ctx.serverOnly.some((p) => rel.startsWith(p))
176
+ return inServerOnlyPrefix(relative(ctx.appRoot, file), ctx.serverOnly)
174
177
  }
175
178
 
176
179
  /** Fails a browser build that would include server-only code at any depth (a client chunk, an
@@ -178,14 +181,43 @@ function isServerOnly(spec: string, importer: string, ctx: BrowserCtx): boolean
178
181
  * offending import is stubbed so the bundler gets as far as it can; `browserBuild` then throws
179
182
  * `server-only-in-client` naming every `<importer> imports <spec>`. */
180
183
  function serverOnlyPlugin(ctx: BrowserCtx, violations: string[]): BunPlugin {
184
+ const writers = ctx.loadWriters ?? new Map<string, string>()
185
+ // F480: who first imported each file (real paths), kept only while a load writer ships, to name the writer chain.
186
+ const importerOf = new Map<string, string>()
187
+ const real = (f: string) => {
188
+ try {
189
+ return realpathSync(f)
190
+ } catch {
191
+ return f
192
+ }
193
+ }
194
+ const noteImport = (spec: string, importer: string) => {
195
+ const from = real(ctx.sourceOf.get(importer) ?? importer)
196
+ try {
197
+ const file = real(isAbsolute(spec) ? spec : Bun.resolveSync(spec, dirname(from)))
198
+ if (!importerOf.has(file)) importerOf.set(file, from)
199
+ } catch {}
200
+ }
201
+ const writerChain = (importer: string): string => {
202
+ const seen = new Set<string>()
203
+ for (let f: string | undefined = real(ctx.sourceOf.get(importer) ?? importer); f !== undefined && !seen.has(f); f = importerOf.get(f)) {
204
+ seen.add(f)
205
+ const why = writers.get(f)
206
+ if (why !== undefined) return ` (${why})`
207
+ }
208
+ return ''
209
+ }
181
210
  return {
182
211
  name: 'brust-server-only',
183
212
  setup(b) {
184
213
  b.onResolve({ filter: /.*/ }, (a) => {
185
214
  if (!a.importer || a.path.startsWith('/_brust/')) return undefined
186
215
  if (a.path === '@brust/core') return { path: BROWSER_ENTRY }
187
- if (!isServerOnly(a.path, a.importer, ctx)) return undefined
188
- const msg = `${relative(ctx.appRoot, ctx.sourceOf.get(a.importer) ?? a.importer)} imports ${a.path}`
216
+ if (!isServerOnly(a.path, a.importer, ctx)) {
217
+ if (writers.size > 0) noteImport(a.path, a.importer)
218
+ return undefined
219
+ }
220
+ const msg = `${relPosix(ctx.appRoot, ctx.sourceOf.get(a.importer) ?? a.importer)} imports ${a.path}${writerChain(a.importer)}`
189
221
  if (!violations.includes(msg)) violations.push(msg)
190
222
  return { path: a.path, namespace: SERVER_ONLY_NS }
191
223
  })
@@ -746,7 +778,7 @@ export async function buildJobs(
746
778
  imports.push(`import * as S${i} from ${JSON.stringify(p)}`) // a package module, external in jobs.js
747
779
  continue
748
780
  }
749
- if (isAbsolute(p) || p.split('/').includes('..') || !isFile(resolve(appRoot, p))) {
781
+ if (isAbsolute(p) || posixOf(p).split('/').includes('..') || escapes(relative(appRoot, resolve(appRoot, p))) || !isFile(resolve(appRoot, p))) {
750
782
  throw new BuildError('store-module', `store module ${p} is not a file inside the app (${appRoot})`)
751
783
  }
752
784
  imports.push(`import * as S${i} from ${JSON.stringify(resolve(appRoot, p))}`)
@@ -1,8 +1,9 @@
1
1
  // `wrangler.jsonc` for `dist/cf/` (M4-CF R5, R6, R7): the user's app-root config merged with the keys brust owns.
2
2
  // Pure apart from `readUserWrangler`. Never adds an `account_id`; copies one only if the user wrote it.
3
3
  import { existsSync } from 'node:fs'
4
- import { isAbsolute, join, relative } from 'node:path'
4
+ import { isAbsolute, join } from 'node:path'
5
5
  import { BuildError } from './errors'
6
+ import { relPosix } from './posix'
6
7
 
7
8
  type Json = Record<string, unknown>
8
9
  export interface UserWrangler {
@@ -49,7 +50,7 @@ export function workerNameOf(pkgName: string): string {
49
50
  }
50
51
 
51
52
  function rebase(o: MergeOpts, p: string): string {
52
- return isAbsolute(p) ? p : relative(o.cfDir, join(o.appRoot, p))
53
+ return isAbsolute(p) ? p : relPosix(o.cfDir, join(o.appRoot, p))
53
54
  }
54
55
 
55
56
  function assertNoAssetsBinding(v: unknown, path: string): void {
@@ -5,6 +5,7 @@
5
5
  import { cpSync, existsSync, mkdirSync, readFileSync, realpathSync, writeFileSync } from 'node:fs'
6
6
  import { builtinModules } from 'node:module'
7
7
  import { dirname, join, relative } from 'node:path'
8
+ import { relPosix } from './posix'
8
9
  import type { BunPlugin } from 'bun'
9
10
  import { BrustConfigError, type CorsConfig, loadCors } from '../config'
10
11
  import { layoutAssets } from './cf-assets'
@@ -102,7 +103,7 @@ function cfGuard(appRoot: string, violations: string[]): BunPlugin {
102
103
  name: 'brust-cf-guard',
103
104
  setup(b) {
104
105
  b.onResolve({ filter: /^bun(:.*)?$/ }, (a) => {
105
- violations.push(`${relative(appRoot, a.importer) || a.importer} imports ${a.path}`)
106
+ violations.push(`${relPosix(appRoot, a.importer) || a.importer} imports ${a.path}`)
106
107
  return { path: a.path, external: true }
107
108
  })
108
109
  b.onResolve({ filter: /^[a-z_]+(\/[a-z_/]+)?$/ }, (a) => (BUILTINS.has(a.path) ? { path: `node:${a.path}`, external: true } : undefined))
@@ -117,7 +118,7 @@ function cfAlias(alias: Record<string, string>, sourceOf: SourceOf): BunPlugin {
117
118
  setup(b) {
118
119
  if (Object.keys(alias).length === 0) return
119
120
  b.onResolve({ filter: /.*/ }, (a) => {
120
- if (a.importer === '' || a.importer.includes('/node_modules/')) return undefined
121
+ if (a.importer === '' || /[\\/]node_modules[\\/]/.test(a.importer)) return undefined
121
122
  let abs: string
122
123
  try {
123
124
  abs = Bun.resolveSync(a.path, dirname(sourceOf.get(a.importer) ?? a.importer))
@@ -4,6 +4,7 @@
4
4
  // A component several trees reach keeps one compile, chosen by role, not by route order (F75).
5
5
  import { readFileSync, realpathSync } from 'node:fs'
6
6
  import { dirname, relative, sep } from 'node:path'
7
+ import { nativeOf, relPosix } from './posix'
7
8
  import { type CompiledComponent, type CompiledTree, compileTree, scanLoadWrites } from '../../native/index.js'
8
9
  import type { FlatRoute, Route } from '../routes'
9
10
  import { BuildError } from './errors'
@@ -196,7 +197,7 @@ export function compileApp(opts: {
196
197
  )
197
198
  let rootId = rootIdOfFile.get(file)
198
199
  if (!rootId) {
199
- const rel = relative(appRoot, file)
200
+ const rel = relPosix(appRoot, file) // G5: the Rust resolver assumes `/`
200
201
  const tree = compileTree(rel, appRoot, opts.runtimeImport, opts.serverOnly, slotValuesJson, cssModules, iconSvgsJson, routeRoots, pathAliasesJson, packagesJson, sourceRoots, opts.loadWrites)
201
202
  if (tree.error) throw new BuildError(tree.error.rule, `${where(rel, tree.error)} ${tree.error.message}`)
202
203
  for (const [i, c] of tree.components.entries()) {
@@ -226,7 +227,7 @@ export function compileApp(opts: {
226
227
  ir.stores ??= []
227
228
  compiled.set(c.id, {
228
229
  id: c.id,
229
- file: `${appRoot}/${c.source}`,
230
+ file: nativeOf(`${appRoot}/${c.source}`), // the spelling Bun.resolveSync returns: these are Map keys and `===` operands
230
231
  ir,
231
232
  jinja: c.jinja,
232
233
  serverTs: c.serverTs,
@@ -23,6 +23,7 @@ import {
23
23
  } from '../actions/prefix'
24
24
  import { ADAPTER_NAMES, BUILTINS, installHint } from '../cache-adapter/load'
25
25
  import { BuildError } from './errors'
26
+ import { posixOf } from './posix'
26
27
 
27
28
  // [actions] (opt-in, ruling R6): present table => actions on. Both byte caps cross napi as u32 (F82: 1..64 MiB / 256 KiB..64 MiB).
28
29
  // [actions]
@@ -419,5 +420,5 @@ export async function loadBuildConfig(appRoot: string, o: { actionsOnly?: boolea
419
420
  if (so === undefined) return { serverOnly: [], actions, cloudflare, cache, cssGlobal, sourceRoots }
420
421
  if (!Array.isArray(so) || so.some((p) => typeof p !== 'string' || p.trim() === ''))
421
422
  throw new BuildError('config', `${file}: build.server_only must be an array of non-empty strings`)
422
- return { serverOnly: so.map((p: string) => p.trim().replace(/^\.\//, '')), actions, cloudflare, cache, cssGlobal, sourceRoots }
423
+ return { serverOnly: so.map((p: string) => posixOf(p.trim()).replace(/^\.\//, '')), actions, cloudflare, cache, cssGlobal, sourceRoots }
423
424
  }
package/src/build/css.ts CHANGED
@@ -122,8 +122,22 @@ const ASSET_FILE = /\.(?:woff2?|ttf|otf|eot|png|jpe?g|gif|webp|avif|svg|ico)$/i
122
122
 
123
123
  const SOURCE_URL = /url\(\s*(["']?)([^"')]+?)\1\s*\)/g
124
124
 
125
+ /** A `url()` value as the file system spells it: CSS escapes undone (Bun prints a Windows path as `C:\\Users\\…`). */
126
+ /** CSS Syntax 4.3.7: an escaped code point that is zero, a surrogate or above U+10FFFF is U+FFFD (never a RangeError). */
127
+ const cssCodePoint = (n: number): number => (n === 0 || n > 0x10ffff || (n >= 0xd800 && n <= 0xdfff) ? 0xfffd : n)
128
+
129
+ export function cssUnescape(s: string): string {
130
+ return s.replace(/\\(?:([0-9a-fA-F]{1,6})\s?|([^\n0-9a-fA-F]))/g, (_m, h: string | undefined, c: string | undefined) =>
131
+ h !== undefined ? String.fromCodePoint(cssCodePoint(Number.parseInt(h, 16))) : c!,
132
+ )
133
+ }
134
+
135
+ /** F490: an absolute local path in either spelling: POSIX `/…`, a Windows drive `C:\…` / `C:/…`, or a UNC `\\host\…`. */
136
+ export const localAbsolute = (p: string): boolean => p.startsWith('/') || /^[A-Za-z]:[\\/]/.test(p) || p.startsWith('\\\\')
137
+
125
138
  /** F393: a `url()` that is the absolute path of a file on disk (see the `loader` in `buildCss`) becomes a
126
- * hashed `./<name>-<hex10>.<ext>` client asset at any size. `/public/…` and `/_brust/…` stay as written. */
139
+ * hashed `./<name>-<hex10>.<ext>` client asset at any size. `/public/…` and `/_brust/…` stay as written.
140
+ * F490: on Windows that path is `C:\\…` (CSS-escaped), so the value is unescaped and both spellings are taken. */
127
141
  function emitSourceAssets(text: string, assets: { name: string; bytes: Uint8Array }[], suffixed: Map<string, string>): string {
128
142
  const emit = (path: string, suffix: string) => {
129
143
  const { name, bytes } = hashedAsset(path)
@@ -133,12 +147,29 @@ function emitSourceAssets(text: string, assets: { name: string; bytes: Uint8Arra
133
147
  return text.replace(SOURCE_URL, (whole, _q: string, path: string) => {
134
148
  const abs = suffixed.get(path)
135
149
  if (abs !== undefined) return emit(abs, path.slice(path.search(/[?#]/)))
136
- const ext = extname(path).toLowerCase()
137
- if (!path.startsWith('/') || !SERVED_ASSET_EXT.includes(ext) || path.startsWith('/public/') || path.startsWith('/_brust/') || !existsSync(path)) return whole
138
- return emit(path, '')
150
+ const file = cssUnescape(path)
151
+ const ext = extname(file).toLowerCase()
152
+ if (!localAbsolute(file) || !SERVED_ASSET_EXT.includes(ext) || file.startsWith('/public/') || file.startsWith('/_brust/') || !existsSync(file)) return whole
153
+ return emit(file, '')
139
154
  })
140
155
  }
141
156
 
157
+ /** F490 fail closed: a `url()` left in the built CSS that still names a file on this machine would ship the machine's
158
+ * path and 404 in the browser, so the build fails instead. A leak is a Windows drive or UNC path, or a `/…` path under
159
+ * the app root or the dist dir (`roots`). Any other root URL passes, even one that happens to exist on the build
160
+ * machine (`url(/tmp/x)`, `url(/fonts/x.woff2)`): only the app's own files are known to be local. */
161
+ export function leakedLocalPaths(text: string, roots: string[]): string[] {
162
+ const out: string[] = []
163
+ for (const m of text.matchAll(SOURCE_URL)) {
164
+ const v = cssUnescape(m[2]!)
165
+ if (v.startsWith('/public/') || v.startsWith('/_brust/') || !localAbsolute(v)) continue
166
+ const posix = v.replaceAll('\\', '/')
167
+ const local = !v.startsWith('/') || roots.some((r) => posix === r || posix.startsWith(`${r}/`))
168
+ if (local && !out.includes(v)) out.push(v)
169
+ }
170
+ return out
171
+ }
172
+
142
173
  /** F393: a `url()` asset with a `?query` / `#fragment` (`?v=3`, `?#iefix`, an SVG font's `#id`) is not given
143
174
  * Bun's path form: a plugin-resolved specifier is printed as written. This plugin resolves such a specifier
144
175
  * itself and records the file it names, so `emitSourceAssets` can copy it and keep the suffix verbatim. The
@@ -259,6 +290,10 @@ export async function buildCss(
259
290
  )
260
291
  }
261
292
  for (const [i, t] of css) css.set(i, emitSourceAssets(t, assets, suffixed))
293
+ const roots = [appRoot, dist].flatMap((r) => [r, real(r)]).map((r) => r.replaceAll('\\', '/').replace(/\/+$/, '')).filter((r) => r !== '')
294
+ const leaks = [...css].flatMap(([i, t]) => leakedLocalPaths(t, roots).map((p) => `url(${p}) in ${sources[i]}`))
295
+ if (leaks.length > 0)
296
+ throw new BuildError('css-asset-path', `${leaks.join('; ')}: the built CSS would name a file on this machine; reference it relative to the stylesheet or as /public/…`)
262
297
  for (const a of assets) writeFileSync(join(dist, 'client', a.name), a.bytes)
263
298
  for (const [i, src] of sources.entries()) {
264
299
  let text = css.get(i)
@@ -10,6 +10,7 @@ import { createHash } from 'node:crypto'
10
10
  import { existsSync, mkdirSync, readFileSync, renameSync, statSync, writeFileSync } from 'node:fs'
11
11
  import { dirname, join, sep } from 'node:path'
12
12
  import { BuildError } from './errors'
13
+ import { nativeOf } from './posix'
13
14
 
14
15
  /** A specifier relative to its importer: `./x`, `../x` and the bare `.` / `..` (a directory). The one test every resolver path uses (F218, F244). */
15
16
  export const RELATIVE_SPEC = /^\.\.?(\/|$)/
@@ -46,11 +47,14 @@ export function clearResolveCache(): void {
46
47
  const PROBE = `
47
48
  const [target, entry, spec, define, conditions] = process.argv.slice(1)
48
49
  const source = 'import ' + JSON.stringify(spec) + '\\n'
50
+ // F490: on Windows the virtual entry comes back to onLoad as C:/…/__brust_resolve__.ts while argv spells it C:\\…, so
51
+ // the two compare in one spelling; else the entry itself was taken for the answer.
52
+ const entryPosix = entry.replaceAll('\\\\', '/')
49
53
  let found
50
54
  await Bun.build({
51
55
  entrypoints: [entry], target, write: false, define: JSON.parse(define), conditions: JSON.parse(conditions), files: { [entry]: source },
52
56
  plugins: [{ name: 'o', setup(b) { b.onLoad({ filter: /./ }, (a) => {
53
- if (a.path === entry) return { contents: source, loader: 'ts' }
57
+ if (a.path.replaceAll('\\\\', '/') === entryPosix) return { contents: source, loader: 'ts' }
54
58
  found ??= a.path
55
59
  return { contents: '', loader: 'js' }
56
60
  }) } }],
@@ -77,7 +81,8 @@ export function resolveNative(spec: string, from: string, target: ResolveTarget,
77
81
  const timeout = opts.timeoutMs ?? RESOLVE_TIMEOUT_MS
78
82
  const r = Bun.spawnSync([process.execPath, '-e', PROBE, target, join(from, '__brust_resolve__.ts'), spec, defs, conds], { cwd: opts.appRoot ?? from, stdout: 'pipe', stderr: 'pipe', timeout, killSignal: 'SIGKILL' })
79
83
  const out = r.exitCode === 0 ? r.stdout.toString() : ''
80
- let path = out
84
+ // F490: one spelling out of the resolver, the platform's (a file system path; POSIX: unchanged).
85
+ let path = nativeOf(out)
81
86
  if (path === '') {
82
87
  // The probe did not answer: today's answer (`Bun.resolveSync`) stands, and the build output says why.
83
88
  const why = r.exitCode === null || r.signalCode ? `the probe did not answer within ${timeout} ms` : r.exitCode !== 0 ? `the probe failed (${r.stderr.toString().trim().split('\n')[0] || `exit ${r.exitCode}`})` : 'the probe resolved nothing'
@@ -5,7 +5,7 @@
5
5
  // a previous brust dist (no `manifest.json` / `.brust` marker; `--force` overrides), is refused
6
6
  // before anything is written or removed.
7
7
  import { createHash } from 'node:crypto'
8
- import { cpSync, existsSync, mkdirSync, readdirSync, readFileSync, realpathSync, renameSync, rmSync, statSync, writeFileSync } from 'node:fs'
8
+ import { cpSync, existsSync, mkdirSync, readdirSync, readFileSync, realpathSync, rmSync, statSync, writeFileSync } from 'node:fs'
9
9
  import { homedir } from 'node:os'
10
10
  import { basename, dirname, isAbsolute, join, parse, relative, resolve } from 'node:path'
11
11
  import { BrustRouteError, type FlatRoute, validateRoutes } from '../routes'
@@ -19,6 +19,8 @@ import { type Compiled, compileApp, scanAppWrites } from './compile'
19
19
  import { buildCss, CssGraph, directCss, resolveGlobals, routeCssSources } from './css'
20
20
  import { type ActionsBuildConfig, type CacheBuildConfig, loadBuildConfig } from './config'
21
21
  import { BuildError } from './errors'
22
+ import { escapes, relPosix } from './posix'
23
+ import { swapDist } from './swap'
22
24
  import { importsStore } from './features'
23
25
  import { type CacheRecord, type ManifestJson, needsWorkers, reachedJobs, tierOf, writeManifest } from './manifest'
24
26
  import { scanRoutes } from './scan'
@@ -83,6 +85,14 @@ function statOk(p: string): boolean {
83
85
  }
84
86
  }
85
87
 
88
+ function realRoot(p: string): string {
89
+ try {
90
+ return realpathSync(p)
91
+ } catch {
92
+ return p
93
+ }
94
+ }
95
+
86
96
  export async function runBuild(opts: {
87
97
  appRoot: string
88
98
  entry: string
@@ -105,7 +115,9 @@ export async function runBuild(opts: {
105
115
  log: (s: string) => void
106
116
  }): Promise<void> {
107
117
  setDevBuild(opts.dev === true)
108
- const appRoot = resolve(opts.appRoot)
118
+ // The app root is the real path: Windows keeps a symlinked cwd as the link, and `relative(link, file)` across drives is
119
+ // an absolute path that every `join(appRoot, rel)` then glues onto the link (N2). POSIX cwd is already real.
120
+ const appRoot = realRoot(resolve(opts.appRoot))
109
121
  const entry = resolve(appRoot, opts.entry)
110
122
  const dist = resolve(appRoot, opts.outDir)
111
123
  assertSafeOutDir(dist, appRoot, [entry, join(appRoot, 'public')])
@@ -134,7 +146,7 @@ export async function runBuild(opts: {
134
146
  if (actions) {
135
147
  actionsEntry = resolve(appRoot, actions.entry)
136
148
  const rel = relative(appRoot, actionsEntry)
137
- if (isAbsolute(actions.entry) || rel === '..' || rel.startsWith('../') || isAbsolute(rel) || !statOk(actionsEntry)) {
149
+ if (isAbsolute(actions.entry) || escapes(rel) || !statOk(actionsEntry)) {
138
150
  throw new BuildError('actions-entry', `actions.entry ${actions.entry} is not a file inside the app`)
139
151
  }
140
152
  // F470: a route under the prefix answers GET and HEAD of its own paths, the actions app everything else there. The
@@ -155,7 +167,7 @@ export async function runBuild(opts: {
155
167
  if (cache?.module !== undefined) {
156
168
  cacheModule = resolve(appRoot, cache.module)
157
169
  const rel = relative(appRoot, cacheModule)
158
- if (isAbsolute(cache.module) || rel === '..' || rel.startsWith('../') || isAbsolute(rel) || !statOk(cacheModule)) {
170
+ if (isAbsolute(cache.module) || escapes(rel) || !statOk(cacheModule)) {
159
171
  throw new BuildError('cache', `cache.module ${cache.module} is not a file inside the app`)
160
172
  }
161
173
  }
@@ -186,13 +198,7 @@ export async function runBuild(opts: {
186
198
  if (hybrid && cf && actions) writeStaticWorker(tmp, actions, cf, opts.log)
187
199
  }
188
200
  rmSync(join(tmp, '.stage'), { recursive: true, force: true })
189
- if (existsSync(dist)) {
190
- const old = join(dirname(dist), `.${basename(dist)}.brust-old`)
191
- rmSync(old, { recursive: true, force: true })
192
- renameSync(dist, old)
193
- renameSync(tmp, dist)
194
- rmSync(old, { recursive: true, force: true })
195
- } else renameSync(tmp, dist)
201
+ swapDist(tmp, dist)
196
202
  } catch (e) {
197
203
  rmSync(tmp, { recursive: true, force: true })
198
204
  throw e
@@ -276,8 +282,14 @@ async function buildInto(
276
282
  stack.push(...(appGraph.get(f) ?? []))
277
283
  }
278
284
  const out = writes.filter((w) => [...w.mods].some((m) => reached.has(m)))
279
- for (const w of out)
280
- o.log(`[brust] warning load-writer-in-client ${relative(appRoot, w.file)} is imported into the browser chunk of the React island ${c.id}: it changes ${[...w.mods].filter((m) => reached.has(m)).map((m) => relative(appRoot, m)).join(', ')} when it loads, and the island reads that module (F230). Its code ships to the browser: keep secrets and server-only code out of it, or write the value in the module that declares it`)
285
+ for (const w of out) {
286
+ const mods = [...w.mods].filter((m) => reached.has(m)).map((m) => relPosix(appRoot, m)).join(', ')
287
+ o.log(`[brust] warning load-writer-in-client ${relPosix(appRoot, w.file)} is imported into the browser chunk of the React island ${c.id}: it changes ${mods} when it loads, and the island reads that module (F230). Its code ships to the browser: keep secrets and server-only code out of it, or write the value in the module that declares it`)
288
+ // F480: a server-only import reached through this writer names the chain in `server-only-in-client`.
289
+ ctx.loadWriters ??= new Map()
290
+ if (!ctx.loadWriters.has(w.file))
291
+ ctx.loadWriters.set(w.file, `${relPosix(appRoot, w.file)} is loaded into the React island ${c.id} because it is judged to write ${mods} when it loads: F230 load writes`)
292
+ }
281
293
  return [...new Set(out.map((w) => w.file))]
282
294
  }
283
295
  const compileOpts = {
@@ -370,7 +382,7 @@ async function buildInto(
370
382
  )
371
383
  for (const w of warnings) o.log(w)
372
384
  }
373
- const entryRel = relative(o.dist, entry)
385
+ const entryRel = relPosix(o.dist, entry) // `/`-spelled: a dist built on Windows runs on Linux (join() below re-spells it)
374
386
  writeFileSync(
375
387
  join(out, 'index.js'),
376
388
  [
@@ -393,7 +405,7 @@ export function devJson(appRoot: string, compiled: Map<string, Compiled>): { ver
393
405
  const tier = tierOf(c.ir)
394
406
  const t = c.ir.tier
395
407
  components[c.id] = {
396
- file: relative(appRoot, c.file),
408
+ file: relPosix(appRoot, c.file),
397
409
  tier,
398
410
  ...(tier === 'react' && t && typeof t === 'object' && 'React' in t ? { reason: String((t as { React: { reason: string } }).React.reason) } : {}),
399
411
  diagnostics: (c.diagnostics ?? []).map((d) => ({ class: d.class, rule: d.rule, line: d.line, col: d.col, message: d.message, remediation: d.remediation })),
@@ -0,0 +1,35 @@
1
+ // F485 (G5): the one choke point for path spelling. A path that leaves the filesystem layer (handed to the native
2
+ // compiler, used as a Map/manifest key, matched against config prefixes, written into dist/*.js, dev.json or a wrangler
3
+ // config) is `/`-separated; a path used only for fs calls stays native. Every helper takes the separator as a parameter
4
+ // (default: the platform's), so a unit test can feed `C:\app\pages\X.tsx` on any OS and POSIX output stays byte-identical.
5
+ import { isAbsolute, relative, sep } from 'node:path'
6
+
7
+ /** `p` with the platform separator spelled `/`. A no-op on POSIX (a `\` there is a legal file name character). */
8
+ export function posixOf(p: string, s: string = sep): string {
9
+ return s === '/' ? p : p.split(s).join('/')
10
+ }
11
+
12
+ /** The reverse of {@link posixOf}: a `/`-separated path (the compiler's spelling) as the platform spells it. */
13
+ export function nativeOf(p: string, s: string = sep): string {
14
+ return s === '/' ? p : p.split('/').join(s)
15
+ }
16
+
17
+ /** `relative(base, file)` spelled with `/`. */
18
+ export function relPosix(base: string, file: string, s: string = sep): string {
19
+ return posixOf(relative(base, file), s)
20
+ }
21
+
22
+ /** A `relative()` result that does not lie inside its base: `..`, `../x`, or an absolute path (another drive on Windows). */
23
+ export function escapes(rel: string, s: string = sep): boolean {
24
+ const p = posixOf(rel, s)
25
+ return p === '..' || p.startsWith('../') || isAbsolute(rel) || (s !== '/' && /^[A-Za-z]:/.test(p)) // `c:x` is a legal POSIX dir name
26
+ }
27
+
28
+ /** `[build] server_only` (spec §8.2): is the app-root-relative `rel` inside a listed prefix? Prefixes are `/`-spelled
29
+ * (config.ts normalises them); `rel` is spelled with `s` and normalised here, so a Windows `lib\server\db.ts` matches
30
+ * `lib/server`. A path outside the app root never matches. */
31
+ export function inServerOnlyPrefix(rel: string, prefixes: string[], s: string = sep): boolean {
32
+ if (escapes(rel, s)) return false
33
+ const p = posixOf(rel, s)
34
+ return prefixes.some((pre) => p.startsWith(pre))
35
+ }
@@ -0,0 +1,47 @@
1
+ // F485 P8: replacing `dist` by the finished temp dir. On Windows a rename of a directory fails (EPERM / EBUSY /
2
+ // EACCES) while anything holds a handle inside it (a running `brust start`, an indexer, an antivirus scan), so the
3
+ // rename is retried briefly and then fails with a message that says what to stop. On POSIX the first try succeeds.
4
+ import { existsSync, renameSync, rmSync } from 'node:fs'
5
+ import { basename, dirname, join } from 'node:path'
6
+ import { BuildError } from './errors'
7
+
8
+ const BUSY = new Set(['EPERM', 'EBUSY', 'EACCES'])
9
+ export const RENAME_TRIES = 5
10
+ export const RENAME_WAIT_MS = 100
11
+
12
+ export interface SwapOps {
13
+ rename: (from: string, to: string) => void
14
+ sleep: (ms: number) => void
15
+ }
16
+
17
+ const real: SwapOps = {
18
+ rename: renameSync,
19
+ sleep: (ms) => void Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, ms),
20
+ }
21
+
22
+ /** `renameSync` that retries a held-handle failure `RENAME_TRIES` times, `RENAME_WAIT_MS` apart. */
23
+ export function renameRetry(from: string, to: string, dist: string, ops: SwapOps = real): void {
24
+ for (let i = 1; ; i++) {
25
+ try {
26
+ ops.rename(from, to)
27
+ return
28
+ } catch (e) {
29
+ const code = (e as NodeJS.ErrnoException).code
30
+ if (code === undefined || !BUSY.has(code)) throw e
31
+ if (i >= RENAME_TRIES)
32
+ throw new BuildError('dist-busy', `cannot replace ${dist} (${code}): stop a running \`brust start\` or anything holding files in it, then build again`)
33
+ ops.sleep(RENAME_WAIT_MS)
34
+ }
35
+ }
36
+ }
37
+
38
+ /** Puts `tmp` in place of `dist`; the previous dist goes through `.<name>.brust-old` and is removed after. */
39
+ export function swapDist(tmp: string, dist: string, ops: SwapOps = real): void {
40
+ if (existsSync(dist)) {
41
+ const old = join(dirname(dist), `.${basename(dist)}.brust-old`)
42
+ rmSync(old, { recursive: true, force: true })
43
+ renameRetry(dist, old, dist, ops)
44
+ renameRetry(tmp, dist, dist, ops)
45
+ rmSync(old, { recursive: true, force: true })
46
+ } else renameRetry(tmp, dist, dist, ops)
47
+ }
package/src/dev/bun.ts CHANGED
@@ -9,6 +9,7 @@ import { loadConfig } from '../config'
9
9
  import { type Diag, parseBuildError, parseWarnings } from './diag'
10
10
  import { tierCounts } from './devtools-data'
11
11
  import { type DevProxy, startProxy } from './proxy'
12
+ import { openCommand } from './open'
12
13
  import { HOTKEYS, Tui, type TuiOut, tuiMode } from './tui'
13
14
  import { loadBuildConfig } from '../build/config'
14
15
  import { broadRootWarnings, changeLine, defaultIgnored, watchLoop } from './watch'
@@ -30,6 +31,25 @@ const BOOT_TIMEOUT_MS = 60_000
30
31
  const TAIL_LINES = 40
31
32
  const cliPath = join(import.meta.dir, '..', 'cli.ts')
32
33
 
34
+ /** The `[actions] prefix` of the build in `dir` (its manifest), or null when there is none. */
35
+ export function readActionsPrefix(dir: string): string | null {
36
+ try {
37
+ return (JSON.parse(readFileSync(join(dir, 'manifest.json'), 'utf8')) as { actions?: { prefix?: string } | null }).actions?.prefix ?? null
38
+ } catch {
39
+ return null
40
+ }
41
+ }
42
+
43
+ /** `read` once per active build: each build is booted as its own child in its own `g<n>` dir, so the child object changes exactly when the build does. */
44
+ export function perBuild<C extends { dir: string }, T>(read: (dir: string) => T): (c: C | null) => T | null {
45
+ let last: [C, T] | undefined
46
+ return (c) => {
47
+ if (!c) return null
48
+ if (last?.[0] !== c) last = [c, read(c.dir)]
49
+ return last[1]
50
+ }
51
+ }
52
+
33
53
  /** A free loopback port (bind port 0, read it, release it). */
34
54
  export function freePort(): number {
35
55
  const s = Bun.serve({ port: 0, hostname: '127.0.0.1', fetch: () => new Response('') })
@@ -134,6 +154,8 @@ export async function runBunDev(o: BunDevOptions): Promise<number> {
134
154
  error: diag && state === 'error' ? `${diag.rule} ${diag.file ? `${diag.file}${diag.line ? `:${diag.line}` : ''} ` : ''}${diag.message}`.trim() : undefined,
135
155
  })
136
156
 
157
+ const prefixOf = perBuild<Child, string | null>(readActionsPrefix)
158
+
137
159
  const devMeta = (): unknown | null => {
138
160
  try {
139
161
  return active ? JSON.parse(readFileSync(join(active.dir, 'dev.json'), 'utf8')) : null
@@ -150,13 +172,7 @@ export async function runBunDev(o: BunDevOptions): Promise<number> {
150
172
  diag: () => diag,
151
173
  upstream: () => active?.port ?? null,
152
174
  meta: devMeta,
153
- actionsPrefix: () => {
154
- try {
155
- return active ? ((JSON.parse(readFileSync(join(active.dir, 'manifest.json'), 'utf8')) as { actions?: { prefix?: string } | null }).actions?.prefix ?? null) : null
156
- } catch {
157
- return null
158
- }
159
- },
175
+ actionsPrefix: () => prefixOf(active),
160
176
  onRequest(r) {
161
177
  tui.log(`${r.method} ${r.path} ${r.status} ${r.ms}ms${r.cache ? ` ${r.cache}` : ''}`)
162
178
  if (!r.path.startsWith('/_brust/')) {
@@ -358,13 +374,14 @@ export async function runBunDev(o: BunDevOptions): Promise<number> {
358
374
  for (const k of b.toString()) {
359
375
  if (k === 'q' || k === '\x03') void stop()
360
376
  else if (k === 'r') proxy.broadcast({ type: 'reload' })
361
- else if (k === 'o') Bun.spawn([process.platform === 'darwin' ? 'open' : 'xdg-open', url], { stdout: 'ignore', stderr: 'ignore' })
377
+ else if (k === 'o') Bun.spawn(openCommand(url), { stdout: 'ignore', stderr: 'ignore' })
362
378
  else if (k === 'w') for (const w of warnings.length ? warnings : ['no warnings']) tui.log(`warning ${w}`)
363
379
  else if (k === 'c') tui.clear()
364
380
  }
365
381
  })
366
382
  ;(out as unknown as NodeJS.WriteStream).on?.('resize', () => tui.resize())
367
383
  }
384
+ // F485 P12: on Windows Ctrl+C (SIGINT) reaches this handler; SIGTERM handlers rarely fire and a kill ends the process without a drain.
368
385
  process.on('SIGINT', () => void stop())
369
386
  process.on('SIGTERM', () => void stop())
370
387
 
@@ -0,0 +1,7 @@
1
+ // F485 P7: the command that opens `url` in the default browser (dev hotkey `o`). Argv array, no shell string.
2
+ export function openCommand(url: string, platform: string = process.platform): string[] {
3
+ if (platform === 'darwin') return ['open', url]
4
+ // cmd parses `&` in a URL as a separator: fine for the internal localhost URL this is called with.
5
+ if (platform === 'win32') return ['cmd', '/c', 'start', '', url] // the empty string is `start`'s window title slot
6
+ return ['xdg-open', url]
7
+ }
package/src/dev.ts CHANGED
@@ -1,7 +1,8 @@
1
1
  // `brust dev [entry] --target cloudflare [-- <wrangler args>]` (M4-CF R10): build, run `wrangler dev` on the
2
2
  // generated project, rebuild + restart wrangler on a source change. No HMR. Each build runs in a child
3
3
  // process: a failed build keeps the old wrangler, and module caches never leak between builds.
4
- import { join, relative, resolve } from 'node:path'
4
+ import { delimiter, join, relative, resolve } from 'node:path'
5
+ import { posixOf } from './build/posix'
5
6
  import { BuildError } from './build/errors'
6
7
  import { loadBuildConfig } from './build/config'
7
8
  import { broadRootWarnings, defaultIgnored, type WatchLoop, watchLoop } from './dev/watch'
@@ -21,7 +22,7 @@ const DEBOUNCE_MS = 300
21
22
  function wranglerBin(appRoot: string): string {
22
23
  const fake = process.env.BRUST_WRANGLER
23
24
  if (fake) return fake
24
- const found = Bun.which('wrangler', { PATH: `${join(appRoot, 'node_modules', '.bin')}:${process.env.PATH ?? ''}` })
25
+ const found = Bun.which('wrangler', { PATH: `${join(appRoot, 'node_modules', '.bin')}${delimiter}${process.env.PATH ?? ''}` })
25
26
  if (!found) throw new BuildError('cf-dev', 'wrangler not found (bun add -d wrangler)')
26
27
  return found
27
28
  }
@@ -71,7 +72,7 @@ export async function runDev(o: DevOptions): Promise<number> {
71
72
  const loop: WatchLoop = watchLoop({
72
73
  root: appRoot,
73
74
  extraRoots,
74
- ignored: (rel) => defaultIgnored(rel, relative(appRoot, dist)),
75
+ ignored: (rel) => defaultIgnored(rel, posixOf(relative(appRoot, dist))),
75
76
  debounceMs: DEBOUNCE_MS,
76
77
  async run() {
77
78
  o.log('[brust] change detected; rebuilding')
@@ -91,6 +92,7 @@ export async function runDev(o: DevOptions): Promise<number> {
91
92
  loop.close()
92
93
  void stopChild().then(() => exitCode(0))
93
94
  }
95
+ // F485 P12: on Windows Ctrl+C (SIGINT) reaches this handler; SIGTERM handlers rarely fire and a kill ends the process without a drain.
94
96
  process.on('SIGINT', stop)
95
97
  process.on('SIGTERM', stop)
96
98
  return done
@@ -0,0 +1,45 @@
1
+ // F488: on Windows a kill of the `bun run start` wrapper (TerminateProcess; no process groups) takes the `.bin/brust.exe` shim down with it
2
+ // but not the server below: it keeps the port, the app dir and the inherited pipes. Probe on windows-latest (PR #428): wrapper -> shim ->
3
+ // server, and after a plain wrapper kill the shim is gone while the server lives. The shim is the server's direct parent, so the server
4
+ // watches `process.ppid`: when that dies it drains like Ctrl+C. Started at boot, synchronously: no process table, nothing awaited.
5
+ // (A PowerShell table read awaited before `ready` cost seconds per start and broke 5 s static builds; the lead ruled it out.)
6
+ // POSIX never watches (platform gate): a POSIX supervisor signals the server directly.
7
+
8
+ /** `process.kill(pid, 0)` throws ESRCH when the process is gone; EPERM means it exists. */
9
+ export function pidAlive(pid: number): boolean {
10
+ try {
11
+ process.kill(pid, 0)
12
+ return true
13
+ } catch (e) {
14
+ return (e as NodeJS.ErrnoException).code === 'EPERM'
15
+ }
16
+ }
17
+
18
+ export interface LauncherWatchOptions {
19
+ /** Runs once, when the parent is gone. */
20
+ onGone: (pid: number) => void
21
+ platform?: NodeJS.Platform
22
+ ppid?: number
23
+ alive?: (pid: number) => boolean
24
+ intervalMs?: number
25
+ log?: (line: string) => void
26
+ }
27
+
28
+ /** Windows only. Returns the watched pid (undefined: nothing watched) and a `stop`. The timer is unref'd: it never holds the process open. */
29
+ export function watchLauncher(opts: LauncherWatchOptions): { pid: number | undefined; stop: () => void } {
30
+ const none = { pid: undefined, stop: () => {} }
31
+ if ((opts.platform ?? process.platform) !== 'win32') return none
32
+ const ppid = opts.ppid ?? process.ppid
33
+ const alive = opts.alive ?? pidAlive
34
+ if (!ppid || !alive(ppid)) {
35
+ ;(opts.log ?? console.error)(`[brust] launcher (pid ${ppid}) is already gone at boot: not watching it`)
36
+ return none
37
+ }
38
+ const timer = setInterval(() => {
39
+ if (alive(ppid)) return
40
+ clearInterval(timer)
41
+ opts.onGone(ppid)
42
+ }, opts.intervalMs ?? 1000)
43
+ timer.unref()
44
+ return { pid: ppid, stop: () => clearInterval(timer) }
45
+ }
package/src/run.ts CHANGED
@@ -11,6 +11,7 @@
11
11
  import { existsSync, readFileSync } from 'node:fs'
12
12
  import { join, resolve } from 'node:path'
13
13
  import { type BrustConfig, type ConfigOverrides, loadConfig } from './config'
14
+ import { watchLauncher } from './launcher-watch'
14
15
  import { beginDrain, localAddr, type StartOptions, type StreamOptions, startServer, untilReady } from './native'
15
16
  import { DEFAULT_MAX_LOADER_RESPONSE_BYTES } from './worker'
16
17
 
@@ -191,9 +192,20 @@ export async function run(opts: RunOptions = {}): Promise<void> {
191
192
  }
192
193
  process.on('uncaughtException', onFatal('uncaught exception'))
193
194
  process.on('unhandledRejection', onFatal('unhandled rejection'))
195
+ // F485 P12: on Windows Ctrl+C (SIGINT) drains; SIGTERM handlers rarely fire and a kill ends the process without a drain (POSIX-only).
194
196
  process.on('SIGINT', () => onSignal(130))
195
197
  process.on('SIGTERM', () => onSignal(143))
196
198
 
199
+ // F488 (Windows only): a killed `bun run start` wrapper takes the shim (our parent) down but leaves this process running; drain when the
200
+ // parent is gone (same path as Ctrl+C). Synchronous, nothing awaited. Not for a one-shot (`opts.onReady`: a static render that exits itself).
201
+ if (!opts.onReady)
202
+ watchLauncher({
203
+ onGone: (pid) => {
204
+ if (exiting) return
205
+ console.error(`[brust] launcher (pid ${pid}) exited: shutting down`)
206
+ onSignal(130)
207
+ },
208
+ })
197
209
  try {
198
210
  await untilReady(cfg.bootTimeoutMs)
199
211
  } catch (e) {