@ai-ecoverse/slicc-kernel 1.50.0 → 1.52.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.
@@ -9,8 +9,8 @@ var __esm = (fn, res, err) => function __init() {
9
9
  }
10
10
  };
11
11
  var __export = (target, all) => {
12
- for (var name in all)
13
- __defProp(target, name, { get: all[name], enumerable: true });
12
+ for (var name2 in all)
13
+ __defProp(target, name2, { get: all[name2], enumerable: true });
14
14
  };
15
15
 
16
16
  // src/process/js/lockdown.ts
@@ -23,22 +23,22 @@ function chain(target) {
23
23
  return out;
24
24
  }
25
25
  function hide(target, names) {
26
- for (const name of names) {
26
+ for (const name2 of names) {
27
27
  const holders = chain(target);
28
28
  for (const holder of holders) {
29
- if (Object.getOwnPropertyDescriptor(holder, name)?.configurable) {
30
- Reflect.deleteProperty(holder, name);
29
+ if (Object.getOwnPropertyDescriptor(holder, name2)?.configurable) {
30
+ Reflect.deleteProperty(holder, name2);
31
31
  }
32
32
  }
33
- const kept = holders.slice(1).some((holder) => Object.hasOwn(holder, name));
34
- const defined = Reflect.defineProperty(target, name, {
33
+ const kept = holders.slice(1).some((holder) => Object.hasOwn(holder, name2));
34
+ const defined = Reflect.defineProperty(target, name2, {
35
35
  value: void 0,
36
36
  writable: false,
37
37
  enumerable: false,
38
38
  configurable: false
39
39
  });
40
- if (kept || !defined && Reflect.get(target, name) !== void 0) {
41
- throw new Error(`slicc-kernel: cannot withhold ${name} from a JS program`);
40
+ if (kept || !defined && Reflect.get(target, name2) !== void 0) {
41
+ throw new Error(`slicc-kernel: cannot withhold ${name2} from a JS program`);
42
42
  }
43
43
  }
44
44
  }
@@ -75,11 +75,11 @@ var init_lockdown = __esm({
75
75
  // src/process/wasi/wasi-abi.ts
76
76
  function wasiErrnoOf(code2) {
77
77
  if (!code2) return E.IO;
78
- const name = code2.startsWith("E") ? code2.slice(1) : code2;
79
- if (name === "OPNOTSUPP") return E.NOTSUP;
80
- if (name === "WOULDBLOCK") return E.AGAIN;
81
- if (name === "NOMEDIUM") return E.NODEV;
82
- return E[name] ?? E.IO;
78
+ const name2 = code2.startsWith("E") ? code2.slice(1) : code2;
79
+ if (name2 === "OPNOTSUPP") return E.NOTSUP;
80
+ if (name2 === "WOULDBLOCK") return E.AGAIN;
81
+ if (name2 === "NOMEDIUM") return E.NODEV;
82
+ return E[name2] ?? E.IO;
83
83
  }
84
84
  function wasixSignal(sig) {
85
85
  return Number.isInteger(sig) && sig >= 1 && sig <= 31 ? sig : void 0;
@@ -520,10 +520,10 @@ function cachingBridge(bridge, now = () => performance.now()) {
520
520
  readdirStat: (p) => {
521
521
  const list = bridge.readdirStat(p);
522
522
  const base = p === "/" ? "" : p;
523
- for (const [name, st] of list) {
523
+ for (const [name2, st] of list) {
524
524
  if (!st) continue;
525
- lstats.set(`${base}/${name}`, st);
526
- if (!st.isSymbolicLink) stats.set(`${base}/${name}`, st);
525
+ lstats.set(`${base}/${name2}`, st);
526
+ if (!st.isSymbolicLink) stats.set(`${base}/${name2}`, st);
527
527
  }
528
528
  return list;
529
529
  },
@@ -969,6 +969,10 @@ function kernelEntry() {
969
969
  function deviceEntry(meta) {
970
970
  return { type: "device", device: meta.device, ...meta.access ? { access: meta.access } : {} };
971
971
  }
972
+ function refuseWrite(s, oflags, rights) {
973
+ const writes = (rights & RIGHTS.FD_WRITE) !== 0n || (oflags & OFLAGS.TRUNC) !== 0;
974
+ if (s?.readonly && writes) throw new WasiError("EROFS");
975
+ }
972
976
  function preopenOf(e) {
973
977
  return {
974
978
  ...e.preopen ? { preopen: e.preopen } : {},
@@ -1076,8 +1080,8 @@ var init_wasi_fds = __esm({
1076
1080
  } catch {
1077
1081
  return out;
1078
1082
  }
1079
- for (const name of [.../* @__PURE__ */ new Set([...names, "dev", ...SYNTHETIC_DIRS])].sort()) {
1080
- const path = `/${name}`;
1083
+ for (const name2 of [.../* @__PURE__ */ new Set([...names, "dev", ...SYNTHETIC_DIRS])].sort()) {
1084
+ const path = `/${name2}`;
1081
1085
  if (path === "/dev") {
1082
1086
  out.push({ type: "dir", path, preopen: path });
1083
1087
  continue;
@@ -1436,6 +1440,7 @@ var init_wasi_fds = __esm({
1436
1440
  return this.install({ type: "dir", path });
1437
1441
  }
1438
1442
  if (!s && !(oflags & OFLAGS.CREAT)) throw new WasiError("ENOENT");
1443
+ refuseWrite(s, oflags, rights);
1439
1444
  if (this.shared) return this.kernelFile(path, s, oflags, rights, fdflags);
1440
1445
  return this.install({ type: "file", file: this.file(path, s, oflags, rights, fdflags) });
1441
1446
  }
@@ -1813,8 +1818,8 @@ function kernelFiletype(kind) {
1813
1818
  return { filetype: FILETYPE.UNKNOWN, seeks: false };
1814
1819
  }
1815
1820
  }
1816
- function direntRecord(next2, ino, name, filetype) {
1817
- const nameBytes = new TextEncoder().encode(name);
1821
+ function direntRecord(next2, ino, name2, filetype) {
1822
+ const nameBytes = new TextEncoder().encode(name2);
1818
1823
  const record = new Uint8Array(SIZE.DIRENT + nameBytes.length);
1819
1824
  const v = new DataView(record.buffer);
1820
1825
  v.setBigUint64(0, BigInt(next2), true);
@@ -1826,8 +1831,8 @@ function direntRecord(next2, ino, name, filetype) {
1826
1831
  }
1827
1832
  function wrap(table) {
1828
1833
  const out = {};
1829
- for (const [name, fn] of Object.entries(table)) {
1830
- out[name] = (...args) => {
1834
+ for (const [name2, fn] of Object.entries(table)) {
1835
+ out[name2] = (...args) => {
1831
1836
  try {
1832
1837
  return fn(...args) ?? E.SUCCESS;
1833
1838
  } catch (e) {
@@ -1888,8 +1893,8 @@ var init_wasi_host = __esm({
1888
1893
  return kernel.call(req);
1889
1894
  };
1890
1895
  const sys = new Proxy(kernel.sys, {
1891
- get: (target, name) => {
1892
- const member = Reflect.get(target, name);
1896
+ get: (target, name2) => {
1897
+ const member = Reflect.get(target, name2);
1893
1898
  if (typeof member !== "function") return member;
1894
1899
  return (...args) => {
1895
1900
  this.fds.flushEarly();
@@ -2117,13 +2122,13 @@ var init_wasi_host = __esm({
2117
2122
  } else if (e.type === "dir") this.setTimes(e.path, atim, mtim, flags);
2118
2123
  },
2119
2124
  fd_prestat_get: (fd, out) => {
2120
- const name = new TextEncoder().encode(fds.preopen(fd).preopen);
2125
+ const name2 = new TextEncoder().encode(fds.preopen(fd).preopen);
2121
2126
  mem.view().setUint8(out, PREOPENTYPE_DIR);
2122
- mem.view().setUint32(out + 4, name.length, true);
2127
+ mem.view().setUint32(out + 4, name2.length, true);
2123
2128
  },
2124
2129
  fd_prestat_dir_name: (fd, buf, len) => {
2125
- const name = new TextEncoder().encode(fds.preopen(fd).preopen);
2126
- mem.bytes(buf, Math.min(len, name.length)).set(name.subarray(0, len));
2130
+ const name2 = new TextEncoder().encode(fds.preopen(fd).preopen);
2131
+ mem.bytes(buf, Math.min(len, name2.length)).set(name2.subarray(0, len));
2127
2132
  },
2128
2133
  fd_readdir: (fd, buf, len, cookie, used) => void this.readdir(fd, buf, len, Number(cookie), used)
2129
2134
  };
@@ -2402,14 +2407,14 @@ var init_wasi_host = __esm({
2402
2407
  const { names, stats } = dir.listing;
2403
2408
  let at = 0;
2404
2409
  for (let i = cookie; i < names.length && at < len; i++) {
2405
- const name = names[i];
2406
- const full = name === "." ? dir.path : name === ".." ? normalize(`${dir.path}/..`) : resolveUnder(dir.path, name);
2407
- if (!stats.has(name)) stats.set(name, this.lstatOrNull(full));
2408
- const st = stats.get(name) ?? null;
2410
+ const name2 = names[i];
2411
+ const full = name2 === "." ? dir.path : name2 === ".." ? normalize(`${dir.path}/..`) : resolveUnder(dir.path, name2);
2412
+ if (!stats.has(name2)) stats.set(name2, this.lstatOrNull(full));
2413
+ const st = stats.get(name2) ?? null;
2409
2414
  const record = direntRecord(
2410
2415
  i + 1,
2411
2416
  st?.ino !== void 0 ? BigInt(st.ino) : pathInode(full),
2412
- name,
2417
+ name2,
2413
2418
  filetypeOf(st)
2414
2419
  );
2415
2420
  const n = Math.min(record.length, len - at);
@@ -2421,7 +2426,7 @@ var init_wasi_host = __esm({
2421
2426
  list(path) {
2422
2427
  const { fs } = this.o;
2423
2428
  const listed = fs.readdirStat(path);
2424
- return { names: [".", "..", ...listed.map(([name]) => name)], stats: new Map(listed) };
2429
+ return { names: [".", "..", ...listed.map(([name2]) => name2)], stats: new Map(listed) };
2425
2430
  }
2426
2431
  lstatOrNull(path) {
2427
2432
  try {
@@ -2483,18 +2488,18 @@ var init_wasix_process = __esm({
2483
2488
  environment() {
2484
2489
  return { ...this.host.o.env, PWD: this.host.cwd };
2485
2490
  }
2486
- locate(name, search, path) {
2487
- if (name.includes("/"))
2488
- return name.startsWith("/") ? name : normalize(`${this.host.cwd}/${name}`);
2489
- if (!search) return name;
2491
+ locate(name2, search, path) {
2492
+ if (name2.includes("/"))
2493
+ return name2.startsWith("/") ? name2 : normalize(`${this.host.cwd}/${name2}`);
2494
+ if (!search) return name2;
2490
2495
  for (const dir of path.split(":")) {
2491
2496
  if (!dir) continue;
2492
2497
  const candidate = normalize(
2493
- `${dir.startsWith("/") ? "" : `${this.host.cwd}/`}${dir}/${name}`
2498
+ `${dir.startsWith("/") ? "" : `${this.host.cwd}/`}${dir}/${name2}`
2494
2499
  );
2495
2500
  if (this.host.o.fs.exists(candidate)) return candidate;
2496
2501
  }
2497
- return name;
2502
+ return name2;
2498
2503
  }
2499
2504
  childFds(ops) {
2500
2505
  const { fds } = this.host;
@@ -2809,7 +2814,7 @@ function processes(host, call2, inThread) {
2809
2814
  const theirs = [];
2810
2815
  host.fds.promoteFiles();
2811
2816
  try {
2812
- const stdio = STDIO.map((name, n) => slot(n, o[name] ?? "inherit", mine, theirs));
2817
+ const stdio = STDIO.map((name2, n) => slot(n, o[name2] ?? "inherit", mine, theirs));
2813
2818
  const req = {
2814
2819
  op: "proc-spawn",
2815
2820
  file: o.argv[0],
@@ -2821,8 +2826,8 @@ function processes(host, call2, inThread) {
2821
2826
  };
2822
2827
  const pid = restarted(() => call2(req));
2823
2828
  const out = { pid };
2824
- STDIO.forEach((name, n) => {
2825
- if (mine[n] !== void 0) out[name] = mine[n];
2829
+ STDIO.forEach((name2, n) => {
2830
+ if (mine[n] !== void 0) out[name2] = mine[n];
2826
2831
  });
2827
2832
  return out;
2828
2833
  } catch (err) {
@@ -3388,7 +3393,7 @@ async function preflight(kernel, hows) {
3388
3393
  }
3389
3394
  }
3390
3395
  async function slots(kernel, o, mine, theirs) {
3391
- const hows = STDIO2.map((name) => o[name] ?? "inherit");
3396
+ const hows = STDIO2.map((name2) => o[name2] ?? "inherit");
3392
3397
  await preflight(kernel, hows);
3393
3398
  const stdio = [];
3394
3399
  for (const [n, how] of hows.entries()) {
@@ -3436,7 +3441,7 @@ function rewrite(hop, status2, location) {
3436
3441
  const toGet = (status2 === 301 || status2 === 302) && hop.method === "POST" || status2 === 303 && hop.method !== "GET" && hop.method !== "HEAD";
3437
3442
  const crossOrigin = next2.origin !== new URL(hop.url).origin;
3438
3443
  const headers = hop.headers.filter(
3439
- ([name]) => !(toGet && BODY_HEADERS.has(name.toLowerCase())) && !(crossOrigin && CREDENTIALS.has(name.toLowerCase()))
3444
+ ([name2]) => !(toGet && BODY_HEADERS.has(name2.toLowerCase())) && !(crossOrigin && CREDENTIALS.has(name2.toLowerCase()))
3440
3445
  );
3441
3446
  return {
3442
3447
  url: withoutFragment(next2),
@@ -3488,7 +3493,7 @@ function parameter(text, from, params) {
3488
3493
  while (SPACE.test(text[at] ?? "")) at++;
3489
3494
  let end = at;
3490
3495
  while (end < text.length && text[end] !== ";" && text[end] !== "=") end++;
3491
- const name = text.slice(at, end).toLowerCase();
3496
+ const name2 = text.slice(at, end).toLowerCase();
3492
3497
  if (text[end] !== "=") return end;
3493
3498
  const start2 = end + 1;
3494
3499
  let value2;
@@ -3501,8 +3506,8 @@ function parameter(text, from, params) {
3501
3506
  if (!value2) return end < 0 ? text.length : end;
3502
3507
  }
3503
3508
  if (end < 0) end = text.length;
3504
- if (TOKEN.test(name) && QUOTABLE.test(value2) && !params.has(name)) {
3505
- params.set(name, value2);
3509
+ if (TOKEN.test(name2) && QUOTABLE.test(value2) && !params.has(name2)) {
3510
+ params.set(name2, value2);
3506
3511
  }
3507
3512
  return end;
3508
3513
  }
@@ -3516,8 +3521,8 @@ function mimeType(input) {
3516
3521
  const params = /* @__PURE__ */ new Map();
3517
3522
  for (let at = semi < 0 ? text.length : semi; at < text.length; ) at = parameter(text, at, params);
3518
3523
  let out = `${type}/${subtype}`.toLowerCase();
3519
- for (const [name, value2] of params) {
3520
- out += `;${name}=${TOKEN.test(value2) ? value2 : `"${value2.replace(/["\\]/g, "\\$&")}"`}`;
3524
+ for (const [name2, value2] of params) {
3525
+ out += `;${name2}=${TOKEN.test(value2) ? value2 : `"${value2.replace(/["\\]/g, "\\$&")}"`}`;
3521
3526
  }
3522
3527
  return out;
3523
3528
  }
@@ -3718,7 +3723,7 @@ function fetchOp(kernel) {
3718
3723
  };
3719
3724
  for (let hops = 0; ; hops++) {
3720
3725
  const head = await send(hop, signal);
3721
- const location = head.headers.find(([name]) => name.toLowerCase() === "location")?.[1];
3726
+ const location = head.headers.find(([name2]) => name2.toLowerCase() === "location")?.[1];
3722
3727
  const follow2 = known.manualRedirects && REDIRECTS.has(head.status) && location !== void 0 && request.redirect !== "manual";
3723
3728
  if (!follow2) {
3724
3729
  const redirected = hops > 0 || head.redirected === true;
@@ -3863,9 +3868,9 @@ function port(n) {
3863
3868
  return n;
3864
3869
  }
3865
3870
  function netOps(kernel, io) {
3866
- const name = async (fd, peer) => addressOf(await kernel.json({ op: "sock-name", fd, peer }));
3871
+ const name2 = async (fd, peer) => addressOf(await kernel.json({ op: "sock-name", fd, peer }));
3867
3872
  const connection = async (fd) => {
3868
- const [local, remote] = [await name(fd, false), await name(fd, true)];
3873
+ const [local, remote] = [await name2(fd, false), await name2(fd, true)];
3869
3874
  const stop = new AbortController();
3870
3875
  let closed;
3871
3876
  const close = () => {
@@ -3947,7 +3952,7 @@ function netOps(kernel, io) {
3947
3952
  };
3948
3953
  await kernel.call({ op: "sock-bind", fd, addr });
3949
3954
  await kernel.call({ op: "sock-listen", fd, backlog: options.backlog ?? 128 });
3950
- return listener(fd, await name(fd, false));
3955
+ return listener(fd, await name2(fd, false));
3951
3956
  }),
3952
3957
  connect: async (options) => {
3953
3958
  const signal = options.signal ?? NEVER;
@@ -4444,10 +4449,25 @@ function ttyOps(kernel) {
4444
4449
  await kernel.call({ op: "tty-pgrp-set", fd, pgrp });
4445
4450
  }
4446
4451
  };
4452
+ const openOn = async (terminal, fd) => {
4453
+ const open = await kernel.json({ op: "fd-list" });
4454
+ const on = open.filter((entry) => entry.terminal === terminal);
4455
+ return (on.find((entry) => entry.fd === fd) ?? on[0])?.fd;
4456
+ };
4457
+ const reopened = async (terminal, termios) => {
4458
+ const fd = await kernel.json({ op: "fd-open-tty", name: terminal });
4459
+ try {
4460
+ await setAttr(fd, termios);
4461
+ } finally {
4462
+ await kernel.call({ op: "fd-close", fd });
4463
+ }
4464
+ };
4447
4465
  const restore = async () => {
4448
4466
  for (const [terminal, { fd, termios }] of [...saved].reverse()) {
4449
4467
  saved.delete(terminal);
4450
- await setAttr(fd, termios).catch(() => void 0);
4468
+ const at = await openOn(terminal, fd).catch(() => void 0);
4469
+ const back = at === void 0 ? reopened(terminal, termios) : setAttr(at, termios);
4470
+ await back.catch(() => void 0);
4451
4471
  }
4452
4472
  };
4453
4473
  return { tty, restore };
@@ -5078,13 +5098,13 @@ var init_js_runtime = __esm({
5078
5098
  });
5079
5099
 
5080
5100
  // src/kernel/net/loopback-names.ts
5081
- function reserved(name) {
5082
- const lower = name.toLowerCase();
5101
+ function reserved(name2) {
5102
+ const lower = name2.toLowerCase();
5083
5103
  return lower === "localhost" || lower.endsWith(".localhost") || lower === HOST_LOOPBACK || lower === "wasmer.sh" || /^\d+(\.\d+){3}$/.test(lower);
5084
5104
  }
5085
- function isHostname(name) {
5086
- if (typeof name !== "string" || name.length > 253 || reserved(name)) return false;
5087
- return name.split(".").every((l) => LABEL.test(l));
5105
+ function isHostname(name2) {
5106
+ if (typeof name2 !== "string" || name2.length > 253 || reserved(name2)) return false;
5107
+ return name2.split(".").every((l) => LABEL.test(l));
5088
5108
  }
5089
5109
  function hostnameOf(env) {
5090
5110
  return isHostname(env.HOSTNAME) ? env.HOSTNAME : DEFAULT_HOSTNAME;
@@ -5126,7 +5146,7 @@ var init_wasi_errno = __esm({
5126
5146
  "use strict";
5127
5147
  init_wasi_abi();
5128
5148
  WASI_ERRNO = {
5129
- ...Object.fromEntries(Object.entries(E).map(([name, errno2]) => [`E${name}`, errno2])),
5149
+ ...Object.fromEntries(Object.entries(E).map(([name2, errno2]) => [`E${name2}`, errno2])),
5130
5150
  EWOULDBLOCK: E.AGAIN,
5131
5151
  ENOTSUP: 138,
5132
5152
  EOPNOTSUPP: 138,
@@ -5204,8 +5224,8 @@ function createHelpers(Fs, ops) {
5204
5224
  function freshState(stat) {
5205
5225
  return { ...stat ? { stat } : {}, len: 0, loaded: false, dirty: false, openCount: 0 };
5206
5226
  }
5207
- function makeNode(parent, name, st) {
5208
- const node = Fs.createNode(parent, name, modeFromStat(st), 0);
5227
+ function makeNode(parent, name2, st) {
5228
+ const node = Fs.createNode(parent, name2, modeFromStat(st), 0);
5209
5229
  node.node_ops = ops.node;
5210
5230
  node.stream_ops = ops.stream;
5211
5231
  node.live = freshState(st);
@@ -5223,9 +5243,9 @@ function createHelpers(Fs, ops) {
5223
5243
  }
5224
5244
  return node.live.stat;
5225
5245
  }
5226
- function childPath(parent, name) {
5246
+ function childPath(parent, name2) {
5227
5247
  const base = liveNodePath(parent);
5228
- return base === "/" ? `/${name}` : `${base}/${name}`;
5248
+ return base === "/" ? `/${name2}` : `${base}/${name2}`;
5229
5249
  }
5230
5250
  function ensureLoaded(node) {
5231
5251
  const s = node.live;
@@ -5392,15 +5412,15 @@ function createNodeOps(h) {
5392
5412
  if (times) setTimes(node, path, ...times);
5393
5413
  node.live.stat = void 0;
5394
5414
  },
5395
- lookup(parent, name) {
5396
- const listed = parent.live.listed?.get(name);
5397
- parent.live.listed?.delete(name);
5398
- const st = listed ?? call2(() => bridgeOf(parent).lstat(childPath(parent, name)));
5399
- return makeNode(parent, name, st);
5415
+ lookup(parent, name2) {
5416
+ const listed = parent.live.listed?.get(name2);
5417
+ parent.live.listed?.delete(name2);
5418
+ const st = listed ?? call2(() => bridgeOf(parent).lstat(childPath(parent, name2)));
5419
+ return makeNode(parent, name2, st);
5400
5420
  },
5401
- mknod(parent, name, mode) {
5421
+ mknod(parent, name2, mode) {
5402
5422
  parent.live.listed = void 0;
5403
- const path = childPath(parent, name);
5423
+ const path = childPath(parent, name2);
5404
5424
  if (Fs.isDir(mode)) {
5405
5425
  call2(() => bridgeOf(parent).mkdir(path));
5406
5426
  const perm = mode & PERM_MASK & ~UMASK;
@@ -5413,7 +5433,7 @@ function createNodeOps(h) {
5413
5433
  } else {
5414
5434
  throw new Fs.ErrnoError(wasiErrno("EPERM"));
5415
5435
  }
5416
- const node = makeNode(parent, name, {
5436
+ const node = makeNode(parent, name2, {
5417
5437
  isFile: Fs.isFile(mode),
5418
5438
  isDirectory: Fs.isDir(mode),
5419
5439
  isSymbolicLink: false,
@@ -5440,11 +5460,11 @@ function createNodeOps(h) {
5440
5460
  oldNode.parent = newDir;
5441
5461
  oldNode.live.stat = void 0;
5442
5462
  },
5443
- unlink(parent, name) {
5463
+ unlink(parent, name2) {
5444
5464
  parent.live.listed = void 0;
5445
5465
  let open;
5446
5466
  try {
5447
- const node = Fs.lookupNode?.(parent, name);
5467
+ const node = Fs.lookupNode?.(parent, name2);
5448
5468
  if (node && node.live?.openCount > 0 && Fs.isFile(node.mode)) open = node;
5449
5469
  } catch {
5450
5470
  }
@@ -5454,18 +5474,18 @@ function createNodeOps(h) {
5454
5474
  if (ranged) ranged.pin();
5455
5475
  else ensureLoaded(open);
5456
5476
  }
5457
- call2(() => bridgeOf(parent).unlink(childPath(parent, name)));
5477
+ call2(() => bridgeOf(parent).unlink(childPath(parent, name2)));
5458
5478
  if (open) open.live.orphan = true;
5459
5479
  },
5460
- rmdir(parent, name) {
5480
+ rmdir(parent, name2) {
5461
5481
  parent.live.listed = void 0;
5462
- call2(() => bridgeOf(parent).rmdir(childPath(parent, name)));
5482
+ call2(() => bridgeOf(parent).rmdir(childPath(parent, name2)));
5463
5483
  },
5464
5484
  readdir(node) {
5465
5485
  const listed = call2(() => bridgeOf(node).readdirStat(liveNodePath(node)));
5466
5486
  node.live.listed = /* @__PURE__ */ new Map();
5467
- for (const [name, st] of listed) if (st) node.live.listed.set(name, st);
5468
- return [".", "..", ...listed.map(([name]) => name)];
5487
+ for (const [name2, st] of listed) if (st) node.live.listed.set(name2, st);
5488
+ return [".", "..", ...listed.map(([name2]) => name2)];
5469
5489
  },
5470
5490
  symlink(parent, newName, target) {
5471
5491
  parent.live.listed = void 0;
@@ -5728,28 +5748,28 @@ function liveRoot(Fs, bridge) {
5728
5748
  const memfs = root.memfs ?? root.node_ops;
5729
5749
  const live = plugin.node_ops;
5730
5750
  root.memfs = memfs;
5731
- const own = (name) => Object.hasOwn(root.contents ?? {}, name);
5751
+ const own = (name2) => Object.hasOwn(root.contents ?? {}, name2);
5732
5752
  root.node_ops = {
5733
5753
  ...memfs,
5734
- lookup: (parent, name) => live.lookup(parent, name),
5735
- mknod: (parent, name, mode, dev) => live.mknod(parent, name, mode, dev),
5736
- unlink: (parent, name) => live.unlink(parent, name),
5737
- rmdir: (parent, name) => (own(name) ? memfs : live).rmdir(parent, name),
5738
- symlink: (parent, name, target) => live.symlink(parent, name, target),
5739
- rename: (node, dir, name) => (node.live ? live : memfs).rename(node, dir, name),
5754
+ lookup: (parent, name2) => live.lookup(parent, name2),
5755
+ mknod: (parent, name2, mode, dev) => live.mknod(parent, name2, mode, dev),
5756
+ unlink: (parent, name2) => live.unlink(parent, name2),
5757
+ rmdir: (parent, name2) => (own(name2) ? memfs : live).rmdir(parent, name2),
5758
+ symlink: (parent, name2, target) => live.symlink(parent, name2, target),
5759
+ rename: (node, dir, name2) => (node.live ? live : memfs).rename(node, dir, name2),
5740
5760
  readdir(node) {
5741
5761
  const names = new Set(memfs.readdir(node));
5742
- for (const name of live.readdir(node)) names.add(name);
5762
+ for (const name2 of live.readdir(node)) names.add(name2);
5743
5763
  return [...names];
5744
5764
  }
5745
5765
  };
5746
5766
  }
5747
5767
  function crosses(Fs, from, to) {
5748
5768
  const parentOf = (path) => Fs.lookupPath?.(path, { parent: true }).node;
5749
- const name = from.replace(/\/+$/, "").split("/").pop() ?? "";
5769
+ const name2 = from.replace(/\/+$/, "").split("/").pop() ?? "";
5750
5770
  try {
5751
5771
  const fromDir = parentOf(from);
5752
- const node = fromDir && Fs.lookupNode?.(fromDir, name);
5772
+ const node = fromDir && Fs.lookupNode?.(fromDir, name2);
5753
5773
  const dir = parentOf(to);
5754
5774
  return !!node && !!dir && !!node.live !== !!dir.live;
5755
5775
  } catch {
@@ -5790,8 +5810,8 @@ function guardKeptNodes(Fs, handled) {
5790
5810
  Fs.sliccKept = true;
5791
5811
  const lookupPath = Fs.lookupPath.bind(Fs);
5792
5812
  Fs.open = (path, flags, mode) => {
5793
- const name = path.slice(path.lastIndexOf("/") + 1);
5794
- if (![...handled].some((held) => held.name === name)) return open(path, flags, mode);
5813
+ const name2 = path.slice(path.lastIndexOf("/") + 1);
5814
+ if (![...handled].some((held) => held.name === name2)) return open(path, flags, mode);
5795
5815
  let node;
5796
5816
  try {
5797
5817
  node = lookupPath(path, { follow: true }).node;
@@ -5839,7 +5859,7 @@ function topLevelDirs(bridge, warn) {
5839
5859
  warn(`cannot list the VFS root, nothing mounted: ${String(err)}`);
5840
5860
  return void 0;
5841
5861
  }
5842
- const candidates = names.filter((name) => name && !name.includes("/") && !MODULE_OWNED_DIRS.has(name)).map((name) => `/${name}`);
5862
+ const candidates = names.filter((name2) => name2 && !name2.includes("/") && !MODULE_OWNED_DIRS.has(name2)).map((name2) => `/${name2}`);
5843
5863
  for (const dir of SYNTHETIC_DIRS2) if (!candidates.includes(dir)) candidates.push(dir);
5844
5864
  const dirs = [];
5845
5865
  for (const dir of candidates) {
@@ -5984,14 +6004,14 @@ var init_kernel_streams = __esm({
5984
6004
  nameTerminal(stream) {
5985
6005
  const kfd = stream.sliccKernelFd;
5986
6006
  if (!stream.tty || kfd === void 0) return;
5987
- const name = this.sys.ttyName?.(kfd);
5988
- if (name) this.nameStream(stream, name);
6007
+ const name2 = this.sys.ttyName?.(kfd);
6008
+ if (name2) this.nameStream(stream, name2);
5989
6009
  }
5990
- nameStream(stream, name) {
5991
- stream.path = name;
5992
- this.ttyNode(name);
6010
+ nameStream(stream, name2) {
6011
+ stream.path = name2;
6012
+ this.ttyNode(name2);
5993
6013
  if (typeof this.Fs.stat !== "function") return;
5994
- stream.stream_ops = { ...stream.stream_ops, getattr: () => this.Fs.stat?.(name) ?? {} };
6014
+ stream.stream_ops = { ...stream.stream_ops, getattr: () => this.Fs.stat?.(name2) ?? {} };
5995
6015
  }
5996
6016
  creatingTerminal = false;
5997
6017
  useTerminalNodes() {
@@ -5999,12 +6019,12 @@ var init_kernel_streams = __esm({
5999
6019
  const { lookupNode, readdir, getPath, mkdev, makedev } = fs;
6000
6020
  const ttyNames = this.sys.ttyNames?.bind(this.sys);
6001
6021
  if (!lookupNode || !readdir || !getPath || !mkdev || !makedev || !ttyNames) return;
6002
- fs.lookupNode = (parent, name) => {
6022
+ fs.lookupNode = (parent, name2) => {
6003
6023
  try {
6004
- return lookupNode.call(fs, parent, name);
6024
+ return lookupNode.call(fs, parent, name2);
6005
6025
  } catch (e) {
6006
- const path = `/dev/${name}`;
6007
- if (this.creatingTerminal || !TTY_NAME.test(name) || getPath.call(fs, parent) !== "/dev")
6026
+ const path = `/dev/${name2}`;
6027
+ if (this.creatingTerminal || !TTY_NAME.test(name2) || getPath.call(fs, parent) !== "/dev")
6008
6028
  throw e;
6009
6029
  if (!ttyNames().includes(path)) throw e;
6010
6030
  this.creatingTerminal = true;
@@ -6013,21 +6033,21 @@ var init_kernel_streams = __esm({
6013
6033
  } finally {
6014
6034
  this.creatingTerminal = false;
6015
6035
  }
6016
- return lookupNode.call(fs, parent, name);
6036
+ return lookupNode.call(fs, parent, name2);
6017
6037
  }
6018
6038
  };
6019
6039
  fs.readdir = (path) => {
6020
6040
  const names = readdir.call(fs, path);
6021
6041
  if (path.replace(/\/+$/, "") !== "/dev") return names;
6022
- const missing = ttyNames().map((tty) => tty.slice("/dev/".length)).filter((name) => TTY_NAME.test(name) && !names.includes(name));
6042
+ const missing = ttyNames().map((tty) => tty.slice("/dev/".length)).filter((name2) => TTY_NAME.test(name2) && !names.includes(name2));
6023
6043
  return [...names, ...missing];
6024
6044
  };
6025
6045
  }
6026
- ttyNode(name) {
6046
+ ttyNode(name2) {
6027
6047
  const { analyzePath, mkdev, makedev } = this.Fs;
6028
- if (!TTY_PATH.test(name) || !analyzePath || !mkdev || !makedev) return;
6029
- if (!analyzePath.call(this.Fs, name).exists)
6030
- mkdev.call(this.Fs, name, makedev.call(this.Fs, 6, 0));
6048
+ if (!TTY_PATH.test(name2) || !analyzePath || !mkdev || !makedev) return;
6049
+ if (!analyzePath.call(this.Fs, name2).exists)
6050
+ mkdev.call(this.Fs, name2, makedev.call(this.Fs, 6, 0));
6031
6051
  }
6032
6052
  ttyOps(kfd) {
6033
6053
  return {
@@ -6064,18 +6084,18 @@ var init_kernel_streams = __esm({
6064
6084
  size: this.call(() => size.call(this.sys, kfd))
6065
6085
  }));
6066
6086
  }
6067
- describe(stream, name, getattr) {
6087
+ describe(stream, name2, getattr) {
6068
6088
  if (this.descriptions.size === 0) this.useDescriptions();
6069
- this.descriptions.set(name, getattr);
6070
- stream.path = name;
6089
+ this.descriptions.set(name2, getattr);
6090
+ stream.path = name2;
6071
6091
  stream.stream_ops = { ...stream.stream_ops, getattr };
6072
6092
  }
6073
6093
  useDescriptions() {
6074
6094
  const fs = this.Fs;
6075
- for (const name of ["stat", "lstat"]) {
6076
- const original = fs[name];
6095
+ for (const name2 of ["stat", "lstat"]) {
6096
+ const original = fs[name2];
6077
6097
  if (typeof original !== "function") continue;
6078
- fs[name] = (path, ...rest2) => {
6098
+ fs[name2] = (path, ...rest2) => {
6079
6099
  const getattr = this.descriptions.get(path);
6080
6100
  return getattr ? getattr() : original.call(fs, path, ...rest2);
6081
6101
  };
@@ -6162,15 +6182,15 @@ var init_kernel_streams = __esm({
6162
6182
  }
6163
6183
  usePtyPaths() {
6164
6184
  const fs = this.Fs;
6165
- for (const name of ["chown", "lchown", "chmod", "lchmod"]) {
6166
- const original = fs[name];
6185
+ for (const name2 of ["chown", "lchown", "chmod", "lchmod"]) {
6186
+ const original = fs[name2];
6167
6187
  if (typeof original !== "function") continue;
6168
- fs[name] = (path, ...rest2) => isPtyPath(path) ? this.existingPty(path) : original.call(fs, path, ...rest2);
6188
+ fs[name2] = (path, ...rest2) => isPtyPath(path) ? this.existingPty(path) : original.call(fs, path, ...rest2);
6169
6189
  }
6170
- for (const name of ["stat", "lstat"]) {
6171
- const original = fs[name];
6190
+ for (const name2 of ["stat", "lstat"]) {
6191
+ const original = fs[name2];
6172
6192
  if (typeof original !== "function") continue;
6173
- fs[name] = (path, ...rest2) => {
6193
+ fs[name2] = (path, ...rest2) => {
6174
6194
  if (!isPtyPath(path)) return original.call(fs, path, ...rest2);
6175
6195
  this.existingPty(path);
6176
6196
  return ptyStat(path);
@@ -6183,14 +6203,14 @@ var init_kernel_streams = __esm({
6183
6203
  if (!exists) throw new this.Fs.ErrnoError(wasiErrno("ENOENT"));
6184
6204
  }
6185
6205
  devicePath(path) {
6186
- const name = path.slice(path.lastIndexOf("/") + 1);
6187
- if (!TTY_NAME.test(name)) return void 0;
6206
+ const name2 = path.slice(path.lastIndexOf("/") + 1);
6207
+ if (!TTY_NAME.test(name2)) return void 0;
6188
6208
  const { lookupPath, cwd } = this.Fs;
6189
6209
  const absolute = path.startsWith("/") ? path : `${cwd?.call(this.Fs) ?? "/"}/${path}`;
6190
6210
  const dir = absolute.slice(0, absolute.lastIndexOf("/")) || "/";
6191
6211
  try {
6192
6212
  const real = lookupPath?.call(this.Fs, dir, { follow: true }).path ?? dir;
6193
- return `${real === "/" ? "" : real}/${name}`;
6213
+ return `${real === "/" ? "" : real}/${name2}`;
6194
6214
  } catch {
6195
6215
  return absolute;
6196
6216
  }
@@ -6487,11 +6507,11 @@ function kernelTimer(setitimer, timer) {
6487
6507
  return 0;
6488
6508
  };
6489
6509
  }
6490
- function syscallOf(glue, name, value2) {
6510
+ function syscallOf(glue, name2, value2) {
6491
6511
  const names = Object.keys(IMPORT_NAMES);
6492
6512
  const own = names.find((key) => glue[key] !== void 0 && glue[key] === value2);
6493
6513
  if (own) return own;
6494
- return typeof value2 === "function" ? names.find((key) => glue[key] !== void 0 && IMPORT_NAMES[key] === name) : void 0;
6514
+ return typeof value2 === "function" ? names.find((key) => glue[key] !== void 0 && IMPORT_NAMES[key] === name2) : void 0;
6495
6515
  }
6496
6516
  function wrapCloexecSyscalls(imports, glue, deps) {
6497
6517
  if (!glue) return;
@@ -6500,10 +6520,10 @@ function wrapCloexecSyscalls(imports, glue, deps) {
6500
6520
  for (const namespace of Object.values(imports)) {
6501
6521
  if (!namespace || typeof namespace !== "object" || seen.has(namespace)) continue;
6502
6522
  seen.add(namespace);
6503
- for (const [name, value2] of Object.entries(namespace)) {
6504
- const key = syscallOf(glue, name, value2);
6523
+ for (const [name2, value2] of Object.entries(namespace)) {
6524
+ const key = syscallOf(glue, name2, value2);
6505
6525
  const wrap2 = key && factories[key];
6506
- if (wrap2) namespace[name] = wrap2(value2);
6526
+ if (wrap2) namespace[name2] = wrap2(value2);
6507
6527
  }
6508
6528
  }
6509
6529
  }
@@ -6547,7 +6567,7 @@ function kernelUmask(imports, deps) {
6547
6567
  function noFollowUtimes(imports, fs, glue) {
6548
6568
  for (const namespace of namespaces(imports)) {
6549
6569
  const key = Object.keys(namespace).find(
6550
- (name) => glue !== void 0 && namespace[name] === glue || name === "__syscall_utimensat"
6570
+ (name2) => glue !== void 0 && namespace[name2] === glue || name2 === "__syscall_utimensat"
6551
6571
  );
6552
6572
  const utimensat = key === void 0 ? void 0 : namespace[key];
6553
6573
  if (key === void 0 || typeof utimensat !== "function") continue;
@@ -6587,10 +6607,10 @@ function namespaces(imports) {
6587
6607
  }
6588
6608
  return [...seen];
6589
6609
  }
6590
- function keyOf(namespace, name, glue) {
6591
- const own = glue?.[name];
6610
+ function keyOf(namespace, name2, glue) {
6611
+ const own = glue?.[name2];
6592
6612
  const found = typeof own === "function" ? Object.keys(namespace).find((k) => namespace[k] === own) : void 0;
6593
- return found ?? (typeof namespace[name] === "function" ? name : void 0);
6613
+ return found ?? (typeof namespace[name2] === "function" ? name2 : void 0);
6594
6614
  }
6595
6615
  function syncFsync(imports, fs, glue) {
6596
6616
  for (const namespace of namespaces(imports)) {
@@ -6654,11 +6674,11 @@ function positioned(original, write2, deps) {
6654
6674
  }
6655
6675
  function positionalIo(imports, deps) {
6656
6676
  for (const namespace of namespaces(imports)) {
6657
- for (const [name, write2] of [
6677
+ for (const [name2, write2] of [
6658
6678
  ["fd_pread", false],
6659
6679
  ["fd_pwrite", true]
6660
6680
  ]) {
6661
- const key = keyOf(namespace, name, deps.glue);
6681
+ const key = keyOf(namespace, name2, deps.glue);
6662
6682
  if (key !== void 0) {
6663
6683
  namespace[key] = positioned(namespace[key], write2, deps);
6664
6684
  }
@@ -6760,8 +6780,8 @@ function describeFdDir(Fs) {
6760
6780
  dir.node_ops = {
6761
6781
  ...ops,
6762
6782
  getattr: () => syntheticAttr(DIR_MODE, 1),
6763
- lookup: (parent, name) => {
6764
- const entry = lookup(parent, name);
6783
+ lookup: (parent, name2) => {
6784
+ const entry = lookup(parent, name2);
6765
6785
  entry.node_ops = {
6766
6786
  ...entry.node_ops,
6767
6787
  getattr: () => syntheticAttr(LINK_MODE, entry.id ?? 0)
@@ -6798,13 +6818,13 @@ function useZeroDevices(Fs) {
6798
6818
  function linkStdio(Fs) {
6799
6819
  const { unlink, symlink } = Fs;
6800
6820
  if (!unlink || !symlink) return;
6801
- for (const [fd, name] of ["stdin", "stdout", "stderr"].entries()) {
6821
+ for (const [fd, name2] of ["stdin", "stdout", "stderr"].entries()) {
6802
6822
  try {
6803
- unlink.call(Fs, `/dev/${name}`);
6823
+ unlink.call(Fs, `/dev/${name2}`);
6804
6824
  } catch {
6805
6825
  }
6806
6826
  try {
6807
- symlink.call(Fs, `/proc/self/fd/${fd}`, `/dev/${name}`);
6827
+ symlink.call(Fs, `/proc/self/fd/${fd}`, `/dev/${name2}`);
6808
6828
  } catch {
6809
6829
  }
6810
6830
  }
@@ -6856,14 +6876,14 @@ function mountTable(mounts = []) {
6856
6876
  }
6857
6877
  function accounts(env = {}) {
6858
6878
  const user = env.USER ?? "web_user";
6859
- const name = NAME.test(user) && user !== "root" ? user : "user";
6879
+ const name2 = NAME.test(user) && user !== "root" ? user : "user";
6860
6880
  const home = env.HOME || "/home";
6861
6881
  return {
6862
6882
  passwd: `root:x:0:0:root:/root:/bin/sh
6863
- ${name}:x:1000:1000:${name}:${home}:/bin/bash
6883
+ ${name2}:x:1000:1000:${name2}:${home}:/bin/bash
6864
6884
  `,
6865
6885
  group: `root:x:0:
6866
- ${name}:x:1000:
6886
+ ${name2}:x:1000:
6867
6887
  `
6868
6888
  };
6869
6889
  }
@@ -7672,9 +7692,9 @@ function createSocketKernel(deps) {
7672
7692
  }),
7673
7693
  shutdown: (fd, how) => guard(() => done({ op: "sock-shutdown", fd: kfd(fd), how })),
7674
7694
  name: (fd, peer) => guard(() => json({ op: "sock-name", fd: kfd(fd), peer })),
7675
- getopt: (fd, level, name) => guard(() => ({ value: json({ op: "sock-getopt", fd: kfd(fd), level, name }) })),
7676
- setopt: (fd, level, name, value2) => guard(() => done({ op: "sock-setopt", fd: kfd(fd), level, name, value: value2 })),
7677
- resolve: (name, family = 4) => guard(() => json({ op: "sock-resolve", name, family })),
7695
+ getopt: (fd, level, name2) => guard(() => ({ value: json({ op: "sock-getopt", fd: kfd(fd), level, name: name2 }) })),
7696
+ setopt: (fd, level, name2, value2) => guard(() => done({ op: "sock-setopt", fd: kfd(fd), level, name: name2, value: value2 })),
7697
+ resolve: (name2, family = 4) => guard(() => json({ op: "sock-resolve", name: name2, family })),
7678
7698
  send: (fd, bytes, flags) => guard(() => {
7679
7699
  const stream = socketAt(fd);
7680
7700
  const nonblock = flags.dontwait === true || (stream.flags & O_NONBLOCK2) !== 0;
@@ -7712,8 +7732,8 @@ var init_process_sockets = __esm({
7712
7732
 
7713
7733
  // src/process/procfs.ts
7714
7734
  function commOf(info) {
7715
- const name = info.argv[0] ?? "";
7716
- return name.slice(name.lastIndexOf("/") + 1).slice(0, 15);
7735
+ const name2 = info.argv[0] ?? "";
7736
+ return name2.slice(name2.lastIndexOf("/") + 1).slice(0, 15);
7717
7737
  }
7718
7738
  function ttyNumber(tty) {
7719
7739
  const pts = tty && /^\/dev\/pts\/(\d+)$/.exec(tty);
@@ -7800,12 +7820,12 @@ function pidStatus(info) {
7800
7820
  ""
7801
7821
  ].join("\n");
7802
7822
  }
7803
- function pidFile(name, info, boot) {
7804
- if (name === "cmdline") return info.state === "Z" ? "" : `${info.argv.join("\0")}\0`;
7805
- if (name === "comm") return `${commOf(info)}
7823
+ function pidFile(name2, info, boot) {
7824
+ if (name2 === "cmdline") return info.state === "Z" ? "" : `${info.argv.join("\0")}\0`;
7825
+ if (name2 === "comm") return `${commOf(info)}
7806
7826
  `;
7807
- if (name === "stat") return pidStat(info, boot);
7808
- if (name === "statm") {
7827
+ if (name2 === "stat") return pidStat(info, boot);
7828
+ if (name2 === "statm") {
7809
7829
  const p = pages(info.memory);
7810
7830
  return `${p} ${p} 0 0 0 ${p} 0
7811
7831
  `;
@@ -7829,18 +7849,18 @@ function memoryInfo(source, used = 0) {
7829
7849
  ["SwapFree", kb(0)]
7830
7850
  ].map(([key, value2]) => `${`${key}:`.padEnd(16)}${value2.padStart(12)}`).concat("").join("\n");
7831
7851
  }
7832
- function systemFile(name, listing, now, memory) {
7852
+ function systemFile(name2, listing, now, memory) {
7833
7853
  const up = Math.max(0, now - listing.boot) / 1e3;
7834
- if (name === "uptime") return `${up.toFixed(2)} ${up.toFixed(2)}
7854
+ if (name2 === "uptime") return `${up.toFixed(2)} ${up.toFixed(2)}
7835
7855
  `;
7836
- if (name === "meminfo") {
7856
+ if (name2 === "meminfo") {
7837
7857
  return memoryInfo(
7838
7858
  memory,
7839
7859
  listing.processes.reduce((sum, p) => sum + p.memory, 0)
7840
7860
  );
7841
7861
  }
7842
7862
  const live = listing.processes.filter((p) => p.state !== "Z");
7843
- if (name === "loadavg") {
7863
+ if (name2 === "loadavg") {
7844
7864
  const last = Math.max(0, ...listing.processes.map((p) => p.pid));
7845
7865
  return `0.00 0.00 0.00 1/${live.length} ${last}
7846
7866
  `;
@@ -7899,8 +7919,8 @@ function useProcfs(Fs, sys, pid, memory = memorySource()) {
7899
7919
  return;
7900
7920
  }
7901
7921
  const error = (errno2 = ENOENT) => new Fs.ErrnoError(errno2);
7902
- const fresh = (parent, name, mode) => {
7903
- const node = createNode.call(Fs, parent, name, mode, 0);
7922
+ const fresh = (parent, name2, mode) => {
7923
+ const node = createNode.call(Fs, parent, name2, mode, 0);
7904
7924
  hashRemoveNode.call(Fs, node);
7905
7925
  node.node_ops = { getattr: attr, setattr: () => {
7906
7926
  } };
@@ -7913,8 +7933,8 @@ function useProcfs(Fs, sys, pid, memory = memorySource()) {
7913
7933
  };
7914
7934
  return node;
7915
7935
  };
7916
- const file = (parent, name, content) => {
7917
- const node = fresh(parent, name, FILE_MODE);
7936
+ const file = (parent, name2, content) => {
7937
+ const node = fresh(parent, name2, FILE_MODE);
7918
7938
  node.stream_ops = {
7919
7939
  open: (stream) => {
7920
7940
  stream.sliccProc = new TextEncoder().encode(content());
@@ -7936,15 +7956,15 @@ function useProcfs(Fs, sys, pid, memory = memorySource()) {
7936
7956
  };
7937
7957
  const find = (processes2, target, own) => (own ? processes2.find((p) => p.tid === target) : void 0) ?? processes2.find((p) => p.pid === target || p.tid === target);
7938
7958
  const infoOf = (target) => find(procList().processes, target, false);
7939
- const pidContent = (target, name, own = false) => () => {
7959
+ const pidContent = (target, name2, own = false) => () => {
7940
7960
  const listing = procList();
7941
7961
  const info = find(listing.processes, target, own);
7942
7962
  if (!info) throw error(ESRCH);
7943
- return pidFile(name, info, listing.boot);
7963
+ return pidFile(name2, info, listing.boot);
7944
7964
  };
7945
7965
  const pidNames = (names) => [.../* @__PURE__ */ new Set([...names, ...PID_FILES])];
7946
- const pidDir = (name, target) => {
7947
- const dir = fresh(proc, name, DIR_MODE2);
7966
+ const pidDir = (name2, target) => {
7967
+ const dir = fresh(proc, name2, DIR_MODE2);
7948
7968
  dir.node_ops.lookup = (parent, child) => {
7949
7969
  if (!PID_FILES.includes(child)) throw error();
7950
7970
  return file(parent, child, pidContent(target, child));
@@ -7957,25 +7977,25 @@ function useProcfs(Fs, sys, pid, memory = memorySource()) {
7957
7977
  const readdir = procOps.readdir?.bind(procOps);
7958
7978
  proc.node_ops = {
7959
7979
  ...procOps,
7960
- lookup: (parent, name) => {
7961
- if (/^[1-9]\d*$/.test(name)) {
7962
- if (!infoOf(Number(name))) throw error();
7963
- return pidDir(name, Number(name));
7980
+ lookup: (parent, name2) => {
7981
+ if (/^[1-9]\d*$/.test(name2)) {
7982
+ if (!infoOf(Number(name2))) throw error();
7983
+ return pidDir(name2, Number(name2));
7964
7984
  }
7965
- if (name === "mounts") return file(parent, name, () => mountTable(sys.mountList?.() ?? []));
7966
- if (SYSTEM_FILES.includes(name)) {
7985
+ if (name2 === "mounts") return file(parent, name2, () => mountTable(sys.mountList?.() ?? []));
7986
+ if (SYSTEM_FILES.includes(name2)) {
7967
7987
  return file(
7968
7988
  parent,
7969
- name,
7970
- () => systemFile(name, procList(), Date.now(), memory)
7989
+ name2,
7990
+ () => systemFile(name2, procList(), Date.now(), memory)
7971
7991
  );
7972
7992
  }
7973
7993
  if (!lookup) throw error();
7974
- return lookup(parent, name);
7994
+ return lookup(parent, name2);
7975
7995
  },
7976
7996
  readdir: (node) => {
7977
7997
  const names = new Set(readdir ? readdir(node) : [".", ".."]);
7978
- for (const name of [...SYSTEM_FILES, "mounts"]) names.add(name);
7998
+ for (const name2 of [...SYSTEM_FILES, "mounts"]) names.add(name2);
7979
7999
  for (const p of procList().processes) names.add(String(p.pid));
7980
8000
  return [...names];
7981
8001
  }
@@ -7985,18 +8005,18 @@ function useProcfs(Fs, sys, pid, memory = memorySource()) {
7985
8005
  const shownPid = () => String(find(procList().processes, pid, true)?.pid ?? pid);
7986
8006
  link.node_ops.readlink = shownPid;
7987
8007
  const procLookup = proc.node_ops.lookup;
7988
- proc.node_ops.lookup = (parent, name) => name === "self" ? link : name === shownPid() ? self : procLookup(parent, name);
8008
+ proc.node_ops.lookup = (parent, name2) => name2 === "self" ? link : name2 === shownPid() ? self : procLookup(parent, name2);
7989
8009
  const selfOps = self.node_ops;
7990
8010
  const selfLookup = selfOps.lookup?.bind(selfOps);
7991
8011
  const selfReaddir = selfOps.readdir?.bind(selfOps);
7992
8012
  self.node_ops = {
7993
8013
  ...selfOps,
7994
- lookup: (parent, name) => {
7995
- if (PID_FILES.includes(name)) {
7996
- return file(parent, name, pidContent(pid, name, true));
8014
+ lookup: (parent, name2) => {
8015
+ if (PID_FILES.includes(name2)) {
8016
+ return file(parent, name2, pidContent(pid, name2, true));
7997
8017
  }
7998
8018
  if (!selfLookup) throw error();
7999
- return selfLookup(parent, name);
8019
+ return selfLookup(parent, name2);
8000
8020
  },
8001
8021
  readdir: (node) => pidNames(selfReaddir ? selfReaddir(node) : [".", ".."])
8002
8022
  };
@@ -8131,9 +8151,9 @@ function kernelSys(transport) {
8131
8151
  ttyNames() {
8132
8152
  return json(call2({ op: "fd-tty-names" }, "fd-tty-names"));
8133
8153
  },
8134
- openTty(name) {
8135
- const req = name === void 0 ? { op: "fd-open-tty" } : { op: "fd-open-tty", name };
8136
- return json(call2(req, `fd-open-tty ${name ?? ""}`));
8154
+ openTty(name2) {
8155
+ const req = name2 === void 0 ? { op: "fd-open-tty" } : { op: "fd-open-tty", name: name2 };
8156
+ return json(call2(req, `fd-open-tty ${name2 ?? ""}`));
8137
8157
  },
8138
8158
  tcgets(fd) {
8139
8159
  return json(call2({ op: "tty-get", fd }, `tty-get ${fd}`));
@@ -8224,8 +8244,8 @@ function wireKernelStdio(Fs, streams, sys) {
8224
8244
  function glueBody(glue) {
8225
8245
  return glue.startsWith("#!") ? glue.slice(glue.indexOf("\n") + 1) : glue;
8226
8246
  }
8227
- function ownValue(module, name) {
8228
- const own = Object.getOwnPropertyDescriptor(module, name);
8247
+ function ownValue(module, name2) {
8248
+ const own = Object.getOwnPropertyDescriptor(module, name2);
8229
8249
  return own && "value" in own ? own.value : void 0;
8230
8250
  }
8231
8251
  function identify(transport, init) {
@@ -8555,9 +8575,9 @@ var init_process_runtime = __esm({
8555
8575
 
8556
8576
  // src/process/wasi/dylink.ts
8557
8577
  function dylinkInfo(module) {
8558
- const [section] = WebAssembly.Module.customSections(module, "dylink.0");
8559
- if (!section) return void 0;
8560
- const bytes = new Uint8Array(section);
8578
+ const [section2] = WebAssembly.Module.customSections(module, "dylink.0");
8579
+ if (!section2) return void 0;
8580
+ const bytes = new Uint8Array(section2);
8561
8581
  let at = 0;
8562
8582
  const uleb = () => {
8563
8583
  let value2 = 0;
@@ -8625,6 +8645,191 @@ var init_wasi_module = __esm({
8625
8645
  }
8626
8646
  });
8627
8647
 
8648
+ // src/process/wasi/wasi-procfs.ts
8649
+ function inProc(path) {
8650
+ return path === "/proc" || path.startsWith("/proc/");
8651
+ }
8652
+ function procfsBridge(fs, tree) {
8653
+ const over = {
8654
+ readFile: (p) => inProc(p) ? tree.read(p) : fs.readFile(p),
8655
+ stat: (p) => inProc(p) ? tree.stat(p) : fs.stat(p),
8656
+ lstat: (p) => inProc(p) ? tree.stat(p, false) : fs.lstat(p),
8657
+ readdir: (p) => {
8658
+ if (inProc(p)) return tree.readdir(p);
8659
+ const names = fs.readdir(p);
8660
+ return p === "/" && !names.includes("proc") ? [...names, "proc"] : names;
8661
+ },
8662
+ exists: (p) => inProc(p) ? tree.exists(p) : fs.exists(p),
8663
+ readlink: (p) => inProc(p) ? tree.readlink(p) : fs.readlink(p),
8664
+ readdirStat: (p) => {
8665
+ if (!inProc(p)) {
8666
+ const listed = fs.readdirStat(p);
8667
+ if (p !== "/" || listed.some(([name2]) => name2 === "proc")) return listed;
8668
+ return [...listed, ["proc", tree.stat("/proc")]];
8669
+ }
8670
+ return tree.readdir(p).map((name2) => {
8671
+ try {
8672
+ return [name2, tree.stat(`${p}/${name2}`, false)];
8673
+ } catch {
8674
+ return [name2, null];
8675
+ }
8676
+ });
8677
+ },
8678
+ rename: (from, to) => {
8679
+ if (inProc(from) || inProc(to)) throw syncError("EROFS", from);
8680
+ fs.rename(from, to);
8681
+ },
8682
+ hold: (p, ...rest2) => inProc(p) ? void 0 : fs.hold?.(p, ...rest2),
8683
+ ...fs.pread ? {
8684
+ pread: (p, at, n, version) => inProc(p) ? tree.read(p).subarray(at, at + n) : fs.pread(p, at, n, version)
8685
+ } : {}
8686
+ };
8687
+ for (const name2 of READ_ONLY) {
8688
+ const fn = fs[name2];
8689
+ if (!fn) continue;
8690
+ over[name2] = (p, ...rest2) => {
8691
+ if (inProc(p)) throw syncError("EROFS", p);
8692
+ return fn.call(fs, p, ...rest2);
8693
+ };
8694
+ }
8695
+ return new Proxy(fs, {
8696
+ get: (target, key, receiver) => key in over ? over[key] : Reflect.get(target, key, receiver)
8697
+ });
8698
+ }
8699
+ var DIR_MODE3, FILE_MODE2, LINK_MODE3, PID_NAMES, SYSTEM_NAMES, ProcTree, READ_ONLY;
8700
+ var init_wasi_procfs = __esm({
8701
+ "src/process/wasi/wasi-procfs.ts"() {
8702
+ "use strict";
8703
+ init_sync_fs_wire();
8704
+ init_process_fds();
8705
+ init_procfs();
8706
+ DIR_MODE3 = 16749;
8707
+ FILE_MODE2 = 33060;
8708
+ LINK_MODE3 = 41471;
8709
+ PID_NAMES = PID_FILES;
8710
+ SYSTEM_NAMES = SYSTEM_FILES;
8711
+ ProcTree = class {
8712
+ source;
8713
+ pid;
8714
+ memory;
8715
+ constructor(source, pid, memory = memorySource()) {
8716
+ this.source = source;
8717
+ this.pid = pid;
8718
+ this.memory = memory;
8719
+ }
8720
+ listing() {
8721
+ return this.source.procList();
8722
+ }
8723
+ alive(pid) {
8724
+ return this.listing().processes.some((p) => p.pid === pid);
8725
+ }
8726
+ node(parts) {
8727
+ const [top, leaf, ...rest2] = parts;
8728
+ if (top === void 0) {
8729
+ return {
8730
+ kind: "dir",
8731
+ names: () => [
8732
+ ...SYSTEM_NAMES,
8733
+ "mounts",
8734
+ "self",
8735
+ ...this.listing().processes.map((p) => String(p.pid))
8736
+ ]
8737
+ };
8738
+ }
8739
+ if (top === "self") {
8740
+ return leaf === void 0 ? { kind: "link", target: String(this.pid) } : void 0;
8741
+ }
8742
+ if (leaf === void 0 && top === "mounts") {
8743
+ return { kind: "file", content: () => mountTable(this.source.mountList()) };
8744
+ }
8745
+ if (leaf === void 0 && SYSTEM_NAMES.includes(top)) {
8746
+ return {
8747
+ kind: "file",
8748
+ content: () => systemFile(top, this.listing(), Date.now(), this.memory)
8749
+ };
8750
+ }
8751
+ if (!/^[1-9]\d*$/.test(top) || rest2.length > 0 || !this.alive(Number(top))) return void 0;
8752
+ if (leaf === void 0) return { kind: "dir", names: () => [...PID_NAMES] };
8753
+ if (!PID_NAMES.includes(leaf)) return void 0;
8754
+ return {
8755
+ kind: "file",
8756
+ content: () => {
8757
+ const listing = this.listing();
8758
+ const info = listing.processes.find((p) => p.pid === Number(top));
8759
+ if (!info) throw syncError("ENOENT", `/proc/${top}/${leaf}`);
8760
+ return pidFile(leaf, info, listing.boot);
8761
+ }
8762
+ };
8763
+ }
8764
+ parts(path, follow2) {
8765
+ const parts = path.split("/").filter((p) => p !== "").slice(1);
8766
+ if (parts[0] === "self" && (follow2 || parts.length > 1)) parts[0] = String(this.pid);
8767
+ return parts;
8768
+ }
8769
+ find(path, follow2) {
8770
+ const node = this.node(this.parts(path, follow2));
8771
+ if (!node) throw syncError("ENOENT", path);
8772
+ return node;
8773
+ }
8774
+ stat(path, follow2 = true) {
8775
+ const node = this.find(path, follow2);
8776
+ const base = {
8777
+ isFile: false,
8778
+ isDirectory: false,
8779
+ size: 0,
8780
+ mtimeMs: Date.now(),
8781
+ readonly: true
8782
+ };
8783
+ if (node.kind === "dir") return { ...base, isDirectory: true, mode: DIR_MODE3 };
8784
+ if (node.kind === "link") {
8785
+ return { ...base, isSymbolicLink: true, mode: LINK_MODE3, size: node.target.length };
8786
+ }
8787
+ return { ...base, isFile: true, mode: FILE_MODE2, size: this.bytes(node).length };
8788
+ }
8789
+ bytes(node) {
8790
+ return new TextEncoder().encode(node.kind === "file" ? node.content() : "");
8791
+ }
8792
+ read(path) {
8793
+ const node = this.find(path, true);
8794
+ if (node.kind !== "file") throw syncError("EISDIR", path);
8795
+ return this.bytes(node);
8796
+ }
8797
+ readdir(path) {
8798
+ const node = this.find(path, true);
8799
+ if (node.kind !== "dir") throw syncError("ENOTDIR", path);
8800
+ return node.names();
8801
+ }
8802
+ readlink(path) {
8803
+ const node = this.find(path, false);
8804
+ if (node.kind !== "link") throw syncError("EINVAL", path);
8805
+ return node.target;
8806
+ }
8807
+ exists(path) {
8808
+ try {
8809
+ this.find(path, true);
8810
+ return true;
8811
+ } catch {
8812
+ return false;
8813
+ }
8814
+ }
8815
+ };
8816
+ READ_ONLY = [
8817
+ "writeFile",
8818
+ "mkdir",
8819
+ "rm",
8820
+ "unlink",
8821
+ "rmdir",
8822
+ "symlink",
8823
+ "chmod",
8824
+ "utimes",
8825
+ "lutimes",
8826
+ "create",
8827
+ "pwrite",
8828
+ "truncate"
8829
+ ];
8830
+ }
8831
+ });
8832
+
8628
8833
  // src/process/wasi/wasi-signals.ts
8629
8834
  var DELIVERED_MASK, KERNEL_DEFAULTS, LIBC_DEFAULT_EXIT, SA_RESTART, DISPOSITION_IGNORE, DISPOSITION_HANDLER, withBit, WASIX_LIBC_DEFAULT_LINE, WasiSignals;
8630
8835
  var init_wasi_signals = __esm({
@@ -8665,8 +8870,8 @@ var init_wasi_signals = __esm({
8665
8870
  bind(exports) {
8666
8871
  this.exports = exports;
8667
8872
  }
8668
- register(name) {
8669
- if (typeof this.exports?.[name] === "function") this.callback = name;
8873
+ register(name2) {
8874
+ if (typeof this.exports?.[name2] === "function") this.callback = name2;
8670
8875
  }
8671
8876
  useHook() {
8672
8877
  this.hooked = true;
@@ -8763,11 +8968,11 @@ var init_wasi_stats = __esm({
8763
8968
  mark = performance.now();
8764
8969
  wrap(tag, table) {
8765
8970
  return Object.fromEntries(
8766
- Object.entries(table).map(([name, value2]) => {
8767
- if (typeof value2 !== "function") return [name, value2];
8971
+ Object.entries(table).map(([name2, value2]) => {
8972
+ if (typeof value2 !== "function") return [name2, value2];
8768
8973
  const fn = value2;
8769
- const key = `${tag}.${name}`;
8770
- return [name, (...args) => this.time(key, () => fn.apply(table, args))];
8974
+ const key = `${tag}.${name2}`;
8975
+ return [name2, (...args) => this.time(key, () => fn.apply(table, args))];
8771
8976
  })
8772
8977
  );
8773
8978
  }
@@ -8779,9 +8984,9 @@ var init_wasi_stats = __esm({
8779
8984
  this.count(key, performance.now() - t);
8780
8985
  }
8781
8986
  }
8782
- phase(name) {
8987
+ phase(name2) {
8783
8988
  const now = performance.now();
8784
- this.phases.push([name, now - this.mark]);
8989
+ this.phases.push([name2, now - this.mark]);
8785
8990
  this.mark = now;
8786
8991
  }
8787
8992
  count(key, ms) {
@@ -8793,7 +8998,7 @@ var init_wasi_stats = __esm({
8793
8998
  }
8794
8999
  report() {
8795
9000
  const ms = (v) => v.toFixed(1).padStart(9);
8796
- const lines = this.phases.map(([name, t]) => `${ms(t)} ms ${name}`);
9001
+ const lines = this.phases.map(([name2, t]) => `${ms(t)} ms ${name2}`);
8797
9002
  lines.push(`${"total ms".padStart(12)} ${"calls".padStart(7)} ${"max ms".padStart(9)} call`);
8798
9003
  const sorted = [...this.rows].sort((a, b) => b[1].ms - a[1].ms);
8799
9004
  for (const [key, row] of sorted) {
@@ -8809,12 +9014,12 @@ var init_wasi_stats = __esm({
8809
9014
  // src/process/wasi/wasix-fork.ts
8810
9015
  function mutableGlobals(exports) {
8811
9016
  const out = [];
8812
- for (const [name, value2] of Object.entries(exports)) {
9017
+ for (const [name2, value2] of Object.entries(exports)) {
8813
9018
  if (!(value2 instanceof WebAssembly.Global) || typeof value2.value !== "number") continue;
8814
9019
  try {
8815
9020
  const v = value2.value;
8816
9021
  value2.value = v;
8817
- out.push([name, v]);
9022
+ out.push([name2, v]);
8818
9023
  } catch {
8819
9024
  }
8820
9025
  }
@@ -8924,8 +9129,8 @@ var init_wasix_fork = __esm({
8924
9129
  return E.SUCCESS;
8925
9130
  }
8926
9131
  restoreGlobals(globals) {
8927
- for (const [name, value2] of globals) {
8928
- const g = this.exports[name];
9132
+ for (const [name2, value2] of globals) {
9133
+ const g = this.exports[name2];
8929
9134
  if (g instanceof WebAssembly.Global) g.value = value2;
8930
9135
  }
8931
9136
  }
@@ -8995,6 +9200,173 @@ var init_wasix_ffi = __esm({
8995
9200
  }
8996
9201
  });
8997
9202
 
9203
+ // src/process/wasi/wasix-trampoline.ts
9204
+ function valueTypes(codes) {
9205
+ const out = [];
9206
+ for (const code2 of codes) {
9207
+ const type = CODES[code2];
9208
+ if (!type) return void 0;
9209
+ out.push(type);
9210
+ }
9211
+ return out;
9212
+ }
9213
+ function u32(n) {
9214
+ const out = [];
9215
+ let v = n >>> 0;
9216
+ do {
9217
+ let b = v & 127;
9218
+ v >>>= 7;
9219
+ if (v) b |= 128;
9220
+ out.push(b);
9221
+ } while (v);
9222
+ return out;
9223
+ }
9224
+ function s32(n) {
9225
+ const out = [];
9226
+ let v = n | 0;
9227
+ for (; ; ) {
9228
+ const b = v & 127;
9229
+ v >>= 7;
9230
+ if (v === 0 && !(b & 64) || v === -1 && b & 64) {
9231
+ out.push(b);
9232
+ return out;
9233
+ }
9234
+ out.push(b | 128);
9235
+ }
9236
+ }
9237
+ function name(s) {
9238
+ const bytes = [...new TextEncoder().encode(s)];
9239
+ return [...u32(bytes.length), ...bytes];
9240
+ }
9241
+ function section(id, body) {
9242
+ return [id, ...u32(body.length), ...body];
9243
+ }
9244
+ function vec(items) {
9245
+ return [...u32(items.length), ...items.flat()];
9246
+ }
9247
+ function align16(n) {
9248
+ return Math.ceil(n / 16) * 16;
9249
+ }
9250
+ function trampolineBytes(params, results, shared) {
9251
+ const sig = [
9252
+ 96,
9253
+ ...vec(params.map((t) => [VALTYPE[t]])),
9254
+ ...vec(results.map((t) => [VALTYPE[t]]))
9255
+ ];
9256
+ const backing = [96, ...vec([[127], [127], [127]]), ...vec([])];
9257
+ const memory = shared ? [3, 0, ...u32(65536)] : [0, 0];
9258
+ const imports = vec([
9259
+ [...name("env"), ...name("memory"), 2, ...memory],
9260
+ [...name("env"), ...name("__indirect_function_table"), 1, 112, 0, 0],
9261
+ [...name("env"), ...name("__stack_pointer"), 3, 127, 1],
9262
+ [...name("env"), ...name("backing"), 3, 127, 0],
9263
+ [...name("env"), ...name("user_data"), 3, 127, 0]
9264
+ ]);
9265
+ const n = params.length;
9266
+ const [orig, args, res] = [n, n + 1, n + 2];
9267
+ const valuesSize = align16(params.reduce((sum, t) => sum + SIZE3[t], 0));
9268
+ const resultsSize = align16(results.reduce((sum, t) => sum + SIZE3[t], 0));
9269
+ const body = [
9270
+ 35,
9271
+ 0,
9272
+ 34,
9273
+ ...u32(orig),
9274
+ 65,
9275
+ ...s32(resultsSize),
9276
+ 107,
9277
+ 34,
9278
+ ...u32(res)
9279
+ ];
9280
+ body.push(65, ...s32(valuesSize), 107, 34, ...u32(args), 36, 0);
9281
+ let at = 0;
9282
+ params.forEach((t, i) => {
9283
+ body.push(32, ...u32(args), 32, ...u32(i), ...STORE[t], 0, ...u32(at));
9284
+ at += SIZE3[t];
9285
+ });
9286
+ body.push(32, ...u32(args), 32, ...u32(res), 35, 2, 35, 1, 17, 1, 0);
9287
+ at = 0;
9288
+ for (const t of results) {
9289
+ body.push(32, ...u32(res), ...LOAD[t], 0, ...u32(at));
9290
+ at += SIZE3[t];
9291
+ }
9292
+ body.push(32, ...u32(orig), 36, 0, 11);
9293
+ const func = [...vec([[...u32(3), 127]]), ...body];
9294
+ return Uint8Array.from([
9295
+ 0,
9296
+ 97,
9297
+ 115,
9298
+ 109,
9299
+ 1,
9300
+ 0,
9301
+ 0,
9302
+ 0,
9303
+ ...section(1, vec([sig, backing])),
9304
+ ...section(2, imports),
9305
+ ...section(3, vec([[0]])),
9306
+ ...section(7, vec([[...name("t"), 0, 0]])),
9307
+ ...section(10, vec([[...u32(func.length), ...func]]))
9308
+ ]);
9309
+ }
9310
+ var CODES, VALTYPE, SIZE3, STORE, LOAD, Trampolines;
9311
+ var init_wasix_trampoline = __esm({
9312
+ "src/process/wasi/wasix-trampoline.ts"() {
9313
+ "use strict";
9314
+ CODES = ["i32", "i64", "f32", "f64", "v128"];
9315
+ VALTYPE = {
9316
+ i32: 127,
9317
+ i64: 126,
9318
+ f32: 125,
9319
+ f64: 124,
9320
+ v128: 123
9321
+ };
9322
+ SIZE3 = { i32: 4, i64: 8, f32: 4, f64: 8, v128: 16 };
9323
+ STORE = {
9324
+ i32: [54],
9325
+ i64: [55],
9326
+ f32: [56],
9327
+ f64: [57],
9328
+ v128: [253, 11]
9329
+ };
9330
+ LOAD = {
9331
+ i32: [40],
9332
+ i64: [41],
9333
+ f32: [42],
9334
+ f64: [43],
9335
+ v128: [253, 0]
9336
+ };
9337
+ Trampolines = class {
9338
+ modules = /* @__PURE__ */ new Map();
9339
+ get compiled() {
9340
+ return this.modules.size;
9341
+ }
9342
+ make(params, results, env) {
9343
+ const shared = env.memory.buffer instanceof SharedArrayBuffer;
9344
+ const key = `${params.join(",")}>${results.join(",")}${shared ? "s" : ""}`;
9345
+ let module = this.modules.get(key);
9346
+ if (!module) {
9347
+ module = new WebAssembly.Module(trampolineBytes(params, results, shared));
9348
+ this.modules.set(key, module);
9349
+ }
9350
+ const i32 = (v) => new WebAssembly.Global({ value: "i32", mutable: false }, v);
9351
+ const instance = new WebAssembly.Instance(module, {
9352
+ env: {
9353
+ memory: env.memory,
9354
+ __indirect_function_table: env.table,
9355
+ __stack_pointer: env.stackPointer,
9356
+ backing: i32(env.backing),
9357
+ user_data: i32(env.userData)
9358
+ }
9359
+ });
9360
+ const sig = {
9361
+ params: params.map((t) => t === "v128" ? "other" : t),
9362
+ results: results.map((t) => t === "v128" ? "other" : t)
9363
+ };
9364
+ return { fn: instance.exports.t, sig };
9365
+ }
9366
+ };
9367
+ }
9368
+ });
9369
+
8998
9370
  // src/process/wasi/wasm-functypes.ts
8999
9371
  function readTypes(r, s) {
9000
9372
  for (let i = r.u32(); i > 0; i--) {
@@ -9063,10 +9435,10 @@ function readGlobals(r, s) {
9063
9435
  }
9064
9436
  function readExports(r, s) {
9065
9437
  for (let i = r.u32(); i > 0; i--) {
9066
- const name = r.name();
9438
+ const name2 = r.name();
9067
9439
  const kind = r.byte();
9068
9440
  const index2 = r.u32();
9069
- if (kind === 0) s.info.exports[name] = index2;
9441
+ if (kind === 0) s.info.exports[name2] = index2;
9070
9442
  }
9071
9443
  }
9072
9444
  function readElems(r, s) {
@@ -9186,8 +9558,8 @@ var init_wasm_functypes = __esm({
9186
9558
  }
9187
9559
  add(info, instance, table, tableBase) {
9188
9560
  const sig = (func) => info.sigs[info.funcs[func] ?? -1];
9189
- for (const [name, func] of Object.entries(info.exports)) {
9190
- const fn = instance.exports[name];
9561
+ for (const [name2, func] of Object.entries(info.exports)) {
9562
+ const fn = instance.exports[name2];
9191
9563
  const type = sig(func);
9192
9564
  if (typeof fn === "function" && type) this.known.set(fn, type);
9193
9565
  }
@@ -9230,8 +9602,8 @@ function growTo(memory, bytes) {
9230
9602
  function growTable(table, length) {
9231
9603
  if (table.length < length) table.grow(length - table.length);
9232
9604
  }
9233
- function call(instance, name) {
9234
- const fn = instance.exports[name];
9605
+ function call(instance, name2) {
9606
+ const fn = instance.exports[name2];
9235
9607
  if (typeof fn === "function") fn();
9236
9608
  }
9237
9609
  var TABLE_BASE2, PAGE2, STACK_SIZE, LIBRARY_DIRS, DlError, WasixLinker;
@@ -9240,6 +9612,7 @@ var init_wasix_linker = __esm({
9240
9612
  "use strict";
9241
9613
  init_dylink();
9242
9614
  init_wasi_files();
9615
+ init_wasix_trampoline();
9243
9616
  init_wasm_functypes();
9244
9617
  TABLE_BASE2 = 1;
9245
9618
  PAGE2 = 65536;
@@ -9264,6 +9637,7 @@ var init_wasix_linker = __esm({
9264
9637
  publisher;
9265
9638
  indices;
9266
9639
  types = new FuncTypes();
9640
+ trampolines = new Trampolines();
9267
9641
  memory;
9268
9642
  host;
9269
9643
  constructor(memory, mainInfo, host, thread = false) {
@@ -9327,16 +9701,25 @@ var init_wasix_linker = __esm({
9327
9701
  this.main = instance;
9328
9702
  if (relocate) call(instance, "__wasm_apply_data_relocs");
9329
9703
  }
9330
- open(name, cwd, ldPath) {
9331
- return this.load(this.locate(name, cwd, ldPath), cwd, ldPath).handle;
9332
- }
9333
- symbol(handle, name) {
9334
- const found = handle === 0 ? this.find(name) : this.findIn(this.module(handle), name, /* @__PURE__ */ new Set());
9335
- if (!found) throw new DlError(`undefined symbol: ${name}`);
9704
+ mainPath;
9705
+ isMain(path) {
9706
+ if (this.mainPath === void 0) return false;
9707
+ if (path === this.mainPath) return true;
9708
+ const real = this.host.real;
9709
+ return real !== void 0 && real(path) === real(this.mainPath);
9710
+ }
9711
+ open(name2, cwd, ldPath) {
9712
+ const path = this.locate(name2, cwd, ldPath);
9713
+ if (this.isMain(path)) return 0;
9714
+ return this.load(path, cwd, ldPath).handle;
9715
+ }
9716
+ symbol(handle, name2) {
9717
+ const found = handle === 0 ? this.find(name2) : this.findIn(this.module(handle), name2, /* @__PURE__ */ new Set());
9718
+ if (!found) throw new DlError(`undefined symbol: ${name2}`);
9336
9719
  const [owner, value2] = found;
9337
- if (typeof value2 === "function") return this.slot(value2, owner, name);
9720
+ if (typeof value2 === "function") return this.slot(value2, owner, name2);
9338
9721
  if (value2 instanceof WebAssembly.Global) return this.baseOf(owner) + value2.value;
9339
- throw new DlError(`${name} is neither a function nor data`);
9722
+ throw new DlError(`${name2} is neither a function nor data`);
9340
9723
  }
9341
9724
  invalid(handle) {
9342
9725
  return !this.modules.has(handle);
@@ -9356,6 +9739,25 @@ var init_wasix_linker = __esm({
9356
9739
  this.indices?.free(index2);
9357
9740
  this.table.set(index2, null);
9358
9741
  }
9742
+ prepareClosure(record) {
9743
+ if (record.index >= this.table.length)
9744
+ throw new DlError(`closure ${record.index}: no such slot`);
9745
+ const full = { kind: "closure-prepare", ...record };
9746
+ this.install(full);
9747
+ this.publisher?.(full);
9748
+ }
9749
+ install(record) {
9750
+ growTable(this.table, record.index + 1);
9751
+ const { fn, sig } = this.trampolines.make(record.params, record.results, {
9752
+ memory: this.memory,
9753
+ table: this.table,
9754
+ stackPointer: this.stackPointer,
9755
+ backing: record.backing,
9756
+ userData: record.userData
9757
+ });
9758
+ this.table.set(record.index, fn);
9759
+ this.types.set(fn, sig);
9760
+ }
9359
9761
  reserve(size) {
9360
9762
  return this.indices?.reserve(this.table.length, size) ?? this.table.length;
9361
9763
  }
@@ -9368,6 +9770,10 @@ var init_wasix_linker = __esm({
9368
9770
  if (record.index < this.table.length) this.table.set(record.index, null);
9369
9771
  return;
9370
9772
  }
9773
+ if (record.kind === "closure-prepare") {
9774
+ this.install(record);
9775
+ return;
9776
+ }
9371
9777
  if (record.kind === "load") {
9372
9778
  if (this.modules.has(record.handle)) return;
9373
9779
  this.instantiate(record.path, this.moduleAt(record.path), record, false);
@@ -9392,14 +9798,14 @@ var init_wasix_linker = __esm({
9392
9798
  if (!m) throw new DlError(`invalid handle ${handle}`);
9393
9799
  return m;
9394
9800
  }
9395
- locate(name, cwd, ldPath) {
9396
- if (name.includes("/"))
9397
- return name.startsWith("/") ? normalize(name) : normalize(`${cwd}/${name}`);
9801
+ locate(name2, cwd, ldPath) {
9802
+ if (name2.includes("/"))
9803
+ return name2.startsWith("/") ? normalize(name2) : normalize(`${cwd}/${name2}`);
9398
9804
  for (const dir of [...ldPath.filter(Boolean), ...LIBRARY_DIRS]) {
9399
- const path = normalize(`${dir.startsWith("/") ? "" : `${cwd}/`}${dir}/${name}`);
9805
+ const path = normalize(`${dir.startsWith("/") ? "" : `${cwd}/`}${dir}/${name2}`);
9400
9806
  if (this.byPath.has(path) || this.host.read(path)) return path;
9401
9807
  }
9402
- throw new DlError(`${name}: not found`);
9808
+ throw new DlError(`${name2}: not found`);
9403
9809
  }
9404
9810
  load(path, cwd, ldPath) {
9405
9811
  const loaded = this.byPath.get(path);
@@ -9494,46 +9900,46 @@ var init_wasix_linker = __esm({
9494
9900
  }
9495
9901
  return linked;
9496
9902
  }
9497
- functionImport(name) {
9498
- const now = this.find(name);
9903
+ functionImport(name2) {
9904
+ const now = this.find(name2);
9499
9905
  if (now && typeof now[1] === "function") return now[1];
9500
9906
  let resolved2;
9501
9907
  return (...args) => {
9502
9908
  if (!resolved2) {
9503
- const later = this.find(name);
9909
+ const later = this.find(name2);
9504
9910
  if (!later || typeof later[1] !== "function")
9505
- throw new WebAssembly.RuntimeError(`unresolved symbol ${name}`);
9911
+ throw new WebAssembly.RuntimeError(`unresolved symbol ${name2}`);
9506
9912
  resolved2 = later[1];
9507
9913
  }
9508
9914
  return resolved2(...args);
9509
9915
  };
9510
9916
  }
9511
- addressOrNull(name) {
9512
- const found = this.find(name);
9917
+ addressOrNull(name2) {
9918
+ const found = this.find(name2);
9513
9919
  if (!found || !(found[1] instanceof WebAssembly.Global)) return 0;
9514
9920
  return this.baseOf(found[0]) + found[1].value;
9515
9921
  }
9516
- slotOrNull(name) {
9517
- const found = this.find(name);
9922
+ slotOrNull(name2) {
9923
+ const found = this.find(name2);
9518
9924
  if (!found || typeof found[1] !== "function") return 0;
9519
- return this.slot(found[1], found[0], name);
9925
+ return this.slot(found[1], found[0], name2);
9520
9926
  }
9521
- find(name) {
9522
- const inMain = this.main?.exports[name];
9927
+ find(name2) {
9928
+ const inMain = this.main?.exports[name2];
9523
9929
  if (inMain !== void 0) return [0, inMain];
9524
9930
  for (const m of this.modules.values()) {
9525
- const v = m.instance?.exports[name];
9931
+ const v = m.instance?.exports[name2];
9526
9932
  if (v !== void 0) return [m.handle, v];
9527
9933
  }
9528
9934
  return void 0;
9529
9935
  }
9530
- findIn(m, name, seen) {
9936
+ findIn(m, name2, seen) {
9531
9937
  if (seen.has(m.handle)) return void 0;
9532
9938
  seen.add(m.handle);
9533
- const v = m.instance.exports[name];
9939
+ const v = m.instance.exports[name2];
9534
9940
  if (v !== void 0) return [m.handle, v];
9535
9941
  for (const h of m.needed) {
9536
- const found = this.findIn(this.module(h), name, seen);
9942
+ const found = this.findIn(this.module(h), name2, seen);
9537
9943
  if (found) return found;
9538
9944
  }
9539
9945
  return void 0;
@@ -9541,14 +9947,23 @@ var init_wasix_linker = __esm({
9541
9947
  baseOf(handle) {
9542
9948
  return handle === 0 ? this.memoryBase : this.module(handle).memoryBase;
9543
9949
  }
9544
- slot(fn, handle, name) {
9950
+ indexed = 0;
9951
+ indexTable() {
9952
+ for (let i = this.indexed; i < this.table.length; i++) {
9953
+ const fn = this.table.get(i);
9954
+ if (fn && !this.slots.has(fn)) this.slots.set(fn, i);
9955
+ }
9956
+ this.indexed = this.table.length;
9957
+ }
9958
+ slot(fn, handle, name2) {
9959
+ this.indexTable();
9545
9960
  const known = this.slots.get(fn);
9546
9961
  if (known !== void 0) return known;
9547
9962
  const index2 = this.reserve(1);
9548
9963
  growTable(this.table, index2 + 1);
9549
9964
  this.table.set(index2, fn);
9550
9965
  this.slots.set(fn, index2);
9551
- this.publisher?.({ kind: "slot", index: index2, handle, name });
9966
+ this.publisher?.({ kind: "slot", index: index2, handle, name: name2 });
9552
9967
  return index2;
9553
9968
  }
9554
9969
  allocate(size, alignment) {
@@ -9786,8 +10201,8 @@ function wasixSocketImports(host, preview1) {
9786
10201
  },
9787
10202
  sock_set_opt_time: (fd) => void socket(fd),
9788
10203
  sock_send_file: () => E.NOSYS,
9789
- resolve: (name, len, _port, addrs, naddrs, out) => {
9790
- const found = call2({ op: "sock-resolve", name: mem.string(name, len), family: 0 });
10204
+ resolve: (name2, len, _port, addrs, naddrs, out) => {
10205
+ const found = call2({ op: "sock-resolve", name: mem.string(name2, len), family: 0 });
9791
10206
  const ips = found.map(ipBytes).filter((ip) => ip !== void 0);
9792
10207
  if (ips.length === 0) throw new WasiError("ENOENT");
9793
10208
  if (naddrs < 1) throw new WasiError("EINVAL");
@@ -9852,7 +10267,7 @@ function posixSignal(sig) {
9852
10267
  function nsToMs(ns) {
9853
10268
  return Math.ceil(Number(ns) / 1e6);
9854
10269
  }
9855
- var FDFLAGSEXT_CLOEXEC, SPAWN_OP_SIZE, SPAWN_OPS, RIGHTS_FD_WRITE, ICANON2, ECHO2, FUTEX_SLICE_MS, WasixHost;
10270
+ var FDFLAGSEXT_CLOEXEC, SPAWN_OP_SIZE, SPAWN_OPS, RIGHTS_FD_WRITE, ICANON2, ECHO2, FUTEX_SLICE_MS, MAIN_HANDLE, WasixHost;
9856
10271
  var init_wasix_host = __esm({
9857
10272
  "src/process/wasi/wasix-host.ts"() {
9858
10273
  "use strict";
@@ -9864,6 +10279,7 @@ var init_wasix_host = __esm({
9864
10279
  init_wasix_linker();
9865
10280
  init_wasix_process();
9866
10281
  init_wasix_sockets();
10282
+ init_wasix_trampoline();
9867
10283
  init_wasm_functypes();
9868
10284
  FDFLAGSEXT_CLOEXEC = 1;
9869
10285
  SPAWN_OP_SIZE = 56;
@@ -9872,6 +10288,7 @@ var init_wasix_host = __esm({
9872
10288
  ICANON2 = 2;
9873
10289
  ECHO2 = 8;
9874
10290
  FUTEX_SLICE_MS = 50;
10291
+ MAIN_HANDLE = 2147483647;
9875
10292
  WasixHost = class _WasixHost {
9876
10293
  process;
9877
10294
  threads;
@@ -9963,6 +10380,18 @@ var init_wasix_host = __esm({
9963
10380
  if (!this.linker) throw new WasiError("ENOTSUP");
9964
10381
  this.mem.view().setUint32(out, this.linker.allocateClosure(), true);
9965
10382
  },
10383
+ closure_prepare: (backing, index2, argTypes, argCount, resultTypes, resultCount, userData) => {
10384
+ if (!this.linker) throw new WasiError("ENOTSUP");
10385
+ const params = valueTypes(this.mem.bytes(argTypes, argCount));
10386
+ const results = valueTypes(this.mem.bytes(resultTypes, resultCount));
10387
+ if (!params || !results) throw new WasiError("EINVAL");
10388
+ try {
10389
+ this.linker.prepareClosure({ index: index2, backing, userData, params, results });
10390
+ } catch (e) {
10391
+ if (e instanceof DlError) throw new WasiError("EINVAL");
10392
+ throw e;
10393
+ }
10394
+ },
9966
10395
  closure_free: (index2) => {
9967
10396
  if (!this.linker) throw new WasiError("ENOTSUP");
9968
10397
  this.linker.freeClosure(index2);
@@ -9992,7 +10421,7 @@ var init_wasix_host = __esm({
9992
10421
  },
9993
10422
  proc_signals_sizes_get: (out) => void mem.view().setUint32(out, 0, true),
9994
10423
  proc_signals_get: () => E.SUCCESS,
9995
- callback_signal: (name, len) => void this.signals?.register(this.str(name, len)),
10424
+ callback_signal: (name2, len) => void this.signals?.register(this.str(name2, len)),
9996
10425
  proc_raise_interval: (sig, interval, repeat) => void host.o.kernel.call({
9997
10426
  op: "proc-alarm",
9998
10427
  sig: posixSignal(sig),
@@ -10139,23 +10568,23 @@ var init_wasix_host = __esm({
10139
10568
  return {
10140
10569
  dlopen: (p, pl, _flags, buf, len, lp, ll, out) => {
10141
10570
  if (p === 0) {
10142
- mem.view().setUint32(out, 0, true);
10571
+ mem.view().setUint32(out, MAIN_HANDLE, true);
10143
10572
  return E.SUCCESS;
10144
10573
  }
10145
10574
  return linked(
10146
10575
  buf,
10147
10576
  len,
10148
10577
  (l) => l.open(this.str(p, pl), host.cwd, lp === 0 ? [] : this.str(lp, ll).split(":")),
10149
- (h) => void mem.view().setUint32(out, h, true)
10578
+ (h) => void mem.view().setUint32(out, h === 0 ? MAIN_HANDLE : h, true)
10150
10579
  );
10151
10580
  },
10152
10581
  dlsym: (handle, s, sl, buf, len, out) => linked(
10153
10582
  buf,
10154
10583
  len,
10155
- (l) => l.symbol(handle, this.str(s, sl)),
10584
+ (l) => l.symbol(handle === MAIN_HANDLE ? 0 : handle, this.str(s, sl)),
10156
10585
  (v) => void mem.view().setUint32(out, v, true)
10157
10586
  ),
10158
- dl_invalid_handle: (handle) => handle !== 0 && this.linker && !this.linker.invalid(handle) ? E.SUCCESS : E.NOEXEC
10587
+ dl_invalid_handle: (handle) => handle === MAIN_HANDLE || handle !== 0 && this.linker && !this.linker.invalid(handle) ? E.SUCCESS : E.NOEXEC
10159
10588
  };
10160
10589
  }
10161
10590
  threadImports() {
@@ -10286,10 +10715,10 @@ function mainModule(lines) {
10286
10715
  }
10287
10716
  return void 0;
10288
10717
  }
10289
- function nameFrame(line, module, name) {
10718
+ function nameFrame(line, module, name2) {
10290
10719
  const m = UNNAMED_FRAME.exec(line);
10291
10720
  if (!m || m[3] !== module) return line;
10292
- const found = name(Number(m[4]));
10721
+ const found = name2(Number(m[4]));
10293
10722
  return found === void 0 ? line : `${m[1]}${found} (${m[2]})`;
10294
10723
  }
10295
10724
  function sidecarNames(read2, path) {
@@ -10325,29 +10754,29 @@ __export(wasi_runtime_exports, {
10325
10754
  trapMessage: () => trapMessage,
10326
10755
  unsupportedImport: () => unsupportedImport
10327
10756
  });
10328
- function enosys(module, name, foreign) {
10329
- const type = foreign?.[module]?.[name];
10330
- if (type === "other") throw new Error(noErrno(`${module}.${name}`));
10757
+ function enosys(module, name2, foreign) {
10758
+ const type = foreign?.[module]?.[name2];
10759
+ if (type === "other") throw new Error(noErrno(`${module}.${name2}`));
10331
10760
  if (type === "none") return () => void 0;
10332
10761
  if (type === "i64") return () => 52n;
10333
10762
  return () => 52;
10334
10763
  }
10335
10764
  function firstOther(foreign) {
10336
10765
  for (const [module, fields] of Object.entries(foreign)) {
10337
- const name = Object.keys(fields).find((field2) => fields[field2] === "other");
10338
- if (name !== void 0) return `${module}.${name}`;
10766
+ const name2 = Object.keys(fields).find((field2) => fields[field2] === "other");
10767
+ if (name2 !== void 0) return `${module}.${name2}`;
10339
10768
  }
10340
10769
  return void 0;
10341
10770
  }
10342
10771
  function accepted(imp, scope2) {
10343
- const { module, name, kind } = imp;
10772
+ const { module, name: name2, kind } = imp;
10344
10773
  if (module === PREVIEW1 || module === WASIX) return true;
10345
10774
  if (!RESERVED2.has(module) && (scope2.extended || scope2.wasi && kind === "function")) return true;
10346
10775
  if (scope2.pie && (module === "GOT.mem" || module === "GOT.func")) return true;
10347
10776
  if (scope2.pie && module === "env" && kind !== "memory") return true;
10348
- if (kind === "memory" && scope2.memory?.module === module && scope2.memory.name === name)
10777
+ if (kind === "memory" && scope2.memory?.module === module && scope2.memory.name === name2)
10349
10778
  return true;
10350
- return module === "wasi" && name === "thread-spawn" && (scope2.wasix || !!scope2.memory?.shared);
10779
+ return module === "wasi" && name2 === "thread-spawn" && (scope2.wasix || !!scope2.memory?.shared);
10351
10780
  }
10352
10781
  function unsupportedImport(module, memory, extended = false, foreign = {}) {
10353
10782
  const imports = WebAssembly.Module.imports(module);
@@ -10538,11 +10967,21 @@ async function instantiate(host, module, memory, threads, {
10538
10967
  }
10539
10968
  if (sync) {
10540
10969
  sync.linker.bindMain(instance, !thread);
10970
+ if (path !== void 0) sync.linker.mainPath = path;
10541
10971
  if (thread) sync.catchUp();
10542
10972
  sync.linker.bindMainGot();
10543
10973
  }
10544
10974
  return { instance, driver };
10545
10975
  }
10976
+ function procTree(call2, pid) {
10977
+ return new ProcTree(
10978
+ {
10979
+ procList: () => call2({ op: "proc-list" }),
10980
+ mountList: () => call2({ op: "mount-list" })
10981
+ },
10982
+ pid
10983
+ );
10984
+ }
10546
10985
  function exportedTable(instance) {
10547
10986
  const table = instance.exports.__indirect_function_table;
10548
10987
  return table instanceof WebAssembly.Table ? table : void 0;
@@ -10559,7 +10998,8 @@ function linkerHost(host, imports) {
10559
10998
  hostImports: () => {
10560
10999
  const { env: _env, "GOT.mem": _mem, "GOT.func": _func, ...rest2 } = imports();
10561
11000
  return rest2;
10562
- }
11001
+ },
11002
+ real: (path) => physicalPath(host.o.fs, path)
10563
11003
  };
10564
11004
  }
10565
11005
  function merge(base, extra) {
@@ -10613,7 +11053,10 @@ async function runWasiProcess(init, port3) {
10613
11053
  ppid: id.ppid,
10614
11054
  parent: () => identify(transport, init).ppid,
10615
11055
  kernel: { sys: traced(stats, "kernel", sys), call: call2 },
10616
- fs: cachingBridge(traced(stats, "fs", createSyncFsSabBridge(transport))),
11056
+ fs: procfsBridge(
11057
+ cachingBridge(traced(stats, "fs", createSyncFsSabBridge(transport))),
11058
+ procTree(call2, id.pid)
11059
+ ),
10617
11060
  ...descriptors(init, fork, threads)
10618
11061
  });
10619
11062
  if (threads) {
@@ -10661,12 +11104,12 @@ async function runWasiProcess(init, port3) {
10661
11104
  if (stats) report(stats, sys);
10662
11105
  }
10663
11106
  }
10664
- function trapMessage(e, env, where = "", name) {
11107
+ function trapMessage(e, env, where = "", name2) {
10665
11108
  const head = `wasm trap${where}: ${e.message}`;
10666
11109
  if (env.SLICC_WASM_BACKTRACE !== "1") return head;
10667
11110
  const lines = (e.stack ?? "").split("\n");
10668
- const main = name && mainModule(lines);
10669
- const frames = lines.filter((line) => /^\s+at .*wasm:\/\/wasm\//.test(line)).slice(0, BACKTRACE_FRAMES).map((line) => name && main ? nameFrame(line, main, name) : line);
11111
+ const main = name2 && mainModule(lines);
11112
+ const frames = lines.filter((line) => /^\s+at .*wasm:\/\/wasm\//.test(line)).slice(0, BACKTRACE_FRAMES).map((line) => name2 && main ? nameFrame(line, main, name2) : line);
10670
11113
  return frames.length ? `${head}
10671
11114
  ${frames.join("\n")}` : head;
10672
11115
  }
@@ -10704,7 +11147,7 @@ async function runWasiThread(init, port3) {
10704
11147
  ppid: id.ppid,
10705
11148
  parent: () => identify(transport, init).ppid,
10706
11149
  kernel: { sys, call: call2 },
10707
- fs: cachingBridge(createSyncFsSabBridge(transport)),
11150
+ fs: procfsBridge(cachingBridge(createSyncFsSabBridge(transport)), procTree(call2, id.pid)),
10708
11151
  shared: threads.ids
10709
11152
  });
10710
11153
  const program = await programImports(init.program, host, transport, thread.tid);
@@ -10746,6 +11189,7 @@ var TRAPPED, PREVIEW1, WASIX, SLICC, SIGNAL_CALLBACK, takeDefault, SLICC_FS, SLI
10746
11189
  var init_wasi_runtime = __esm({
10747
11190
  "src/process/wasi/wasi-runtime.ts"() {
10748
11191
  "use strict";
11192
+ init_physical_path();
10749
11193
  init_protocol();
10750
11194
  init_signals();
10751
11195
  init_sync_sab_bridge();
@@ -10758,6 +11202,7 @@ var init_wasi_runtime = __esm({
10758
11202
  init_wasi_host();
10759
11203
  init_wasi_imports();
10760
11204
  init_wasi_module();
11205
+ init_wasi_procfs();
10761
11206
  init_wasi_signals();
10762
11207
  init_wasi_stats();
10763
11208
  init_wasi_threads();
@@ -10817,8 +11262,8 @@ var init_wasi_runtime = __esm({
10817
11262
  const ids = this.ids;
10818
11263
  if (!ids) return { preview1, wasix };
10819
11264
  const wrap2 = (table) => Object.fromEntries(
10820
- Object.entries(table).map(([name, fn]) => [
10821
- name,
11265
+ Object.entries(table).map(([name2, fn]) => [
11266
+ name2,
10822
11267
  ((...args) => {
10823
11268
  if (Atomics.load(ids, DL_GEN) !== this.gen) this.catchUp();
10824
11269
  const result = fn(...args);
@@ -10858,19 +11303,19 @@ var NODE_SLOTS = [
10858
11303
  "clearImmediate"
10859
11304
  ];
10860
11305
  function vacate(target, names) {
10861
- for (const name of names) {
11306
+ for (const name2 of names) {
10862
11307
  for (let at = target; at && at !== Object.prototype; ) {
10863
- if (Object.getOwnPropertyDescriptor(at, name)?.configurable) Reflect.deleteProperty(at, name);
11308
+ if (Object.getOwnPropertyDescriptor(at, name2)?.configurable) Reflect.deleteProperty(at, name2);
10864
11309
  at = Object.getPrototypeOf(at);
10865
11310
  }
10866
- Reflect.defineProperty(target, name, {
11311
+ Reflect.defineProperty(target, name2, {
10867
11312
  value: void 0,
10868
11313
  writable: true,
10869
11314
  enumerable: false,
10870
11315
  configurable: true
10871
11316
  });
10872
- if (Reflect.get(target, name) !== void 0) {
10873
- throw new Error(`slicc-kernel: cannot withhold ${name} from a JS program`);
11317
+ if (Reflect.get(target, name2) !== void 0) {
11318
+ throw new Error(`slicc-kernel: cannot withhold ${name2} from a JS program`);
10874
11319
  }
10875
11320
  }
10876
11321
  }