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