brustjs 0.1.45-alpha → 0.1.46-alpha

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "brustjs",
3
- "version": "0.1.45-alpha",
3
+ "version": "0.1.46-alpha",
4
4
  "description": "Bun + Rust SSR framework — React on the server, Rust everywhere else (napi cdylib + per-worker SharedArrayBuffer).",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -41,12 +41,12 @@
41
41
  "typescript": "^6.0.3"
42
42
  },
43
43
  "optionalDependencies": {
44
- "brustjs-darwin-x64": "0.1.45-alpha",
45
- "brustjs-darwin-arm64": "0.1.45-alpha",
46
- "brustjs-linux-x64-gnu": "0.1.45-alpha",
47
- "brustjs-linux-arm64-gnu": "0.1.45-alpha",
48
- "brustjs-linux-x64-musl": "0.1.45-alpha",
49
- "brustjs-linux-arm64-musl": "0.1.45-alpha"
44
+ "brustjs-darwin-x64": "0.1.46-alpha",
45
+ "brustjs-darwin-arm64": "0.1.46-alpha",
46
+ "brustjs-linux-x64-gnu": "0.1.46-alpha",
47
+ "brustjs-linux-arm64-gnu": "0.1.46-alpha",
48
+ "brustjs-linux-x64-musl": "0.1.46-alpha",
49
+ "brustjs-linux-arm64-musl": "0.1.46-alpha"
50
50
  },
51
51
  "peerDependencies": {
52
52
  "react": "^19.2.6",
package/runtime/index.js CHANGED
@@ -77,8 +77,8 @@ function requireNative() {
77
77
  try {
78
78
  const binding = require('brustjs-android-arm64')
79
79
  const bindingPackageVersion = require('brustjs-android-arm64/package.json').version
80
- if (bindingPackageVersion !== '0.1.45-alpha' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
81
- throw new Error(`Native binding package version mismatch, expected 0.1.45-alpha but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
80
+ if (bindingPackageVersion !== '0.1.46-alpha' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
81
+ throw new Error(`Native binding package version mismatch, expected 0.1.46-alpha but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
82
82
  }
83
83
  return binding
84
84
  } catch (e) {
@@ -93,8 +93,8 @@ function requireNative() {
93
93
  try {
94
94
  const binding = require('brustjs-android-arm-eabi')
95
95
  const bindingPackageVersion = require('brustjs-android-arm-eabi/package.json').version
96
- if (bindingPackageVersion !== '0.1.45-alpha' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
97
- throw new Error(`Native binding package version mismatch, expected 0.1.45-alpha but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
96
+ if (bindingPackageVersion !== '0.1.46-alpha' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
97
+ throw new Error(`Native binding package version mismatch, expected 0.1.46-alpha but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
98
98
  }
99
99
  return binding
100
100
  } catch (e) {
@@ -114,8 +114,8 @@ function requireNative() {
114
114
  try {
115
115
  const binding = require('brustjs-win32-x64-gnu')
116
116
  const bindingPackageVersion = require('brustjs-win32-x64-gnu/package.json').version
117
- if (bindingPackageVersion !== '0.1.45-alpha' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
118
- throw new Error(`Native binding package version mismatch, expected 0.1.45-alpha but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
117
+ if (bindingPackageVersion !== '0.1.46-alpha' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
118
+ throw new Error(`Native binding package version mismatch, expected 0.1.46-alpha but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
119
119
  }
120
120
  return binding
121
121
  } catch (e) {
@@ -130,8 +130,8 @@ function requireNative() {
130
130
  try {
131
131
  const binding = require('brustjs-win32-x64-msvc')
132
132
  const bindingPackageVersion = require('brustjs-win32-x64-msvc/package.json').version
133
- if (bindingPackageVersion !== '0.1.45-alpha' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
134
- throw new Error(`Native binding package version mismatch, expected 0.1.45-alpha but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
133
+ if (bindingPackageVersion !== '0.1.46-alpha' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
134
+ throw new Error(`Native binding package version mismatch, expected 0.1.46-alpha but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
135
135
  }
136
136
  return binding
137
137
  } catch (e) {
@@ -147,8 +147,8 @@ function requireNative() {
147
147
  try {
148
148
  const binding = require('brustjs-win32-ia32-msvc')
149
149
  const bindingPackageVersion = require('brustjs-win32-ia32-msvc/package.json').version
150
- if (bindingPackageVersion !== '0.1.45-alpha' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
151
- throw new Error(`Native binding package version mismatch, expected 0.1.45-alpha but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
150
+ if (bindingPackageVersion !== '0.1.46-alpha' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
151
+ throw new Error(`Native binding package version mismatch, expected 0.1.46-alpha but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
152
152
  }
153
153
  return binding
154
154
  } catch (e) {
@@ -163,8 +163,8 @@ function requireNative() {
163
163
  try {
164
164
  const binding = require('brustjs-win32-arm64-msvc')
165
165
  const bindingPackageVersion = require('brustjs-win32-arm64-msvc/package.json').version
166
- if (bindingPackageVersion !== '0.1.45-alpha' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
167
- throw new Error(`Native binding package version mismatch, expected 0.1.45-alpha but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
166
+ if (bindingPackageVersion !== '0.1.46-alpha' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
167
+ throw new Error(`Native binding package version mismatch, expected 0.1.46-alpha but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
168
168
  }
169
169
  return binding
170
170
  } catch (e) {
@@ -182,8 +182,8 @@ function requireNative() {
182
182
  try {
183
183
  const binding = require('brustjs-darwin-universal')
184
184
  const bindingPackageVersion = require('brustjs-darwin-universal/package.json').version
185
- if (bindingPackageVersion !== '0.1.45-alpha' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
186
- throw new Error(`Native binding package version mismatch, expected 0.1.45-alpha but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
185
+ if (bindingPackageVersion !== '0.1.46-alpha' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
186
+ throw new Error(`Native binding package version mismatch, expected 0.1.46-alpha but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
187
187
  }
188
188
  return binding
189
189
  } catch (e) {
@@ -198,8 +198,8 @@ function requireNative() {
198
198
  try {
199
199
  const binding = require('brustjs-darwin-x64')
200
200
  const bindingPackageVersion = require('brustjs-darwin-x64/package.json').version
201
- if (bindingPackageVersion !== '0.1.45-alpha' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
202
- throw new Error(`Native binding package version mismatch, expected 0.1.45-alpha but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
201
+ if (bindingPackageVersion !== '0.1.46-alpha' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
202
+ throw new Error(`Native binding package version mismatch, expected 0.1.46-alpha but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
203
203
  }
204
204
  return binding
205
205
  } catch (e) {
@@ -214,8 +214,8 @@ function requireNative() {
214
214
  try {
215
215
  const binding = require('brustjs-darwin-arm64')
216
216
  const bindingPackageVersion = require('brustjs-darwin-arm64/package.json').version
217
- if (bindingPackageVersion !== '0.1.45-alpha' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
218
- throw new Error(`Native binding package version mismatch, expected 0.1.45-alpha but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
217
+ if (bindingPackageVersion !== '0.1.46-alpha' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
218
+ throw new Error(`Native binding package version mismatch, expected 0.1.46-alpha but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
219
219
  }
220
220
  return binding
221
221
  } catch (e) {
@@ -234,8 +234,8 @@ function requireNative() {
234
234
  try {
235
235
  const binding = require('brustjs-freebsd-x64')
236
236
  const bindingPackageVersion = require('brustjs-freebsd-x64/package.json').version
237
- if (bindingPackageVersion !== '0.1.45-alpha' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
238
- throw new Error(`Native binding package version mismatch, expected 0.1.45-alpha but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
237
+ if (bindingPackageVersion !== '0.1.46-alpha' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
238
+ throw new Error(`Native binding package version mismatch, expected 0.1.46-alpha but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
239
239
  }
240
240
  return binding
241
241
  } catch (e) {
@@ -250,8 +250,8 @@ function requireNative() {
250
250
  try {
251
251
  const binding = require('brustjs-freebsd-arm64')
252
252
  const bindingPackageVersion = require('brustjs-freebsd-arm64/package.json').version
253
- if (bindingPackageVersion !== '0.1.45-alpha' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
254
- throw new Error(`Native binding package version mismatch, expected 0.1.45-alpha but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
253
+ if (bindingPackageVersion !== '0.1.46-alpha' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
254
+ throw new Error(`Native binding package version mismatch, expected 0.1.46-alpha but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
255
255
  }
256
256
  return binding
257
257
  } catch (e) {
@@ -271,8 +271,8 @@ function requireNative() {
271
271
  try {
272
272
  const binding = require('brustjs-linux-x64-musl')
273
273
  const bindingPackageVersion = require('brustjs-linux-x64-musl/package.json').version
274
- if (bindingPackageVersion !== '0.1.45-alpha' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
275
- throw new Error(`Native binding package version mismatch, expected 0.1.45-alpha but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
274
+ if (bindingPackageVersion !== '0.1.46-alpha' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
275
+ throw new Error(`Native binding package version mismatch, expected 0.1.46-alpha but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
276
276
  }
277
277
  return binding
278
278
  } catch (e) {
@@ -287,8 +287,8 @@ function requireNative() {
287
287
  try {
288
288
  const binding = require('brustjs-linux-x64-gnu')
289
289
  const bindingPackageVersion = require('brustjs-linux-x64-gnu/package.json').version
290
- if (bindingPackageVersion !== '0.1.45-alpha' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
291
- throw new Error(`Native binding package version mismatch, expected 0.1.45-alpha but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
290
+ if (bindingPackageVersion !== '0.1.46-alpha' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
291
+ throw new Error(`Native binding package version mismatch, expected 0.1.46-alpha but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
292
292
  }
293
293
  return binding
294
294
  } catch (e) {
@@ -305,8 +305,8 @@ function requireNative() {
305
305
  try {
306
306
  const binding = require('brustjs-linux-arm64-musl')
307
307
  const bindingPackageVersion = require('brustjs-linux-arm64-musl/package.json').version
308
- if (bindingPackageVersion !== '0.1.45-alpha' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
309
- throw new Error(`Native binding package version mismatch, expected 0.1.45-alpha but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
308
+ if (bindingPackageVersion !== '0.1.46-alpha' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
309
+ throw new Error(`Native binding package version mismatch, expected 0.1.46-alpha but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
310
310
  }
311
311
  return binding
312
312
  } catch (e) {
@@ -321,8 +321,8 @@ function requireNative() {
321
321
  try {
322
322
  const binding = require('brustjs-linux-arm64-gnu')
323
323
  const bindingPackageVersion = require('brustjs-linux-arm64-gnu/package.json').version
324
- if (bindingPackageVersion !== '0.1.45-alpha' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
325
- throw new Error(`Native binding package version mismatch, expected 0.1.45-alpha but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
324
+ if (bindingPackageVersion !== '0.1.46-alpha' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
325
+ throw new Error(`Native binding package version mismatch, expected 0.1.46-alpha but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
326
326
  }
327
327
  return binding
328
328
  } catch (e) {
@@ -339,8 +339,8 @@ function requireNative() {
339
339
  try {
340
340
  const binding = require('brustjs-linux-arm-musleabihf')
341
341
  const bindingPackageVersion = require('brustjs-linux-arm-musleabihf/package.json').version
342
- if (bindingPackageVersion !== '0.1.45-alpha' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
343
- throw new Error(`Native binding package version mismatch, expected 0.1.45-alpha but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
342
+ if (bindingPackageVersion !== '0.1.46-alpha' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
343
+ throw new Error(`Native binding package version mismatch, expected 0.1.46-alpha but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
344
344
  }
345
345
  return binding
346
346
  } catch (e) {
@@ -355,8 +355,8 @@ function requireNative() {
355
355
  try {
356
356
  const binding = require('brustjs-linux-arm-gnueabihf')
357
357
  const bindingPackageVersion = require('brustjs-linux-arm-gnueabihf/package.json').version
358
- if (bindingPackageVersion !== '0.1.45-alpha' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
359
- throw new Error(`Native binding package version mismatch, expected 0.1.45-alpha but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
358
+ if (bindingPackageVersion !== '0.1.46-alpha' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
359
+ throw new Error(`Native binding package version mismatch, expected 0.1.46-alpha but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
360
360
  }
361
361
  return binding
362
362
  } catch (e) {
@@ -373,8 +373,8 @@ function requireNative() {
373
373
  try {
374
374
  const binding = require('brustjs-linux-loong64-musl')
375
375
  const bindingPackageVersion = require('brustjs-linux-loong64-musl/package.json').version
376
- if (bindingPackageVersion !== '0.1.45-alpha' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
377
- throw new Error(`Native binding package version mismatch, expected 0.1.45-alpha but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
376
+ if (bindingPackageVersion !== '0.1.46-alpha' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
377
+ throw new Error(`Native binding package version mismatch, expected 0.1.46-alpha but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
378
378
  }
379
379
  return binding
380
380
  } catch (e) {
@@ -389,8 +389,8 @@ function requireNative() {
389
389
  try {
390
390
  const binding = require('brustjs-linux-loong64-gnu')
391
391
  const bindingPackageVersion = require('brustjs-linux-loong64-gnu/package.json').version
392
- if (bindingPackageVersion !== '0.1.45-alpha' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
393
- throw new Error(`Native binding package version mismatch, expected 0.1.45-alpha but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
392
+ if (bindingPackageVersion !== '0.1.46-alpha' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
393
+ throw new Error(`Native binding package version mismatch, expected 0.1.46-alpha but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
394
394
  }
395
395
  return binding
396
396
  } catch (e) {
@@ -407,8 +407,8 @@ function requireNative() {
407
407
  try {
408
408
  const binding = require('brustjs-linux-riscv64-musl')
409
409
  const bindingPackageVersion = require('brustjs-linux-riscv64-musl/package.json').version
410
- if (bindingPackageVersion !== '0.1.45-alpha' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
411
- throw new Error(`Native binding package version mismatch, expected 0.1.45-alpha but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
410
+ if (bindingPackageVersion !== '0.1.46-alpha' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
411
+ throw new Error(`Native binding package version mismatch, expected 0.1.46-alpha but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
412
412
  }
413
413
  return binding
414
414
  } catch (e) {
@@ -423,8 +423,8 @@ function requireNative() {
423
423
  try {
424
424
  const binding = require('brustjs-linux-riscv64-gnu')
425
425
  const bindingPackageVersion = require('brustjs-linux-riscv64-gnu/package.json').version
426
- if (bindingPackageVersion !== '0.1.45-alpha' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
427
- throw new Error(`Native binding package version mismatch, expected 0.1.45-alpha but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
426
+ if (bindingPackageVersion !== '0.1.46-alpha' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
427
+ throw new Error(`Native binding package version mismatch, expected 0.1.46-alpha but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
428
428
  }
429
429
  return binding
430
430
  } catch (e) {
@@ -440,8 +440,8 @@ function requireNative() {
440
440
  try {
441
441
  const binding = require('brustjs-linux-ppc64-gnu')
442
442
  const bindingPackageVersion = require('brustjs-linux-ppc64-gnu/package.json').version
443
- if (bindingPackageVersion !== '0.1.45-alpha' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
444
- throw new Error(`Native binding package version mismatch, expected 0.1.45-alpha but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
443
+ if (bindingPackageVersion !== '0.1.46-alpha' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
444
+ throw new Error(`Native binding package version mismatch, expected 0.1.46-alpha but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
445
445
  }
446
446
  return binding
447
447
  } catch (e) {
@@ -456,8 +456,8 @@ function requireNative() {
456
456
  try {
457
457
  const binding = require('brustjs-linux-s390x-gnu')
458
458
  const bindingPackageVersion = require('brustjs-linux-s390x-gnu/package.json').version
459
- if (bindingPackageVersion !== '0.1.45-alpha' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
460
- throw new Error(`Native binding package version mismatch, expected 0.1.45-alpha but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
459
+ if (bindingPackageVersion !== '0.1.46-alpha' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
460
+ throw new Error(`Native binding package version mismatch, expected 0.1.46-alpha but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
461
461
  }
462
462
  return binding
463
463
  } catch (e) {
@@ -476,8 +476,8 @@ function requireNative() {
476
476
  try {
477
477
  const binding = require('brustjs-openharmony-arm64')
478
478
  const bindingPackageVersion = require('brustjs-openharmony-arm64/package.json').version
479
- if (bindingPackageVersion !== '0.1.45-alpha' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
480
- throw new Error(`Native binding package version mismatch, expected 0.1.45-alpha but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
479
+ if (bindingPackageVersion !== '0.1.46-alpha' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
480
+ throw new Error(`Native binding package version mismatch, expected 0.1.46-alpha but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
481
481
  }
482
482
  return binding
483
483
  } catch (e) {
@@ -492,8 +492,8 @@ function requireNative() {
492
492
  try {
493
493
  const binding = require('brustjs-openharmony-x64')
494
494
  const bindingPackageVersion = require('brustjs-openharmony-x64/package.json').version
495
- if (bindingPackageVersion !== '0.1.45-alpha' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
496
- throw new Error(`Native binding package version mismatch, expected 0.1.45-alpha but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
495
+ if (bindingPackageVersion !== '0.1.46-alpha' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
496
+ throw new Error(`Native binding package version mismatch, expected 0.1.46-alpha but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
497
497
  }
498
498
  return binding
499
499
  } catch (e) {
@@ -508,8 +508,8 @@ function requireNative() {
508
508
  try {
509
509
  const binding = require('brustjs-openharmony-arm')
510
510
  const bindingPackageVersion = require('brustjs-openharmony-arm/package.json').version
511
- if (bindingPackageVersion !== '0.1.45-alpha' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
512
- throw new Error(`Native binding package version mismatch, expected 0.1.45-alpha but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
511
+ if (bindingPackageVersion !== '0.1.46-alpha' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
512
+ throw new Error(`Native binding package version mismatch, expected 0.1.46-alpha but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
513
513
  }
514
514
  return binding
515
515
  } catch (e) {
@@ -24,6 +24,14 @@ import {
24
24
  registerNavigator,
25
25
  } from '../navigation/store.ts'
26
26
  import { installActiveNav } from '../navigation/active-nav.ts'
27
+ import {
28
+ pageCacheKey,
29
+ getCachedPage,
30
+ fetchPagePayload,
31
+ inflightPage,
32
+ prefetchPage,
33
+ type PagePayload,
34
+ } from './page-cache.ts'
27
35
 
28
36
  // Track React roots created by hydrateOne so we can unmount them before
29
37
  // removing their DOM in swapMainContent. Without this, removing the DOM
@@ -242,22 +250,47 @@ export function isFullDocumentPayload(html: string): boolean {
242
250
 
243
251
  let inFlight: AbortController | null = null
244
252
 
253
+ // scrollY of each page we navigated away from (keyed pathname+search), so
254
+ // back/forward restores the reading position instead of jumping to top.
255
+ const scrollPositions = new Map<string, number>()
256
+ // The page currently in the DOM. Tracked here (set at boot + on every commit)
257
+ // instead of read from `location` at save time, because popstate updates
258
+ // `location` to the DESTINATION before the event fires — reading it there
259
+ // would record the leaving page's scroll under the wrong key.
260
+ let currentPageKey = ''
261
+
245
262
  export async function navigate(url: URL, mode: 'push' | 'replace' | 'none'): Promise<void> {
246
263
  inFlight?.abort()
247
264
  const ac = new AbortController()
248
265
  inFlight = ac
249
266
  try {
250
267
  __navStart(url.pathname, url.search)
251
- const resp = await fetch(`/_brust/page${url.pathname}${url.search}`, {
252
- signal: ac.signal,
253
- headers: { Accept: 'application/json' },
254
- })
255
- if (!resp.ok) throw new Error(`navigation: status ${resp.status}`)
256
- const { html, title, store } = (await resp.json()) as {
257
- html: string
258
- title: string
259
- store?: Record<string, Record<string, unknown>>
268
+ const key = pageCacheKey(url)
269
+ // Visited pages are served from the in-memory cache — no refetch. Forward
270
+ // navigations respect PAGE_STALE_MS (default max age); back/forward reuses
271
+ // any entry regardless of age, like the browser's bfcache.
272
+ const cached = getCachedPage(key, mode === 'none' ? Number.POSITIVE_INFINITY : undefined)
273
+ let payload: PagePayload
274
+ if (cached) {
275
+ payload = cached
276
+ } else {
277
+ // A hover prefetch may already have this page in flight — await it
278
+ // instead of double-fetching; if it failed, fall back to a direct fetch.
279
+ const pre = inflightPage(key)
280
+ if (pre) {
281
+ try {
282
+ payload = await pre
283
+ } catch {
284
+ payload = await fetchPagePayload(url, ac.signal)
285
+ }
286
+ } else {
287
+ payload = await fetchPagePayload(url, ac.signal)
288
+ }
289
+ // The prefetch promise isn't tied to our AbortController, so an abort
290
+ // during that await doesn't throw — check for supersession explicitly.
291
+ if (ac.signal.aborted) return
260
292
  }
293
+ const { html, title, store } = payload
261
294
  // A standalone (no-<main>) route ships its FULL document here. We can't swap
262
295
  // that into the current shell's <main> without nesting a second document
263
296
  // (duplicate chrome — the classic two-topbars artifact), and the current
@@ -269,14 +302,20 @@ export async function navigate(url: URL, mode: 'push' | 'replace' | 'none'): Pro
269
302
  }
270
303
  const main = document.querySelector('main')
271
304
  if (!main) throw new Error('navigation: no <main> element')
305
+ scrollPositions.set(currentPageKey, window.scrollY)
272
306
  unmountIslandsIn(main as HTMLElement)
273
307
  swapMainContent(main as HTMLElement, html)
274
- if (store) applyStoreSnapshot(store)
308
+ // Only a FRESH payload re-applies the server store snapshot: replaying a
309
+ // cached (stale) snapshot would roll back live client store state the user
310
+ // changed since the page was first fetched.
311
+ if (!cached && store) applyStoreSnapshot(store)
275
312
  if (title) document.title = title
276
313
  if (mode === 'push') history.pushState({}, '', url.href)
277
314
  else if (mode === 'replace') history.replaceState({}, '', url.href)
278
- window.scrollTo(0, 0)
315
+ if (mode === 'none') window.scrollTo(0, scrollPositions.get(key) ?? 0)
316
+ else window.scrollTo(0, 0)
279
317
  hydrateMarkersIn(main as HTMLElement)
318
+ currentPageKey = key
280
319
  __navCommit(url.pathname, url.search)
281
320
  } catch (err) {
282
321
  if ((err as Error).name === 'AbortError') return
@@ -288,7 +327,76 @@ export async function navigate(url: URL, mode: 'push' | 'replace' | 'none'): Pro
288
327
  }
289
328
  }
290
329
 
330
+ /** Resolve an <a> to a prefetchable in-app URL, or null when prefetch must not
331
+ * run: not ours (cross-origin, target, download, /_brust/), explicitly opted
332
+ * out (data-brust-no-intercept disables SPA handling entirely;
333
+ * data-brust-no-prefetch keeps the SPA click but skips the speculative fetch),
334
+ * or the page we are already on. Exported for unit testing. */
335
+ export function prefetchUrlFor(a: HTMLAnchorElement): URL | null {
336
+ if (a.target && a.target !== '_self') return null
337
+ if (a.hasAttribute('download')) return null
338
+ if (a.dataset.brustNoIntercept !== undefined) return null
339
+ if (a.dataset.brustNoPrefetch !== undefined) return null
340
+ if (!a.getAttribute('href')) return null
341
+ const url = new URL(a.href, location.href)
342
+ if (url.origin !== location.origin) return null
343
+ if (url.pathname.startsWith('/_brust/')) return null
344
+ if (url.pathname === location.pathname && url.search === location.search) return null
345
+ return url
346
+ }
347
+
348
+ // Hover-intent delay: long enough that a cursor sweeping across a nav list
349
+ // doesn't fire a fetch per link, short enough to beat the click (~200-300ms
350
+ // between hover and press for a deliberate click).
351
+ const HOVER_DELAY_MS = 80
352
+
353
+ /** Hover/touch prefetch: pointer rests on an internal link for HOVER_DELAY_MS
354
+ * (or a touch starts — the tap commits within ~100ms anyway) → fetch its nav
355
+ * payload into the page cache so the eventual click swaps instantly.
356
+ * prefetchPage dedupes in-flight fetches and respects Save-Data/2g. */
357
+ function installPrefetch(): void {
358
+ const timers = new WeakMap<HTMLAnchorElement, ReturnType<typeof setTimeout>>()
359
+ document.addEventListener('pointerover', (e) => {
360
+ const a = (e.target as HTMLElement | null)?.closest('a') as HTMLAnchorElement | null
361
+ if (!a || timers.has(a)) return
362
+ const url = prefetchUrlFor(a)
363
+ if (!url) return
364
+ timers.set(
365
+ a,
366
+ setTimeout(() => {
367
+ timers.delete(a)
368
+ void prefetchPage(url)
369
+ }, HOVER_DELAY_MS),
370
+ )
371
+ })
372
+ document.addEventListener('pointerout', (e) => {
373
+ const a = (e.target as HTMLElement | null)?.closest('a') as HTMLAnchorElement | null
374
+ if (!a) return
375
+ // Moving between children of the same link is not a leave.
376
+ if (e.relatedTarget instanceof Node && a.contains(e.relatedTarget)) return
377
+ const t = timers.get(a)
378
+ if (t !== undefined) {
379
+ clearTimeout(t)
380
+ timers.delete(a)
381
+ }
382
+ })
383
+ document.addEventListener(
384
+ 'touchstart',
385
+ (e) => {
386
+ const a = (e.target as HTMLElement | null)?.closest('a') as HTMLAnchorElement | null
387
+ if (!a) return
388
+ const url = prefetchUrlFor(a)
389
+ if (url) void prefetchPage(url)
390
+ },
391
+ { passive: true },
392
+ )
393
+ }
394
+
291
395
  function installInterceptor(): void {
396
+ // We restore scroll ourselves on popstate (the page cache makes back/forward
397
+ // an instant in-place swap); stop the browser's automatic restoration from
398
+ // fighting the swap.
399
+ if ('scrollRestoration' in history) history.scrollRestoration = 'manual'
292
400
  document.addEventListener('click', (e) => {
293
401
  const target = e.target as HTMLElement | null
294
402
  const a = target?.closest('a') as HTMLAnchorElement | null
@@ -309,17 +417,20 @@ function installInterceptor(): void {
309
417
 
310
418
  if (typeof document !== 'undefined') {
311
419
  registerNavigator((url, replace) => navigate(url, replace ? 'replace' : 'push'))
420
+ currentPageKey = location.pathname + location.search
312
421
  if (document.readyState === 'loading') {
313
422
  document.addEventListener('DOMContentLoaded', () => {
314
423
  __navInit(location.pathname, location.search)
315
424
  installActiveNav()
316
425
  hydrateMarkersIn(document.body)
317
426
  installInterceptor()
427
+ installPrefetch()
318
428
  })
319
429
  } else {
320
430
  __navInit(location.pathname, location.search)
321
431
  installActiveNav()
322
432
  hydrateMarkersIn(document.body)
323
433
  installInterceptor()
434
+ installPrefetch()
324
435
  }
325
436
  }
@@ -0,0 +1,108 @@
1
+ // runtime/islands/page-cache.ts — in-memory cache for SPA navigation payloads
2
+ // (/_brust/page/*) plus the fetch/dedupe machinery behind hover prefetch.
3
+ // Browser-only at call time (fetch/navigator), but import-safe anywhere.
4
+ //
5
+ // Lifetime: one document load. A full reload (dev rebuild WS, full-document
6
+ // fallback, hard refresh) drops the whole cache with the JS heap, so dev never
7
+ // serves stale pages across rebuilds.
8
+
9
+ export interface PagePayload {
10
+ html: string
11
+ title: string
12
+ store?: Record<string, Record<string, unknown>>
13
+ }
14
+
15
+ /** Bound the cache so a long session can't grow memory unbounded (LRU evict). */
16
+ export const PAGE_CACHE_MAX = 64
17
+ /** Forward navigations reuse an entry for this long; back/forward (popstate)
18
+ * passes Infinity and reuses any entry regardless of age (bfcache-like). */
19
+ export const PAGE_STALE_MS = 5 * 60_000
20
+
21
+ interface Entry {
22
+ payload: PagePayload
23
+ at: number
24
+ }
25
+
26
+ const cache = new Map<string, Entry>()
27
+ const inflight = new Map<string, Promise<PagePayload>>()
28
+
29
+ export function pageCacheKey(url: URL): string {
30
+ return url.pathname + url.search
31
+ }
32
+
33
+ export function getCachedPage(key: string, maxAgeMs: number = PAGE_STALE_MS): PagePayload | null {
34
+ const e = cache.get(key)
35
+ if (!e) return null
36
+ if (Date.now() - e.at > maxAgeMs) {
37
+ cache.delete(key)
38
+ return null
39
+ }
40
+ // LRU bump: Map iteration order is insertion order, so re-inserting moves
41
+ // this key to the "most recently used" end.
42
+ cache.delete(key)
43
+ cache.set(key, e)
44
+ return e.payload
45
+ }
46
+
47
+ export function setCachedPage(key: string, payload: PagePayload): void {
48
+ cache.delete(key)
49
+ cache.set(key, { payload, at: Date.now() })
50
+ if (cache.size > PAGE_CACHE_MAX) {
51
+ const oldest = cache.keys().next().value
52
+ if (oldest !== undefined) cache.delete(oldest)
53
+ }
54
+ }
55
+
56
+ /** Fetch a nav payload and cache it on success. Shared by navigate (direct,
57
+ * abortable) and prefetch (deduped, signal-less). */
58
+ export async function fetchPagePayload(url: URL, signal?: AbortSignal): Promise<PagePayload> {
59
+ const resp = await fetch(`/_brust/page${url.pathname}${url.search}`, {
60
+ signal,
61
+ headers: { Accept: 'application/json' },
62
+ })
63
+ if (!resp.ok) throw new Error(`navigation: status ${resp.status}`)
64
+ const payload = (await resp.json()) as PagePayload
65
+ setCachedPage(pageCacheKey(url), payload)
66
+ return payload
67
+ }
68
+
69
+ /** @internal — the in-flight prefetch for `key`, if any. navigate() awaits it
70
+ * instead of double-fetching when a click lands mid-prefetch. */
71
+ export function inflightPage(key: string): Promise<PagePayload> | undefined {
72
+ return inflight.get(key)
73
+ }
74
+
75
+ function prefetchAllowed(): boolean {
76
+ if (typeof navigator === 'undefined') return false
77
+ const conn = (navigator as { connection?: { saveData?: boolean; effectiveType?: string } })
78
+ .connection
79
+ if (conn?.saveData) return false
80
+ if (typeof conn?.effectiveType === 'string' && conn.effectiveType.includes('2g')) return false
81
+ return true
82
+ }
83
+
84
+ /** Speculatively load a page into the cache (hover/touch intent). No-op when
85
+ * already cached fresh or when the connection asks not to (Save-Data, 2g).
86
+ * Failures are silent — the eventual click just fetches normally. */
87
+ export function prefetchPage(url: URL): Promise<void> {
88
+ if (!prefetchAllowed()) return Promise.resolve()
89
+ const key = pageCacheKey(url)
90
+ if (getCachedPage(key) !== null) return Promise.resolve()
91
+ let p = inflight.get(key)
92
+ if (!p) {
93
+ p = fetchPagePayload(url).finally(() => {
94
+ inflight.delete(key)
95
+ })
96
+ inflight.set(key, p)
97
+ }
98
+ return p.then(
99
+ () => undefined,
100
+ () => undefined,
101
+ )
102
+ }
103
+
104
+ // Test-only: drop all entries and in-flight markers.
105
+ export function __resetPageCacheForTest(): void {
106
+ cache.clear()
107
+ inflight.clear()
108
+ }