@fireproof/core 0.17.4 → 0.17.5

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.
@@ -4089,7 +4089,7 @@ var Fireproof = (() => {
4089
4089
  };
4090
4090
  var parse = (source, base4) => CID.parse(source, base4);
4091
4091
 
4092
- // ../../node_modules/.pnpm/@web3-storage+pail@0.4.0/node_modules/@web3-storage/pail/src/block.js
4092
+ // ../../node_modules/.pnpm/@web3-storage+pail@0.4.2/node_modules/@web3-storage/pail/src/block.js
4093
4093
  var MemoryBlockstore = class {
4094
4094
  /** @type {Map<string, Uint8Array>} */
4095
4095
  #blocks = /* @__PURE__ */ new Map();
@@ -4136,6 +4136,22 @@ 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
+ };
4139
4155
 
4140
4156
  // ../../node_modules/.pnpm/yocto-queue@1.0.0/node_modules/yocto-queue/index.js
4141
4157
  var Node = class {
@@ -10013,7 +10029,7 @@ You can use close({ resize: true }) to resize header`);
10013
10029
  }
10014
10030
  return bytes;
10015
10031
  }
10016
- var PACKAGE_VERSION = "0.17.3";
10032
+ var PACKAGE_VERSION = "0.17.4";
10017
10033
  var match = PACKAGE_VERSION.match(/^([^.]*\.[^.]*)/);
10018
10034
  if (!match)
10019
10035
  throw new Error("invalid version: " + PACKAGE_VERSION);
@@ -18768,7 +18784,7 @@ ${key.data.toString("base64")}
18768
18784
  var import_path = __require("path");
18769
18785
  var import_os = __require("os");
18770
18786
  var import_promises = __require("fs/promises");
18771
- var PACKAGE_VERSION2 = "0.17.3";
18787
+ var PACKAGE_VERSION2 = "0.17.4";
18772
18788
  var match2 = PACKAGE_VERSION2.match(/^([^.]*\.[^.]*)/);
18773
18789
  if (!match2)
18774
18790
  throw new Error("invalid version: " + PACKAGE_VERSION2);
@@ -19034,7 +19050,7 @@ ${key.data.toString("base64")}
19034
19050
  return await (0, import_promises.writeFile)(path, data);
19035
19051
  }
19036
19052
 
19037
- // ../../node_modules/.pnpm/@web3-storage+pail@0.4.1/node_modules/@web3-storage/pail/src/clock/index.js
19053
+ // ../../node_modules/.pnpm/@web3-storage+pail@0.4.2/node_modules/@web3-storage/pail/src/clock/index.js
19038
19054
  var advance = async (blocks, head, event) => {
19039
19055
  const events = new EventFetcher(blocks);
19040
19056
  const headmap = new Map(head.map((cid) => [cid.toString(), cid]));
@@ -19160,7 +19176,7 @@ ${key.data.toString("base64")}
19160
19176
  };
19161
19177
  var shortLink = (l) => `${String(l).slice(0, 4)}..${String(l).slice(-4)}`;
19162
19178
 
19163
- // ../../node_modules/.pnpm/@web3-storage+pail@0.4.1/node_modules/@web3-storage/pail/src/shard.js
19179
+ // ../../node_modules/.pnpm/@web3-storage+pail@0.4.2/node_modules/@web3-storage/pail/src/shard.js
19164
19180
  var MaxKeyLength = 64;
19165
19181
  var MaxShardSize = 512 * 1024;
19166
19182
  var CID_TAG2 = new Token(Type.tag, 42);
@@ -19292,7 +19308,7 @@ ${key.data.toString("base64")}
19292
19308
  }
19293
19309
  };
19294
19310
 
19295
- // ../../node_modules/.pnpm/@web3-storage+pail@0.4.1/node_modules/@web3-storage/pail/src/index.js
19311
+ // ../../node_modules/.pnpm/@web3-storage+pail@0.4.2/node_modules/@web3-storage/pail/src/index.js
19296
19312
  var put = async (blocks, root2, key, value) => {
19297
19313
  const shards = new ShardFetcher(blocks);
19298
19314
  const rshard = await shards.get(root2);
@@ -19495,71 +19511,7 @@ ${key.data.toString("base64")}
19495
19511
  return [shard];
19496
19512
  };
19497
19513
 
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
19514
+ // ../../node_modules/.pnpm/@web3-storage+pail@0.4.2/node_modules/@web3-storage/pail/src/batch/shard.js
19563
19515
  var ShardLinkByteLength = 36;
19564
19516
  var CID_TAG3 = new Token(Type.tag, 42);
19565
19517
  var create8 = (init2) => ({
@@ -19606,7 +19558,7 @@ ${key.data.toString("base64")}
19606
19558
  return tokensToLength(tokens);
19607
19559
  };
19608
19560
 
19609
- // ../../node_modules/.pnpm/@web3-storage+pail@0.4.1/node_modules/@web3-storage/pail/src/batch/index.js
19561
+ // ../../node_modules/.pnpm/@web3-storage+pail@0.4.2/node_modules/@web3-storage/pail/src/batch/index.js
19610
19562
  var Batcher = class _Batcher {
19611
19563
  #committed = false;
19612
19564
  /**
@@ -19788,9 +19740,9 @@ ${key.data.toString("base64")}
19788
19740
  static code = "ERR_BATCH_COMMITTED";
19789
19741
  };
19790
19742
 
19791
- // ../../node_modules/.pnpm/@web3-storage+pail@0.4.1/node_modules/@web3-storage/pail/src/crdt/index.js
19743
+ // ../../node_modules/.pnpm/@web3-storage+pail@0.4.2/node_modules/@web3-storage/pail/src/crdt/index.js
19792
19744
  var put3 = async (blocks, head, key, value) => {
19793
- const mblocks = new MemoryBlockstore2();
19745
+ const mblocks = new MemoryBlockstore();
19794
19746
  blocks = new MultiBlockFetcher(mblocks, blocks);
19795
19747
  if (!head.length) {
19796
19748
  const shard = await ShardBlock.create();
@@ -19874,7 +19826,7 @@ ${key.data.toString("base64")}
19874
19826
  var root = async (blocks, head) => {
19875
19827
  if (!head.length)
19876
19828
  throw new Error("cannot determine root of headless clock");
19877
- const mblocks = new MemoryBlockstore2();
19829
+ const mblocks = new MemoryBlockstore();
19878
19830
  blocks = new MultiBlockFetcher(mblocks, blocks);
19879
19831
  const events = new EventFetcher(blocks);
19880
19832
  if (head.length === 1) {
@@ -19933,7 +19885,7 @@ ${key.data.toString("base64")}
19933
19885
  return;
19934
19886
  const result = await root(blocks, head);
19935
19887
  if (result.additions.length) {
19936
- blocks = new MultiBlockFetcher(new MemoryBlockstore2(result.additions), blocks);
19888
+ blocks = new MultiBlockFetcher(new MemoryBlockstore(result.additions), blocks);
19937
19889
  }
19938
19890
  return get2(blocks, result.root, key);
19939
19891
  };
@@ -19942,7 +19894,7 @@ ${key.data.toString("base64")}
19942
19894
  return;
19943
19895
  const result = await root(blocks, head);
19944
19896
  if (result.additions.length) {
19945
- blocks = new MultiBlockFetcher(new MemoryBlockstore2(result.additions), blocks);
19897
+ blocks = new MultiBlockFetcher(new MemoryBlockstore(result.additions), blocks);
19946
19898
  }
19947
19899
  yield* entries(blocks, result.root, options);
19948
19900
  };
@@ -20026,7 +19978,7 @@ ${key.data.toString("base64")}
20026
19978
  return acc.concat(...rest);
20027
19979
  };
20028
19980
 
20029
- // ../../node_modules/.pnpm/@web3-storage+pail@0.4.1/node_modules/@web3-storage/pail/src/crdt/batch/index.js
19981
+ // ../../node_modules/.pnpm/@web3-storage+pail@0.4.2/node_modules/@web3-storage/pail/src/crdt/batch/index.js
20030
19982
  var Batcher2 = class _Batcher {
20031
19983
  #committed = false;
20032
19984
  /**
@@ -20071,7 +20023,7 @@ ${key.data.toString("base64")}
20071
20023
  const res = await commit(this);
20072
20024
  const data = { type: "batch", ops: this.ops, root: res.root };
20073
20025
  const event = await EventBlock.create(data, this.head);
20074
- const mblocks = new MemoryBlockstore2();
20026
+ const mblocks = new MemoryBlockstore();
20075
20027
  const blocks = new MultiBlockFetcher(mblocks, this.blocks);
20076
20028
  mblocks.putSync(event.cid, event.bytes);
20077
20029
  const head = await advance(blocks, this.head, event.cid);
@@ -20111,7 +20063,7 @@ ${key.data.toString("base64")}
20111
20063
  * @param {string} init.prefix
20112
20064
  */
20113
20065
  static async create({ blocks, head, prefix }) {
20114
- const mblocks = new MemoryBlockstore2();
20066
+ const mblocks = new MemoryBlockstore();
20115
20067
  blocks = new MultiBlockFetcher(mblocks, blocks);
20116
20068
  if (!head.length) {
20117
20069
  const base5 = await ShardBlock.create();