@ai-ecoverse/slicc-kernel 1.75.0 → 1.75.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/README.md +1 -1
- package/dist/kernel-worker.js +60 -9
- package/dist/kernel-worker.js.map +2 -2
- package/dist/node.js +60 -9
- package/dist/node.js.map +3 -3
- package/package.json +1 -1
package/dist/node.js
CHANGED
|
@@ -3428,6 +3428,7 @@ async function positioned(handle, op) {
|
|
|
3428
3428
|
function isHandle(child) {
|
|
3429
3429
|
return "kind" in child;
|
|
3430
3430
|
}
|
|
3431
|
+
var FILE_TIMES_MS = 100;
|
|
3431
3432
|
var OpfsFs = class {
|
|
3432
3433
|
root;
|
|
3433
3434
|
meta;
|
|
@@ -3698,8 +3699,50 @@ var OpfsFs = class {
|
|
|
3698
3699
|
const fallback = directory || EXECUTABLE.test(path) ? 493 : 420;
|
|
3699
3700
|
return (directory ? S_IFDIR : S_IFREG) | (meta?.mode ?? fallback);
|
|
3700
3701
|
}
|
|
3702
|
+
id = crypto.randomUUID();
|
|
3701
3703
|
dirTimes = /* @__PURE__ */ new Map();
|
|
3702
3704
|
dirDirty = /* @__PURE__ */ new Set();
|
|
3705
|
+
fileTimes = /* @__PURE__ */ new Map();
|
|
3706
|
+
written(target) {
|
|
3707
|
+
this.committed(target);
|
|
3708
|
+
if (!this.ranged) return;
|
|
3709
|
+
this.fileTimes.set(target, Date.now());
|
|
3710
|
+
this.scheduleFileTimes();
|
|
3711
|
+
}
|
|
3712
|
+
scheduleFileTimes() {
|
|
3713
|
+
if (this.flushing.file || this.fileTimes.size === 0) return;
|
|
3714
|
+
this.flushing.file = setTimeout(() => {
|
|
3715
|
+
void this.flushFileTimes().catch(() => void 0).finally(() => {
|
|
3716
|
+
this.flushing.file = void 0;
|
|
3717
|
+
this.scheduleFileTimes();
|
|
3718
|
+
});
|
|
3719
|
+
}, FILE_TIMES_MS);
|
|
3720
|
+
this.flushing.file.unref?.();
|
|
3721
|
+
}
|
|
3722
|
+
async flushFileTimes() {
|
|
3723
|
+
for (const [path, ms] of [...this.fileTimes]) {
|
|
3724
|
+
const mtimeFor = await this.modified(path).catch(() => 0);
|
|
3725
|
+
await this.meta.update(
|
|
3726
|
+
path,
|
|
3727
|
+
(entry) => this.fileTimes.get(path) !== ms || this.explicitWins(entry, ms) ? entry : { ...entry, path, mtimeMs: ms, mtimeFor, ctimeMs: ms }
|
|
3728
|
+
);
|
|
3729
|
+
if (this.fileTimes.get(path) === ms) this.fileTimes.delete(path);
|
|
3730
|
+
}
|
|
3731
|
+
}
|
|
3732
|
+
timesOf(path) {
|
|
3733
|
+
return this.dirTimes.get(path) ?? this.fileTimes.get(path);
|
|
3734
|
+
}
|
|
3735
|
+
explicitWins(entry, ms) {
|
|
3736
|
+
if (entry?.timesAt === void 0 || entry.timesBy === this.id) return false;
|
|
3737
|
+
return entry.timesAt >= ms;
|
|
3738
|
+
}
|
|
3739
|
+
movePending(from, to) {
|
|
3740
|
+
for (const [path, ms] of [...this.fileTimes]) {
|
|
3741
|
+
if (!within2(path, from)) continue;
|
|
3742
|
+
this.fileTimes.delete(path);
|
|
3743
|
+
if (to !== void 0) this.fileTimes.set(to + path.slice(from.length), ms);
|
|
3744
|
+
}
|
|
3745
|
+
}
|
|
3703
3746
|
flushing = {};
|
|
3704
3747
|
touch(...dirs) {
|
|
3705
3748
|
const now = Date.now();
|
|
@@ -3723,11 +3766,10 @@ var OpfsFs = class {
|
|
|
3723
3766
|
if (this.dirTimes.get(path) === ms) this.dirTimes.delete(path);
|
|
3724
3767
|
}
|
|
3725
3768
|
}
|
|
3726
|
-
async statOf(path, handle, meta) {
|
|
3769
|
+
async statOf(path, handle, meta, touched) {
|
|
3727
3770
|
const directory = handle.kind === "directory";
|
|
3728
3771
|
const file = directory ? void 0 : await handle.getFile();
|
|
3729
3772
|
const modified = file?.lastModified ?? 0;
|
|
3730
|
-
const touched = directory ? this.dirTimes.get(path) : void 0;
|
|
3731
3773
|
const kept = meta?.mtimeMs !== void 0 && meta.mtimeFor === modified ? meta.mtimeMs : modified;
|
|
3732
3774
|
const mtime = touched ?? kept;
|
|
3733
3775
|
return {
|
|
@@ -3759,13 +3801,14 @@ var OpfsFs = class {
|
|
|
3759
3801
|
}
|
|
3760
3802
|
async describe(found) {
|
|
3761
3803
|
if (found.link) return this.owned(this.linkStat(found.link), found.path, found.link);
|
|
3804
|
+
const touched = this.timesOf(found.path);
|
|
3762
3805
|
if (!this.owners) {
|
|
3763
3806
|
const [meta2] = await this.meta.get([found.path]);
|
|
3764
|
-
return this.statOf(found.path, found.handle, meta2);
|
|
3807
|
+
return this.statOf(found.path, found.handle, meta2, touched);
|
|
3765
3808
|
}
|
|
3766
3809
|
const entries = await this.meta.get(chain(found.path));
|
|
3767
3810
|
const meta = entries.pop();
|
|
3768
|
-
const stat = await this.statOf(found.path, found.handle, meta);
|
|
3811
|
+
const stat = await this.statOf(found.path, found.handle, meta, touched);
|
|
3769
3812
|
return { ...stat, ...ownOf(meta) ?? inherit(entries) };
|
|
3770
3813
|
}
|
|
3771
3814
|
async stat(path) {
|
|
@@ -3822,13 +3865,14 @@ var OpfsFs = class {
|
|
|
3822
3865
|
async pwrite(path, offset, bytes) {
|
|
3823
3866
|
const [handle, , target] = await this.fileFor(path);
|
|
3824
3867
|
await this.retrying(path, () => positioned(handle, (io) => io.write(offset, bytes)), true);
|
|
3825
|
-
this.
|
|
3868
|
+
this.written(target);
|
|
3826
3869
|
}
|
|
3827
3870
|
async truncate(path, size) {
|
|
3828
3871
|
const handle = await this.existing(path, true);
|
|
3829
|
-
const
|
|
3872
|
+
const resolve = this.ranged || this.remote?.watched();
|
|
3873
|
+
const target = resolve ? (await this.locate(path, true)).path : path;
|
|
3830
3874
|
await this.retrying(path, () => positioned(handle, (io) => io.truncate(size)), true);
|
|
3831
|
-
this.
|
|
3875
|
+
this.written(target);
|
|
3832
3876
|
}
|
|
3833
3877
|
async writeSession(path, truncate) {
|
|
3834
3878
|
const [handle, , target] = await this.fileFor(path);
|
|
@@ -3918,13 +3962,16 @@ var OpfsFs = class {
|
|
|
3918
3962
|
async readdirStat(path) {
|
|
3919
3963
|
const [dir, children2] = await this.listing(path);
|
|
3920
3964
|
const base = dir === "/" ? "" : dir;
|
|
3965
|
+
const touched = children2.map(([name2]) => this.timesOf(`${base}/${name2}`));
|
|
3921
3966
|
const metas = await this.meta.get(children2.map(([name2]) => `${base}/${name2}`));
|
|
3922
3967
|
const handed2 = this.owners ? await this.handedTo(dir) : void 0;
|
|
3923
3968
|
const owned4 = (stat, entry) => handed2 ? { ...stat, ...ownOf(entry) ?? handed2 } : stat;
|
|
3924
3969
|
return Promise.all(
|
|
3925
3970
|
children2.map(async ([name2, child], i) => {
|
|
3926
3971
|
if (!isHandle(child)) return [name2, owned4(this.linkStat(child), child)];
|
|
3927
|
-
const stat = await this.statOf(`${base}/${name2}`, child, metas[i]).catch(
|
|
3972
|
+
const stat = await this.statOf(`${base}/${name2}`, child, metas[i], touched[i]).catch(
|
|
3973
|
+
() => null
|
|
3974
|
+
);
|
|
3928
3975
|
return [name2, stat && owned4(stat, metas[i])];
|
|
3929
3976
|
})
|
|
3930
3977
|
);
|
|
@@ -3982,6 +4029,7 @@ var OpfsFs = class {
|
|
|
3982
4029
|
throw translate(err, path);
|
|
3983
4030
|
}
|
|
3984
4031
|
this.changed(found.path);
|
|
4032
|
+
this.movePending(found.path);
|
|
3985
4033
|
}
|
|
3986
4034
|
await this.meta.remove([found.path]);
|
|
3987
4035
|
this.touch(parentOf4(found.path));
|
|
@@ -4045,6 +4093,7 @@ var OpfsFs = class {
|
|
|
4045
4093
|
const moved2 = await this.place(source.handle, dir, staging);
|
|
4046
4094
|
if (swap) await this.rm(destination, { recursive: true });
|
|
4047
4095
|
await this.meta.move(source.path, destination, carry);
|
|
4096
|
+
this.movePending(source.path, destination);
|
|
4048
4097
|
if (!moved2) await this.rm(source.path, { recursive: true });
|
|
4049
4098
|
let copied = !moved2;
|
|
4050
4099
|
if (swap) {
|
|
@@ -4166,6 +4215,7 @@ var OpfsFs = class {
|
|
|
4166
4215
|
const handle = found.handle;
|
|
4167
4216
|
const file = handle.kind === "file" ? await handle.getFile() : void 0;
|
|
4168
4217
|
this.dirTimes.delete(found.path);
|
|
4218
|
+
this.fileTimes.delete(found.path);
|
|
4169
4219
|
const ctimeMs = Date.now();
|
|
4170
4220
|
await this.meta.update(found.path, (entry) => ({
|
|
4171
4221
|
...entry,
|
|
@@ -4174,7 +4224,8 @@ var OpfsFs = class {
|
|
|
4174
4224
|
mtimeMs: mtime.getTime(),
|
|
4175
4225
|
mtimeFor: file?.lastModified ?? 0,
|
|
4176
4226
|
ctimeMs,
|
|
4177
|
-
timesAt: ctimeMs
|
|
4227
|
+
timesAt: ctimeMs,
|
|
4228
|
+
timesBy: this.id
|
|
4178
4229
|
}));
|
|
4179
4230
|
}
|
|
4180
4231
|
async reconcile() {
|