@ai-ecoverse/slicc-kernel 1.154.1 → 1.154.3
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/driver-worker.js +5 -2
- package/dist/driver-worker.js.map +2 -2
- package/dist/index.js +5 -2
- package/dist/index.js.map +2 -2
- package/dist/kernel-worker.js +165 -13
- package/dist/kernel-worker.js.map +2 -2
- package/dist/node-driver-worker.js +5 -2
- package/dist/node-driver-worker.js.map +2 -2
- package/dist/node-process-worker.js +1 -1
- package/dist/node.js +170 -15
- package/dist/node.js.map +3 -3
- package/dist/process-worker.js +1 -1
- package/dist/types/embedder-relay.d.ts +3 -0
- package/dist/types/fs/opfs.d.ts +3 -0
- package/dist/types/kernel/vfs-file.d.ts +5 -0
- package/package.json +1 -1
package/dist/kernel-worker.js
CHANGED
|
@@ -942,6 +942,12 @@ var ProtectedFs = class {
|
|
|
942
942
|
return fs.pwrite?.(...args);
|
|
943
943
|
}
|
|
944
944
|
} : {},
|
|
945
|
+
...fs.append ? {
|
|
946
|
+
async append(path, bytes) {
|
|
947
|
+
await check(path, true);
|
|
948
|
+
return fs.append.call(fs, path, bytes);
|
|
949
|
+
}
|
|
950
|
+
} : {},
|
|
945
951
|
...fs.truncate ? {
|
|
946
952
|
async truncate(path, size) {
|
|
947
953
|
await check(path, true);
|
|
@@ -1512,6 +1518,7 @@ var OpfsFs = class {
|
|
|
1512
1518
|
mounts = {};
|
|
1513
1519
|
locks;
|
|
1514
1520
|
lockPrefix;
|
|
1521
|
+
appendPrefix;
|
|
1515
1522
|
rootName;
|
|
1516
1523
|
renamePrefix;
|
|
1517
1524
|
constructor(root, meta = new MemoryMeta(), channel, options = {}) {
|
|
@@ -1520,6 +1527,7 @@ var OpfsFs = class {
|
|
|
1520
1527
|
this.ranged = options.ranged === true;
|
|
1521
1528
|
this.locks = options.locks === void 0 ? lockManager() : options.locks ?? void 0;
|
|
1522
1529
|
this.lockPrefix = `slicc-excl:${channel ?? ""}:`;
|
|
1530
|
+
this.appendPrefix = `slicc-append:${escapeRoot(channel ?? "")}:`;
|
|
1523
1531
|
this.rootName = channel;
|
|
1524
1532
|
this.renamePrefix = `${RENAME_LOCK}${escapeRoot(channel ?? "")}:`;
|
|
1525
1533
|
this.channel = channel === void 0 ? void 0 : new BroadcastChannel(channel);
|
|
@@ -2413,11 +2421,43 @@ var OpfsFs = class {
|
|
|
2413
2421
|
if (this.renamesInFlight()) await this.writeWaits(at);
|
|
2414
2422
|
this.fileWrites.set(at, (this.fileWrites.get(at) ?? 0) + 1);
|
|
2415
2423
|
try {
|
|
2416
|
-
await this.truncated(path, size);
|
|
2424
|
+
await this.ending(path, () => this.truncated(path, size));
|
|
2425
|
+
} finally {
|
|
2426
|
+
this.writeEnded(at);
|
|
2427
|
+
}
|
|
2428
|
+
}
|
|
2429
|
+
async append(path, bytes) {
|
|
2430
|
+
if (!this.locks || !this.remote || !this.shared()) {
|
|
2431
|
+
throw fsError("ENOTSUP", `${path}: appended by position while no other tab shares the root`);
|
|
2432
|
+
}
|
|
2433
|
+
const at = normalizePath(path);
|
|
2434
|
+
if (this.renamesInFlight()) await this.writeWaits(at);
|
|
2435
|
+
this.fileWrites.set(at, (this.fileWrites.get(at) ?? 0) + 1);
|
|
2436
|
+
try {
|
|
2437
|
+
const found = await this.locate(path, true);
|
|
2438
|
+
if (found.handle?.kind !== "file") throw fsError(found.handle ? "EISDIR" : "ENOENT", path);
|
|
2439
|
+
this.refuse(found.path);
|
|
2440
|
+
const [entry] = await this.meta.get([found.path]);
|
|
2441
|
+
if (entry?.fifo || entry?.socket) throw fsError("ENXIO", path);
|
|
2442
|
+
const handle = found.handle;
|
|
2443
|
+
return await this.ending(found.path, async () => {
|
|
2444
|
+
const end = (await this.io(handle.getFile())).size;
|
|
2445
|
+
await this.writeAt(handle, found.path, path, end, bytes);
|
|
2446
|
+
return end + bytes.length;
|
|
2447
|
+
});
|
|
2417
2448
|
} finally {
|
|
2418
2449
|
this.writeEnded(at);
|
|
2419
2450
|
}
|
|
2420
2451
|
}
|
|
2452
|
+
async ending(path, op) {
|
|
2453
|
+
if (!this.locks || !this.remote || !this.shared()) return op();
|
|
2454
|
+
const physical = (await this.locate(path, true)).path;
|
|
2455
|
+
let result;
|
|
2456
|
+
await this.locks.request(`${this.appendPrefix}${physical}`, async () => {
|
|
2457
|
+
result = await op();
|
|
2458
|
+
});
|
|
2459
|
+
return result;
|
|
2460
|
+
}
|
|
2421
2461
|
async truncated(path, size) {
|
|
2422
2462
|
const handle = await this.existing(path, true);
|
|
2423
2463
|
await this.refuseNode(path, (await this.io(handle.getFile())).size === 0);
|
|
@@ -4608,6 +4648,7 @@ function embedderAsker(port) {
|
|
|
4608
4648
|
void asked.body.cancel(message3.error.message).catch(() => void 0);
|
|
4609
4649
|
push(asked, message3.error);
|
|
4610
4650
|
} else if ("progress" in message3) asked.progress(message3.progress);
|
|
4651
|
+
else if ("bodyCancel" in message3) void asked.body.cancel("the page").catch(() => void 0);
|
|
4611
4652
|
else void sendBody(message3.id, asked);
|
|
4612
4653
|
};
|
|
4613
4654
|
return { hookFor, answer: answer2 };
|
|
@@ -8049,7 +8090,7 @@ function satisfies(version, range2) {
|
|
|
8049
8090
|
}
|
|
8050
8091
|
|
|
8051
8092
|
// src/version.ts
|
|
8052
|
-
var KERNEL_VERSION = true ? "1.154.
|
|
8093
|
+
var KERNEL_VERSION = true ? "1.154.3" : "0.0.0-dev";
|
|
8053
8094
|
var OS_RELEASE = "6.0.0-slicc";
|
|
8054
8095
|
function procVersion() {
|
|
8055
8096
|
return `Linux version ${OS_RELEASE} (slicc-kernel ${KERNEL_VERSION}) #1 SMP PREEMPT_DYNAMIC
|
|
@@ -10719,6 +10760,7 @@ function withCommandDirs(fs, names2, userDir = async () => void 0, owners = fals
|
|
|
10719
10760
|
...fs.chown ? { chown: fs.chown.bind(fs) } : {},
|
|
10720
10761
|
...fs.createExclusive ? { createExclusive: fs.createExclusive.bind(fs) } : {},
|
|
10721
10762
|
...fs.copyFile ? { copyFile: fs.copyFile.bind(fs) } : {},
|
|
10763
|
+
...fs.append ? { append: fs.append.bind(fs) } : {},
|
|
10722
10764
|
...fs.ancestry ? { ancestry: fs.ancestry.bind(fs) } : {},
|
|
10723
10765
|
...fs.hasOwner ? { hasOwner: fs.hasOwner.bind(fs) } : {},
|
|
10724
10766
|
chmod: (path, mode) => fs.chmod(path, mode),
|
|
@@ -10955,6 +10997,15 @@ var FreshModules = class {
|
|
|
10955
10997
|
if (fresh3) this.fresh.set(normalizePath(to), fresh3);
|
|
10956
10998
|
}
|
|
10957
10999
|
};
|
|
11000
|
+
const { append } = fs;
|
|
11001
|
+
if (append) {
|
|
11002
|
+
overrides.append = async (path, bytes) => {
|
|
11003
|
+
const fresh3 = this.fresh.has(normalizePath(path));
|
|
11004
|
+
const end = await append.call(fs, path, bytes);
|
|
11005
|
+
if (fresh3 && end - bytes.length < MAGIC.length) await decide(path);
|
|
11006
|
+
return end;
|
|
11007
|
+
};
|
|
11008
|
+
}
|
|
10958
11009
|
const ranged2 = rangedOps(fs);
|
|
10959
11010
|
if (ranged2) {
|
|
10960
11011
|
overrides.pwrite = async (path, at, bytes, transfer, options) => {
|
|
@@ -11348,6 +11399,19 @@ var FsWatchers = class {
|
|
|
11348
11399
|
"change"
|
|
11349
11400
|
)
|
|
11350
11401
|
};
|
|
11402
|
+
const { append } = fs;
|
|
11403
|
+
if (append) {
|
|
11404
|
+
overrides.append = async (path, bytes) => {
|
|
11405
|
+
let end = 0;
|
|
11406
|
+
await content(
|
|
11407
|
+
async (_path) => {
|
|
11408
|
+
end = await append.call(fs, path, bytes);
|
|
11409
|
+
},
|
|
11410
|
+
() => ["change"]
|
|
11411
|
+
)(path);
|
|
11412
|
+
return end;
|
|
11413
|
+
};
|
|
11414
|
+
}
|
|
11351
11415
|
const ranged2 = rangedOps(fs);
|
|
11352
11416
|
if (ranged2) {
|
|
11353
11417
|
overrides.pwrite = content(ranged2.pwrite, () => ["change"]);
|
|
@@ -11851,6 +11915,7 @@ var BodyPipe = class {
|
|
|
11851
11915
|
queue = [];
|
|
11852
11916
|
size = 0;
|
|
11853
11917
|
ended = false;
|
|
11918
|
+
dropped = false;
|
|
11854
11919
|
wake;
|
|
11855
11920
|
room;
|
|
11856
11921
|
stream;
|
|
@@ -11869,7 +11934,8 @@ var BodyPipe = class {
|
|
|
11869
11934
|
this.room?.();
|
|
11870
11935
|
controller.enqueue(next3);
|
|
11871
11936
|
} else controller.close();
|
|
11872
|
-
}
|
|
11937
|
+
},
|
|
11938
|
+
cancel: () => this.drop()
|
|
11873
11939
|
},
|
|
11874
11940
|
{ highWaterMark: 0 }
|
|
11875
11941
|
);
|
|
@@ -11877,8 +11943,14 @@ var BodyPipe = class {
|
|
|
11877
11943
|
get full() {
|
|
11878
11944
|
return this.size >= EMBEDDER_WINDOW;
|
|
11879
11945
|
}
|
|
11946
|
+
drop() {
|
|
11947
|
+
this.dropped = true;
|
|
11948
|
+
this.queue = [];
|
|
11949
|
+
this.size = 0;
|
|
11950
|
+
this.end();
|
|
11951
|
+
}
|
|
11880
11952
|
push(bytes) {
|
|
11881
|
-
if (bytes.length === 0) return;
|
|
11953
|
+
if (bytes.length === 0 || this.dropped) return;
|
|
11882
11954
|
this.queue.push(bytes.slice());
|
|
11883
11955
|
this.size += bytes.length;
|
|
11884
11956
|
this.wake?.();
|
|
@@ -11894,6 +11966,30 @@ var BodyPipe = class {
|
|
|
11894
11966
|
this.room?.();
|
|
11895
11967
|
}
|
|
11896
11968
|
};
|
|
11969
|
+
function endsWith(stream, ended) {
|
|
11970
|
+
const reader = stream.getReader();
|
|
11971
|
+
return new ReadableStream(
|
|
11972
|
+
{
|
|
11973
|
+
pull: async (controller) => {
|
|
11974
|
+
let got;
|
|
11975
|
+
try {
|
|
11976
|
+
got = await reader.read();
|
|
11977
|
+
} catch (err) {
|
|
11978
|
+
ended();
|
|
11979
|
+
throw err;
|
|
11980
|
+
}
|
|
11981
|
+
if (!got.done) return controller.enqueue(got.value);
|
|
11982
|
+
ended();
|
|
11983
|
+
controller.close();
|
|
11984
|
+
},
|
|
11985
|
+
cancel: (reason) => {
|
|
11986
|
+
ended();
|
|
11987
|
+
return reader.cancel(reason);
|
|
11988
|
+
}
|
|
11989
|
+
},
|
|
11990
|
+
{ highWaterMark: 0 }
|
|
11991
|
+
);
|
|
11992
|
+
}
|
|
11897
11993
|
function replyStream(reply) {
|
|
11898
11994
|
if (reply instanceof ReadableStream) return reply;
|
|
11899
11995
|
const bytes = typeof reply === "string" ? new TextEncoder().encode(reply) : reply instanceof Uint8Array ? reply : new Uint8Array(0);
|
|
@@ -11968,7 +12064,10 @@ var EmbedderChannel = class {
|
|
|
11968
12064
|
signal: this.abort.signal,
|
|
11969
12065
|
progress
|
|
11970
12066
|
})
|
|
11971
|
-
).then((reply) =>
|
|
12067
|
+
).then((reply) => {
|
|
12068
|
+
if (!(reply instanceof ReadableStream)) body.drop();
|
|
12069
|
+
return endsWith(replyStream(reply), () => body.drop()).getReader();
|
|
12070
|
+
});
|
|
11972
12071
|
this.replied = asked.catch((err) => {
|
|
11973
12072
|
body.end();
|
|
11974
12073
|
throw this.fail(err);
|
|
@@ -13184,6 +13283,7 @@ var RELINKED = [
|
|
|
13184
13283
|
["writeFile", [0]],
|
|
13185
13284
|
["pread", [0]],
|
|
13186
13285
|
["pwrite", [0]],
|
|
13286
|
+
["append", [0]],
|
|
13187
13287
|
["truncate", [0]],
|
|
13188
13288
|
["lstat", [0]],
|
|
13189
13289
|
["stat", [0]],
|
|
@@ -13489,6 +13589,19 @@ var MountFs = class _MountFs {
|
|
|
13489
13589
|
);
|
|
13490
13590
|
}
|
|
13491
13591
|
}
|
|
13592
|
+
async append(path, bytes, redirects = 0) {
|
|
13593
|
+
const real = await this.follow(path, 0, true);
|
|
13594
|
+
const { append } = this.base;
|
|
13595
|
+
if (!this.at(real) && append) {
|
|
13596
|
+
return this.based(
|
|
13597
|
+
[real],
|
|
13598
|
+
redirects,
|
|
13599
|
+
() => append.call(this.base, real, bytes),
|
|
13600
|
+
([to], n) => this.append(to, bytes, n)
|
|
13601
|
+
);
|
|
13602
|
+
}
|
|
13603
|
+
throw errnoError("ENOTSUP", `${real}: appended by position on a mount`);
|
|
13604
|
+
}
|
|
13492
13605
|
async pwrite(path, offset, bytes, transfer = false, options, redirects = 0) {
|
|
13493
13606
|
const real = await this.follow(path, 0, true);
|
|
13494
13607
|
const found = this.at(real);
|
|
@@ -23453,6 +23566,7 @@ var O_ACCMODE = 3;
|
|
|
23453
23566
|
var O_WRONLY = 1;
|
|
23454
23567
|
var O_RDWR = 2;
|
|
23455
23568
|
var O_APPEND = 1024;
|
|
23569
|
+
var POSITIONAL_MS = 100;
|
|
23456
23570
|
var SEEK_SET = 0;
|
|
23457
23571
|
var SEEK_CUR = 1;
|
|
23458
23572
|
var SEEK_END = 2;
|
|
@@ -23648,6 +23762,34 @@ var VfsNode = class {
|
|
|
23648
23762
|
if (this.ranged) this.ranged.path = path;
|
|
23649
23763
|
this.cap = void 0;
|
|
23650
23764
|
}
|
|
23765
|
+
async append(bytes) {
|
|
23766
|
+
const { append } = this.fs;
|
|
23767
|
+
const recently = performance.now() - this.positionalAt < POSITIONAL_MS;
|
|
23768
|
+
if (!append || this.orphaned || this.revoked || bytes.length === 0 || recently) {
|
|
23769
|
+
const at = await this.size();
|
|
23770
|
+
return at + await this.pwrite(bytes, at);
|
|
23771
|
+
}
|
|
23772
|
+
await this.settled();
|
|
23773
|
+
await this.fits(await this.size() + bytes.length);
|
|
23774
|
+
await this.flush();
|
|
23775
|
+
const end = await this.followed(() => append.call(this.fs, this.path, bytes)).catch(
|
|
23776
|
+
(err) => {
|
|
23777
|
+
if (!positional(err)) throw err;
|
|
23778
|
+
return void 0;
|
|
23779
|
+
}
|
|
23780
|
+
);
|
|
23781
|
+
if (end === void 0) {
|
|
23782
|
+
this.positionalAt = performance.now();
|
|
23783
|
+
const at = await this.size();
|
|
23784
|
+
return at + await this.pwrite(bytes, at);
|
|
23785
|
+
}
|
|
23786
|
+
this.reread();
|
|
23787
|
+
return end;
|
|
23788
|
+
}
|
|
23789
|
+
positionalAt = Number.NEGATIVE_INFINITY;
|
|
23790
|
+
shared() {
|
|
23791
|
+
this.positionalAt = Number.NEGATIVE_INFINITY;
|
|
23792
|
+
}
|
|
23651
23793
|
async pwrite(bytes, at) {
|
|
23652
23794
|
if (bytes.length === 0) return 0;
|
|
23653
23795
|
await this.settled();
|
|
@@ -23736,6 +23878,9 @@ var VfsNode = class {
|
|
|
23736
23878
|
this.writeBackCost = performance.now() - started;
|
|
23737
23879
|
}
|
|
23738
23880
|
};
|
|
23881
|
+
function positional(err) {
|
|
23882
|
+
return err?.code === "ENOTSUP";
|
|
23883
|
+
}
|
|
23739
23884
|
var VfsNodes = class {
|
|
23740
23885
|
byPath = /* @__PURE__ */ new Map();
|
|
23741
23886
|
kept = /* @__PURE__ */ new Map();
|
|
@@ -23840,6 +23985,9 @@ var VfsNodes = class {
|
|
|
23840
23985
|
if (node.path === path) node.renamedTo(others[0]);
|
|
23841
23986
|
return true;
|
|
23842
23987
|
}
|
|
23988
|
+
shared() {
|
|
23989
|
+
for (const node of new Set(this.byPath.values())) node.shared();
|
|
23990
|
+
}
|
|
23843
23991
|
holdsAny() {
|
|
23844
23992
|
return this.byPath.size > 0;
|
|
23845
23993
|
}
|
|
@@ -24092,12 +24240,13 @@ function heldIo(fs, nodes, changed) {
|
|
|
24092
24240
|
return {
|
|
24093
24241
|
append: (path, bytes) => write(
|
|
24094
24242
|
path,
|
|
24095
|
-
|
|
24096
|
-
const at = await held.size();
|
|
24097
|
-
await held.pwrite(bytes, at);
|
|
24098
|
-
return at + bytes.length;
|
|
24099
|
-
},
|
|
24243
|
+
(held) => held.append(bytes),
|
|
24100
24244
|
async () => {
|
|
24245
|
+
const end = await fs.append?.(path, bytes).catch((err) => {
|
|
24246
|
+
if (!positional(err)) throw err;
|
|
24247
|
+
return void 0;
|
|
24248
|
+
});
|
|
24249
|
+
if (end !== void 0) return end;
|
|
24101
24250
|
const at = (await fs.stat(path)).size;
|
|
24102
24251
|
if (ranged2) await ranged2.pwrite(path, at, bytes, true);
|
|
24103
24252
|
else {
|
|
@@ -24246,8 +24395,8 @@ function vfsFile(fs, opts, nodes) {
|
|
|
24246
24395
|
return out;
|
|
24247
24396
|
}) : void 0,
|
|
24248
24397
|
write: writable2 ? (bytes) => serial(async () => {
|
|
24249
|
-
if (opts.flags & O_APPEND) offset = await node.
|
|
24250
|
-
offset += await node.pwrite(bytes, offset);
|
|
24398
|
+
if (opts.flags & O_APPEND) offset = await node.append(bytes);
|
|
24399
|
+
else offset += await node.pwrite(bytes, offset);
|
|
24251
24400
|
return bytes.length;
|
|
24252
24401
|
}) : void 0,
|
|
24253
24402
|
seek: (to, whence) => serial(async () => {
|
|
@@ -32583,7 +32732,10 @@ var Launcher = class {
|
|
|
32583
32732
|
peers.watch((crowded) => {
|
|
32584
32733
|
this.changes.flush();
|
|
32585
32734
|
this.changes.foreign(crowded);
|
|
32586
|
-
if (crowded)
|
|
32735
|
+
if (crowded) {
|
|
32736
|
+
void this.held?.bindIds((path) => this.rootFileId(path));
|
|
32737
|
+
for (const nodes of this.openFiles) nodes.shared();
|
|
32738
|
+
}
|
|
32587
32739
|
});
|
|
32588
32740
|
return {
|
|
32589
32741
|
...peers,
|