@fireproof/core 0.14.2 → 0.14.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -20987,7 +20987,7 @@ var import_os = require("os");
20987
20987
  var import_promises = require("fs/promises");
20988
20988
 
20989
20989
  // src/version.ts
20990
- var PACKAGE_VERSION = "0.14.2";
20990
+ var PACKAGE_VERSION = "0.14.3";
20991
20991
 
20992
20992
  // src/store.ts
20993
20993
  var match = PACKAGE_VERSION.match(/^([^.]*\.[^.]*)/);
@@ -27423,7 +27423,7 @@ var import_err_code7 = __toESM(require_err_code(), 1);
27423
27423
  // ../../node_modules/.pnpm/ipfs-unixfs@11.0.2/node_modules/ipfs-unixfs/dist/src/index.js
27424
27424
  var import_err_code5 = __toESM(require_err_code(), 1);
27425
27425
 
27426
- // ../../node_modules/.pnpm/protons-runtime@5.0.2_uint8arraylist@2.4.3/node_modules/protons-runtime/dist/src/utils.js
27426
+ // ../../node_modules/.pnpm/protons-runtime@5.0.2/node_modules/protons-runtime/dist/src/utils.js
27427
27427
  var import_reader3 = __toESM(require_reader(), 1);
27428
27428
  var import_reader_buffer = __toESM(require_reader_buffer(), 1);
27429
27429
  var import_minimal2 = __toESM(require_minimal(), 1);
@@ -27473,13 +27473,13 @@ function writer() {
27473
27473
  return patchWriter(import_writer2.default.create());
27474
27474
  }
27475
27475
 
27476
- // ../../node_modules/.pnpm/protons-runtime@5.0.2_uint8arraylist@2.4.3/node_modules/protons-runtime/dist/src/decode.js
27476
+ // ../../node_modules/.pnpm/protons-runtime@5.0.2/node_modules/protons-runtime/dist/src/decode.js
27477
27477
  function decodeMessage(buf3, codec) {
27478
27478
  const r = reader(buf3 instanceof Uint8Array ? buf3 : buf3.subarray());
27479
27479
  return codec.decode(r);
27480
27480
  }
27481
27481
 
27482
- // ../../node_modules/.pnpm/protons-runtime@5.0.2_uint8arraylist@2.4.3/node_modules/protons-runtime/dist/src/encode.js
27482
+ // ../../node_modules/.pnpm/protons-runtime@5.0.2/node_modules/protons-runtime/dist/src/encode.js
27483
27483
  function encodeMessage(message2, codec) {
27484
27484
  const w = writer();
27485
27485
  codec.encode(message2, w, {
@@ -27488,7 +27488,7 @@ function encodeMessage(message2, codec) {
27488
27488
  return w.finish();
27489
27489
  }
27490
27490
 
27491
- // ../../node_modules/.pnpm/protons-runtime@5.0.2_uint8arraylist@2.4.3/node_modules/protons-runtime/dist/src/codec.js
27491
+ // ../../node_modules/.pnpm/protons-runtime@5.0.2/node_modules/protons-runtime/dist/src/codec.js
27492
27492
  var CODEC_TYPES;
27493
27493
  (function(CODEC_TYPES2) {
27494
27494
  CODEC_TYPES2[CODEC_TYPES2["VARINT"] = 0] = "VARINT";
@@ -27507,7 +27507,7 @@ function createCodec(name8, type2, encode19, decode21) {
27507
27507
  };
27508
27508
  }
27509
27509
 
27510
- // ../../node_modules/.pnpm/protons-runtime@5.0.2_uint8arraylist@2.4.3/node_modules/protons-runtime/dist/src/codecs/enum.js
27510
+ // ../../node_modules/.pnpm/protons-runtime@5.0.2/node_modules/protons-runtime/dist/src/codecs/enum.js
27511
27511
  function enumeration(v) {
27512
27512
  function findValue(val) {
27513
27513
  if (v[val.toString()] == null) {
@@ -27526,7 +27526,7 @@ function enumeration(v) {
27526
27526
  return createCodec("enum", CODEC_TYPES.VARINT, encode19, decode21);
27527
27527
  }
27528
27528
 
27529
- // ../../node_modules/.pnpm/protons-runtime@5.0.2_uint8arraylist@2.4.3/node_modules/protons-runtime/dist/src/codecs/message.js
27529
+ // ../../node_modules/.pnpm/protons-runtime@5.0.2/node_modules/protons-runtime/dist/src/codecs/message.js
27530
27530
  function message(encode19, decode21) {
27531
27531
  return createCodec("message", CODEC_TYPES.LENGTH_DELIMITED, encode19, decode21);
27532
27532
  }
@@ -30379,7 +30379,7 @@ var DbLoader = class _DbLoader extends Loader {
30379
30379
  this.isCompacting = true;
30380
30380
  const compactHead = this.clock.head;
30381
30381
  const compactingResult = await doCompact(blocks, this.clock.head);
30382
- await this.clock.applyHead(null, compactHead, compactHead, null);
30382
+ await this.clock.applyHead(compactHead, compactHead, null);
30383
30383
  return compactingResult;
30384
30384
  };
30385
30385
  this.compacting = this._setWaitForWrite(compactingFn);
@@ -30394,9 +30394,9 @@ var DbLoader = class _DbLoader extends Loader {
30394
30394
  }
30395
30395
  async _applyCarHeader(carHeader, snap = false) {
30396
30396
  if (snap) {
30397
- await this.clock.applyHead(null, carHeader.head, this.clock.head);
30397
+ await this.clock.applyHead(carHeader.head, this.clock.head);
30398
30398
  } else {
30399
- await this.clock.applyHead(null, carHeader.head, []);
30399
+ await this.clock.applyHead(carHeader.head, []);
30400
30400
  }
30401
30401
  }
30402
30402
  makeCarHeader(result, cars, compact = false) {
@@ -30552,7 +30552,7 @@ function applyHeadQueue(worker) {
30552
30552
  const task = queue.shift();
30553
30553
  if (!task)
30554
30554
  continue;
30555
- await worker(task.id, task.tblocks, task.newHead, task.prevHead, task.updates);
30555
+ await worker(task.id, task.newHead, task.prevHead, task.updates);
30556
30556
  if (task.updates) {
30557
30557
  allUpdates.push(...task.updates);
30558
30558
  }
@@ -30596,18 +30596,18 @@ var CRDTClock = class {
30596
30596
  setHead(head) {
30597
30597
  this.head = head;
30598
30598
  }
30599
- async applyHead(tblocks, newHead, prevHead, updates = null) {
30599
+ async applyHead(newHead, prevHead, updates = null) {
30600
30600
  const taskId = Math.random().toString().slice(2, 8);
30601
30601
  for await (const { updates: updatesAcc, all } of this.applyHeadQueue.push({
30602
30602
  id: taskId,
30603
- tblocks,
30603
+ // tblocks,
30604
30604
  newHead,
30605
30605
  prevHead,
30606
30606
  updates
30607
30607
  })) {
30608
30608
  ;
30609
- (async (updatesAcc2, all2) => {
30610
- Promise.resolve().then(async () => {
30609
+ ((updatesAcc2, all2) => {
30610
+ void Promise.resolve().then(async () => {
30611
30611
  let intUpdates = updatesAcc2;
30612
30612
  if (this.watchers.size && !all2) {
30613
30613
  const changes = await clockChangesSince(this.blocks, this.head, prevHead, {});
@@ -30619,11 +30619,11 @@ var CRDTClock = class {
30619
30619
  })([...updatesAcc], all);
30620
30620
  }
30621
30621
  }
30622
- async int_applyHead(taskId, tblocks, newHead, prevHead, updates = null) {
30622
+ async int_applyHead(taskId, newHead, prevHead) {
30623
30623
  const ogHead = this.head.sort((a, b) => a.toString().localeCompare(b.toString()));
30624
30624
  newHead = newHead.sort((a, b) => a.toString().localeCompare(b.toString()));
30625
- newHead.map((cid) => {
30626
- const got = this.blocks.get(cid);
30625
+ newHead.map(async (cid) => {
30626
+ const got = await this.blocks.get(cid);
30627
30627
  if (!got) {
30628
30628
  throw new Error("int_applyHead missing block: " + cid.toString());
30629
30629
  }
@@ -30638,23 +30638,23 @@ var CRDTClock = class {
30638
30638
  }
30639
30639
  let head = this.head;
30640
30640
  const noLoader = false;
30641
- const withBlocks = async (tblocks2, fn) => {
30641
+ const withBlocks = async (fn) => {
30642
30642
  if (!this.blocks)
30643
30643
  throw new Error("missing blocks");
30644
30644
  return await this.blocks.transaction(fn, void 0, { noLoader });
30645
30645
  };
30646
- await withBlocks(tblocks, async (tblocks2) => {
30646
+ await withBlocks(async (tblocks) => {
30647
30647
  for (const cid of newHead) {
30648
30648
  try {
30649
- head = await advance(tblocks2, head, cid);
30649
+ head = await advance(tblocks, head, cid);
30650
30650
  } catch (e) {
30651
30651
  console.error("failed to advance", cid.toString(), e);
30652
30652
  continue;
30653
30653
  }
30654
30654
  }
30655
- const result = await root(tblocks2, head);
30655
+ const result = await root(tblocks, head);
30656
30656
  for (const { cid, bytes } of [...result.additions, ...result.removals]) {
30657
- tblocks2.putSync(cid, bytes);
30657
+ tblocks.putSync(cid, bytes);
30658
30658
  }
30659
30659
  return { head };
30660
30660
  });
@@ -30733,7 +30733,7 @@ var CRDT = class {
30733
30733
  }
30734
30734
  return { head };
30735
30735
  });
30736
- await this.clock.applyHead(null, got.head, prevHead, updates);
30736
+ await this.clock.applyHead(got.head, prevHead, updates);
30737
30737
  return got;
30738
30738
  })();
30739
30739
  if (loader) {
@@ -30768,7 +30768,7 @@ var CRDT = class {
30768
30768
  return await getBlock(this.blocks, cidString);
30769
30769
  }
30770
30770
  async getThatBlock() {
30771
- const blockJson = { "cid": "bafyreib7ee4pscqpuioxobmh3ac5xbbslypmaqqbkugalhw67hnco6dvoa", "bytes": "omRkYXRhpGNrZXl4JDAxOGFmNzdiLWZmMTUtNzI5Ny04ODZiLTYwMjViM2MxODI2ZWRyb2902CpYJQABcRIgKVLI53HO1TFDbPUoSaybd0mop2oX/CRFm1RrpiY4ne9kdHlwZWNwdXRldmFsdWXYKlglAAFxEiAGw53MVtPzeeGT/itfdLBfCVu6MTj96AHU6v9a3K/wYGdwYXJlbnRzgdgqWCUAAXESIJiL5qjdpgghUfbQLpKJeCgMX+ubhoTpYBoZHYdzbQJ/" };
30771
+ const blockJson = { cid: "bafyreib7ee4pscqpuioxobmh3ac5xbbslypmaqqbkugalhw67hnco6dvoa", bytes: "omRkYXRhpGNrZXl4JDAxOGFmNzdiLWZmMTUtNzI5Ny04ODZiLTYwMjViM2MxODI2ZWRyb2902CpYJQABcRIgKVLI53HO1TFDbPUoSaybd0mop2oX/CRFm1RrpiY4ne9kdHlwZWNwdXRldmFsdWXYKlglAAFxEiAGw53MVtPzeeGT/itfdLBfCVu6MTj96AHU6v9a3K/wYGdwYXJlbnRzgdgqWCUAAXESIJiL5qjdpgghUfbQLpKJeCgMX+ubhoTpYBoZHYdzbQJ/" };
30772
30772
  return await getThatBlock(blockJson);
30773
30773
  }
30774
30774
  async get(key) {