@fireproof/core 0.14.2 → 0.14.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -11583,7 +11583,7 @@ replaceTraps((oldTraps) => ({
11583
11583
  }));
11584
11584
 
11585
11585
  // src/version.ts
11586
- var PACKAGE_VERSION = "0.14.2";
11586
+ var PACKAGE_VERSION = "0.14.4";
11587
11587
 
11588
11588
  // src/store.ts
11589
11589
  var match = PACKAGE_VERSION.match(/^([^.]*\.[^.]*)/);
@@ -18065,7 +18065,7 @@ var import_err_code7 = __toESM(require_err_code(), 1);
18065
18065
  // ../../node_modules/.pnpm/ipfs-unixfs@11.0.2/node_modules/ipfs-unixfs/dist/src/index.js
18066
18066
  var import_err_code5 = __toESM(require_err_code(), 1);
18067
18067
 
18068
- // ../../node_modules/.pnpm/protons-runtime@5.0.2_uint8arraylist@2.4.3/node_modules/protons-runtime/dist/src/utils.js
18068
+ // ../../node_modules/.pnpm/protons-runtime@5.0.2/node_modules/protons-runtime/dist/src/utils.js
18069
18069
  var import_reader3 = __toESM(require_reader(), 1);
18070
18070
  var import_reader_buffer = __toESM(require_reader_buffer(), 1);
18071
18071
  var import_minimal2 = __toESM(require_minimal(), 1);
@@ -18115,13 +18115,13 @@ function writer() {
18115
18115
  return patchWriter(import_writer2.default.create());
18116
18116
  }
18117
18117
 
18118
- // ../../node_modules/.pnpm/protons-runtime@5.0.2_uint8arraylist@2.4.3/node_modules/protons-runtime/dist/src/decode.js
18118
+ // ../../node_modules/.pnpm/protons-runtime@5.0.2/node_modules/protons-runtime/dist/src/decode.js
18119
18119
  function decodeMessage(buf3, codec) {
18120
18120
  const r = reader(buf3 instanceof Uint8Array ? buf3 : buf3.subarray());
18121
18121
  return codec.decode(r);
18122
18122
  }
18123
18123
 
18124
- // ../../node_modules/.pnpm/protons-runtime@5.0.2_uint8arraylist@2.4.3/node_modules/protons-runtime/dist/src/encode.js
18124
+ // ../../node_modules/.pnpm/protons-runtime@5.0.2/node_modules/protons-runtime/dist/src/encode.js
18125
18125
  function encodeMessage(message2, codec) {
18126
18126
  const w = writer();
18127
18127
  codec.encode(message2, w, {
@@ -18130,7 +18130,7 @@ function encodeMessage(message2, codec) {
18130
18130
  return w.finish();
18131
18131
  }
18132
18132
 
18133
- // ../../node_modules/.pnpm/protons-runtime@5.0.2_uint8arraylist@2.4.3/node_modules/protons-runtime/dist/src/codec.js
18133
+ // ../../node_modules/.pnpm/protons-runtime@5.0.2/node_modules/protons-runtime/dist/src/codec.js
18134
18134
  var CODEC_TYPES;
18135
18135
  (function(CODEC_TYPES2) {
18136
18136
  CODEC_TYPES2[CODEC_TYPES2["VARINT"] = 0] = "VARINT";
@@ -18149,7 +18149,7 @@ function createCodec(name8, type2, encode19, decode21) {
18149
18149
  };
18150
18150
  }
18151
18151
 
18152
- // ../../node_modules/.pnpm/protons-runtime@5.0.2_uint8arraylist@2.4.3/node_modules/protons-runtime/dist/src/codecs/enum.js
18152
+ // ../../node_modules/.pnpm/protons-runtime@5.0.2/node_modules/protons-runtime/dist/src/codecs/enum.js
18153
18153
  function enumeration(v) {
18154
18154
  function findValue(val) {
18155
18155
  if (v[val.toString()] == null) {
@@ -18168,7 +18168,7 @@ function enumeration(v) {
18168
18168
  return createCodec("enum", CODEC_TYPES.VARINT, encode19, decode21);
18169
18169
  }
18170
18170
 
18171
- // ../../node_modules/.pnpm/protons-runtime@5.0.2_uint8arraylist@2.4.3/node_modules/protons-runtime/dist/src/codecs/message.js
18171
+ // ../../node_modules/.pnpm/protons-runtime@5.0.2/node_modules/protons-runtime/dist/src/codecs/message.js
18172
18172
  function message(encode19, decode21) {
18173
18173
  return createCodec("message", CODEC_TYPES.LENGTH_DELIMITED, encode19, decode21);
18174
18174
  }
@@ -21022,7 +21022,7 @@ var _DbLoader = class _DbLoader extends Loader {
21022
21022
  this.isCompacting = true;
21023
21023
  const compactHead = this.clock.head;
21024
21024
  const compactingResult = await doCompact(blocks, this.clock.head);
21025
- await this.clock.applyHead(null, compactHead, compactHead, null);
21025
+ await this.clock.applyHead(compactHead, compactHead, null);
21026
21026
  return compactingResult;
21027
21027
  };
21028
21028
  this.compacting = this._setWaitForWrite(compactingFn);
@@ -21037,9 +21037,9 @@ var _DbLoader = class _DbLoader extends Loader {
21037
21037
  }
21038
21038
  async _applyCarHeader(carHeader, snap = false) {
21039
21039
  if (snap) {
21040
- await this.clock.applyHead(null, carHeader.head, this.clock.head);
21040
+ await this.clock.applyHead(carHeader.head, this.clock.head);
21041
21041
  } else {
21042
- await this.clock.applyHead(null, carHeader.head, []);
21042
+ await this.clock.applyHead(carHeader.head, []);
21043
21043
  }
21044
21044
  }
21045
21045
  makeCarHeader(result, cars, compact = false) {
@@ -21198,7 +21198,7 @@ function applyHeadQueue(worker) {
21198
21198
  const task = queue.shift();
21199
21199
  if (!task)
21200
21200
  continue;
21201
- await worker(task.id, task.tblocks, task.newHead, task.prevHead, task.updates);
21201
+ await worker(task.id, task.newHead, task.prevHead, task.updates);
21202
21202
  if (task.updates) {
21203
21203
  allUpdates.push(...task.updates);
21204
21204
  }
@@ -21242,18 +21242,18 @@ var CRDTClock = class {
21242
21242
  setHead(head) {
21243
21243
  this.head = head;
21244
21244
  }
21245
- async applyHead(tblocks, newHead, prevHead, updates = null) {
21245
+ async applyHead(newHead, prevHead, updates = null) {
21246
21246
  const taskId = Math.random().toString().slice(2, 8);
21247
21247
  for await (const { updates: updatesAcc, all } of this.applyHeadQueue.push({
21248
21248
  id: taskId,
21249
- tblocks,
21249
+ // tblocks,
21250
21250
  newHead,
21251
21251
  prevHead,
21252
21252
  updates
21253
21253
  })) {
21254
21254
  ;
21255
- (async (updatesAcc2, all2) => {
21256
- Promise.resolve().then(async () => {
21255
+ ((updatesAcc2, all2) => {
21256
+ void Promise.resolve().then(async () => {
21257
21257
  let intUpdates = updatesAcc2;
21258
21258
  if (this.watchers.size && !all2) {
21259
21259
  const changes = await clockChangesSince(this.blocks, this.head, prevHead, {});
@@ -21265,11 +21265,11 @@ var CRDTClock = class {
21265
21265
  })([...updatesAcc], all);
21266
21266
  }
21267
21267
  }
21268
- async int_applyHead(taskId, tblocks, newHead, prevHead, updates = null) {
21268
+ async int_applyHead(taskId, newHead, prevHead) {
21269
21269
  const ogHead = this.head.sort((a, b) => a.toString().localeCompare(b.toString()));
21270
21270
  newHead = newHead.sort((a, b) => a.toString().localeCompare(b.toString()));
21271
- newHead.map((cid) => {
21272
- const got = this.blocks.get(cid);
21271
+ newHead.map(async (cid) => {
21272
+ const got = await this.blocks.get(cid);
21273
21273
  if (!got) {
21274
21274
  throw new Error("int_applyHead missing block: " + cid.toString());
21275
21275
  }
@@ -21284,23 +21284,23 @@ var CRDTClock = class {
21284
21284
  }
21285
21285
  let head = this.head;
21286
21286
  const noLoader = false;
21287
- const withBlocks = async (tblocks2, fn) => {
21287
+ const withBlocks = async (fn) => {
21288
21288
  if (!this.blocks)
21289
21289
  throw new Error("missing blocks");
21290
21290
  return await this.blocks.transaction(fn, void 0, { noLoader });
21291
21291
  };
21292
- await withBlocks(tblocks, async (tblocks2) => {
21292
+ await withBlocks(async (tblocks) => {
21293
21293
  for (const cid of newHead) {
21294
21294
  try {
21295
- head = await advance(tblocks2, head, cid);
21295
+ head = await advance(tblocks, head, cid);
21296
21296
  } catch (e) {
21297
21297
  console.error("failed to advance", cid.toString(), e);
21298
21298
  continue;
21299
21299
  }
21300
21300
  }
21301
- const result = await root(tblocks2, head);
21301
+ const result = await root(tblocks, head);
21302
21302
  for (const { cid, bytes } of [...result.additions, ...result.removals]) {
21303
- tblocks2.putSync(cid, bytes);
21303
+ tblocks.putSync(cid, bytes);
21304
21304
  }
21305
21305
  return { head };
21306
21306
  });
@@ -21379,7 +21379,7 @@ var CRDT = class {
21379
21379
  }
21380
21380
  return { head };
21381
21381
  });
21382
- await this.clock.applyHead(null, got.head, prevHead, updates);
21382
+ await this.clock.applyHead(got.head, prevHead, updates);
21383
21383
  return got;
21384
21384
  })();
21385
21385
  if (loader) {
@@ -21414,7 +21414,7 @@ var CRDT = class {
21414
21414
  return await getBlock(this.blocks, cidString);
21415
21415
  }
21416
21416
  async getThatBlock() {
21417
- const blockJson = { "cid": "bafyreib7ee4pscqpuioxobmh3ac5xbbslypmaqqbkugalhw67hnco6dvoa", "bytes": "omRkYXRhpGNrZXl4JDAxOGFmNzdiLWZmMTUtNzI5Ny04ODZiLTYwMjViM2MxODI2ZWRyb2902CpYJQABcRIgKVLI53HO1TFDbPUoSaybd0mop2oX/CRFm1RrpiY4ne9kdHlwZWNwdXRldmFsdWXYKlglAAFxEiAGw53MVtPzeeGT/itfdLBfCVu6MTj96AHU6v9a3K/wYGdwYXJlbnRzgdgqWCUAAXESIJiL5qjdpgghUfbQLpKJeCgMX+ubhoTpYBoZHYdzbQJ/" };
21417
+ const blockJson = { cid: "bafyreib7ee4pscqpuioxobmh3ac5xbbslypmaqqbkugalhw67hnco6dvoa", bytes: "omRkYXRhpGNrZXl4JDAxOGFmNzdiLWZmMTUtNzI5Ny04ODZiLTYwMjViM2MxODI2ZWRyb2902CpYJQABcRIgKVLI53HO1TFDbPUoSaybd0mop2oX/CRFm1RrpiY4ne9kdHlwZWNwdXRldmFsdWXYKlglAAFxEiAGw53MVtPzeeGT/itfdLBfCVu6MTj96AHU6v9a3K/wYGdwYXJlbnRzgdgqWCUAAXESIJiL5qjdpgghUfbQLpKJeCgMX+ubhoTpYBoZHYdzbQJ/" };
21418
21418
  return await getThatBlock(blockJson);
21419
21419
  }
21420
21420
  async get(key) {