@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.
@@ -11605,7 +11605,7 @@ replaceTraps((oldTraps) => ({
11605
11605
  }));
11606
11606
 
11607
11607
  // src/version.ts
11608
- var PACKAGE_VERSION = "0.14.2";
11608
+ var PACKAGE_VERSION = "0.14.3";
11609
11609
 
11610
11610
  // src/store.ts
11611
11611
  var match = PACKAGE_VERSION.match(/^([^.]*\.[^.]*)/);
@@ -18087,7 +18087,7 @@ var import_err_code7 = __toESM(require_err_code(), 1);
18087
18087
  // ../../node_modules/.pnpm/ipfs-unixfs@11.0.2/node_modules/ipfs-unixfs/dist/src/index.js
18088
18088
  var import_err_code5 = __toESM(require_err_code(), 1);
18089
18089
 
18090
- // ../../node_modules/.pnpm/protons-runtime@5.0.2_uint8arraylist@2.4.3/node_modules/protons-runtime/dist/src/utils.js
18090
+ // ../../node_modules/.pnpm/protons-runtime@5.0.2/node_modules/protons-runtime/dist/src/utils.js
18091
18091
  var import_reader3 = __toESM(require_reader(), 1);
18092
18092
  var import_reader_buffer = __toESM(require_reader_buffer(), 1);
18093
18093
  var import_minimal2 = __toESM(require_minimal(), 1);
@@ -18137,13 +18137,13 @@ function writer() {
18137
18137
  return patchWriter(import_writer2.default.create());
18138
18138
  }
18139
18139
 
18140
- // ../../node_modules/.pnpm/protons-runtime@5.0.2_uint8arraylist@2.4.3/node_modules/protons-runtime/dist/src/decode.js
18140
+ // ../../node_modules/.pnpm/protons-runtime@5.0.2/node_modules/protons-runtime/dist/src/decode.js
18141
18141
  function decodeMessage(buf3, codec) {
18142
18142
  const r = reader(buf3 instanceof Uint8Array ? buf3 : buf3.subarray());
18143
18143
  return codec.decode(r);
18144
18144
  }
18145
18145
 
18146
- // ../../node_modules/.pnpm/protons-runtime@5.0.2_uint8arraylist@2.4.3/node_modules/protons-runtime/dist/src/encode.js
18146
+ // ../../node_modules/.pnpm/protons-runtime@5.0.2/node_modules/protons-runtime/dist/src/encode.js
18147
18147
  function encodeMessage(message2, codec) {
18148
18148
  const w = writer();
18149
18149
  codec.encode(message2, w, {
@@ -18152,7 +18152,7 @@ function encodeMessage(message2, codec) {
18152
18152
  return w.finish();
18153
18153
  }
18154
18154
 
18155
- // ../../node_modules/.pnpm/protons-runtime@5.0.2_uint8arraylist@2.4.3/node_modules/protons-runtime/dist/src/codec.js
18155
+ // ../../node_modules/.pnpm/protons-runtime@5.0.2/node_modules/protons-runtime/dist/src/codec.js
18156
18156
  var CODEC_TYPES;
18157
18157
  (function(CODEC_TYPES2) {
18158
18158
  CODEC_TYPES2[CODEC_TYPES2["VARINT"] = 0] = "VARINT";
@@ -18171,7 +18171,7 @@ function createCodec(name8, type2, encode19, decode21) {
18171
18171
  };
18172
18172
  }
18173
18173
 
18174
- // ../../node_modules/.pnpm/protons-runtime@5.0.2_uint8arraylist@2.4.3/node_modules/protons-runtime/dist/src/codecs/enum.js
18174
+ // ../../node_modules/.pnpm/protons-runtime@5.0.2/node_modules/protons-runtime/dist/src/codecs/enum.js
18175
18175
  function enumeration(v) {
18176
18176
  function findValue(val) {
18177
18177
  if (v[val.toString()] == null) {
@@ -18190,7 +18190,7 @@ function enumeration(v) {
18190
18190
  return createCodec("enum", CODEC_TYPES.VARINT, encode19, decode21);
18191
18191
  }
18192
18192
 
18193
- // ../../node_modules/.pnpm/protons-runtime@5.0.2_uint8arraylist@2.4.3/node_modules/protons-runtime/dist/src/codecs/message.js
18193
+ // ../../node_modules/.pnpm/protons-runtime@5.0.2/node_modules/protons-runtime/dist/src/codecs/message.js
18194
18194
  function message(encode19, decode21) {
18195
18195
  return createCodec("message", CODEC_TYPES.LENGTH_DELIMITED, encode19, decode21);
18196
18196
  }
@@ -21044,7 +21044,7 @@ var _DbLoader = class _DbLoader extends Loader {
21044
21044
  this.isCompacting = true;
21045
21045
  const compactHead = this.clock.head;
21046
21046
  const compactingResult = await doCompact(blocks, this.clock.head);
21047
- await this.clock.applyHead(null, compactHead, compactHead, null);
21047
+ await this.clock.applyHead(compactHead, compactHead, null);
21048
21048
  return compactingResult;
21049
21049
  };
21050
21050
  this.compacting = this._setWaitForWrite(compactingFn);
@@ -21059,9 +21059,9 @@ var _DbLoader = class _DbLoader extends Loader {
21059
21059
  }
21060
21060
  async _applyCarHeader(carHeader, snap = false) {
21061
21061
  if (snap) {
21062
- await this.clock.applyHead(null, carHeader.head, this.clock.head);
21062
+ await this.clock.applyHead(carHeader.head, this.clock.head);
21063
21063
  } else {
21064
- await this.clock.applyHead(null, carHeader.head, []);
21064
+ await this.clock.applyHead(carHeader.head, []);
21065
21065
  }
21066
21066
  }
21067
21067
  makeCarHeader(result, cars, compact = false) {
@@ -21220,7 +21220,7 @@ function applyHeadQueue(worker) {
21220
21220
  const task = queue.shift();
21221
21221
  if (!task)
21222
21222
  continue;
21223
- await worker(task.id, task.tblocks, task.newHead, task.prevHead, task.updates);
21223
+ await worker(task.id, task.newHead, task.prevHead, task.updates);
21224
21224
  if (task.updates) {
21225
21225
  allUpdates.push(...task.updates);
21226
21226
  }
@@ -21264,18 +21264,18 @@ var CRDTClock = class {
21264
21264
  setHead(head) {
21265
21265
  this.head = head;
21266
21266
  }
21267
- async applyHead(tblocks, newHead, prevHead, updates = null) {
21267
+ async applyHead(newHead, prevHead, updates = null) {
21268
21268
  const taskId = Math.random().toString().slice(2, 8);
21269
21269
  for await (const { updates: updatesAcc, all } of this.applyHeadQueue.push({
21270
21270
  id: taskId,
21271
- tblocks,
21271
+ // tblocks,
21272
21272
  newHead,
21273
21273
  prevHead,
21274
21274
  updates
21275
21275
  })) {
21276
21276
  ;
21277
- (async (updatesAcc2, all2) => {
21278
- Promise.resolve().then(async () => {
21277
+ ((updatesAcc2, all2) => {
21278
+ void Promise.resolve().then(async () => {
21279
21279
  let intUpdates = updatesAcc2;
21280
21280
  if (this.watchers.size && !all2) {
21281
21281
  const changes = await clockChangesSince(this.blocks, this.head, prevHead, {});
@@ -21287,11 +21287,11 @@ var CRDTClock = class {
21287
21287
  })([...updatesAcc], all);
21288
21288
  }
21289
21289
  }
21290
- async int_applyHead(taskId, tblocks, newHead, prevHead, updates = null) {
21290
+ async int_applyHead(taskId, newHead, prevHead) {
21291
21291
  const ogHead = this.head.sort((a, b) => a.toString().localeCompare(b.toString()));
21292
21292
  newHead = newHead.sort((a, b) => a.toString().localeCompare(b.toString()));
21293
- newHead.map((cid) => {
21294
- const got = this.blocks.get(cid);
21293
+ newHead.map(async (cid) => {
21294
+ const got = await this.blocks.get(cid);
21295
21295
  if (!got) {
21296
21296
  throw new Error("int_applyHead missing block: " + cid.toString());
21297
21297
  }
@@ -21306,23 +21306,23 @@ var CRDTClock = class {
21306
21306
  }
21307
21307
  let head = this.head;
21308
21308
  const noLoader = false;
21309
- const withBlocks = async (tblocks2, fn) => {
21309
+ const withBlocks = async (fn) => {
21310
21310
  if (!this.blocks)
21311
21311
  throw new Error("missing blocks");
21312
21312
  return await this.blocks.transaction(fn, void 0, { noLoader });
21313
21313
  };
21314
- await withBlocks(tblocks, async (tblocks2) => {
21314
+ await withBlocks(async (tblocks) => {
21315
21315
  for (const cid of newHead) {
21316
21316
  try {
21317
- head = await advance(tblocks2, head, cid);
21317
+ head = await advance(tblocks, head, cid);
21318
21318
  } catch (e) {
21319
21319
  console.error("failed to advance", cid.toString(), e);
21320
21320
  continue;
21321
21321
  }
21322
21322
  }
21323
- const result = await root(tblocks2, head);
21323
+ const result = await root(tblocks, head);
21324
21324
  for (const { cid, bytes } of [...result.additions, ...result.removals]) {
21325
- tblocks2.putSync(cid, bytes);
21325
+ tblocks.putSync(cid, bytes);
21326
21326
  }
21327
21327
  return { head };
21328
21328
  });
@@ -21401,7 +21401,7 @@ var CRDT = class {
21401
21401
  }
21402
21402
  return { head };
21403
21403
  });
21404
- await this.clock.applyHead(null, got.head, prevHead, updates);
21404
+ await this.clock.applyHead(got.head, prevHead, updates);
21405
21405
  return got;
21406
21406
  })();
21407
21407
  if (loader) {
@@ -21436,7 +21436,7 @@ var CRDT = class {
21436
21436
  return await getBlock(this.blocks, cidString);
21437
21437
  }
21438
21438
  async getThatBlock() {
21439
- const blockJson = { "cid": "bafyreib7ee4pscqpuioxobmh3ac5xbbslypmaqqbkugalhw67hnco6dvoa", "bytes": "omRkYXRhpGNrZXl4JDAxOGFmNzdiLWZmMTUtNzI5Ny04ODZiLTYwMjViM2MxODI2ZWRyb2902CpYJQABcRIgKVLI53HO1TFDbPUoSaybd0mop2oX/CRFm1RrpiY4ne9kdHlwZWNwdXRldmFsdWXYKlglAAFxEiAGw53MVtPzeeGT/itfdLBfCVu6MTj96AHU6v9a3K/wYGdwYXJlbnRzgdgqWCUAAXESIJiL5qjdpgghUfbQLpKJeCgMX+ubhoTpYBoZHYdzbQJ/" };
21439
+ const blockJson = { cid: "bafyreib7ee4pscqpuioxobmh3ac5xbbslypmaqqbkugalhw67hnco6dvoa", bytes: "omRkYXRhpGNrZXl4JDAxOGFmNzdiLWZmMTUtNzI5Ny04ODZiLTYwMjViM2MxODI2ZWRyb2902CpYJQABcRIgKVLI53HO1TFDbPUoSaybd0mop2oX/CRFm1RrpiY4ne9kdHlwZWNwdXRldmFsdWXYKlglAAFxEiAGw53MVtPzeeGT/itfdLBfCVu6MTj96AHU6v9a3K/wYGdwYXJlbnRzgdgqWCUAAXESIJiL5qjdpgghUfbQLpKJeCgMX+ubhoTpYBoZHYdzbQJ/" };
21440
21440
  return await getThatBlock(blockJson);
21441
21441
  }
21442
21442
  async get(key) {