@fireproof/core 0.17.2 → 0.17.4

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.
Files changed (34) hide show
  1. package/dist/browser/fireproof.cjs +10 -6
  2. package/dist/browser/fireproof.cjs.map +1 -1
  3. package/dist/browser/fireproof.d.cts +15 -12
  4. package/dist/browser/fireproof.d.ts +15 -12
  5. package/dist/browser/fireproof.global.js +174 -107
  6. package/dist/browser/fireproof.global.js.map +1 -1
  7. package/dist/browser/fireproof.js +14 -6
  8. package/dist/browser/fireproof.js.map +1 -1
  9. package/dist/browser/metafile-cjs.json +1 -1
  10. package/dist/browser/metafile-esm.json +1 -1
  11. package/dist/browser/metafile-iife.json +1 -1
  12. package/dist/memory/fireproof.cjs +10 -6
  13. package/dist/memory/fireproof.cjs.map +1 -1
  14. package/dist/memory/fireproof.d.cts +15 -12
  15. package/dist/memory/fireproof.d.ts +15 -12
  16. package/dist/memory/fireproof.global.js +174 -107
  17. package/dist/memory/fireproof.global.js.map +1 -1
  18. package/dist/memory/fireproof.js +14 -6
  19. package/dist/memory/fireproof.js.map +1 -1
  20. package/dist/memory/metafile-cjs.json +1 -1
  21. package/dist/memory/metafile-esm.json +1 -1
  22. package/dist/memory/metafile-iife.json +1 -1
  23. package/dist/node/fireproof.cjs +4 -5
  24. package/dist/node/fireproof.cjs.map +1 -1
  25. package/dist/node/fireproof.d.cts +15 -12
  26. package/dist/node/fireproof.d.ts +15 -12
  27. package/dist/node/fireproof.global.js +169 -98
  28. package/dist/node/fireproof.global.js.map +1 -1
  29. package/dist/node/fireproof.js +4 -5
  30. package/dist/node/fireproof.js.map +1 -1
  31. package/dist/node/metafile-cjs.json +1 -1
  32. package/dist/node/metafile-esm.json +1 -1
  33. package/dist/node/metafile-iife.json +1 -1
  34. package/package.json +8 -5
@@ -4136,22 +4136,6 @@ var Fireproof = (() => {
4136
4136
  }
4137
4137
  }
4138
4138
  };
4139
- var MultiBlockFetcher = class {
4140
- /** @type {API.BlockFetcher[]} */
4141
- #fetchers;
4142
- /** @param {API.BlockFetcher[]} fetchers */
4143
- constructor(...fetchers) {
4144
- this.#fetchers = fetchers;
4145
- }
4146
- /** @type {API.BlockFetcher['get']} */
4147
- async get(link2) {
4148
- for (const f of this.#fetchers) {
4149
- const v = await f.get(link2);
4150
- if (v)
4151
- return v;
4152
- }
4153
- }
4154
- };
4155
4139
 
4156
4140
  // ../../node_modules/.pnpm/yocto-queue@1.0.0/node_modules/yocto-queue/index.js
4157
4141
  var Node = class {
@@ -9952,8 +9936,7 @@ You can use close({ resize: true }) to resize header`);
9952
9936
  return uint8Array;
9953
9937
  }
9954
9938
  async function encryptedEncodeCarFile(crypto22, key, rootCid, t) {
9955
- const encryptionKeyUint8 = hexStringToUint8Array(key);
9956
- const encryptionKey = encryptionKeyUint8.buffer.slice(0, encryptionKeyUint8.byteLength);
9939
+ const encryptionKey = hexStringToUint8Array(key);
9957
9940
  const encryptedBlocks = new MemoryBlockstore();
9958
9941
  const cidsToEncrypt = [];
9959
9942
  for (const { cid } of t.entries()) {
@@ -10030,7 +10013,7 @@ You can use close({ resize: true }) to resize header`);
10030
10013
  }
10031
10014
  return bytes;
10032
10015
  }
10033
- var PACKAGE_VERSION = "0.16.10";
10016
+ var PACKAGE_VERSION = "0.17.3";
10034
10017
  var match = PACKAGE_VERSION.match(/^([^.]*\.[^.]*)/);
10035
10018
  if (!match)
10036
10019
  throw new Error("invalid version: " + PACKAGE_VERSION);
@@ -10106,11 +10089,11 @@ You can use close({ resize: true }) to resize header`);
10106
10089
  constructor(name7, ebOpts) {
10107
10090
  this.name = name7;
10108
10091
  this.ebOpts = ebOpts;
10109
- this.metaStore = new ebOpts.store.MetaStore(this.name);
10110
- this.carStore = new ebOpts.store.DataStore(this.name);
10111
- this.fileStore = new ebOpts.store.DataStore(this.name);
10112
- this.remoteWAL = new ebOpts.store.RemoteWAL(this);
10092
+ this.carStore = ebOpts.store.makeDataStore(this.name);
10093
+ this.fileStore = ebOpts.store.makeDataStore(this.name);
10094
+ this.remoteWAL = ebOpts.store.makeRemoteWAL(this);
10113
10095
  this.ready = Promise.resolve().then(async () => {
10096
+ this.metaStore = ebOpts.store.makeMetaStore(this);
10114
10097
  if (!this.metaStore || !this.carStore || !this.remoteWAL)
10115
10098
  throw new Error("stores not initialized");
10116
10099
  const metas = this.ebOpts.meta ? [this.ebOpts.meta] : await this.metaStore.load("main");
@@ -10284,19 +10267,30 @@ You can use close({ resize: true }) to resize header`);
10284
10267
  const sCid = cid.toString();
10285
10268
  if (this.getBlockCache.has(sCid))
10286
10269
  return this.getBlockCache.get(sCid);
10287
- const got = await Promise.any(
10288
- // maybe worth taking this in chunks of 5? to allow cache to favor recent files, carLog order is newest first
10289
- this.carLog.map(async (carCid) => {
10290
- const reader = await this.loadCar(carCid);
10291
- if (!reader) {
10292
- throw new Error(`missing car reader ${carCid.toString()}`);
10293
- }
10294
- await this.cacheCarReader(reader);
10295
- if (this.getBlockCache.has(sCid))
10296
- return this.getBlockCache.get(sCid);
10297
- throw new Error(`block not in reader: ${cid.toString()}`);
10298
- })
10299
- ).catch(() => void 0);
10270
+ const getCarCid = async (carCid) => {
10271
+ const reader = await this.loadCar(carCid);
10272
+ if (!reader) {
10273
+ throw new Error(`missing car reader ${carCid.toString()}`);
10274
+ }
10275
+ await this.cacheCarReader(reader);
10276
+ if (this.getBlockCache.has(sCid))
10277
+ return this.getBlockCache.get(sCid);
10278
+ throw new Error(`block not in reader: ${cid.toString()}`);
10279
+ };
10280
+ let got;
10281
+ const batchSize = 5;
10282
+ for (let i = 0; i < this.carLog.length; i += batchSize) {
10283
+ const promises = [];
10284
+ for (let j = i; j < Math.min(i + batchSize, this.carLog.length); j++) {
10285
+ promises.push(getCarCid(this.carLog[j]));
10286
+ }
10287
+ try {
10288
+ got = await Promise.any(promises);
10289
+ } catch {
10290
+ }
10291
+ if (got)
10292
+ break;
10293
+ }
10300
10294
  if (got) {
10301
10295
  this.getBlockCache.set(sCid, got);
10302
10296
  }
@@ -18766,12 +18760,15 @@ ${key.data.toString("base64")}
18766
18760
  DataStore: () => DataStore2,
18767
18761
  MetaStore: () => MetaStore2,
18768
18762
  RemoteWAL: () => RemoteWAL2,
18763
+ makeDataStore: () => makeDataStore,
18764
+ makeMetaStore: () => makeMetaStore,
18765
+ makeRemoteWAL: () => makeRemoteWAL,
18769
18766
  testConfig: () => testConfig
18770
18767
  });
18771
18768
  var import_path = __require("path");
18772
18769
  var import_os = __require("os");
18773
18770
  var import_promises = __require("fs/promises");
18774
- var PACKAGE_VERSION2 = "0.16.10";
18771
+ var PACKAGE_VERSION2 = "0.17.3";
18775
18772
  var match2 = PACKAGE_VERSION2.match(/^([^.]*\.[^.]*)/);
18776
18773
  if (!match2)
18777
18774
  throw new Error("invalid version: " + PACKAGE_VERSION2);
@@ -18859,14 +18856,14 @@ ${key.data.toString("base64")}
18859
18856
  processQueue = new CommitQueue2();
18860
18857
  constructor(loader) {
18861
18858
  this.loader = loader;
18862
- this.ready = (async () => {
18859
+ this.ready = Promise.resolve().then(async () => {
18863
18860
  const walState = await this.load().catch((e) => {
18864
18861
  console.error("error loading wal", e);
18865
18862
  return null;
18866
18863
  });
18867
18864
  this.walState.operations = walState?.operations || [];
18868
18865
  this.walState.fileOperations = walState?.fileOperations || [];
18869
- })();
18866
+ });
18870
18867
  }
18871
18868
  async enqueue(dbMeta, opts) {
18872
18869
  await this.ready;
@@ -18965,6 +18962,9 @@ ${key.data.toString("base64")}
18965
18962
  await rmlp;
18966
18963
  }
18967
18964
  };
18965
+ var makeDataStore = (name7) => new DataStore2(name7);
18966
+ var makeMetaStore = (loader) => new MetaStore2(loader.name);
18967
+ var makeRemoteWAL = (loader) => new RemoteWAL2(loader);
18968
18968
  var RemoteWAL2 = class extends RemoteWAL {
18969
18969
  filePathForBranch(branch) {
18970
18970
  return (0, import_path.join)(MetaStore2.dataDir, this.loader.name, "wal", branch + ".json");
@@ -19034,7 +19034,7 @@ ${key.data.toString("base64")}
19034
19034
  return await (0, import_promises.writeFile)(path, data);
19035
19035
  }
19036
19036
 
19037
- // ../../node_modules/.pnpm/@web3-storage+pail@0.4.0/node_modules/@web3-storage/pail/src/clock/index.js
19037
+ // ../../node_modules/.pnpm/@web3-storage+pail@0.4.1/node_modules/@web3-storage/pail/src/clock/index.js
19038
19038
  var advance = async (blocks, head, event) => {
19039
19039
  const events = new EventFetcher(blocks);
19040
19040
  const headmap = new Map(head.map((cid) => [cid.toString(), cid]));
@@ -19160,7 +19160,7 @@ ${key.data.toString("base64")}
19160
19160
  };
19161
19161
  var shortLink = (l) => `${String(l).slice(0, 4)}..${String(l).slice(-4)}`;
19162
19162
 
19163
- // ../../node_modules/.pnpm/@web3-storage+pail@0.4.0/node_modules/@web3-storage/pail/src/shard.js
19163
+ // ../../node_modules/.pnpm/@web3-storage+pail@0.4.1/node_modules/@web3-storage/pail/src/shard.js
19164
19164
  var MaxKeyLength = 64;
19165
19165
  var MaxShardSize = 512 * 1024;
19166
19166
  var CID_TAG2 = new Token(Type.tag, 42);
@@ -19291,41 +19291,8 @@ ${key.data.toString("base64")}
19291
19291
  }
19292
19292
  }
19293
19293
  };
19294
- var encodedLength = (shard) => {
19295
- let entriesLength = 0;
19296
- for (const entry of shard.entries) {
19297
- entriesLength += entryEncodedLength(entry);
19298
- }
19299
- const tokens = [
19300
- new Token(Type.map, 3),
19301
- new Token(Type.string, "entries"),
19302
- new Token(Type.array, shard.entries.length),
19303
- new Token(Type.string, "maxKeyLength"),
19304
- new Token(Type.uint, shard.maxKeyLength),
19305
- new Token(Type.string, "maxSize"),
19306
- new Token(Type.uint, shard.maxSize)
19307
- ];
19308
- return tokensToLength(tokens) + entriesLength;
19309
- };
19310
- var entryEncodedLength = (entry) => {
19311
- const tokens = [
19312
- new Token(Type.array, entry.length),
19313
- new Token(Type.string, entry[0])
19314
- ];
19315
- if (Array.isArray(entry[1])) {
19316
- tokens.push(new Token(Type.array, entry[1].length));
19317
- for (const link2 of entry[1]) {
19318
- tokens.push(CID_TAG2);
19319
- tokens.push(new Token(Type.bytes, { length: link2.byteLength + 1 }));
19320
- }
19321
- } else {
19322
- tokens.push(CID_TAG2);
19323
- tokens.push(new Token(Type.bytes, { length: entry[1].byteLength + 1 }));
19324
- }
19325
- return tokensToLength(tokens);
19326
- };
19327
19294
 
19328
- // ../../node_modules/.pnpm/@web3-storage+pail@0.4.0/node_modules/@web3-storage/pail/src/index.js
19295
+ // ../../node_modules/.pnpm/@web3-storage+pail@0.4.1/node_modules/@web3-storage/pail/src/index.js
19329
19296
  var put = async (blocks, root2, key, value) => {
19330
19297
  const shards = new ShardFetcher(blocks);
19331
19298
  const rshard = await shards.get(root2);
@@ -19528,15 +19495,118 @@ ${key.data.toString("base64")}
19528
19495
  return [shard];
19529
19496
  };
19530
19497
 
19531
- // ../../node_modules/.pnpm/@web3-storage+pail@0.4.0/node_modules/@web3-storage/pail/src/batch/shard.js
19498
+ // ../../node_modules/.pnpm/@web3-storage+pail@0.4.1/node_modules/@web3-storage/pail/src/block.js
19499
+ var MemoryBlockstore2 = class {
19500
+ /** @type {Map<string, Uint8Array>} */
19501
+ #blocks = /* @__PURE__ */ new Map();
19502
+ /**
19503
+ * @param {Array<import('multiformats').Block>} [blocks]
19504
+ */
19505
+ constructor(blocks) {
19506
+ if (blocks) {
19507
+ this.#blocks = new Map(blocks.map((b) => [b.cid.toString(), b.bytes]));
19508
+ }
19509
+ }
19510
+ /** @type {API.BlockFetcher['get']} */
19511
+ async get(cid) {
19512
+ const bytes = this.#blocks.get(cid.toString());
19513
+ if (!bytes)
19514
+ return;
19515
+ return { cid, bytes };
19516
+ }
19517
+ /**
19518
+ * @param {API.UnknownLink} cid
19519
+ * @param {Uint8Array} bytes
19520
+ */
19521
+ async put(cid, bytes) {
19522
+ this.#blocks.set(cid.toString(), bytes);
19523
+ }
19524
+ /**
19525
+ * @param {API.UnknownLink} cid
19526
+ * @param {Uint8Array} bytes
19527
+ */
19528
+ putSync(cid, bytes) {
19529
+ this.#blocks.set(cid.toString(), bytes);
19530
+ }
19531
+ /** @param {API.UnknownLink} cid */
19532
+ async delete(cid) {
19533
+ this.#blocks.delete(cid.toString());
19534
+ }
19535
+ /** @param {API.UnknownLink} cid */
19536
+ deleteSync(cid) {
19537
+ this.#blocks.delete(cid.toString());
19538
+ }
19539
+ *entries() {
19540
+ for (const [str, bytes] of this.#blocks) {
19541
+ yield { cid: parse(str), bytes };
19542
+ }
19543
+ }
19544
+ };
19545
+ var MultiBlockFetcher = class {
19546
+ /** @type {API.BlockFetcher[]} */
19547
+ #fetchers;
19548
+ /** @param {API.BlockFetcher[]} fetchers */
19549
+ constructor(...fetchers) {
19550
+ this.#fetchers = fetchers;
19551
+ }
19552
+ /** @type {API.BlockFetcher['get']} */
19553
+ async get(link2) {
19554
+ for (const f of this.#fetchers) {
19555
+ const v = await f.get(link2);
19556
+ if (v)
19557
+ return v;
19558
+ }
19559
+ }
19560
+ };
19561
+
19562
+ // ../../node_modules/.pnpm/@web3-storage+pail@0.4.1/node_modules/@web3-storage/pail/src/batch/shard.js
19563
+ var ShardLinkByteLength = 36;
19564
+ var CID_TAG3 = new Token(Type.tag, 42);
19532
19565
  var create8 = (init2) => ({
19533
19566
  base: init2?.base,
19534
19567
  prefix: init2?.prefix ?? "",
19535
- entries: init2?.entries ?? [],
19568
+ entries: [...init2?.entries ?? []],
19536
19569
  ...configure(init2)
19537
19570
  });
19571
+ var encodedLength = (shard) => {
19572
+ let entriesLength = 0;
19573
+ for (const entry of shard.entries) {
19574
+ entriesLength += entryEncodedLength(entry);
19575
+ }
19576
+ const tokens = [
19577
+ new Token(Type.map, 3),
19578
+ new Token(Type.string, "entries"),
19579
+ new Token(Type.array, shard.entries.length),
19580
+ new Token(Type.string, "maxKeyLength"),
19581
+ new Token(Type.uint, shard.maxKeyLength),
19582
+ new Token(Type.string, "maxSize"),
19583
+ new Token(Type.uint, shard.maxSize)
19584
+ ];
19585
+ return tokensToLength(tokens) + entriesLength;
19586
+ };
19587
+ var entryEncodedLength = (entry) => {
19588
+ const tokens = [
19589
+ new Token(Type.array, entry.length),
19590
+ new Token(Type.string, entry[0])
19591
+ ];
19592
+ if (Array.isArray(entry[1])) {
19593
+ tokens.push(new Token(Type.array, entry[1].length));
19594
+ for (const item of entry[1]) {
19595
+ tokens.push(CID_TAG3);
19596
+ if (isLink(item)) {
19597
+ tokens.push(new Token(Type.bytes, { length: item.byteLength + 1 }));
19598
+ } else {
19599
+ tokens.push(new Token(Type.bytes, { length: ShardLinkByteLength + 1 }));
19600
+ }
19601
+ }
19602
+ } else {
19603
+ tokens.push(CID_TAG3);
19604
+ tokens.push(new Token(Type.bytes, { length: entry[1].byteLength + 1 }));
19605
+ }
19606
+ return tokensToLength(tokens);
19607
+ };
19538
19608
 
19539
- // ../../node_modules/.pnpm/@web3-storage+pail@0.4.0/node_modules/@web3-storage/pail/src/batch/index.js
19609
+ // ../../node_modules/.pnpm/@web3-storage+pail@0.4.1/node_modules/@web3-storage/pail/src/batch/index.js
19540
19610
  var Batcher = class _Batcher {
19541
19611
  #committed = false;
19542
19612
  /**
@@ -19551,7 +19621,7 @@ ${key.data.toString("base64")}
19551
19621
  constructor({ blocks, entries: entries3, prefix, maxSize, maxKeyLength, base: base4 }) {
19552
19622
  this.blocks = blocks;
19553
19623
  this.prefix = prefix;
19554
- this.entries = entries3;
19624
+ this.entries = [...entries3];
19555
19625
  this.base = base4;
19556
19626
  this.maxSize = maxSize;
19557
19627
  this.maxKeyLength = maxKeyLength;
@@ -19581,7 +19651,7 @@ ${key.data.toString("base64")}
19581
19651
  static async create({ blocks, link: link2, prefix }) {
19582
19652
  const shards = new ShardFetcher(blocks);
19583
19653
  const base4 = await shards.get(link2);
19584
- return new _Batcher({ blocks, entries: base4.value.entries, prefix, base: base4, ...configure(base4.value) });
19654
+ return new _Batcher({ blocks, prefix, base: base4, ...base4.value });
19585
19655
  }
19586
19656
  };
19587
19657
  var put2 = async (blocks, shard, key, value) => {
@@ -19618,7 +19688,7 @@ ${key.data.toString("base64")}
19618
19688
  entry = [pfxskeys[0].key, [batcher]];
19619
19689
  }
19620
19690
  shard.entries = putEntry(asShardEntries(shard.entries), asShardEntry(entry));
19621
- const size = encodedLength(withEntries(asShardEntries(shard.entries), shard));
19691
+ const size = encodedLength(shard);
19622
19692
  if (size > shard.maxSize) {
19623
19693
  const common = findCommonPrefix(
19624
19694
  asShardEntries(shard.entries),
@@ -19655,14 +19725,16 @@ ${key.data.toString("base64")}
19655
19725
  }
19656
19726
  };
19657
19727
  var traverse2 = async (shards, key, shard) => {
19658
- for (const e of shard.entries) {
19659
- const [k, v] = e;
19728
+ for (let i = 0; i < shard.entries.length; i++) {
19729
+ const [k, v] = shard.entries[i];
19660
19730
  if (key <= k)
19661
19731
  break;
19662
19732
  if (key.startsWith(k) && Array.isArray(v)) {
19663
19733
  if (isShardLink(v[0])) {
19664
19734
  const blk = await shards.get(v[0], shard.prefix + k);
19665
- v[0] = create8({ base: blk, prefix: blk.prefix, ...blk.value });
19735
+ const batcher = create8({ base: blk, prefix: blk.prefix, ...blk.value });
19736
+ shard.entries[i] = [k, v[1] == null ? [batcher] : [batcher, v[1]]];
19737
+ return traverse2(shards, key.slice(k.length), batcher);
19666
19738
  }
19667
19739
  return traverse2(shards, key.slice(k.length), v[0]);
19668
19740
  }
@@ -19716,9 +19788,9 @@ ${key.data.toString("base64")}
19716
19788
  static code = "ERR_BATCH_COMMITTED";
19717
19789
  };
19718
19790
 
19719
- // ../../node_modules/.pnpm/@web3-storage+pail@0.4.0/node_modules/@web3-storage/pail/src/crdt/index.js
19791
+ // ../../node_modules/.pnpm/@web3-storage+pail@0.4.1/node_modules/@web3-storage/pail/src/crdt/index.js
19720
19792
  var put3 = async (blocks, head, key, value) => {
19721
- const mblocks = new MemoryBlockstore();
19793
+ const mblocks = new MemoryBlockstore2();
19722
19794
  blocks = new MultiBlockFetcher(mblocks, blocks);
19723
19795
  if (!head.length) {
19724
19796
  const shard = await ShardBlock.create();
@@ -19802,7 +19874,7 @@ ${key.data.toString("base64")}
19802
19874
  var root = async (blocks, head) => {
19803
19875
  if (!head.length)
19804
19876
  throw new Error("cannot determine root of headless clock");
19805
- const mblocks = new MemoryBlockstore();
19877
+ const mblocks = new MemoryBlockstore2();
19806
19878
  blocks = new MultiBlockFetcher(mblocks, blocks);
19807
19879
  const events = new EventFetcher(blocks);
19808
19880
  if (head.length === 1) {
@@ -19861,7 +19933,7 @@ ${key.data.toString("base64")}
19861
19933
  return;
19862
19934
  const result = await root(blocks, head);
19863
19935
  if (result.additions.length) {
19864
- blocks = new MultiBlockFetcher(new MemoryBlockstore(result.additions), blocks);
19936
+ blocks = new MultiBlockFetcher(new MemoryBlockstore2(result.additions), blocks);
19865
19937
  }
19866
19938
  return get2(blocks, result.root, key);
19867
19939
  };
@@ -19870,7 +19942,7 @@ ${key.data.toString("base64")}
19870
19942
  return;
19871
19943
  const result = await root(blocks, head);
19872
19944
  if (result.additions.length) {
19873
- blocks = new MultiBlockFetcher(new MemoryBlockstore(result.additions), blocks);
19945
+ blocks = new MultiBlockFetcher(new MemoryBlockstore2(result.additions), blocks);
19874
19946
  }
19875
19947
  yield* entries(blocks, result.root, options);
19876
19948
  };
@@ -19954,7 +20026,7 @@ ${key.data.toString("base64")}
19954
20026
  return acc.concat(...rest);
19955
20027
  };
19956
20028
 
19957
- // ../../node_modules/.pnpm/@web3-storage+pail@0.4.0/node_modules/@web3-storage/pail/src/crdt/batch/index.js
20029
+ // ../../node_modules/.pnpm/@web3-storage+pail@0.4.1/node_modules/@web3-storage/pail/src/crdt/batch/index.js
19958
20030
  var Batcher2 = class _Batcher {
19959
20031
  #committed = false;
19960
20032
  /**
@@ -19973,7 +20045,7 @@ ${key.data.toString("base64")}
19973
20045
  this.blocks = blocks;
19974
20046
  this.head = head;
19975
20047
  this.prefix = prefix;
19976
- this.entries = entries3;
20048
+ this.entries = [...entries3];
19977
20049
  this.base = base4;
19978
20050
  this.maxSize = maxSize;
19979
20051
  this.maxKeyLength = maxKeyLength;
@@ -19999,7 +20071,7 @@ ${key.data.toString("base64")}
19999
20071
  const res = await commit(this);
20000
20072
  const data = { type: "batch", ops: this.ops, root: res.root };
20001
20073
  const event = await EventBlock.create(data, this.head);
20002
- const mblocks = new MemoryBlockstore();
20074
+ const mblocks = new MemoryBlockstore2();
20003
20075
  const blocks = new MultiBlockFetcher(mblocks, this.blocks);
20004
20076
  mblocks.putSync(event.cid, event.bytes);
20005
20077
  const head = await advance(blocks, this.head, event.cid);
@@ -20039,7 +20111,7 @@ ${key.data.toString("base64")}
20039
20111
  * @param {string} init.prefix
20040
20112
  */
20041
20113
  static async create({ blocks, head, prefix }) {
20042
- const mblocks = new MemoryBlockstore();
20114
+ const mblocks = new MemoryBlockstore2();
20043
20115
  blocks = new MultiBlockFetcher(mblocks, blocks);
20044
20116
  if (!head.length) {
20045
20117
  const base5 = await ShardBlock.create();
@@ -28480,10 +28552,8 @@ ${key.data.toString("base64")}
28480
28552
 
28481
28553
  // src/crdt-helpers.ts
28482
28554
  function time(tag2) {
28483
- console.time(tag2);
28484
28555
  }
28485
28556
  function timeEnd(tag2) {
28486
- console.timeEnd(tag2);
28487
28557
  }
28488
28558
  async function applyBulkUpdateToCrdt(tblocks, head, updates) {
28489
28559
  let result = null;
@@ -28610,6 +28680,7 @@ ${key.data.toString("base64")}
28610
28680
  if (!block)
28611
28681
  throw new Error(`Missing linked block ${link2.toString()}`);
28612
28682
  const { value } = await decode11({ bytes: block.bytes, hasher: sha256, codec: src_exports });
28683
+ value.cid = link2;
28613
28684
  readFiles(blocks, value);
28614
28685
  return value;
28615
28686
  }
@@ -29531,7 +29602,7 @@ ${key.data.toString("base64")}
29531
29602
  try {
29532
29603
  head = await advance(tblocks, head, cid);
29533
29604
  } catch (e) {
29534
- console.error("failed to advance", cid.toString(), e);
29605
+ console.log("failed to advance head:", cid.toString());
29535
29606
  continue;
29536
29607
  }
29537
29608
  }
@@ -29561,8 +29632,8 @@ ${key.data.toString("base64")}
29561
29632
  return { head: this.clock.head };
29562
29633
  },
29563
29634
  autoCompact: this.opts.autoCompact || 100,
29564
- crypto: crypto_node_exports,
29565
- store: store_node_exports,
29635
+ crypto: this.opts.crypto || crypto_node_exports,
29636
+ store: this.opts.store || store_node_exports,
29566
29637
  public: this.opts.public,
29567
29638
  meta: this.opts.meta
29568
29639
  });