Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
0cd5c7f
build(runtime): take the base64 codec from the shared runtime-common …
edusperoni Dec 4, 2026
1624660
feat(runtime): run the HTTP module loader on runtime-common
edusperoni Dec 5, 2026
2108347
build: pin runtime-common foundation and implement its platform funct…
edusperoni Dec 5, 2026
89b9580
feat(runtime): pump through Loop::PumpUntil
edusperoni Dec 5, 2026
2a2d735
fix(runtime): termination always ends a module load with a throw
edusperoni Dec 5, 2026
31b4eaa
build: pin runtime-common at ebb7b87
edusperoni Dec 5, 2026
2f63376
fix(runtime): V8 callbacks throw on Terminated instead of returning
edusperoni Dec 5, 2026
b6fd4b1
build: pin runtime-common at 95d96cc and implement its app-file seam
edusperoni Dec 5, 2026
32ab7ec
feat(runtime): give the code cache a directory of its own
edusperoni Dec 5, 2026
88d3a22
feat(runtime): compile app files and keep code caches through the sha…
edusperoni Dec 5, 2026
4f94119
feat(runtime): remove the code caches older runtimes left beside sources
edusperoni Dec 5, 2026
ce8edad
build: pin runtime-common at 6826386
edusperoni Dec 5, 2026
9e562df
test: let in-flight cache writes finish before checking for temporaries
edusperoni Dec 5, 2026
71a1da0
build: pin runtime-common at 39e2174 and implement its URL parser seam
edusperoni Dec 5, 2026
85a53ba
test: pin the verbatim spelling of module and script URLs
edusperoni Dec 5, 2026
4bc5dcb
feat(runtime): name modules through the shared core's module identity
edusperoni Dec 5, 2026
e9158bb
build: pin runtime-common at 3bcf603
edusperoni Dec 5, 2026
03d1633
feat(runtime): give each isolate a loader config snapshot
edusperoni Dec 5, 2026
5e3390c
feat(runtime): load modules through the shared core's registry and re…
edusperoni Dec 5, 2026
f5ed9fc
test(runtime): pin the shared resolver's specifier rules
edusperoni Dec 5, 2026
60a6ac9
build: pin runtime-common at da7852d
edusperoni Dec 5, 2026
1ee254f
fix(runtime): prefilter blob: URLs on the whole scheme
edusperoni Dec 5, 2026
63ac13e
test(runtime): pin the reviewed resolver rules
edusperoni Dec 6, 2026
83a7256
test(runtime): benchmark import() through the module loader
edusperoni Dec 6, 2026
d07ac5d
build: pin runtime-common at 8585d65
edusperoni Dec 6, 2026
8d5168e
refactor(runtime): load and import modules through runtime-common
edusperoni Dec 6, 2026
495d00d
test(runtime): JSON module strictness and import() while a worker closes
edusperoni Dec 6, 2026
9768a8a
feat(runtime): enforceImportAttributes app config
edusperoni Dec 6, 2026
e731308
build: pin runtime-common at f73c0f5
edusperoni Dec 6, 2026
e3bad81
build: pin runtime-common at ab7f353
edusperoni Dec 6, 2026
9ae6061
refactor(runtime): host callbacks, import.meta and ns:module from run…
edusperoni Dec 6, 2026
b646096
feat(runtime): appSchemeOrigins app config
edusperoni Dec 6, 2026
80193fe
test: import() of CommonJS and .js files
edusperoni Dec 6, 2026
c39a453
refactor(runtime): evaluation layer and main-entry boot from runtime-…
edusperoni Dec 6, 2026
18197cc
test: module identity, pending top-level await and require() cycles
edusperoni Dec 6, 2026
57a3f49
build: pin runtime-common at 53ed375
edusperoni Dec 6, 2026
580b42f
refactor(runtime)!: require() from runtime-common 8
edusperoni Dec 6, 2026
0afa3dc
test: worker entry names and line-1 extend() class names
edusperoni Dec 6, 2026
ad2c64c
refactor(runtime): drop the worker's calling directory from runtime init
edusperoni Dec 6, 2026
620a2db
test: bump the shared tests to 589478f
edusperoni Dec 6, 2026
3d11ab0
fix(runtime): key both spellings of the data directory as one app root
edusperoni Dec 6, 2026
e4fc5a1
test: one module through either spelling of the data directory
edusperoni Dec 6, 2026
e384149
test: run the shared import specs
edusperoni Dec 6, 2026
391978b
fix(runtime): crash breadcrumbs and profiler frames per module, runti…
edusperoni Dec 6, 2026
d5185c2
test: ~name and JSON worker entries
edusperoni Dec 6, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,6 @@
path = test-app/build-tools/android-dts-generator
url = https://github.com/NativeScript/android-dts-generator.git
branch = main
[submodule "test-app/runtime/src/main/cpp/runtime-common"]
path = test-app/runtime/src/main/cpp/runtime-common
url = https://github.com/NativeScript/runtime-common.git
4 changes: 2 additions & 2 deletions docs/ns-builtin-modules.md
Original file line number Diff line number Diff line change
Expand Up @@ -776,7 +776,7 @@ unmodified where a shim exists:
|---|---|---|
| `node:util` | `inspect`, `format`, `TextEncoder`, `TextDecoder` | Re-exports `ns:util`'s members unchanged (`nodeUtil.inspect === nsUtil.inspect`) from a **distinct, separately frozen module object**. `TextEncoder`/`TextDecoder` are the globals of those names, as they are in Node. Documented as partial. |
| `node:url` | `URL`, `URLSearchParams`, `fileURLToPath`, `pathToFileURL` | Re-exports `ns:url`'s members unchanged (`nodeUrl.fileURLToPath === nsUrl.fileURLToPath`) from a **distinct, separately frozen module object**; the converters are Node-strict and throw Node's messages. Documented as partial — no legacy `url.parse`/`format`/`resolve`, and no `URLPattern` (Node's `node:url` has none). |
| `node:module` | `createRequire` | Re-exports `ns:module`'s `createRequire` unchanged from a **distinct, separately frozen module object**. `createPumpingRequire` is deliberately absent: it has no Node counterpart, so code written against this shim keeps running on Node. `require.resolve`/`.cache`/`.main` are not implemented, and neither is any other `node:module` member (`Module`, `builtinModules`, `isBuiltin`, `register`, `syncBuiltinESMExports`). Documented as partial. |
| `node:module` | `createRequire` | Re-exports `ns:module`'s `createRequire` unchanged from a **distinct, separately frozen module object**. `createPumpingRequire` is deliberately absent: it has no Node counterpart, so code written against this shim keeps running on Node. `require.cache` is not implemented (`require.resolve` and `require.main` are), and neither is any other `node:module` member (`Module`, `builtinModules`, `isBuiltin`, `register`, `syncBuiltinESMExports`). Documented as partial. |
| `node:worker_threads` | the messaging and thread surface — see [worker-threads.md](worker-threads.md) | The channel half (`MessagePort`, `MessageChannel`, `BroadcastChannel`, `receiveMessageOnPort`) is the real implementation, the same objects the globals of those names hold; the thread half is a bridge over the `Worker` that `ns:worker_threads` exports. The channel half has no `ns:` counterpart — its surface tracks Node's, so there is nothing for a standard module to own. The one place it breaks the absent-not-throwing rule below is deliberate: `postMessageToThread` and `moveMessagePortToContext` are present and throw an `Error` naming themselves, because silently missing thread-addressed messaging reads as a delivery bug rather than as an unsupported call. Documented as partial. |

## Loading ES modules
Expand Down Expand Up @@ -1379,7 +1379,7 @@ internal require is a fixed parameter of the builtin function wrapper
(`exports`, `require`, `module`, `binding`, `primordials`).

The files under `js/` that are *not* in the public registry — `primordials.js`,
`require-factory.js`, `inspect.js`, `json-helper.js`, `events.js`,
`inspect.js`, `json-helper.js`, `events.js`,
`error-events.js`, `structured-clone.js`, `blob-url.js`, `performance.js`,
`weak-ref.js`, `interop-globals.js` — are the internal builtins: each is run
from its own native call site and none is named in the public registry.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { createRequire } from "node:module";

let attempt;
try {
createRequire(import.meta.url)("./cycle-root.mjs");
attempt = "<no error thrown>";
} catch (e) {
attempt = String(e && e.code) + ": " + String((e && e.message) || e);
}

export { attempt };
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// Statically imports a module that require()s this one while it is still
// evaluating.
import { attempt } from "./cycle-requirer.mjs";

export const outcome = attempt;
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// Reached by import() first, then by require(): both must see this one
// evaluation.
const counts = globalThis.__nsIdentityEvaluations || (globalThis.__nsIdentityEvaluations = {});
counts.importFirst = (counts.importFirst || 0) + 1;

export const token = {};
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// Reached by require() first, then by import(): both must see this one
// evaluation.
const counts = globalThis.__nsIdentityEvaluations || (globalThis.__nsIdentityEvaluations = {});
counts.requireFirst = (counts.requireFirst || 0) + 1;

export const token = {};
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// Started by import() and still parked in its top-level await when a pumping
// require() asks for it. Its export is declared after the await, so a
// namespace read before the evaluation settled would throw.
globalThis.__nsTlaStillRunningStarted = true;

await new Promise(function (resolve) {
__ns__setTimeout(resolve, 300);
});

export const value = "settled";
2 changes: 2 additions & 0 deletions test-app/app/src/main/assets/app/esm/json-strict/comment.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// a comment
{"a": 1}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

3 changes: 3 additions & 0 deletions test-app/app/src/main/assets/app/esm/json-strict/importer.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export function load(spec) {
return import(spec, { with: { type: "json" } });
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"a": 1};globalThis.__jsonStrictInjected = true
1 change: 1 addition & 0 deletions test-app/app/src/main/assets/app/esm/json-strict/ok.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"name": "strict"}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"__proto__": {"polluted": true}, "own": 1}
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import data from "./trailing-comma.json" with { type: "json" };
export default data;
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"a": 1,}
6 changes: 6 additions & 0 deletions test-app/app/src/main/assets/app/mainpage.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ TNSGetOutput = function () {
__approot = __dirname.substr(0, __dirname.length - 4);
var shared = require("./shared");
shared.runRequireTests();
shared.runImportTests();
shared.runWeakRefTests();
shared.runRuntimeTests();
shared.runWorkerTests();
Expand All @@ -36,6 +37,7 @@ require("./tests/testWorkerTerminateDuringRequireMint");
require("./tests/testWorkerTerminateCaughtRequire");
require("./tests/testWorkerTerminateAfterClose");
require("./tests/testWorkerOptions");
require("./tests/testWorkerEntryNames");
require("./tests/testWorkerResourceLimits");
require("./tests/testWorkerNestedConsole");
require("./tests/testWorkerConcurrentStartup");
Expand Down Expand Up @@ -151,6 +153,10 @@ require('./tests/testConcurrentProxyGeneration');
require('./tests/testEsmHttpLoader');
// What import() settles with, per importer kind and specifier shape
require('./tests/testDynamicImport');
// JSON modules: strict JSON.parse, and the SyntaxError they reject with
require('./tests/testJsonModules');
// import() of CommonJS files and of .js files with either syntax
require('./tests/testImportCommonJs');
// File modules large enough to load off the JS thread
require('./tests/testFileModuleLoad');
// Node-API addon surface
Expand Down
2 changes: 1 addition & 1 deletion test-app/app/src/main/assets/app/shared
Submodule shared updated 2 files
+3 −7 Import/index.js
+8 −15 Require/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -578,7 +578,10 @@ exports.run = function () {
// Yield to the looper between benchmarks so GC and queued work run outside timed rounds.
function next() {
if (index >= benchmarks.length) {
runContention();
require("./moduleBenchmarks").run(report, skipped, ROUNDS, SCALE, function (r) {
results.push.apply(results, r);
runContention();
});
return;
}
gc();
Expand Down
21 changes: 21 additions & 0 deletions test-app/app/src/main/assets/app/tests/benchmarks/modbench/hub.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { v0 } from "./m0.mjs";
import { v1 } from "./m1.mjs";
import { v2 } from "./m2.mjs";
import { v3 } from "./m3.mjs";
import { v4 } from "./m4.mjs";
import { v5 } from "./m5.mjs";
import { v6 } from "./m6.mjs";
import { v7 } from "./m7.mjs";
import { v8 } from "./m8.mjs";
import { v9 } from "./m9.mjs";
import { v10 } from "./m10.mjs";
import { v11 } from "./m11.mjs";
import { v12 } from "./m12.mjs";
import { v13 } from "./m13.mjs";
import { v14 } from "./m14.mjs";
import { v15 } from "./m15.mjs";
import { v16 } from "./m16.mjs";
import { v17 } from "./m17.mjs";
import { v18 } from "./m18.mjs";
import { v19 } from "./m19.mjs";
export const sum = v0 + v1 + v2 + v3 + v4 + v5 + v6 + v7 + v8 + v9 + v10 + v11 + v12 + v13 + v14 + v15 + v16 + v17 + v18 + v19;
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const name = "leaf";
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const v0 = 0;
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const v1 = 1;
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const v10 = 10;
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const v11 = 11;
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const v12 = 12;
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const v13 = 13;
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const v14 = 14;
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const v15 = 15;
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const v16 = 16;
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const v17 = 17;
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const v18 = 18;
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const v19 = 19;
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const v2 = 2;
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const v3 = 3;
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const v4 = 4;
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const v5 = 5;
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const v6 = 6;
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const v7 = 7;
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const v8 = 8;
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const v9 = 9;
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
// Module loader rows for the JniBench harness: import() of cached modules
// through each specifier form, and links of a fresh module whose 20 static
// imports are cached. Async, so each row awaits every import.

function rows(appRoot) {
var leafPath = appRoot + "/tests/benchmarks/modbench/leaf.mjs";
var hubSeq = 0;
return [
["module.import() cached relative", 2000, function () { return import("./modbench/leaf.mjs"); }],
["module.import() cached bare mapped", 2000, function () { return import("ns-modbench-leaf"); }],
["module.import() cached app-relative", 2000, function () { return import("~/tests/benchmarks/modbench/leaf.mjs"); }],
["module.import() cached absolute path", 2000, function () { return import(leafPath); }],
["module.import() cached file URL", 2000, function () { return import("file://" + leafPath); }],
["module.import() fresh hub, 20 cached static imports", 200, function () {
return import("./modbench/hub.mjs?i=" + (hubSeq++));
}]
];
}

exports.run = function (report, skipped, rounds, scale, done) {
// The runtime's own spelling of the app root; getFilesDir() may spell it
// through another mount (/data/user/0 for /data/data).
var appRoot = __dirname.slice(0, __dirname.length - "/tests/benchmarks".length);
require("ns:module").configureLoader({ importMap: { imports: { "ns-modbench-leaf": "~/tests/benchmarks/modbench/leaf.mjs" } } });
var list = rows(appRoot).filter(function (row) { return !skipped(row[0]); });
var results = [];
function loop(body, n) {
var i = 0;
return new Promise(function (resolve, reject) {
function step() {
if (i >= n) { resolve(); return; }
i++;
body().then(step, reject);
}
step();
});
}
function runRow(index) {
if (index >= list.length) { done(results); return; }
var row = list[index];
var n = row[1] * scale;
var samples = [];
var r = 0;
loop(row[2], Math.max(200, n >> 2)).then(function round() {
if (r >= rounds) {
results.push(report(row[0], samples, null, n * rounds));
setTimeout(function () { runRow(index + 1); }, 50);
return;
}
r++;
var start = performance.now();
return loop(row[2], n).then(function () {
samples.push(((performance.now() - start) * 1e6) / n);
return round();
});
}).catch(function (e) {
console.log("JNIBENCH_ERROR " + row[0] + ": " + e);
runRow(index + 1);
});
}
runRow(0);
};
Loading