@ai-ecoverse/slicc-kernel 1.110.4 → 1.110.6

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.
@@ -5212,7 +5212,7 @@ var KERNEL_VERSION, OS_RELEASE;
5212
5212
  var init_version = __esm({
5213
5213
  "src/version.ts"() {
5214
5214
  "use strict";
5215
- KERNEL_VERSION = true ? "1.110.4" : "0.0.0-dev";
5215
+ KERNEL_VERSION = true ? "1.110.6" : "0.0.0-dev";
5216
5216
  OS_RELEASE = "6.0.0-slicc";
5217
5217
  }
5218
5218
  });
@@ -6484,12 +6484,13 @@ function fetchOp(kernel) {
6484
6484
  throw signal.aborted ? signal.reason : failed(err);
6485
6485
  }
6486
6486
  };
6487
- const body = (handle, signal) => {
6487
+ const body = (handle, request) => {
6488
+ const { signal } = request;
6488
6489
  let aborted;
6489
6490
  const settle = () => {
6490
6491
  if (aborted) signal.removeEventListener("abort", aborted);
6491
6492
  };
6492
- return new ReadableStream(
6493
+ const stream = new ReadableStream(
6493
6494
  {
6494
6495
  start(controller) {
6495
6496
  aborted = () => {
@@ -6524,8 +6525,10 @@ function fetchOp(kernel) {
6524
6525
  },
6525
6526
  { highWaterMark: 0 }
6526
6527
  );
6528
+ keptRequests.set(stream, request);
6529
+ return stream;
6527
6530
  };
6528
- const respond = (head, method, redirected, encoded, signal) => {
6531
+ const respond = (head, method, redirected, encoded, request) => {
6529
6532
  if (head.status < 200 || head.status > 599) {
6530
6533
  void close(head.handle);
6531
6534
  throw failed(new JsCallError("EPROTO", `status ${head.status}`));
@@ -6533,7 +6536,7 @@ function fetchOp(kernel) {
6533
6536
  const empty = method === "HEAD" || NULL_BODY.has(head.status);
6534
6537
  if (empty) void close(head.handle);
6535
6538
  const headers = new Headers(head.headers);
6536
- let stream = empty ? null : body(head.handle, signal);
6539
+ let stream = empty ? null : body(head.handle, request);
6537
6540
  const coding = headers.get("content-encoding")?.trim().toLowerCase();
6538
6541
  if (stream && encoded && coding && DECODED.has(coding)) {
6539
6542
  const format = coding === "deflate" ? "deflate" : "gzip";
@@ -6541,6 +6544,7 @@ function fetchOp(kernel) {
6541
6544
  new DecompressionStream(format)
6542
6545
  );
6543
6546
  headers.delete("content-length");
6547
+ keptRequests.set(stream, request);
6544
6548
  }
6545
6549
  const response = new Response(stream, {
6546
6550
  status: head.status,
@@ -6586,7 +6590,7 @@ function fetchOp(kernel) {
6586
6590
  const follow2 = known.manualRedirects && REDIRECTS.has(head.status) && location !== void 0 && request.redirect !== "manual";
6587
6591
  if (!follow2) {
6588
6592
  const redirected = hops > 0 || head.redirected === true;
6589
- return respond(head, hop.method, redirected, known.encodedBodies, signal);
6593
+ return respond(head, hop.method, redirected, known.encodedBodies, request);
6590
6594
  }
6591
6595
  await close(head.handle);
6592
6596
  if (request.redirect === "error") throw failed(new Error("unexpected redirect"));
@@ -6595,7 +6599,7 @@ function fetchOp(kernel) {
6595
6599
  }
6596
6600
  };
6597
6601
  }
6598
- var CHUNK2, MAX_REDIRECTS, NULL_BODY, REDIRECTS, BODY_HEADERS, DECODED, CREDENTIALS, BAD_PORTS, OVER, TOKEN, QUOTABLE, SPACE, BASE64, SLICE;
6602
+ var CHUNK2, MAX_REDIRECTS, keptRequests, NULL_BODY, REDIRECTS, BODY_HEADERS, DECODED, CREDENTIALS, BAD_PORTS, OVER, TOKEN, QUOTABLE, SPACE, BASE64, SLICE;
6599
6603
  var init_js_fetch = __esm({
6600
6604
  "src/process/js/js-fetch.ts"() {
6601
6605
  "use strict";
@@ -6603,6 +6607,7 @@ var init_js_fetch = __esm({
6603
6607
  init_js_kernel();
6604
6608
  CHUNK2 = 64 * 1024;
6605
6609
  MAX_REDIRECTS = 20;
6610
+ keptRequests = /* @__PURE__ */ new WeakMap();
6606
6611
  NULL_BODY = /* @__PURE__ */ new Set([101, 103, 204, 205, 304]);
6607
6612
  REDIRECTS = /* @__PURE__ */ new Set([301, 302, 303, 307, 308]);
6608
6613
  BODY_HEADERS = /* @__PURE__ */ new Set([
@@ -9020,6 +9025,7 @@ function useMounts(Fs, env = {}, live = false) {
9020
9025
  if (typeof Fs.open !== "function" || typeof writeFile !== "function") return;
9021
9026
  const { passwd, group } = accounts(env);
9022
9027
  const backing = { "/etc/mtab": "/proc/mounts" };
9028
+ const defaults = {};
9023
9029
  try {
9024
9030
  if (!live) writeFile.call(Fs, "/proc/mounts", mountTable());
9025
9031
  } catch {
@@ -9027,20 +9033,39 @@ function useMounts(Fs, env = {}, live = false) {
9027
9033
  }
9028
9034
  try {
9029
9035
  mkdirTree.call(Fs, "/dev/.etc");
9030
- writeFile.call(Fs, "/dev/.etc/passwd", passwd);
9031
- writeFile.call(Fs, "/dev/.etc/group", group);
9032
- writeFile.call(Fs, "/dev/.etc/hosts", hostsFile(hostnameOf(env)));
9033
- writeFile.call(Fs, "/dev/.etc/hostname", `${hostnameOf(env)}
9034
- `);
9035
- backing["/etc/passwd"] = "/dev/.etc/passwd";
9036
- backing["/etc/group"] = "/dev/.etc/group";
9037
- backing["/etc/hosts"] = "/dev/.etc/hosts";
9038
- backing["/etc/hostname"] = "/dev/.etc/hostname";
9036
+ const files = {
9037
+ passwd,
9038
+ group,
9039
+ hosts: hostsFile(hostnameOf(env)),
9040
+ hostname: `${hostnameOf(env)}
9041
+ `
9042
+ };
9043
+ for (const [name2, text] of Object.entries(files)) {
9044
+ writeFile.call(Fs, `/dev/.etc/${name2}`, text);
9045
+ backing[`/etc/${name2}`] = `/dev/.etc/${name2}`;
9046
+ defaults[`/etc/${name2}`] = text;
9047
+ }
9039
9048
  } catch {
9040
9049
  }
9041
9050
  const open = Fs.open.bind(Fs);
9051
+ const seed = (path, text) => {
9052
+ let stream;
9053
+ try {
9054
+ stream = open(path, O_WRONLY5 | O_CREAT | O_EXCL, 420);
9055
+ } catch {
9056
+ return;
9057
+ }
9058
+ try {
9059
+ const bytes = new TextEncoder().encode(text);
9060
+ Fs.write(stream, bytes, 0, bytes.length);
9061
+ } finally {
9062
+ Fs.closeStream(stream.fd);
9063
+ }
9064
+ };
9042
9065
  Fs.open = (path, flags, mode) => {
9043
9066
  const instead = backing[path];
9067
+ const text = defaults[path];
9068
+ if (text !== void 0 && (flags & (O_ACCMODE3 | O_CREAT)) !== 0) seed(path, text);
9044
9069
  if (!instead || (flags & (O_ACCMODE3 | O_CREAT)) !== 0) return open(path, flags, mode);
9045
9070
  try {
9046
9071
  return open(path, flags, mode);
@@ -9222,7 +9247,7 @@ function linuxDevices(Fs) {
9222
9247
  }
9223
9248
  }
9224
9249
  }
9225
- var O_CLOEXEC, FD_CLOEXEC, F_DUPFD, F_GETFD, F_SETFD, F_GETFL, F_DUPFD_CLOEXEC, tracked, IMPORT_NAMES, EBADF, AT_SYMLINK_NOFOLLOW2, EMSCRIPTEN_EPERM, O_PATH2, LITERALS, UTIME_NOW, UTIME_OMIT, PROT_WRITE, MAP_PRIVATE, MAP_TYPE, O_WRONLY5, MAP_ALIGN, DIR_MODE, LINK_MODE, CHAR_DEVICE, O_ACCMODE3, O_CREAT, field, pinnedRoot, rootKind, NAME, AT_FDCWD, AT_EACCESS2, W_ACCESS, X_ACCESS, AT_SYMLINK_FOLLOW, UTS_FIELD, DEVICE_MODES;
9250
+ var O_CLOEXEC, FD_CLOEXEC, F_DUPFD, F_GETFD, F_SETFD, F_GETFL, F_DUPFD_CLOEXEC, tracked, IMPORT_NAMES, EBADF, AT_SYMLINK_NOFOLLOW2, EMSCRIPTEN_EPERM, O_PATH2, LITERALS, UTIME_NOW, UTIME_OMIT, PROT_WRITE, MAP_PRIVATE, MAP_TYPE, O_WRONLY5, MAP_ALIGN, DIR_MODE, LINK_MODE, CHAR_DEVICE, O_ACCMODE3, O_CREAT, O_EXCL, field, pinnedRoot, rootKind, NAME, AT_FDCWD, AT_EACCESS2, W_ACCESS, X_ACCESS, AT_SYMLINK_FOLLOW, UTS_FIELD, DEVICE_MODES;
9226
9251
  var init_process_fds = __esm({
9227
9252
  "src/process/process-fds.ts"() {
9228
9253
  "use strict";
@@ -9282,6 +9307,7 @@ var init_process_fds = __esm({
9282
9307
  CHAR_DEVICE = 8630;
9283
9308
  O_ACCMODE3 = 3;
9284
9309
  O_CREAT = 64;
9310
+ O_EXCL = 128;
9285
9311
  field = (text) => (text || "none").replace(/[\s\\]/g, (c) => `\\${c.charCodeAt(0).toString(8).padStart(3, "0")}`);
9286
9312
  rootKind = () => globalThis.navigator?.storage ? "opfs" : "memory";
9287
9313
  NAME = /^[a-z_][a-z0-9_-]*$/i;
@@ -11726,7 +11752,7 @@ function datesOf(real) {
11726
11752
  dates[key] = new Date(value2);
11727
11753
  return dates;
11728
11754
  }
11729
- var POLLIN, POLLOUT, POLLERR, POLLHUP, POLLRDNORM, POLLWRNORM, TCSETSF, O_NONBLOCK2, SOCKET_MODE, PTY_PATH, TTY_PATH, TTY_NAME, SEALED_PATH2, STRERROR, CLIPBOARD_PATH2, O_CREAT2, O_EXCL, O_NOCTTY, O_TRUNC2, O_DIRECTORY, KILLED_BY_SIGPIPE, ProcessExit, SyscallError, KernelStreams;
11755
+ var POLLIN, POLLOUT, POLLERR, POLLHUP, POLLRDNORM, POLLWRNORM, TCSETSF, O_NONBLOCK2, SOCKET_MODE, PTY_PATH, TTY_PATH, TTY_NAME, SEALED_PATH2, STRERROR, CLIPBOARD_PATH2, O_CREAT2, O_EXCL2, O_NOCTTY, O_TRUNC2, O_DIRECTORY, KILLED_BY_SIGPIPE, ProcessExit, SyscallError, KernelStreams;
11730
11756
  var init_kernel_streams = __esm({
11731
11757
  "src/process/kernel-streams.ts"() {
11732
11758
  "use strict";
@@ -11756,7 +11782,7 @@ var init_kernel_streams = __esm({
11756
11782
  };
11757
11783
  CLIPBOARD_PATH2 = "/dev/clipboard";
11758
11784
  O_CREAT2 = 64;
11759
- O_EXCL = 128;
11785
+ O_EXCL2 = 128;
11760
11786
  O_NOCTTY = 256;
11761
11787
  O_TRUNC2 = 512;
11762
11788
  O_DIRECTORY = 65536;
@@ -12057,13 +12083,13 @@ var init_kernel_streams = __esm({
12057
12083
  try {
12058
12084
  return open(path, flags, mode);
12059
12085
  } catch (err) {
12060
- const lost = err.errno === wasiErrno("EEXIST") && !(flags & O_EXCL);
12086
+ const lost = err.errno === wasiErrno("EEXIST") && !(flags & O_EXCL2);
12061
12087
  if (!lost) throw err;
12062
12088
  return open(path, flags, mode);
12063
12089
  }
12064
12090
  }
12065
12091
  refuseExclusiveLink(path, flags) {
12066
- if ((flags & (O_CREAT2 | O_EXCL)) !== (O_CREAT2 | O_EXCL)) return;
12092
+ if ((flags & (O_CREAT2 | O_EXCL2)) !== (O_CREAT2 | O_EXCL2)) return;
12067
12093
  let mode = 0;
12068
12094
  try {
12069
12095
  mode = this.Fs.stat?.(path, true)?.mode ?? 0;
@@ -12105,7 +12131,7 @@ var init_kernel_streams = __esm({
12105
12131
  vessel(open, kfd, at, terminal) {
12106
12132
  let stream;
12107
12133
  try {
12108
- stream = open("/dev/null", at.flags & ~(O_CREAT2 | O_EXCL | O_TRUNC2), at.mode);
12134
+ stream = open("/dev/null", at.flags & ~(O_CREAT2 | O_EXCL2 | O_TRUNC2), at.mode);
12109
12135
  } catch (e) {
12110
12136
  this.sys.close(kfd);
12111
12137
  throw e;
@@ -12444,7 +12470,7 @@ function restoreForkedStreams(Fs, streams2, table) {
12444
12470
  } else {
12445
12471
  const placed = place(
12446
12472
  Fs,
12447
- Fs.open(entry.path, entry.flags & ~(O_CREAT3 | O_EXCL2 | O_TRUNC3)),
12473
+ Fs.open(entry.path, entry.flags & ~(O_CREAT3 | O_EXCL3 | O_TRUNC3)),
12448
12474
  entry.fd
12449
12475
  );
12450
12476
  setCloseOnExec(placed, (entry.flags & O_CLOEXEC) !== 0);
@@ -12453,7 +12479,7 @@ function restoreForkedStreams(Fs, streams2, table) {
12453
12479
  }
12454
12480
  }
12455
12481
  }
12456
- var O_RDWR4, O_ACCMODE4, O_CREAT3, O_EXCL2, O_TRUNC3, PLACEHOLDER_DIR, NAMED_DEVICES, ACCESS, DEVICES2, FIFO_MODE, nextStreamIno, streamInos;
12482
+ var O_RDWR4, O_ACCMODE4, O_CREAT3, O_EXCL3, O_TRUNC3, PLACEHOLDER_DIR, NAMED_DEVICES, ACCESS, DEVICES2, FIFO_MODE, nextStreamIno, streamInos;
12457
12483
  var init_process_fork = __esm({
12458
12484
  "src/process/process-fork.ts"() {
12459
12485
  "use strict";
@@ -12461,7 +12487,7 @@ var init_process_fork = __esm({
12461
12487
  O_RDWR4 = 2;
12462
12488
  O_ACCMODE4 = 3;
12463
12489
  O_CREAT3 = 64;
12464
- O_EXCL2 = 128;
12490
+ O_EXCL3 = 128;
12465
12491
  O_TRUNC3 = 512;
12466
12492
  PLACEHOLDER_DIR = "/dev/slicc-fd";
12467
12493
  NAMED_DEVICES = {