@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.
package/dist/database.js CHANGED
@@ -78,6 +78,7 @@ export class Database {
78
78
  * @instance
79
79
  */
80
80
  toJSON() {
81
+ // todo this prepareHeader ignores secondary storage, need both
81
82
  return this.blocks.valet ? this.blocks.valet.primary.prepareHeader(this.toHeader(), false) : this.toHeader(); // omg
82
83
  }
83
84
  toHeader() {
@@ -39076,10 +39076,6 @@ const defaultConfig$1 = {
39076
39076
  class Browser extends Base {
39077
39077
  constructor (name, config = {}) {
39078
39078
  super(name, Object.assign({}, defaultConfig$1, config));
39079
- this.isBrowser = false;
39080
- try {
39081
- this.isBrowser = window.localStorage && true;
39082
- } catch (e) {}
39083
39079
  }
39084
39080
 
39085
39081
  withDB = async dbWorkFun => {
@@ -39119,12 +39115,16 @@ class Browser extends Base {
39119
39115
  }
39120
39116
 
39121
39117
  loadHeader (branch = 'main') {
39122
- return this.isBrowser && localStorage.getItem(this.headerKey(branch))
39118
+ try {
39119
+ return localStorage.getItem(this.headerKey(branch))
39120
+ } catch (e) {}
39123
39121
  }
39124
39122
 
39125
39123
  async writeHeader (branch, header) {
39126
39124
  if (this.config.readonly) return
39127
- return this.isBrowser && localStorage.setItem(this.headerKey(branch), this.prepareHeader(header))
39125
+ try {
39126
+ return localStorage.setItem(this.headerKey(branch), this.prepareHeader(header))
39127
+ } catch (e) {}
39128
39128
  }
39129
39129
 
39130
39130
  headerKey (branch = 'main') {
@@ -40018,6 +40018,7 @@ class Valet {
40018
40018
 
40019
40019
  async function parkCar (storage, innerBlockstore, cids) {
40020
40020
  // console.log('parkCar', this.instanceId, this.name, carCid, cids)
40021
+ if (storage.readonly) return
40021
40022
  let newCar;
40022
40023
  if (storage.keyMaterial) {
40023
40024
  // console.log('encrypting car', innerBlockstore.label)
@@ -41641,6 +41642,7 @@ class Database {
41641
41642
  * @instance
41642
41643
  */
41643
41644
  toJSON () {
41645
+ // todo this prepareHeader ignores secondary storage, need both
41644
41646
  return this.blocks.valet ? this.blocks.valet.primary.prepareHeader(this.toHeader(), false) : this.toHeader() // omg
41645
41647
  }
41646
41648