@ai-ecoverse/slicc-kernel 1.1.0 → 1.2.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 +20 -2
- package/dist/index.js +2 -1
- package/dist/index.js.map +2 -2
- package/dist/kernel-worker.js +504 -106
- package/dist/kernel-worker.js.map +4 -4
- package/dist/process-worker.js +33 -17
- package/dist/process-worker.js.map +3 -3
- package/package.json +5 -6
package/dist/process-worker.js
CHANGED
|
@@ -55,6 +55,20 @@ var SIGNAL_BY_NAME = {
|
|
|
55
55
|
SIGCONT: SIG.CONT
|
|
56
56
|
};
|
|
57
57
|
|
|
58
|
+
// src/fs/types.ts
|
|
59
|
+
function inodeOf(path) {
|
|
60
|
+
let h1 = 3735928559;
|
|
61
|
+
let h2 = 1103547991;
|
|
62
|
+
for (let i = 0; i < path.length; i++) {
|
|
63
|
+
const c = path.charCodeAt(i);
|
|
64
|
+
h1 = Math.imul(h1 ^ c, 2654435761);
|
|
65
|
+
h2 = Math.imul(h2 ^ c, 1597334677);
|
|
66
|
+
}
|
|
67
|
+
h1 = Math.imul(h1 ^ h1 >>> 16, 2246822507) ^ Math.imul(h2 ^ h2 >>> 13, 3266489909);
|
|
68
|
+
h2 = Math.imul(h2 ^ h2 >>> 16, 2246822507) ^ Math.imul(h1 ^ h1 >>> 13, 3266489909);
|
|
69
|
+
return 4294967296 * (2097151 & h2) + (h1 >>> 0) || 1;
|
|
70
|
+
}
|
|
71
|
+
|
|
58
72
|
// src/realm/live-vfs-fs.ts
|
|
59
73
|
var ERRNO_BY_CODE = {
|
|
60
74
|
EACCES: 2,
|
|
@@ -103,18 +117,6 @@ function liveNodePath(node) {
|
|
|
103
117
|
const root = node.mount.opts.root.replace(/\/+$/, "");
|
|
104
118
|
return parts.length === 0 ? root || "/" : `${root}/${parts.reverse().join("/")}`;
|
|
105
119
|
}
|
|
106
|
-
function inodeOf(path) {
|
|
107
|
-
let h1 = 3735928559;
|
|
108
|
-
let h2 = 1103547991;
|
|
109
|
-
for (let i = 0; i < path.length; i++) {
|
|
110
|
-
const c = path.charCodeAt(i);
|
|
111
|
-
h1 = Math.imul(h1 ^ c, 2654435761);
|
|
112
|
-
h2 = Math.imul(h2 ^ c, 1597334677);
|
|
113
|
-
}
|
|
114
|
-
h1 = Math.imul(h1 ^ h1 >>> 16, 2246822507) ^ Math.imul(h2 ^ h2 >>> 13, 3266489909);
|
|
115
|
-
h2 = Math.imul(h2 ^ h2 >>> 16, 2246822507) ^ Math.imul(h1 ^ h1 >>> 13, 3266489909);
|
|
116
|
-
return 4294967296 * (2097151 & h2) + (h1 >>> 0) || 1;
|
|
117
|
-
}
|
|
118
120
|
function modeFromStat(st) {
|
|
119
121
|
const type = st.isSymbolicLink ? S_IFLNK : st.isDirectory ? S_IFDIR : S_IFREG;
|
|
120
122
|
const fallback = st.isDirectory || st.isSymbolicLink ? 511 : 438;
|
|
@@ -242,9 +244,9 @@ function createNodeOps(h) {
|
|
|
242
244
|
gid: 0,
|
|
243
245
|
rdev: 0,
|
|
244
246
|
size,
|
|
245
|
-
atime: mtime,
|
|
247
|
+
atime: new Date(st.atimeMs ?? mtime.getTime()),
|
|
246
248
|
mtime,
|
|
247
|
-
ctime: mtime,
|
|
249
|
+
ctime: new Date(st.ctimeMs ?? mtime.getTime()),
|
|
248
250
|
blksize: 4096,
|
|
249
251
|
blocks: Math.ceil(size / 4096)
|
|
250
252
|
};
|
|
@@ -277,10 +279,13 @@ function createNodeOps(h) {
|
|
|
277
279
|
node.live.stat = void 0;
|
|
278
280
|
},
|
|
279
281
|
lookup(parent, name) {
|
|
280
|
-
const
|
|
282
|
+
const listed = parent.live.listed?.get(name);
|
|
283
|
+
parent.live.listed?.delete(name);
|
|
284
|
+
const st = listed ?? call(() => bridgeOf(parent).lstat(childPath(parent, name)));
|
|
281
285
|
return makeNode(parent, name, st);
|
|
282
286
|
},
|
|
283
287
|
mknod(parent, name, mode) {
|
|
288
|
+
parent.live.listed = void 0;
|
|
284
289
|
const path = childPath(parent, name);
|
|
285
290
|
if (Fs.isDir(mode)) {
|
|
286
291
|
call(() => bridgeOf(parent).mkdir(path));
|
|
@@ -303,6 +308,8 @@ function createNodeOps(h) {
|
|
|
303
308
|
return node;
|
|
304
309
|
},
|
|
305
310
|
rename(oldNode, newDir, newName) {
|
|
311
|
+
oldNode.parent.live.listed = void 0;
|
|
312
|
+
newDir.live.listed = void 0;
|
|
306
313
|
const from = liveNodePath(oldNode);
|
|
307
314
|
const to = childPath(newDir, newName);
|
|
308
315
|
flushNode(oldNode);
|
|
@@ -317,6 +324,7 @@ function createNodeOps(h) {
|
|
|
317
324
|
oldNode.live.stat = void 0;
|
|
318
325
|
},
|
|
319
326
|
unlink(parent, name) {
|
|
327
|
+
parent.live.listed = void 0;
|
|
320
328
|
let open;
|
|
321
329
|
try {
|
|
322
330
|
const node = Fs.lookupNode?.(parent, name);
|
|
@@ -331,19 +339,24 @@ function createNodeOps(h) {
|
|
|
331
339
|
if (open) open.live.orphan = true;
|
|
332
340
|
},
|
|
333
341
|
rmdir(parent, name) {
|
|
342
|
+
parent.live.listed = void 0;
|
|
334
343
|
call(() => bridgeOf(parent).rmdir(childPath(parent, name)));
|
|
335
344
|
},
|
|
336
345
|
readdir(node) {
|
|
337
|
-
|
|
346
|
+
const listed = call(() => bridgeOf(node).readdirStat(liveNodePath(node)));
|
|
347
|
+
node.live.listed = /* @__PURE__ */ new Map();
|
|
348
|
+
for (const [name, st] of listed) if (st) node.live.listed.set(name, st);
|
|
349
|
+
return [".", "..", ...listed.map(([name]) => name)];
|
|
338
350
|
},
|
|
339
351
|
symlink(parent, newName, target) {
|
|
352
|
+
parent.live.listed = void 0;
|
|
340
353
|
const path = childPath(parent, newName);
|
|
341
354
|
call(() => bridgeOf(parent).symlink(target, path));
|
|
342
355
|
return makeNode(parent, newName, {
|
|
343
356
|
isFile: false,
|
|
344
357
|
isDirectory: false,
|
|
345
358
|
isSymbolicLink: true,
|
|
346
|
-
size: target.length
|
|
359
|
+
size: new TextEncoder().encode(target).length
|
|
347
360
|
});
|
|
348
361
|
},
|
|
349
362
|
readlink(node) {
|
|
@@ -463,6 +476,7 @@ function invalidateLiveVfs(Fs, plugin) {
|
|
|
463
476
|
if (!ownedBy(plugin, node)) continue;
|
|
464
477
|
const s = node.live;
|
|
465
478
|
s.stat = void 0;
|
|
479
|
+
s.listed = void 0;
|
|
466
480
|
if (s.openCount === 0) {
|
|
467
481
|
if (node !== node.mount.root) drop.push(node);
|
|
468
482
|
} else if (s.loaded && !s.dirty) {
|
|
@@ -560,6 +574,8 @@ function parseSyncFsStat(json) {
|
|
|
560
574
|
size: s.size,
|
|
561
575
|
...typeof s.mode === "number" ? { mode: s.mode } : {},
|
|
562
576
|
...typeof s.mtimeMs === "number" ? { mtimeMs: s.mtimeMs } : {},
|
|
577
|
+
...typeof s.atimeMs === "number" ? { atimeMs: s.atimeMs } : {},
|
|
578
|
+
...typeof s.ctimeMs === "number" ? { ctimeMs: s.ctimeMs } : {},
|
|
563
579
|
...typeof s.ino === "number" ? { ino: s.ino } : {}
|
|
564
580
|
};
|
|
565
581
|
}
|