@ai-ecoverse/slicc-kernel 1.60.0 → 1.60.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 +1 -1
- package/dist/kernel-worker.js +102 -14
- package/dist/kernel-worker.js.map +3 -3
- package/dist/node-process-worker.js +1 -1
- package/dist/node-process-worker.js.map +2 -2
- package/dist/node.js +102 -14
- package/dist/node.js.map +3 -3
- package/dist/process-worker.js +1 -1
- package/dist/process-worker.js.map +2 -2
- package/package.json +1 -1
package/dist/node.js
CHANGED
|
@@ -2520,10 +2520,31 @@ var ERRNO_BY_DOM_ERROR = {
|
|
|
2520
2520
|
TypeError: "EINVAL",
|
|
2521
2521
|
NotAllowedError: "EACCES"
|
|
2522
2522
|
};
|
|
2523
|
-
|
|
2523
|
+
var reported = /* @__PURE__ */ new Set();
|
|
2524
|
+
function translate(err, path, op = "lookup", mapped = true) {
|
|
2524
2525
|
if (typeof err?.code === "string") return err;
|
|
2525
|
-
const
|
|
2526
|
-
|
|
2526
|
+
const raw = err?.name;
|
|
2527
|
+
const name2 = typeof raw === "string" ? raw : "Error";
|
|
2528
|
+
const code = mapped && ERRNO_BY_DOM_ERROR[name2] || "EIO";
|
|
2529
|
+
const error = Object.assign(fsError(code, path), { domName: name2, op, cause: err });
|
|
2530
|
+
if (code !== "EIO") return error;
|
|
2531
|
+
const detail = err?.message;
|
|
2532
|
+
error.message += ` (OPFS ${op}: ${name2}${typeof detail === "string" && detail ? `: ${detail}` : ""})`;
|
|
2533
|
+
if (!reported.has(`${name2}/${op}`)) {
|
|
2534
|
+
reported.add(`${name2}/${op}`);
|
|
2535
|
+
console.warn(
|
|
2536
|
+
`slicc-kernel: ${error.message}, reported as EIO; logged once per error and operation`
|
|
2537
|
+
);
|
|
2538
|
+
}
|
|
2539
|
+
return error;
|
|
2540
|
+
}
|
|
2541
|
+
var META_OPS = ["get", "update", "move", "remove", "links", "under", "all"];
|
|
2542
|
+
function sidecar(meta) {
|
|
2543
|
+
const pathOf = ([first]) => [first, "/"].flat().find((p) => typeof p === "string");
|
|
2544
|
+
const guarded = (op) => (...args) => meta[op].apply(meta, args).catch((err) => {
|
|
2545
|
+
throw translate(err, pathOf(args), "sidecar", false);
|
|
2546
|
+
});
|
|
2547
|
+
return Object.fromEntries(META_OPS.map((op) => [op, guarded(op)]));
|
|
2527
2548
|
}
|
|
2528
2549
|
function missing(err) {
|
|
2529
2550
|
const code = err?.code;
|
|
@@ -2608,7 +2629,7 @@ var OpfsFs = class {
|
|
|
2608
2629
|
owners = false;
|
|
2609
2630
|
constructor(root, meta = new MemoryMeta(), channel, options = {}) {
|
|
2610
2631
|
this.root = root;
|
|
2611
|
-
this.meta = meta;
|
|
2632
|
+
this.meta = sidecar(meta);
|
|
2612
2633
|
this.ranged = options.ranged === true;
|
|
2613
2634
|
this.channel = channel === void 0 ? void 0 : new BroadcastChannel(channel);
|
|
2614
2635
|
if (this.channel) {
|
|
@@ -2913,7 +2934,8 @@ var OpfsFs = class {
|
|
|
2913
2934
|
} catch (err) {
|
|
2914
2935
|
const name2 = err?.name;
|
|
2915
2936
|
const again = name2 === "NotReadableError" || locks && LOCKED.has(name2);
|
|
2916
|
-
if (!again || attempt >= READ_ATTEMPTS)
|
|
2937
|
+
if (!again || attempt >= READ_ATTEMPTS)
|
|
2938
|
+
throw translate(err, path, locks ? "write" : "read");
|
|
2917
2939
|
await new Promise((resolve) => setTimeout(resolve, attempt * 10));
|
|
2918
2940
|
}
|
|
2919
2941
|
}
|
|
@@ -2955,9 +2977,15 @@ var OpfsFs = class {
|
|
|
2955
2977
|
true
|
|
2956
2978
|
);
|
|
2957
2979
|
return {
|
|
2958
|
-
write: (at, bytes) => writable.write({ type: "write", position: at, data: bytes })
|
|
2959
|
-
|
|
2960
|
-
|
|
2980
|
+
write: (at, bytes) => writable.write({ type: "write", position: at, data: bytes }).catch((err) => {
|
|
2981
|
+
throw translate(err, path, "write", false);
|
|
2982
|
+
}),
|
|
2983
|
+
truncate: (size) => writable.truncate(size).catch((err) => {
|
|
2984
|
+
throw translate(err, path, "write", false);
|
|
2985
|
+
}),
|
|
2986
|
+
close: () => writable.close().catch((err) => {
|
|
2987
|
+
throw translate(err, path, "commit", false);
|
|
2988
|
+
})
|
|
2961
2989
|
};
|
|
2962
2990
|
}
|
|
2963
2991
|
async readFile(path) {
|
|
@@ -2992,9 +3020,13 @@ var OpfsFs = class {
|
|
|
2992
3020
|
const [file, existed, target] = await this.fileFor(path);
|
|
2993
3021
|
if (!existed) await this.stampNew(target, owner, false);
|
|
2994
3022
|
if (!existed && content.length === 0) return;
|
|
2995
|
-
|
|
2996
|
-
|
|
2997
|
-
|
|
3023
|
+
try {
|
|
3024
|
+
const writable = await file.createWritable();
|
|
3025
|
+
await writable.write(content);
|
|
3026
|
+
await writable.close();
|
|
3027
|
+
} catch (err) {
|
|
3028
|
+
throw translate(err, path, "commit", false);
|
|
3029
|
+
}
|
|
2998
3030
|
}
|
|
2999
3031
|
async listing(path) {
|
|
3000
3032
|
const found = await this.locate(path, true);
|
|
@@ -3270,6 +3302,49 @@ var OpfsFs = class {
|
|
|
3270
3302
|
return removed;
|
|
3271
3303
|
}
|
|
3272
3304
|
};
|
|
3305
|
+
var READS = [
|
|
3306
|
+
"stat",
|
|
3307
|
+
"lstat",
|
|
3308
|
+
"exists",
|
|
3309
|
+
"readFile",
|
|
3310
|
+
"readFileBuffer",
|
|
3311
|
+
"pread",
|
|
3312
|
+
"readdir",
|
|
3313
|
+
"readdirStat",
|
|
3314
|
+
"readlink",
|
|
3315
|
+
"realpath"
|
|
3316
|
+
];
|
|
3317
|
+
var WRITES = [
|
|
3318
|
+
"writeFile",
|
|
3319
|
+
"pwrite",
|
|
3320
|
+
"truncate",
|
|
3321
|
+
"writeSession",
|
|
3322
|
+
"mkdir",
|
|
3323
|
+
"rm",
|
|
3324
|
+
"link",
|
|
3325
|
+
"rename",
|
|
3326
|
+
"symlink",
|
|
3327
|
+
"chmod",
|
|
3328
|
+
"utimes",
|
|
3329
|
+
"lutimes",
|
|
3330
|
+
"chown"
|
|
3331
|
+
];
|
|
3332
|
+
for (const [names, op] of [
|
|
3333
|
+
[READS, "read"],
|
|
3334
|
+
[WRITES, "write"]
|
|
3335
|
+
]) {
|
|
3336
|
+
for (const name2 of names) {
|
|
3337
|
+
const proto = OpfsFs.prototype;
|
|
3338
|
+
const inner = proto[name2];
|
|
3339
|
+
proto[name2] = async function(...args) {
|
|
3340
|
+
try {
|
|
3341
|
+
return await inner.apply(this, args);
|
|
3342
|
+
} catch (err) {
|
|
3343
|
+
throw translate(err, String(args[0]), op, false);
|
|
3344
|
+
}
|
|
3345
|
+
};
|
|
3346
|
+
}
|
|
3347
|
+
}
|
|
3273
3348
|
|
|
3274
3349
|
// src/fs/unlinked.ts
|
|
3275
3350
|
var UNLINKED_DIR = ".slicc-unlinked";
|
|
@@ -6159,6 +6234,19 @@ function mkdirOptions(entry, mode = 511) {
|
|
|
6159
6234
|
const parents = 511 & ~(entry.umask?.() ?? 18) | 192;
|
|
6160
6235
|
return { recursive: true, owner: { ...owner, parents } };
|
|
6161
6236
|
}
|
|
6237
|
+
async function mkdirExclusive(entry, path, mode) {
|
|
6238
|
+
const { fs } = entry;
|
|
6239
|
+
const { owner } = mkdirOptions(entry, mode);
|
|
6240
|
+
const own = owner ? { owner } : {};
|
|
6241
|
+
try {
|
|
6242
|
+
await fs.mkdir(path, own);
|
|
6243
|
+
} catch (err) {
|
|
6244
|
+
if (err?.code !== "ENOENT") throw err;
|
|
6245
|
+
const above = owner ? { owner: { ...owner, mode: owner.parents } } : {};
|
|
6246
|
+
await fs.mkdir(path.slice(0, path.lastIndexOf("/")) || "/", { recursive: true, ...above });
|
|
6247
|
+
await fs.mkdir(path, own);
|
|
6248
|
+
}
|
|
6249
|
+
}
|
|
6162
6250
|
async function chown(entry, path, req) {
|
|
6163
6251
|
const cred = entry.cred?.();
|
|
6164
6252
|
if (!cred) {
|
|
@@ -6191,7 +6279,7 @@ async function run(entry, path, req) {
|
|
|
6191
6279
|
case "readdir-stat":
|
|
6192
6280
|
return json2(await readdirStat(fs, path));
|
|
6193
6281
|
case "mkdir":
|
|
6194
|
-
await fs.mkdir(path, mkdirOptions(entry, req.mode));
|
|
6282
|
+
await (req.exclusive ? mkdirExclusive(entry, path, req.mode) : fs.mkdir(path, mkdirOptions(entry, req.mode)));
|
|
6195
6283
|
return done;
|
|
6196
6284
|
case "rm":
|
|
6197
6285
|
await fs.rm(path, { recursive: true });
|
|
@@ -11091,9 +11179,9 @@ var Dying = class {
|
|
|
11091
11179
|
clear() {
|
|
11092
11180
|
clearTimeout(this.timer);
|
|
11093
11181
|
}
|
|
11094
|
-
status(
|
|
11182
|
+
status(reported2) {
|
|
11095
11183
|
if (this.ending) return [this.ending.code, this.ending.sig];
|
|
11096
|
-
return [typeof
|
|
11184
|
+
return [typeof reported2 === "number" ? reported2 : CRASHED, void 0];
|
|
11097
11185
|
}
|
|
11098
11186
|
};
|
|
11099
11187
|
function killThread(thread, caught, sig) {
|