@fireproof/core 0.7.0-alpha.3 → 0.7.0-alpha.5

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fireproof/core",
3
- "version": "0.7.0-alpha.3",
3
+ "version": "0.7.0-alpha.5",
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/fireproof.js CHANGED
@@ -50,7 +50,7 @@ export class Fireproof {
50
50
  clock: {
51
51
  byId: byId ? parseCID(byId) : null,
52
52
  byKey: byKey ? parseCID(byKey) : null,
53
- db: (db && db.length > 0) ? db.map(c => parseCID(c)) : null
53
+ db: db && db.length > 0 ? db.map(c => parseCID(c)) : null
54
54
  },
55
55
  code,
56
56
  name
@@ -73,7 +73,9 @@ export class Fireproof {
73
73
 
74
74
  const withBlocks = new Database(database.name)
75
75
  withBlocks.blocks = database.blocks
76
- withBlocks.clock = definition.clock
76
+ withBlocks.ready.then(() => {
77
+ withBlocks.clock = definition.clock.map(c => parseCID(c))
78
+ })
77
79
 
78
80
  const snappedDb = Fireproof.fromJSON(definition, null, withBlocks)
79
81
  ;[...database.indexes.values()].forEach(index => {
package/src/loader.js CHANGED
@@ -1,26 +1,16 @@
1
1
  import { Browser } from './storage/browser.js'
2
- import { Filesystem } from './storage/filesystem.js'
3
2
  import { Rest } from './storage/rest.js'
4
3
 
5
- const FORCE_IDB = typeof process !== 'undefined' && !!process.env?.FORCE_IDB
6
-
7
- /* global window */
8
-
9
4
  export const Loader = {
10
5
  appropriate: (name, config = {}) => {
11
- let isBrowser = false
12
- try {
13
- isBrowser = window.localStorage && true
14
- } catch (e) {}
6
+ if (config.StorageClass) {
7
+ return new config.StorageClass(name, config)
8
+ }
15
9
 
16
10
  if (config.type === 'rest') {
17
11
  return new Rest(name, config)
18
12
  }
19
13
 
20
- if (FORCE_IDB || isBrowser) {
21
- return new Browser(name, config)
22
- } else {
23
- return new Filesystem(name, config)
24
- }
14
+ return new Browser(name, config)
25
15
  }
26
16
  }