@fireproof/core 0.5.12 → 0.5.13

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.
@@ -9573,7 +9573,15 @@ var _polyfillNode_events = /*#__PURE__*/Object.freeze({
9573
9573
 
9574
9574
  var require$$0$1 = /*@__PURE__*/getAugmentedNamespace(_polyfillNode_events);
9575
9575
 
9576
- var streamBrowser = require$$0$1.EventEmitter;
9576
+ var streamBrowser;
9577
+ var hasRequiredStreamBrowser;
9578
+
9579
+ function requireStreamBrowser () {
9580
+ if (hasRequiredStreamBrowser) return streamBrowser;
9581
+ hasRequiredStreamBrowser = 1;
9582
+ streamBrowser = require$$0$1.EventEmitter;
9583
+ return streamBrowser;
9584
+ }
9577
9585
 
9578
9586
  // shim for using process in browser
9579
9587
  // based off https://github.com/defunctzombie/node-process/blob/master/browser.js
@@ -9716,7 +9724,7 @@ var argv = [];
9716
9724
  var version$2 = ''; // empty string to avoid regexp issues
9717
9725
  var versions = {};
9718
9726
  var release = {};
9719
- var config$1 = {};
9727
+ var config = {};
9720
9728
 
9721
9729
  function noop$2() {}
9722
9730
 
@@ -9793,7 +9801,7 @@ var browser$1$1 = {
9793
9801
  hrtime: hrtime,
9794
9802
  platform: platform,
9795
9803
  release: release,
9796
- config: config$1,
9804
+ config: config,
9797
9805
  uptime: uptime
9798
9806
  };
9799
9807
 
@@ -9874,11 +9882,11 @@ function format(f) {
9874
9882
  // Mark that a method should not be used.
9875
9883
  // Returns a modified function which warns once by default.
9876
9884
  // If --no-deprecation is set, then it is a no-op.
9877
- function deprecate$2(fn, msg) {
9885
+ function deprecate$1(fn, msg) {
9878
9886
  // Allow for deprecating things in the process of starting up.
9879
9887
  if (isUndefined(global$1.process)) {
9880
9888
  return function() {
9881
- return deprecate$2(fn, msg).apply(this, arguments);
9889
+ return deprecate$1(fn, msg).apply(this, arguments);
9882
9890
  };
9883
9891
  }
9884
9892
 
@@ -10487,7 +10495,7 @@ var _polyfillNode_util = {
10487
10495
  isBoolean: isBoolean,
10488
10496
  isArray: isArray,
10489
10497
  inspect: inspect,
10490
- deprecate: deprecate$2,
10498
+ deprecate: deprecate$1,
10491
10499
  format: format,
10492
10500
  debuglog: debuglog,
10493
10501
  promisify: promisify,
@@ -10500,7 +10508,7 @@ var _polyfillNode_util$1 = /*#__PURE__*/Object.freeze({
10500
10508
  callbackify: callbackify,
10501
10509
  debuglog: debuglog,
10502
10510
  default: _polyfillNode_util,
10503
- deprecate: deprecate$2,
10511
+ deprecate: deprecate$1,
10504
10512
  format: format,
10505
10513
  inherits: inherits$w,
10506
10514
  inspect: inspect,
@@ -10688,99 +10696,108 @@ function requireBuffer_list () {
10688
10696
  return buffer_list;
10689
10697
  }
10690
10698
 
10691
- // undocumented cb() API, needed for core, not for public API
10692
- function destroy(err, cb) {
10693
- const readableDestroyed = this._readableState && this._readableState.destroyed;
10694
- const writableDestroyed = this._writableState && this._writableState.destroyed;
10695
- if (readableDestroyed || writableDestroyed) {
10696
- if (cb) {
10697
- cb(err);
10698
- } else if (err) {
10699
- if (!this._writableState) {
10700
- process.nextTick(emitErrorNT, this, err);
10701
- } else if (!this._writableState.errorEmitted) {
10702
- this._writableState.errorEmitted = true;
10703
- process.nextTick(emitErrorNT, this, err);
10704
- }
10705
- }
10706
- return this;
10707
- }
10708
-
10709
- // we set destroyed to true before firing error callbacks in order
10710
- // to make it re-entrance safe in case destroy() is called within callbacks
10699
+ var destroy_1;
10700
+ var hasRequiredDestroy;
10701
+
10702
+ function requireDestroy () {
10703
+ if (hasRequiredDestroy) return destroy_1;
10704
+ hasRequiredDestroy = 1;
10705
+
10706
+ // undocumented cb() API, needed for core, not for public API
10707
+ function destroy(err, cb) {
10708
+ const readableDestroyed = this._readableState && this._readableState.destroyed;
10709
+ const writableDestroyed = this._writableState && this._writableState.destroyed;
10710
+ if (readableDestroyed || writableDestroyed) {
10711
+ if (cb) {
10712
+ cb(err);
10713
+ } else if (err) {
10714
+ if (!this._writableState) {
10715
+ process.nextTick(emitErrorNT, this, err);
10716
+ } else if (!this._writableState.errorEmitted) {
10717
+ this._writableState.errorEmitted = true;
10718
+ process.nextTick(emitErrorNT, this, err);
10719
+ }
10720
+ }
10721
+ return this;
10722
+ }
10711
10723
 
10712
- if (this._readableState) {
10713
- this._readableState.destroyed = true;
10714
- }
10724
+ // we set destroyed to true before firing error callbacks in order
10725
+ // to make it re-entrance safe in case destroy() is called within callbacks
10715
10726
 
10716
- // if this is a duplex stream mark the writable part as destroyed as well
10717
- if (this._writableState) {
10718
- this._writableState.destroyed = true;
10719
- }
10720
- this._destroy(err || null, err => {
10721
- if (!cb && err) {
10722
- if (!this._writableState) {
10723
- process.nextTick(emitErrorAndCloseNT, this, err);
10724
- } else if (!this._writableState.errorEmitted) {
10725
- this._writableState.errorEmitted = true;
10726
- process.nextTick(emitErrorAndCloseNT, this, err);
10727
- } else {
10728
- process.nextTick(emitCloseNT, this);
10729
- }
10730
- } else if (cb) {
10731
- process.nextTick(emitCloseNT, this);
10732
- cb(err);
10733
- } else {
10734
- process.nextTick(emitCloseNT, this);
10735
- }
10736
- });
10737
- return this;
10738
- }
10739
- function emitErrorAndCloseNT(self, err) {
10740
- emitErrorNT(self, err);
10741
- emitCloseNT(self);
10742
- }
10743
- function emitCloseNT(self) {
10744
- if (self._writableState && !self._writableState.emitClose) return;
10745
- if (self._readableState && !self._readableState.emitClose) return;
10746
- self.emit('close');
10747
- }
10748
- function undestroy() {
10749
- if (this._readableState) {
10750
- this._readableState.destroyed = false;
10751
- this._readableState.reading = false;
10752
- this._readableState.ended = false;
10753
- this._readableState.endEmitted = false;
10754
- }
10755
- if (this._writableState) {
10756
- this._writableState.destroyed = false;
10757
- this._writableState.ended = false;
10758
- this._writableState.ending = false;
10759
- this._writableState.finalCalled = false;
10760
- this._writableState.prefinished = false;
10761
- this._writableState.finished = false;
10762
- this._writableState.errorEmitted = false;
10763
- }
10764
- }
10765
- function emitErrorNT(self, err) {
10766
- self.emit('error', err);
10767
- }
10768
- function errorOrDestroy(stream, err) {
10769
- // We have tests that rely on errors being emitted
10770
- // in the same tick, so changing this is semver major.
10771
- // For now when you opt-in to autoDestroy we allow
10772
- // the error to be emitted nextTick. In a future
10773
- // semver major update we should change the default to this.
10727
+ if (this._readableState) {
10728
+ this._readableState.destroyed = true;
10729
+ }
10774
10730
 
10775
- const rState = stream._readableState;
10776
- const wState = stream._writableState;
10777
- if (rState && rState.autoDestroy || wState && wState.autoDestroy) stream.destroy(err);else stream.emit('error', err);
10731
+ // if this is a duplex stream mark the writable part as destroyed as well
10732
+ if (this._writableState) {
10733
+ this._writableState.destroyed = true;
10734
+ }
10735
+ this._destroy(err || null, err => {
10736
+ if (!cb && err) {
10737
+ if (!this._writableState) {
10738
+ process.nextTick(emitErrorAndCloseNT, this, err);
10739
+ } else if (!this._writableState.errorEmitted) {
10740
+ this._writableState.errorEmitted = true;
10741
+ process.nextTick(emitErrorAndCloseNT, this, err);
10742
+ } else {
10743
+ process.nextTick(emitCloseNT, this);
10744
+ }
10745
+ } else if (cb) {
10746
+ process.nextTick(emitCloseNT, this);
10747
+ cb(err);
10748
+ } else {
10749
+ process.nextTick(emitCloseNT, this);
10750
+ }
10751
+ });
10752
+ return this;
10753
+ }
10754
+ function emitErrorAndCloseNT(self, err) {
10755
+ emitErrorNT(self, err);
10756
+ emitCloseNT(self);
10757
+ }
10758
+ function emitCloseNT(self) {
10759
+ if (self._writableState && !self._writableState.emitClose) return;
10760
+ if (self._readableState && !self._readableState.emitClose) return;
10761
+ self.emit('close');
10762
+ }
10763
+ function undestroy() {
10764
+ if (this._readableState) {
10765
+ this._readableState.destroyed = false;
10766
+ this._readableState.reading = false;
10767
+ this._readableState.ended = false;
10768
+ this._readableState.endEmitted = false;
10769
+ }
10770
+ if (this._writableState) {
10771
+ this._writableState.destroyed = false;
10772
+ this._writableState.ended = false;
10773
+ this._writableState.ending = false;
10774
+ this._writableState.finalCalled = false;
10775
+ this._writableState.prefinished = false;
10776
+ this._writableState.finished = false;
10777
+ this._writableState.errorEmitted = false;
10778
+ }
10779
+ }
10780
+ function emitErrorNT(self, err) {
10781
+ self.emit('error', err);
10782
+ }
10783
+ function errorOrDestroy(stream, err) {
10784
+ // We have tests that rely on errors being emitted
10785
+ // in the same tick, so changing this is semver major.
10786
+ // For now when you opt-in to autoDestroy we allow
10787
+ // the error to be emitted nextTick. In a future
10788
+ // semver major update we should change the default to this.
10789
+
10790
+ const rState = stream._readableState;
10791
+ const wState = stream._writableState;
10792
+ if (rState && rState.autoDestroy || wState && wState.autoDestroy) stream.destroy(err);else stream.emit('error', err);
10793
+ }
10794
+ destroy_1 = {
10795
+ destroy,
10796
+ undestroy,
10797
+ errorOrDestroy
10798
+ };
10799
+ return destroy_1;
10778
10800
  }
10779
- var destroy_1 = {
10780
- destroy,
10781
- undestroy,
10782
- errorOrDestroy
10783
- };
10784
10801
 
10785
10802
  var errorsBrowser = {};
10786
10803
 
@@ -10910,92 +10927,109 @@ createErrorType('ERR_UNKNOWN_ENCODING', function (arg) {
10910
10927
  createErrorType('ERR_STREAM_UNSHIFT_AFTER_END_EVENT', 'stream.unshift() after end event');
10911
10928
  errorsBrowser.codes = codes;
10912
10929
 
10913
- const ERR_INVALID_OPT_VALUE = errorsBrowser.codes.ERR_INVALID_OPT_VALUE;
10914
- function highWaterMarkFrom(options, isDuplex, duplexKey) {
10915
- return options.highWaterMark != null ? options.highWaterMark : isDuplex ? options[duplexKey] : null;
10916
- }
10917
- function getHighWaterMark(state, options, duplexKey, isDuplex) {
10918
- const hwm = highWaterMarkFrom(options, isDuplex, duplexKey);
10919
- if (hwm != null) {
10920
- if (!(isFinite(hwm) && Math.floor(hwm) === hwm) || hwm < 0) {
10921
- const name = isDuplex ? duplexKey : 'highWaterMark';
10922
- throw new ERR_INVALID_OPT_VALUE(name, hwm);
10923
- }
10924
- return Math.floor(hwm);
10925
- }
10930
+ var state;
10931
+ var hasRequiredState;
10926
10932
 
10927
- // Default value
10928
- return state.objectMode ? 16 : 16 * 1024;
10933
+ function requireState () {
10934
+ if (hasRequiredState) return state;
10935
+ hasRequiredState = 1;
10936
+
10937
+ const ERR_INVALID_OPT_VALUE = errorsBrowser.codes.ERR_INVALID_OPT_VALUE;
10938
+ function highWaterMarkFrom(options, isDuplex, duplexKey) {
10939
+ return options.highWaterMark != null ? options.highWaterMark : isDuplex ? options[duplexKey] : null;
10940
+ }
10941
+ function getHighWaterMark(state, options, duplexKey, isDuplex) {
10942
+ const hwm = highWaterMarkFrom(options, isDuplex, duplexKey);
10943
+ if (hwm != null) {
10944
+ if (!(isFinite(hwm) && Math.floor(hwm) === hwm) || hwm < 0) {
10945
+ const name = isDuplex ? duplexKey : 'highWaterMark';
10946
+ throw new ERR_INVALID_OPT_VALUE(name, hwm);
10947
+ }
10948
+ return Math.floor(hwm);
10949
+ }
10950
+
10951
+ // Default value
10952
+ return state.objectMode ? 16 : 16 * 1024;
10953
+ }
10954
+ state = {
10955
+ getHighWaterMark
10956
+ };
10957
+ return state;
10929
10958
  }
10930
- var state = {
10931
- getHighWaterMark
10932
- };
10933
10959
 
10934
- /**
10935
- * Module exports.
10936
- */
10960
+ var browser$b;
10961
+ var hasRequiredBrowser$3;
10937
10962
 
10938
- var browser$b = deprecate$1;
10963
+ function requireBrowser$3 () {
10964
+ if (hasRequiredBrowser$3) return browser$b;
10965
+ hasRequiredBrowser$3 = 1;
10966
+ /**
10967
+ * Module exports.
10968
+ */
10939
10969
 
10940
- /**
10941
- * Mark that a method should not be used.
10942
- * Returns a modified function which warns once by default.
10943
- *
10944
- * If `localStorage.noDeprecation = true` is set, then it is a no-op.
10945
- *
10946
- * If `localStorage.throwDeprecation = true` is set, then deprecated functions
10947
- * will throw an Error when invoked.
10948
- *
10949
- * If `localStorage.traceDeprecation = true` is set, then deprecated functions
10950
- * will invoke `console.trace()` instead of `console.error()`.
10951
- *
10952
- * @param {Function} fn - the function to deprecate
10953
- * @param {String} msg - the string to print to the console when `fn` is invoked
10954
- * @returns {Function} a new "deprecated" version of `fn`
10955
- * @api public
10956
- */
10970
+ browser$b = deprecate;
10957
10971
 
10958
- function deprecate$1 (fn, msg) {
10959
- if (config('noDeprecation')) {
10960
- return fn;
10961
- }
10972
+ /**
10973
+ * Mark that a method should not be used.
10974
+ * Returns a modified function which warns once by default.
10975
+ *
10976
+ * If `localStorage.noDeprecation = true` is set, then it is a no-op.
10977
+ *
10978
+ * If `localStorage.throwDeprecation = true` is set, then deprecated functions
10979
+ * will throw an Error when invoked.
10980
+ *
10981
+ * If `localStorage.traceDeprecation = true` is set, then deprecated functions
10982
+ * will invoke `console.trace()` instead of `console.error()`.
10983
+ *
10984
+ * @param {Function} fn - the function to deprecate
10985
+ * @param {String} msg - the string to print to the console when `fn` is invoked
10986
+ * @returns {Function} a new "deprecated" version of `fn`
10987
+ * @api public
10988
+ */
10962
10989
 
10963
- var warned = false;
10964
- function deprecated() {
10965
- if (!warned) {
10966
- if (config('throwDeprecation')) {
10967
- throw new Error(msg);
10968
- } else if (config('traceDeprecation')) {
10969
- console.trace(msg);
10970
- } else {
10971
- console.warn(msg);
10972
- }
10973
- warned = true;
10974
- }
10975
- return fn.apply(this, arguments);
10976
- }
10990
+ function deprecate (fn, msg) {
10991
+ if (config('noDeprecation')) {
10992
+ return fn;
10993
+ }
10977
10994
 
10978
- return deprecated;
10979
- }
10995
+ var warned = false;
10996
+ function deprecated() {
10997
+ if (!warned) {
10998
+ if (config('throwDeprecation')) {
10999
+ throw new Error(msg);
11000
+ } else if (config('traceDeprecation')) {
11001
+ console.trace(msg);
11002
+ } else {
11003
+ console.warn(msg);
11004
+ }
11005
+ warned = true;
11006
+ }
11007
+ return fn.apply(this, arguments);
11008
+ }
10980
11009
 
10981
- /**
10982
- * Checks `localStorage` for boolean values for the given `name`.
10983
- *
10984
- * @param {String} name
10985
- * @returns {Boolean}
10986
- * @api private
10987
- */
11010
+ return deprecated;
11011
+ }
10988
11012
 
10989
- function config (name) {
10990
- // accessing global.localStorage can trigger a DOMException in sandboxed iframes
10991
- try {
10992
- if (!commonjsGlobal.localStorage) return false;
10993
- } catch (_) {
10994
- return false;
10995
- }
10996
- var val = commonjsGlobal.localStorage[name];
10997
- if (null == val) return false;
10998
- return String(val).toLowerCase() === 'true';
11013
+ /**
11014
+ * Checks `localStorage` for boolean values for the given `name`.
11015
+ *
11016
+ * @param {String} name
11017
+ * @returns {Boolean}
11018
+ * @api private
11019
+ */
11020
+
11021
+ function config (name) {
11022
+ // accessing global.localStorage can trigger a DOMException in sandboxed iframes
11023
+ try {
11024
+ if (!commonjsGlobal.localStorage) return false;
11025
+ } catch (_) {
11026
+ return false;
11027
+ }
11028
+ var val = commonjsGlobal.localStorage[name];
11029
+ if (null == val) return false;
11030
+ return String(val).toLowerCase() === 'true';
11031
+ }
11032
+ return browser$b;
10999
11033
  }
11000
11034
 
11001
11035
  var _stream_writable;
@@ -11026,12 +11060,12 @@ function require_stream_writable () {
11026
11060
 
11027
11061
  /*<replacement>*/
11028
11062
  const internalUtil = {
11029
- deprecate: browser$b
11063
+ deprecate: requireBrowser$3()
11030
11064
  };
11031
11065
  /*</replacement>*/
11032
11066
 
11033
11067
  /*<replacement>*/
11034
- var Stream = streamBrowser;
11068
+ var Stream = requireStreamBrowser();
11035
11069
  /*</replacement>*/
11036
11070
 
11037
11071
  const Buffer = require$$6$1.Buffer;
@@ -11042,8 +11076,8 @@ function require_stream_writable () {
11042
11076
  function _isUint8Array(obj) {
11043
11077
  return Buffer.isBuffer(obj) || obj instanceof OurUint8Array;
11044
11078
  }
11045
- const destroyImpl = destroy_1;
11046
- const _require = state,
11079
+ const destroyImpl = requireDestroy();
11080
+ const _require = requireState(),
11047
11081
  getHighWaterMark = _require.getHighWaterMark;
11048
11082
  const _require$codes = errorsBrowser.codes,
11049
11083
  ERR_INVALID_ARG_TYPE = _require$codes.ERR_INVALID_ARG_TYPE,
@@ -12237,7 +12271,7 @@ function require_stream_readable () {
12237
12271
  /*</replacement>*/
12238
12272
 
12239
12273
  /*<replacement>*/
12240
- var Stream = streamBrowser;
12274
+ var Stream = requireStreamBrowser();
12241
12275
  /*</replacement>*/
12242
12276
 
12243
12277
  const Buffer = require$$6$1.Buffer;
@@ -12260,8 +12294,8 @@ function require_stream_readable () {
12260
12294
  /*</replacement>*/
12261
12295
 
12262
12296
  const BufferList = requireBuffer_list();
12263
- const destroyImpl = destroy_1;
12264
- const _require = state,
12297
+ const destroyImpl = requireDestroy();
12298
+ const _require = requireState(),
12265
12299
  getHighWaterMark = _require.getHighWaterMark;
12266
12300
  const _require$codes = errorsBrowser.codes,
12267
12301
  ERR_INVALID_ARG_TYPE = _require$codes.ERR_INVALID_ARG_TYPE,
@@ -15627,7 +15661,7 @@ function WriteReq(chunk, encoding, cb) {
15627
15661
 
15628
15662
  function WritableState(options, stream) {
15629
15663
  Object.defineProperty(this, 'buffer', {
15630
- get: deprecate$2(function () {
15664
+ get: deprecate$1(function () {
15631
15665
  return this.getBuffer();
15632
15666
  }, '_writableState.buffer is deprecated. Use _writableState.getBuffer ' + 'instead.')
15633
15667
  });
@@ -41075,21 +41109,22 @@ class Sync {
41075
41109
  // console.log('not a car', data.toString())
41076
41110
  }
41077
41111
  if (reader) {
41112
+ console.log('got car');
41078
41113
  this.status = 'parking car';
41079
41114
  const blz = new Set();
41080
41115
  for await (const block of reader.blocks()) {
41081
41116
  blz.add(block);
41082
41117
  }
41083
41118
  const roots = await reader.getRoots();
41084
- // console.log(
41085
- // 'got car',
41086
- // roots.map(c => c.toString()),
41087
- // this.database.clock.map(c => c.toString())
41088
- // )
41089
- // console.log(
41090
- // 'got blocks',
41091
- // [...blz].map(({ cid }) => cid.toString())
41092
- // )
41119
+ console.log(
41120
+ 'got car',
41121
+ roots.map(c => c.toString()),
41122
+ this.database.clock.map(c => c.toString())
41123
+ );
41124
+ console.log(
41125
+ 'got blocks',
41126
+ [...blz].map(({ cid }) => cid.toString())
41127
+ );
41093
41128
  // @ts-ignore
41094
41129
  reader.entries = reader.blocks;
41095
41130
  await this.database.blocks.commit(
@@ -41137,7 +41172,7 @@ class Sync {
41137
41172
  this.peer.send(JSON.stringify({ ok: true }));
41138
41173
  // this.pushBacklogResolve({ ok: true })
41139
41174
  } else {
41140
- // console.log('do send', carBlock.bytes.length)
41175
+ console.log('do send', carBlock.bytes.length);
41141
41176
  this.status = 'sending diff car';
41142
41177
  this.peer.send(carBlock.bytes);
41143
41178
  // this.pushBacklogResolve({ ok: true })