@ai-ecoverse/slicc-kernel 1.26.6 → 1.27.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +26 -3
- package/dist/driver-worker.js +1 -1
- package/dist/driver-worker.js.map +1 -1
- package/dist/index.js +66 -12
- package/dist/index.js.map +4 -4
- package/dist/kernel-worker.js +297 -17
- package/dist/kernel-worker.js.map +4 -4
- package/dist/node-driver-worker.js +1 -1
- package/dist/node-driver-worker.js.map +1 -1
- package/dist/node-process-worker.js +82 -19
- package/dist/node-process-worker.js.map +4 -4
- package/dist/node.js +243 -11
- package/dist/node.js.map +4 -4
- package/dist/process-worker.js +82 -19
- package/dist/process-worker.js.map +4 -4
- package/dist/testing.js +27 -0
- package/dist/testing.js.map +7 -0
- package/package.json +4 -3
package/dist/process-worker.js
CHANGED
|
@@ -2955,6 +2955,7 @@ function createSocketKernel(deps) {
|
|
|
2955
2955
|
name: (fd, peer) => guard(() => json({ op: "sock-name", fd: kfd(fd), peer })),
|
|
2956
2956
|
getopt: (fd, level, name) => guard(() => ({ value: json({ op: "sock-getopt", fd: kfd(fd), level, name }) })),
|
|
2957
2957
|
setopt: (fd, level, name, value2) => guard(() => done({ op: "sock-setopt", fd: kfd(fd), level, name, value: value2 })),
|
|
2958
|
+
resolve: (name, family = 4) => guard(() => json({ op: "sock-resolve", name, family })),
|
|
2958
2959
|
send: (fd, bytes, flags) => guard(() => {
|
|
2959
2960
|
const stream = socketAt(fd);
|
|
2960
2961
|
const nonblock = flags.dontwait === true || (stream.flags & O_NONBLOCK) !== 0;
|
|
@@ -6341,6 +6342,67 @@ var init_wasix_process = __esm({
|
|
|
6341
6342
|
}
|
|
6342
6343
|
});
|
|
6343
6344
|
|
|
6345
|
+
// src/kernel/net/routes.ts
|
|
6346
|
+
function ipv4Bytes(text) {
|
|
6347
|
+
const parts = text.split(".");
|
|
6348
|
+
if (parts.length !== 4 || !parts.every((p) => /^\d{1,3}$/.test(p))) return void 0;
|
|
6349
|
+
const bytes = parts.map(Number);
|
|
6350
|
+
return bytes.every((b) => b <= 255) ? bytes : void 0;
|
|
6351
|
+
}
|
|
6352
|
+
function ipv6Groups(text) {
|
|
6353
|
+
if (!text.includes(":")) return void 0;
|
|
6354
|
+
let canonical;
|
|
6355
|
+
try {
|
|
6356
|
+
canonical = new URL(`http://[${text}]/`).hostname.slice(1, -1);
|
|
6357
|
+
} catch {
|
|
6358
|
+
return void 0;
|
|
6359
|
+
}
|
|
6360
|
+
const [head, tail] = canonical.split("::");
|
|
6361
|
+
const part = (s) => s ? s.split(":").map((h) => Number.parseInt(h, 16)) : [];
|
|
6362
|
+
const front = part(head);
|
|
6363
|
+
const back = part(tail);
|
|
6364
|
+
return tail === void 0 ? front : [...front, ...new Array(8 - front.length - back.length).fill(0), ...back];
|
|
6365
|
+
}
|
|
6366
|
+
function toBits(values, width) {
|
|
6367
|
+
return values.reduce((acc, v) => acc << BigInt(width) | BigInt(v), 0n);
|
|
6368
|
+
}
|
|
6369
|
+
function addressBits(host) {
|
|
6370
|
+
const v4 = ipv4Bytes(host);
|
|
6371
|
+
if (v4) return { v6: false, bits: toBits(v4, 8) };
|
|
6372
|
+
const v6 = ipv6Groups(host);
|
|
6373
|
+
return v6 ? { v6: true, bits: toBits(v6, 16) } : void 0;
|
|
6374
|
+
}
|
|
6375
|
+
function parsePrefix(text) {
|
|
6376
|
+
const parts = text.trim().split("/");
|
|
6377
|
+
if (parts.length > 2) return void 0;
|
|
6378
|
+
const [address = "", size] = parts;
|
|
6379
|
+
const parsed = addressBits(address);
|
|
6380
|
+
if (!parsed) return void 0;
|
|
6381
|
+
const max = parsed.v6 ? 128 : 32;
|
|
6382
|
+
const length = size === void 0 ? max : /^\d{1,3}$/.test(size) ? Number(size) : -1;
|
|
6383
|
+
if (length < 0 || length > max) return void 0;
|
|
6384
|
+
return { ...parsed, length };
|
|
6385
|
+
}
|
|
6386
|
+
var HOST_ADDRESS, RESERVED;
|
|
6387
|
+
var init_routes = __esm({
|
|
6388
|
+
"src/kernel/net/routes.ts"() {
|
|
6389
|
+
"use strict";
|
|
6390
|
+
init_loopback_names();
|
|
6391
|
+
HOST_ADDRESS = HOST_LOOPBACK_ADDRESS.join(".");
|
|
6392
|
+
RESERVED = [
|
|
6393
|
+
"0.0.0.0/8",
|
|
6394
|
+
"127.0.0.0/8",
|
|
6395
|
+
"169.254.0.0/16",
|
|
6396
|
+
"224.0.0.0/4",
|
|
6397
|
+
"240.0.0.0/4",
|
|
6398
|
+
"::/96",
|
|
6399
|
+
"::ffff:0:0/96",
|
|
6400
|
+
"fe80::/10",
|
|
6401
|
+
"ff00::/8"
|
|
6402
|
+
].map((p) => parsePrefix(p));
|
|
6403
|
+
}
|
|
6404
|
+
});
|
|
6405
|
+
|
|
6344
6406
|
// src/process/wasi/wasix-sockets.ts
|
|
6345
6407
|
function readAddr(view, ptr) {
|
|
6346
6408
|
const tag = view.getUint8(ptr);
|
|
@@ -6387,20 +6449,16 @@ function writeAddr(view, ptr, addr) {
|
|
|
6387
6449
|
const octets = ipv4(addr.host) ?? [127, 0, 0, 1];
|
|
6388
6450
|
octets.forEach((b, i) => void view.setUint8(ptr + 4 + i, b));
|
|
6389
6451
|
}
|
|
6452
|
+
function ipBytes(host) {
|
|
6453
|
+
const groups = ipv4(host) ? void 0 : ipv6Groups(host);
|
|
6454
|
+
return groups ? groups.flatMap((g) => [g >> 8, g & 255]) : ipv4(host);
|
|
6455
|
+
}
|
|
6390
6456
|
function ipv4(host) {
|
|
6391
6457
|
const parts = host.split(".");
|
|
6392
6458
|
if (parts.length !== 4) return void 0;
|
|
6393
6459
|
const bytes = parts.map((p) => /^\d{1,3}$/.test(p) ? Number(p) : Number.NaN);
|
|
6394
6460
|
return bytes.every((b) => b >= 0 && b <= 255) ? bytes : void 0;
|
|
6395
6461
|
}
|
|
6396
|
-
function resolveName(name) {
|
|
6397
|
-
if (name === "localhost" || name === "localhost.localdomain" || name === "ip6-localhost") {
|
|
6398
|
-
return [127, 0, 0, 1];
|
|
6399
|
-
}
|
|
6400
|
-
if (name === "::1") return [127, 0, 0, 1];
|
|
6401
|
-
if (name.toLowerCase() === HOST_LOOPBACK) return [...HOST_LOOPBACK_ADDRESS];
|
|
6402
|
-
return ipv4(name);
|
|
6403
|
-
}
|
|
6404
6462
|
function wasixSocketImports(host, preview1) {
|
|
6405
6463
|
const { mem, fds, o } = host;
|
|
6406
6464
|
const call2 = (req) => o.kernel.call(req);
|
|
@@ -6492,14 +6550,19 @@ function wasixSocketImports(host, preview1) {
|
|
|
6492
6550
|
sock_set_opt_time: (fd) => void socket(fd),
|
|
6493
6551
|
sock_send_file: () => E.NOSYS,
|
|
6494
6552
|
resolve: (name, len, _port, addrs, naddrs, out) => {
|
|
6495
|
-
const
|
|
6496
|
-
|
|
6553
|
+
const found = call2({ op: "sock-resolve", name: mem.string(name, len), family: 0 });
|
|
6554
|
+
const ips = found.map(ipBytes).filter((ip) => ip !== void 0);
|
|
6555
|
+
if (ips.length === 0) throw new WasiError("ENOENT");
|
|
6497
6556
|
if (naddrs < 1) throw new WasiError("EINVAL");
|
|
6498
6557
|
const view = mem.view();
|
|
6499
|
-
|
|
6500
|
-
view.
|
|
6501
|
-
|
|
6502
|
-
|
|
6558
|
+
const count = Math.min(ips.length, naddrs);
|
|
6559
|
+
new Uint8Array(view.buffer, addrs, ADDR_IP_SIZE * count).fill(0);
|
|
6560
|
+
for (let i = 0; i < count; i++) {
|
|
6561
|
+
const at = addrs + i * ADDR_IP_SIZE;
|
|
6562
|
+
view.setUint8(at, ips[i].length === 4 ? INET4 : INET6);
|
|
6563
|
+
new Uint8Array(view.buffer, at + 2, ips[i].length).set(ips[i]);
|
|
6564
|
+
}
|
|
6565
|
+
view.setUint32(out, count, true);
|
|
6503
6566
|
}
|
|
6504
6567
|
};
|
|
6505
6568
|
}
|
|
@@ -6507,7 +6570,7 @@ var INET4, INET6, UNIX, STREAM, ADDR_IP_SIZE, LOOPBACK, OPTIONS;
|
|
|
6507
6570
|
var init_wasix_sockets = __esm({
|
|
6508
6571
|
"src/process/wasi/wasix-sockets.ts"() {
|
|
6509
6572
|
"use strict";
|
|
6510
|
-
|
|
6573
|
+
init_routes();
|
|
6511
6574
|
init_wasi_abi();
|
|
6512
6575
|
init_wasi_files();
|
|
6513
6576
|
INET4 = 1;
|
|
@@ -7016,7 +7079,7 @@ function firstOther(foreign) {
|
|
|
7016
7079
|
function accepted(imp, scope2) {
|
|
7017
7080
|
const { module, name, kind } = imp;
|
|
7018
7081
|
if (module === PREVIEW1 || module === WASIX) return true;
|
|
7019
|
-
if (!
|
|
7082
|
+
if (!RESERVED2.has(module) && (scope2.extended || scope2.wasi && kind === "function")) return true;
|
|
7020
7083
|
if (scope2.pie && (module === "GOT.mem" || module === "GOT.func")) return true;
|
|
7021
7084
|
if (scope2.pie && module === "env" && kind !== "memory") return true;
|
|
7022
7085
|
if (kind === "memory" && scope2.memory?.module === module && scope2.memory.name === name)
|
|
@@ -7044,7 +7107,7 @@ function unsupportedImport(module, memory, extended = false, foreign = {}) {
|
|
|
7044
7107
|
}
|
|
7045
7108
|
function linkImports(module, preview1, wasix, memory, threads, program = {}, foreign, slicc = {}) {
|
|
7046
7109
|
for (const ns of Object.keys(program)) {
|
|
7047
|
-
if (
|
|
7110
|
+
if (RESERVED2.has(ns) || ns === SLICC)
|
|
7048
7111
|
throw new Error(`the imports module may not define ${ns}`);
|
|
7049
7112
|
}
|
|
7050
7113
|
const imports = {
|
|
@@ -7352,7 +7415,7 @@ async function runWasiThread(init, port) {
|
|
|
7352
7415
|
throw e;
|
|
7353
7416
|
}
|
|
7354
7417
|
}
|
|
7355
|
-
var TRAPPED, PREVIEW1, WASIX, SLICC,
|
|
7418
|
+
var TRAPPED, PREVIEW1, WASIX, SLICC, RESERVED2, noErrno, FALLBACK_MAXIMUM_PAGES, LinkSync, DL_GEN, BACKTRACE_FRAMES;
|
|
7356
7419
|
var init_wasi_runtime = __esm({
|
|
7357
7420
|
"src/process/wasi/wasi-runtime.ts"() {
|
|
7358
7421
|
"use strict";
|
|
@@ -7378,7 +7441,7 @@ var init_wasi_runtime = __esm({
|
|
|
7378
7441
|
PREVIEW1 = "wasi_snapshot_preview1";
|
|
7379
7442
|
WASIX = "wasix_32v1";
|
|
7380
7443
|
SLICC = "slicc";
|
|
7381
|
-
|
|
7444
|
+
RESERVED2 = RESERVED_NAMESPACES;
|
|
7382
7445
|
noErrno = (key) => `imports ${key}: its result cannot carry ENOSYS, and this host does not provide it`;
|
|
7383
7446
|
FALLBACK_MAXIMUM_PAGES = 32768;
|
|
7384
7447
|
LinkSync = class {
|