@ai-ecoverse/slicc-kernel 1.47.2 → 1.48.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 +12 -1
- package/dist/kernel-worker.js +32 -3
- package/dist/kernel-worker.js.map +2 -2
- package/dist/node-process-worker.js +83 -9
- package/dist/node-process-worker.js.map +4 -4
- package/dist/node.js +32 -3
- package/dist/node.js.map +2 -2
- package/dist/process-worker.js +83 -9
- package/dist/process-worker.js.map +4 -4
- package/package.json +2 -2
package/dist/process-worker.js
CHANGED
|
@@ -5460,6 +5460,75 @@ var init_wasi_poll = __esm({
|
|
|
5460
5460
|
}
|
|
5461
5461
|
});
|
|
5462
5462
|
|
|
5463
|
+
// src/process/wasi/wasi-termios.ts
|
|
5464
|
+
function writeTermios(mem, ptr, termios) {
|
|
5465
|
+
mem.bytes(ptr, OSPEED + 4).fill(0);
|
|
5466
|
+
const v = mem.view();
|
|
5467
|
+
v.setUint32(ptr, termios.c_iflag, true);
|
|
5468
|
+
v.setUint32(ptr + 4, termios.c_oflag, true);
|
|
5469
|
+
v.setUint32(ptr + 8, termios.c_cflag, true);
|
|
5470
|
+
v.setUint32(ptr + 12, termios.c_lflag, true);
|
|
5471
|
+
for (let i = 0; i < NCCS; i++) v.setUint8(ptr + C_CC + i, termios.c_cc[i] ?? 0);
|
|
5472
|
+
v.setUint8(ptr + C_LINE, 0);
|
|
5473
|
+
v.setUint32(ptr + ISPEED, B38400, true);
|
|
5474
|
+
v.setUint32(ptr + OSPEED, B38400, true);
|
|
5475
|
+
}
|
|
5476
|
+
function readTermios(mem, ptr) {
|
|
5477
|
+
const v = mem.view();
|
|
5478
|
+
return {
|
|
5479
|
+
c_iflag: v.getUint32(ptr, true),
|
|
5480
|
+
c_oflag: v.getUint32(ptr + 4, true),
|
|
5481
|
+
c_cflag: v.getUint32(ptr + 8, true),
|
|
5482
|
+
c_lflag: v.getUint32(ptr + 12, true),
|
|
5483
|
+
c_cc: Array.from({ length: NCCS }, (_, i) => v.getUint8(ptr + C_CC + i))
|
|
5484
|
+
};
|
|
5485
|
+
}
|
|
5486
|
+
function sliccTty(mem, fds, kernel) {
|
|
5487
|
+
const { sys } = kernel;
|
|
5488
|
+
const terminal = (fd) => {
|
|
5489
|
+
const e = fds.find(fd);
|
|
5490
|
+
if (!e) throw new WasiError("EBADF");
|
|
5491
|
+
if (e.type !== "kernel" || fds.kind(fd, e) !== "tty") throw new WasiError("ENOTTY");
|
|
5492
|
+
return fd;
|
|
5493
|
+
};
|
|
5494
|
+
const needs = (value2) => {
|
|
5495
|
+
if (value2 === void 0) throw new WasiError("ENOTTY");
|
|
5496
|
+
return value2;
|
|
5497
|
+
};
|
|
5498
|
+
const setAttr = (fd, actions, ptr) => {
|
|
5499
|
+
if (actions < 0 || actions > TCSAFLUSH) throw new WasiError("EINVAL");
|
|
5500
|
+
const at = terminal(fd);
|
|
5501
|
+
needs(sys.tcsets);
|
|
5502
|
+
sys.tcsets?.(at, readTermios(mem, ptr));
|
|
5503
|
+
};
|
|
5504
|
+
const size = (fd, ptr) => {
|
|
5505
|
+
const [rows, cols] = needs(sys.winsize?.(terminal(fd)));
|
|
5506
|
+
mem.bytes(ptr, 8).fill(0);
|
|
5507
|
+
const v = mem.view();
|
|
5508
|
+
v.setUint16(ptr, rows, true);
|
|
5509
|
+
v.setUint16(ptr + 2, cols, true);
|
|
5510
|
+
};
|
|
5511
|
+
return {
|
|
5512
|
+
tcgetattr: (fd, ptr) => void writeTermios(mem, ptr, needs(sys.tcgets?.(terminal(fd)))),
|
|
5513
|
+
tcsetattr: (fd, actions, ptr) => void setAttr(fd, actions, ptr),
|
|
5514
|
+
winsize: (fd, ptr) => void size(fd, ptr)
|
|
5515
|
+
};
|
|
5516
|
+
}
|
|
5517
|
+
var NCCS, C_LINE, C_CC, ISPEED, OSPEED, B38400, TCSAFLUSH;
|
|
5518
|
+
var init_wasi_termios = __esm({
|
|
5519
|
+
"src/process/wasi/wasi-termios.ts"() {
|
|
5520
|
+
"use strict";
|
|
5521
|
+
init_wasi_files();
|
|
5522
|
+
NCCS = 32;
|
|
5523
|
+
C_LINE = 16;
|
|
5524
|
+
C_CC = 17;
|
|
5525
|
+
ISPEED = 52;
|
|
5526
|
+
OSPEED = 56;
|
|
5527
|
+
B38400 = 15;
|
|
5528
|
+
TCSAFLUSH = 2;
|
|
5529
|
+
}
|
|
5530
|
+
});
|
|
5531
|
+
|
|
5463
5532
|
// src/process/wasi/wasi-host.ts
|
|
5464
5533
|
function filetypeOf(s) {
|
|
5465
5534
|
if (!s) return FILETYPE.UNKNOWN;
|
|
@@ -5482,6 +5551,7 @@ function kernelFiletype(kind) {
|
|
|
5482
5551
|
case "device":
|
|
5483
5552
|
return { filetype: FILETYPE.CHARACTER_DEVICE, seeks: true };
|
|
5484
5553
|
case "socket":
|
|
5554
|
+
case "stream":
|
|
5485
5555
|
return { filetype: FILETYPE.SOCKET_STREAM, seeks: false };
|
|
5486
5556
|
case "file":
|
|
5487
5557
|
return { filetype: FILETYPE.REGULAR_FILE, seeks: true };
|
|
@@ -5528,6 +5598,7 @@ var init_wasi_host = __esm({
|
|
|
5528
5598
|
init_wasi_files();
|
|
5529
5599
|
init_wasi_memory();
|
|
5530
5600
|
init_wasi_poll();
|
|
5601
|
+
init_wasi_termios();
|
|
5531
5602
|
WasiExit = class extends Error {
|
|
5532
5603
|
code;
|
|
5533
5604
|
constructor(code2) {
|
|
@@ -5586,6 +5657,9 @@ var init_wasi_host = __esm({
|
|
|
5586
5657
|
const umask = this.o.kernel.call({ op: "proc-umask" });
|
|
5587
5658
|
if (umask !== DEFAULT_UMASK) this.o.fs.chmod(path, mode & ~umask);
|
|
5588
5659
|
}
|
|
5660
|
+
sliccTtyImports() {
|
|
5661
|
+
return wrap(sliccTty(this.mem, this.fds, this.o.kernel));
|
|
5662
|
+
}
|
|
5589
5663
|
sliccFsImports() {
|
|
5590
5664
|
const { mem, fds } = this;
|
|
5591
5665
|
const at = (dirfd, p, l) => fds.resolve(dirfd, mem.string(p, l));
|
|
@@ -7928,11 +8002,7 @@ var init_wasix_host = __esm({
|
|
|
7928
8002
|
v.setUint8(ptr + 16, isTty(0));
|
|
7929
8003
|
v.setUint8(ptr + 17, isTty(1));
|
|
7930
8004
|
v.setUint8(ptr + 18, isTty(2));
|
|
7931
|
-
if (fd === void 0)
|
|
7932
|
-
v.setUint32(ptr, 80, true);
|
|
7933
|
-
v.setUint32(ptr + 4, 24, true);
|
|
7934
|
-
return;
|
|
7935
|
-
}
|
|
8005
|
+
if (fd === void 0) throw new WasiError("ENOTTY");
|
|
7936
8006
|
const [rows, cols] = host.o.kernel.sys.winsize?.(fd) ?? [24, 80];
|
|
7937
8007
|
const termios = host.o.kernel.sys.tcgets?.(fd);
|
|
7938
8008
|
v.setUint32(ptr, cols, true);
|
|
@@ -8081,15 +8151,16 @@ function unsupportedImport(module, memory, extended = false, foreign = {}) {
|
|
|
8081
8151
|
}
|
|
8082
8152
|
return void 0;
|
|
8083
8153
|
}
|
|
8084
|
-
function linkImports(module, preview1, wasix, memory, threads, program = {}, foreign, slicc = {}, sliccFs = {}) {
|
|
8154
|
+
function linkImports(module, preview1, wasix, memory, threads, program = {}, foreign, slicc = {}, sliccFs = {}, sliccTty2 = {}) {
|
|
8085
8155
|
for (const ns of Object.keys(program)) {
|
|
8086
|
-
if (RESERVED2.has(ns) || ns === SLICC || ns === SLICC_FS)
|
|
8156
|
+
if (RESERVED2.has(ns) || ns === SLICC || ns === SLICC_FS || ns === SLICC_TTY)
|
|
8087
8157
|
throw new Error(`the imports module may not define ${ns}`);
|
|
8088
8158
|
}
|
|
8089
8159
|
const imports = {
|
|
8090
8160
|
...program,
|
|
8091
8161
|
[SLICC]: { ...slicc },
|
|
8092
8162
|
[SLICC_FS]: { ...sliccFs },
|
|
8163
|
+
[SLICC_TTY]: { ...sliccTty2 },
|
|
8093
8164
|
[PREVIEW1]: preview1,
|
|
8094
8165
|
...wasix ? { [WASIX]: { ...wasix } } : {},
|
|
8095
8166
|
...threads ? { wasi: { "thread-spawn": (arg) => threads.spawn(arg) } } : {}
|
|
@@ -8218,6 +8289,7 @@ async function instantiate(host, module, memory, threads, {
|
|
|
8218
8289
|
);
|
|
8219
8290
|
const slicc = traced(stats, "slicc", host.sliccImports());
|
|
8220
8291
|
const sliccFs = traced(stats, "slicc_fs", host.sliccFsImports());
|
|
8292
|
+
const sliccTty2 = traced(stats, "slicc_tty", host.sliccTtyImports());
|
|
8221
8293
|
const hostImports = linkImports(
|
|
8222
8294
|
module,
|
|
8223
8295
|
preview1,
|
|
@@ -8227,7 +8299,8 @@ async function instantiate(host, module, memory, threads, {
|
|
|
8227
8299
|
extra,
|
|
8228
8300
|
foreign,
|
|
8229
8301
|
slicc,
|
|
8230
|
-
sliccFs
|
|
8302
|
+
sliccFs,
|
|
8303
|
+
sliccTty2
|
|
8231
8304
|
);
|
|
8232
8305
|
const imports = sync ? merge(hostImports, sync.linker.mainImports(module)) : hostImports;
|
|
8233
8306
|
instance = await WebAssembly.instantiate(module, imports);
|
|
@@ -8434,7 +8507,7 @@ async function runWasiThread(init, port2) {
|
|
|
8434
8507
|
throw e;
|
|
8435
8508
|
}
|
|
8436
8509
|
}
|
|
8437
|
-
var TRAPPED, PREVIEW1, WASIX, SLICC, SIGNAL_CALLBACK, takeDefault, SLICC_FS, RESERVED2, importsSigactionHook, noErrno, FALLBACK_MAXIMUM_PAGES, LinkSync, DL_GEN, BACKTRACE_FRAMES;
|
|
8510
|
+
var TRAPPED, PREVIEW1, WASIX, SLICC, SIGNAL_CALLBACK, takeDefault, SLICC_FS, SLICC_TTY, RESERVED2, importsSigactionHook, noErrno, FALLBACK_MAXIMUM_PAGES, LinkSync, DL_GEN, BACKTRACE_FRAMES;
|
|
8438
8511
|
var init_wasi_runtime = __esm({
|
|
8439
8512
|
"src/process/wasi/wasi-runtime.ts"() {
|
|
8440
8513
|
"use strict";
|
|
@@ -8467,6 +8540,7 @@ var init_wasi_runtime = __esm({
|
|
|
8467
8540
|
if (defaultAction(sig) === "terminate") throw new WasiExit(128 + sig);
|
|
8468
8541
|
};
|
|
8469
8542
|
SLICC_FS = "slicc_fs";
|
|
8543
|
+
SLICC_TTY = "slicc_tty";
|
|
8470
8544
|
RESERVED2 = RESERVED_NAMESPACES;
|
|
8471
8545
|
importsSigactionHook = (module) => WebAssembly.Module.imports(module).some((i) => i.module === SLICC && i.name === "sigaction_set");
|
|
8472
8546
|
noErrno = (key) => `imports ${key}: its result cannot carry ENOSYS, and this host does not provide it`;
|