@fireproof/core 0.5.15 → 0.5.17

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.
@@ -34,17 +34,9 @@ function getAugmentedNamespace(n) {
34
34
  return a;
35
35
  }
36
36
 
37
- var browserExports$1 = {};
38
- var browser$d = {
39
- get exports(){ return browserExports$1; },
40
- set exports(v){ browserExports$1 = v; },
41
- };
37
+ var browser$d = {exports: {}};
42
38
 
43
- var safeBufferExports = {};
44
- var safeBuffer$1 = {
45
- get exports(){ return safeBufferExports; },
46
- set exports(v){ safeBufferExports = v; },
47
- };
39
+ var safeBuffer$1 = {exports: {}};
48
40
 
49
41
  var global$1 = (typeof global !== "undefined" ? global :
50
42
  typeof self !== "undefined" ? self :
@@ -2109,8 +2101,10 @@ var require$$6$1 = /*@__PURE__*/getAugmentedNamespace(_polyfillNode_buffer);
2109
2101
  throw new TypeError('Argument must be a number')
2110
2102
  }
2111
2103
  return buffer.SlowBuffer(size)
2112
- };
2113
- } (safeBuffer$1, safeBufferExports));
2104
+ };
2105
+ } (safeBuffer$1, safeBuffer$1.exports));
2106
+
2107
+ var safeBufferExports = safeBuffer$1.exports;
2114
2108
 
2115
2109
  // limit of Crypto.getRandomValues()
2116
2110
  // https://developer.mozilla.org/en-US/docs/Web/API/Crypto/getRandomValues
@@ -2161,6 +2155,9 @@ function randomBytes$2 (size, cb) {
2161
2155
  return bytes
2162
2156
  }
2163
2157
 
2158
+ var browserExports$1 = browser$d.exports;
2159
+ var randomBytes$3 = /*@__PURE__*/getDefaultExportFromCjs(browserExports$1);
2160
+
2164
2161
  var encode_1$2 = encode$9;
2165
2162
 
2166
2163
  var MSB$4 = 0x80
@@ -2243,13 +2240,13 @@ var length$2 = function (value) {
2243
2240
  )
2244
2241
  };
2245
2242
 
2246
- var varint$2 = {
2243
+ var varint$3 = {
2247
2244
  encode: encode_1$2
2248
2245
  , decode: decode$d
2249
2246
  , encodingLength: length$2
2250
2247
  };
2251
2248
 
2252
- var _brrp_varint$1 = varint$2;
2249
+ var _brrp_varint$1 = varint$3;
2253
2250
 
2254
2251
  /**
2255
2252
  * @param {Uint8Array} data
@@ -5715,12 +5712,12 @@ async function findEventsToSync (blocks, head) {
5715
5712
  // console.time(callTag + '.findCommonAncestorWithSortedEvents')
5716
5713
  const { ancestor, sorted } = await findCommonAncestorWithSortedEvents(events, head);
5717
5714
  // console.timeEnd(callTag + '.findCommonAncestorWithSortedEvents')
5718
- // console.log('sorted', !!ancestor, sorted.length)
5715
+ // console.log('sorted', !!ancestor, sorted)
5719
5716
  // console.time(callTag + '.contains')
5720
5717
 
5721
5718
  const toSync = ancestor ? await asyncFilter(sorted, async uks => !(await contains(events, ancestor, uks.cid))) : sorted;
5722
5719
  // console.timeEnd(callTag + '.contains')
5723
- console.log('toSync', !!ancestor, sorted.length - toSync.length);
5720
+ console.log('optimize sorted', !!ancestor, sorted.length - toSync.length);
5724
5721
 
5725
5722
  return { cids: events, events: toSync }
5726
5723
  }
@@ -7164,6 +7161,8 @@ var varint$1 = {
7164
7161
  , encodingLength: length$1
7165
7162
  };
7166
7163
 
7164
+ var varint$2 = /*@__PURE__*/getDefaultExportFromCjs(varint$1);
7165
+
7167
7166
  const CIDV0_BYTES = {
7168
7167
  SHA2_256: 0x12,
7169
7168
  LENGTH: 0x20,
@@ -7188,8 +7187,8 @@ function decodeVarint (bytes, seeker) {
7188
7187
  if (!bytes.length) {
7189
7188
  throw new Error('Unexpected end of data')
7190
7189
  }
7191
- const i = varint$1.decode(bytes);
7192
- seeker.seek(/** @type {number} */(varint$1.decode.bytes));
7190
+ const i = varint$2.decode(bytes);
7191
+ seeker.seek(/** @type {number} */(varint$2.decode.bytes));
7193
7192
  return i
7194
7193
  /* c8 ignore next 2 */
7195
7194
  // Node.js 12 c8 bug
@@ -7240,10 +7239,10 @@ function getMultihashLength (bytes) {
7240
7239
  // where both code and length are varints, so we have to decode
7241
7240
  // them first before we can know total length
7242
7241
 
7243
- varint$1.decode(bytes); // code
7244
- const codeLength = /** @type {number} */(varint$1.decode.bytes);
7245
- const length = varint$1.decode(bytes.subarray(varint$1.decode.bytes));
7246
- const lengthLength = /** @type {number} */(varint$1.decode.bytes);
7242
+ varint$2.decode(bytes); // code
7243
+ const codeLength = /** @type {number} */(varint$2.decode.bytes);
7244
+ const length = varint$2.decode(bytes.subarray(varint$2.decode.bytes));
7245
+ const lengthLength = /** @type {number} */(varint$2.decode.bytes);
7247
7246
  const mhLength = codeLength + lengthLength + length;
7248
7247
 
7249
7248
  return mhLength
@@ -7951,7 +7950,7 @@ const addRoot = (writer, root, options = {}) => {
7951
7950
  */
7952
7951
  const blockLength = ({ cid, bytes }) => {
7953
7952
  const size = cid.bytes.byteLength + bytes.byteLength;
7954
- return varint$1.encodingLength(size) + size
7953
+ return varint$2.encodingLength(size) + size
7955
7954
  };
7956
7955
 
7957
7956
  /**
@@ -7960,7 +7959,7 @@ const blockLength = ({ cid, bytes }) => {
7960
7959
  */
7961
7960
  const addBlock = (writer, { cid, bytes }) => {
7962
7961
  const byteLength = cid.bytes.byteLength + bytes.byteLength;
7963
- const size = varint$1.encode(byteLength);
7962
+ const size = varint$2.encode(byteLength);
7964
7963
  if (writer.byteOffset + size.length + byteLength > writer.bytes.byteLength) {
7965
7964
  throw new RangeError('Buffer has no capacity for this block')
7966
7965
  } else {
@@ -7980,7 +7979,7 @@ const close = (writer, options = {}) => {
7980
7979
  const { roots, bytes, byteOffset, headerSize } = writer;
7981
7980
 
7982
7981
  const headerBytes = encode$5({ version: 1, roots });
7983
- const varintBytes = varint$1.encode(headerBytes.length);
7982
+ const varintBytes = varint$2.encode(headerBytes.length);
7984
7983
 
7985
7984
  const size = varintBytes.length + headerBytes.byteLength;
7986
7985
  const offset = headerSize - size;
@@ -8057,7 +8056,7 @@ const calculateHeaderLength = (rootLengths) => {
8057
8056
  tokens.push(new Token(Type.bytes, { length: rootLength + 1 }));
8058
8057
  }
8059
8058
  const length = tokensToLength(tokens); // no options needed here because we have simple tokens
8060
- return varint$1.encodingLength(length) + length
8059
+ return varint$2.encodingLength(length) + length
8061
8060
  };
8062
8061
 
8063
8062
  /**
@@ -8400,23 +8399,11 @@ replaceTraps((oldTraps) => ({
8400
8399
  has: (target, prop) => !!getMethod(target, prop) || oldTraps.has(target, prop),
8401
8400
  }));
8402
8401
 
8403
- var cargoQueueExports = {};
8404
- var cargoQueue$1 = {
8405
- get exports(){ return cargoQueueExports; },
8406
- set exports(v){ cargoQueueExports = v; },
8407
- };
8402
+ var cargoQueue$1 = {exports: {}};
8408
8403
 
8409
- var queueExports = {};
8410
- var queue$1 = {
8411
- get exports(){ return queueExports; },
8412
- set exports(v){ queueExports = v; },
8413
- };
8404
+ var queue$1 = {exports: {}};
8414
8405
 
8415
- var onlyOnceExports = {};
8416
- var onlyOnce = {
8417
- get exports(){ return onlyOnceExports; },
8418
- set exports(v){ onlyOnceExports = v; },
8419
- };
8406
+ var onlyOnce = {exports: {}};
8420
8407
 
8421
8408
  (function (module, exports) {
8422
8409
 
@@ -8432,8 +8419,10 @@ var onlyOnce = {
8432
8419
  callFn.apply(this, args);
8433
8420
  };
8434
8421
  }
8435
- module.exports = exports["default"];
8436
- } (onlyOnce, onlyOnceExports));
8422
+ module.exports = exports["default"];
8423
+ } (onlyOnce, onlyOnce.exports));
8424
+
8425
+ var onlyOnceExports = onlyOnce.exports;
8437
8426
 
8438
8427
  var setImmediate$1 = {};
8439
8428
 
@@ -8470,11 +8459,7 @@ if (hasQueueMicrotask) {
8470
8459
 
8471
8460
  setImmediate$1.default = wrap(_defer);
8472
8461
 
8473
- var DoublyLinkedListExports = {};
8474
- var DoublyLinkedList = {
8475
- get exports(){ return DoublyLinkedListExports; },
8476
- set exports(v){ DoublyLinkedListExports = v; },
8477
- };
8462
+ var DoublyLinkedList = {exports: {}};
8478
8463
 
8479
8464
  (function (module, exports) {
8480
8465
 
@@ -8567,22 +8552,16 @@ var DoublyLinkedList = {
8567
8552
  dll.length = 1;
8568
8553
  dll.head = dll.tail = node;
8569
8554
  }
8570
- module.exports = exports["default"];
8571
- } (DoublyLinkedList, DoublyLinkedListExports));
8555
+ module.exports = exports["default"];
8556
+ } (DoublyLinkedList, DoublyLinkedList.exports));
8557
+
8558
+ var DoublyLinkedListExports = DoublyLinkedList.exports;
8572
8559
 
8573
8560
  var wrapAsync = {};
8574
8561
 
8575
- var asyncifyExports = {};
8576
- var asyncify = {
8577
- get exports(){ return asyncifyExports; },
8578
- set exports(v){ asyncifyExports = v; },
8579
- };
8562
+ var asyncify = {exports: {}};
8580
8563
 
8581
- var initialParamsExports = {};
8582
- var initialParams = {
8583
- get exports(){ return initialParamsExports; },
8584
- set exports(v){ initialParamsExports = v; },
8585
- };
8564
+ var initialParams = {exports: {}};
8586
8565
 
8587
8566
  (function (module, exports) {
8588
8567
 
@@ -8597,13 +8576,15 @@ var initialParams = {
8597
8576
  };
8598
8577
  };
8599
8578
 
8600
- module.exports = exports["default"];
8601
- } (initialParams, initialParamsExports));
8579
+ module.exports = exports["default"];
8580
+ } (initialParams, initialParams.exports));
8581
+
8582
+ var initialParamsExports = initialParams.exports;
8602
8583
 
8603
8584
  var hasRequiredAsyncify;
8604
8585
 
8605
8586
  function requireAsyncify () {
8606
- if (hasRequiredAsyncify) return asyncifyExports;
8587
+ if (hasRequiredAsyncify) return asyncify.exports;
8607
8588
  hasRequiredAsyncify = 1;
8608
8589
  (function (module, exports) {
8609
8590
 
@@ -8722,9 +8703,9 @@ function requireAsyncify () {
8722
8703
  }, err);
8723
8704
  }
8724
8705
  }
8725
- module.exports = exports['default'];
8726
- } (asyncify, asyncifyExports));
8727
- return asyncifyExports;
8706
+ module.exports = exports['default'];
8707
+ } (asyncify, asyncify.exports));
8708
+ return asyncify.exports;
8728
8709
  }
8729
8710
 
8730
8711
  var hasRequiredWrapAsync;
@@ -9061,8 +9042,10 @@ function requireWrapAsync () {
9061
9042
  });
9062
9043
  return q;
9063
9044
  }
9064
- module.exports = exports['default'];
9065
- } (queue$1, queueExports));
9045
+ module.exports = exports['default'];
9046
+ } (queue$1, queue$1.exports));
9047
+
9048
+ var queueExports = queue$1.exports;
9066
9049
 
9067
9050
  (function (module, exports) {
9068
9051
 
@@ -9134,9 +9117,10 @@ function requireWrapAsync () {
9134
9117
  function cargo(worker, concurrency, payload) {
9135
9118
  return (0, _queue2.default)(worker, concurrency, payload);
9136
9119
  }
9137
- module.exports = exports['default'];
9138
- } (cargoQueue$1, cargoQueueExports));
9120
+ module.exports = exports['default'];
9121
+ } (cargoQueue$1, cargoQueue$1.exports));
9139
9122
 
9123
+ var cargoQueueExports = cargoQueue$1.exports;
9140
9124
  var cargoQueue = /*@__PURE__*/getDefaultExportFromCjs(cargoQueueExports);
9141
9125
 
9142
9126
  var cryptoBrowserify = {};
@@ -9173,11 +9157,7 @@ var _polyfillNode_inherits = /*#__PURE__*/Object.freeze({
9173
9157
 
9174
9158
  var require$$3$1 = /*@__PURE__*/getAugmentedNamespace(_polyfillNode_inherits);
9175
9159
 
9176
- var readableBrowserExports = {};
9177
- var readableBrowser = {
9178
- get exports(){ return readableBrowserExports; },
9179
- set exports(v){ readableBrowserExports = v; },
9180
- };
9160
+ var readableBrowser = {exports: {}};
9181
9161
 
9182
9162
  var domain;
9183
9163
 
@@ -9659,7 +9639,15 @@ var _polyfillNode_events = /*#__PURE__*/Object.freeze({
9659
9639
 
9660
9640
  var require$$0$1 = /*@__PURE__*/getAugmentedNamespace(_polyfillNode_events);
9661
9641
 
9662
- var streamBrowser = require$$0$1.EventEmitter;
9642
+ var streamBrowser;
9643
+ var hasRequiredStreamBrowser;
9644
+
9645
+ function requireStreamBrowser () {
9646
+ if (hasRequiredStreamBrowser) return streamBrowser;
9647
+ hasRequiredStreamBrowser = 1;
9648
+ streamBrowser = require$$0$1.EventEmitter;
9649
+ return streamBrowser;
9650
+ }
9663
9651
 
9664
9652
  // shim for using process in browser
9665
9653
  // based off https://github.com/defunctzombie/node-process/blob/master/browser.js
@@ -9802,7 +9790,7 @@ var argv = [];
9802
9790
  var version$2 = ''; // empty string to avoid regexp issues
9803
9791
  var versions = {};
9804
9792
  var release = {};
9805
- var config$1 = {};
9793
+ var config = {};
9806
9794
 
9807
9795
  function noop$2() {}
9808
9796
 
@@ -9879,7 +9867,7 @@ var browser$1$1 = {
9879
9867
  hrtime: hrtime,
9880
9868
  platform: platform,
9881
9869
  release: release,
9882
- config: config$1,
9870
+ config: config,
9883
9871
  uptime: uptime
9884
9872
  };
9885
9873
 
@@ -9960,11 +9948,11 @@ function format(f) {
9960
9948
  // Mark that a method should not be used.
9961
9949
  // Returns a modified function which warns once by default.
9962
9950
  // If --no-deprecation is set, then it is a no-op.
9963
- function deprecate$2(fn, msg) {
9951
+ function deprecate$1(fn, msg) {
9964
9952
  // Allow for deprecating things in the process of starting up.
9965
9953
  if (isUndefined(global$1.process)) {
9966
9954
  return function() {
9967
- return deprecate$2(fn, msg).apply(this, arguments);
9955
+ return deprecate$1(fn, msg).apply(this, arguments);
9968
9956
  };
9969
9957
  }
9970
9958
 
@@ -10573,7 +10561,7 @@ var _polyfillNode_util = {
10573
10561
  isBoolean: isBoolean,
10574
10562
  isArray: isArray,
10575
10563
  inspect: inspect,
10576
- deprecate: deprecate$2,
10564
+ deprecate: deprecate$1,
10577
10565
  format: format,
10578
10566
  debuglog: debuglog,
10579
10567
  promisify: promisify,
@@ -10586,7 +10574,7 @@ var _polyfillNode_util$1 = /*#__PURE__*/Object.freeze({
10586
10574
  callbackify: callbackify,
10587
10575
  debuglog: debuglog,
10588
10576
  default: _polyfillNode_util,
10589
- deprecate: deprecate$2,
10577
+ deprecate: deprecate$1,
10590
10578
  format: format,
10591
10579
  inherits: inherits$w,
10592
10580
  inspect: inspect,
@@ -10774,99 +10762,108 @@ function requireBuffer_list () {
10774
10762
  return buffer_list;
10775
10763
  }
10776
10764
 
10777
- // undocumented cb() API, needed for core, not for public API
10778
- function destroy(err, cb) {
10779
- const readableDestroyed = this._readableState && this._readableState.destroyed;
10780
- const writableDestroyed = this._writableState && this._writableState.destroyed;
10781
- if (readableDestroyed || writableDestroyed) {
10782
- if (cb) {
10783
- cb(err);
10784
- } else if (err) {
10785
- if (!this._writableState) {
10786
- process.nextTick(emitErrorNT, this, err);
10787
- } else if (!this._writableState.errorEmitted) {
10788
- this._writableState.errorEmitted = true;
10789
- process.nextTick(emitErrorNT, this, err);
10790
- }
10791
- }
10792
- return this;
10793
- }
10794
-
10795
- // we set destroyed to true before firing error callbacks in order
10796
- // to make it re-entrance safe in case destroy() is called within callbacks
10765
+ var destroy_1;
10766
+ var hasRequiredDestroy;
10767
+
10768
+ function requireDestroy () {
10769
+ if (hasRequiredDestroy) return destroy_1;
10770
+ hasRequiredDestroy = 1;
10771
+
10772
+ // undocumented cb() API, needed for core, not for public API
10773
+ function destroy(err, cb) {
10774
+ const readableDestroyed = this._readableState && this._readableState.destroyed;
10775
+ const writableDestroyed = this._writableState && this._writableState.destroyed;
10776
+ if (readableDestroyed || writableDestroyed) {
10777
+ if (cb) {
10778
+ cb(err);
10779
+ } else if (err) {
10780
+ if (!this._writableState) {
10781
+ process.nextTick(emitErrorNT, this, err);
10782
+ } else if (!this._writableState.errorEmitted) {
10783
+ this._writableState.errorEmitted = true;
10784
+ process.nextTick(emitErrorNT, this, err);
10785
+ }
10786
+ }
10787
+ return this;
10788
+ }
10797
10789
 
10798
- if (this._readableState) {
10799
- this._readableState.destroyed = true;
10800
- }
10790
+ // we set destroyed to true before firing error callbacks in order
10791
+ // to make it re-entrance safe in case destroy() is called within callbacks
10801
10792
 
10802
- // if this is a duplex stream mark the writable part as destroyed as well
10803
- if (this._writableState) {
10804
- this._writableState.destroyed = true;
10805
- }
10806
- this._destroy(err || null, err => {
10807
- if (!cb && err) {
10808
- if (!this._writableState) {
10809
- process.nextTick(emitErrorAndCloseNT, this, err);
10810
- } else if (!this._writableState.errorEmitted) {
10811
- this._writableState.errorEmitted = true;
10812
- process.nextTick(emitErrorAndCloseNT, this, err);
10813
- } else {
10814
- process.nextTick(emitCloseNT, this);
10815
- }
10816
- } else if (cb) {
10817
- process.nextTick(emitCloseNT, this);
10818
- cb(err);
10819
- } else {
10820
- process.nextTick(emitCloseNT, this);
10821
- }
10822
- });
10823
- return this;
10824
- }
10825
- function emitErrorAndCloseNT(self, err) {
10826
- emitErrorNT(self, err);
10827
- emitCloseNT(self);
10828
- }
10829
- function emitCloseNT(self) {
10830
- if (self._writableState && !self._writableState.emitClose) return;
10831
- if (self._readableState && !self._readableState.emitClose) return;
10832
- self.emit('close');
10833
- }
10834
- function undestroy() {
10835
- if (this._readableState) {
10836
- this._readableState.destroyed = false;
10837
- this._readableState.reading = false;
10838
- this._readableState.ended = false;
10839
- this._readableState.endEmitted = false;
10840
- }
10841
- if (this._writableState) {
10842
- this._writableState.destroyed = false;
10843
- this._writableState.ended = false;
10844
- this._writableState.ending = false;
10845
- this._writableState.finalCalled = false;
10846
- this._writableState.prefinished = false;
10847
- this._writableState.finished = false;
10848
- this._writableState.errorEmitted = false;
10849
- }
10850
- }
10851
- function emitErrorNT(self, err) {
10852
- self.emit('error', err);
10853
- }
10854
- function errorOrDestroy(stream, err) {
10855
- // We have tests that rely on errors being emitted
10856
- // in the same tick, so changing this is semver major.
10857
- // For now when you opt-in to autoDestroy we allow
10858
- // the error to be emitted nextTick. In a future
10859
- // semver major update we should change the default to this.
10793
+ if (this._readableState) {
10794
+ this._readableState.destroyed = true;
10795
+ }
10860
10796
 
10861
- const rState = stream._readableState;
10862
- const wState = stream._writableState;
10863
- if (rState && rState.autoDestroy || wState && wState.autoDestroy) stream.destroy(err);else stream.emit('error', err);
10797
+ // if this is a duplex stream mark the writable part as destroyed as well
10798
+ if (this._writableState) {
10799
+ this._writableState.destroyed = true;
10800
+ }
10801
+ this._destroy(err || null, err => {
10802
+ if (!cb && err) {
10803
+ if (!this._writableState) {
10804
+ process.nextTick(emitErrorAndCloseNT, this, err);
10805
+ } else if (!this._writableState.errorEmitted) {
10806
+ this._writableState.errorEmitted = true;
10807
+ process.nextTick(emitErrorAndCloseNT, this, err);
10808
+ } else {
10809
+ process.nextTick(emitCloseNT, this);
10810
+ }
10811
+ } else if (cb) {
10812
+ process.nextTick(emitCloseNT, this);
10813
+ cb(err);
10814
+ } else {
10815
+ process.nextTick(emitCloseNT, this);
10816
+ }
10817
+ });
10818
+ return this;
10819
+ }
10820
+ function emitErrorAndCloseNT(self, err) {
10821
+ emitErrorNT(self, err);
10822
+ emitCloseNT(self);
10823
+ }
10824
+ function emitCloseNT(self) {
10825
+ if (self._writableState && !self._writableState.emitClose) return;
10826
+ if (self._readableState && !self._readableState.emitClose) return;
10827
+ self.emit('close');
10828
+ }
10829
+ function undestroy() {
10830
+ if (this._readableState) {
10831
+ this._readableState.destroyed = false;
10832
+ this._readableState.reading = false;
10833
+ this._readableState.ended = false;
10834
+ this._readableState.endEmitted = false;
10835
+ }
10836
+ if (this._writableState) {
10837
+ this._writableState.destroyed = false;
10838
+ this._writableState.ended = false;
10839
+ this._writableState.ending = false;
10840
+ this._writableState.finalCalled = false;
10841
+ this._writableState.prefinished = false;
10842
+ this._writableState.finished = false;
10843
+ this._writableState.errorEmitted = false;
10844
+ }
10845
+ }
10846
+ function emitErrorNT(self, err) {
10847
+ self.emit('error', err);
10848
+ }
10849
+ function errorOrDestroy(stream, err) {
10850
+ // We have tests that rely on errors being emitted
10851
+ // in the same tick, so changing this is semver major.
10852
+ // For now when you opt-in to autoDestroy we allow
10853
+ // the error to be emitted nextTick. In a future
10854
+ // semver major update we should change the default to this.
10855
+
10856
+ const rState = stream._readableState;
10857
+ const wState = stream._writableState;
10858
+ if (rState && rState.autoDestroy || wState && wState.autoDestroy) stream.destroy(err);else stream.emit('error', err);
10859
+ }
10860
+ destroy_1 = {
10861
+ destroy,
10862
+ undestroy,
10863
+ errorOrDestroy
10864
+ };
10865
+ return destroy_1;
10864
10866
  }
10865
- var destroy_1 = {
10866
- destroy,
10867
- undestroy,
10868
- errorOrDestroy
10869
- };
10870
10867
 
10871
10868
  var errorsBrowser = {};
10872
10869
 
@@ -10996,92 +10993,109 @@ createErrorType('ERR_UNKNOWN_ENCODING', function (arg) {
10996
10993
  createErrorType('ERR_STREAM_UNSHIFT_AFTER_END_EVENT', 'stream.unshift() after end event');
10997
10994
  errorsBrowser.codes = codes;
10998
10995
 
10999
- const ERR_INVALID_OPT_VALUE = errorsBrowser.codes.ERR_INVALID_OPT_VALUE;
11000
- function highWaterMarkFrom(options, isDuplex, duplexKey) {
11001
- return options.highWaterMark != null ? options.highWaterMark : isDuplex ? options[duplexKey] : null;
11002
- }
11003
- function getHighWaterMark(state, options, duplexKey, isDuplex) {
11004
- const hwm = highWaterMarkFrom(options, isDuplex, duplexKey);
11005
- if (hwm != null) {
11006
- if (!(isFinite(hwm) && Math.floor(hwm) === hwm) || hwm < 0) {
11007
- const name = isDuplex ? duplexKey : 'highWaterMark';
11008
- throw new ERR_INVALID_OPT_VALUE(name, hwm);
11009
- }
11010
- return Math.floor(hwm);
11011
- }
10996
+ var state;
10997
+ var hasRequiredState;
11012
10998
 
11013
- // Default value
11014
- return state.objectMode ? 16 : 16 * 1024;
10999
+ function requireState () {
11000
+ if (hasRequiredState) return state;
11001
+ hasRequiredState = 1;
11002
+
11003
+ const ERR_INVALID_OPT_VALUE = errorsBrowser.codes.ERR_INVALID_OPT_VALUE;
11004
+ function highWaterMarkFrom(options, isDuplex, duplexKey) {
11005
+ return options.highWaterMark != null ? options.highWaterMark : isDuplex ? options[duplexKey] : null;
11006
+ }
11007
+ function getHighWaterMark(state, options, duplexKey, isDuplex) {
11008
+ const hwm = highWaterMarkFrom(options, isDuplex, duplexKey);
11009
+ if (hwm != null) {
11010
+ if (!(isFinite(hwm) && Math.floor(hwm) === hwm) || hwm < 0) {
11011
+ const name = isDuplex ? duplexKey : 'highWaterMark';
11012
+ throw new ERR_INVALID_OPT_VALUE(name, hwm);
11013
+ }
11014
+ return Math.floor(hwm);
11015
+ }
11016
+
11017
+ // Default value
11018
+ return state.objectMode ? 16 : 16 * 1024;
11019
+ }
11020
+ state = {
11021
+ getHighWaterMark
11022
+ };
11023
+ return state;
11015
11024
  }
11016
- var state = {
11017
- getHighWaterMark
11018
- };
11019
11025
 
11020
- /**
11021
- * Module exports.
11022
- */
11026
+ var browser$b;
11027
+ var hasRequiredBrowser$3;
11023
11028
 
11024
- var browser$b = deprecate$1;
11029
+ function requireBrowser$3 () {
11030
+ if (hasRequiredBrowser$3) return browser$b;
11031
+ hasRequiredBrowser$3 = 1;
11032
+ /**
11033
+ * Module exports.
11034
+ */
11025
11035
 
11026
- /**
11027
- * Mark that a method should not be used.
11028
- * Returns a modified function which warns once by default.
11029
- *
11030
- * If `localStorage.noDeprecation = true` is set, then it is a no-op.
11031
- *
11032
- * If `localStorage.throwDeprecation = true` is set, then deprecated functions
11033
- * will throw an Error when invoked.
11034
- *
11035
- * If `localStorage.traceDeprecation = true` is set, then deprecated functions
11036
- * will invoke `console.trace()` instead of `console.error()`.
11037
- *
11038
- * @param {Function} fn - the function to deprecate
11039
- * @param {String} msg - the string to print to the console when `fn` is invoked
11040
- * @returns {Function} a new "deprecated" version of `fn`
11041
- * @api public
11042
- */
11036
+ browser$b = deprecate;
11043
11037
 
11044
- function deprecate$1 (fn, msg) {
11045
- if (config('noDeprecation')) {
11046
- return fn;
11047
- }
11038
+ /**
11039
+ * Mark that a method should not be used.
11040
+ * Returns a modified function which warns once by default.
11041
+ *
11042
+ * If `localStorage.noDeprecation = true` is set, then it is a no-op.
11043
+ *
11044
+ * If `localStorage.throwDeprecation = true` is set, then deprecated functions
11045
+ * will throw an Error when invoked.
11046
+ *
11047
+ * If `localStorage.traceDeprecation = true` is set, then deprecated functions
11048
+ * will invoke `console.trace()` instead of `console.error()`.
11049
+ *
11050
+ * @param {Function} fn - the function to deprecate
11051
+ * @param {String} msg - the string to print to the console when `fn` is invoked
11052
+ * @returns {Function} a new "deprecated" version of `fn`
11053
+ * @api public
11054
+ */
11048
11055
 
11049
- var warned = false;
11050
- function deprecated() {
11051
- if (!warned) {
11052
- if (config('throwDeprecation')) {
11053
- throw new Error(msg);
11054
- } else if (config('traceDeprecation')) {
11055
- console.trace(msg);
11056
- } else {
11057
- console.warn(msg);
11058
- }
11059
- warned = true;
11060
- }
11061
- return fn.apply(this, arguments);
11062
- }
11056
+ function deprecate (fn, msg) {
11057
+ if (config('noDeprecation')) {
11058
+ return fn;
11059
+ }
11063
11060
 
11064
- return deprecated;
11065
- }
11061
+ var warned = false;
11062
+ function deprecated() {
11063
+ if (!warned) {
11064
+ if (config('throwDeprecation')) {
11065
+ throw new Error(msg);
11066
+ } else if (config('traceDeprecation')) {
11067
+ console.trace(msg);
11068
+ } else {
11069
+ console.warn(msg);
11070
+ }
11071
+ warned = true;
11072
+ }
11073
+ return fn.apply(this, arguments);
11074
+ }
11066
11075
 
11067
- /**
11068
- * Checks `localStorage` for boolean values for the given `name`.
11069
- *
11070
- * @param {String} name
11071
- * @returns {Boolean}
11072
- * @api private
11073
- */
11076
+ return deprecated;
11077
+ }
11074
11078
 
11075
- function config (name) {
11076
- // accessing global.localStorage can trigger a DOMException in sandboxed iframes
11077
- try {
11078
- if (!commonjsGlobal.localStorage) return false;
11079
- } catch (_) {
11080
- return false;
11081
- }
11082
- var val = commonjsGlobal.localStorage[name];
11083
- if (null == val) return false;
11084
- return String(val).toLowerCase() === 'true';
11079
+ /**
11080
+ * Checks `localStorage` for boolean values for the given `name`.
11081
+ *
11082
+ * @param {String} name
11083
+ * @returns {Boolean}
11084
+ * @api private
11085
+ */
11086
+
11087
+ function config (name) {
11088
+ // accessing global.localStorage can trigger a DOMException in sandboxed iframes
11089
+ try {
11090
+ if (!commonjsGlobal.localStorage) return false;
11091
+ } catch (_) {
11092
+ return false;
11093
+ }
11094
+ var val = commonjsGlobal.localStorage[name];
11095
+ if (null == val) return false;
11096
+ return String(val).toLowerCase() === 'true';
11097
+ }
11098
+ return browser$b;
11085
11099
  }
11086
11100
 
11087
11101
  var _stream_writable;
@@ -11112,12 +11126,12 @@ function require_stream_writable () {
11112
11126
 
11113
11127
  /*<replacement>*/
11114
11128
  const internalUtil = {
11115
- deprecate: browser$b
11129
+ deprecate: requireBrowser$3()
11116
11130
  };
11117
11131
  /*</replacement>*/
11118
11132
 
11119
11133
  /*<replacement>*/
11120
- var Stream = streamBrowser;
11134
+ var Stream = requireStreamBrowser();
11121
11135
  /*</replacement>*/
11122
11136
 
11123
11137
  const Buffer = require$$6$1.Buffer;
@@ -11128,8 +11142,8 @@ function require_stream_writable () {
11128
11142
  function _isUint8Array(obj) {
11129
11143
  return Buffer.isBuffer(obj) || obj instanceof OurUint8Array;
11130
11144
  }
11131
- const destroyImpl = destroy_1;
11132
- const _require = state,
11145
+ const destroyImpl = requireDestroy();
11146
+ const _require = requireState(),
11133
11147
  getHighWaterMark = _require.getHighWaterMark;
11134
11148
  const _require$codes = errorsBrowser.codes,
11135
11149
  ERR_INVALID_ARG_TYPE = _require$codes.ERR_INVALID_ARG_TYPE,
@@ -12323,7 +12337,7 @@ function require_stream_readable () {
12323
12337
  /*</replacement>*/
12324
12338
 
12325
12339
  /*<replacement>*/
12326
- var Stream = streamBrowser;
12340
+ var Stream = requireStreamBrowser();
12327
12341
  /*</replacement>*/
12328
12342
 
12329
12343
  const Buffer = require$$6$1.Buffer;
@@ -12346,8 +12360,8 @@ function require_stream_readable () {
12346
12360
  /*</replacement>*/
12347
12361
 
12348
12362
  const BufferList = requireBuffer_list();
12349
- const destroyImpl = destroy_1;
12350
- const _require = state,
12363
+ const destroyImpl = requireDestroy();
12364
+ const _require = requireState(),
12351
12365
  getHighWaterMark = _require.getHighWaterMark;
12352
12366
  const _require$codes = errorsBrowser.codes,
12353
12367
  ERR_INVALID_ARG_TYPE = _require$codes.ERR_INVALID_ARG_TYPE,
@@ -13540,8 +13554,10 @@ var pipeline_1 = pipeline;
13540
13554
  exports.Transform = _stream_transform;
13541
13555
  exports.PassThrough = _stream_passthrough;
13542
13556
  exports.finished = endOfStream;
13543
- exports.pipeline = pipeline_1;
13544
- } (readableBrowser, readableBrowserExports));
13557
+ exports.pipeline = pipeline_1;
13558
+ } (readableBrowser, readableBrowser.exports));
13559
+
13560
+ var readableBrowserExports = readableBrowser.exports;
13545
13561
 
13546
13562
  var Buffer$E = safeBufferExports.Buffer;
13547
13563
  var Transform$6 = readableBrowserExports.Transform;
@@ -13947,11 +13963,7 @@ function fn5 (a, b, c, d, e, m, k, s) {
13947
13963
 
13948
13964
  var ripemd160 = RIPEMD160$4;
13949
13965
 
13950
- var sha_jsExports = {};
13951
- var sha_js = {
13952
- get exports(){ return sha_jsExports; },
13953
- set exports(v){ sha_jsExports = v; },
13954
- };
13966
+ var sha_js = {exports: {}};
13955
13967
 
13956
13968
  var Buffer$B = safeBufferExports.Buffer;
13957
13969
 
@@ -14755,6 +14767,8 @@ exports$1.sha256 = sha256$1;
14755
14767
  exports$1.sha384 = sha384$1;
14756
14768
  exports$1.sha512 = sha512$1;
14757
14769
 
14770
+ var sha_jsExports = sha_js.exports;
14771
+
14758
14772
  function BufferList() {
14759
14773
  this.head = null;
14760
14774
  this.tail = null;
@@ -15713,7 +15727,7 @@ function WriteReq(chunk, encoding, cb) {
15713
15727
 
15714
15728
  function WritableState(options, stream) {
15715
15729
  Object.defineProperty(this, 'buffer', {
15716
- get: deprecate$2(function () {
15730
+ get: deprecate$1(function () {
15717
15731
  return this.getBuffer();
15718
15732
  }, '_writableState.buffer is deprecated. Use _writableState.getBuffer ' + 'instead.')
15719
15733
  });
@@ -16705,12 +16719,6 @@ var browser$9 = function createHmac (alg, key) {
16705
16719
  return new Hmac$2(alg, key)
16706
16720
  };
16707
16721
 
16708
- var algosExports = {};
16709
- var algos = {
16710
- get exports(){ return algosExports; },
16711
- set exports(v){ algosExports = v; },
16712
- };
16713
-
16714
16722
  var sha224WithRSAEncryption = {
16715
16723
  sign: "rsa",
16716
16724
  hash: "sha224",
@@ -16875,9 +16883,7 @@ var require$$6 = {
16875
16883
  }
16876
16884
  };
16877
16885
 
16878
- (function (module) {
16879
- module.exports = require$$6;
16880
- } (algos));
16886
+ var algos = require$$6;
16881
16887
 
16882
16888
  var browser$8 = {};
16883
16889
 
@@ -19117,7 +19123,7 @@ var modes = {};
19117
19123
  exports['des-ede'] = {
19118
19124
  key: 16,
19119
19125
  iv: 0
19120
- };
19126
+ };
19121
19127
  } (modes));
19122
19128
 
19123
19129
  var DES = browserifyDes;
@@ -19190,11 +19196,9 @@ browser$7.listCiphers = browser$7.getCiphers = getCiphers;
19190
19196
 
19191
19197
  var browser$5 = {};
19192
19198
 
19193
- var bnExports$1 = {};
19194
- var bn$1 = {
19195
- get exports(){ return bnExports$1; },
19196
- set exports(v){ bnExports$1 = v; },
19197
- };
19199
+ var bn$1 = {exports: {}};
19200
+
19201
+ bn$1.exports;
19198
19202
 
19199
19203
  (function (module) {
19200
19204
  (function (module, exports) {
@@ -22639,19 +22643,17 @@ var bn$1 = {
22639
22643
  var res = this.imod(a._invmp(this.m).mul(this.r2));
22640
22644
  return res._forceRed(this);
22641
22645
  };
22642
- })(module, commonjsGlobal);
22646
+ })(module, commonjsGlobal);
22643
22647
  } (bn$1));
22644
22648
 
22645
- var brorandExports = {};
22646
- var brorand = {
22647
- get exports(){ return brorandExports; },
22648
- set exports(v){ brorandExports = v; },
22649
- };
22649
+ var bnExports$1 = bn$1.exports;
22650
+
22651
+ var brorand = {exports: {}};
22650
22652
 
22651
22653
  var hasRequiredBrorand;
22652
22654
 
22653
22655
  function requireBrorand () {
22654
- if (hasRequiredBrorand) return brorandExports;
22656
+ if (hasRequiredBrorand) return brorand.exports;
22655
22657
  hasRequiredBrorand = 1;
22656
22658
  var r;
22657
22659
 
@@ -22665,7 +22667,7 @@ function requireBrorand () {
22665
22667
  function Rand(rand) {
22666
22668
  this.rand = rand;
22667
22669
  }
22668
- brorandExports.Rand = Rand;
22670
+ brorand.exports.Rand = Rand;
22669
22671
 
22670
22672
  Rand.prototype.generate = function generate(len) {
22671
22673
  return this._rand(len);
@@ -22718,7 +22720,7 @@ function requireBrorand () {
22718
22720
  } catch (e) {
22719
22721
  }
22720
22722
  }
22721
- return brorandExports;
22723
+ return brorand.exports;
22722
22724
  }
22723
22725
 
22724
22726
  var mr;
@@ -23225,17 +23227,11 @@ function requireBrowser$2 () {
23225
23227
  return browser$5;
23226
23228
  }
23227
23229
 
23228
- var signExports = {};
23229
- var sign = {
23230
- get exports(){ return signExports; },
23231
- set exports(v){ signExports = v; },
23232
- };
23230
+ var sign = {exports: {}};
23233
23231
 
23234
- var bnExports = {};
23235
- var bn = {
23236
- get exports(){ return bnExports; },
23237
- set exports(v){ bnExports = v; },
23238
- };
23232
+ var bn = {exports: {}};
23233
+
23234
+ bn.exports;
23239
23235
 
23240
23236
  (function (module) {
23241
23237
  (function (module, exports) {
@@ -26585,9 +26581,11 @@ var bn = {
26585
26581
  var res = this.imod(a._invmp(this.m).mul(this.r2));
26586
26582
  return res._forceRed(this);
26587
26583
  };
26588
- })(module, commonjsGlobal);
26584
+ })(module, commonjsGlobal);
26589
26585
  } (bn));
26590
26586
 
26587
+ var bnExports = bn.exports;
26588
+
26591
26589
  var BN$a = bnExports;
26592
26590
  var randomBytes$1 = browserExports$1;
26593
26591
 
@@ -26758,7 +26756,7 @@ var utils$k = {};
26758
26756
  return toHex(arr);
26759
26757
  else
26760
26758
  return arr;
26761
- };
26759
+ };
26762
26760
  } (utils$k));
26763
26761
 
26764
26762
  (function (exports) {
@@ -26878,7 +26876,7 @@ var utils$k = {};
26878
26876
  function intFromLE(bytes) {
26879
26877
  return new BN(bytes, 'hex', 'le');
26880
26878
  }
26881
- utils.intFromLE = intFromLE;
26879
+ utils.intFromLE = intFromLE;
26882
26880
  } (utils$l));
26883
26881
 
26884
26882
  var curve = {};
@@ -28817,7 +28815,7 @@ Point.prototype.mixedAdd = Point.prototype.add;
28817
28815
  curve.base = base$2;
28818
28816
  curve.short = short;
28819
28817
  curve.mont = mont;
28820
- curve.edwards = edwards;
28818
+ curve.edwards = edwards;
28821
28819
  } (curve));
28822
28820
 
28823
28821
  var curves$1 = {};
@@ -30030,7 +30028,7 @@ Hmac.prototype.digest = function digest(enc) {
30030
30028
  hash.sha224 = hash.sha.sha224;
30031
30029
  hash.sha384 = hash.sha.sha384;
30032
30030
  hash.sha512 = hash.sha.sha512;
30033
- hash.ripemd160 = hash.ripemd.ripemd160;
30031
+ hash.ripemd160 = hash.ripemd.ripemd160;
30034
30032
  } (hash$2));
30035
30033
 
30036
30034
  var secp256k1;
@@ -31027,7 +31025,7 @@ function requireSecp256k1 () {
31027
31025
  '483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8',
31028
31026
  pre,
31029
31027
  ],
31030
- });
31028
+ });
31031
31029
  } (curves$1));
31032
31030
 
31033
31031
  var hash$1 = hash$2;
@@ -31970,8 +31968,8 @@ function requireElliptic () {
31970
31968
 
31971
31969
  // Protocols
31972
31970
  elliptic.ec = requireEc();
31973
- elliptic.eddsa = eddsa;
31974
- } (elliptic));
31971
+ elliptic.eddsa = eddsa;
31972
+ } (elliptic));
31975
31973
  return elliptic;
31976
31974
  }
31977
31975
 
@@ -33031,7 +33029,7 @@ var der$2 = {};
33031
33029
  0x1d: 'charstr',
33032
33030
  0x1e: 'bmpstr'
33033
33031
  };
33034
- exports.tagByName = reverse(exports.tag);
33032
+ exports.tagByName = reverse(exports.tag);
33035
33033
  } (der$2));
33036
33034
 
33037
33035
  const inherits$3 = require$$3$1;
@@ -33355,7 +33353,7 @@ PEMEncoder.prototype.encode = function encode(data, options) {
33355
33353
  const encoders = exports;
33356
33354
 
33357
33355
  encoders.der = der_1$1;
33358
- encoders.pem = pem$1;
33356
+ encoders.pem = pem$1;
33359
33357
  } (encoders));
33360
33358
 
33361
33359
  var decoders = {};
@@ -33749,7 +33747,7 @@ PEMDecoder.prototype.decode = function decode(data, options) {
33749
33747
  const decoders = exports;
33750
33748
 
33751
33749
  decoders.der = der_1;
33752
- decoders.pem = pem;
33750
+ decoders.pem = pem;
33753
33751
  } (decoders));
33754
33752
 
33755
33753
  (function (exports) {
@@ -33808,7 +33806,7 @@ PEMDecoder.prototype.decode = function decode(data, options) {
33808
33806
 
33809
33807
  Entity.prototype.encode = function encode(data, enc, /* internal */ reporter) {
33810
33808
  return this._getEncoder(enc).encode(data, reporter);
33811
- };
33809
+ };
33812
33810
  } (api));
33813
33811
 
33814
33812
  var base$1 = {};
@@ -33820,7 +33818,7 @@ var base$1 = {};
33820
33818
  base.Reporter = reporter.Reporter;
33821
33819
  base.DecoderBuffer = buffer.DecoderBuffer;
33822
33820
  base.EncoderBuffer = buffer.EncoderBuffer;
33823
- base.Node = node;
33821
+ base.Node = node;
33824
33822
  } (base$1));
33825
33823
 
33826
33824
  var constants = {};
@@ -33845,7 +33843,7 @@ var constants = {};
33845
33843
  return res;
33846
33844
  };
33847
33845
 
33848
- constants.der = der$2;
33846
+ constants.der = der$2;
33849
33847
  } (constants));
33850
33848
 
33851
33849
  (function (exports) {
@@ -33858,7 +33856,7 @@ var constants = {};
33858
33856
  asn1.base = base$1;
33859
33857
  asn1.constants = constants;
33860
33858
  asn1.decoders = decoders;
33861
- asn1.encoders = encoders;
33859
+ asn1.encoders = encoders;
33862
33860
  } (asn1$2));
33863
33861
 
33864
33862
  var asn = asn1$2;
@@ -34232,7 +34230,7 @@ var require$$4 = {
34232
34230
  var hasRequiredSign;
34233
34231
 
34234
34232
  function requireSign () {
34235
- if (hasRequiredSign) return signExports;
34233
+ if (hasRequiredSign) return sign.exports;
34236
34234
  hasRequiredSign = 1;
34237
34235
  // much of this based on https://github.com/indutny/self-signed/blob/gh-pages/lib/rsa.js
34238
34236
  var Buffer = safeBufferExports.Buffer;
@@ -34375,9 +34373,9 @@ function requireSign () {
34375
34373
  }
34376
34374
 
34377
34375
  sign.exports = sign$1;
34378
- signExports.getKey = getKey;
34379
- signExports.makeKey = makeKey;
34380
- return signExports;
34376
+ sign.exports.getKey = getKey;
34377
+ sign.exports.makeKey = makeKey;
34378
+ return sign.exports;
34381
34379
  }
34382
34380
 
34383
34381
  var verify_1;
@@ -34956,7 +34954,7 @@ function compare$3 (a, b) {
34956
34954
 
34957
34955
  exports.publicDecrypt = function publicDecrypt (key, buf) {
34958
34956
  return exports.privateDecrypt(key, buf, true)
34959
- };
34957
+ };
34960
34958
  } (browser$2));
34961
34959
 
34962
34960
  var browser$1 = {};
@@ -35078,8 +35076,8 @@ function requireCryptoBrowserify () {
35078
35076
  cryptoBrowserify.createHash = cryptoBrowserify.Hash = browser$a;
35079
35077
  cryptoBrowserify.createHmac = cryptoBrowserify.Hmac = browser$9;
35080
35078
 
35081
- var algos = algosExports;
35082
- var algoKeys = Object.keys(algos);
35079
+ var algos$1 = algos;
35080
+ var algoKeys = Object.keys(algos$1);
35083
35081
  var hashes = ['sha1', 'sha224', 'sha256', 'sha384', 'sha512', 'md5', 'rmd160'].concat(algoKeys);
35084
35082
  cryptoBrowserify.getHashes = function () {
35085
35083
  return hashes
@@ -37425,8 +37423,8 @@ class TransactionBlockstore {
37425
37423
  */
37426
37424
  async * entries () {
37427
37425
  for (const transaction of this.inflightTransactions) {
37428
- for (const [str, bytes] of transaction) {
37429
- yield { cid: str, bytes };
37426
+ for (const [cid, bytes] of transaction.entries()) { // test for this?
37427
+ yield { cid: cid.toString(), bytes };
37430
37428
  }
37431
37429
  }
37432
37430
  for (const [str, bytes] of this.committedBlocks) {
@@ -37477,7 +37475,7 @@ class TransactionBlockstore {
37477
37475
  doCommit = async innerBlockstore => {
37478
37476
  const cids = new Set();
37479
37477
  for (const { cid, bytes } of innerBlockstore.entries()) {
37480
- const stringCid = cid.toString(); // unnecessary string conversion, can we fix upstream?
37478
+ const stringCid = cid.toString();
37481
37479
  if (this.committedBlocks.has(stringCid)) ; else {
37482
37480
  this.committedBlocks.set(stringCid, bytes);
37483
37481
  cids.add(stringCid);
@@ -37698,6 +37696,9 @@ const bulkFromEvents = (sorted, event) => {
37698
37696
  const {
37699
37697
  data: { type, value, key }
37700
37698
  } = event;
37699
+ if (!key) {
37700
+ throw new Error('key is required')
37701
+ }
37701
37702
  const bulkEvent = type === 'put' ? { key, value } : { key, del: true };
37702
37703
  bulk.set(bulkEvent.key, bulkEvent); // last wins
37703
37704
  }
@@ -37997,7 +37998,7 @@ async function visMerkleClock (blocks, head) {
37997
37998
  return { vis: lines.join('\n') }
37998
37999
  }
37999
38000
 
38000
- var charwise = {};
38001
+ var charwise$1 = {};
38001
38002
 
38002
38003
  var number = {};
38003
38004
 
@@ -38225,8 +38226,10 @@ object.factory = function (codec) {
38225
38226
 
38226
38227
  //for leveldb, request strings
38227
38228
  exports.buffer = false;
38228
- exports.type = 'charwise';
38229
- } (charwise));
38229
+ exports.type = 'charwise';
38230
+ } (charwise$1));
38231
+
38232
+ var charwise = /*@__PURE__*/getDefaultExportFromCjs(charwise$1);
38230
38233
 
38231
38234
  /* global localStorage */
38232
38235
  let storageSupported = false;
@@ -39278,11 +39281,7 @@ async function loadIndex (blocks, index, indexOpts) {
39278
39281
  return index.root
39279
39282
  }
39280
39283
 
39281
- var browserExports = {};
39282
- var browser = {
39283
- get exports(){ return browserExports; },
39284
- set exports(v){ browserExports = v; },
39285
- };
39284
+ var browser = {exports: {}};
39286
39285
 
39287
39286
  /**
39288
39287
  * Helpers.
@@ -39998,8 +39997,10 @@ var common = setup;
39998
39997
  } catch (error) {
39999
39998
  return '[UnexpectedJSONParseError]: ' + error.message;
40000
39999
  }
40001
- };
40002
- } (browser, browserExports));
40000
+ };
40001
+ } (browser, browser.exports));
40002
+
40003
+ var browserExports = browser.exports;
40003
40004
 
40004
40005
  // originally pulled out of simple-peer
40005
40006
 
@@ -41150,6 +41151,8 @@ Peer.channelConfig = {};
41150
41151
 
41151
41152
  var simplePeer = Peer;
41152
41153
 
41154
+ var SimplePeer = /*@__PURE__*/getDefaultExportFromCjs(simplePeer);
41155
+
41153
41156
  /**
41154
41157
  * @typedef {import('./database.js').Database} Database
41155
41158
  */
@@ -41161,7 +41164,7 @@ class Sync {
41161
41164
  * @static
41162
41165
  */
41163
41166
  status = 'new'
41164
- constructor (database, PeerClass = simplePeer) {
41167
+ constructor (database, PeerClass = SimplePeer) {
41165
41168
  this.database = database;
41166
41169
  this.database.blocks.syncs.add(this); // should this happen during setup?
41167
41170
  this.PeerClass = PeerClass;
@@ -41302,7 +41305,7 @@ class Sync {
41302
41305
  destroy () {
41303
41306
  this.database.blocks.syncs.delete(this);
41304
41307
  this.status = 'destroyed';
41305
- this.peer.destroy();
41308
+ // this.peer.destroy() todo
41306
41309
  }
41307
41310
 
41308
41311
  async sendUpdate (blockstore) {
@@ -41339,14 +41342,15 @@ class Sync {
41339
41342
  const blocks = database.blocks;
41340
41343
  const rootCIDs = database.clock;
41341
41344
 
41342
- const syncCIDs = [...new Set([...rootCIDs, ...allCIDs])].filter(cid => !skip.includes(cid.toString()));
41345
+ const newCIDs = [...new Set([...rootCIDs, ...allCIDs])].filter(cid => !skip.includes(cid.toString()));
41346
+ const syncCIDs = [...new Set([...rootCIDs, ...allCIDs.filter(cid => !skip.includes(cid.toString()))])];
41343
41347
  // console.log(
41344
41348
  // 'makeCar',
41345
41349
  // rootCIDs.map(c => c.toString()),
41346
41350
  // syncCIDs.map(c => c.toString()),
41347
41351
  // allCIDs.map(c => c.toString())
41348
41352
  // )
41349
- if (syncCIDs.length === 0) {
41353
+ if (newCIDs.length === 0) {
41350
41354
  return null
41351
41355
  }
41352
41356
 
@@ -41398,7 +41402,7 @@ class Fireproof {
41398
41402
  const fp = new Database(new TransactionBlockstore(name, existingConfig.key), [], opts);
41399
41403
  return Fireproof.fromJSON(existingConfig, fp)
41400
41404
  } else {
41401
- const instanceKey = browserExports$1(32).toString('hex'); // pass null to disable encryption
41405
+ const instanceKey = randomBytes$3(32).toString('hex'); // pass null to disable encryption
41402
41406
  return new Database(new TransactionBlockstore(name, instanceKey), [], opts)
41403
41407
  }
41404
41408
  } else {