@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.
@@ -20977,7 +20977,7 @@ import { homedir } from "os";
20977
20977
  import { mkdir, readFile, writeFile, unlink } from "fs/promises";
20978
20978
 
20979
20979
  // src/version.ts
20980
- var PACKAGE_VERSION = "0.14.2";
20980
+ var PACKAGE_VERSION = "0.14.3";
20981
20981
 
20982
20982
  // src/store.ts
20983
20983
  var match = PACKAGE_VERSION.match(/^([^.]*\.[^.]*)/);
@@ -27413,7 +27413,7 @@ var import_err_code7 = __toESM(require_err_code(), 1);
27413
27413
  // ../../node_modules/.pnpm/ipfs-unixfs@11.0.2/node_modules/ipfs-unixfs/dist/src/index.js
27414
27414
  var import_err_code5 = __toESM(require_err_code(), 1);
27415
27415
 
27416
- // ../../node_modules/.pnpm/protons-runtime@5.0.2_uint8arraylist@2.4.3/node_modules/protons-runtime/dist/src/utils.js
27416
+ // ../../node_modules/.pnpm/protons-runtime@5.0.2/node_modules/protons-runtime/dist/src/utils.js
27417
27417
  var import_reader3 = __toESM(require_reader(), 1);
27418
27418
  var import_reader_buffer = __toESM(require_reader_buffer(), 1);
27419
27419
  var import_minimal2 = __toESM(require_minimal(), 1);
@@ -27463,13 +27463,13 @@ function writer() {
27463
27463
  return patchWriter(import_writer2.default.create());
27464
27464
  }
27465
27465
 
27466
- // ../../node_modules/.pnpm/protons-runtime@5.0.2_uint8arraylist@2.4.3/node_modules/protons-runtime/dist/src/decode.js
27466
+ // ../../node_modules/.pnpm/protons-runtime@5.0.2/node_modules/protons-runtime/dist/src/decode.js
27467
27467
  function decodeMessage(buf3, codec) {
27468
27468
  const r = reader(buf3 instanceof Uint8Array ? buf3 : buf3.subarray());
27469
27469
  return codec.decode(r);
27470
27470
  }
27471
27471
 
27472
- // ../../node_modules/.pnpm/protons-runtime@5.0.2_uint8arraylist@2.4.3/node_modules/protons-runtime/dist/src/encode.js
27472
+ // ../../node_modules/.pnpm/protons-runtime@5.0.2/node_modules/protons-runtime/dist/src/encode.js
27473
27473
  function encodeMessage(message2, codec) {
27474
27474
  const w = writer();
27475
27475
  codec.encode(message2, w, {
@@ -27478,7 +27478,7 @@ function encodeMessage(message2, codec) {
27478
27478
  return w.finish();
27479
27479
  }
27480
27480
 
27481
- // ../../node_modules/.pnpm/protons-runtime@5.0.2_uint8arraylist@2.4.3/node_modules/protons-runtime/dist/src/codec.js
27481
+ // ../../node_modules/.pnpm/protons-runtime@5.0.2/node_modules/protons-runtime/dist/src/codec.js
27482
27482
  var CODEC_TYPES;
27483
27483
  (function(CODEC_TYPES2) {
27484
27484
  CODEC_TYPES2[CODEC_TYPES2["VARINT"] = 0] = "VARINT";
@@ -27497,7 +27497,7 @@ function createCodec(name8, type2, encode19, decode21) {
27497
27497
  };
27498
27498
  }
27499
27499
 
27500
- // ../../node_modules/.pnpm/protons-runtime@5.0.2_uint8arraylist@2.4.3/node_modules/protons-runtime/dist/src/codecs/enum.js
27500
+ // ../../node_modules/.pnpm/protons-runtime@5.0.2/node_modules/protons-runtime/dist/src/codecs/enum.js
27501
27501
  function enumeration(v) {
27502
27502
  function findValue(val) {
27503
27503
  if (v[val.toString()] == null) {
@@ -27516,7 +27516,7 @@ function enumeration(v) {
27516
27516
  return createCodec("enum", CODEC_TYPES.VARINT, encode19, decode21);
27517
27517
  }
27518
27518
 
27519
- // ../../node_modules/.pnpm/protons-runtime@5.0.2_uint8arraylist@2.4.3/node_modules/protons-runtime/dist/src/codecs/message.js
27519
+ // ../../node_modules/.pnpm/protons-runtime@5.0.2/node_modules/protons-runtime/dist/src/codecs/message.js
27520
27520
  function message(encode19, decode21) {
27521
27521
  return createCodec("message", CODEC_TYPES.LENGTH_DELIMITED, encode19, decode21);
27522
27522
  }
@@ -30369,7 +30369,7 @@ var DbLoader = class _DbLoader extends Loader {
30369
30369
  this.isCompacting = true;
30370
30370
  const compactHead = this.clock.head;
30371
30371
  const compactingResult = await doCompact(blocks, this.clock.head);
30372
- await this.clock.applyHead(null, compactHead, compactHead, null);
30372
+ await this.clock.applyHead(compactHead, compactHead, null);
30373
30373
  return compactingResult;
30374
30374
  };
30375
30375
  this.compacting = this._setWaitForWrite(compactingFn);
@@ -30384,9 +30384,9 @@ var DbLoader = class _DbLoader extends Loader {
30384
30384
  }
30385
30385
  async _applyCarHeader(carHeader, snap = false) {
30386
30386
  if (snap) {
30387
- await this.clock.applyHead(null, carHeader.head, this.clock.head);
30387
+ await this.clock.applyHead(carHeader.head, this.clock.head);
30388
30388
  } else {
30389
- await this.clock.applyHead(null, carHeader.head, []);
30389
+ await this.clock.applyHead(carHeader.head, []);
30390
30390
  }
30391
30391
  }
30392
30392
  makeCarHeader(result, cars, compact = false) {
@@ -30542,7 +30542,7 @@ function applyHeadQueue(worker) {
30542
30542
  const task = queue.shift();
30543
30543
  if (!task)
30544
30544
  continue;
30545
- await worker(task.id, task.tblocks, task.newHead, task.prevHead, task.updates);
30545
+ await worker(task.id, task.newHead, task.prevHead, task.updates);
30546
30546
  if (task.updates) {
30547
30547
  allUpdates.push(...task.updates);
30548
30548
  }
@@ -30586,18 +30586,18 @@ var CRDTClock = class {
30586
30586
  setHead(head) {
30587
30587
  this.head = head;
30588
30588
  }
30589
- async applyHead(tblocks, newHead, prevHead, updates = null) {
30589
+ async applyHead(newHead, prevHead, updates = null) {
30590
30590
  const taskId = Math.random().toString().slice(2, 8);
30591
30591
  for await (const { updates: updatesAcc, all } of this.applyHeadQueue.push({
30592
30592
  id: taskId,
30593
- tblocks,
30593
+ // tblocks,
30594
30594
  newHead,
30595
30595
  prevHead,
30596
30596
  updates
30597
30597
  })) {
30598
30598
  ;
30599
- (async (updatesAcc2, all2) => {
30600
- Promise.resolve().then(async () => {
30599
+ ((updatesAcc2, all2) => {
30600
+ void Promise.resolve().then(async () => {
30601
30601
  let intUpdates = updatesAcc2;
30602
30602
  if (this.watchers.size && !all2) {
30603
30603
  const changes = await clockChangesSince(this.blocks, this.head, prevHead, {});
@@ -30609,11 +30609,11 @@ var CRDTClock = class {
30609
30609
  })([...updatesAcc], all);
30610
30610
  }
30611
30611
  }
30612
- async int_applyHead(taskId, tblocks, newHead, prevHead, updates = null) {
30612
+ async int_applyHead(taskId, newHead, prevHead) {
30613
30613
  const ogHead = this.head.sort((a, b) => a.toString().localeCompare(b.toString()));
30614
30614
  newHead = newHead.sort((a, b) => a.toString().localeCompare(b.toString()));
30615
- newHead.map((cid) => {
30616
- const got = this.blocks.get(cid);
30615
+ newHead.map(async (cid) => {
30616
+ const got = await this.blocks.get(cid);
30617
30617
  if (!got) {
30618
30618
  throw new Error("int_applyHead missing block: " + cid.toString());
30619
30619
  }
@@ -30628,23 +30628,23 @@ var CRDTClock = class {
30628
30628
  }
30629
30629
  let head = this.head;
30630
30630
  const noLoader = false;
30631
- const withBlocks = async (tblocks2, fn) => {
30631
+ const withBlocks = async (fn) => {
30632
30632
  if (!this.blocks)
30633
30633
  throw new Error("missing blocks");
30634
30634
  return await this.blocks.transaction(fn, void 0, { noLoader });
30635
30635
  };
30636
- await withBlocks(tblocks, async (tblocks2) => {
30636
+ await withBlocks(async (tblocks) => {
30637
30637
  for (const cid of newHead) {
30638
30638
  try {
30639
- head = await advance(tblocks2, head, cid);
30639
+ head = await advance(tblocks, head, cid);
30640
30640
  } catch (e) {
30641
30641
  console.error("failed to advance", cid.toString(), e);
30642
30642
  continue;
30643
30643
  }
30644
30644
  }
30645
- const result = await root(tblocks2, head);
30645
+ const result = await root(tblocks, head);
30646
30646
  for (const { cid, bytes } of [...result.additions, ...result.removals]) {
30647
- tblocks2.putSync(cid, bytes);
30647
+ tblocks.putSync(cid, bytes);
30648
30648
  }
30649
30649
  return { head };
30650
30650
  });
@@ -30723,7 +30723,7 @@ var CRDT = class {
30723
30723
  }
30724
30724
  return { head };
30725
30725
  });
30726
- await this.clock.applyHead(null, got.head, prevHead, updates);
30726
+ await this.clock.applyHead(got.head, prevHead, updates);
30727
30727
  return got;
30728
30728
  })();
30729
30729
  if (loader) {
@@ -30758,7 +30758,7 @@ var CRDT = class {
30758
30758
  return await getBlock(this.blocks, cidString);
30759
30759
  }
30760
30760
  async getThatBlock() {
30761
- const blockJson = { "cid": "bafyreib7ee4pscqpuioxobmh3ac5xbbslypmaqqbkugalhw67hnco6dvoa", "bytes": "omRkYXRhpGNrZXl4JDAxOGFmNzdiLWZmMTUtNzI5Ny04ODZiLTYwMjViM2MxODI2ZWRyb2902CpYJQABcRIgKVLI53HO1TFDbPUoSaybd0mop2oX/CRFm1RrpiY4ne9kdHlwZWNwdXRldmFsdWXYKlglAAFxEiAGw53MVtPzeeGT/itfdLBfCVu6MTj96AHU6v9a3K/wYGdwYXJlbnRzgdgqWCUAAXESIJiL5qjdpgghUfbQLpKJeCgMX+ubhoTpYBoZHYdzbQJ/" };
30761
+ const blockJson = { cid: "bafyreib7ee4pscqpuioxobmh3ac5xbbslypmaqqbkugalhw67hnco6dvoa", bytes: "omRkYXRhpGNrZXl4JDAxOGFmNzdiLWZmMTUtNzI5Ny04ODZiLTYwMjViM2MxODI2ZWRyb2902CpYJQABcRIgKVLI53HO1TFDbPUoSaybd0mop2oX/CRFm1RrpiY4ne9kdHlwZWNwdXRldmFsdWXYKlglAAFxEiAGw53MVtPzeeGT/itfdLBfCVu6MTj96AHU6v9a3K/wYGdwYXJlbnRzgdgqWCUAAXESIJiL5qjdpgghUfbQLpKJeCgMX+ubhoTpYBoZHYdzbQJ/" };
30762
30762
  return await getThatBlock(blockJson);
30763
30763
  }
30764
30764
  async get(key) {