@nubjs/nub-win32-arm64 0.0.12 → 0.0.14

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/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "@nubjs/nub-win32-arm64",
3
- "version": "0.0.12",
3
+ "version": "0.0.14",
4
4
  "description": "Nub binary for win32-arm64",
5
5
  "license": "MIT",
6
- "repository": "https://github.com/colinhacks/nub",
6
+ "repository": "https://github.com/nub-js/nub",
7
7
  "os": [
8
8
  "win32"
9
9
  ],
Binary file
@@ -0,0 +1,21 @@
1
+ // R8 early step for the compat tier (--import preload.mjs). Restores
2
+ // NODE_COMPILE_CACHE into process.env as a SIDE EFFECT, and must be the FIRST
3
+ // import in preload.mjs so it runs before transform-core.mjs's module body — which
4
+ // reads `NODE_COMPILE_CACHE === "0"` as nub's transpile-cache disable signal.
5
+ //
6
+ // Why a separate module instead of a statement in preload.mjs: ESM `import`s are
7
+ // hoisted and their module bodies evaluate in source order BEFORE any statement in
8
+ // the importer. transform-core.mjs is imported in preload.mjs, so the only way to
9
+ // mutate process.env ahead of transform-core's evaluation is from a module imported
10
+ // earlier in source order. The fast tier (preload.cjs, CommonJS) has no such
11
+ // hoisting and calls common.restoreCompileCacheEnv() directly instead.
12
+ //
13
+ // spawn.rs strips NODE_COMPILE_CACHE from the child env (so Node's V8 compile cache
14
+ // never caches nub's preload chain) and stashes the original value in a PID-keyed
15
+ // sentinel file; here we read + delete it and put it back. Restoring it in JS does
16
+ // not re-enable Node's bootstrap compile cache. See preload-common.cjs
17
+ // (restoreCompileCacheEnv) for the full mechanism — this file just calls it.
18
+ import { createRequire } from "node:module";
19
+
20
+ const require_ = createRequire(import.meta.url);
21
+ require_("./preload-common.cjs").restoreCompileCacheEnv();
@@ -0,0 +1,178 @@
1
+ // Polyfill preloads for Nub v0.1 — the shared implementation for BOTH tiers.
2
+ //
3
+ // This is a CommonJS module with ZERO top-level await so the fast tier
4
+ // (Node 22.15+, `--require` CJS preload) can `require()` it synchronously: a
5
+ // `require()`-loaded preload keeps Node's synchronous `Module.runMain` CJS entry
6
+ // path (top-level `executionAsyncId()===1`, sync exception origin), which the old
7
+ // `--import` ESM preload broke (R1). The compat tier (`--import` preload.mjs)
8
+ // reuses this same logic via the `installSyncPolyfills` export, then loads the two
9
+ // ESM side-effect modules (worker-polyfill, navigator-locks) with dynamic
10
+ // `import()` — on the < 22.15 floor `require()` of an ES module is unreliable.
11
+ //
12
+ // All polyfills feature-detect and bow out if the global is already present.
13
+ //
14
+ // Node 22.15+ (our floor) already has: navigator, navigator.locks,
15
+ // navigator.hardwareConcurrency, WebSocket. No polyfills needed.
16
+ //
17
+ // Node 24+ adds: URLPattern, RegExp.escape, Error.isError, Promise.try.
18
+ // We polyfill those on Node 22.x only.
19
+ //
20
+ // No Node version ships: Temporal, reportError, browser-shape Worker.
21
+ // These need polyfills on all supported versions. (Temporal is a lazy global
22
+ // installed by the preload entry, NOT here — see preload.cjs / preload.mjs.)
23
+
24
+ const { createRequire } = require("node:module");
25
+ const __require = createRequire(__filename);
26
+
27
+ // Install every globalThis/prototype polyfill that doesn't depend on loading the
28
+ // ESM side-effect modules (worker-polyfill, navigator-locks). Synchronous and
29
+ // idempotent — safe to call once per realm. `preloaded` carries the CJS-required
30
+ // polyfill packages the preload entry stashed (urlpattern, float16), since the
31
+ // resolve hook would otherwise clobber a later import of them.
32
+ function installSyncPolyfills(preloaded) {
33
+ preloaded = preloaded || {};
34
+
35
+ // ── reportError (WinterTC min-common-API, not in any Node) ──────────
36
+ // Defined NON-ENUMERABLE so it is invisible to `Object.keys(globalThis)` /
37
+ // for-in / structured-clone-of-keys — that invisibility-to-enumeration IS the
38
+ // additive contract: code written for vanilla Node must not observe nub's
39
+ // injected globals when it enumerates the global object. Node defines its own
40
+ // globals non-enumerably for the same reason. Kept writable+configurable so
41
+ // user code can still override or delete it, matching Node's global descriptors.
42
+ if (typeof globalThis.reportError !== "function") {
43
+ Object.defineProperty(globalThis, "reportError", {
44
+ value: (err) => {
45
+ queueMicrotask(() => {
46
+ throw err;
47
+ });
48
+ },
49
+ enumerable: false,
50
+ writable: true,
51
+ configurable: true,
52
+ });
53
+ }
54
+
55
+ // ── URLPattern (native on Node 24+, missing on 22.x) ───────────────
56
+ if (typeof globalThis.URLPattern === "undefined") {
57
+ const mod = preloaded.urlpattern;
58
+ const URLPattern = mod?.URLPattern;
59
+ if (URLPattern) globalThis.URLPattern = URLPattern;
60
+ }
61
+
62
+ // Temporal (in no Node version) is installed as a LAZY global by the preload
63
+ // entry after this runs — see preload.cjs / preload.mjs (A37). Touching
64
+ // globalThis.Temporal here would defeat that laziness, so we must not.
65
+
66
+ // ── Stage 4 polyfills (native on Node 24+, missing on 22.x) ────────
67
+
68
+ // RegExp.escape — spec-faithful port of the TC39 proposal (native on Node 24+),
69
+ // so the 22.x floor behaves byte-for-byte like native: a leading digit/letter is
70
+ // control-escaped, syntax chars are backslashed, control chars use \t\n\v\f\r, and
71
+ // the "other punctuators" + whitespace set is hex-escaped. Verified byte-identical
72
+ // to Node's native RegExp.escape across every ASCII char + leading/whitespace/
73
+ // astral cases (so a concatenated `escape(s)` is safe too, not just
74
+ // `new RegExp(escape(s))`). The earlier reduced-fidelity version only escaped the
75
+ // syntax chars.
76
+ if (typeof RegExp.escape !== "function") {
77
+ const SYNTAX = new Set(["^", "$", "\\", ".", "*", "+", "?", "(", ")", "[", "]", "{", "}", "|", "/"]);
78
+ const CONTROL = { "\t": "\\t", "\n": "\\n", "\v": "\\v", "\f": "\\f", "\r": "\\r" };
79
+ // ASCII "other punctuators" the spec escapes by code, plus SPACE.
80
+ const OTHER = new Set([..." ,-=<>#&!%:;@~'\"`"]);
81
+ const isWhiteSpace = (cp) =>
82
+ cp === 0x09 || cp === 0x0a || cp === 0x0b || cp === 0x0c || cp === 0x0d ||
83
+ cp === 0x20 || cp === 0xa0 || cp === 0x1680 || (cp >= 0x2000 && cp <= 0x200a) ||
84
+ cp === 0x2028 || cp === 0x2029 || cp === 0x202f || cp === 0x205f || cp === 0x3000 ||
85
+ cp === 0xfeff;
86
+ const hexEscape = (cp) => {
87
+ if (cp <= 0xff) return "\\x" + cp.toString(16).padStart(2, "0");
88
+ if (cp <= 0xffff) return "\\u" + cp.toString(16).padStart(4, "0");
89
+ const h = cp - 0x10000;
90
+ const hi = 0xd800 + (h >> 10);
91
+ const lo = 0xdc00 + (h & 0x3ff);
92
+ return "\\u" + hi.toString(16).padStart(4, "0") + "\\u" + lo.toString(16).padStart(4, "0");
93
+ };
94
+ const encode = (ch, cp) =>
95
+ SYNTAX.has(ch)
96
+ ? "\\" + ch
97
+ : CONTROL[ch] ?? ((OTHER.has(ch) || isWhiteSpace(cp)) ? hexEscape(cp) : ch);
98
+ RegExp.escape = (s) => {
99
+ if (typeof s !== "string") throw new TypeError("RegExp.escape argument must be a string");
100
+ const cps = [...s]; // iterate by code point (astral-safe)
101
+ let out = "";
102
+ for (let i = 0; i < cps.length; i++) {
103
+ const ch = cps[i];
104
+ const cp = ch.codePointAt(0);
105
+ // A leading decimal-digit/ASCII-letter is control-escaped so a preceding `\`
106
+ // in a concatenated pattern can't form an escape sequence.
107
+ if (i === 0 && ((cp >= 0x30 && cp <= 0x39) || (cp >= 0x41 && cp <= 0x5a) || (cp >= 0x61 && cp <= 0x7a))) {
108
+ out += "\\x" + cp.toString(16).padStart(2, "0");
109
+ } else {
110
+ out += encode(ch, cp);
111
+ }
112
+ }
113
+ return out;
114
+ };
115
+ }
116
+
117
+ // Error.isError (~95% fidelity — cross-realm internal-slot unreachable)
118
+ if (typeof Error.isError !== "function") {
119
+ Error.isError = (value) => {
120
+ if (value == null || typeof value !== "object") return false;
121
+ return value instanceof Error;
122
+ };
123
+ }
124
+
125
+ // Promise.try
126
+ if (typeof Promise.try !== "function") {
127
+ Promise.try = (fn, ...args) => {
128
+ return new Promise((resolve) => resolve(fn(...args)));
129
+ };
130
+ }
131
+
132
+ // Float16Array (TC39 Stage 4, native on Node 24+; absent on our 22.x floor).
133
+ // Installed from the spec-compliant @petamoriken/float16 polyfill (vendored,
134
+ // preloaded by the preload entry). It provides the full TypedArray method
135
+ // surface (map/filter/subarray/set/reduce/…) and correct round-to-nearest-even,
136
+ // including subnormals — unlike the prior hand-rolled Proxy shim, which had
137
+ // ~30 methods missing and truncating/denormal-flushing conversion.
138
+ //
139
+ // INHERENT userland limitation (not fixable by any JS polyfill): a polyfilled
140
+ // Float16Array isn't recognized by `ArrayBuffer.isView()` (it has no V8 internal
141
+ // [[TypedArrayName]] slot). Code needing that check should use the polyfill's
142
+ // `isFloat16Array`. See wiki/runtime/float16array-polyfill.md.
143
+ if (typeof globalThis.Float16Array === "undefined") {
144
+ const f16 = preloaded.float16;
145
+ if (f16?.Float16Array) {
146
+ globalThis.Float16Array = f16.Float16Array;
147
+
148
+ if (typeof DataView.prototype.getFloat16 !== "function") {
149
+ DataView.prototype.getFloat16 = function (offset, littleEndian) {
150
+ return f16.getFloat16(this, offset, littleEndian);
151
+ };
152
+ DataView.prototype.setFloat16 = function (offset, value, littleEndian) {
153
+ f16.setFloat16(this, offset, value, littleEndian);
154
+ };
155
+ }
156
+
157
+ if (typeof Math.f16round !== "function") {
158
+ Math.f16round = f16.f16round;
159
+ }
160
+ }
161
+ }
162
+ }
163
+
164
+ // Load the two ESM side-effect modules — Web Locks (navigator.locks) and the
165
+ // browser-shape Worker global — synchronously via `require()`. Valid on the fast
166
+ // tier ONLY (Node 22.15+), where require(esm) of these side-effecting ES modules
167
+ // works (verified). The compat tier must NOT call this; it loads them with
168
+ // dynamic `import()` from preload.mjs instead.
169
+ function installEsmPolyfillsSync() {
170
+ // ── navigator.locks (native on Node 24+, missing on 22.x) ──────────
171
+ if (typeof globalThis.navigator?.locks === "undefined") {
172
+ __require("./navigator-locks.mjs");
173
+ }
174
+ // ── Worker (browser-shape global, not in any Node) ──────────────────
175
+ __require("./worker-polyfill.mjs");
176
+ }
177
+
178
+ module.exports = { installSyncPolyfills, installEsmPolyfillsSync };