@fireproof/core 0.7.2-dev.2 → 0.7.2-dev.4
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/database.js +1 -0
- package/dist/src/fireproof.js +186 -219
- package/dist/src/fireproof.js.map +1 -1
- package/dist/src/fireproof.mjs +186 -219
- package/dist/src/fireproof.mjs.map +1 -1
- package/dist/storage/browser.js +8 -7
- package/package.json +1 -1
- package/src/database.js +1 -0
- package/src/storage/browser.js +6 -6
package/dist/src/fireproof.mjs
CHANGED
@@ -11478,15 +11478,7 @@ var _polyfillNode_events = /*#__PURE__*/Object.freeze({
|
|
11478
11478
|
|
11479
11479
|
var require$$0$1 = /*@__PURE__*/getAugmentedNamespace(_polyfillNode_events);
|
11480
11480
|
|
11481
|
-
var streamBrowser;
|
11482
|
-
var hasRequiredStreamBrowser;
|
11483
|
-
|
11484
|
-
function requireStreamBrowser () {
|
11485
|
-
if (hasRequiredStreamBrowser) return streamBrowser;
|
11486
|
-
hasRequiredStreamBrowser = 1;
|
11487
|
-
streamBrowser = require$$0$1.EventEmitter;
|
11488
|
-
return streamBrowser;
|
11489
|
-
}
|
11481
|
+
var streamBrowser = require$$0$1.EventEmitter;
|
11490
11482
|
|
11491
11483
|
// shim for using process in browser
|
11492
11484
|
// based off https://github.com/defunctzombie/node-process/blob/master/browser.js
|
@@ -11629,7 +11621,7 @@ var argv = [];
|
|
11629
11621
|
var version$1 = ''; // empty string to avoid regexp issues
|
11630
11622
|
var versions = {};
|
11631
11623
|
var release = {};
|
11632
|
-
var config = {};
|
11624
|
+
var config$1 = {};
|
11633
11625
|
|
11634
11626
|
function noop$2() {}
|
11635
11627
|
|
@@ -11706,7 +11698,7 @@ var browser$1$1 = {
|
|
11706
11698
|
hrtime: hrtime,
|
11707
11699
|
platform: platform,
|
11708
11700
|
release: release,
|
11709
|
-
config: config,
|
11701
|
+
config: config$1,
|
11710
11702
|
uptime: uptime
|
11711
11703
|
};
|
11712
11704
|
|
@@ -11787,11 +11779,11 @@ function format(f) {
|
|
11787
11779
|
// Mark that a method should not be used.
|
11788
11780
|
// Returns a modified function which warns once by default.
|
11789
11781
|
// If --no-deprecation is set, then it is a no-op.
|
11790
|
-
function deprecate(fn, msg) {
|
11782
|
+
function deprecate$1(fn, msg) {
|
11791
11783
|
// Allow for deprecating things in the process of starting up.
|
11792
11784
|
if (isUndefined(global$1.process)) {
|
11793
11785
|
return function() {
|
11794
|
-
return deprecate(fn, msg).apply(this, arguments);
|
11786
|
+
return deprecate$1(fn, msg).apply(this, arguments);
|
11795
11787
|
};
|
11796
11788
|
}
|
11797
11789
|
|
@@ -12400,7 +12392,7 @@ var _polyfillNode_util = {
|
|
12400
12392
|
isBoolean: isBoolean,
|
12401
12393
|
isArray: isArray,
|
12402
12394
|
inspect: inspect,
|
12403
|
-
deprecate: deprecate,
|
12395
|
+
deprecate: deprecate$1,
|
12404
12396
|
format: format,
|
12405
12397
|
debuglog: debuglog,
|
12406
12398
|
promisify: promisify,
|
@@ -12413,7 +12405,7 @@ var _polyfillNode_util$1 = /*#__PURE__*/Object.freeze({
|
|
12413
12405
|
callbackify: callbackify,
|
12414
12406
|
debuglog: debuglog,
|
12415
12407
|
default: _polyfillNode_util,
|
12416
|
-
deprecate: deprecate,
|
12408
|
+
deprecate: deprecate$1,
|
12417
12409
|
format: format,
|
12418
12410
|
inherits: inherits$1,
|
12419
12411
|
inspect: inspect,
|
@@ -12601,108 +12593,99 @@ function requireBuffer_list () {
|
|
12601
12593
|
return buffer_list;
|
12602
12594
|
}
|
12603
12595
|
|
12604
|
-
|
12605
|
-
|
12606
|
-
|
12607
|
-
|
12608
|
-
|
12609
|
-
|
12610
|
-
|
12611
|
-
|
12612
|
-
|
12613
|
-
|
12614
|
-
|
12615
|
-
|
12616
|
-
|
12617
|
-
|
12618
|
-
|
12619
|
-
|
12620
|
-
|
12621
|
-
} else if (!this._writableState.errorEmitted) {
|
12622
|
-
this._writableState.errorEmitted = true;
|
12623
|
-
process.nextTick(emitErrorNT, this, err);
|
12624
|
-
}
|
12625
|
-
}
|
12626
|
-
return this;
|
12627
|
-
}
|
12596
|
+
// undocumented cb() API, needed for core, not for public API
|
12597
|
+
function destroy(err, cb) {
|
12598
|
+
const readableDestroyed = this._readableState && this._readableState.destroyed;
|
12599
|
+
const writableDestroyed = this._writableState && this._writableState.destroyed;
|
12600
|
+
if (readableDestroyed || writableDestroyed) {
|
12601
|
+
if (cb) {
|
12602
|
+
cb(err);
|
12603
|
+
} else if (err) {
|
12604
|
+
if (!this._writableState) {
|
12605
|
+
process.nextTick(emitErrorNT, this, err);
|
12606
|
+
} else if (!this._writableState.errorEmitted) {
|
12607
|
+
this._writableState.errorEmitted = true;
|
12608
|
+
process.nextTick(emitErrorNT, this, err);
|
12609
|
+
}
|
12610
|
+
}
|
12611
|
+
return this;
|
12612
|
+
}
|
12628
12613
|
|
12629
|
-
|
12630
|
-
|
12614
|
+
// we set destroyed to true before firing error callbacks in order
|
12615
|
+
// to make it re-entrance safe in case destroy() is called within callbacks
|
12631
12616
|
|
12632
|
-
|
12633
|
-
|
12634
|
-
|
12617
|
+
if (this._readableState) {
|
12618
|
+
this._readableState.destroyed = true;
|
12619
|
+
}
|
12635
12620
|
|
12636
|
-
|
12637
|
-
|
12638
|
-
|
12639
|
-
|
12640
|
-
|
12641
|
-
|
12642
|
-
|
12643
|
-
|
12644
|
-
|
12645
|
-
|
12646
|
-
|
12647
|
-
|
12648
|
-
|
12649
|
-
|
12650
|
-
|
12651
|
-
|
12652
|
-
|
12653
|
-
|
12654
|
-
|
12655
|
-
|
12656
|
-
|
12657
|
-
|
12658
|
-
|
12659
|
-
|
12660
|
-
|
12661
|
-
|
12662
|
-
|
12663
|
-
|
12664
|
-
|
12665
|
-
|
12666
|
-
|
12667
|
-
|
12668
|
-
|
12669
|
-
|
12670
|
-
|
12671
|
-
|
12672
|
-
|
12673
|
-
|
12674
|
-
|
12675
|
-
|
12676
|
-
|
12677
|
-
|
12678
|
-
|
12679
|
-
|
12680
|
-
|
12681
|
-
|
12682
|
-
|
12683
|
-
|
12684
|
-
|
12685
|
-
|
12686
|
-
|
12687
|
-
|
12688
|
-
|
12689
|
-
|
12690
|
-
|
12691
|
-
|
12692
|
-
|
12693
|
-
|
12621
|
+
// if this is a duplex stream mark the writable part as destroyed as well
|
12622
|
+
if (this._writableState) {
|
12623
|
+
this._writableState.destroyed = true;
|
12624
|
+
}
|
12625
|
+
this._destroy(err || null, err => {
|
12626
|
+
if (!cb && err) {
|
12627
|
+
if (!this._writableState) {
|
12628
|
+
process.nextTick(emitErrorAndCloseNT, this, err);
|
12629
|
+
} else if (!this._writableState.errorEmitted) {
|
12630
|
+
this._writableState.errorEmitted = true;
|
12631
|
+
process.nextTick(emitErrorAndCloseNT, this, err);
|
12632
|
+
} else {
|
12633
|
+
process.nextTick(emitCloseNT, this);
|
12634
|
+
}
|
12635
|
+
} else if (cb) {
|
12636
|
+
process.nextTick(emitCloseNT, this);
|
12637
|
+
cb(err);
|
12638
|
+
} else {
|
12639
|
+
process.nextTick(emitCloseNT, this);
|
12640
|
+
}
|
12641
|
+
});
|
12642
|
+
return this;
|
12643
|
+
}
|
12644
|
+
function emitErrorAndCloseNT(self, err) {
|
12645
|
+
emitErrorNT(self, err);
|
12646
|
+
emitCloseNT(self);
|
12647
|
+
}
|
12648
|
+
function emitCloseNT(self) {
|
12649
|
+
if (self._writableState && !self._writableState.emitClose) return;
|
12650
|
+
if (self._readableState && !self._readableState.emitClose) return;
|
12651
|
+
self.emit('close');
|
12652
|
+
}
|
12653
|
+
function undestroy() {
|
12654
|
+
if (this._readableState) {
|
12655
|
+
this._readableState.destroyed = false;
|
12656
|
+
this._readableState.reading = false;
|
12657
|
+
this._readableState.ended = false;
|
12658
|
+
this._readableState.endEmitted = false;
|
12659
|
+
}
|
12660
|
+
if (this._writableState) {
|
12661
|
+
this._writableState.destroyed = false;
|
12662
|
+
this._writableState.ended = false;
|
12663
|
+
this._writableState.ending = false;
|
12664
|
+
this._writableState.finalCalled = false;
|
12665
|
+
this._writableState.prefinished = false;
|
12666
|
+
this._writableState.finished = false;
|
12667
|
+
this._writableState.errorEmitted = false;
|
12668
|
+
}
|
12669
|
+
}
|
12670
|
+
function emitErrorNT(self, err) {
|
12671
|
+
self.emit('error', err);
|
12672
|
+
}
|
12673
|
+
function errorOrDestroy(stream, err) {
|
12674
|
+
// We have tests that rely on errors being emitted
|
12675
|
+
// in the same tick, so changing this is semver major.
|
12676
|
+
// For now when you opt-in to autoDestroy we allow
|
12677
|
+
// the error to be emitted nextTick. In a future
|
12678
|
+
// semver major update we should change the default to this.
|
12694
12679
|
|
12695
|
-
|
12696
|
-
|
12697
|
-
|
12698
|
-
}
|
12699
|
-
destroy_1 = {
|
12700
|
-
destroy,
|
12701
|
-
undestroy,
|
12702
|
-
errorOrDestroy
|
12703
|
-
};
|
12704
|
-
return destroy_1;
|
12680
|
+
const rState = stream._readableState;
|
12681
|
+
const wState = stream._writableState;
|
12682
|
+
if (rState && rState.autoDestroy || wState && wState.autoDestroy) stream.destroy(err);else stream.emit('error', err);
|
12705
12683
|
}
|
12684
|
+
var destroy_1 = {
|
12685
|
+
destroy,
|
12686
|
+
undestroy,
|
12687
|
+
errorOrDestroy
|
12688
|
+
};
|
12706
12689
|
|
12707
12690
|
var errorsBrowser = {};
|
12708
12691
|
|
@@ -12832,109 +12815,92 @@ createErrorType('ERR_UNKNOWN_ENCODING', function (arg) {
|
|
12832
12815
|
createErrorType('ERR_STREAM_UNSHIFT_AFTER_END_EVENT', 'stream.unshift() after end event');
|
12833
12816
|
errorsBrowser.codes = codes;
|
12834
12817
|
|
12835
|
-
|
12836
|
-
|
12837
|
-
|
12838
|
-
function requireState () {
|
12839
|
-
if (hasRequiredState) return state;
|
12840
|
-
hasRequiredState = 1;
|
12841
|
-
|
12842
|
-
const ERR_INVALID_OPT_VALUE = errorsBrowser.codes.ERR_INVALID_OPT_VALUE;
|
12843
|
-
function highWaterMarkFrom(options, isDuplex, duplexKey) {
|
12844
|
-
return options.highWaterMark != null ? options.highWaterMark : isDuplex ? options[duplexKey] : null;
|
12845
|
-
}
|
12846
|
-
function getHighWaterMark(state, options, duplexKey, isDuplex) {
|
12847
|
-
const hwm = highWaterMarkFrom(options, isDuplex, duplexKey);
|
12848
|
-
if (hwm != null) {
|
12849
|
-
if (!(isFinite(hwm) && Math.floor(hwm) === hwm) || hwm < 0) {
|
12850
|
-
const name = isDuplex ? duplexKey : 'highWaterMark';
|
12851
|
-
throw new ERR_INVALID_OPT_VALUE(name, hwm);
|
12852
|
-
}
|
12853
|
-
return Math.floor(hwm);
|
12854
|
-
}
|
12855
|
-
|
12856
|
-
// Default value
|
12857
|
-
return state.objectMode ? 16 : 16 * 1024;
|
12858
|
-
}
|
12859
|
-
state = {
|
12860
|
-
getHighWaterMark
|
12861
|
-
};
|
12862
|
-
return state;
|
12818
|
+
const ERR_INVALID_OPT_VALUE = errorsBrowser.codes.ERR_INVALID_OPT_VALUE;
|
12819
|
+
function highWaterMarkFrom(options, isDuplex, duplexKey) {
|
12820
|
+
return options.highWaterMark != null ? options.highWaterMark : isDuplex ? options[duplexKey] : null;
|
12863
12821
|
}
|
12822
|
+
function getHighWaterMark(state, options, duplexKey, isDuplex) {
|
12823
|
+
const hwm = highWaterMarkFrom(options, isDuplex, duplexKey);
|
12824
|
+
if (hwm != null) {
|
12825
|
+
if (!(isFinite(hwm) && Math.floor(hwm) === hwm) || hwm < 0) {
|
12826
|
+
const name = isDuplex ? duplexKey : 'highWaterMark';
|
12827
|
+
throw new ERR_INVALID_OPT_VALUE(name, hwm);
|
12828
|
+
}
|
12829
|
+
return Math.floor(hwm);
|
12830
|
+
}
|
12864
12831
|
|
12865
|
-
|
12866
|
-
|
12832
|
+
// Default value
|
12833
|
+
return state.objectMode ? 16 : 16 * 1024;
|
12834
|
+
}
|
12835
|
+
var state = {
|
12836
|
+
getHighWaterMark
|
12837
|
+
};
|
12867
12838
|
|
12868
|
-
|
12869
|
-
|
12870
|
-
|
12871
|
-
/**
|
12872
|
-
* Module exports.
|
12873
|
-
*/
|
12839
|
+
/**
|
12840
|
+
* Module exports.
|
12841
|
+
*/
|
12874
12842
|
|
12875
|
-
|
12843
|
+
var browser$b = deprecate;
|
12876
12844
|
|
12877
|
-
|
12878
|
-
|
12879
|
-
|
12880
|
-
|
12881
|
-
|
12882
|
-
|
12883
|
-
|
12884
|
-
|
12885
|
-
|
12886
|
-
|
12887
|
-
|
12888
|
-
|
12889
|
-
|
12890
|
-
|
12891
|
-
|
12892
|
-
|
12893
|
-
|
12845
|
+
/**
|
12846
|
+
* Mark that a method should not be used.
|
12847
|
+
* Returns a modified function which warns once by default.
|
12848
|
+
*
|
12849
|
+
* If `localStorage.noDeprecation = true` is set, then it is a no-op.
|
12850
|
+
*
|
12851
|
+
* If `localStorage.throwDeprecation = true` is set, then deprecated functions
|
12852
|
+
* will throw an Error when invoked.
|
12853
|
+
*
|
12854
|
+
* If `localStorage.traceDeprecation = true` is set, then deprecated functions
|
12855
|
+
* will invoke `console.trace()` instead of `console.error()`.
|
12856
|
+
*
|
12857
|
+
* @param {Function} fn - the function to deprecate
|
12858
|
+
* @param {String} msg - the string to print to the console when `fn` is invoked
|
12859
|
+
* @returns {Function} a new "deprecated" version of `fn`
|
12860
|
+
* @api public
|
12861
|
+
*/
|
12894
12862
|
|
12895
|
-
|
12896
|
-
|
12897
|
-
|
12898
|
-
|
12863
|
+
function deprecate (fn, msg) {
|
12864
|
+
if (config('noDeprecation')) {
|
12865
|
+
return fn;
|
12866
|
+
}
|
12899
12867
|
|
12900
|
-
|
12901
|
-
|
12902
|
-
|
12903
|
-
|
12904
|
-
|
12905
|
-
|
12906
|
-
|
12907
|
-
|
12908
|
-
|
12909
|
-
|
12910
|
-
|
12911
|
-
|
12912
|
-
|
12913
|
-
|
12868
|
+
var warned = false;
|
12869
|
+
function deprecated() {
|
12870
|
+
if (!warned) {
|
12871
|
+
if (config('throwDeprecation')) {
|
12872
|
+
throw new Error(msg);
|
12873
|
+
} else if (config('traceDeprecation')) {
|
12874
|
+
console.trace(msg);
|
12875
|
+
} else {
|
12876
|
+
console.warn(msg);
|
12877
|
+
}
|
12878
|
+
warned = true;
|
12879
|
+
}
|
12880
|
+
return fn.apply(this, arguments);
|
12881
|
+
}
|
12914
12882
|
|
12915
|
-
|
12916
|
-
|
12883
|
+
return deprecated;
|
12884
|
+
}
|
12917
12885
|
|
12918
|
-
|
12919
|
-
|
12920
|
-
|
12921
|
-
|
12922
|
-
|
12923
|
-
|
12924
|
-
|
12886
|
+
/**
|
12887
|
+
* Checks `localStorage` for boolean values for the given `name`.
|
12888
|
+
*
|
12889
|
+
* @param {String} name
|
12890
|
+
* @returns {Boolean}
|
12891
|
+
* @api private
|
12892
|
+
*/
|
12925
12893
|
|
12926
|
-
|
12927
|
-
|
12928
|
-
|
12929
|
-
|
12930
|
-
|
12931
|
-
|
12932
|
-
|
12933
|
-
|
12934
|
-
|
12935
|
-
|
12936
|
-
}
|
12937
|
-
return browser$b;
|
12894
|
+
function config (name) {
|
12895
|
+
// accessing global.localStorage can trigger a DOMException in sandboxed iframes
|
12896
|
+
try {
|
12897
|
+
if (!commonjsGlobal.localStorage) return false;
|
12898
|
+
} catch (_) {
|
12899
|
+
return false;
|
12900
|
+
}
|
12901
|
+
var val = commonjsGlobal.localStorage[name];
|
12902
|
+
if (null == val) return false;
|
12903
|
+
return String(val).toLowerCase() === 'true';
|
12938
12904
|
}
|
12939
12905
|
|
12940
12906
|
var _stream_writable;
|
@@ -12965,12 +12931,12 @@ function require_stream_writable () {
|
|
12965
12931
|
|
12966
12932
|
/*<replacement>*/
|
12967
12933
|
const internalUtil = {
|
12968
|
-
deprecate:
|
12934
|
+
deprecate: browser$b
|
12969
12935
|
};
|
12970
12936
|
/*</replacement>*/
|
12971
12937
|
|
12972
12938
|
/*<replacement>*/
|
12973
|
-
var Stream =
|
12939
|
+
var Stream = streamBrowser;
|
12974
12940
|
/*</replacement>*/
|
12975
12941
|
|
12976
12942
|
const Buffer = require$$6$1.Buffer;
|
@@ -12981,8 +12947,8 @@ function require_stream_writable () {
|
|
12981
12947
|
function _isUint8Array(obj) {
|
12982
12948
|
return Buffer.isBuffer(obj) || obj instanceof OurUint8Array;
|
12983
12949
|
}
|
12984
|
-
const destroyImpl =
|
12985
|
-
const _require =
|
12950
|
+
const destroyImpl = destroy_1;
|
12951
|
+
const _require = state,
|
12986
12952
|
getHighWaterMark = _require.getHighWaterMark;
|
12987
12953
|
const _require$codes = errorsBrowser.codes,
|
12988
12954
|
ERR_INVALID_ARG_TYPE = _require$codes.ERR_INVALID_ARG_TYPE,
|
@@ -14176,7 +14142,7 @@ function require_stream_readable () {
|
|
14176
14142
|
/*</replacement>*/
|
14177
14143
|
|
14178
14144
|
/*<replacement>*/
|
14179
|
-
var Stream =
|
14145
|
+
var Stream = streamBrowser;
|
14180
14146
|
/*</replacement>*/
|
14181
14147
|
|
14182
14148
|
const Buffer = require$$6$1.Buffer;
|
@@ -14199,8 +14165,8 @@ function require_stream_readable () {
|
|
14199
14165
|
/*</replacement>*/
|
14200
14166
|
|
14201
14167
|
const BufferList = requireBuffer_list();
|
14202
|
-
const destroyImpl =
|
14203
|
-
const _require =
|
14168
|
+
const destroyImpl = destroy_1;
|
14169
|
+
const _require = state,
|
14204
14170
|
getHighWaterMark = _require.getHighWaterMark;
|
14205
14171
|
const _require$codes = errorsBrowser.codes,
|
14206
14172
|
ERR_INVALID_ARG_TYPE = _require$codes.ERR_INVALID_ARG_TYPE,
|
@@ -17653,7 +17619,7 @@ function WriteReq(chunk, encoding, cb) {
|
|
17653
17619
|
|
17654
17620
|
function WritableState(options, stream) {
|
17655
17621
|
Object.defineProperty(this, 'buffer', {
|
17656
|
-
get: deprecate(function () {
|
17622
|
+
get: deprecate$1(function () {
|
17657
17623
|
return this.getBuffer();
|
17658
17624
|
}, '_writableState.buffer is deprecated. Use _writableState.getBuffer ' + 'instead.')
|
17659
17625
|
});
|
@@ -39074,10 +39040,6 @@ const defaultConfig$1 = {
|
|
39074
39040
|
class Browser extends Base {
|
39075
39041
|
constructor (name, config = {}) {
|
39076
39042
|
super(name, Object.assign({}, defaultConfig$1, config));
|
39077
|
-
this.isBrowser = false;
|
39078
|
-
try {
|
39079
|
-
this.isBrowser = window.localStorage && true;
|
39080
|
-
} catch (e) {}
|
39081
39043
|
}
|
39082
39044
|
|
39083
39045
|
withDB = async dbWorkFun => {
|
@@ -39117,12 +39079,16 @@ class Browser extends Base {
|
|
39117
39079
|
}
|
39118
39080
|
|
39119
39081
|
loadHeader (branch = 'main') {
|
39120
|
-
|
39082
|
+
try {
|
39083
|
+
return JSON.parse(localStorage.getItem(this.headerKey(branch)))
|
39084
|
+
} catch (e) {}
|
39121
39085
|
}
|
39122
39086
|
|
39123
39087
|
async writeHeader (branch, header) {
|
39124
39088
|
if (this.config.readonly) return
|
39125
|
-
|
39089
|
+
try {
|
39090
|
+
return localStorage.setItem(this.headerKey(branch), this.prepareHeader(header))
|
39091
|
+
} catch (e) {}
|
39126
39092
|
}
|
39127
39093
|
|
39128
39094
|
headerKey (branch = 'main') {
|
@@ -41640,6 +41606,7 @@ class Database {
|
|
41640
41606
|
* @instance
|
41641
41607
|
*/
|
41642
41608
|
toJSON () {
|
41609
|
+
// todo this prepareHeader ignores secondary storage, need both
|
41643
41610
|
return this.blocks.valet ? this.blocks.valet.primary.prepareHeader(this.toHeader(), false) : this.toHeader() // omg
|
41644
41611
|
}
|
41645
41612
|
|