@fireproof/core 0.14.1 → 0.14.3

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.
@@ -11583,7 +11583,7 @@ replaceTraps((oldTraps) => ({
11583
11583
  }));
11584
11584
 
11585
11585
  // src/version.ts
11586
- var PACKAGE_VERSION = "0.14.1";
11586
+ var PACKAGE_VERSION = "0.14.3";
11587
11587
 
11588
11588
  // src/store.ts
11589
11589
  var match = PACKAGE_VERSION.match(/^([^.]*\.[^.]*)/);
@@ -20786,11 +20786,9 @@ async function processFileset(blocks, files, publicFiles = false) {
20786
20786
  const dbBlockstore = blocks.parent;
20787
20787
  const t = new Transaction(dbBlockstore);
20788
20788
  const didPut = [];
20789
- let totalSize = 0;
20790
20789
  for (const filename in files) {
20791
20790
  if (File === files[filename].constructor) {
20792
20791
  const file = files[filename];
20793
- totalSize += file.size;
20794
20792
  const { cid, blocks: fileBlocks } = await encodeFile2(file);
20795
20793
  didPut.push(filename);
20796
20794
  for (const block of fileBlocks) {
@@ -20799,8 +20797,6 @@ async function processFileset(blocks, files, publicFiles = false) {
20799
20797
  files[filename] = { cid, type: file.type, size: file.size };
20800
20798
  }
20801
20799
  }
20802
- if (totalSize > 1024 * 1024 * 1)
20803
- throw new Error("Sync limit for files in a single update is 1MB");
20804
20800
  if (didPut.length) {
20805
20801
  const car = await dbBlockstore.loader?.commit(t, { files }, { public: publicFiles });
20806
20802
  if (car) {
@@ -21026,7 +21022,7 @@ var _DbLoader = class _DbLoader extends Loader {
21026
21022
  this.isCompacting = true;
21027
21023
  const compactHead = this.clock.head;
21028
21024
  const compactingResult = await doCompact(blocks, this.clock.head);
21029
- await this.clock.applyHead(null, compactHead, compactHead, null);
21025
+ await this.clock.applyHead(compactHead, compactHead, null);
21030
21026
  return compactingResult;
21031
21027
  };
21032
21028
  this.compacting = this._setWaitForWrite(compactingFn);
@@ -21041,9 +21037,9 @@ var _DbLoader = class _DbLoader extends Loader {
21041
21037
  }
21042
21038
  async _applyCarHeader(carHeader, snap = false) {
21043
21039
  if (snap) {
21044
- await this.clock.applyHead(null, carHeader.head, this.clock.head);
21040
+ await this.clock.applyHead(carHeader.head, this.clock.head);
21045
21041
  } else {
21046
- await this.clock.applyHead(null, carHeader.head, []);
21042
+ await this.clock.applyHead(carHeader.head, []);
21047
21043
  }
21048
21044
  }
21049
21045
  makeCarHeader(result, cars, compact = false) {
@@ -21202,7 +21198,7 @@ function applyHeadQueue(worker) {
21202
21198
  const task = queue.shift();
21203
21199
  if (!task)
21204
21200
  continue;
21205
- await worker(task.id, task.tblocks, task.newHead, task.prevHead, task.updates);
21201
+ await worker(task.id, task.newHead, task.prevHead, task.updates);
21206
21202
  if (task.updates) {
21207
21203
  allUpdates.push(...task.updates);
21208
21204
  }
@@ -21246,18 +21242,18 @@ var CRDTClock = class {
21246
21242
  setHead(head) {
21247
21243
  this.head = head;
21248
21244
  }
21249
- async applyHead(tblocks, newHead, prevHead, updates = null) {
21245
+ async applyHead(newHead, prevHead, updates = null) {
21250
21246
  const taskId = Math.random().toString().slice(2, 8);
21251
21247
  for await (const { updates: updatesAcc, all } of this.applyHeadQueue.push({
21252
21248
  id: taskId,
21253
- tblocks,
21249
+ // tblocks,
21254
21250
  newHead,
21255
21251
  prevHead,
21256
21252
  updates
21257
21253
  })) {
21258
21254
  ;
21259
- (async (updatesAcc2, all2) => {
21260
- Promise.resolve().then(async () => {
21255
+ ((updatesAcc2, all2) => {
21256
+ void Promise.resolve().then(async () => {
21261
21257
  let intUpdates = updatesAcc2;
21262
21258
  if (this.watchers.size && !all2) {
21263
21259
  const changes = await clockChangesSince(this.blocks, this.head, prevHead, {});
@@ -21269,11 +21265,11 @@ var CRDTClock = class {
21269
21265
  })([...updatesAcc], all);
21270
21266
  }
21271
21267
  }
21272
- async int_applyHead(taskId, tblocks, newHead, prevHead, updates = null) {
21268
+ async int_applyHead(taskId, newHead, prevHead) {
21273
21269
  const ogHead = this.head.sort((a, b) => a.toString().localeCompare(b.toString()));
21274
21270
  newHead = newHead.sort((a, b) => a.toString().localeCompare(b.toString()));
21275
- newHead.map((cid) => {
21276
- const got = this.blocks.get(cid);
21271
+ newHead.map(async (cid) => {
21272
+ const got = await this.blocks.get(cid);
21277
21273
  if (!got) {
21278
21274
  throw new Error("int_applyHead missing block: " + cid.toString());
21279
21275
  }
@@ -21288,23 +21284,23 @@ var CRDTClock = class {
21288
21284
  }
21289
21285
  let head = this.head;
21290
21286
  const noLoader = false;
21291
- const withBlocks = async (tblocks2, fn) => {
21287
+ const withBlocks = async (fn) => {
21292
21288
  if (!this.blocks)
21293
21289
  throw new Error("missing blocks");
21294
21290
  return await this.blocks.transaction(fn, void 0, { noLoader });
21295
21291
  };
21296
- await withBlocks(tblocks, async (tblocks2) => {
21292
+ await withBlocks(async (tblocks) => {
21297
21293
  for (const cid of newHead) {
21298
21294
  try {
21299
- head = await advance(tblocks2, head, cid);
21295
+ head = await advance(tblocks, head, cid);
21300
21296
  } catch (e) {
21301
21297
  console.error("failed to advance", cid.toString(), e);
21302
21298
  continue;
21303
21299
  }
21304
21300
  }
21305
- const result = await root(tblocks2, head);
21301
+ const result = await root(tblocks, head);
21306
21302
  for (const { cid, bytes } of [...result.additions, ...result.removals]) {
21307
- tblocks2.putSync(cid, bytes);
21303
+ tblocks.putSync(cid, bytes);
21308
21304
  }
21309
21305
  return { head };
21310
21306
  });
@@ -21383,7 +21379,7 @@ var CRDT = class {
21383
21379
  }
21384
21380
  return { head };
21385
21381
  });
21386
- await this.clock.applyHead(null, got.head, prevHead, updates);
21382
+ await this.clock.applyHead(got.head, prevHead, updates);
21387
21383
  return got;
21388
21384
  })();
21389
21385
  if (loader) {
@@ -21418,7 +21414,7 @@ var CRDT = class {
21418
21414
  return await getBlock(this.blocks, cidString);
21419
21415
  }
21420
21416
  async getThatBlock() {
21421
- const blockJson = { "cid": "bafyreib7ee4pscqpuioxobmh3ac5xbbslypmaqqbkugalhw67hnco6dvoa", "bytes": "omRkYXRhpGNrZXl4JDAxOGFmNzdiLWZmMTUtNzI5Ny04ODZiLTYwMjViM2MxODI2ZWRyb2902CpYJQABcRIgKVLI53HO1TFDbPUoSaybd0mop2oX/CRFm1RrpiY4ne9kdHlwZWNwdXRldmFsdWXYKlglAAFxEiAGw53MVtPzeeGT/itfdLBfCVu6MTj96AHU6v9a3K/wYGdwYXJlbnRzgdgqWCUAAXESIJiL5qjdpgghUfbQLpKJeCgMX+ubhoTpYBoZHYdzbQJ/" };
21417
+ const blockJson = { cid: "bafyreib7ee4pscqpuioxobmh3ac5xbbslypmaqqbkugalhw67hnco6dvoa", bytes: "omRkYXRhpGNrZXl4JDAxOGFmNzdiLWZmMTUtNzI5Ny04ODZiLTYwMjViM2MxODI2ZWRyb2902CpYJQABcRIgKVLI53HO1TFDbPUoSaybd0mop2oX/CRFm1RrpiY4ne9kdHlwZWNwdXRldmFsdWXYKlglAAFxEiAGw53MVtPzeeGT/itfdLBfCVu6MTj96AHU6v9a3K/wYGdwYXJlbnRzgdgqWCUAAXESIJiL5qjdpgghUfbQLpKJeCgMX+ubhoTpYBoZHYdzbQJ/" };
21422
21418
  return await getThatBlock(blockJson);
21423
21419
  }
21424
21420
  async get(key) {