@ai-ecoverse/slicc-kernel 1.158.0 → 1.159.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 +8 -0
- package/dist/driver-worker.js.map +2 -2
- package/dist/index.js.map +2 -2
- package/dist/kernel-worker.js +229 -23
- package/dist/kernel-worker.js.map +4 -4
- package/dist/node-driver-worker.js +22 -0
- package/dist/node-driver-worker.js.map +2 -2
- package/dist/node-process-worker.js +659 -376
- package/dist/node-process-worker.js.map +4 -4
- package/dist/node.js +231 -25
- package/dist/node.js.map +4 -4
- package/dist/process-worker.js +131 -34
- package/dist/process-worker.js.map +4 -4
- package/dist/types/kernel/embedder.d.ts +6 -2
- package/dist/types/kernel/fd-rights.d.ts +32 -0
- package/dist/types/kernel/net/tls-server.d.ts +6 -1
- package/dist/types/kernel/pipe.d.ts +19 -2
- package/dist/types/kernel/socket-syscalls.d.ts +12 -0
- package/dist/types/kernel/socket.d.ts +9 -1
- package/dist/types/process/js/js-context.d.ts +9 -0
- package/dist/types/process/js/js-net.d.ts +1 -0
- package/dist/types/process/js/js-rights.d.ts +46 -0
- package/dist/types/process/js/js-sync.d.ts +8 -1
- package/package.json +1 -1
|
@@ -1668,7 +1668,7 @@ var init_wasi_threads = __esm({
|
|
|
1668
1668
|
this.beforeSpawn?.();
|
|
1669
1669
|
const tid = Atomics.add(this.ids, LAST_TID, 1) + 1;
|
|
1670
1670
|
const modules = this.modules?.();
|
|
1671
|
-
const
|
|
1671
|
+
const blocked2 = this.blocked?.();
|
|
1672
1672
|
this.port.postMessage({
|
|
1673
1673
|
type: WASM_THREAD_SPAWN,
|
|
1674
1674
|
thread: {
|
|
@@ -1677,7 +1677,7 @@ var init_wasi_threads = __esm({
|
|
|
1677
1677
|
memory: this.memory,
|
|
1678
1678
|
ids: this.ids.buffer,
|
|
1679
1679
|
...modules ? { modules } : {},
|
|
1680
|
-
...anyBlocked(
|
|
1680
|
+
...anyBlocked(blocked2) ? { blocked: blocked2 } : {}
|
|
1681
1681
|
}
|
|
1682
1682
|
});
|
|
1683
1683
|
return tid;
|
|
@@ -1843,8 +1843,8 @@ function localWait(wait2, blocks = true) {
|
|
|
1843
1843
|
function localCpuNanos() {
|
|
1844
1844
|
if (!local || !localSab) return void 0;
|
|
1845
1845
|
const now = epochMicros();
|
|
1846
|
-
const
|
|
1847
|
-
return BigInt(Math.max(0, now - localStart -
|
|
1846
|
+
const blocked2 = Number(Atomics.load(local, BLOCKED)) + localIdle(localSab, now).idle;
|
|
1847
|
+
return BigInt(Math.max(0, now - localStart - blocked2)) * 1000n;
|
|
1848
1848
|
}
|
|
1849
1849
|
function localIdle(sab, now) {
|
|
1850
1850
|
const state = Number(Atomics.load(slots(sab), IDLE));
|
|
@@ -2640,14 +2640,14 @@ function typeOf(info) {
|
|
|
2640
2640
|
function device(info) {
|
|
2641
2641
|
return info.meta && "device" in info.meta ? info.meta : void 0;
|
|
2642
2642
|
}
|
|
2643
|
-
function readDevice(info, max,
|
|
2643
|
+
function readDevice(info, max, random2) {
|
|
2644
2644
|
if (typeOf(info) === "directory") throw new JsCallError("EISDIR", "read");
|
|
2645
2645
|
const dev = device(info);
|
|
2646
2646
|
if (!dev) return void 0;
|
|
2647
2647
|
if (dev.access === "write") throw new JsCallError("EBADF", "read");
|
|
2648
2648
|
if (dev.device === "null") return new Uint8Array(0);
|
|
2649
2649
|
const out = new Uint8Array(Math.min(max, CHUNK));
|
|
2650
|
-
if (dev.device === "urandom")
|
|
2650
|
+
if (dev.device === "urandom") random2(out);
|
|
2651
2651
|
return out;
|
|
2652
2652
|
}
|
|
2653
2653
|
function writeDevice(info) {
|
|
@@ -3217,11 +3217,11 @@ function remainingMs(deadline, now) {
|
|
|
3217
3217
|
}
|
|
3218
3218
|
function semImports(host) {
|
|
3219
3219
|
const { mem } = host;
|
|
3220
|
-
const
|
|
3220
|
+
const call3 = (req) => host.o.kernel.call(req);
|
|
3221
3221
|
const name2 = (ptr, len) => mem.string(ptr, len);
|
|
3222
3222
|
return {
|
|
3223
3223
|
sem_open: (np, nl, oflag, mode, value2, out) => {
|
|
3224
|
-
const handle =
|
|
3224
|
+
const handle = call3({
|
|
3225
3225
|
op: "sem-open",
|
|
3226
3226
|
name: name2(np, nl),
|
|
3227
3227
|
create: (oflag & SEM_CREAT) !== 0,
|
|
@@ -3231,9 +3231,9 @@ function semImports(host) {
|
|
|
3231
3231
|
});
|
|
3232
3232
|
mem.view().setUint32(out, handle, true);
|
|
3233
3233
|
},
|
|
3234
|
-
sem_close: (handle) => void
|
|
3235
|
-
sem_unlink: (np, nl) => void
|
|
3236
|
-
sem_post: (handle) => void
|
|
3234
|
+
sem_close: (handle) => void call3({ op: "sem-close", handle }),
|
|
3235
|
+
sem_unlink: (np, nl) => void call3({ op: "sem-unlink", name: name2(np, nl) }),
|
|
3236
|
+
sem_post: (handle) => void call3({ op: "sem-post", handle }),
|
|
3237
3237
|
sem_wait: (handle, how, clock, deadline) => {
|
|
3238
3238
|
const kind = HOW[how];
|
|
3239
3239
|
if (!kind) throw new WasiError("EINVAL");
|
|
@@ -3243,9 +3243,9 @@ function semImports(host) {
|
|
|
3243
3243
|
if (clock !== CLOCK.REALTIME && clock !== CLOCK.MONOTONIC) throw new WasiError("EINVAL");
|
|
3244
3244
|
timeoutMs2 = remainingMs(deadline, host.now(clock));
|
|
3245
3245
|
}
|
|
3246
|
-
|
|
3246
|
+
call3({ op: "sem-wait", handle, how: kind, timeoutMs: timeoutMs2 });
|
|
3247
3247
|
},
|
|
3248
|
-
sem_getvalue: (handle, out) => void mem.view().setInt32(out,
|
|
3248
|
+
sem_getvalue: (handle, out) => void mem.view().setInt32(out, call3({ op: "sem-getvalue", handle }), true)
|
|
3249
3249
|
};
|
|
3250
3250
|
}
|
|
3251
3251
|
var SEM_CREAT, SEM_EXCL, HOW, NS_PER_MS;
|
|
@@ -3309,8 +3309,8 @@ var init_wasi_cred = __esm({
|
|
|
3309
3309
|
call;
|
|
3310
3310
|
shared;
|
|
3311
3311
|
signals;
|
|
3312
|
-
constructor(
|
|
3313
|
-
this.call =
|
|
3312
|
+
constructor(call3, shared, signals = UNGATED) {
|
|
3313
|
+
this.call = call3;
|
|
3314
3314
|
this.shared = shared;
|
|
3315
3315
|
this.signals = signals;
|
|
3316
3316
|
}
|
|
@@ -3565,8 +3565,8 @@ var init_wasi_fds = __esm({
|
|
|
3565
3565
|
return this.install({ type: "dir", path: normalize(path), preopen: name2 });
|
|
3566
3566
|
}
|
|
3567
3567
|
preopens(cwd, root) {
|
|
3568
|
-
const
|
|
3569
|
-
const dot = { type: "dir", path:
|
|
3568
|
+
const here2 = normalize(cwd);
|
|
3569
|
+
const dot = { type: "dir", path: here2, preopen: "." };
|
|
3570
3570
|
const out = [dot];
|
|
3571
3571
|
let names = [];
|
|
3572
3572
|
try {
|
|
@@ -3588,7 +3588,7 @@ var init_wasi_fds = __esm({
|
|
|
3588
3588
|
if (root) {
|
|
3589
3589
|
out.push(
|
|
3590
3590
|
{ type: "dir", path: "/", preopen: "/" },
|
|
3591
|
-
{ type: "dir", path:
|
|
3591
|
+
{ type: "dir", path: here2, preopen: "./" }
|
|
3592
3592
|
);
|
|
3593
3593
|
dot.twin = 3 + out.length - 1;
|
|
3594
3594
|
}
|
|
@@ -4332,10 +4332,10 @@ var init_wasi_fds = __esm({
|
|
|
4332
4332
|
return fd;
|
|
4333
4333
|
}
|
|
4334
4334
|
restartable;
|
|
4335
|
-
restarting(
|
|
4335
|
+
restarting(call3) {
|
|
4336
4336
|
for (; ; ) {
|
|
4337
4337
|
try {
|
|
4338
|
-
return
|
|
4338
|
+
return call3();
|
|
4339
4339
|
} catch (err) {
|
|
4340
4340
|
if (err.code !== "EINTR" || !this.restartable?.()) throw err;
|
|
4341
4341
|
}
|
|
@@ -4477,11 +4477,11 @@ var init_wasi_memory = __esm({
|
|
|
4477
4477
|
return at;
|
|
4478
4478
|
}
|
|
4479
4479
|
putStrings(list, ptrs, buf) {
|
|
4480
|
-
const
|
|
4480
|
+
const encoder6 = new TextEncoder();
|
|
4481
4481
|
const v = this.view();
|
|
4482
4482
|
let at = buf;
|
|
4483
4483
|
list.forEach((s, i) => {
|
|
4484
|
-
const b =
|
|
4484
|
+
const b = encoder6.encode(s);
|
|
4485
4485
|
v.setUint32(ptrs + i * 4, at, true);
|
|
4486
4486
|
this.bytes(at, b.length).set(b);
|
|
4487
4487
|
v.setUint8(at + b.length, 0);
|
|
@@ -4489,12 +4489,12 @@ var init_wasi_memory = __esm({
|
|
|
4489
4489
|
});
|
|
4490
4490
|
}
|
|
4491
4491
|
putSizes(list, countPtr, sizePtr) {
|
|
4492
|
-
const
|
|
4492
|
+
const encoder6 = new TextEncoder();
|
|
4493
4493
|
const v = this.view();
|
|
4494
4494
|
v.setUint32(countPtr, list.length, true);
|
|
4495
4495
|
v.setUint32(
|
|
4496
4496
|
sizePtr,
|
|
4497
|
-
list.reduce((n, s) => n +
|
|
4497
|
+
list.reduce((n, s) => n + encoder6.encode(s).length + 1, 0),
|
|
4498
4498
|
true
|
|
4499
4499
|
);
|
|
4500
4500
|
}
|
|
@@ -4752,8 +4752,8 @@ var init_wasi_sigmask = __esm({
|
|
|
4752
4752
|
return true;
|
|
4753
4753
|
}
|
|
4754
4754
|
pending() {
|
|
4755
|
-
const
|
|
4756
|
-
return libcBits(
|
|
4755
|
+
const own2 = Atomics.load(this.header, SAB_I_SIGNALS);
|
|
4756
|
+
return libcBits(own2 | (this.process ? Atomics.load(this.process, SAB_I_SIGNALS) : 0));
|
|
4757
4757
|
}
|
|
4758
4758
|
};
|
|
4759
4759
|
}
|
|
@@ -4843,7 +4843,7 @@ function timeoutMs(ns) {
|
|
|
4843
4843
|
}
|
|
4844
4844
|
function wasixEpollImports(host) {
|
|
4845
4845
|
const { mem, fds, o } = host;
|
|
4846
|
-
const
|
|
4846
|
+
const call3 = (req) => o.kernel.call(req);
|
|
4847
4847
|
const kernelFd = (fd, refusal2) => {
|
|
4848
4848
|
const e = fds.find(fd);
|
|
4849
4849
|
if (!e) throw new WasiError("EBADF");
|
|
@@ -4860,7 +4860,7 @@ function wasixEpollImports(host) {
|
|
|
4860
4860
|
};
|
|
4861
4861
|
return {
|
|
4862
4862
|
epoll_create: (out) => {
|
|
4863
|
-
const fd =
|
|
4863
|
+
const fd = call3({ op: "epoll-create" });
|
|
4864
4864
|
fds.adopt(fd, "stream", false);
|
|
4865
4865
|
mem.view().setUint32(out, fd, true);
|
|
4866
4866
|
},
|
|
@@ -4872,7 +4872,7 @@ function wasixEpollImports(host) {
|
|
|
4872
4872
|
if (how !== "del" && event === 0) throw new WasiError("EINVAL");
|
|
4873
4873
|
const events = event === 0 ? 0 : mem.view().getUint32(event, true);
|
|
4874
4874
|
const data = event === 0 ? [] : [...mem.bytes(event + DATA_OFFSET, DATA_SIZE)];
|
|
4875
|
-
|
|
4875
|
+
call3({ op: "epoll-ctl", epfd, how, fd, events, data });
|
|
4876
4876
|
},
|
|
4877
4877
|
epoll_wait: (epfd, ptr, maxevents, timeout, out) => {
|
|
4878
4878
|
mem.view().setUint32(out, 0, true);
|
|
@@ -4880,7 +4880,7 @@ function wasixEpollImports(host) {
|
|
|
4880
4880
|
kernelFd(epfd, "EINVAL");
|
|
4881
4881
|
const max = Math.min(maxevents | 0, MAX_EVENTS);
|
|
4882
4882
|
const ms = host.entered ? 0 : timeoutMs(timeout);
|
|
4883
|
-
const events =
|
|
4883
|
+
const events = call3({ op: "epoll-wait", epfd, max, timeoutMs: ms });
|
|
4884
4884
|
if (host.entered && events.length === 0 && timeoutMs(timeout) !== 0) return E.INTR;
|
|
4885
4885
|
writeEvents2(ptr, events);
|
|
4886
4886
|
mem.view().setUint32(out, events.length, true);
|
|
@@ -4889,7 +4889,7 @@ function wasixEpollImports(host) {
|
|
|
4889
4889
|
fd_event: (initial, flags, out) => {
|
|
4890
4890
|
const value2 = BigInt.asUintN(64, initial);
|
|
4891
4891
|
if (value2 > EVENTFD_MAX) throw new WasiError("EINVAL");
|
|
4892
|
-
const fd =
|
|
4892
|
+
const fd = call3({
|
|
4893
4893
|
op: "eventfd-open",
|
|
4894
4894
|
initial: value2.toString(),
|
|
4895
4895
|
semaphore: (flags & EVENTFD_SEMAPHORE) !== 0
|
|
@@ -5140,12 +5140,12 @@ function optionalAddr(view, ptr) {
|
|
|
5140
5140
|
}
|
|
5141
5141
|
function datagramCalls(host) {
|
|
5142
5142
|
const { mem, o } = host;
|
|
5143
|
-
const
|
|
5143
|
+
const call3 = (req) => o.kernel.call(req);
|
|
5144
5144
|
return {
|
|
5145
5145
|
recvFrom(fd, nonblock, iovs, n, riflags, outLen, outFlags, outAddr) {
|
|
5146
5146
|
const max = Math.min(mem.capacity(iovs, n), MAX_DATAGRAM);
|
|
5147
5147
|
const peek = (riflags & RIFLAG_PEEK) !== 0;
|
|
5148
|
-
const raw =
|
|
5148
|
+
const raw = call3({ op: "sock-recvfrom", fd, max, peek, nonblock });
|
|
5149
5149
|
const got = decodeReceived(raw);
|
|
5150
5150
|
const view = mem.view();
|
|
5151
5151
|
view.setUint32(outLen, mem.scatter(iovs, n, got.bytes), true);
|
|
@@ -5158,7 +5158,7 @@ function datagramCalls(host) {
|
|
|
5158
5158
|
const named = optionalAddr(mem.view(), addr);
|
|
5159
5159
|
const to = named && absolute(host.cwd, named);
|
|
5160
5160
|
const body = mem.gather(iovs, n);
|
|
5161
|
-
const sent =
|
|
5161
|
+
const sent = call3({ op: "sock-sendto", fd, body, ...to ? { addr: to } : {}, nonblock });
|
|
5162
5162
|
mem.view().setUint32(out, sent, true);
|
|
5163
5163
|
return E.SUCCESS;
|
|
5164
5164
|
}
|
|
@@ -5166,7 +5166,7 @@ function datagramCalls(host) {
|
|
|
5166
5166
|
}
|
|
5167
5167
|
function wasixSocketImports(host, preview1) {
|
|
5168
5168
|
const { mem, fds, o } = host;
|
|
5169
|
-
const
|
|
5169
|
+
const call3 = (req) => o.kernel.call(req);
|
|
5170
5170
|
const socket = (fd) => {
|
|
5171
5171
|
const e = fds.get(fd);
|
|
5172
5172
|
if (e.type !== "kernel" || fds.kind(fd, e) !== "socket") throw new WasiError("ENOTSOCK");
|
|
@@ -5185,7 +5185,7 @@ function wasixSocketImports(host, preview1) {
|
|
|
5185
5185
|
return {
|
|
5186
5186
|
sock_open: (af, type, _proto, out) => {
|
|
5187
5187
|
const req = openRequest2(af, type);
|
|
5188
|
-
const fd =
|
|
5188
|
+
const fd = call3(req);
|
|
5189
5189
|
fds.adopt(fd, "socket", false, "type" in req);
|
|
5190
5190
|
mem.view().setUint32(out, fd, true);
|
|
5191
5191
|
},
|
|
@@ -5193,7 +5193,7 @@ function wasixSocketImports(host, preview1) {
|
|
|
5193
5193
|
const req = pairRequest(af, type);
|
|
5194
5194
|
mem.view().setUint32(out1, 0, true);
|
|
5195
5195
|
mem.view().setUint32(out2, 0, true);
|
|
5196
|
-
const [a, b] =
|
|
5196
|
+
const [a, b] = call3(req);
|
|
5197
5197
|
fds.adopt(a, "socket", false, "type" in req);
|
|
5198
5198
|
fds.adopt(b, "socket", false, "type" in req);
|
|
5199
5199
|
mem.view().setUint32(out1, a, true);
|
|
@@ -5201,31 +5201,31 @@ function wasixSocketImports(host, preview1) {
|
|
|
5201
5201
|
},
|
|
5202
5202
|
sock_bind: (fd, addr) => {
|
|
5203
5203
|
socket(fd);
|
|
5204
|
-
|
|
5204
|
+
call3({ op: "sock-bind", fd, addr: absolute(host.cwd, readAddr(mem.view(), addr)) });
|
|
5205
5205
|
},
|
|
5206
5206
|
sock_listen: (fd, backlog) => {
|
|
5207
5207
|
socket(fd);
|
|
5208
|
-
|
|
5208
|
+
call3({ op: "sock-listen", fd, backlog });
|
|
5209
5209
|
},
|
|
5210
5210
|
sock_connect: (fd, addr) => {
|
|
5211
5211
|
const e = socket(fd);
|
|
5212
5212
|
const to = absolute(host.cwd, readAddr(mem.view(), addr));
|
|
5213
|
-
|
|
5213
|
+
call3({ op: "sock-connect", fd, addr: to, nonblock: e.nonblock });
|
|
5214
5214
|
},
|
|
5215
5215
|
sock_accept_v2: (fd, flags, outFd, outAddr) => {
|
|
5216
5216
|
const e = socket(fd);
|
|
5217
|
-
const r =
|
|
5217
|
+
const r = call3({ op: "sock-accept", fd, nonblock: e.nonblock });
|
|
5218
5218
|
fds.adopt(r.fd, "socket", (flags & FDFLAGS.NONBLOCK) !== 0);
|
|
5219
5219
|
mem.view().setUint32(outFd, r.fd, true);
|
|
5220
5220
|
writeAddr(mem.view(), outAddr, r.peer);
|
|
5221
5221
|
},
|
|
5222
5222
|
sock_addr_local: (fd, out) => {
|
|
5223
5223
|
socket(fd);
|
|
5224
|
-
writeAddr(mem.view(), out,
|
|
5224
|
+
writeAddr(mem.view(), out, call3({ op: "sock-name", fd, peer: false }));
|
|
5225
5225
|
},
|
|
5226
5226
|
sock_addr_peer: (fd, out) => {
|
|
5227
5227
|
socket(fd);
|
|
5228
|
-
writeAddr(mem.view(), out,
|
|
5228
|
+
writeAddr(mem.view(), out, call3({ op: "sock-name", fd, peer: true }));
|
|
5229
5229
|
},
|
|
5230
5230
|
sock_recv_from: (fd, iovs, n, riflags, outLen, outFlags, outAddr) => {
|
|
5231
5231
|
if (datagrams(fd)) {
|
|
@@ -5241,7 +5241,7 @@ function wasixSocketImports(host, preview1) {
|
|
|
5241
5241
|
outFlags
|
|
5242
5242
|
);
|
|
5243
5243
|
if (r !== E.SUCCESS) return r;
|
|
5244
|
-
writeAddr(mem.view(), outAddr,
|
|
5244
|
+
writeAddr(mem.view(), outAddr, call3({ op: "sock-name", fd, peer: true }));
|
|
5245
5245
|
return E.SUCCESS;
|
|
5246
5246
|
},
|
|
5247
5247
|
sock_send_to: (fd, iovs, n, flags, addr, out) => {
|
|
@@ -5261,24 +5261,24 @@ function wasixSocketImports(host, preview1) {
|
|
|
5261
5261
|
sock_get_opt_flag: (fd, opt, out) => {
|
|
5262
5262
|
socket(fd);
|
|
5263
5263
|
const pair = option(opt);
|
|
5264
|
-
const v = pair ?
|
|
5264
|
+
const v = pair ? call3({ op: "sock-getopt", fd, level: pair[0], name: pair[1] }) : 0;
|
|
5265
5265
|
mem.view().setUint8(out, v ? 1 : 0);
|
|
5266
5266
|
},
|
|
5267
5267
|
sock_set_opt_flag: (fd, opt, flag) => {
|
|
5268
5268
|
socket(fd);
|
|
5269
5269
|
const pair = option(opt);
|
|
5270
|
-
if (pair)
|
|
5270
|
+
if (pair) call3({ op: "sock-setopt", fd, level: pair[0], name: pair[1], value: flag ? 1 : 0 });
|
|
5271
5271
|
},
|
|
5272
5272
|
sock_get_opt_size: (fd, opt, out) => {
|
|
5273
5273
|
socket(fd);
|
|
5274
5274
|
const pair = option(opt);
|
|
5275
|
-
const v = pair ?
|
|
5275
|
+
const v = pair ? call3({ op: "sock-getopt", fd, level: pair[0], name: pair[1] }) : 0;
|
|
5276
5276
|
mem.view().setBigUint64(out, BigInt(v), true);
|
|
5277
5277
|
},
|
|
5278
5278
|
sock_set_opt_size: (fd, opt, size) => {
|
|
5279
5279
|
socket(fd);
|
|
5280
5280
|
const pair = option(opt);
|
|
5281
|
-
if (pair)
|
|
5281
|
+
if (pair) call3({ op: "sock-setopt", fd, level: pair[0], name: pair[1], value: Number(size) });
|
|
5282
5282
|
},
|
|
5283
5283
|
sock_get_opt_time: (fd, _opt, out) => {
|
|
5284
5284
|
socket(fd);
|
|
@@ -5287,7 +5287,7 @@ function wasixSocketImports(host, preview1) {
|
|
|
5287
5287
|
sock_set_opt_time: (fd) => void socket(fd),
|
|
5288
5288
|
sock_send_file: () => E.NOSYS,
|
|
5289
5289
|
resolve: (name2, len, _port, addrs, naddrs, out) => {
|
|
5290
|
-
const found =
|
|
5290
|
+
const found = call3({ op: "sock-resolve", name: mem.string(name2, len), family: 0 });
|
|
5291
5291
|
const ips = found.map(ipBytes).filter((ip) => ip !== void 0);
|
|
5292
5292
|
if (ips.length === 0) throw new WasiError("ENOENT");
|
|
5293
5293
|
if (naddrs < 1) throw new WasiError("EINVAL");
|
|
@@ -5339,7 +5339,7 @@ var init_wasix_sockets = __esm({
|
|
|
5339
5339
|
});
|
|
5340
5340
|
|
|
5341
5341
|
// src/process/wasi/wasi-host.ts
|
|
5342
|
-
function
|
|
5342
|
+
function idOf2(value2) {
|
|
5343
5343
|
return value2 >>> 0 === 4294967295 ? void 0 : value2 >>> 0;
|
|
5344
5344
|
}
|
|
5345
5345
|
function linkedOf(st) {
|
|
@@ -5499,7 +5499,7 @@ var init_wasi_host = __esm({
|
|
|
5499
5499
|
o;
|
|
5500
5500
|
constructor(o) {
|
|
5501
5501
|
const { kernel } = o;
|
|
5502
|
-
const
|
|
5502
|
+
const call3 = (req) => {
|
|
5503
5503
|
if (req.op !== "fd-promote") this.fds.flushEarly();
|
|
5504
5504
|
return kernel.call(req);
|
|
5505
5505
|
};
|
|
@@ -5513,7 +5513,7 @@ var init_wasi_host = __esm({
|
|
|
5513
5513
|
};
|
|
5514
5514
|
}
|
|
5515
5515
|
});
|
|
5516
|
-
this.o = { ...o, kernel: { sys, call:
|
|
5516
|
+
this.o = { ...o, kernel: { sys, call: call3 } };
|
|
5517
5517
|
this.startCwd = o.cwd;
|
|
5518
5518
|
this.fds = new WasiFds(this.o.kernel, o.fs);
|
|
5519
5519
|
if (o.held) this.fds.held = o.held;
|
|
@@ -5593,9 +5593,9 @@ var init_wasi_host = __esm({
|
|
|
5593
5593
|
};
|
|
5594
5594
|
const modeOf2 = (st) => (st.mode ?? 0) & 4095;
|
|
5595
5595
|
const chown = (path, uid, gid, follow3, handle) => {
|
|
5596
|
-
const { chown:
|
|
5597
|
-
if (!
|
|
5598
|
-
|
|
5596
|
+
const { chown: own2 } = this.o.fs;
|
|
5597
|
+
if (!own2) throw new WasiError("ENOSYS");
|
|
5598
|
+
own2.call(this.o.fs, path, idOf2(uid), idOf2(gid), follow3, handle);
|
|
5599
5599
|
};
|
|
5600
5600
|
const caller = () => {
|
|
5601
5601
|
const cred = this.creds.get();
|
|
@@ -6921,13 +6921,13 @@ function importsContext({
|
|
|
6921
6921
|
instance
|
|
6922
6922
|
}) {
|
|
6923
6923
|
const { fs } = host.o;
|
|
6924
|
-
const
|
|
6924
|
+
const call3 = (req) => value(raw(req));
|
|
6925
6925
|
const pathOf = (fd) => {
|
|
6926
6926
|
const e = host.fds.get(fd);
|
|
6927
6927
|
if (e.type === "file") return e.file.path;
|
|
6928
6928
|
if (e.type === "dir") return e.path;
|
|
6929
6929
|
if (e.type === "kernel" && host.fds.kind(fd, e) === "file") {
|
|
6930
|
-
return
|
|
6930
|
+
return call3({ op: "fd-vfs-stat", fd }).path;
|
|
6931
6931
|
}
|
|
6932
6932
|
return void 0;
|
|
6933
6933
|
};
|
|
@@ -6935,7 +6935,7 @@ function importsContext({
|
|
|
6935
6935
|
const e = host.fds.get(fd);
|
|
6936
6936
|
if (e.type === "file") return { path: e.file.path, size: e.file.size() };
|
|
6937
6937
|
if (e.type === "kernel" && host.fds.kind(fd, e) === "file") {
|
|
6938
|
-
return
|
|
6938
|
+
return call3({ op: "fd-vfs-stat", fd });
|
|
6939
6939
|
}
|
|
6940
6940
|
return { path: pathOf(fd) };
|
|
6941
6941
|
};
|
|
@@ -6947,7 +6947,7 @@ function importsContext({
|
|
|
6947
6947
|
const owners = fs.owners === true;
|
|
6948
6948
|
const live = () => {
|
|
6949
6949
|
if (!owners) return { uid: UID, gid: UID };
|
|
6950
|
-
const cred =
|
|
6950
|
+
const cred = call3({ op: "proc-cred" });
|
|
6951
6951
|
return { uid: cred.euid, gid: cred.egid };
|
|
6952
6952
|
};
|
|
6953
6953
|
const fds = {
|
|
@@ -6998,7 +6998,7 @@ function importsContext({
|
|
|
6998
6998
|
const path = requirePath(fd);
|
|
6999
6999
|
host.fds.promote(fd);
|
|
7000
7000
|
try {
|
|
7001
|
-
|
|
7001
|
+
call3({ op: "lock", path, exclusive, fd });
|
|
7002
7002
|
} catch (err) {
|
|
7003
7003
|
if (code(err) === "EAGAIN") return E.AGAIN;
|
|
7004
7004
|
throw err;
|
|
@@ -7006,7 +7006,7 @@ function importsContext({
|
|
|
7006
7006
|
return E.SUCCESS;
|
|
7007
7007
|
},
|
|
7008
7008
|
unlock(fd) {
|
|
7009
|
-
|
|
7009
|
+
call3({ op: "unlock", path: requirePath(fd), fd });
|
|
7010
7010
|
}
|
|
7011
7011
|
};
|
|
7012
7012
|
const ctx = {
|
|
@@ -7023,15 +7023,15 @@ function importsContext({
|
|
|
7023
7023
|
}
|
|
7024
7024
|
}),
|
|
7025
7025
|
fds,
|
|
7026
|
-
syscall: (req) => req.op === "proc-umask" ? host.umask(req.mask) :
|
|
7027
|
-
net: network(raw,
|
|
7028
|
-
...processes(host,
|
|
7026
|
+
syscall: (req) => req.op === "proc-umask" ? host.umask(req.mask) : call3(req),
|
|
7027
|
+
net: network(raw, call3),
|
|
7028
|
+
...processes(host, call3, tid !== MAIN_TID),
|
|
7029
7029
|
async: {
|
|
7030
|
-
submit: (req) =>
|
|
7030
|
+
submit: (req) => call3({ op: "async-submit", req }),
|
|
7031
7031
|
wait(timeoutMs2) {
|
|
7032
7032
|
for (; ; ) {
|
|
7033
7033
|
try {
|
|
7034
|
-
return
|
|
7034
|
+
return call3({
|
|
7035
7035
|
op: "async-wait",
|
|
7036
7036
|
...timeoutMs2 !== void 0 ? { timeoutMs: timeoutMs2 } : {}
|
|
7037
7037
|
});
|
|
@@ -7047,10 +7047,10 @@ function importsContext({
|
|
|
7047
7047
|
if (!result.ok) return { error: result.errno };
|
|
7048
7048
|
return { value: value(result) };
|
|
7049
7049
|
},
|
|
7050
|
-
resolve: (v) =>
|
|
7051
|
-
hold: () =>
|
|
7050
|
+
resolve: (v) => call3({ op: "async-resolve", value: v }),
|
|
7051
|
+
hold: () => call3({ op: "async-hold" }),
|
|
7052
7052
|
cancel: (id) => void raw({ op: "async-cancel", id }),
|
|
7053
|
-
close: () => void
|
|
7053
|
+
close: () => void call3({ op: "async-close" })
|
|
7054
7054
|
},
|
|
7055
7055
|
errno: (err) => wasiErrnoOf(code(err))
|
|
7056
7056
|
};
|
|
@@ -7065,12 +7065,12 @@ function loopbackHost(host) {
|
|
|
7065
7065
|
if (typeof host === "string" && LOOPBACK2.test(host)) return host;
|
|
7066
7066
|
throw new WasiError("EINVAL");
|
|
7067
7067
|
}
|
|
7068
|
-
function network(raw,
|
|
7068
|
+
function network(raw, call3) {
|
|
7069
7069
|
return {
|
|
7070
7070
|
connect({ host, port: port3, nonblock = false }) {
|
|
7071
7071
|
const to = loopbackHost(host);
|
|
7072
7072
|
if (!Number.isInteger(port3) || port3 < 1 || port3 > 65535) throw new WasiError("EINVAL");
|
|
7073
|
-
const fd =
|
|
7073
|
+
const fd = call3({ op: "sock-open", domain: "inet" });
|
|
7074
7074
|
const addr = { family: "inet", host: to, port: port3 };
|
|
7075
7075
|
const r = raw({ op: "sock-connect", fd, addr, ...nonblock ? { nonblock: true } : {} });
|
|
7076
7076
|
if (r.ok || nonblock && r.errno === "EINPROGRESS") return fd;
|
|
@@ -7078,18 +7078,18 @@ function network(raw, call2) {
|
|
|
7078
7078
|
throw new WasiError(r.errno);
|
|
7079
7079
|
},
|
|
7080
7080
|
ready(fd) {
|
|
7081
|
-
const sel =
|
|
7081
|
+
const sel = call3({ op: "fd-select", read: [], write: [fd], timeoutMs: 0 });
|
|
7082
7082
|
if (!sel.write.includes(fd)) return E.INPROGRESS;
|
|
7083
|
-
return
|
|
7083
|
+
return call3({ op: "sock-getopt", fd, level: SOL_SOCKET, name: SO_ERROR });
|
|
7084
7084
|
}
|
|
7085
7085
|
};
|
|
7086
7086
|
}
|
|
7087
|
-
function processes(host,
|
|
7088
|
-
const close = (fd) => void
|
|
7087
|
+
function processes(host, call3, inThread) {
|
|
7088
|
+
const close = (fd) => void call3({ op: "fd-close", fd });
|
|
7089
7089
|
const slot2 = (n, how, mine, theirs) => {
|
|
7090
7090
|
if (how === "inherit") return { fd: n };
|
|
7091
7091
|
if (how === "null") return { none: true };
|
|
7092
|
-
const [read2, write2] =
|
|
7092
|
+
const [read2, write2] = call3({ op: "fd-pipe" });
|
|
7093
7093
|
mine[n] = n === 0 ? write2 : read2;
|
|
7094
7094
|
theirs.push(n === 0 ? read2 : write2);
|
|
7095
7095
|
return { fd: n === 0 ? read2 : write2 };
|
|
@@ -7111,7 +7111,7 @@ function processes(host, call2, inThread) {
|
|
|
7111
7111
|
stdio,
|
|
7112
7112
|
...inThread ? {} : { restart: true }
|
|
7113
7113
|
};
|
|
7114
|
-
const pid = restarted(() =>
|
|
7114
|
+
const pid = restarted(() => call3(req));
|
|
7115
7115
|
const out = { pid };
|
|
7116
7116
|
STDIO2.forEach((name2, n) => {
|
|
7117
7117
|
if (mine[n] !== void 0) out[name2] = mine[n];
|
|
@@ -7128,7 +7128,7 @@ function processes(host, call2, inThread) {
|
|
|
7128
7128
|
wait(pid) {
|
|
7129
7129
|
for (; ; ) {
|
|
7130
7130
|
try {
|
|
7131
|
-
const [, status2] =
|
|
7131
|
+
const [, status2] = call3({ op: "proc-wait", pid, nohang: false });
|
|
7132
7132
|
host.o.fs.invalidate?.();
|
|
7133
7133
|
const signal = status2 & 127;
|
|
7134
7134
|
return signal ? { status: 128 + signal, signal } : { status: status2 >> 8 & 255 };
|
|
@@ -7138,7 +7138,7 @@ function processes(host, call2, inThread) {
|
|
|
7138
7138
|
}
|
|
7139
7139
|
},
|
|
7140
7140
|
kill(pid, sig) {
|
|
7141
|
-
|
|
7141
|
+
call3({ op: "proc-kill", pid, sig });
|
|
7142
7142
|
}
|
|
7143
7143
|
};
|
|
7144
7144
|
}
|
|
@@ -7245,7 +7245,7 @@ var KERNEL_VERSION, OS_RELEASE;
|
|
|
7245
7245
|
var init_version = __esm({
|
|
7246
7246
|
"src/version.ts"() {
|
|
7247
7247
|
"use strict";
|
|
7248
|
-
KERNEL_VERSION = true ? "1.
|
|
7248
|
+
KERNEL_VERSION = true ? "1.159.0" : "0.0.0-dev";
|
|
7249
7249
|
OS_RELEASE = "6.0.0-slicc";
|
|
7250
7250
|
}
|
|
7251
7251
|
});
|
|
@@ -7377,14 +7377,14 @@ function fdsOf(fds) {
|
|
|
7377
7377
|
return { fd, kernel: from };
|
|
7378
7378
|
});
|
|
7379
7379
|
}
|
|
7380
|
-
function groupOf(o,
|
|
7381
|
-
const { pgid, session } = o;
|
|
7380
|
+
function groupOf(o, call3) {
|
|
7381
|
+
const { pgid, session: session2 } = o;
|
|
7382
7382
|
const valid = pgid === void 0 || Number.isInteger(pgid) && pgid >= 0;
|
|
7383
|
-
if (!valid ||
|
|
7384
|
-
throw new JsCallError("EINVAL",
|
|
7383
|
+
if (!valid || session2 !== void 0 && typeof session2 !== "boolean") {
|
|
7384
|
+
throw new JsCallError("EINVAL", call3);
|
|
7385
7385
|
}
|
|
7386
|
-
if (
|
|
7387
|
-
return
|
|
7386
|
+
if (session2 && pgid !== void 0) throw new JsCallError("EINVAL", call3);
|
|
7387
|
+
return session2 ? { session: true } : pgid !== void 0 ? { pgid } : {};
|
|
7388
7388
|
}
|
|
7389
7389
|
function deathOf(signal, defaults) {
|
|
7390
7390
|
if (signal === void 0) return {};
|
|
@@ -7393,9 +7393,9 @@ function deathOf(signal, defaults) {
|
|
|
7393
7393
|
}
|
|
7394
7394
|
return { deathSignal: defaults.signal(signal) };
|
|
7395
7395
|
}
|
|
7396
|
-
function argv0Of(argv0,
|
|
7396
|
+
function argv0Of(argv0, call3) {
|
|
7397
7397
|
if (argv0 === void 0) return {};
|
|
7398
|
-
if (typeof argv0 !== "string") throw new JsCallError("EINVAL",
|
|
7398
|
+
if (typeof argv0 !== "string") throw new JsCallError("EINVAL", call3);
|
|
7399
7399
|
return { argv0 };
|
|
7400
7400
|
}
|
|
7401
7401
|
async function closeAll(io, fds) {
|
|
@@ -7791,11 +7791,11 @@ async function pumpFrom(kernel, handle, reader, signal) {
|
|
|
7791
7791
|
function fetchOp(kernel) {
|
|
7792
7792
|
const traits = /* @__PURE__ */ new Map();
|
|
7793
7793
|
const traitsOf = (url) => {
|
|
7794
|
-
const
|
|
7795
|
-
const known = traits.get(
|
|
7796
|
-
traits.set(
|
|
7794
|
+
const own2 = local2(url);
|
|
7795
|
+
const known = traits.get(own2) ?? kernel.json({ op: "net-traits", url });
|
|
7796
|
+
traits.set(own2, known);
|
|
7797
7797
|
known.catch(() => {
|
|
7798
|
-
traits.delete(
|
|
7798
|
+
traits.delete(own2);
|
|
7799
7799
|
});
|
|
7800
7800
|
return known;
|
|
7801
7801
|
};
|
|
@@ -8076,13 +8076,13 @@ function keyText(key, what) {
|
|
|
8076
8076
|
throw new JsCallError("EINVAL", what, "ERR_INVALID_ARG_TYPE: key must be a string or bytes");
|
|
8077
8077
|
}
|
|
8078
8078
|
function serveRequest(tls) {
|
|
8079
|
-
const
|
|
8079
|
+
const own2 = clientCert(tls, "listen").clientCert;
|
|
8080
8080
|
if (tls.select !== void 0 && typeof tls.select !== "function")
|
|
8081
8081
|
throw new JsCallError("EINVAL", "listen", "ERR_INVALID_ARG_TYPE: select must be a function");
|
|
8082
|
-
if (!
|
|
8082
|
+
if (!own2 && !tls.select)
|
|
8083
8083
|
throw new JsCallError("EINVAL", "listen", "ERR_INVALID_ARG_VALUE: a server needs cert and key");
|
|
8084
8084
|
return {
|
|
8085
|
-
...
|
|
8085
|
+
...own2 ? { cert: own2 } : {},
|
|
8086
8086
|
...tls.select ? { select: true } : {},
|
|
8087
8087
|
...tls.ca !== void 0 ? { ca: caList(tls.ca) } : {},
|
|
8088
8088
|
...tls.requestCert ? { requestCert: true } : {},
|
|
@@ -8171,9 +8171,9 @@ function withAlert(err) {
|
|
|
8171
8171
|
const alert = ALERT.exec(err.detail ?? "")?.[1];
|
|
8172
8172
|
return alert === void 0 ? err : Object.assign(err, { alert: Number(alert) });
|
|
8173
8173
|
}
|
|
8174
|
-
async function secureCall(
|
|
8174
|
+
async function secureCall(call3, what = "connect") {
|
|
8175
8175
|
try {
|
|
8176
|
-
return await
|
|
8176
|
+
return await call3();
|
|
8177
8177
|
} catch (err) {
|
|
8178
8178
|
const e = err;
|
|
8179
8179
|
const code2 = e.code === "EPROTO" && e.detail ? TLS_CODE.exec(e.detail)?.[1] : void 0;
|
|
@@ -8226,14 +8226,14 @@ async function selected(pick, offer, ms) {
|
|
|
8226
8226
|
}
|
|
8227
8227
|
}
|
|
8228
8228
|
async function serveOn(kernel, conn, req, signal = NEVER, pick, ms = HANDSHAKE_TIMEOUT_MS) {
|
|
8229
|
-
const
|
|
8229
|
+
const call3 = (body) => secureCall(async () => {
|
|
8230
8230
|
const r = await kernel.blocking(body, signal);
|
|
8231
8231
|
return r.ok && r.kind === "json" ? r.json : {};
|
|
8232
8232
|
}, "accept");
|
|
8233
|
-
let wire = await
|
|
8233
|
+
let wire = await call3({ op: "sock-tls-serve", fd: conn.fd, ...req });
|
|
8234
8234
|
while (wire.select) {
|
|
8235
8235
|
const { wire: choice, thrown } = await selected(pick, wire.select, ms);
|
|
8236
|
-
wire = await
|
|
8236
|
+
wire = await call3({ op: "sock-tls-select", fd: conn.fd, ...choice }).catch((err) => {
|
|
8237
8237
|
throw thrown ?? err;
|
|
8238
8238
|
});
|
|
8239
8239
|
}
|
|
@@ -8346,15 +8346,15 @@ function listenerOf(ops, fd, at, handshakes, tls) {
|
|
|
8346
8346
|
};
|
|
8347
8347
|
}
|
|
8348
8348
|
async function contextOf(kernel, io, options) {
|
|
8349
|
-
const
|
|
8350
|
-
if (!
|
|
8349
|
+
const own2 = clientCert(options ?? {}, "tlsContext").clientCert;
|
|
8350
|
+
if (!own2)
|
|
8351
8351
|
throw new JsCallError(
|
|
8352
8352
|
"EINVAL",
|
|
8353
8353
|
"tlsContext",
|
|
8354
8354
|
"ERR_INVALID_ARG_VALUE: a context needs cert and key"
|
|
8355
8355
|
);
|
|
8356
8356
|
const fd = await secureCall(
|
|
8357
|
-
() => kernel.json({ op: "sock-tls-context", cert:
|
|
8357
|
+
() => kernel.json({ op: "sock-tls-context", cert: own2 }),
|
|
8358
8358
|
"tlsContext"
|
|
8359
8359
|
);
|
|
8360
8360
|
let closed;
|
|
@@ -8375,6 +8375,13 @@ function resetOf(kernel, fd, closed, close) {
|
|
|
8375
8375
|
await close();
|
|
8376
8376
|
};
|
|
8377
8377
|
}
|
|
8378
|
+
function adoptOf(kernel, connection, listening, name2) {
|
|
8379
|
+
return async (fd) => {
|
|
8380
|
+
const req = { op: "sock-getopt", fd, level: SOL_SOCKET2, name: SO_ACCEPTCONN };
|
|
8381
|
+
if (await kernel.json(req) !== 1) return connection(fd);
|
|
8382
|
+
return listening(fd, await name2(fd, false));
|
|
8383
|
+
};
|
|
8384
|
+
}
|
|
8378
8385
|
function netOps(kernel, io, sync) {
|
|
8379
8386
|
const name2 = async (fd, peer) => addressOf(await kernel.json({ op: "sock-name", fd, peer }));
|
|
8380
8387
|
const connection = async (fd) => {
|
|
@@ -8475,9 +8482,9 @@ function netOps(kernel, io, sync) {
|
|
|
8475
8482
|
const done = await kernel.blocking(req, options.signal ?? NEVER);
|
|
8476
8483
|
return done.ok && done.kind === "json" ? done.json : void 0;
|
|
8477
8484
|
});
|
|
8478
|
-
const
|
|
8479
|
-
if (options.socket) return Object.assign(Object.create(options.socket), { tls:
|
|
8480
|
-
return Object.assign(await connection(r.fd), { tls:
|
|
8485
|
+
const session2 = sessionOf(r);
|
|
8486
|
+
if (options.socket) return Object.assign(Object.create(options.socket), { tls: session2 });
|
|
8487
|
+
return Object.assign(await connection(r.fd), { tls: session2 });
|
|
8481
8488
|
};
|
|
8482
8489
|
const lookup2 = async (name3, options = {}) => {
|
|
8483
8490
|
const family = options.family ?? 0;
|
|
@@ -8496,11 +8503,6 @@ function netOps(kernel, io, sync) {
|
|
|
8496
8503
|
});
|
|
8497
8504
|
return [...r.ok && r.kind === "json" ? r.json : []];
|
|
8498
8505
|
};
|
|
8499
|
-
const inetAt = (options) => ({
|
|
8500
|
-
family: "inet",
|
|
8501
|
-
host: options.host ?? "127.0.0.1",
|
|
8502
|
-
port: port(options.port ?? 0)
|
|
8503
|
-
});
|
|
8504
8506
|
const listenSync = (options = {}) => {
|
|
8505
8507
|
const lane = sync;
|
|
8506
8508
|
const addr = inetAt(options);
|
|
@@ -8520,6 +8522,7 @@ function netOps(kernel, io, sync) {
|
|
|
8520
8522
|
return {
|
|
8521
8523
|
sync: { listen: listenSync },
|
|
8522
8524
|
resolve: lookup2,
|
|
8525
|
+
adopt: adoptOf(kernel, connection, listener, name2),
|
|
8523
8526
|
listen: async (options = {}) => {
|
|
8524
8527
|
const tls = options.tls ? serveRequest(options.tls) : void 0;
|
|
8525
8528
|
return opened2(async (fd) => {
|
|
@@ -8542,7 +8545,7 @@ function netOps(kernel, io, sync) {
|
|
|
8542
8545
|
}
|
|
8543
8546
|
};
|
|
8544
8547
|
}
|
|
8545
|
-
var PEM, TLS_CODE, ALERT, SHUT_RD, SHUT_WR, LOOPBACK3, IPV4, NEVER, SOL_SOCKET2, SO_ERROR2, ALERTS, HANDSHAKE_TIMEOUT_MS, HANDSHAKES_MAX;
|
|
8548
|
+
var PEM, TLS_CODE, ALERT, SHUT_RD, SHUT_WR, LOOPBACK3, IPV4, NEVER, SOL_SOCKET2, SO_ERROR2, SO_ACCEPTCONN, ALERTS, HANDSHAKE_TIMEOUT_MS, HANDSHAKES_MAX, inetAt;
|
|
8546
8549
|
var init_js_net = __esm({
|
|
8547
8550
|
"src/process/js/js-net.ts"() {
|
|
8548
8551
|
"use strict";
|
|
@@ -8558,6 +8561,7 @@ var init_js_net = __esm({
|
|
|
8558
8561
|
NEVER = new AbortController().signal;
|
|
8559
8562
|
SOL_SOCKET2 = 1;
|
|
8560
8563
|
SO_ERROR2 = 4;
|
|
8564
|
+
SO_ACCEPTCONN = 30;
|
|
8561
8565
|
ALERTS = {
|
|
8562
8566
|
unrecognized_name: 112,
|
|
8563
8567
|
no_application_protocol: 120,
|
|
@@ -8567,6 +8571,11 @@ var init_js_net = __esm({
|
|
|
8567
8571
|
};
|
|
8568
8572
|
HANDSHAKE_TIMEOUT_MS = 12e4;
|
|
8569
8573
|
HANDSHAKES_MAX = 64;
|
|
8574
|
+
inetAt = (options) => ({
|
|
8575
|
+
family: "inet",
|
|
8576
|
+
host: options.host ?? "127.0.0.1",
|
|
8577
|
+
port: port(options.port ?? 0)
|
|
8578
|
+
});
|
|
8570
8579
|
}
|
|
8571
8580
|
});
|
|
8572
8581
|
|
|
@@ -8692,13 +8701,13 @@ function needsLoad(s, view, path) {
|
|
|
8692
8701
|
s.seen = view?.now();
|
|
8693
8702
|
return true;
|
|
8694
8703
|
}
|
|
8695
|
-
function loadedWatch(bridge,
|
|
8704
|
+
function loadedWatch(bridge, call3, path, st) {
|
|
8696
8705
|
const view = bridge.changes;
|
|
8697
|
-
return view && linkedWatch({ view, stat: () =>
|
|
8706
|
+
return view && linkedWatch({ view, stat: () => call3(() => bridge.stat(path())) }, st);
|
|
8698
8707
|
}
|
|
8699
|
-
function rangedFileOf(bridge,
|
|
8708
|
+
function rangedFileOf(bridge, call3, path, io) {
|
|
8700
8709
|
const seen = bridge.changes?.now();
|
|
8701
|
-
const stat = () =>
|
|
8710
|
+
const stat = () => call3(() => bridge.stat(path()));
|
|
8702
8711
|
const st = stat();
|
|
8703
8712
|
const watch = bridge.changes && linkedWatch({ view: bridge.changes, ino: st.ino, seen, stat }, st);
|
|
8704
8713
|
return new RangedFile(io, path(), st.size, st.version, watch);
|
|
@@ -8740,7 +8749,7 @@ function cachedStat(node, dir, view) {
|
|
|
8740
8749
|
}
|
|
8741
8750
|
return s.stat !== void 0 && (!dir || s.statAt === syncCallCount());
|
|
8742
8751
|
}
|
|
8743
|
-
function searchParents(Fs, node, bridge,
|
|
8752
|
+
function searchParents(Fs, node, bridge, call3) {
|
|
8744
8753
|
const cred = Fs.sliccCred;
|
|
8745
8754
|
if (!cred) return;
|
|
8746
8755
|
let cur = node.parent;
|
|
@@ -8749,12 +8758,12 @@ function searchParents(Fs, node, bridge, call2) {
|
|
|
8749
8758
|
if (st && st.uid !== void 0 && st.mode !== void 0) {
|
|
8750
8759
|
const perm = { uid: st.uid, gid: st.gid ?? 0, mode: st.mode & 4095 };
|
|
8751
8760
|
if (!permits(cred, perm, X_OK, true)) {
|
|
8752
|
-
|
|
8761
|
+
call3(() => bridge.access?.(liveNodePath(cur), X_OK, "eaccess"));
|
|
8753
8762
|
cur.live.stat = void 0;
|
|
8754
8763
|
return;
|
|
8755
8764
|
}
|
|
8756
8765
|
} else {
|
|
8757
|
-
|
|
8766
|
+
call3(() => bridge.access?.(liveNodePath(cur), X_OK, "eaccess"));
|
|
8758
8767
|
return;
|
|
8759
8768
|
}
|
|
8760
8769
|
if (cur === cur.parent) break;
|
|
@@ -8764,7 +8773,7 @@ function searchParents(Fs, node, bridge, call2) {
|
|
|
8764
8773
|
function linkedStates(bridgeOf) {
|
|
8765
8774
|
const opens = /* @__PURE__ */ new Map();
|
|
8766
8775
|
const byId = /* @__PURE__ */ new Map();
|
|
8767
|
-
const
|
|
8776
|
+
const idOf5 = (st) => st?.ino === void 0 || (st.nlink ?? 1) < 2 ? void 0 : `${st.dev}:${st.ino}`;
|
|
8768
8777
|
function know(s, id) {
|
|
8769
8778
|
s.id = id;
|
|
8770
8779
|
if (!byId.has(id)) byId.set(id, s);
|
|
@@ -8778,14 +8787,14 @@ function linkedStates(bridgeOf) {
|
|
|
8778
8787
|
return;
|
|
8779
8788
|
}
|
|
8780
8789
|
opens.set(s, node);
|
|
8781
|
-
const id =
|
|
8790
|
+
const id = idOf5(s.stat);
|
|
8782
8791
|
if (id !== void 0) know(s, id);
|
|
8783
8792
|
}
|
|
8784
8793
|
function sharedWith(node) {
|
|
8785
8794
|
const st = node.live.stat;
|
|
8786
8795
|
if (st?.ino === void 0) return void 0;
|
|
8787
8796
|
const id = `${st.dev}:${st.ino}`;
|
|
8788
|
-
if (!byId.has(id) &&
|
|
8797
|
+
if (!byId.has(id) && idOf5(st) !== void 0) {
|
|
8789
8798
|
for (const [s2, other] of opens) {
|
|
8790
8799
|
if (s2.id !== void 0 || s2.orphan) continue;
|
|
8791
8800
|
let st2;
|
|
@@ -8793,7 +8802,7 @@ function linkedStates(bridgeOf) {
|
|
|
8793
8802
|
st2 = bridgeOf(other).lstat(liveNodePath(other));
|
|
8794
8803
|
} catch {
|
|
8795
8804
|
}
|
|
8796
|
-
const known =
|
|
8805
|
+
const known = idOf5(st2);
|
|
8797
8806
|
if (known !== void 0) know(s2, known);
|
|
8798
8807
|
}
|
|
8799
8808
|
}
|
|
@@ -8801,7 +8810,7 @@ function linkedStates(bridgeOf) {
|
|
|
8801
8810
|
return s && s !== node.live && !stale(s) ? s : void 0;
|
|
8802
8811
|
}
|
|
8803
8812
|
const holder = (node) => opens.get(node.live) ?? node;
|
|
8804
|
-
return { opening: opening2, sharedWith, know, idOf:
|
|
8813
|
+
return { opening: opening2, sharedWith, know, idOf: idOf5, holder };
|
|
8805
8814
|
}
|
|
8806
8815
|
function filled(s, stat, asked) {
|
|
8807
8816
|
Object.assign(s, { stat, statAt: syncCallCount(), seenAt: syncEpoch(), ...asked });
|
|
@@ -8861,7 +8870,7 @@ function relinked(Fs, moving, to) {
|
|
|
8861
8870
|
Fs.hashAddNode?.(moving);
|
|
8862
8871
|
moving.live.stat = void 0;
|
|
8863
8872
|
}
|
|
8864
|
-
function renameFollower(Fs, bridgeOf,
|
|
8873
|
+
function renameFollower(Fs, bridgeOf, call3) {
|
|
8865
8874
|
const open = /* @__PURE__ */ new Set();
|
|
8866
8875
|
const seen = /* @__PURE__ */ new Map();
|
|
8867
8876
|
const follow3 = (node, missing2 = false) => {
|
|
@@ -8877,7 +8886,7 @@ function renameFollower(Fs, bridgeOf, call2) {
|
|
|
8877
8886
|
seen.set(bridge, now);
|
|
8878
8887
|
return false;
|
|
8879
8888
|
}
|
|
8880
|
-
const reply =
|
|
8889
|
+
const reply = call3(
|
|
8881
8890
|
() => ask(
|
|
8882
8891
|
since,
|
|
8883
8892
|
held2.map((n) => liveNodePath(n))
|
|
@@ -8980,7 +8989,7 @@ function createHelpers(Fs, ops) {
|
|
|
8980
8989
|
const dirty = /* @__PURE__ */ new Set();
|
|
8981
8990
|
const handled = /* @__PURE__ */ new Set();
|
|
8982
8991
|
const linked = linkedStates(bridgeOf);
|
|
8983
|
-
const renames = renameFollower(Fs, bridgeOf, (fn) =>
|
|
8992
|
+
const renames = renameFollower(Fs, bridgeOf, (fn) => call3(fn));
|
|
8984
8993
|
function markDirty(node) {
|
|
8985
8994
|
node.live.dirty = true;
|
|
8986
8995
|
dirty.add(node);
|
|
@@ -9000,7 +9009,7 @@ function createHelpers(Fs, ops) {
|
|
|
9000
9009
|
}
|
|
9001
9010
|
}
|
|
9002
9011
|
}
|
|
9003
|
-
function
|
|
9012
|
+
function call3(fn) {
|
|
9004
9013
|
try {
|
|
9005
9014
|
return fn();
|
|
9006
9015
|
} catch (err) {
|
|
@@ -9009,7 +9018,7 @@ function createHelpers(Fs, ops) {
|
|
|
9009
9018
|
}
|
|
9010
9019
|
function metadataCall(fn) {
|
|
9011
9020
|
try {
|
|
9012
|
-
|
|
9021
|
+
call3(fn);
|
|
9013
9022
|
} catch (err) {
|
|
9014
9023
|
if (err.errno !== wasiErrno("ENOSYS")) throw err;
|
|
9015
9024
|
}
|
|
@@ -9029,7 +9038,7 @@ function createHelpers(Fs, ops) {
|
|
|
9029
9038
|
const view = bridgeOf(node).changes;
|
|
9030
9039
|
if (!cachedStat(node, Fs.isDir(node.mode), view)) {
|
|
9031
9040
|
const asked = { statGen: view?.now(), filledAt: performance.now() };
|
|
9032
|
-
const st =
|
|
9041
|
+
const st = call3(() => bridgeOf(node).lstat(liveNodePath(linked.holder(node))));
|
|
9033
9042
|
if (!adopted(node, st, asked)) return node.live.bound;
|
|
9034
9043
|
}
|
|
9035
9044
|
return node.live.stat;
|
|
@@ -9042,9 +9051,9 @@ function createHelpers(Fs, ops) {
|
|
|
9042
9051
|
const s = node.live;
|
|
9043
9052
|
if (!needsLoad(s, bridgeOf(node).changes, () => liveNodePath(linked.holder(node)))) return;
|
|
9044
9053
|
const path = () => liveNodePath(linked.holder(node));
|
|
9045
|
-
const bytes =
|
|
9054
|
+
const bytes = call3(() => fileIo(node).readFile(path()));
|
|
9046
9055
|
Object.assign(s, { data: bytes, len: bytes.length, loaded: true });
|
|
9047
|
-
s.watch = loadedWatch(bridgeOf(node),
|
|
9056
|
+
s.watch = loadedWatch(bridgeOf(node), call3, path, s.stat ?? { size: bytes.length });
|
|
9048
9057
|
}
|
|
9049
9058
|
function rangedOf(node) {
|
|
9050
9059
|
const s = node.live;
|
|
@@ -9057,7 +9066,7 @@ function createHelpers(Fs, ops) {
|
|
|
9057
9066
|
pwrite: (_, at, bytes, transfer) => file().pwrite(path(), at, bytes, transfer),
|
|
9058
9067
|
truncate: (_, size) => file().truncate(path(), size)
|
|
9059
9068
|
};
|
|
9060
|
-
s.ranged = rangedFileOf(bridge,
|
|
9069
|
+
s.ranged = rangedFileOf(bridge, call3, path, io);
|
|
9061
9070
|
return s.ranged;
|
|
9062
9071
|
}
|
|
9063
9072
|
function ensureCapacity(node, need) {
|
|
@@ -9073,7 +9082,7 @@ function createHelpers(Fs, ops) {
|
|
|
9073
9082
|
const s = node.live;
|
|
9074
9083
|
if (!s.dirty || stale(s) || !(s.data || s.ranged)) return;
|
|
9075
9084
|
const whole = () => s.data.slice(0, s.len);
|
|
9076
|
-
const write2 = () => s.ranged ?
|
|
9085
|
+
const write2 = () => s.ranged ? call3(() => s.ranged?.flush()) : call3(() => fileIo(node).writeFile(liveNodePath(linked.holder(node)), whole(), true));
|
|
9077
9086
|
followingOnce(write2, () => renames.follow(node, true));
|
|
9078
9087
|
s.dirty = false;
|
|
9079
9088
|
s.stat = void 0;
|
|
@@ -9105,16 +9114,16 @@ function createHelpers(Fs, ops) {
|
|
|
9105
9114
|
const path = liveNodePath(node);
|
|
9106
9115
|
const bridge = bridgeOf(node);
|
|
9107
9116
|
if (statOf(node).ranged && bridge.truncate) {
|
|
9108
|
-
|
|
9117
|
+
call3(() => bridge.truncate?.(path, size));
|
|
9109
9118
|
s.stat = void 0;
|
|
9110
9119
|
return;
|
|
9111
9120
|
}
|
|
9112
9121
|
const bytes = new Uint8Array(size);
|
|
9113
9122
|
if (size > 0) {
|
|
9114
|
-
const cur =
|
|
9123
|
+
const cur = call3(() => bridgeOf(node).readFile(path));
|
|
9115
9124
|
bytes.set(cur.subarray(0, Math.min(size, cur.length)));
|
|
9116
9125
|
}
|
|
9117
|
-
|
|
9126
|
+
call3(() => bridgeOf(node).writeFile(path, bytes));
|
|
9118
9127
|
s.stat = void 0;
|
|
9119
9128
|
}
|
|
9120
9129
|
return {
|
|
@@ -9123,7 +9132,7 @@ function createHelpers(Fs, ops) {
|
|
|
9123
9132
|
handled,
|
|
9124
9133
|
linked,
|
|
9125
9134
|
...renames,
|
|
9126
|
-
call:
|
|
9135
|
+
call: call3,
|
|
9127
9136
|
metadataCall,
|
|
9128
9137
|
makeNode,
|
|
9129
9138
|
statOf,
|
|
@@ -9165,7 +9174,7 @@ function orphaned(h, node, st) {
|
|
|
9165
9174
|
if (id !== void 0) h.linked.know(s, id);
|
|
9166
9175
|
}
|
|
9167
9176
|
function createNodeOps(h) {
|
|
9168
|
-
const { Fs, bridgeOf, call:
|
|
9177
|
+
const { Fs, bridgeOf, call: call3, metadataCall, makeNode, statOf, childPath, flushNode, truncate } = h;
|
|
9169
9178
|
const { ensureLoaded } = h;
|
|
9170
9179
|
const setTimes = (node, path, atime, mtime) => {
|
|
9171
9180
|
const now = Fs.sliccTouch === true;
|
|
@@ -9192,7 +9201,7 @@ function createNodeOps(h) {
|
|
|
9192
9201
|
node.live.stat = void 0;
|
|
9193
9202
|
const cached2 = owned && cachedStat(node, Fs.isDir(node.mode), bridgeOf(node).changes);
|
|
9194
9203
|
const st = statOf(node);
|
|
9195
|
-
if (cached2) searchParents(Fs, node, bridgeOf(node),
|
|
9204
|
+
if (cached2) searchParents(Fs, node, bridgeOf(node), call3);
|
|
9196
9205
|
const s = node.live;
|
|
9197
9206
|
const size = Fs.isDir(node.mode) ? 4096 : s.ranged?.size() ?? (s.loaded ? s.len : st.size);
|
|
9198
9207
|
const mtime = new Date(st.mtimeMs ?? 0);
|
|
@@ -9240,7 +9249,7 @@ function createNodeOps(h) {
|
|
|
9240
9249
|
const listed2 = parent.live.listed?.get(name2);
|
|
9241
9250
|
parent.live.listed?.delete(name2);
|
|
9242
9251
|
const asked = listed2 ? listing(parent.live) : asking(bridgeOf(parent));
|
|
9243
|
-
const st = listed2 ??
|
|
9252
|
+
const st = listed2 ?? call3(() => bridgeOf(parent).lstat(childPath(parent, name2)));
|
|
9244
9253
|
return answeredAt(makeNode(parent, name2, st), asked);
|
|
9245
9254
|
},
|
|
9246
9255
|
mknod(parent, name2, mode) {
|
|
@@ -9249,17 +9258,17 @@ function createNodeOps(h) {
|
|
|
9249
9258
|
const bridge = bridgeOf(parent);
|
|
9250
9259
|
const perm = bridge.owners ? mode & PERM_MASK : void 0;
|
|
9251
9260
|
if (Fs.isDir(mode) && perm !== void 0) {
|
|
9252
|
-
|
|
9261
|
+
call3(() => bridge.mkdir(path, perm));
|
|
9253
9262
|
} else if (Fs.isDir(mode)) {
|
|
9254
|
-
|
|
9263
|
+
call3(() => bridge.mkdir(path));
|
|
9255
9264
|
const masked = mode & PERM_MASK & ~UMASK2;
|
|
9256
9265
|
if (masked !== DEFAULT_DIR_PERM) metadataCall(() => bridge.chmod(path, masked));
|
|
9257
9266
|
} else if (Fs.isFile(mode)) {
|
|
9258
|
-
|
|
9267
|
+
call3(
|
|
9259
9268
|
() => bridge.create ? bridge.create(path, perm, opening.get(h.Fs) > 0) : bridge.writeFile(path, new Uint8Array(0))
|
|
9260
9269
|
);
|
|
9261
9270
|
} else if ((mode & S_IFMT2) === S_IFIFO2 && bridge.mkfifo) {
|
|
9262
|
-
|
|
9271
|
+
call3(() => bridge.mkfifo?.(path, mode & PERM_MASK));
|
|
9263
9272
|
} else {
|
|
9264
9273
|
throw new Fs.ErrnoError(wasiErrno("EPERM"));
|
|
9265
9274
|
}
|
|
@@ -9301,17 +9310,17 @@ function createNodeOps(h) {
|
|
|
9301
9310
|
if (ranged) ranged.pin();
|
|
9302
9311
|
else ensureLoaded(open);
|
|
9303
9312
|
}
|
|
9304
|
-
|
|
9313
|
+
call3(() => bridgeOf(parent).unlink(childPath(parent, name2)));
|
|
9305
9314
|
if (open && st) orphaned(h, open, st);
|
|
9306
9315
|
},
|
|
9307
9316
|
rmdir(parent, name2) {
|
|
9308
9317
|
parent.live.listed = void 0;
|
|
9309
|
-
|
|
9318
|
+
call3(() => bridgeOf(parent).rmdir(childPath(parent, name2)));
|
|
9310
9319
|
},
|
|
9311
9320
|
readdir(node) {
|
|
9312
9321
|
const listedAt = performance.now();
|
|
9313
9322
|
const listedGen = bridgeOf(node).changes?.now();
|
|
9314
|
-
const listed2 =
|
|
9323
|
+
const listed2 = call3(() => bridgeOf(node).readdirStat(liveNodePath(node)));
|
|
9315
9324
|
node.live.listed = /* @__PURE__ */ new Map();
|
|
9316
9325
|
Object.assign(node.live, { listedAt, listedGen });
|
|
9317
9326
|
for (const [name2, st] of listed2) if (st) node.live.listed.set(name2, st);
|
|
@@ -9320,7 +9329,7 @@ function createNodeOps(h) {
|
|
|
9320
9329
|
symlink(parent, newName, target) {
|
|
9321
9330
|
parent.live.listed = void 0;
|
|
9322
9331
|
const path = childPath(parent, newName);
|
|
9323
|
-
|
|
9332
|
+
call3(() => bridgeOf(parent).symlink(target, path));
|
|
9324
9333
|
return makeNode(parent, newName, {
|
|
9325
9334
|
isFile: false,
|
|
9326
9335
|
isDirectory: false,
|
|
@@ -9333,9 +9342,9 @@ function createNodeOps(h) {
|
|
|
9333
9342
|
const bridge = bridgeOf(node);
|
|
9334
9343
|
const path = liveNodePath(node);
|
|
9335
9344
|
if (bridge.links && Fs.sliccReading !== node) {
|
|
9336
|
-
|
|
9345
|
+
call3(() => bridge.access?.(path, 0, "follow", true));
|
|
9337
9346
|
}
|
|
9338
|
-
return
|
|
9347
|
+
return call3(() => bridge.readlink(path));
|
|
9339
9348
|
}
|
|
9340
9349
|
};
|
|
9341
9350
|
}
|
|
@@ -9684,13 +9693,13 @@ function liveRoot(Fs, bridge) {
|
|
|
9684
9693
|
const memfs = root.memfs ?? root.node_ops;
|
|
9685
9694
|
const live = plugin.node_ops;
|
|
9686
9695
|
root.memfs = memfs;
|
|
9687
|
-
const
|
|
9696
|
+
const own2 = (name2) => Object.hasOwn(root.contents ?? {}, name2);
|
|
9688
9697
|
root.node_ops = {
|
|
9689
9698
|
...memfs,
|
|
9690
9699
|
lookup: (parent, name2) => live.lookup(parent, name2),
|
|
9691
9700
|
mknod: (parent, name2, mode, dev) => live.mknod(parent, name2, mode, dev),
|
|
9692
9701
|
unlink: (parent, name2) => live.unlink(parent, name2),
|
|
9693
|
-
rmdir: (parent, name2) => (
|
|
9702
|
+
rmdir: (parent, name2) => (own2(name2) ? memfs : live).rmdir(parent, name2),
|
|
9694
9703
|
symlink: (parent, name2, target) => live.symlink(parent, name2, target),
|
|
9695
9704
|
rename: (node, dir, name2) => (node.live ? live : memfs).rename(node, dir, name2),
|
|
9696
9705
|
readdir(node) {
|
|
@@ -9834,14 +9843,14 @@ function guardRenames(Fs) {
|
|
|
9834
9843
|
rename(from, to);
|
|
9835
9844
|
};
|
|
9836
9845
|
}
|
|
9837
|
-
function
|
|
9846
|
+
function idOf3(value2) {
|
|
9838
9847
|
return value2 === -1 || value2 === 4294967295 ? void 0 : value2 >>> 0;
|
|
9839
9848
|
}
|
|
9840
9849
|
function chownHeld(Fs, node, s, uid, gid) {
|
|
9841
9850
|
const bridge = node.mount.opts.bridge;
|
|
9842
9851
|
const handle = s.handle;
|
|
9843
9852
|
try {
|
|
9844
|
-
bridge.chown?.(liveNodePath(node),
|
|
9853
|
+
bridge.chown?.(liveNodePath(node), idOf3(uid), idOf3(gid), false, handle);
|
|
9845
9854
|
} catch (err) {
|
|
9846
9855
|
throw toErrno(Fs, err);
|
|
9847
9856
|
}
|
|
@@ -9863,7 +9872,7 @@ function useLiveChown(Fs) {
|
|
|
9863
9872
|
const node = typeof path === "string" ? Fs.lookupPath(path, { follow: !dontFollow }).node : path;
|
|
9864
9873
|
if (!node.live || node.live.orphan) return chown(path, uid, gid, dontFollow);
|
|
9865
9874
|
try {
|
|
9866
|
-
node.mount.opts.bridge.chown?.(liveNodePath(node),
|
|
9875
|
+
node.mount.opts.bridge.chown?.(liveNodePath(node), idOf3(uid), idOf3(gid));
|
|
9867
9876
|
} catch (err) {
|
|
9868
9877
|
throw toErrno(Fs, err);
|
|
9869
9878
|
}
|
|
@@ -10289,8 +10298,8 @@ function kernelTimer(setitimer, timer) {
|
|
|
10289
10298
|
}
|
|
10290
10299
|
function syscallOf(glue, name2, value2) {
|
|
10291
10300
|
const names = Object.keys(IMPORT_NAMES);
|
|
10292
|
-
const
|
|
10293
|
-
if (
|
|
10301
|
+
const own2 = names.find((key) => glue[key] !== void 0 && glue[key] === value2);
|
|
10302
|
+
if (own2) return own2;
|
|
10294
10303
|
return typeof value2 === "function" ? names.find((key) => glue[key] !== void 0 && IMPORT_NAMES[key] === name2) : void 0;
|
|
10295
10304
|
}
|
|
10296
10305
|
function wrapCloexecSyscalls(imports, glue, deps) {
|
|
@@ -10314,9 +10323,9 @@ function pathOpensLinks(Fs) {
|
|
|
10314
10323
|
fs.mayOpen = (node, flags) => flags & O_PATH2 && isLink.call(fs, node.mode) ? 0 : mayOpen.call(fs, node, flags);
|
|
10315
10324
|
}
|
|
10316
10325
|
function importKey(namespace, name2, glue) {
|
|
10317
|
-
const
|
|
10318
|
-
if (typeof
|
|
10319
|
-
const found = Object.keys(namespace).find((k) => namespace[k] ===
|
|
10326
|
+
const own2 = glue?.[name2];
|
|
10327
|
+
if (typeof own2 === "function") {
|
|
10328
|
+
const found = Object.keys(namespace).find((k) => namespace[k] === own2);
|
|
10320
10329
|
if (found !== void 0) return found;
|
|
10321
10330
|
}
|
|
10322
10331
|
const literal = LITERALS[name2];
|
|
@@ -10354,12 +10363,12 @@ function kernelUmask(imports, deps) {
|
|
|
10354
10363
|
glue,
|
|
10355
10364
|
(mknodat) => (dirfd, path, mode, dev) => mknodat(dirfd, path, mode & ~umask, dev)
|
|
10356
10365
|
);
|
|
10357
|
-
wrapImport(imports, "umask", glue, (
|
|
10358
|
-
|
|
10366
|
+
wrapImport(imports, "umask", glue, (own2) => {
|
|
10367
|
+
own2(umask);
|
|
10359
10368
|
return (mask) => {
|
|
10360
10369
|
const old = umask;
|
|
10361
10370
|
umask = mask & 511;
|
|
10362
|
-
|
|
10371
|
+
own2(umask);
|
|
10363
10372
|
deps.set(umask);
|
|
10364
10373
|
return old;
|
|
10365
10374
|
};
|
|
@@ -10424,8 +10433,8 @@ function namespaces(imports) {
|
|
|
10424
10433
|
return [...seen];
|
|
10425
10434
|
}
|
|
10426
10435
|
function keyOf(namespace, name2, glue) {
|
|
10427
|
-
const
|
|
10428
|
-
const found = typeof
|
|
10436
|
+
const own2 = glue?.[name2];
|
|
10437
|
+
const found = typeof own2 === "function" ? Object.keys(namespace).find((k) => namespace[k] === own2) : void 0;
|
|
10429
10438
|
return found ?? (typeof namespace[name2] === "function" ? name2 : void 0);
|
|
10430
10439
|
}
|
|
10431
10440
|
function syncFsync(imports, fs, glue) {
|
|
@@ -10659,12 +10668,12 @@ function useFifoOpens(Fs, attach) {
|
|
|
10659
10668
|
function useDevRemoval(Fs) {
|
|
10660
10669
|
const fs = Fs;
|
|
10661
10670
|
for (const name2 of ["unlink", "rmdir"]) {
|
|
10662
|
-
const
|
|
10663
|
-
if (typeof
|
|
10671
|
+
const remove2 = fs[name2];
|
|
10672
|
+
if (typeof remove2 !== "function") continue;
|
|
10664
10673
|
fs[name2] = (path) => {
|
|
10665
10674
|
const refused3 = devRemoval(absoluteOf(path, Fs.cwd()), fs.sliccCred);
|
|
10666
10675
|
if (refused3) throw new Fs.ErrnoError(wasiErrno(refused3));
|
|
10667
|
-
|
|
10676
|
+
remove2.call(Fs, path);
|
|
10668
10677
|
};
|
|
10669
10678
|
}
|
|
10670
10679
|
}
|
|
@@ -10802,12 +10811,12 @@ function cString(memory, at) {
|
|
|
10802
10811
|
function baseOf3(Fs, dirfd) {
|
|
10803
10812
|
return dirfd === AT_FDCWD2 ? Fs.cwd?.() ?? "/" : Fs.getStream?.(dirfd)?.path ?? "/";
|
|
10804
10813
|
}
|
|
10805
|
-
function readonlyRefusal(Fs, memory,
|
|
10806
|
-
if (!(
|
|
10814
|
+
function readonlyRefusal(Fs, memory, call3) {
|
|
10815
|
+
if (!(call3.amode & W_ACCESS)) return 0;
|
|
10807
10816
|
try {
|
|
10808
|
-
const name2 = cString(memory,
|
|
10809
|
-
const abs = name2.startsWith("/") ? name2 : `${baseOf3(Fs,
|
|
10810
|
-
const follow3 = (
|
|
10817
|
+
const name2 = cString(memory, call3.path);
|
|
10818
|
+
const abs = name2.startsWith("/") ? name2 : `${baseOf3(Fs, call3.dirfd)}/${name2}`;
|
|
10819
|
+
const follow3 = (call3.flags & AT_SYMLINK_NOFOLLOW2) === 0;
|
|
10811
10820
|
const { node } = Fs.lookupPath.call(Fs, abs, {
|
|
10812
10821
|
follow: follow3
|
|
10813
10822
|
});
|
|
@@ -10819,15 +10828,15 @@ function readonlyRefusal(Fs, memory, call2) {
|
|
|
10819
10828
|
return 0;
|
|
10820
10829
|
}
|
|
10821
10830
|
}
|
|
10822
|
-
function kernelChecks(Fs, memory,
|
|
10823
|
-
const name2 = cString(memory,
|
|
10824
|
-
const abs = name2.startsWith("/") ? name2 : `${baseOf3(Fs,
|
|
10831
|
+
function kernelChecks(Fs, memory, call3) {
|
|
10832
|
+
const name2 = cString(memory, call3.path);
|
|
10833
|
+
const abs = name2.startsWith("/") ? name2 : `${baseOf3(Fs, call3.dirfd)}/${name2}`;
|
|
10825
10834
|
const lookupPath = Fs.lookupPath;
|
|
10826
|
-
const { node } = lookupPath.call(Fs, abs, { follow: (
|
|
10835
|
+
const { node } = lookupPath.call(Fs, abs, { follow: (call3.flags & AT_SYMLINK_NOFOLLOW2) === 0 });
|
|
10827
10836
|
const bridge = node.live ? node.mount.opts.bridge : void 0;
|
|
10828
10837
|
if (!bridge?.owners || !bridge.access) return 0;
|
|
10829
|
-
const kind =
|
|
10830
|
-
bridge.access(liveNodePath(node),
|
|
10838
|
+
const kind = call3.flags & AT_EACCESS2 ? "eaccess" : "access";
|
|
10839
|
+
bridge.access(liveNodePath(node), call3.amode, kind, (call3.flags & AT_SYMLINK_NOFOLLOW2) !== 0);
|
|
10831
10840
|
return 0;
|
|
10832
10841
|
}
|
|
10833
10842
|
function goneCwdGetcwd(imports, fs, glue) {
|
|
@@ -10835,18 +10844,18 @@ function goneCwdGetcwd(imports, fs, glue) {
|
|
|
10835
10844
|
imports,
|
|
10836
10845
|
"getcwd",
|
|
10837
10846
|
glue,
|
|
10838
|
-
(
|
|
10847
|
+
(own2) => (...args) => fs()?.sliccCwdGone?.() === true ? -44 : own2(...args),
|
|
10839
10848
|
true
|
|
10840
10849
|
);
|
|
10841
10850
|
}
|
|
10842
10851
|
function kernelAccess(imports, fs, memory, glue) {
|
|
10843
|
-
wrapImport(imports, "faccessat", glue, (
|
|
10852
|
+
wrapImport(imports, "faccessat", glue, (own2) => (dirfd, path, amode, flags) => {
|
|
10844
10853
|
const Fs = fs();
|
|
10845
10854
|
const heap = memory();
|
|
10846
|
-
const
|
|
10847
|
-
const refused3 = Fs?.lookupPath && heap ? readonlyRefusal(Fs, heap,
|
|
10855
|
+
const call3 = { dirfd, path, amode: amode & 7, flags };
|
|
10856
|
+
const refused3 = Fs?.lookupPath && heap ? readonlyRefusal(Fs, heap, call3) : 0;
|
|
10848
10857
|
if (refused3 !== 0) return refused3;
|
|
10849
|
-
const rc =
|
|
10858
|
+
const rc = own2(dirfd, path, amode, flags);
|
|
10850
10859
|
if (rc !== 0 || !Fs?.lookupPath || !heap) return rc;
|
|
10851
10860
|
try {
|
|
10852
10861
|
return kernelChecks(Fs, heap, { dirfd, path, amode: amode & 7, flags });
|
|
@@ -10860,10 +10869,10 @@ function kernelLink(imports, fs, memory, glue) {
|
|
|
10860
10869
|
imports,
|
|
10861
10870
|
"linkat",
|
|
10862
10871
|
glue,
|
|
10863
|
-
(
|
|
10872
|
+
(own2) => (olddirfd, oldpath, newdirfd, newpath, flags) => {
|
|
10864
10873
|
const Fs = fs();
|
|
10865
10874
|
const heap = memory();
|
|
10866
|
-
if (!Fs?.lookupPath || !heap) return
|
|
10875
|
+
if (!Fs?.lookupPath || !heap) return own2(olddirfd, oldpath, newdirfd, newpath, flags);
|
|
10867
10876
|
const at = (dirfd, ptr) => {
|
|
10868
10877
|
const name2 = cString(heap, ptr);
|
|
10869
10878
|
return name2.startsWith("/") ? name2 : `${baseOf3(Fs, dirfd)}/${name2}`;
|
|
@@ -10876,7 +10885,7 @@ function kernelLink(imports, fs, memory, glue) {
|
|
|
10876
10885
|
} catch (err) {
|
|
10877
10886
|
return -errnoOf2(err);
|
|
10878
10887
|
}
|
|
10879
|
-
return
|
|
10888
|
+
return own2(olddirfd, oldpath, newdirfd, newpath, flags);
|
|
10880
10889
|
},
|
|
10881
10890
|
true
|
|
10882
10891
|
);
|
|
@@ -10903,28 +10912,28 @@ function devCreations(imports, fs, memory, glue) {
|
|
|
10903
10912
|
imports,
|
|
10904
10913
|
"openat",
|
|
10905
10914
|
glue,
|
|
10906
|
-
(
|
|
10915
|
+
(own2) => (dirfd, path, flags, varargs) => flags & O_CREAT && check(dirfd, path) || own2(dirfd, path, flags, varargs),
|
|
10907
10916
|
true
|
|
10908
10917
|
);
|
|
10909
10918
|
wrapImport(
|
|
10910
10919
|
imports,
|
|
10911
10920
|
"mkdirat",
|
|
10912
10921
|
glue,
|
|
10913
|
-
(
|
|
10922
|
+
(own2) => (dirfd, path, mode) => check(dirfd, path) || own2(dirfd, path, mode),
|
|
10914
10923
|
true
|
|
10915
10924
|
);
|
|
10916
10925
|
wrapImport(
|
|
10917
10926
|
imports,
|
|
10918
10927
|
"mknodat",
|
|
10919
10928
|
glue,
|
|
10920
|
-
(
|
|
10929
|
+
(own2) => (dirfd, path, mode, dev) => check(dirfd, path) || own2(dirfd, path, mode, dev),
|
|
10921
10930
|
true
|
|
10922
10931
|
);
|
|
10923
10932
|
wrapImport(
|
|
10924
10933
|
imports,
|
|
10925
10934
|
"symlinkat",
|
|
10926
10935
|
glue,
|
|
10927
|
-
(
|
|
10936
|
+
(own2) => (target, dirfd, path) => check(dirfd, path) || own2(target, dirfd, path),
|
|
10928
10937
|
true
|
|
10929
10938
|
);
|
|
10930
10939
|
}
|
|
@@ -10935,9 +10944,9 @@ function kernelUname(imports, hostname, memory, glue) {
|
|
|
10935
10944
|
imports,
|
|
10936
10945
|
"uname",
|
|
10937
10946
|
glue,
|
|
10938
|
-
(
|
|
10947
|
+
(own2) => (buf) => {
|
|
10939
10948
|
const heap = memory();
|
|
10940
|
-
if (!buf || !heap) return
|
|
10949
|
+
if (!buf || !heap) return own2(buf);
|
|
10941
10950
|
const bytes = new Uint8Array(heap.buffer, buf, UTS_FIELD * fields.length);
|
|
10942
10951
|
bytes.fill(0);
|
|
10943
10952
|
encoded.forEach((field2, i) => {
|
|
@@ -11286,8 +11295,8 @@ function withPidFiles(names, extra) {
|
|
|
11286
11295
|
}
|
|
11287
11296
|
function exeNodes(fresh, info, error, self) {
|
|
11288
11297
|
return {
|
|
11289
|
-
exeLink: (parent, target,
|
|
11290
|
-
const of = info(target,
|
|
11298
|
+
exeLink: (parent, target, own2 = false) => {
|
|
11299
|
+
const of = info(target, own2);
|
|
11291
11300
|
const exe = of?.exe;
|
|
11292
11301
|
if (!of || exe === void 0) throw error();
|
|
11293
11302
|
const link = fresh(parent, "exe", LINK_MODE2);
|
|
@@ -11297,7 +11306,7 @@ function exeNodes(fresh, info, error, self) {
|
|
|
11297
11306
|
};
|
|
11298
11307
|
return link;
|
|
11299
11308
|
},
|
|
11300
|
-
hasExe: (target,
|
|
11309
|
+
hasExe: (target, own2 = false) => info(target, own2)?.exe === void 0 ? [] : ["exe"]
|
|
11301
11310
|
};
|
|
11302
11311
|
}
|
|
11303
11312
|
function useProcfs(Fs, sys, pid, memory = memorySource()) {
|
|
@@ -11348,11 +11357,11 @@ function useProcfs(Fs, sys, pid, memory = memorySource()) {
|
|
|
11348
11357
|
};
|
|
11349
11358
|
return node;
|
|
11350
11359
|
};
|
|
11351
|
-
const
|
|
11352
|
-
const infoOf = (target) =>
|
|
11353
|
-
const pidContent = (target, name2,
|
|
11360
|
+
const find2 = (processes2, target, own2) => (own2 ? processes2.find((p) => p.tid === target) : void 0) ?? processes2.find((p) => p.pid === target || p.tid === target);
|
|
11361
|
+
const infoOf = (target) => find2(procList().processes, target, false);
|
|
11362
|
+
const pidContent = (target, name2, own2 = false) => () => {
|
|
11354
11363
|
const listing2 = procList();
|
|
11355
|
-
const info =
|
|
11364
|
+
const info = find2(listing2.processes, target, own2);
|
|
11356
11365
|
if (!info) throw error();
|
|
11357
11366
|
return pidFile(name2, info, listing2.boot);
|
|
11358
11367
|
};
|
|
@@ -11366,7 +11375,7 @@ function useProcfs(Fs, sys, pid, memory = memorySource()) {
|
|
|
11366
11375
|
dir.node_ops.readdir = () => [".", "..", ...Object.keys(tree)];
|
|
11367
11376
|
return dir;
|
|
11368
11377
|
};
|
|
11369
|
-
const exe = exeNodes(fresh, (at,
|
|
11378
|
+
const exe = exeNodes(fresh, (at, own2) => find2(procList().processes, at, own2), error, pid);
|
|
11370
11379
|
const pidNames = (names) => withPidFiles(names, exe.hasExe(pid, true));
|
|
11371
11380
|
const pidDir = (name2, target) => {
|
|
11372
11381
|
const dir = fresh(proc, name2, DIR_MODE2);
|
|
@@ -11449,7 +11458,7 @@ function useProcfs(Fs, sys, pid, memory = memorySource()) {
|
|
|
11449
11458
|
};
|
|
11450
11459
|
hashRemoveNode.call(Fs, self);
|
|
11451
11460
|
const link = fresh(proc, "self", LINK_MODE2);
|
|
11452
|
-
const shownPid = () => String(
|
|
11461
|
+
const shownPid = () => String(find2(procList().processes, pid, true)?.pid ?? pid);
|
|
11453
11462
|
link.node_ops.readlink = shownPid;
|
|
11454
11463
|
const procLookup = proc.node_ops.lookup;
|
|
11455
11464
|
proc.node_ops.lookup = (parent, name2) => name2 === "self" ? link : name2 === shownPid() ? self : procLookup(parent, name2);
|
|
@@ -11677,7 +11686,7 @@ function shownLink(fs, tree, q) {
|
|
|
11677
11686
|
}
|
|
11678
11687
|
}
|
|
11679
11688
|
function routing(fs, tree, toProc, shadowing) {
|
|
11680
|
-
return (p, inner,
|
|
11689
|
+
return (p, inner, own2, follow3 = true, outside) => {
|
|
11681
11690
|
const proc = (q) => {
|
|
11682
11691
|
const target = outside ? current(fs, tree, q) : void 0;
|
|
11683
11692
|
return target === void 0 ? inner(q) : outside(target);
|
|
@@ -11688,7 +11697,7 @@ function routing(fs, tree, toProc, shadowing) {
|
|
|
11688
11697
|
if (real !== void 0) return proc(real);
|
|
11689
11698
|
}
|
|
11690
11699
|
try {
|
|
11691
|
-
return
|
|
11700
|
+
return own2();
|
|
11692
11701
|
} catch (err) {
|
|
11693
11702
|
if (directMiss(err, p)) throw err;
|
|
11694
11703
|
const real = toProc(p, follow3);
|
|
@@ -11704,14 +11713,14 @@ function procfsBridge(fs, tree) {
|
|
|
11704
11713
|
const readOnly2 = guard(toProc, shadowing);
|
|
11705
11714
|
const snapshots = /* @__PURE__ */ new Map();
|
|
11706
11715
|
let lastSnapshot = 0;
|
|
11707
|
-
const
|
|
11716
|
+
const snapshot2 = (q) => {
|
|
11708
11717
|
lastSnapshot--;
|
|
11709
11718
|
snapshots.set(lastSnapshot, tree.read(q));
|
|
11710
11719
|
return lastSnapshot;
|
|
11711
11720
|
};
|
|
11712
11721
|
const late = (p) => {
|
|
11713
11722
|
const q = toProc(p, true);
|
|
11714
|
-
return q === void 0 ? void 0 :
|
|
11723
|
+
return q === void 0 ? void 0 : snapshot2(q);
|
|
11715
11724
|
};
|
|
11716
11725
|
const over = {
|
|
11717
11726
|
readFile: (p) => via(
|
|
@@ -11744,14 +11753,14 @@ function procfsBridge(fs, tree) {
|
|
|
11744
11753
|
),
|
|
11745
11754
|
exists: (p) => {
|
|
11746
11755
|
if (inProc(p)) return tree.exists(p);
|
|
11747
|
-
const
|
|
11756
|
+
const probe2 = () => {
|
|
11748
11757
|
try {
|
|
11749
11758
|
return toProc(p, true);
|
|
11750
11759
|
} catch {
|
|
11751
11760
|
return null;
|
|
11752
11761
|
}
|
|
11753
11762
|
};
|
|
11754
|
-
const real = shadowing() ?
|
|
11763
|
+
const real = shadowing() ? probe2() : void 0;
|
|
11755
11764
|
if (real === null) return false;
|
|
11756
11765
|
if (real !== void 0) return tree.exists(real);
|
|
11757
11766
|
try {
|
|
@@ -11760,7 +11769,7 @@ function procfsBridge(fs, tree) {
|
|
|
11760
11769
|
} catch (err) {
|
|
11761
11770
|
if (directMiss(err, p)) return false;
|
|
11762
11771
|
}
|
|
11763
|
-
const late2 =
|
|
11772
|
+
const late2 = probe2();
|
|
11764
11773
|
return typeof late2 === "string" && tree.exists(late2);
|
|
11765
11774
|
},
|
|
11766
11775
|
readlink: (p) => via(
|
|
@@ -11802,7 +11811,7 @@ function procfsBridge(fs, tree) {
|
|
|
11802
11811
|
hold: (p, held2, open, handle, want, seen) => {
|
|
11803
11812
|
if (handle !== void 0 && snapshots.delete(handle)) return void 0;
|
|
11804
11813
|
if (!held2) return fs.hold?.(p, held2, open, handle);
|
|
11805
|
-
return via(p,
|
|
11814
|
+
return via(p, snapshot2, () => fs.hold?.(p, held2, open, void 0, want, seen) ?? late(p));
|
|
11806
11815
|
},
|
|
11807
11816
|
kept: (handle) => snapshots.has(handle) || fs.kept?.(handle) === true,
|
|
11808
11817
|
escape: (p) => inProc(p) ? current(fs, tree, p) : void 0,
|
|
@@ -12173,6 +12182,69 @@ var init_js_proc = __esm({
|
|
|
12173
12182
|
}
|
|
12174
12183
|
});
|
|
12175
12184
|
|
|
12185
|
+
// src/process/js/js-rights.ts
|
|
12186
|
+
function sendmsgRequest(fd, data, options = {}) {
|
|
12187
|
+
return {
|
|
12188
|
+
op: "sock-sendmsg",
|
|
12189
|
+
fd,
|
|
12190
|
+
body: typeof data === "string" ? encoder2.encode(data) : data,
|
|
12191
|
+
fds: options.fds ?? [],
|
|
12192
|
+
nonblock: options.nonblock === true
|
|
12193
|
+
};
|
|
12194
|
+
}
|
|
12195
|
+
function recvmsgRequest(fd, max = RECV_DEFAULT, options = {}) {
|
|
12196
|
+
return {
|
|
12197
|
+
op: "sock-recvmsg",
|
|
12198
|
+
fd,
|
|
12199
|
+
max,
|
|
12200
|
+
cloexec: options.cloexec === true,
|
|
12201
|
+
nonblock: options.nonblock === true
|
|
12202
|
+
};
|
|
12203
|
+
}
|
|
12204
|
+
function decodeReceived2(frame) {
|
|
12205
|
+
const view = new DataView(frame.buffer, frame.byteOffset, frame.byteLength);
|
|
12206
|
+
const count = view.getUint32(0, true);
|
|
12207
|
+
const fds = [];
|
|
12208
|
+
for (let i = 0; i < count; i++) fds.push(view.getUint32(8 + i * 4, true));
|
|
12209
|
+
return {
|
|
12210
|
+
bytes: frame.slice(8 + count * 4),
|
|
12211
|
+
fds,
|
|
12212
|
+
ctrunc: (view.getUint32(4, true) & 1) === 1
|
|
12213
|
+
};
|
|
12214
|
+
}
|
|
12215
|
+
async function blocked(kernel, watch, req) {
|
|
12216
|
+
if (req.nonblock) return kernel.call(req);
|
|
12217
|
+
const { signal, done } = watch(req.fd);
|
|
12218
|
+
try {
|
|
12219
|
+
return await kernel.blocking(req, signal);
|
|
12220
|
+
} finally {
|
|
12221
|
+
done();
|
|
12222
|
+
}
|
|
12223
|
+
}
|
|
12224
|
+
function rightsAsync(kernel, forget, watch) {
|
|
12225
|
+
return {
|
|
12226
|
+
socketpair: async () => await kernel.json({ op: "sock-pair", domain: "unix", type: "stream" }),
|
|
12227
|
+
sendmsg: async (fd, data, options) => jsonOf(await blocked(kernel, watch, sendmsgRequest(fd, data, options))),
|
|
12228
|
+
async recvmsg(fd, max, options) {
|
|
12229
|
+
const got = decodeReceived2(
|
|
12230
|
+
bytesOf2(await blocked(kernel, watch, recvmsgRequest(fd, max, options)))
|
|
12231
|
+
);
|
|
12232
|
+
for (const n of got.fds) forget(n);
|
|
12233
|
+
return got;
|
|
12234
|
+
}
|
|
12235
|
+
};
|
|
12236
|
+
}
|
|
12237
|
+
var jsonOf, bytesOf2, encoder2, RECV_DEFAULT;
|
|
12238
|
+
var init_js_rights = __esm({
|
|
12239
|
+
"src/process/js/js-rights.ts"() {
|
|
12240
|
+
"use strict";
|
|
12241
|
+
jsonOf = (r) => r.ok && r.kind === "json" ? r.json : void 0;
|
|
12242
|
+
bytesOf2 = (r) => r.ok && r.kind === "bytes" ? r.bytes : new Uint8Array(8);
|
|
12243
|
+
encoder2 = new TextEncoder();
|
|
12244
|
+
RECV_DEFAULT = 64 * 1024;
|
|
12245
|
+
}
|
|
12246
|
+
});
|
|
12247
|
+
|
|
12176
12248
|
// src/process/js/js-run.ts
|
|
12177
12249
|
function stdioOf(how) {
|
|
12178
12250
|
if (how === void 0) return "pipe";
|
|
@@ -12210,7 +12282,7 @@ function runSync(kernel, d, o) {
|
|
|
12210
12282
|
const named = argv0Of(o.argv0, "run");
|
|
12211
12283
|
const stdout = stdioOf(o.stdout);
|
|
12212
12284
|
const stderr = stderrOf(o.stderr);
|
|
12213
|
-
const input = typeof o.input === "string" ?
|
|
12285
|
+
const input = typeof o.input === "string" ? encoder3.encode(o.input) : o.input;
|
|
12214
12286
|
const maxBuffer = limit(o.maxBuffer);
|
|
12215
12287
|
const timeout = limit(o.timeout);
|
|
12216
12288
|
const bytes = kernel.bytes({
|
|
@@ -12233,13 +12305,13 @@ function runSync(kernel, d, o) {
|
|
|
12233
12305
|
});
|
|
12234
12306
|
return decodeRun(bytes, stdout, stderr);
|
|
12235
12307
|
}
|
|
12236
|
-
var
|
|
12308
|
+
var encoder3, STDIO4;
|
|
12237
12309
|
var init_js_run = __esm({
|
|
12238
12310
|
"src/process/js/js-run.ts"() {
|
|
12239
12311
|
"use strict";
|
|
12240
12312
|
init_js_children();
|
|
12241
12313
|
init_js_kernel();
|
|
12242
|
-
|
|
12314
|
+
encoder3 = new TextEncoder();
|
|
12243
12315
|
STDIO4 = /* @__PURE__ */ new Set(["pipe", "ignore", "inherit"]);
|
|
12244
12316
|
}
|
|
12245
12317
|
});
|
|
@@ -12297,7 +12369,7 @@ function syncOps(kernel, shared) {
|
|
|
12297
12369
|
return r.ok && r.kind === "bytes" ? r.bytes : new Uint8Array(0);
|
|
12298
12370
|
};
|
|
12299
12371
|
const write2 = (fd, data, options) => {
|
|
12300
|
-
const bytes = typeof data === "string" ?
|
|
12372
|
+
const bytes = typeof data === "string" ? encoder4.encode(data) : data;
|
|
12301
12373
|
const i = info(fd);
|
|
12302
12374
|
if (writeDevice(i)) return bytes.length;
|
|
12303
12375
|
const nonblock = options?.nonblock === true;
|
|
@@ -12388,6 +12460,12 @@ function syncOps(kernel, shared) {
|
|
|
12388
12460
|
kernel.call({ op: "fd-close", fd });
|
|
12389
12461
|
},
|
|
12390
12462
|
socketpair: () => kernel.json({ op: "sock-pair", domain: "unix", type: "stream" }),
|
|
12463
|
+
sendmsg: (fd, data, options) => kernel.json(sendmsgRequest(fd, data, options)),
|
|
12464
|
+
recvmsg(fd, max, options) {
|
|
12465
|
+
const got = decodeReceived2(kernel.bytes(recvmsgRequest(fd, max, options)));
|
|
12466
|
+
for (const n of got.fds) infos.delete(n);
|
|
12467
|
+
return got;
|
|
12468
|
+
},
|
|
12391
12469
|
pipe: () => kernel.json({ op: "fd-pipe" }),
|
|
12392
12470
|
open: procOpenSync(open, kernel, { resolve: resolve2, pid: shared.pid }),
|
|
12393
12471
|
fs: procFsSync(syncPathOps(kernel, resolve2, statOf, open, tryDevSync), kernel, {
|
|
@@ -12534,14 +12612,14 @@ function syncPathOps(kernel, resolve2, statOf, open, tryDev) {
|
|
|
12534
12612
|
...mode !== void 0 ? { mode } : {}
|
|
12535
12613
|
});
|
|
12536
12614
|
try {
|
|
12537
|
-
file.write(0, typeof data === "string" ?
|
|
12615
|
+
file.write(0, typeof data === "string" ? encoder4.encode(data) : data);
|
|
12538
12616
|
} finally {
|
|
12539
12617
|
file.close();
|
|
12540
12618
|
}
|
|
12541
12619
|
}
|
|
12542
12620
|
};
|
|
12543
12621
|
}
|
|
12544
|
-
var
|
|
12622
|
+
var encoder4, noLane, READ_ONLY, JsSyncKernel;
|
|
12545
12623
|
var init_js_sync = __esm({
|
|
12546
12624
|
"src/process/js/js-sync.ts"() {
|
|
12547
12625
|
"use strict";
|
|
@@ -12553,7 +12631,8 @@ var init_js_sync = __esm({
|
|
|
12553
12631
|
init_js_io();
|
|
12554
12632
|
init_js_kernel();
|
|
12555
12633
|
init_js_proc();
|
|
12556
|
-
|
|
12634
|
+
init_js_rights();
|
|
12635
|
+
encoder4 = new TextEncoder();
|
|
12557
12636
|
noLane = () => ({ ok: false, errno: "ENOSYS", message: "no sync lane" });
|
|
12558
12637
|
READ_ONLY = /* @__PURE__ */ new Set([...SYNC_FS_READ_ONLY, "fd-path-flush"]);
|
|
12559
12638
|
JsSyncKernel = class {
|
|
@@ -12788,17 +12867,17 @@ var init_emscripten_vfs_hook = __esm({
|
|
|
12788
12867
|
});
|
|
12789
12868
|
|
|
12790
12869
|
// src/process/fd-metadata.ts
|
|
12791
|
-
function
|
|
12870
|
+
function idOf4(value2) {
|
|
12792
12871
|
return value2 === -1 || value2 === 4294967295 ? void 0 : value2 >>> 0;
|
|
12793
12872
|
}
|
|
12794
12873
|
function timeOf(value2) {
|
|
12795
12874
|
return typeof value2 === "number" && Number.isFinite(value2) ? value2 : null;
|
|
12796
12875
|
}
|
|
12797
|
-
function useKernelFdMetadata(Fs, sys,
|
|
12876
|
+
function useKernelFdMetadata(Fs, sys, call3) {
|
|
12798
12877
|
const { fdChown, fdChmod, fdUtimes } = sys;
|
|
12799
12878
|
const meta = Fs;
|
|
12800
12879
|
const kernelFd = (stream) => stream?.sliccKernelFile ? stream.sliccKernelFd : void 0;
|
|
12801
|
-
const
|
|
12880
|
+
const find2 = (match) => {
|
|
12802
12881
|
for (const s of Fs.streams) {
|
|
12803
12882
|
const kfd = s && match(s) ? kernelFd(s) : void 0;
|
|
12804
12883
|
if (kfd !== void 0) return kfd;
|
|
@@ -12806,13 +12885,13 @@ function useKernelFdMetadata(Fs, sys, call2) {
|
|
|
12806
12885
|
return void 0;
|
|
12807
12886
|
};
|
|
12808
12887
|
const ofPath = (path, follow3) => {
|
|
12809
|
-
if (typeof path !== "string") return
|
|
12888
|
+
if (typeof path !== "string") return find2((s) => s.node === path);
|
|
12810
12889
|
const fd = follow3 ? fdOfPath(path, Fs.cwd()) : void 0;
|
|
12811
12890
|
if (fd !== void 0) return kernelFd(Fs.getStream(fd));
|
|
12812
|
-
return
|
|
12891
|
+
return find2((s) => s.path === path);
|
|
12813
12892
|
};
|
|
12814
12893
|
const ofFd = (fd) => kernelFd(Fs.getStream(fd));
|
|
12815
|
-
const chownBy = (kfd, uid, gid) =>
|
|
12894
|
+
const chownBy = (kfd, uid, gid) => call3(() => fdChown?.call(sys, kfd, idOf4(uid), idOf4(gid)));
|
|
12816
12895
|
if (fdChown && meta.chown) {
|
|
12817
12896
|
const chown = meta.chown.bind(Fs);
|
|
12818
12897
|
meta.chown = (path, uid, gid, dontFollow) => {
|
|
@@ -12834,7 +12913,7 @@ function useKernelFdMetadata(Fs, sys, call2) {
|
|
|
12834
12913
|
meta.chmod = (path, mode, dontFollow) => {
|
|
12835
12914
|
const kfd = ofPath(path, !dontFollow);
|
|
12836
12915
|
if (kfd === void 0) return chmod(path, mode, dontFollow);
|
|
12837
|
-
|
|
12916
|
+
call3(() => fdChmod.call(sys, kfd, mode & 4095));
|
|
12838
12917
|
};
|
|
12839
12918
|
}
|
|
12840
12919
|
if (fdChmod && meta.fchmod) {
|
|
@@ -12842,7 +12921,7 @@ function useKernelFdMetadata(Fs, sys, call2) {
|
|
|
12842
12921
|
meta.fchmod = (fd, mode) => {
|
|
12843
12922
|
const kfd = ofFd(fd);
|
|
12844
12923
|
if (kfd === void 0) return fchmod(fd, mode);
|
|
12845
|
-
|
|
12924
|
+
call3(() => fdChmod.call(sys, kfd, mode & 4095));
|
|
12846
12925
|
};
|
|
12847
12926
|
}
|
|
12848
12927
|
if (fdUtimes && meta.utime) {
|
|
@@ -12851,7 +12930,7 @@ function useKernelFdMetadata(Fs, sys, call2) {
|
|
|
12851
12930
|
const kfd = ofPath(path, true);
|
|
12852
12931
|
if (kfd === void 0) return utime(path, atime, mtime);
|
|
12853
12932
|
const now = meta.sliccTouch === true;
|
|
12854
|
-
|
|
12933
|
+
call3(() => fdUtimes.call(sys, kfd, timeOf(atime), timeOf(mtime), now));
|
|
12855
12934
|
};
|
|
12856
12935
|
}
|
|
12857
12936
|
}
|
|
@@ -13874,13 +13953,13 @@ function ownReady(Fs, read2, write2) {
|
|
|
13874
13953
|
}
|
|
13875
13954
|
function anySelect(Fs, transport, read2, write2, timeoutMs2) {
|
|
13876
13955
|
const kernel = (fd) => Fs.getStream(fd)?.sliccKernelFd;
|
|
13877
|
-
const
|
|
13878
|
-
if (![...read2, ...write2].some(
|
|
13956
|
+
const own2 = (fd) => kernel(fd) === void 0;
|
|
13957
|
+
if (![...read2, ...write2].some(own2)) return kernelSelect(Fs, transport, read2, write2, timeoutMs2);
|
|
13879
13958
|
const deadline = timeoutMs2 < 0 ? Number.POSITIVE_INFINITY : Date.now() + timeoutMs2;
|
|
13880
|
-
const kernelRead = read2.filter((fd) => !
|
|
13881
|
-
const kernelWrite = write2.filter((fd) => !
|
|
13959
|
+
const kernelRead = read2.filter((fd) => !own2(fd));
|
|
13960
|
+
const kernelWrite = write2.filter((fd) => !own2(fd));
|
|
13882
13961
|
for (; ; ) {
|
|
13883
|
-
const local3 = ownReady(Fs, read2.filter(
|
|
13962
|
+
const local3 = ownReady(Fs, read2.filter(own2), write2.filter(own2));
|
|
13884
13963
|
const pending = local3.read.length > 0 || local3.write.length > 0;
|
|
13885
13964
|
const slice = pending ? 0 : Math.min(SELECT_SLICE_MS, Math.max(0, deadline - Date.now()));
|
|
13886
13965
|
const got = kernelSelect(Fs, transport, kernelRead, kernelWrite, slice);
|
|
@@ -13895,7 +13974,7 @@ function createProcessKernel(deps) {
|
|
|
13895
13974
|
const { transport, Fs } = deps;
|
|
13896
13975
|
if (deps.stdioPromoter) lockPromoters.set(Fs, deps.stdioPromoter);
|
|
13897
13976
|
const reaped = /* @__PURE__ */ new Map();
|
|
13898
|
-
const
|
|
13977
|
+
const call3 = (req, label) => transport.call(req, Infinity, label);
|
|
13899
13978
|
const at = (path) => path === "" || path.startsWith("/") ? path : `${Fs.cwd()}/${path}`;
|
|
13900
13979
|
const slot2 = (fd, n, promote) => {
|
|
13901
13980
|
const stream = fd >= 0 ? Fs.getStream(fd) : null;
|
|
@@ -13999,29 +14078,29 @@ function createProcessKernel(deps) {
|
|
|
13999
14078
|
execCaptures.delete(pid);
|
|
14000
14079
|
return status2;
|
|
14001
14080
|
},
|
|
14002
|
-
pause: () => status(
|
|
14003
|
-
sigInherited: () => inheritedOf(
|
|
14081
|
+
pause: () => status(call3({ op: "sig-pause" }, "pause")),
|
|
14082
|
+
sigInherited: () => inheritedOf(call3({ op: "sig-inherited" }, "sig-inherited")),
|
|
14004
14083
|
mount(source, target, type, flags, data) {
|
|
14005
14084
|
const req = { op: "mount", source, target: at(target), type, flags, data };
|
|
14006
|
-
return status(
|
|
14085
|
+
return status(call3(req, `mount ${target}`));
|
|
14007
14086
|
},
|
|
14008
14087
|
umount2(target, flags) {
|
|
14009
|
-
return status(
|
|
14088
|
+
return status(call3({ op: "umount", target: at(target), flags }, `umount ${target}`));
|
|
14010
14089
|
},
|
|
14011
14090
|
kill(pid, sig) {
|
|
14012
14091
|
if (pid === deps.pid && !throughKernel(sig)) {
|
|
14013
14092
|
if (sig !== 0) deps.raise?.(sig);
|
|
14014
14093
|
return 0;
|
|
14015
14094
|
}
|
|
14016
|
-
return status(
|
|
14095
|
+
return status(call3({ op: "proc-kill", pid, sig }, `kill ${pid}`));
|
|
14017
14096
|
},
|
|
14018
|
-
setpgid: (pid, pgid) => status(
|
|
14019
|
-
setsid: () => number(
|
|
14020
|
-
getpgid: (pid) => number(
|
|
14021
|
-
getsid: (pid) => number(
|
|
14022
|
-
cred: () => credOf(
|
|
14097
|
+
setpgid: (pid, pgid) => status(call3({ op: "proc-setpgid", pid, pgid }, "setpgid")),
|
|
14098
|
+
setsid: () => number(call3({ op: "proc-setsid" }, "setsid")),
|
|
14099
|
+
getpgid: (pid) => number(call3({ op: "proc-getpgid", pid }, "getpgid")),
|
|
14100
|
+
getsid: (pid) => number(call3({ op: "proc-getsid", pid }, "getsid")),
|
|
14101
|
+
cred: () => credOf(call3({ op: "proc-cred" }, "cred")),
|
|
14023
14102
|
setcred(change) {
|
|
14024
|
-
const cred = credOf(
|
|
14103
|
+
const cred = credOf(call3({ op: "proc-setcred", change }, "setcred"));
|
|
14025
14104
|
if (typeof cred === "object" && deps.owner) {
|
|
14026
14105
|
deps.owner.uid = cred.euid;
|
|
14027
14106
|
deps.owner.gid = cred.egid;
|
|
@@ -14031,12 +14110,12 @@ function createProcessKernel(deps) {
|
|
|
14031
14110
|
tcgetpgrp(fd) {
|
|
14032
14111
|
const kfd = Fs.getStream(fd)?.sliccKernelFd;
|
|
14033
14112
|
if (kfd === void 0) return -wasiErrno("ENOTTY");
|
|
14034
|
-
return number(
|
|
14113
|
+
return number(call3({ op: "tty-pgrp-get", fd: kfd }, "tcgetpgrp"));
|
|
14035
14114
|
},
|
|
14036
14115
|
tcsetpgrp(fd, pgrp) {
|
|
14037
14116
|
const kfd = Fs.getStream(fd)?.sliccKernelFd;
|
|
14038
14117
|
if (kfd === void 0) return -wasiErrno("ENOTTY");
|
|
14039
|
-
return status(
|
|
14118
|
+
return status(call3({ op: "tty-pgrp-set", fd: kfd, pgrp }, "tcsetpgrp"));
|
|
14040
14119
|
},
|
|
14041
14120
|
wait(pid, nohang, options) {
|
|
14042
14121
|
const key = pid > 0 ? reaped.has(pid) ? pid : void 0 : reaped.keys().next().value;
|
|
@@ -14074,14 +14153,14 @@ var init_process_children = __esm({
|
|
|
14074
14153
|
|
|
14075
14154
|
// src/process/process-http.ts
|
|
14076
14155
|
function createHttpKernel(transport) {
|
|
14077
|
-
const
|
|
14156
|
+
const call3 = (req) => {
|
|
14078
14157
|
const r = transport.call(req, Number.POSITIVE_INFINITY, req.op);
|
|
14079
14158
|
if (!r.ok) throw new HttpError(r.errno, r.message);
|
|
14080
14159
|
return r;
|
|
14081
14160
|
};
|
|
14082
14161
|
return {
|
|
14083
14162
|
request(req) {
|
|
14084
|
-
const r =
|
|
14163
|
+
const r = call3({
|
|
14085
14164
|
op: "net-request",
|
|
14086
14165
|
url: req.url,
|
|
14087
14166
|
method: (req.method ?? "GET").toUpperCase(),
|
|
@@ -14091,10 +14170,10 @@ function createHttpKernel(transport) {
|
|
|
14091
14170
|
return r.json;
|
|
14092
14171
|
},
|
|
14093
14172
|
read(handle, max) {
|
|
14094
|
-
return
|
|
14173
|
+
return call3({ op: "net-read", handle, max }).bytes;
|
|
14095
14174
|
},
|
|
14096
14175
|
close(handle) {
|
|
14097
|
-
|
|
14176
|
+
call3({ op: "net-close", handle });
|
|
14098
14177
|
}
|
|
14099
14178
|
};
|
|
14100
14179
|
}
|
|
@@ -14220,8 +14299,8 @@ var init_process_signals = __esm({
|
|
|
14220
14299
|
this.hooks.killed(killed);
|
|
14221
14300
|
}
|
|
14222
14301
|
const timers = Atomics.exchange(this.header, SAB_I_TIMERS, 0);
|
|
14223
|
-
const
|
|
14224
|
-
const pending =
|
|
14302
|
+
const blocked2 = Atomics.load(this.header, SAB_I_BLOCKED);
|
|
14303
|
+
const pending = blocked2 === 0 ? Atomics.exchange(this.header, SAB_I_SIGNALS, 0) : Atomics.and(this.header, SAB_I_SIGNALS, blocked2) & ~blocked2;
|
|
14225
14304
|
if (this.depth <= 1) this.lastDelivered = pending | (timers & 1 ? sigbit(SIG.ALRM) : 0);
|
|
14226
14305
|
if (pending !== 0 || timers !== 0) this.delivered++;
|
|
14227
14306
|
this.raised |= pending | (timers & 1 ? sigbit(SIG.ALRM) : 0) | (timers & ~1 ? -1 : 0);
|
|
@@ -14248,17 +14327,17 @@ function resolved(Fs, addr) {
|
|
|
14248
14327
|
}
|
|
14249
14328
|
function createSocketKernel(deps) {
|
|
14250
14329
|
const { transport, Fs, sys, streams: streams2 } = deps;
|
|
14251
|
-
const
|
|
14330
|
+
const call3 = (req) => {
|
|
14252
14331
|
const r = transport.call(req, Number.POSITIVE_INFINITY, req.op);
|
|
14253
14332
|
if (!r.ok) throw new SyscallError(r.errno);
|
|
14254
14333
|
return r;
|
|
14255
14334
|
};
|
|
14256
14335
|
const json2 = (req) => {
|
|
14257
|
-
const r =
|
|
14336
|
+
const r = call3(req);
|
|
14258
14337
|
return r.ok && r.kind === "json" ? r.json : void 0;
|
|
14259
14338
|
};
|
|
14260
14339
|
const done = (req) => {
|
|
14261
|
-
|
|
14340
|
+
call3(req);
|
|
14262
14341
|
return 0;
|
|
14263
14342
|
};
|
|
14264
14343
|
const guard2 = (op) => {
|
|
@@ -14403,7 +14482,7 @@ function ownedBuffer(body, given) {
|
|
|
14403
14482
|
return body === given ? void 0 : [body.buffer];
|
|
14404
14483
|
}
|
|
14405
14484
|
function kernelSys(transport) {
|
|
14406
|
-
const
|
|
14485
|
+
const call3 = (req, label, transfer) => {
|
|
14407
14486
|
const r = transport.call(req, Number.POSITIVE_INFINITY, label, transfer);
|
|
14408
14487
|
if (!r.ok) throw new SyscallError(r.errno);
|
|
14409
14488
|
return r;
|
|
@@ -14415,7 +14494,7 @@ function kernelSys(transport) {
|
|
|
14415
14494
|
...opts?.nonblock ? { nonblock: true } : {},
|
|
14416
14495
|
...opts?.peek ? { peek: true } : {}
|
|
14417
14496
|
};
|
|
14418
|
-
const r =
|
|
14497
|
+
const r = call3({ op: "fd-read", fd, max, ...flags }, `fd-read ${fd}`);
|
|
14419
14498
|
return r.ok && r.kind === "bytes" ? r.bytes : new Uint8Array(0);
|
|
14420
14499
|
},
|
|
14421
14500
|
write(fd, bytes, opts) {
|
|
@@ -14426,21 +14505,21 @@ function kernelSys(transport) {
|
|
|
14426
14505
|
body,
|
|
14427
14506
|
...opts?.nonblock ? { nonblock: true } : {}
|
|
14428
14507
|
};
|
|
14429
|
-
const n = json2(
|
|
14508
|
+
const n = json2(call3(req, `fd-write ${fd}`, ownedBuffer(body, bytes)));
|
|
14430
14509
|
return typeof n === "number" ? n : bytes.length;
|
|
14431
14510
|
},
|
|
14432
14511
|
close(fd) {
|
|
14433
|
-
|
|
14512
|
+
call3({ op: "fd-close", fd }, `fd-close ${fd}`);
|
|
14434
14513
|
},
|
|
14435
14514
|
pipe() {
|
|
14436
|
-
return json2(
|
|
14515
|
+
return json2(call3({ op: "fd-pipe" }, "fd-pipe"));
|
|
14437
14516
|
},
|
|
14438
14517
|
poll(fd) {
|
|
14439
|
-
return json2(
|
|
14518
|
+
return json2(call3({ op: "fd-poll", fd }, `fd-poll ${fd}`));
|
|
14440
14519
|
},
|
|
14441
14520
|
openVfs(path, flags, position, opts) {
|
|
14442
14521
|
return json2(
|
|
14443
|
-
|
|
14522
|
+
call3(
|
|
14444
14523
|
{
|
|
14445
14524
|
op: "fd-open-vfs",
|
|
14446
14525
|
path,
|
|
@@ -14462,126 +14541,126 @@ function kernelSys(transport) {
|
|
|
14462
14541
|
);
|
|
14463
14542
|
},
|
|
14464
14543
|
seek(fd, offset, whence) {
|
|
14465
|
-
return json2(
|
|
14544
|
+
return json2(call3({ op: "fd-seek", fd, offset, whence }, `fd-seek ${fd}`));
|
|
14466
14545
|
},
|
|
14467
14546
|
flush(fd) {
|
|
14468
|
-
|
|
14547
|
+
call3({ op: "fd-flush", fd }, `fd-flush ${fd}`);
|
|
14469
14548
|
},
|
|
14470
14549
|
pread(fd, max, at) {
|
|
14471
|
-
const r =
|
|
14550
|
+
const r = call3({ op: "fd-pread", fd, max, offset: at }, `fd-pread ${fd}`);
|
|
14472
14551
|
return r.ok && r.kind === "bytes" ? r.bytes : new Uint8Array(0);
|
|
14473
14552
|
},
|
|
14474
14553
|
pwrite(fd, bytes, at) {
|
|
14475
14554
|
const body = ownBytes(bytes);
|
|
14476
14555
|
return json2(
|
|
14477
|
-
|
|
14556
|
+
call3({ op: "fd-pwrite", fd, offset: at, body }, `fd-pwrite ${fd}`, ownedBuffer(body, bytes))
|
|
14478
14557
|
);
|
|
14479
14558
|
},
|
|
14480
14559
|
isatty(fd) {
|
|
14481
|
-
return json2(
|
|
14560
|
+
return json2(call3({ op: "fd-info", fd }, `fd-info ${fd}`))?.tty === true;
|
|
14482
14561
|
},
|
|
14483
14562
|
ttyName(fd) {
|
|
14484
|
-
return json2(
|
|
14563
|
+
return json2(call3({ op: "fd-info", fd }, `fd-info ${fd}`))?.name;
|
|
14485
14564
|
},
|
|
14486
14565
|
kind(fd) {
|
|
14487
|
-
return json2(
|
|
14566
|
+
return json2(call3({ op: "fd-info", fd }, `fd-info ${fd}`))?.kind;
|
|
14488
14567
|
},
|
|
14489
14568
|
heldMeta(fd) {
|
|
14490
|
-
return json2(
|
|
14569
|
+
return json2(call3({ op: "fd-info", fd }, `fd-info ${fd}`)).meta;
|
|
14491
14570
|
},
|
|
14492
14571
|
access(fd) {
|
|
14493
|
-
return json2(
|
|
14572
|
+
return json2(call3({ op: "fd-info", fd }, `fd-info ${fd}`)).access;
|
|
14494
14573
|
},
|
|
14495
14574
|
size(fd) {
|
|
14496
|
-
return json2(
|
|
14575
|
+
return json2(call3({ op: "fd-vfs-stat", fd }, `fd-vfs-stat ${fd}`)).size;
|
|
14497
14576
|
},
|
|
14498
14577
|
fdStat(fd) {
|
|
14499
|
-
const r = json2(
|
|
14578
|
+
const r = json2(call3({ op: "fd-vfs-stat", fd, full: true }, `fd-vfs-stat ${fd}`));
|
|
14500
14579
|
return r?.stat;
|
|
14501
14580
|
},
|
|
14502
14581
|
fdChmod(fd, mode) {
|
|
14503
|
-
|
|
14582
|
+
call3({ op: "fd-chmod", fd, mode }, `fd-chmod ${fd}`);
|
|
14504
14583
|
},
|
|
14505
14584
|
fdChown(fd, uid, gid) {
|
|
14506
14585
|
const ids = { ...uid !== void 0 ? { uid } : {}, ...gid !== void 0 ? { gid } : {} };
|
|
14507
|
-
|
|
14586
|
+
call3({ op: "fd-chown", fd, ...ids }, `fd-chown ${fd}`);
|
|
14508
14587
|
},
|
|
14509
14588
|
fdUtimes(fd, atimeMs, mtimeMs, now) {
|
|
14510
|
-
|
|
14589
|
+
call3({ op: "fd-utimes", fd, atimeMs, mtimeMs, now }, `fd-utimes ${fd}`);
|
|
14511
14590
|
},
|
|
14512
14591
|
ttyNames() {
|
|
14513
|
-
return json2(
|
|
14592
|
+
return json2(call3({ op: "fd-tty-names" }, "fd-tty-names"));
|
|
14514
14593
|
},
|
|
14515
14594
|
ttyOwner(name2) {
|
|
14516
|
-
return json2(
|
|
14595
|
+
return json2(call3({ op: "fd-tty-owner", name: name2 }, `fd-tty-owner ${name2}`));
|
|
14517
14596
|
},
|
|
14518
14597
|
openTty(name2) {
|
|
14519
14598
|
const req = name2 === void 0 ? { op: "fd-open-tty" } : { op: "fd-open-tty", name: name2 };
|
|
14520
|
-
return json2(
|
|
14599
|
+
return json2(call3(req, `fd-open-tty ${name2 ?? ""}`));
|
|
14521
14600
|
},
|
|
14522
14601
|
tcgets(fd) {
|
|
14523
|
-
return json2(
|
|
14602
|
+
return json2(call3({ op: "tty-get", fd }, `tty-get ${fd}`));
|
|
14524
14603
|
},
|
|
14525
14604
|
tcsets(fd, termios, flush) {
|
|
14526
|
-
|
|
14605
|
+
call3({ op: "tty-set", fd, termios, ...flush ? { flush } : {} }, `tty-set ${fd}`);
|
|
14527
14606
|
},
|
|
14528
14607
|
winsize(fd) {
|
|
14529
|
-
return json2(
|
|
14608
|
+
return json2(call3({ op: "tty-winsz", fd }, `tty-winsz ${fd}`));
|
|
14530
14609
|
},
|
|
14531
14610
|
openPty() {
|
|
14532
|
-
return json2(
|
|
14611
|
+
return json2(call3({ op: "pty-open" }, "pty-open"));
|
|
14533
14612
|
},
|
|
14534
14613
|
openPts(n, noctty) {
|
|
14535
|
-
return json2(
|
|
14614
|
+
return json2(call3({ op: "pty-slave-open", n, noctty }, `pty-slave-open ${n}`));
|
|
14536
14615
|
},
|
|
14537
14616
|
openSealed(flags) {
|
|
14538
|
-
return json2(
|
|
14617
|
+
return json2(call3({ op: "fd-open-sealed", flags }, "fd-open-sealed"));
|
|
14539
14618
|
},
|
|
14540
14619
|
openClipboard(flags) {
|
|
14541
|
-
return json2(
|
|
14620
|
+
return json2(call3({ op: "fd-open-clipboard", flags }, "fd-open-clipboard"));
|
|
14542
14621
|
},
|
|
14543
14622
|
clipboardAbort(fd) {
|
|
14544
|
-
|
|
14623
|
+
call3({ op: "fd-clipboard-abort", fd }, "fd-clipboard-abort");
|
|
14545
14624
|
},
|
|
14546
14625
|
openEmbedder(flags) {
|
|
14547
|
-
return json2(
|
|
14626
|
+
return json2(call3({ op: "fd-open-embedder", flags }, "fd-open-embedder"));
|
|
14548
14627
|
},
|
|
14549
14628
|
ptyNumbers() {
|
|
14550
|
-
return json2(
|
|
14629
|
+
return json2(call3({ op: "pty-list" }, "pty-list"));
|
|
14551
14630
|
},
|
|
14552
14631
|
procList() {
|
|
14553
|
-
return json2(
|
|
14632
|
+
return json2(call3({ op: "proc-list" }, "proc-list"));
|
|
14554
14633
|
},
|
|
14555
14634
|
mountList() {
|
|
14556
|
-
return json2(
|
|
14635
|
+
return json2(call3({ op: "mount-list" }, "mount-list"));
|
|
14557
14636
|
},
|
|
14558
14637
|
setLock(target, kind, start2, len, wait2) {
|
|
14559
14638
|
const req = { op: "lk-set", ...target, kind, start: start2, len, ...wait2 ? { wait: wait2 } : {} };
|
|
14560
|
-
|
|
14639
|
+
call3(req, "lk-set");
|
|
14561
14640
|
},
|
|
14562
14641
|
getLock(target, kind, start2, len) {
|
|
14563
|
-
return json2(
|
|
14642
|
+
return json2(call3({ op: "lk-get", ...target, kind, start: start2, len }, "lk-get"));
|
|
14564
14643
|
},
|
|
14565
14644
|
closeLocks(target) {
|
|
14566
|
-
|
|
14645
|
+
call3({ op: "lk-close", ...target }, "lk-close");
|
|
14567
14646
|
},
|
|
14568
14647
|
flock(fd, kind, wait2) {
|
|
14569
|
-
|
|
14648
|
+
call3({ op: "flock", fd, kind, ...wait2 ? { wait: wait2 } : {} }, `flock ${fd}`);
|
|
14570
14649
|
},
|
|
14571
14650
|
ptyNumber(fd) {
|
|
14572
|
-
return json2(
|
|
14651
|
+
return json2(call3({ op: "pty-number", fd }, `pty-number ${fd}`));
|
|
14573
14652
|
},
|
|
14574
14653
|
ptyLock(fd, lock) {
|
|
14575
|
-
|
|
14654
|
+
call3({ op: "pty-lock", fd, lock }, `pty-lock ${fd}`);
|
|
14576
14655
|
},
|
|
14577
14656
|
setControllingTerminal(fd) {
|
|
14578
|
-
|
|
14657
|
+
call3({ op: "pty-ctty", fd }, `pty-ctty ${fd}`);
|
|
14579
14658
|
},
|
|
14580
14659
|
setPacketMode(fd, on) {
|
|
14581
|
-
|
|
14660
|
+
call3({ op: "pty-packet", fd, on }, `pty-packet ${fd}`);
|
|
14582
14661
|
},
|
|
14583
14662
|
setWinsize(fd, rows, cols) {
|
|
14584
|
-
|
|
14663
|
+
call3({ op: "pty-winsz-set", fd, rows, cols }, `pty-winsz-set ${fd}`);
|
|
14585
14664
|
}
|
|
14586
14665
|
};
|
|
14587
14666
|
}
|
|
@@ -14634,8 +14713,8 @@ function glueBody(glue) {
|
|
|
14634
14713
|
return glue.startsWith("#!") ? glue.slice(glue.indexOf("\n") + 1) : glue;
|
|
14635
14714
|
}
|
|
14636
14715
|
function ownValue(module, name2) {
|
|
14637
|
-
const
|
|
14638
|
-
return
|
|
14716
|
+
const own2 = Object.getOwnPropertyDescriptor(module, name2);
|
|
14717
|
+
return own2 && "value" in own2 ? own2.value : void 0;
|
|
14639
14718
|
}
|
|
14640
14719
|
function identify(transport, init) {
|
|
14641
14720
|
const r = transport.call({ op: "proc-identity" }, Number.POSITIVE_INFINITY, "proc-identity");
|
|
@@ -14779,8 +14858,8 @@ async function runWasmProcess(init, port3, deps = {}) {
|
|
|
14779
14858
|
};
|
|
14780
14859
|
const transport = credSyncTransport(gated, () => early(), init.cred);
|
|
14781
14860
|
const sys = kernelSys(transport);
|
|
14782
|
-
const
|
|
14783
|
-
const say = (fd) => (text) => sys.write(fd,
|
|
14861
|
+
const encoder6 = new TextEncoder();
|
|
14862
|
+
const say = (fd) => (text) => sys.write(fd, encoder6.encode(`${text}
|
|
14784
14863
|
`));
|
|
14785
14864
|
let ready;
|
|
14786
14865
|
let failed5;
|
|
@@ -15193,7 +15272,7 @@ function preopensOf(given, resolve2) {
|
|
|
15193
15272
|
function createJsWasi(deps, o = {}) {
|
|
15194
15273
|
const transport = laneTransport(deps.lane);
|
|
15195
15274
|
const sys = kernelSys(transport);
|
|
15196
|
-
const
|
|
15275
|
+
const call3 = (req) => {
|
|
15197
15276
|
const r = deps.lane(req);
|
|
15198
15277
|
if (!r.ok) throw new JsCallError(r.errno, req.op);
|
|
15199
15278
|
return r.kind === "json" ? r.json : r.kind === "bytes" ? r.bytes : void 0;
|
|
@@ -15203,13 +15282,13 @@ function createJsWasi(deps, o = {}) {
|
|
|
15203
15282
|
env: { ...o.env ?? {} },
|
|
15204
15283
|
cwd: deps.cwd,
|
|
15205
15284
|
pid: deps.pid,
|
|
15206
|
-
kernel: { sys, call:
|
|
15285
|
+
kernel: { sys, call: call3 },
|
|
15207
15286
|
fs: createSyncFsSabBridge(transport, { ...deps.fs, direct: true }),
|
|
15208
15287
|
bare: true
|
|
15209
15288
|
});
|
|
15210
15289
|
const owned = deps.owned;
|
|
15211
15290
|
const guest = /* @__PURE__ */ new Map();
|
|
15212
|
-
const
|
|
15291
|
+
const own2 = (g, k) => {
|
|
15213
15292
|
guest.set(g, k);
|
|
15214
15293
|
owned.add(k);
|
|
15215
15294
|
};
|
|
@@ -15226,13 +15305,13 @@ function createJsWasi(deps, o = {}) {
|
|
|
15226
15305
|
(o.stdio ?? [0, 1, 2]).forEach((fd, i) => {
|
|
15227
15306
|
const k = host.fds.adoptCopy(fd);
|
|
15228
15307
|
opened2.push(k);
|
|
15229
|
-
|
|
15308
|
+
own2(i, k);
|
|
15230
15309
|
});
|
|
15231
15310
|
for (const [name2, path] of preopensOf(o.preopens, deps.resolve)) {
|
|
15232
15311
|
const k = host.fds.preopenAt(path, name2);
|
|
15233
15312
|
opened2.push(k);
|
|
15234
15313
|
const g = 3 + roots.size;
|
|
15235
|
-
|
|
15314
|
+
own2(g, k);
|
|
15236
15315
|
roots.set(g, path);
|
|
15237
15316
|
}
|
|
15238
15317
|
} catch (err) {
|
|
@@ -15259,7 +15338,7 @@ function createJsWasi(deps, o = {}) {
|
|
|
15259
15338
|
const opens = (out, root) => {
|
|
15260
15339
|
const k = view().getUint32(out, true);
|
|
15261
15340
|
const g = free();
|
|
15262
|
-
|
|
15341
|
+
own2(g, k);
|
|
15263
15342
|
if (root !== void 0) roots.set(g, root);
|
|
15264
15343
|
view().setUint32(out, g, true);
|
|
15265
15344
|
};
|
|
@@ -15642,9 +15721,9 @@ async function selectOp(kernel, sets, signal) {
|
|
|
15642
15721
|
return { read: got.read ?? [], write: got.write ?? [] };
|
|
15643
15722
|
}
|
|
15644
15723
|
function listen(listeners, listener) {
|
|
15645
|
-
const
|
|
15646
|
-
listeners.add(
|
|
15647
|
-
return () => void listeners.delete(
|
|
15724
|
+
const own2 = (error, promise) => listener(error, promise);
|
|
15725
|
+
listeners.add(own2);
|
|
15726
|
+
return () => void listeners.delete(own2);
|
|
15648
15727
|
}
|
|
15649
15728
|
function identityOf(answer2, fallback) {
|
|
15650
15729
|
const id = answer2;
|
|
@@ -15875,11 +15954,11 @@ function watchingSyncOps(kernel, syncKernel, shared) {
|
|
|
15875
15954
|
};
|
|
15876
15955
|
return { ...ops, fs: { ...ops.fs, watch } };
|
|
15877
15956
|
}
|
|
15878
|
-
function pendingReads(kernel, info,
|
|
15957
|
+
function pendingReads(kernel, info, random2) {
|
|
15879
15958
|
const reading = /* @__PURE__ */ new Map();
|
|
15880
15959
|
const read2 = async (fd, max = CHUNK, signal) => {
|
|
15881
15960
|
index2(max, "read");
|
|
15882
|
-
const emulated = readDevice(await info(fd), max,
|
|
15961
|
+
const emulated = readDevice(await info(fd), max, random2);
|
|
15883
15962
|
if (emulated) return emulated;
|
|
15884
15963
|
const stop = new AbortController();
|
|
15885
15964
|
const waits = reading.get(fd) ?? /* @__PURE__ */ new Set();
|
|
@@ -15898,13 +15977,23 @@ function pendingReads(kernel, info, random) {
|
|
|
15898
15977
|
for (const stop of reading.get(fd) ?? []) stop.abort(new JsCallError("EBADF", "read"));
|
|
15899
15978
|
reading.delete(fd);
|
|
15900
15979
|
};
|
|
15901
|
-
|
|
15980
|
+
const watch = (fd) => {
|
|
15981
|
+
const stop = new AbortController();
|
|
15982
|
+
const waits = reading.get(fd) ?? /* @__PURE__ */ new Set();
|
|
15983
|
+
reading.set(fd, waits.add(stop));
|
|
15984
|
+
const done = () => {
|
|
15985
|
+
waits.delete(stop);
|
|
15986
|
+
if (waits.size === 0 && reading.get(fd) === waits) reading.delete(fd);
|
|
15987
|
+
};
|
|
15988
|
+
return { signal: stop.signal, done };
|
|
15989
|
+
};
|
|
15990
|
+
return { read: read2, closing, watch };
|
|
15902
15991
|
}
|
|
15903
15992
|
function tracked2(pending, writeAll, writeSome, failed5) {
|
|
15904
15993
|
return (fd, data, options) => {
|
|
15905
15994
|
const status2 = failed5?.();
|
|
15906
15995
|
if (status2 !== void 0) return Promise.reject(new JsExit(status2));
|
|
15907
|
-
const bytes = typeof data === "string" ?
|
|
15996
|
+
const bytes = typeof data === "string" ? encoder5.encode(data) : data;
|
|
15908
15997
|
let settle;
|
|
15909
15998
|
const settled2 = new Promise((resolve2) => settle = resolve2);
|
|
15910
15999
|
pending.add(settled2);
|
|
@@ -15934,6 +16023,12 @@ function measured(measure) {
|
|
|
15934
16023
|
}
|
|
15935
16024
|
return out;
|
|
15936
16025
|
}
|
|
16026
|
+
function realmOps(o) {
|
|
16027
|
+
return {
|
|
16028
|
+
runScript: scriptRunner(o.runScript),
|
|
16029
|
+
promiseState: (promise) => o.promiseState?.(promise)
|
|
16030
|
+
};
|
|
16031
|
+
}
|
|
15937
16032
|
function scriptRunner(run) {
|
|
15938
16033
|
return (source, options = {}) => {
|
|
15939
16034
|
if (typeof source !== "string") throw new TypeError("runScript needs a source string");
|
|
@@ -15953,7 +16048,7 @@ function createContext(o) {
|
|
|
15953
16048
|
const infos = /* @__PURE__ */ new Map();
|
|
15954
16049
|
const handles = /* @__PURE__ */ new Map();
|
|
15955
16050
|
const pending = /* @__PURE__ */ new Set();
|
|
15956
|
-
const
|
|
16051
|
+
const random2 = o.random ?? cryptoRandom;
|
|
15957
16052
|
let held2;
|
|
15958
16053
|
const resolve2 = (path) => resolvePath(cwdFor(o.cwd, held2, path), path);
|
|
15959
16054
|
const tryDev = (abs) => resolveDevAsync(kernel, abs);
|
|
@@ -15974,7 +16069,7 @@ function createContext(o) {
|
|
|
15974
16069
|
infos.set(fd, got);
|
|
15975
16070
|
return got;
|
|
15976
16071
|
};
|
|
15977
|
-
const { read: read2, closing } = pendingReads(kernel, info,
|
|
16072
|
+
const { read: read2, closing, watch } = pendingReads(kernel, info, random2);
|
|
15978
16073
|
const { writes, writeAll, writeSome } = writer(kernel, info, o.pid);
|
|
15979
16074
|
const write2 = tracked2(pending, writeAll, writeSome, o.failed);
|
|
15980
16075
|
const writable2 = (fd) => new WritableStream({
|
|
@@ -16009,7 +16104,7 @@ function createContext(o) {
|
|
|
16009
16104
|
const syncKernel = new JsSyncKernel(lane, kernel, unwind);
|
|
16010
16105
|
held2 = heldOn(o.held, lane, syncKernel);
|
|
16011
16106
|
const terminal = ttyOps(kernel, syncKernel);
|
|
16012
|
-
const shared = { pid: o.pid, resolve: resolve2, random, infos, handles, closing };
|
|
16107
|
+
const shared = { pid: o.pid, resolve: resolve2, random: random2, infos, handles, closing };
|
|
16013
16108
|
const wasi = wasiFor({ lane, pid: o.pid, cwd: o.cwd, resolve: resolve2, fs: o.fs, owned: o.owned });
|
|
16014
16109
|
const sync = {
|
|
16015
16110
|
kernel: KERNEL_INFO,
|
|
@@ -16028,7 +16123,7 @@ function createContext(o) {
|
|
|
16028
16123
|
cred: () => syncKernel.json({ op: "proc-cred" }),
|
|
16029
16124
|
umask: (mask) => syncKernel.json(umaskRequest(mask)),
|
|
16030
16125
|
setcred: setcredOn(syncKernel),
|
|
16031
|
-
|
|
16126
|
+
...realmOps(o)
|
|
16032
16127
|
};
|
|
16033
16128
|
const io = { read: read2, send: writeAll, close: (fd) => ctx.close(fd) };
|
|
16034
16129
|
const defaults = { env: o.env, cwd: o.cwd, signal: signalNumber };
|
|
@@ -16054,7 +16149,7 @@ function createContext(o) {
|
|
|
16054
16149
|
closing(fd);
|
|
16055
16150
|
await kernel.call({ op: "fd-close", fd });
|
|
16056
16151
|
},
|
|
16057
|
-
|
|
16152
|
+
...rightsAsync(kernel, (fd) => infos.delete(fd), watch),
|
|
16058
16153
|
pipe: async () => await kernel.json({ op: "fd-pipe" }),
|
|
16059
16154
|
select: (sets, options) => selectOp(kernel, sets, options?.signal),
|
|
16060
16155
|
async fdStatus(fd) {
|
|
@@ -16079,7 +16174,7 @@ function createContext(o) {
|
|
|
16079
16174
|
cwd: o.cwd,
|
|
16080
16175
|
...o.env.TERM !== void 0 ? { term: o.env.TERM } : {}
|
|
16081
16176
|
}),
|
|
16082
|
-
crontab: async (
|
|
16177
|
+
crontab: async (call3) => await kernel.json({ ...call3, op: "proc-crontab" }),
|
|
16083
16178
|
...children,
|
|
16084
16179
|
net,
|
|
16085
16180
|
websocket: websocketOp(kernel),
|
|
@@ -16284,14 +16379,14 @@ function pathOps(kernel, resolve2, statOf, open, tryDev) {
|
|
|
16284
16379
|
true
|
|
16285
16380
|
);
|
|
16286
16381
|
try {
|
|
16287
|
-
await file.write(0, typeof data === "string" ?
|
|
16382
|
+
await file.write(0, typeof data === "string" ? encoder5.encode(data) : data);
|
|
16288
16383
|
} finally {
|
|
16289
16384
|
await file.close();
|
|
16290
16385
|
}
|
|
16291
16386
|
}
|
|
16292
16387
|
};
|
|
16293
16388
|
}
|
|
16294
|
-
var KERNEL_INFO, JsExit,
|
|
16389
|
+
var KERNEL_INFO, JsExit, encoder5, cryptoRandom, MEMORY_FIELDS;
|
|
16295
16390
|
var init_js_context = __esm({
|
|
16296
16391
|
"src/process/js/js-context.ts"() {
|
|
16297
16392
|
"use strict";
|
|
@@ -16309,6 +16404,7 @@ var init_js_context = __esm({
|
|
|
16309
16404
|
init_js_kernel();
|
|
16310
16405
|
init_js_net();
|
|
16311
16406
|
init_js_proc();
|
|
16407
|
+
init_js_rights();
|
|
16312
16408
|
init_js_run();
|
|
16313
16409
|
init_js_sync();
|
|
16314
16410
|
init_js_tty();
|
|
@@ -16324,7 +16420,7 @@ var init_js_context = __esm({
|
|
|
16324
16420
|
this.status = status2;
|
|
16325
16421
|
}
|
|
16326
16422
|
};
|
|
16327
|
-
|
|
16423
|
+
encoder5 = new TextEncoder();
|
|
16328
16424
|
cryptoRandom = (bytes) => void crypto.getRandomValues(bytes);
|
|
16329
16425
|
MEMORY_FIELDS = [
|
|
16330
16426
|
"heapUsed",
|
|
@@ -16378,7 +16474,7 @@ function started(port3, control) {
|
|
|
16378
16474
|
};
|
|
16379
16475
|
});
|
|
16380
16476
|
}
|
|
16381
|
-
function threadContext(
|
|
16477
|
+
function threadContext(post3, start2) {
|
|
16382
16478
|
const spawn = (options) => {
|
|
16383
16479
|
let asked;
|
|
16384
16480
|
try {
|
|
@@ -16397,7 +16493,7 @@ function threadContext(post2, start2) {
|
|
|
16397
16493
|
transfer
|
|
16398
16494
|
};
|
|
16399
16495
|
try {
|
|
16400
|
-
|
|
16496
|
+
post3.postMessage(msg, [channel.port2, control.port2, ...transfer]);
|
|
16401
16497
|
} catch (err) {
|
|
16402
16498
|
channel.port1.close();
|
|
16403
16499
|
control.port1.close();
|
|
@@ -16510,6 +16606,7 @@ async function runJs(init, port3, deps, thread) {
|
|
|
16510
16606
|
memory: deps.memory,
|
|
16511
16607
|
asyncContext: deps.asyncContext,
|
|
16512
16608
|
runScript: deps.runScript,
|
|
16609
|
+
promiseState: deps.promiseState,
|
|
16513
16610
|
...thread?.owned ? { owned: thread.owned } : {},
|
|
16514
16611
|
held: init.held,
|
|
16515
16612
|
failed: () => failedWith
|
|
@@ -16651,9 +16748,9 @@ var init_wasi_module = __esm({
|
|
|
16651
16748
|
});
|
|
16652
16749
|
|
|
16653
16750
|
// src/process/wasi/wasi-ptsfs.ts
|
|
16654
|
-
function ptsBridge(fs,
|
|
16655
|
-
const open = () =>
|
|
16656
|
-
const kernel = { json: (req) =>
|
|
16751
|
+
function ptsBridge(fs, call3) {
|
|
16752
|
+
const open = () => call3({ op: "pty-list" });
|
|
16753
|
+
const kernel = { json: (req) => call3(req) };
|
|
16657
16754
|
const entry = (p, known = open()) => {
|
|
16658
16755
|
const n = PTS_ENTRY.exec(p)?.[1];
|
|
16659
16756
|
if (n === void 0 || !known.includes(Number(n))) throw syncError("ENOENT", p);
|
|
@@ -17071,8 +17168,8 @@ var init_wasix_fork = __esm({
|
|
|
17071
17168
|
return out;
|
|
17072
17169
|
}
|
|
17073
17170
|
dataPointer() {
|
|
17074
|
-
const
|
|
17075
|
-
if (this.linked && (this.threadStack || !
|
|
17171
|
+
const own2 = this.exports[STACK_POINTER] instanceof WebAssembly.Global;
|
|
17172
|
+
if (this.linked && (this.threadStack || !own2)) return this.linked.low + 15 & ~15;
|
|
17076
17173
|
const g = this.exports.__data_end;
|
|
17077
17174
|
const dataEnd = g instanceof WebAssembly.Global ? g.value : 0;
|
|
17078
17175
|
return dataEnd < this.stackUpper ? dataEnd + 15 & ~15 : 16;
|
|
@@ -17119,9 +17216,9 @@ function write(view, at, type, value2) {
|
|
|
17119
17216
|
else if (type === "f32") view.setFloat32(at, Number(value2), true);
|
|
17120
17217
|
else view.setFloat64(at, Number(value2), true);
|
|
17121
17218
|
}
|
|
17122
|
-
function scalars(
|
|
17123
|
-
if (
|
|
17124
|
-
return
|
|
17219
|
+
function scalars(types2) {
|
|
17220
|
+
if (types2.includes("other")) throw new WasiError("EINVAL");
|
|
17221
|
+
return types2;
|
|
17125
17222
|
}
|
|
17126
17223
|
function callDynamic(ctx, ...operands) {
|
|
17127
17224
|
const [id, values, valuesLen, results, resultsLen, strict] = operands.map((n) => n >>> 0);
|
|
@@ -17132,7 +17229,7 @@ function callDynamic(ctx, ...operands) {
|
|
|
17132
17229
|
if (!fn || !sig) throw new WasiError("EINVAL");
|
|
17133
17230
|
const params = scalars(sig.params);
|
|
17134
17231
|
const outs = scalars(sig.results);
|
|
17135
|
-
const size = (
|
|
17232
|
+
const size = (types2) => types2.reduce((n, type) => n + SIZE2[type], 0);
|
|
17136
17233
|
if (strict && (size(params) !== valuesLen || size(outs) !== resultsLen)) {
|
|
17137
17234
|
throw new WasiError("EINVAL");
|
|
17138
17235
|
}
|
|
@@ -17569,7 +17666,7 @@ function growTo(memory, bytes) {
|
|
|
17569
17666
|
function growTable(table, length) {
|
|
17570
17667
|
if (table.length < length) table.grow(length - table.length);
|
|
17571
17668
|
}
|
|
17572
|
-
function
|
|
17669
|
+
function call2(instance, name2) {
|
|
17573
17670
|
const fn = instance.exports[name2];
|
|
17574
17671
|
if (typeof fn === "function") fn();
|
|
17575
17672
|
}
|
|
@@ -17668,7 +17765,7 @@ var init_wasix_linker = __esm({
|
|
|
17668
17765
|
}
|
|
17669
17766
|
bindMain(instance, relocate) {
|
|
17670
17767
|
this.main = instance;
|
|
17671
|
-
if (relocate)
|
|
17768
|
+
if (relocate) call2(instance, "__wasm_apply_data_relocs");
|
|
17672
17769
|
}
|
|
17673
17770
|
mainPath;
|
|
17674
17771
|
isMain(path) {
|
|
@@ -17904,10 +18001,10 @@ var init_wasix_linker = __esm({
|
|
|
17904
18001
|
if (!first || at.handle < first.handle) this.byPath.set(path, linked);
|
|
17905
18002
|
for (const resolve2 of pending) resolve2();
|
|
17906
18003
|
if (init) {
|
|
17907
|
-
|
|
17908
|
-
|
|
18004
|
+
call2(linked.instance, "__wasm_apply_data_relocs");
|
|
18005
|
+
call2(linked.instance, "__wasm_call_ctors");
|
|
17909
18006
|
} else if (!this.carryTls(linked)) {
|
|
17910
|
-
|
|
18007
|
+
call2(linked.instance, "__wasix_init_tls");
|
|
17911
18008
|
}
|
|
17912
18009
|
return linked;
|
|
17913
18010
|
}
|
|
@@ -18716,20 +18813,20 @@ function kernelOf(init, port3, hooks = { masks: () => null, raise: () => {
|
|
|
18716
18813
|
);
|
|
18717
18814
|
const transport = gate.transport();
|
|
18718
18815
|
const sys = kernelSys(transport);
|
|
18719
|
-
const
|
|
18816
|
+
const call3 = (req) => {
|
|
18720
18817
|
const r = transport.call(req, Number.POSITIVE_INFINITY, req.op);
|
|
18721
18818
|
if (!r.ok) throw new SyscallError(r.errno);
|
|
18722
18819
|
return r.kind === "json" ? r.json : r.kind === "bytes" ? r.bytes : void 0;
|
|
18723
18820
|
};
|
|
18724
18821
|
const say = (text) => sys.write(2, new TextEncoder().encode(`${init.argv0}: ${text}
|
|
18725
18822
|
`));
|
|
18726
|
-
return { transport, sys, call:
|
|
18823
|
+
return { transport, sys, call: call3, say, gate };
|
|
18727
18824
|
}
|
|
18728
18825
|
function traced(stats, tag, table) {
|
|
18729
18826
|
return stats ? stats.wrap(tag, table) : table;
|
|
18730
18827
|
}
|
|
18731
|
-
function timedCalls(stats,
|
|
18732
|
-
return (req) => stats.time(`kernel.${req.op}`, () =>
|
|
18828
|
+
function timedCalls(stats, call3) {
|
|
18829
|
+
return (req) => stats.time(`kernel.${req.op}`, () => call3(req));
|
|
18733
18830
|
}
|
|
18734
18831
|
function report(stats, sys) {
|
|
18735
18832
|
stats.phase("run");
|
|
@@ -18752,8 +18849,8 @@ function threadStackLow(memory, start2) {
|
|
|
18752
18849
|
return stack - size;
|
|
18753
18850
|
}
|
|
18754
18851
|
function ownStack(driver, instance, linked, low) {
|
|
18755
|
-
const
|
|
18756
|
-
const pointer =
|
|
18852
|
+
const own2 = instance.exports.__stack_pointer;
|
|
18853
|
+
const pointer = own2 instanceof WebAssembly.Global ? own2 : linked;
|
|
18757
18854
|
if (!pointer) return false;
|
|
18758
18855
|
driver.useThreadStack(pointer, low);
|
|
18759
18856
|
return true;
|
|
@@ -18863,11 +18960,11 @@ function bindLinker(host, sync, instance, at) {
|
|
|
18863
18960
|
if (at.thread || at.forked) sync.catchUp();
|
|
18864
18961
|
sync.linker.bindMainGot();
|
|
18865
18962
|
}
|
|
18866
|
-
function procTree(
|
|
18963
|
+
function procTree(call3, pid) {
|
|
18867
18964
|
return new ProcTree(
|
|
18868
18965
|
{
|
|
18869
|
-
procList: () =>
|
|
18870
|
-
mountList: () =>
|
|
18966
|
+
procList: () => call3({ op: "proc-list" }),
|
|
18967
|
+
mountList: () => call3({ op: "mount-list" })
|
|
18871
18968
|
},
|
|
18872
18969
|
pid
|
|
18873
18970
|
);
|
|
@@ -18909,16 +19006,16 @@ function ownersOf(init) {
|
|
|
18909
19006
|
...init.changes ? { changes: init.changes } : {}
|
|
18910
19007
|
};
|
|
18911
19008
|
}
|
|
18912
|
-
function heldOf2(init,
|
|
19009
|
+
function heldOf2(init, call3) {
|
|
18913
19010
|
const { held: held2 } = init;
|
|
18914
19011
|
if (!held2) return {};
|
|
18915
|
-
const ask = () =>
|
|
19012
|
+
const ask = () => call3({ op: "cwd-check" });
|
|
18916
19013
|
return { held: new HeldCwd(held2.sab, held2.slot, ask, { ...held2, path: init.cwd }) };
|
|
18917
19014
|
}
|
|
18918
19015
|
async function runWasiProcess(init, port3) {
|
|
18919
19016
|
captureBacktraces(init.env);
|
|
18920
19017
|
const signals = new WasiSignals(
|
|
18921
|
-
takeDefault((req) =>
|
|
19018
|
+
takeDefault((req) => call3(req), init.pid),
|
|
18922
19019
|
(code2) => {
|
|
18923
19020
|
throw new WasiExit(code2);
|
|
18924
19021
|
}
|
|
@@ -18933,7 +19030,7 @@ async function runWasiProcess(init, port3) {
|
|
|
18933
19030
|
} = kernelOf(init, port3, signals, sizeOf2(main));
|
|
18934
19031
|
const id = identify(transport, init);
|
|
18935
19032
|
const stats = init.env.SLICC_WASI_STATS === "1" ? new WasiStats() : void 0;
|
|
18936
|
-
const
|
|
19033
|
+
const call3 = stats ? timedCalls(stats, kernelCall) : kernelCall;
|
|
18937
19034
|
const { module } = init.program;
|
|
18938
19035
|
const refused3 = unsupportedImport(
|
|
18939
19036
|
module,
|
|
@@ -18955,7 +19052,7 @@ async function runWasiProcess(init, port3) {
|
|
|
18955
19052
|
pid: id.pid,
|
|
18956
19053
|
ppid: id.ppid,
|
|
18957
19054
|
parent: () => identify(transport, init).ppid,
|
|
18958
|
-
kernel: { sys: traced(stats, "kernel", sys), call:
|
|
19055
|
+
kernel: { sys: traced(stats, "kernel", sys), call: call3 },
|
|
18959
19056
|
fs: ptsBridge(
|
|
18960
19057
|
procfsBridge(
|
|
18961
19058
|
cachingBridge(
|
|
@@ -18967,12 +19064,12 @@ async function runWasiProcess(init, port3) {
|
|
|
18967
19064
|
void 0,
|
|
18968
19065
|
threads?.ids
|
|
18969
19066
|
),
|
|
18970
|
-
procTree(
|
|
19067
|
+
procTree(call3, id.pid)
|
|
18971
19068
|
),
|
|
18972
|
-
|
|
19069
|
+
call3
|
|
18973
19070
|
),
|
|
18974
19071
|
...descriptors(init, fork, threads),
|
|
18975
|
-
...heldOf2(init,
|
|
19072
|
+
...heldOf2(init, call3),
|
|
18976
19073
|
...threads ? { credGen: threads.ids } : {}
|
|
18977
19074
|
});
|
|
18978
19075
|
host.sigmask = sigmaskOf(module, init.sab, gate, threads);
|
|
@@ -19066,11 +19163,11 @@ function captureBacktraces(env) {
|
|
|
19066
19163
|
async function runWasiThread(init, port3) {
|
|
19067
19164
|
captureBacktraces(init.env);
|
|
19068
19165
|
const { thread } = init;
|
|
19069
|
-
const { transport, sys, call:
|
|
19166
|
+
const { transport, sys, call: call3, say, gate } = kernelOf(init, port3, {
|
|
19070
19167
|
masks: () => null,
|
|
19071
19168
|
raise: (sig) => signals.raise(sig)
|
|
19072
19169
|
});
|
|
19073
|
-
const signals = new WasiSignals(takeThreadDefault(
|
|
19170
|
+
const signals = new WasiSignals(takeThreadDefault(call3, init.pid));
|
|
19074
19171
|
const threads = new WasiThreads(port3, thread.memory, threadCap(init.env), thread.tid, thread.ids);
|
|
19075
19172
|
threads.received = thread.modules;
|
|
19076
19173
|
const id = identify(transport, init);
|
|
@@ -19081,7 +19178,7 @@ async function runWasiThread(init, port3) {
|
|
|
19081
19178
|
pid: id.pid,
|
|
19082
19179
|
ppid: id.ppid,
|
|
19083
19180
|
parent: () => identify(transport, init).ppid,
|
|
19084
|
-
kernel: { sys, call:
|
|
19181
|
+
kernel: { sys, call: call3 },
|
|
19085
19182
|
fs: ptsBridge(
|
|
19086
19183
|
procfsBridge(
|
|
19087
19184
|
cachingBridge(
|
|
@@ -19089,12 +19186,12 @@ async function runWasiThread(init, port3) {
|
|
|
19089
19186
|
void 0,
|
|
19090
19187
|
threads.ids
|
|
19091
19188
|
),
|
|
19092
|
-
procTree(
|
|
19189
|
+
procTree(call3, id.pid)
|
|
19093
19190
|
),
|
|
19094
|
-
|
|
19191
|
+
call3
|
|
19095
19192
|
),
|
|
19096
19193
|
shared: threads.ids,
|
|
19097
|
-
...heldOf2(init,
|
|
19194
|
+
...heldOf2(init, call3)
|
|
19098
19195
|
});
|
|
19099
19196
|
host.tid = thread.tid;
|
|
19100
19197
|
host.sigmask = sigmaskOf(init.program.module, init.sab, gate, threads, init.signals);
|
|
@@ -19173,17 +19270,17 @@ var init_wasi_runtime = __esm({
|
|
|
19173
19270
|
WASIX = "wasix_32v1";
|
|
19174
19271
|
SLICC = "slicc";
|
|
19175
19272
|
SIGNAL_CALLBACK = "__wasm_signal";
|
|
19176
|
-
takeDefault = (
|
|
19177
|
-
|
|
19273
|
+
takeDefault = (call3, pid) => (sig) => {
|
|
19274
|
+
call3({ op: "proc-kill", pid, sig });
|
|
19178
19275
|
if (defaultAction(sig) === "terminate") throw new WasiExit(128 + sig);
|
|
19179
19276
|
};
|
|
19180
|
-
takeThreadDefault = (
|
|
19277
|
+
takeThreadDefault = (call3, pid) => (sig) => {
|
|
19181
19278
|
if (defaultAction(sig) !== "terminate") {
|
|
19182
|
-
|
|
19279
|
+
call3({ op: "proc-kill", pid, sig });
|
|
19183
19280
|
return;
|
|
19184
19281
|
}
|
|
19185
19282
|
try {
|
|
19186
|
-
|
|
19283
|
+
call3({ op: "proc-kill-self", sig });
|
|
19187
19284
|
} catch {
|
|
19188
19285
|
}
|
|
19189
19286
|
throw new WasiExit(128 + sig);
|
|
@@ -19213,9 +19310,9 @@ var init_wasi_runtime = __esm({
|
|
|
19213
19310
|
call;
|
|
19214
19311
|
ids;
|
|
19215
19312
|
owner;
|
|
19216
|
-
constructor(linker,
|
|
19313
|
+
constructor(linker, call3, threads) {
|
|
19217
19314
|
this.linker = linker;
|
|
19218
|
-
this.call =
|
|
19315
|
+
this.call = call3;
|
|
19219
19316
|
this.ids = threads?.ids;
|
|
19220
19317
|
this.owner = threads?.tid ?? 0;
|
|
19221
19318
|
linker.publisher = (record) => this.publish(record);
|
|
@@ -19300,6 +19397,7 @@ init_lockdown();
|
|
|
19300
19397
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
19301
19398
|
import { isBuiltin, registerHooks } from "node:module";
|
|
19302
19399
|
import { resolve, sep } from "node:path";
|
|
19400
|
+
import { types } from "node:util";
|
|
19303
19401
|
import { getHeapStatistics } from "node:v8";
|
|
19304
19402
|
import { runInThisContext } from "node:vm";
|
|
19305
19403
|
var NODE_GLOBALS = ["localStorage", "sessionStorage"];
|
|
@@ -19410,6 +19508,189 @@ function nodeRunScript(source, filename) {
|
|
|
19410
19508
|
options.filename = filename;
|
|
19411
19509
|
return freeze({ value: runHere(source, options), completion: true });
|
|
19412
19510
|
}
|
|
19511
|
+
var isPromise = types.isPromise;
|
|
19512
|
+
var here = globalThis;
|
|
19513
|
+
var define = Reflect.defineProperty;
|
|
19514
|
+
var remove = Reflect.deleteProperty;
|
|
19515
|
+
var call = Reflect.apply;
|
|
19516
|
+
var hasOwn = Object.hasOwn;
|
|
19517
|
+
var stringify = JSON.stringify;
|
|
19518
|
+
var endsWith = String.prototype.endsWith;
|
|
19519
|
+
var sliceOf = String.prototype.slice;
|
|
19520
|
+
var toHex = Number.prototype.toString;
|
|
19521
|
+
var random = Math.random;
|
|
19522
|
+
var makeBigInt = BigInt;
|
|
19523
|
+
var builtin = process.getBuiltinModule.bind(process);
|
|
19524
|
+
var find = Array.prototype.find;
|
|
19525
|
+
var keysOf = Object.keys;
|
|
19526
|
+
var nothing = Object.create;
|
|
19527
|
+
var isList = Array.isArray;
|
|
19528
|
+
var seal = Object.freeze;
|
|
19529
|
+
var ownKeys = Reflect.ownKeys;
|
|
19530
|
+
var ownDescriptor = Reflect.getOwnPropertyDescriptor;
|
|
19531
|
+
var BASE = Object.prototype;
|
|
19532
|
+
function snapshot(of) {
|
|
19533
|
+
const keys = ownKeys(of);
|
|
19534
|
+
const out = [];
|
|
19535
|
+
for (let i = 0; i < keys.length; i++) {
|
|
19536
|
+
const key = keys[i];
|
|
19537
|
+
out[i] = [key, ownDescriptor(of, key)];
|
|
19538
|
+
}
|
|
19539
|
+
return out;
|
|
19540
|
+
}
|
|
19541
|
+
function sameDescriptor(a, b) {
|
|
19542
|
+
if (a === void 0 || b === void 0) return a === b;
|
|
19543
|
+
for (let i = 0; i < FIELDS.length; i++) {
|
|
19544
|
+
const field2 = FIELDS[i];
|
|
19545
|
+
if (own(a, field2) !== own(b, field2)) return false;
|
|
19546
|
+
}
|
|
19547
|
+
return true;
|
|
19548
|
+
}
|
|
19549
|
+
var FIELDS = ["value", "get", "set", "writable", "enumerable", "configurable"];
|
|
19550
|
+
var BASE_SNAPSHOT = snapshot(BASE);
|
|
19551
|
+
function baseUnchanged() {
|
|
19552
|
+
const keys = ownKeys(BASE);
|
|
19553
|
+
if (keys.length !== BASE_SNAPSHOT.length) return false;
|
|
19554
|
+
for (let i = 0; i < keys.length; i++) {
|
|
19555
|
+
const was = BASE_SNAPSHOT[i];
|
|
19556
|
+
if (keys[i] !== was[0]) return false;
|
|
19557
|
+
if (!sameDescriptor(ownDescriptor(BASE, keys[i]), was[1])) return false;
|
|
19558
|
+
}
|
|
19559
|
+
return true;
|
|
19560
|
+
}
|
|
19561
|
+
var SERIALIZED = [Array.prototype, String.prototype, Number.prototype, Boolean.prototype];
|
|
19562
|
+
function untouched() {
|
|
19563
|
+
if (!baseUnchanged()) return false;
|
|
19564
|
+
for (let i = 0; i < SERIALIZED.length; i++) {
|
|
19565
|
+
if (ownDescriptor(SERIALIZED[i], "toJSON") !== void 0) return false;
|
|
19566
|
+
}
|
|
19567
|
+
return true;
|
|
19568
|
+
}
|
|
19569
|
+
var Failure = Error;
|
|
19570
|
+
var WrongType = TypeError;
|
|
19571
|
+
function own(from, key) {
|
|
19572
|
+
return typeof from === "object" && from !== null && hasOwn(from, key) ? from[key] : void 0;
|
|
19573
|
+
}
|
|
19574
|
+
function bare(fields) {
|
|
19575
|
+
const out = nothing(null);
|
|
19576
|
+
const keys = keysOf(fields);
|
|
19577
|
+
for (let i = 0; i < keys.length; i++) out[keys[i]] = fields[keys[i]];
|
|
19578
|
+
return out;
|
|
19579
|
+
}
|
|
19580
|
+
var session;
|
|
19581
|
+
var inspectorGone = false;
|
|
19582
|
+
var probing = false;
|
|
19583
|
+
function post(method, params) {
|
|
19584
|
+
let out;
|
|
19585
|
+
let failed5;
|
|
19586
|
+
let done = false;
|
|
19587
|
+
call(session.post, session, [
|
|
19588
|
+
method,
|
|
19589
|
+
bare(params),
|
|
19590
|
+
(err, result) => {
|
|
19591
|
+
failed5 = err;
|
|
19592
|
+
out = result;
|
|
19593
|
+
done = true;
|
|
19594
|
+
}
|
|
19595
|
+
]);
|
|
19596
|
+
if (!done) throw new Failure("slicc-kernel: the inspector did not answer synchronously");
|
|
19597
|
+
if (failed5) throw failed5;
|
|
19598
|
+
return out;
|
|
19599
|
+
}
|
|
19600
|
+
function inspectorSession(load) {
|
|
19601
|
+
try {
|
|
19602
|
+
const made = new (load()).Session();
|
|
19603
|
+
made.connect();
|
|
19604
|
+
return made;
|
|
19605
|
+
} catch {
|
|
19606
|
+
return void 0;
|
|
19607
|
+
}
|
|
19608
|
+
}
|
|
19609
|
+
function connected() {
|
|
19610
|
+
if (session) return true;
|
|
19611
|
+
if (inspectorGone) return false;
|
|
19612
|
+
session = inspectorSession(() => builtin("node:inspector"));
|
|
19613
|
+
inspectorGone = session === void 0;
|
|
19614
|
+
return !inspectorGone;
|
|
19615
|
+
}
|
|
19616
|
+
function idOf(key, value2, group) {
|
|
19617
|
+
if (!define(here, key, { __proto__: null, value: value2, configurable: true })) {
|
|
19618
|
+
return void 0;
|
|
19619
|
+
}
|
|
19620
|
+
const result = own(
|
|
19621
|
+
post("Runtime.evaluate", {
|
|
19622
|
+
expression: `this[${stringify(key)}]`,
|
|
19623
|
+
objectGroup: group,
|
|
19624
|
+
includeCommandLineAPI: false,
|
|
19625
|
+
silent: true,
|
|
19626
|
+
returnByValue: false,
|
|
19627
|
+
generatePreview: false
|
|
19628
|
+
}),
|
|
19629
|
+
"result"
|
|
19630
|
+
);
|
|
19631
|
+
return own(result, "objectId");
|
|
19632
|
+
}
|
|
19633
|
+
function primitive(remote) {
|
|
19634
|
+
const raw = own(remote, "unserializableValue");
|
|
19635
|
+
if (typeof raw !== "string") return own(remote, "value");
|
|
19636
|
+
if (call(endsWith, raw, ["n"])) return makeBigInt(call(sliceOf, raw, [0, -1]));
|
|
19637
|
+
if (raw === "NaN") return 0 / 0;
|
|
19638
|
+
if (raw === "-0") return -0;
|
|
19639
|
+
return raw === "Infinity" ? 1 / 0 : -1 / 0;
|
|
19640
|
+
}
|
|
19641
|
+
function internal(list, name2) {
|
|
19642
|
+
if (!isList(list)) return void 0;
|
|
19643
|
+
return own(call(find, list, [(item) => own(item, "name") === name2]), "value");
|
|
19644
|
+
}
|
|
19645
|
+
function probe(promise, group, key) {
|
|
19646
|
+
const promiseId = idOf(key, promise, group);
|
|
19647
|
+
if (promiseId === void 0) return void 0;
|
|
19648
|
+
const found = own(
|
|
19649
|
+
post("Runtime.getProperties", {
|
|
19650
|
+
objectId: promiseId,
|
|
19651
|
+
ownProperties: true,
|
|
19652
|
+
generatePreview: false
|
|
19653
|
+
}),
|
|
19654
|
+
"internalProperties"
|
|
19655
|
+
);
|
|
19656
|
+
const state = own(internal(found, "[[PromiseState]]"), "value");
|
|
19657
|
+
if (state === "pending") return seal({ state, value: void 0 });
|
|
19658
|
+
const result = internal(found, "[[PromiseResult]]");
|
|
19659
|
+
const resultId = own(result, "objectId");
|
|
19660
|
+
if (typeof resultId !== "string") return seal({ state, value: primitive(result) });
|
|
19661
|
+
const holder = nothing(null);
|
|
19662
|
+
const holderId = idOf(key, holder, group);
|
|
19663
|
+
if (holderId === void 0) return void 0;
|
|
19664
|
+
post("Runtime.callFunctionOn", {
|
|
19665
|
+
objectId: resultId,
|
|
19666
|
+
functionDeclaration: 'function (h) { "use strict"; h.v = this; }',
|
|
19667
|
+
arguments: [bare({ objectId: holderId })],
|
|
19668
|
+
objectGroup: group,
|
|
19669
|
+
silent: true,
|
|
19670
|
+
returnByValue: false,
|
|
19671
|
+
generatePreview: false
|
|
19672
|
+
});
|
|
19673
|
+
return seal({ state, value: holder.v });
|
|
19674
|
+
}
|
|
19675
|
+
function nodePromiseState(promise) {
|
|
19676
|
+
if (!isPromise(promise)) throw new WrongType("promiseState needs a native promise");
|
|
19677
|
+
if (probing) throw new Failure("slicc-kernel: promiseState is already running");
|
|
19678
|
+
if (!untouched() || !connected()) return void 0;
|
|
19679
|
+
probing = true;
|
|
19680
|
+
const tag = call(toHex, random() * 2 ** 52, [16]);
|
|
19681
|
+
const group = `slicc-promise-${tag}`;
|
|
19682
|
+
const key = `__slicc_promise_${tag}`;
|
|
19683
|
+
try {
|
|
19684
|
+
return probe(promise, group, key);
|
|
19685
|
+
} finally {
|
|
19686
|
+
remove(here, key);
|
|
19687
|
+
try {
|
|
19688
|
+
post("Runtime.releaseObjectGroup", { objectGroup: group });
|
|
19689
|
+
} finally {
|
|
19690
|
+
probing = false;
|
|
19691
|
+
}
|
|
19692
|
+
}
|
|
19693
|
+
}
|
|
19413
19694
|
var Storage = AsyncLocalStorage;
|
|
19414
19695
|
var apply = Reflect.apply;
|
|
19415
19696
|
var freeze = Object.freeze;
|
|
@@ -19448,7 +19729,7 @@ function started2(init, port3, run, wasi, js) {
|
|
|
19448
19729
|
if (wasmInit.program?.abi === "wasi") return wasi().then((m) => m.runWasiProcess(wasmInit, port3));
|
|
19449
19730
|
return run(wasmInit, port3);
|
|
19450
19731
|
}
|
|
19451
|
-
function processEntry(port3, run = runWasmProcess, wasi = loadWasi, js = loadJs,
|
|
19732
|
+
function processEntry(port3, run = runWasmProcess, wasi = loadWasi, js = loadJs, seal2 = () => {
|
|
19452
19733
|
}) {
|
|
19453
19734
|
const failed5 = (err, code2) => port3.postMessage({
|
|
19454
19735
|
type: WASM_PROCESS_ERROR,
|
|
@@ -19459,7 +19740,7 @@ function processEntry(port3, run = runWasmProcess, wasi = loadWasi, js = loadJs,
|
|
|
19459
19740
|
const sealOnce = () => {
|
|
19460
19741
|
if (refused3 === void 0) {
|
|
19461
19742
|
try {
|
|
19462
|
-
|
|
19743
|
+
seal2();
|
|
19463
19744
|
refused3 = null;
|
|
19464
19745
|
} catch (error) {
|
|
19465
19746
|
refused3 = { error };
|
|
@@ -19508,12 +19789,12 @@ var cacheDir = workerData?.compileCache;
|
|
|
19508
19789
|
var cached = typeof cacheDir === "string" && ownCache(cacheDir, enableCompileCache(cacheDir));
|
|
19509
19790
|
var imported = cached ? () => flushCompileCache() : void 0;
|
|
19510
19791
|
var port2 = parentPort;
|
|
19511
|
-
var
|
|
19792
|
+
var post2 = {
|
|
19512
19793
|
postMessage: (message2, transfer) => port2.postMessage(message2, transfer)
|
|
19513
19794
|
};
|
|
19514
19795
|
var strayScope = nodeProcess ? { process: nodeProcess } : {};
|
|
19515
19796
|
var onMessage = processEntry(
|
|
19516
|
-
|
|
19797
|
+
post2,
|
|
19517
19798
|
(init, at) => {
|
|
19518
19799
|
workerShaped(globalThis, glueUrl(init.program?.path));
|
|
19519
19800
|
return runWasmProcess(init, at);
|
|
@@ -19526,6 +19807,7 @@ var onMessage = processEntry(
|
|
|
19526
19807
|
memory: nodeMemory,
|
|
19527
19808
|
asyncContext: nodeAsyncContext,
|
|
19528
19809
|
runScript: nodeRunScript,
|
|
19810
|
+
promiseState: nodePromiseState,
|
|
19529
19811
|
imported
|
|
19530
19812
|
}),
|
|
19531
19813
|
runJsThread: (init, at) => runJsThread(init, at, {
|
|
@@ -19534,6 +19816,7 @@ var onMessage = processEntry(
|
|
|
19534
19816
|
memory: nodeMemory,
|
|
19535
19817
|
asyncContext: nodeAsyncContext,
|
|
19536
19818
|
runScript: nodeRunScript,
|
|
19819
|
+
promiseState: nodePromiseState,
|
|
19537
19820
|
imported
|
|
19538
19821
|
})
|
|
19539
19822
|
}),
|