@fireproof/core 0.17.2 → 0.17.4

Sign up to get free protection for your applications and to get access to all the features.
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
@@ -4129,22 +4129,6 @@ var Fireproof = (() => {
4129
4129
  }
4130
4130
  }
4131
4131
  };
4132
- var MultiBlockFetcher = class {
4133
- /** @type {API.BlockFetcher[]} */
4134
- #fetchers;
4135
- /** @param {API.BlockFetcher[]} fetchers */
4136
- constructor(...fetchers) {
4137
- this.#fetchers = fetchers;
4138
- }
4139
- /** @type {API.BlockFetcher['get']} */
4140
- async get(link2) {
4141
- for (const f of this.#fetchers) {
4142
- const v = await f.get(link2);
4143
- if (v)
4144
- return v;
4145
- }
4146
- }
4147
- };
4148
4132
 
4149
4133
  // ../../node_modules/.pnpm/yocto-queue@1.0.0/node_modules/yocto-queue/index.js
4150
4134
  var Node = class {
@@ -9891,8 +9875,7 @@ You can use close({ resize: true }) to resize header`);
9891
9875
  return uint8Array;
9892
9876
  }
9893
9877
  async function encryptedEncodeCarFile(crypto2, key, rootCid, t) {
9894
- const encryptionKeyUint8 = hexStringToUint8Array(key);
9895
- const encryptionKey = encryptionKeyUint8.buffer.slice(0, encryptionKeyUint8.byteLength);
9878
+ const encryptionKey = hexStringToUint8Array(key);
9896
9879
  const encryptedBlocks = new MemoryBlockstore();
9897
9880
  const cidsToEncrypt = [];
9898
9881
  for (const { cid } of t.entries()) {
@@ -9969,7 +9952,7 @@ You can use close({ resize: true }) to resize header`);
9969
9952
  }
9970
9953
  return bytes;
9971
9954
  }
9972
- var PACKAGE_VERSION = "0.16.10";
9955
+ var PACKAGE_VERSION = "0.17.3";
9973
9956
  var match = PACKAGE_VERSION.match(/^([^.]*\.[^.]*)/);
9974
9957
  if (!match)
9975
9958
  throw new Error("invalid version: " + PACKAGE_VERSION);
@@ -10045,11 +10028,11 @@ You can use close({ resize: true }) to resize header`);
10045
10028
  constructor(name7, ebOpts) {
10046
10029
  this.name = name7;
10047
10030
  this.ebOpts = ebOpts;
10048
- this.metaStore = new ebOpts.store.MetaStore(this.name);
10049
- this.carStore = new ebOpts.store.DataStore(this.name);
10050
- this.fileStore = new ebOpts.store.DataStore(this.name);
10051
- this.remoteWAL = new ebOpts.store.RemoteWAL(this);
10031
+ this.carStore = ebOpts.store.makeDataStore(this.name);
10032
+ this.fileStore = ebOpts.store.makeDataStore(this.name);
10033
+ this.remoteWAL = ebOpts.store.makeRemoteWAL(this);
10052
10034
  this.ready = Promise.resolve().then(async () => {
10035
+ this.metaStore = ebOpts.store.makeMetaStore(this);
10053
10036
  if (!this.metaStore || !this.carStore || !this.remoteWAL)
10054
10037
  throw new Error("stores not initialized");
10055
10038
  const metas = this.ebOpts.meta ? [this.ebOpts.meta] : await this.metaStore.load("main");
@@ -10223,19 +10206,30 @@ You can use close({ resize: true }) to resize header`);
10223
10206
  const sCid = cid.toString();
10224
10207
  if (this.getBlockCache.has(sCid))
10225
10208
  return this.getBlockCache.get(sCid);
10226
- const got = await Promise.any(
10227
- // maybe worth taking this in chunks of 5? to allow cache to favor recent files, carLog order is newest first
10228
- this.carLog.map(async (carCid) => {
10229
- const reader = await this.loadCar(carCid);
10230
- if (!reader) {
10231
- throw new Error(`missing car reader ${carCid.toString()}`);
10232
- }
10233
- await this.cacheCarReader(reader);
10234
- if (this.getBlockCache.has(sCid))
10235
- return this.getBlockCache.get(sCid);
10236
- throw new Error(`block not in reader: ${cid.toString()}`);
10237
- })
10238
- ).catch(() => void 0);
10209
+ const getCarCid = async (carCid) => {
10210
+ const reader = await this.loadCar(carCid);
10211
+ if (!reader) {
10212
+ throw new Error(`missing car reader ${carCid.toString()}`);
10213
+ }
10214
+ await this.cacheCarReader(reader);
10215
+ if (this.getBlockCache.has(sCid))
10216
+ return this.getBlockCache.get(sCid);
10217
+ throw new Error(`block not in reader: ${cid.toString()}`);
10218
+ };
10219
+ let got;
10220
+ const batchSize = 5;
10221
+ for (let i = 0; i < this.carLog.length; i += batchSize) {
10222
+ const promises = [];
10223
+ for (let j = i; j < Math.min(i + batchSize, this.carLog.length); j++) {
10224
+ promises.push(getCarCid(this.carLog[j]));
10225
+ }
10226
+ try {
10227
+ got = await Promise.any(promises);
10228
+ } catch {
10229
+ }
10230
+ if (got)
10231
+ break;
10232
+ }
10239
10233
  if (got) {
10240
10234
  this.getBlockCache.set(sCid, got);
10241
10235
  }
@@ -10476,14 +10470,6 @@ You can use close({ resize: true }) to resize header`);
10476
10470
  return bytes;
10477
10471
  }
10478
10472
 
10479
- // ../encrypted-blockstore/dist/lib/store-web.js
10480
- var store_web_exports = {};
10481
- __export(store_web_exports, {
10482
- DataStore: () => DataStore2,
10483
- MetaStore: () => MetaStore2,
10484
- RemoteWAL: () => RemoteWAL2
10485
- });
10486
-
10487
10473
  // ../../node_modules/.pnpm/idb@7.1.1/node_modules/idb/build/wrap-idb-value.js
10488
10474
  var instanceOfAny = (object, constructors) => constructors.some((c) => object instanceof c);
10489
10475
  var idbProxyableTypes;
@@ -10692,7 +10678,7 @@ You can use close({ resize: true }) to resize header`);
10692
10678
  }));
10693
10679
 
10694
10680
  // ../encrypted-blockstore/dist/lib/store-web.js
10695
- var PACKAGE_VERSION2 = "0.16.10";
10681
+ var PACKAGE_VERSION2 = "0.17.3";
10696
10682
  var match2 = PACKAGE_VERSION2.match(/^([^.]*\.[^.]*)/);
10697
10683
  if (!match2)
10698
10684
  throw new Error("invalid version: " + PACKAGE_VERSION2);
@@ -10780,14 +10766,14 @@ You can use close({ resize: true }) to resize header`);
10780
10766
  processQueue = new CommitQueue2();
10781
10767
  constructor(loader) {
10782
10768
  this.loader = loader;
10783
- this.ready = (async () => {
10769
+ this.ready = Promise.resolve().then(async () => {
10784
10770
  const walState = await this.load().catch((e) => {
10785
10771
  console.error("error loading wal", e);
10786
10772
  return null;
10787
10773
  });
10788
10774
  this.walState.operations = walState?.operations || [];
10789
10775
  this.walState.fileOperations = walState?.fileOperations || [];
10790
- })();
10776
+ });
10791
10777
  }
10792
10778
  async enqueue(dbMeta, opts) {
10793
10779
  await this.ready;
@@ -10886,6 +10872,9 @@ You can use close({ resize: true }) to resize header`);
10886
10872
  await rmlp;
10887
10873
  }
10888
10874
  };
10875
+ var makeDataStore = (name7) => new DataStore2(name7);
10876
+ var makeMetaStore = (loader) => new MetaStore2(loader.name);
10877
+ var makeRemoteWAL = (loader) => new RemoteWAL2(loader);
10889
10878
  var DataStore2 = class extends DataStore {
10890
10879
  tag = "car-web-idb";
10891
10880
  idb = null;
@@ -10980,7 +10969,14 @@ You can use close({ resize: true }) to resize header`);
10980
10969
  }
10981
10970
  };
10982
10971
 
10983
- // ../../node_modules/.pnpm/@web3-storage+pail@0.4.0/node_modules/@web3-storage/pail/src/clock/index.js
10972
+ // src/eb-web.ts
10973
+ var store = {
10974
+ makeDataStore,
10975
+ makeMetaStore,
10976
+ makeRemoteWAL
10977
+ };
10978
+
10979
+ // ../../node_modules/.pnpm/@web3-storage+pail@0.4.1/node_modules/@web3-storage/pail/src/clock/index.js
10984
10980
  var advance = async (blocks, head, event) => {
10985
10981
  const events = new EventFetcher(blocks);
10986
10982
  const headmap = new Map(head.map((cid) => [cid.toString(), cid]));
@@ -11106,7 +11102,7 @@ You can use close({ resize: true }) to resize header`);
11106
11102
  };
11107
11103
  var shortLink = (l) => `${String(l).slice(0, 4)}..${String(l).slice(-4)}`;
11108
11104
 
11109
- // ../../node_modules/.pnpm/@web3-storage+pail@0.4.0/node_modules/@web3-storage/pail/src/shard.js
11105
+ // ../../node_modules/.pnpm/@web3-storage+pail@0.4.1/node_modules/@web3-storage/pail/src/shard.js
11110
11106
  var MaxKeyLength = 64;
11111
11107
  var MaxShardSize = 512 * 1024;
11112
11108
  var CID_TAG2 = new Token(Type.tag, 42);
@@ -11237,41 +11233,8 @@ You can use close({ resize: true }) to resize header`);
11237
11233
  }
11238
11234
  }
11239
11235
  };
11240
- var encodedLength = (shard) => {
11241
- let entriesLength = 0;
11242
- for (const entry of shard.entries) {
11243
- entriesLength += entryEncodedLength(entry);
11244
- }
11245
- const tokens = [
11246
- new Token(Type.map, 3),
11247
- new Token(Type.string, "entries"),
11248
- new Token(Type.array, shard.entries.length),
11249
- new Token(Type.string, "maxKeyLength"),
11250
- new Token(Type.uint, shard.maxKeyLength),
11251
- new Token(Type.string, "maxSize"),
11252
- new Token(Type.uint, shard.maxSize)
11253
- ];
11254
- return tokensToLength(tokens) + entriesLength;
11255
- };
11256
- var entryEncodedLength = (entry) => {
11257
- const tokens = [
11258
- new Token(Type.array, entry.length),
11259
- new Token(Type.string, entry[0])
11260
- ];
11261
- if (Array.isArray(entry[1])) {
11262
- tokens.push(new Token(Type.array, entry[1].length));
11263
- for (const link2 of entry[1]) {
11264
- tokens.push(CID_TAG2);
11265
- tokens.push(new Token(Type.bytes, { length: link2.byteLength + 1 }));
11266
- }
11267
- } else {
11268
- tokens.push(CID_TAG2);
11269
- tokens.push(new Token(Type.bytes, { length: entry[1].byteLength + 1 }));
11270
- }
11271
- return tokensToLength(tokens);
11272
- };
11273
11236
 
11274
- // ../../node_modules/.pnpm/@web3-storage+pail@0.4.0/node_modules/@web3-storage/pail/src/index.js
11237
+ // ../../node_modules/.pnpm/@web3-storage+pail@0.4.1/node_modules/@web3-storage/pail/src/index.js
11275
11238
  var put = async (blocks, root2, key, value) => {
11276
11239
  const shards = new ShardFetcher(blocks);
11277
11240
  const rshard = await shards.get(root2);
@@ -11474,15 +11437,118 @@ You can use close({ resize: true }) to resize header`);
11474
11437
  return [shard];
11475
11438
  };
11476
11439
 
11477
- // ../../node_modules/.pnpm/@web3-storage+pail@0.4.0/node_modules/@web3-storage/pail/src/batch/shard.js
11440
+ // ../../node_modules/.pnpm/@web3-storage+pail@0.4.1/node_modules/@web3-storage/pail/src/block.js
11441
+ var MemoryBlockstore2 = class {
11442
+ /** @type {Map<string, Uint8Array>} */
11443
+ #blocks = /* @__PURE__ */ new Map();
11444
+ /**
11445
+ * @param {Array<import('multiformats').Block>} [blocks]
11446
+ */
11447
+ constructor(blocks) {
11448
+ if (blocks) {
11449
+ this.#blocks = new Map(blocks.map((b) => [b.cid.toString(), b.bytes]));
11450
+ }
11451
+ }
11452
+ /** @type {API.BlockFetcher['get']} */
11453
+ async get(cid) {
11454
+ const bytes = this.#blocks.get(cid.toString());
11455
+ if (!bytes)
11456
+ return;
11457
+ return { cid, bytes };
11458
+ }
11459
+ /**
11460
+ * @param {API.UnknownLink} cid
11461
+ * @param {Uint8Array} bytes
11462
+ */
11463
+ async put(cid, bytes) {
11464
+ this.#blocks.set(cid.toString(), bytes);
11465
+ }
11466
+ /**
11467
+ * @param {API.UnknownLink} cid
11468
+ * @param {Uint8Array} bytes
11469
+ */
11470
+ putSync(cid, bytes) {
11471
+ this.#blocks.set(cid.toString(), bytes);
11472
+ }
11473
+ /** @param {API.UnknownLink} cid */
11474
+ async delete(cid) {
11475
+ this.#blocks.delete(cid.toString());
11476
+ }
11477
+ /** @param {API.UnknownLink} cid */
11478
+ deleteSync(cid) {
11479
+ this.#blocks.delete(cid.toString());
11480
+ }
11481
+ *entries() {
11482
+ for (const [str, bytes] of this.#blocks) {
11483
+ yield { cid: parse(str), bytes };
11484
+ }
11485
+ }
11486
+ };
11487
+ var MultiBlockFetcher = class {
11488
+ /** @type {API.BlockFetcher[]} */
11489
+ #fetchers;
11490
+ /** @param {API.BlockFetcher[]} fetchers */
11491
+ constructor(...fetchers) {
11492
+ this.#fetchers = fetchers;
11493
+ }
11494
+ /** @type {API.BlockFetcher['get']} */
11495
+ async get(link2) {
11496
+ for (const f of this.#fetchers) {
11497
+ const v = await f.get(link2);
11498
+ if (v)
11499
+ return v;
11500
+ }
11501
+ }
11502
+ };
11503
+
11504
+ // ../../node_modules/.pnpm/@web3-storage+pail@0.4.1/node_modules/@web3-storage/pail/src/batch/shard.js
11505
+ var ShardLinkByteLength = 36;
11506
+ var CID_TAG3 = new Token(Type.tag, 42);
11478
11507
  var create8 = (init2) => ({
11479
11508
  base: init2?.base,
11480
11509
  prefix: init2?.prefix ?? "",
11481
- entries: init2?.entries ?? [],
11510
+ entries: [...init2?.entries ?? []],
11482
11511
  ...configure(init2)
11483
11512
  });
11513
+ var encodedLength = (shard) => {
11514
+ let entriesLength = 0;
11515
+ for (const entry of shard.entries) {
11516
+ entriesLength += entryEncodedLength(entry);
11517
+ }
11518
+ const tokens = [
11519
+ new Token(Type.map, 3),
11520
+ new Token(Type.string, "entries"),
11521
+ new Token(Type.array, shard.entries.length),
11522
+ new Token(Type.string, "maxKeyLength"),
11523
+ new Token(Type.uint, shard.maxKeyLength),
11524
+ new Token(Type.string, "maxSize"),
11525
+ new Token(Type.uint, shard.maxSize)
11526
+ ];
11527
+ return tokensToLength(tokens) + entriesLength;
11528
+ };
11529
+ var entryEncodedLength = (entry) => {
11530
+ const tokens = [
11531
+ new Token(Type.array, entry.length),
11532
+ new Token(Type.string, entry[0])
11533
+ ];
11534
+ if (Array.isArray(entry[1])) {
11535
+ tokens.push(new Token(Type.array, entry[1].length));
11536
+ for (const item of entry[1]) {
11537
+ tokens.push(CID_TAG3);
11538
+ if (isLink(item)) {
11539
+ tokens.push(new Token(Type.bytes, { length: item.byteLength + 1 }));
11540
+ } else {
11541
+ tokens.push(new Token(Type.bytes, { length: ShardLinkByteLength + 1 }));
11542
+ }
11543
+ }
11544
+ } else {
11545
+ tokens.push(CID_TAG3);
11546
+ tokens.push(new Token(Type.bytes, { length: entry[1].byteLength + 1 }));
11547
+ }
11548
+ return tokensToLength(tokens);
11549
+ };
11484
11550
 
11485
- // ../../node_modules/.pnpm/@web3-storage+pail@0.4.0/node_modules/@web3-storage/pail/src/batch/index.js
11551
+ // ../../node_modules/.pnpm/@web3-storage+pail@0.4.1/node_modules/@web3-storage/pail/src/batch/index.js
11486
11552
  var Batcher = class _Batcher {
11487
11553
  #committed = false;
11488
11554
  /**
@@ -11497,7 +11563,7 @@ You can use close({ resize: true }) to resize header`);
11497
11563
  constructor({ blocks, entries: entries3, prefix, maxSize, maxKeyLength, base: base4 }) {
11498
11564
  this.blocks = blocks;
11499
11565
  this.prefix = prefix;
11500
- this.entries = entries3;
11566
+ this.entries = [...entries3];
11501
11567
  this.base = base4;
11502
11568
  this.maxSize = maxSize;
11503
11569
  this.maxKeyLength = maxKeyLength;
@@ -11527,7 +11593,7 @@ You can use close({ resize: true }) to resize header`);
11527
11593
  static async create({ blocks, link: link2, prefix }) {
11528
11594
  const shards = new ShardFetcher(blocks);
11529
11595
  const base4 = await shards.get(link2);
11530
- return new _Batcher({ blocks, entries: base4.value.entries, prefix, base: base4, ...configure(base4.value) });
11596
+ return new _Batcher({ blocks, prefix, base: base4, ...base4.value });
11531
11597
  }
11532
11598
  };
11533
11599
  var put2 = async (blocks, shard, key, value) => {
@@ -11564,7 +11630,7 @@ You can use close({ resize: true }) to resize header`);
11564
11630
  entry = [pfxskeys[0].key, [batcher]];
11565
11631
  }
11566
11632
  shard.entries = putEntry(asShardEntries(shard.entries), asShardEntry(entry));
11567
- const size = encodedLength(withEntries(asShardEntries(shard.entries), shard));
11633
+ const size = encodedLength(shard);
11568
11634
  if (size > shard.maxSize) {
11569
11635
  const common = findCommonPrefix(
11570
11636
  asShardEntries(shard.entries),
@@ -11601,14 +11667,16 @@ You can use close({ resize: true }) to resize header`);
11601
11667
  }
11602
11668
  };
11603
11669
  var traverse2 = async (shards, key, shard) => {
11604
- for (const e of shard.entries) {
11605
- const [k, v] = e;
11670
+ for (let i = 0; i < shard.entries.length; i++) {
11671
+ const [k, v] = shard.entries[i];
11606
11672
  if (key <= k)
11607
11673
  break;
11608
11674
  if (key.startsWith(k) && Array.isArray(v)) {
11609
11675
  if (isShardLink(v[0])) {
11610
11676
  const blk = await shards.get(v[0], shard.prefix + k);
11611
- v[0] = create8({ base: blk, prefix: blk.prefix, ...blk.value });
11677
+ const batcher = create8({ base: blk, prefix: blk.prefix, ...blk.value });
11678
+ shard.entries[i] = [k, v[1] == null ? [batcher] : [batcher, v[1]]];
11679
+ return traverse2(shards, key.slice(k.length), batcher);
11612
11680
  }
11613
11681
  return traverse2(shards, key.slice(k.length), v[0]);
11614
11682
  }
@@ -11662,9 +11730,9 @@ You can use close({ resize: true }) to resize header`);
11662
11730
  static code = "ERR_BATCH_COMMITTED";
11663
11731
  };
11664
11732
 
11665
- // ../../node_modules/.pnpm/@web3-storage+pail@0.4.0/node_modules/@web3-storage/pail/src/crdt/index.js
11733
+ // ../../node_modules/.pnpm/@web3-storage+pail@0.4.1/node_modules/@web3-storage/pail/src/crdt/index.js
11666
11734
  var put3 = async (blocks, head, key, value) => {
11667
- const mblocks = new MemoryBlockstore();
11735
+ const mblocks = new MemoryBlockstore2();
11668
11736
  blocks = new MultiBlockFetcher(mblocks, blocks);
11669
11737
  if (!head.length) {
11670
11738
  const shard = await ShardBlock.create();
@@ -11748,7 +11816,7 @@ You can use close({ resize: true }) to resize header`);
11748
11816
  var root = async (blocks, head) => {
11749
11817
  if (!head.length)
11750
11818
  throw new Error("cannot determine root of headless clock");
11751
- const mblocks = new MemoryBlockstore();
11819
+ const mblocks = new MemoryBlockstore2();
11752
11820
  blocks = new MultiBlockFetcher(mblocks, blocks);
11753
11821
  const events = new EventFetcher(blocks);
11754
11822
  if (head.length === 1) {
@@ -11807,7 +11875,7 @@ You can use close({ resize: true }) to resize header`);
11807
11875
  return;
11808
11876
  const result = await root(blocks, head);
11809
11877
  if (result.additions.length) {
11810
- blocks = new MultiBlockFetcher(new MemoryBlockstore(result.additions), blocks);
11878
+ blocks = new MultiBlockFetcher(new MemoryBlockstore2(result.additions), blocks);
11811
11879
  }
11812
11880
  return get2(blocks, result.root, key);
11813
11881
  };
@@ -11816,7 +11884,7 @@ You can use close({ resize: true }) to resize header`);
11816
11884
  return;
11817
11885
  const result = await root(blocks, head);
11818
11886
  if (result.additions.length) {
11819
- blocks = new MultiBlockFetcher(new MemoryBlockstore(result.additions), blocks);
11887
+ blocks = new MultiBlockFetcher(new MemoryBlockstore2(result.additions), blocks);
11820
11888
  }
11821
11889
  yield* entries(blocks, result.root, options);
11822
11890
  };
@@ -11900,7 +11968,7 @@ You can use close({ resize: true }) to resize header`);
11900
11968
  return acc.concat(...rest);
11901
11969
  };
11902
11970
 
11903
- // ../../node_modules/.pnpm/@web3-storage+pail@0.4.0/node_modules/@web3-storage/pail/src/crdt/batch/index.js
11971
+ // ../../node_modules/.pnpm/@web3-storage+pail@0.4.1/node_modules/@web3-storage/pail/src/crdt/batch/index.js
11904
11972
  var Batcher2 = class _Batcher {
11905
11973
  #committed = false;
11906
11974
  /**
@@ -11919,7 +11987,7 @@ You can use close({ resize: true }) to resize header`);
11919
11987
  this.blocks = blocks;
11920
11988
  this.head = head;
11921
11989
  this.prefix = prefix;
11922
- this.entries = entries3;
11990
+ this.entries = [...entries3];
11923
11991
  this.base = base4;
11924
11992
  this.maxSize = maxSize;
11925
11993
  this.maxKeyLength = maxKeyLength;
@@ -11945,7 +12013,7 @@ You can use close({ resize: true }) to resize header`);
11945
12013
  const res = await commit(this);
11946
12014
  const data = { type: "batch", ops: this.ops, root: res.root };
11947
12015
  const event = await EventBlock.create(data, this.head);
11948
- const mblocks = new MemoryBlockstore();
12016
+ const mblocks = new MemoryBlockstore2();
11949
12017
  const blocks = new MultiBlockFetcher(mblocks, this.blocks);
11950
12018
  mblocks.putSync(event.cid, event.bytes);
11951
12019
  const head = await advance(blocks, this.head, event.cid);
@@ -11985,7 +12053,7 @@ You can use close({ resize: true }) to resize header`);
11985
12053
  * @param {string} init.prefix
11986
12054
  */
11987
12055
  static async create({ blocks, head, prefix }) {
11988
- const mblocks = new MemoryBlockstore();
12056
+ const mblocks = new MemoryBlockstore2();
11989
12057
  blocks = new MultiBlockFetcher(mblocks, blocks);
11990
12058
  if (!head.length) {
11991
12059
  const base5 = await ShardBlock.create();
@@ -20431,10 +20499,8 @@ You can use close({ resize: true }) to resize header`);
20431
20499
 
20432
20500
  // src/crdt-helpers.ts
20433
20501
  function time(tag2) {
20434
- console.time(tag2);
20435
20502
  }
20436
20503
  function timeEnd(tag2) {
20437
- console.timeEnd(tag2);
20438
20504
  }
20439
20505
  async function applyBulkUpdateToCrdt(tblocks, head, updates) {
20440
20506
  let result = null;
@@ -20561,6 +20627,7 @@ You can use close({ resize: true }) to resize header`);
20561
20627
  if (!block)
20562
20628
  throw new Error(`Missing linked block ${link2.toString()}`);
20563
20629
  const { value } = await decode11({ bytes: block.bytes, hasher: sha256, codec: src_exports });
20630
+ value.cid = link2;
20564
20631
  readFiles(blocks, value);
20565
20632
  return value;
20566
20633
  }
@@ -21482,7 +21549,7 @@ You can use close({ resize: true }) to resize header`);
21482
21549
  try {
21483
21550
  head = await advance(tblocks, head, cid);
21484
21551
  } catch (e) {
21485
- console.error("failed to advance", cid.toString(), e);
21552
+ console.log("failed to advance head:", cid.toString());
21486
21553
  continue;
21487
21554
  }
21488
21555
  }
@@ -21512,8 +21579,8 @@ You can use close({ resize: true }) to resize header`);
21512
21579
  return { head: this.clock.head };
21513
21580
  },
21514
21581
  autoCompact: this.opts.autoCompact || 100,
21515
- crypto: crypto_web_exports,
21516
- store: store_web_exports,
21582
+ crypto: this.opts.crypto || crypto_web_exports,
21583
+ store: this.opts.store || store,
21517
21584
  public: this.opts.public,
21518
21585
  meta: this.opts.meta
21519
21586
  });
@@ -21528,7 +21595,7 @@ You can use close({ resize: true }) to resize header`);
21528
21595
  },
21529
21596
  crypto: crypto_web_exports,
21530
21597
  public: this.opts.public,
21531
- store: store_web_exports
21598
+ store
21532
21599
  });
21533
21600
  this.ready = Promise.all([this.blockstore.ready, this.indexBlockstore.ready]).then(() => {
21534
21601
  });