@fireproof/core 0.7.0-alpha.3 → 0.7.0-alpha.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -11485,7 +11485,15 @@ var _polyfillNode_events = /*#__PURE__*/Object.freeze({
11485
11485
 
11486
11486
  var require$$0$1 = /*@__PURE__*/getAugmentedNamespace(_polyfillNode_events);
11487
11487
 
11488
- var streamBrowser = require$$0$1.EventEmitter;
11488
+ var streamBrowser;
11489
+ var hasRequiredStreamBrowser;
11490
+
11491
+ function requireStreamBrowser () {
11492
+ if (hasRequiredStreamBrowser) return streamBrowser;
11493
+ hasRequiredStreamBrowser = 1;
11494
+ streamBrowser = require$$0$1.EventEmitter;
11495
+ return streamBrowser;
11496
+ }
11489
11497
 
11490
11498
  // shim for using process in browser
11491
11499
  // based off https://github.com/defunctzombie/node-process/blob/master/browser.js
@@ -11628,7 +11636,7 @@ var argv = [];
11628
11636
  var version$2 = ''; // empty string to avoid regexp issues
11629
11637
  var versions = {};
11630
11638
  var release = {};
11631
- var config$1 = {};
11639
+ var config = {};
11632
11640
 
11633
11641
  function noop$3() {}
11634
11642
 
@@ -11705,7 +11713,7 @@ var browser$1$1 = {
11705
11713
  hrtime: hrtime,
11706
11714
  platform: platform,
11707
11715
  release: release,
11708
- config: config$1,
11716
+ config: config,
11709
11717
  uptime: uptime
11710
11718
  };
11711
11719
 
@@ -11786,11 +11794,11 @@ function format(f) {
11786
11794
  // Mark that a method should not be used.
11787
11795
  // Returns a modified function which warns once by default.
11788
11796
  // If --no-deprecation is set, then it is a no-op.
11789
- function deprecate$2(fn, msg) {
11797
+ function deprecate$1(fn, msg) {
11790
11798
  // Allow for deprecating things in the process of starting up.
11791
11799
  if (isUndefined(global$1.process)) {
11792
11800
  return function() {
11793
- return deprecate$2(fn, msg).apply(this, arguments);
11801
+ return deprecate$1(fn, msg).apply(this, arguments);
11794
11802
  };
11795
11803
  }
11796
11804
 
@@ -12399,7 +12407,7 @@ var _polyfillNode_util = {
12399
12407
  isBoolean: isBoolean,
12400
12408
  isArray: isArray,
12401
12409
  inspect: inspect,
12402
- deprecate: deprecate$2,
12410
+ deprecate: deprecate$1,
12403
12411
  format: format,
12404
12412
  debuglog: debuglog,
12405
12413
  promisify: promisify,
@@ -12412,7 +12420,7 @@ var _polyfillNode_util$1 = /*#__PURE__*/Object.freeze({
12412
12420
  callbackify: callbackify,
12413
12421
  debuglog: debuglog,
12414
12422
  default: _polyfillNode_util,
12415
- deprecate: deprecate$2,
12423
+ deprecate: deprecate$1,
12416
12424
  format: format,
12417
12425
  inherits: inherits$w,
12418
12426
  inspect: inspect,
@@ -12600,99 +12608,108 @@ function requireBuffer_list () {
12600
12608
  return buffer_list;
12601
12609
  }
12602
12610
 
12603
- // undocumented cb() API, needed for core, not for public API
12604
- function destroy(err, cb) {
12605
- const readableDestroyed = this._readableState && this._readableState.destroyed;
12606
- const writableDestroyed = this._writableState && this._writableState.destroyed;
12607
- if (readableDestroyed || writableDestroyed) {
12608
- if (cb) {
12609
- cb(err);
12610
- } else if (err) {
12611
- if (!this._writableState) {
12612
- process.nextTick(emitErrorNT, this, err);
12613
- } else if (!this._writableState.errorEmitted) {
12614
- this._writableState.errorEmitted = true;
12615
- process.nextTick(emitErrorNT, this, err);
12616
- }
12617
- }
12618
- return this;
12619
- }
12611
+ var destroy_1;
12612
+ var hasRequiredDestroy;
12613
+
12614
+ function requireDestroy () {
12615
+ if (hasRequiredDestroy) return destroy_1;
12616
+ hasRequiredDestroy = 1;
12617
+
12618
+ // undocumented cb() API, needed for core, not for public API
12619
+ function destroy(err, cb) {
12620
+ const readableDestroyed = this._readableState && this._readableState.destroyed;
12621
+ const writableDestroyed = this._writableState && this._writableState.destroyed;
12622
+ if (readableDestroyed || writableDestroyed) {
12623
+ if (cb) {
12624
+ cb(err);
12625
+ } else if (err) {
12626
+ if (!this._writableState) {
12627
+ process.nextTick(emitErrorNT, this, err);
12628
+ } else if (!this._writableState.errorEmitted) {
12629
+ this._writableState.errorEmitted = true;
12630
+ process.nextTick(emitErrorNT, this, err);
12631
+ }
12632
+ }
12633
+ return this;
12634
+ }
12620
12635
 
12621
- // we set destroyed to true before firing error callbacks in order
12622
- // to make it re-entrance safe in case destroy() is called within callbacks
12636
+ // we set destroyed to true before firing error callbacks in order
12637
+ // to make it re-entrance safe in case destroy() is called within callbacks
12623
12638
 
12624
- if (this._readableState) {
12625
- this._readableState.destroyed = true;
12626
- }
12627
-
12628
- // if this is a duplex stream mark the writable part as destroyed as well
12629
- if (this._writableState) {
12630
- this._writableState.destroyed = true;
12631
- }
12632
- this._destroy(err || null, err => {
12633
- if (!cb && err) {
12634
- if (!this._writableState) {
12635
- process.nextTick(emitErrorAndCloseNT, this, err);
12636
- } else if (!this._writableState.errorEmitted) {
12637
- this._writableState.errorEmitted = true;
12638
- process.nextTick(emitErrorAndCloseNT, this, err);
12639
- } else {
12640
- process.nextTick(emitCloseNT, this);
12641
- }
12642
- } else if (cb) {
12643
- process.nextTick(emitCloseNT, this);
12644
- cb(err);
12645
- } else {
12646
- process.nextTick(emitCloseNT, this);
12647
- }
12648
- });
12649
- return this;
12650
- }
12651
- function emitErrorAndCloseNT(self, err) {
12652
- emitErrorNT(self, err);
12653
- emitCloseNT(self);
12654
- }
12655
- function emitCloseNT(self) {
12656
- if (self._writableState && !self._writableState.emitClose) return;
12657
- if (self._readableState && !self._readableState.emitClose) return;
12658
- self.emit('close');
12659
- }
12660
- function undestroy() {
12661
- if (this._readableState) {
12662
- this._readableState.destroyed = false;
12663
- this._readableState.reading = false;
12664
- this._readableState.ended = false;
12665
- this._readableState.endEmitted = false;
12666
- }
12667
- if (this._writableState) {
12668
- this._writableState.destroyed = false;
12669
- this._writableState.ended = false;
12670
- this._writableState.ending = false;
12671
- this._writableState.finalCalled = false;
12672
- this._writableState.prefinished = false;
12673
- this._writableState.finished = false;
12674
- this._writableState.errorEmitted = false;
12675
- }
12676
- }
12677
- function emitErrorNT(self, err) {
12678
- self.emit('error', err);
12679
- }
12680
- function errorOrDestroy(stream, err) {
12681
- // We have tests that rely on errors being emitted
12682
- // in the same tick, so changing this is semver major.
12683
- // For now when you opt-in to autoDestroy we allow
12684
- // the error to be emitted nextTick. In a future
12685
- // semver major update we should change the default to this.
12639
+ if (this._readableState) {
12640
+ this._readableState.destroyed = true;
12641
+ }
12686
12642
 
12687
- const rState = stream._readableState;
12688
- const wState = stream._writableState;
12689
- if (rState && rState.autoDestroy || wState && wState.autoDestroy) stream.destroy(err);else stream.emit('error', err);
12643
+ // if this is a duplex stream mark the writable part as destroyed as well
12644
+ if (this._writableState) {
12645
+ this._writableState.destroyed = true;
12646
+ }
12647
+ this._destroy(err || null, err => {
12648
+ if (!cb && err) {
12649
+ if (!this._writableState) {
12650
+ process.nextTick(emitErrorAndCloseNT, this, err);
12651
+ } else if (!this._writableState.errorEmitted) {
12652
+ this._writableState.errorEmitted = true;
12653
+ process.nextTick(emitErrorAndCloseNT, this, err);
12654
+ } else {
12655
+ process.nextTick(emitCloseNT, this);
12656
+ }
12657
+ } else if (cb) {
12658
+ process.nextTick(emitCloseNT, this);
12659
+ cb(err);
12660
+ } else {
12661
+ process.nextTick(emitCloseNT, this);
12662
+ }
12663
+ });
12664
+ return this;
12665
+ }
12666
+ function emitErrorAndCloseNT(self, err) {
12667
+ emitErrorNT(self, err);
12668
+ emitCloseNT(self);
12669
+ }
12670
+ function emitCloseNT(self) {
12671
+ if (self._writableState && !self._writableState.emitClose) return;
12672
+ if (self._readableState && !self._readableState.emitClose) return;
12673
+ self.emit('close');
12674
+ }
12675
+ function undestroy() {
12676
+ if (this._readableState) {
12677
+ this._readableState.destroyed = false;
12678
+ this._readableState.reading = false;
12679
+ this._readableState.ended = false;
12680
+ this._readableState.endEmitted = false;
12681
+ }
12682
+ if (this._writableState) {
12683
+ this._writableState.destroyed = false;
12684
+ this._writableState.ended = false;
12685
+ this._writableState.ending = false;
12686
+ this._writableState.finalCalled = false;
12687
+ this._writableState.prefinished = false;
12688
+ this._writableState.finished = false;
12689
+ this._writableState.errorEmitted = false;
12690
+ }
12691
+ }
12692
+ function emitErrorNT(self, err) {
12693
+ self.emit('error', err);
12694
+ }
12695
+ function errorOrDestroy(stream, err) {
12696
+ // We have tests that rely on errors being emitted
12697
+ // in the same tick, so changing this is semver major.
12698
+ // For now when you opt-in to autoDestroy we allow
12699
+ // the error to be emitted nextTick. In a future
12700
+ // semver major update we should change the default to this.
12701
+
12702
+ const rState = stream._readableState;
12703
+ const wState = stream._writableState;
12704
+ if (rState && rState.autoDestroy || wState && wState.autoDestroy) stream.destroy(err);else stream.emit('error', err);
12705
+ }
12706
+ destroy_1 = {
12707
+ destroy,
12708
+ undestroy,
12709
+ errorOrDestroy
12710
+ };
12711
+ return destroy_1;
12690
12712
  }
12691
- var destroy_1 = {
12692
- destroy,
12693
- undestroy,
12694
- errorOrDestroy
12695
- };
12696
12713
 
12697
12714
  var errorsBrowser = {};
12698
12715
 
@@ -12822,92 +12839,109 @@ createErrorType('ERR_UNKNOWN_ENCODING', function (arg) {
12822
12839
  createErrorType('ERR_STREAM_UNSHIFT_AFTER_END_EVENT', 'stream.unshift() after end event');
12823
12840
  errorsBrowser.codes = codes;
12824
12841
 
12825
- const ERR_INVALID_OPT_VALUE = errorsBrowser.codes.ERR_INVALID_OPT_VALUE;
12826
- function highWaterMarkFrom(options, isDuplex, duplexKey) {
12827
- return options.highWaterMark != null ? options.highWaterMark : isDuplex ? options[duplexKey] : null;
12828
- }
12829
- function getHighWaterMark(state, options, duplexKey, isDuplex) {
12830
- const hwm = highWaterMarkFrom(options, isDuplex, duplexKey);
12831
- if (hwm != null) {
12832
- if (!(isFinite(hwm) && Math.floor(hwm) === hwm) || hwm < 0) {
12833
- const name = isDuplex ? duplexKey : 'highWaterMark';
12834
- throw new ERR_INVALID_OPT_VALUE(name, hwm);
12835
- }
12836
- return Math.floor(hwm);
12837
- }
12842
+ var state;
12843
+ var hasRequiredState;
12838
12844
 
12839
- // Default value
12840
- return state.objectMode ? 16 : 16 * 1024;
12845
+ function requireState () {
12846
+ if (hasRequiredState) return state;
12847
+ hasRequiredState = 1;
12848
+
12849
+ const ERR_INVALID_OPT_VALUE = errorsBrowser.codes.ERR_INVALID_OPT_VALUE;
12850
+ function highWaterMarkFrom(options, isDuplex, duplexKey) {
12851
+ return options.highWaterMark != null ? options.highWaterMark : isDuplex ? options[duplexKey] : null;
12852
+ }
12853
+ function getHighWaterMark(state, options, duplexKey, isDuplex) {
12854
+ const hwm = highWaterMarkFrom(options, isDuplex, duplexKey);
12855
+ if (hwm != null) {
12856
+ if (!(isFinite(hwm) && Math.floor(hwm) === hwm) || hwm < 0) {
12857
+ const name = isDuplex ? duplexKey : 'highWaterMark';
12858
+ throw new ERR_INVALID_OPT_VALUE(name, hwm);
12859
+ }
12860
+ return Math.floor(hwm);
12861
+ }
12862
+
12863
+ // Default value
12864
+ return state.objectMode ? 16 : 16 * 1024;
12865
+ }
12866
+ state = {
12867
+ getHighWaterMark
12868
+ };
12869
+ return state;
12841
12870
  }
12842
- var state = {
12843
- getHighWaterMark
12844
- };
12845
12871
 
12846
- /**
12847
- * Module exports.
12848
- */
12872
+ var browser$b;
12873
+ var hasRequiredBrowser$3;
12849
12874
 
12850
- var browser$b = deprecate$1;
12875
+ function requireBrowser$3 () {
12876
+ if (hasRequiredBrowser$3) return browser$b;
12877
+ hasRequiredBrowser$3 = 1;
12878
+ /**
12879
+ * Module exports.
12880
+ */
12851
12881
 
12852
- /**
12853
- * Mark that a method should not be used.
12854
- * Returns a modified function which warns once by default.
12855
- *
12856
- * If `localStorage.noDeprecation = true` is set, then it is a no-op.
12857
- *
12858
- * If `localStorage.throwDeprecation = true` is set, then deprecated functions
12859
- * will throw an Error when invoked.
12860
- *
12861
- * If `localStorage.traceDeprecation = true` is set, then deprecated functions
12862
- * will invoke `console.trace()` instead of `console.error()`.
12863
- *
12864
- * @param {Function} fn - the function to deprecate
12865
- * @param {String} msg - the string to print to the console when `fn` is invoked
12866
- * @returns {Function} a new "deprecated" version of `fn`
12867
- * @api public
12868
- */
12882
+ browser$b = deprecate;
12869
12883
 
12870
- function deprecate$1 (fn, msg) {
12871
- if (config('noDeprecation')) {
12872
- return fn;
12873
- }
12884
+ /**
12885
+ * Mark that a method should not be used.
12886
+ * Returns a modified function which warns once by default.
12887
+ *
12888
+ * If `localStorage.noDeprecation = true` is set, then it is a no-op.
12889
+ *
12890
+ * If `localStorage.throwDeprecation = true` is set, then deprecated functions
12891
+ * will throw an Error when invoked.
12892
+ *
12893
+ * If `localStorage.traceDeprecation = true` is set, then deprecated functions
12894
+ * will invoke `console.trace()` instead of `console.error()`.
12895
+ *
12896
+ * @param {Function} fn - the function to deprecate
12897
+ * @param {String} msg - the string to print to the console when `fn` is invoked
12898
+ * @returns {Function} a new "deprecated" version of `fn`
12899
+ * @api public
12900
+ */
12874
12901
 
12875
- var warned = false;
12876
- function deprecated() {
12877
- if (!warned) {
12878
- if (config('throwDeprecation')) {
12879
- throw new Error(msg);
12880
- } else if (config('traceDeprecation')) {
12881
- console.trace(msg);
12882
- } else {
12883
- console.warn(msg);
12884
- }
12885
- warned = true;
12886
- }
12887
- return fn.apply(this, arguments);
12888
- }
12902
+ function deprecate (fn, msg) {
12903
+ if (config('noDeprecation')) {
12904
+ return fn;
12905
+ }
12889
12906
 
12890
- return deprecated;
12891
- }
12907
+ var warned = false;
12908
+ function deprecated() {
12909
+ if (!warned) {
12910
+ if (config('throwDeprecation')) {
12911
+ throw new Error(msg);
12912
+ } else if (config('traceDeprecation')) {
12913
+ console.trace(msg);
12914
+ } else {
12915
+ console.warn(msg);
12916
+ }
12917
+ warned = true;
12918
+ }
12919
+ return fn.apply(this, arguments);
12920
+ }
12892
12921
 
12893
- /**
12894
- * Checks `localStorage` for boolean values for the given `name`.
12895
- *
12896
- * @param {String} name
12897
- * @returns {Boolean}
12898
- * @api private
12899
- */
12922
+ return deprecated;
12923
+ }
12900
12924
 
12901
- function config (name) {
12902
- // accessing global.localStorage can trigger a DOMException in sandboxed iframes
12903
- try {
12904
- if (!commonjsGlobal.localStorage) return false;
12905
- } catch (_) {
12906
- return false;
12907
- }
12908
- var val = commonjsGlobal.localStorage[name];
12909
- if (null == val) return false;
12910
- return String(val).toLowerCase() === 'true';
12925
+ /**
12926
+ * Checks `localStorage` for boolean values for the given `name`.
12927
+ *
12928
+ * @param {String} name
12929
+ * @returns {Boolean}
12930
+ * @api private
12931
+ */
12932
+
12933
+ function config (name) {
12934
+ // accessing global.localStorage can trigger a DOMException in sandboxed iframes
12935
+ try {
12936
+ if (!commonjsGlobal.localStorage) return false;
12937
+ } catch (_) {
12938
+ return false;
12939
+ }
12940
+ var val = commonjsGlobal.localStorage[name];
12941
+ if (null == val) return false;
12942
+ return String(val).toLowerCase() === 'true';
12943
+ }
12944
+ return browser$b;
12911
12945
  }
12912
12946
 
12913
12947
  var _stream_writable;
@@ -12938,12 +12972,12 @@ function require_stream_writable () {
12938
12972
 
12939
12973
  /*<replacement>*/
12940
12974
  const internalUtil = {
12941
- deprecate: browser$b
12975
+ deprecate: requireBrowser$3()
12942
12976
  };
12943
12977
  /*</replacement>*/
12944
12978
 
12945
12979
  /*<replacement>*/
12946
- var Stream = streamBrowser;
12980
+ var Stream = requireStreamBrowser();
12947
12981
  /*</replacement>*/
12948
12982
 
12949
12983
  const Buffer = require$$6$1.Buffer;
@@ -12954,8 +12988,8 @@ function require_stream_writable () {
12954
12988
  function _isUint8Array(obj) {
12955
12989
  return Buffer.isBuffer(obj) || obj instanceof OurUint8Array;
12956
12990
  }
12957
- const destroyImpl = destroy_1;
12958
- const _require = state,
12991
+ const destroyImpl = requireDestroy();
12992
+ const _require = requireState(),
12959
12993
  getHighWaterMark = _require.getHighWaterMark;
12960
12994
  const _require$codes = errorsBrowser.codes,
12961
12995
  ERR_INVALID_ARG_TYPE = _require$codes.ERR_INVALID_ARG_TYPE,
@@ -14149,7 +14183,7 @@ function require_stream_readable () {
14149
14183
  /*</replacement>*/
14150
14184
 
14151
14185
  /*<replacement>*/
14152
- var Stream = streamBrowser;
14186
+ var Stream = requireStreamBrowser();
14153
14187
  /*</replacement>*/
14154
14188
 
14155
14189
  const Buffer = require$$6$1.Buffer;
@@ -14172,8 +14206,8 @@ function require_stream_readable () {
14172
14206
  /*</replacement>*/
14173
14207
 
14174
14208
  const BufferList = requireBuffer_list();
14175
- const destroyImpl = destroy_1;
14176
- const _require = state,
14209
+ const destroyImpl = requireDestroy();
14210
+ const _require = requireState(),
14177
14211
  getHighWaterMark = _require.getHighWaterMark;
14178
14212
  const _require$codes = errorsBrowser.codes,
14179
14213
  ERR_INVALID_ARG_TYPE = _require$codes.ERR_INVALID_ARG_TYPE,
@@ -17539,7 +17573,7 @@ function WriteReq(chunk, encoding, cb) {
17539
17573
 
17540
17574
  function WritableState(options, stream) {
17541
17575
  Object.defineProperty(this, 'buffer', {
17542
- get: deprecate$2(function () {
17576
+ get: deprecate$1(function () {
17543
17577
  return this.getBuffer();
17544
17578
  }, '_writableState.buffer is deprecated. Use _writableState.getBuffer ' + 'instead.')
17545
17579
  });
@@ -38952,7 +38986,7 @@ class VMemoryBlockstore {
38952
38986
  }
38953
38987
  }
38954
38988
 
38955
- const defaultConfig$2 = {
38989
+ const defaultConfig$1 = {
38956
38990
  headerKeyPrefix: 'fp.'
38957
38991
  };
38958
38992
 
@@ -38960,7 +38994,7 @@ const defaultConfig$2 = {
38960
38994
 
38961
38995
  class Browser extends Base {
38962
38996
  constructor (name, config = {}) {
38963
- super(name, Object.assign({}, defaultConfig$2, config));
38997
+ super(name, Object.assign({}, defaultConfig$1, config));
38964
38998
  this.isBrowser = false;
38965
38999
  try {
38966
39000
  this.isBrowser = window.localStorage && true;
@@ -39017,209 +39051,6 @@ class Browser extends Base {
39017
39051
  }
39018
39052
  }
39019
39053
 
39020
- // Copyright Joyent, Inc. and other Node contributors.
39021
- //
39022
- // Permission is hereby granted, free of charge, to any person obtaining a
39023
- // copy of this software and associated documentation files (the
39024
- // "Software"), to deal in the Software without restriction, including
39025
- // without limitation the rights to use, copy, modify, merge, publish,
39026
- // distribute, sublicense, and/or sell copies of the Software, and to permit
39027
- // persons to whom the Software is furnished to do so, subject to the
39028
- // following conditions:
39029
- //
39030
- // The above copyright notice and this permission notice shall be included
39031
- // in all copies or substantial portions of the Software.
39032
- //
39033
- // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
39034
- // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
39035
- // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
39036
- // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
39037
- // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
39038
- // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
39039
- // USE OR OTHER DEALINGS IN THE SOFTWARE.
39040
-
39041
- // resolves . and .. elements in a path array with directory names there
39042
- // must be no slashes, empty elements, or device names (c:\) in the array
39043
- // (so also no leading and trailing slashes - it does not distinguish
39044
- // relative and absolute paths)
39045
- function normalizeArray(parts, allowAboveRoot) {
39046
- // if the path tries to go above the root, `up` ends up > 0
39047
- var up = 0;
39048
- for (var i = parts.length - 1; i >= 0; i--) {
39049
- var last = parts[i];
39050
- if (last === '.') {
39051
- parts.splice(i, 1);
39052
- } else if (last === '..') {
39053
- parts.splice(i, 1);
39054
- up++;
39055
- } else if (up) {
39056
- parts.splice(i, 1);
39057
- up--;
39058
- }
39059
- }
39060
-
39061
- // if the path is allowed to go above the root, restore leading ..s
39062
- if (allowAboveRoot) {
39063
- for (; up--; up) {
39064
- parts.unshift('..');
39065
- }
39066
- }
39067
-
39068
- return parts;
39069
- }
39070
-
39071
- // Split a filename into [root, dir, basename, ext], unix version
39072
- // 'root' is just a slash, or nothing.
39073
- var splitPathRe =
39074
- /^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/;
39075
- var splitPath = function(filename) {
39076
- return splitPathRe.exec(filename).slice(1);
39077
- };
39078
-
39079
- // path.normalize(path)
39080
- // posix version
39081
- function normalize(path) {
39082
- var isPathAbsolute = isAbsolute(path),
39083
- trailingSlash = substr(path, -1) === '/';
39084
-
39085
- // Normalize the path
39086
- path = normalizeArray(filter(path.split('/'), function(p) {
39087
- return !!p;
39088
- }), !isPathAbsolute).join('/');
39089
-
39090
- if (!path && !isPathAbsolute) {
39091
- path = '.';
39092
- }
39093
- if (path && trailingSlash) {
39094
- path += '/';
39095
- }
39096
-
39097
- return (isPathAbsolute ? '/' : '') + path;
39098
- }
39099
- // posix version
39100
- function isAbsolute(path) {
39101
- return path.charAt(0) === '/';
39102
- }
39103
-
39104
- // posix version
39105
- function join() {
39106
- var paths = Array.prototype.slice.call(arguments, 0);
39107
- return normalize(filter(paths, function(p, index) {
39108
- if (typeof p !== 'string') {
39109
- throw new TypeError('Arguments to path.join must be strings');
39110
- }
39111
- return p;
39112
- }).join('/'));
39113
- }
39114
-
39115
- function dirname(path) {
39116
- var result = splitPath(path),
39117
- root = result[0],
39118
- dir = result[1];
39119
-
39120
- if (!root && !dir) {
39121
- // No dirname whatsoever
39122
- return '.';
39123
- }
39124
-
39125
- if (dir) {
39126
- // It has a dirname, strip trailing slash
39127
- dir = dir.substr(0, dir.length - 1);
39128
- }
39129
-
39130
- return root + dir;
39131
- }
39132
- function filter (xs, f) {
39133
- if (xs.filter) return xs.filter(f);
39134
- var res = [];
39135
- for (var i = 0; i < xs.length; i++) {
39136
- if (f(xs[i], i, xs)) res.push(xs[i]);
39137
- }
39138
- return res;
39139
- }
39140
-
39141
- // String.prototype.substr - negative index don't work in IE8
39142
- var substr = 'ab'.substr(-1) === 'b' ?
39143
- function (str, start, len) { return str.substr(start, len) } :
39144
- function (str, start, len) {
39145
- if (start < 0) start = str.length + start;
39146
- return str.substr(start, len);
39147
- }
39148
- ;
39149
-
39150
- function homedir(){
39151
- return '$HOME'
39152
- }
39153
-
39154
- var fs = {};
39155
-
39156
- const readFileSync = fs.readFileSync;
39157
-
39158
- const defaultConfig$1 = {
39159
- dataDir: join(homedir(), '.fireproof')
39160
- };
39161
-
39162
- class Filesystem extends Base {
39163
- constructor (name, config = {}) {
39164
- const mergedConfig = Object.assign({}, defaultConfig$1, config);
39165
- // console.log('Filesystem', name, mergedConfig, header)
39166
- super(name, mergedConfig);
39167
- }
39168
-
39169
- async writeCars (cars) {
39170
- if (this.config.readonly) return
39171
- const writes = [];
39172
- for (const { cid, bytes } of cars) {
39173
- const carFilename = join(this.config.dataDir, this.name, `${cid.toString()}.car`);
39174
- // console.log('writeCars', carFilename)
39175
- writes.push(writeSync(carFilename, bytes));
39176
- }
39177
- await Promise.all(writes);
39178
- }
39179
-
39180
- async readCar (carCid) {
39181
- const carFilename = join(this.config.dataDir, this.name, `${carCid.toString()}.car`);
39182
- const got = readFileSync(carFilename);
39183
- // console.log('readCar', carFilename, got.constructor.name)
39184
- return got
39185
- }
39186
-
39187
- loadHeader (branch = 'main') {
39188
- const header = loadSync(this.headerFilename(branch));
39189
- // console.log('fs getHeader', this.headerFilename(), header, typeof header)
39190
- if (!header) return null
39191
- return JSON.parse(header)
39192
- }
39193
-
39194
- async writeHeader (branch, header) {
39195
- // console.log('saveHeader', this.isBrowser)
39196
- if (this.config.readonly) return
39197
- const pHeader = this.prepareHeader(header);
39198
- // console.log('writeHeader fs', branch, pHeader)
39199
- await writeSync(this.headerFilename(branch), pHeader);
39200
- }
39201
-
39202
- headerFilename (branch = 'main') {
39203
- // console.log('headerFilename', this.config.dataDir, this.name)
39204
- return join(this.config.dataDir, this.name, branch + '.json')
39205
- }
39206
- }
39207
-
39208
- function loadSync (filename) {
39209
- try {
39210
- return readFileSync(filename, 'utf8').toString()
39211
- } catch (error) {
39212
- // console.log('error', error)
39213
- return null
39214
- }
39215
- }
39216
-
39217
- async function writeSync (fullpath, stringValue) {
39218
- await fs.promises.mkdir(dirname(fullpath), { recursive: true });
39219
- // writeFileSync(fullpath, stringValue)
39220
- await fs.promises.writeFile(fullpath, stringValue);
39221
- }
39222
-
39223
39054
  /**
39224
39055
  * Returns a `Buffer` instance from the given data URI `uri`.
39225
39056
  *
@@ -45943,26 +45774,17 @@ class Rest extends Base {
45943
45774
  }
45944
45775
  }
45945
45776
 
45946
- const FORCE_IDB = typeof process !== 'undefined' && !!process.env?.FORCE_IDB;
45947
-
45948
- /* global window */
45949
-
45950
45777
  const Loader = {
45951
45778
  appropriate: (name, config = {}) => {
45952
- let isBrowser = false;
45953
- try {
45954
- isBrowser = window.localStorage && true;
45955
- } catch (e) {}
45779
+ if (config.StorageClass) {
45780
+ return new config.StorageClass(name, config)
45781
+ }
45956
45782
 
45957
45783
  if (config.type === 'rest') {
45958
45784
  return new Rest(name, config)
45959
45785
  }
45960
45786
 
45961
- if (FORCE_IDB || isBrowser) {
45962
- return new Browser(name, config)
45963
- } else {
45964
- return new Filesystem(name, config)
45965
- }
45787
+ return new Browser(name, config)
45966
45788
  }
45967
45789
  };
45968
45790
 
@@ -50356,7 +50178,7 @@ class Fireproof {
50356
50178
  clock: {
50357
50179
  byId: byId ? parseCID(byId) : null,
50358
50180
  byKey: byKey ? parseCID(byKey) : null,
50359
- db: (db && db.length > 0) ? db.map(c => parseCID(c)) : null
50181
+ db: db && db.length > 0 ? db.map(c => parseCID(c)) : null
50360
50182
  },
50361
50183
  code,
50362
50184
  name
@@ -50379,7 +50201,9 @@ class Fireproof {
50379
50201
 
50380
50202
  const withBlocks = new Database(database.name);
50381
50203
  withBlocks.blocks = database.blocks;
50382
- withBlocks.clock = definition.clock;
50204
+ withBlocks.ready.then(() => {
50205
+ withBlocks.clock = definition.clock.map(c => parseCID(c));
50206
+ });
50383
50207
 
50384
50208
  const snappedDb = Fireproof.fromJSON(definition, null, withBlocks)
50385
50209
  ;[...database.indexes.values()].forEach(index => {