@ai-ecoverse/slicc-kernel 1.164.5 → 1.165.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.
@@ -1,9 +1,9 @@
1
1
  var __defProp = Object.defineProperty;
2
2
  var __getOwnPropNames = Object.getOwnPropertyNames;
3
- var __esm = (fn, res, err) => function __init() {
3
+ var __esm = (fn2, res, err) => function __init() {
4
4
  if (err) throw err[0];
5
5
  try {
6
- return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
6
+ return fn2 && (res = (0, fn2[__getOwnPropNames(fn2)[0]])(fn2 = 0)), res;
7
7
  } catch (e) {
8
8
  throw err = [e], e;
9
9
  }
@@ -78,6 +78,23 @@ var init_captured_globals = __esm({
78
78
  }
79
79
  });
80
80
 
81
+ // src/process/raw-stack.ts
82
+ function setRawStack(read2) {
83
+ reader = read2;
84
+ }
85
+ function rawStack(error) {
86
+ const stack = reader(error);
87
+ return typeof stack === "string" ? stack : void 0;
88
+ }
89
+ var reader;
90
+ var init_raw_stack = __esm({
91
+ "src/process/raw-stack.ts"() {
92
+ "use strict";
93
+ init_captured_globals();
94
+ reader = (error) => error.stack;
95
+ }
96
+ });
97
+
81
98
  // src/process/js/lockdown.ts
82
99
  function chain(target) {
83
100
  const out = [];
@@ -3412,7 +3429,7 @@ var init_wasi_cred = __esm({
3412
3429
  };
3413
3430
  KNOWN = 65536;
3414
3431
  LOCKED = 131072;
3415
- UNGATED = { quiet: (fn) => fn(), deliver: () => {
3432
+ UNGATED = { quiet: (fn2) => fn2(), deliver: () => {
3416
3433
  } };
3417
3434
  UmaskCache = class {
3418
3435
  mask;
@@ -5527,21 +5544,21 @@ function kernelFiletype(kind) {
5527
5544
  }
5528
5545
  function direntRecord(next2, ino, name2, filetype) {
5529
5546
  const nameBytes = new capturedTextEncoder().encode(name2);
5530
- const record = new capturedUint8Array(SIZE.DIRENT + nameBytes.length);
5531
- const v = new capturedDataView(record.buffer);
5547
+ const record2 = new capturedUint8Array(SIZE.DIRENT + nameBytes.length);
5548
+ const v = new capturedDataView(record2.buffer);
5532
5549
  v.setBigUint64(0, capturedBigInt(next2), true);
5533
5550
  v.setBigUint64(8, ino, true);
5534
5551
  v.setUint32(16, nameBytes.length, true);
5535
5552
  v.setUint8(20, filetype);
5536
- record.set(nameBytes, SIZE.DIRENT);
5537
- return record;
5553
+ record2.set(nameBytes, SIZE.DIRENT);
5554
+ return record2;
5538
5555
  }
5539
5556
  function wrap(table) {
5540
5557
  const out = {};
5541
- for (const [name2, fn] of capturedObject.entries(table)) {
5558
+ for (const [name2, fn2] of capturedObject.entries(table)) {
5542
5559
  out[name2] = (...args) => {
5543
5560
  try {
5544
- return fn(...args) ?? E.SUCCESS;
5561
+ return fn2(...args) ?? E.SUCCESS;
5545
5562
  } catch (e) {
5546
5563
  if (e instanceof WasiExit) throw e;
5547
5564
  if (e instanceof WasiError) return wasiErrnoOf(e.code);
@@ -5661,7 +5678,7 @@ var init_wasi_host = __esm({
5661
5678
  mask === void 0 ? { op: "proc-umask" } : { op: "proc-umask", mask }
5662
5679
  ),
5663
5680
  o.credGen ?? o.shared,
5664
- { quiet: (fn) => this.quietly(fn), deliver: () => this.deliverDue() }
5681
+ { quiet: (fn2) => this.quietly(fn2), deliver: () => this.deliverDue() }
5665
5682
  );
5666
5683
  if (o.shared) this.fds.share(o.shared, true);
5667
5684
  else if (o.forked) this.fds.restore(o.forked.fds, o.forked.cloexec);
@@ -6768,14 +6785,14 @@ var init_wasi_host = __esm({
6768
6785
  const full = name2 === "." ? dir.path : name2 === ".." ? normalize(`${dir.path}/..`) : resolveUnder(dir.path, name2);
6769
6786
  if (!stats.has(name2)) stats.set(name2, this.lstatOrNull(full));
6770
6787
  const st = stats.get(name2) ?? null;
6771
- const record = direntRecord(
6788
+ const record2 = direntRecord(
6772
6789
  i + 1,
6773
6790
  st?.ino !== void 0 ? capturedBigInt(st.ino) : pathInode(full),
6774
6791
  name2,
6775
6792
  filetypeOf(st)
6776
6793
  );
6777
- const n = capturedMath.min(record.length, len - at);
6778
- this.mem.bytes(buf + at, n).set(record.subarray(0, n));
6794
+ const n = capturedMath.min(record2.length, len - at);
6795
+ this.mem.bytes(buf + at, n).set(record2.subarray(0, n));
6779
6796
  at += n;
6780
6797
  }
6781
6798
  this.mem.view().setUint32(usedPtr, at, true);
@@ -7385,7 +7402,7 @@ var init_version = __esm({
7385
7402
  "src/version.ts"() {
7386
7403
  "use strict";
7387
7404
  init_captured_globals();
7388
- KERNEL_VERSION = true ? "1.164.5" : "0.0.0-dev";
7405
+ KERNEL_VERSION = true ? "1.165.0" : "0.0.0-dev";
7389
7406
  OS_RELEASE = "6.0.0-slicc";
7390
7407
  }
7391
7408
  });
@@ -7860,14 +7877,14 @@ function bytesOf(chunk) {
7860
7877
  async function bodyOf(request, cap, signal) {
7861
7878
  signal.throwIfAborted();
7862
7879
  if (!request.body || request.method === "GET" || request.method === "HEAD") return void 0;
7863
- const reader = request.body.getReader();
7864
- const stop = () => void reader.cancel(signal.reason).catch(() => void 0);
7880
+ const reader2 = request.body.getReader();
7881
+ const stop = () => void reader2.cancel(signal.reason).catch(() => void 0);
7865
7882
  signal.addEventListener("abort", stop, { once: true });
7866
7883
  const parts = [];
7867
7884
  let length = 0;
7868
7885
  try {
7869
7886
  for (; ; ) {
7870
- const next2 = await reader.read().catch((err) => {
7887
+ const next2 = await reader2.read().catch((err) => {
7871
7888
  throw signal.aborted ? signal.reason : failed(err);
7872
7889
  });
7873
7890
  signal.throwIfAborted();
@@ -7875,7 +7892,7 @@ async function bodyOf(request, cap, signal) {
7875
7892
  const chunk = bytesOf(next2.value);
7876
7893
  length += chunk.length;
7877
7894
  if (length > cap) {
7878
- reader.cancel().catch(() => void 0);
7895
+ reader2.cancel().catch(() => void 0);
7879
7896
  return OVER;
7880
7897
  }
7881
7898
  parts.push(chunk);
@@ -7897,24 +7914,24 @@ function streams(known, request, init, url) {
7897
7914
  return request.method !== "GET" && request.method !== "HEAD" && !local2(url);
7898
7915
  }
7899
7916
  async function pump(kernel, handle, stream, signal) {
7900
- const reader = stream.getReader();
7901
- const stop = () => void reader.cancel(signal.reason).catch(() => void 0);
7917
+ const reader2 = stream.getReader();
7918
+ const stop = () => void reader2.cancel(signal.reason).catch(() => void 0);
7902
7919
  signal.addEventListener("abort", stop, { once: true });
7903
7920
  try {
7904
- await pumpFrom(kernel, handle, reader, signal);
7921
+ await pumpFrom(kernel, handle, reader2, signal);
7905
7922
  } finally {
7906
7923
  signal.removeEventListener("abort", stop);
7907
7924
  }
7908
7925
  }
7909
- async function pumpFrom(kernel, handle, reader, signal) {
7926
+ async function pumpFrom(kernel, handle, reader2, signal) {
7910
7927
  for (; ; ) {
7911
7928
  let bytes;
7912
7929
  try {
7913
- const next2 = await reader.read();
7930
+ const next2 = await reader2.read();
7914
7931
  if (next2.done) break;
7915
7932
  bytes = bytesOf(next2.value);
7916
7933
  } catch (err) {
7917
- await reader.cancel(err).catch(() => void 0);
7934
+ await reader2.cancel(err).catch(() => void 0);
7918
7935
  await kernel.raw({ op: "net-close", handle });
7919
7936
  return;
7920
7937
  }
@@ -7924,7 +7941,7 @@ async function pumpFrom(kernel, handle, reader, signal) {
7924
7941
  () => false
7925
7942
  );
7926
7943
  if (!taken) {
7927
- await reader.cancel().catch(() => void 0);
7944
+ await reader2.cancel().catch(() => void 0);
7928
7945
  return;
7929
7946
  }
7930
7947
  }
@@ -9138,7 +9155,7 @@ function createHelpers(Fs, ops) {
9138
9155
  const dirty = new capturedSet();
9139
9156
  const handled = new capturedSet();
9140
9157
  const linked = linkedStates(bridgeOf);
9141
- const renames = renameFollower(Fs, bridgeOf, (fn) => call3(fn));
9158
+ const renames = renameFollower(Fs, bridgeOf, (fn2) => call3(fn2));
9142
9159
  function markDirty(node) {
9143
9160
  node.live.dirty = true;
9144
9161
  dirty.add(node);
@@ -9158,16 +9175,16 @@ function createHelpers(Fs, ops) {
9158
9175
  }
9159
9176
  }
9160
9177
  }
9161
- function call3(fn) {
9178
+ function call3(fn2) {
9162
9179
  try {
9163
- return fn();
9180
+ return fn2();
9164
9181
  } catch (err) {
9165
9182
  throw toErrno(Fs, err);
9166
9183
  }
9167
9184
  }
9168
- function metadataCall(fn) {
9185
+ function metadataCall(fn2) {
9169
9186
  try {
9170
- call3(fn);
9187
+ call3(fn2);
9171
9188
  } catch (err) {
9172
9189
  if (err.errno !== wasiErrno("ENOSYS")) throw err;
9173
9190
  }
@@ -11990,9 +12007,9 @@ function procfsBridge(fs, tree) {
11990
12007
  [NOT_FOLLOWING, false]
11991
12008
  ]) {
11992
12009
  for (const name2 of names) {
11993
- const fn = fs[name2];
11994
- if (!fn) continue;
11995
- over[name2] = (p, ...rest2) => readOnly2([[p, follow3]], () => fn.call(fs, p, ...rest2));
12010
+ const fn2 = fs[name2];
12011
+ if (!fn2) continue;
12012
+ over[name2] = (p, ...rest2) => readOnly2([[p, follow3]], () => fn2.call(fs, p, ...rest2));
11996
12013
  }
11997
12014
  }
11998
12015
  const { chown } = fs;
@@ -14439,10 +14456,10 @@ var init_process_signals = __esm({
14439
14456
  };
14440
14457
  this.raw.call(req, capturedNumber.POSITIVE_INFINITY, "sig-mask");
14441
14458
  }
14442
- quiet(fn) {
14459
+ quiet(fn2) {
14443
14460
  this.quieted++;
14444
14461
  try {
14445
- return fn();
14462
+ return fn2();
14446
14463
  } finally {
14447
14464
  this.quieted--;
14448
14465
  }
@@ -15519,7 +15536,7 @@ function createJsWasi(deps, o = {}) {
15519
15536
  view().setUint32(out, g, true);
15520
15537
  };
15521
15538
  const imports = {};
15522
- for (const [name2, fn] of capturedObject.entries(table)) {
15539
+ for (const [name2, fn2] of capturedObject.entries(table)) {
15523
15540
  if (SPECIAL.has(name2)) continue;
15524
15541
  const fdArgs = fdArgsOf(name2);
15525
15542
  imports[name2] = ((...raw) => {
@@ -15532,7 +15549,7 @@ function createJsWasi(deps, o = {}) {
15532
15549
  if (!confined(name2, raw)) return E.NOTCAPABLE;
15533
15550
  const out = RESULTS[name2];
15534
15551
  if (out !== void 0 && (raw[out] >>> 0) + 4 > host.mem.size()) return E.FAULT;
15535
- const errno2 = fn(...args);
15552
+ const errno2 = fn2(...args);
15536
15553
  if (errno2 !== E.SUCCESS) return errno2;
15537
15554
  if (out !== void 0) opens(raw[out] >>> 0, roots.get(raw[0]));
15538
15555
  return errno2;
@@ -15585,13 +15602,13 @@ function createJsWasi(deps, o = {}) {
15585
15602
  const run = (instance, entry) => {
15586
15603
  const memory = instance.exports.memory;
15587
15604
  if (memory instanceof capturedWebAssembly.Memory) host.mem.bind(memory);
15588
- const fn = instance.exports[entry];
15589
- if (typeof fn !== "function") {
15605
+ const fn2 = instance.exports[entry];
15606
+ if (typeof fn2 !== "function") {
15590
15607
  if (entry === "_initialize") return 0;
15591
15608
  throw new JsCallError("EINVAL", `wasi: the instance exports no ${entry}`);
15592
15609
  }
15593
15610
  try {
15594
- fn();
15611
+ fn2();
15595
15612
  return 0;
15596
15613
  } catch (err) {
15597
15614
  if (err instanceof JsWasiExit && o.returnOnExit !== false) return err.code;
@@ -16208,7 +16225,9 @@ function realmOps(o) {
16208
16225
  return {
16209
16226
  runScript: scriptRunner(o.runScript),
16210
16227
  promiseState: (promise) => o.promiseState?.(promise),
16211
- ...hook ? { setStackFormatter: (fn) => hook(fn) } : {},
16228
+ ...hook ? {
16229
+ setStackFormatter: (fn2, options) => hook(fn2, options)
16230
+ } : {},
16212
16231
  ...source ? { errorSource: (error) => source(error) } : {}
16213
16232
  };
16214
16233
  }
@@ -17180,8 +17199,8 @@ var init_wasi_signals = __esm({
17180
17199
  if (defaultAction(sig) !== "terminate") this.uncaught &= ~sigbit(sig);
17181
17200
  }
17182
17201
  handler() {
17183
- const fn = this.callback ? this.exports?.[this.callback] : void 0;
17184
- return typeof fn === "function" ? fn : void 0;
17202
+ const fn2 = this.callback ? this.exports?.[this.callback] : void 0;
17203
+ return typeof fn2 === "function" ? fn2 : void 0;
17185
17204
  }
17186
17205
  };
17187
17206
  }
@@ -17201,16 +17220,16 @@ var init_wasi_stats = __esm({
17201
17220
  return capturedObject.fromEntries(
17202
17221
  capturedObject.entries(table).map(([name2, value2]) => {
17203
17222
  if (typeof value2 !== "function") return [name2, value2];
17204
- const fn = value2;
17223
+ const fn2 = value2;
17205
17224
  const key = `${tag}.${name2}`;
17206
- return [name2, (...args) => this.time(key, () => fn.apply(table, args))];
17225
+ return [name2, (...args) => this.time(key, () => fn2.apply(table, args))];
17207
17226
  })
17208
17227
  );
17209
17228
  }
17210
- time(key, fn) {
17229
+ time(key, fn2) {
17211
17230
  const t = capturedperformance.now();
17212
17231
  try {
17213
- return fn();
17232
+ return fn2();
17214
17233
  } finally {
17215
17234
  this.count(key, capturedperformance.now() - t);
17216
17235
  }
@@ -17435,9 +17454,9 @@ function callDynamic(ctx, ...operands) {
17435
17454
  const [id, values, valuesLen, results, resultsLen, strict] = operands.map((n) => n >>> 0);
17436
17455
  const table = ctx.table();
17437
17456
  if (!table) throw new WasiError("ENOTSUP");
17438
- const fn = id < table.length ? table.get(id) : null;
17439
- const sig = fn ? ctx.types.of(fn) : void 0;
17440
- if (!fn || !sig) throw new WasiError("EINVAL");
17457
+ const fn2 = id < table.length ? table.get(id) : null;
17458
+ const sig = fn2 ? ctx.types.of(fn2) : void 0;
17459
+ if (!fn2 || !sig) throw new WasiError("EINVAL");
17441
17460
  const params = scalars(sig.params);
17442
17461
  const outs = scalars(sig.results);
17443
17462
  const size = (types3) => types3.reduce((n, type) => n + SIZE2[type], 0);
@@ -17455,7 +17474,7 @@ function callDynamic(ctx, ...operands) {
17455
17474
  at += SIZE2[type];
17456
17475
  return v;
17457
17476
  });
17458
- const returned = fn(...args);
17477
+ const returned = fn2(...args);
17459
17478
  const got = outs.length === 1 ? [returned] : returned ?? [];
17460
17479
  const after = ctx.mem.view();
17461
17480
  const stop = results + resultsLen;
@@ -17837,30 +17856,30 @@ var init_wasm_functypes = __esm({
17837
17856
  add(info, instance, table, tableBase) {
17838
17857
  const sig = (func) => info.sigs[info.funcs[func] ?? -1];
17839
17858
  for (const [name2, func] of capturedObject.entries(info.exports)) {
17840
- const fn = instance.exports[name2];
17859
+ const fn2 = instance.exports[name2];
17841
17860
  const type = sig(func);
17842
- if (typeof fn === "function" && type) this.known.set(fn, type);
17861
+ if (typeof fn2 === "function" && type) this.known.set(fn2, type);
17843
17862
  }
17844
17863
  if (!table) return;
17845
17864
  for (const seg of info.elems) {
17846
17865
  const start2 = seg.offset + (seg.tableBase ? tableBase : 0);
17847
17866
  seg.funcs.forEach((func, i) => {
17848
17867
  const type = sig(func);
17849
- const fn = start2 + i < table.length ? table.get(start2 + i) : null;
17850
- if (fn && type) this.known.set(fn, type);
17868
+ const fn2 = start2 + i < table.length ? table.get(start2 + i) : null;
17869
+ if (fn2 && type) this.known.set(fn2, type);
17851
17870
  });
17852
17871
  }
17853
17872
  }
17854
- set(fn, sig) {
17855
- this.known.set(fn, sig);
17873
+ set(fn2, sig) {
17874
+ this.known.set(fn2, sig);
17856
17875
  }
17857
- of(fn) {
17858
- const known = this.known.get(fn);
17876
+ of(fn2) {
17877
+ const known = this.known.get(fn2);
17859
17878
  if (known || this.pending.length === 0) return known;
17860
17879
  const pending = this.pending;
17861
17880
  this.pending = [];
17862
17881
  for (const run of pending) run();
17863
- return this.known.get(fn);
17882
+ return this.known.get(fn2);
17864
17883
  }
17865
17884
  };
17866
17885
  }
@@ -17881,8 +17900,8 @@ function growTable(table, length) {
17881
17900
  if (table.length < length) table.grow(length - table.length);
17882
17901
  }
17883
17902
  function call2(instance, name2) {
17884
- const fn = instance.exports[name2];
17885
- if (typeof fn === "function") fn();
17903
+ const fn2 = instance.exports[name2];
17904
+ if (typeof fn2 === "function") fn2();
17886
17905
  }
17887
17906
  var TABLE_BASE2, PAGE2, STACK_SIZE, LIBRARY_DIRS, DlError, WasixLinker;
17888
17907
  var init_wasix_linker = __esm({
@@ -18033,23 +18052,23 @@ var init_wasix_linker = __esm({
18033
18052
  this.table.set(index3, null);
18034
18053
  }
18035
18054
  live = new capturedSet();
18036
- prepareClosure(record) {
18037
- if (!this.live.has(record.index)) throw new DlError(`closure ${record.index}: not allocated`);
18038
- const full = { kind: "closure-prepare", ...record };
18055
+ prepareClosure(record2) {
18056
+ if (!this.live.has(record2.index)) throw new DlError(`closure ${record2.index}: not allocated`);
18057
+ const full = { kind: "closure-prepare", ...record2 };
18039
18058
  this.install(full);
18040
18059
  this.publisher?.(full);
18041
18060
  }
18042
- install(record) {
18043
- growTable(this.table, record.index + 1);
18044
- const { fn, sig } = this.trampolines.make(record.params, record.results, {
18061
+ install(record2) {
18062
+ growTable(this.table, record2.index + 1);
18063
+ const { fn: fn2, sig } = this.trampolines.make(record2.params, record2.results, {
18045
18064
  memory: this.memory,
18046
18065
  table: this.table,
18047
18066
  stackPointer: this.stackPointer,
18048
- backing: record.backing,
18049
- userData: record.userData
18067
+ backing: record2.backing,
18068
+ userData: record2.userData
18050
18069
  });
18051
- this.table.set(record.index, fn);
18052
- this.types.set(fn, sig);
18070
+ this.table.set(record2.index, fn2);
18071
+ this.types.set(fn2, sig);
18053
18072
  }
18054
18073
  reserveLoad(size) {
18055
18074
  return this.indices?.load(this.table.length, size) ?? {
@@ -18079,33 +18098,33 @@ var init_wasix_linker = __esm({
18079
18098
  );
18080
18099
  return true;
18081
18100
  }
18082
- replay(record) {
18083
- if (record.kind === "closure") {
18084
- growTable(this.table, record.index + 1);
18085
- this.live.add(record.index);
18101
+ replay(record2) {
18102
+ if (record2.kind === "closure") {
18103
+ growTable(this.table, record2.index + 1);
18104
+ this.live.add(record2.index);
18086
18105
  return;
18087
18106
  }
18088
- if (record.kind === "closure-free") {
18089
- this.live.delete(record.index);
18090
- if (record.index < this.table.length) this.table.set(record.index, null);
18107
+ if (record2.kind === "closure-free") {
18108
+ this.live.delete(record2.index);
18109
+ if (record2.index < this.table.length) this.table.set(record2.index, null);
18091
18110
  return;
18092
18111
  }
18093
- if (record.kind === "closure-prepare") {
18094
- this.install(record);
18112
+ if (record2.kind === "closure-prepare") {
18113
+ this.install(record2);
18095
18114
  return;
18096
18115
  }
18097
- if (record.kind === "load") {
18098
- if (this.modules.has(record.handle)) return;
18099
- const linked = this.instantiate(record.path, this.moduleAt(record.path), record, false);
18100
- linked.needed.push(...record.needed ?? []);
18101
- this.nextHandle = capturedMath.max(this.nextHandle, record.handle + 1);
18116
+ if (record2.kind === "load") {
18117
+ if (this.modules.has(record2.handle)) return;
18118
+ const linked = this.instantiate(record2.path, this.moduleAt(record2.path), record2, false);
18119
+ linked.needed.push(...record2.needed ?? []);
18120
+ this.nextHandle = capturedMath.max(this.nextHandle, record2.handle + 1);
18102
18121
  return;
18103
18122
  }
18104
- const value2 = record.handle === 0 ? this.main?.exports[record.name] : this.module(record.handle).instance.exports[record.name];
18105
- if (typeof value2 !== "function") throw new DlError(`${record.name}: not a function`);
18106
- growTable(this.table, record.index + 1);
18107
- this.table.set(record.index, value2);
18108
- this.slots.set(value2, record.index);
18123
+ const value2 = record2.handle === 0 ? this.main?.exports[record2.name] : this.module(record2.handle).instance.exports[record2.name];
18124
+ if (typeof value2 !== "function") throw new DlError(`${record2.name}: not a function`);
18125
+ growTable(this.table, record2.index + 1);
18126
+ this.table.set(record2.index, value2);
18127
+ this.slots.set(value2, record2.index);
18109
18128
  }
18110
18129
  moduleAt(path) {
18111
18130
  const cached2 = this.cache?.[path];
@@ -18148,7 +18167,7 @@ var init_wasix_linker = __esm({
18148
18167
  );
18149
18168
  const memoryBase = this.allocate(info.memorySize, 2 ** info.memoryAlign);
18150
18169
  const { base: tableBase, handle } = this.reserveLoad(info.tableSize);
18151
- const record = {
18170
+ const record2 = {
18152
18171
  kind: "load",
18153
18172
  handle,
18154
18173
  path,
@@ -18156,9 +18175,9 @@ var init_wasix_linker = __esm({
18156
18175
  tableBase,
18157
18176
  ...needed.length > 0 ? { needed } : {}
18158
18177
  };
18159
- const linked = this.instantiate(path, module, record, true);
18178
+ const linked = this.instantiate(path, module, record2, true);
18160
18179
  linked.needed.push(...needed);
18161
- this.publisher?.(record);
18180
+ this.publisher?.(record2);
18162
18181
  return linked;
18163
18182
  }
18164
18183
  instantiate(path, module, at, init) {
@@ -18273,19 +18292,19 @@ var init_wasix_linker = __esm({
18273
18292
  indexed = 0;
18274
18293
  indexTable() {
18275
18294
  for (let i = this.indexed; i < this.table.length; i++) {
18276
- const fn = this.table.get(i);
18277
- if (fn && !this.slots.has(fn)) this.slots.set(fn, i);
18295
+ const fn2 = this.table.get(i);
18296
+ if (fn2 && !this.slots.has(fn2)) this.slots.set(fn2, i);
18278
18297
  }
18279
18298
  this.indexed = this.table.length;
18280
18299
  }
18281
- slot(fn, handle, name2) {
18300
+ slot(fn2, handle, name2) {
18282
18301
  this.indexTable();
18283
- const known = this.slots.get(fn);
18302
+ const known = this.slots.get(fn2);
18284
18303
  if (known !== void 0) return known;
18285
18304
  const index3 = this.reserve(1);
18286
18305
  growTable(this.table, index3 + 1);
18287
- this.table.set(index3, fn);
18288
- this.slots.set(fn, index3);
18306
+ this.table.set(index3, fn2);
18307
+ this.slots.set(fn2, index3);
18289
18308
  this.publisher?.({ kind: "slot", index: index3, handle, name: name2 });
18290
18309
  return index3;
18291
18310
  }
@@ -18876,7 +18895,7 @@ __export(wasi_runtime_exports, {
18876
18895
  function wireSignals(host, gate) {
18877
18896
  host.interrupted = () => gate.interrupt();
18878
18897
  host.raisedOnEntry = () => gate.raisedOnEntry();
18879
- host.quietly = (fn) => gate.quiet(fn);
18898
+ host.quietly = (fn2) => gate.quiet(fn2);
18880
18899
  host.deliverDue = () => void gate.interrupt();
18881
18900
  host.fds.restartable = () => gate.restartable();
18882
18901
  }
@@ -18897,7 +18916,7 @@ function delivering(ns, table, host, driver, before) {
18897
18916
  out[name2] = value2;
18898
18917
  continue;
18899
18918
  }
18900
- const fn = value2;
18919
+ const fn2 = value2;
18901
18920
  out[name2] = (...args) => {
18902
18921
  host.entered = false;
18903
18922
  if (driver.idle) {
@@ -18905,7 +18924,7 @@ function delivering(ns, table, host, driver, before) {
18905
18924
  host.entered = host.interrupted?.() === true;
18906
18925
  host.enteredSignals = host.entered ? host.raisedOnEntry?.() ?? -1 : 0;
18907
18926
  }
18908
- return fn(...args);
18927
+ return fn2(...args);
18909
18928
  };
18910
18929
  }
18911
18930
  return out;
@@ -19344,7 +19363,7 @@ async function runWasiProcess(init, port3) {
19344
19363
  function trapMessage(e, env, where = "", name2) {
19345
19364
  const head = `wasm trap${where}: ${e.message}`;
19346
19365
  if (env.SLICC_WASM_BACKTRACE !== "1") return head;
19347
- const lines = (e.stack ?? "").split("\n");
19366
+ const lines = (rawStack(e) ?? "").split("\n");
19348
19367
  const main = name2 && mainModule(lines);
19349
19368
  const frames = lines.filter((line) => /^\s+at .*wasm:\/\/wasm\//.test(line)).slice(0, BACKTRACE_FRAMES).map((line) => name2 && main ? nameFrame(line, main, name2) : line);
19350
19369
  return frames.length ? `${head}
@@ -19468,6 +19487,7 @@ var init_wasi_runtime = __esm({
19468
19487
  init_kernel_streams();
19469
19488
  init_process_runtime();
19470
19489
  init_process_signals();
19490
+ init_raw_stack();
19471
19491
  init_dylink();
19472
19492
  init_wasi_files();
19473
19493
  init_wasi_host();
@@ -19533,7 +19553,7 @@ var init_wasi_runtime = __esm({
19533
19553
  this.call = call3;
19534
19554
  this.ids = threads?.ids;
19535
19555
  this.owner = threads?.tid ?? 0;
19536
- linker.publisher = (record) => this.publish(record);
19556
+ linker.publisher = (record2) => this.publish(record2);
19537
19557
  linker.indices = {
19538
19558
  reserve: (floor, size) => this.call({ op: "dl-reserve", floor, size }),
19539
19559
  load: (floor, size) => this.call({ op: "dl-load-reserve", floor, size }),
@@ -19562,8 +19582,8 @@ var init_wasi_runtime = __esm({
19562
19582
  bump() {
19563
19583
  if (this.ids) capturedAtomics.add(this.ids, DL_GEN, 1);
19564
19584
  }
19565
- publish(record) {
19566
- const since = this.call({ op: "dl-log", append: record, from: this.count });
19585
+ publish(record2) {
19586
+ const since = this.call({ op: "dl-log", append: record2, from: this.count });
19567
19587
  for (const r of since.slice(0, -1)) this.linker.replay(r);
19568
19588
  this.count += since.length;
19569
19589
  this.bump();
@@ -19588,11 +19608,11 @@ var init_wasi_runtime = __esm({
19588
19608
  const ids = this.ids;
19589
19609
  if (!ids) return { preview1, wasix };
19590
19610
  const wrap2 = (table) => capturedObject.fromEntries(
19591
- capturedObject.entries(table).map(([name2, fn]) => [
19611
+ capturedObject.entries(table).map(([name2, fn2]) => [
19592
19612
  name2,
19593
19613
  ((...args) => {
19594
19614
  this.current();
19595
- const result = fn(...args);
19615
+ const result = fn2(...args);
19596
19616
  this.current();
19597
19617
  return result;
19598
19618
  })
@@ -19623,6 +19643,7 @@ import { runInThisContext } from "node:vm";
19623
19643
 
19624
19644
  // src/node-stack.ts
19625
19645
  init_captured_globals();
19646
+ init_raw_stack();
19626
19647
  import { createRequire } from "node:module";
19627
19648
  import { types } from "node:util";
19628
19649
  function quietly(target, run) {
@@ -19635,18 +19656,20 @@ function quietly(target, run) {
19635
19656
  target.emitWarning = emit;
19636
19657
  }
19637
19658
  }
19638
- function positionsOf(load) {
19659
+ function bindingOf(load) {
19639
19660
  try {
19640
19661
  const { internalBinding } = quietly(
19641
19662
  capturedprocess,
19642
19663
  () => load("internal/test/binding")
19643
19664
  );
19644
- const get = internalBinding("errors").getErrorSourcePositions;
19645
- return typeof get === "function" ? get : void 0;
19665
+ return internalBinding("errors");
19646
19666
  } catch {
19647
- return void 0;
19667
+ return {};
19648
19668
  }
19649
19669
  }
19670
+ function fn(value2) {
19671
+ return typeof value2 === "function" ? value2 : void 0;
19672
+ }
19650
19673
  var apply = capturedReflect.apply;
19651
19674
  var push = capturedArray.prototype.push;
19652
19675
  var startsWith = capturedString.prototype.startsWith;
@@ -19657,6 +19680,9 @@ var setHas = capturedSet.prototype.has;
19657
19680
  var setAdd = capturedSet.prototype.add;
19658
19681
  var mapGet = capturedWeakMap.prototype.get;
19659
19682
  var mapSet = capturedWeakMap.prototype.set;
19683
+ var mapHas = capturedWeakMap.prototype.has;
19684
+ var mapDelete = capturedWeakMap.prototype.delete;
19685
+ var MainError = capturedError;
19660
19686
  var isNativeError = types.isNativeError;
19661
19687
  var freeze = capturedObject.freeze;
19662
19688
  var blank = capturedObject.create;
@@ -19669,11 +19695,17 @@ function internals() {
19669
19695
  if (capturedprocess.sourceMapsEnabled) {
19670
19696
  fallback = load("internal/source_map/prepare_stack_trace").prepareStackTraceWithSourceMaps;
19671
19697
  }
19672
- if (typeof set !== "function" || typeof fallback !== "function") return void 0;
19698
+ const overrides = errors.overrideStackTrace;
19699
+ const usable = typeof set === "function" && typeof fallback === "function";
19700
+ if (!usable || !types.isWeakMap(overrides)) return void 0;
19701
+ const binding = bindingOf(load);
19673
19702
  return {
19674
19703
  setInternalPrepareStackTrace: set,
19675
19704
  fallback,
19676
- positions: positionsOf(load)
19705
+ positions: fn(binding.getErrorSourcePositions),
19706
+ setCallback: fn(binding.setPrepareStackTraceCallback),
19707
+ overrides,
19708
+ nodeDefault: errors.ErrorPrepareStackTrace
19677
19709
  };
19678
19710
  } catch {
19679
19711
  return void 0;
@@ -19769,6 +19801,7 @@ function keptFrames(trace) {
19769
19801
  return out;
19770
19802
  }
19771
19803
  var formatter = null;
19804
+ var withOwn = false;
19772
19805
  var formatting = false;
19773
19806
  var seen = new capturedWeakMap();
19774
19807
  function positionsAt(positions, error, site) {
@@ -19779,17 +19812,20 @@ function positionsAt(positions, error, site) {
19779
19812
  return void 0;
19780
19813
  }
19781
19814
  }
19815
+ function record(positions, error, trace) {
19816
+ if (typeof error === "object" && error !== null && trace.length > 0) {
19817
+ const site = trace[0];
19818
+ apply(mapSet, seen, [error, { site, at: positionsAt(positions, error, site) }]);
19819
+ }
19820
+ }
19782
19821
  function stackDispatcher(fallback, positions) {
19783
19822
  return (error, trace) => {
19784
- if (typeof error === "object" && error !== null && trace.length > 0) {
19785
- const site = trace[0];
19786
- apply(mapSet, seen, [error, { site, at: positionsAt(positions, error, site) }]);
19787
- }
19788
- const fn = formatter;
19789
- if (fn === null || formatting) return apply(fallback, void 0, [error, trace]);
19823
+ record(positions, error, trace);
19824
+ const fn2 = formatter;
19825
+ if (fn2 === null || formatting) return apply(fallback, void 0, [error, trace]);
19790
19826
  formatting = true;
19791
19827
  try {
19792
- const out = apply(fn, void 0, [error, keptFrames(trace)]);
19828
+ const out = apply(fn2, void 0, [error, keptFrames(trace)]);
19793
19829
  if (typeof out === "string") return out;
19794
19830
  } catch {
19795
19831
  } finally {
@@ -19798,14 +19834,81 @@ function stackDispatcher(fallback, positions) {
19798
19834
  return apply(fallback, void 0, [error, trace]);
19799
19835
  };
19800
19836
  }
19837
+ function errorOf(realm) {
19838
+ return realm === null || realm === void 0 ? void 0 : realm.Error;
19839
+ }
19840
+ function prepareOf(holder) {
19841
+ return holder === null || holder === void 0 ? void 0 : holder.prepareStackTrace;
19842
+ }
19843
+ function ownPrepare(realm, nodeDefault) {
19844
+ let self2;
19845
+ if (typeof prepareOf(errorOf(realm)) === "function") self2 = errorOf(realm);
19846
+ else if (typeof prepareOf(MainError) === "function") self2 = MainError;
19847
+ else return void 0;
19848
+ const value2 = prepareOf(self2);
19849
+ return value2 === nodeDefault ? void 0 : { fn: value2, self: self2 };
19850
+ }
19851
+ function calling(run) {
19852
+ formatting = true;
19853
+ try {
19854
+ return run();
19855
+ } finally {
19856
+ formatting = false;
19857
+ }
19858
+ }
19859
+ function kernelCallback(internal2, dispatch) {
19860
+ const { fallback, positions, overrides, nodeDefault } = internal2;
19861
+ return (realm, error, trace) => {
19862
+ if (apply(mapHas, overrides, [error]) === true) {
19863
+ const override = apply(mapGet, overrides, [error]);
19864
+ apply(mapDelete, overrides, [error]);
19865
+ return apply(override, void 0, [error, trace]);
19866
+ }
19867
+ const own2 = ownPrepare(realm, nodeDefault);
19868
+ if (formatting) return apply(fallback, void 0, [error, keptFrames(trace)]);
19869
+ const fmt = formatter;
19870
+ if (fmt !== null && withOwn) {
19871
+ record(positions, error, trace);
19872
+ return calling(() => apply(fmt, void 0, [error, keptFrames(trace), own2?.fn]));
19873
+ }
19874
+ if (own2 === void 0) return apply(dispatch, void 0, [error, trace]);
19875
+ record(positions, error, trace);
19876
+ return calling(() => apply(own2.fn, own2.self, [error, keptFrames(trace)]));
19877
+ };
19878
+ }
19879
+ function rawReader(overrides, fallback) {
19880
+ return (error) => {
19881
+ apply(mapSet, overrides, [
19882
+ error,
19883
+ (e, trace) => apply(fallback, void 0, [e, trace])
19884
+ ]);
19885
+ try {
19886
+ return error.stack;
19887
+ } finally {
19888
+ apply(mapDelete, overrides, [error]);
19889
+ }
19890
+ };
19891
+ }
19801
19892
  var found = internals();
19802
- if (found) found.setInternalPrepareStackTrace(stackDispatcher(found.fallback, found.positions));
19803
- var nodeStackFormatter = found ? (fn) => {
19804
- if (fn !== null && typeof fn !== "function") {
19893
+ if (found) {
19894
+ const dispatch = stackDispatcher(found.fallback, found.positions);
19895
+ found.setInternalPrepareStackTrace(dispatch);
19896
+ if (found.setCallback) {
19897
+ found.setCallback(kernelCallback(found, dispatch));
19898
+ setRawStack(rawReader(found.overrides, found.fallback));
19899
+ }
19900
+ }
19901
+ var nodeStackFormatter = found ? (next2, options) => {
19902
+ if (next2 !== null && typeof next2 !== "function") {
19805
19903
  throw new capturedTypeError("setStackFormatter needs a function or null");
19806
19904
  }
19905
+ const own2 = options === void 0 ? false : options.own;
19906
+ if (typeof own2 !== "boolean" && own2 !== void 0) {
19907
+ throw new capturedTypeError("setStackFormatter: own must be a boolean");
19908
+ }
19807
19909
  const previous = formatter;
19808
- formatter = fn;
19910
+ formatter = next2;
19911
+ withOwn = next2 !== null && own2 === true;
19809
19912
  return previous;
19810
19913
  } : void 0;
19811
19914
  function errorSourceOf(error) {
@@ -20153,9 +20256,9 @@ function nodeAsyncContext() {
20153
20256
  const getStore = storage.getStore.bind(storage);
20154
20257
  const enterWith = storage.enterWith.bind(storage);
20155
20258
  const api = blank2(null);
20156
- api.run = freeze2((store, fn, ...args) => {
20157
- if (typeof fn !== "function") throw new capturedTypeError("asyncContext.run needs a function");
20158
- return run(store, () => apply2(fn, void 0, args));
20259
+ api.run = freeze2((store, fn2, ...args) => {
20260
+ if (typeof fn2 !== "function") throw new capturedTypeError("asyncContext.run needs a function");
20261
+ return run(store, () => apply2(fn2, void 0, args));
20159
20262
  });
20160
20263
  api.getStore = freeze2(() => getStore());
20161
20264
  api.enterWith = freeze2((store) => enterWith(store));
@@ -20170,6 +20273,7 @@ init_captured_globals();
20170
20273
  init_cpu_clock();
20171
20274
  init_protocol();
20172
20275
  init_process_runtime();
20276
+ init_raw_stack();
20173
20277
  var loadWasi = () => Promise.resolve().then(() => (init_wasi_runtime(), wasi_runtime_exports));
20174
20278
  var loadJs = () => Promise.resolve().then(() => (init_js_runtime(), js_runtime_exports));
20175
20279
  var NOT_RUNNABLE2 = 126;
@@ -20186,7 +20290,7 @@ function processEntry(port3, run = runWasmProcess, wasi = loadWasi, js = loadJs,
20186
20290
  }) {
20187
20291
  const failed5 = (err, code2) => port3.postMessage({
20188
20292
  type: WASM_PROCESS_ERROR,
20189
- message: err instanceof capturedError ? err.stack ?? err.message : capturedString(err),
20293
+ message: err instanceof capturedError ? rawStack(err) ?? err.message : capturedString(err),
20190
20294
  ...code2 === void 0 ? {} : { code: code2 }
20191
20295
  });
20192
20296
  let refused3;