@fireproof/core 0.3.11 → 0.3.13
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/README.md +1 -1
- package/dist/bundle.js +2168 -0
- package/dist/src/blockstore.d.ts +115 -0
- package/dist/src/blockstore.d.ts.map +1 -0
- package/dist/src/clock.d.ts +98 -0
- package/dist/src/clock.d.ts.map +1 -0
- package/dist/src/crypto.d.ts +18 -0
- package/dist/src/crypto.d.ts.map +1 -0
- package/dist/src/db-index.d.ts +116 -0
- package/dist/src/db-index.d.ts.map +1 -0
- package/dist/src/fireproof.d.ts +167 -0
- package/dist/src/fireproof.d.ts.map +1 -0
- package/dist/src/hydrator.d.ts +6 -0
- package/dist/src/hydrator.d.ts.map +1 -0
- package/dist/src/index.d.ts +6 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/listener.d.ts +36 -0
- package/dist/src/listener.d.ts.map +1 -0
- package/dist/src/prolly.d.ts +83 -0
- package/dist/src/prolly.d.ts.map +1 -0
- package/dist/src/sha1.d.ts +9 -0
- package/dist/src/sha1.d.ts.map +1 -0
- package/dist/src/valet.d.ts +34 -0
- package/dist/src/valet.d.ts.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/package.json +39 -5
- package/src/blockstore.js +24 -23
- package/src/clock.js +4 -3
- package/src/crypto.js +1 -0
- package/src/db-index.js +23 -18
- package/src/fireproof.js +31 -26
- package/src/hydrator.js +3 -3
- package/src/index.js +6 -0
- package/src/listener.js +9 -8
- package/src/prolly.js +12 -25
- package/src/sha1.js +2 -1
- package/src/valet.js +22 -20
- package/hooks/use-fireproof.js +0 -135
- package/index.js +0 -6
- package/scripts/keygen.js +0 -3
- package/test/block.js +0 -65
- package/test/clock.test.js +0 -694
- package/test/db-index.test.js +0 -261
- package/test/fireproof.test.js +0 -493
- package/test/fulltext.test.js +0 -66
- package/test/helpers.js +0 -45
- package/test/hydrator.test.js +0 -81
- package/test/listener.test.js +0 -102
- package/test/prolly.test.js +0 -190
- package/test/proofs.test.js +0 -53
- package/test/reproduce-fixture-bug.test.js +0 -65
- package/test/valet.test.js +0 -59
package/test/block.js
DELETED
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
import { parse } from 'multiformats/link'
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* @typedef {{ cid: import('../src/link').AnyLink, bytes: Uint8Array }} AnyBlock
|
|
5
|
-
* @typedef {{ get: (link: import('../src/link').AnyLink) => Promise<AnyBlock | undefined> }} BlockFetcher
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
/** @implements {BlockFetcher} */
|
|
9
|
-
export class MemoryBlockstore {
|
|
10
|
-
/** @type {Map<string, Uint8Array>} */
|
|
11
|
-
#blocks = new Map()
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* @param {import('../src/link').AnyLink} cid
|
|
15
|
-
* @returns {Promise<AnyBlock | undefined>}
|
|
16
|
-
*/
|
|
17
|
-
async get (cid) {
|
|
18
|
-
const bytes = this.#blocks.get(cid.toString())
|
|
19
|
-
if (!bytes) return
|
|
20
|
-
return { cid, bytes }
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* @param {import('../src/link').AnyLink} cid
|
|
25
|
-
* @param {Uint8Array} bytes
|
|
26
|
-
*/
|
|
27
|
-
async put (cid, bytes) {
|
|
28
|
-
// console.log('put', cid)
|
|
29
|
-
this.#blocks.set(cid.toString(), bytes)
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* @param {import('../src/link').AnyLink} cid
|
|
34
|
-
* @param {Uint8Array} bytes
|
|
35
|
-
*/
|
|
36
|
-
putSync (cid, bytes) {
|
|
37
|
-
this.#blocks.set(cid.toString(), bytes)
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
* entries () {
|
|
41
|
-
for (const [str, bytes] of this.#blocks) {
|
|
42
|
-
yield { cid: parse(str), bytes }
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
export class MultiBlockFetcher {
|
|
48
|
-
/** @type {BlockFetcher[]} */
|
|
49
|
-
#fetchers
|
|
50
|
-
|
|
51
|
-
/** @param {BlockFetcher[]} fetchers */
|
|
52
|
-
constructor (...fetchers) {
|
|
53
|
-
this.#fetchers = fetchers
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
/** @param {import('../src/link').AnyLink} link */
|
|
57
|
-
async get (link) {
|
|
58
|
-
for (const f of this.#fetchers) {
|
|
59
|
-
const v = await f.get(link)
|
|
60
|
-
if (v) {
|
|
61
|
-
return v
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
}
|