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

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.
@@ -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') {
@@ -40016,6 +40016,7 @@ class Valet {
40016
40016
 
40017
40017
  async function parkCar (storage, innerBlockstore, cids) {
40018
40018
  // console.log('parkCar', this.instanceId, this.name, carCid, cids)
40019
+ if (storage.readonly) return
40019
40020
  let newCar;
40020
40021
  if (storage.keyMaterial) {
40021
40022
  // console.log('encrypting car', innerBlockstore.label)
@@ -41639,6 +41640,7 @@ class Database {
41639
41640
  * @instance
41640
41641
  */
41641
41642
  toJSON () {
41643
+ // todo this prepareHeader ignores secondary storage, need both
41642
41644
  return this.blocks.valet ? this.blocks.valet.primary.prepareHeader(this.toHeader(), false) : this.toHeader() // omg
41643
41645
  }
41644
41646