@ai-ecoverse/slicc-kernel 1.117.1 → 1.117.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 +125 -47
- package/dist/kernel-worker.js.map +3 -3
- package/dist/node-process-worker.js +1 -1
- package/dist/node.js +125 -47
- package/dist/node.js.map +3 -3
- package/dist/process-worker.js +1 -1
- package/dist/types/fs/opfs.d.ts +6 -0
- package/dist/types/fs/unlinked.d.ts +2 -0
- package/package.json +1 -1
|
@@ -5377,7 +5377,7 @@ var KERNEL_VERSION, OS_RELEASE;
|
|
|
5377
5377
|
var init_version = __esm({
|
|
5378
5378
|
"src/version.ts"() {
|
|
5379
5379
|
"use strict";
|
|
5380
|
-
KERNEL_VERSION = true ? "1.117.
|
|
5380
|
+
KERNEL_VERSION = true ? "1.117.2" : "0.0.0-dev";
|
|
5381
5381
|
OS_RELEASE = "6.0.0-slicc";
|
|
5382
5382
|
}
|
|
5383
5383
|
});
|
package/dist/node.js
CHANGED
|
@@ -4122,6 +4122,7 @@ var ABSENT_MS = 2;
|
|
|
4122
4122
|
var ABSENT_NAMES = 4096;
|
|
4123
4123
|
var FILE_HANDLES = 4096;
|
|
4124
4124
|
var STALE = /* @__PURE__ */ new Set(["NotFoundError", "TypeMismatchError"]);
|
|
4125
|
+
var REPLACED_ATTEMPTS = 4;
|
|
4125
4126
|
var EXECUTABLE = /\/node_modules\/(?:@[^/]+\/)?[^/]+\/bin\//;
|
|
4126
4127
|
var ERRNO_BY_DOM_ERROR = {
|
|
4127
4128
|
NotFoundError: "ENOENT",
|
|
@@ -4252,6 +4253,8 @@ var OpfsFs = class {
|
|
|
4252
4253
|
files = new PathMap();
|
|
4253
4254
|
absent = new PathMap();
|
|
4254
4255
|
changes = 0;
|
|
4256
|
+
replacing = Promise.resolve();
|
|
4257
|
+
replacements = 0;
|
|
4255
4258
|
snapshots = /* @__PURE__ */ new WeakMap();
|
|
4256
4259
|
found = /* @__PURE__ */ new WeakMap();
|
|
4257
4260
|
checked = /* @__PURE__ */ new WeakMap();
|
|
@@ -4586,7 +4589,22 @@ var OpfsFs = class {
|
|
|
4586
4589
|
}
|
|
4587
4590
|
return void 0;
|
|
4588
4591
|
}
|
|
4589
|
-
|
|
4592
|
+
locate(path, follow2) {
|
|
4593
|
+
return this.unreplaced(() => this.located(path, follow2));
|
|
4594
|
+
}
|
|
4595
|
+
async unreplaced(op) {
|
|
4596
|
+
for (let attempt = 1; ; attempt++) {
|
|
4597
|
+
const seen = this.replacements;
|
|
4598
|
+
try {
|
|
4599
|
+
return await op();
|
|
4600
|
+
} catch (err) {
|
|
4601
|
+
if (attempt >= REPLACED_ATTEMPTS || !missing2(err)) throw err;
|
|
4602
|
+
await this.replacing;
|
|
4603
|
+
if (this.replacements === seen) throw err;
|
|
4604
|
+
}
|
|
4605
|
+
}
|
|
4606
|
+
}
|
|
4607
|
+
async located(path, follow2) {
|
|
4590
4608
|
let current = path;
|
|
4591
4609
|
for (let hops = 0; hops <= MAX_LINKS5; hops++) {
|
|
4592
4610
|
try {
|
|
@@ -4784,11 +4802,11 @@ var OpfsFs = class {
|
|
|
4784
4802
|
const stat = await this.statOf(found.path, found.handle, meta, touched);
|
|
4785
4803
|
return { ...stat, ...ownOf(meta) ?? inherit(entries) };
|
|
4786
4804
|
}
|
|
4787
|
-
|
|
4788
|
-
return this.describe(await this.
|
|
4805
|
+
stat(path) {
|
|
4806
|
+
return this.unreplaced(async () => this.describe(await this.located(path, true)));
|
|
4789
4807
|
}
|
|
4790
|
-
|
|
4791
|
-
return this.describe(await this.
|
|
4808
|
+
lstat(path) {
|
|
4809
|
+
return this.unreplaced(async () => this.describe(await this.located(path, false)));
|
|
4792
4810
|
}
|
|
4793
4811
|
async exists(path) {
|
|
4794
4812
|
return this.locate(path, true).then(
|
|
@@ -4812,6 +4830,12 @@ var OpfsFs = class {
|
|
|
4812
4830
|
}
|
|
4813
4831
|
}
|
|
4814
4832
|
}
|
|
4833
|
+
reading(path, op) {
|
|
4834
|
+
return this.unreplaced(async () => {
|
|
4835
|
+
const handle = await this.existing(path);
|
|
4836
|
+
return this.retrying(path, () => op(handle), false);
|
|
4837
|
+
});
|
|
4838
|
+
}
|
|
4815
4839
|
async existing(path, writing = false) {
|
|
4816
4840
|
const found = await this.locate(path, true);
|
|
4817
4841
|
if (writing) this.refuse(found.path);
|
|
@@ -4825,52 +4849,35 @@ var OpfsFs = class {
|
|
|
4825
4849
|
if (entry?.fifo || entry?.socket) throw fsError("ENXIO", path);
|
|
4826
4850
|
}
|
|
4827
4851
|
async readFileBuffer(path) {
|
|
4828
|
-
const
|
|
4829
|
-
const bytes = await this.retrying(
|
|
4852
|
+
const bytes = await this.reading(
|
|
4830
4853
|
path,
|
|
4831
|
-
async () => new Uint8Array(await (await handle.getFile()).arrayBuffer())
|
|
4832
|
-
false
|
|
4854
|
+
async (handle) => new Uint8Array(await (await handle.getFile()).arrayBuffer())
|
|
4833
4855
|
);
|
|
4834
4856
|
await this.refuseNode(path, bytes.length === 0);
|
|
4835
4857
|
return bytes;
|
|
4836
4858
|
}
|
|
4837
4859
|
async readVersioned(path, cached = false) {
|
|
4838
|
-
|
|
4839
|
-
|
|
4840
|
-
|
|
4841
|
-
|
|
4842
|
-
|
|
4843
|
-
|
|
4844
|
-
|
|
4845
|
-
await this.refuseNode(path, bytes.length === 0);
|
|
4846
|
-
return { bytes, version: `${file.lastModified}:${file.size}:${stamp}` };
|
|
4847
|
-
},
|
|
4848
|
-
false
|
|
4849
|
-
);
|
|
4860
|
+
return this.reading(path, async (handle) => {
|
|
4861
|
+
const stamp = await this.stamp(path, cached);
|
|
4862
|
+
const file = await handle.getFile();
|
|
4863
|
+
const bytes = new Uint8Array(await file.arrayBuffer());
|
|
4864
|
+
await this.refuseNode(path, bytes.length === 0);
|
|
4865
|
+
return { bytes, version: `${file.lastModified}:${file.size}:${stamp}` };
|
|
4866
|
+
});
|
|
4850
4867
|
}
|
|
4851
4868
|
async version(path, cached = false) {
|
|
4852
|
-
|
|
4853
|
-
|
|
4854
|
-
|
|
4855
|
-
|
|
4856
|
-
|
|
4857
|
-
const file = await handle.getFile();
|
|
4858
|
-
return `${file.lastModified}:${file.size}:${stamp}`;
|
|
4859
|
-
},
|
|
4860
|
-
false
|
|
4861
|
-
);
|
|
4869
|
+
return this.reading(path, async (handle) => {
|
|
4870
|
+
const stamp = await this.stamp(path, cached);
|
|
4871
|
+
const file = await handle.getFile();
|
|
4872
|
+
return `${file.lastModified}:${file.size}:${stamp}`;
|
|
4873
|
+
});
|
|
4862
4874
|
}
|
|
4863
4875
|
async pread(path, offset, length2) {
|
|
4864
|
-
|
|
4865
|
-
|
|
4866
|
-
path,
|
|
4867
|
-
|
|
4868
|
-
|
|
4869
|
-
await this.refuseNode(path, file.size === 0);
|
|
4870
|
-
return new Uint8Array(await file.slice(offset, offset + length2).arrayBuffer());
|
|
4871
|
-
},
|
|
4872
|
-
false
|
|
4873
|
-
);
|
|
4876
|
+
return this.reading(path, async (handle) => {
|
|
4877
|
+
const file = await handle.getFile();
|
|
4878
|
+
await this.refuseNode(path, file.size === 0);
|
|
4879
|
+
return new Uint8Array(await file.slice(offset, offset + length2).arrayBuffer());
|
|
4880
|
+
});
|
|
4874
4881
|
}
|
|
4875
4882
|
async pwrite(path, offset, bytes) {
|
|
4876
4883
|
const [handle, , target] = await this.fileFor(path);
|
|
@@ -5183,7 +5190,10 @@ var OpfsFs = class {
|
|
|
5183
5190
|
const staging = swap ? `.${name2}.${crypto.randomUUID()}` : name2;
|
|
5184
5191
|
this.forget(destination);
|
|
5185
5192
|
const timed2 = await this.explicitTimes(source.path);
|
|
5186
|
-
const moved2 = await this.
|
|
5193
|
+
const moved2 = await this.replacingTarget(
|
|
5194
|
+
targetStat !== null,
|
|
5195
|
+
() => this.place(source.handle, dir, staging)
|
|
5196
|
+
);
|
|
5187
5197
|
if (swap) await this.rm(destination, { recursive: true });
|
|
5188
5198
|
await this.meta.move(source.path, destination, carry);
|
|
5189
5199
|
this.movePending(source.path, destination);
|
|
@@ -5199,6 +5209,21 @@ var OpfsFs = class {
|
|
|
5199
5209
|
this.changed(source.path, destination);
|
|
5200
5210
|
this.touch(Date.now(), parentOf4(source.path), parent.path);
|
|
5201
5211
|
}
|
|
5212
|
+
async replacingTarget(replaces, op) {
|
|
5213
|
+
if (!replaces) return op();
|
|
5214
|
+
const { promise, resolve: resolve2 } = Promise.withResolvers();
|
|
5215
|
+
const before = this.replacing;
|
|
5216
|
+
this.replacing = Promise.all([before, promise]).then(() => void 0);
|
|
5217
|
+
this.replacements++;
|
|
5218
|
+
this.changes++;
|
|
5219
|
+
try {
|
|
5220
|
+
return await op();
|
|
5221
|
+
} finally {
|
|
5222
|
+
this.replacements++;
|
|
5223
|
+
this.changes++;
|
|
5224
|
+
resolve2();
|
|
5225
|
+
}
|
|
5226
|
+
}
|
|
5202
5227
|
async modified(path) {
|
|
5203
5228
|
const handle = await this.handle(path);
|
|
5204
5229
|
return handle.kind === "file" ? (await handle.getFile()).lastModified : 0;
|
|
@@ -5401,6 +5426,16 @@ function pidOwner(proc) {
|
|
|
5401
5426
|
function webLocks() {
|
|
5402
5427
|
return globalThis.navigator?.locks;
|
|
5403
5428
|
}
|
|
5429
|
+
var LOOKUP_OPS = [
|
|
5430
|
+
"exists",
|
|
5431
|
+
"readFile",
|
|
5432
|
+
"readFileBuffer",
|
|
5433
|
+
"readVersioned",
|
|
5434
|
+
"version",
|
|
5435
|
+
"pread",
|
|
5436
|
+
"readlink",
|
|
5437
|
+
"realpath"
|
|
5438
|
+
];
|
|
5404
5439
|
var within4 = (path, target) => path === target || target === "/" || path.startsWith(`${target}/`);
|
|
5405
5440
|
var parentOf5 = (path) => path.slice(0, path.lastIndexOf("/")) || "/";
|
|
5406
5441
|
var lockName = (instance) => `slicc-unlinked:${instance}`;
|
|
@@ -5439,6 +5474,8 @@ var UnlinkedKeeper = class {
|
|
|
5439
5474
|
gate = new PathGate();
|
|
5440
5475
|
queue = Promise.resolve();
|
|
5441
5476
|
count = 0;
|
|
5477
|
+
replacing = /* @__PURE__ */ new Map();
|
|
5478
|
+
replaced = 0;
|
|
5442
5479
|
links = /* @__PURE__ */ new Map();
|
|
5443
5480
|
linked = /* @__PURE__ */ new Map();
|
|
5444
5481
|
dirOwner;
|
|
@@ -5461,6 +5498,44 @@ var UnlinkedKeeper = class {
|
|
|
5461
5498
|
}
|
|
5462
5499
|
wrap(fs = this.fs) {
|
|
5463
5500
|
const keeper = this;
|
|
5501
|
+
const { replacing } = this;
|
|
5502
|
+
const replace = async (target, op) => {
|
|
5503
|
+
const before = replacing.get(target);
|
|
5504
|
+
const { promise, resolve: resolve2 } = Promise.withResolvers();
|
|
5505
|
+
const mine = {
|
|
5506
|
+
done: Promise.all([before?.done, promise]).then(() => void 0)
|
|
5507
|
+
};
|
|
5508
|
+
replacing.set(target, mine);
|
|
5509
|
+
try {
|
|
5510
|
+
await op();
|
|
5511
|
+
} finally {
|
|
5512
|
+
keeper.replaced += 1;
|
|
5513
|
+
resolve2();
|
|
5514
|
+
if (replacing.get(target) === mine) replacing.delete(target);
|
|
5515
|
+
}
|
|
5516
|
+
};
|
|
5517
|
+
const unreplaced = async (path, op) => {
|
|
5518
|
+
const at = fs.resolvePath("/", path);
|
|
5519
|
+
for (let attempt = 1; ; attempt++) {
|
|
5520
|
+
await replacing.get(at)?.done;
|
|
5521
|
+
const seen = keeper.replaced;
|
|
5522
|
+
try {
|
|
5523
|
+
return await op();
|
|
5524
|
+
} catch (err) {
|
|
5525
|
+
const code = err?.code;
|
|
5526
|
+
if (attempt >= 3 || code !== "ENOENT") throw err;
|
|
5527
|
+
await replacing.get(at)?.done;
|
|
5528
|
+
if (keeper.replaced === seen) throw err;
|
|
5529
|
+
}
|
|
5530
|
+
}
|
|
5531
|
+
};
|
|
5532
|
+
const looking = (name2) => {
|
|
5533
|
+
const call = fs[name2];
|
|
5534
|
+
if (!call) return {};
|
|
5535
|
+
return {
|
|
5536
|
+
[name2]: (path, ...rest2) => unreplaced(path, () => call.call(fs, path, ...rest2))
|
|
5537
|
+
};
|
|
5538
|
+
};
|
|
5464
5539
|
const visible = (names) => names.filter((name2) => name2 !== UNLINKED_DIR);
|
|
5465
5540
|
const counted3 = (st) => {
|
|
5466
5541
|
const hidden = keeper.links.get(`${st.dev ?? 0}:${st.ino}`) ?? 0;
|
|
@@ -5468,9 +5543,10 @@ var UnlinkedKeeper = class {
|
|
|
5468
5543
|
};
|
|
5469
5544
|
return {
|
|
5470
5545
|
...fs,
|
|
5546
|
+
...LOOKUP_OPS.reduce((all, name2) => Object.assign(all, looking(name2)), {}),
|
|
5471
5547
|
links: (path) => mayLink(fs, path),
|
|
5472
|
-
stat: async (
|
|
5473
|
-
lstat: async (
|
|
5548
|
+
stat: (path) => unreplaced(path, async () => counted3(await fs.stat(path))),
|
|
5549
|
+
lstat: (path) => unreplaced(path, async () => counted3(await fs.lstat(path))),
|
|
5474
5550
|
async rm(path, options) {
|
|
5475
5551
|
const target = fs.resolvePath("/", path);
|
|
5476
5552
|
const pinned = await keeper.pin(target);
|
|
@@ -5480,8 +5556,10 @@ var UnlinkedKeeper = class {
|
|
|
5480
5556
|
async rename(from, to) {
|
|
5481
5557
|
const target = fs.resolvePath("/", to);
|
|
5482
5558
|
if (target === fs.resolvePath("/", from)) return fs.rename(from, to);
|
|
5483
|
-
|
|
5484
|
-
|
|
5559
|
+
await replace(target, async () => {
|
|
5560
|
+
const pinned = await keeper.pin(target);
|
|
5561
|
+
await keeper.settle(pinned, () => fs.rename(from, to));
|
|
5562
|
+
});
|
|
5485
5563
|
},
|
|
5486
5564
|
readdir: async (path) => visible(await fs.readdir(path)),
|
|
5487
5565
|
readdirStat: async (path) => (await fs.readdirStat(path)).filter(([name2]) => name2 !== UNLINKED_DIR).map(([name2, st]) => [name2, st && counted3(st)])
|
|
@@ -6578,7 +6656,7 @@ function satisfies(version, range2) {
|
|
|
6578
6656
|
}
|
|
6579
6657
|
|
|
6580
6658
|
// src/version.ts
|
|
6581
|
-
var KERNEL_VERSION = true ? "1.117.
|
|
6659
|
+
var KERNEL_VERSION = true ? "1.117.2" : "0.0.0-dev";
|
|
6582
6660
|
var OS_RELEASE = "6.0.0-slicc";
|
|
6583
6661
|
function procVersion() {
|
|
6584
6662
|
return `Linux version ${OS_RELEASE} (slicc-kernel ${KERNEL_VERSION}) #1 SMP PREEMPT_DYNAMIC
|