@nubjs/nub-linux-x64-musl 0.0.4 → 0.0.7

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.
Files changed (37) hide show
  1. package/bin/nub +0 -0
  2. package/package.json +1 -1
  3. package/runtime/addons/nub-native.node +0 -0
  4. package/runtime/cache-evict.mjs +69 -0
  5. package/runtime/node_modules/@oxc-parser/binding-linux-x64-musl/README.md +3 -0
  6. package/runtime/node_modules/@oxc-parser/binding-linux-x64-musl/package.json +42 -0
  7. package/runtime/node_modules/@oxc-parser/binding-linux-x64-musl/parser.linux-x64-musl.node +0 -0
  8. package/runtime/node_modules/@oxc-transform/binding-linux-x64-musl/README.md +3 -0
  9. package/runtime/node_modules/@oxc-transform/binding-linux-x64-musl/package.json +44 -0
  10. package/runtime/node_modules/@oxc-transform/binding-linux-x64-musl/transform.linux-x64-musl.node +0 -0
  11. package/runtime/polyfills.mjs +73 -97
  12. package/runtime/preload-async-hooks.mjs +50 -0
  13. package/runtime/preload.mjs +274 -320
  14. package/runtime/transform-core.mjs +762 -0
  15. package/runtime/version.mjs +12 -0
  16. package/runtime/worker-polyfill.mjs +147 -9
  17. package/runtime/node_modules/get-tsconfig/LICENSE +0 -21
  18. package/runtime/node_modules/get-tsconfig/README.md +0 -268
  19. package/runtime/node_modules/get-tsconfig/dist/index.cjs +0 -7
  20. package/runtime/node_modules/get-tsconfig/dist/index.d.cts +0 -2116
  21. package/runtime/node_modules/get-tsconfig/dist/index.d.mts +0 -2116
  22. package/runtime/node_modules/get-tsconfig/dist/index.mjs +0 -7
  23. package/runtime/node_modules/get-tsconfig/package.json +0 -46
  24. package/runtime/node_modules/oxc-transform/LICENSE +0 -22
  25. package/runtime/node_modules/oxc-transform/README.md +0 -84
  26. package/runtime/node_modules/oxc-transform/browser.js +0 -1
  27. package/runtime/node_modules/oxc-transform/index.d.ts +0 -658
  28. package/runtime/node_modules/oxc-transform/index.js +0 -598
  29. package/runtime/node_modules/oxc-transform/package.json +0 -114
  30. package/runtime/node_modules/oxc-transform/webcontainer-fallback.cjs +0 -21
  31. package/runtime/node_modules/resolve-pkg-maps/LICENSE +0 -21
  32. package/runtime/node_modules/resolve-pkg-maps/README.md +0 -216
  33. package/runtime/node_modules/resolve-pkg-maps/dist/index.cjs +0 -1
  34. package/runtime/node_modules/resolve-pkg-maps/dist/index.d.cts +0 -11
  35. package/runtime/node_modules/resolve-pkg-maps/dist/index.d.mts +0 -11
  36. package/runtime/node_modules/resolve-pkg-maps/dist/index.mjs +0 -1
  37. package/runtime/node_modules/resolve-pkg-maps/package.json +0 -42
package/bin/nub CHANGED
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nubjs/nub-linux-x64-musl",
3
- "version": "0.0.4",
3
+ "version": "0.0.7",
4
4
  "description": "Nub binary for linux-x64-musl",
5
5
  "license": "MIT",
6
6
  "repository": "https://github.com/colinhacks/nub",
Binary file
@@ -0,0 +1,69 @@
1
+ // Bounded-size eviction for the transpile cache (A16). Kept in its own module
2
+ // so it loads lazily — only when a sweep is actually due (see preload.mjs's
3
+ // throttled maybeSweepCache) — and so it can be tested in isolation.
4
+ //
5
+ // LRU by mtime: when the cache exceeds `maxBytes`, delete oldest-written entries
6
+ // until at or below `lowWater`. Entries are content-addressed, so evicting one
7
+ // only costs a re-transpile on next use. mtime reflects write time, not last
8
+ // read — true read-LRU would need an mtime touch on every cache hit, defeating
9
+ // the read-only fast path; oldest-written is the right, cheap proxy for a cache
10
+ // whose entries are written once per source version.
11
+
12
+ import { readdirSync, statSync, unlinkSync } from "node:fs";
13
+ import { join } from "node:path";
14
+
15
+ // A valid cache entry is a 64-char lowercase-hex sha256 (see cacheKey in
16
+ // preload.mjs). Everything else — the `.sweep` sentinel, `*.tmp` in-flight
17
+ // writes from cacheSet — is skipped: never counted toward the cap, never
18
+ // evicted.
19
+ const ENTRY_RE = /^[0-9a-f]{64}$/;
20
+
21
+ /**
22
+ * Evict oldest entries from `dir` until total entry bytes ≤ `lowWater`, if they
23
+ * exceed `maxBytes`. Returns `{ scanned, deleted, freed }`. Best-effort: a stat
24
+ * or unlink that fails (concurrent reader/evictor, Windows open handle) is
25
+ * skipped, and the next sweep retries. Never throws.
26
+ */
27
+ export function sweepCache(dir, maxBytes, lowWater = Math.floor(maxBytes * 0.75)) {
28
+ let names;
29
+ try {
30
+ names = readdirSync(dir);
31
+ } catch {
32
+ return { scanned: 0, deleted: 0, freed: 0 };
33
+ }
34
+
35
+ const entries = [];
36
+ let total = 0;
37
+ for (const name of names) {
38
+ if (!ENTRY_RE.test(name)) continue;
39
+ const path = join(dir, name);
40
+ const s = statSync(path, { throwIfNoEntry: false });
41
+ if (!s || !s.isFile()) continue;
42
+ entries.push({ path, size: s.size, mtime: s.mtimeMs });
43
+ total += s.size;
44
+ }
45
+
46
+ if (total <= maxBytes) {
47
+ return { scanned: entries.length, deleted: 0, freed: 0 };
48
+ }
49
+
50
+ // Oldest first; delete down to the low-water mark so we don't sweep again on
51
+ // the very next write.
52
+ entries.sort((a, b) => a.mtime - b.mtime);
53
+ let deleted = 0;
54
+ let freed = 0;
55
+ for (const e of entries) {
56
+ if (total <= lowWater) break;
57
+ try {
58
+ unlinkSync(e.path);
59
+ total -= e.size;
60
+ freed += e.size;
61
+ deleted++;
62
+ } catch {
63
+ // Already removed by a concurrent sweep, or held open (Windows): skip.
64
+ // `total` is unchanged so we keep trying to reach lowWater via other
65
+ // entries; the loop is bounded by `entries`, so it still terminates.
66
+ }
67
+ }
68
+ return { scanned: entries.length, deleted, freed };
69
+ }
@@ -0,0 +1,3 @@
1
+ # `@oxc-parser/binding-linux-x64-musl`
2
+
3
+ This is the **x86_64-unknown-linux-musl** binary for `@oxc-parser/binding`
@@ -0,0 +1,42 @@
1
+ {
2
+ "name": "@oxc-parser/binding-linux-x64-musl",
3
+ "version": "0.132.0",
4
+ "cpu": [
5
+ "x64"
6
+ ],
7
+ "main": "parser.linux-x64-musl.node",
8
+ "files": [
9
+ "parser.linux-x64-musl.node"
10
+ ],
11
+ "description": "Oxc Parser Node API",
12
+ "keywords": [
13
+ "ast",
14
+ "estree",
15
+ "javascript",
16
+ "oxc",
17
+ "parser",
18
+ "typescript"
19
+ ],
20
+ "author": "Boshen and oxc contributors",
21
+ "homepage": "https://oxc.rs/docs/guide/usage/parser",
22
+ "license": "MIT",
23
+ "engines": {
24
+ "node": "^20.19.0 || >=22.12.0"
25
+ },
26
+ "repository": {
27
+ "type": "git",
28
+ "url": "git+https://github.com/oxc-project/oxc.git",
29
+ "directory": "napi/parser"
30
+ },
31
+ "bugs": "https://github.com/oxc-project/oxc/issues",
32
+ "publishConfig": {
33
+ "registry": "https://registry.npmjs.org/",
34
+ "access": "public"
35
+ },
36
+ "os": [
37
+ "linux"
38
+ ],
39
+ "libc": [
40
+ "musl"
41
+ ]
42
+ }
@@ -0,0 +1,3 @@
1
+ # `@oxc-transform/binding-linux-x64-musl`
2
+
3
+ This is the **x86_64-unknown-linux-musl** binary for `@oxc-transform/binding`
@@ -0,0 +1,44 @@
1
+ {
2
+ "name": "@oxc-transform/binding-linux-x64-musl",
3
+ "version": "0.132.0",
4
+ "cpu": [
5
+ "x64"
6
+ ],
7
+ "main": "transform.linux-x64-musl.node",
8
+ "files": [
9
+ "transform.linux-x64-musl.node"
10
+ ],
11
+ "description": "Oxc Transformer Node API",
12
+ "keywords": [
13
+ "babel",
14
+ "javascript",
15
+ "jsx",
16
+ "oxc",
17
+ "transform",
18
+ "transformer",
19
+ "tsx",
20
+ "typescript"
21
+ ],
22
+ "author": "Boshen and oxc contributors",
23
+ "homepage": "https://oxc.rs/docs/guide/usage/transformer",
24
+ "license": "MIT",
25
+ "engines": {
26
+ "node": "^20.19.0 || >=22.12.0"
27
+ },
28
+ "repository": {
29
+ "type": "git",
30
+ "url": "git+https://github.com/oxc-project/oxc.git",
31
+ "directory": "napi/transform"
32
+ },
33
+ "bugs": "https://github.com/oxc-project/oxc/issues",
34
+ "publishConfig": {
35
+ "registry": "https://registry.npmjs.org/",
36
+ "access": "public"
37
+ },
38
+ "os": [
39
+ "linux"
40
+ ],
41
+ "libc": [
42
+ "musl"
43
+ ]
44
+ }
@@ -26,19 +26,59 @@ if (typeof globalThis.URLPattern === "undefined") {
26
26
  if (URLPattern) globalThis.URLPattern = URLPattern;
27
27
  }
28
28
 
29
- // ── Temporal (not in any Node version) ──────────────────────────────
30
- if (typeof globalThis.Temporal === "undefined") {
31
- const mod = globalThis.__nubPreloaded?.temporal;
32
- const Temporal = mod?.Temporal;
33
- if (Temporal) globalThis.Temporal = Temporal;
34
- }
29
+ // Temporal (in no Node version) is installed as a LAZY global by the main
30
+ // preload after this module runs — see preload.mjs (A37). Touching
31
+ // globalThis.Temporal here would defeat that laziness, so we must not.
35
32
 
36
33
  // ── Stage 4 polyfills (native on Node 24+, missing on 22.x) ────────
37
34
 
38
- // RegExp.escape
35
+ // RegExp.escape — spec-faithful port of the TC39 proposal (native on Node 24+),
36
+ // so the 22.x floor behaves byte-for-byte like native: a leading digit/letter is
37
+ // control-escaped, syntax chars are backslashed, control chars use \t\n\v\f\r, and
38
+ // the "other punctuators" + whitespace set is hex-escaped. Verified byte-identical
39
+ // to Node's native RegExp.escape across every ASCII char + leading/whitespace/
40
+ // astral cases (so a concatenated `escape(s)` is safe too, not just
41
+ // `new RegExp(escape(s))`). The earlier reduced-fidelity version only escaped the
42
+ // syntax chars.
39
43
  if (typeof RegExp.escape !== "function") {
40
- const escapeRe = /[\\^$.*+?()[\]{}|]/g;
41
- RegExp.escape = (s) => String(s).replace(escapeRe, "\\$&");
44
+ const SYNTAX = new Set(["^", "$", "\\", ".", "*", "+", "?", "(", ")", "[", "]", "{", "}", "|", "/"]);
45
+ const CONTROL = { "\t": "\\t", "\n": "\\n", "\v": "\\v", "\f": "\\f", "\r": "\\r" };
46
+ // ASCII "other punctuators" the spec escapes by code, plus SPACE.
47
+ const OTHER = new Set([..." ,-=<>#&!%:;@~'\"`"]);
48
+ const isWhiteSpace = (cp) =>
49
+ cp === 0x09 || cp === 0x0a || cp === 0x0b || cp === 0x0c || cp === 0x0d ||
50
+ cp === 0x20 || cp === 0xa0 || cp === 0x1680 || (cp >= 0x2000 && cp <= 0x200a) ||
51
+ cp === 0x2028 || cp === 0x2029 || cp === 0x202f || cp === 0x205f || cp === 0x3000 ||
52
+ cp === 0xfeff;
53
+ const hexEscape = (cp) => {
54
+ if (cp <= 0xff) return "\\x" + cp.toString(16).padStart(2, "0");
55
+ if (cp <= 0xffff) return "\\u" + cp.toString(16).padStart(4, "0");
56
+ const h = cp - 0x10000;
57
+ const hi = 0xd800 + (h >> 10);
58
+ const lo = 0xdc00 + (h & 0x3ff);
59
+ return "\\u" + hi.toString(16).padStart(4, "0") + "\\u" + lo.toString(16).padStart(4, "0");
60
+ };
61
+ const encode = (ch, cp) =>
62
+ SYNTAX.has(ch)
63
+ ? "\\" + ch
64
+ : CONTROL[ch] ?? ((OTHER.has(ch) || isWhiteSpace(cp)) ? hexEscape(cp) : ch);
65
+ RegExp.escape = (s) => {
66
+ if (typeof s !== "string") throw new TypeError("RegExp.escape argument must be a string");
67
+ const cps = [...s]; // iterate by code point (astral-safe)
68
+ let out = "";
69
+ for (let i = 0; i < cps.length; i++) {
70
+ const ch = cps[i];
71
+ const cp = ch.codePointAt(0);
72
+ // A leading decimal-digit/ASCII-letter is control-escaped so a preceding `\`
73
+ // in a concatenated pattern can't form an escape sequence.
74
+ if (i === 0 && ((cp >= 0x30 && cp <= 0x39) || (cp >= 0x41 && cp <= 0x5a) || (cp >= 0x61 && cp <= 0x7a))) {
75
+ out += "\\x" + cp.toString(16).padStart(2, "0");
76
+ } else {
77
+ out += encode(ch, cp);
78
+ }
79
+ }
80
+ return out;
81
+ };
42
82
  }
43
83
 
44
84
  // Error.isError (~95% fidelity — cross-realm internal-slot unreachable)
@@ -56,98 +96,34 @@ if (typeof Promise.try !== "function") {
56
96
  };
57
97
  }
58
98
 
59
- // Float16Array (TC39 Stage 4, native on Node 24+)
60
- // Partial TypedArray integration: instanceof TypedArray works via
61
- // prototype chain setup, but ArrayBuffer.isView() returns false
62
- // (requires V8 internal slots we can't set from userland).
99
+ // Float16Array (TC39 Stage 4, native on Node 24+; absent on our 22.x floor).
100
+ // Installed from the spec-compliant @petamoriken/float16 polyfill (vendored,
101
+ // preloaded by preload.mjs). It provides the full TypedArray method surface
102
+ // (map/filter/subarray/set/reduce/…) and correct round-to-nearest-even,
103
+ // including subnormals — unlike the prior hand-rolled Proxy shim, which had
104
+ // ~30 methods missing and truncating/denormal-flushing conversion.
105
+ //
106
+ // INHERENT userland limitation (not fixable by any JS polyfill): a polyfilled
107
+ // Float16Array isn't recognized by `ArrayBuffer.isView()` (it has no V8 internal
108
+ // [[TypedArrayName]] slot). Code needing that check should use the polyfill's
109
+ // `isFloat16Array`. See wiki/runtime/float16array-polyfill.md.
63
110
  if (typeof globalThis.Float16Array === "undefined") {
64
- const TypedArray = Object.getPrototypeOf(Uint8Array);
65
- const buf = new ArrayBuffer(2);
66
- const f32 = new Float32Array(1);
67
- const u32 = new Uint32Array(f32.buffer);
68
- const u16view = new Uint16Array(buf);
69
-
70
- function f32ToF16(val) {
71
- f32[0] = val;
72
- const bits = u32[0];
73
- const sign = (bits >> 16) & 0x8000;
74
- const exp = ((bits >> 23) & 0xff) - 127 + 15;
75
- const frac = (bits >> 13) & 0x3ff;
76
- if (exp <= 0) return sign;
77
- if (exp >= 31) return sign | 0x7c00 | (frac ? 1 : 0);
78
- return sign | (exp << 10) | frac;
79
- }
80
-
81
- function f16ToF32(h) {
82
- const sign = (h & 0x8000) >> 15;
83
- const exp = (h & 0x7c00) >> 10;
84
- const frac = h & 0x03ff;
85
- if (exp === 0) {
86
- if (frac === 0) return sign ? -0 : 0;
87
- let e = -1;
88
- let f = frac;
89
- while ((f & 0x400) === 0) { f <<= 1; e--; }
90
- f &= 0x3ff;
91
- u32[0] = (sign << 31) | ((e + 127) << 23) | (f << 13);
92
- return f32[0];
111
+ const f16 = globalThis.__nubPreloaded?.float16;
112
+ if (f16?.Float16Array) {
113
+ globalThis.Float16Array = f16.Float16Array;
114
+
115
+ if (typeof DataView.prototype.getFloat16 !== "function") {
116
+ DataView.prototype.getFloat16 = function (offset, littleEndian) {
117
+ return f16.getFloat16(this, offset, littleEndian);
118
+ };
119
+ DataView.prototype.setFloat16 = function (offset, value, littleEndian) {
120
+ f16.setFloat16(this, offset, value, littleEndian);
121
+ };
93
122
  }
94
- if (exp === 31) {
95
- return frac ? NaN : (sign ? -Infinity : Infinity);
96
- }
97
- u32[0] = (sign << 31) | ((exp - 15 + 127) << 23) | (frac << 13);
98
- return f32[0];
99
- }
100
123
 
101
- class Float16Array {
102
- #data;
103
- constructor(arg) {
104
- if (typeof arg === "number") {
105
- this.#data = new Uint16Array(arg);
106
- } else if (arg instanceof ArrayBuffer || arg instanceof SharedArrayBuffer) {
107
- this.#data = new Uint16Array(arg);
108
- } else if (ArrayBuffer.isView(arg) || Array.isArray(arg)) {
109
- this.#data = new Uint16Array(arg.length);
110
- for (let i = 0; i < arg.length; i++) this.#data[i] = f32ToF16(Number(arg[i]));
111
- } else {
112
- this.#data = new Uint16Array(0);
113
- }
114
- this.length = this.#data.length;
115
- this.byteLength = this.#data.byteLength;
116
- this.byteOffset = this.#data.byteOffset;
117
- this.buffer = this.#data.buffer;
118
- this.BYTES_PER_ELEMENT = 2;
119
- return new Proxy(this, {
120
- get(target, prop) {
121
- if (typeof prop === "string" && /^\d+$/.test(prop)) return f16ToF32(target.#data[prop]);
122
- return Reflect.get(target, prop);
123
- },
124
- set(target, prop, value) {
125
- if (typeof prop === "string" && /^\d+$/.test(prop)) { target.#data[prop] = f32ToF16(Number(value)); return true; }
126
- return Reflect.set(target, prop, value);
127
- },
128
- });
124
+ if (typeof Math.f16round !== "function") {
125
+ Math.f16round = f16.f16round;
129
126
  }
130
- [Symbol.iterator]() { let i = 0; const d = this.#data; return { next: () => i < d.length ? { value: f16ToF32(d[i++]), done: false } : { done: true } }; }
131
- static get BYTES_PER_ELEMENT() { return 2; }
132
- }
133
-
134
- // Set up prototype chain so `instanceof TypedArray` works.
135
- Object.setPrototypeOf(Float16Array.prototype, TypedArray.prototype);
136
- Object.setPrototypeOf(Float16Array, TypedArray);
137
-
138
- globalThis.Float16Array = Float16Array;
139
-
140
- if (typeof DataView.prototype.getFloat16 !== "function") {
141
- DataView.prototype.getFloat16 = function (offset, le) {
142
- return f16ToF32(this.getUint16(offset, le));
143
- };
144
- DataView.prototype.setFloat16 = function (offset, value, le) {
145
- this.setUint16(offset, f32ToF16(value), le);
146
- };
147
- }
148
-
149
- if (typeof Math.f16round !== "function") {
150
- Math.f16round = (x) => f16ToF32(f32ToF16(x));
151
127
  }
152
128
  }
153
129
 
@@ -0,0 +1,50 @@
1
+ // Nub compat-tier hooks module — Node 18.19 through 22.14.
2
+ //
3
+ // On Node 22.15+, runtime/preload.mjs registers its hooks synchronously via
4
+ // `module.registerHooks({ resolve, load })`. That API didn't exist before 22.15,
5
+ // so on 18.19..22.14 the main-thread bootstrap calls
6
+ // `module.register('./preload-async-hooks.mjs', parentURL)` instead, which loads
7
+ // THIS file into a dedicated loader worker thread and uses its async
8
+ // `resolve` / `load` exports. (CommonJS `require()` is augmented separately, on
9
+ // the main thread, by preload.mjs's installCjsRequireHooks — `module.register`
10
+ // hooks the ESM loader only.)
11
+ //
12
+ // There is NO logic of its own here: resolution + transpilation come verbatim
13
+ // from runtime/transform-core.mjs, the single source of truth shared with the
14
+ // fast path. The two tiers can no longer drift — the only difference is the
15
+ // async function signatures Node's loader-worker protocol requires (it awaits
16
+ // the returned values, so returning the core's synchronous results is fine). The
17
+ // worker injects no watch hooks (watch IPC is main-thread only), so the core's
18
+ // dependency reporters stay no-ops here, exactly as before the extraction.
19
+
20
+ import {
21
+ TRANSPILE_EXTS, DATA_EXTS,
22
+ extname, resolveSpec, loadTranspile, loadData, ensureParser,
23
+ } from "./transform-core.mjs";
24
+
25
+ // Node calls this once per worker when the main thread invokes
26
+ // `module.register(url, parentURL, { data })`. We accept and ignore the payload
27
+ // so future main-thread → worker plumbing is non-breaking. Returning a Promise
28
+ // lets the main thread `await register(...)`.
29
+ export async function initialize(_data) {}
30
+
31
+ // ── Resolve hook ────────────────────────────────────────────────────
32
+ export async function resolve(specifier, context, nextResolve) {
33
+ const r = resolveSpec(specifier, context.parentURL);
34
+ return r ?? nextResolve(specifier, context);
35
+ }
36
+
37
+ // ── Load hook ───────────────────────────────────────────────────────
38
+ export async function load(url, context, nextLoad) {
39
+ const ext = extname(url);
40
+ if (TRANSPILE_EXTS.has(ext)) {
41
+ // Ensure oxc-parser is loaded (via dynamic import — `require` of this
42
+ // ESM-only package fails below require(esm) on Node 18.19 / 20.x). The async
43
+ // load hook can await; the synchronous module-format + decorator detection
44
+ // inside loadTranspile then has the parser.
45
+ await ensureParser();
46
+ return loadTranspile(url, ext);
47
+ }
48
+ if (ext in DATA_EXTS) return loadData(url, ext);
49
+ return nextLoad(url, context);
50
+ }