@ai-ecoverse/slicc-kernel 1.167.4 → 1.168.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +9 -1
- package/dist/index.js.map +1 -1
- package/dist/kernel-worker.js +193 -77
- package/dist/kernel-worker.js.map +4 -4
- package/dist/meta.js +61 -2
- package/dist/meta.js.map +3 -3
- package/dist/node-process-worker.cjs +1 -1
- package/dist/node-process-worker.cjs.map +2 -2
- package/dist/node-process-worker.js +1 -1
- package/dist/node-process-worker.js.map +2 -2
- package/dist/node.js +347 -231
- package/dist/node.js.map +4 -4
- package/dist/process-worker.js +1 -1
- package/dist/process-worker.js.map +2 -2
- package/dist/types/fs/opfs.d.ts +1 -0
- package/dist/types/fs/remote.d.ts +1 -0
- package/dist/types/fs/types.d.ts +2 -0
- package/dist/types/kernel/replacing.d.ts +17 -0
- package/dist/types/launcher.d.ts +7 -0
- package/dist/types/meta.d.ts +4 -0
- package/package.json +3 -3
package/dist/kernel-worker.js
CHANGED
|
@@ -1753,9 +1753,11 @@ var OpfsFs = class {
|
|
|
1753
1753
|
this.channel.onmessage = ({ data }) => {
|
|
1754
1754
|
const { paths, trees, outside } = noticeOf(data);
|
|
1755
1755
|
for (const path of [...paths, ...trees]) this.forget(normalizePath(path));
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1756
|
+
if (!outside) remote?.emit({ paths, trees });
|
|
1757
|
+
else
|
|
1758
|
+
void this.noticed(paths.map(normalizePath), Date.now()).finally(
|
|
1759
|
+
() => remote?.emit({ paths, trees, outside: true })
|
|
1760
|
+
);
|
|
1759
1761
|
};
|
|
1760
1762
|
this.channel.unref?.();
|
|
1761
1763
|
}
|
|
@@ -2121,6 +2123,9 @@ var OpfsFs = class {
|
|
|
2121
2123
|
this.exact--;
|
|
2122
2124
|
}
|
|
2123
2125
|
}
|
|
2126
|
+
refresh(trees) {
|
|
2127
|
+
for (const tree2 of trees) this.forget(normalizePath(tree2));
|
|
2128
|
+
}
|
|
2124
2129
|
forget(path) {
|
|
2125
2130
|
this.changes++;
|
|
2126
2131
|
this.dirs.deleteTree(path);
|
|
@@ -7598,14 +7603,14 @@ var UserDb = class {
|
|
|
7598
7603
|
this.fs = fs;
|
|
7599
7604
|
this.owners = owners;
|
|
7600
7605
|
}
|
|
7601
|
-
async stampHome(row,
|
|
7606
|
+
async stampHome(row, shared2, homeMode) {
|
|
7602
7607
|
const home = this.fs.resolvePath("/", row.home);
|
|
7603
7608
|
if (!this.owners || !this.fs.chown || !HOME_DIR.test(home)) return;
|
|
7604
7609
|
if (!await this.realDir(home)) return;
|
|
7605
|
-
const gid =
|
|
7610
|
+
const gid = shared2?.gid ?? row.gid;
|
|
7606
7611
|
await this.fs.chown(home, { uid: row.uid, gid, follow: false, kind: "adopt" });
|
|
7607
7612
|
const scoop = row.name.startsWith("scoop-");
|
|
7608
|
-
await this.fs.chmod(home, homeMode ?? (
|
|
7613
|
+
await this.fs.chmod(home, homeMode ?? (shared2 ? 1512 : scoop ? 488 : 448));
|
|
7609
7614
|
const pnpm = `${home}/.local/share/pnpm`;
|
|
7610
7615
|
if (await this.realDir(pnpm)) await this.fs.chmod(pnpm, scoop ? 488 : 448);
|
|
7611
7616
|
}
|
|
@@ -7642,9 +7647,9 @@ var UserDb = class {
|
|
|
7642
7647
|
const [passwd, group] = await this.texts();
|
|
7643
7648
|
return { passwd: parsePasswd(passwd), group: parseGroup(group) };
|
|
7644
7649
|
}
|
|
7645
|
-
async provision(row, umask,
|
|
7646
|
-
const dirs = 511 & ~umask | (
|
|
7647
|
-
const gid =
|
|
7650
|
+
async provision(row, umask, shared2) {
|
|
7651
|
+
const dirs = 511 & ~umask | (shared2 ? 1024 : 0);
|
|
7652
|
+
const gid = shared2?.gid ?? row.gid;
|
|
7648
7653
|
const owner = this.owners ? { uid: row.uid, gid } : void 0;
|
|
7649
7654
|
const made2 = owner ? { recursive: true, owner: { ...owner, mode: dirs, parents: dirs } } : { recursive: true };
|
|
7650
7655
|
const pnpm = `${row.home}/.local/share/pnpm`;
|
|
@@ -7748,7 +7753,7 @@ var UserDb = class {
|
|
|
7748
7753
|
const users = parsed(passwd);
|
|
7749
7754
|
const groups = parsed(group);
|
|
7750
7755
|
const found = users.find((r) => r.name === name2);
|
|
7751
|
-
const
|
|
7756
|
+
const shared2 = homeGroupOf(groups, options.homeGroup);
|
|
7752
7757
|
const homeMode = homeModeOf(options.homeMode);
|
|
7753
7758
|
if (found) {
|
|
7754
7759
|
const more = groupsOf(groups, options.groups ?? []);
|
|
@@ -7756,8 +7761,8 @@ var UserDb = class {
|
|
|
7756
7761
|
throw fsError("EINVAL", `a user is no member of its own group ${name2}`);
|
|
7757
7762
|
}
|
|
7758
7763
|
if (found.uid >= FIRST_UID && found.uid <= LAST_UID) {
|
|
7759
|
-
await this.provision(found, this.umaskFor(options),
|
|
7760
|
-
await this.stampHome(found,
|
|
7764
|
+
await this.provision(found, this.umaskFor(options), shared2);
|
|
7765
|
+
await this.stampHome(found, shared2, homeMode);
|
|
7761
7766
|
}
|
|
7762
7767
|
if (joined(name2, more)) await this.fs.writeFile(GROUP, formatGroup(group));
|
|
7763
7768
|
remember();
|
|
@@ -7774,8 +7779,8 @@ var UserDb = class {
|
|
|
7774
7779
|
const fresh3 = !await this.fs.exists(home);
|
|
7775
7780
|
await this.fs.mkdir(home, { recursive: true });
|
|
7776
7781
|
try {
|
|
7777
|
-
await this.provision(row, this.umaskFor(options),
|
|
7778
|
-
await this.stampHome(row,
|
|
7782
|
+
await this.provision(row, this.umaskFor(options), shared2);
|
|
7783
|
+
await this.stampHome(row, shared2, homeMode);
|
|
7779
7784
|
await this.fs.mkdir("/etc", { recursive: true });
|
|
7780
7785
|
await this.commit(formatPasswd(passwd), formatGroup(group));
|
|
7781
7786
|
} catch (err) {
|
|
@@ -7824,10 +7829,10 @@ var UserDb = class {
|
|
|
7824
7829
|
);
|
|
7825
7830
|
for (const r of parsed(keptGroups)) r.members = r.members.filter((m) => m !== name2);
|
|
7826
7831
|
const home = this.fs.resolvePath("/", row.home);
|
|
7827
|
-
const
|
|
7832
|
+
const shared2 = parsed(passwd).some(
|
|
7828
7833
|
(r) => r !== row && this.fs.resolvePath("/", r.home) === home
|
|
7829
7834
|
);
|
|
7830
|
-
const removeHome = !options.keepHome && !
|
|
7835
|
+
const removeHome = !options.keepHome && !shared2 && HOME_DIR.test(home) && await this.fs.exists(home);
|
|
7831
7836
|
const staged = `/home/.${name2}.removed-${Date.now()}`;
|
|
7832
7837
|
await this.commit(
|
|
7833
7838
|
formatPasswd(passwd.filter((r) => r !== row)),
|
|
@@ -8492,7 +8497,7 @@ function satisfies(version, range2) {
|
|
|
8492
8497
|
}
|
|
8493
8498
|
|
|
8494
8499
|
// src/version.ts
|
|
8495
|
-
var KERNEL_VERSION = true ? "1.
|
|
8500
|
+
var KERNEL_VERSION = true ? "1.168.0" : "0.0.0-dev";
|
|
8496
8501
|
var OS_RELEASE = "6.0.0-slicc";
|
|
8497
8502
|
function procVersion() {
|
|
8498
8503
|
return `Linux version ${OS_RELEASE} (slicc-kernel ${KERNEL_VERSION}) #1 SMP PREEMPT_DYNAMIC
|
|
@@ -8575,8 +8580,8 @@ function abiOf(raw2, fallback) {
|
|
|
8575
8580
|
const abi = raw2 ?? fallback;
|
|
8576
8581
|
return abi === "emscripten" || abi === "wasi" || abi === "js" ? abi : void 0;
|
|
8577
8582
|
}
|
|
8578
|
-
function commandOf(pkg, name2, raw2, packageAbi,
|
|
8579
|
-
const withEnv = envFields({ ...
|
|
8583
|
+
function commandOf(pkg, name2, raw2, packageAbi, shared2) {
|
|
8584
|
+
const withEnv = envFields({ ...shared2, ...envOf(pkg, raw2.env) });
|
|
8580
8585
|
const script = inside(pkg, raw2.script);
|
|
8581
8586
|
if (script) {
|
|
8582
8587
|
return { name: name2, abi: packageAbi, glue: script, wasm: script, argv0: name2, script, ...withEnv };
|
|
@@ -8626,13 +8631,13 @@ function commandsOf(pkg, manifest) {
|
|
|
8626
8631
|
const packageAbi = abiOf(slicc.abi, "emscripten");
|
|
8627
8632
|
const entries = slicc.commands;
|
|
8628
8633
|
if (!packageAbi || !entries || typeof entries !== "object") return [];
|
|
8629
|
-
const
|
|
8634
|
+
const shared2 = envOf(pkg, slicc.env);
|
|
8630
8635
|
const out = [];
|
|
8631
8636
|
for (const [name2, raw2] of Object.entries(entries)) {
|
|
8632
8637
|
if (!commandName(name2) || !raw2 || typeof raw2 !== "object") {
|
|
8633
8638
|
continue;
|
|
8634
8639
|
}
|
|
8635
|
-
const command = commandOf(pkg, name2, raw2, packageAbi,
|
|
8640
|
+
const command = commandOf(pkg, name2, raw2, packageAbi, shared2);
|
|
8636
8641
|
if (command) out.push(command);
|
|
8637
8642
|
}
|
|
8638
8643
|
return out;
|
|
@@ -9793,8 +9798,8 @@ var UnlinkedKeeper = class {
|
|
|
9793
9798
|
void peers.ask(tab, { kept: { items: [], paths } }, PEER_RM_MS);
|
|
9794
9799
|
throw fsError("EBUSY", `${target}: open in another tab that did not answer`);
|
|
9795
9800
|
}
|
|
9796
|
-
const { whole, sends, shared } = await this.setAside(target, asked);
|
|
9797
|
-
return { whole, undoing: (op) => this.undoing(op, peers, sends, heard,
|
|
9801
|
+
const { whole, sends, shared: shared2 } = await this.setAside(target, asked);
|
|
9802
|
+
return { whole, undoing: (op) => this.undoing(op, peers, sends, heard, shared2) };
|
|
9798
9803
|
}
|
|
9799
9804
|
async setAside(target, asked) {
|
|
9800
9805
|
const mine = this.heldWithin(target);
|
|
@@ -9802,25 +9807,25 @@ var UnlinkedKeeper = class {
|
|
|
9802
9807
|
for (const { holders } of asked)
|
|
9803
9808
|
for (const { path } of holders) tabsOf.set(path, (tabsOf.get(path) ?? 0) + 1);
|
|
9804
9809
|
const done5 = /* @__PURE__ */ new Map();
|
|
9805
|
-
const
|
|
9810
|
+
const shared2 = [];
|
|
9806
9811
|
const sends = [];
|
|
9807
9812
|
for (const { tab, holders, paths } of asked) {
|
|
9808
9813
|
const items = [];
|
|
9809
9814
|
for (const holder of holders) {
|
|
9810
9815
|
if (!done5.has(holder.path)) {
|
|
9811
9816
|
const many = mine.has(holder.path) || (tabsOf.get(holder.path) ?? 0) > 1;
|
|
9812
|
-
done5.set(holder.path, await this.asideOne(holder, many, mine,
|
|
9817
|
+
done5.set(holder.path, await this.asideOne(holder, many, mine, shared2));
|
|
9813
9818
|
}
|
|
9814
9819
|
items.push({ path: holder.path, hidden: done5.get(holder.path), fid: holder.fid });
|
|
9815
9820
|
}
|
|
9816
9821
|
sends.push({ tab, items, paths });
|
|
9817
9822
|
}
|
|
9818
|
-
return { whole: done5.get(target) !== void 0, sends, shared };
|
|
9823
|
+
return { whole: done5.get(target) !== void 0, sends, shared: shared2 };
|
|
9819
9824
|
}
|
|
9820
|
-
async asideOne(holder, many, mine,
|
|
9825
|
+
async asideOne(holder, many, mine, shared2) {
|
|
9821
9826
|
if (!many) return this.asideFor(holder.path, holder.instance);
|
|
9822
9827
|
const one = await this.sharedAside(holder.path, mine);
|
|
9823
|
-
if (one)
|
|
9828
|
+
if (one) shared2.push(one);
|
|
9824
9829
|
return one?.hidden;
|
|
9825
9830
|
}
|
|
9826
9831
|
async sharedAside(path, mine) {
|
|
@@ -9865,16 +9870,16 @@ var UnlinkedKeeper = class {
|
|
|
9865
9870
|
sharedLocks() {
|
|
9866
9871
|
return this.locks;
|
|
9867
9872
|
}
|
|
9868
|
-
async undoing(op, peers, sends, heard,
|
|
9873
|
+
async undoing(op, peers, sends, heard, shared2 = []) {
|
|
9869
9874
|
let failed3;
|
|
9870
9875
|
let out;
|
|
9871
9876
|
try {
|
|
9872
9877
|
out = await op();
|
|
9873
9878
|
} catch (err) {
|
|
9874
9879
|
failed3 = err ?? new Error("failed");
|
|
9875
|
-
await this.rollBackAsides(sends,
|
|
9880
|
+
await this.rollBackAsides(sends, shared2);
|
|
9876
9881
|
}
|
|
9877
|
-
const hiddenShared = new Set(
|
|
9882
|
+
const hiddenShared = new Set(shared2.map((one) => one.hidden));
|
|
9878
9883
|
const answers2 = sends.map(({ tab, items, paths }) => {
|
|
9879
9884
|
const keeps = items.some((item) => item.hidden && hiddenShared.has(item.hidden));
|
|
9880
9885
|
return {
|
|
@@ -9885,7 +9890,7 @@ var UnlinkedKeeper = class {
|
|
|
9885
9890
|
await Promise.all(
|
|
9886
9891
|
answers2.map(({ told }, i) => heard[i] ? Promise.race([told, delay(PEER_RM_MS)]) : void 0)
|
|
9887
9892
|
);
|
|
9888
|
-
for (const one of
|
|
9893
|
+
for (const one of shared2) {
|
|
9889
9894
|
const waits = answers2.filter(
|
|
9890
9895
|
({ keeps }, i) => keeps && sends[i]?.items.some((item) => item.hidden === one.hidden)
|
|
9891
9896
|
);
|
|
@@ -9895,7 +9900,7 @@ var UnlinkedKeeper = class {
|
|
|
9895
9900
|
if (failed3 !== void 0) throw failed3;
|
|
9896
9901
|
return out;
|
|
9897
9902
|
}
|
|
9898
|
-
async rollBackAsides(sends,
|
|
9903
|
+
async rollBackAsides(sends, shared2) {
|
|
9899
9904
|
const back = /* @__PURE__ */ new Map();
|
|
9900
9905
|
for (const item of sends.flatMap((send2) => send2.items)) {
|
|
9901
9906
|
const { hidden, path } = item;
|
|
@@ -9903,7 +9908,7 @@ var UnlinkedKeeper = class {
|
|
|
9903
9908
|
if (!back.has(hidden)) back.set(hidden, await this.moveBack(hidden, path));
|
|
9904
9909
|
if (back.get(hidden)) item.hidden = void 0;
|
|
9905
9910
|
}
|
|
9906
|
-
for (const { hidden, path, local: local2, file } of
|
|
9911
|
+
for (const { hidden, path, local: local2, file } of shared2) {
|
|
9907
9912
|
if (!back.get(hidden) || !file) continue;
|
|
9908
9913
|
for (const holder of local2) {
|
|
9909
9914
|
holder.unkeep(path, file);
|
|
@@ -13144,8 +13149,8 @@ var CwdTable = class {
|
|
|
13144
13149
|
this.inodeOf = inodeOf2;
|
|
13145
13150
|
}
|
|
13146
13151
|
async hold(path, from) {
|
|
13147
|
-
const
|
|
13148
|
-
if (
|
|
13152
|
+
const shared2 = from === void 0 ? void 0 : this.held.get(from);
|
|
13153
|
+
if (shared2 && shared2.path === path) return this.share(from);
|
|
13149
13154
|
const ino = await this.inodeOf(path).catch(() => void 0);
|
|
13150
13155
|
const slot2 = this.free.pop() ?? (this.next < UNTRACKED ? this.next++ : UNTRACKED);
|
|
13151
13156
|
if (slot2 === UNTRACKED) return slot2;
|
|
@@ -17509,13 +17514,13 @@ async function flock(req, ctx) {
|
|
|
17509
17514
|
if (!FLOCK_KINDS.has(req.kind)) throw new KernelError("EINVAL");
|
|
17510
17515
|
const { key, owner } = await flockOf(req.fd);
|
|
17511
17516
|
const granted2 = req.kind !== "unlock";
|
|
17512
|
-
const
|
|
17513
|
-
if (
|
|
17517
|
+
const shared2 = locks.shared?.() === true;
|
|
17518
|
+
if (shared2 && !granted2) await ctx.settle?.(req.fd, false);
|
|
17514
17519
|
if (req.kind !== "unlock" && req.wait)
|
|
17515
17520
|
await locks.flocks.wait(key, owner, req.kind, ctx.blocking);
|
|
17516
17521
|
else if (!await locks.flocks.set(key, owner, req.kind)) throw new KernelError("EAGAIN");
|
|
17517
|
-
if (
|
|
17518
|
-
return
|
|
17522
|
+
if (shared2 && granted2) await grantedAcross(ctx, req.fd);
|
|
17523
|
+
return shared2 ? json3(true) : done3;
|
|
17519
17524
|
}
|
|
17520
17525
|
async function grantedAcross(ctx, fd) {
|
|
17521
17526
|
ctx.locks?.fresh?.();
|
|
@@ -17543,15 +17548,15 @@ async function recordLock2(req, ctx) {
|
|
|
17543
17548
|
return json3({ kind: held.kind, pid: held.owner, start: held.start, len });
|
|
17544
17549
|
}
|
|
17545
17550
|
const granted2 = req.kind !== "unlock";
|
|
17546
|
-
const
|
|
17547
|
-
const fd =
|
|
17551
|
+
const shared2 = locks.shared?.() === true;
|
|
17552
|
+
const fd = shared2 ? req.fd : void 0;
|
|
17548
17553
|
if (!granted2 && fd !== void 0) await ctx.settle?.(fd, false);
|
|
17549
17554
|
if (req.kind !== "unlock" && req.wait)
|
|
17550
17555
|
await locks.wait(key, owner, req.kind, range2, ctx.blocking);
|
|
17551
17556
|
else if (!await locks.set(key, owner, req.kind, range2.start, range2.end))
|
|
17552
17557
|
throw new KernelError("EAGAIN");
|
|
17553
|
-
if (granted2 &&
|
|
17554
|
-
return
|
|
17558
|
+
if (granted2 && shared2) await grantedAcross(ctx, fd);
|
|
17559
|
+
return shared2 ? json3(true) : done3;
|
|
17555
17560
|
}
|
|
17556
17561
|
|
|
17557
17562
|
// src/kernel/net/loopback-transport.ts
|
|
@@ -23791,9 +23796,9 @@ function pausing(signal) {
|
|
|
23791
23796
|
return { pausedAt, select };
|
|
23792
23797
|
}
|
|
23793
23798
|
async function serveSecure(proc, socket, req) {
|
|
23794
|
-
const
|
|
23795
|
-
if (req.listener && !
|
|
23796
|
-
const server =
|
|
23799
|
+
const shared2 = req.listener?.serving;
|
|
23800
|
+
if (req.listener && !shared2) throw new KernelError("EINVAL", "the listener has no tls");
|
|
23801
|
+
const server = shared2 ?? await serverOf(proc, req);
|
|
23797
23802
|
const { engine, leaf, alpn, store, flags: flags2 } = server;
|
|
23798
23803
|
const limit = handshakeSignal(proc, server.timeoutMs);
|
|
23799
23804
|
const { pausedAt, select } = pausing(limit.signal);
|
|
@@ -23807,12 +23812,12 @@ async function serveSecure(proc, socket, req) {
|
|
|
23807
23812
|
(flags2 & TLS_KEYLOG) !== 0
|
|
23808
23813
|
),
|
|
23809
23814
|
limit.signal,
|
|
23810
|
-
(reason) => !
|
|
23815
|
+
(reason) => !shared2 && reason === timedOut
|
|
23811
23816
|
).finally(() => {
|
|
23812
23817
|
limit.done();
|
|
23813
23818
|
selections.delete(socket);
|
|
23814
23819
|
socket.pending = void 0;
|
|
23815
|
-
if (!
|
|
23820
|
+
if (!shared2) server.release();
|
|
23816
23821
|
});
|
|
23817
23822
|
run2.catch(() => void 0);
|
|
23818
23823
|
const first = await Promise.race([run2, pausedAt.then((pause2) => ({ pause: pause2 }))]);
|
|
@@ -29047,6 +29052,39 @@ var RenameLog = class {
|
|
|
29047
29052
|
}
|
|
29048
29053
|
};
|
|
29049
29054
|
|
|
29055
|
+
// src/kernel/replacing.ts
|
|
29056
|
+
var REPLACING_LOCK = "slicc-kernel-replacing:v1:";
|
|
29057
|
+
function replacingLocks(scope = globalThis) {
|
|
29058
|
+
const locks = scope.navigator?.locks;
|
|
29059
|
+
return typeof locks?.request === "function" ? locks : void 0;
|
|
29060
|
+
}
|
|
29061
|
+
function replacingLock(metadata, root) {
|
|
29062
|
+
return `${REPLACING_LOCK}${metadata}:${root}`;
|
|
29063
|
+
}
|
|
29064
|
+
function shared(locks, names2, run2, waited) {
|
|
29065
|
+
const [name2, ...rest2] = names2;
|
|
29066
|
+
if (name2 === void 0) return run2(waited);
|
|
29067
|
+
const next3 = (after) => shared(locks, rest2, run2, after);
|
|
29068
|
+
return locks.request(
|
|
29069
|
+
name2,
|
|
29070
|
+
{ mode: "shared", ifAvailable: true },
|
|
29071
|
+
(lock) => lock ? next3(waited) : locks.request(name2, { mode: "shared" }, () => next3(true))
|
|
29072
|
+
);
|
|
29073
|
+
}
|
|
29074
|
+
var PackageLocks = class {
|
|
29075
|
+
locks;
|
|
29076
|
+
metadata;
|
|
29077
|
+
constructor(metadata, locks = replacingLocks()) {
|
|
29078
|
+
this.metadata = metadata;
|
|
29079
|
+
this.locks = locks;
|
|
29080
|
+
}
|
|
29081
|
+
loading(roots, run2) {
|
|
29082
|
+
if (!this.locks || roots.length === 0) return run2(false);
|
|
29083
|
+
const names2 = roots.map((root) => replacingLock(this.metadata, root));
|
|
29084
|
+
return shared(this.locks, names2, run2, false);
|
|
29085
|
+
}
|
|
29086
|
+
};
|
|
29087
|
+
|
|
29050
29088
|
// src/kernel/settling.ts
|
|
29051
29089
|
var SETUP_OPS = /* @__PURE__ */ new Set([
|
|
29052
29090
|
"proc-list",
|
|
@@ -31297,6 +31335,7 @@ var COMMAND2 = /^\/(?:usr\/)?bin\/([^/]+)$/;
|
|
|
31297
31335
|
var SHIM_MARKER = /^\/\/ pnpm-wasm-shim=(\{.*\})$/gm;
|
|
31298
31336
|
var SHIM_MAX = 64 * 1024;
|
|
31299
31337
|
var PACKAGE_ROOT = /^(.*\/node_modules\/(?:@[^/]+\/)?[^/]+)\//;
|
|
31338
|
+
var NODE_MODULES = /\/node_modules(?:\/|$)/;
|
|
31300
31339
|
var ENV_REFERENCE = /\$\{([A-Za-z_][A-Za-z0-9_]*)\}/g;
|
|
31301
31340
|
var WASM_MAGIC = [0, 97, 115, 109];
|
|
31302
31341
|
var SHEBANG_MAX = 256;
|
|
@@ -31364,6 +31403,21 @@ function packageRootOf(path, roots) {
|
|
|
31364
31403
|
}
|
|
31365
31404
|
return void 0;
|
|
31366
31405
|
}
|
|
31406
|
+
function planFiles(planned) {
|
|
31407
|
+
const { target } = planned;
|
|
31408
|
+
const files = [
|
|
31409
|
+
target.glue,
|
|
31410
|
+
target.wasm,
|
|
31411
|
+
target.imports,
|
|
31412
|
+
target.copy,
|
|
31413
|
+
...(target.variants ?? []).map((variant) => variant.wasm),
|
|
31414
|
+
...planned.sources ?? []
|
|
31415
|
+
];
|
|
31416
|
+
return files.filter((file) => file !== void 0);
|
|
31417
|
+
}
|
|
31418
|
+
function sameList(a, b) {
|
|
31419
|
+
return a.length === b.length && a.every((item, i) => item === b[i]);
|
|
31420
|
+
}
|
|
31367
31421
|
function modulePath(glue) {
|
|
31368
31422
|
return glue.endsWith(".js") ? `${glue.slice(0, -3)}.wasm` : `${glue}.wasm`;
|
|
31369
31423
|
}
|
|
@@ -31537,6 +31591,7 @@ var Launcher = class {
|
|
|
31537
31591
|
sudoer;
|
|
31538
31592
|
jobs = new JobTable();
|
|
31539
31593
|
locks;
|
|
31594
|
+
packageLocks;
|
|
31540
31595
|
fifos = new FifoTable();
|
|
31541
31596
|
memories;
|
|
31542
31597
|
sems = new SemTable();
|
|
@@ -31609,6 +31664,7 @@ var Launcher = class {
|
|
|
31609
31664
|
this.memories = memoriesOf(options.wasmMemories);
|
|
31610
31665
|
this.rootFs = options.fs;
|
|
31611
31666
|
this.locks = kernelLocks(options.fs.rootName, this.flushingPeers(options.fs));
|
|
31667
|
+
this.packageLocks = new PackageLocks(options.packageLocks ?? META_DB);
|
|
31612
31668
|
this.dac = this.usersMode === "off" ? void 0 : new Dac(this.usersMode, options.onDenial);
|
|
31613
31669
|
if (this.dac) this.wireDac(this.dac);
|
|
31614
31670
|
this.clipboard = new ClipboardBroker(
|
|
@@ -31702,15 +31758,7 @@ var Launcher = class {
|
|
|
31702
31758
|
this.nodes.keepsOnDisk = true;
|
|
31703
31759
|
this.openFiles.add(this.nodes);
|
|
31704
31760
|
options.fs.onPeer?.(() => this.flushOpen());
|
|
31705
|
-
options.fs.remoteChanges?.((change) =>
|
|
31706
|
-
this.held.doubt(change.paths, change.moved?.to);
|
|
31707
|
-
if (change.moved) this.moved(change.moved.from, change.moved.to);
|
|
31708
|
-
this.changes.flush();
|
|
31709
|
-
this.cwds.touched(change.paths, change.trees);
|
|
31710
|
-
this.rewritten(change.paths, change.trees);
|
|
31711
|
-
this.watchers.heard(change.content ? "change" : "rename", change.paths);
|
|
31712
|
-
this.watchers.heard("rename", change.trees ?? []);
|
|
31713
|
-
});
|
|
31761
|
+
options.fs.remoteChanges?.((change) => this.remoteChanged(change));
|
|
31714
31762
|
const holders = [this.held, this.openFiles];
|
|
31715
31763
|
options.fs.heldBy?.(
|
|
31716
31764
|
(dir) => holders.flatMap((set3) => [...set3].flatMap((holder) => [...holder.held()])).filter((p) => p.startsWith(`${dir}/`) && this.mounts.locate(p) === void 0)
|
|
@@ -31920,6 +31968,26 @@ var Launcher = class {
|
|
|
31920
31968
|
}
|
|
31921
31969
|
return trusted;
|
|
31922
31970
|
}
|
|
31971
|
+
remoteChanged(change) {
|
|
31972
|
+
this.held.doubt(change.paths, change.moved?.to);
|
|
31973
|
+
if (change.moved) this.moved(change.moved.from, change.moved.to);
|
|
31974
|
+
this.changes.flush();
|
|
31975
|
+
this.cwds.touched(change.paths, change.trees);
|
|
31976
|
+
this.rewritten(change.paths, change.trees);
|
|
31977
|
+
this.watchers.heard(change.content ? "change" : "rename", change.paths);
|
|
31978
|
+
this.watchers.heard("rename", change.trees ?? []);
|
|
31979
|
+
if (change.outside && this.catalogChanged([...change.paths, ...change.trees ?? []])) {
|
|
31980
|
+
this.resetCatalogs();
|
|
31981
|
+
}
|
|
31982
|
+
}
|
|
31983
|
+
catalogChanged(paths) {
|
|
31984
|
+
const roots = [this.modulesDir, this.pnpmHome, ...this.appended].map(normalizePath);
|
|
31985
|
+
return paths.map(normalizePath).some(
|
|
31986
|
+
(at) => at === "/" || NODE_MODULES.test(at) || roots.some(
|
|
31987
|
+
(root) => at === root || at.startsWith(`${root}/`) || root.startsWith(`${at}/`)
|
|
31988
|
+
)
|
|
31989
|
+
);
|
|
31990
|
+
}
|
|
31923
31991
|
resetCatalogs() {
|
|
31924
31992
|
this.catalogs.clear();
|
|
31925
31993
|
this.ownCatalogs.clear();
|
|
@@ -32320,7 +32388,11 @@ var Launcher = class {
|
|
|
32320
32388
|
secrets.push({ name: name2, value: value2, placeholder });
|
|
32321
32389
|
}
|
|
32322
32390
|
const scrub = scrubberOf(secrets);
|
|
32323
|
-
|
|
32391
|
+
const recheck = async (next3) => {
|
|
32392
|
+
const same3 = sameList(planFiles(next3), planFiles(planned)) && sameList(await this.interpreterChain(next3, booked.cwd, scope), interpreters) && (this.usersMode === "enforce" && await this.trustedFiles(next3, req.file, booked.cwd, scope)) === trusted;
|
|
32393
|
+
if (!same3) throw new SpawnError("EACCES");
|
|
32394
|
+
};
|
|
32395
|
+
return { env, pid, cwd: booked.cwd, ...scrub ? { scrub } : {}, recheck };
|
|
32324
32396
|
}
|
|
32325
32397
|
async interpreterChain(planned, cwd, scope) {
|
|
32326
32398
|
const out = [];
|
|
@@ -32605,25 +32677,16 @@ var Launcher = class {
|
|
|
32605
32677
|
async launch(asked, req) {
|
|
32606
32678
|
const cwd = await physicalPathAsync(this.base, req.cwd);
|
|
32607
32679
|
const seen = { ...req.env, HOSTNAME: this.hostname, cwd };
|
|
32608
|
-
const env = { ...expandDefaults(asked.target.env, seen), ...req.env };
|
|
32609
|
-
for (const key of asked.target.unset ?? []) delete env[key];
|
|
32610
|
-
delete env[TICKET_ENV];
|
|
32611
|
-
const own = env.HOSTNAME;
|
|
32612
|
-
if (asked.target.abi === "wasi") env.HOSTNAME = this.hostname;
|
|
32613
|
-
const planned = chosen2(asked, env);
|
|
32614
|
-
const { target, args } = planned;
|
|
32615
|
-
let program;
|
|
32616
|
-
let exeId;
|
|
32617
32680
|
await this.pnpmReady();
|
|
32681
|
+
let loaded;
|
|
32618
32682
|
try {
|
|
32619
|
-
|
|
32620
|
-
if (this.integrity) await this.checkedSources(planned, caller);
|
|
32621
|
-
[program, exeId] = await this.loaded(target, env, caller);
|
|
32622
|
-
if (readsEtcHostname(program)) setOrDrop(env, "HOSTNAME", own);
|
|
32683
|
+
loaded = await this.loadedUnder(asked, (planned2) => this.loadPlanned(planned2, req, seen));
|
|
32623
32684
|
} catch (err) {
|
|
32624
32685
|
await req.fds.closeAll();
|
|
32625
32686
|
throw err;
|
|
32626
32687
|
}
|
|
32688
|
+
const { planned, env, program, exeId } = loaded;
|
|
32689
|
+
const { target, args } = planned;
|
|
32627
32690
|
const done5 = this.heldUrl(program);
|
|
32628
32691
|
try {
|
|
32629
32692
|
const cwdSlot = await this.cwds.hold(cwd, req.cwdFrom);
|
|
@@ -32651,6 +32714,52 @@ var Launcher = class {
|
|
|
32651
32714
|
throw err;
|
|
32652
32715
|
}
|
|
32653
32716
|
}
|
|
32717
|
+
async loadPlanned(asked, req, seen) {
|
|
32718
|
+
const env = { ...expandDefaults(asked.target.env, seen), ...req.env };
|
|
32719
|
+
for (const key of asked.target.unset ?? []) delete env[key];
|
|
32720
|
+
delete env[TICKET_ENV];
|
|
32721
|
+
const own = env.HOSTNAME;
|
|
32722
|
+
if (asked.target.abi === "wasi") env.HOSTNAME = this.hostname;
|
|
32723
|
+
const planned = chosen2(asked, env);
|
|
32724
|
+
const caller = { pid: req.ppid ?? 0, uid: req.cred.euid, tag: req.tags?.[0] };
|
|
32725
|
+
if (this.integrity) await this.checkedSources(planned, caller);
|
|
32726
|
+
const [program, exeId] = await this.loaded(planned.target, env, caller);
|
|
32727
|
+
if (readsEtcHostname(program)) setOrDrop(env, "HOSTNAME", own);
|
|
32728
|
+
return { planned, env, program, exeId };
|
|
32729
|
+
}
|
|
32730
|
+
packageRoots(planned) {
|
|
32731
|
+
const packages2 = [this.modulesDir, ...this.appended];
|
|
32732
|
+
const roots = /* @__PURE__ */ new Set();
|
|
32733
|
+
for (const file of planFiles(planned)) {
|
|
32734
|
+
if (!file.startsWith("/")) continue;
|
|
32735
|
+
const at = normalizePath(file);
|
|
32736
|
+
const root = PACKAGE_ROOT.exec(at)?.[1] ?? packageRootOf(at, packages2);
|
|
32737
|
+
if (root !== void 0 && root !== at) roots.add(root);
|
|
32738
|
+
}
|
|
32739
|
+
return [...roots].sort();
|
|
32740
|
+
}
|
|
32741
|
+
async loadedUnder(asked, load) {
|
|
32742
|
+
const { replan, recheck } = asked;
|
|
32743
|
+
let planned = asked;
|
|
32744
|
+
let roots = this.packageRoots(planned);
|
|
32745
|
+
let stale = false;
|
|
32746
|
+
for (; ; ) {
|
|
32747
|
+
const held = roots;
|
|
32748
|
+
const done5 = await this.packageLocks.loading(held, async (waited) => {
|
|
32749
|
+
if (!waited && !stale) return { value: await load(planned) };
|
|
32750
|
+
this.rootFs.refresh?.(held);
|
|
32751
|
+
this.resetCatalogs();
|
|
32752
|
+
if (replan) planned = await replan() ?? planned;
|
|
32753
|
+
await recheck?.(planned);
|
|
32754
|
+
const now = this.packageRoots(planned);
|
|
32755
|
+
if (now.every((root) => held.includes(root))) return { value: await load(planned) };
|
|
32756
|
+
roots = [.../* @__PURE__ */ new Set([...held, ...now])].sort();
|
|
32757
|
+
stale = true;
|
|
32758
|
+
return void 0;
|
|
32759
|
+
});
|
|
32760
|
+
if (done5) return done5.value;
|
|
32761
|
+
}
|
|
32762
|
+
}
|
|
32654
32763
|
groupSession(pgid) {
|
|
32655
32764
|
return this.jobs.sessionOf(pgid);
|
|
32656
32765
|
}
|
|
@@ -33079,7 +33188,7 @@ var Launcher = class {
|
|
|
33079
33188
|
const scope = grant ? "" : await this.scopeOf(cred.euid);
|
|
33080
33189
|
const file = booked === void 0 ? req.file : await this.ticketFile(req, fds);
|
|
33081
33190
|
const planned = await this.checkedPlan({ ...req, file }, { ppid, cred, scope }, fds);
|
|
33082
|
-
const redeemed = await this.redeemed(
|
|
33191
|
+
const { recheck, ...redeemed } = await this.redeemed(
|
|
33083
33192
|
{ ...req, file },
|
|
33084
33193
|
{ ppid, cred, scope, booked },
|
|
33085
33194
|
planned,
|
|
@@ -33087,7 +33196,9 @@ var Launcher = class {
|
|
|
33087
33196
|
);
|
|
33088
33197
|
const exec = req.exec ? { exec: true } : {};
|
|
33089
33198
|
const deciding = req.exec ? void 0 : this.undecided(ppid);
|
|
33090
|
-
const
|
|
33199
|
+
const replan = () => this.planOrSearch({ ...req, file }, { ppid, cred, scope });
|
|
33200
|
+
const again = { ...planned, replan, recheck };
|
|
33201
|
+
const handle = await this.launch(again, {
|
|
33091
33202
|
...deciding ? { decided: deciding.promise } : {},
|
|
33092
33203
|
cwd: req.cwd,
|
|
33093
33204
|
cwdFrom: inheritedCwd(req.chdir, this.cwdSlots.get(ppid)),
|
|
@@ -33981,9 +34092,13 @@ var Launcher = class {
|
|
|
33981
34092
|
const file = await this.execFile(argv[0] ?? "", cwd, this.execGuard(credOf(account), 0, tag));
|
|
33982
34093
|
if (!await this.base.exists(cwd))
|
|
33983
34094
|
await this.stackFor(tags, base).fs.mkdir(cwd, { recursive: true });
|
|
33984
|
-
const
|
|
33985
|
-
|
|
33986
|
-
|
|
34095
|
+
const plan = async () => {
|
|
34096
|
+
const found = await this.plan(file, argv, cwd, scope);
|
|
34097
|
+
await this.mayExec(credOf(account), { file, cwd, pid: 0, tag }, found);
|
|
34098
|
+
return found;
|
|
34099
|
+
};
|
|
34100
|
+
const planned = await plan();
|
|
34101
|
+
return { cwd, file, planned: planned && { ...planned, replan: plan } };
|
|
33987
34102
|
}
|
|
33988
34103
|
async openTerminal(argv, options) {
|
|
33989
34104
|
const tagged = tagsOption(options);
|
|
@@ -34707,6 +34822,7 @@ function serveKernel(port, deps) {
|
|
|
34707
34822
|
await fs.reconcile();
|
|
34708
34823
|
const started = new Launcher({
|
|
34709
34824
|
fs,
|
|
34825
|
+
...name2 ? { packageLocks: name2 } : {},
|
|
34710
34826
|
...workers(deps),
|
|
34711
34827
|
...req.modules ? { modules: req.modules } : {},
|
|
34712
34828
|
...req.commands ? { commands: req.commands } : {},
|