@ai-ecoverse/slicc-kernel 1.128.0 → 1.128.1
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 +11 -5
- package/dist/kernel-worker.js +435 -345
- package/dist/kernel-worker.js.map +4 -4
- package/dist/meta.js +5 -2
- package/dist/meta.js.map +2 -2
- package/dist/node-process-worker.js +1 -1
- package/dist/node.js +1 -1
- package/dist/node.js.map +2 -2
- package/dist/process-worker.js +1 -1
- package/dist/types/fs/meta.d.ts +1 -0
- package/dist/types/fs/roots.d.ts +3 -0
- package/dist/types/serve.d.ts +1 -0
- package/package.json +3 -3
package/dist/kernel-worker.js
CHANGED
|
@@ -185,8 +185,8 @@ var IndexedDbMeta = class {
|
|
|
185
185
|
const [transaction, store] = this.transaction("readonly");
|
|
186
186
|
const found = /* @__PURE__ */ new Map();
|
|
187
187
|
for (const path of missing4) {
|
|
188
|
-
const
|
|
189
|
-
|
|
188
|
+
const request3 = store.get(path);
|
|
189
|
+
request3.onsuccess = () => void found.set(path, request3.result ?? null);
|
|
190
190
|
}
|
|
191
191
|
await settle(transaction, () => void 0);
|
|
192
192
|
if (generation === this.generation)
|
|
@@ -202,16 +202,16 @@ var IndexedDbMeta = class {
|
|
|
202
202
|
const requests = paths.map((path) => store.get(path));
|
|
203
203
|
return settle(
|
|
204
204
|
transaction,
|
|
205
|
-
() => requests.map((
|
|
205
|
+
() => requests.map((request3) => request3.result ?? void 0)
|
|
206
206
|
);
|
|
207
207
|
}
|
|
208
208
|
async update(path, change) {
|
|
209
209
|
this.settleRemoves();
|
|
210
210
|
const [transaction, store] = this.transaction("readwrite");
|
|
211
|
-
const
|
|
211
|
+
const request3 = store.get(path);
|
|
212
212
|
let next3;
|
|
213
|
-
|
|
214
|
-
next3 = change(
|
|
213
|
+
request3.onsuccess = () => {
|
|
214
|
+
next3 = change(request3.result);
|
|
215
215
|
if (next3) store.put(next3);
|
|
216
216
|
else store.delete(path);
|
|
217
217
|
};
|
|
@@ -225,9 +225,9 @@ var IndexedDbMeta = class {
|
|
|
225
225
|
const [transaction, store] = this.transaction("readwrite");
|
|
226
226
|
const next3 = /* @__PURE__ */ new Map();
|
|
227
227
|
for (const { path, change } of changes) {
|
|
228
|
-
const
|
|
229
|
-
|
|
230
|
-
const entry = change(
|
|
228
|
+
const request3 = store.get(path);
|
|
229
|
+
request3.onsuccess = () => {
|
|
230
|
+
const entry = change(request3.result);
|
|
231
231
|
next3.set(path, entry ?? null);
|
|
232
232
|
if (entry) store.put(entry);
|
|
233
233
|
else store.delete(path);
|
|
@@ -301,9 +301,9 @@ var IndexedDbMeta = class {
|
|
|
301
301
|
this.removing = /* @__PURE__ */ new Map();
|
|
302
302
|
const [transaction, store] = this.transaction("readwrite");
|
|
303
303
|
for (const [path, seen] of batch) {
|
|
304
|
-
const
|
|
305
|
-
|
|
306
|
-
if (
|
|
304
|
+
const request3 = store.get(path);
|
|
305
|
+
request3.onsuccess = () => {
|
|
306
|
+
if (request3.result && JSON.stringify(request3.result) === seen) store.delete(path);
|
|
307
307
|
};
|
|
308
308
|
}
|
|
309
309
|
const paths = [...batch.keys()];
|
|
@@ -312,8 +312,8 @@ var IndexedDbMeta = class {
|
|
|
312
312
|
async links(dir) {
|
|
313
313
|
this.settleRemoves();
|
|
314
314
|
const [transaction, store] = this.transaction("readonly");
|
|
315
|
-
const
|
|
316
|
-
return settle(transaction, () =>
|
|
315
|
+
const request3 = store.index("dir").getAll(dir);
|
|
316
|
+
return settle(transaction, () => request3.result);
|
|
317
317
|
}
|
|
318
318
|
async under(path) {
|
|
319
319
|
this.settleRemoves();
|
|
@@ -330,22 +330,25 @@ var IndexedDbMeta = class {
|
|
|
330
330
|
async all() {
|
|
331
331
|
this.settleRemoves();
|
|
332
332
|
const [transaction, store] = this.transaction("readonly");
|
|
333
|
-
const
|
|
334
|
-
return settle(transaction, () =>
|
|
333
|
+
const request3 = store.getAll();
|
|
334
|
+
return settle(transaction, () => request3.result);
|
|
335
335
|
}
|
|
336
336
|
};
|
|
337
|
-
function
|
|
337
|
+
function openMetaDb(name2, factory) {
|
|
338
338
|
return new Promise((resolve2, reject) => {
|
|
339
|
-
const
|
|
340
|
-
|
|
339
|
+
const request3 = factory.open(name2, META_VERSION);
|
|
340
|
+
request3.onupgradeneeded = (event) => {
|
|
341
341
|
if (event.oldVersion < 1) {
|
|
342
|
-
|
|
342
|
+
request3.result.createObjectStore(META_STORE, { keyPath: "path" }).createIndex("dir", "dir");
|
|
343
343
|
}
|
|
344
344
|
};
|
|
345
|
-
|
|
346
|
-
|
|
345
|
+
request3.onsuccess = () => resolve2(request3.result);
|
|
346
|
+
request3.onerror = () => reject(request3.error);
|
|
347
347
|
});
|
|
348
348
|
}
|
|
349
|
+
async function openMeta(name2, factory) {
|
|
350
|
+
return new IndexedDbMeta(await openMetaDb(name2, factory));
|
|
351
|
+
}
|
|
349
352
|
|
|
350
353
|
// src/fs/types.ts
|
|
351
354
|
function rangedOps(fs) {
|
|
@@ -689,37 +692,37 @@ function missing(err) {
|
|
|
689
692
|
return code === "ENOENT" || code === "ENOTDIR";
|
|
690
693
|
}
|
|
691
694
|
async function resolved(fs, path, follow2, hops = []) {
|
|
692
|
-
let
|
|
695
|
+
let done5 = [];
|
|
693
696
|
let todo = partsOf(path);
|
|
694
697
|
for (let links = 0; todo.length > 0; ) {
|
|
695
698
|
const part = todo.shift();
|
|
696
699
|
if (part === "..") {
|
|
697
|
-
|
|
700
|
+
done5.pop();
|
|
698
701
|
continue;
|
|
699
702
|
}
|
|
700
703
|
if (todo.length === 0 && !follow2) {
|
|
701
|
-
|
|
704
|
+
done5.push(part);
|
|
702
705
|
break;
|
|
703
706
|
}
|
|
704
|
-
const at = `/${[...
|
|
707
|
+
const at = `/${[...done5, part].join("/")}`;
|
|
705
708
|
const st = await fs.lstat(at).catch((err) => {
|
|
706
709
|
if (missing(err)) return void 0;
|
|
707
710
|
throw err;
|
|
708
711
|
});
|
|
709
712
|
if (!st) {
|
|
710
|
-
return normalizePath([...
|
|
713
|
+
return normalizePath([...done5, part, ...todo].join("/"));
|
|
711
714
|
}
|
|
712
715
|
if (!st.isSymbolicLink) {
|
|
713
|
-
|
|
716
|
+
done5.push(part);
|
|
714
717
|
continue;
|
|
715
718
|
}
|
|
716
719
|
if (++links > MAX_LINKS) throw fsError("ELOOP", path);
|
|
717
720
|
hops.push(normalizePath([at, ...todo].join("/")));
|
|
718
721
|
const link2 = await fs.readlink(at);
|
|
719
|
-
if (link2.startsWith("/"))
|
|
722
|
+
if (link2.startsWith("/")) done5 = [];
|
|
720
723
|
todo = [...partsOf(link2), ...todo];
|
|
721
724
|
}
|
|
722
|
-
return `/${
|
|
725
|
+
return `/${done5.join("/")}`;
|
|
723
726
|
}
|
|
724
727
|
async function namesOf(fs, path) {
|
|
725
728
|
const lexical2 = normalizePath(path);
|
|
@@ -1034,16 +1037,16 @@ var RemoteWatch = class {
|
|
|
1034
1037
|
this.channel.postMessage({ tab: this.tab, paths: this.mine, seq: seq2 });
|
|
1035
1038
|
if (this.peers.size === 0) return Promise.resolve();
|
|
1036
1039
|
return new Promise((resolve2) => {
|
|
1037
|
-
const
|
|
1040
|
+
const done5 = () => {
|
|
1038
1041
|
clearTimeout(timer);
|
|
1039
1042
|
this.waiting.delete(seq2);
|
|
1040
1043
|
resolve2();
|
|
1041
1044
|
};
|
|
1042
1045
|
const timer = setTimeout(() => {
|
|
1043
|
-
|
|
1046
|
+
done5();
|
|
1044
1047
|
void this.prune();
|
|
1045
1048
|
}, ANNOUNCE_WAIT_MS);
|
|
1046
|
-
this.waiting.set(seq2, { left: new Set(this.peers), done:
|
|
1049
|
+
this.waiting.set(seq2, { left: new Set(this.peers), done: done5 });
|
|
1047
1050
|
});
|
|
1048
1051
|
}
|
|
1049
1052
|
emit(change) {
|
|
@@ -1201,11 +1204,11 @@ async function openSync(handle) {
|
|
|
1201
1204
|
}
|
|
1202
1205
|
}
|
|
1203
1206
|
function writeAll(access2, at, bytes) {
|
|
1204
|
-
for (let
|
|
1205
|
-
const n = access2.write(bytes.subarray(
|
|
1207
|
+
for (let done5 = 0; done5 < bytes.length; ) {
|
|
1208
|
+
const n = access2.write(bytes.subarray(done5), { at: at + done5 });
|
|
1206
1209
|
if (!(n > 0))
|
|
1207
1210
|
throw Object.assign(new Error("the file system took no more bytes"), { code: "ENOSPC" });
|
|
1208
|
-
|
|
1211
|
+
done5 += n;
|
|
1209
1212
|
}
|
|
1210
1213
|
}
|
|
1211
1214
|
async function positioned(handle, op) {
|
|
@@ -1428,7 +1431,7 @@ var OpfsFs = class {
|
|
|
1428
1431
|
return await op();
|
|
1429
1432
|
} finally {
|
|
1430
1433
|
this.unlocked--;
|
|
1431
|
-
if (this.unlocked === 0) for (const
|
|
1434
|
+
if (this.unlocked === 0) for (const done5 of this.idle.splice(0)) done5();
|
|
1432
1435
|
}
|
|
1433
1436
|
}
|
|
1434
1437
|
settle;
|
|
@@ -1545,9 +1548,9 @@ var OpfsFs = class {
|
|
|
1545
1548
|
opfsOps() {
|
|
1546
1549
|
return this.calls + this.others;
|
|
1547
1550
|
}
|
|
1548
|
-
io(
|
|
1551
|
+
io(request3) {
|
|
1549
1552
|
this.others++;
|
|
1550
|
-
return
|
|
1553
|
+
return request3;
|
|
1551
1554
|
}
|
|
1552
1555
|
fresh() {
|
|
1553
1556
|
this.changes++;
|
|
@@ -1703,30 +1706,30 @@ var OpfsFs = class {
|
|
|
1703
1706
|
}
|
|
1704
1707
|
throw fsError("ELOOP", path);
|
|
1705
1708
|
}
|
|
1706
|
-
async physical(base, path,
|
|
1707
|
-
let
|
|
1709
|
+
async physical(base, path, used2, of) {
|
|
1710
|
+
let done5 = [];
|
|
1708
1711
|
let todo = (path.startsWith("/") ? path : `${base}/${path}`).split("/").filter((p) => p !== "" && p !== ".");
|
|
1709
|
-
let hops =
|
|
1712
|
+
let hops = used2;
|
|
1710
1713
|
while (todo.length > 0) {
|
|
1711
1714
|
const part = todo.shift();
|
|
1712
|
-
if (part === "..")
|
|
1713
|
-
else if (!todo.includes(".."))
|
|
1715
|
+
if (part === "..") done5.pop();
|
|
1716
|
+
else if (!todo.includes("..")) done5.push(part);
|
|
1714
1717
|
else {
|
|
1715
|
-
const at = `/${[...
|
|
1718
|
+
const at = `/${[...done5, part].join("/")}`;
|
|
1716
1719
|
this.crossing(of, [at, ...todo].join("/"));
|
|
1717
1720
|
const st = await this.lstat(at);
|
|
1718
1721
|
if (!st.isSymbolicLink && !st.isDirectory) throw fsError("ENOTDIR", at);
|
|
1719
|
-
if (!st.isSymbolicLink)
|
|
1722
|
+
if (!st.isSymbolicLink) done5.push(part);
|
|
1720
1723
|
else if (this.rejectLinks) throw fsError("ELOOP", of);
|
|
1721
1724
|
else if (++hops > MAX_LINKS2) throw fsError("ELOOP", path);
|
|
1722
1725
|
else {
|
|
1723
1726
|
const link2 = await this.readlink(at);
|
|
1724
|
-
if (link2.startsWith("/"))
|
|
1727
|
+
if (link2.startsWith("/")) done5 = [];
|
|
1725
1728
|
todo = [...link2.split("/").filter((p) => p !== "" && p !== "."), ...todo];
|
|
1726
1729
|
}
|
|
1727
1730
|
}
|
|
1728
1731
|
}
|
|
1729
|
-
return { path: `/${
|
|
1732
|
+
return { path: `/${done5.join("/")}`, hops };
|
|
1730
1733
|
}
|
|
1731
1734
|
mode(path, directory, meta) {
|
|
1732
1735
|
const fallback = directory || EXECUTABLE.test(path) ? 493 : 420;
|
|
@@ -2688,7 +2691,7 @@ var OpfsFs = class {
|
|
|
2688
2691
|
}
|
|
2689
2692
|
async present(paths) {
|
|
2690
2693
|
const listed = /* @__PURE__ */ new Map();
|
|
2691
|
-
const
|
|
2694
|
+
const done5 = /* @__PURE__ */ new Map();
|
|
2692
2695
|
const list = (dir) => {
|
|
2693
2696
|
const known = listed.get(dir);
|
|
2694
2697
|
if (known !== void 0) return known;
|
|
@@ -2707,7 +2710,7 @@ var OpfsFs = class {
|
|
|
2707
2710
|
}
|
|
2708
2711
|
return children3;
|
|
2709
2712
|
})().then((children3) => {
|
|
2710
|
-
|
|
2713
|
+
done5.set(dir, children3);
|
|
2711
2714
|
return children3;
|
|
2712
2715
|
});
|
|
2713
2716
|
listed.set(dir, listing);
|
|
@@ -2721,7 +2724,7 @@ var OpfsFs = class {
|
|
|
2721
2724
|
await Promise.all(Array.from({ length: Math.min(RECONCILE_LISTINGS, dirs.length) }, lister));
|
|
2722
2725
|
return async (path) => {
|
|
2723
2726
|
if (split(path).length === 0) return true;
|
|
2724
|
-
const listing =
|
|
2727
|
+
const listing = done5.get(parentOf3(path));
|
|
2725
2728
|
if (listing === null) return this.real(path);
|
|
2726
2729
|
return listing?.has(baseOf(path)) === true;
|
|
2727
2730
|
};
|
|
@@ -2797,6 +2800,85 @@ for (const [names2, op] of [
|
|
|
2797
2800
|
}
|
|
2798
2801
|
}
|
|
2799
2802
|
|
|
2803
|
+
// src/fs/roots.ts
|
|
2804
|
+
var ROOTS_DB = "slicc-kernel-roots";
|
|
2805
|
+
var ROOTS_STORE = "roots";
|
|
2806
|
+
function request(req) {
|
|
2807
|
+
return new Promise((resolve2, reject) => {
|
|
2808
|
+
req.onsuccess = () => resolve2(req.result);
|
|
2809
|
+
req.onerror = () => reject(req.error);
|
|
2810
|
+
});
|
|
2811
|
+
}
|
|
2812
|
+
function open(factory) {
|
|
2813
|
+
const req = factory.open(ROOTS_DB, 1);
|
|
2814
|
+
req.onupgradeneeded = () => req.result.createObjectStore(ROOTS_STORE, { keyPath: "id" });
|
|
2815
|
+
return request(req);
|
|
2816
|
+
}
|
|
2817
|
+
async function same(a, b) {
|
|
2818
|
+
try {
|
|
2819
|
+
return await a.isSameEntry(b);
|
|
2820
|
+
} catch {
|
|
2821
|
+
return false;
|
|
2822
|
+
}
|
|
2823
|
+
}
|
|
2824
|
+
var nameOf = (id2) => `${META_DB}:${id2}`;
|
|
2825
|
+
function done(tx) {
|
|
2826
|
+
return new Promise((resolve2, reject) => {
|
|
2827
|
+
tx.oncomplete = () => resolve2();
|
|
2828
|
+
tx.onerror = () => reject(tx.error);
|
|
2829
|
+
tx.onabort = () => reject(tx.error);
|
|
2830
|
+
});
|
|
2831
|
+
}
|
|
2832
|
+
async function used(root) {
|
|
2833
|
+
for await (const _ of root.keys()) return true;
|
|
2834
|
+
return false;
|
|
2835
|
+
}
|
|
2836
|
+
async function seed(factory, name2) {
|
|
2837
|
+
const known = await factory.databases?.().catch(() => void 0);
|
|
2838
|
+
if (known && !known.some((db) => db.name === META_DB)) return;
|
|
2839
|
+
const from = await openMetaDb(META_DB, factory);
|
|
2840
|
+
const to = await openMetaDb(name2, factory);
|
|
2841
|
+
try {
|
|
2842
|
+
const rows = await request(
|
|
2843
|
+
from.transaction(META_STORE, "readonly").objectStore(META_STORE).getAll()
|
|
2844
|
+
);
|
|
2845
|
+
const tx = to.transaction(META_STORE, "readwrite");
|
|
2846
|
+
const store = tx.objectStore(META_STORE);
|
|
2847
|
+
for (const row of rows) store.put(row);
|
|
2848
|
+
await done(tx);
|
|
2849
|
+
console.warn(
|
|
2850
|
+
`slicc-kernel: a root not seen before got its own metadata database ${name2}, a copy of ${rows.length} records of ${META_DB} (#1120)`
|
|
2851
|
+
);
|
|
2852
|
+
} finally {
|
|
2853
|
+
from.close();
|
|
2854
|
+
to.close();
|
|
2855
|
+
}
|
|
2856
|
+
}
|
|
2857
|
+
async function rootId(factory, root, locks = globalThis.navigator?.locks) {
|
|
2858
|
+
const find = async () => {
|
|
2859
|
+
const db = await open(factory);
|
|
2860
|
+
try {
|
|
2861
|
+
const all = await request(
|
|
2862
|
+
db.transaction(ROOTS_STORE, "readonly").objectStore(ROOTS_STORE).getAll()
|
|
2863
|
+
);
|
|
2864
|
+
for (const record of all) if (await same(record.handle, root)) return record.id;
|
|
2865
|
+
const id2 = crypto.randomUUID();
|
|
2866
|
+
if (await used(root)) await seed(factory, nameOf(id2));
|
|
2867
|
+
const tx = db.transaction(ROOTS_STORE, "readwrite");
|
|
2868
|
+
tx.objectStore(ROOTS_STORE).put({ id: id2, handle: root });
|
|
2869
|
+
await done(tx);
|
|
2870
|
+
return id2;
|
|
2871
|
+
} finally {
|
|
2872
|
+
db.close();
|
|
2873
|
+
}
|
|
2874
|
+
};
|
|
2875
|
+
return locks ? locks.request(ROOTS_DB, find) : find();
|
|
2876
|
+
}
|
|
2877
|
+
async function metadataName(top, root, id2) {
|
|
2878
|
+
if (!top || await same(top, root)) return META_DB;
|
|
2879
|
+
return nameOf(await id2(root));
|
|
2880
|
+
}
|
|
2881
|
+
|
|
2800
2882
|
// src/kernel/net/http1.ts
|
|
2801
2883
|
var HttpError = class extends Error {
|
|
2802
2884
|
status;
|
|
@@ -3362,8 +3444,8 @@ var CdpFacade = class {
|
|
|
3362
3444
|
} catch {
|
|
3363
3445
|
break;
|
|
3364
3446
|
}
|
|
3365
|
-
const
|
|
3366
|
-
served2.add(
|
|
3447
|
+
const done5 = this.serve(conn).finally(() => served2.delete(done5));
|
|
3448
|
+
served2.add(done5);
|
|
3367
3449
|
}
|
|
3368
3450
|
await Promise.allSettled([...served2]);
|
|
3369
3451
|
}
|
|
@@ -3574,12 +3656,12 @@ var CdpHosts = class {
|
|
|
3574
3656
|
available(runtime) {
|
|
3575
3657
|
return this.pick(runtime) !== void 0;
|
|
3576
3658
|
}
|
|
3577
|
-
async connect(
|
|
3578
|
-
const entry = this.pick(
|
|
3659
|
+
async connect(request3) {
|
|
3660
|
+
const entry = this.pick(request3.runtime);
|
|
3579
3661
|
if (!entry) throw new HttpError(503, NO_CDP_HOST);
|
|
3580
3662
|
let conn;
|
|
3581
3663
|
try {
|
|
3582
|
-
conn = await entry.hook(
|
|
3664
|
+
conn = await entry.hook(request3.runtime ? { runtime: request3.runtime } : {});
|
|
3583
3665
|
} catch (e) {
|
|
3584
3666
|
throw new HttpError(502, `CDP host: ${e instanceof Error ? e.message : String(e)}`);
|
|
3585
3667
|
}
|
|
@@ -3613,7 +3695,7 @@ function fresh(bytes, start2 = 0, end = bytes.length) {
|
|
|
3613
3695
|
|
|
3614
3696
|
// src/cdp/port.ts
|
|
3615
3697
|
function portCdpHook(ask, gone) {
|
|
3616
|
-
return (
|
|
3698
|
+
return (request3) => new Promise((resolve2, reject) => {
|
|
3617
3699
|
const { port1, port2 } = new MessageChannel();
|
|
3618
3700
|
let closed = false;
|
|
3619
3701
|
const conn = {
|
|
@@ -3650,7 +3732,7 @@ function portCdpHook(ask, gone) {
|
|
|
3650
3732
|
reject(new Error("the CDP host is gone"));
|
|
3651
3733
|
conn.onclose?.("the CDP host is gone");
|
|
3652
3734
|
});
|
|
3653
|
-
ask(
|
|
3735
|
+
ask(request3, port2);
|
|
3654
3736
|
});
|
|
3655
3737
|
}
|
|
3656
3738
|
|
|
@@ -4960,10 +5042,10 @@ function uplinkLink(conn, onReset) {
|
|
|
4960
5042
|
pipe.openRead();
|
|
4961
5043
|
pipe.openWrite();
|
|
4962
5044
|
}
|
|
4963
|
-
let
|
|
5045
|
+
let open2 = true;
|
|
4964
5046
|
const close = () => {
|
|
4965
|
-
if (!
|
|
4966
|
-
|
|
5047
|
+
if (!open2) return;
|
|
5048
|
+
open2 = false;
|
|
4967
5049
|
conn.close();
|
|
4968
5050
|
};
|
|
4969
5051
|
void inbound(conn, rx).catch((err) => {
|
|
@@ -5788,9 +5870,9 @@ function uploadsFor(peer) {
|
|
|
5788
5870
|
return { of, answer: (call) => pulls.get(call.nid)?.(call) };
|
|
5789
5871
|
}
|
|
5790
5872
|
function serveTransport(peer, transport, { closeWaitMs = CLOSE_WAIT_MS2 } = {}) {
|
|
5791
|
-
const
|
|
5873
|
+
const open2 = /* @__PURE__ */ new Map();
|
|
5792
5874
|
const fail2 = (nid, e) => {
|
|
5793
|
-
|
|
5875
|
+
open2.delete(nid);
|
|
5794
5876
|
const { status, code } = e;
|
|
5795
5877
|
peer.postMessage({
|
|
5796
5878
|
net: "error",
|
|
@@ -5804,7 +5886,7 @@ function serveTransport(peer, transport, { closeWaitMs = CLOSE_WAIT_MS2 } = {})
|
|
|
5804
5886
|
const start2 = async (call) => {
|
|
5805
5887
|
const abort = new AbortController();
|
|
5806
5888
|
const entry = { abort };
|
|
5807
|
-
|
|
5889
|
+
open2.set(call.nid, entry);
|
|
5808
5890
|
try {
|
|
5809
5891
|
const response = await transport.fetch({
|
|
5810
5892
|
url: call.url,
|
|
@@ -5813,11 +5895,11 @@ function serveTransport(peer, transport, { closeWaitMs = CLOSE_WAIT_MS2 } = {})
|
|
|
5813
5895
|
...call.streamed ? { bodyStream: uploads.of(call.nid, abort.signal) } : call.body ? { body: call.body } : {},
|
|
5814
5896
|
signal: abort.signal
|
|
5815
5897
|
});
|
|
5816
|
-
if (!
|
|
5898
|
+
if (!open2.has(call.nid)) {
|
|
5817
5899
|
await response.cancel();
|
|
5818
5900
|
return;
|
|
5819
5901
|
}
|
|
5820
|
-
|
|
5902
|
+
open2.set(call.nid, { abort, body: response.body[Symbol.asyncIterator](), response });
|
|
5821
5903
|
peer.postMessage({
|
|
5822
5904
|
net: "head",
|
|
5823
5905
|
nid: call.nid,
|
|
@@ -5845,7 +5927,7 @@ function serveTransport(peer, transport, { closeWaitMs = CLOSE_WAIT_MS2 } = {})
|
|
|
5845
5927
|
};
|
|
5846
5928
|
const openSocket = async (call) => {
|
|
5847
5929
|
const abort = new AbortController();
|
|
5848
|
-
|
|
5930
|
+
open2.set(call.nid, { abort });
|
|
5849
5931
|
try {
|
|
5850
5932
|
if (!transport.websocket) throw new Error(NO_WEBSOCKET);
|
|
5851
5933
|
const socket = await transport.websocket({
|
|
@@ -5854,7 +5936,7 @@ function serveTransport(peer, transport, { closeWaitMs = CLOSE_WAIT_MS2 } = {})
|
|
|
5854
5936
|
headers: call.headers,
|
|
5855
5937
|
signal: abort.signal
|
|
5856
5938
|
});
|
|
5857
|
-
if (!
|
|
5939
|
+
if (!open2.delete(call.nid)) {
|
|
5858
5940
|
socket.close(1e3, "cancelled");
|
|
5859
5941
|
return;
|
|
5860
5942
|
}
|
|
@@ -5922,12 +6004,12 @@ function serveTransport(peer, transport, { closeWaitMs = CLOSE_WAIT_MS2 } = {})
|
|
|
5922
6004
|
peer.postMessage({ net: "ws-acked", nid: call.nid, n: payloadSize(call.data) });
|
|
5923
6005
|
};
|
|
5924
6006
|
const read = async (nid) => {
|
|
5925
|
-
const body =
|
|
6007
|
+
const body = open2.get(nid)?.body;
|
|
5926
6008
|
if (!body) return;
|
|
5927
6009
|
try {
|
|
5928
6010
|
const next3 = await body.next();
|
|
5929
6011
|
if (next3.done) {
|
|
5930
|
-
|
|
6012
|
+
open2.delete(nid);
|
|
5931
6013
|
peer.postMessage({ net: "end", nid });
|
|
5932
6014
|
} else {
|
|
5933
6015
|
const bytes = fresh(next3.value);
|
|
@@ -5940,8 +6022,8 @@ function serveTransport(peer, transport, { closeWaitMs = CLOSE_WAIT_MS2 } = {})
|
|
|
5940
6022
|
const drop = (nid) => {
|
|
5941
6023
|
sockets.get(nid)?.close(1e3, "cancelled");
|
|
5942
6024
|
refill(nid, 0, true);
|
|
5943
|
-
const entry =
|
|
5944
|
-
|
|
6025
|
+
const entry = open2.get(nid);
|
|
6026
|
+
open2.delete(nid);
|
|
5945
6027
|
entry?.abort.abort();
|
|
5946
6028
|
void entry?.response?.cancel().catch(() => void 0);
|
|
5947
6029
|
};
|
|
@@ -5960,7 +6042,7 @@ function serveTransport(peer, transport, { closeWaitMs = CLOSE_WAIT_MS2 } = {})
|
|
|
5960
6042
|
else drop(call.nid);
|
|
5961
6043
|
},
|
|
5962
6044
|
close() {
|
|
5963
|
-
for (const nid of [...
|
|
6045
|
+
for (const nid of [...open2.keys(), ...sockets.keys()]) drop(nid);
|
|
5964
6046
|
}
|
|
5965
6047
|
};
|
|
5966
6048
|
}
|
|
@@ -6449,12 +6531,12 @@ function signalOf(host) {
|
|
|
6449
6531
|
throw fsError("EINVAL", `this kernel names no signal ${name2}`);
|
|
6450
6532
|
});
|
|
6451
6533
|
}
|
|
6452
|
-
function dialFor(l, req,
|
|
6534
|
+
function dialFor(l, req, open2) {
|
|
6453
6535
|
const socket = dialSocket(l.net, req.port, req.host);
|
|
6454
6536
|
const { port1, port2 } = new MessageChannel();
|
|
6455
|
-
|
|
6537
|
+
open2.set(
|
|
6456
6538
|
req.id,
|
|
6457
|
-
serveSocket(socket, port1, () =>
|
|
6539
|
+
serveSocket(socket, port1, () => open2.delete(req.id))
|
|
6458
6540
|
);
|
|
6459
6541
|
return { result: port2, transfer: [port2] };
|
|
6460
6542
|
}
|
|
@@ -6533,7 +6615,7 @@ function cdpRegistry(send2, gone) {
|
|
|
6533
6615
|
return {
|
|
6534
6616
|
serve(l, req) {
|
|
6535
6617
|
const hook = portCdpHook(
|
|
6536
|
-
(
|
|
6618
|
+
(request3, cdp) => send2({ cdpOpen: { ...request3, registration: req.id }, port: cdp }, [
|
|
6537
6619
|
cdp
|
|
6538
6620
|
]),
|
|
6539
6621
|
gone
|
|
@@ -6556,7 +6638,7 @@ function facadeRegistry(send2, gone) {
|
|
|
6556
6638
|
return {
|
|
6557
6639
|
serve(l, req) {
|
|
6558
6640
|
const hook = portFacadeHook(
|
|
6559
|
-
(
|
|
6641
|
+
(request3, facade) => send2({ facadeOpen: { ...request3, registration: req.id }, port: facade }, [
|
|
6560
6642
|
facade
|
|
6561
6643
|
]),
|
|
6562
6644
|
gone
|
|
@@ -6938,7 +7020,7 @@ function satisfies(version, range2) {
|
|
|
6938
7020
|
}
|
|
6939
7021
|
|
|
6940
7022
|
// src/version.ts
|
|
6941
|
-
var KERNEL_VERSION = true ? "1.128.
|
|
7023
|
+
var KERNEL_VERSION = true ? "1.128.1" : "0.0.0-dev";
|
|
6942
7024
|
var OS_RELEASE = "6.0.0-slicc";
|
|
6943
7025
|
function procVersion() {
|
|
6944
7026
|
return `Linux version ${OS_RELEASE} (slicc-kernel ${KERNEL_VERSION}) #1 SMP PREEMPT_DYNAMIC
|
|
@@ -8015,7 +8097,7 @@ var UnlinkedKeeper = class {
|
|
|
8015
8097
|
throw err;
|
|
8016
8098
|
}
|
|
8017
8099
|
sealed();
|
|
8018
|
-
const
|
|
8100
|
+
const done5 = () => {
|
|
8019
8101
|
for (const release of releases) release();
|
|
8020
8102
|
};
|
|
8021
8103
|
const files = /* @__PURE__ */ new Map();
|
|
@@ -8030,7 +8112,7 @@ var UnlinkedKeeper = class {
|
|
|
8030
8112
|
moved: new Set(hidden.keys()),
|
|
8031
8113
|
commit: () => {
|
|
8032
8114
|
for (const file of files.values()) file.release();
|
|
8033
|
-
|
|
8115
|
+
done5();
|
|
8034
8116
|
},
|
|
8035
8117
|
rollback: async () => {
|
|
8036
8118
|
for (const [path, file] of files) {
|
|
@@ -8041,7 +8123,7 @@ var UnlinkedKeeper = class {
|
|
|
8041
8123
|
await this.tidy(parentOf5(file.hidden));
|
|
8042
8124
|
});
|
|
8043
8125
|
}
|
|
8044
|
-
|
|
8126
|
+
done5();
|
|
8045
8127
|
}
|
|
8046
8128
|
};
|
|
8047
8129
|
}
|
|
@@ -8127,14 +8209,14 @@ var systemCronClock = {
|
|
|
8127
8209
|
sleep(until, signal) {
|
|
8128
8210
|
if (signal.aborted) return Promise.resolve();
|
|
8129
8211
|
return new Promise((resolve2) => {
|
|
8130
|
-
const
|
|
8212
|
+
const done5 = () => {
|
|
8131
8213
|
clearTimeout(timer);
|
|
8132
|
-
signal.removeEventListener("abort",
|
|
8214
|
+
signal.removeEventListener("abort", done5);
|
|
8133
8215
|
resolve2();
|
|
8134
8216
|
};
|
|
8135
|
-
const timer = setTimeout(
|
|
8217
|
+
const timer = setTimeout(done5, Math.max(0, until - Date.now()));
|
|
8136
8218
|
timer.unref?.();
|
|
8137
|
-
signal.addEventListener("abort",
|
|
8219
|
+
signal.addEventListener("abort", done5, { once: true });
|
|
8138
8220
|
});
|
|
8139
8221
|
}
|
|
8140
8222
|
};
|
|
@@ -8485,12 +8567,12 @@ var Budget = class {
|
|
|
8485
8567
|
while (this.free < n) {
|
|
8486
8568
|
signal.throwIfAborted();
|
|
8487
8569
|
await new Promise((resolve2) => {
|
|
8488
|
-
const
|
|
8489
|
-
signal.removeEventListener("abort",
|
|
8570
|
+
const done5 = () => {
|
|
8571
|
+
signal.removeEventListener("abort", done5);
|
|
8490
8572
|
resolve2();
|
|
8491
8573
|
};
|
|
8492
|
-
this.waiters.push(
|
|
8493
|
-
signal.addEventListener("abort",
|
|
8574
|
+
this.waiters.push(done5);
|
|
8575
|
+
signal.addEventListener("abort", done5, { once: true });
|
|
8494
8576
|
});
|
|
8495
8577
|
}
|
|
8496
8578
|
this.free -= n;
|
|
@@ -8629,9 +8711,9 @@ async function watchHangup(conn, abort, until) {
|
|
|
8629
8711
|
}
|
|
8630
8712
|
}
|
|
8631
8713
|
var BODILESS_METHODS = /* @__PURE__ */ new Set(["GET", "HEAD"]);
|
|
8632
|
-
async function* drain(body,
|
|
8714
|
+
async function* drain(body, done5) {
|
|
8633
8715
|
yield* body;
|
|
8634
|
-
|
|
8716
|
+
done5();
|
|
8635
8717
|
}
|
|
8636
8718
|
function untilAborted(response, signal) {
|
|
8637
8719
|
return new Promise((resolve2, reject) => {
|
|
@@ -8723,11 +8805,11 @@ var RealmProxy = class {
|
|
|
8723
8805
|
this.slots.release(1);
|
|
8724
8806
|
break;
|
|
8725
8807
|
}
|
|
8726
|
-
const
|
|
8808
|
+
const done5 = this.serve(conn).finally(() => {
|
|
8727
8809
|
this.slots.release(1);
|
|
8728
|
-
served2.delete(
|
|
8810
|
+
served2.delete(done5);
|
|
8729
8811
|
});
|
|
8730
|
-
served2.add(
|
|
8812
|
+
served2.add(done5);
|
|
8731
8813
|
}
|
|
8732
8814
|
} catch {
|
|
8733
8815
|
}
|
|
@@ -8977,8 +9059,8 @@ var RealmProxy = class {
|
|
|
8977
9059
|
chain2 = chain2.then(() => ctx.sink.write(bytes, stop));
|
|
8978
9060
|
return chain2;
|
|
8979
9061
|
};
|
|
8980
|
-
const
|
|
8981
|
-
const reading = AbortSignal.any([stop,
|
|
9062
|
+
const done5 = new AbortController();
|
|
9063
|
+
const reading = AbortSignal.any([stop, done5.signal, hangup]);
|
|
8982
9064
|
const stopping = () => socket.close(1001, "the proxy is stopping");
|
|
8983
9065
|
stop.addEventListener("abort", stopping, { once: true });
|
|
8984
9066
|
let guestDone = false;
|
|
@@ -8995,10 +9077,10 @@ var RealmProxy = class {
|
|
|
8995
9077
|
if (guestDone) return;
|
|
8996
9078
|
closeSent = true;
|
|
8997
9079
|
await toGuest(closeFrame(wireCode(closed.code), closed.reason));
|
|
8998
|
-
AbortSignal.timeout(this.limits.closeWaitMs).addEventListener("abort", () =>
|
|
9080
|
+
AbortSignal.timeout(this.limits.closeWaitMs).addEventListener("abort", () => done5.abort(), {
|
|
8999
9081
|
once: true
|
|
9000
9082
|
});
|
|
9001
|
-
})().catch(() =>
|
|
9083
|
+
})().catch(() => done5.abort());
|
|
9002
9084
|
const reader = new WsReader(ctx.incoming, MESSAGE_LIMIT, true);
|
|
9003
9085
|
try {
|
|
9004
9086
|
for (; ; ) {
|
|
@@ -9855,13 +9937,13 @@ var FsWatchers = class {
|
|
|
9855
9937
|
next: async (signal) => {
|
|
9856
9938
|
while (watch.notes.length === 0 && !watch.ended && !signal.aborted) {
|
|
9857
9939
|
await new Promise((resolve2) => {
|
|
9858
|
-
const
|
|
9940
|
+
const done5 = () => {
|
|
9859
9941
|
watch.wake = void 0;
|
|
9860
|
-
signal.removeEventListener("abort",
|
|
9942
|
+
signal.removeEventListener("abort", done5);
|
|
9861
9943
|
resolve2();
|
|
9862
9944
|
};
|
|
9863
|
-
watch.wake =
|
|
9864
|
-
signal.addEventListener("abort",
|
|
9945
|
+
watch.wake = done5;
|
|
9946
|
+
signal.addEventListener("abort", done5, { once: true });
|
|
9865
9947
|
});
|
|
9866
9948
|
}
|
|
9867
9949
|
const notes = watch.notes.splice(0);
|
|
@@ -9912,14 +9994,14 @@ var FsWatchers = class {
|
|
|
9912
9994
|
}
|
|
9913
9995
|
wrap(fs) {
|
|
9914
9996
|
const after = (run2, changed, type) => async (...args) => {
|
|
9915
|
-
let
|
|
9997
|
+
let done5 = false;
|
|
9916
9998
|
try {
|
|
9917
9999
|
await run2(...args);
|
|
9918
|
-
|
|
10000
|
+
done5 = true;
|
|
9919
10001
|
} finally {
|
|
9920
10002
|
const paths = changed(...args);
|
|
9921
10003
|
this.report(paths);
|
|
9922
|
-
if (
|
|
10004
|
+
if (done5) this.emit(type, paths);
|
|
9923
10005
|
}
|
|
9924
10006
|
};
|
|
9925
10007
|
const reals = this.reals;
|
|
@@ -9941,15 +10023,15 @@ var FsWatchers = class {
|
|
|
9941
10023
|
const content = (run2, types) => async (...args) => {
|
|
9942
10024
|
const at = normalizePath(args[0]);
|
|
9943
10025
|
const fresh2 = this.covers(at) && !await fs.exists(at).catch(() => true);
|
|
9944
|
-
let
|
|
10026
|
+
let done5 = false;
|
|
9945
10027
|
try {
|
|
9946
10028
|
await run2(...args);
|
|
9947
|
-
|
|
10029
|
+
done5 = true;
|
|
9948
10030
|
} finally {
|
|
9949
10031
|
const real = await realOf(at);
|
|
9950
10032
|
const paths = real === at ? [at] : [at, real];
|
|
9951
10033
|
this.report(paths);
|
|
9952
|
-
if (
|
|
10034
|
+
if (done5) for (const type of types(fresh2)) this.emit(type, paths);
|
|
9953
10035
|
}
|
|
9954
10036
|
};
|
|
9955
10037
|
const written2 = (fresh2) => fresh2 ? ["rename", "change"] : ["change"];
|
|
@@ -9980,13 +10062,13 @@ var FsWatchers = class {
|
|
|
9980
10062
|
}
|
|
9981
10063
|
}
|
|
9982
10064
|
const fresh2 = !options?.recursive || this.typed.size > 0 && !await fs.exists(path);
|
|
9983
|
-
let
|
|
10065
|
+
let done5 = false;
|
|
9984
10066
|
try {
|
|
9985
10067
|
await fs.mkdir(path, options);
|
|
9986
|
-
|
|
10068
|
+
done5 = true;
|
|
9987
10069
|
} finally {
|
|
9988
10070
|
this.report([...created4, path]);
|
|
9989
|
-
if (
|
|
10071
|
+
if (done5) this.emit("rename", fresh2 ? [...created4, path] : created4);
|
|
9990
10072
|
}
|
|
9991
10073
|
},
|
|
9992
10074
|
rm: reshaping(after(fs.rm.bind(fs), (path) => [path], "rename")),
|
|
@@ -10192,8 +10274,8 @@ var ChildTable = class {
|
|
|
10192
10274
|
for (; ; ) {
|
|
10193
10275
|
const candidates = this.candidates(pid, flags2);
|
|
10194
10276
|
if (candidates.length === 0) throw new KernelError("ECHILD");
|
|
10195
|
-
const
|
|
10196
|
-
if (
|
|
10277
|
+
const done5 = candidates.find(([, child]) => child.code !== void 0);
|
|
10278
|
+
if (done5) return this.reap(done5[0], done5[1].code);
|
|
10197
10279
|
const changed = this.stateReport(candidates, flags2);
|
|
10198
10280
|
if (changed) return changed;
|
|
10199
10281
|
if (nohang) return [0, 0];
|
|
@@ -10589,7 +10671,7 @@ var FifoTable = class {
|
|
|
10589
10671
|
}
|
|
10590
10672
|
end(key, path, fifo, reads, writes) {
|
|
10591
10673
|
const { pipe } = fifo;
|
|
10592
|
-
let
|
|
10674
|
+
let open2 = true;
|
|
10593
10675
|
return new OpenFile({
|
|
10594
10676
|
fifo: path,
|
|
10595
10677
|
identity: fifo,
|
|
@@ -10612,8 +10694,8 @@ var FifoTable = class {
|
|
|
10612
10694
|
}
|
|
10613
10695
|
} : {},
|
|
10614
10696
|
close: () => {
|
|
10615
|
-
if (!
|
|
10616
|
-
|
|
10697
|
+
if (!open2) return;
|
|
10698
|
+
open2 = false;
|
|
10617
10699
|
this.release(key, fifo, reads, writes);
|
|
10618
10700
|
},
|
|
10619
10701
|
poll: () => ({
|
|
@@ -10887,8 +10969,8 @@ var HeldPaths = class extends Map {
|
|
|
10887
10969
|
for (const file of [...this.uses.keys()]) this.letGo(file, true);
|
|
10888
10970
|
this.keptHandles.clear();
|
|
10889
10971
|
}
|
|
10890
|
-
hold(path, on,
|
|
10891
|
-
if (
|
|
10972
|
+
hold(path, on, open2 = false, real, handle) {
|
|
10973
|
+
if (open2) return this.holdOpen(path, on, real, handle);
|
|
10892
10974
|
this.holdWrite(path, on);
|
|
10893
10975
|
return void 0;
|
|
10894
10976
|
}
|
|
@@ -11179,7 +11261,7 @@ var MountTable = class {
|
|
|
11179
11261
|
session(mount, real, rel2) {
|
|
11180
11262
|
let session = this.sessions.get(real);
|
|
11181
11263
|
if (!session) {
|
|
11182
|
-
const
|
|
11264
|
+
const open2 = () => mount.conn.call({
|
|
11183
11265
|
op: "open",
|
|
11184
11266
|
path: rel2,
|
|
11185
11267
|
write: true,
|
|
@@ -11188,7 +11270,7 @@ var MountTable = class {
|
|
|
11188
11270
|
exclusive: false
|
|
11189
11271
|
});
|
|
11190
11272
|
const before = this.committing.get(real)?.done ?? Promise.resolve();
|
|
11191
|
-
const fh = before.then(
|
|
11273
|
+
const fh = before.then(open2, open2);
|
|
11192
11274
|
session = { mount, fh, extents: [], truncated: false };
|
|
11193
11275
|
this.sessions.set(real, session);
|
|
11194
11276
|
fh.catch(() => this.sessions.delete(real));
|
|
@@ -11203,20 +11285,20 @@ var MountTable = class {
|
|
|
11203
11285
|
if (!session) return this.committing.get(real)?.done;
|
|
11204
11286
|
this.sessions.delete(real);
|
|
11205
11287
|
session.mount.epoch++;
|
|
11206
|
-
const
|
|
11288
|
+
const done5 = (async () => {
|
|
11207
11289
|
try {
|
|
11208
11290
|
await session.mount.conn.call({ op: "release", fh: await session.fh });
|
|
11209
11291
|
} finally {
|
|
11210
11292
|
this.forget(session.mount, real);
|
|
11211
11293
|
}
|
|
11212
11294
|
})();
|
|
11213
|
-
const entry = { mount: session.mount, done:
|
|
11295
|
+
const entry = { mount: session.mount, done: done5 };
|
|
11214
11296
|
this.committing.set(real, entry);
|
|
11215
11297
|
const settle3 = () => {
|
|
11216
11298
|
if (this.committing.get(real) === entry) this.committing.delete(real);
|
|
11217
11299
|
};
|
|
11218
|
-
|
|
11219
|
-
return
|
|
11300
|
+
done5.then(settle3, settle3);
|
|
11301
|
+
return done5;
|
|
11220
11302
|
}
|
|
11221
11303
|
async commitUnder(prefix) {
|
|
11222
11304
|
const at = normalizePath(prefix);
|
|
@@ -11390,8 +11472,8 @@ var MountFs = class _MountFs {
|
|
|
11390
11472
|
}
|
|
11391
11473
|
async across(from, to, redirects) {
|
|
11392
11474
|
const moved2 = [await this.through(from), await this.through(to)];
|
|
11393
|
-
const
|
|
11394
|
-
if (
|
|
11475
|
+
const same2 = moved2[0] === normalizePath(from) && moved2[1] === normalizePath(to);
|
|
11476
|
+
if (same2 || redirects >= MAX_LINKS7) throw errnoError("EXDEV", `${from} -> ${to}`);
|
|
11395
11477
|
return moved2;
|
|
11396
11478
|
}
|
|
11397
11479
|
async based(paths, redirects, run2, again) {
|
|
@@ -12239,7 +12321,7 @@ async function storageUsage() {
|
|
|
12239
12321
|
return { quota: estimate.quota, usage: estimate.usage ?? 0 };
|
|
12240
12322
|
}
|
|
12241
12323
|
var PLAIN_DIR_MODE = 493;
|
|
12242
|
-
var
|
|
12324
|
+
var done2 = { ok: true, kind: "void" };
|
|
12243
12325
|
function json2(value2) {
|
|
12244
12326
|
return { ok: true, kind: "json", json: value2 };
|
|
12245
12327
|
}
|
|
@@ -12284,14 +12366,14 @@ async function chown(entry, path, req) {
|
|
|
12284
12366
|
const cred = entry.cred?.();
|
|
12285
12367
|
if (!cred) {
|
|
12286
12368
|
await (req.op === "chown" ? entry.fs.stat(real) : entry.fs.lstat(real));
|
|
12287
|
-
return
|
|
12369
|
+
return done2;
|
|
12288
12370
|
}
|
|
12289
12371
|
await chownAs(entry.fs, cred, real, {
|
|
12290
12372
|
...req.uid !== void 0 ? { uid: req.uid } : {},
|
|
12291
12373
|
...req.gid !== void 0 ? { gid: req.gid } : {},
|
|
12292
12374
|
follow: req.op === "chown"
|
|
12293
12375
|
});
|
|
12294
|
-
return
|
|
12376
|
+
return done2;
|
|
12295
12377
|
}
|
|
12296
12378
|
async function runMkdir(entry, path, req) {
|
|
12297
12379
|
const { fs } = entry;
|
|
@@ -12302,7 +12384,7 @@ async function runMkdir(entry, path, req) {
|
|
|
12302
12384
|
await (req.exclusive ? mkdirExclusive(entry, path, req.mode) : fs.mkdir(path, mkdirOptions(entry, req.mode)));
|
|
12303
12385
|
await fixParents?.();
|
|
12304
12386
|
if (fresh2) await fs.chmod(path, plain2);
|
|
12305
|
-
return
|
|
12387
|
+
return done2;
|
|
12306
12388
|
}
|
|
12307
12389
|
async function shownAs(entry, path, st) {
|
|
12308
12390
|
const real = st.isFile && st.size === 0 ? entry.fs.realpath?.(path, true) : void 0;
|
|
@@ -12319,7 +12401,7 @@ async function run(entry, path, req) {
|
|
|
12319
12401
|
return { ok: true, kind: "bytes", bytes: await readSource(entry, path) };
|
|
12320
12402
|
case "write":
|
|
12321
12403
|
await fs.writeFile(path, req.body ?? new Uint8Array(0), ownerFor2(entry, 438));
|
|
12322
|
-
return
|
|
12404
|
+
return done2;
|
|
12323
12405
|
case "exists":
|
|
12324
12406
|
return json2(await fs.exists(path));
|
|
12325
12407
|
case "stat": {
|
|
@@ -12340,53 +12422,53 @@ async function run(entry, path, req) {
|
|
|
12340
12422
|
return runMkdir(entry, path, req);
|
|
12341
12423
|
case "rm":
|
|
12342
12424
|
await fs.rm(path, { recursive: true });
|
|
12343
|
-
return
|
|
12425
|
+
return done2;
|
|
12344
12426
|
case "rename": {
|
|
12345
12427
|
const to = fs.resolvePath(cwd, req.arg2 ?? "");
|
|
12346
12428
|
await fs.rename(path, to);
|
|
12347
12429
|
entry.renamed?.(path, to);
|
|
12348
|
-
return
|
|
12430
|
+
return done2;
|
|
12349
12431
|
}
|
|
12350
12432
|
case "link":
|
|
12351
12433
|
await fs.link(path, fs.resolvePath(cwd, req.arg2 ?? ""), req.mode === 1);
|
|
12352
|
-
return
|
|
12434
|
+
return done2;
|
|
12353
12435
|
case "unlink":
|
|
12354
12436
|
await fs.rm(path, { file: true });
|
|
12355
|
-
return
|
|
12437
|
+
return done2;
|
|
12356
12438
|
case "rmdir":
|
|
12357
12439
|
if (!(await fs.lstat(path)).isDirectory) throw syncError("ENOTDIR", path);
|
|
12358
12440
|
if ((await fs.readdir(path)).length > 0) throw syncError("ENOTEMPTY", path);
|
|
12359
12441
|
await fs.rm(path, { recursive: true });
|
|
12360
|
-
return
|
|
12442
|
+
return done2;
|
|
12361
12443
|
case "symlink":
|
|
12362
12444
|
await fs.symlink(req.arg2 ?? "", path, ownerFor2(entry));
|
|
12363
|
-
return
|
|
12445
|
+
return done2;
|
|
12364
12446
|
case "copy":
|
|
12365
12447
|
return copyOp(entry, path, req);
|
|
12366
12448
|
case "mkfifo": {
|
|
12367
12449
|
const owner = ownerFor2(entry, req.mode ?? 438) ?? { uid: 0, gid: 0 };
|
|
12368
12450
|
await createExclusive(fs, path, { ...owner, fifo: true });
|
|
12369
12451
|
entry.fresh?.(path);
|
|
12370
|
-
return
|
|
12452
|
+
return done2;
|
|
12371
12453
|
}
|
|
12372
12454
|
case "create":
|
|
12373
12455
|
await createExclusive(fs, path, ownerFor2(entry, req.mode ?? 438));
|
|
12374
12456
|
if (req.opening) entry.created?.add(path);
|
|
12375
12457
|
entry.fresh?.(path);
|
|
12376
|
-
return
|
|
12458
|
+
return done2;
|
|
12377
12459
|
case "readlink":
|
|
12378
12460
|
return json2(await fs.readlink(path));
|
|
12379
12461
|
case "chmod": {
|
|
12380
12462
|
const g = guardOf(entry);
|
|
12381
12463
|
await fs.chmod(path, g ? await chmodMode(g, path, req.mode ?? 0) : req.mode ?? 0);
|
|
12382
|
-
return
|
|
12464
|
+
return done2;
|
|
12383
12465
|
}
|
|
12384
12466
|
case "utimes":
|
|
12385
12467
|
await fs.utimes(path, ...await timesOf(entry, path, req));
|
|
12386
|
-
return
|
|
12468
|
+
return done2;
|
|
12387
12469
|
case "lutimes":
|
|
12388
12470
|
await lutimesOf(fs, path, ...await timesOf(entry, path, req));
|
|
12389
|
-
return
|
|
12471
|
+
return done2;
|
|
12390
12472
|
case "chown":
|
|
12391
12473
|
case "lchown":
|
|
12392
12474
|
return chown(entry, path, req);
|
|
@@ -12525,8 +12607,8 @@ async function stillThere(entry, path, req) {
|
|
|
12525
12607
|
}
|
|
12526
12608
|
async function holdOp(entry, path, req) {
|
|
12527
12609
|
const mode = req.mode ?? 0;
|
|
12528
|
-
const [on,
|
|
12529
|
-
if (on &&
|
|
12610
|
+
const [on, open2] = [(mode & 1) === 1, (mode & 2) === 2];
|
|
12611
|
+
if (on && open2) {
|
|
12530
12612
|
for (; ; ) {
|
|
12531
12613
|
const r = entry.replacements;
|
|
12532
12614
|
await r?.settled(path);
|
|
@@ -12536,26 +12618,26 @@ async function holdOp(entry, path, req) {
|
|
|
12536
12618
|
await entry.source?.open(path, real);
|
|
12537
12619
|
await stillThere(entry, path, req);
|
|
12538
12620
|
if (!r || !r.missed(path) && !r.changedSince(path, gen))
|
|
12539
|
-
return json2(entry.hold?.(path, on,
|
|
12621
|
+
return json2(entry.hold?.(path, on, open2, real) ?? null);
|
|
12540
12622
|
}
|
|
12541
12623
|
}
|
|
12542
|
-
entry.hold?.(path, on,
|
|
12543
|
-
return
|
|
12624
|
+
entry.hold?.(path, on, open2, void 0, req.handle);
|
|
12625
|
+
return done2;
|
|
12544
12626
|
}
|
|
12545
12627
|
async function followed(g, path) {
|
|
12546
12628
|
const st = await g.fs.lstat(path).catch(() => void 0);
|
|
12547
12629
|
if (st?.isSymbolicLink && !trustedLink(permOf(st), g.links)) deny(g, "follow", path);
|
|
12548
|
-
return
|
|
12630
|
+
return done2;
|
|
12549
12631
|
}
|
|
12550
12632
|
async function accessOp(entry, path, req) {
|
|
12551
12633
|
const g = guardOf(entry);
|
|
12552
|
-
if (!g) return
|
|
12634
|
+
if (!g) return done2;
|
|
12553
12635
|
if (req.arg2 === "follow") return followed(g, path);
|
|
12554
|
-
const
|
|
12555
|
-
const cred =
|
|
12556
|
-
const options = { follow: req.nofollow !== true, ...
|
|
12557
|
-
await need({ ...g, cred },
|
|
12558
|
-
return
|
|
12636
|
+
const open2 = req.arg2 === "open";
|
|
12637
|
+
const cred = open2 || req.arg2 === "eaccess" ? g.cred : realIds(g.cred);
|
|
12638
|
+
const options = { follow: req.nofollow !== true, ...open2 ? { directory: false } : {} };
|
|
12639
|
+
await need({ ...g, cred }, open2 ? "open" : "access", path, req.mode ?? 0, options);
|
|
12640
|
+
return done2;
|
|
12559
12641
|
}
|
|
12560
12642
|
var CHANGING = /* @__PURE__ */ new Set([
|
|
12561
12643
|
"mkdir",
|
|
@@ -12614,7 +12696,7 @@ async function copyOp(entry, path, req) {
|
|
|
12614
12696
|
await (fs.copyFile ? fs.copyFile(path, to, options) : copyByBytes(fs, path, to, options));
|
|
12615
12697
|
if (!owner) await fs.chmod(to, mode);
|
|
12616
12698
|
entry.fresh?.(to);
|
|
12617
|
-
return
|
|
12699
|
+
return done2;
|
|
12618
12700
|
}
|
|
12619
12701
|
async function createExclusive(fs, path, owner) {
|
|
12620
12702
|
if (fs.createExclusive) return fs.createExclusive(path, owner);
|
|
@@ -12661,7 +12743,7 @@ async function ranged(fs, path, req) {
|
|
|
12661
12743
|
};
|
|
12662
12744
|
if (req.op === "pwrite") await ops.pwrite(path, offset, req.body ?? new Uint8Array(0), true);
|
|
12663
12745
|
else await ops.truncate(path, req.length ?? 0);
|
|
12664
|
-
return
|
|
12746
|
+
return done2;
|
|
12665
12747
|
}
|
|
12666
12748
|
var CHOWN_OPS = /* @__PURE__ */ new Set(["chown", "lchown"]);
|
|
12667
12749
|
var UNLINKED_OPS = /* @__PURE__ */ new Set(["read", "pread", "pwrite", "append", "truncate"]);
|
|
@@ -13102,10 +13184,10 @@ var CpuClock = class {
|
|
|
13102
13184
|
}
|
|
13103
13185
|
times() {
|
|
13104
13186
|
const now = this.frozen ?? this.now();
|
|
13105
|
-
const
|
|
13106
|
-
const busy = this.kind === "sys" ? Math.min(
|
|
13187
|
+
const open2 = this.since === 0 ? 0 : Math.max(0, now - this.since);
|
|
13188
|
+
const busy = this.kind === "sys" ? Math.min(open2, SYS_CAP_US) : 0;
|
|
13107
13189
|
const sys = this.sys + busy;
|
|
13108
|
-
const idle2 = this.idle + (
|
|
13190
|
+
const idle2 = this.idle + (open2 - busy) + localIdle(this.sab, now).idle;
|
|
13109
13191
|
const user = Math.max(0, now - this.start - sys - idle2);
|
|
13110
13192
|
this.last = {
|
|
13111
13193
|
utime: Math.max(this.last.utime, Math.floor(user / 1e3)),
|
|
@@ -13262,19 +13344,19 @@ var Pages = class {
|
|
|
13262
13344
|
return Math.max(0, end - at);
|
|
13263
13345
|
}
|
|
13264
13346
|
write(at, bytes) {
|
|
13265
|
-
for (let
|
|
13266
|
-
const pos = at +
|
|
13347
|
+
for (let done5 = 0; done5 < bytes.length; ) {
|
|
13348
|
+
const pos = at + done5;
|
|
13267
13349
|
const page = Math.floor(pos / PAGE);
|
|
13268
13350
|
const from = pos - page * PAGE;
|
|
13269
|
-
const n = Math.min(PAGE - from, bytes.length -
|
|
13351
|
+
const n = Math.min(PAGE - from, bytes.length - done5);
|
|
13270
13352
|
let target = this.pages.get(page);
|
|
13271
13353
|
if (!target) {
|
|
13272
13354
|
target = this.take(0);
|
|
13273
13355
|
this.pages.set(page, target);
|
|
13274
13356
|
}
|
|
13275
|
-
target.set(bytes.subarray(
|
|
13357
|
+
target.set(bytes.subarray(done5, done5 + n), from);
|
|
13276
13358
|
this.dirty.add(page);
|
|
13277
|
-
|
|
13359
|
+
done5 += n;
|
|
13278
13360
|
}
|
|
13279
13361
|
this.length = Math.max(this.length, at + bytes.length);
|
|
13280
13362
|
}
|
|
@@ -13351,10 +13433,10 @@ var Pages = class {
|
|
|
13351
13433
|
clean -= PAGE;
|
|
13352
13434
|
}
|
|
13353
13435
|
}
|
|
13354
|
-
take(
|
|
13436
|
+
take(used2) {
|
|
13355
13437
|
const page = this.free.pop();
|
|
13356
13438
|
if (!page) return new Uint8Array(PAGE);
|
|
13357
|
-
page.fill(0,
|
|
13439
|
+
page.fill(0, used2);
|
|
13358
13440
|
return page;
|
|
13359
13441
|
}
|
|
13360
13442
|
drop(page) {
|
|
@@ -13596,9 +13678,9 @@ function pidFile(name2, info, boot) {
|
|
|
13596
13678
|
}
|
|
13597
13679
|
return pidStatus(info);
|
|
13598
13680
|
}
|
|
13599
|
-
function memoryInfo(source,
|
|
13681
|
+
function memoryInfo(source, used2 = 0) {
|
|
13600
13682
|
const total = source.deviceMemory ? source.deviceMemory * KIB * KIB * KIB : FALLBACK_MEMORY;
|
|
13601
|
-
const free = Math.max(0, total -
|
|
13683
|
+
const free = Math.max(0, total - used2 - (source.usedHeap ?? 0));
|
|
13602
13684
|
const kb = (bytes) => `${Math.floor(bytes / KIB)} kB`;
|
|
13603
13685
|
return [
|
|
13604
13686
|
["MemTotal", kb(total)],
|
|
@@ -13651,10 +13733,10 @@ function memorySource(scope = globalThis) {
|
|
|
13651
13733
|
const nav = scope.navigator;
|
|
13652
13734
|
const perf = scope.performance;
|
|
13653
13735
|
const deviceMemory = nav?.deviceMemory;
|
|
13654
|
-
const
|
|
13736
|
+
const used2 = perf?.memory?.usedJSHeapSize;
|
|
13655
13737
|
return {
|
|
13656
13738
|
...typeof deviceMemory === "number" && deviceMemory > 0 ? { deviceMemory } : {},
|
|
13657
|
-
...typeof
|
|
13739
|
+
...typeof used2 === "number" ? { usedHeap: used2 } : {}
|
|
13658
13740
|
};
|
|
13659
13741
|
}
|
|
13660
13742
|
|
|
@@ -13823,7 +13905,7 @@ var ProcTree = class {
|
|
|
13823
13905
|
};
|
|
13824
13906
|
var MAX_HOPS3 = 40;
|
|
13825
13907
|
function* procWalk(path, follow2) {
|
|
13826
|
-
let
|
|
13908
|
+
let done5 = [];
|
|
13827
13909
|
let todo = path.split("/").filter((part) => part !== "");
|
|
13828
13910
|
let hops = 0;
|
|
13829
13911
|
let broken;
|
|
@@ -13831,20 +13913,20 @@ function* procWalk(path, follow2) {
|
|
|
13831
13913
|
const part = todo.shift();
|
|
13832
13914
|
if (part === ".") continue;
|
|
13833
13915
|
if (part === "..") {
|
|
13834
|
-
|
|
13916
|
+
done5.pop();
|
|
13835
13917
|
continue;
|
|
13836
13918
|
}
|
|
13837
|
-
const at = `/${[...
|
|
13838
|
-
const whole = normalize(`/${[...
|
|
13919
|
+
const at = `/${[...done5, part].join("/")}`;
|
|
13920
|
+
const whole = normalize(`/${[...done5, part, ...todo].join("/")}`);
|
|
13839
13921
|
if (inProc(at) && inProc(whole)) return broken ?? whole;
|
|
13840
13922
|
if (!follow2 && todo.length === 0) return void 0;
|
|
13841
13923
|
const target = yield { at, check: todo.find((next3) => next3 !== ".") === ".." };
|
|
13842
13924
|
if (typeof target === "string") {
|
|
13843
13925
|
if (++hops > MAX_HOPS3) return void 0;
|
|
13844
|
-
[
|
|
13926
|
+
[done5, todo] = throughLink(target, done5, todo);
|
|
13845
13927
|
} else {
|
|
13846
13928
|
broken ??= refusalOf(target);
|
|
13847
|
-
|
|
13929
|
+
done5.push(part);
|
|
13848
13930
|
}
|
|
13849
13931
|
}
|
|
13850
13932
|
return void 0;
|
|
@@ -13857,9 +13939,9 @@ function refusalOf(found) {
|
|
|
13857
13939
|
if (found === true) return void 0;
|
|
13858
13940
|
return found === false ? { refused: "ENOTDIR" } : found;
|
|
13859
13941
|
}
|
|
13860
|
-
function throughLink(target,
|
|
13942
|
+
function throughLink(target, done5, todo) {
|
|
13861
13943
|
const parts2 = target.split("/").filter((part) => part !== "");
|
|
13862
|
-
return [target.startsWith("/") ? [] :
|
|
13944
|
+
return [target.startsWith("/") ? [] : done5, [...parts2, ...todo]];
|
|
13863
13945
|
}
|
|
13864
13946
|
async function procAlias(fs, path, follow2) {
|
|
13865
13947
|
const { readlink, lstat } = fs;
|
|
@@ -14056,16 +14138,16 @@ var EpollFile = class _EpollFile {
|
|
|
14056
14138
|
changes = new Notifier();
|
|
14057
14139
|
cursor = 0;
|
|
14058
14140
|
ctl(fds, how, fd, events, data) {
|
|
14059
|
-
const
|
|
14060
|
-
if (
|
|
14141
|
+
const open2 = fds.get(fd);
|
|
14142
|
+
if (open2.file === this) throw new KernelError("EINVAL");
|
|
14061
14143
|
const known = this.regs.get(fd);
|
|
14062
|
-
const current = known?.open ===
|
|
14144
|
+
const current = known?.open === open2 ? known : void 0;
|
|
14063
14145
|
if (how === "add" || how === "set" && !current) {
|
|
14064
14146
|
if (current) throw new KernelError("EEXIST");
|
|
14065
|
-
if (UNPOLLABLE.has(kernelFdKind(
|
|
14066
|
-
if (
|
|
14147
|
+
if (UNPOLLABLE.has(kernelFdKind(open2.file))) throw new KernelError("EPERM");
|
|
14148
|
+
if (open2.file instanceof _EpollFile && open2.file.reaches(this)) throw new KernelError("ELOOP");
|
|
14067
14149
|
if (known) this.drop(known);
|
|
14068
|
-
this.register(fd,
|
|
14150
|
+
this.register(fd, open2, events, data);
|
|
14069
14151
|
} else if (!current) {
|
|
14070
14152
|
throw new KernelError("ENOENT");
|
|
14071
14153
|
} else if (how === "del") {
|
|
@@ -14132,15 +14214,15 @@ var EpollFile = class _EpollFile {
|
|
|
14132
14214
|
for (const reg of [...this.regs.values()]) this.drop(reg);
|
|
14133
14215
|
this.changes.wake();
|
|
14134
14216
|
}
|
|
14135
|
-
register(fd,
|
|
14217
|
+
register(fd, open2, events, data) {
|
|
14136
14218
|
const stop = new AbortController();
|
|
14137
|
-
const unhook =
|
|
14219
|
+
const unhook = open2.onClose(() => {
|
|
14138
14220
|
this.drop(reg);
|
|
14139
14221
|
this.changes.wake();
|
|
14140
14222
|
});
|
|
14141
14223
|
const reg = {
|
|
14142
14224
|
fd,
|
|
14143
|
-
open,
|
|
14225
|
+
open: open2,
|
|
14144
14226
|
events,
|
|
14145
14227
|
data,
|
|
14146
14228
|
gen: 1,
|
|
@@ -14221,17 +14303,17 @@ function changedAt(wakers, key, signal) {
|
|
|
14221
14303
|
return new Promise((resolve2, reject) => {
|
|
14222
14304
|
const set3 = wakers.get(key) ?? /* @__PURE__ */ new Set();
|
|
14223
14305
|
wakers.set(key, set3);
|
|
14224
|
-
const
|
|
14306
|
+
const done5 = () => {
|
|
14225
14307
|
set3.delete(wake);
|
|
14226
14308
|
if (set3.size === 0 && wakers.get(key) === set3) wakers.delete(key);
|
|
14227
14309
|
signal.removeEventListener("abort", abort);
|
|
14228
14310
|
};
|
|
14229
14311
|
const wake = () => {
|
|
14230
|
-
|
|
14312
|
+
done5();
|
|
14231
14313
|
resolve2();
|
|
14232
14314
|
};
|
|
14233
14315
|
const abort = () => {
|
|
14234
|
-
|
|
14316
|
+
done5();
|
|
14235
14317
|
reject(new KernelError("EINTR"));
|
|
14236
14318
|
};
|
|
14237
14319
|
set3.add(wake);
|
|
@@ -14439,7 +14521,7 @@ var HOST_OPS = [
|
|
|
14439
14521
|
"async-close"
|
|
14440
14522
|
];
|
|
14441
14523
|
var json3 = (value2) => ({ ok: true, kind: "json", json: value2 });
|
|
14442
|
-
var
|
|
14524
|
+
var done3 = { ok: true, kind: "void" };
|
|
14443
14525
|
var KEPT_OPS = /* @__PURE__ */ new Set(["fd-write"]);
|
|
14444
14526
|
var unknownSettled = false;
|
|
14445
14527
|
var AsyncOps = class {
|
|
@@ -14576,7 +14658,7 @@ async function hostSyscall(req, ctx) {
|
|
|
14576
14658
|
if (req.fd !== void 0 && ctx.locks?.shared?.() && ctx.flockOf) {
|
|
14577
14659
|
return flock({ op: "flock", fd: req.fd, kind: "unlock" }, ctx);
|
|
14578
14660
|
}
|
|
14579
|
-
return
|
|
14661
|
+
return done3;
|
|
14580
14662
|
case "lk-set":
|
|
14581
14663
|
case "lk-get":
|
|
14582
14664
|
case "lk-close":
|
|
@@ -14597,12 +14679,12 @@ async function hostSyscall(req, ctx) {
|
|
|
14597
14679
|
return json3(ctx.ops.hold());
|
|
14598
14680
|
case "async-cancel":
|
|
14599
14681
|
ctx.ops.cancel(req.id);
|
|
14600
|
-
return
|
|
14682
|
+
return done3;
|
|
14601
14683
|
case "async-settle":
|
|
14602
14684
|
return json3(await ctx.ops.settle(req.ids));
|
|
14603
14685
|
case "async-close":
|
|
14604
14686
|
ctx.ops.close();
|
|
14605
|
-
return
|
|
14687
|
+
return done3;
|
|
14606
14688
|
}
|
|
14607
14689
|
}
|
|
14608
14690
|
async function wholeLock(req, ctx) {
|
|
@@ -14620,7 +14702,7 @@ async function wholeLock(req, ctx) {
|
|
|
14620
14702
|
if (!locks.flockFree(key, owner, kind)) throw new KernelError("EAGAIN");
|
|
14621
14703
|
}
|
|
14622
14704
|
if (!locks.lock(ctx.pid, req.path, req.exclusive, req.fd)) throw new KernelError("EAGAIN");
|
|
14623
|
-
return
|
|
14705
|
+
return done3;
|
|
14624
14706
|
}
|
|
14625
14707
|
var FLOCK_KINDS = /* @__PURE__ */ new Set(["shared", "exclusive", "unlock"]);
|
|
14626
14708
|
async function flock(req, ctx) {
|
|
@@ -14635,7 +14717,7 @@ async function flock(req, ctx) {
|
|
|
14635
14717
|
await locks.flocks.wait(key, owner, req.kind, ctx.blocking);
|
|
14636
14718
|
else if (!await locks.flocks.set(key, owner, req.kind)) throw new KernelError("EAGAIN");
|
|
14637
14719
|
if (shared && granted2) await grantedAcross(ctx, req.fd);
|
|
14638
|
-
return shared ? json3(true) :
|
|
14720
|
+
return shared ? json3(true) : done3;
|
|
14639
14721
|
}
|
|
14640
14722
|
async function grantedAcross(ctx, fd) {
|
|
14641
14723
|
ctx.locks?.fresh?.();
|
|
@@ -14652,7 +14734,7 @@ async function recordLock2(req, ctx) {
|
|
|
14652
14734
|
if (req.op === "lk-close") {
|
|
14653
14735
|
if (req.fd !== void 0 && locks.shared?.()) await ctx.settle?.(req.fd, false);
|
|
14654
14736
|
locks.dropFile(await fileKey(target, "close"), owner);
|
|
14655
|
-
return
|
|
14737
|
+
return done3;
|
|
14656
14738
|
}
|
|
14657
14739
|
const range2 = lockRange(req.start, req.len);
|
|
14658
14740
|
const key = await fileKey(target, req.kind, req.op === "lk-set" && req.fd !== void 0);
|
|
@@ -14671,7 +14753,7 @@ async function recordLock2(req, ctx) {
|
|
|
14671
14753
|
else if (!await locks.set(key, owner, req.kind, range2.start, range2.end))
|
|
14672
14754
|
throw new KernelError("EAGAIN");
|
|
14673
14755
|
if (granted2 && shared) await grantedAcross(ctx, fd);
|
|
14674
|
-
return shared ? json3(true) :
|
|
14756
|
+
return shared ? json3(true) : done3;
|
|
14675
14757
|
}
|
|
14676
14758
|
|
|
14677
14759
|
// src/kernel/net/loopback-transport.ts
|
|
@@ -15223,7 +15305,7 @@ var CA_RENEW_BEFORE = 30 * DAY;
|
|
|
15223
15305
|
var LEAF_LIFETIME = 7 * DAY;
|
|
15224
15306
|
var ECDSA = { name: "ECDSA", namedCurve: "P-256" };
|
|
15225
15307
|
var SIGN = { name: "ECDSA", hash: "SHA-256" };
|
|
15226
|
-
function
|
|
15308
|
+
function request2(req) {
|
|
15227
15309
|
return new Promise((resolve2, reject) => {
|
|
15228
15310
|
req.onsuccess = () => resolve2(req.result);
|
|
15229
15311
|
req.onerror = () => reject(req.error);
|
|
@@ -15231,7 +15313,7 @@ function request(req) {
|
|
|
15231
15313
|
}
|
|
15232
15314
|
function indexedDbCaStore(dbName = "slicc-realm-ca") {
|
|
15233
15315
|
let db;
|
|
15234
|
-
const
|
|
15316
|
+
const open2 = () => {
|
|
15235
15317
|
db ??= new Promise((resolve2, reject) => {
|
|
15236
15318
|
const req = indexedDB.open(dbName, 1);
|
|
15237
15319
|
req.onupgradeneeded = () => req.result.createObjectStore("ca");
|
|
@@ -15245,11 +15327,11 @@ function indexedDbCaStore(dbName = "slicc-realm-ca") {
|
|
|
15245
15327
|
};
|
|
15246
15328
|
return {
|
|
15247
15329
|
async get(owner) {
|
|
15248
|
-
const store = (await
|
|
15249
|
-
return await
|
|
15330
|
+
const store = (await open2()).transaction("ca").objectStore("ca");
|
|
15331
|
+
return await request2(store.get(owner));
|
|
15250
15332
|
},
|
|
15251
15333
|
async swap(owner, expected, record) {
|
|
15252
|
-
const tx = (await
|
|
15334
|
+
const tx = (await open2()).transaction("ca", "readwrite");
|
|
15253
15335
|
const store = tx.objectStore("ca");
|
|
15254
15336
|
let stored = record;
|
|
15255
15337
|
const read = store.get(owner);
|
|
@@ -15952,7 +16034,7 @@ var WsHandles = class {
|
|
|
15952
16034
|
async connect(handle, req, entry) {
|
|
15953
16035
|
const { transport, local } = this;
|
|
15954
16036
|
const port = local?.port(req.url);
|
|
15955
|
-
const
|
|
16037
|
+
const open2 = { protocols: req.protocols, headers: req.headers, signal: entry.abort.signal };
|
|
15956
16038
|
if (port === void 0 && (!transport.traits.websocket || !transport.websocket)) {
|
|
15957
16039
|
return fail("ENOTSUP", NO_WEBSOCKET2);
|
|
15958
16040
|
}
|
|
@@ -15960,8 +16042,8 @@ var WsHandles = class {
|
|
|
15960
16042
|
try {
|
|
15961
16043
|
socket = port === void 0 ? await transport.websocket({
|
|
15962
16044
|
url: toHostLoopback(req.url),
|
|
15963
|
-
...
|
|
15964
|
-
}) : await local.websocket({ url: req.url, ...
|
|
16045
|
+
...open2
|
|
16046
|
+
}) : await local.websocket({ url: req.url, ...open2 }, port);
|
|
15965
16047
|
} catch (e) {
|
|
15966
16048
|
return fail(errnoOf(e), message(e));
|
|
15967
16049
|
}
|
|
@@ -16164,14 +16246,14 @@ var HttpHandles = class {
|
|
|
16164
16246
|
const port = this.local?.port(req.url);
|
|
16165
16247
|
try {
|
|
16166
16248
|
const target = port === void 0 ? toHostLoopback(req.url) : req.url;
|
|
16167
|
-
const
|
|
16249
|
+
const request3 = {
|
|
16168
16250
|
url: target,
|
|
16169
16251
|
method: req.method,
|
|
16170
16252
|
headers: req.headers,
|
|
16171
16253
|
...entry.upload ? { bodyStream: entry.upload } : req.body ? { body: req.body } : {},
|
|
16172
16254
|
signal: entry.abort.signal
|
|
16173
16255
|
};
|
|
16174
|
-
const response = port === void 0 ? await this.transport.fetch(
|
|
16256
|
+
const response = port === void 0 ? await this.transport.fetch(request3, this.owner) : await this.local.fetch(request3, port);
|
|
16175
16257
|
entry.body = response.body[Symbol.asyncIterator]();
|
|
16176
16258
|
entry.cancel = () => response.cancel();
|
|
16177
16259
|
if (!this.open.has(handle)) await entry.cancel().catch(() => void 0);
|
|
@@ -16323,10 +16405,10 @@ var RemoteUplink = class {
|
|
|
16323
16405
|
write: async (bytes) => {
|
|
16324
16406
|
const copy = bytes.slice();
|
|
16325
16407
|
const call = { uplink: "write", uid: ++this.nextId, cid, bytes: copy };
|
|
16326
|
-
const
|
|
16408
|
+
const done5 = await this.ask(call, void 0, [
|
|
16327
16409
|
copy.buffer
|
|
16328
16410
|
]);
|
|
16329
|
-
return
|
|
16411
|
+
return done5.n;
|
|
16330
16412
|
},
|
|
16331
16413
|
closeWrite: () => this.port.postMessage({ uplink: "close-write", cid }),
|
|
16332
16414
|
close: () => this.port.postMessage({ uplink: "close", cid })
|
|
@@ -16933,7 +17015,7 @@ function terminalOf(ctx, fd) {
|
|
|
16933
17015
|
return tty;
|
|
16934
17016
|
}
|
|
16935
17017
|
var json4 = (value2) => ({ ok: true, kind: "json", json: value2 });
|
|
16936
|
-
var
|
|
17018
|
+
var done4 = { ok: true, kind: "void" };
|
|
16937
17019
|
function sizeKey(rows, cols) {
|
|
16938
17020
|
return `${rows}x${cols}`;
|
|
16939
17021
|
}
|
|
@@ -16956,23 +17038,23 @@ function ptySyscall(req, ctx) {
|
|
|
16956
17038
|
return json4(masterOf(ctx, req.fd).index);
|
|
16957
17039
|
case "pty-lock":
|
|
16958
17040
|
masterOf(ctx, req.fd).locked = req.lock;
|
|
16959
|
-
return
|
|
17041
|
+
return done4;
|
|
16960
17042
|
case "pty-ctty": {
|
|
16961
17043
|
const tty = terminalOf(ctx, req.fd);
|
|
16962
17044
|
const leader = ctx.jobs?.getsid(ctx.pid, 0) === ctx.pid;
|
|
16963
|
-
if (leader && ctx.jobs?.controllingTerminal(ctx.pid) === tty) return
|
|
17045
|
+
if (leader && ctx.jobs?.controllingTerminal(ctx.pid) === tty) return done4;
|
|
16964
17046
|
if (!ctx.jobs?.acquireTerminal(ctx.pid, tty)) throw new KernelError("EPERM");
|
|
16965
|
-
return
|
|
17047
|
+
return done4;
|
|
16966
17048
|
}
|
|
16967
17049
|
case "pty-list":
|
|
16968
17050
|
return json4(ctx.ptys?.numbers() ?? []);
|
|
16969
17051
|
case "pty-packet":
|
|
16970
17052
|
masterOf(ctx, req.fd).packet = req.on;
|
|
16971
|
-
return
|
|
17053
|
+
return done4;
|
|
16972
17054
|
case "pty-winsz-set": {
|
|
16973
17055
|
const tty = terminalOf(ctx, req.fd);
|
|
16974
17056
|
if (ctx.sizesRead?.get(tty) !== sizeKey(req.rows, req.cols)) tty.resize(req.cols, req.rows);
|
|
16975
|
-
return
|
|
17057
|
+
return done4;
|
|
16976
17058
|
}
|
|
16977
17059
|
}
|
|
16978
17060
|
}
|
|
@@ -17059,8 +17141,8 @@ async function runChild(req, deps) {
|
|
|
17059
17141
|
let status;
|
|
17060
17142
|
try {
|
|
17061
17143
|
status = await reaped(deps, pid);
|
|
17062
|
-
const
|
|
17063
|
-
await Promise.race([Promise.all(
|
|
17144
|
+
const open2 = controls2.filter((c) => c.opened);
|
|
17145
|
+
await Promise.race([Promise.all(open2.map((c) => c.eof)), decided.promise]);
|
|
17064
17146
|
} finally {
|
|
17065
17147
|
cancel?.();
|
|
17066
17148
|
for (const control of controls2) control.shut = true;
|
|
@@ -17338,7 +17420,7 @@ function filePath(addr) {
|
|
|
17338
17420
|
if (addr.family !== "unix" || addr.path === "" || addr.path.startsWith("\0")) return void 0;
|
|
17339
17421
|
return normalizePath(addr.path);
|
|
17340
17422
|
}
|
|
17341
|
-
function
|
|
17423
|
+
function nameOf2(st) {
|
|
17342
17424
|
return { key: `${st.dev ?? 0}:${st.ino}`, typed: st.isSocket === true };
|
|
17343
17425
|
}
|
|
17344
17426
|
function codeOf3(err) {
|
|
@@ -17360,7 +17442,7 @@ function socketNames(deps) {
|
|
|
17360
17442
|
const remove = () => fs.rm(path, { file: true }).catch(() => void 0);
|
|
17361
17443
|
try {
|
|
17362
17444
|
if (!deps.owners && owner.mode !== void 0) await fs.chmod(path, owner.mode);
|
|
17363
|
-
return { ...
|
|
17445
|
+
return { ...nameOf2(await fs.lstat(path)), remove };
|
|
17364
17446
|
} catch (err) {
|
|
17365
17447
|
await remove();
|
|
17366
17448
|
throw err;
|
|
@@ -17369,7 +17451,7 @@ function socketNames(deps) {
|
|
|
17369
17451
|
async find(path) {
|
|
17370
17452
|
const g = deps.guard();
|
|
17371
17453
|
if (g) await need(g, "connect", path, W_OK, { directory: false });
|
|
17372
|
-
return
|
|
17454
|
+
return nameOf2(await fs.stat(path));
|
|
17373
17455
|
}
|
|
17374
17456
|
};
|
|
17375
17457
|
}
|
|
@@ -18185,17 +18267,17 @@ function scrubbed(inner, scrubber, idleMs = SCRUB_IDLE_MS) {
|
|
|
18185
18267
|
});
|
|
18186
18268
|
};
|
|
18187
18269
|
const settling = (signal) => new Promise((resolve2, reject) => {
|
|
18188
|
-
const
|
|
18189
|
-
waiters.delete(
|
|
18270
|
+
const done5 = () => {
|
|
18271
|
+
waiters.delete(done5);
|
|
18190
18272
|
signal?.removeEventListener("abort", stop);
|
|
18191
18273
|
resolve2();
|
|
18192
18274
|
};
|
|
18193
18275
|
const stop = () => {
|
|
18194
|
-
waiters.delete(
|
|
18276
|
+
waiters.delete(done5);
|
|
18195
18277
|
reject(new KernelError("EINTR"));
|
|
18196
18278
|
};
|
|
18197
18279
|
if (signal?.aborted) return stop();
|
|
18198
|
-
waiters.add(
|
|
18280
|
+
waiters.add(done5);
|
|
18199
18281
|
signal?.addEventListener("abort", stop, { once: true });
|
|
18200
18282
|
});
|
|
18201
18283
|
const settled = async () => {
|
|
@@ -18387,15 +18469,15 @@ async function substituteHead(head, ask) {
|
|
|
18387
18469
|
if (!head.endsWith("\r\n\r\n")) return void 0;
|
|
18388
18470
|
const lines2 = head.slice(0, -4).split("\r\n");
|
|
18389
18471
|
if (lines2.some((l) => l.includes("\n") || l.includes("\r"))) return void 0;
|
|
18390
|
-
const
|
|
18391
|
-
const found =
|
|
18392
|
-
if (!
|
|
18472
|
+
const request3 = REQUEST_LINE2.exec(lines2[0]);
|
|
18473
|
+
const found = request3 ? scan(lines2) : void 0;
|
|
18474
|
+
if (!request3 || !found || found.length !== 1) return void 0;
|
|
18393
18475
|
const at = found[0];
|
|
18394
18476
|
if (at.placeholders.length > SESSION_PLACEHOLDERS) return void 0;
|
|
18395
18477
|
const values = usable(
|
|
18396
18478
|
await ask(`header:${at.name}`, at.placeholders, {
|
|
18397
|
-
method:
|
|
18398
|
-
path:
|
|
18479
|
+
method: request3[1],
|
|
18480
|
+
path: request3[2]
|
|
18399
18481
|
})
|
|
18400
18482
|
);
|
|
18401
18483
|
if (Object.keys(values).length === 0) return void 0;
|
|
@@ -18498,7 +18580,7 @@ var Http1Writer = class {
|
|
|
18498
18580
|
this.buffer = new Uint8Array(0);
|
|
18499
18581
|
const s = this.s;
|
|
18500
18582
|
const session = sessionId();
|
|
18501
|
-
const
|
|
18583
|
+
const done5 = await substituteHead(
|
|
18502
18584
|
latin12(all.subarray(0, end)),
|
|
18503
18585
|
async (position, placeholders, head2) => s.broker.sessionMaterialize({
|
|
18504
18586
|
stamp: await s.stamp(),
|
|
@@ -18514,10 +18596,10 @@ var Http1Writer = class {
|
|
|
18514
18596
|
head: head2
|
|
18515
18597
|
})
|
|
18516
18598
|
).catch(() => void 0);
|
|
18517
|
-
const head =
|
|
18518
|
-
if (
|
|
18599
|
+
const head = done5 ? bytesOf(done5.head) : all.subarray(0, end);
|
|
18600
|
+
if (done5) {
|
|
18519
18601
|
this.scope.add(
|
|
18520
|
-
Object.entries(
|
|
18602
|
+
Object.entries(done5.values).map(([placeholder, value2]) => ({
|
|
18521
18603
|
name: "sealed",
|
|
18522
18604
|
value: value2,
|
|
18523
18605
|
placeholder
|
|
@@ -18935,15 +19017,15 @@ function alertOf(session) {
|
|
|
18935
19017
|
}
|
|
18936
19018
|
async function handshake(conn, o, session, inbox) {
|
|
18937
19019
|
for (; ; ) {
|
|
18938
|
-
let
|
|
19020
|
+
let done5;
|
|
18939
19021
|
try {
|
|
18940
|
-
|
|
19022
|
+
done5 = session.handshake();
|
|
18941
19023
|
} catch (err) {
|
|
18942
19024
|
await send(conn, session).catch(() => void 0);
|
|
18943
19025
|
throw refused2(o.engine, session, err);
|
|
18944
19026
|
}
|
|
18945
19027
|
await send(conn, session);
|
|
18946
|
-
if (
|
|
19028
|
+
if (done5) return;
|
|
18947
19029
|
if (!await inbox.more()) {
|
|
18948
19030
|
throw new KernelError(
|
|
18949
19031
|
"ECONNRESET",
|
|
@@ -20173,9 +20255,9 @@ var VfsNodes = class {
|
|
|
20173
20255
|
}
|
|
20174
20256
|
open(path, pin, writable2 = false, id2, ino) {
|
|
20175
20257
|
const found = this.named(path, id2);
|
|
20176
|
-
const
|
|
20177
|
-
if (found && !
|
|
20178
|
-
const node = (
|
|
20258
|
+
const same2 = !found || ino === void 0 || found.ino === void 0 || found.ino === ino;
|
|
20259
|
+
if (found && !same2) this.orphan(found);
|
|
20260
|
+
const node = (same2 ? found : void 0) ?? this.create(path, id2, new VfsNode(this.fs, path, void 0, false, false, pin));
|
|
20179
20261
|
node.ino ??= ino;
|
|
20180
20262
|
node.opens++;
|
|
20181
20263
|
if (writable2) node.writers++;
|
|
@@ -20358,9 +20440,9 @@ function heldIo(fs, nodes, changed) {
|
|
|
20358
20440
|
const held = await node(path);
|
|
20359
20441
|
if (!held) return fallback();
|
|
20360
20442
|
const out = await held.serial(async () => {
|
|
20361
|
-
const
|
|
20443
|
+
const done5 = await op(held);
|
|
20362
20444
|
await held.flush();
|
|
20363
|
-
return
|
|
20445
|
+
return done5;
|
|
20364
20446
|
});
|
|
20365
20447
|
changed(fs.resolvePath("/", path));
|
|
20366
20448
|
if (held.path !== fs.resolvePath("/", path)) changed(held.path);
|
|
@@ -21193,30 +21275,30 @@ var WasmProcess = class {
|
|
|
21193
21275
|
else await file?.flush?.();
|
|
21194
21276
|
}
|
|
21195
21277
|
async flockOf(fd) {
|
|
21196
|
-
const
|
|
21278
|
+
const open2 = this.fds.get(fd);
|
|
21197
21279
|
const { locks } = this.options;
|
|
21198
|
-
if (locks && !flockHooked.has(
|
|
21199
|
-
flockHooked.add(
|
|
21200
|
-
|
|
21280
|
+
if (locks && !flockHooked.has(open2)) {
|
|
21281
|
+
flockHooked.add(open2);
|
|
21282
|
+
open2.onClose(() => locks.flocks.drop(open2));
|
|
21201
21283
|
}
|
|
21202
|
-
return { key: await this.objectKeyOf(
|
|
21284
|
+
return { key: await this.objectKeyOf(open2), owner: open2 };
|
|
21203
21285
|
}
|
|
21204
|
-
async objectKeyOf(
|
|
21205
|
-
const { file } =
|
|
21286
|
+
async objectKeyOf(open2) {
|
|
21287
|
+
const { file } = open2;
|
|
21206
21288
|
const meta = file.heldMeta;
|
|
21207
21289
|
if (meta && "device" in meta) return `device:${meta.device}`;
|
|
21208
21290
|
if (meta && "dir" in meta) {
|
|
21209
21291
|
const st2 = await this.options.fs.stat?.(meta.dir).catch(() => void 0);
|
|
21210
21292
|
return st2 ? identityKey(st2, meta.dir) : objectKey(file);
|
|
21211
21293
|
}
|
|
21212
|
-
const known = fileKeys.get(
|
|
21294
|
+
const known = fileKeys.get(open2);
|
|
21213
21295
|
if (known !== void 0) return known;
|
|
21214
21296
|
const vfs = await file.stat?.().catch(() => void 0);
|
|
21215
21297
|
if (!vfs || vfs.orphan) return objectKey(file);
|
|
21216
21298
|
const st = await this.options.fs.stat?.(vfs.path).catch(() => void 0);
|
|
21217
21299
|
if (!st) return objectKey(file);
|
|
21218
21300
|
const key = identityKey(st, vfs.path);
|
|
21219
|
-
fileKeys.set(
|
|
21301
|
+
fileKeys.set(open2, key);
|
|
21220
21302
|
return key;
|
|
21221
21303
|
}
|
|
21222
21304
|
async dropRecordLocks(fd) {
|
|
@@ -21338,17 +21420,17 @@ var WasmProcess = class {
|
|
|
21338
21420
|
return fd;
|
|
21339
21421
|
}
|
|
21340
21422
|
if (this.writesAt(req) && this.options.readonlyAt?.(path)) throw new KernelError("EROFS");
|
|
21341
|
-
const
|
|
21423
|
+
const open2 = { ...req, path };
|
|
21342
21424
|
const plain2 = this.plainMode(req.mode);
|
|
21343
21425
|
if (req.exclusive) {
|
|
21344
21426
|
await nodes.createExclusive(path, this.newOwner(req.mode));
|
|
21345
21427
|
if (plain2 !== void 0) await fs.chmod?.(path, plain2);
|
|
21346
|
-
this.fds.installAt(fd, this.openVfsFile(
|
|
21428
|
+
this.fds.installAt(fd, this.openVfsFile(open2, void 0, fs));
|
|
21347
21429
|
} else if (req.create) {
|
|
21348
21430
|
await nodes.onEntry(path, async () => {
|
|
21349
21431
|
const marks = this.options.owners || plain2 !== void 0;
|
|
21350
21432
|
const fresh2 = marks && !await present3(fs, path, true);
|
|
21351
|
-
this.fds.installAt(fd, this.openVfsFile(
|
|
21433
|
+
this.fds.installAt(fd, this.openVfsFile(open2, await nodes.identify(path), fs));
|
|
21352
21434
|
await this.fds.get(fd).file.stat?.();
|
|
21353
21435
|
if (fresh2 && plain2 !== void 0) await fs.chmod?.(path, plain2);
|
|
21354
21436
|
else if (fresh2) {
|
|
@@ -21362,7 +21444,7 @@ var WasmProcess = class {
|
|
|
21362
21444
|
await this.stillOpen(at, req.handle);
|
|
21363
21445
|
return nodes.identify(at);
|
|
21364
21446
|
},
|
|
21365
|
-
(id2, at) => this.fds.installAt(fd, this.openVfsFile({ ...
|
|
21447
|
+
(id2, at) => this.fds.installAt(fd, this.openVfsFile({ ...open2, path: at }, id2, fs)),
|
|
21366
21448
|
{ at: path, gen }
|
|
21367
21449
|
);
|
|
21368
21450
|
}
|
|
@@ -21477,11 +21559,11 @@ var WasmProcess = class {
|
|
|
21477
21559
|
}
|
|
21478
21560
|
async stampClipboards() {
|
|
21479
21561
|
if (!this.options.clipboard) return;
|
|
21480
|
-
const
|
|
21481
|
-
if (
|
|
21562
|
+
const open2 = this.fds.numbers().filter((fd) => this.fds.get(fd).file.clipboard);
|
|
21563
|
+
if (open2.length === 0) return;
|
|
21482
21564
|
const stamp = await this.clipboardStamp().catch(() => void 0);
|
|
21483
21565
|
if (!stamp) return;
|
|
21484
|
-
for (const fd of
|
|
21566
|
+
for (const fd of open2) {
|
|
21485
21567
|
const channel = this.fds.get(fd).file.clipboard;
|
|
21486
21568
|
if (channel) channel.stamp = stamp;
|
|
21487
21569
|
}
|
|
@@ -22274,18 +22356,18 @@ function descId(file) {
|
|
|
22274
22356
|
}
|
|
22275
22357
|
function inheritedFds(fds) {
|
|
22276
22358
|
return fds.numbers().filter((fd) => fd > 2 && !fds.get(fd).file.held).map((fd) => {
|
|
22277
|
-
const
|
|
22359
|
+
const open2 = fds.get(fd);
|
|
22278
22360
|
const flags2 = fds.statusFlags(fd);
|
|
22279
|
-
const kind =
|
|
22280
|
-
const meta =
|
|
22361
|
+
const kind = open2.file instanceof KernelSocket || isDatagram(open2.file) ? "socket" : kernelFdKind(open2.file);
|
|
22362
|
+
const meta = open2.file.heldMeta;
|
|
22281
22363
|
return {
|
|
22282
22364
|
fd,
|
|
22283
22365
|
kind,
|
|
22284
22366
|
...kind === "device" && meta && "device" in meta ? { device: meta } : {},
|
|
22285
22367
|
...flags2 !== void 0 ? { flags: flags2 } : {},
|
|
22286
22368
|
...fds.closesOnExec(fd) ? { cloexec: true } : {},
|
|
22287
|
-
...kind === "stream" ? { desc: descId(
|
|
22288
|
-
...
|
|
22369
|
+
...kind === "stream" ? { desc: descId(open2) } : {},
|
|
22370
|
+
...open2.file.fifo ? { fifo: open2.file.fifo } : {}
|
|
22289
22371
|
};
|
|
22290
22372
|
});
|
|
22291
22373
|
}
|
|
@@ -22451,7 +22533,7 @@ function holdingToken(opts, holds2, caller) {
|
|
|
22451
22533
|
noLinks: opts.noLinks,
|
|
22452
22534
|
cwd: opts.cwd,
|
|
22453
22535
|
...opts.statfs ? { statfs: opts.statfs } : {},
|
|
22454
|
-
hold: (path, on,
|
|
22536
|
+
hold: (path, on, open2, real, handle) => holds2.hold(path, on, open2, real, handle),
|
|
22455
22537
|
keptFor: (handle) => holds2.keptFor(handle),
|
|
22456
22538
|
unlinked: (path) => holds2.keptAt(path),
|
|
22457
22539
|
gate: (path, op) => opts.unlinkGate && holds2.holding(path) ? opts.unlinkGate.run(holds2.keyOf(path), op) : op(),
|
|
@@ -22600,11 +22682,11 @@ function spawnWasmProcess(opts) {
|
|
|
22600
22682
|
});
|
|
22601
22683
|
const lane = opts.program.abi === "js" ? openLane(token, dispatch2) : void 0;
|
|
22602
22684
|
const { promise: exited, resolve: settle3 } = Promise.withResolvers();
|
|
22603
|
-
let
|
|
22685
|
+
let done5 = false;
|
|
22604
22686
|
let endedBy;
|
|
22605
22687
|
const finish = (code, sig) => {
|
|
22606
|
-
if (
|
|
22607
|
-
|
|
22688
|
+
if (done5) return;
|
|
22689
|
+
done5 = true;
|
|
22608
22690
|
started(true);
|
|
22609
22691
|
clocks.freeze();
|
|
22610
22692
|
dying.clear();
|
|
@@ -22655,7 +22737,7 @@ function spawnWasmProcess(opts) {
|
|
|
22655
22737
|
};
|
|
22656
22738
|
const spawnThread = (thread) => {
|
|
22657
22739
|
const { program } = opts;
|
|
22658
|
-
if (
|
|
22740
|
+
if (done5 || program.abi === "js") return;
|
|
22659
22741
|
if (threads.size >= WASM_MAX_THREADS - 1) {
|
|
22660
22742
|
opts.onError?.(`more than ${WASM_MAX_THREADS} threads`);
|
|
22661
22743
|
finish(CRASHED);
|
|
@@ -22691,7 +22773,7 @@ function spawnWasmProcess(opts) {
|
|
|
22691
22773
|
transferOf(opts, lane?.lane)
|
|
22692
22774
|
);
|
|
22693
22775
|
const terminate = (code, sig) => {
|
|
22694
|
-
if (opts.program.abi !== "wasi" ||
|
|
22776
|
+
if (opts.program.abi !== "wasi" || done5) finish(code, sig);
|
|
22695
22777
|
else dying.start(code, sig, header3, process, () => finish(code, sig));
|
|
22696
22778
|
};
|
|
22697
22779
|
const signal = (sig, info) => {
|
|
@@ -22713,7 +22795,7 @@ function spawnWasmProcess(opts) {
|
|
|
22713
22795
|
signalMasks: () => process.signalMasks(),
|
|
22714
22796
|
umask: () => process.umask,
|
|
22715
22797
|
cred: () => copyCred(process.cred),
|
|
22716
|
-
writesBack: () => opts.program.abi === "wasi" && !
|
|
22798
|
+
writesBack: () => opts.program.abi === "wasi" && !done5,
|
|
22717
22799
|
...clockViews(clocks)
|
|
22718
22800
|
};
|
|
22719
22801
|
}
|
|
@@ -23381,21 +23463,21 @@ function replayingHops(inner, heldMs = HELD_MS) {
|
|
|
23381
23463
|
return { ...inner.traits, manualRedirects: true };
|
|
23382
23464
|
},
|
|
23383
23465
|
...inner.websocket ? { websocket: inner.websocket.bind(inner) } : {},
|
|
23384
|
-
async fetch(
|
|
23385
|
-
const key = keyOf3(owner,
|
|
23466
|
+
async fetch(request3, owner = KERNEL) {
|
|
23467
|
+
const key = keyOf3(owner, request3.method, request3.url);
|
|
23386
23468
|
const waiting = held.get(key);
|
|
23387
|
-
if (waiting && waiting.fingerprint === fingerprint(
|
|
23469
|
+
if (waiting && waiting.fingerprint === fingerprint(request3.headers)) {
|
|
23388
23470
|
held.delete(key);
|
|
23389
23471
|
clearTimeout(waiting.timer);
|
|
23390
23472
|
return replay(waiting);
|
|
23391
23473
|
}
|
|
23392
23474
|
if (waiting) drop(key);
|
|
23393
|
-
const response = await inner.fetch(
|
|
23475
|
+
const response = await inner.fetch(request3);
|
|
23394
23476
|
if (!response.redirects?.length) return response;
|
|
23395
23477
|
return replay({
|
|
23396
23478
|
owner,
|
|
23397
|
-
method:
|
|
23398
|
-
fingerprint: fingerprint(
|
|
23479
|
+
method: request3.method,
|
|
23480
|
+
fingerprint: fingerprint(request3.headers),
|
|
23399
23481
|
hops: response.redirects,
|
|
23400
23482
|
final: response
|
|
23401
23483
|
});
|
|
@@ -23921,7 +24003,7 @@ async function dispatch(h, req) {
|
|
|
23921
24003
|
}
|
|
23922
24004
|
}
|
|
23923
24005
|
function serveFilesystem(port, handlers, capabilities = {}, options = {}) {
|
|
23924
|
-
let
|
|
24006
|
+
let open2 = false;
|
|
23925
24007
|
const reply = (message3, transfer = []) => port.postMessage(message3, transfer);
|
|
23926
24008
|
async function hello(message3) {
|
|
23927
24009
|
const refused3 = driverVersionError(message3.protocol);
|
|
@@ -23931,7 +24013,7 @@ function serveFilesystem(port, handlers, capabilities = {}, options = {}) {
|
|
|
23931
24013
|
}
|
|
23932
24014
|
try {
|
|
23933
24015
|
const refined = await handlers.mount?.(message3.mount);
|
|
23934
|
-
|
|
24016
|
+
open2 = true;
|
|
23935
24017
|
reply({
|
|
23936
24018
|
hello: { protocol: DRIVER_PROTOCOL, capabilities: { ...capabilities, ...refined } }
|
|
23937
24019
|
});
|
|
@@ -23952,7 +24034,7 @@ function serveFilesystem(port, handlers, capabilities = {}, options = {}) {
|
|
|
23952
24034
|
void hello(data.hello);
|
|
23953
24035
|
return;
|
|
23954
24036
|
}
|
|
23955
|
-
if (!
|
|
24037
|
+
if (!open2) return;
|
|
23956
24038
|
dispatch(handlers, data).then(
|
|
23957
24039
|
(result) => {
|
|
23958
24040
|
if (result instanceof Uint8Array) {
|
|
@@ -24101,10 +24183,10 @@ function kernelFsHandlers(fs) {
|
|
|
24101
24183
|
readlink: (path) => fs.readlink(path),
|
|
24102
24184
|
async setattr(path, change) {
|
|
24103
24185
|
if (change.size !== void 0) {
|
|
24104
|
-
const
|
|
24186
|
+
const open2 = [...handles.values()].find(
|
|
24105
24187
|
(h) => h.path === path && h.session !== void 0
|
|
24106
24188
|
)?.session;
|
|
24107
|
-
if (
|
|
24189
|
+
if (open2 !== void 0) await (await open2).truncate(change.size);
|
|
24108
24190
|
else await fs.truncate?.(path, change.size);
|
|
24109
24191
|
}
|
|
24110
24192
|
if (change.mode !== void 0) await fs.chmod(path, change.mode);
|
|
@@ -24121,7 +24203,7 @@ function granted(handle) {
|
|
|
24121
24203
|
() => false
|
|
24122
24204
|
);
|
|
24123
24205
|
}
|
|
24124
|
-
function removableMedium(onLost,
|
|
24206
|
+
function removableMedium(onLost, open2 = (handle) => new OpfsFs(handle)) {
|
|
24125
24207
|
const slot2 = mediumSlot(
|
|
24126
24208
|
async (err, handle) => denied(err) && !await granted(handle),
|
|
24127
24209
|
onLost
|
|
@@ -24129,7 +24211,7 @@ function removableMedium(onLost, open = (handle) => new OpfsFs(handle)) {
|
|
|
24129
24211
|
return {
|
|
24130
24212
|
handlers: slot2.handlers,
|
|
24131
24213
|
present: slot2.present,
|
|
24132
|
-
insert: (handle) => slot2.insert(handle, kernelFsHandlers(
|
|
24214
|
+
insert: (handle) => slot2.insert(handle, kernelFsHandlers(open2(handle))),
|
|
24133
24215
|
eject: slot2.eject
|
|
24134
24216
|
};
|
|
24135
24217
|
}
|
|
@@ -24255,13 +24337,13 @@ function codeOf5(err) {
|
|
|
24255
24337
|
function wait(ms, signal) {
|
|
24256
24338
|
if (signal.aborted) return Promise.resolve();
|
|
24257
24339
|
return new Promise((resolve2) => {
|
|
24258
|
-
const
|
|
24340
|
+
const done5 = () => {
|
|
24259
24341
|
clearTimeout(timer);
|
|
24260
|
-
signal.removeEventListener("abort",
|
|
24342
|
+
signal.removeEventListener("abort", done5);
|
|
24261
24343
|
resolve2();
|
|
24262
24344
|
};
|
|
24263
|
-
const timer = setTimeout(
|
|
24264
|
-
signal.addEventListener("abort",
|
|
24345
|
+
const timer = setTimeout(done5, ms);
|
|
24346
|
+
signal.addEventListener("abort", done5, { once: true });
|
|
24265
24347
|
});
|
|
24266
24348
|
}
|
|
24267
24349
|
async function mountFstab(lines2, mount, signal, retries = FSTAB_RETRIES, discard = () => {
|
|
@@ -24422,8 +24504,8 @@ var HostfsClient = class {
|
|
|
24422
24504
|
let buffered = "";
|
|
24423
24505
|
try {
|
|
24424
24506
|
for (; ; ) {
|
|
24425
|
-
const { done:
|
|
24426
|
-
if (
|
|
24507
|
+
const { done: done5, value: value2 } = await reader.read();
|
|
24508
|
+
if (done5) return;
|
|
24427
24509
|
buffered += decoder4.decode(value2, { stream: true });
|
|
24428
24510
|
let end = buffered.indexOf("\n");
|
|
24429
24511
|
while (end >= 0) {
|
|
@@ -24455,14 +24537,14 @@ function hostfsHandlers(current, againMs = RESTORE_AGAIN_MS) {
|
|
|
24455
24537
|
return fresh2(remote);
|
|
24456
24538
|
};
|
|
24457
24539
|
const call = (op, body = {}) => current().call(op, body);
|
|
24458
|
-
const
|
|
24540
|
+
const same2 = (was, mode, seen) => seen?.mode === (mode | 128) && (was.ino !== void 0 && seen.ino !== void 0 ? seen.ino === was.ino : seen.size === was.size && seen.mtime === was.mtime);
|
|
24459
24541
|
const settle3 = (client, { was, ...restore }) => client.call("setattr", restore).catch((err) => {
|
|
24460
24542
|
if (!client.gone || !client.cleanup) throw err;
|
|
24461
24543
|
void client.cleanup("setattr", restore).catch(() => {
|
|
24462
24544
|
});
|
|
24463
24545
|
const timer = setTimeout(async () => {
|
|
24464
24546
|
const seen = await client.cleanup?.("stat", { path: restore.path }).catch(() => null);
|
|
24465
|
-
if (
|
|
24547
|
+
if (same2(was, restore.mode, seen))
|
|
24466
24548
|
void client.cleanup?.("setattr", restore).catch(() => {
|
|
24467
24549
|
});
|
|
24468
24550
|
}, againMs);
|
|
@@ -24586,13 +24668,13 @@ async function resize(h, path, size) {
|
|
|
24586
24668
|
}
|
|
24587
24669
|
function sleep(ms, signal) {
|
|
24588
24670
|
return new Promise((resolve2) => {
|
|
24589
|
-
const
|
|
24671
|
+
const done5 = () => {
|
|
24590
24672
|
clearTimeout(timer);
|
|
24591
|
-
signal.removeEventListener("abort",
|
|
24673
|
+
signal.removeEventListener("abort", done5);
|
|
24592
24674
|
resolve2();
|
|
24593
24675
|
};
|
|
24594
|
-
const timer = setTimeout(
|
|
24595
|
-
signal.addEventListener("abort",
|
|
24676
|
+
const timer = setTimeout(done5, ms);
|
|
24677
|
+
signal.addEventListener("abort", done5);
|
|
24596
24678
|
});
|
|
24597
24679
|
}
|
|
24598
24680
|
function keepWatching(loop, signal) {
|
|
@@ -24676,8 +24758,8 @@ function timed(transport, ms) {
|
|
|
24676
24758
|
let expired = false;
|
|
24677
24759
|
const running = run2();
|
|
24678
24760
|
inflight.add(running);
|
|
24679
|
-
const
|
|
24680
|
-
running.then(
|
|
24761
|
+
const done5 = () => inflight.delete(running);
|
|
24762
|
+
running.then(done5, done5);
|
|
24681
24763
|
const timer = setTimeout(() => {
|
|
24682
24764
|
expired = true;
|
|
24683
24765
|
const why = `the host folder did not answer ${name2} within ${ms} ms`;
|
|
@@ -24974,17 +25056,17 @@ function memoryMedia() {
|
|
|
24974
25056
|
put: async (id2, handle) => void handles.set(id2, handle)
|
|
24975
25057
|
};
|
|
24976
25058
|
}
|
|
24977
|
-
function settle2(
|
|
25059
|
+
function settle2(request3, value2) {
|
|
24978
25060
|
return new Promise((resolve2, reject) => {
|
|
24979
|
-
|
|
24980
|
-
|
|
25061
|
+
request3.onsuccess = () => resolve2(value2());
|
|
25062
|
+
request3.onerror = () => reject(request3.error);
|
|
24981
25063
|
});
|
|
24982
25064
|
}
|
|
24983
25065
|
function openMedia(name2, factory) {
|
|
24984
|
-
const
|
|
24985
|
-
|
|
24986
|
-
return settle2(
|
|
24987
|
-
const db =
|
|
25066
|
+
const request3 = factory.open(name2, 1);
|
|
25067
|
+
request3.onupgradeneeded = () => request3.result.createObjectStore(MEDIA_STORE);
|
|
25068
|
+
return settle2(request3, () => {
|
|
25069
|
+
const db = request3.result;
|
|
24988
25070
|
const store = (mode) => db.transaction(MEDIA_STORE, mode).objectStore(MEDIA_STORE);
|
|
24989
25071
|
return {
|
|
24990
25072
|
get: (id2) => {
|
|
@@ -25017,14 +25099,14 @@ var ChunkedBytes = class {
|
|
|
25017
25099
|
}
|
|
25018
25100
|
write(offset, bytes, owned4 = false) {
|
|
25019
25101
|
const whole = owned4 && bytes.byteOffset === 0 && bytes.byteLength === bytes.buffer.byteLength;
|
|
25020
|
-
for (let
|
|
25021
|
-
const at = offset +
|
|
25102
|
+
for (let done5 = 0; done5 < bytes.length; ) {
|
|
25103
|
+
const at = offset + done5;
|
|
25022
25104
|
const index = Math.floor(at / CHUNK3);
|
|
25023
25105
|
const from = at - index * CHUNK3;
|
|
25024
|
-
const n = Math.min(CHUNK3 - from, bytes.length -
|
|
25106
|
+
const n = Math.min(CHUNK3 - from, bytes.length - done5);
|
|
25025
25107
|
if (whole && n === CHUNK3 && bytes.length === CHUNK3) this.chunks[index] = bytes;
|
|
25026
|
-
else this.room(index, from + n).set(bytes.subarray(
|
|
25027
|
-
|
|
25108
|
+
else this.room(index, from + n).set(bytes.subarray(done5, done5 + n), from);
|
|
25109
|
+
done5 += n;
|
|
25028
25110
|
}
|
|
25029
25111
|
this.size = Math.max(this.size, offset + bytes.length);
|
|
25030
25112
|
}
|
|
@@ -25528,9 +25610,9 @@ function parseArgs(args) {
|
|
|
25528
25610
|
break;
|
|
25529
25611
|
}
|
|
25530
25612
|
if (!arg.startsWith("-") || arg === "-") break;
|
|
25531
|
-
const
|
|
25532
|
-
if (typeof
|
|
25533
|
-
i +=
|
|
25613
|
+
const used2 = flags(parsed2, arg, args[i + 1]);
|
|
25614
|
+
if (typeof used2 === "string") return used2;
|
|
25615
|
+
i += used2;
|
|
25534
25616
|
}
|
|
25535
25617
|
parsed2.command = args.slice(i);
|
|
25536
25618
|
if (parsed2.list ? parsed2.command.length > 0 : parsed2.command.length === 0) return USAGE;
|
|
@@ -26560,9 +26642,9 @@ var Launcher = class {
|
|
|
26560
26642
|
const known = this.sameFiles.get(`${a}|${b}`);
|
|
26561
26643
|
if (known?.stamp === stamp) return known.same;
|
|
26562
26644
|
const [p, q] = await Promise.all([this.base.readFileBuffer(a), this.base.readFileBuffer(b)]);
|
|
26563
|
-
const
|
|
26564
|
-
this.sameFiles.set(`${a}|${b}`, { stamp, same });
|
|
26565
|
-
return
|
|
26645
|
+
const same2 = p.length === q.length && p.every((byte, i) => byte === q[i]);
|
|
26646
|
+
this.sameFiles.set(`${a}|${b}`, { stamp, same: same2 });
|
|
26647
|
+
return same2;
|
|
26566
26648
|
}
|
|
26567
26649
|
async wasmOwner(wasm, name2, scope) {
|
|
26568
26650
|
const leaf = baseName2(wasm);
|
|
@@ -26855,10 +26937,10 @@ var Launcher = class {
|
|
|
26855
26937
|
const drop = () => {
|
|
26856
26938
|
if (cache.get(key) === found) cache.delete(key);
|
|
26857
26939
|
};
|
|
26858
|
-
loading2.then((
|
|
26859
|
-
if (
|
|
26940
|
+
loading2.then((done5) => {
|
|
26941
|
+
if (done5.key === key || done5.key === void 0 && !key.includes("\0")) return;
|
|
26860
26942
|
drop();
|
|
26861
|
-
if (
|
|
26943
|
+
if (done5.key !== void 0 && revocations === this.revocations) cache.set(done5.key, found);
|
|
26862
26944
|
}, drop);
|
|
26863
26945
|
return found;
|
|
26864
26946
|
}
|
|
@@ -27003,17 +27085,17 @@ var Launcher = class {
|
|
|
27003
27085
|
await req.fds.closeAll();
|
|
27004
27086
|
throw err;
|
|
27005
27087
|
}
|
|
27006
|
-
const
|
|
27088
|
+
const done5 = this.heldUrl(program);
|
|
27007
27089
|
try {
|
|
27008
27090
|
const handle = await this.admitted(
|
|
27009
27091
|
program.abi !== "js",
|
|
27010
27092
|
req.fds,
|
|
27011
27093
|
(fds, quietOom) => this.start({ ...req, fds, quietOom, cwd, program, argv0: target.argv0, args, env })
|
|
27012
27094
|
);
|
|
27013
|
-
void handle.exited.finally(
|
|
27095
|
+
void handle.exited.finally(done5);
|
|
27014
27096
|
return handle;
|
|
27015
27097
|
} catch (err) {
|
|
27016
|
-
|
|
27098
|
+
done5();
|
|
27017
27099
|
throw err;
|
|
27018
27100
|
}
|
|
27019
27101
|
}
|
|
@@ -27556,8 +27638,8 @@ var Launcher = class {
|
|
|
27556
27638
|
const at = normalizePath(path);
|
|
27557
27639
|
this.unlinked.closed(at);
|
|
27558
27640
|
this.writers?.unlinked.closed(at);
|
|
27559
|
-
const
|
|
27560
|
-
if (!
|
|
27641
|
+
const open2 = [...this.openFiles].some((nodes) => nodes.writes(at)) || heldUnder(this.held, at);
|
|
27642
|
+
if (!open2) void this.mounts.commit(at).catch(() => void 0);
|
|
27561
27643
|
}
|
|
27562
27644
|
signalMasksOf(pid) {
|
|
27563
27645
|
const masks = this.processes.get(pid)?.signalMasks?.();
|
|
@@ -28013,7 +28095,7 @@ var Launcher = class {
|
|
|
28013
28095
|
(path) => this.mountRoot(path),
|
|
28014
28096
|
{
|
|
28015
28097
|
locks: webLocks(),
|
|
28016
|
-
busy: (path) => [...this.openFiles].some((
|
|
28098
|
+
busy: (path) => [...this.openFiles].some((open2) => open2.holds(path)),
|
|
28017
28099
|
owner: this.unlinkOwnerOption,
|
|
28018
28100
|
...this.owners ? { dirOwner: { uid: 0, gid: 0, mode: 448 } } : {}
|
|
28019
28101
|
}
|
|
@@ -28180,11 +28262,11 @@ function cronLocks() {
|
|
|
28180
28262
|
// src/pin.ts
|
|
28181
28263
|
function pinScript(url) {
|
|
28182
28264
|
try {
|
|
28183
|
-
const
|
|
28184
|
-
|
|
28185
|
-
|
|
28186
|
-
if (
|
|
28187
|
-
const source = `${
|
|
28265
|
+
const request3 = new XMLHttpRequest();
|
|
28266
|
+
request3.open("GET", url.href, false);
|
|
28267
|
+
request3.send();
|
|
28268
|
+
if (request3.status !== 200) return url.href;
|
|
28269
|
+
const source = `${request3.responseText}
|
|
28188
28270
|
//# sourceURL=${url.href}
|
|
28189
28271
|
`;
|
|
28190
28272
|
return URL.createObjectURL(new Blob([source], { type: "text/javascript" }));
|
|
@@ -28337,9 +28419,9 @@ var RemoteTransport = class {
|
|
|
28337
28419
|
waiter?.reject(new TransportError("the request was cancelled"));
|
|
28338
28420
|
this.port.postMessage({ net: "cancel", nid });
|
|
28339
28421
|
}
|
|
28340
|
-
async fetch(
|
|
28422
|
+
async fetch(request3) {
|
|
28341
28423
|
const nid = ++this.nextId;
|
|
28342
|
-
const { signal } =
|
|
28424
|
+
const { signal } = request3;
|
|
28343
28425
|
signal.throwIfAborted();
|
|
28344
28426
|
let finished = false;
|
|
28345
28427
|
const abort = () => {
|
|
@@ -28354,16 +28436,16 @@ var RemoteTransport = class {
|
|
|
28354
28436
|
finished = true;
|
|
28355
28437
|
signal.removeEventListener("abort", abort);
|
|
28356
28438
|
};
|
|
28357
|
-
if (
|
|
28439
|
+
if (request3.bodyStream) this.uploads.set(nid, request3.bodyStream[Symbol.asyncIterator]());
|
|
28358
28440
|
let head;
|
|
28359
28441
|
try {
|
|
28360
28442
|
head = await this.ask({
|
|
28361
28443
|
net: "fetch",
|
|
28362
28444
|
nid,
|
|
28363
|
-
url:
|
|
28364
|
-
method:
|
|
28365
|
-
headers:
|
|
28366
|
-
...
|
|
28445
|
+
url: request3.url,
|
|
28446
|
+
method: request3.method,
|
|
28447
|
+
headers: request3.headers,
|
|
28448
|
+
...request3.bodyStream ? { streamed: true } : request3.body ? { body: request3.body } : {}
|
|
28367
28449
|
});
|
|
28368
28450
|
} catch (e) {
|
|
28369
28451
|
finish();
|
|
@@ -28406,9 +28488,9 @@ var RemoteTransport = class {
|
|
|
28406
28488
|
}
|
|
28407
28489
|
};
|
|
28408
28490
|
}
|
|
28409
|
-
async websocket(
|
|
28491
|
+
async websocket(request3) {
|
|
28410
28492
|
const nid = ++this.nextId;
|
|
28411
|
-
const { signal } =
|
|
28493
|
+
const { signal } = request3;
|
|
28412
28494
|
signal.throwIfAborted();
|
|
28413
28495
|
const abort = () => this.cancel(nid);
|
|
28414
28496
|
signal.addEventListener("abort", abort, { once: true });
|
|
@@ -28417,9 +28499,9 @@ var RemoteTransport = class {
|
|
|
28417
28499
|
opened2 = await this.ask({
|
|
28418
28500
|
net: "ws-open",
|
|
28419
28501
|
nid,
|
|
28420
|
-
url:
|
|
28421
|
-
protocols:
|
|
28422
|
-
headers:
|
|
28502
|
+
url: request3.url,
|
|
28503
|
+
protocols: request3.protocols,
|
|
28504
|
+
headers: request3.headers
|
|
28423
28505
|
});
|
|
28424
28506
|
} finally {
|
|
28425
28507
|
signal.removeEventListener("abort", abort);
|
|
@@ -28489,6 +28571,12 @@ async function inOpfs(deps, root) {
|
|
|
28489
28571
|
const opfs = await deps.storage().catch(() => void 0);
|
|
28490
28572
|
return await opfs?.resolve(root).catch(() => null) != null;
|
|
28491
28573
|
}
|
|
28574
|
+
async function rootNamed(deps, req, root) {
|
|
28575
|
+
if (req.metadata !== void 0 || !req.root || !deps.rootId) return req;
|
|
28576
|
+
const top = await deps.storage().catch(() => void 0);
|
|
28577
|
+
const name2 = await metadataName(top, root, deps.rootId);
|
|
28578
|
+
return name2 === META_DB ? req : { ...req, metadata: name2 };
|
|
28579
|
+
}
|
|
28492
28580
|
function workers(deps) {
|
|
28493
28581
|
return {
|
|
28494
28582
|
createWorker: deps.createWorker,
|
|
@@ -28533,7 +28621,7 @@ function cdpOption(req, port) {
|
|
|
28533
28621
|
if (!req.cdp) return {};
|
|
28534
28622
|
return {
|
|
28535
28623
|
cdp: portCdpHook(
|
|
28536
|
-
(
|
|
28624
|
+
(request3, cdp) => port.postMessage({ cdpOpen: request3, port: cdp }, [cdp])
|
|
28537
28625
|
)
|
|
28538
28626
|
};
|
|
28539
28627
|
}
|
|
@@ -28543,7 +28631,7 @@ function pageHooks(req, port) {
|
|
|
28543
28631
|
function facadesOption(req, port) {
|
|
28544
28632
|
if (!req.facades) return {};
|
|
28545
28633
|
const hook = portFacadeHook(
|
|
28546
|
-
(
|
|
28634
|
+
(request3, facade) => port.postMessage({ facadeOpen: request3, port: facade }, [facade])
|
|
28547
28635
|
);
|
|
28548
28636
|
const facades = {};
|
|
28549
28637
|
for (const [name2, spec] of Object.entries(req.facades)) {
|
|
@@ -28745,6 +28833,7 @@ function serveKernel(port, deps) {
|
|
|
28745
28833
|
}
|
|
28746
28834
|
async function init(req) {
|
|
28747
28835
|
launcher = (req.root ? Promise.resolve(req.root) : deps.storage()).then(async (root) => {
|
|
28836
|
+
req = await rootNamed(deps, req, root);
|
|
28748
28837
|
const name2 = req.metadata ?? META_DB;
|
|
28749
28838
|
const { meta, media } = await stores(deps, name2, req.media);
|
|
28750
28839
|
const net = remotes(port, req);
|
|
@@ -28852,6 +28941,7 @@ serveKernel(globalThis, {
|
|
|
28852
28941
|
createDriverWorker: () => new Worker(driverWorker, { type: "module" }),
|
|
28853
28942
|
moduleUrl: blobModuleUrl,
|
|
28854
28943
|
metadata: (name2) => openMeta(name2, indexedDB),
|
|
28855
|
-
media: (name2) => openMedia(name2, indexedDB)
|
|
28944
|
+
media: (name2) => openMedia(name2, indexedDB),
|
|
28945
|
+
rootId: (root) => rootId(indexedDB, root)
|
|
28856
28946
|
});
|
|
28857
28947
|
//# sourceMappingURL=kernel-worker.js.map
|