@ai-ecoverse/slicc-kernel 1.146.4 → 1.146.5

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.
@@ -7156,7 +7156,7 @@ var KERNEL_VERSION, OS_RELEASE;
7156
7156
  var init_version = __esm({
7157
7157
  "src/version.ts"() {
7158
7158
  "use strict";
7159
- KERNEL_VERSION = true ? "1.146.4" : "0.0.0-dev";
7159
+ KERNEL_VERSION = true ? "1.146.5" : "0.0.0-dev";
7160
7160
  OS_RELEASE = "6.0.0-slicc";
7161
7161
  }
7162
7162
  });
package/dist/node.js CHANGED
@@ -3305,7 +3305,7 @@ function satisfies(version, range2) {
3305
3305
  }
3306
3306
 
3307
3307
  // src/version.ts
3308
- var KERNEL_VERSION = true ? "1.146.4" : "0.0.0-dev";
3308
+ var KERNEL_VERSION = true ? "1.146.5" : "0.0.0-dev";
3309
3309
  var OS_RELEASE = "6.0.0-slicc";
3310
3310
  function procVersion() {
3311
3311
  return `Linux version ${OS_RELEASE} (slicc-kernel ${KERNEL_VERSION}) #1 SMP PREEMPT_DYNAMIC
@@ -23359,6 +23359,28 @@ function prefixes(path) {
23359
23359
  function within9(path, root) {
23360
23360
  return path === root || path.startsWith(`${root}/`);
23361
23361
  }
23362
+ var unstored = () => Object.assign(new Error("the file system kept fewer bytes than were written"), {
23363
+ code: "ENOSPC"
23364
+ });
23365
+ var CHECKED_BYTES = 16 * 1024 * 1024;
23366
+ var Extent = class {
23367
+ floor = 0;
23368
+ exact;
23369
+ wrote(end) {
23370
+ this.floor = Math.max(this.floor, end);
23371
+ if (this.exact !== void 0) this.exact = Math.max(this.exact, end);
23372
+ }
23373
+ cut(size) {
23374
+ this.exact = size;
23375
+ this.floor = Math.min(this.floor, size);
23376
+ }
23377
+ big() {
23378
+ return Math.max(this.floor, this.exact ?? 0) >= CHECKED_BYTES;
23379
+ }
23380
+ check(size) {
23381
+ if (size < this.floor || this.exact !== void 0 && size < this.exact) throw unstored();
23382
+ }
23383
+ };
23362
23384
  var LOCKED = /* @__PURE__ */ new Set(["NotReadableError", "NoModificationAllowedError", "InvalidStateError"]);
23363
23385
  var SYNC_BACKOFF_MS = [5, 10, 20, 40, 80];
23364
23386
  async function openSync(handle) {
@@ -23384,14 +23406,22 @@ function writeAll5(access2, at, bytes) {
23384
23406
  }
23385
23407
  }
23386
23408
  async function positioned(handle, op) {
23409
+ const extent = new Extent();
23387
23410
  const access2 = await openSync(handle);
23388
23411
  if (access2) {
23389
23412
  try {
23390
23413
  op({
23391
- write: (at, bytes) => writeAll5(access2, at, bytes),
23392
- truncate: (n) => access2.truncate(n)
23414
+ write: (at, bytes) => {
23415
+ writeAll5(access2, at, bytes);
23416
+ extent.wrote(at + bytes.length);
23417
+ },
23418
+ truncate: (n) => {
23419
+ access2.truncate(n);
23420
+ extent.cut(n);
23421
+ }
23393
23422
  });
23394
23423
  access2.flush();
23424
+ if (access2.getSize) extent.check(access2.getSize());
23395
23425
  } finally {
23396
23426
  access2.close();
23397
23427
  }
@@ -23400,14 +23430,25 @@ async function positioned(handle, op) {
23400
23430
  const writable2 = await handle.createWritable({ keepExistingData: true });
23401
23431
  try {
23402
23432
  await op({
23403
- write: (at, bytes) => writable2.write({ type: "write", position: at, data: bytes }),
23404
- truncate: (n) => writable2.truncate(n)
23433
+ write: async (at, bytes) => {
23434
+ await writable2.write({
23435
+ type: "write",
23436
+ position: at,
23437
+ data: bytes
23438
+ });
23439
+ extent.wrote(at + bytes.length);
23440
+ },
23441
+ truncate: async (n) => {
23442
+ await writable2.truncate(n);
23443
+ extent.cut(n);
23444
+ }
23405
23445
  });
23406
23446
  } catch (err) {
23407
23447
  await writable2.abort();
23408
23448
  throw err;
23409
23449
  }
23410
23450
  await writable2.close();
23451
+ if (extent.big()) extent.check((await handle.getFile()).size);
23411
23452
  }
23412
23453
  function isHandle(child) {
23413
23454
  return "kind" in child;
@@ -24382,6 +24423,11 @@ var OpfsFs = class {
24382
24423
  writable2 = await this.io(file.createWritable());
24383
24424
  await writable2.write(content);
24384
24425
  await writable2.close();
24426
+ if (typeof content !== "string" && content.length >= CHECKED_BYTES) {
24427
+ const extent = new Extent();
24428
+ extent.cut(content.length);
24429
+ extent.check((await file.getFile()).size);
24430
+ }
24385
24431
  } catch (err) {
24386
24432
  await writable2?.abort().catch(() => void 0);
24387
24433
  throw translate(err, path, "commit", false);