@nubjs/nub-linux-arm64 0.0.33 → 0.0.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/bin/nub +0 -0
- package/bin/nubx +0 -0
- package/package.json +1 -1
- package/runtime/addons/nub-native.node +0 -0
- package/runtime/preload-common.cjs +47 -0
- package/runtime/version.mjs +1 -1
package/bin/nub
CHANGED
|
Binary file
|
package/bin/nubx
CHANGED
|
Binary file
|
package/package.json
CHANGED
|
Binary file
|
|
@@ -20,6 +20,29 @@ const { readdirSync } = require("node:fs");
|
|
|
20
20
|
const { fileURLToPath, pathToFileURL } = require("node:url");
|
|
21
21
|
const { join, dirname, extname: pathExtname } = require("node:path");
|
|
22
22
|
|
|
23
|
+
// ── data: URL unknown-format fidelity helpers ───────────────────────
|
|
24
|
+
// Mirror Node's internal/modules/esm/get_format.js so nub's sync registerHooks load
|
|
25
|
+
// hook surfaces ERR_UNKNOWN_MODULE_FORMAT for an unsupported `data:` MIME exactly as
|
|
26
|
+
// plain Node does (see the load hook for why the sync tier needs this pre-check).
|
|
27
|
+
// `mimeToFormat`: text/application javascript -> module, application/json -> json,
|
|
28
|
+
// application/wasm -> wasm, anything else -> null (unknown).
|
|
29
|
+
function dataUrlMimeToFormat(mime) {
|
|
30
|
+
if (mime == null) return null;
|
|
31
|
+
if (/^\s*(text|application)\/javascript\s*(;\s*charset=utf-?8\s*)?$/i.test(mime)) return "module";
|
|
32
|
+
if (mime === "application/json") return "json";
|
|
33
|
+
if (mime === "application/wasm") return "wasm";
|
|
34
|
+
return null;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
// Returns true when `url` is a `data:` URL whose MIME maps to no module format —
|
|
38
|
+
// i.e. the case where Node would ultimately throw ERR_UNKNOWN_MODULE_FORMAT.
|
|
39
|
+
function unknownDataUrlFormat(url) {
|
|
40
|
+
// Strip the `data:` scheme; Node parses the pathname (everything after `data:`).
|
|
41
|
+
const m = /^([^/]+\/[^;,]+)(?:[^,]*?)(;base64)?,/.exec(url.slice(5));
|
|
42
|
+
const mime = m ? m[1] : null;
|
|
43
|
+
return dataUrlMimeToFormat(mime) === null;
|
|
44
|
+
}
|
|
45
|
+
|
|
23
46
|
// Yarn PnP API handle, fetched lazily via Node's `module.findPnpApi`. `.pnp.cjs`
|
|
24
47
|
// (injected by the Rust spawn layer via --require, ahead of nub's preload) sets
|
|
25
48
|
// `process.versions.pnp` and installs `findPnpApi`, which returns the pnpapi object
|
|
@@ -208,6 +231,30 @@ function makeHooks(core, watchReporting) {
|
|
|
208
231
|
}
|
|
209
232
|
if (ext in core.DATA_EXTS) return core.loadData(url, ext);
|
|
210
233
|
|
|
234
|
+
// Fidelity: a `data:` URL whose MIME maps to no module format (e.g.
|
|
235
|
+
// `data:application/x-unknown,…`) must surface Node's ERR_UNKNOWN_MODULE_FORMAT.
|
|
236
|
+
// Node's default load returns `format: null` for this, which its ASYNC loader path
|
|
237
|
+
// later converts to ERR_UNKNOWN_MODULE_FORMAT in validateLoadResult. But nub's SYNC
|
|
238
|
+
// `module.registerHooks` load hook routes the default step's result through
|
|
239
|
+
// customization_hooks' validateLoadSloppy -> validateFormat, which accepts only a
|
|
240
|
+
// string or `undefined` and throws ERR_INVALID_RETURN_PROPERTY_VALUE on `null` —
|
|
241
|
+
// and it does so INSIDE the `nextLoad` call below (the validator wraps each step),
|
|
242
|
+
// so nub never gets the result back to normalize it, and nub's own load-hook frame
|
|
243
|
+
// leaks into the user-visible stack. Vanilla Node, having registered no hook on this
|
|
244
|
+
// path, never hits that validator and throws the correct ERR_UNKNOWN_MODULE_FORMAT.
|
|
245
|
+
// Return `format: undefined` (not the default step's `null`) WITHOUT calling the
|
|
246
|
+
// default load: undefined passes validateFormat, then Node's own
|
|
247
|
+
// #translate -> validateLoadResult sees format == null and throws the NATIVE
|
|
248
|
+
// ERR_UNKNOWN_MODULE_FORMAT — byte-identical to plain Node (the `[code]` name
|
|
249
|
+
// decoration, the exact message, and a stack with zero nub frames). Short-circuit
|
|
250
|
+
// so the chain stops here; the empty source is never read (the throw precedes any
|
|
251
|
+
// translation).
|
|
252
|
+
if (typeof url === "string" && url.startsWith("data:") &&
|
|
253
|
+
(!context || context.format == null) &&
|
|
254
|
+
unknownDataUrlFormat(url)) {
|
|
255
|
+
return { format: undefined, source: "", shortCircuit: true };
|
|
256
|
+
}
|
|
257
|
+
|
|
211
258
|
const r = nextLoad(url, context);
|
|
212
259
|
// nub's sync `module.registerHooks` load hook forces the synchronous
|
|
213
260
|
// module-job (ModuleJobSync.syncLink -> loadAndTranslateForImportInRequiredESM),
|
package/runtime/version.mjs
CHANGED
|
@@ -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.
|
|
12
|
+
export const NUB_VERSION = "0.0.34";
|