@ai-ecoverse/slicc-kernel 1.66.0 → 1.66.1
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/dist/driver-worker.js +7 -2
- package/dist/driver-worker.js.map +3 -3
- package/dist/driver.js +6 -1
- package/dist/driver.js.map +3 -3
- package/dist/index.js +8 -3
- package/dist/index.js.map +3 -3
- package/dist/kernel-worker.js +28 -23
- package/dist/kernel-worker.js.map +4 -4
- package/dist/node-driver-worker.js +7 -2
- package/dist/node-driver-worker.js.map +3 -3
- package/dist/node.js +29 -24
- package/dist/node.js.map +4 -4
- package/package.json +1 -1
package/dist/node.js
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
// src/node.ts
|
|
2
2
|
import { MessageChannel as MessageChannel2, Worker } from "node:worker_threads";
|
|
3
3
|
|
|
4
|
+
// src/bytes.ts
|
|
5
|
+
function fresh(bytes, start2 = 0, end = bytes.length) {
|
|
6
|
+
return new Uint8Array(bytes.subarray(start2, end));
|
|
7
|
+
}
|
|
8
|
+
|
|
4
9
|
// src/cdp/port.ts
|
|
5
10
|
function serveCdpPort(port, hook, request, onDone) {
|
|
6
11
|
let conn;
|
|
@@ -2034,7 +2039,7 @@ function serveTransport(peer, transport, { closeWaitMs = CLOSE_WAIT_MS } = {}) {
|
|
|
2034
2039
|
}
|
|
2035
2040
|
if (typeof data === "string") peer.postMessage({ net: "ws-message", nid, data });
|
|
2036
2041
|
else {
|
|
2037
|
-
const bytes = data
|
|
2042
|
+
const bytes = fresh(data);
|
|
2038
2043
|
peer.postMessage({ net: "ws-message", nid, data: bytes }, [bytes.buffer]);
|
|
2039
2044
|
}
|
|
2040
2045
|
flow.inflight += payloadSize(data);
|
|
@@ -2072,7 +2077,7 @@ function serveTransport(peer, transport, { closeWaitMs = CLOSE_WAIT_MS } = {}) {
|
|
|
2072
2077
|
open.delete(nid);
|
|
2073
2078
|
peer.postMessage({ net: "end", nid });
|
|
2074
2079
|
} else {
|
|
2075
|
-
const bytes = next2.value
|
|
2080
|
+
const bytes = fresh(next2.value);
|
|
2076
2081
|
peer.postMessage({ net: "chunk", nid, bytes }, [bytes.buffer]);
|
|
2077
2082
|
}
|
|
2078
2083
|
} catch (e) {
|
|
@@ -2366,7 +2371,7 @@ var UserDb = class {
|
|
|
2366
2371
|
joined(name2, extra);
|
|
2367
2372
|
group.push({ name: name2, gid: uid, members: [] });
|
|
2368
2373
|
passwd.push(row);
|
|
2369
|
-
const
|
|
2374
|
+
const fresh2 = !await this.fs.exists(home);
|
|
2370
2375
|
await this.fs.mkdir(home, { recursive: true });
|
|
2371
2376
|
try {
|
|
2372
2377
|
await this.provision(row);
|
|
@@ -2374,7 +2379,7 @@ var UserDb = class {
|
|
|
2374
2379
|
await this.fs.mkdir("/etc", { recursive: true });
|
|
2375
2380
|
await this.commit(formatPasswd(passwd), formatGroup(group));
|
|
2376
2381
|
} catch (err) {
|
|
2377
|
-
if (
|
|
2382
|
+
if (fresh2) await this.fs.rm(home, { recursive: true, force: true });
|
|
2378
2383
|
throw err;
|
|
2379
2384
|
}
|
|
2380
2385
|
remember();
|
|
@@ -2519,7 +2524,7 @@ async function fsCall(fs, method, args, owner, g) {
|
|
|
2519
2524
|
}
|
|
2520
2525
|
switch (method) {
|
|
2521
2526
|
case "readFile": {
|
|
2522
|
-
const bytes = (await fs.readFileBuffer(path(0)))
|
|
2527
|
+
const bytes = fresh(await fs.readFileBuffer(path(0)));
|
|
2523
2528
|
return { result: bytes, transfer: [bytes.buffer] };
|
|
2524
2529
|
}
|
|
2525
2530
|
case "writeFile":
|
|
@@ -5721,9 +5726,9 @@ var HeldPaths = class extends Map {
|
|
|
5721
5726
|
return this.keptHandles.get(handle);
|
|
5722
5727
|
}
|
|
5723
5728
|
keep(path, file) {
|
|
5724
|
-
const
|
|
5725
|
-
for (const id2 of
|
|
5726
|
-
this.uses.set(file, Math.max(
|
|
5729
|
+
const fresh2 = this.handlesAt(path).filter((id2) => !this.keptHandles.has(id2));
|
|
5730
|
+
for (const id2 of fresh2) this.keptHandles.set(id2, file);
|
|
5731
|
+
this.uses.set(file, Math.max(fresh2.length, 1));
|
|
5727
5732
|
this.unlinked.set(path, file);
|
|
5728
5733
|
}
|
|
5729
5734
|
unkeep(path, file) {
|
|
@@ -6279,7 +6284,7 @@ var MountFs = class {
|
|
|
6279
6284
|
const chunk2 = mount.caps.maxIo ?? DEFAULT_IO;
|
|
6280
6285
|
try {
|
|
6281
6286
|
for (let offset = 0; offset < bytes.length; offset += chunk2) {
|
|
6282
|
-
const part = bytes
|
|
6287
|
+
const part = fresh(bytes, offset, offset + chunk2);
|
|
6283
6288
|
await mount.conn.call({ op: "write", fh, offset, bytes: part }, [part.buffer]);
|
|
6284
6289
|
}
|
|
6285
6290
|
} finally {
|
|
@@ -6376,7 +6381,7 @@ var MountFs = class {
|
|
|
6376
6381
|
async writeRuns(mount, fh, offset, bytes, transfer) {
|
|
6377
6382
|
const chunk2 = mount.caps.maxIo ?? DEFAULT_IO;
|
|
6378
6383
|
for (let at = 0; at < bytes.length; at += chunk2) {
|
|
6379
|
-
const part = handed(bytes, transfer, chunk2) ? bytes : bytes
|
|
6384
|
+
const part = handed(bytes, transfer, chunk2) ? bytes : fresh(bytes, at, at + chunk2);
|
|
6380
6385
|
await mount.conn.call({ op: "write", fh, offset: offset + at, bytes: part }, [part.buffer]);
|
|
6381
6386
|
}
|
|
6382
6387
|
}
|
|
@@ -6608,8 +6613,8 @@ var MountFs = class {
|
|
|
6608
6613
|
}
|
|
6609
6614
|
this.writable(mount, real);
|
|
6610
6615
|
const { uid, gid, mode } = change;
|
|
6611
|
-
const
|
|
6612
|
-
const set2 =
|
|
6616
|
+
const fresh2 = change.kind === "new" && { uid, gid, mode };
|
|
6617
|
+
const set2 = fresh2 ? await this.driverOwner(found, real, fresh2, false) : change;
|
|
6613
6618
|
this.table.forget(mount, real);
|
|
6614
6619
|
const attrs = Object.entries({ uid: set2.uid, gid: set2.gid, mode: set2.mode });
|
|
6615
6620
|
await mount.conn.call({
|
|
@@ -7239,9 +7244,9 @@ var Pages = class {
|
|
|
7239
7244
|
const page = (start2 + at) / PAGE;
|
|
7240
7245
|
if (this.pages.has(page)) continue;
|
|
7241
7246
|
const part = bytes.subarray(at, Math.min(at + PAGE, bytes.length));
|
|
7242
|
-
const
|
|
7243
|
-
|
|
7244
|
-
this.pages.set(page,
|
|
7247
|
+
const fresh2 = this.take(part.length);
|
|
7248
|
+
fresh2.set(part);
|
|
7249
|
+
this.pages.set(page, fresh2);
|
|
7245
7250
|
}
|
|
7246
7251
|
}
|
|
7247
7252
|
read(at, length2) {
|
|
@@ -11340,10 +11345,10 @@ var WasmProcess = class {
|
|
|
11340
11345
|
this.fds.installAt(fd, this.openVfsFile(open));
|
|
11341
11346
|
} else if (req.create) {
|
|
11342
11347
|
await nodes.onEntry(path, async () => {
|
|
11343
|
-
const
|
|
11348
|
+
const fresh2 = this.options.owners && !await present2(this.options.fs, path, true);
|
|
11344
11349
|
this.fds.installAt(fd, this.openVfsFile(open, await nodes.identify(path)));
|
|
11345
11350
|
await this.fds.get(fd).file.stat?.();
|
|
11346
|
-
if (
|
|
11351
|
+
if (fresh2) await this.options.fs.chown?.(path, { ...this.newOwner(), kind: "new" });
|
|
11347
11352
|
});
|
|
11348
11353
|
} else {
|
|
11349
11354
|
this.fds.installAt(fd, this.openVfsFile(open, await nodes.identify(path)));
|
|
@@ -12787,7 +12792,7 @@ function serveFilesystem(port, handlers, capabilities = {}, options = {}) {
|
|
|
12787
12792
|
(result) => {
|
|
12788
12793
|
if (result instanceof Uint8Array) {
|
|
12789
12794
|
const whole = result.byteOffset === 0 && result.byteLength === result.buffer.byteLength;
|
|
12790
|
-
const bytes = options.owned && whole ? result : result
|
|
12795
|
+
const bytes = options.owned && whole ? result : fresh(result);
|
|
12791
12796
|
reply({ id: data.id, result: bytes }, [bytes.buffer]);
|
|
12792
12797
|
} else reply({ id: data.id, result: result ?? null });
|
|
12793
12798
|
},
|
|
@@ -13275,14 +13280,14 @@ var RESTORE_AGAIN_MS = 3e4;
|
|
|
13275
13280
|
function hostfsHandlers(current, againMs = RESTORE_AGAIN_MS) {
|
|
13276
13281
|
const handles = /* @__PURE__ */ new Map();
|
|
13277
13282
|
let nextFh = 0;
|
|
13278
|
-
const
|
|
13283
|
+
const fresh2 = (remote) => {
|
|
13279
13284
|
if (remote.client.token === remote.token && !remote.client.gone) return remote;
|
|
13280
13285
|
throw fsError2("ESTALE", "the folder was granted again, so this open file is gone");
|
|
13281
13286
|
};
|
|
13282
13287
|
const live = (fh) => {
|
|
13283
13288
|
const remote = handles.get(fh);
|
|
13284
13289
|
if (!remote) throw fsError2("EBADF", `handle ${fh}`);
|
|
13285
|
-
return
|
|
13290
|
+
return fresh2(remote);
|
|
13286
13291
|
};
|
|
13287
13292
|
const call = (op, body = {}) => current().call(op, body);
|
|
13288
13293
|
const same = (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);
|
|
@@ -13364,7 +13369,7 @@ function hostfsHandlers(current, againMs = RESTORE_AGAIN_MS) {
|
|
|
13364
13369
|
if (!remote) throw fsError2("EBADF", `handle ${fh}`);
|
|
13365
13370
|
handles.delete(fh);
|
|
13366
13371
|
try {
|
|
13367
|
-
await
|
|
13372
|
+
await fresh2(remote).client.call("release", { fh: remote.fh }, true);
|
|
13368
13373
|
} finally {
|
|
13369
13374
|
if (remote.restore) await settle(current(), remote.restore);
|
|
13370
13375
|
}
|
|
@@ -15649,8 +15654,8 @@ var Launcher = class {
|
|
|
15649
15654
|
];
|
|
15650
15655
|
for (const [path, mode] of layout) {
|
|
15651
15656
|
const real = await this.realLayoutPath(path);
|
|
15652
|
-
const
|
|
15653
|
-
if (
|
|
15657
|
+
const fresh2 = real !== void 0 && !await this.base.hasOwner?.(real);
|
|
15658
|
+
if (fresh2) await this.base.chown?.(real, { uid: 0, gid: 0, mode, follow: false });
|
|
15654
15659
|
}
|
|
15655
15660
|
}
|
|
15656
15661
|
async realLayoutPath(given) {
|
|
@@ -16395,7 +16400,7 @@ function dialStream(port, onClose) {
|
|
|
16395
16400
|
const writable2 = new WritableStream({
|
|
16396
16401
|
write(chunk2) {
|
|
16397
16402
|
if (closed) throw errorWithCode("EPIPE: the connection is closed");
|
|
16398
|
-
const copy = chunk2
|
|
16403
|
+
const copy = fresh(chunk2);
|
|
16399
16404
|
const acked = new Promise((resolve, reject) => acks.push({ resolve, reject }));
|
|
16400
16405
|
port.postMessage(copy, [copy.buffer]);
|
|
16401
16406
|
return acked;
|