@ai-ecoverse/slicc-kernel 1.141.3 → 1.142.1
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/README.md +17 -2
- package/dist/index.js.map +1 -1
- package/dist/kernel-worker.js +492 -107
- package/dist/kernel-worker.js.map +4 -4
- package/dist/meta.js +3 -0
- package/dist/meta.js.map +2 -2
- package/dist/node-driver-worker.js.map +2 -2
- package/dist/node-process-worker.js +113 -85
- package/dist/node-process-worker.js.map +3 -3
- package/dist/node.js +505 -110
- package/dist/node.js.map +4 -4
- package/dist/process-worker.js +14 -2
- package/dist/process-worker.js.map +2 -2
- package/dist/types/fs/meta.d.ts +2 -0
- package/dist/types/fs/opfs.d.ts +30 -0
- package/dist/types/fs/remote.d.ts +15 -0
- package/dist/types/fs/types.d.ts +7 -0
- package/dist/types/kernel/proc-info.d.ts +7 -0
- package/dist/types/node.d.ts +1 -0
- package/package.json +2 -2
|
@@ -906,7 +906,7 @@ function cachingBridge(bridge, now = () => performance.now(), shared) {
|
|
|
906
906
|
if ("until" in hit) return live(hit, path) ? hit : void 0;
|
|
907
907
|
return young2(hit) && !seen.changed(map, path) ? hit : void 0;
|
|
908
908
|
};
|
|
909
|
-
const
|
|
909
|
+
const cached2 = (map, path, get) => {
|
|
910
910
|
if (blind) return get();
|
|
911
911
|
cache.fresh();
|
|
912
912
|
let hit = usable(map, path);
|
|
@@ -984,11 +984,11 @@ function cachingBridge(bridge, now = () => performance.now(), shared) {
|
|
|
984
984
|
}
|
|
985
985
|
return bridge.readlink(p);
|
|
986
986
|
},
|
|
987
|
-
stat: (p) =>
|
|
988
|
-
lstat: (p) =>
|
|
987
|
+
stat: (p) => cached2(stats, p, () => bridge.stat(p)),
|
|
988
|
+
lstat: (p) => cached2(lstats, p, () => bridge.lstat(p)),
|
|
989
989
|
exists: (p) => {
|
|
990
990
|
try {
|
|
991
|
-
|
|
991
|
+
cached2(stats, p, () => bridge.stat(p));
|
|
992
992
|
return true;
|
|
993
993
|
} catch {
|
|
994
994
|
return false;
|
|
@@ -2019,10 +2019,10 @@ function callError(result, op) {
|
|
|
2019
2019
|
}
|
|
2020
2020
|
function untilAborted(work, signal) {
|
|
2021
2021
|
if (!signal) return work;
|
|
2022
|
-
return new Promise((
|
|
2022
|
+
return new Promise((resolve2) => {
|
|
2023
2023
|
const done = () => {
|
|
2024
2024
|
signal.removeEventListener("abort", done);
|
|
2025
|
-
|
|
2025
|
+
resolve2();
|
|
2026
2026
|
};
|
|
2027
2027
|
signal.addEventListener("abort", done, { once: true });
|
|
2028
2028
|
work.then(done, done);
|
|
@@ -6725,7 +6725,7 @@ var KERNEL_VERSION, OS_RELEASE;
|
|
|
6725
6725
|
var init_version = __esm({
|
|
6726
6726
|
"src/version.ts"() {
|
|
6727
6727
|
"use strict";
|
|
6728
|
-
KERNEL_VERSION = true ? "1.
|
|
6728
|
+
KERNEL_VERSION = true ? "1.142.1" : "0.0.0-dev";
|
|
6729
6729
|
OS_RELEASE = "6.0.0-slicc";
|
|
6730
6730
|
}
|
|
6731
6731
|
});
|
|
@@ -7673,7 +7673,7 @@ function netOps(kernel, io) {
|
|
|
7673
7673
|
});
|
|
7674
7674
|
return { fd, local: local3, remote, readable: readable3, writable: writable2, close };
|
|
7675
7675
|
};
|
|
7676
|
-
const
|
|
7676
|
+
const resolve2 = async (host, signal) => {
|
|
7677
7677
|
if (IPV4.test(host)) return host;
|
|
7678
7678
|
const r = await kernel.blocking({ op: "sock-resolve", name: host, family: 4 }, signal);
|
|
7679
7679
|
return (r.ok && r.kind === "json" ? r.json : [])[0];
|
|
@@ -7773,7 +7773,7 @@ function netOps(kernel, io) {
|
|
|
7773
7773
|
if (host.includes(":")) throw new JsCallError("EADDRNOTAVAIL", host);
|
|
7774
7774
|
const addr = {
|
|
7775
7775
|
family: "inet",
|
|
7776
|
-
host: await
|
|
7776
|
+
host: await resolve2(host, signal),
|
|
7777
7777
|
port: port(options.port)
|
|
7778
7778
|
};
|
|
7779
7779
|
return opened2(async (fd) => {
|
|
@@ -8568,9 +8568,9 @@ function createNodeOps(h) {
|
|
|
8568
8568
|
const owned = bridgeOf(node).owners === true;
|
|
8569
8569
|
if (owned && Fs.isLink(node.mode) && statOf(node).uid === void 0)
|
|
8570
8570
|
node.live.stat = void 0;
|
|
8571
|
-
const
|
|
8571
|
+
const cached2 = owned && cachedStat(node, Fs.isDir(node.mode), bridgeOf(node).changes);
|
|
8572
8572
|
const st = statOf(node);
|
|
8573
|
-
if (
|
|
8573
|
+
if (cached2) searchParents(Fs, node, bridgeOf(node), call2);
|
|
8574
8574
|
const s = node.live;
|
|
8575
8575
|
const size = Fs.isDir(node.mode) ? 4096 : s.ranged?.size() ?? (s.loaded ? s.len : st.size);
|
|
8576
8576
|
const mtime = new Date(st.mtimeMs ?? 0);
|
|
@@ -9181,7 +9181,7 @@ function guardVanished(Fs) {
|
|
|
9181
9181
|
const drop = forget;
|
|
9182
9182
|
const lookupPath = Fs.lookupPath.bind(Fs);
|
|
9183
9183
|
const ops = Fs;
|
|
9184
|
-
const
|
|
9184
|
+
const cached2 = (path, follow3) => {
|
|
9185
9185
|
try {
|
|
9186
9186
|
const node = lookupPath(path, { follow: follow3 }).node;
|
|
9187
9187
|
return node.live && node.live.openCount === 0 && !node.live.dirty ? node : void 0;
|
|
@@ -9204,7 +9204,7 @@ function guardVanished(Fs) {
|
|
|
9204
9204
|
const code2 = err.errno;
|
|
9205
9205
|
const taken = code2 === wasiErrno("EEXIST") && op === open;
|
|
9206
9206
|
if (code2 !== wasiErrno("ENOENT") && !taken || typeof path !== "string") throw err;
|
|
9207
|
-
const node =
|
|
9207
|
+
const node = cached2(path, follows(args));
|
|
9208
9208
|
if (!node) throw err;
|
|
9209
9209
|
drop(node);
|
|
9210
9210
|
return op(...args);
|
|
@@ -10892,7 +10892,18 @@ var init_procfs = __esm({
|
|
|
10892
10892
|
slicc_opfs_ops: (listing2) => `${listing2.opfsOps ?? 0}
|
|
10893
10893
|
`,
|
|
10894
10894
|
slicc_cwd_checks: (listing2) => `${listing2.cwdChecks ?? 0}
|
|
10895
|
-
|
|
10895
|
+
`,
|
|
10896
|
+
slicc_rename_ack_busy: (listing2) => `${listing2.renameAcks?.busy ?? 0}
|
|
10897
|
+
`,
|
|
10898
|
+
slicc_rename_acks: (listing2) => {
|
|
10899
|
+
const samples = [...listing2.renameAcks?.ackMs ?? []].sort((a, b) => a - b);
|
|
10900
|
+
const median = samples[Math.floor(samples.length / 2)] ?? 0;
|
|
10901
|
+
const most = samples.at(-1) ?? 0;
|
|
10902
|
+
const waits = listing2.renameAcks?.waits ?? 0;
|
|
10903
|
+
const queries = listing2.renameAcks?.queries ?? 0;
|
|
10904
|
+
return `${listing2.renameAcks?.acks ?? 0} ${median.toFixed(1)} ${most.toFixed(1)} ${waits} ${queries}
|
|
10905
|
+
`;
|
|
10906
|
+
}
|
|
10896
10907
|
}
|
|
10897
10908
|
};
|
|
10898
10909
|
sigMask = (mask = 0) => (mask >>> 1).toString(16).padStart(16, "0");
|
|
@@ -11444,7 +11455,7 @@ function promised(file) {
|
|
|
11444
11455
|
const out = { ...file };
|
|
11445
11456
|
for (const [name2, value2] of Object.entries(file)) {
|
|
11446
11457
|
if (typeof value2 === "function") {
|
|
11447
|
-
out[name2] = (...args) => new Promise((
|
|
11458
|
+
out[name2] = (...args) => new Promise((resolve2) => resolve2(value2(...args)));
|
|
11448
11459
|
}
|
|
11449
11460
|
}
|
|
11450
11461
|
return out;
|
|
@@ -11625,7 +11636,7 @@ function laneOf(lane, silence = SYNC_FS_REQUEST_TIMEOUT_MS, open = createSyncSab
|
|
|
11625
11636
|
};
|
|
11626
11637
|
}
|
|
11627
11638
|
function syncOps(kernel, shared) {
|
|
11628
|
-
const { infos, handles, resolve } = shared;
|
|
11639
|
+
const { infos, handles, resolve: resolve2 } = shared;
|
|
11629
11640
|
const tryDevSync = (abs) => {
|
|
11630
11641
|
try {
|
|
11631
11642
|
const resolved2 = physicalPath(
|
|
@@ -11678,7 +11689,7 @@ function syncOps(kernel, shared) {
|
|
|
11678
11689
|
return at;
|
|
11679
11690
|
};
|
|
11680
11691
|
const statOf = (op, path) => {
|
|
11681
|
-
const abs =
|
|
11692
|
+
const abs = resolve2(path);
|
|
11682
11693
|
if (inDev(abs)) return devSync(kernel, devStat(abs, op === "stat"));
|
|
11683
11694
|
try {
|
|
11684
11695
|
kernel.call({ op: "fd-path-flush", path: abs });
|
|
@@ -11708,7 +11719,7 @@ function syncOps(kernel, shared) {
|
|
|
11708
11719
|
return handle.file;
|
|
11709
11720
|
};
|
|
11710
11721
|
const open = (path, options = {}) => {
|
|
11711
|
-
const abs =
|
|
11722
|
+
const abs = resolve2(path);
|
|
11712
11723
|
if (inDev(abs)) return openDev2(abs, options);
|
|
11713
11724
|
try {
|
|
11714
11725
|
let existing;
|
|
@@ -11751,9 +11762,9 @@ function syncOps(kernel, shared) {
|
|
|
11751
11762
|
},
|
|
11752
11763
|
socketpair: () => kernel.json({ op: "sock-pair", domain: "unix", type: "stream" }),
|
|
11753
11764
|
pipe: () => kernel.json({ op: "fd-pipe" }),
|
|
11754
|
-
open: procOpenSync(open, kernel, { resolve, pid: shared.pid }),
|
|
11755
|
-
fs: procFsSync(syncPathOps(kernel,
|
|
11756
|
-
resolve,
|
|
11765
|
+
open: procOpenSync(open, kernel, { resolve: resolve2, pid: shared.pid }),
|
|
11766
|
+
fs: procFsSync(syncPathOps(kernel, resolve2, statOf, open, tryDevSync), kernel, {
|
|
11767
|
+
resolve: resolve2,
|
|
11757
11768
|
pid: shared.pid
|
|
11758
11769
|
})
|
|
11759
11770
|
};
|
|
@@ -11822,41 +11833,41 @@ function syncFile(kernel, fd, path, append, forget) {
|
|
|
11822
11833
|
}
|
|
11823
11834
|
};
|
|
11824
11835
|
}
|
|
11825
|
-
function syncPathOps(kernel,
|
|
11836
|
+
function syncPathOps(kernel, resolve2, statOf, open, tryDev) {
|
|
11826
11837
|
return {
|
|
11827
11838
|
stat: (path) => statOf("stat", path),
|
|
11828
11839
|
lstat: (path) => statOf("lstat", path),
|
|
11829
11840
|
exists(path) {
|
|
11830
|
-
const abs =
|
|
11841
|
+
const abs = resolve2(path);
|
|
11831
11842
|
if (inDev(abs)) return devSync(kernel, devExists(abs));
|
|
11832
11843
|
if (kernel.json({ op: "exists", path: abs }) === true) return true;
|
|
11833
11844
|
const devPath = tryDev(abs);
|
|
11834
11845
|
return devPath ? devSync(kernel, devExists(devPath)) : false;
|
|
11835
11846
|
},
|
|
11836
11847
|
readdir(path) {
|
|
11837
|
-
const abs =
|
|
11848
|
+
const abs = resolve2(path);
|
|
11838
11849
|
if (inDev(abs)) return devSync(kernel, devReaddir(abs));
|
|
11839
11850
|
return kernel.json({ op: "readdir", path: abs });
|
|
11840
11851
|
},
|
|
11841
11852
|
mkdir: (path, options) => void kernel.call({
|
|
11842
11853
|
op: "mkdir",
|
|
11843
|
-
path:
|
|
11854
|
+
path: resolve2(path),
|
|
11844
11855
|
...options?.recursive === false ? { exclusive: true } : {},
|
|
11845
11856
|
mode: options?.mode === void 0 ? 511 : modeOf(options.mode)
|
|
11846
11857
|
}),
|
|
11847
|
-
rm: (path) => void kernel.call({ op: "rm", path:
|
|
11848
|
-
unlink: (path) => void kernel.call({ op: "unlink", path:
|
|
11849
|
-
rename: (from, to) => void kernel.call({ op: "rename", path:
|
|
11850
|
-
chmod: (path, mode) => void kernel.call({ op: "chmod", path:
|
|
11851
|
-
link: (from, to) => void kernel.call({ op: "link", path:
|
|
11852
|
-
symlink: (target, path) => void kernel.call({ op: "symlink", path:
|
|
11858
|
+
rm: (path) => void kernel.call({ op: "rm", path: resolve2(path) }),
|
|
11859
|
+
unlink: (path) => void kernel.call({ op: "unlink", path: resolve2(path) }),
|
|
11860
|
+
rename: (from, to) => void kernel.call({ op: "rename", path: resolve2(from), arg2: resolve2(to) }),
|
|
11861
|
+
chmod: (path, mode) => void kernel.call({ op: "chmod", path: resolve2(path), mode: modeOf(mode) }),
|
|
11862
|
+
link: (from, to) => void kernel.call({ op: "link", path: resolve2(from), arg2: resolve2(to) }),
|
|
11863
|
+
symlink: (target, path) => void kernel.call({ op: "symlink", path: resolve2(path), arg2: target }),
|
|
11853
11864
|
readlink(path) {
|
|
11854
|
-
const abs =
|
|
11865
|
+
const abs = resolve2(path);
|
|
11855
11866
|
if (inDev(abs)) return devSync(kernel, devReadlink(abs));
|
|
11856
11867
|
return String(kernel.json({ op: "readlink", path: abs }));
|
|
11857
11868
|
},
|
|
11858
11869
|
statfs(path) {
|
|
11859
|
-
let abs =
|
|
11870
|
+
let abs = resolve2(path);
|
|
11860
11871
|
if (inDev(abs)) {
|
|
11861
11872
|
try {
|
|
11862
11873
|
const target = devSync(kernel, devResolveTarget(abs));
|
|
@@ -11868,7 +11879,7 @@ function syncPathOps(kernel, resolve, statOf, open, tryDev) {
|
|
|
11868
11879
|
return statFsOf(kernel.json({ op: "statfs", path: abs }));
|
|
11869
11880
|
},
|
|
11870
11881
|
readFile(path) {
|
|
11871
|
-
const abs =
|
|
11882
|
+
const abs = resolve2(path);
|
|
11872
11883
|
if (inDev(abs)) return readWholeSync(open(abs));
|
|
11873
11884
|
try {
|
|
11874
11885
|
kernel.call({ op: "fd-path-flush", path: abs });
|
|
@@ -14126,8 +14137,8 @@ async function runWasmProcess(init, port3, deps = {}) {
|
|
|
14126
14137
|
let exports;
|
|
14127
14138
|
let atExit = () => () => {
|
|
14128
14139
|
};
|
|
14129
|
-
const initialized = new Promise((
|
|
14130
|
-
ready =
|
|
14140
|
+
const initialized = new Promise((resolve2, reject) => {
|
|
14141
|
+
ready = resolve2;
|
|
14131
14142
|
failed5 = reject;
|
|
14132
14143
|
});
|
|
14133
14144
|
const id = identify(transport, init);
|
|
@@ -14513,12 +14524,12 @@ function within2(root, dir, path) {
|
|
|
14513
14524
|
}
|
|
14514
14525
|
return true;
|
|
14515
14526
|
}
|
|
14516
|
-
function preopensOf(given,
|
|
14527
|
+
function preopensOf(given, resolve2) {
|
|
14517
14528
|
if (given === void 0) return [];
|
|
14518
14529
|
if (typeof given !== "object" || given === null) throw new JsCallError("EINVAL", "wasi preopens");
|
|
14519
14530
|
return Object.entries(given).map(([name2, path]) => {
|
|
14520
14531
|
if (typeof path !== "string" || path === "") throw new JsCallError("EINVAL", "wasi preopens");
|
|
14521
|
-
return [name2, normalize(
|
|
14532
|
+
return [name2, normalize(resolve2(path))];
|
|
14522
14533
|
});
|
|
14523
14534
|
}
|
|
14524
14535
|
function createJsWasi(deps, o = {}) {
|
|
@@ -14847,8 +14858,8 @@ function websocketOp(kernel) {
|
|
|
14847
14858
|
}
|
|
14848
14859
|
let settle;
|
|
14849
14860
|
let lose;
|
|
14850
|
-
const closed = new Promise((
|
|
14851
|
-
settle =
|
|
14861
|
+
const closed = new Promise((resolve2, reject) => {
|
|
14862
|
+
settle = resolve2;
|
|
14852
14863
|
lose = reject;
|
|
14853
14864
|
});
|
|
14854
14865
|
closed.catch(() => void 0);
|
|
@@ -14947,7 +14958,7 @@ var init_js_websocket = __esm({
|
|
|
14947
14958
|
SEND_BUFFER = 1024 * 1024;
|
|
14948
14959
|
MAX_REASON = 123;
|
|
14949
14960
|
NEVER2 = new AbortController().signal;
|
|
14950
|
-
wait = (ms) => new Promise((
|
|
14961
|
+
wait = (ms) => new Promise((resolve2) => setTimeout(resolve2, ms));
|
|
14951
14962
|
}
|
|
14952
14963
|
});
|
|
14953
14964
|
|
|
@@ -15225,7 +15236,7 @@ function tracked2(pending, writeAll, writeSome, failed5) {
|
|
|
15225
15236
|
if (status2 !== void 0) return Promise.reject(new JsExit(status2));
|
|
15226
15237
|
const bytes = typeof data === "string" ? encoder4.encode(data) : data;
|
|
15227
15238
|
let settle;
|
|
15228
|
-
const settled2 = new Promise((
|
|
15239
|
+
const settled2 = new Promise((resolve2) => settle = resolve2);
|
|
15229
15240
|
pending.add(settled2);
|
|
15230
15241
|
return (async () => {
|
|
15231
15242
|
try {
|
|
@@ -15260,7 +15271,7 @@ function createContext(o) {
|
|
|
15260
15271
|
const pending = /* @__PURE__ */ new Set();
|
|
15261
15272
|
const random = o.random ?? cryptoRandom;
|
|
15262
15273
|
let held2;
|
|
15263
|
-
const
|
|
15274
|
+
const resolve2 = (path) => resolvePath(cwdFor(o.cwd, held2, path), path);
|
|
15264
15275
|
const tryDev = (abs) => resolveDevAsync(kernel, abs);
|
|
15265
15276
|
let exiting;
|
|
15266
15277
|
const exit = (code2 = 0) => {
|
|
@@ -15288,13 +15299,13 @@ function createContext(o) {
|
|
|
15288
15299
|
}
|
|
15289
15300
|
});
|
|
15290
15301
|
const statOf = async (op, path) => {
|
|
15291
|
-
const abs =
|
|
15302
|
+
const abs = resolve2(path);
|
|
15292
15303
|
if (inDev(abs)) return devAsync(kernel, devStat(abs, op === "stat"));
|
|
15293
15304
|
return vfsStat(kernel, abs, op, tryDev);
|
|
15294
15305
|
};
|
|
15295
15306
|
const devIo = { infos, handles, read: read2, write: writeAll };
|
|
15296
15307
|
const open = async (path, options = {}, whole = false) => {
|
|
15297
|
-
const abs =
|
|
15308
|
+
const abs = resolve2(path);
|
|
15298
15309
|
if (inDev(abs)) return openDev(kernel, abs, options, devIo);
|
|
15299
15310
|
try {
|
|
15300
15311
|
return await vfsOpen(kernel, abs, options, statOf, devIo, whole);
|
|
@@ -15305,8 +15316,8 @@ function createContext(o) {
|
|
|
15305
15316
|
return openDev(kernel, devPath, options, devIo);
|
|
15306
15317
|
}
|
|
15307
15318
|
};
|
|
15308
|
-
const fs = procFsAsync(pathOps(kernel,
|
|
15309
|
-
resolve,
|
|
15319
|
+
const fs = procFsAsync(pathOps(kernel, resolve2, statOf, open, tryDev), kernel, {
|
|
15320
|
+
resolve: resolve2,
|
|
15310
15321
|
pid: o.pid
|
|
15311
15322
|
});
|
|
15312
15323
|
const lane = o.lane ?? laneOf(void 0);
|
|
@@ -15314,13 +15325,13 @@ function createContext(o) {
|
|
|
15314
15325
|
const syncKernel = new JsSyncKernel(lane, kernel, unwind);
|
|
15315
15326
|
held2 = heldOn(o.held, lane, syncKernel);
|
|
15316
15327
|
const terminal = ttyOps(kernel, syncKernel);
|
|
15317
|
-
const shared = { pid: o.pid, resolve, random, infos, handles, closing };
|
|
15318
|
-
const wasi = wasiFor({ lane, pid: o.pid, cwd: o.cwd, resolve, fs: o.fs, owned: o.owned });
|
|
15328
|
+
const shared = { pid: o.pid, resolve: resolve2, random, infos, handles, closing };
|
|
15329
|
+
const wasi = wasiFor({ lane, pid: o.pid, cwd: o.cwd, resolve: resolve2, fs: o.fs, owned: o.owned });
|
|
15319
15330
|
const sync = {
|
|
15320
15331
|
kernel: KERNEL_INFO,
|
|
15321
15332
|
tty: terminal.syncTty,
|
|
15322
15333
|
...watchingSyncOps(kernel, syncKernel, shared),
|
|
15323
|
-
run: (options) => runSync(syncKernel, { env: o.env, cwd: o.cwd, resolve, signal: signalNumber }, options),
|
|
15334
|
+
run: (options) => runSync(syncKernel, { env: o.env, cwd: o.cwd, resolve: resolve2, signal: signalNumber }, options),
|
|
15324
15335
|
spawn: (options) => spawnSync(options),
|
|
15325
15336
|
wasi: { create: wasi.create },
|
|
15326
15337
|
exit: (status2 = 0) => {
|
|
@@ -15369,8 +15380,8 @@ function createContext(o) {
|
|
|
15369
15380
|
return { type, tty: type === "tty", seekable: type === "file" };
|
|
15370
15381
|
},
|
|
15371
15382
|
isatty: async (fd) => typeOf(await info(fd)) === "tty",
|
|
15372
|
-
open: procOpenAsync(open, kernel, { resolve, pid: o.pid }),
|
|
15373
|
-
resolve,
|
|
15383
|
+
open: procOpenAsync(open, kernel, { resolve: resolve2, pid: o.pid }),
|
|
15384
|
+
resolve: resolve2,
|
|
15374
15385
|
fs,
|
|
15375
15386
|
signals: {
|
|
15376
15387
|
on: async (signal, handler) => kernel.setHandler(signalNumber(signal), handler),
|
|
@@ -15401,7 +15412,7 @@ function createContext(o) {
|
|
|
15401
15412
|
wasi.closeAll();
|
|
15402
15413
|
for (; ; ) {
|
|
15403
15414
|
await Promise.all([...pending]);
|
|
15404
|
-
await new Promise((
|
|
15415
|
+
await new Promise((resolve3) => setTimeout(resolve3, 0));
|
|
15405
15416
|
if (pending.size === 0) break;
|
|
15406
15417
|
}
|
|
15407
15418
|
await terminal.restore();
|
|
@@ -15516,41 +15527,41 @@ async function sendSome(kernel, fd, body, signal) {
|
|
|
15516
15527
|
await kernel.blocking({ op: "fd-select", read: [], write: [fd], timeoutMs: -1 }, signal);
|
|
15517
15528
|
}
|
|
15518
15529
|
}
|
|
15519
|
-
function pathOps(kernel,
|
|
15530
|
+
function pathOps(kernel, resolve2, statOf, open, tryDev) {
|
|
15520
15531
|
return {
|
|
15521
15532
|
stat: (path) => statOf("stat", path),
|
|
15522
15533
|
lstat: (path) => statOf("lstat", path),
|
|
15523
15534
|
async exists(path) {
|
|
15524
|
-
const abs =
|
|
15535
|
+
const abs = resolve2(path);
|
|
15525
15536
|
if (inDev(abs)) return devAsync(kernel, devExists(abs));
|
|
15526
15537
|
if (await kernel.json({ op: "exists", path: abs }) === true) return true;
|
|
15527
15538
|
const devPath = await tryDev(abs);
|
|
15528
15539
|
return devPath ? devAsync(kernel, devExists(devPath)) : false;
|
|
15529
15540
|
},
|
|
15530
15541
|
async readdir(path) {
|
|
15531
|
-
const abs =
|
|
15542
|
+
const abs = resolve2(path);
|
|
15532
15543
|
if (inDev(abs)) return devAsync(kernel, devReaddir(abs));
|
|
15533
15544
|
return await kernel.json({ op: "readdir", path: abs });
|
|
15534
15545
|
},
|
|
15535
15546
|
mkdir: async (path, options) => void await kernel.call({
|
|
15536
15547
|
op: "mkdir",
|
|
15537
|
-
path:
|
|
15548
|
+
path: resolve2(path),
|
|
15538
15549
|
...options?.recursive === false ? { exclusive: true } : {},
|
|
15539
15550
|
mode: options?.mode === void 0 ? 511 : modeOf(options.mode)
|
|
15540
15551
|
}),
|
|
15541
|
-
rm: async (path) => void await kernel.call({ op: "rm", path:
|
|
15542
|
-
unlink: async (path) => void await kernel.call({ op: "unlink", path:
|
|
15543
|
-
rename: async (from, to) => void await kernel.call({ op: "rename", path:
|
|
15544
|
-
chmod: async (path, mode) => void await kernel.call({ op: "chmod", path:
|
|
15545
|
-
link: async (from, to) => void await kernel.call({ op: "link", path:
|
|
15546
|
-
symlink: async (target, path) => void await kernel.call({ op: "symlink", path:
|
|
15552
|
+
rm: async (path) => void await kernel.call({ op: "rm", path: resolve2(path) }),
|
|
15553
|
+
unlink: async (path) => void await kernel.call({ op: "unlink", path: resolve2(path) }),
|
|
15554
|
+
rename: async (from, to) => void await kernel.call({ op: "rename", path: resolve2(from), arg2: resolve2(to) }),
|
|
15555
|
+
chmod: async (path, mode) => void await kernel.call({ op: "chmod", path: resolve2(path), mode: modeOf(mode) }),
|
|
15556
|
+
link: async (from, to) => void await kernel.call({ op: "link", path: resolve2(from), arg2: resolve2(to) }),
|
|
15557
|
+
symlink: async (target, path) => void await kernel.call({ op: "symlink", path: resolve2(path), arg2: target }),
|
|
15547
15558
|
async readlink(path) {
|
|
15548
|
-
const abs =
|
|
15559
|
+
const abs = resolve2(path);
|
|
15549
15560
|
if (inDev(abs)) return devAsync(kernel, devReadlink(abs));
|
|
15550
15561
|
return String(await kernel.json({ op: "readlink", path: abs }));
|
|
15551
15562
|
},
|
|
15552
15563
|
async statfs(path) {
|
|
15553
|
-
let abs =
|
|
15564
|
+
let abs = resolve2(path);
|
|
15554
15565
|
if (inDev(abs)) {
|
|
15555
15566
|
const target = await devAsync(kernel, devResolveTarget(abs)).catch(() => void 0);
|
|
15556
15567
|
if (target?.startsWith("/")) abs = target;
|
|
@@ -15560,11 +15571,11 @@ function pathOps(kernel, resolve, statOf, open, tryDev) {
|
|
|
15560
15571
|
},
|
|
15561
15572
|
async watch(path, options, listener) {
|
|
15562
15573
|
const [given, onNote] = watchArgs(options, listener);
|
|
15563
|
-
const id = await kernel.json(watchRequest(
|
|
15574
|
+
const id = await kernel.json(watchRequest(resolve2(path), given));
|
|
15564
15575
|
return follow2(kernel, id, onNote);
|
|
15565
15576
|
},
|
|
15566
15577
|
async readFile(path) {
|
|
15567
|
-
const abs =
|
|
15578
|
+
const abs = resolve2(path);
|
|
15568
15579
|
if (inDev(abs)) return readWhole(await open(abs));
|
|
15569
15580
|
try {
|
|
15570
15581
|
await kernel.call({ op: "fd-path-flush", path: abs });
|
|
@@ -15647,7 +15658,7 @@ function optionsOf(options) {
|
|
|
15647
15658
|
}
|
|
15648
15659
|
function started(port3, control) {
|
|
15649
15660
|
const exited = Promise.withResolvers();
|
|
15650
|
-
return new Promise((
|
|
15661
|
+
return new Promise((resolve2, reject) => {
|
|
15651
15662
|
const thread = (tid) => Object.freeze({
|
|
15652
15663
|
tid,
|
|
15653
15664
|
port: port3,
|
|
@@ -15659,7 +15670,7 @@ function started(port3, control) {
|
|
|
15659
15670
|
});
|
|
15660
15671
|
control.onmessage = (event) => {
|
|
15661
15672
|
const said = event.data;
|
|
15662
|
-
if ("tid" in said)
|
|
15673
|
+
if ("tid" in said) resolve2(thread(said.tid));
|
|
15663
15674
|
else if ("errno" in said) {
|
|
15664
15675
|
control.close();
|
|
15665
15676
|
port3.close();
|
|
@@ -15742,7 +15753,7 @@ function trapStrays(scope2, stray) {
|
|
|
15742
15753
|
});
|
|
15743
15754
|
}
|
|
15744
15755
|
async function settledStrays() {
|
|
15745
|
-
for (let turn = 0; turn < 2; turn++) await new Promise((
|
|
15756
|
+
for (let turn = 0; turn < 2; turn++) await new Promise((resolve2) => setTimeout(resolve2, 0));
|
|
15746
15757
|
}
|
|
15747
15758
|
function message(err) {
|
|
15748
15759
|
return err instanceof Error ? err.message : String(err);
|
|
@@ -15765,7 +15776,7 @@ async function runJs(init, port3, deps, thread) {
|
|
|
15765
15776
|
const failed5 = (err) => thread && outOfMemory(err) ? JS_THREAD_NO_MEMORY : 1;
|
|
15766
15777
|
const transport = createAsyncSabTransport(init.sab, port3, deps.waitAsync);
|
|
15767
15778
|
let resolveExit;
|
|
15768
|
-
const exit = new Promise((
|
|
15779
|
+
const exit = new Promise((resolve2) => resolveExit = resolve2);
|
|
15769
15780
|
let exitedWith;
|
|
15770
15781
|
const exited = (status3) => {
|
|
15771
15782
|
exitedWith ??= status3;
|
|
@@ -15823,6 +15834,7 @@ async function runJs(init, port3, deps, thread) {
|
|
|
15823
15834
|
(deps.lockdown ?? lockdown)();
|
|
15824
15835
|
const { url, glue } = init.program;
|
|
15825
15836
|
main = mainOf(await (url ? import(url) : (deps.load ?? importSource)(glue)));
|
|
15837
|
+
deps.imported?.();
|
|
15826
15838
|
} catch (err) {
|
|
15827
15839
|
await say(message(err));
|
|
15828
15840
|
return NOT_RUNNABLE;
|
|
@@ -16954,7 +16966,7 @@ var init_wasix_linker = __esm({
|
|
|
16954
16966
|
return { env, "GOT.mem": gotMem, "GOT.func": gotFunc };
|
|
16955
16967
|
}
|
|
16956
16968
|
bindMainGot() {
|
|
16957
|
-
for (const
|
|
16969
|
+
for (const resolve2 of this.mainGot) resolve2();
|
|
16958
16970
|
}
|
|
16959
16971
|
bindMain(instance, relocate) {
|
|
16960
16972
|
this.main = instance;
|
|
@@ -17086,8 +17098,8 @@ var init_wasix_linker = __esm({
|
|
|
17086
17098
|
this.slots.set(value2, record.index);
|
|
17087
17099
|
}
|
|
17088
17100
|
moduleAt(path) {
|
|
17089
|
-
const
|
|
17090
|
-
if (
|
|
17101
|
+
const cached2 = this.cache?.[path];
|
|
17102
|
+
if (cached2) return cached2;
|
|
17091
17103
|
const bytes = this.host.read(path);
|
|
17092
17104
|
if (!bytes) throw new DlError(`${path}: gone`);
|
|
17093
17105
|
return new WebAssembly.Module(bytes);
|
|
@@ -17192,7 +17204,7 @@ var init_wasix_linker = __esm({
|
|
|
17192
17204
|
this.modules.set(at.handle, linked);
|
|
17193
17205
|
const first = this.byPath.get(path);
|
|
17194
17206
|
if (!first || at.handle < first.handle) this.byPath.set(path, linked);
|
|
17195
|
-
for (const
|
|
17207
|
+
for (const resolve2 of pending) resolve2();
|
|
17196
17208
|
if (init) {
|
|
17197
17209
|
call(linked.instance, "__wasm_apply_data_relocs");
|
|
17198
17210
|
call(linked.instance, "__wasm_call_ctors");
|
|
@@ -17967,8 +17979,8 @@ function createImportedMemory(spec, copy2) {
|
|
|
17967
17979
|
if (copy2) fillMemory(memory, copy2);
|
|
17968
17980
|
return memory;
|
|
17969
17981
|
}
|
|
17970
|
-
function restoreExportedMemory(instance,
|
|
17971
|
-
if (
|
|
17982
|
+
function restoreExportedMemory(instance, imported2, init) {
|
|
17983
|
+
if (imported2 || !init.fork?.wasi) return;
|
|
17972
17984
|
fillMemory(instance.exports.memory, init.fork.memory);
|
|
17973
17985
|
}
|
|
17974
17986
|
function fillMemory(memory, copy2) {
|
|
@@ -17979,8 +17991,8 @@ function fillMemory(memory, copy2) {
|
|
|
17979
17991
|
function sizeOf2(main) {
|
|
17980
17992
|
return () => main.memory?.buffer.byteLength ?? 0;
|
|
17981
17993
|
}
|
|
17982
|
-
function memoryOf(instance,
|
|
17983
|
-
return
|
|
17994
|
+
function memoryOf(instance, imported2) {
|
|
17995
|
+
return imported2 ?? instance.exports.memory;
|
|
17984
17996
|
}
|
|
17985
17997
|
function kernelOf(init, port3, hooks = { masks: () => null, raise: () => {
|
|
17986
17998
|
} }, memory) {
|
|
@@ -18321,9 +18333,9 @@ function programNames(host, program, warned) {
|
|
|
18321
18333
|
const path = program.names;
|
|
18322
18334
|
if (path === void 0) return void 0;
|
|
18323
18335
|
const read2 = (p) => host.o.fs.readFile(p);
|
|
18324
|
-
const
|
|
18336
|
+
const imported2 = WebAssembly.Module.imports(program.module).filter((i) => i.kind === "function");
|
|
18325
18337
|
return sidecarNames(read2, path, {
|
|
18326
|
-
functions: () =>
|
|
18338
|
+
functions: () => imported2.length + definedFunctions(read2(program.path)),
|
|
18327
18339
|
warn: (line) => warned.push(line)
|
|
18328
18340
|
});
|
|
18329
18341
|
}
|
|
@@ -18567,12 +18579,13 @@ var init_wasi_runtime = __esm({
|
|
|
18567
18579
|
});
|
|
18568
18580
|
|
|
18569
18581
|
// src/node-process-worker.ts
|
|
18570
|
-
import { createRequire } from "node:module";
|
|
18571
|
-
import { parentPort } from "node:worker_threads";
|
|
18582
|
+
import { createRequire, enableCompileCache, flushCompileCache } from "node:module";
|
|
18583
|
+
import { parentPort, workerData } from "node:worker_threads";
|
|
18572
18584
|
|
|
18573
18585
|
// src/node-lockdown.ts
|
|
18574
18586
|
init_lockdown();
|
|
18575
18587
|
import { isBuiltin, registerHooks } from "node:module";
|
|
18588
|
+
import { resolve, sep } from "node:path";
|
|
18576
18589
|
import { getHeapStatistics } from "node:v8";
|
|
18577
18590
|
var NODE_GLOBALS = ["localStorage", "sessionStorage"];
|
|
18578
18591
|
var NODE_SLOTS = [
|
|
@@ -18665,6 +18678,16 @@ function workerShaped(scope2, href) {
|
|
|
18665
18678
|
location: slot2(Object.freeze({ href }))
|
|
18666
18679
|
});
|
|
18667
18680
|
}
|
|
18681
|
+
function ownCache(dir, result) {
|
|
18682
|
+
const active = result.directory;
|
|
18683
|
+
if (active === void 0) return false;
|
|
18684
|
+
if (!`${resolve(active)}${sep}`.startsWith(`${resolve(dir)}${sep}`)) {
|
|
18685
|
+
throw new Error(
|
|
18686
|
+
`slicc-kernel: compileCache ${dir} was asked for, but this worker already caches in ${active} (a host preload enabled it): refusing to run programs`
|
|
18687
|
+
);
|
|
18688
|
+
}
|
|
18689
|
+
return true;
|
|
18690
|
+
}
|
|
18668
18691
|
|
|
18669
18692
|
// src/node-process-worker.ts
|
|
18670
18693
|
init_js_runtime();
|
|
@@ -18741,6 +18764,9 @@ var scope = globalThis;
|
|
|
18741
18764
|
scope.require ??= createRequire(import.meta.url);
|
|
18742
18765
|
scope.__filename ??= new URL(import.meta.url).pathname;
|
|
18743
18766
|
scope.__dirname ??= new URL(".", import.meta.url).pathname;
|
|
18767
|
+
var cacheDir = workerData?.compileCache;
|
|
18768
|
+
var cached = typeof cacheDir === "string" && ownCache(cacheDir, enableCompileCache(cacheDir));
|
|
18769
|
+
var imported = cached ? () => flushCompileCache() : void 0;
|
|
18744
18770
|
var port2 = parentPort;
|
|
18745
18771
|
var post = {
|
|
18746
18772
|
postMessage: (message2, transfer) => port2.postMessage(message2, transfer)
|
|
@@ -18757,12 +18783,14 @@ var onMessage = processEntry(
|
|
|
18757
18783
|
runJsProcess: (init, at) => runJsProcess(init, at, {
|
|
18758
18784
|
lockdown: () => nodeLockdown(),
|
|
18759
18785
|
scope: strayScope,
|
|
18760
|
-
memory: nodeMemory
|
|
18786
|
+
memory: nodeMemory,
|
|
18787
|
+
imported
|
|
18761
18788
|
}),
|
|
18762
18789
|
runJsThread: (init, at) => runJsThread(init, at, {
|
|
18763
18790
|
lockdown: () => nodeLockdown(),
|
|
18764
18791
|
scope: strayScope,
|
|
18765
|
-
memory: nodeMemory
|
|
18792
|
+
memory: nodeMemory,
|
|
18793
|
+
imported
|
|
18766
18794
|
})
|
|
18767
18795
|
}),
|
|
18768
18796
|
() => nodeLockdown()
|