@fireproof/core 0.7.2-dev.2 → 0.7.2-dev.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -39074,10 +39074,6 @@ const defaultConfig$1 = {
39074
39074
  class Browser extends Base {
39075
39075
  constructor (name, config = {}) {
39076
39076
  super(name, Object.assign({}, defaultConfig$1, config));
39077
- this.isBrowser = false;
39078
- try {
39079
- this.isBrowser = window.localStorage && true;
39080
- } catch (e) {}
39081
39077
  }
39082
39078
 
39083
39079
  withDB = async dbWorkFun => {
@@ -39117,12 +39113,16 @@ class Browser extends Base {
39117
39113
  }
39118
39114
 
39119
39115
  loadHeader (branch = 'main') {
39120
- return this.isBrowser && localStorage.getItem(this.headerKey(branch))
39116
+ try {
39117
+ return localStorage.getItem(this.headerKey(branch))
39118
+ } catch (e) {}
39121
39119
  }
39122
39120
 
39123
39121
  async writeHeader (branch, header) {
39124
39122
  if (this.config.readonly) return
39125
- return this.isBrowser && localStorage.setItem(this.headerKey(branch), this.prepareHeader(header))
39123
+ try {
39124
+ return localStorage.setItem(this.headerKey(branch), this.prepareHeader(header))
39125
+ } catch (e) {}
39126
39126
  }
39127
39127
 
39128
39128
  headerKey (branch = 'main') {
@@ -41640,6 +41640,7 @@ class Database {
41640
41640
  * @instance
41641
41641
  */
41642
41642
  toJSON () {
41643
+ // todo this prepareHeader ignores secondary storage, need both
41643
41644
  return this.blocks.valet ? this.blocks.valet.primary.prepareHeader(this.toHeader(), false) : this.toHeader() // omg
41644
41645
  }
41645
41646