@nubjs/nub-win32-arm64 0.0.44 → 0.0.45

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/bin/nub.exe CHANGED
Binary file
package/bin/nubx.exe CHANGED
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nubjs/nub-win32-arm64",
3
- "version": "0.0.44",
3
+ "version": "0.0.45",
4
4
  "description": "Nub binary for win32-arm64",
5
5
  "license": "MIT",
6
6
  "repository": "https://github.com/nubjs/nub",
Binary file
@@ -32,6 +32,38 @@ const __require = createRequire(__filename);
32
32
  function installSyncPolyfills(preloaded) {
33
33
  preloaded = preloaded || {};
34
34
 
35
+ // ── Web Storage: neutralize the throwing localStorage getter ────────
36
+ // When nub injects `--experimental-webstorage` on the 22.4–24 band AND the user
37
+ // did NOT pass `--localstorage-file`, Node installs a `localStorage` global that
38
+ // is a getter THROWING `ERR_INVALID_ARG_VALUE` on ANY access — even
39
+ // `typeof localStorage` throws, so feature-detection is impossible and the throw
40
+ // can surface before user code expects it. The spawn layer signals this case via
41
+ // the internal `__NUB_NEUTRALIZE_LOCALSTORAGE` env var (set iff flag-injected ∧
42
+ // no user file). Replace the throwing getter with a plain `undefined` value —
43
+ // matching Node 25+'s clean shape — so `typeof localStorage === "undefined"` is
44
+ // true and no throw occurs; `sessionStorage`, which needs only the flag, keeps
45
+ // working. This runs in the preload BEFORE any user code, so the throwing getter
46
+ // is never observed. When the user passes `--localstorage-file`, the env var is
47
+ // absent and `localStorage` works normally (we do not touch it). We deliberately
48
+ // KEEP the env var set so it inherits to the whole process subtree: a `node`- or
49
+ // `nub`-spawned grandchild re-inherits the webstorage flag via NODE_OPTIONS and
50
+ // would otherwise re-install the throwing getter with no neutralize signal. It's
51
+ // an internal `__NUB_*` plumbing var that's explicitly fine to leak to children.
52
+ // Neutralization is idempotent — a descendant re-running this preload with the
53
+ // var still set just re-defines `localStorage` to undefined again, which is
54
+ // harmless. The descriptor is configurable+writable so user code can still assign
55
+ // its own `localStorage`.
56
+ if (process.env.__NUB_NEUTRALIZE_LOCALSTORAGE) {
57
+ try {
58
+ Object.defineProperty(globalThis, "localStorage", {
59
+ value: undefined,
60
+ configurable: true,
61
+ writable: true,
62
+ enumerable: false,
63
+ });
64
+ } catch { /* descriptor non-configurable on this runtime: leave Node's behavior */ }
65
+ }
66
+
35
67
  // ── reportError (WinterTC min-common-API, not in any Node) ──────────
36
68
  // Defined NON-ENUMERABLE so it is invisible to `Object.keys(globalThis)` /
37
69
  // for-in / structured-clone-of-keys — that invisibility-to-enumeration IS the
@@ -160,22 +160,6 @@ export const TRANSPILE_EXTS = new Set([".ts", ".tsx", ".mts", ".cts", ".jsx"]);
160
160
  export const DATA_EXTS = { ".jsonc": "jsonc", ".json5": "json5", ".toml": "toml", ".yaml": "yaml", ".yml": "yaml", ".txt": "txt" };
161
161
  export const TS_PARENT_EXTS = new Set([".ts", ".tsx", ".mts", ".cts"]);
162
162
 
163
- // Reserved words / literals that cannot be a lexical binding name in a module
164
- // (modules are strict mode). A data file with a top-level key like `package`
165
- // (e.g. a Cargo.toml `[package]` table) must NOT emit `export const package = …`
166
- // — that is a SyntaxError that takes down the whole module, default export
167
- // included. Such keys stay reachable via the default export. Matches bun, which
168
- // deoptimizes invalid-identifier keys rather than failing the whole module.
169
- const RESERVED_EXPORT_NAMES = new Set([
170
- "break", "case", "catch", "class", "const", "continue", "debugger", "default",
171
- "delete", "do", "else", "enum", "export", "extends", "false", "finally", "for",
172
- "function", "if", "import", "in", "instanceof", "new", "null", "return", "super",
173
- "switch", "this", "throw", "true", "try", "typeof", "var", "void", "while", "with",
174
- // Strict-mode (modules are always strict) future-reserved + restricted names:
175
- "implements", "interface", "let", "package", "private", "protected", "public",
176
- "static", "yield", "await", "eval", "arguments",
177
- ]);
178
-
179
163
  // Packages resolved from Nub's distribution, not the user's.
180
164
  export const VENDORED_PACKAGES = new Set(["@oxc-project/runtime"]);
181
165
 
@@ -689,15 +673,12 @@ export function loadData(url, ext) {
689
673
  return { format: "module", source: "export default undefined;\n", shortCircuit: true };
690
674
  }
691
675
 
692
- let code = `const _data = ${JSON.stringify(parsed)};\nexport default _data;\n`;
693
- if (typeof parsed === "object" && !Array.isArray(parsed)) {
694
- for (const key of Object.keys(parsed)) {
695
- // Emit a named export only for keys that are valid, non-reserved binding
696
- // identifiers; everything else remains reachable via the default export.
697
- if (/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(key) && !RESERVED_EXPORT_NAMES.has(key)) {
698
- code += `export const ${key} = _data[${JSON.stringify(key)}];\n`;
699
- }
700
- }
701
- }
676
+ // Default export only. Data modules deliberately do NOT emit per-key named
677
+ // exports: named imports of data are categorically un-typeable in TypeScript
678
+ // (a `declare module "*.yaml"` wildcard has no per-key export index signature),
679
+ // and default-only matches Node's own JSON modules. Consumers destructure the
680
+ // default — `import cfg from "./c.yaml"; const { host } = cfg;` which the
681
+ // `@nubjs/types` `Record<string, unknown>` default type makes sound.
682
+ const code = `export default ${JSON.stringify(parsed)};\n`;
702
683
  return { format: "module", source: code, shortCircuit: true };
703
684
  }
@@ -9,4 +9,4 @@
9
9
  // previously lived as a literal inside preload.mjs, which `make version` patched,
10
10
  // while the worker carried a hand-maintained "…-compat" copy that `make version`
11
11
  // never touched — a latent staleness bug this module closes.)
12
- export const NUB_VERSION = "0.0.44";
12
+ export const NUB_VERSION = "0.0.45";