@ai-ecoverse/slicc-kernel 1.181.0 → 1.183.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.
Files changed (39) hide show
  1. package/README.md +62 -11
  2. package/dist/driver-worker.js +290 -90
  3. package/dist/driver-worker.js.map +4 -4
  4. package/dist/index.js +328 -102
  5. package/dist/index.js.map +4 -4
  6. package/dist/kernel-worker.js +1727 -703
  7. package/dist/kernel-worker.js.map +4 -4
  8. package/dist/node-driver-worker.js +298 -98
  9. package/dist/node-driver-worker.js.map +4 -4
  10. package/dist/node-process-worker.cjs +849 -193
  11. package/dist/node-process-worker.cjs.map +4 -4
  12. package/dist/node-process-worker.js +849 -193
  13. package/dist/node-process-worker.js.map +4 -4
  14. package/dist/node.js +1897 -751
  15. package/dist/node.js.map +4 -4
  16. package/dist/process-worker.js +805 -149
  17. package/dist/process-worker.js.map +4 -4
  18. package/dist/types/cdp/types.d.ts +2 -0
  19. package/dist/types/client/attach.d.ts +2 -0
  20. package/dist/types/client/protocol.d.ts +1 -0
  21. package/dist/types/client/serve-client.d.ts +1 -0
  22. package/dist/types/devices-relay.d.ts +74 -0
  23. package/dist/types/index.d.ts +14 -0
  24. package/dist/types/kernel/devices.d.ts +155 -0
  25. package/dist/types/kernel/embedder.d.ts +2 -0
  26. package/dist/types/kernel/fd-table.d.ts +3 -1
  27. package/dist/types/kernel/host.d.ts +2 -0
  28. package/dist/types/kernel/process.d.ts +20 -0
  29. package/dist/types/kernel/serial-ioctl.d.ts +73 -0
  30. package/dist/types/kernel/socket.d.ts +2 -0
  31. package/dist/types/launcher.d.ts +4 -0
  32. package/dist/types/node.d.ts +6 -2
  33. package/dist/types/process/js/js-dev.d.ts +24 -0
  34. package/dist/types/process/kernel-streams.d.ts +11 -1
  35. package/dist/types/process/process-pty.d.ts +1 -0
  36. package/dist/types/process/wasi/wasi-fds.d.ts +1 -0
  37. package/dist/types/process/wasi/wasi-termios.d.ts +1 -0
  38. package/dist/types/serve.d.ts +14 -1
  39. package/package.json +3 -3
@@ -46,11 +46,120 @@ function serveCdpPort(port, hook, request, onDone) {
46
46
  };
47
47
  }
48
48
 
49
- // src/embedder-relay.ts
49
+ // src/devices-relay.ts
50
+ function quiet() {
51
+ return void 0;
52
+ }
53
+ function errorOf(err) {
54
+ const name = err?.name;
55
+ const message = err instanceof Error ? err.message : String(err);
56
+ return { name: typeof name === "string" ? name : "Error", message };
57
+ }
50
58
  function fresh(bytes) {
51
59
  return bytes.byteOffset === 0 && bytes.byteLength === bytes.buffer.byteLength ? bytes : bytes.slice();
52
60
  }
53
- function errorOf(err) {
61
+ function devicesAnswerer(port, hookFor) {
62
+ const locals = /* @__PURE__ */ new Map();
63
+ const post = (message, transfer = []) => port.postMessage({ devicesReply: message }, transfer);
64
+ const open = async (id, asked) => {
65
+ const local = { abort: new AbortController() };
66
+ locals.set(id, local);
67
+ try {
68
+ const hook = hookFor(asked.client);
69
+ if (!hook)
70
+ throw Object.assign(new Error("this page has no devices hook"), {
71
+ name: "NotSupportedError"
72
+ });
73
+ const streams = await hook.open({
74
+ path: asked.path,
75
+ flags: asked.flags,
76
+ stamp: asked.stamp,
77
+ signal: local.abort.signal
78
+ });
79
+ if (!locals.has(id)) {
80
+ await streams?.readable?.cancel("closed").catch(quiet);
81
+ await streams?.writable?.abort("closed").catch(quiet);
82
+ await Promise.resolve(streams?.control?.("close")).catch(quiet);
83
+ return;
84
+ }
85
+ local.streams = streams;
86
+ local.reader = streams.readable.getReader();
87
+ local.writer = streams.writable.getWriter();
88
+ post({ id, opened: true });
89
+ } catch (err) {
90
+ locals.delete(id);
91
+ post({ id, failed: errorOf(err) });
92
+ }
93
+ };
94
+ const pull = async (id, local) => {
95
+ try {
96
+ const got = await local.reader.read();
97
+ if (got.done) return post({ id, done: true });
98
+ const bytes = fresh(got.value);
99
+ post({ id, chunk: bytes }, [bytes.buffer]);
100
+ } catch (err) {
101
+ post({ id, readError: errorOf(err) });
102
+ }
103
+ };
104
+ const write = async (id, local, bytes, seq) => {
105
+ try {
106
+ await local.writer.write(bytes);
107
+ post({ id, wrote: seq });
108
+ } catch (err) {
109
+ post({ id, writeError: errorOf(err), seq });
110
+ }
111
+ };
112
+ const control = async (id, local, asked) => {
113
+ try {
114
+ await local.closing;
115
+ const value = await local.streams.control(asked.op, asked.args);
116
+ post({ id, answered: asked.seq, ...value !== void 0 ? { value } : {} });
117
+ } catch (err) {
118
+ post({ id, refused: asked.seq, error: errorOf(err) });
119
+ }
120
+ if (asked.op === "close") locals.delete(id);
121
+ };
122
+ const release = async (local, reason) => {
123
+ const { reader: reader2, writer } = local;
124
+ local.reader = void 0;
125
+ local.writer = void 0;
126
+ await reader2?.cancel(reason).catch(quiet);
127
+ reader2?.releaseLock();
128
+ await writer?.abort(reason).catch(quiet);
129
+ writer?.releaseLock();
130
+ };
131
+ const cancel = (id, local, reason) => {
132
+ local.abort.abort(new DOMException(reason, "AbortError"));
133
+ if (!local.streams) {
134
+ locals.delete(id);
135
+ return;
136
+ }
137
+ local.closing = Promise.resolve(local.closing).then(() => release(local, reason));
138
+ };
139
+ return {
140
+ handle(data) {
141
+ const message = data?.devices;
142
+ if (!message) return false;
143
+ if ("open" in message) {
144
+ void open(message.id, message.open);
145
+ return true;
146
+ }
147
+ const local = locals.get(message.id);
148
+ if (!local) return true;
149
+ if ("pull" in message) void pull(message.id, local);
150
+ else if ("write" in message) void write(message.id, local, message.write, message.seq);
151
+ else if ("control" in message) void control(message.id, local, message.control);
152
+ else cancel(message.id, local, message.cancel);
153
+ return true;
154
+ }
155
+ };
156
+ }
157
+
158
+ // src/embedder-relay.ts
159
+ function fresh2(bytes) {
160
+ return bytes.byteOffset === 0 && bytes.byteLength === bytes.buffer.byteLength ? bytes : bytes.slice();
161
+ }
162
+ function errorOf2(err) {
54
163
  const name = err?.name;
55
164
  const message = err instanceof Error ? err.message : String(err);
56
165
  return { name: typeof name === "string" ? name : "Error", message };
@@ -89,7 +198,7 @@ function embedderAnswerer(port, hookFor) {
89
198
  const post = (message, transfer = []) => port.postMessage({ embedderReply: message }, transfer);
90
199
  const fail = (id, err) => {
91
200
  running.delete(id);
92
- post({ id, error: errorOf(err) });
201
+ post({ id, error: errorOf2(err) });
93
202
  };
94
203
  const start = async (ask) => {
95
204
  const state = { abort: new AbortController(), body: [], wakeBody: void 0 };
@@ -124,7 +233,7 @@ function embedderAnswerer(port, hookFor) {
124
233
  post({ id, done: true });
125
234
  return;
126
235
  }
127
- const bytes = fresh(got.value);
236
+ const bytes = fresh2(got.value);
128
237
  post({ id, chunk: bytes }, [bytes.buffer]);
129
238
  } catch (err) {
130
239
  fail(id, err);
@@ -204,6 +313,9 @@ function serveFacadePort(port, hook, { name, stamp }, onDone) {
204
313
  };
205
314
  }
206
315
 
316
+ // src/fs/owners.ts
317
+ var ROOT_OWNER = Object.freeze({ uid: 0, gid: 0 });
318
+
207
319
  // src/kernel/pipe.ts
208
320
  var PIPE_CAPACITY = 64 * 1024;
209
321
 
@@ -226,6 +338,139 @@ function kindsOf(hook) {
226
338
  );
227
339
  }
228
340
 
341
+ // src/kernel/serial-ioctl.ts
342
+ var IOCTL = {
343
+ TCGETS: 21505,
344
+ TCSETS: 21506,
345
+ TCSETSW: 21507,
346
+ TCSETSF: 21508,
347
+ TCSBRK: 21513,
348
+ TCFLSH: 21515,
349
+ TIOCEXCL: 21516,
350
+ TIOCNXCL: 21517,
351
+ TIOCSCTTY: 21518,
352
+ TIOCGPGRP: 21519,
353
+ TIOCSPGRP: 21520,
354
+ TIOCOUTQ: 21521,
355
+ TIOCGWINSZ: 21523,
356
+ TIOCSWINSZ: 21524,
357
+ TIOCMGET: 21525,
358
+ TIOCMBIS: 21526,
359
+ TIOCMBIC: 21527,
360
+ TIOCMSET: 21528,
361
+ FIONREAD: 21531,
362
+ TIOCNOTTY: 21538,
363
+ TCSBRKP: 21541,
364
+ TIOCSBRK: 21543,
365
+ TIOCCBRK: 21544,
366
+ TCGETS2: 2150388778,
367
+ TCSETS2: 1076646955,
368
+ TCSETSW2: 1076646956,
369
+ TCSETSF2: 1076646957
370
+ };
371
+ var TERMIOS_GETS = /* @__PURE__ */ new Set([IOCTL.TCGETS, IOCTL.TCGETS2]);
372
+ var TERMIOS_SETS = /* @__PURE__ */ new Set([
373
+ IOCTL.TCSETS,
374
+ IOCTL.TCSETSW,
375
+ IOCTL.TCSETSF,
376
+ IOCTL.TCSETS2,
377
+ IOCTL.TCSETSW2,
378
+ IOCTL.TCSETSF2
379
+ ]);
380
+ var INT_OUT = /* @__PURE__ */ new Set([
381
+ IOCTL.TIOCMGET,
382
+ IOCTL.FIONREAD,
383
+ IOCTL.TIOCOUTQ
384
+ ]);
385
+ var INT_IN = /* @__PURE__ */ new Set([
386
+ IOCTL.TIOCMBIS,
387
+ IOCTL.TIOCMBIC,
388
+ IOCTL.TIOCMSET
389
+ ]);
390
+ var INT_ARG = /* @__PURE__ */ new Set([IOCTL.TCSBRK, IOCTL.TCSBRKP, IOCTL.TCFLSH]);
391
+ var CSIZE = 48;
392
+ var CSTOPB = 64;
393
+ var PARENB = 256;
394
+ var PARODD = 512;
395
+ var CRTSCTS = 2147483648;
396
+ function settingsOf(cflag, baudRate) {
397
+ return {
398
+ baudRate,
399
+ dataBits: 5 + ((cflag & CSIZE) >> 4),
400
+ parity: cflag & PARENB ? cflag & PARODD ? "odd" : "even" : "none",
401
+ stopBits: cflag & CSTOPB ? 2 : 1,
402
+ flowControl: cflag & CRTSCTS ? "hardware" : "none"
403
+ };
404
+ }
405
+ var SERIAL_CFLAG = 13 | 48 | 128 | 1024 | 2048;
406
+ var SERIAL_LFLAG = 16 | 32 | 512 | 2048;
407
+
408
+ // src/kernel/signals.ts
409
+ var SIG = {
410
+ HUP: 1,
411
+ INT: 2,
412
+ QUIT: 3,
413
+ ILL: 4,
414
+ TRAP: 5,
415
+ ABRT: 6,
416
+ BUS: 7,
417
+ FPE: 8,
418
+ KILL: 9,
419
+ USR1: 10,
420
+ SEGV: 11,
421
+ USR2: 12,
422
+ PIPE: 13,
423
+ ALRM: 14,
424
+ TERM: 15,
425
+ STKFLT: 16,
426
+ CHLD: 17,
427
+ CONT: 18,
428
+ STOP: 19,
429
+ TSTP: 20,
430
+ TTIN: 21,
431
+ TTOU: 22,
432
+ URG: 23,
433
+ XCPU: 24,
434
+ XFSZ: 25,
435
+ VTALRM: 26,
436
+ PROF: 27,
437
+ WINCH: 28,
438
+ POLL: 29,
439
+ PWR: 30,
440
+ SYS: 31
441
+ };
442
+ var IGNORED_BY_DEFAULT = /* @__PURE__ */ new Set([SIG.CHLD, SIG.URG, SIG.WINCH]);
443
+ var STOPPING = /* @__PURE__ */ new Set([SIG.STOP, SIG.TSTP, SIG.TTIN, SIG.TTOU]);
444
+ function quiet2(p) {
445
+ p.catch(() => void 0);
446
+ return p;
447
+ }
448
+ var SIGNAL_BY_NAME = {
449
+ SIGINT: SIG.INT,
450
+ SIGTERM: SIG.TERM,
451
+ SIGKILL: SIG.KILL,
452
+ SIGSTOP: SIG.STOP,
453
+ SIGCONT: SIG.CONT
454
+ };
455
+ var SI = { USER: 0, QUEUE: -1, TIMER: -2, TKILL: -6, KERNEL: 128 };
456
+ var KERNEL_SIGINFO = Object.freeze({
457
+ code: SI.KERNEL,
458
+ pid: 0,
459
+ uid: 0,
460
+ status: 0
461
+ });
462
+
463
+ // src/kernel/tty.ts
464
+ var encoder = new TextEncoder();
465
+
466
+ // src/kernel/devices.ts
467
+ var HIGH_WATER = 64 * 1024;
468
+ var DEFAULT_SETTINGS = settingsOf(SERIAL_CFLAG, 9600);
469
+ function devicesHook(hook) {
470
+ if (typeof hook?.open !== "function") throw new TypeError("devices needs open");
471
+ return { open: (request) => hook.open(request) };
472
+ }
473
+
229
474
  // src/kernel/net/transport.ts
230
475
  var FORBIDDEN_HEADER = "forbidden-header";
231
476
 
@@ -318,7 +563,7 @@ function honors(traits, redirect) {
318
563
  const raw = traits.manualRedirects === true && (hops === void 0 || hops === false);
319
564
  return redirect === "manual" && raw;
320
565
  }
321
- function refused(message) {
566
+ function refused2(message) {
322
567
  return new TransportError(message, 502, void 0, "transport");
323
568
  }
324
569
  var RemoteTransport = class {
@@ -409,7 +654,7 @@ var RemoteTransport = class {
409
654
  const { signal, redirect } = request;
410
655
  signal.throwIfAborted();
411
656
  if (unfollowed(redirect) && !honors(this.traits, redirect)) {
412
- throw refused(`this transport cannot honor redirect: ${redirect}`);
657
+ throw refused2(`this transport cannot honor redirect: ${redirect}`);
413
658
  }
414
659
  let finished = false;
415
660
  const abort = () => {
@@ -460,7 +705,7 @@ var RemoteTransport = class {
460
705
  };
461
706
  if (unfollowed(redirect) && (redirected || redirects?.length)) {
462
707
  await cancel();
463
- throw refused(`this transport followed a redirect despite redirect: ${redirect}`);
708
+ throw refused2(`this transport followed a redirect despite redirect: ${redirect}`);
464
709
  }
465
710
  return {
466
711
  ...url !== void 0 ? { url } : {},
@@ -527,63 +772,8 @@ var RemoteTransport = class {
527
772
  }
528
773
  };
529
774
 
530
- // src/kernel/signals.ts
531
- var SIG = {
532
- HUP: 1,
533
- INT: 2,
534
- QUIT: 3,
535
- ILL: 4,
536
- TRAP: 5,
537
- ABRT: 6,
538
- BUS: 7,
539
- FPE: 8,
540
- KILL: 9,
541
- USR1: 10,
542
- SEGV: 11,
543
- USR2: 12,
544
- PIPE: 13,
545
- ALRM: 14,
546
- TERM: 15,
547
- STKFLT: 16,
548
- CHLD: 17,
549
- CONT: 18,
550
- STOP: 19,
551
- TSTP: 20,
552
- TTIN: 21,
553
- TTOU: 22,
554
- URG: 23,
555
- XCPU: 24,
556
- XFSZ: 25,
557
- VTALRM: 26,
558
- PROF: 27,
559
- WINCH: 28,
560
- POLL: 29,
561
- PWR: 30,
562
- SYS: 31
563
- };
564
- var IGNORED_BY_DEFAULT = /* @__PURE__ */ new Set([SIG.CHLD, SIG.URG, SIG.WINCH]);
565
- var STOPPING = /* @__PURE__ */ new Set([SIG.STOP, SIG.TSTP, SIG.TTIN, SIG.TTOU]);
566
- function quiet(p) {
567
- p.catch(() => void 0);
568
- return p;
569
- }
570
- var SIGNAL_BY_NAME = {
571
- SIGINT: SIG.INT,
572
- SIGTERM: SIG.TERM,
573
- SIGKILL: SIG.KILL,
574
- SIGSTOP: SIG.STOP,
575
- SIGCONT: SIG.CONT
576
- };
577
- var SI = { USER: 0, QUEUE: -1, TIMER: -2, TKILL: -6, KERNEL: 128 };
578
- var KERNEL_SIGINFO = Object.freeze({
579
- code: SI.KERNEL,
580
- pid: 0,
581
- uid: 0,
582
- status: 0
583
- });
584
-
585
775
  // src/bytes.ts
586
- function fresh2(bytes, start = 0, end = bytes.length) {
776
+ function fresh3(bytes, start = 0, end = bytes.length) {
587
777
  return new Uint8Array(bytes.subarray(start, end));
588
778
  }
589
779
 
@@ -640,7 +830,7 @@ function dialStream(port, onClose) {
640
830
  const writable = new WritableStream({
641
831
  write(chunk) {
642
832
  if (closed) throw errorWithCode("EPIPE: the connection is closed");
643
- const copy = fresh2(chunk);
833
+ const copy = fresh3(chunk);
644
834
  const acked = new Promise((resolve, reject) => acks.push({ resolve, reject }));
645
835
  port.postMessage(copy, [copy.buffer]);
646
836
  return acked;
@@ -661,7 +851,7 @@ function dialStream(port, onClose) {
661
851
 
662
852
  // src/client/loopback-fetch.ts
663
853
  var OWN_HEADERS = /* @__PURE__ */ new Set(["host", "connection", "content-length", "transfer-encoding"]);
664
- var encoder = new TextEncoder();
854
+ var encoder2 = new TextEncoder();
665
855
  var latin1 = new TextDecoder("latin1");
666
856
  var ByteSource = class {
667
857
  buffered = new Uint8Array(0);
@@ -679,7 +869,7 @@ var ByteSource = class {
679
869
  return true;
680
870
  }
681
871
  async until(marker) {
682
- const needle = encoder.encode(marker);
872
+ const needle = encoder2.encode(marker);
683
873
  for (; ; ) {
684
874
  const at = indexOf(this.buffered, needle);
685
875
  if (at >= 0) return this.take(at + needle.length);
@@ -787,7 +977,7 @@ async function requestBytes(request) {
787
977
  });
788
978
  if (body) lines.push(`Content-Length: ${body.length}`);
789
979
  lines.push("Connection: close", "", "");
790
- const head = encoder.encode(lines.join("\r\n"));
980
+ const head = encoder2.encode(lines.join("\r\n"));
791
981
  const out = new Uint8Array(head.length + (body?.length ?? 0));
792
982
  out.set(head);
793
983
  if (body) out.set(body, head.length);
@@ -827,7 +1017,7 @@ async function loopbackFetch(dial, input, options) {
827
1017
  }
828
1018
 
829
1019
  // src/client/protocol.ts
830
- var PROTOCOL = [1, 16];
1020
+ var PROTOCOL = [1, 18];
831
1021
  function locksOf(scope = globalThis) {
832
1022
  const locks = scope.navigator?.locks;
833
1023
  return typeof locks?.request === "function" ? locks : void 0;
@@ -854,8 +1044,8 @@ var KernelCallError = class extends Error {
854
1044
  this.code = code;
855
1045
  }
856
1046
  };
857
- var encoder2 = new TextEncoder();
858
- var bytesOf2 = (data) => typeof data === "string" ? encoder2.encode(data) : data;
1047
+ var encoder3 = new TextEncoder();
1048
+ var bytesOf2 = (data) => typeof data === "string" ? encoder3.encode(data) : data;
859
1049
  var UNAVAILABLE = {
860
1050
  manualRedirects: false,
861
1051
  encodedBodies: false,
@@ -941,8 +1131,10 @@ var Channel = class {
941
1131
  return this.request(call).done;
942
1132
  }
943
1133
  requests;
1134
+ devices;
944
1135
  receive(data) {
945
1136
  if (this.requests?.handle(data)) return;
1137
+ if (this.devices?.handle(data)) return;
946
1138
  if (data.traits && data.id === void 0) {
947
1139
  if (this.remote) this.remote.traits = data.traits;
948
1140
  for (const listener of [...this.traitsListeners]) listener(data.traits);
@@ -1147,7 +1339,7 @@ async function sudoRunOn(channel, replay, { stdout, stderr, tag }) {
1147
1339
  return { pid, pgid: pid, ended: endedOf(done, () => endedBy) };
1148
1340
  }
1149
1341
  function endedOf(done, signal) {
1150
- return quiet(
1342
+ return quiet2(
1151
1343
  done.then((status) => {
1152
1344
  const by = signal();
1153
1345
  return { status, ...by ? { signal: by } : {} };
@@ -1277,9 +1469,14 @@ function since(channel, minor, what, run) {
1277
1469
  }
1278
1470
  return run();
1279
1471
  }
1280
- async function greet(channel, lock, timeoutMs, requests) {
1472
+ async function greet(channel, lock, timeoutMs, requests, devices) {
1281
1473
  channel.post({
1282
- hello: { protocol: PROTOCOL, ...lock ? { lock } : {}, ...requests ? { requests } : {} }
1474
+ hello: {
1475
+ protocol: PROTOCOL,
1476
+ ...lock ? { lock } : {},
1477
+ ...requests ? { requests } : {},
1478
+ ...devices ? { devices: true } : {}
1479
+ }
1283
1480
  });
1284
1481
  const timer = setTimeout(
1285
1482
  () => channel.end(
@@ -1293,9 +1490,9 @@ async function greet(channel, lock, timeoutMs, requests) {
1293
1490
  } finally {
1294
1491
  clearTimeout(timer);
1295
1492
  }
1296
- const refused3 = hello.error ?? versionError(hello.protocol);
1297
- if (refused3) {
1298
- const error = new Error(refused3);
1493
+ const refused4 = hello.error ?? versionError(hello.protocol);
1494
+ if (refused4) {
1495
+ const error = new Error(refused4);
1299
1496
  channel.end(error);
1300
1497
  throw error;
1301
1498
  }
@@ -1307,11 +1504,14 @@ async function attachKernel(port, options = {}) {
1307
1504
  const channel = new Channel(port, own.release);
1308
1505
  const requests = options.requests;
1309
1506
  if (requests) channel.requests = embedderAnswerer(port, () => requests);
1507
+ const devices = options.devices ? devicesHook(options.devices) : void 0;
1508
+ if (devices) channel.devices = devicesAnswerer(port, () => devices);
1310
1509
  const hello = await greet(
1311
1510
  channel,
1312
1511
  own.name,
1313
1512
  options.timeoutMs ?? 1e4,
1314
- requests ? kindsOf(requests) : void 0
1513
+ requests ? kindsOf(requests) : void 0,
1514
+ devices !== void 0
1315
1515
  );
1316
1516
  channel.protocol = hello.protocol;
1317
1517
  if (hello.lock && locks) void locks.request(hello.lock, () => channel.end(new KernelGoneError()));
@@ -1377,7 +1577,7 @@ function ownerOf(req) {
1377
1577
  function withOwner(base, owner) {
1378
1578
  return owner ? { ...base, owner } : base;
1379
1579
  }
1380
- function fsError(code, message = code) {
1580
+ function fsError2(code, message = code) {
1381
1581
  return Object.assign(new Error(message), { code });
1382
1582
  }
1383
1583
  var SET_ATTRS = ["mode", "mtime", "atime", "size", "uid", "gid"];
@@ -1421,32 +1621,32 @@ async function dispatch(h, req) {
1421
1621
  case "rename":
1422
1622
  return h.rename(req.from, req.to);
1423
1623
  case "link":
1424
- if (!h.link) throw fsError("EPERM", "this file system has no hard links");
1624
+ if (!h.link) throw fsError2("EPERM", "this file system has no hard links");
1425
1625
  return h.link(req.from, req.to);
1426
1626
  case "mkfifo":
1427
- if (!h.mkfifo) throw fsError("EPERM", "this file system has no FIFOs");
1627
+ if (!h.mkfifo) throw fsError2("EPERM", "this file system has no FIFOs");
1428
1628
  return ownerOf(req) ? h.mkfifo(req.path, ownerOf(req)) : h.mkfifo(req.path);
1429
1629
  case "symlink":
1430
- if (!h.symlink) throw fsError("EPERM", "this file system has no symlinks");
1630
+ if (!h.symlink) throw fsError2("EPERM", "this file system has no symlinks");
1431
1631
  return ownerOf(req) ? h.symlink(req.target, req.path, ownerOf(req)) : h.symlink(req.target, req.path);
1432
1632
  case "readlink":
1433
- if (!h.readlink) throw fsError("EINVAL", `${req.path} is not a symlink`);
1633
+ if (!h.readlink) throw fsError2("EINVAL", `${req.path} is not a symlink`);
1434
1634
  return h.readlink(req.path);
1435
1635
  case "setattr":
1436
1636
  return h.setattr?.(req.path, setAttrOf(req));
1437
1637
  case "statfs":
1438
1638
  return h.statfs?.() ?? null;
1439
1639
  default:
1440
- throw fsError("ENOSYS", `unknown driver op ${req.op}`);
1640
+ throw fsError2("ENOSYS", `unknown driver op ${req.op}`);
1441
1641
  }
1442
1642
  }
1443
1643
  function serveFilesystem(port, handlers, capabilities = {}, options = {}) {
1444
1644
  let open = false;
1445
1645
  const reply = (message, transfer = []) => port.postMessage(message, transfer);
1446
1646
  async function hello(message) {
1447
- const refused3 = driverVersionError(message.protocol);
1448
- if (refused3) {
1449
- reply({ hello: { protocol: DRIVER_PROTOCOL, error: refused3, errno: "EPROTO" } });
1647
+ const refused4 = driverVersionError(message.protocol);
1648
+ if (refused4) {
1649
+ reply({ hello: { protocol: DRIVER_PROTOCOL, error: refused4, errno: "EPROTO" } });
1450
1650
  return;
1451
1651
  }
1452
1652
  try {
@@ -1477,7 +1677,7 @@ function serveFilesystem(port, handlers, capabilities = {}, options = {}) {
1477
1677
  (result) => {
1478
1678
  if (result instanceof Uint8Array) {
1479
1679
  const whole = result.byteOffset === 0 && result.byteLength === result.buffer.byteLength;
1480
- const bytes = options.owned && whole ? result : fresh2(result);
1680
+ const bytes = options.owned && whole ? result : fresh3(result);
1481
1681
  reply({ id: data.id, result: bytes }, [bytes.buffer]);
1482
1682
  } else reply({ id: data.id, result: result ?? null });
1483
1683
  },
@@ -1616,7 +1816,7 @@ var fileOf = proto.getFileName;
1616
1816
  var hashOf = proto.getScriptHash;
1617
1817
  var isEval = proto.isEval;
1618
1818
  var originOf = proto.getEvalOrigin;
1619
- var lineOf = proto.getLineNumber;
1819
+ var lineOf2 = proto.getLineNumber;
1620
1820
  var nameOf = proto.getScriptNameOrSourceURL;
1621
1821
  var functionOf = proto.getFunctionName;
1622
1822
  var typeOf = proto.getTypeName;
@@ -1746,7 +1946,7 @@ function stackDispatcher(fallback, positions) {
1746
1946
  return apply(fallback, void 0, [error, trace]);
1747
1947
  };
1748
1948
  }
1749
- function errorOf2(realm) {
1949
+ function errorOf3(realm) {
1750
1950
  return realm === null || realm === void 0 ? void 0 : realm.Error;
1751
1951
  }
1752
1952
  function prepareOf(holder) {
@@ -1754,7 +1954,7 @@ function prepareOf(holder) {
1754
1954
  }
1755
1955
  function ownPrepare(realm, nodeDefault) {
1756
1956
  let self2;
1757
- if (typeof prepareOf(errorOf2(realm)) === "function") self2 = errorOf2(realm);
1957
+ if (typeof prepareOf(errorOf3(realm)) === "function") self2 = errorOf3(realm);
1758
1958
  else if (typeof prepareOf(MainError) === "function") self2 = MainError;
1759
1959
  else return void 0;
1760
1960
  const value = prepareOf(self2);
@@ -1838,7 +2038,7 @@ function errorSourceOf(error) {
1838
2038
  if (jsonParseSite(error, got))
1839
2039
  return at.scriptResourceName === void 0 ? answer(at) : void 0;
1840
2040
  const file = scriptOf(site);
1841
- if (at.scriptResourceName !== file || apply(lineOf, site, []) !== at.lineNumber) return void 0;
2041
+ if (at.scriptResourceName !== file || apply(lineOf2, site, []) !== at.lineNumber) return void 0;
1842
2042
  return answer(at);
1843
2043
  }
1844
2044
  function answer(at) {
@@ -1883,7 +2083,7 @@ var OPEN_SLOTS = [
1883
2083
  "Worker",
1884
2084
  "postMessage"
1885
2085
  ];
1886
- function chain(target) {
2086
+ function chain2(target) {
1887
2087
  const out = [];
1888
2088
  for (let at = target; at && at !== Object.prototype; ) {
1889
2089
  out.push(at);
@@ -1893,7 +2093,7 @@ function chain(target) {
1893
2093
  }
1894
2094
  function hide(target, names) {
1895
2095
  for (const name of names) {
1896
- const holders = chain(target);
2096
+ const holders = chain2(target);
1897
2097
  for (const holder of holders) Reflect.deleteProperty(holder, name);
1898
2098
  const kept = holders.slice(1).some((holder) => Object.hasOwn(holder, name));
1899
2099
  const defined = Reflect.defineProperty(target, name, {
@@ -1909,7 +2109,7 @@ function hide(target, names) {
1909
2109
  }
1910
2110
  function vacate(target, names) {
1911
2111
  for (const name of names) {
1912
- const holders = chain(target);
2112
+ const holders = chain2(target);
1913
2113
  for (const holder of holders) Reflect.deleteProperty(holder, name);
1914
2114
  const kept = holders.slice(1).some((holder) => Object.hasOwn(holder, name));
1915
2115
  const opened = Reflect.defineProperty(target, name, {
@@ -1960,7 +2160,7 @@ function zeroedBuffers(buffer) {
1960
2160
  poolSize: fixed(0)
1961
2161
  });
1962
2162
  }
1963
- function refused2(specifier) {
2163
+ function refused3(specifier) {
1964
2164
  return Object.assign(new Error(`slicc-kernel: a JS program cannot import ${specifier}`), {
1965
2165
  code: "ERR_ACCESS_DENIED"
1966
2166
  });
@@ -1975,12 +2175,12 @@ function refuseModules() {
1975
2175
  registerHooks({
1976
2176
  resolve(specifier, context, next) {
1977
2177
  if (specifier.startsWith(SOURCE_MODULE)) {
1978
- if (!sources.has(specifier)) throw refused2(specifier);
2178
+ if (!sources.has(specifier)) throw refused3(specifier);
1979
2179
  return { url: specifier, shortCircuit: true };
1980
2180
  }
1981
- if (isBuiltin(specifier)) throw refused2(specifier);
2181
+ if (isBuiltin(specifier)) throw refused3(specifier);
1982
2182
  const resolved = next(specifier, context);
1983
- if (!resolved.url.startsWith("data:")) throw refused2(resolved.url);
2183
+ if (!resolved.url.startsWith("data:")) throw refused3(resolved.url);
1984
2184
  return resolved;
1985
2185
  },
1986
2186
  load(url, context, next) {