@fireproof/core 0.5.3 → 0.5.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.
- package/dist/src/fireproof.d.ts +3 -2
- package/dist/src/fireproof.js +199 -227
- package/dist/src/fireproof.js.map +1 -1
- package/dist/src/fireproof.mjs +199 -227
- package/dist/src/fireproof.mjs.map +1 -1
- package/package.json +1 -1
- package/src/database.js +2 -0
- package/src/db-index.js +12 -7
- package/src/fireproof.js +5 -6
- package/src/listener.js +2 -2
package/dist/src/fireproof.mjs
CHANGED
@@ -9539,15 +9539,7 @@ var _polyfillNode_events = /*#__PURE__*/Object.freeze({
|
|
9539
9539
|
|
9540
9540
|
var require$$0$1 = /*@__PURE__*/getAugmentedNamespace(_polyfillNode_events);
|
9541
9541
|
|
9542
|
-
var streamBrowser;
|
9543
|
-
var hasRequiredStreamBrowser;
|
9544
|
-
|
9545
|
-
function requireStreamBrowser () {
|
9546
|
-
if (hasRequiredStreamBrowser) return streamBrowser;
|
9547
|
-
hasRequiredStreamBrowser = 1;
|
9548
|
-
streamBrowser = require$$0$1.EventEmitter;
|
9549
|
-
return streamBrowser;
|
9550
|
-
}
|
9542
|
+
var streamBrowser = require$$0$1.EventEmitter;
|
9551
9543
|
|
9552
9544
|
// shim for using process in browser
|
9553
9545
|
// based off https://github.com/defunctzombie/node-process/blob/master/browser.js
|
@@ -9690,7 +9682,7 @@ var argv = [];
|
|
9690
9682
|
var version$2 = ''; // empty string to avoid regexp issues
|
9691
9683
|
var versions = {};
|
9692
9684
|
var release = {};
|
9693
|
-
var config = {};
|
9685
|
+
var config$1 = {};
|
9694
9686
|
|
9695
9687
|
function noop$2() {}
|
9696
9688
|
|
@@ -9767,7 +9759,7 @@ var browser$1$1 = {
|
|
9767
9759
|
hrtime: hrtime,
|
9768
9760
|
platform: platform,
|
9769
9761
|
release: release,
|
9770
|
-
config: config,
|
9762
|
+
config: config$1,
|
9771
9763
|
uptime: uptime
|
9772
9764
|
};
|
9773
9765
|
|
@@ -9848,11 +9840,11 @@ function format(f) {
|
|
9848
9840
|
// Mark that a method should not be used.
|
9849
9841
|
// Returns a modified function which warns once by default.
|
9850
9842
|
// If --no-deprecation is set, then it is a no-op.
|
9851
|
-
function deprecate$
|
9843
|
+
function deprecate$2(fn, msg) {
|
9852
9844
|
// Allow for deprecating things in the process of starting up.
|
9853
9845
|
if (isUndefined(global$1.process)) {
|
9854
9846
|
return function() {
|
9855
|
-
return deprecate$
|
9847
|
+
return deprecate$2(fn, msg).apply(this, arguments);
|
9856
9848
|
};
|
9857
9849
|
}
|
9858
9850
|
|
@@ -10461,7 +10453,7 @@ var _polyfillNode_util = {
|
|
10461
10453
|
isBoolean: isBoolean,
|
10462
10454
|
isArray: isArray,
|
10463
10455
|
inspect: inspect,
|
10464
|
-
deprecate: deprecate$
|
10456
|
+
deprecate: deprecate$2,
|
10465
10457
|
format: format,
|
10466
10458
|
debuglog: debuglog,
|
10467
10459
|
promisify: promisify,
|
@@ -10474,7 +10466,7 @@ var _polyfillNode_util$1 = /*#__PURE__*/Object.freeze({
|
|
10474
10466
|
callbackify: callbackify,
|
10475
10467
|
debuglog: debuglog,
|
10476
10468
|
default: _polyfillNode_util,
|
10477
|
-
deprecate: deprecate$
|
10469
|
+
deprecate: deprecate$2,
|
10478
10470
|
format: format,
|
10479
10471
|
inherits: inherits$w,
|
10480
10472
|
inspect: inspect,
|
@@ -10662,108 +10654,99 @@ function requireBuffer_list () {
|
|
10662
10654
|
return buffer_list;
|
10663
10655
|
}
|
10664
10656
|
|
10665
|
-
|
10666
|
-
|
10667
|
-
|
10668
|
-
|
10669
|
-
|
10670
|
-
|
10671
|
-
|
10672
|
-
|
10673
|
-
|
10674
|
-
|
10675
|
-
|
10676
|
-
|
10677
|
-
|
10678
|
-
|
10679
|
-
|
10680
|
-
|
10681
|
-
|
10682
|
-
} else if (!this._writableState.errorEmitted) {
|
10683
|
-
this._writableState.errorEmitted = true;
|
10684
|
-
process.nextTick(emitErrorNT, this, err);
|
10685
|
-
}
|
10686
|
-
}
|
10687
|
-
return this;
|
10688
|
-
}
|
10657
|
+
// undocumented cb() API, needed for core, not for public API
|
10658
|
+
function destroy(err, cb) {
|
10659
|
+
const readableDestroyed = this._readableState && this._readableState.destroyed;
|
10660
|
+
const writableDestroyed = this._writableState && this._writableState.destroyed;
|
10661
|
+
if (readableDestroyed || writableDestroyed) {
|
10662
|
+
if (cb) {
|
10663
|
+
cb(err);
|
10664
|
+
} else if (err) {
|
10665
|
+
if (!this._writableState) {
|
10666
|
+
process.nextTick(emitErrorNT, this, err);
|
10667
|
+
} else if (!this._writableState.errorEmitted) {
|
10668
|
+
this._writableState.errorEmitted = true;
|
10669
|
+
process.nextTick(emitErrorNT, this, err);
|
10670
|
+
}
|
10671
|
+
}
|
10672
|
+
return this;
|
10673
|
+
}
|
10689
10674
|
|
10690
|
-
|
10691
|
-
|
10675
|
+
// we set destroyed to true before firing error callbacks in order
|
10676
|
+
// to make it re-entrance safe in case destroy() is called within callbacks
|
10692
10677
|
|
10693
|
-
|
10694
|
-
|
10695
|
-
|
10678
|
+
if (this._readableState) {
|
10679
|
+
this._readableState.destroyed = true;
|
10680
|
+
}
|
10696
10681
|
|
10697
|
-
|
10698
|
-
|
10699
|
-
|
10700
|
-
|
10701
|
-
|
10702
|
-
|
10703
|
-
|
10704
|
-
|
10705
|
-
|
10706
|
-
|
10707
|
-
|
10708
|
-
|
10709
|
-
|
10710
|
-
|
10711
|
-
|
10712
|
-
|
10713
|
-
|
10714
|
-
|
10715
|
-
|
10716
|
-
|
10717
|
-
|
10718
|
-
|
10719
|
-
|
10720
|
-
|
10721
|
-
|
10722
|
-
|
10723
|
-
|
10724
|
-
|
10725
|
-
|
10726
|
-
|
10727
|
-
|
10728
|
-
|
10729
|
-
|
10730
|
-
|
10731
|
-
|
10732
|
-
|
10733
|
-
|
10734
|
-
|
10735
|
-
|
10736
|
-
|
10737
|
-
|
10738
|
-
|
10739
|
-
|
10740
|
-
|
10741
|
-
|
10742
|
-
|
10743
|
-
|
10744
|
-
|
10745
|
-
|
10746
|
-
|
10747
|
-
|
10748
|
-
}
|
10749
|
-
function errorOrDestroy(stream, err) {
|
10750
|
-
// We have tests that rely on errors being emitted
|
10751
|
-
// in the same tick, so changing this is semver major.
|
10752
|
-
// For now when you opt-in to autoDestroy we allow
|
10753
|
-
// the error to be emitted nextTick. In a future
|
10754
|
-
// semver major update we should change the default to this.
|
10755
|
-
|
10756
|
-
const rState = stream._readableState;
|
10757
|
-
const wState = stream._writableState;
|
10758
|
-
if (rState && rState.autoDestroy || wState && wState.autoDestroy) stream.destroy(err);else stream.emit('error', err);
|
10759
|
-
}
|
10760
|
-
destroy_1 = {
|
10761
|
-
destroy,
|
10762
|
-
undestroy,
|
10763
|
-
errorOrDestroy
|
10764
|
-
};
|
10765
|
-
return destroy_1;
|
10682
|
+
// if this is a duplex stream mark the writable part as destroyed as well
|
10683
|
+
if (this._writableState) {
|
10684
|
+
this._writableState.destroyed = true;
|
10685
|
+
}
|
10686
|
+
this._destroy(err || null, err => {
|
10687
|
+
if (!cb && err) {
|
10688
|
+
if (!this._writableState) {
|
10689
|
+
process.nextTick(emitErrorAndCloseNT, this, err);
|
10690
|
+
} else if (!this._writableState.errorEmitted) {
|
10691
|
+
this._writableState.errorEmitted = true;
|
10692
|
+
process.nextTick(emitErrorAndCloseNT, this, err);
|
10693
|
+
} else {
|
10694
|
+
process.nextTick(emitCloseNT, this);
|
10695
|
+
}
|
10696
|
+
} else if (cb) {
|
10697
|
+
process.nextTick(emitCloseNT, this);
|
10698
|
+
cb(err);
|
10699
|
+
} else {
|
10700
|
+
process.nextTick(emitCloseNT, this);
|
10701
|
+
}
|
10702
|
+
});
|
10703
|
+
return this;
|
10704
|
+
}
|
10705
|
+
function emitErrorAndCloseNT(self, err) {
|
10706
|
+
emitErrorNT(self, err);
|
10707
|
+
emitCloseNT(self);
|
10708
|
+
}
|
10709
|
+
function emitCloseNT(self) {
|
10710
|
+
if (self._writableState && !self._writableState.emitClose) return;
|
10711
|
+
if (self._readableState && !self._readableState.emitClose) return;
|
10712
|
+
self.emit('close');
|
10713
|
+
}
|
10714
|
+
function undestroy() {
|
10715
|
+
if (this._readableState) {
|
10716
|
+
this._readableState.destroyed = false;
|
10717
|
+
this._readableState.reading = false;
|
10718
|
+
this._readableState.ended = false;
|
10719
|
+
this._readableState.endEmitted = false;
|
10720
|
+
}
|
10721
|
+
if (this._writableState) {
|
10722
|
+
this._writableState.destroyed = false;
|
10723
|
+
this._writableState.ended = false;
|
10724
|
+
this._writableState.ending = false;
|
10725
|
+
this._writableState.finalCalled = false;
|
10726
|
+
this._writableState.prefinished = false;
|
10727
|
+
this._writableState.finished = false;
|
10728
|
+
this._writableState.errorEmitted = false;
|
10729
|
+
}
|
10730
|
+
}
|
10731
|
+
function emitErrorNT(self, err) {
|
10732
|
+
self.emit('error', err);
|
10766
10733
|
}
|
10734
|
+
function errorOrDestroy(stream, err) {
|
10735
|
+
// We have tests that rely on errors being emitted
|
10736
|
+
// in the same tick, so changing this is semver major.
|
10737
|
+
// For now when you opt-in to autoDestroy we allow
|
10738
|
+
// the error to be emitted nextTick. In a future
|
10739
|
+
// semver major update we should change the default to this.
|
10740
|
+
|
10741
|
+
const rState = stream._readableState;
|
10742
|
+
const wState = stream._writableState;
|
10743
|
+
if (rState && rState.autoDestroy || wState && wState.autoDestroy) stream.destroy(err);else stream.emit('error', err);
|
10744
|
+
}
|
10745
|
+
var destroy_1 = {
|
10746
|
+
destroy,
|
10747
|
+
undestroy,
|
10748
|
+
errorOrDestroy
|
10749
|
+
};
|
10767
10750
|
|
10768
10751
|
var errorsBrowser = {};
|
10769
10752
|
|
@@ -10893,109 +10876,92 @@ createErrorType('ERR_UNKNOWN_ENCODING', function (arg) {
|
|
10893
10876
|
createErrorType('ERR_STREAM_UNSHIFT_AFTER_END_EVENT', 'stream.unshift() after end event');
|
10894
10877
|
errorsBrowser.codes = codes;
|
10895
10878
|
|
10896
|
-
|
10897
|
-
|
10898
|
-
|
10899
|
-
function requireState () {
|
10900
|
-
if (hasRequiredState) return state;
|
10901
|
-
hasRequiredState = 1;
|
10902
|
-
|
10903
|
-
const ERR_INVALID_OPT_VALUE = errorsBrowser.codes.ERR_INVALID_OPT_VALUE;
|
10904
|
-
function highWaterMarkFrom(options, isDuplex, duplexKey) {
|
10905
|
-
return options.highWaterMark != null ? options.highWaterMark : isDuplex ? options[duplexKey] : null;
|
10906
|
-
}
|
10907
|
-
function getHighWaterMark(state, options, duplexKey, isDuplex) {
|
10908
|
-
const hwm = highWaterMarkFrom(options, isDuplex, duplexKey);
|
10909
|
-
if (hwm != null) {
|
10910
|
-
if (!(isFinite(hwm) && Math.floor(hwm) === hwm) || hwm < 0) {
|
10911
|
-
const name = isDuplex ? duplexKey : 'highWaterMark';
|
10912
|
-
throw new ERR_INVALID_OPT_VALUE(name, hwm);
|
10913
|
-
}
|
10914
|
-
return Math.floor(hwm);
|
10915
|
-
}
|
10916
|
-
|
10917
|
-
// Default value
|
10918
|
-
return state.objectMode ? 16 : 16 * 1024;
|
10919
|
-
}
|
10920
|
-
state = {
|
10921
|
-
getHighWaterMark
|
10922
|
-
};
|
10923
|
-
return state;
|
10879
|
+
const ERR_INVALID_OPT_VALUE = errorsBrowser.codes.ERR_INVALID_OPT_VALUE;
|
10880
|
+
function highWaterMarkFrom(options, isDuplex, duplexKey) {
|
10881
|
+
return options.highWaterMark != null ? options.highWaterMark : isDuplex ? options[duplexKey] : null;
|
10924
10882
|
}
|
10883
|
+
function getHighWaterMark(state, options, duplexKey, isDuplex) {
|
10884
|
+
const hwm = highWaterMarkFrom(options, isDuplex, duplexKey);
|
10885
|
+
if (hwm != null) {
|
10886
|
+
if (!(isFinite(hwm) && Math.floor(hwm) === hwm) || hwm < 0) {
|
10887
|
+
const name = isDuplex ? duplexKey : 'highWaterMark';
|
10888
|
+
throw new ERR_INVALID_OPT_VALUE(name, hwm);
|
10889
|
+
}
|
10890
|
+
return Math.floor(hwm);
|
10891
|
+
}
|
10925
10892
|
|
10926
|
-
|
10927
|
-
|
10893
|
+
// Default value
|
10894
|
+
return state.objectMode ? 16 : 16 * 1024;
|
10895
|
+
}
|
10896
|
+
var state = {
|
10897
|
+
getHighWaterMark
|
10898
|
+
};
|
10928
10899
|
|
10929
|
-
|
10930
|
-
|
10931
|
-
|
10932
|
-
/**
|
10933
|
-
* Module exports.
|
10934
|
-
*/
|
10900
|
+
/**
|
10901
|
+
* Module exports.
|
10902
|
+
*/
|
10935
10903
|
|
10936
|
-
|
10904
|
+
var browser$a = deprecate$1;
|
10937
10905
|
|
10938
|
-
|
10939
|
-
|
10940
|
-
|
10941
|
-
|
10942
|
-
|
10943
|
-
|
10944
|
-
|
10945
|
-
|
10946
|
-
|
10947
|
-
|
10948
|
-
|
10949
|
-
|
10950
|
-
|
10951
|
-
|
10952
|
-
|
10953
|
-
|
10954
|
-
|
10906
|
+
/**
|
10907
|
+
* Mark that a method should not be used.
|
10908
|
+
* Returns a modified function which warns once by default.
|
10909
|
+
*
|
10910
|
+
* If `localStorage.noDeprecation = true` is set, then it is a no-op.
|
10911
|
+
*
|
10912
|
+
* If `localStorage.throwDeprecation = true` is set, then deprecated functions
|
10913
|
+
* will throw an Error when invoked.
|
10914
|
+
*
|
10915
|
+
* If `localStorage.traceDeprecation = true` is set, then deprecated functions
|
10916
|
+
* will invoke `console.trace()` instead of `console.error()`.
|
10917
|
+
*
|
10918
|
+
* @param {Function} fn - the function to deprecate
|
10919
|
+
* @param {String} msg - the string to print to the console when `fn` is invoked
|
10920
|
+
* @returns {Function} a new "deprecated" version of `fn`
|
10921
|
+
* @api public
|
10922
|
+
*/
|
10955
10923
|
|
10956
|
-
|
10957
|
-
|
10958
|
-
|
10959
|
-
|
10924
|
+
function deprecate$1 (fn, msg) {
|
10925
|
+
if (config('noDeprecation')) {
|
10926
|
+
return fn;
|
10927
|
+
}
|
10960
10928
|
|
10961
|
-
|
10962
|
-
|
10963
|
-
|
10964
|
-
|
10965
|
-
|
10966
|
-
|
10967
|
-
|
10968
|
-
|
10969
|
-
|
10970
|
-
|
10971
|
-
|
10972
|
-
|
10973
|
-
|
10974
|
-
|
10929
|
+
var warned = false;
|
10930
|
+
function deprecated() {
|
10931
|
+
if (!warned) {
|
10932
|
+
if (config('throwDeprecation')) {
|
10933
|
+
throw new Error(msg);
|
10934
|
+
} else if (config('traceDeprecation')) {
|
10935
|
+
console.trace(msg);
|
10936
|
+
} else {
|
10937
|
+
console.warn(msg);
|
10938
|
+
}
|
10939
|
+
warned = true;
|
10940
|
+
}
|
10941
|
+
return fn.apply(this, arguments);
|
10942
|
+
}
|
10975
10943
|
|
10976
|
-
|
10977
|
-
|
10944
|
+
return deprecated;
|
10945
|
+
}
|
10978
10946
|
|
10979
|
-
|
10980
|
-
|
10981
|
-
|
10982
|
-
|
10983
|
-
|
10984
|
-
|
10985
|
-
|
10947
|
+
/**
|
10948
|
+
* Checks `localStorage` for boolean values for the given `name`.
|
10949
|
+
*
|
10950
|
+
* @param {String} name
|
10951
|
+
* @returns {Boolean}
|
10952
|
+
* @api private
|
10953
|
+
*/
|
10986
10954
|
|
10987
|
-
|
10988
|
-
|
10989
|
-
|
10990
|
-
|
10991
|
-
|
10992
|
-
|
10993
|
-
|
10994
|
-
|
10995
|
-
|
10996
|
-
|
10997
|
-
}
|
10998
|
-
return browser$a;
|
10955
|
+
function config (name) {
|
10956
|
+
// accessing global.localStorage can trigger a DOMException in sandboxed iframes
|
10957
|
+
try {
|
10958
|
+
if (!commonjsGlobal.localStorage) return false;
|
10959
|
+
} catch (_) {
|
10960
|
+
return false;
|
10961
|
+
}
|
10962
|
+
var val = commonjsGlobal.localStorage[name];
|
10963
|
+
if (null == val) return false;
|
10964
|
+
return String(val).toLowerCase() === 'true';
|
10999
10965
|
}
|
11000
10966
|
|
11001
10967
|
var _stream_writable;
|
@@ -11026,12 +10992,12 @@ function require_stream_writable () {
|
|
11026
10992
|
|
11027
10993
|
/*<replacement>*/
|
11028
10994
|
const internalUtil = {
|
11029
|
-
deprecate:
|
10995
|
+
deprecate: browser$a
|
11030
10996
|
};
|
11031
10997
|
/*</replacement>*/
|
11032
10998
|
|
11033
10999
|
/*<replacement>*/
|
11034
|
-
var Stream =
|
11000
|
+
var Stream = streamBrowser;
|
11035
11001
|
/*</replacement>*/
|
11036
11002
|
|
11037
11003
|
const Buffer = require$$0$2.Buffer;
|
@@ -11042,8 +11008,8 @@ function require_stream_writable () {
|
|
11042
11008
|
function _isUint8Array(obj) {
|
11043
11009
|
return Buffer.isBuffer(obj) || obj instanceof OurUint8Array;
|
11044
11010
|
}
|
11045
|
-
const destroyImpl =
|
11046
|
-
const _require =
|
11011
|
+
const destroyImpl = destroy_1;
|
11012
|
+
const _require = state,
|
11047
11013
|
getHighWaterMark = _require.getHighWaterMark;
|
11048
11014
|
const _require$codes = errorsBrowser.codes,
|
11049
11015
|
ERR_INVALID_ARG_TYPE = _require$codes.ERR_INVALID_ARG_TYPE,
|
@@ -12237,7 +12203,7 @@ function require_stream_readable () {
|
|
12237
12203
|
/*</replacement>*/
|
12238
12204
|
|
12239
12205
|
/*<replacement>*/
|
12240
|
-
var Stream =
|
12206
|
+
var Stream = streamBrowser;
|
12241
12207
|
/*</replacement>*/
|
12242
12208
|
|
12243
12209
|
const Buffer = require$$0$2.Buffer;
|
@@ -12260,8 +12226,8 @@ function require_stream_readable () {
|
|
12260
12226
|
/*</replacement>*/
|
12261
12227
|
|
12262
12228
|
const BufferList = requireBuffer_list();
|
12263
|
-
const destroyImpl =
|
12264
|
-
const _require =
|
12229
|
+
const destroyImpl = destroy_1;
|
12230
|
+
const _require = state,
|
12265
12231
|
getHighWaterMark = _require.getHighWaterMark;
|
12266
12232
|
const _require$codes = errorsBrowser.codes,
|
12267
12233
|
ERR_INVALID_ARG_TYPE = _require$codes.ERR_INVALID_ARG_TYPE,
|
@@ -15627,7 +15593,7 @@ function WriteReq(chunk, encoding, cb) {
|
|
15627
15593
|
|
15628
15594
|
function WritableState(options, stream) {
|
15629
15595
|
Object.defineProperty(this, 'buffer', {
|
15630
|
-
get: deprecate$
|
15596
|
+
get: deprecate$2(function () {
|
15631
15597
|
return this.getBuffer();
|
15632
15598
|
}, '_writableState.buffer is deprecated. Use _writableState.getBuffer ' + 'instead.')
|
15633
15599
|
});
|
@@ -38027,6 +37993,7 @@ function localSet (key, value) {
|
|
38027
37993
|
}
|
38028
37994
|
|
38029
37995
|
// @ts-nocheck
|
37996
|
+
const parseCID = cid => (typeof cid === 'string' ? CID$1.parse(cid) : cid);
|
38030
37997
|
|
38031
37998
|
/**
|
38032
37999
|
* @class Fireproof
|
@@ -38416,9 +38383,9 @@ class Listener {
|
|
38416
38383
|
* @returns {Function} A function to unsubscribe from the topic.
|
38417
38384
|
* @memberof Listener
|
38418
38385
|
* @instance
|
38419
|
-
* @param {any} since
|
38386
|
+
* @param {any} [since] - clock to flush from on launch
|
38420
38387
|
*/
|
38421
|
-
on (topic, subscriber, since) {
|
38388
|
+
on (topic, subscriber, since = undefined) {
|
38422
38389
|
const listOfTopicSubscribers = getTopicList(this.subcribers, topic);
|
38423
38390
|
listOfTopicSubscribers.push(subscriber);
|
38424
38391
|
if (typeof since !== 'undefined') {
|
@@ -38833,7 +38800,7 @@ class DbIndex {
|
|
38833
38800
|
let removeByIdIndexEntries = [];
|
38834
38801
|
await loadIndex(blocks, this.indexById, idIndexOpts);
|
38835
38802
|
await loadIndex(blocks, this.indexByKey, dbIndexOpts);
|
38836
|
-
console.log('head', this.dbHead, this.indexById)
|
38803
|
+
// console.log('head', this.dbHead, this.indexById)
|
38837
38804
|
if (this.indexById.root) {
|
38838
38805
|
const oldChangeEntries = await this.indexById.root.getMany(result.rows.map(({ key }) => key));
|
38839
38806
|
oldIndexEntries = oldChangeEntries.result.map((key) => ({ key, del: true }));
|
@@ -38882,13 +38849,18 @@ async function bulkIndex (blocks, inIndex, indexEntries, opts) {
|
|
38882
38849
|
inIndex.root = await load({ cid, get: getBlock, ...dbIndexOpts });
|
38883
38850
|
}
|
38884
38851
|
const { root, blocks: newBlocks } = await inIndex.root.bulk(indexEntries);
|
38885
|
-
|
38886
|
-
|
38887
|
-
|
38888
|
-
await
|
38852
|
+
if (root) {
|
38853
|
+
returnRootBlock = await root.block;
|
38854
|
+
returnNode = root;
|
38855
|
+
for await (const block of newBlocks) {
|
38856
|
+
await putBlock(block.cid, block.bytes);
|
38857
|
+
}
|
38858
|
+
await putBlock(returnRootBlock.cid, returnRootBlock.bytes);
|
38859
|
+
return { root: returnNode, cid: returnRootBlock.cid }
|
38860
|
+
} else {
|
38861
|
+
// throw new Error('test for index after delete')
|
38862
|
+
return { root: null, cid: null }
|
38889
38863
|
}
|
38890
|
-
await putBlock(returnRootBlock.cid, returnRootBlock.bytes);
|
38891
|
-
return { root: returnNode, cid: returnRootBlock.cid }
|
38892
38864
|
}
|
38893
38865
|
|
38894
38866
|
async function loadIndex (blocks, index, indexOpts) {
|
@@ -38925,8 +38897,6 @@ async function doIndexQuery (blocks, indexByKey, query = {}) {
|
|
38925
38897
|
}
|
38926
38898
|
}
|
38927
38899
|
|
38928
|
-
const parseCID = cid => (typeof cid === 'string' ? CID$1.parse(cid) : cid);
|
38929
|
-
|
38930
38900
|
class Fireproof {
|
38931
38901
|
/**
|
38932
38902
|
* @function storage
|
@@ -39010,7 +38980,7 @@ class Fireproof {
|
|
39010
38980
|
const allCIDs = await database.allCIDs();
|
39011
38981
|
const blocks = database.blocks;
|
39012
38982
|
|
39013
|
-
const rootCid =
|
38983
|
+
const rootCid = parseCID(allCIDs[allCIDs.length - 1]);
|
39014
38984
|
if (typeof key === 'undefined') {
|
39015
38985
|
key = blocks.valet?.getKeyMaterial();
|
39016
38986
|
}
|
@@ -39028,7 +38998,9 @@ class Fireproof {
|
|
39028
38998
|
allCIDs.map(async c => {
|
39029
38999
|
const b = await blocks.get(c);
|
39030
39000
|
// console.log('block', b)
|
39031
|
-
if (typeof b.cid === 'string') {
|
39001
|
+
if (typeof b.cid === 'string') {
|
39002
|
+
b.cid = parseCID(b.cid);
|
39003
|
+
}
|
39032
39004
|
// if (b.bytes.constructor.name === 'Buffer') console.log('conver vbuff')
|
39033
39005
|
return b
|
39034
39006
|
})
|