@fireproof/core 0.8.0-dev.2 → 0.8.0-dev.4

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.
@@ -9331,7 +9331,15 @@ var _polyfillNode_events = /*#__PURE__*/Object.freeze({
9331
9331
 
9332
9332
  var require$$0$1 = /*@__PURE__*/getAugmentedNamespace(_polyfillNode_events);
9333
9333
 
9334
- var streamBrowser = require$$0$1.EventEmitter;
9334
+ var streamBrowser;
9335
+ var hasRequiredStreamBrowser;
9336
+
9337
+ function requireStreamBrowser () {
9338
+ if (hasRequiredStreamBrowser) return streamBrowser;
9339
+ hasRequiredStreamBrowser = 1;
9340
+ streamBrowser = require$$0$1.EventEmitter;
9341
+ return streamBrowser;
9342
+ }
9335
9343
 
9336
9344
  // shim for using process in browser
9337
9345
  // based off https://github.com/defunctzombie/node-process/blob/master/browser.js
@@ -9474,7 +9482,7 @@ var argv = [];
9474
9482
  var version$1 = ''; // empty string to avoid regexp issues
9475
9483
  var versions = {};
9476
9484
  var release = {};
9477
- var config$2 = {};
9485
+ var config$1 = {};
9478
9486
 
9479
9487
  function noop$3() {}
9480
9488
 
@@ -9551,7 +9559,7 @@ var browser$1$1 = {
9551
9559
  hrtime: hrtime,
9552
9560
  platform: platform,
9553
9561
  release: release,
9554
- config: config$2,
9562
+ config: config$1,
9555
9563
  uptime: uptime
9556
9564
  };
9557
9565
 
@@ -9632,11 +9640,11 @@ function format$6(f) {
9632
9640
  // Mark that a method should not be used.
9633
9641
  // Returns a modified function which warns once by default.
9634
9642
  // If --no-deprecation is set, then it is a no-op.
9635
- function deprecate$1(fn, msg) {
9643
+ function deprecate(fn, msg) {
9636
9644
  // Allow for deprecating things in the process of starting up.
9637
9645
  if (isUndefined(global$1.process)) {
9638
9646
  return function() {
9639
- return deprecate$1(fn, msg).apply(this, arguments);
9647
+ return deprecate(fn, msg).apply(this, arguments);
9640
9648
  };
9641
9649
  }
9642
9650
 
@@ -10245,7 +10253,7 @@ var _polyfillNode_util = {
10245
10253
  isBoolean: isBoolean,
10246
10254
  isArray: isArray,
10247
10255
  inspect: inspect,
10248
- deprecate: deprecate$1,
10256
+ deprecate: deprecate,
10249
10257
  format: format$6,
10250
10258
  debuglog: debuglog,
10251
10259
  promisify: promisify,
@@ -10258,7 +10266,7 @@ var _polyfillNode_util$1 = /*#__PURE__*/Object.freeze({
10258
10266
  callbackify: callbackify,
10259
10267
  debuglog: debuglog,
10260
10268
  default: _polyfillNode_util,
10261
- deprecate: deprecate$1,
10269
+ deprecate: deprecate,
10262
10270
  format: format$6,
10263
10271
  inherits: inherits$1,
10264
10272
  inspect: inspect,
@@ -10446,99 +10454,108 @@ function requireBuffer_list () {
10446
10454
  return buffer_list;
10447
10455
  }
10448
10456
 
10449
- // undocumented cb() API, needed for core, not for public API
10450
- function destroy(err, cb) {
10451
- const readableDestroyed = this._readableState && this._readableState.destroyed;
10452
- const writableDestroyed = this._writableState && this._writableState.destroyed;
10453
- if (readableDestroyed || writableDestroyed) {
10454
- if (cb) {
10455
- cb(err);
10456
- } else if (err) {
10457
- if (!this._writableState) {
10458
- process.nextTick(emitErrorNT, this, err);
10459
- } else if (!this._writableState.errorEmitted) {
10460
- this._writableState.errorEmitted = true;
10461
- process.nextTick(emitErrorNT, this, err);
10462
- }
10463
- }
10464
- return this;
10465
- }
10457
+ var destroy_1;
10458
+ var hasRequiredDestroy;
10466
10459
 
10467
- // we set destroyed to true before firing error callbacks in order
10468
- // to make it re-entrance safe in case destroy() is called within callbacks
10460
+ function requireDestroy () {
10461
+ if (hasRequiredDestroy) return destroy_1;
10462
+ hasRequiredDestroy = 1;
10469
10463
 
10470
- if (this._readableState) {
10471
- this._readableState.destroyed = true;
10472
- }
10464
+ // undocumented cb() API, needed for core, not for public API
10465
+ function destroy(err, cb) {
10466
+ const readableDestroyed = this._readableState && this._readableState.destroyed;
10467
+ const writableDestroyed = this._writableState && this._writableState.destroyed;
10468
+ if (readableDestroyed || writableDestroyed) {
10469
+ if (cb) {
10470
+ cb(err);
10471
+ } else if (err) {
10472
+ if (!this._writableState) {
10473
+ process.nextTick(emitErrorNT, this, err);
10474
+ } else if (!this._writableState.errorEmitted) {
10475
+ this._writableState.errorEmitted = true;
10476
+ process.nextTick(emitErrorNT, this, err);
10477
+ }
10478
+ }
10479
+ return this;
10480
+ }
10473
10481
 
10474
- // if this is a duplex stream mark the writable part as destroyed as well
10475
- if (this._writableState) {
10476
- this._writableState.destroyed = true;
10477
- }
10478
- this._destroy(err || null, err => {
10479
- if (!cb && err) {
10480
- if (!this._writableState) {
10481
- process.nextTick(emitErrorAndCloseNT, this, err);
10482
- } else if (!this._writableState.errorEmitted) {
10483
- this._writableState.errorEmitted = true;
10484
- process.nextTick(emitErrorAndCloseNT, this, err);
10485
- } else {
10486
- process.nextTick(emitCloseNT, this);
10487
- }
10488
- } else if (cb) {
10489
- process.nextTick(emitCloseNT, this);
10490
- cb(err);
10491
- } else {
10492
- process.nextTick(emitCloseNT, this);
10493
- }
10494
- });
10495
- return this;
10496
- }
10497
- function emitErrorAndCloseNT(self, err) {
10498
- emitErrorNT(self, err);
10499
- emitCloseNT(self);
10500
- }
10501
- function emitCloseNT(self) {
10502
- if (self._writableState && !self._writableState.emitClose) return;
10503
- if (self._readableState && !self._readableState.emitClose) return;
10504
- self.emit('close');
10505
- }
10506
- function undestroy() {
10507
- if (this._readableState) {
10508
- this._readableState.destroyed = false;
10509
- this._readableState.reading = false;
10510
- this._readableState.ended = false;
10511
- this._readableState.endEmitted = false;
10512
- }
10513
- if (this._writableState) {
10514
- this._writableState.destroyed = false;
10515
- this._writableState.ended = false;
10516
- this._writableState.ending = false;
10517
- this._writableState.finalCalled = false;
10518
- this._writableState.prefinished = false;
10519
- this._writableState.finished = false;
10520
- this._writableState.errorEmitted = false;
10521
- }
10522
- }
10523
- function emitErrorNT(self, err) {
10524
- self.emit('error', err);
10525
- }
10526
- function errorOrDestroy(stream, err) {
10527
- // We have tests that rely on errors being emitted
10528
- // in the same tick, so changing this is semver major.
10529
- // For now when you opt-in to autoDestroy we allow
10530
- // the error to be emitted nextTick. In a future
10531
- // semver major update we should change the default to this.
10482
+ // we set destroyed to true before firing error callbacks in order
10483
+ // to make it re-entrance safe in case destroy() is called within callbacks
10532
10484
 
10533
- const rState = stream._readableState;
10534
- const wState = stream._writableState;
10535
- if (rState && rState.autoDestroy || wState && wState.autoDestroy) stream.destroy(err);else stream.emit('error', err);
10485
+ if (this._readableState) {
10486
+ this._readableState.destroyed = true;
10487
+ }
10488
+
10489
+ // if this is a duplex stream mark the writable part as destroyed as well
10490
+ if (this._writableState) {
10491
+ this._writableState.destroyed = true;
10492
+ }
10493
+ this._destroy(err || null, err => {
10494
+ if (!cb && err) {
10495
+ if (!this._writableState) {
10496
+ process.nextTick(emitErrorAndCloseNT, this, err);
10497
+ } else if (!this._writableState.errorEmitted) {
10498
+ this._writableState.errorEmitted = true;
10499
+ process.nextTick(emitErrorAndCloseNT, this, err);
10500
+ } else {
10501
+ process.nextTick(emitCloseNT, this);
10502
+ }
10503
+ } else if (cb) {
10504
+ process.nextTick(emitCloseNT, this);
10505
+ cb(err);
10506
+ } else {
10507
+ process.nextTick(emitCloseNT, this);
10508
+ }
10509
+ });
10510
+ return this;
10511
+ }
10512
+ function emitErrorAndCloseNT(self, err) {
10513
+ emitErrorNT(self, err);
10514
+ emitCloseNT(self);
10515
+ }
10516
+ function emitCloseNT(self) {
10517
+ if (self._writableState && !self._writableState.emitClose) return;
10518
+ if (self._readableState && !self._readableState.emitClose) return;
10519
+ self.emit('close');
10520
+ }
10521
+ function undestroy() {
10522
+ if (this._readableState) {
10523
+ this._readableState.destroyed = false;
10524
+ this._readableState.reading = false;
10525
+ this._readableState.ended = false;
10526
+ this._readableState.endEmitted = false;
10527
+ }
10528
+ if (this._writableState) {
10529
+ this._writableState.destroyed = false;
10530
+ this._writableState.ended = false;
10531
+ this._writableState.ending = false;
10532
+ this._writableState.finalCalled = false;
10533
+ this._writableState.prefinished = false;
10534
+ this._writableState.finished = false;
10535
+ this._writableState.errorEmitted = false;
10536
+ }
10537
+ }
10538
+ function emitErrorNT(self, err) {
10539
+ self.emit('error', err);
10540
+ }
10541
+ function errorOrDestroy(stream, err) {
10542
+ // We have tests that rely on errors being emitted
10543
+ // in the same tick, so changing this is semver major.
10544
+ // For now when you opt-in to autoDestroy we allow
10545
+ // the error to be emitted nextTick. In a future
10546
+ // semver major update we should change the default to this.
10547
+
10548
+ const rState = stream._readableState;
10549
+ const wState = stream._writableState;
10550
+ if (rState && rState.autoDestroy || wState && wState.autoDestroy) stream.destroy(err);else stream.emit('error', err);
10551
+ }
10552
+ destroy_1 = {
10553
+ destroy,
10554
+ undestroy,
10555
+ errorOrDestroy
10556
+ };
10557
+ return destroy_1;
10536
10558
  }
10537
- var destroy_1 = {
10538
- destroy,
10539
- undestroy,
10540
- errorOrDestroy
10541
- };
10542
10559
 
10543
10560
  var errorsBrowser = {};
10544
10561
 
@@ -10668,92 +10685,109 @@ createErrorType('ERR_UNKNOWN_ENCODING', function (arg) {
10668
10685
  createErrorType('ERR_STREAM_UNSHIFT_AFTER_END_EVENT', 'stream.unshift() after end event');
10669
10686
  errorsBrowser.codes = codes;
10670
10687
 
10671
- const ERR_INVALID_OPT_VALUE = errorsBrowser.codes.ERR_INVALID_OPT_VALUE;
10672
- function highWaterMarkFrom(options, isDuplex, duplexKey) {
10673
- return options.highWaterMark != null ? options.highWaterMark : isDuplex ? options[duplexKey] : null;
10674
- }
10675
- function getHighWaterMark(state, options, duplexKey, isDuplex) {
10676
- const hwm = highWaterMarkFrom(options, isDuplex, duplexKey);
10677
- if (hwm != null) {
10678
- if (!(isFinite(hwm) && Math.floor(hwm) === hwm) || hwm < 0) {
10679
- const name = isDuplex ? duplexKey : 'highWaterMark';
10680
- throw new ERR_INVALID_OPT_VALUE(name, hwm);
10681
- }
10682
- return Math.floor(hwm);
10683
- }
10688
+ var state;
10689
+ var hasRequiredState;
10684
10690
 
10685
- // Default value
10686
- return state.objectMode ? 16 : 16 * 1024;
10691
+ function requireState () {
10692
+ if (hasRequiredState) return state;
10693
+ hasRequiredState = 1;
10694
+
10695
+ const ERR_INVALID_OPT_VALUE = errorsBrowser.codes.ERR_INVALID_OPT_VALUE;
10696
+ function highWaterMarkFrom(options, isDuplex, duplexKey) {
10697
+ return options.highWaterMark != null ? options.highWaterMark : isDuplex ? options[duplexKey] : null;
10698
+ }
10699
+ function getHighWaterMark(state, options, duplexKey, isDuplex) {
10700
+ const hwm = highWaterMarkFrom(options, isDuplex, duplexKey);
10701
+ if (hwm != null) {
10702
+ if (!(isFinite(hwm) && Math.floor(hwm) === hwm) || hwm < 0) {
10703
+ const name = isDuplex ? duplexKey : 'highWaterMark';
10704
+ throw new ERR_INVALID_OPT_VALUE(name, hwm);
10705
+ }
10706
+ return Math.floor(hwm);
10707
+ }
10708
+
10709
+ // Default value
10710
+ return state.objectMode ? 16 : 16 * 1024;
10711
+ }
10712
+ state = {
10713
+ getHighWaterMark
10714
+ };
10715
+ return state;
10687
10716
  }
10688
- var state = {
10689
- getHighWaterMark
10690
- };
10691
10717
 
10692
- /**
10693
- * Module exports.
10694
- */
10718
+ var browser$c;
10719
+ var hasRequiredBrowser$b;
10695
10720
 
10696
- var browser$c = deprecate;
10721
+ function requireBrowser$b () {
10722
+ if (hasRequiredBrowser$b) return browser$c;
10723
+ hasRequiredBrowser$b = 1;
10724
+ /**
10725
+ * Module exports.
10726
+ */
10697
10727
 
10698
- /**
10699
- * Mark that a method should not be used.
10700
- * Returns a modified function which warns once by default.
10701
- *
10702
- * If `localStorage.noDeprecation = true` is set, then it is a no-op.
10703
- *
10704
- * If `localStorage.throwDeprecation = true` is set, then deprecated functions
10705
- * will throw an Error when invoked.
10706
- *
10707
- * If `localStorage.traceDeprecation = true` is set, then deprecated functions
10708
- * will invoke `console.trace()` instead of `console.error()`.
10709
- *
10710
- * @param {Function} fn - the function to deprecate
10711
- * @param {String} msg - the string to print to the console when `fn` is invoked
10712
- * @returns {Function} a new "deprecated" version of `fn`
10713
- * @api public
10714
- */
10728
+ browser$c = deprecate;
10715
10729
 
10716
- function deprecate (fn, msg) {
10717
- if (config$1('noDeprecation')) {
10718
- return fn;
10719
- }
10730
+ /**
10731
+ * Mark that a method should not be used.
10732
+ * Returns a modified function which warns once by default.
10733
+ *
10734
+ * If `localStorage.noDeprecation = true` is set, then it is a no-op.
10735
+ *
10736
+ * If `localStorage.throwDeprecation = true` is set, then deprecated functions
10737
+ * will throw an Error when invoked.
10738
+ *
10739
+ * If `localStorage.traceDeprecation = true` is set, then deprecated functions
10740
+ * will invoke `console.trace()` instead of `console.error()`.
10741
+ *
10742
+ * @param {Function} fn - the function to deprecate
10743
+ * @param {String} msg - the string to print to the console when `fn` is invoked
10744
+ * @returns {Function} a new "deprecated" version of `fn`
10745
+ * @api public
10746
+ */
10720
10747
 
10721
- var warned = false;
10722
- function deprecated() {
10723
- if (!warned) {
10724
- if (config$1('throwDeprecation')) {
10725
- throw new Error(msg);
10726
- } else if (config$1('traceDeprecation')) {
10727
- console.trace(msg);
10728
- } else {
10729
- console.warn(msg);
10730
- }
10731
- warned = true;
10732
- }
10733
- return fn.apply(this, arguments);
10734
- }
10748
+ function deprecate (fn, msg) {
10749
+ if (config('noDeprecation')) {
10750
+ return fn;
10751
+ }
10735
10752
 
10736
- return deprecated;
10737
- }
10753
+ var warned = false;
10754
+ function deprecated() {
10755
+ if (!warned) {
10756
+ if (config('throwDeprecation')) {
10757
+ throw new Error(msg);
10758
+ } else if (config('traceDeprecation')) {
10759
+ console.trace(msg);
10760
+ } else {
10761
+ console.warn(msg);
10762
+ }
10763
+ warned = true;
10764
+ }
10765
+ return fn.apply(this, arguments);
10766
+ }
10738
10767
 
10739
- /**
10740
- * Checks `localStorage` for boolean values for the given `name`.
10741
- *
10742
- * @param {String} name
10743
- * @returns {Boolean}
10744
- * @api private
10745
- */
10768
+ return deprecated;
10769
+ }
10746
10770
 
10747
- function config$1 (name) {
10748
- // accessing global.localStorage can trigger a DOMException in sandboxed iframes
10749
- try {
10750
- if (!commonjsGlobal.localStorage) return false;
10751
- } catch (_) {
10752
- return false;
10753
- }
10754
- var val = commonjsGlobal.localStorage[name];
10755
- if (null == val) return false;
10756
- return String(val).toLowerCase() === 'true';
10771
+ /**
10772
+ * Checks `localStorage` for boolean values for the given `name`.
10773
+ *
10774
+ * @param {String} name
10775
+ * @returns {Boolean}
10776
+ * @api private
10777
+ */
10778
+
10779
+ function config (name) {
10780
+ // accessing global.localStorage can trigger a DOMException in sandboxed iframes
10781
+ try {
10782
+ if (!commonjsGlobal.localStorage) return false;
10783
+ } catch (_) {
10784
+ return false;
10785
+ }
10786
+ var val = commonjsGlobal.localStorage[name];
10787
+ if (null == val) return false;
10788
+ return String(val).toLowerCase() === 'true';
10789
+ }
10790
+ return browser$c;
10757
10791
  }
10758
10792
 
10759
10793
  var _stream_writable;
@@ -10784,12 +10818,12 @@ function require_stream_writable () {
10784
10818
 
10785
10819
  /*<replacement>*/
10786
10820
  const internalUtil = {
10787
- deprecate: browser$c
10821
+ deprecate: requireBrowser$b()
10788
10822
  };
10789
10823
  /*</replacement>*/
10790
10824
 
10791
10825
  /*<replacement>*/
10792
- var Stream = streamBrowser;
10826
+ var Stream = requireStreamBrowser();
10793
10827
  /*</replacement>*/
10794
10828
 
10795
10829
  const Buffer = require$$6$1.Buffer;
@@ -10800,8 +10834,8 @@ function require_stream_writable () {
10800
10834
  function _isUint8Array(obj) {
10801
10835
  return Buffer.isBuffer(obj) || obj instanceof OurUint8Array;
10802
10836
  }
10803
- const destroyImpl = destroy_1;
10804
- const _require = state,
10837
+ const destroyImpl = requireDestroy();
10838
+ const _require = requireState(),
10805
10839
  getHighWaterMark = _require.getHighWaterMark;
10806
10840
  const _require$codes = errorsBrowser.codes,
10807
10841
  ERR_INVALID_ARG_TYPE = _require$codes.ERR_INVALID_ARG_TYPE,
@@ -11995,7 +12029,7 @@ function require_stream_readable () {
11995
12029
  /*</replacement>*/
11996
12030
 
11997
12031
  /*<replacement>*/
11998
- var Stream = streamBrowser;
12032
+ var Stream = requireStreamBrowser();
11999
12033
  /*</replacement>*/
12000
12034
 
12001
12035
  const Buffer = require$$6$1.Buffer;
@@ -12018,8 +12052,8 @@ function require_stream_readable () {
12018
12052
  /*</replacement>*/
12019
12053
 
12020
12054
  const BufferList = requireBuffer_list();
12021
- const destroyImpl = destroy_1;
12022
- const _require = state,
12055
+ const destroyImpl = requireDestroy();
12056
+ const _require = requireState(),
12023
12057
  getHighWaterMark = _require.getHighWaterMark;
12024
12058
  const _require$codes = errorsBrowser.codes,
12025
12059
  ERR_INVALID_ARG_TYPE = _require$codes.ERR_INVALID_ARG_TYPE,
@@ -15472,7 +15506,7 @@ function WriteReq(chunk, encoding, cb) {
15472
15506
 
15473
15507
  function WritableState(options, stream) {
15474
15508
  Object.defineProperty(this, 'buffer', {
15475
- get: deprecate$1(function () {
15509
+ get: deprecate(function () {
15476
15510
  return this.getBuffer();
15477
15511
  }, '_writableState.buffer is deprecated. Use _writableState.getBuffer ' + 'instead.')
15478
15512
  });
@@ -37141,6 +37175,7 @@ const blockOpts$1 = { cache: nocache, chunker, codec: codec$1, hasher: sha256$3,
37141
37175
  const NO_ENCRYPT = typeof process !== 'undefined' && !!process.env?.NO_ENCRYPT;
37142
37176
 
37143
37177
  let Base$1 = class Base {
37178
+ static format = '0.8'
37144
37179
  lastCar = null
37145
37180
  carLog = []
37146
37181
  keyMaterial = null
@@ -37257,7 +37292,10 @@ let Base$1 = class Base {
37257
37292
  header.key && this.setKeyMaterial(header.key);
37258
37293
  // this.setCarCidMapCarCid(header.car) // instead we should just extract the list of cars from the car
37259
37294
  const carHeader = await this.readHeaderCar(header.car);
37260
- this.carLog = carHeader.cars;
37295
+
37296
+ // console.log('carHeader', this.name, carHeader)
37297
+
37298
+ this.carLog = carHeader.cars || [];
37261
37299
  // console.log('stored carHeader', this.name, this.config.type, this.carLog)
37262
37300
 
37263
37301
  // this.lastCar = header.car // ?
@@ -37571,7 +37609,7 @@ let Base$1 = class Base {
37571
37609
  };
37572
37610
 
37573
37611
  const defaultConfig$1 = {
37574
- headerKeyPrefix: 'fp.'
37612
+ headerKeyPrefix: 'fp.' + Base$1.format
37575
37613
  };
37576
37614
 
37577
37615
  /* global localStorage */
@@ -37583,7 +37621,7 @@ class Browser extends Base$1 {
37583
37621
 
37584
37622
  withDB = async dbWorkFun => {
37585
37623
  if (!this.idb) {
37586
- this.idb = await openDB(`fp.${this.keyId}.${this.name}.valet`, 3, {
37624
+ this.idb = await openDB(`fp.${Base$1.format}.${this.keyId}.${this.name}.valet`, 3, {
37587
37625
  upgrade (db, oldVersion, newVersion, transaction) {
37588
37626
  if (oldVersion < 1) {
37589
37627
  db.createObjectStore('cars');
@@ -38201,7 +38239,7 @@ var browserPonyfill = {
38201
38239
  var fetch$2 = /*@__PURE__*/getDefaultExportFromCjs(browserPonyfillExports);
38202
38240
 
38203
38241
  const defaultConfig = {
38204
- url: 'http://localhost:4000'
38242
+ url: 'http://localhost:4000/v' + Base$1.format
38205
38243
  };
38206
38244
 
38207
38245
  class Rest extends Base$1 {