@ai-ecoverse/slicc-kernel 1.128.0 → 1.128.2
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 +437 -346
- 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 +3 -2
- 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 +4 -4
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.2" : "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 (; ; ) {
|
|
@@ -9690,8 +9772,9 @@ var FreshModules = class {
|
|
|
9690
9772
|
if (ranged2) {
|
|
9691
9773
|
overrides.pwrite = async (path, at, bytes, transfer) => {
|
|
9692
9774
|
const touches2 = at < MAGIC.length && this.fresh.has(normalizePath(path));
|
|
9775
|
+
const first = at === 0 && bytes.length >= MAGIC.length ? bytes.slice(0, MAGIC.length) : void 0;
|
|
9693
9776
|
await ranged2.pwrite(path, at, bytes, transfer);
|
|
9694
|
-
if (touches2) await decide(path);
|
|
9777
|
+
if (touches2) await decide(path, first);
|
|
9695
9778
|
};
|
|
9696
9779
|
overrides.truncate = async (path, size) => {
|
|
9697
9780
|
await ranged2.truncate(path, size);
|
|
@@ -9855,13 +9938,13 @@ var FsWatchers = class {
|
|
|
9855
9938
|
next: async (signal) => {
|
|
9856
9939
|
while (watch.notes.length === 0 && !watch.ended && !signal.aborted) {
|
|
9857
9940
|
await new Promise((resolve2) => {
|
|
9858
|
-
const
|
|
9941
|
+
const done5 = () => {
|
|
9859
9942
|
watch.wake = void 0;
|
|
9860
|
-
signal.removeEventListener("abort",
|
|
9943
|
+
signal.removeEventListener("abort", done5);
|
|
9861
9944
|
resolve2();
|
|
9862
9945
|
};
|
|
9863
|
-
watch.wake =
|
|
9864
|
-
signal.addEventListener("abort",
|
|
9946
|
+
watch.wake = done5;
|
|
9947
|
+
signal.addEventListener("abort", done5, { once: true });
|
|
9865
9948
|
});
|
|
9866
9949
|
}
|
|
9867
9950
|
const notes = watch.notes.splice(0);
|
|
@@ -9912,14 +9995,14 @@ var FsWatchers = class {
|
|
|
9912
9995
|
}
|
|
9913
9996
|
wrap(fs) {
|
|
9914
9997
|
const after = (run2, changed, type) => async (...args) => {
|
|
9915
|
-
let
|
|
9998
|
+
let done5 = false;
|
|
9916
9999
|
try {
|
|
9917
10000
|
await run2(...args);
|
|
9918
|
-
|
|
10001
|
+
done5 = true;
|
|
9919
10002
|
} finally {
|
|
9920
10003
|
const paths = changed(...args);
|
|
9921
10004
|
this.report(paths);
|
|
9922
|
-
if (
|
|
10005
|
+
if (done5) this.emit(type, paths);
|
|
9923
10006
|
}
|
|
9924
10007
|
};
|
|
9925
10008
|
const reals = this.reals;
|
|
@@ -9941,15 +10024,15 @@ var FsWatchers = class {
|
|
|
9941
10024
|
const content = (run2, types) => async (...args) => {
|
|
9942
10025
|
const at = normalizePath(args[0]);
|
|
9943
10026
|
const fresh2 = this.covers(at) && !await fs.exists(at).catch(() => true);
|
|
9944
|
-
let
|
|
10027
|
+
let done5 = false;
|
|
9945
10028
|
try {
|
|
9946
10029
|
await run2(...args);
|
|
9947
|
-
|
|
10030
|
+
done5 = true;
|
|
9948
10031
|
} finally {
|
|
9949
10032
|
const real = await realOf(at);
|
|
9950
10033
|
const paths = real === at ? [at] : [at, real];
|
|
9951
10034
|
this.report(paths);
|
|
9952
|
-
if (
|
|
10035
|
+
if (done5) for (const type of types(fresh2)) this.emit(type, paths);
|
|
9953
10036
|
}
|
|
9954
10037
|
};
|
|
9955
10038
|
const written2 = (fresh2) => fresh2 ? ["rename", "change"] : ["change"];
|
|
@@ -9980,13 +10063,13 @@ var FsWatchers = class {
|
|
|
9980
10063
|
}
|
|
9981
10064
|
}
|
|
9982
10065
|
const fresh2 = !options?.recursive || this.typed.size > 0 && !await fs.exists(path);
|
|
9983
|
-
let
|
|
10066
|
+
let done5 = false;
|
|
9984
10067
|
try {
|
|
9985
10068
|
await fs.mkdir(path, options);
|
|
9986
|
-
|
|
10069
|
+
done5 = true;
|
|
9987
10070
|
} finally {
|
|
9988
10071
|
this.report([...created4, path]);
|
|
9989
|
-
if (
|
|
10072
|
+
if (done5) this.emit("rename", fresh2 ? [...created4, path] : created4);
|
|
9990
10073
|
}
|
|
9991
10074
|
},
|
|
9992
10075
|
rm: reshaping(after(fs.rm.bind(fs), (path) => [path], "rename")),
|
|
@@ -10192,8 +10275,8 @@ var ChildTable = class {
|
|
|
10192
10275
|
for (; ; ) {
|
|
10193
10276
|
const candidates = this.candidates(pid, flags2);
|
|
10194
10277
|
if (candidates.length === 0) throw new KernelError("ECHILD");
|
|
10195
|
-
const
|
|
10196
|
-
if (
|
|
10278
|
+
const done5 = candidates.find(([, child]) => child.code !== void 0);
|
|
10279
|
+
if (done5) return this.reap(done5[0], done5[1].code);
|
|
10197
10280
|
const changed = this.stateReport(candidates, flags2);
|
|
10198
10281
|
if (changed) return changed;
|
|
10199
10282
|
if (nohang) return [0, 0];
|
|
@@ -10589,7 +10672,7 @@ var FifoTable = class {
|
|
|
10589
10672
|
}
|
|
10590
10673
|
end(key, path, fifo, reads, writes) {
|
|
10591
10674
|
const { pipe } = fifo;
|
|
10592
|
-
let
|
|
10675
|
+
let open2 = true;
|
|
10593
10676
|
return new OpenFile({
|
|
10594
10677
|
fifo: path,
|
|
10595
10678
|
identity: fifo,
|
|
@@ -10612,8 +10695,8 @@ var FifoTable = class {
|
|
|
10612
10695
|
}
|
|
10613
10696
|
} : {},
|
|
10614
10697
|
close: () => {
|
|
10615
|
-
if (!
|
|
10616
|
-
|
|
10698
|
+
if (!open2) return;
|
|
10699
|
+
open2 = false;
|
|
10617
10700
|
this.release(key, fifo, reads, writes);
|
|
10618
10701
|
},
|
|
10619
10702
|
poll: () => ({
|
|
@@ -10887,8 +10970,8 @@ var HeldPaths = class extends Map {
|
|
|
10887
10970
|
for (const file of [...this.uses.keys()]) this.letGo(file, true);
|
|
10888
10971
|
this.keptHandles.clear();
|
|
10889
10972
|
}
|
|
10890
|
-
hold(path, on,
|
|
10891
|
-
if (
|
|
10973
|
+
hold(path, on, open2 = false, real, handle) {
|
|
10974
|
+
if (open2) return this.holdOpen(path, on, real, handle);
|
|
10892
10975
|
this.holdWrite(path, on);
|
|
10893
10976
|
return void 0;
|
|
10894
10977
|
}
|
|
@@ -11179,7 +11262,7 @@ var MountTable = class {
|
|
|
11179
11262
|
session(mount, real, rel2) {
|
|
11180
11263
|
let session = this.sessions.get(real);
|
|
11181
11264
|
if (!session) {
|
|
11182
|
-
const
|
|
11265
|
+
const open2 = () => mount.conn.call({
|
|
11183
11266
|
op: "open",
|
|
11184
11267
|
path: rel2,
|
|
11185
11268
|
write: true,
|
|
@@ -11188,7 +11271,7 @@ var MountTable = class {
|
|
|
11188
11271
|
exclusive: false
|
|
11189
11272
|
});
|
|
11190
11273
|
const before = this.committing.get(real)?.done ?? Promise.resolve();
|
|
11191
|
-
const fh = before.then(
|
|
11274
|
+
const fh = before.then(open2, open2);
|
|
11192
11275
|
session = { mount, fh, extents: [], truncated: false };
|
|
11193
11276
|
this.sessions.set(real, session);
|
|
11194
11277
|
fh.catch(() => this.sessions.delete(real));
|
|
@@ -11203,20 +11286,20 @@ var MountTable = class {
|
|
|
11203
11286
|
if (!session) return this.committing.get(real)?.done;
|
|
11204
11287
|
this.sessions.delete(real);
|
|
11205
11288
|
session.mount.epoch++;
|
|
11206
|
-
const
|
|
11289
|
+
const done5 = (async () => {
|
|
11207
11290
|
try {
|
|
11208
11291
|
await session.mount.conn.call({ op: "release", fh: await session.fh });
|
|
11209
11292
|
} finally {
|
|
11210
11293
|
this.forget(session.mount, real);
|
|
11211
11294
|
}
|
|
11212
11295
|
})();
|
|
11213
|
-
const entry = { mount: session.mount, done:
|
|
11296
|
+
const entry = { mount: session.mount, done: done5 };
|
|
11214
11297
|
this.committing.set(real, entry);
|
|
11215
11298
|
const settle3 = () => {
|
|
11216
11299
|
if (this.committing.get(real) === entry) this.committing.delete(real);
|
|
11217
11300
|
};
|
|
11218
|
-
|
|
11219
|
-
return
|
|
11301
|
+
done5.then(settle3, settle3);
|
|
11302
|
+
return done5;
|
|
11220
11303
|
}
|
|
11221
11304
|
async commitUnder(prefix) {
|
|
11222
11305
|
const at = normalizePath(prefix);
|
|
@@ -11390,8 +11473,8 @@ var MountFs = class _MountFs {
|
|
|
11390
11473
|
}
|
|
11391
11474
|
async across(from, to, redirects) {
|
|
11392
11475
|
const moved2 = [await this.through(from), await this.through(to)];
|
|
11393
|
-
const
|
|
11394
|
-
if (
|
|
11476
|
+
const same2 = moved2[0] === normalizePath(from) && moved2[1] === normalizePath(to);
|
|
11477
|
+
if (same2 || redirects >= MAX_LINKS7) throw errnoError("EXDEV", `${from} -> ${to}`);
|
|
11395
11478
|
return moved2;
|
|
11396
11479
|
}
|
|
11397
11480
|
async based(paths, redirects, run2, again) {
|
|
@@ -12239,7 +12322,7 @@ async function storageUsage() {
|
|
|
12239
12322
|
return { quota: estimate.quota, usage: estimate.usage ?? 0 };
|
|
12240
12323
|
}
|
|
12241
12324
|
var PLAIN_DIR_MODE = 493;
|
|
12242
|
-
var
|
|
12325
|
+
var done2 = { ok: true, kind: "void" };
|
|
12243
12326
|
function json2(value2) {
|
|
12244
12327
|
return { ok: true, kind: "json", json: value2 };
|
|
12245
12328
|
}
|
|
@@ -12284,14 +12367,14 @@ async function chown(entry, path, req) {
|
|
|
12284
12367
|
const cred = entry.cred?.();
|
|
12285
12368
|
if (!cred) {
|
|
12286
12369
|
await (req.op === "chown" ? entry.fs.stat(real) : entry.fs.lstat(real));
|
|
12287
|
-
return
|
|
12370
|
+
return done2;
|
|
12288
12371
|
}
|
|
12289
12372
|
await chownAs(entry.fs, cred, real, {
|
|
12290
12373
|
...req.uid !== void 0 ? { uid: req.uid } : {},
|
|
12291
12374
|
...req.gid !== void 0 ? { gid: req.gid } : {},
|
|
12292
12375
|
follow: req.op === "chown"
|
|
12293
12376
|
});
|
|
12294
|
-
return
|
|
12377
|
+
return done2;
|
|
12295
12378
|
}
|
|
12296
12379
|
async function runMkdir(entry, path, req) {
|
|
12297
12380
|
const { fs } = entry;
|
|
@@ -12302,7 +12385,7 @@ async function runMkdir(entry, path, req) {
|
|
|
12302
12385
|
await (req.exclusive ? mkdirExclusive(entry, path, req.mode) : fs.mkdir(path, mkdirOptions(entry, req.mode)));
|
|
12303
12386
|
await fixParents?.();
|
|
12304
12387
|
if (fresh2) await fs.chmod(path, plain2);
|
|
12305
|
-
return
|
|
12388
|
+
return done2;
|
|
12306
12389
|
}
|
|
12307
12390
|
async function shownAs(entry, path, st) {
|
|
12308
12391
|
const real = st.isFile && st.size === 0 ? entry.fs.realpath?.(path, true) : void 0;
|
|
@@ -12319,7 +12402,7 @@ async function run(entry, path, req) {
|
|
|
12319
12402
|
return { ok: true, kind: "bytes", bytes: await readSource(entry, path) };
|
|
12320
12403
|
case "write":
|
|
12321
12404
|
await fs.writeFile(path, req.body ?? new Uint8Array(0), ownerFor2(entry, 438));
|
|
12322
|
-
return
|
|
12405
|
+
return done2;
|
|
12323
12406
|
case "exists":
|
|
12324
12407
|
return json2(await fs.exists(path));
|
|
12325
12408
|
case "stat": {
|
|
@@ -12340,53 +12423,53 @@ async function run(entry, path, req) {
|
|
|
12340
12423
|
return runMkdir(entry, path, req);
|
|
12341
12424
|
case "rm":
|
|
12342
12425
|
await fs.rm(path, { recursive: true });
|
|
12343
|
-
return
|
|
12426
|
+
return done2;
|
|
12344
12427
|
case "rename": {
|
|
12345
12428
|
const to = fs.resolvePath(cwd, req.arg2 ?? "");
|
|
12346
12429
|
await fs.rename(path, to);
|
|
12347
12430
|
entry.renamed?.(path, to);
|
|
12348
|
-
return
|
|
12431
|
+
return done2;
|
|
12349
12432
|
}
|
|
12350
12433
|
case "link":
|
|
12351
12434
|
await fs.link(path, fs.resolvePath(cwd, req.arg2 ?? ""), req.mode === 1);
|
|
12352
|
-
return
|
|
12435
|
+
return done2;
|
|
12353
12436
|
case "unlink":
|
|
12354
12437
|
await fs.rm(path, { file: true });
|
|
12355
|
-
return
|
|
12438
|
+
return done2;
|
|
12356
12439
|
case "rmdir":
|
|
12357
12440
|
if (!(await fs.lstat(path)).isDirectory) throw syncError("ENOTDIR", path);
|
|
12358
12441
|
if ((await fs.readdir(path)).length > 0) throw syncError("ENOTEMPTY", path);
|
|
12359
12442
|
await fs.rm(path, { recursive: true });
|
|
12360
|
-
return
|
|
12443
|
+
return done2;
|
|
12361
12444
|
case "symlink":
|
|
12362
12445
|
await fs.symlink(req.arg2 ?? "", path, ownerFor2(entry));
|
|
12363
|
-
return
|
|
12446
|
+
return done2;
|
|
12364
12447
|
case "copy":
|
|
12365
12448
|
return copyOp(entry, path, req);
|
|
12366
12449
|
case "mkfifo": {
|
|
12367
12450
|
const owner = ownerFor2(entry, req.mode ?? 438) ?? { uid: 0, gid: 0 };
|
|
12368
12451
|
await createExclusive(fs, path, { ...owner, fifo: true });
|
|
12369
12452
|
entry.fresh?.(path);
|
|
12370
|
-
return
|
|
12453
|
+
return done2;
|
|
12371
12454
|
}
|
|
12372
12455
|
case "create":
|
|
12373
12456
|
await createExclusive(fs, path, ownerFor2(entry, req.mode ?? 438));
|
|
12374
12457
|
if (req.opening) entry.created?.add(path);
|
|
12375
12458
|
entry.fresh?.(path);
|
|
12376
|
-
return
|
|
12459
|
+
return done2;
|
|
12377
12460
|
case "readlink":
|
|
12378
12461
|
return json2(await fs.readlink(path));
|
|
12379
12462
|
case "chmod": {
|
|
12380
12463
|
const g = guardOf(entry);
|
|
12381
12464
|
await fs.chmod(path, g ? await chmodMode(g, path, req.mode ?? 0) : req.mode ?? 0);
|
|
12382
|
-
return
|
|
12465
|
+
return done2;
|
|
12383
12466
|
}
|
|
12384
12467
|
case "utimes":
|
|
12385
12468
|
await fs.utimes(path, ...await timesOf(entry, path, req));
|
|
12386
|
-
return
|
|
12469
|
+
return done2;
|
|
12387
12470
|
case "lutimes":
|
|
12388
12471
|
await lutimesOf(fs, path, ...await timesOf(entry, path, req));
|
|
12389
|
-
return
|
|
12472
|
+
return done2;
|
|
12390
12473
|
case "chown":
|
|
12391
12474
|
case "lchown":
|
|
12392
12475
|
return chown(entry, path, req);
|
|
@@ -12525,8 +12608,8 @@ async function stillThere(entry, path, req) {
|
|
|
12525
12608
|
}
|
|
12526
12609
|
async function holdOp(entry, path, req) {
|
|
12527
12610
|
const mode = req.mode ?? 0;
|
|
12528
|
-
const [on,
|
|
12529
|
-
if (on &&
|
|
12611
|
+
const [on, open2] = [(mode & 1) === 1, (mode & 2) === 2];
|
|
12612
|
+
if (on && open2) {
|
|
12530
12613
|
for (; ; ) {
|
|
12531
12614
|
const r = entry.replacements;
|
|
12532
12615
|
await r?.settled(path);
|
|
@@ -12536,26 +12619,26 @@ async function holdOp(entry, path, req) {
|
|
|
12536
12619
|
await entry.source?.open(path, real);
|
|
12537
12620
|
await stillThere(entry, path, req);
|
|
12538
12621
|
if (!r || !r.missed(path) && !r.changedSince(path, gen))
|
|
12539
|
-
return json2(entry.hold?.(path, on,
|
|
12622
|
+
return json2(entry.hold?.(path, on, open2, real) ?? null);
|
|
12540
12623
|
}
|
|
12541
12624
|
}
|
|
12542
|
-
entry.hold?.(path, on,
|
|
12543
|
-
return
|
|
12625
|
+
entry.hold?.(path, on, open2, void 0, req.handle);
|
|
12626
|
+
return done2;
|
|
12544
12627
|
}
|
|
12545
12628
|
async function followed(g, path) {
|
|
12546
12629
|
const st = await g.fs.lstat(path).catch(() => void 0);
|
|
12547
12630
|
if (st?.isSymbolicLink && !trustedLink(permOf(st), g.links)) deny(g, "follow", path);
|
|
12548
|
-
return
|
|
12631
|
+
return done2;
|
|
12549
12632
|
}
|
|
12550
12633
|
async function accessOp(entry, path, req) {
|
|
12551
12634
|
const g = guardOf(entry);
|
|
12552
|
-
if (!g) return
|
|
12635
|
+
if (!g) return done2;
|
|
12553
12636
|
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
|
|
12637
|
+
const open2 = req.arg2 === "open";
|
|
12638
|
+
const cred = open2 || req.arg2 === "eaccess" ? g.cred : realIds(g.cred);
|
|
12639
|
+
const options = { follow: req.nofollow !== true, ...open2 ? { directory: false } : {} };
|
|
12640
|
+
await need({ ...g, cred }, open2 ? "open" : "access", path, req.mode ?? 0, options);
|
|
12641
|
+
return done2;
|
|
12559
12642
|
}
|
|
12560
12643
|
var CHANGING = /* @__PURE__ */ new Set([
|
|
12561
12644
|
"mkdir",
|
|
@@ -12614,7 +12697,7 @@ async function copyOp(entry, path, req) {
|
|
|
12614
12697
|
await (fs.copyFile ? fs.copyFile(path, to, options) : copyByBytes(fs, path, to, options));
|
|
12615
12698
|
if (!owner) await fs.chmod(to, mode);
|
|
12616
12699
|
entry.fresh?.(to);
|
|
12617
|
-
return
|
|
12700
|
+
return done2;
|
|
12618
12701
|
}
|
|
12619
12702
|
async function createExclusive(fs, path, owner) {
|
|
12620
12703
|
if (fs.createExclusive) return fs.createExclusive(path, owner);
|
|
@@ -12661,7 +12744,7 @@ async function ranged(fs, path, req) {
|
|
|
12661
12744
|
};
|
|
12662
12745
|
if (req.op === "pwrite") await ops.pwrite(path, offset, req.body ?? new Uint8Array(0), true);
|
|
12663
12746
|
else await ops.truncate(path, req.length ?? 0);
|
|
12664
|
-
return
|
|
12747
|
+
return done2;
|
|
12665
12748
|
}
|
|
12666
12749
|
var CHOWN_OPS = /* @__PURE__ */ new Set(["chown", "lchown"]);
|
|
12667
12750
|
var UNLINKED_OPS = /* @__PURE__ */ new Set(["read", "pread", "pwrite", "append", "truncate"]);
|
|
@@ -13102,10 +13185,10 @@ var CpuClock = class {
|
|
|
13102
13185
|
}
|
|
13103
13186
|
times() {
|
|
13104
13187
|
const now = this.frozen ?? this.now();
|
|
13105
|
-
const
|
|
13106
|
-
const busy = this.kind === "sys" ? Math.min(
|
|
13188
|
+
const open2 = this.since === 0 ? 0 : Math.max(0, now - this.since);
|
|
13189
|
+
const busy = this.kind === "sys" ? Math.min(open2, SYS_CAP_US) : 0;
|
|
13107
13190
|
const sys = this.sys + busy;
|
|
13108
|
-
const idle2 = this.idle + (
|
|
13191
|
+
const idle2 = this.idle + (open2 - busy) + localIdle(this.sab, now).idle;
|
|
13109
13192
|
const user = Math.max(0, now - this.start - sys - idle2);
|
|
13110
13193
|
this.last = {
|
|
13111
13194
|
utime: Math.max(this.last.utime, Math.floor(user / 1e3)),
|
|
@@ -13262,19 +13345,19 @@ var Pages = class {
|
|
|
13262
13345
|
return Math.max(0, end - at);
|
|
13263
13346
|
}
|
|
13264
13347
|
write(at, bytes) {
|
|
13265
|
-
for (let
|
|
13266
|
-
const pos = at +
|
|
13348
|
+
for (let done5 = 0; done5 < bytes.length; ) {
|
|
13349
|
+
const pos = at + done5;
|
|
13267
13350
|
const page = Math.floor(pos / PAGE);
|
|
13268
13351
|
const from = pos - page * PAGE;
|
|
13269
|
-
const n = Math.min(PAGE - from, bytes.length -
|
|
13352
|
+
const n = Math.min(PAGE - from, bytes.length - done5);
|
|
13270
13353
|
let target = this.pages.get(page);
|
|
13271
13354
|
if (!target) {
|
|
13272
13355
|
target = this.take(0);
|
|
13273
13356
|
this.pages.set(page, target);
|
|
13274
13357
|
}
|
|
13275
|
-
target.set(bytes.subarray(
|
|
13358
|
+
target.set(bytes.subarray(done5, done5 + n), from);
|
|
13276
13359
|
this.dirty.add(page);
|
|
13277
|
-
|
|
13360
|
+
done5 += n;
|
|
13278
13361
|
}
|
|
13279
13362
|
this.length = Math.max(this.length, at + bytes.length);
|
|
13280
13363
|
}
|
|
@@ -13351,10 +13434,10 @@ var Pages = class {
|
|
|
13351
13434
|
clean -= PAGE;
|
|
13352
13435
|
}
|
|
13353
13436
|
}
|
|
13354
|
-
take(
|
|
13437
|
+
take(used2) {
|
|
13355
13438
|
const page = this.free.pop();
|
|
13356
13439
|
if (!page) return new Uint8Array(PAGE);
|
|
13357
|
-
page.fill(0,
|
|
13440
|
+
page.fill(0, used2);
|
|
13358
13441
|
return page;
|
|
13359
13442
|
}
|
|
13360
13443
|
drop(page) {
|
|
@@ -13596,9 +13679,9 @@ function pidFile(name2, info, boot) {
|
|
|
13596
13679
|
}
|
|
13597
13680
|
return pidStatus(info);
|
|
13598
13681
|
}
|
|
13599
|
-
function memoryInfo(source,
|
|
13682
|
+
function memoryInfo(source, used2 = 0) {
|
|
13600
13683
|
const total = source.deviceMemory ? source.deviceMemory * KIB * KIB * KIB : FALLBACK_MEMORY;
|
|
13601
|
-
const free = Math.max(0, total -
|
|
13684
|
+
const free = Math.max(0, total - used2 - (source.usedHeap ?? 0));
|
|
13602
13685
|
const kb = (bytes) => `${Math.floor(bytes / KIB)} kB`;
|
|
13603
13686
|
return [
|
|
13604
13687
|
["MemTotal", kb(total)],
|
|
@@ -13651,10 +13734,10 @@ function memorySource(scope = globalThis) {
|
|
|
13651
13734
|
const nav = scope.navigator;
|
|
13652
13735
|
const perf = scope.performance;
|
|
13653
13736
|
const deviceMemory = nav?.deviceMemory;
|
|
13654
|
-
const
|
|
13737
|
+
const used2 = perf?.memory?.usedJSHeapSize;
|
|
13655
13738
|
return {
|
|
13656
13739
|
...typeof deviceMemory === "number" && deviceMemory > 0 ? { deviceMemory } : {},
|
|
13657
|
-
...typeof
|
|
13740
|
+
...typeof used2 === "number" ? { usedHeap: used2 } : {}
|
|
13658
13741
|
};
|
|
13659
13742
|
}
|
|
13660
13743
|
|
|
@@ -13823,7 +13906,7 @@ var ProcTree = class {
|
|
|
13823
13906
|
};
|
|
13824
13907
|
var MAX_HOPS3 = 40;
|
|
13825
13908
|
function* procWalk(path, follow2) {
|
|
13826
|
-
let
|
|
13909
|
+
let done5 = [];
|
|
13827
13910
|
let todo = path.split("/").filter((part) => part !== "");
|
|
13828
13911
|
let hops = 0;
|
|
13829
13912
|
let broken;
|
|
@@ -13831,20 +13914,20 @@ function* procWalk(path, follow2) {
|
|
|
13831
13914
|
const part = todo.shift();
|
|
13832
13915
|
if (part === ".") continue;
|
|
13833
13916
|
if (part === "..") {
|
|
13834
|
-
|
|
13917
|
+
done5.pop();
|
|
13835
13918
|
continue;
|
|
13836
13919
|
}
|
|
13837
|
-
const at = `/${[...
|
|
13838
|
-
const whole = normalize(`/${[...
|
|
13920
|
+
const at = `/${[...done5, part].join("/")}`;
|
|
13921
|
+
const whole = normalize(`/${[...done5, part, ...todo].join("/")}`);
|
|
13839
13922
|
if (inProc(at) && inProc(whole)) return broken ?? whole;
|
|
13840
13923
|
if (!follow2 && todo.length === 0) return void 0;
|
|
13841
13924
|
const target = yield { at, check: todo.find((next3) => next3 !== ".") === ".." };
|
|
13842
13925
|
if (typeof target === "string") {
|
|
13843
13926
|
if (++hops > MAX_HOPS3) return void 0;
|
|
13844
|
-
[
|
|
13927
|
+
[done5, todo] = throughLink(target, done5, todo);
|
|
13845
13928
|
} else {
|
|
13846
13929
|
broken ??= refusalOf(target);
|
|
13847
|
-
|
|
13930
|
+
done5.push(part);
|
|
13848
13931
|
}
|
|
13849
13932
|
}
|
|
13850
13933
|
return void 0;
|
|
@@ -13857,9 +13940,9 @@ function refusalOf(found) {
|
|
|
13857
13940
|
if (found === true) return void 0;
|
|
13858
13941
|
return found === false ? { refused: "ENOTDIR" } : found;
|
|
13859
13942
|
}
|
|
13860
|
-
function throughLink(target,
|
|
13943
|
+
function throughLink(target, done5, todo) {
|
|
13861
13944
|
const parts2 = target.split("/").filter((part) => part !== "");
|
|
13862
|
-
return [target.startsWith("/") ? [] :
|
|
13945
|
+
return [target.startsWith("/") ? [] : done5, [...parts2, ...todo]];
|
|
13863
13946
|
}
|
|
13864
13947
|
async function procAlias(fs, path, follow2) {
|
|
13865
13948
|
const { readlink, lstat } = fs;
|
|
@@ -14056,16 +14139,16 @@ var EpollFile = class _EpollFile {
|
|
|
14056
14139
|
changes = new Notifier();
|
|
14057
14140
|
cursor = 0;
|
|
14058
14141
|
ctl(fds, how, fd, events, data) {
|
|
14059
|
-
const
|
|
14060
|
-
if (
|
|
14142
|
+
const open2 = fds.get(fd);
|
|
14143
|
+
if (open2.file === this) throw new KernelError("EINVAL");
|
|
14061
14144
|
const known = this.regs.get(fd);
|
|
14062
|
-
const current = known?.open ===
|
|
14145
|
+
const current = known?.open === open2 ? known : void 0;
|
|
14063
14146
|
if (how === "add" || how === "set" && !current) {
|
|
14064
14147
|
if (current) throw new KernelError("EEXIST");
|
|
14065
|
-
if (UNPOLLABLE.has(kernelFdKind(
|
|
14066
|
-
if (
|
|
14148
|
+
if (UNPOLLABLE.has(kernelFdKind(open2.file))) throw new KernelError("EPERM");
|
|
14149
|
+
if (open2.file instanceof _EpollFile && open2.file.reaches(this)) throw new KernelError("ELOOP");
|
|
14067
14150
|
if (known) this.drop(known);
|
|
14068
|
-
this.register(fd,
|
|
14151
|
+
this.register(fd, open2, events, data);
|
|
14069
14152
|
} else if (!current) {
|
|
14070
14153
|
throw new KernelError("ENOENT");
|
|
14071
14154
|
} else if (how === "del") {
|
|
@@ -14132,15 +14215,15 @@ var EpollFile = class _EpollFile {
|
|
|
14132
14215
|
for (const reg of [...this.regs.values()]) this.drop(reg);
|
|
14133
14216
|
this.changes.wake();
|
|
14134
14217
|
}
|
|
14135
|
-
register(fd,
|
|
14218
|
+
register(fd, open2, events, data) {
|
|
14136
14219
|
const stop = new AbortController();
|
|
14137
|
-
const unhook =
|
|
14220
|
+
const unhook = open2.onClose(() => {
|
|
14138
14221
|
this.drop(reg);
|
|
14139
14222
|
this.changes.wake();
|
|
14140
14223
|
});
|
|
14141
14224
|
const reg = {
|
|
14142
14225
|
fd,
|
|
14143
|
-
open,
|
|
14226
|
+
open: open2,
|
|
14144
14227
|
events,
|
|
14145
14228
|
data,
|
|
14146
14229
|
gen: 1,
|
|
@@ -14221,17 +14304,17 @@ function changedAt(wakers, key, signal) {
|
|
|
14221
14304
|
return new Promise((resolve2, reject) => {
|
|
14222
14305
|
const set3 = wakers.get(key) ?? /* @__PURE__ */ new Set();
|
|
14223
14306
|
wakers.set(key, set3);
|
|
14224
|
-
const
|
|
14307
|
+
const done5 = () => {
|
|
14225
14308
|
set3.delete(wake);
|
|
14226
14309
|
if (set3.size === 0 && wakers.get(key) === set3) wakers.delete(key);
|
|
14227
14310
|
signal.removeEventListener("abort", abort);
|
|
14228
14311
|
};
|
|
14229
14312
|
const wake = () => {
|
|
14230
|
-
|
|
14313
|
+
done5();
|
|
14231
14314
|
resolve2();
|
|
14232
14315
|
};
|
|
14233
14316
|
const abort = () => {
|
|
14234
|
-
|
|
14317
|
+
done5();
|
|
14235
14318
|
reject(new KernelError("EINTR"));
|
|
14236
14319
|
};
|
|
14237
14320
|
set3.add(wake);
|
|
@@ -14439,7 +14522,7 @@ var HOST_OPS = [
|
|
|
14439
14522
|
"async-close"
|
|
14440
14523
|
];
|
|
14441
14524
|
var json3 = (value2) => ({ ok: true, kind: "json", json: value2 });
|
|
14442
|
-
var
|
|
14525
|
+
var done3 = { ok: true, kind: "void" };
|
|
14443
14526
|
var KEPT_OPS = /* @__PURE__ */ new Set(["fd-write"]);
|
|
14444
14527
|
var unknownSettled = false;
|
|
14445
14528
|
var AsyncOps = class {
|
|
@@ -14576,7 +14659,7 @@ async function hostSyscall(req, ctx) {
|
|
|
14576
14659
|
if (req.fd !== void 0 && ctx.locks?.shared?.() && ctx.flockOf) {
|
|
14577
14660
|
return flock({ op: "flock", fd: req.fd, kind: "unlock" }, ctx);
|
|
14578
14661
|
}
|
|
14579
|
-
return
|
|
14662
|
+
return done3;
|
|
14580
14663
|
case "lk-set":
|
|
14581
14664
|
case "lk-get":
|
|
14582
14665
|
case "lk-close":
|
|
@@ -14597,12 +14680,12 @@ async function hostSyscall(req, ctx) {
|
|
|
14597
14680
|
return json3(ctx.ops.hold());
|
|
14598
14681
|
case "async-cancel":
|
|
14599
14682
|
ctx.ops.cancel(req.id);
|
|
14600
|
-
return
|
|
14683
|
+
return done3;
|
|
14601
14684
|
case "async-settle":
|
|
14602
14685
|
return json3(await ctx.ops.settle(req.ids));
|
|
14603
14686
|
case "async-close":
|
|
14604
14687
|
ctx.ops.close();
|
|
14605
|
-
return
|
|
14688
|
+
return done3;
|
|
14606
14689
|
}
|
|
14607
14690
|
}
|
|
14608
14691
|
async function wholeLock(req, ctx) {
|
|
@@ -14620,7 +14703,7 @@ async function wholeLock(req, ctx) {
|
|
|
14620
14703
|
if (!locks.flockFree(key, owner, kind)) throw new KernelError("EAGAIN");
|
|
14621
14704
|
}
|
|
14622
14705
|
if (!locks.lock(ctx.pid, req.path, req.exclusive, req.fd)) throw new KernelError("EAGAIN");
|
|
14623
|
-
return
|
|
14706
|
+
return done3;
|
|
14624
14707
|
}
|
|
14625
14708
|
var FLOCK_KINDS = /* @__PURE__ */ new Set(["shared", "exclusive", "unlock"]);
|
|
14626
14709
|
async function flock(req, ctx) {
|
|
@@ -14635,7 +14718,7 @@ async function flock(req, ctx) {
|
|
|
14635
14718
|
await locks.flocks.wait(key, owner, req.kind, ctx.blocking);
|
|
14636
14719
|
else if (!await locks.flocks.set(key, owner, req.kind)) throw new KernelError("EAGAIN");
|
|
14637
14720
|
if (shared && granted2) await grantedAcross(ctx, req.fd);
|
|
14638
|
-
return shared ? json3(true) :
|
|
14721
|
+
return shared ? json3(true) : done3;
|
|
14639
14722
|
}
|
|
14640
14723
|
async function grantedAcross(ctx, fd) {
|
|
14641
14724
|
ctx.locks?.fresh?.();
|
|
@@ -14652,7 +14735,7 @@ async function recordLock2(req, ctx) {
|
|
|
14652
14735
|
if (req.op === "lk-close") {
|
|
14653
14736
|
if (req.fd !== void 0 && locks.shared?.()) await ctx.settle?.(req.fd, false);
|
|
14654
14737
|
locks.dropFile(await fileKey(target, "close"), owner);
|
|
14655
|
-
return
|
|
14738
|
+
return done3;
|
|
14656
14739
|
}
|
|
14657
14740
|
const range2 = lockRange(req.start, req.len);
|
|
14658
14741
|
const key = await fileKey(target, req.kind, req.op === "lk-set" && req.fd !== void 0);
|
|
@@ -14671,7 +14754,7 @@ async function recordLock2(req, ctx) {
|
|
|
14671
14754
|
else if (!await locks.set(key, owner, req.kind, range2.start, range2.end))
|
|
14672
14755
|
throw new KernelError("EAGAIN");
|
|
14673
14756
|
if (granted2 && shared) await grantedAcross(ctx, fd);
|
|
14674
|
-
return shared ? json3(true) :
|
|
14757
|
+
return shared ? json3(true) : done3;
|
|
14675
14758
|
}
|
|
14676
14759
|
|
|
14677
14760
|
// src/kernel/net/loopback-transport.ts
|
|
@@ -15223,7 +15306,7 @@ var CA_RENEW_BEFORE = 30 * DAY;
|
|
|
15223
15306
|
var LEAF_LIFETIME = 7 * DAY;
|
|
15224
15307
|
var ECDSA = { name: "ECDSA", namedCurve: "P-256" };
|
|
15225
15308
|
var SIGN = { name: "ECDSA", hash: "SHA-256" };
|
|
15226
|
-
function
|
|
15309
|
+
function request2(req) {
|
|
15227
15310
|
return new Promise((resolve2, reject) => {
|
|
15228
15311
|
req.onsuccess = () => resolve2(req.result);
|
|
15229
15312
|
req.onerror = () => reject(req.error);
|
|
@@ -15231,7 +15314,7 @@ function request(req) {
|
|
|
15231
15314
|
}
|
|
15232
15315
|
function indexedDbCaStore(dbName = "slicc-realm-ca") {
|
|
15233
15316
|
let db;
|
|
15234
|
-
const
|
|
15317
|
+
const open2 = () => {
|
|
15235
15318
|
db ??= new Promise((resolve2, reject) => {
|
|
15236
15319
|
const req = indexedDB.open(dbName, 1);
|
|
15237
15320
|
req.onupgradeneeded = () => req.result.createObjectStore("ca");
|
|
@@ -15245,11 +15328,11 @@ function indexedDbCaStore(dbName = "slicc-realm-ca") {
|
|
|
15245
15328
|
};
|
|
15246
15329
|
return {
|
|
15247
15330
|
async get(owner) {
|
|
15248
|
-
const store = (await
|
|
15249
|
-
return await
|
|
15331
|
+
const store = (await open2()).transaction("ca").objectStore("ca");
|
|
15332
|
+
return await request2(store.get(owner));
|
|
15250
15333
|
},
|
|
15251
15334
|
async swap(owner, expected, record) {
|
|
15252
|
-
const tx = (await
|
|
15335
|
+
const tx = (await open2()).transaction("ca", "readwrite");
|
|
15253
15336
|
const store = tx.objectStore("ca");
|
|
15254
15337
|
let stored = record;
|
|
15255
15338
|
const read = store.get(owner);
|
|
@@ -15952,7 +16035,7 @@ var WsHandles = class {
|
|
|
15952
16035
|
async connect(handle, req, entry) {
|
|
15953
16036
|
const { transport, local } = this;
|
|
15954
16037
|
const port = local?.port(req.url);
|
|
15955
|
-
const
|
|
16038
|
+
const open2 = { protocols: req.protocols, headers: req.headers, signal: entry.abort.signal };
|
|
15956
16039
|
if (port === void 0 && (!transport.traits.websocket || !transport.websocket)) {
|
|
15957
16040
|
return fail("ENOTSUP", NO_WEBSOCKET2);
|
|
15958
16041
|
}
|
|
@@ -15960,8 +16043,8 @@ var WsHandles = class {
|
|
|
15960
16043
|
try {
|
|
15961
16044
|
socket = port === void 0 ? await transport.websocket({
|
|
15962
16045
|
url: toHostLoopback(req.url),
|
|
15963
|
-
...
|
|
15964
|
-
}) : await local.websocket({ url: req.url, ...
|
|
16046
|
+
...open2
|
|
16047
|
+
}) : await local.websocket({ url: req.url, ...open2 }, port);
|
|
15965
16048
|
} catch (e) {
|
|
15966
16049
|
return fail(errnoOf(e), message(e));
|
|
15967
16050
|
}
|
|
@@ -16164,14 +16247,14 @@ var HttpHandles = class {
|
|
|
16164
16247
|
const port = this.local?.port(req.url);
|
|
16165
16248
|
try {
|
|
16166
16249
|
const target = port === void 0 ? toHostLoopback(req.url) : req.url;
|
|
16167
|
-
const
|
|
16250
|
+
const request3 = {
|
|
16168
16251
|
url: target,
|
|
16169
16252
|
method: req.method,
|
|
16170
16253
|
headers: req.headers,
|
|
16171
16254
|
...entry.upload ? { bodyStream: entry.upload } : req.body ? { body: req.body } : {},
|
|
16172
16255
|
signal: entry.abort.signal
|
|
16173
16256
|
};
|
|
16174
|
-
const response = port === void 0 ? await this.transport.fetch(
|
|
16257
|
+
const response = port === void 0 ? await this.transport.fetch(request3, this.owner) : await this.local.fetch(request3, port);
|
|
16175
16258
|
entry.body = response.body[Symbol.asyncIterator]();
|
|
16176
16259
|
entry.cancel = () => response.cancel();
|
|
16177
16260
|
if (!this.open.has(handle)) await entry.cancel().catch(() => void 0);
|
|
@@ -16323,10 +16406,10 @@ var RemoteUplink = class {
|
|
|
16323
16406
|
write: async (bytes) => {
|
|
16324
16407
|
const copy = bytes.slice();
|
|
16325
16408
|
const call = { uplink: "write", uid: ++this.nextId, cid, bytes: copy };
|
|
16326
|
-
const
|
|
16409
|
+
const done5 = await this.ask(call, void 0, [
|
|
16327
16410
|
copy.buffer
|
|
16328
16411
|
]);
|
|
16329
|
-
return
|
|
16412
|
+
return done5.n;
|
|
16330
16413
|
},
|
|
16331
16414
|
closeWrite: () => this.port.postMessage({ uplink: "close-write", cid }),
|
|
16332
16415
|
close: () => this.port.postMessage({ uplink: "close", cid })
|
|
@@ -16933,7 +17016,7 @@ function terminalOf(ctx, fd) {
|
|
|
16933
17016
|
return tty;
|
|
16934
17017
|
}
|
|
16935
17018
|
var json4 = (value2) => ({ ok: true, kind: "json", json: value2 });
|
|
16936
|
-
var
|
|
17019
|
+
var done4 = { ok: true, kind: "void" };
|
|
16937
17020
|
function sizeKey(rows, cols) {
|
|
16938
17021
|
return `${rows}x${cols}`;
|
|
16939
17022
|
}
|
|
@@ -16956,23 +17039,23 @@ function ptySyscall(req, ctx) {
|
|
|
16956
17039
|
return json4(masterOf(ctx, req.fd).index);
|
|
16957
17040
|
case "pty-lock":
|
|
16958
17041
|
masterOf(ctx, req.fd).locked = req.lock;
|
|
16959
|
-
return
|
|
17042
|
+
return done4;
|
|
16960
17043
|
case "pty-ctty": {
|
|
16961
17044
|
const tty = terminalOf(ctx, req.fd);
|
|
16962
17045
|
const leader = ctx.jobs?.getsid(ctx.pid, 0) === ctx.pid;
|
|
16963
|
-
if (leader && ctx.jobs?.controllingTerminal(ctx.pid) === tty) return
|
|
17046
|
+
if (leader && ctx.jobs?.controllingTerminal(ctx.pid) === tty) return done4;
|
|
16964
17047
|
if (!ctx.jobs?.acquireTerminal(ctx.pid, tty)) throw new KernelError("EPERM");
|
|
16965
|
-
return
|
|
17048
|
+
return done4;
|
|
16966
17049
|
}
|
|
16967
17050
|
case "pty-list":
|
|
16968
17051
|
return json4(ctx.ptys?.numbers() ?? []);
|
|
16969
17052
|
case "pty-packet":
|
|
16970
17053
|
masterOf(ctx, req.fd).packet = req.on;
|
|
16971
|
-
return
|
|
17054
|
+
return done4;
|
|
16972
17055
|
case "pty-winsz-set": {
|
|
16973
17056
|
const tty = terminalOf(ctx, req.fd);
|
|
16974
17057
|
if (ctx.sizesRead?.get(tty) !== sizeKey(req.rows, req.cols)) tty.resize(req.cols, req.rows);
|
|
16975
|
-
return
|
|
17058
|
+
return done4;
|
|
16976
17059
|
}
|
|
16977
17060
|
}
|
|
16978
17061
|
}
|
|
@@ -17059,8 +17142,8 @@ async function runChild(req, deps) {
|
|
|
17059
17142
|
let status;
|
|
17060
17143
|
try {
|
|
17061
17144
|
status = await reaped(deps, pid);
|
|
17062
|
-
const
|
|
17063
|
-
await Promise.race([Promise.all(
|
|
17145
|
+
const open2 = controls2.filter((c) => c.opened);
|
|
17146
|
+
await Promise.race([Promise.all(open2.map((c) => c.eof)), decided.promise]);
|
|
17064
17147
|
} finally {
|
|
17065
17148
|
cancel?.();
|
|
17066
17149
|
for (const control of controls2) control.shut = true;
|
|
@@ -17338,7 +17421,7 @@ function filePath(addr) {
|
|
|
17338
17421
|
if (addr.family !== "unix" || addr.path === "" || addr.path.startsWith("\0")) return void 0;
|
|
17339
17422
|
return normalizePath(addr.path);
|
|
17340
17423
|
}
|
|
17341
|
-
function
|
|
17424
|
+
function nameOf2(st) {
|
|
17342
17425
|
return { key: `${st.dev ?? 0}:${st.ino}`, typed: st.isSocket === true };
|
|
17343
17426
|
}
|
|
17344
17427
|
function codeOf3(err) {
|
|
@@ -17360,7 +17443,7 @@ function socketNames(deps) {
|
|
|
17360
17443
|
const remove = () => fs.rm(path, { file: true }).catch(() => void 0);
|
|
17361
17444
|
try {
|
|
17362
17445
|
if (!deps.owners && owner.mode !== void 0) await fs.chmod(path, owner.mode);
|
|
17363
|
-
return { ...
|
|
17446
|
+
return { ...nameOf2(await fs.lstat(path)), remove };
|
|
17364
17447
|
} catch (err) {
|
|
17365
17448
|
await remove();
|
|
17366
17449
|
throw err;
|
|
@@ -17369,7 +17452,7 @@ function socketNames(deps) {
|
|
|
17369
17452
|
async find(path) {
|
|
17370
17453
|
const g = deps.guard();
|
|
17371
17454
|
if (g) await need(g, "connect", path, W_OK, { directory: false });
|
|
17372
|
-
return
|
|
17455
|
+
return nameOf2(await fs.stat(path));
|
|
17373
17456
|
}
|
|
17374
17457
|
};
|
|
17375
17458
|
}
|
|
@@ -18185,17 +18268,17 @@ function scrubbed(inner, scrubber, idleMs = SCRUB_IDLE_MS) {
|
|
|
18185
18268
|
});
|
|
18186
18269
|
};
|
|
18187
18270
|
const settling = (signal) => new Promise((resolve2, reject) => {
|
|
18188
|
-
const
|
|
18189
|
-
waiters.delete(
|
|
18271
|
+
const done5 = () => {
|
|
18272
|
+
waiters.delete(done5);
|
|
18190
18273
|
signal?.removeEventListener("abort", stop);
|
|
18191
18274
|
resolve2();
|
|
18192
18275
|
};
|
|
18193
18276
|
const stop = () => {
|
|
18194
|
-
waiters.delete(
|
|
18277
|
+
waiters.delete(done5);
|
|
18195
18278
|
reject(new KernelError("EINTR"));
|
|
18196
18279
|
};
|
|
18197
18280
|
if (signal?.aborted) return stop();
|
|
18198
|
-
waiters.add(
|
|
18281
|
+
waiters.add(done5);
|
|
18199
18282
|
signal?.addEventListener("abort", stop, { once: true });
|
|
18200
18283
|
});
|
|
18201
18284
|
const settled = async () => {
|
|
@@ -18387,15 +18470,15 @@ async function substituteHead(head, ask) {
|
|
|
18387
18470
|
if (!head.endsWith("\r\n\r\n")) return void 0;
|
|
18388
18471
|
const lines2 = head.slice(0, -4).split("\r\n");
|
|
18389
18472
|
if (lines2.some((l) => l.includes("\n") || l.includes("\r"))) return void 0;
|
|
18390
|
-
const
|
|
18391
|
-
const found =
|
|
18392
|
-
if (!
|
|
18473
|
+
const request3 = REQUEST_LINE2.exec(lines2[0]);
|
|
18474
|
+
const found = request3 ? scan(lines2) : void 0;
|
|
18475
|
+
if (!request3 || !found || found.length !== 1) return void 0;
|
|
18393
18476
|
const at = found[0];
|
|
18394
18477
|
if (at.placeholders.length > SESSION_PLACEHOLDERS) return void 0;
|
|
18395
18478
|
const values = usable(
|
|
18396
18479
|
await ask(`header:${at.name}`, at.placeholders, {
|
|
18397
|
-
method:
|
|
18398
|
-
path:
|
|
18480
|
+
method: request3[1],
|
|
18481
|
+
path: request3[2]
|
|
18399
18482
|
})
|
|
18400
18483
|
);
|
|
18401
18484
|
if (Object.keys(values).length === 0) return void 0;
|
|
@@ -18498,7 +18581,7 @@ var Http1Writer = class {
|
|
|
18498
18581
|
this.buffer = new Uint8Array(0);
|
|
18499
18582
|
const s = this.s;
|
|
18500
18583
|
const session = sessionId();
|
|
18501
|
-
const
|
|
18584
|
+
const done5 = await substituteHead(
|
|
18502
18585
|
latin12(all.subarray(0, end)),
|
|
18503
18586
|
async (position, placeholders, head2) => s.broker.sessionMaterialize({
|
|
18504
18587
|
stamp: await s.stamp(),
|
|
@@ -18514,10 +18597,10 @@ var Http1Writer = class {
|
|
|
18514
18597
|
head: head2
|
|
18515
18598
|
})
|
|
18516
18599
|
).catch(() => void 0);
|
|
18517
|
-
const head =
|
|
18518
|
-
if (
|
|
18600
|
+
const head = done5 ? bytesOf(done5.head) : all.subarray(0, end);
|
|
18601
|
+
if (done5) {
|
|
18519
18602
|
this.scope.add(
|
|
18520
|
-
Object.entries(
|
|
18603
|
+
Object.entries(done5.values).map(([placeholder, value2]) => ({
|
|
18521
18604
|
name: "sealed",
|
|
18522
18605
|
value: value2,
|
|
18523
18606
|
placeholder
|
|
@@ -18935,15 +19018,15 @@ function alertOf(session) {
|
|
|
18935
19018
|
}
|
|
18936
19019
|
async function handshake(conn, o, session, inbox) {
|
|
18937
19020
|
for (; ; ) {
|
|
18938
|
-
let
|
|
19021
|
+
let done5;
|
|
18939
19022
|
try {
|
|
18940
|
-
|
|
19023
|
+
done5 = session.handshake();
|
|
18941
19024
|
} catch (err) {
|
|
18942
19025
|
await send(conn, session).catch(() => void 0);
|
|
18943
19026
|
throw refused2(o.engine, session, err);
|
|
18944
19027
|
}
|
|
18945
19028
|
await send(conn, session);
|
|
18946
|
-
if (
|
|
19029
|
+
if (done5) return;
|
|
18947
19030
|
if (!await inbox.more()) {
|
|
18948
19031
|
throw new KernelError(
|
|
18949
19032
|
"ECONNRESET",
|
|
@@ -20173,9 +20256,9 @@ var VfsNodes = class {
|
|
|
20173
20256
|
}
|
|
20174
20257
|
open(path, pin, writable2 = false, id2, ino) {
|
|
20175
20258
|
const found = this.named(path, id2);
|
|
20176
|
-
const
|
|
20177
|
-
if (found && !
|
|
20178
|
-
const node = (
|
|
20259
|
+
const same2 = !found || ino === void 0 || found.ino === void 0 || found.ino === ino;
|
|
20260
|
+
if (found && !same2) this.orphan(found);
|
|
20261
|
+
const node = (same2 ? found : void 0) ?? this.create(path, id2, new VfsNode(this.fs, path, void 0, false, false, pin));
|
|
20179
20262
|
node.ino ??= ino;
|
|
20180
20263
|
node.opens++;
|
|
20181
20264
|
if (writable2) node.writers++;
|
|
@@ -20358,9 +20441,9 @@ function heldIo(fs, nodes, changed) {
|
|
|
20358
20441
|
const held = await node(path);
|
|
20359
20442
|
if (!held) return fallback();
|
|
20360
20443
|
const out = await held.serial(async () => {
|
|
20361
|
-
const
|
|
20444
|
+
const done5 = await op(held);
|
|
20362
20445
|
await held.flush();
|
|
20363
|
-
return
|
|
20446
|
+
return done5;
|
|
20364
20447
|
});
|
|
20365
20448
|
changed(fs.resolvePath("/", path));
|
|
20366
20449
|
if (held.path !== fs.resolvePath("/", path)) changed(held.path);
|
|
@@ -21193,30 +21276,30 @@ var WasmProcess = class {
|
|
|
21193
21276
|
else await file?.flush?.();
|
|
21194
21277
|
}
|
|
21195
21278
|
async flockOf(fd) {
|
|
21196
|
-
const
|
|
21279
|
+
const open2 = this.fds.get(fd);
|
|
21197
21280
|
const { locks } = this.options;
|
|
21198
|
-
if (locks && !flockHooked.has(
|
|
21199
|
-
flockHooked.add(
|
|
21200
|
-
|
|
21281
|
+
if (locks && !flockHooked.has(open2)) {
|
|
21282
|
+
flockHooked.add(open2);
|
|
21283
|
+
open2.onClose(() => locks.flocks.drop(open2));
|
|
21201
21284
|
}
|
|
21202
|
-
return { key: await this.objectKeyOf(
|
|
21285
|
+
return { key: await this.objectKeyOf(open2), owner: open2 };
|
|
21203
21286
|
}
|
|
21204
|
-
async objectKeyOf(
|
|
21205
|
-
const { file } =
|
|
21287
|
+
async objectKeyOf(open2) {
|
|
21288
|
+
const { file } = open2;
|
|
21206
21289
|
const meta = file.heldMeta;
|
|
21207
21290
|
if (meta && "device" in meta) return `device:${meta.device}`;
|
|
21208
21291
|
if (meta && "dir" in meta) {
|
|
21209
21292
|
const st2 = await this.options.fs.stat?.(meta.dir).catch(() => void 0);
|
|
21210
21293
|
return st2 ? identityKey(st2, meta.dir) : objectKey(file);
|
|
21211
21294
|
}
|
|
21212
|
-
const known = fileKeys.get(
|
|
21295
|
+
const known = fileKeys.get(open2);
|
|
21213
21296
|
if (known !== void 0) return known;
|
|
21214
21297
|
const vfs = await file.stat?.().catch(() => void 0);
|
|
21215
21298
|
if (!vfs || vfs.orphan) return objectKey(file);
|
|
21216
21299
|
const st = await this.options.fs.stat?.(vfs.path).catch(() => void 0);
|
|
21217
21300
|
if (!st) return objectKey(file);
|
|
21218
21301
|
const key = identityKey(st, vfs.path);
|
|
21219
|
-
fileKeys.set(
|
|
21302
|
+
fileKeys.set(open2, key);
|
|
21220
21303
|
return key;
|
|
21221
21304
|
}
|
|
21222
21305
|
async dropRecordLocks(fd) {
|
|
@@ -21338,17 +21421,17 @@ var WasmProcess = class {
|
|
|
21338
21421
|
return fd;
|
|
21339
21422
|
}
|
|
21340
21423
|
if (this.writesAt(req) && this.options.readonlyAt?.(path)) throw new KernelError("EROFS");
|
|
21341
|
-
const
|
|
21424
|
+
const open2 = { ...req, path };
|
|
21342
21425
|
const plain2 = this.plainMode(req.mode);
|
|
21343
21426
|
if (req.exclusive) {
|
|
21344
21427
|
await nodes.createExclusive(path, this.newOwner(req.mode));
|
|
21345
21428
|
if (plain2 !== void 0) await fs.chmod?.(path, plain2);
|
|
21346
|
-
this.fds.installAt(fd, this.openVfsFile(
|
|
21429
|
+
this.fds.installAt(fd, this.openVfsFile(open2, void 0, fs));
|
|
21347
21430
|
} else if (req.create) {
|
|
21348
21431
|
await nodes.onEntry(path, async () => {
|
|
21349
21432
|
const marks = this.options.owners || plain2 !== void 0;
|
|
21350
21433
|
const fresh2 = marks && !await present3(fs, path, true);
|
|
21351
|
-
this.fds.installAt(fd, this.openVfsFile(
|
|
21434
|
+
this.fds.installAt(fd, this.openVfsFile(open2, await nodes.identify(path), fs));
|
|
21352
21435
|
await this.fds.get(fd).file.stat?.();
|
|
21353
21436
|
if (fresh2 && plain2 !== void 0) await fs.chmod?.(path, plain2);
|
|
21354
21437
|
else if (fresh2) {
|
|
@@ -21362,7 +21445,7 @@ var WasmProcess = class {
|
|
|
21362
21445
|
await this.stillOpen(at, req.handle);
|
|
21363
21446
|
return nodes.identify(at);
|
|
21364
21447
|
},
|
|
21365
|
-
(id2, at) => this.fds.installAt(fd, this.openVfsFile({ ...
|
|
21448
|
+
(id2, at) => this.fds.installAt(fd, this.openVfsFile({ ...open2, path: at }, id2, fs)),
|
|
21366
21449
|
{ at: path, gen }
|
|
21367
21450
|
);
|
|
21368
21451
|
}
|
|
@@ -21477,11 +21560,11 @@ var WasmProcess = class {
|
|
|
21477
21560
|
}
|
|
21478
21561
|
async stampClipboards() {
|
|
21479
21562
|
if (!this.options.clipboard) return;
|
|
21480
|
-
const
|
|
21481
|
-
if (
|
|
21563
|
+
const open2 = this.fds.numbers().filter((fd) => this.fds.get(fd).file.clipboard);
|
|
21564
|
+
if (open2.length === 0) return;
|
|
21482
21565
|
const stamp = await this.clipboardStamp().catch(() => void 0);
|
|
21483
21566
|
if (!stamp) return;
|
|
21484
|
-
for (const fd of
|
|
21567
|
+
for (const fd of open2) {
|
|
21485
21568
|
const channel = this.fds.get(fd).file.clipboard;
|
|
21486
21569
|
if (channel) channel.stamp = stamp;
|
|
21487
21570
|
}
|
|
@@ -22274,18 +22357,18 @@ function descId(file) {
|
|
|
22274
22357
|
}
|
|
22275
22358
|
function inheritedFds(fds) {
|
|
22276
22359
|
return fds.numbers().filter((fd) => fd > 2 && !fds.get(fd).file.held).map((fd) => {
|
|
22277
|
-
const
|
|
22360
|
+
const open2 = fds.get(fd);
|
|
22278
22361
|
const flags2 = fds.statusFlags(fd);
|
|
22279
|
-
const kind =
|
|
22280
|
-
const meta =
|
|
22362
|
+
const kind = open2.file instanceof KernelSocket || isDatagram(open2.file) ? "socket" : kernelFdKind(open2.file);
|
|
22363
|
+
const meta = open2.file.heldMeta;
|
|
22281
22364
|
return {
|
|
22282
22365
|
fd,
|
|
22283
22366
|
kind,
|
|
22284
22367
|
...kind === "device" && meta && "device" in meta ? { device: meta } : {},
|
|
22285
22368
|
...flags2 !== void 0 ? { flags: flags2 } : {},
|
|
22286
22369
|
...fds.closesOnExec(fd) ? { cloexec: true } : {},
|
|
22287
|
-
...kind === "stream" ? { desc: descId(
|
|
22288
|
-
...
|
|
22370
|
+
...kind === "stream" ? { desc: descId(open2) } : {},
|
|
22371
|
+
...open2.file.fifo ? { fifo: open2.file.fifo } : {}
|
|
22289
22372
|
};
|
|
22290
22373
|
});
|
|
22291
22374
|
}
|
|
@@ -22451,7 +22534,7 @@ function holdingToken(opts, holds2, caller) {
|
|
|
22451
22534
|
noLinks: opts.noLinks,
|
|
22452
22535
|
cwd: opts.cwd,
|
|
22453
22536
|
...opts.statfs ? { statfs: opts.statfs } : {},
|
|
22454
|
-
hold: (path, on,
|
|
22537
|
+
hold: (path, on, open2, real, handle) => holds2.hold(path, on, open2, real, handle),
|
|
22455
22538
|
keptFor: (handle) => holds2.keptFor(handle),
|
|
22456
22539
|
unlinked: (path) => holds2.keptAt(path),
|
|
22457
22540
|
gate: (path, op) => opts.unlinkGate && holds2.holding(path) ? opts.unlinkGate.run(holds2.keyOf(path), op) : op(),
|
|
@@ -22600,11 +22683,11 @@ function spawnWasmProcess(opts) {
|
|
|
22600
22683
|
});
|
|
22601
22684
|
const lane = opts.program.abi === "js" ? openLane(token, dispatch2) : void 0;
|
|
22602
22685
|
const { promise: exited, resolve: settle3 } = Promise.withResolvers();
|
|
22603
|
-
let
|
|
22686
|
+
let done5 = false;
|
|
22604
22687
|
let endedBy;
|
|
22605
22688
|
const finish = (code, sig) => {
|
|
22606
|
-
if (
|
|
22607
|
-
|
|
22689
|
+
if (done5) return;
|
|
22690
|
+
done5 = true;
|
|
22608
22691
|
started(true);
|
|
22609
22692
|
clocks.freeze();
|
|
22610
22693
|
dying.clear();
|
|
@@ -22655,7 +22738,7 @@ function spawnWasmProcess(opts) {
|
|
|
22655
22738
|
};
|
|
22656
22739
|
const spawnThread = (thread) => {
|
|
22657
22740
|
const { program } = opts;
|
|
22658
|
-
if (
|
|
22741
|
+
if (done5 || program.abi === "js") return;
|
|
22659
22742
|
if (threads.size >= WASM_MAX_THREADS - 1) {
|
|
22660
22743
|
opts.onError?.(`more than ${WASM_MAX_THREADS} threads`);
|
|
22661
22744
|
finish(CRASHED);
|
|
@@ -22691,7 +22774,7 @@ function spawnWasmProcess(opts) {
|
|
|
22691
22774
|
transferOf(opts, lane?.lane)
|
|
22692
22775
|
);
|
|
22693
22776
|
const terminate = (code, sig) => {
|
|
22694
|
-
if (opts.program.abi !== "wasi" ||
|
|
22777
|
+
if (opts.program.abi !== "wasi" || done5) finish(code, sig);
|
|
22695
22778
|
else dying.start(code, sig, header3, process, () => finish(code, sig));
|
|
22696
22779
|
};
|
|
22697
22780
|
const signal = (sig, info) => {
|
|
@@ -22713,7 +22796,7 @@ function spawnWasmProcess(opts) {
|
|
|
22713
22796
|
signalMasks: () => process.signalMasks(),
|
|
22714
22797
|
umask: () => process.umask,
|
|
22715
22798
|
cred: () => copyCred(process.cred),
|
|
22716
|
-
writesBack: () => opts.program.abi === "wasi" && !
|
|
22799
|
+
writesBack: () => opts.program.abi === "wasi" && !done5,
|
|
22717
22800
|
...clockViews(clocks)
|
|
22718
22801
|
};
|
|
22719
22802
|
}
|
|
@@ -23381,21 +23464,21 @@ function replayingHops(inner, heldMs = HELD_MS) {
|
|
|
23381
23464
|
return { ...inner.traits, manualRedirects: true };
|
|
23382
23465
|
},
|
|
23383
23466
|
...inner.websocket ? { websocket: inner.websocket.bind(inner) } : {},
|
|
23384
|
-
async fetch(
|
|
23385
|
-
const key = keyOf3(owner,
|
|
23467
|
+
async fetch(request3, owner = KERNEL) {
|
|
23468
|
+
const key = keyOf3(owner, request3.method, request3.url);
|
|
23386
23469
|
const waiting = held.get(key);
|
|
23387
|
-
if (waiting && waiting.fingerprint === fingerprint(
|
|
23470
|
+
if (waiting && waiting.fingerprint === fingerprint(request3.headers)) {
|
|
23388
23471
|
held.delete(key);
|
|
23389
23472
|
clearTimeout(waiting.timer);
|
|
23390
23473
|
return replay(waiting);
|
|
23391
23474
|
}
|
|
23392
23475
|
if (waiting) drop(key);
|
|
23393
|
-
const response = await inner.fetch(
|
|
23476
|
+
const response = await inner.fetch(request3);
|
|
23394
23477
|
if (!response.redirects?.length) return response;
|
|
23395
23478
|
return replay({
|
|
23396
23479
|
owner,
|
|
23397
|
-
method:
|
|
23398
|
-
fingerprint: fingerprint(
|
|
23480
|
+
method: request3.method,
|
|
23481
|
+
fingerprint: fingerprint(request3.headers),
|
|
23399
23482
|
hops: response.redirects,
|
|
23400
23483
|
final: response
|
|
23401
23484
|
});
|
|
@@ -23921,7 +24004,7 @@ async function dispatch(h, req) {
|
|
|
23921
24004
|
}
|
|
23922
24005
|
}
|
|
23923
24006
|
function serveFilesystem(port, handlers, capabilities = {}, options = {}) {
|
|
23924
|
-
let
|
|
24007
|
+
let open2 = false;
|
|
23925
24008
|
const reply = (message3, transfer = []) => port.postMessage(message3, transfer);
|
|
23926
24009
|
async function hello(message3) {
|
|
23927
24010
|
const refused3 = driverVersionError(message3.protocol);
|
|
@@ -23931,7 +24014,7 @@ function serveFilesystem(port, handlers, capabilities = {}, options = {}) {
|
|
|
23931
24014
|
}
|
|
23932
24015
|
try {
|
|
23933
24016
|
const refined = await handlers.mount?.(message3.mount);
|
|
23934
|
-
|
|
24017
|
+
open2 = true;
|
|
23935
24018
|
reply({
|
|
23936
24019
|
hello: { protocol: DRIVER_PROTOCOL, capabilities: { ...capabilities, ...refined } }
|
|
23937
24020
|
});
|
|
@@ -23952,7 +24035,7 @@ function serveFilesystem(port, handlers, capabilities = {}, options = {}) {
|
|
|
23952
24035
|
void hello(data.hello);
|
|
23953
24036
|
return;
|
|
23954
24037
|
}
|
|
23955
|
-
if (!
|
|
24038
|
+
if (!open2) return;
|
|
23956
24039
|
dispatch(handlers, data).then(
|
|
23957
24040
|
(result) => {
|
|
23958
24041
|
if (result instanceof Uint8Array) {
|
|
@@ -24101,10 +24184,10 @@ function kernelFsHandlers(fs) {
|
|
|
24101
24184
|
readlink: (path) => fs.readlink(path),
|
|
24102
24185
|
async setattr(path, change) {
|
|
24103
24186
|
if (change.size !== void 0) {
|
|
24104
|
-
const
|
|
24187
|
+
const open2 = [...handles.values()].find(
|
|
24105
24188
|
(h) => h.path === path && h.session !== void 0
|
|
24106
24189
|
)?.session;
|
|
24107
|
-
if (
|
|
24190
|
+
if (open2 !== void 0) await (await open2).truncate(change.size);
|
|
24108
24191
|
else await fs.truncate?.(path, change.size);
|
|
24109
24192
|
}
|
|
24110
24193
|
if (change.mode !== void 0) await fs.chmod(path, change.mode);
|
|
@@ -24121,7 +24204,7 @@ function granted(handle) {
|
|
|
24121
24204
|
() => false
|
|
24122
24205
|
);
|
|
24123
24206
|
}
|
|
24124
|
-
function removableMedium(onLost,
|
|
24207
|
+
function removableMedium(onLost, open2 = (handle) => new OpfsFs(handle)) {
|
|
24125
24208
|
const slot2 = mediumSlot(
|
|
24126
24209
|
async (err, handle) => denied(err) && !await granted(handle),
|
|
24127
24210
|
onLost
|
|
@@ -24129,7 +24212,7 @@ function removableMedium(onLost, open = (handle) => new OpfsFs(handle)) {
|
|
|
24129
24212
|
return {
|
|
24130
24213
|
handlers: slot2.handlers,
|
|
24131
24214
|
present: slot2.present,
|
|
24132
|
-
insert: (handle) => slot2.insert(handle, kernelFsHandlers(
|
|
24215
|
+
insert: (handle) => slot2.insert(handle, kernelFsHandlers(open2(handle))),
|
|
24133
24216
|
eject: slot2.eject
|
|
24134
24217
|
};
|
|
24135
24218
|
}
|
|
@@ -24255,13 +24338,13 @@ function codeOf5(err) {
|
|
|
24255
24338
|
function wait(ms, signal) {
|
|
24256
24339
|
if (signal.aborted) return Promise.resolve();
|
|
24257
24340
|
return new Promise((resolve2) => {
|
|
24258
|
-
const
|
|
24341
|
+
const done5 = () => {
|
|
24259
24342
|
clearTimeout(timer);
|
|
24260
|
-
signal.removeEventListener("abort",
|
|
24343
|
+
signal.removeEventListener("abort", done5);
|
|
24261
24344
|
resolve2();
|
|
24262
24345
|
};
|
|
24263
|
-
const timer = setTimeout(
|
|
24264
|
-
signal.addEventListener("abort",
|
|
24346
|
+
const timer = setTimeout(done5, ms);
|
|
24347
|
+
signal.addEventListener("abort", done5, { once: true });
|
|
24265
24348
|
});
|
|
24266
24349
|
}
|
|
24267
24350
|
async function mountFstab(lines2, mount, signal, retries = FSTAB_RETRIES, discard = () => {
|
|
@@ -24422,8 +24505,8 @@ var HostfsClient = class {
|
|
|
24422
24505
|
let buffered = "";
|
|
24423
24506
|
try {
|
|
24424
24507
|
for (; ; ) {
|
|
24425
|
-
const { done:
|
|
24426
|
-
if (
|
|
24508
|
+
const { done: done5, value: value2 } = await reader.read();
|
|
24509
|
+
if (done5) return;
|
|
24427
24510
|
buffered += decoder4.decode(value2, { stream: true });
|
|
24428
24511
|
let end = buffered.indexOf("\n");
|
|
24429
24512
|
while (end >= 0) {
|
|
@@ -24455,14 +24538,14 @@ function hostfsHandlers(current, againMs = RESTORE_AGAIN_MS) {
|
|
|
24455
24538
|
return fresh2(remote);
|
|
24456
24539
|
};
|
|
24457
24540
|
const call = (op, body = {}) => current().call(op, body);
|
|
24458
|
-
const
|
|
24541
|
+
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
24542
|
const settle3 = (client, { was, ...restore }) => client.call("setattr", restore).catch((err) => {
|
|
24460
24543
|
if (!client.gone || !client.cleanup) throw err;
|
|
24461
24544
|
void client.cleanup("setattr", restore).catch(() => {
|
|
24462
24545
|
});
|
|
24463
24546
|
const timer = setTimeout(async () => {
|
|
24464
24547
|
const seen = await client.cleanup?.("stat", { path: restore.path }).catch(() => null);
|
|
24465
|
-
if (
|
|
24548
|
+
if (same2(was, restore.mode, seen))
|
|
24466
24549
|
void client.cleanup?.("setattr", restore).catch(() => {
|
|
24467
24550
|
});
|
|
24468
24551
|
}, againMs);
|
|
@@ -24586,13 +24669,13 @@ async function resize(h, path, size) {
|
|
|
24586
24669
|
}
|
|
24587
24670
|
function sleep(ms, signal) {
|
|
24588
24671
|
return new Promise((resolve2) => {
|
|
24589
|
-
const
|
|
24672
|
+
const done5 = () => {
|
|
24590
24673
|
clearTimeout(timer);
|
|
24591
|
-
signal.removeEventListener("abort",
|
|
24674
|
+
signal.removeEventListener("abort", done5);
|
|
24592
24675
|
resolve2();
|
|
24593
24676
|
};
|
|
24594
|
-
const timer = setTimeout(
|
|
24595
|
-
signal.addEventListener("abort",
|
|
24677
|
+
const timer = setTimeout(done5, ms);
|
|
24678
|
+
signal.addEventListener("abort", done5);
|
|
24596
24679
|
});
|
|
24597
24680
|
}
|
|
24598
24681
|
function keepWatching(loop, signal) {
|
|
@@ -24676,8 +24759,8 @@ function timed(transport, ms) {
|
|
|
24676
24759
|
let expired = false;
|
|
24677
24760
|
const running = run2();
|
|
24678
24761
|
inflight.add(running);
|
|
24679
|
-
const
|
|
24680
|
-
running.then(
|
|
24762
|
+
const done5 = () => inflight.delete(running);
|
|
24763
|
+
running.then(done5, done5);
|
|
24681
24764
|
const timer = setTimeout(() => {
|
|
24682
24765
|
expired = true;
|
|
24683
24766
|
const why = `the host folder did not answer ${name2} within ${ms} ms`;
|
|
@@ -24974,17 +25057,17 @@ function memoryMedia() {
|
|
|
24974
25057
|
put: async (id2, handle) => void handles.set(id2, handle)
|
|
24975
25058
|
};
|
|
24976
25059
|
}
|
|
24977
|
-
function settle2(
|
|
25060
|
+
function settle2(request3, value2) {
|
|
24978
25061
|
return new Promise((resolve2, reject) => {
|
|
24979
|
-
|
|
24980
|
-
|
|
25062
|
+
request3.onsuccess = () => resolve2(value2());
|
|
25063
|
+
request3.onerror = () => reject(request3.error);
|
|
24981
25064
|
});
|
|
24982
25065
|
}
|
|
24983
25066
|
function openMedia(name2, factory) {
|
|
24984
|
-
const
|
|
24985
|
-
|
|
24986
|
-
return settle2(
|
|
24987
|
-
const db =
|
|
25067
|
+
const request3 = factory.open(name2, 1);
|
|
25068
|
+
request3.onupgradeneeded = () => request3.result.createObjectStore(MEDIA_STORE);
|
|
25069
|
+
return settle2(request3, () => {
|
|
25070
|
+
const db = request3.result;
|
|
24988
25071
|
const store = (mode) => db.transaction(MEDIA_STORE, mode).objectStore(MEDIA_STORE);
|
|
24989
25072
|
return {
|
|
24990
25073
|
get: (id2) => {
|
|
@@ -25017,14 +25100,14 @@ var ChunkedBytes = class {
|
|
|
25017
25100
|
}
|
|
25018
25101
|
write(offset, bytes, owned4 = false) {
|
|
25019
25102
|
const whole = owned4 && bytes.byteOffset === 0 && bytes.byteLength === bytes.buffer.byteLength;
|
|
25020
|
-
for (let
|
|
25021
|
-
const at = offset +
|
|
25103
|
+
for (let done5 = 0; done5 < bytes.length; ) {
|
|
25104
|
+
const at = offset + done5;
|
|
25022
25105
|
const index = Math.floor(at / CHUNK3);
|
|
25023
25106
|
const from = at - index * CHUNK3;
|
|
25024
|
-
const n = Math.min(CHUNK3 - from, bytes.length -
|
|
25107
|
+
const n = Math.min(CHUNK3 - from, bytes.length - done5);
|
|
25025
25108
|
if (whole && n === CHUNK3 && bytes.length === CHUNK3) this.chunks[index] = bytes;
|
|
25026
|
-
else this.room(index, from + n).set(bytes.subarray(
|
|
25027
|
-
|
|
25109
|
+
else this.room(index, from + n).set(bytes.subarray(done5, done5 + n), from);
|
|
25110
|
+
done5 += n;
|
|
25028
25111
|
}
|
|
25029
25112
|
this.size = Math.max(this.size, offset + bytes.length);
|
|
25030
25113
|
}
|
|
@@ -25528,9 +25611,9 @@ function parseArgs(args) {
|
|
|
25528
25611
|
break;
|
|
25529
25612
|
}
|
|
25530
25613
|
if (!arg.startsWith("-") || arg === "-") break;
|
|
25531
|
-
const
|
|
25532
|
-
if (typeof
|
|
25533
|
-
i +=
|
|
25614
|
+
const used2 = flags(parsed2, arg, args[i + 1]);
|
|
25615
|
+
if (typeof used2 === "string") return used2;
|
|
25616
|
+
i += used2;
|
|
25534
25617
|
}
|
|
25535
25618
|
parsed2.command = args.slice(i);
|
|
25536
25619
|
if (parsed2.list ? parsed2.command.length > 0 : parsed2.command.length === 0) return USAGE;
|
|
@@ -26560,9 +26643,9 @@ var Launcher = class {
|
|
|
26560
26643
|
const known = this.sameFiles.get(`${a}|${b}`);
|
|
26561
26644
|
if (known?.stamp === stamp) return known.same;
|
|
26562
26645
|
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
|
|
26646
|
+
const same2 = p.length === q.length && p.every((byte, i) => byte === q[i]);
|
|
26647
|
+
this.sameFiles.set(`${a}|${b}`, { stamp, same: same2 });
|
|
26648
|
+
return same2;
|
|
26566
26649
|
}
|
|
26567
26650
|
async wasmOwner(wasm, name2, scope) {
|
|
26568
26651
|
const leaf = baseName2(wasm);
|
|
@@ -26855,10 +26938,10 @@ var Launcher = class {
|
|
|
26855
26938
|
const drop = () => {
|
|
26856
26939
|
if (cache.get(key) === found) cache.delete(key);
|
|
26857
26940
|
};
|
|
26858
|
-
loading2.then((
|
|
26859
|
-
if (
|
|
26941
|
+
loading2.then((done5) => {
|
|
26942
|
+
if (done5.key === key || done5.key === void 0 && !key.includes("\0")) return;
|
|
26860
26943
|
drop();
|
|
26861
|
-
if (
|
|
26944
|
+
if (done5.key !== void 0 && revocations === this.revocations) cache.set(done5.key, found);
|
|
26862
26945
|
}, drop);
|
|
26863
26946
|
return found;
|
|
26864
26947
|
}
|
|
@@ -27003,17 +27086,17 @@ var Launcher = class {
|
|
|
27003
27086
|
await req.fds.closeAll();
|
|
27004
27087
|
throw err;
|
|
27005
27088
|
}
|
|
27006
|
-
const
|
|
27089
|
+
const done5 = this.heldUrl(program);
|
|
27007
27090
|
try {
|
|
27008
27091
|
const handle = await this.admitted(
|
|
27009
27092
|
program.abi !== "js",
|
|
27010
27093
|
req.fds,
|
|
27011
27094
|
(fds, quietOom) => this.start({ ...req, fds, quietOom, cwd, program, argv0: target.argv0, args, env })
|
|
27012
27095
|
);
|
|
27013
|
-
void handle.exited.finally(
|
|
27096
|
+
void handle.exited.finally(done5);
|
|
27014
27097
|
return handle;
|
|
27015
27098
|
} catch (err) {
|
|
27016
|
-
|
|
27099
|
+
done5();
|
|
27017
27100
|
throw err;
|
|
27018
27101
|
}
|
|
27019
27102
|
}
|
|
@@ -27556,8 +27639,8 @@ var Launcher = class {
|
|
|
27556
27639
|
const at = normalizePath(path);
|
|
27557
27640
|
this.unlinked.closed(at);
|
|
27558
27641
|
this.writers?.unlinked.closed(at);
|
|
27559
|
-
const
|
|
27560
|
-
if (!
|
|
27642
|
+
const open2 = [...this.openFiles].some((nodes) => nodes.writes(at)) || heldUnder(this.held, at);
|
|
27643
|
+
if (!open2) void this.mounts.commit(at).catch(() => void 0);
|
|
27561
27644
|
}
|
|
27562
27645
|
signalMasksOf(pid) {
|
|
27563
27646
|
const masks = this.processes.get(pid)?.signalMasks?.();
|
|
@@ -28013,7 +28096,7 @@ var Launcher = class {
|
|
|
28013
28096
|
(path) => this.mountRoot(path),
|
|
28014
28097
|
{
|
|
28015
28098
|
locks: webLocks(),
|
|
28016
|
-
busy: (path) => [...this.openFiles].some((
|
|
28099
|
+
busy: (path) => [...this.openFiles].some((open2) => open2.holds(path)),
|
|
28017
28100
|
owner: this.unlinkOwnerOption,
|
|
28018
28101
|
...this.owners ? { dirOwner: { uid: 0, gid: 0, mode: 448 } } : {}
|
|
28019
28102
|
}
|
|
@@ -28180,11 +28263,11 @@ function cronLocks() {
|
|
|
28180
28263
|
// src/pin.ts
|
|
28181
28264
|
function pinScript(url) {
|
|
28182
28265
|
try {
|
|
28183
|
-
const
|
|
28184
|
-
|
|
28185
|
-
|
|
28186
|
-
if (
|
|
28187
|
-
const source = `${
|
|
28266
|
+
const request3 = new XMLHttpRequest();
|
|
28267
|
+
request3.open("GET", url.href, false);
|
|
28268
|
+
request3.send();
|
|
28269
|
+
if (request3.status !== 200) return url.href;
|
|
28270
|
+
const source = `${request3.responseText}
|
|
28188
28271
|
//# sourceURL=${url.href}
|
|
28189
28272
|
`;
|
|
28190
28273
|
return URL.createObjectURL(new Blob([source], { type: "text/javascript" }));
|
|
@@ -28337,9 +28420,9 @@ var RemoteTransport = class {
|
|
|
28337
28420
|
waiter?.reject(new TransportError("the request was cancelled"));
|
|
28338
28421
|
this.port.postMessage({ net: "cancel", nid });
|
|
28339
28422
|
}
|
|
28340
|
-
async fetch(
|
|
28423
|
+
async fetch(request3) {
|
|
28341
28424
|
const nid = ++this.nextId;
|
|
28342
|
-
const { signal } =
|
|
28425
|
+
const { signal } = request3;
|
|
28343
28426
|
signal.throwIfAborted();
|
|
28344
28427
|
let finished = false;
|
|
28345
28428
|
const abort = () => {
|
|
@@ -28354,16 +28437,16 @@ var RemoteTransport = class {
|
|
|
28354
28437
|
finished = true;
|
|
28355
28438
|
signal.removeEventListener("abort", abort);
|
|
28356
28439
|
};
|
|
28357
|
-
if (
|
|
28440
|
+
if (request3.bodyStream) this.uploads.set(nid, request3.bodyStream[Symbol.asyncIterator]());
|
|
28358
28441
|
let head;
|
|
28359
28442
|
try {
|
|
28360
28443
|
head = await this.ask({
|
|
28361
28444
|
net: "fetch",
|
|
28362
28445
|
nid,
|
|
28363
|
-
url:
|
|
28364
|
-
method:
|
|
28365
|
-
headers:
|
|
28366
|
-
...
|
|
28446
|
+
url: request3.url,
|
|
28447
|
+
method: request3.method,
|
|
28448
|
+
headers: request3.headers,
|
|
28449
|
+
...request3.bodyStream ? { streamed: true } : request3.body ? { body: request3.body } : {}
|
|
28367
28450
|
});
|
|
28368
28451
|
} catch (e) {
|
|
28369
28452
|
finish();
|
|
@@ -28406,9 +28489,9 @@ var RemoteTransport = class {
|
|
|
28406
28489
|
}
|
|
28407
28490
|
};
|
|
28408
28491
|
}
|
|
28409
|
-
async websocket(
|
|
28492
|
+
async websocket(request3) {
|
|
28410
28493
|
const nid = ++this.nextId;
|
|
28411
|
-
const { signal } =
|
|
28494
|
+
const { signal } = request3;
|
|
28412
28495
|
signal.throwIfAborted();
|
|
28413
28496
|
const abort = () => this.cancel(nid);
|
|
28414
28497
|
signal.addEventListener("abort", abort, { once: true });
|
|
@@ -28417,9 +28500,9 @@ var RemoteTransport = class {
|
|
|
28417
28500
|
opened2 = await this.ask({
|
|
28418
28501
|
net: "ws-open",
|
|
28419
28502
|
nid,
|
|
28420
|
-
url:
|
|
28421
|
-
protocols:
|
|
28422
|
-
headers:
|
|
28503
|
+
url: request3.url,
|
|
28504
|
+
protocols: request3.protocols,
|
|
28505
|
+
headers: request3.headers
|
|
28423
28506
|
});
|
|
28424
28507
|
} finally {
|
|
28425
28508
|
signal.removeEventListener("abort", abort);
|
|
@@ -28489,6 +28572,12 @@ async function inOpfs(deps, root) {
|
|
|
28489
28572
|
const opfs = await deps.storage().catch(() => void 0);
|
|
28490
28573
|
return await opfs?.resolve(root).catch(() => null) != null;
|
|
28491
28574
|
}
|
|
28575
|
+
async function rootNamed(deps, req, root) {
|
|
28576
|
+
if (req.metadata !== void 0 || !req.root || !deps.rootId) return req;
|
|
28577
|
+
const top = await deps.storage().catch(() => void 0);
|
|
28578
|
+
const name2 = await metadataName(top, root, deps.rootId);
|
|
28579
|
+
return name2 === META_DB ? req : { ...req, metadata: name2 };
|
|
28580
|
+
}
|
|
28492
28581
|
function workers(deps) {
|
|
28493
28582
|
return {
|
|
28494
28583
|
createWorker: deps.createWorker,
|
|
@@ -28533,7 +28622,7 @@ function cdpOption(req, port) {
|
|
|
28533
28622
|
if (!req.cdp) return {};
|
|
28534
28623
|
return {
|
|
28535
28624
|
cdp: portCdpHook(
|
|
28536
|
-
(
|
|
28625
|
+
(request3, cdp) => port.postMessage({ cdpOpen: request3, port: cdp }, [cdp])
|
|
28537
28626
|
)
|
|
28538
28627
|
};
|
|
28539
28628
|
}
|
|
@@ -28543,7 +28632,7 @@ function pageHooks(req, port) {
|
|
|
28543
28632
|
function facadesOption(req, port) {
|
|
28544
28633
|
if (!req.facades) return {};
|
|
28545
28634
|
const hook = portFacadeHook(
|
|
28546
|
-
(
|
|
28635
|
+
(request3, facade) => port.postMessage({ facadeOpen: request3, port: facade }, [facade])
|
|
28547
28636
|
);
|
|
28548
28637
|
const facades = {};
|
|
28549
28638
|
for (const [name2, spec] of Object.entries(req.facades)) {
|
|
@@ -28745,6 +28834,7 @@ function serveKernel(port, deps) {
|
|
|
28745
28834
|
}
|
|
28746
28835
|
async function init(req) {
|
|
28747
28836
|
launcher = (req.root ? Promise.resolve(req.root) : deps.storage()).then(async (root) => {
|
|
28837
|
+
req = await rootNamed(deps, req, root);
|
|
28748
28838
|
const name2 = req.metadata ?? META_DB;
|
|
28749
28839
|
const { meta, media } = await stores(deps, name2, req.media);
|
|
28750
28840
|
const net = remotes(port, req);
|
|
@@ -28852,6 +28942,7 @@ serveKernel(globalThis, {
|
|
|
28852
28942
|
createDriverWorker: () => new Worker(driverWorker, { type: "module" }),
|
|
28853
28943
|
moduleUrl: blobModuleUrl,
|
|
28854
28944
|
metadata: (name2) => openMeta(name2, indexedDB),
|
|
28855
|
-
media: (name2) => openMedia(name2, indexedDB)
|
|
28945
|
+
media: (name2) => openMedia(name2, indexedDB),
|
|
28946
|
+
rootId: (root) => rootId(indexedDB, root)
|
|
28856
28947
|
});
|
|
28857
28948
|
//# sourceMappingURL=kernel-worker.js.map
|