@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.
@@ -7,11 +7,6 @@ const defaultConfig = {
7
7
  export class Browser extends Base {
8
8
  constructor(name, config = {}) {
9
9
  super(name, Object.assign({}, defaultConfig, config));
10
- this.isBrowser = false;
11
- try {
12
- this.isBrowser = window.localStorage && true;
13
- }
14
- catch (e) { }
15
10
  }
16
11
  withDB = async (dbWorkFun) => {
17
12
  if (!this.idb) {
@@ -48,12 +43,18 @@ export class Browser extends Base {
48
43
  });
49
44
  }
50
45
  loadHeader(branch = 'main') {
51
- return this.isBrowser && localStorage.getItem(this.headerKey(branch));
46
+ try {
47
+ return localStorage.getItem(this.headerKey(branch));
48
+ }
49
+ catch (e) { }
52
50
  }
53
51
  async writeHeader(branch, header) {
54
52
  if (this.config.readonly)
55
53
  return;
56
- return this.isBrowser && localStorage.setItem(this.headerKey(branch), this.prepareHeader(header));
54
+ try {
55
+ return localStorage.setItem(this.headerKey(branch), this.prepareHeader(header));
56
+ }
57
+ catch (e) { }
57
58
  }
58
59
  headerKey(branch = 'main') {
59
60
  return this.config.headerKeyPrefix + this.name + '.' + branch;
package/dist/valet.js CHANGED
@@ -102,6 +102,8 @@ export class Valet {
102
102
  }
103
103
  async function parkCar(storage, innerBlockstore, cids) {
104
104
  // console.log('parkCar', this.instanceId, this.name, carCid, cids)
105
+ if (storage.readonly)
106
+ return;
105
107
  let newCar;
106
108
  if (storage.keyMaterial) {
107
109
  // console.log('encrypting car', innerBlockstore.label)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fireproof/core",
3
- "version": "0.7.2-dev",
3
+ "version": "0.7.2-dev.3",
4
4
  "description": "Live data for React, accelerated by proofs, powered by IPFS",
5
5
  "main": "dist/src/fireproof.js",
6
6
  "module": "dist/src/fireproof.mjs",
package/src/database.js CHANGED
@@ -86,6 +86,7 @@ export class Database {
86
86
  * @instance
87
87
  */
88
88
  toJSON () {
89
+ // todo this prepareHeader ignores secondary storage, need both
89
90
  return this.blocks.valet ? this.blocks.valet.primary.prepareHeader(this.toHeader(), false) : this.toHeader() // omg
90
91
  }
91
92
 
@@ -10,10 +10,6 @@ const defaultConfig = {
10
10
  export class Browser extends Base {
11
11
  constructor (name, config = {}) {
12
12
  super(name, Object.assign({}, defaultConfig, config))
13
- this.isBrowser = false
14
- try {
15
- this.isBrowser = window.localStorage && true
16
- } catch (e) {}
17
13
  }
18
14
 
19
15
  withDB = async dbWorkFun => {
@@ -53,12 +49,16 @@ export class Browser extends Base {
53
49
  }
54
50
 
55
51
  loadHeader (branch = 'main') {
56
- return this.isBrowser && localStorage.getItem(this.headerKey(branch))
52
+ try {
53
+ return localStorage.getItem(this.headerKey(branch))
54
+ } catch (e) {}
57
55
  }
58
56
 
59
57
  async writeHeader (branch, header) {
60
58
  if (this.config.readonly) return
61
- return this.isBrowser && localStorage.setItem(this.headerKey(branch), this.prepareHeader(header))
59
+ try {
60
+ return localStorage.setItem(this.headerKey(branch), this.prepareHeader(header))
61
+ } catch (e) {}
62
62
  }
63
63
 
64
64
  headerKey (branch = 'main') {
package/src/valet.js CHANGED
@@ -106,6 +106,7 @@ export class Valet {
106
106
 
107
107
  async function parkCar (storage, innerBlockstore, cids) {
108
108
  // console.log('parkCar', this.instanceId, this.name, carCid, cids)
109
+ if (storage.readonly) return
109
110
  let newCar
110
111
  if (storage.keyMaterial) {
111
112
  // console.log('encrypting car', innerBlockstore.label)