@ai-ecoverse/slicc-kernel 1.141.3 → 1.142.0
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 +3 -1
- package/dist/kernel-worker.js +1 -1
- package/dist/node-driver-worker.js.map +2 -2
- package/dist/node-process-worker.js +101 -84
- package/dist/node-process-worker.js.map +3 -3
- package/dist/node.js +17 -4
- package/dist/node.js.map +2 -2
- package/dist/process-worker.js +2 -1
- package/dist/process-worker.js.map +2 -2
- 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.0" : "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);
|
|
@@ -11444,7 +11444,7 @@ function promised(file) {
|
|
|
11444
11444
|
const out = { ...file };
|
|
11445
11445
|
for (const [name2, value2] of Object.entries(file)) {
|
|
11446
11446
|
if (typeof value2 === "function") {
|
|
11447
|
-
out[name2] = (...args) => new Promise((
|
|
11447
|
+
out[name2] = (...args) => new Promise((resolve2) => resolve2(value2(...args)));
|
|
11448
11448
|
}
|
|
11449
11449
|
}
|
|
11450
11450
|
return out;
|
|
@@ -11625,7 +11625,7 @@ function laneOf(lane, silence = SYNC_FS_REQUEST_TIMEOUT_MS, open = createSyncSab
|
|
|
11625
11625
|
};
|
|
11626
11626
|
}
|
|
11627
11627
|
function syncOps(kernel, shared) {
|
|
11628
|
-
const { infos, handles, resolve } = shared;
|
|
11628
|
+
const { infos, handles, resolve: resolve2 } = shared;
|
|
11629
11629
|
const tryDevSync = (abs) => {
|
|
11630
11630
|
try {
|
|
11631
11631
|
const resolved2 = physicalPath(
|
|
@@ -11678,7 +11678,7 @@ function syncOps(kernel, shared) {
|
|
|
11678
11678
|
return at;
|
|
11679
11679
|
};
|
|
11680
11680
|
const statOf = (op, path) => {
|
|
11681
|
-
const abs =
|
|
11681
|
+
const abs = resolve2(path);
|
|
11682
11682
|
if (inDev(abs)) return devSync(kernel, devStat(abs, op === "stat"));
|
|
11683
11683
|
try {
|
|
11684
11684
|
kernel.call({ op: "fd-path-flush", path: abs });
|
|
@@ -11708,7 +11708,7 @@ function syncOps(kernel, shared) {
|
|
|
11708
11708
|
return handle.file;
|
|
11709
11709
|
};
|
|
11710
11710
|
const open = (path, options = {}) => {
|
|
11711
|
-
const abs =
|
|
11711
|
+
const abs = resolve2(path);
|
|
11712
11712
|
if (inDev(abs)) return openDev2(abs, options);
|
|
11713
11713
|
try {
|
|
11714
11714
|
let existing;
|
|
@@ -11751,9 +11751,9 @@ function syncOps(kernel, shared) {
|
|
|
11751
11751
|
},
|
|
11752
11752
|
socketpair: () => kernel.json({ op: "sock-pair", domain: "unix", type: "stream" }),
|
|
11753
11753
|
pipe: () => kernel.json({ op: "fd-pipe" }),
|
|
11754
|
-
open: procOpenSync(open, kernel, { resolve, pid: shared.pid }),
|
|
11755
|
-
fs: procFsSync(syncPathOps(kernel,
|
|
11756
|
-
resolve,
|
|
11754
|
+
open: procOpenSync(open, kernel, { resolve: resolve2, pid: shared.pid }),
|
|
11755
|
+
fs: procFsSync(syncPathOps(kernel, resolve2, statOf, open, tryDevSync), kernel, {
|
|
11756
|
+
resolve: resolve2,
|
|
11757
11757
|
pid: shared.pid
|
|
11758
11758
|
})
|
|
11759
11759
|
};
|
|
@@ -11822,41 +11822,41 @@ function syncFile(kernel, fd, path, append, forget) {
|
|
|
11822
11822
|
}
|
|
11823
11823
|
};
|
|
11824
11824
|
}
|
|
11825
|
-
function syncPathOps(kernel,
|
|
11825
|
+
function syncPathOps(kernel, resolve2, statOf, open, tryDev) {
|
|
11826
11826
|
return {
|
|
11827
11827
|
stat: (path) => statOf("stat", path),
|
|
11828
11828
|
lstat: (path) => statOf("lstat", path),
|
|
11829
11829
|
exists(path) {
|
|
11830
|
-
const abs =
|
|
11830
|
+
const abs = resolve2(path);
|
|
11831
11831
|
if (inDev(abs)) return devSync(kernel, devExists(abs));
|
|
11832
11832
|
if (kernel.json({ op: "exists", path: abs }) === true) return true;
|
|
11833
11833
|
const devPath = tryDev(abs);
|
|
11834
11834
|
return devPath ? devSync(kernel, devExists(devPath)) : false;
|
|
11835
11835
|
},
|
|
11836
11836
|
readdir(path) {
|
|
11837
|
-
const abs =
|
|
11837
|
+
const abs = resolve2(path);
|
|
11838
11838
|
if (inDev(abs)) return devSync(kernel, devReaddir(abs));
|
|
11839
11839
|
return kernel.json({ op: "readdir", path: abs });
|
|
11840
11840
|
},
|
|
11841
11841
|
mkdir: (path, options) => void kernel.call({
|
|
11842
11842
|
op: "mkdir",
|
|
11843
|
-
path:
|
|
11843
|
+
path: resolve2(path),
|
|
11844
11844
|
...options?.recursive === false ? { exclusive: true } : {},
|
|
11845
11845
|
mode: options?.mode === void 0 ? 511 : modeOf(options.mode)
|
|
11846
11846
|
}),
|
|
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:
|
|
11847
|
+
rm: (path) => void kernel.call({ op: "rm", path: resolve2(path) }),
|
|
11848
|
+
unlink: (path) => void kernel.call({ op: "unlink", path: resolve2(path) }),
|
|
11849
|
+
rename: (from, to) => void kernel.call({ op: "rename", path: resolve2(from), arg2: resolve2(to) }),
|
|
11850
|
+
chmod: (path, mode) => void kernel.call({ op: "chmod", path: resolve2(path), mode: modeOf(mode) }),
|
|
11851
|
+
link: (from, to) => void kernel.call({ op: "link", path: resolve2(from), arg2: resolve2(to) }),
|
|
11852
|
+
symlink: (target, path) => void kernel.call({ op: "symlink", path: resolve2(path), arg2: target }),
|
|
11853
11853
|
readlink(path) {
|
|
11854
|
-
const abs =
|
|
11854
|
+
const abs = resolve2(path);
|
|
11855
11855
|
if (inDev(abs)) return devSync(kernel, devReadlink(abs));
|
|
11856
11856
|
return String(kernel.json({ op: "readlink", path: abs }));
|
|
11857
11857
|
},
|
|
11858
11858
|
statfs(path) {
|
|
11859
|
-
let abs =
|
|
11859
|
+
let abs = resolve2(path);
|
|
11860
11860
|
if (inDev(abs)) {
|
|
11861
11861
|
try {
|
|
11862
11862
|
const target = devSync(kernel, devResolveTarget(abs));
|
|
@@ -11868,7 +11868,7 @@ function syncPathOps(kernel, resolve, statOf, open, tryDev) {
|
|
|
11868
11868
|
return statFsOf(kernel.json({ op: "statfs", path: abs }));
|
|
11869
11869
|
},
|
|
11870
11870
|
readFile(path) {
|
|
11871
|
-
const abs =
|
|
11871
|
+
const abs = resolve2(path);
|
|
11872
11872
|
if (inDev(abs)) return readWholeSync(open(abs));
|
|
11873
11873
|
try {
|
|
11874
11874
|
kernel.call({ op: "fd-path-flush", path: abs });
|
|
@@ -14126,8 +14126,8 @@ async function runWasmProcess(init, port3, deps = {}) {
|
|
|
14126
14126
|
let exports;
|
|
14127
14127
|
let atExit = () => () => {
|
|
14128
14128
|
};
|
|
14129
|
-
const initialized = new Promise((
|
|
14130
|
-
ready =
|
|
14129
|
+
const initialized = new Promise((resolve2, reject) => {
|
|
14130
|
+
ready = resolve2;
|
|
14131
14131
|
failed5 = reject;
|
|
14132
14132
|
});
|
|
14133
14133
|
const id = identify(transport, init);
|
|
@@ -14513,12 +14513,12 @@ function within2(root, dir, path) {
|
|
|
14513
14513
|
}
|
|
14514
14514
|
return true;
|
|
14515
14515
|
}
|
|
14516
|
-
function preopensOf(given,
|
|
14516
|
+
function preopensOf(given, resolve2) {
|
|
14517
14517
|
if (given === void 0) return [];
|
|
14518
14518
|
if (typeof given !== "object" || given === null) throw new JsCallError("EINVAL", "wasi preopens");
|
|
14519
14519
|
return Object.entries(given).map(([name2, path]) => {
|
|
14520
14520
|
if (typeof path !== "string" || path === "") throw new JsCallError("EINVAL", "wasi preopens");
|
|
14521
|
-
return [name2, normalize(
|
|
14521
|
+
return [name2, normalize(resolve2(path))];
|
|
14522
14522
|
});
|
|
14523
14523
|
}
|
|
14524
14524
|
function createJsWasi(deps, o = {}) {
|
|
@@ -14847,8 +14847,8 @@ function websocketOp(kernel) {
|
|
|
14847
14847
|
}
|
|
14848
14848
|
let settle;
|
|
14849
14849
|
let lose;
|
|
14850
|
-
const closed = new Promise((
|
|
14851
|
-
settle =
|
|
14850
|
+
const closed = new Promise((resolve2, reject) => {
|
|
14851
|
+
settle = resolve2;
|
|
14852
14852
|
lose = reject;
|
|
14853
14853
|
});
|
|
14854
14854
|
closed.catch(() => void 0);
|
|
@@ -14947,7 +14947,7 @@ var init_js_websocket = __esm({
|
|
|
14947
14947
|
SEND_BUFFER = 1024 * 1024;
|
|
14948
14948
|
MAX_REASON = 123;
|
|
14949
14949
|
NEVER2 = new AbortController().signal;
|
|
14950
|
-
wait = (ms) => new Promise((
|
|
14950
|
+
wait = (ms) => new Promise((resolve2) => setTimeout(resolve2, ms));
|
|
14951
14951
|
}
|
|
14952
14952
|
});
|
|
14953
14953
|
|
|
@@ -15225,7 +15225,7 @@ function tracked2(pending, writeAll, writeSome, failed5) {
|
|
|
15225
15225
|
if (status2 !== void 0) return Promise.reject(new JsExit(status2));
|
|
15226
15226
|
const bytes = typeof data === "string" ? encoder4.encode(data) : data;
|
|
15227
15227
|
let settle;
|
|
15228
|
-
const settled2 = new Promise((
|
|
15228
|
+
const settled2 = new Promise((resolve2) => settle = resolve2);
|
|
15229
15229
|
pending.add(settled2);
|
|
15230
15230
|
return (async () => {
|
|
15231
15231
|
try {
|
|
@@ -15260,7 +15260,7 @@ function createContext(o) {
|
|
|
15260
15260
|
const pending = /* @__PURE__ */ new Set();
|
|
15261
15261
|
const random = o.random ?? cryptoRandom;
|
|
15262
15262
|
let held2;
|
|
15263
|
-
const
|
|
15263
|
+
const resolve2 = (path) => resolvePath(cwdFor(o.cwd, held2, path), path);
|
|
15264
15264
|
const tryDev = (abs) => resolveDevAsync(kernel, abs);
|
|
15265
15265
|
let exiting;
|
|
15266
15266
|
const exit = (code2 = 0) => {
|
|
@@ -15288,13 +15288,13 @@ function createContext(o) {
|
|
|
15288
15288
|
}
|
|
15289
15289
|
});
|
|
15290
15290
|
const statOf = async (op, path) => {
|
|
15291
|
-
const abs =
|
|
15291
|
+
const abs = resolve2(path);
|
|
15292
15292
|
if (inDev(abs)) return devAsync(kernel, devStat(abs, op === "stat"));
|
|
15293
15293
|
return vfsStat(kernel, abs, op, tryDev);
|
|
15294
15294
|
};
|
|
15295
15295
|
const devIo = { infos, handles, read: read2, write: writeAll };
|
|
15296
15296
|
const open = async (path, options = {}, whole = false) => {
|
|
15297
|
-
const abs =
|
|
15297
|
+
const abs = resolve2(path);
|
|
15298
15298
|
if (inDev(abs)) return openDev(kernel, abs, options, devIo);
|
|
15299
15299
|
try {
|
|
15300
15300
|
return await vfsOpen(kernel, abs, options, statOf, devIo, whole);
|
|
@@ -15305,8 +15305,8 @@ function createContext(o) {
|
|
|
15305
15305
|
return openDev(kernel, devPath, options, devIo);
|
|
15306
15306
|
}
|
|
15307
15307
|
};
|
|
15308
|
-
const fs = procFsAsync(pathOps(kernel,
|
|
15309
|
-
resolve,
|
|
15308
|
+
const fs = procFsAsync(pathOps(kernel, resolve2, statOf, open, tryDev), kernel, {
|
|
15309
|
+
resolve: resolve2,
|
|
15310
15310
|
pid: o.pid
|
|
15311
15311
|
});
|
|
15312
15312
|
const lane = o.lane ?? laneOf(void 0);
|
|
@@ -15314,13 +15314,13 @@ function createContext(o) {
|
|
|
15314
15314
|
const syncKernel = new JsSyncKernel(lane, kernel, unwind);
|
|
15315
15315
|
held2 = heldOn(o.held, lane, syncKernel);
|
|
15316
15316
|
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 });
|
|
15317
|
+
const shared = { pid: o.pid, resolve: resolve2, random, infos, handles, closing };
|
|
15318
|
+
const wasi = wasiFor({ lane, pid: o.pid, cwd: o.cwd, resolve: resolve2, fs: o.fs, owned: o.owned });
|
|
15319
15319
|
const sync = {
|
|
15320
15320
|
kernel: KERNEL_INFO,
|
|
15321
15321
|
tty: terminal.syncTty,
|
|
15322
15322
|
...watchingSyncOps(kernel, syncKernel, shared),
|
|
15323
|
-
run: (options) => runSync(syncKernel, { env: o.env, cwd: o.cwd, resolve, signal: signalNumber }, options),
|
|
15323
|
+
run: (options) => runSync(syncKernel, { env: o.env, cwd: o.cwd, resolve: resolve2, signal: signalNumber }, options),
|
|
15324
15324
|
spawn: (options) => spawnSync(options),
|
|
15325
15325
|
wasi: { create: wasi.create },
|
|
15326
15326
|
exit: (status2 = 0) => {
|
|
@@ -15369,8 +15369,8 @@ function createContext(o) {
|
|
|
15369
15369
|
return { type, tty: type === "tty", seekable: type === "file" };
|
|
15370
15370
|
},
|
|
15371
15371
|
isatty: async (fd) => typeOf(await info(fd)) === "tty",
|
|
15372
|
-
open: procOpenAsync(open, kernel, { resolve, pid: o.pid }),
|
|
15373
|
-
resolve,
|
|
15372
|
+
open: procOpenAsync(open, kernel, { resolve: resolve2, pid: o.pid }),
|
|
15373
|
+
resolve: resolve2,
|
|
15374
15374
|
fs,
|
|
15375
15375
|
signals: {
|
|
15376
15376
|
on: async (signal, handler) => kernel.setHandler(signalNumber(signal), handler),
|
|
@@ -15401,7 +15401,7 @@ function createContext(o) {
|
|
|
15401
15401
|
wasi.closeAll();
|
|
15402
15402
|
for (; ; ) {
|
|
15403
15403
|
await Promise.all([...pending]);
|
|
15404
|
-
await new Promise((
|
|
15404
|
+
await new Promise((resolve3) => setTimeout(resolve3, 0));
|
|
15405
15405
|
if (pending.size === 0) break;
|
|
15406
15406
|
}
|
|
15407
15407
|
await terminal.restore();
|
|
@@ -15516,41 +15516,41 @@ async function sendSome(kernel, fd, body, signal) {
|
|
|
15516
15516
|
await kernel.blocking({ op: "fd-select", read: [], write: [fd], timeoutMs: -1 }, signal);
|
|
15517
15517
|
}
|
|
15518
15518
|
}
|
|
15519
|
-
function pathOps(kernel,
|
|
15519
|
+
function pathOps(kernel, resolve2, statOf, open, tryDev) {
|
|
15520
15520
|
return {
|
|
15521
15521
|
stat: (path) => statOf("stat", path),
|
|
15522
15522
|
lstat: (path) => statOf("lstat", path),
|
|
15523
15523
|
async exists(path) {
|
|
15524
|
-
const abs =
|
|
15524
|
+
const abs = resolve2(path);
|
|
15525
15525
|
if (inDev(abs)) return devAsync(kernel, devExists(abs));
|
|
15526
15526
|
if (await kernel.json({ op: "exists", path: abs }) === true) return true;
|
|
15527
15527
|
const devPath = await tryDev(abs);
|
|
15528
15528
|
return devPath ? devAsync(kernel, devExists(devPath)) : false;
|
|
15529
15529
|
},
|
|
15530
15530
|
async readdir(path) {
|
|
15531
|
-
const abs =
|
|
15531
|
+
const abs = resolve2(path);
|
|
15532
15532
|
if (inDev(abs)) return devAsync(kernel, devReaddir(abs));
|
|
15533
15533
|
return await kernel.json({ op: "readdir", path: abs });
|
|
15534
15534
|
},
|
|
15535
15535
|
mkdir: async (path, options) => void await kernel.call({
|
|
15536
15536
|
op: "mkdir",
|
|
15537
|
-
path:
|
|
15537
|
+
path: resolve2(path),
|
|
15538
15538
|
...options?.recursive === false ? { exclusive: true } : {},
|
|
15539
15539
|
mode: options?.mode === void 0 ? 511 : modeOf(options.mode)
|
|
15540
15540
|
}),
|
|
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:
|
|
15541
|
+
rm: async (path) => void await kernel.call({ op: "rm", path: resolve2(path) }),
|
|
15542
|
+
unlink: async (path) => void await kernel.call({ op: "unlink", path: resolve2(path) }),
|
|
15543
|
+
rename: async (from, to) => void await kernel.call({ op: "rename", path: resolve2(from), arg2: resolve2(to) }),
|
|
15544
|
+
chmod: async (path, mode) => void await kernel.call({ op: "chmod", path: resolve2(path), mode: modeOf(mode) }),
|
|
15545
|
+
link: async (from, to) => void await kernel.call({ op: "link", path: resolve2(from), arg2: resolve2(to) }),
|
|
15546
|
+
symlink: async (target, path) => void await kernel.call({ op: "symlink", path: resolve2(path), arg2: target }),
|
|
15547
15547
|
async readlink(path) {
|
|
15548
|
-
const abs =
|
|
15548
|
+
const abs = resolve2(path);
|
|
15549
15549
|
if (inDev(abs)) return devAsync(kernel, devReadlink(abs));
|
|
15550
15550
|
return String(await kernel.json({ op: "readlink", path: abs }));
|
|
15551
15551
|
},
|
|
15552
15552
|
async statfs(path) {
|
|
15553
|
-
let abs =
|
|
15553
|
+
let abs = resolve2(path);
|
|
15554
15554
|
if (inDev(abs)) {
|
|
15555
15555
|
const target = await devAsync(kernel, devResolveTarget(abs)).catch(() => void 0);
|
|
15556
15556
|
if (target?.startsWith("/")) abs = target;
|
|
@@ -15560,11 +15560,11 @@ function pathOps(kernel, resolve, statOf, open, tryDev) {
|
|
|
15560
15560
|
},
|
|
15561
15561
|
async watch(path, options, listener) {
|
|
15562
15562
|
const [given, onNote] = watchArgs(options, listener);
|
|
15563
|
-
const id = await kernel.json(watchRequest(
|
|
15563
|
+
const id = await kernel.json(watchRequest(resolve2(path), given));
|
|
15564
15564
|
return follow2(kernel, id, onNote);
|
|
15565
15565
|
},
|
|
15566
15566
|
async readFile(path) {
|
|
15567
|
-
const abs =
|
|
15567
|
+
const abs = resolve2(path);
|
|
15568
15568
|
if (inDev(abs)) return readWhole(await open(abs));
|
|
15569
15569
|
try {
|
|
15570
15570
|
await kernel.call({ op: "fd-path-flush", path: abs });
|
|
@@ -15647,7 +15647,7 @@ function optionsOf(options) {
|
|
|
15647
15647
|
}
|
|
15648
15648
|
function started(port3, control) {
|
|
15649
15649
|
const exited = Promise.withResolvers();
|
|
15650
|
-
return new Promise((
|
|
15650
|
+
return new Promise((resolve2, reject) => {
|
|
15651
15651
|
const thread = (tid) => Object.freeze({
|
|
15652
15652
|
tid,
|
|
15653
15653
|
port: port3,
|
|
@@ -15659,7 +15659,7 @@ function started(port3, control) {
|
|
|
15659
15659
|
});
|
|
15660
15660
|
control.onmessage = (event) => {
|
|
15661
15661
|
const said = event.data;
|
|
15662
|
-
if ("tid" in said)
|
|
15662
|
+
if ("tid" in said) resolve2(thread(said.tid));
|
|
15663
15663
|
else if ("errno" in said) {
|
|
15664
15664
|
control.close();
|
|
15665
15665
|
port3.close();
|
|
@@ -15742,7 +15742,7 @@ function trapStrays(scope2, stray) {
|
|
|
15742
15742
|
});
|
|
15743
15743
|
}
|
|
15744
15744
|
async function settledStrays() {
|
|
15745
|
-
for (let turn = 0; turn < 2; turn++) await new Promise((
|
|
15745
|
+
for (let turn = 0; turn < 2; turn++) await new Promise((resolve2) => setTimeout(resolve2, 0));
|
|
15746
15746
|
}
|
|
15747
15747
|
function message(err) {
|
|
15748
15748
|
return err instanceof Error ? err.message : String(err);
|
|
@@ -15765,7 +15765,7 @@ async function runJs(init, port3, deps, thread) {
|
|
|
15765
15765
|
const failed5 = (err) => thread && outOfMemory(err) ? JS_THREAD_NO_MEMORY : 1;
|
|
15766
15766
|
const transport = createAsyncSabTransport(init.sab, port3, deps.waitAsync);
|
|
15767
15767
|
let resolveExit;
|
|
15768
|
-
const exit = new Promise((
|
|
15768
|
+
const exit = new Promise((resolve2) => resolveExit = resolve2);
|
|
15769
15769
|
let exitedWith;
|
|
15770
15770
|
const exited = (status3) => {
|
|
15771
15771
|
exitedWith ??= status3;
|
|
@@ -15823,6 +15823,7 @@ async function runJs(init, port3, deps, thread) {
|
|
|
15823
15823
|
(deps.lockdown ?? lockdown)();
|
|
15824
15824
|
const { url, glue } = init.program;
|
|
15825
15825
|
main = mainOf(await (url ? import(url) : (deps.load ?? importSource)(glue)));
|
|
15826
|
+
deps.imported?.();
|
|
15826
15827
|
} catch (err) {
|
|
15827
15828
|
await say(message(err));
|
|
15828
15829
|
return NOT_RUNNABLE;
|
|
@@ -16954,7 +16955,7 @@ var init_wasix_linker = __esm({
|
|
|
16954
16955
|
return { env, "GOT.mem": gotMem, "GOT.func": gotFunc };
|
|
16955
16956
|
}
|
|
16956
16957
|
bindMainGot() {
|
|
16957
|
-
for (const
|
|
16958
|
+
for (const resolve2 of this.mainGot) resolve2();
|
|
16958
16959
|
}
|
|
16959
16960
|
bindMain(instance, relocate) {
|
|
16960
16961
|
this.main = instance;
|
|
@@ -17086,8 +17087,8 @@ var init_wasix_linker = __esm({
|
|
|
17086
17087
|
this.slots.set(value2, record.index);
|
|
17087
17088
|
}
|
|
17088
17089
|
moduleAt(path) {
|
|
17089
|
-
const
|
|
17090
|
-
if (
|
|
17090
|
+
const cached2 = this.cache?.[path];
|
|
17091
|
+
if (cached2) return cached2;
|
|
17091
17092
|
const bytes = this.host.read(path);
|
|
17092
17093
|
if (!bytes) throw new DlError(`${path}: gone`);
|
|
17093
17094
|
return new WebAssembly.Module(bytes);
|
|
@@ -17192,7 +17193,7 @@ var init_wasix_linker = __esm({
|
|
|
17192
17193
|
this.modules.set(at.handle, linked);
|
|
17193
17194
|
const first = this.byPath.get(path);
|
|
17194
17195
|
if (!first || at.handle < first.handle) this.byPath.set(path, linked);
|
|
17195
|
-
for (const
|
|
17196
|
+
for (const resolve2 of pending) resolve2();
|
|
17196
17197
|
if (init) {
|
|
17197
17198
|
call(linked.instance, "__wasm_apply_data_relocs");
|
|
17198
17199
|
call(linked.instance, "__wasm_call_ctors");
|
|
@@ -17967,8 +17968,8 @@ function createImportedMemory(spec, copy2) {
|
|
|
17967
17968
|
if (copy2) fillMemory(memory, copy2);
|
|
17968
17969
|
return memory;
|
|
17969
17970
|
}
|
|
17970
|
-
function restoreExportedMemory(instance,
|
|
17971
|
-
if (
|
|
17971
|
+
function restoreExportedMemory(instance, imported2, init) {
|
|
17972
|
+
if (imported2 || !init.fork?.wasi) return;
|
|
17972
17973
|
fillMemory(instance.exports.memory, init.fork.memory);
|
|
17973
17974
|
}
|
|
17974
17975
|
function fillMemory(memory, copy2) {
|
|
@@ -17979,8 +17980,8 @@ function fillMemory(memory, copy2) {
|
|
|
17979
17980
|
function sizeOf2(main) {
|
|
17980
17981
|
return () => main.memory?.buffer.byteLength ?? 0;
|
|
17981
17982
|
}
|
|
17982
|
-
function memoryOf(instance,
|
|
17983
|
-
return
|
|
17983
|
+
function memoryOf(instance, imported2) {
|
|
17984
|
+
return imported2 ?? instance.exports.memory;
|
|
17984
17985
|
}
|
|
17985
17986
|
function kernelOf(init, port3, hooks = { masks: () => null, raise: () => {
|
|
17986
17987
|
} }, memory) {
|
|
@@ -18321,9 +18322,9 @@ function programNames(host, program, warned) {
|
|
|
18321
18322
|
const path = program.names;
|
|
18322
18323
|
if (path === void 0) return void 0;
|
|
18323
18324
|
const read2 = (p) => host.o.fs.readFile(p);
|
|
18324
|
-
const
|
|
18325
|
+
const imported2 = WebAssembly.Module.imports(program.module).filter((i) => i.kind === "function");
|
|
18325
18326
|
return sidecarNames(read2, path, {
|
|
18326
|
-
functions: () =>
|
|
18327
|
+
functions: () => imported2.length + definedFunctions(read2(program.path)),
|
|
18327
18328
|
warn: (line) => warned.push(line)
|
|
18328
18329
|
});
|
|
18329
18330
|
}
|
|
@@ -18567,12 +18568,13 @@ var init_wasi_runtime = __esm({
|
|
|
18567
18568
|
});
|
|
18568
18569
|
|
|
18569
18570
|
// src/node-process-worker.ts
|
|
18570
|
-
import { createRequire } from "node:module";
|
|
18571
|
-
import { parentPort } from "node:worker_threads";
|
|
18571
|
+
import { createRequire, enableCompileCache, flushCompileCache } from "node:module";
|
|
18572
|
+
import { parentPort, workerData } from "node:worker_threads";
|
|
18572
18573
|
|
|
18573
18574
|
// src/node-lockdown.ts
|
|
18574
18575
|
init_lockdown();
|
|
18575
18576
|
import { isBuiltin, registerHooks } from "node:module";
|
|
18577
|
+
import { resolve, sep } from "node:path";
|
|
18576
18578
|
import { getHeapStatistics } from "node:v8";
|
|
18577
18579
|
var NODE_GLOBALS = ["localStorage", "sessionStorage"];
|
|
18578
18580
|
var NODE_SLOTS = [
|
|
@@ -18665,6 +18667,16 @@ function workerShaped(scope2, href) {
|
|
|
18665
18667
|
location: slot2(Object.freeze({ href }))
|
|
18666
18668
|
});
|
|
18667
18669
|
}
|
|
18670
|
+
function ownCache(dir, result) {
|
|
18671
|
+
const active = result.directory;
|
|
18672
|
+
if (active === void 0) return false;
|
|
18673
|
+
if (!`${resolve(active)}${sep}`.startsWith(`${resolve(dir)}${sep}`)) {
|
|
18674
|
+
throw new Error(
|
|
18675
|
+
`slicc-kernel: compileCache ${dir} was asked for, but this worker already caches in ${active} (a host preload enabled it): refusing to run programs`
|
|
18676
|
+
);
|
|
18677
|
+
}
|
|
18678
|
+
return true;
|
|
18679
|
+
}
|
|
18668
18680
|
|
|
18669
18681
|
// src/node-process-worker.ts
|
|
18670
18682
|
init_js_runtime();
|
|
@@ -18741,6 +18753,9 @@ var scope = globalThis;
|
|
|
18741
18753
|
scope.require ??= createRequire(import.meta.url);
|
|
18742
18754
|
scope.__filename ??= new URL(import.meta.url).pathname;
|
|
18743
18755
|
scope.__dirname ??= new URL(".", import.meta.url).pathname;
|
|
18756
|
+
var cacheDir = workerData?.compileCache;
|
|
18757
|
+
var cached = typeof cacheDir === "string" && ownCache(cacheDir, enableCompileCache(cacheDir));
|
|
18758
|
+
var imported = cached ? () => flushCompileCache() : void 0;
|
|
18744
18759
|
var port2 = parentPort;
|
|
18745
18760
|
var post = {
|
|
18746
18761
|
postMessage: (message2, transfer) => port2.postMessage(message2, transfer)
|
|
@@ -18757,12 +18772,14 @@ var onMessage = processEntry(
|
|
|
18757
18772
|
runJsProcess: (init, at) => runJsProcess(init, at, {
|
|
18758
18773
|
lockdown: () => nodeLockdown(),
|
|
18759
18774
|
scope: strayScope,
|
|
18760
|
-
memory: nodeMemory
|
|
18775
|
+
memory: nodeMemory,
|
|
18776
|
+
imported
|
|
18761
18777
|
}),
|
|
18762
18778
|
runJsThread: (init, at) => runJsThread(init, at, {
|
|
18763
18779
|
lockdown: () => nodeLockdown(),
|
|
18764
18780
|
scope: strayScope,
|
|
18765
|
-
memory: nodeMemory
|
|
18781
|
+
memory: nodeMemory,
|
|
18782
|
+
imported
|
|
18766
18783
|
})
|
|
18767
18784
|
}),
|
|
18768
18785
|
() => nodeLockdown()
|