@fireproof/core 0.7.0-alpha.4 → 0.7.0-alpha.6

Sign up to get free protection for your applications and to get access to all the features.
@@ -39,7 +39,7 @@ export class Base {
39
39
  // currently we don't do that, because we only use
40
40
  // the config for first run, and then we use the headers
41
41
  // once they exist
42
- this.ready = this.getHeaders().then((blocksReady) => {
42
+ this.ready = this.getHeaders().then(blocksReady => {
43
43
  // console.log('blocksReady base', this.name, blocksReady)
44
44
  return blocksReady;
45
45
  });
@@ -243,8 +243,10 @@ export class Base {
243
243
  };
244
244
  const { blocks } = await blocksFromEncryptedCarBlock(roots[0], readerGetWithCodec, this.keyMaterial);
245
245
  const rootBlock = blocks[blocks.length - 1];
246
- const blocksIterable = function* () { for (const block of blocks)
247
- yield block; };
246
+ const blocksIterable = function* () {
247
+ for (const block of blocks)
248
+ yield block;
249
+ };
248
250
  const gat = async (dataCID) => {
249
251
  dataCID = dataCID.toString();
250
252
  return blocks.find(b => b.cid.toString() === dataCID);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fireproof/core",
3
- "version": "0.7.0-alpha.4",
3
+ "version": "0.7.0-alpha.6",
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",
@@ -49,7 +49,6 @@
49
49
  "cli-color": "^2.0.3",
50
50
  "crypto-browserify": "^3.12.0",
51
51
  "encrypted-block": "^0.0.3",
52
- "filer": "^1.4.1",
53
52
  "idb": "^7.1.1",
54
53
  "ipld-hashmap": "^2.1.18",
55
54
  "multiformats": "^11.0.1",
@@ -81,8 +80,7 @@
81
80
  "standard": "^17.0.0",
82
81
  "typescript": "^5.0.2",
83
82
  "webpack": "^5.78.0",
84
- "webpack-cli": "^5.0.1",
85
- "webpack-node-externals": "^3.0.0"
83
+ "webpack-cli": "^5.0.1"
86
84
  },
87
85
  "mocha": {
88
86
  "require": [
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
- import { Rest } from './storage/rest.js'
4
-
5
- const FORCE_IDB = typeof process !== 'undefined' && !!process.env?.FORCE_IDB
6
-
7
- /* global window */
2
+ // import { Rest } from './storage/rest.js'
8
3
 
9
4
  export const Loader = {
10
5
  appropriate: (name, config = {}) => {
11
- let isBrowser = false
12
- try {
13
- isBrowser = window.localStorage && true
14
- } catch (e) {}
15
-
16
- if (config.type === 'rest') {
17
- return new Rest(name, config)
6
+ if (config.StorageClass) {
7
+ return new config.StorageClass(name, config)
18
8
  }
19
9
 
20
- if (FORCE_IDB || isBrowser) {
21
- return new Browser(name, config)
22
- } else {
23
- return new Filesystem(name, config)
24
- }
10
+ // if (config.type === 'rest') {
11
+ // return new Rest(name, config)
12
+ // }
13
+
14
+ return new Browser(name, config)
25
15
  }
26
16
  }
@@ -45,7 +45,7 @@ export class Base {
45
45
  // currently we don't do that, because we only use
46
46
  // the config for first run, and then we use the headers
47
47
  // once they exist
48
- this.ready = this.getHeaders().then((blocksReady) => {
48
+ this.ready = this.getHeaders().then(blocksReady => {
49
49
  // console.log('blocksReady base', this.name, blocksReady)
50
50
  return blocksReady
51
51
  })
@@ -258,7 +258,9 @@ export class Base {
258
258
  }
259
259
  const { blocks } = await blocksFromEncryptedCarBlock(roots[0], readerGetWithCodec, this.keyMaterial)
260
260
  const rootBlock = blocks[blocks.length - 1]
261
- const blocksIterable = function * () { for (const block of blocks) yield block }
261
+ const blocksIterable = function * () {
262
+ for (const block of blocks) yield block
263
+ }
262
264
 
263
265
  const gat = async dataCID => {
264
266
  dataCID = dataCID.toString()
@@ -295,7 +297,7 @@ export class Base {
295
297
  }
296
298
  }
297
299
 
298
- writeCars (cars) { }
300
+ writeCars (cars) {}
299
301
 
300
302
  async updateCarCidMap (carCid, cids) {
301
303
  // this hydrates the map if it has not been hydrated