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