@fireproof/core 0.7.2-dev.6 → 0.7.2-dev.7

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.
@@ -8200,7 +8200,15 @@ var _polyfillNode_events = /*#__PURE__*/Object.freeze({
8200
8200
 
8201
8201
  var require$$0$1 = /*@__PURE__*/getAugmentedNamespace(_polyfillNode_events);
8202
8202
 
8203
- var streamBrowser = require$$0$1.EventEmitter;
8203
+ var streamBrowser;
8204
+ var hasRequiredStreamBrowser;
8205
+
8206
+ function requireStreamBrowser () {
8207
+ if (hasRequiredStreamBrowser) return streamBrowser;
8208
+ hasRequiredStreamBrowser = 1;
8209
+ streamBrowser = require$$0$1.EventEmitter;
8210
+ return streamBrowser;
8211
+ }
8204
8212
 
8205
8213
  // shim for using process in browser
8206
8214
  // based off https://github.com/defunctzombie/node-process/blob/master/browser.js
@@ -8343,7 +8351,7 @@ var argv = [];
8343
8351
  var version$1 = ''; // empty string to avoid regexp issues
8344
8352
  var versions = {};
8345
8353
  var release = {};
8346
- var config$1 = {};
8354
+ var config = {};
8347
8355
 
8348
8356
  function noop$3() {}
8349
8357
 
@@ -8420,7 +8428,7 @@ var browser$1$1 = {
8420
8428
  hrtime: hrtime,
8421
8429
  platform: platform,
8422
8430
  release: release,
8423
- config: config$1,
8431
+ config: config,
8424
8432
  uptime: uptime
8425
8433
  };
8426
8434
 
@@ -8501,11 +8509,11 @@ function format(f) {
8501
8509
  // Mark that a method should not be used.
8502
8510
  // Returns a modified function which warns once by default.
8503
8511
  // If --no-deprecation is set, then it is a no-op.
8504
- function deprecate$1(fn, msg) {
8512
+ function deprecate(fn, msg) {
8505
8513
  // Allow for deprecating things in the process of starting up.
8506
8514
  if (isUndefined(global$1.process)) {
8507
8515
  return function() {
8508
- return deprecate$1(fn, msg).apply(this, arguments);
8516
+ return deprecate(fn, msg).apply(this, arguments);
8509
8517
  };
8510
8518
  }
8511
8519
 
@@ -9114,7 +9122,7 @@ var _polyfillNode_util = {
9114
9122
  isBoolean: isBoolean,
9115
9123
  isArray: isArray,
9116
9124
  inspect: inspect,
9117
- deprecate: deprecate$1,
9125
+ deprecate: deprecate,
9118
9126
  format: format,
9119
9127
  debuglog: debuglog,
9120
9128
  promisify: promisify,
@@ -9127,7 +9135,7 @@ var _polyfillNode_util$1 = /*#__PURE__*/Object.freeze({
9127
9135
  callbackify: callbackify,
9128
9136
  debuglog: debuglog,
9129
9137
  default: _polyfillNode_util,
9130
- deprecate: deprecate$1,
9138
+ deprecate: deprecate,
9131
9139
  format: format,
9132
9140
  inherits: inherits$1,
9133
9141
  inspect: inspect,
@@ -9315,99 +9323,108 @@ function requireBuffer_list () {
9315
9323
  return buffer_list;
9316
9324
  }
9317
9325
 
9318
- // undocumented cb() API, needed for core, not for public API
9319
- function destroy(err, cb) {
9320
- const readableDestroyed = this._readableState && this._readableState.destroyed;
9321
- const writableDestroyed = this._writableState && this._writableState.destroyed;
9322
- if (readableDestroyed || writableDestroyed) {
9323
- if (cb) {
9324
- cb(err);
9325
- } else if (err) {
9326
- if (!this._writableState) {
9327
- process.nextTick(emitErrorNT, this, err);
9328
- } else if (!this._writableState.errorEmitted) {
9329
- this._writableState.errorEmitted = true;
9330
- process.nextTick(emitErrorNT, this, err);
9331
- }
9332
- }
9333
- return this;
9334
- }
9326
+ var destroy_1;
9327
+ var hasRequiredDestroy;
9335
9328
 
9336
- // we set destroyed to true before firing error callbacks in order
9337
- // to make it re-entrance safe in case destroy() is called within callbacks
9329
+ function requireDestroy () {
9330
+ if (hasRequiredDestroy) return destroy_1;
9331
+ hasRequiredDestroy = 1;
9338
9332
 
9339
- if (this._readableState) {
9340
- this._readableState.destroyed = true;
9341
- }
9333
+ // undocumented cb() API, needed for core, not for public API
9334
+ function destroy(err, cb) {
9335
+ const readableDestroyed = this._readableState && this._readableState.destroyed;
9336
+ const writableDestroyed = this._writableState && this._writableState.destroyed;
9337
+ if (readableDestroyed || writableDestroyed) {
9338
+ if (cb) {
9339
+ cb(err);
9340
+ } else if (err) {
9341
+ if (!this._writableState) {
9342
+ process.nextTick(emitErrorNT, this, err);
9343
+ } else if (!this._writableState.errorEmitted) {
9344
+ this._writableState.errorEmitted = true;
9345
+ process.nextTick(emitErrorNT, this, err);
9346
+ }
9347
+ }
9348
+ return this;
9349
+ }
9342
9350
 
9343
- // if this is a duplex stream mark the writable part as destroyed as well
9344
- if (this._writableState) {
9345
- this._writableState.destroyed = true;
9346
- }
9347
- this._destroy(err || null, err => {
9348
- if (!cb && err) {
9349
- if (!this._writableState) {
9350
- process.nextTick(emitErrorAndCloseNT, this, err);
9351
- } else if (!this._writableState.errorEmitted) {
9352
- this._writableState.errorEmitted = true;
9353
- process.nextTick(emitErrorAndCloseNT, this, err);
9354
- } else {
9355
- process.nextTick(emitCloseNT, this);
9356
- }
9357
- } else if (cb) {
9358
- process.nextTick(emitCloseNT, this);
9359
- cb(err);
9360
- } else {
9361
- process.nextTick(emitCloseNT, this);
9362
- }
9363
- });
9364
- return this;
9365
- }
9366
- function emitErrorAndCloseNT(self, err) {
9367
- emitErrorNT(self, err);
9368
- emitCloseNT(self);
9369
- }
9370
- function emitCloseNT(self) {
9371
- if (self._writableState && !self._writableState.emitClose) return;
9372
- if (self._readableState && !self._readableState.emitClose) return;
9373
- self.emit('close');
9374
- }
9375
- function undestroy() {
9376
- if (this._readableState) {
9377
- this._readableState.destroyed = false;
9378
- this._readableState.reading = false;
9379
- this._readableState.ended = false;
9380
- this._readableState.endEmitted = false;
9381
- }
9382
- if (this._writableState) {
9383
- this._writableState.destroyed = false;
9384
- this._writableState.ended = false;
9385
- this._writableState.ending = false;
9386
- this._writableState.finalCalled = false;
9387
- this._writableState.prefinished = false;
9388
- this._writableState.finished = false;
9389
- this._writableState.errorEmitted = false;
9390
- }
9391
- }
9392
- function emitErrorNT(self, err) {
9393
- self.emit('error', err);
9394
- }
9395
- function errorOrDestroy(stream, err) {
9396
- // We have tests that rely on errors being emitted
9397
- // in the same tick, so changing this is semver major.
9398
- // For now when you opt-in to autoDestroy we allow
9399
- // the error to be emitted nextTick. In a future
9400
- // semver major update we should change the default to this.
9351
+ // we set destroyed to true before firing error callbacks in order
9352
+ // to make it re-entrance safe in case destroy() is called within callbacks
9401
9353
 
9402
- const rState = stream._readableState;
9403
- const wState = stream._writableState;
9404
- if (rState && rState.autoDestroy || wState && wState.autoDestroy) stream.destroy(err);else stream.emit('error', err);
9354
+ if (this._readableState) {
9355
+ this._readableState.destroyed = true;
9356
+ }
9357
+
9358
+ // if this is a duplex stream mark the writable part as destroyed as well
9359
+ if (this._writableState) {
9360
+ this._writableState.destroyed = true;
9361
+ }
9362
+ this._destroy(err || null, err => {
9363
+ if (!cb && err) {
9364
+ if (!this._writableState) {
9365
+ process.nextTick(emitErrorAndCloseNT, this, err);
9366
+ } else if (!this._writableState.errorEmitted) {
9367
+ this._writableState.errorEmitted = true;
9368
+ process.nextTick(emitErrorAndCloseNT, this, err);
9369
+ } else {
9370
+ process.nextTick(emitCloseNT, this);
9371
+ }
9372
+ } else if (cb) {
9373
+ process.nextTick(emitCloseNT, this);
9374
+ cb(err);
9375
+ } else {
9376
+ process.nextTick(emitCloseNT, this);
9377
+ }
9378
+ });
9379
+ return this;
9380
+ }
9381
+ function emitErrorAndCloseNT(self, err) {
9382
+ emitErrorNT(self, err);
9383
+ emitCloseNT(self);
9384
+ }
9385
+ function emitCloseNT(self) {
9386
+ if (self._writableState && !self._writableState.emitClose) return;
9387
+ if (self._readableState && !self._readableState.emitClose) return;
9388
+ self.emit('close');
9389
+ }
9390
+ function undestroy() {
9391
+ if (this._readableState) {
9392
+ this._readableState.destroyed = false;
9393
+ this._readableState.reading = false;
9394
+ this._readableState.ended = false;
9395
+ this._readableState.endEmitted = false;
9396
+ }
9397
+ if (this._writableState) {
9398
+ this._writableState.destroyed = false;
9399
+ this._writableState.ended = false;
9400
+ this._writableState.ending = false;
9401
+ this._writableState.finalCalled = false;
9402
+ this._writableState.prefinished = false;
9403
+ this._writableState.finished = false;
9404
+ this._writableState.errorEmitted = false;
9405
+ }
9406
+ }
9407
+ function emitErrorNT(self, err) {
9408
+ self.emit('error', err);
9409
+ }
9410
+ function errorOrDestroy(stream, err) {
9411
+ // We have tests that rely on errors being emitted
9412
+ // in the same tick, so changing this is semver major.
9413
+ // For now when you opt-in to autoDestroy we allow
9414
+ // the error to be emitted nextTick. In a future
9415
+ // semver major update we should change the default to this.
9416
+
9417
+ const rState = stream._readableState;
9418
+ const wState = stream._writableState;
9419
+ if (rState && rState.autoDestroy || wState && wState.autoDestroy) stream.destroy(err);else stream.emit('error', err);
9420
+ }
9421
+ destroy_1 = {
9422
+ destroy,
9423
+ undestroy,
9424
+ errorOrDestroy
9425
+ };
9426
+ return destroy_1;
9405
9427
  }
9406
- var destroy_1 = {
9407
- destroy,
9408
- undestroy,
9409
- errorOrDestroy
9410
- };
9411
9428
 
9412
9429
  var errorsBrowser = {};
9413
9430
 
@@ -9537,92 +9554,109 @@ createErrorType('ERR_UNKNOWN_ENCODING', function (arg) {
9537
9554
  createErrorType('ERR_STREAM_UNSHIFT_AFTER_END_EVENT', 'stream.unshift() after end event');
9538
9555
  errorsBrowser.codes = codes;
9539
9556
 
9540
- const ERR_INVALID_OPT_VALUE = errorsBrowser.codes.ERR_INVALID_OPT_VALUE;
9541
- function highWaterMarkFrom(options, isDuplex, duplexKey) {
9542
- return options.highWaterMark != null ? options.highWaterMark : isDuplex ? options[duplexKey] : null;
9543
- }
9544
- function getHighWaterMark(state, options, duplexKey, isDuplex) {
9545
- const hwm = highWaterMarkFrom(options, isDuplex, duplexKey);
9546
- if (hwm != null) {
9547
- if (!(isFinite(hwm) && Math.floor(hwm) === hwm) || hwm < 0) {
9548
- const name = isDuplex ? duplexKey : 'highWaterMark';
9549
- throw new ERR_INVALID_OPT_VALUE(name, hwm);
9550
- }
9551
- return Math.floor(hwm);
9552
- }
9557
+ var state;
9558
+ var hasRequiredState;
9559
+
9560
+ function requireState () {
9561
+ if (hasRequiredState) return state;
9562
+ hasRequiredState = 1;
9553
9563
 
9554
- // Default value
9555
- return state.objectMode ? 16 : 16 * 1024;
9564
+ const ERR_INVALID_OPT_VALUE = errorsBrowser.codes.ERR_INVALID_OPT_VALUE;
9565
+ function highWaterMarkFrom(options, isDuplex, duplexKey) {
9566
+ return options.highWaterMark != null ? options.highWaterMark : isDuplex ? options[duplexKey] : null;
9567
+ }
9568
+ function getHighWaterMark(state, options, duplexKey, isDuplex) {
9569
+ const hwm = highWaterMarkFrom(options, isDuplex, duplexKey);
9570
+ if (hwm != null) {
9571
+ if (!(isFinite(hwm) && Math.floor(hwm) === hwm) || hwm < 0) {
9572
+ const name = isDuplex ? duplexKey : 'highWaterMark';
9573
+ throw new ERR_INVALID_OPT_VALUE(name, hwm);
9574
+ }
9575
+ return Math.floor(hwm);
9576
+ }
9577
+
9578
+ // Default value
9579
+ return state.objectMode ? 16 : 16 * 1024;
9580
+ }
9581
+ state = {
9582
+ getHighWaterMark
9583
+ };
9584
+ return state;
9556
9585
  }
9557
- var state = {
9558
- getHighWaterMark
9559
- };
9560
9586
 
9561
- /**
9562
- * Module exports.
9563
- */
9587
+ var browser$b;
9588
+ var hasRequiredBrowser$a;
9564
9589
 
9565
- var browser$b = deprecate;
9590
+ function requireBrowser$a () {
9591
+ if (hasRequiredBrowser$a) return browser$b;
9592
+ hasRequiredBrowser$a = 1;
9593
+ /**
9594
+ * Module exports.
9595
+ */
9566
9596
 
9567
- /**
9568
- * Mark that a method should not be used.
9569
- * Returns a modified function which warns once by default.
9570
- *
9571
- * If `localStorage.noDeprecation = true` is set, then it is a no-op.
9572
- *
9573
- * If `localStorage.throwDeprecation = true` is set, then deprecated functions
9574
- * will throw an Error when invoked.
9575
- *
9576
- * If `localStorage.traceDeprecation = true` is set, then deprecated functions
9577
- * will invoke `console.trace()` instead of `console.error()`.
9578
- *
9579
- * @param {Function} fn - the function to deprecate
9580
- * @param {String} msg - the string to print to the console when `fn` is invoked
9581
- * @returns {Function} a new "deprecated" version of `fn`
9582
- * @api public
9583
- */
9597
+ browser$b = deprecate;
9584
9598
 
9585
- function deprecate (fn, msg) {
9586
- if (config('noDeprecation')) {
9587
- return fn;
9588
- }
9599
+ /**
9600
+ * Mark that a method should not be used.
9601
+ * Returns a modified function which warns once by default.
9602
+ *
9603
+ * If `localStorage.noDeprecation = true` is set, then it is a no-op.
9604
+ *
9605
+ * If `localStorage.throwDeprecation = true` is set, then deprecated functions
9606
+ * will throw an Error when invoked.
9607
+ *
9608
+ * If `localStorage.traceDeprecation = true` is set, then deprecated functions
9609
+ * will invoke `console.trace()` instead of `console.error()`.
9610
+ *
9611
+ * @param {Function} fn - the function to deprecate
9612
+ * @param {String} msg - the string to print to the console when `fn` is invoked
9613
+ * @returns {Function} a new "deprecated" version of `fn`
9614
+ * @api public
9615
+ */
9589
9616
 
9590
- var warned = false;
9591
- function deprecated() {
9592
- if (!warned) {
9593
- if (config('throwDeprecation')) {
9594
- throw new Error(msg);
9595
- } else if (config('traceDeprecation')) {
9596
- console.trace(msg);
9597
- } else {
9598
- console.warn(msg);
9599
- }
9600
- warned = true;
9601
- }
9602
- return fn.apply(this, arguments);
9603
- }
9617
+ function deprecate (fn, msg) {
9618
+ if (config('noDeprecation')) {
9619
+ return fn;
9620
+ }
9604
9621
 
9605
- return deprecated;
9606
- }
9622
+ var warned = false;
9623
+ function deprecated() {
9624
+ if (!warned) {
9625
+ if (config('throwDeprecation')) {
9626
+ throw new Error(msg);
9627
+ } else if (config('traceDeprecation')) {
9628
+ console.trace(msg);
9629
+ } else {
9630
+ console.warn(msg);
9631
+ }
9632
+ warned = true;
9633
+ }
9634
+ return fn.apply(this, arguments);
9635
+ }
9607
9636
 
9608
- /**
9609
- * Checks `localStorage` for boolean values for the given `name`.
9610
- *
9611
- * @param {String} name
9612
- * @returns {Boolean}
9613
- * @api private
9614
- */
9637
+ return deprecated;
9638
+ }
9615
9639
 
9616
- function config (name) {
9617
- // accessing global.localStorage can trigger a DOMException in sandboxed iframes
9618
- try {
9619
- if (!commonjsGlobal.localStorage) return false;
9620
- } catch (_) {
9621
- return false;
9622
- }
9623
- var val = commonjsGlobal.localStorage[name];
9624
- if (null == val) return false;
9625
- return String(val).toLowerCase() === 'true';
9640
+ /**
9641
+ * Checks `localStorage` for boolean values for the given `name`.
9642
+ *
9643
+ * @param {String} name
9644
+ * @returns {Boolean}
9645
+ * @api private
9646
+ */
9647
+
9648
+ function config (name) {
9649
+ // accessing global.localStorage can trigger a DOMException in sandboxed iframes
9650
+ try {
9651
+ if (!commonjsGlobal.localStorage) return false;
9652
+ } catch (_) {
9653
+ return false;
9654
+ }
9655
+ var val = commonjsGlobal.localStorage[name];
9656
+ if (null == val) return false;
9657
+ return String(val).toLowerCase() === 'true';
9658
+ }
9659
+ return browser$b;
9626
9660
  }
9627
9661
 
9628
9662
  var _stream_writable;
@@ -9653,12 +9687,12 @@ function require_stream_writable () {
9653
9687
 
9654
9688
  /*<replacement>*/
9655
9689
  const internalUtil = {
9656
- deprecate: browser$b
9690
+ deprecate: requireBrowser$a()
9657
9691
  };
9658
9692
  /*</replacement>*/
9659
9693
 
9660
9694
  /*<replacement>*/
9661
- var Stream = streamBrowser;
9695
+ var Stream = requireStreamBrowser();
9662
9696
  /*</replacement>*/
9663
9697
 
9664
9698
  const Buffer = require$$6$1.Buffer;
@@ -9669,8 +9703,8 @@ function require_stream_writable () {
9669
9703
  function _isUint8Array(obj) {
9670
9704
  return Buffer.isBuffer(obj) || obj instanceof OurUint8Array;
9671
9705
  }
9672
- const destroyImpl = destroy_1;
9673
- const _require = state,
9706
+ const destroyImpl = requireDestroy();
9707
+ const _require = requireState(),
9674
9708
  getHighWaterMark = _require.getHighWaterMark;
9675
9709
  const _require$codes = errorsBrowser.codes,
9676
9710
  ERR_INVALID_ARG_TYPE = _require$codes.ERR_INVALID_ARG_TYPE,
@@ -10864,7 +10898,7 @@ function require_stream_readable () {
10864
10898
  /*</replacement>*/
10865
10899
 
10866
10900
  /*<replacement>*/
10867
- var Stream = streamBrowser;
10901
+ var Stream = requireStreamBrowser();
10868
10902
  /*</replacement>*/
10869
10903
 
10870
10904
  const Buffer = require$$6$1.Buffer;
@@ -10887,8 +10921,8 @@ function require_stream_readable () {
10887
10921
  /*</replacement>*/
10888
10922
 
10889
10923
  const BufferList = requireBuffer_list();
10890
- const destroyImpl = destroy_1;
10891
- const _require = state,
10924
+ const destroyImpl = requireDestroy();
10925
+ const _require = requireState(),
10892
10926
  getHighWaterMark = _require.getHighWaterMark;
10893
10927
  const _require$codes = errorsBrowser.codes,
10894
10928
  ERR_INVALID_ARG_TYPE = _require$codes.ERR_INVALID_ARG_TYPE,
@@ -14341,7 +14375,7 @@ function WriteReq(chunk, encoding, cb) {
14341
14375
 
14342
14376
  function WritableState(options, stream) {
14343
14377
  Object.defineProperty(this, 'buffer', {
14344
- get: deprecate$1(function () {
14378
+ get: deprecate(function () {
14345
14379
  return this.getBuffer();
14346
14380
  }, '_writableState.buffer is deprecated. Use _writableState.getBuffer ' + 'instead.')
14347
14381
  });
@@ -38908,6 +38942,7 @@ class Base {
38908
38942
  lastCid: clock[0],
38909
38943
  get: cid => allBlocks.get(cid.toString())
38910
38944
  };
38945
+ console.log('compact', this.instanceId, this.name, blocks.lastCid.toString(), dataCids.length);
38911
38946
  await this.parkCar(blocks, dataCids);
38912
38947
  }
38913
38948
 
@@ -39052,6 +39087,7 @@ class Base {
39052
39087
 
39053
39088
  async mapForIPLDHashmapCarCid (carCid) {
39054
39089
  // console.log('mapForIPLDHashmapCarCid', carCid)
39090
+ // todo why is this writeable?
39055
39091
  const carMapReader = await this.getWriteableCarReader(carCid);
39056
39092
  const indexNode = await load$1(carMapReader, carMapReader.root.cid, {
39057
39093
  blockHasher: blockOpts$1.hasher,
@@ -39090,7 +39126,21 @@ class Base {
39090
39126
  return combinedReader
39091
39127
  }
39092
39128
 
39129
+ async xgetCarReader (carCid) {
39130
+ return this.getCarReaderImpl(carCid)
39131
+ }
39132
+
39133
+ carReaderCache = new Map()
39093
39134
  async getCarReader (carCid) {
39135
+ if (this.carReaderCache.has(carCid)) {
39136
+ return this.carReaderCache.get(carCid)
39137
+ }
39138
+ const result = await this.getCarReaderImpl(carCid);
39139
+ this.carReaderCache.set(carCid, result);
39140
+ return result
39141
+ }
39142
+
39143
+ async getCarReaderImpl (carCid) {
39094
39144
  carCid = carCid.toString();
39095
39145
  const carBytes = await this.readCar(carCid);
39096
39146
  // console.log('getCarReader', this.constructor.name, carCid, carBytes.length)
@@ -40081,19 +40131,6 @@ class Valet {
40081
40131
  }
40082
40132
  }
40083
40133
 
40084
- // async compact() {
40085
- // const carCids = []
40086
- // // for await (const { cid } of this.valet.cids()) {
40087
- // // yield { cid }
40088
- // // }
40089
- // // create a blockstore with all data
40090
- // {
40091
- // entries: () => syncCIDs.map(cid => ({ cid })),
40092
- // get: async cid => await blocks.get(cid)
40093
- // }
40094
- // // park it
40095
- // }
40096
-
40097
40134
  /**
40098
40135
  * Iterate over all blocks in the store.
40099
40136
  *