@ai-ecoverse/slicc-kernel 1.13.0 → 1.14.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 +1 -1
- package/dist/kernel-worker.js +40 -5
- package/dist/kernel-worker.js.map +2 -2
- package/dist/node.js +40 -5
- package/dist/node.js.map +2 -2
- package/package.json +2 -1
package/dist/node.js
CHANGED
|
@@ -1168,9 +1168,28 @@ async function packages(fs, modules) {
|
|
|
1168
1168
|
}
|
|
1169
1169
|
return dirs;
|
|
1170
1170
|
}
|
|
1171
|
+
async function pnpmGlobalRoots(fs, home) {
|
|
1172
|
+
const roots = [];
|
|
1173
|
+
const global = `${home}/global`;
|
|
1174
|
+
for (const version of (await fs.readdir(global).catch(() => [])).sort()) {
|
|
1175
|
+
for (const group of (await fs.readdir(`${global}/${version}`).catch(() => [])).sort()) {
|
|
1176
|
+
const dir = `${global}/${version}/${group}`;
|
|
1177
|
+
const st = await fs.lstat(dir).catch(() => void 0);
|
|
1178
|
+
if (st?.isDirectory && await fs.exists(`${dir}/node_modules`))
|
|
1179
|
+
roots.push(`${dir}/node_modules`);
|
|
1180
|
+
}
|
|
1181
|
+
}
|
|
1182
|
+
return roots;
|
|
1183
|
+
}
|
|
1184
|
+
async function packagesIn(fs, roots) {
|
|
1185
|
+
const dirs = [];
|
|
1186
|
+
for (const root of typeof roots === "string" ? [roots] : roots)
|
|
1187
|
+
dirs.push(...await packages(fs, root));
|
|
1188
|
+
return dirs;
|
|
1189
|
+
}
|
|
1171
1190
|
async function scanCommands(fs, modules) {
|
|
1172
1191
|
const found = /* @__PURE__ */ new Map();
|
|
1173
|
-
for (const pkg of await
|
|
1192
|
+
for (const pkg of await packagesIn(fs, modules)) {
|
|
1174
1193
|
let manifest;
|
|
1175
1194
|
try {
|
|
1176
1195
|
manifest = JSON.parse(await fs.readFile(`${pkg}/package.json`));
|
|
@@ -1189,7 +1208,7 @@ async function scanCommands(fs, modules) {
|
|
|
1189
1208
|
}
|
|
1190
1209
|
async function scanFilesystems(fs, modules) {
|
|
1191
1210
|
const found = /* @__PURE__ */ new Map();
|
|
1192
|
-
for (const pkg of await
|
|
1211
|
+
for (const pkg of await packagesIn(fs, modules)) {
|
|
1193
1212
|
let manifest;
|
|
1194
1213
|
try {
|
|
1195
1214
|
manifest = JSON.parse(await fs.readFile(`${pkg}/package.json`));
|
|
@@ -6749,6 +6768,7 @@ function foreignImports(bytes) {
|
|
|
6749
6768
|
}
|
|
6750
6769
|
|
|
6751
6770
|
// src/launcher.ts
|
|
6771
|
+
var PNPM_HOME = "/home/.local/share/pnpm";
|
|
6752
6772
|
var COMMAND2 = /^\/(?:usr\/)?bin\/([^/]+)$/;
|
|
6753
6773
|
var PACKAGE_ROOT = /^(.*\/node_modules\/(?:@[^/]+\/)?[^/]+)\//;
|
|
6754
6774
|
var ENV_REFERENCE = /\$\{([A-Za-z_][A-Za-z0-9_]*)\}/g;
|
|
@@ -6838,6 +6858,7 @@ var Launcher = class {
|
|
|
6838
6858
|
ca;
|
|
6839
6859
|
transport;
|
|
6840
6860
|
watchers = new FsWatchers();
|
|
6861
|
+
pnpmHome;
|
|
6841
6862
|
mounts;
|
|
6842
6863
|
createDriverWorker;
|
|
6843
6864
|
openFiles = /* @__PURE__ */ new Set();
|
|
@@ -6854,6 +6875,7 @@ var Launcher = class {
|
|
|
6854
6875
|
this.base = this.watchers.wrap(this.mounts.wrap(options.fs));
|
|
6855
6876
|
this.createWorker = options.createWorker;
|
|
6856
6877
|
this.createDriverWorker = options.createDriverWorker;
|
|
6878
|
+
this.pnpmHome = options.env?.PNPM_HOME ?? PNPM_HOME;
|
|
6857
6879
|
this.modulesDir = options.modules ?? "/node_modules";
|
|
6858
6880
|
this.env = { ...networkEnv(), ...options.env };
|
|
6859
6881
|
this.ca = kernelCa(options.caStore ?? memoryCaStore());
|
|
@@ -6864,11 +6886,17 @@ var Launcher = class {
|
|
|
6864
6886
|
ca: this.ca
|
|
6865
6887
|
});
|
|
6866
6888
|
this.fs = withCommandDirs(this.base, async () => new Set((await this.commands()).keys()));
|
|
6889
|
+
this.watchers.watch([this.modulesDir, this.pnpmHome], { recursive: true }, () => {
|
|
6890
|
+
this.catalog = void 0;
|
|
6891
|
+
});
|
|
6867
6892
|
}
|
|
6868
6893
|
commands() {
|
|
6869
|
-
this.catalog ??= scanCommands(this.base,
|
|
6894
|
+
this.catalog ??= this.roots().then((roots) => scanCommands(this.base, roots));
|
|
6870
6895
|
return this.catalog;
|
|
6871
6896
|
}
|
|
6897
|
+
async roots() {
|
|
6898
|
+
return [this.modulesDir, ...await pnpmGlobalRoots(this.base, this.pnpmHome)];
|
|
6899
|
+
}
|
|
6872
6900
|
async resolve(file, argv0, cwd) {
|
|
6873
6901
|
const name2 = COMMAND2.exec(file)?.[1] ?? (file.includes("/") ? void 0 : file);
|
|
6874
6902
|
if (name2 !== void 0) {
|
|
@@ -7122,7 +7150,7 @@ var Launcher = class {
|
|
|
7122
7150
|
}
|
|
7123
7151
|
};
|
|
7124
7152
|
}
|
|
7125
|
-
const module = (await scanFilesystems(this.base, this.
|
|
7153
|
+
const module = (await scanFilesystems(this.base, await this.roots())).get(type);
|
|
7126
7154
|
if (!module) throw fsError("ENODEV", `unknown file system type ${type}`);
|
|
7127
7155
|
if (!this.createDriverWorker)
|
|
7128
7156
|
throw fsError("ENODEV", `this kernel cannot start ${type} drivers`);
|
|
@@ -7162,7 +7190,14 @@ var Launcher = class {
|
|
|
7162
7190
|
await writeCaFile(this.base, this.ca).catch(() => void 0);
|
|
7163
7191
|
}
|
|
7164
7192
|
environment(cwd, extra) {
|
|
7165
|
-
return {
|
|
7193
|
+
return {
|
|
7194
|
+
PATH: `/usr/bin:/bin:${this.pnpmHome}/bin`,
|
|
7195
|
+
HOME: "/home",
|
|
7196
|
+
PNPM_HOME: this.pnpmHome,
|
|
7197
|
+
...this.env,
|
|
7198
|
+
PWD: cwd,
|
|
7199
|
+
...extra
|
|
7200
|
+
};
|
|
7166
7201
|
}
|
|
7167
7202
|
async starting(argv, dir) {
|
|
7168
7203
|
this.catalog = void 0;
|