@ai-ecoverse/slicc-kernel 1.64.1 → 1.65.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 +9 -2
- package/dist/driver-worker.js +87 -4
- package/dist/driver-worker.js.map +3 -3
- package/dist/index.js.map +2 -2
- package/dist/kernel-worker.js +183 -39
- package/dist/kernel-worker.js.map +4 -4
- package/dist/node-process-worker.js +401 -195
- package/dist/node-process-worker.js.map +4 -4
- package/dist/node.js +183 -39
- package/dist/node.js.map +4 -4
- package/dist/process-worker.js +492 -270
- package/dist/process-worker.js.map +4 -4
- package/package.json +1 -1
|
@@ -82,9 +82,21 @@ var init_lockdown = __esm({
|
|
|
82
82
|
"SharedWorker",
|
|
83
83
|
"BroadcastChannel",
|
|
84
84
|
"postMessage",
|
|
85
|
-
"close"
|
|
85
|
+
"close",
|
|
86
|
+
"webkitRequestFileSystem",
|
|
87
|
+
"webkitRequestFileSystemSync",
|
|
88
|
+
"webkitResolveLocalFileSystemURL",
|
|
89
|
+
"webkitResolveLocalFileSystemSyncURL"
|
|
90
|
+
];
|
|
91
|
+
BLOCKED_NAVIGATOR = [
|
|
92
|
+
"storage",
|
|
93
|
+
"storageBuckets",
|
|
94
|
+
"locks",
|
|
95
|
+
"serviceWorker",
|
|
96
|
+
"usb",
|
|
97
|
+
"hid",
|
|
98
|
+
"serial"
|
|
86
99
|
];
|
|
87
|
-
BLOCKED_NAVIGATOR = ["storage", "locks", "serviceWorker"];
|
|
88
100
|
OPEN_SLOTS = ["fetch", "WebSocket"];
|
|
89
101
|
}
|
|
90
102
|
});
|
|
@@ -1153,16 +1165,16 @@ var init_cred = __esm({
|
|
|
1153
1165
|
});
|
|
1154
1166
|
|
|
1155
1167
|
// src/realm/sync-fs-wire.ts
|
|
1156
|
-
function parseSyncFsUsage(
|
|
1157
|
-
const u =
|
|
1168
|
+
function parseSyncFsUsage(json2) {
|
|
1169
|
+
const u = json2;
|
|
1158
1170
|
if (!u || typeof u.quota !== "number" || typeof u.usage !== "number") return null;
|
|
1159
1171
|
return { quota: u.quota, usage: u.usage };
|
|
1160
1172
|
}
|
|
1161
1173
|
function syncError(code2, label) {
|
|
1162
1174
|
return Object.assign(new Error(`${code2}: ${label}`), { code: code2 });
|
|
1163
1175
|
}
|
|
1164
|
-
function parseSyncFsStat(
|
|
1165
|
-
const s =
|
|
1176
|
+
function parseSyncFsStat(json2) {
|
|
1177
|
+
const s = json2;
|
|
1166
1178
|
if (!s || typeof s.isFile !== "boolean" || typeof s.isDirectory !== "boolean" || typeof s.size !== "number") {
|
|
1167
1179
|
return null;
|
|
1168
1180
|
}
|
|
@@ -2001,11 +2013,11 @@ var init_wasi_memory = __esm({
|
|
|
2001
2013
|
return at;
|
|
2002
2014
|
}
|
|
2003
2015
|
putStrings(list, ptrs, buf) {
|
|
2004
|
-
const
|
|
2016
|
+
const encoder5 = new TextEncoder();
|
|
2005
2017
|
const v = this.view();
|
|
2006
2018
|
let at = buf;
|
|
2007
2019
|
list.forEach((s, i) => {
|
|
2008
|
-
const b =
|
|
2020
|
+
const b = encoder5.encode(s);
|
|
2009
2021
|
v.setUint32(ptrs + i * 4, at, true);
|
|
2010
2022
|
this.bytes(at, b.length).set(b);
|
|
2011
2023
|
v.setUint8(at + b.length, 0);
|
|
@@ -2013,12 +2025,12 @@ var init_wasi_memory = __esm({
|
|
|
2013
2025
|
});
|
|
2014
2026
|
}
|
|
2015
2027
|
putSizes(list, countPtr, sizePtr) {
|
|
2016
|
-
const
|
|
2028
|
+
const encoder5 = new TextEncoder();
|
|
2017
2029
|
const v = this.view();
|
|
2018
2030
|
v.setUint32(countPtr, list.length, true);
|
|
2019
2031
|
v.setUint32(
|
|
2020
2032
|
sizePtr,
|
|
2021
|
-
list.reduce((n, s) => n +
|
|
2033
|
+
list.reduce((n, s) => n + encoder5.encode(s).length + 1, 0),
|
|
2022
2034
|
true
|
|
2023
2035
|
);
|
|
2024
2036
|
}
|
|
@@ -3734,14 +3746,32 @@ var init_js_kernel = __esm({
|
|
|
3734
3746
|
const result = await this.call(req);
|
|
3735
3747
|
return result.ok && result.kind === "bytes" ? result.bytes : new Uint8Array(0);
|
|
3736
3748
|
}
|
|
3737
|
-
async blocking(req, signal) {
|
|
3749
|
+
async blocking(req, signal, track) {
|
|
3738
3750
|
for (; ; ) {
|
|
3739
|
-
const id = await this.
|
|
3751
|
+
const id = await this.submit(req, track);
|
|
3740
3752
|
const result = await this.settled(id, signal);
|
|
3741
3753
|
if (result.ok) return result;
|
|
3742
3754
|
if (result.errno !== "EINTR") throw new JsCallError(result.errno, req.op);
|
|
3743
3755
|
}
|
|
3744
3756
|
}
|
|
3757
|
+
acks = [];
|
|
3758
|
+
ack(id) {
|
|
3759
|
+
this.acks.push(id);
|
|
3760
|
+
}
|
|
3761
|
+
async submit(req, track) {
|
|
3762
|
+
const ack = this.acks;
|
|
3763
|
+
this.acks = [];
|
|
3764
|
+
const r = await this.transport.call({
|
|
3765
|
+
op: "async-submit",
|
|
3766
|
+
req,
|
|
3767
|
+
...ack.length > 0 ? { ack } : {}
|
|
3768
|
+
});
|
|
3769
|
+
const id = r.ok && r.kind === "json" ? r.json : void 0;
|
|
3770
|
+
if (id !== void 0) track?.(id);
|
|
3771
|
+
this.deliver();
|
|
3772
|
+
if (id === void 0) throw new JsCallError(r.ok ? "EIO" : r.errno, "async-submit");
|
|
3773
|
+
return id;
|
|
3774
|
+
}
|
|
3745
3775
|
async settled(id, signal) {
|
|
3746
3776
|
for (; ; ) {
|
|
3747
3777
|
const seen = Atomics.load(this.header, SAB_I_ASYNC);
|
|
@@ -3943,6 +3973,165 @@ var init_js_children = __esm({
|
|
|
3943
3973
|
}
|
|
3944
3974
|
});
|
|
3945
3975
|
|
|
3976
|
+
// src/process/js/js-io.ts
|
|
3977
|
+
function typeOf(info) {
|
|
3978
|
+
if (info.meta && "dir" in info.meta) return "directory";
|
|
3979
|
+
if (info.meta && "device" in info.meta) return "device";
|
|
3980
|
+
if (info.tty || info.kind === "tty") return "tty";
|
|
3981
|
+
if (info.kind === "socket") return "socket";
|
|
3982
|
+
return info.kind === "file" ? "file" : "pipe";
|
|
3983
|
+
}
|
|
3984
|
+
function device(info) {
|
|
3985
|
+
return info.meta && "device" in info.meta ? info.meta : void 0;
|
|
3986
|
+
}
|
|
3987
|
+
function readDevice(info, max, random) {
|
|
3988
|
+
if (typeOf(info) === "directory") throw new JsCallError("EISDIR", "read");
|
|
3989
|
+
const dev = device(info);
|
|
3990
|
+
if (!dev) return void 0;
|
|
3991
|
+
if (dev.access === "write") throw new JsCallError("EBADF", "read");
|
|
3992
|
+
if (dev.device === "null") return new Uint8Array(0);
|
|
3993
|
+
const out = new Uint8Array(Math.min(max, CHUNK));
|
|
3994
|
+
if (dev.device === "urandom") random(out);
|
|
3995
|
+
return out;
|
|
3996
|
+
}
|
|
3997
|
+
function writeDevice(info) {
|
|
3998
|
+
if (typeOf(info) === "directory") throw new JsCallError("EISDIR", "write");
|
|
3999
|
+
const dev = device(info);
|
|
4000
|
+
if (!dev) return false;
|
|
4001
|
+
if (dev.access === "read") throw new JsCallError("EBADF", "write");
|
|
4002
|
+
if (dev.device === "full") throw new JsCallError("ENOSPC", "write");
|
|
4003
|
+
return true;
|
|
4004
|
+
}
|
|
4005
|
+
function brokenPipe(err, info) {
|
|
4006
|
+
return err instanceof JsCallError && err.code === "EPIPE" && typeOf(info) !== "socket";
|
|
4007
|
+
}
|
|
4008
|
+
function written(r, fallback) {
|
|
4009
|
+
return r.ok && r.kind === "json" && typeof r.json === "number" ? r.json : fallback;
|
|
4010
|
+
}
|
|
4011
|
+
function joined(parts, length) {
|
|
4012
|
+
if (parts.length === 1) return parts[0];
|
|
4013
|
+
const out = new Uint8Array(length);
|
|
4014
|
+
let at = 0;
|
|
4015
|
+
for (const part of parts) {
|
|
4016
|
+
out.set(part, at);
|
|
4017
|
+
at += part.length;
|
|
4018
|
+
}
|
|
4019
|
+
return out;
|
|
4020
|
+
}
|
|
4021
|
+
function fileWrite(fd, append, offset, body) {
|
|
4022
|
+
return append ? { op: "fd-write", fd, body } : { op: "fd-pwrite", fd, offset, body };
|
|
4023
|
+
}
|
|
4024
|
+
function isExclusive(o) {
|
|
4025
|
+
return o.create === true && o.exclusive === true;
|
|
4026
|
+
}
|
|
4027
|
+
function absent(err) {
|
|
4028
|
+
if (err instanceof JsCallError && err.code === "ENOENT") return void 0;
|
|
4029
|
+
throw err;
|
|
4030
|
+
}
|
|
4031
|
+
function checkOpen(abs, o, existing) {
|
|
4032
|
+
if (existing && isExclusive(o)) throw new JsCallError("EEXIST", abs);
|
|
4033
|
+
if (!existing && !o.create) throw new JsCallError("ENOENT", abs);
|
|
4034
|
+
if (existing?.isDirectory) throw new JsCallError("EISDIR", abs);
|
|
4035
|
+
}
|
|
4036
|
+
function flagsOf(o) {
|
|
4037
|
+
const write2 = o.write || o.append || o.truncate;
|
|
4038
|
+
const access = write2 ? o.read ? O_RDWR3 : O_WRONLY3 : 0;
|
|
4039
|
+
return access | (o.append ? O_APPEND3 : 0);
|
|
4040
|
+
}
|
|
4041
|
+
function openRequest(abs, o) {
|
|
4042
|
+
return {
|
|
4043
|
+
op: "fd-open-vfs",
|
|
4044
|
+
path: abs,
|
|
4045
|
+
flags: flagsOf(o),
|
|
4046
|
+
position: 0,
|
|
4047
|
+
...isExclusive(o) ? { exclusive: true } : o.create ? { create: true } : { existing: true },
|
|
4048
|
+
...o.truncate ? { truncate: true } : {}
|
|
4049
|
+
};
|
|
4050
|
+
}
|
|
4051
|
+
function index2(n, what) {
|
|
4052
|
+
if (!Number.isSafeInteger(n) || n < 0) throw new JsCallError("EINVAL", what);
|
|
4053
|
+
}
|
|
4054
|
+
var CHUNK, MAX_IO, O_WRONLY3, O_RDWR3, O_APPEND3;
|
|
4055
|
+
var init_js_io = __esm({
|
|
4056
|
+
"src/process/js/js-io.ts"() {
|
|
4057
|
+
"use strict";
|
|
4058
|
+
init_js_kernel();
|
|
4059
|
+
CHUNK = 64 * 1024;
|
|
4060
|
+
MAX_IO = 1024 * 1024;
|
|
4061
|
+
O_WRONLY3 = 1;
|
|
4062
|
+
O_RDWR3 = 2;
|
|
4063
|
+
O_APPEND3 = 1024;
|
|
4064
|
+
}
|
|
4065
|
+
});
|
|
4066
|
+
|
|
4067
|
+
// src/process/js/js-exit.ts
|
|
4068
|
+
function json(r) {
|
|
4069
|
+
return r.ok && r.kind === "json" ? r.json : void 0;
|
|
4070
|
+
}
|
|
4071
|
+
function restoreMode(lane, { terminal, fd, termios }) {
|
|
4072
|
+
const open = json(lane({ op: "fd-list" })) ?? [];
|
|
4073
|
+
const on = open.filter((entry) => entry.terminal === terminal);
|
|
4074
|
+
const at = (on.find((entry) => entry.fd === fd) ?? on[0])?.fd;
|
|
4075
|
+
if (at !== void 0) {
|
|
4076
|
+
lane({ op: "tty-set", fd: at, termios });
|
|
4077
|
+
return;
|
|
4078
|
+
}
|
|
4079
|
+
const opened = json(lane({ op: "fd-open-tty", name: terminal }));
|
|
4080
|
+
if (typeof opened !== "number") return;
|
|
4081
|
+
lane({ op: "tty-set", fd: opened, termios });
|
|
4082
|
+
lane({ op: "fd-close", fd: opened });
|
|
4083
|
+
}
|
|
4084
|
+
function writeOut(lane, fd, data) {
|
|
4085
|
+
let at = 0;
|
|
4086
|
+
while (at < data.length) {
|
|
4087
|
+
const body = data.subarray(at, at + MAX_IO);
|
|
4088
|
+
const r = lane({ op: "fd-write", fd, body });
|
|
4089
|
+
if (!r.ok && r.errno === "EINTR") continue;
|
|
4090
|
+
if (!r.ok) return false;
|
|
4091
|
+
const n = written(r, body.length);
|
|
4092
|
+
if (n <= 0) return false;
|
|
4093
|
+
at += n;
|
|
4094
|
+
}
|
|
4095
|
+
return true;
|
|
4096
|
+
}
|
|
4097
|
+
function progress(result, len) {
|
|
4098
|
+
if (!result) return len;
|
|
4099
|
+
if (result.ok) return written(result, len);
|
|
4100
|
+
return result.errno === "EINTR" ? 0 : -1;
|
|
4101
|
+
}
|
|
4102
|
+
function settled(lane, writes) {
|
|
4103
|
+
const inFlight = writes.filter((w) => w.op !== void 0);
|
|
4104
|
+
const out = /* @__PURE__ */ new Map();
|
|
4105
|
+
if (inFlight.length === 0) return out;
|
|
4106
|
+
const r = lane({ op: "async-settle", ids: inFlight.map((w) => w.op) });
|
|
4107
|
+
const results = r.ok && r.kind === "json" ? r.json : [];
|
|
4108
|
+
inFlight.forEach((w, i) => {
|
|
4109
|
+
const result = results[i];
|
|
4110
|
+
out.set(w, progress(result, w.len));
|
|
4111
|
+
});
|
|
4112
|
+
return out;
|
|
4113
|
+
}
|
|
4114
|
+
function exitAtOnce(lane, writes, modes, status2) {
|
|
4115
|
+
const done = settled(lane, writes);
|
|
4116
|
+
const broken = /* @__PURE__ */ new Set();
|
|
4117
|
+
for (const w of writes) {
|
|
4118
|
+
const sent = done.get(w);
|
|
4119
|
+
if (sent === -1) broken.add(w.fd);
|
|
4120
|
+
if (broken.has(w.fd)) continue;
|
|
4121
|
+
if (!writeOut(lane, w.fd, w.data.subarray(w.at + (sent ?? 0)))) broken.add(w.fd);
|
|
4122
|
+
}
|
|
4123
|
+
for (const mode of modes) restoreMode(lane, mode);
|
|
4124
|
+
lane({ op: "proc-exit", status: status2 & 255 });
|
|
4125
|
+
const parked = new Int32Array(new SharedArrayBuffer(4));
|
|
4126
|
+
for (; ; ) Atomics.wait(parked, 0, 0);
|
|
4127
|
+
}
|
|
4128
|
+
var init_js_exit = __esm({
|
|
4129
|
+
"src/process/js/js-exit.ts"() {
|
|
4130
|
+
"use strict";
|
|
4131
|
+
init_js_io();
|
|
4132
|
+
}
|
|
4133
|
+
});
|
|
4134
|
+
|
|
3946
4135
|
// src/process/js/js-fetch.ts
|
|
3947
4136
|
function withoutFragment(url) {
|
|
3948
4137
|
url.hash = "";
|
|
@@ -4175,7 +4364,7 @@ function fetchOp(kernel) {
|
|
|
4175
4364
|
let r;
|
|
4176
4365
|
try {
|
|
4177
4366
|
signal.throwIfAborted();
|
|
4178
|
-
r = await kernel.blocking({ op: "net-read", handle, max:
|
|
4367
|
+
r = await kernel.blocking({ op: "net-read", handle, max: CHUNK2 }, signal);
|
|
4179
4368
|
} catch (err) {
|
|
4180
4369
|
settle();
|
|
4181
4370
|
await close(handle);
|
|
@@ -4264,12 +4453,12 @@ function fetchOp(kernel) {
|
|
|
4264
4453
|
}
|
|
4265
4454
|
};
|
|
4266
4455
|
}
|
|
4267
|
-
var
|
|
4456
|
+
var CHUNK2, MAX_REDIRECTS, NULL_BODY, REDIRECTS, BODY_HEADERS, DECODED, CREDENTIALS, OVER, TOKEN, QUOTABLE, SPACE, BASE64, SLICE;
|
|
4268
4457
|
var init_js_fetch = __esm({
|
|
4269
4458
|
"src/process/js/js-fetch.ts"() {
|
|
4270
4459
|
"use strict";
|
|
4271
4460
|
init_js_kernel();
|
|
4272
|
-
|
|
4461
|
+
CHUNK2 = 64 * 1024;
|
|
4273
4462
|
MAX_REDIRECTS = 20;
|
|
4274
4463
|
NULL_BODY = /* @__PURE__ */ new Set([101, 103, 204, 205, 304]);
|
|
4275
4464
|
REDIRECTS = /* @__PURE__ */ new Set([301, 302, 303, 307, 308]);
|
|
@@ -4291,97 +4480,6 @@ var init_js_fetch = __esm({
|
|
|
4291
4480
|
}
|
|
4292
4481
|
});
|
|
4293
4482
|
|
|
4294
|
-
// src/process/js/js-io.ts
|
|
4295
|
-
function typeOf(info) {
|
|
4296
|
-
if (info.meta && "dir" in info.meta) return "directory";
|
|
4297
|
-
if (info.meta && "device" in info.meta) return "device";
|
|
4298
|
-
if (info.tty || info.kind === "tty") return "tty";
|
|
4299
|
-
if (info.kind === "socket") return "socket";
|
|
4300
|
-
return info.kind === "file" ? "file" : "pipe";
|
|
4301
|
-
}
|
|
4302
|
-
function device(info) {
|
|
4303
|
-
return info.meta && "device" in info.meta ? info.meta : void 0;
|
|
4304
|
-
}
|
|
4305
|
-
function readDevice(info, max, random) {
|
|
4306
|
-
if (typeOf(info) === "directory") throw new JsCallError("EISDIR", "read");
|
|
4307
|
-
const dev = device(info);
|
|
4308
|
-
if (!dev) return void 0;
|
|
4309
|
-
if (dev.access === "write") throw new JsCallError("EBADF", "read");
|
|
4310
|
-
if (dev.device === "null") return new Uint8Array(0);
|
|
4311
|
-
const out = new Uint8Array(Math.min(max, CHUNK2));
|
|
4312
|
-
if (dev.device === "urandom") random(out);
|
|
4313
|
-
return out;
|
|
4314
|
-
}
|
|
4315
|
-
function writeDevice(info) {
|
|
4316
|
-
if (typeOf(info) === "directory") throw new JsCallError("EISDIR", "write");
|
|
4317
|
-
const dev = device(info);
|
|
4318
|
-
if (!dev) return false;
|
|
4319
|
-
if (dev.access === "read") throw new JsCallError("EBADF", "write");
|
|
4320
|
-
if (dev.device === "full") throw new JsCallError("ENOSPC", "write");
|
|
4321
|
-
return true;
|
|
4322
|
-
}
|
|
4323
|
-
function brokenPipe(err, info) {
|
|
4324
|
-
return err instanceof JsCallError && err.code === "EPIPE" && typeOf(info) !== "socket";
|
|
4325
|
-
}
|
|
4326
|
-
function written(r, fallback) {
|
|
4327
|
-
return r.ok && r.kind === "json" && typeof r.json === "number" ? r.json : fallback;
|
|
4328
|
-
}
|
|
4329
|
-
function joined(parts, length) {
|
|
4330
|
-
if (parts.length === 1) return parts[0];
|
|
4331
|
-
const out = new Uint8Array(length);
|
|
4332
|
-
let at = 0;
|
|
4333
|
-
for (const part of parts) {
|
|
4334
|
-
out.set(part, at);
|
|
4335
|
-
at += part.length;
|
|
4336
|
-
}
|
|
4337
|
-
return out;
|
|
4338
|
-
}
|
|
4339
|
-
function fileWrite(fd, append, offset, body) {
|
|
4340
|
-
return append ? { op: "fd-write", fd, body } : { op: "fd-pwrite", fd, offset, body };
|
|
4341
|
-
}
|
|
4342
|
-
function isExclusive(o) {
|
|
4343
|
-
return o.create === true && o.exclusive === true;
|
|
4344
|
-
}
|
|
4345
|
-
function absent(err) {
|
|
4346
|
-
if (err instanceof JsCallError && err.code === "ENOENT") return void 0;
|
|
4347
|
-
throw err;
|
|
4348
|
-
}
|
|
4349
|
-
function checkOpen(abs, o, existing) {
|
|
4350
|
-
if (existing && isExclusive(o)) throw new JsCallError("EEXIST", abs);
|
|
4351
|
-
if (!existing && !o.create) throw new JsCallError("ENOENT", abs);
|
|
4352
|
-
if (existing?.isDirectory) throw new JsCallError("EISDIR", abs);
|
|
4353
|
-
}
|
|
4354
|
-
function flagsOf(o) {
|
|
4355
|
-
const write2 = o.write || o.append || o.truncate;
|
|
4356
|
-
const access = write2 ? o.read ? O_RDWR3 : O_WRONLY3 : 0;
|
|
4357
|
-
return access | (o.append ? O_APPEND3 : 0);
|
|
4358
|
-
}
|
|
4359
|
-
function openRequest(abs, o) {
|
|
4360
|
-
return {
|
|
4361
|
-
op: "fd-open-vfs",
|
|
4362
|
-
path: abs,
|
|
4363
|
-
flags: flagsOf(o),
|
|
4364
|
-
position: 0,
|
|
4365
|
-
...isExclusive(o) ? { exclusive: true } : o.create ? { create: true } : { existing: true },
|
|
4366
|
-
...o.truncate ? { truncate: true } : {}
|
|
4367
|
-
};
|
|
4368
|
-
}
|
|
4369
|
-
function index2(n, what) {
|
|
4370
|
-
if (!Number.isSafeInteger(n) || n < 0) throw new JsCallError("EINVAL", what);
|
|
4371
|
-
}
|
|
4372
|
-
var CHUNK2, MAX_IO, O_WRONLY3, O_RDWR3, O_APPEND3;
|
|
4373
|
-
var init_js_io = __esm({
|
|
4374
|
-
"src/process/js/js-io.ts"() {
|
|
4375
|
-
"use strict";
|
|
4376
|
-
init_js_kernel();
|
|
4377
|
-
CHUNK2 = 64 * 1024;
|
|
4378
|
-
MAX_IO = 1024 * 1024;
|
|
4379
|
-
O_WRONLY3 = 1;
|
|
4380
|
-
O_RDWR3 = 2;
|
|
4381
|
-
O_APPEND3 = 1024;
|
|
4382
|
-
}
|
|
4383
|
-
});
|
|
4384
|
-
|
|
4385
4483
|
// src/process/js/js-net.ts
|
|
4386
4484
|
function errnoName(errno2) {
|
|
4387
4485
|
const found = Object.entries(E).find(([, n]) => n === errno2);
|
|
@@ -4523,6 +4621,67 @@ var init_js_net = __esm({
|
|
|
4523
4621
|
}
|
|
4524
4622
|
});
|
|
4525
4623
|
|
|
4624
|
+
// src/process/js/js-run.ts
|
|
4625
|
+
function stdioOf(how) {
|
|
4626
|
+
if (how === void 0) return "pipe";
|
|
4627
|
+
if (!STDIO3.has(how)) throw new JsCallError("EINVAL", "run");
|
|
4628
|
+
return how;
|
|
4629
|
+
}
|
|
4630
|
+
function limit(value2) {
|
|
4631
|
+
if (value2 === void 0 || value2 === Number.POSITIVE_INFINITY) return value2;
|
|
4632
|
+
if (!(value2 >= 0)) throw new JsCallError("EINVAL", "run");
|
|
4633
|
+
return value2;
|
|
4634
|
+
}
|
|
4635
|
+
function decodeRun(bytes, stdout, stderr) {
|
|
4636
|
+
const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
|
|
4637
|
+
const size = view.getUint32(0, true);
|
|
4638
|
+
const outcome = JSON.parse(new TextDecoder().decode(bytes.subarray(4, 4 + size)));
|
|
4639
|
+
const out = bytes.slice(4 + size, 4 + size + outcome.out);
|
|
4640
|
+
const err = bytes.slice(4 + size + outcome.out, 4 + size + outcome.out + outcome.err);
|
|
4641
|
+
return {
|
|
4642
|
+
pid: outcome.pid,
|
|
4643
|
+
status: outcome.status,
|
|
4644
|
+
...outcome.signal !== void 0 ? { signal: outcome.signal } : {},
|
|
4645
|
+
...stdout === "pipe" ? { stdout: out } : {},
|
|
4646
|
+
...stderr === "pipe" ? { stderr: err } : {},
|
|
4647
|
+
...outcome.error ? { error: outcome.error } : {}
|
|
4648
|
+
};
|
|
4649
|
+
}
|
|
4650
|
+
function runSync(kernel, d, o) {
|
|
4651
|
+
const [file] = o.argv;
|
|
4652
|
+
if (file === void 0) throw new JsCallError("EINVAL", "run");
|
|
4653
|
+
const stdout = stdioOf(o.stdout);
|
|
4654
|
+
const stderr = stdioOf(o.stderr);
|
|
4655
|
+
const input = typeof o.input === "string" ? encoder2.encode(o.input) : o.input;
|
|
4656
|
+
const maxBuffer = limit(o.maxBuffer);
|
|
4657
|
+
const timeout = limit(o.timeout);
|
|
4658
|
+
const bytes = kernel.bytes({
|
|
4659
|
+
op: "proc-run",
|
|
4660
|
+
file,
|
|
4661
|
+
argv: [...o.argv],
|
|
4662
|
+
env: { ...o.env ?? d.env },
|
|
4663
|
+
cwd: o.cwd === void 0 ? d.cwd : d.resolve(o.cwd),
|
|
4664
|
+
stdin: stdioOf(o.stdin),
|
|
4665
|
+
...input ? { input } : {},
|
|
4666
|
+
stdout,
|
|
4667
|
+
stderr,
|
|
4668
|
+
...maxBuffer !== void 0 && maxBuffer !== Number.POSITIVE_INFINITY ? { maxBuffer } : {},
|
|
4669
|
+
...maxBuffer === Number.POSITIVE_INFINITY ? { maxBuffer: Number.MAX_SAFE_INTEGER } : {},
|
|
4670
|
+
...timeout !== void 0 && timeout !== Number.POSITIVE_INFINITY ? { timeoutMs: timeout } : {},
|
|
4671
|
+
killSignal: d.signal(o.killSignal ?? "SIGTERM")
|
|
4672
|
+
});
|
|
4673
|
+
return decodeRun(bytes, stdout, stderr);
|
|
4674
|
+
}
|
|
4675
|
+
var encoder2, STDIO3;
|
|
4676
|
+
var init_js_run = __esm({
|
|
4677
|
+
"src/process/js/js-run.ts"() {
|
|
4678
|
+
"use strict";
|
|
4679
|
+
init_js_kernel();
|
|
4680
|
+
encoder2 = new TextEncoder();
|
|
4681
|
+
STDIO3 = /* @__PURE__ */ new Set(["pipe", "ignore", "inherit"]);
|
|
4682
|
+
}
|
|
4683
|
+
});
|
|
4684
|
+
|
|
4526
4685
|
// src/realm/sync-sab-bridge.ts
|
|
4527
4686
|
function createSyncSabTransport(sab, port3, deps = {}) {
|
|
4528
4687
|
const views = sabViews(sab);
|
|
@@ -4602,7 +4761,7 @@ function createSyncFsSabBridge(transport, opts = {}) {
|
|
|
4602
4761
|
if (r.ok && r.kind === "bytes") return r.bytes;
|
|
4603
4762
|
throw errnoError("EIO", path);
|
|
4604
4763
|
}
|
|
4605
|
-
function
|
|
4764
|
+
function json2(req, path) {
|
|
4606
4765
|
const r = run(req, path);
|
|
4607
4766
|
if (r.ok && r.kind === "json") return r.json;
|
|
4608
4767
|
throw errnoError("EIO", path);
|
|
@@ -4630,31 +4789,31 @@ function createSyncFsSabBridge(transport, opts = {}) {
|
|
|
4630
4789
|
return {
|
|
4631
4790
|
...io({}),
|
|
4632
4791
|
pinned: (handle) => io({ handle }),
|
|
4633
|
-
kept: (handle) =>
|
|
4792
|
+
kept: (handle) => json2({ op: "kept", path: "/", handle }, "/") === true,
|
|
4634
4793
|
keptStat: (handle) => {
|
|
4635
|
-
const s = parseSyncFsStat(
|
|
4794
|
+
const s = parseSyncFsStat(json2({ op: "stat", path: "/", handle }, "/"));
|
|
4636
4795
|
if (!s) throw errnoError("EIO", "/");
|
|
4637
4796
|
return s;
|
|
4638
4797
|
},
|
|
4639
4798
|
stat: (path) => {
|
|
4640
|
-
const s = parseSyncFsStat(
|
|
4799
|
+
const s = parseSyncFsStat(json2({ op: "stat", path }, path));
|
|
4641
4800
|
if (!s) throw errnoError("EIO", path);
|
|
4642
4801
|
return s;
|
|
4643
4802
|
},
|
|
4644
4803
|
lstat: (path) => {
|
|
4645
|
-
const s = parseSyncFsStat(
|
|
4804
|
+
const s = parseSyncFsStat(json2({ op: "lstat", path }, path));
|
|
4646
4805
|
if (!s) throw errnoError("EIO", path);
|
|
4647
4806
|
return s;
|
|
4648
4807
|
},
|
|
4649
4808
|
readdir: (path) => {
|
|
4650
|
-
const list =
|
|
4809
|
+
const list = json2({ op: "readdir", path }, path);
|
|
4651
4810
|
if (!Array.isArray(list) || !list.every((s) => typeof s === "string")) {
|
|
4652
4811
|
throw errnoError("EIO", path);
|
|
4653
4812
|
}
|
|
4654
4813
|
return list;
|
|
4655
4814
|
},
|
|
4656
4815
|
readdirStat: (path) => {
|
|
4657
|
-
const list =
|
|
4816
|
+
const list = json2({ op: "readdir-stat", path }, path);
|
|
4658
4817
|
if (!Array.isArray(list)) throw errnoError("EIO", path);
|
|
4659
4818
|
return list.map((entry) => {
|
|
4660
4819
|
if (!Array.isArray(entry) || typeof entry[0] !== "string") throw errnoError("EIO", path);
|
|
@@ -4665,7 +4824,7 @@ function createSyncFsSabBridge(transport, opts = {}) {
|
|
|
4665
4824
|
});
|
|
4666
4825
|
},
|
|
4667
4826
|
exists: (path) => {
|
|
4668
|
-
const v =
|
|
4827
|
+
const v = json2({ op: "exists", path }, path);
|
|
4669
4828
|
if (typeof v !== "boolean") throw errnoError("EIO", path);
|
|
4670
4829
|
return v;
|
|
4671
4830
|
},
|
|
@@ -4691,7 +4850,7 @@ function createSyncFsSabBridge(transport, opts = {}) {
|
|
|
4691
4850
|
run({ op: "symlink", path: linkPath, arg2: target }, linkPath);
|
|
4692
4851
|
},
|
|
4693
4852
|
readlink: (path) => {
|
|
4694
|
-
const target =
|
|
4853
|
+
const target = json2({ op: "readlink", path }, path);
|
|
4695
4854
|
if (typeof target !== "string") throw errnoError("EIO", path);
|
|
4696
4855
|
return target;
|
|
4697
4856
|
},
|
|
@@ -4721,11 +4880,11 @@ function createSyncFsSabBridge(transport, opts = {}) {
|
|
|
4721
4880
|
},
|
|
4722
4881
|
hold: (path, held, open, handle, want = 0) => {
|
|
4723
4882
|
const mode = (held ? 1 : 0) | (open ? 2 : 0);
|
|
4724
|
-
if (mode === 3) return
|
|
4883
|
+
if (mode === 3) return json2({ op: "hold", path, mode: mode | want }, path);
|
|
4725
4884
|
run({ op: "hold", path, mode, ...handle !== void 0 ? { handle } : {} }, path);
|
|
4726
4885
|
return void 0;
|
|
4727
4886
|
},
|
|
4728
|
-
statfs: (path = "/") => parseSyncFsUsage(
|
|
4887
|
+
statfs: (path = "/") => parseSyncFsUsage(json2({ op: "statfs", path }, path))
|
|
4729
4888
|
};
|
|
4730
4889
|
}
|
|
4731
4890
|
var init_sync_sab_bridge = __esm({
|
|
@@ -4751,7 +4910,7 @@ function syncOps(kernel, shared) {
|
|
|
4751
4910
|
infos.set(fd, got);
|
|
4752
4911
|
return got;
|
|
4753
4912
|
};
|
|
4754
|
-
const read2 = (fd, max =
|
|
4913
|
+
const read2 = (fd, max = CHUNK) => {
|
|
4755
4914
|
index2(max, "read");
|
|
4756
4915
|
const emulated = readDevice(info(fd), max, shared.random);
|
|
4757
4916
|
if (emulated) return emulated;
|
|
@@ -4759,7 +4918,7 @@ function syncOps(kernel, shared) {
|
|
|
4759
4918
|
return r.ok && r.kind === "bytes" ? r.bytes : new Uint8Array(0);
|
|
4760
4919
|
};
|
|
4761
4920
|
const write2 = (fd, data) => {
|
|
4762
|
-
const bytes = typeof data === "string" ?
|
|
4921
|
+
const bytes = typeof data === "string" ? encoder3.encode(data) : data;
|
|
4763
4922
|
const i = info(fd);
|
|
4764
4923
|
if (writeDevice(i)) return;
|
|
4765
4924
|
let at = 0;
|
|
@@ -4902,14 +5061,14 @@ function syncPathOps(kernel, resolve, statOf, open) {
|
|
|
4902
5061
|
writeFile(path, data) {
|
|
4903
5062
|
const file = open(path, { write: true, create: true, truncate: true });
|
|
4904
5063
|
try {
|
|
4905
|
-
file.write(0, typeof data === "string" ?
|
|
5064
|
+
file.write(0, typeof data === "string" ? encoder3.encode(data) : data);
|
|
4906
5065
|
} finally {
|
|
4907
5066
|
file.close();
|
|
4908
5067
|
}
|
|
4909
5068
|
}
|
|
4910
5069
|
};
|
|
4911
5070
|
}
|
|
4912
|
-
var
|
|
5071
|
+
var encoder3, JsSyncKernel;
|
|
4913
5072
|
var init_js_sync = __esm({
|
|
4914
5073
|
"src/process/js/js-sync.ts"() {
|
|
4915
5074
|
"use strict";
|
|
@@ -4918,7 +5077,7 @@ var init_js_sync = __esm({
|
|
|
4918
5077
|
init_sync_sab_bridge();
|
|
4919
5078
|
init_js_io();
|
|
4920
5079
|
init_js_kernel();
|
|
4921
|
-
|
|
5080
|
+
encoder3 = new TextEncoder();
|
|
4922
5081
|
JsSyncKernel = class {
|
|
4923
5082
|
lane;
|
|
4924
5083
|
kernel;
|
|
@@ -5026,7 +5185,8 @@ function ttyOps(kernel) {
|
|
|
5026
5185
|
await back.catch(() => void 0);
|
|
5027
5186
|
}
|
|
5028
5187
|
};
|
|
5029
|
-
|
|
5188
|
+
const modes = () => [...saved].reverse().map(([terminal, { fd, termios }]) => ({ terminal, fd, termios }));
|
|
5189
|
+
return { tty, restore, modes };
|
|
5030
5190
|
}
|
|
5031
5191
|
var BRKINT, INPCK, ISTRIP, ICRNL, IXON, ONLCR, CS8, ISIG, ICANON, ECHO, IEXTEN, VTIME, VMIN;
|
|
5032
5192
|
var init_js_tty = __esm({
|
|
@@ -5117,14 +5277,14 @@ function websocketOp(kernel) {
|
|
|
5117
5277
|
finish();
|
|
5118
5278
|
};
|
|
5119
5279
|
signal.addEventListener("abort", onAbort, { once: true });
|
|
5120
|
-
let
|
|
5280
|
+
let settled2 = false;
|
|
5121
5281
|
let readDone = false;
|
|
5122
5282
|
const release = () => {
|
|
5123
|
-
if (!
|
|
5283
|
+
if (!settled2 || !readDone || freed) return;
|
|
5124
5284
|
finish();
|
|
5125
5285
|
};
|
|
5126
5286
|
kernel.blocking({ op: "net-ws-wait", handle }, stop.signal).then((r) => {
|
|
5127
|
-
|
|
5287
|
+
settled2 = true;
|
|
5128
5288
|
settle(r.json);
|
|
5129
5289
|
release();
|
|
5130
5290
|
}).catch(lose);
|
|
@@ -5172,7 +5332,7 @@ function websocketOp(kernel) {
|
|
|
5172
5332
|
async write(chunk, controller) {
|
|
5173
5333
|
stop.signal.throwIfAborted();
|
|
5174
5334
|
const send = async (body) => {
|
|
5175
|
-
if (
|
|
5335
|
+
if (settled2) throw new JsCallError("EPIPE", "the websocket is closed");
|
|
5176
5336
|
return await kernel.json({ op: "net-ws-send", handle, ...body });
|
|
5177
5337
|
};
|
|
5178
5338
|
let buffered = await send(typeof chunk === "string" ? { text: chunk } : { body: chunk });
|
|
@@ -5232,6 +5392,41 @@ function resolvePath(cwd, path) {
|
|
|
5232
5392
|
}
|
|
5233
5393
|
return `/${parts.join("/")}`;
|
|
5234
5394
|
}
|
|
5395
|
+
function writer(kernel, info, pid) {
|
|
5396
|
+
const writes = /* @__PURE__ */ new Set();
|
|
5397
|
+
const sendAll = async (fd, data, i, w, signal) => {
|
|
5398
|
+
while (w.at < data.length) {
|
|
5399
|
+
const body = data.subarray(w.at, w.at + MAX_IO);
|
|
5400
|
+
w.len = body.length;
|
|
5401
|
+
try {
|
|
5402
|
+
w.at += signal ? await sendSome(kernel, fd, body, signal) : written(
|
|
5403
|
+
await kernel.blocking({ op: "fd-write", fd, body }, void 0, (id) => {
|
|
5404
|
+
if (w.op !== void 0) kernel.ack(w.op);
|
|
5405
|
+
w.op = id;
|
|
5406
|
+
}),
|
|
5407
|
+
body.length
|
|
5408
|
+
);
|
|
5409
|
+
if (w.op !== void 0) kernel.ack(w.op);
|
|
5410
|
+
w.op = void 0;
|
|
5411
|
+
} catch (err) {
|
|
5412
|
+
if (brokenPipe(err, i)) await kernel.call({ op: "proc-kill", pid, sig: SIG.PIPE });
|
|
5413
|
+
throw err;
|
|
5414
|
+
}
|
|
5415
|
+
}
|
|
5416
|
+
};
|
|
5417
|
+
const writeAll = async (fd, data, signal) => {
|
|
5418
|
+
const w = { fd, data, at: 0, len: 0 };
|
|
5419
|
+
if (!signal) writes.add(w);
|
|
5420
|
+
try {
|
|
5421
|
+
const i = await info(fd);
|
|
5422
|
+
if (writeDevice(i)) return;
|
|
5423
|
+
await sendAll(fd, data, i, w, signal);
|
|
5424
|
+
} finally {
|
|
5425
|
+
writes.delete(w);
|
|
5426
|
+
}
|
|
5427
|
+
};
|
|
5428
|
+
return { writes, writeAll };
|
|
5429
|
+
}
|
|
5235
5430
|
function createContext(o) {
|
|
5236
5431
|
const { kernel } = o;
|
|
5237
5432
|
const infos = /* @__PURE__ */ new Map();
|
|
@@ -5256,36 +5451,23 @@ function createContext(o) {
|
|
|
5256
5451
|
infos.set(fd, got);
|
|
5257
5452
|
return got;
|
|
5258
5453
|
};
|
|
5259
|
-
const read2 = async (fd, max =
|
|
5454
|
+
const read2 = async (fd, max = CHUNK, signal) => {
|
|
5260
5455
|
index2(max, "read");
|
|
5261
5456
|
const emulated = readDevice(await info(fd), max, random);
|
|
5262
5457
|
if (emulated) return emulated;
|
|
5263
5458
|
return readPipe(kernel, fd, Math.min(max, MAX_IO), signal);
|
|
5264
5459
|
};
|
|
5265
|
-
const writeAll =
|
|
5266
|
-
const i = await info(fd);
|
|
5267
|
-
if (writeDevice(i)) return;
|
|
5268
|
-
let at = 0;
|
|
5269
|
-
while (at < data.length) {
|
|
5270
|
-
const body = data.subarray(at, at + MAX_IO);
|
|
5271
|
-
try {
|
|
5272
|
-
at += signal ? await sendSome(kernel, fd, body, signal) : written(await kernel.blocking({ op: "fd-write", fd, body }), body.length);
|
|
5273
|
-
} catch (err) {
|
|
5274
|
-
if (brokenPipe(err, i)) await kernel.call({ op: "proc-kill", pid: o.pid, sig: SIG.PIPE });
|
|
5275
|
-
throw err;
|
|
5276
|
-
}
|
|
5277
|
-
}
|
|
5278
|
-
};
|
|
5460
|
+
const { writes, writeAll } = writer(kernel, info, o.pid);
|
|
5279
5461
|
const write2 = (fd, data) => {
|
|
5280
|
-
const bytes = typeof data === "string" ?
|
|
5462
|
+
const bytes = typeof data === "string" ? encoder4.encode(data) : data;
|
|
5281
5463
|
let settle;
|
|
5282
|
-
const
|
|
5283
|
-
pending.add(
|
|
5464
|
+
const settled2 = new Promise((resolve2) => settle = resolve2);
|
|
5465
|
+
pending.add(settled2);
|
|
5284
5466
|
return (async () => {
|
|
5285
5467
|
try {
|
|
5286
5468
|
await writeAll(fd, bytes);
|
|
5287
5469
|
} finally {
|
|
5288
|
-
pending.delete(
|
|
5470
|
+
pending.delete(settled2);
|
|
5289
5471
|
settle();
|
|
5290
5472
|
}
|
|
5291
5473
|
})();
|
|
@@ -5318,14 +5500,17 @@ function createContext(o) {
|
|
|
5318
5500
|
return handle.file;
|
|
5319
5501
|
};
|
|
5320
5502
|
const fs = pathOps(kernel, resolve, statOf, open);
|
|
5321
|
-
const
|
|
5322
|
-
|
|
5323
|
-
resolve,
|
|
5324
|
-
random,
|
|
5325
|
-
infos,
|
|
5326
|
-
handles
|
|
5327
|
-
});
|
|
5503
|
+
const lane = o.lane ?? laneOf(void 0);
|
|
5504
|
+
const syncKernel = new JsSyncKernel(lane, kernel, unwind);
|
|
5328
5505
|
const terminal = ttyOps(kernel);
|
|
5506
|
+
const sync = {
|
|
5507
|
+
...syncOps(syncKernel, { pid: o.pid, resolve, random, infos, handles }),
|
|
5508
|
+
run: (options) => runSync(syncKernel, { env: o.env, cwd: o.cwd, resolve, signal: signalNumber }, options),
|
|
5509
|
+
exit: (status2 = 0) => {
|
|
5510
|
+
exiting ??= status2 & 255;
|
|
5511
|
+
return exitAtOnce(lane, [...writes], terminal.modes(), exiting);
|
|
5512
|
+
}
|
|
5513
|
+
};
|
|
5329
5514
|
const io = { read: read2, send: writeAll, close: (fd) => ctx.close(fd) };
|
|
5330
5515
|
const children = childOps(kernel, io, { env: o.env, cwd: o.cwd, signal: signalNumber });
|
|
5331
5516
|
const strays = o.strays ?? { exception: /* @__PURE__ */ new Set(), rejection: /* @__PURE__ */ new Set() };
|
|
@@ -5499,24 +5684,26 @@ function pathOps(kernel, resolve, statOf, open) {
|
|
|
5499
5684
|
async writeFile(path, data) {
|
|
5500
5685
|
const file = await open(path, { write: true, create: true, truncate: true });
|
|
5501
5686
|
try {
|
|
5502
|
-
await file.write(0, typeof data === "string" ?
|
|
5687
|
+
await file.write(0, typeof data === "string" ? encoder4.encode(data) : data);
|
|
5503
5688
|
} finally {
|
|
5504
5689
|
await file.close();
|
|
5505
5690
|
}
|
|
5506
5691
|
}
|
|
5507
5692
|
};
|
|
5508
5693
|
}
|
|
5509
|
-
var JsExit,
|
|
5694
|
+
var JsExit, encoder4;
|
|
5510
5695
|
var init_js_context = __esm({
|
|
5511
5696
|
"src/process/js/js-context.ts"() {
|
|
5512
5697
|
"use strict";
|
|
5513
5698
|
init_signals();
|
|
5514
5699
|
init_sync_fs_wire();
|
|
5515
5700
|
init_js_children();
|
|
5701
|
+
init_js_exit();
|
|
5516
5702
|
init_js_fetch();
|
|
5517
5703
|
init_js_io();
|
|
5518
5704
|
init_js_kernel();
|
|
5519
5705
|
init_js_net();
|
|
5706
|
+
init_js_run();
|
|
5520
5707
|
init_js_sync();
|
|
5521
5708
|
init_js_tty();
|
|
5522
5709
|
init_js_websocket();
|
|
@@ -5528,7 +5715,7 @@ var init_js_context = __esm({
|
|
|
5528
5715
|
this.status = status2;
|
|
5529
5716
|
}
|
|
5530
5717
|
};
|
|
5531
|
-
|
|
5718
|
+
encoder4 = new TextEncoder();
|
|
5532
5719
|
}
|
|
5533
5720
|
});
|
|
5534
5721
|
|
|
@@ -7597,7 +7784,7 @@ function useDevFd(Fs) {
|
|
|
7597
7784
|
};
|
|
7598
7785
|
}
|
|
7599
7786
|
function mountTable(mounts = []) {
|
|
7600
|
-
const root =
|
|
7787
|
+
const root = pinnedRoot ?? rootKind();
|
|
7601
7788
|
const lines = [`${root} / ${root} rw 0 0`, "devfs /dev devfs rw 0 0", "proc /proc proc rw 0 0"];
|
|
7602
7789
|
for (const m of mounts) {
|
|
7603
7790
|
const options = Object.entries(m.options).map(([k, v]) => v === "" ? k : `${k}=${v}`);
|
|
@@ -7703,7 +7890,7 @@ function linuxDevices(Fs) {
|
|
|
7703
7890
|
}
|
|
7704
7891
|
}
|
|
7705
7892
|
}
|
|
7706
|
-
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_PATH, UTIME_NOW, UTIME_OMIT, PROT_WRITE, MAP_PRIVATE, MAP_TYPE, O_WRONLY4, MAP_ALIGN, DIR_MODE, LINK_MODE, CHAR_DEVICE, O_ACCMODE2, O_CREAT2, field, NAME, AT_FDCWD, AT_EACCESS2, DEVICE_MODES;
|
|
7893
|
+
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_PATH, UTIME_NOW, UTIME_OMIT, PROT_WRITE, MAP_PRIVATE, MAP_TYPE, O_WRONLY4, MAP_ALIGN, DIR_MODE, LINK_MODE, CHAR_DEVICE, O_ACCMODE2, O_CREAT2, field, pinnedRoot, rootKind, NAME, AT_FDCWD, AT_EACCESS2, DEVICE_MODES;
|
|
7707
7894
|
var init_process_fds = __esm({
|
|
7708
7895
|
"src/process/process-fds.ts"() {
|
|
7709
7896
|
"use strict";
|
|
@@ -7745,6 +7932,7 @@ var init_process_fds = __esm({
|
|
|
7745
7932
|
O_ACCMODE2 = 3;
|
|
7746
7933
|
O_CREAT2 = 64;
|
|
7747
7934
|
field = (text) => (text || "none").replace(/[\s\\]/g, (c) => `\\${c.charCodeAt(0).toString(8).padStart(3, "0")}`);
|
|
7935
|
+
rootKind = () => globalThis.navigator?.storage ? "opfs" : "memory";
|
|
7748
7936
|
NAME = /^[a-z_][a-z0-9_-]*$/i;
|
|
7749
7937
|
AT_FDCWD = -100;
|
|
7750
7938
|
AT_EACCESS2 = 512;
|
|
@@ -8398,7 +8586,7 @@ function createSocketKernel(deps) {
|
|
|
8398
8586
|
if (!r.ok) throw new SyscallError(r.errno);
|
|
8399
8587
|
return r;
|
|
8400
8588
|
};
|
|
8401
|
-
const
|
|
8589
|
+
const json2 = (req) => {
|
|
8402
8590
|
const r = call2(req);
|
|
8403
8591
|
return r.ok && r.kind === "json" ? r.json : void 0;
|
|
8404
8592
|
};
|
|
@@ -8438,9 +8626,9 @@ function createSocketKernel(deps) {
|
|
|
8438
8626
|
return stream.fd;
|
|
8439
8627
|
};
|
|
8440
8628
|
return {
|
|
8441
|
-
socket: (domain, nonblock, cloexec) => guard(() => install(
|
|
8629
|
+
socket: (domain, nonblock, cloexec) => guard(() => install(json2({ op: "sock-open", domain }), nonblock, cloexec)),
|
|
8442
8630
|
socketpair: (domain, nonblock, cloexec) => guard(() => {
|
|
8443
|
-
const [a, b] =
|
|
8631
|
+
const [a, b] = json2({ op: "sock-pair", domain });
|
|
8444
8632
|
let first;
|
|
8445
8633
|
try {
|
|
8446
8634
|
first = install(a, nonblock, cloexec);
|
|
@@ -8475,7 +8663,7 @@ function createSocketKernel(deps) {
|
|
|
8475
8663
|
fd: listener.sliccKernelFd,
|
|
8476
8664
|
nonblock: (listener.flags & O_NONBLOCK2) !== 0
|
|
8477
8665
|
};
|
|
8478
|
-
const got =
|
|
8666
|
+
const got = json2(req);
|
|
8479
8667
|
return { fd: install(got.fd, nonblock, cloexec), peer: got.peer };
|
|
8480
8668
|
}),
|
|
8481
8669
|
connect: (fd, addr) => guard(() => {
|
|
@@ -8489,10 +8677,10 @@ function createSocketKernel(deps) {
|
|
|
8489
8677
|
});
|
|
8490
8678
|
}),
|
|
8491
8679
|
shutdown: (fd, how) => guard(() => done({ op: "sock-shutdown", fd: kfd(fd), how })),
|
|
8492
|
-
name: (fd, peer) => guard(() =>
|
|
8493
|
-
getopt: (fd, level, name2) => guard(() => ({ value:
|
|
8680
|
+
name: (fd, peer) => guard(() => json2({ op: "sock-name", fd: kfd(fd), peer })),
|
|
8681
|
+
getopt: (fd, level, name2) => guard(() => ({ value: json2({ op: "sock-getopt", fd: kfd(fd), level, name: name2 }) })),
|
|
8494
8682
|
setopt: (fd, level, name2, value2) => guard(() => done({ op: "sock-setopt", fd: kfd(fd), level, name: name2, value: value2 })),
|
|
8495
|
-
resolve: (name2, family = 4) => guard(() =>
|
|
8683
|
+
resolve: (name2, family = 4) => guard(() => json2({ op: "sock-resolve", name: name2, family })),
|
|
8496
8684
|
send: (fd, bytes, flags) => guard(() => {
|
|
8497
8685
|
const stream = socketAt(fd);
|
|
8498
8686
|
const nonblock = flags.dontwait === true || (stream.flags & O_NONBLOCK2) !== 0;
|
|
@@ -8910,7 +9098,7 @@ function kernelSys(transport) {
|
|
|
8910
9098
|
if (!r.ok) throw new SyscallError(r.errno);
|
|
8911
9099
|
return r;
|
|
8912
9100
|
};
|
|
8913
|
-
const
|
|
9101
|
+
const json2 = (r) => r.ok && r.kind === "json" ? r.json : void 0;
|
|
8914
9102
|
return {
|
|
8915
9103
|
read(fd, max, opts) {
|
|
8916
9104
|
const flags = {
|
|
@@ -8927,20 +9115,20 @@ function kernelSys(transport) {
|
|
|
8927
9115
|
body: bytes,
|
|
8928
9116
|
...opts?.nonblock ? { nonblock: true } : {}
|
|
8929
9117
|
};
|
|
8930
|
-
const n =
|
|
9118
|
+
const n = json2(call2(req, `fd-write ${fd}`));
|
|
8931
9119
|
return typeof n === "number" ? n : bytes.length;
|
|
8932
9120
|
},
|
|
8933
9121
|
close(fd) {
|
|
8934
9122
|
call2({ op: "fd-close", fd }, `fd-close ${fd}`);
|
|
8935
9123
|
},
|
|
8936
9124
|
pipe() {
|
|
8937
|
-
return
|
|
9125
|
+
return json2(call2({ op: "fd-pipe" }, "fd-pipe"));
|
|
8938
9126
|
},
|
|
8939
9127
|
poll(fd) {
|
|
8940
|
-
return
|
|
9128
|
+
return json2(call2({ op: "fd-poll", fd }, `fd-poll ${fd}`));
|
|
8941
9129
|
},
|
|
8942
9130
|
openVfs(path, flags, position, opts) {
|
|
8943
|
-
return
|
|
9131
|
+
return json2(
|
|
8944
9132
|
call2(
|
|
8945
9133
|
{
|
|
8946
9134
|
op: "fd-open-vfs",
|
|
@@ -8960,7 +9148,7 @@ function kernelSys(transport) {
|
|
|
8960
9148
|
);
|
|
8961
9149
|
},
|
|
8962
9150
|
seek(fd, offset, whence) {
|
|
8963
|
-
return
|
|
9151
|
+
return json2(call2({ op: "fd-seek", fd, offset, whence }, `fd-seek ${fd}`));
|
|
8964
9152
|
},
|
|
8965
9153
|
flush(fd) {
|
|
8966
9154
|
call2({ op: "fd-flush", fd }, `fd-flush ${fd}`);
|
|
@@ -8970,64 +9158,64 @@ function kernelSys(transport) {
|
|
|
8970
9158
|
return r.ok && r.kind === "bytes" ? r.bytes : new Uint8Array(0);
|
|
8971
9159
|
},
|
|
8972
9160
|
pwrite(fd, bytes, at) {
|
|
8973
|
-
return
|
|
9161
|
+
return json2(
|
|
8974
9162
|
call2({ op: "fd-pwrite", fd, offset: at, body: bytes }, `fd-pwrite ${fd}`)
|
|
8975
9163
|
);
|
|
8976
9164
|
},
|
|
8977
9165
|
isatty(fd) {
|
|
8978
|
-
return
|
|
9166
|
+
return json2(call2({ op: "fd-info", fd }, `fd-info ${fd}`))?.tty === true;
|
|
8979
9167
|
},
|
|
8980
9168
|
ttyName(fd) {
|
|
8981
|
-
return
|
|
9169
|
+
return json2(call2({ op: "fd-info", fd }, `fd-info ${fd}`))?.name;
|
|
8982
9170
|
},
|
|
8983
9171
|
kind(fd) {
|
|
8984
|
-
return
|
|
9172
|
+
return json2(call2({ op: "fd-info", fd }, `fd-info ${fd}`))?.kind;
|
|
8985
9173
|
},
|
|
8986
9174
|
heldMeta(fd) {
|
|
8987
|
-
return
|
|
9175
|
+
return json2(call2({ op: "fd-info", fd }, `fd-info ${fd}`)).meta;
|
|
8988
9176
|
},
|
|
8989
9177
|
access(fd) {
|
|
8990
|
-
return
|
|
9178
|
+
return json2(call2({ op: "fd-info", fd }, `fd-info ${fd}`)).access;
|
|
8991
9179
|
},
|
|
8992
9180
|
size(fd) {
|
|
8993
|
-
return
|
|
9181
|
+
return json2(call2({ op: "fd-vfs-stat", fd }, `fd-vfs-stat ${fd}`)).size;
|
|
8994
9182
|
},
|
|
8995
9183
|
ttyNames() {
|
|
8996
|
-
return
|
|
9184
|
+
return json2(call2({ op: "fd-tty-names" }, "fd-tty-names"));
|
|
8997
9185
|
},
|
|
8998
9186
|
ttyOwner(name2) {
|
|
8999
|
-
return
|
|
9187
|
+
return json2(call2({ op: "fd-tty-owner", name: name2 }, `fd-tty-owner ${name2}`));
|
|
9000
9188
|
},
|
|
9001
9189
|
openTty(name2) {
|
|
9002
9190
|
const req = name2 === void 0 ? { op: "fd-open-tty" } : { op: "fd-open-tty", name: name2 };
|
|
9003
|
-
return
|
|
9191
|
+
return json2(call2(req, `fd-open-tty ${name2 ?? ""}`));
|
|
9004
9192
|
},
|
|
9005
9193
|
tcgets(fd) {
|
|
9006
|
-
return
|
|
9194
|
+
return json2(call2({ op: "tty-get", fd }, `tty-get ${fd}`));
|
|
9007
9195
|
},
|
|
9008
9196
|
tcsets(fd, termios, flush) {
|
|
9009
9197
|
call2({ op: "tty-set", fd, termios, ...flush ? { flush } : {} }, `tty-set ${fd}`);
|
|
9010
9198
|
},
|
|
9011
9199
|
winsize(fd) {
|
|
9012
|
-
return
|
|
9200
|
+
return json2(call2({ op: "tty-winsz", fd }, `tty-winsz ${fd}`));
|
|
9013
9201
|
},
|
|
9014
9202
|
openPty() {
|
|
9015
|
-
return
|
|
9203
|
+
return json2(call2({ op: "pty-open" }, "pty-open"));
|
|
9016
9204
|
},
|
|
9017
9205
|
openPts(n, noctty) {
|
|
9018
|
-
return
|
|
9206
|
+
return json2(call2({ op: "pty-slave-open", n, noctty }, `pty-slave-open ${n}`));
|
|
9019
9207
|
},
|
|
9020
9208
|
ptyNumbers() {
|
|
9021
|
-
return
|
|
9209
|
+
return json2(call2({ op: "pty-list" }, "pty-list"));
|
|
9022
9210
|
},
|
|
9023
9211
|
procList() {
|
|
9024
|
-
return
|
|
9212
|
+
return json2(call2({ op: "proc-list" }, "proc-list"));
|
|
9025
9213
|
},
|
|
9026
9214
|
mountList() {
|
|
9027
|
-
return
|
|
9215
|
+
return json2(call2({ op: "mount-list" }, "mount-list"));
|
|
9028
9216
|
},
|
|
9029
9217
|
ptyNumber(fd) {
|
|
9030
|
-
return
|
|
9218
|
+
return json2(call2({ op: "pty-number", fd }, `pty-number ${fd}`));
|
|
9031
9219
|
},
|
|
9032
9220
|
ptyLock(fd, lock) {
|
|
9033
9221
|
call2({ op: "pty-lock", fd, lock }, `pty-lock ${fd}`);
|
|
@@ -9151,8 +9339,8 @@ async function runWasmProcess(init, port3, deps = {}) {
|
|
|
9151
9339
|
}
|
|
9152
9340
|
};
|
|
9153
9341
|
const sys = kernelSys(transport);
|
|
9154
|
-
const
|
|
9155
|
-
const say = (fd) => (text) => sys.write(fd,
|
|
9342
|
+
const encoder5 = new TextEncoder();
|
|
9343
|
+
const say = (fd) => (text) => sys.write(fd, encoder5.encode(`${text}
|
|
9156
9344
|
`));
|
|
9157
9345
|
let ready;
|
|
9158
9346
|
let failed5;
|
|
@@ -12491,6 +12679,7 @@ init_protocol();
|
|
|
12491
12679
|
init_process_runtime();
|
|
12492
12680
|
var loadWasi = () => Promise.resolve().then(() => (init_wasi_runtime(), wasi_runtime_exports));
|
|
12493
12681
|
var loadJs = () => Promise.resolve().then(() => (init_js_runtime(), js_runtime_exports));
|
|
12682
|
+
var NOT_RUNNABLE2 = 126;
|
|
12494
12683
|
function started(init, port3, run, wasi, js) {
|
|
12495
12684
|
if (init.program?.abi === "js") {
|
|
12496
12685
|
const jsInit = init;
|
|
@@ -12500,18 +12689,35 @@ function started(init, port3, run, wasi, js) {
|
|
|
12500
12689
|
if (wasmInit.program?.abi === "wasi") return wasi().then((m) => m.runWasiProcess(wasmInit, port3));
|
|
12501
12690
|
return run(wasmInit, port3);
|
|
12502
12691
|
}
|
|
12503
|
-
function processEntry(port3, run = runWasmProcess, wasi = loadWasi, js = loadJs) {
|
|
12504
|
-
|
|
12692
|
+
function processEntry(port3, run = runWasmProcess, wasi = loadWasi, js = loadJs, seal = () => {
|
|
12693
|
+
}) {
|
|
12694
|
+
const failed5 = (err, code2) => port3.postMessage({
|
|
12505
12695
|
type: WASM_PROCESS_ERROR,
|
|
12506
|
-
message: err instanceof Error ? err.stack ?? err.message : String(err)
|
|
12696
|
+
message: err instanceof Error ? err.stack ?? err.message : String(err),
|
|
12697
|
+
...code2 === void 0 ? {} : { code: code2 }
|
|
12507
12698
|
});
|
|
12699
|
+
let refused2;
|
|
12700
|
+
const sealOnce = () => {
|
|
12701
|
+
if (refused2 === void 0) {
|
|
12702
|
+
try {
|
|
12703
|
+
seal();
|
|
12704
|
+
refused2 = null;
|
|
12705
|
+
} catch (error) {
|
|
12706
|
+
refused2 = { error };
|
|
12707
|
+
}
|
|
12708
|
+
}
|
|
12709
|
+
return refused2;
|
|
12710
|
+
};
|
|
12508
12711
|
return (data) => {
|
|
12509
12712
|
const type = data?.type;
|
|
12713
|
+
if (type !== WASM_THREAD_INIT && type !== WASM_PROCESS_INIT) return;
|
|
12714
|
+
const refusal2 = sealOnce();
|
|
12510
12715
|
if (type === WASM_THREAD_INIT) {
|
|
12716
|
+
if (refusal2) return failed5(refusal2.error);
|
|
12511
12717
|
wasi().then((m) => m.runWasiThread(data, port3)).catch(failed5);
|
|
12512
12718
|
return;
|
|
12513
12719
|
}
|
|
12514
|
-
if (
|
|
12720
|
+
if (refusal2) return failed5(refusal2.error, NOT_RUNNABLE2);
|
|
12515
12721
|
started(data, port3, run, wasi, js).then(
|
|
12516
12722
|
(code2) => port3.postMessage({ type: WASM_PROCESS_EXIT, code: code2 }),
|
|
12517
12723
|
failed5
|