@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.
Files changed (52) hide show
  1. package/README.md +1 -1
  2. package/dist/bundle.js +2168 -0
  3. package/dist/src/blockstore.d.ts +115 -0
  4. package/dist/src/blockstore.d.ts.map +1 -0
  5. package/dist/src/clock.d.ts +98 -0
  6. package/dist/src/clock.d.ts.map +1 -0
  7. package/dist/src/crypto.d.ts +18 -0
  8. package/dist/src/crypto.d.ts.map +1 -0
  9. package/dist/src/db-index.d.ts +116 -0
  10. package/dist/src/db-index.d.ts.map +1 -0
  11. package/dist/src/fireproof.d.ts +167 -0
  12. package/dist/src/fireproof.d.ts.map +1 -0
  13. package/dist/src/hydrator.d.ts +6 -0
  14. package/dist/src/hydrator.d.ts.map +1 -0
  15. package/dist/src/index.d.ts +6 -0
  16. package/dist/src/index.d.ts.map +1 -0
  17. package/dist/src/listener.d.ts +36 -0
  18. package/dist/src/listener.d.ts.map +1 -0
  19. package/dist/src/prolly.d.ts +83 -0
  20. package/dist/src/prolly.d.ts.map +1 -0
  21. package/dist/src/sha1.d.ts +9 -0
  22. package/dist/src/sha1.d.ts.map +1 -0
  23. package/dist/src/valet.d.ts +34 -0
  24. package/dist/src/valet.d.ts.map +1 -0
  25. package/dist/tsconfig.tsbuildinfo +1 -0
  26. package/package.json +39 -5
  27. package/src/blockstore.js +24 -23
  28. package/src/clock.js +4 -3
  29. package/src/crypto.js +1 -0
  30. package/src/db-index.js +23 -18
  31. package/src/fireproof.js +31 -26
  32. package/src/hydrator.js +3 -3
  33. package/src/index.js +6 -0
  34. package/src/listener.js +9 -8
  35. package/src/prolly.js +12 -25
  36. package/src/sha1.js +2 -1
  37. package/src/valet.js +22 -20
  38. package/hooks/use-fireproof.js +0 -135
  39. package/index.js +0 -6
  40. package/scripts/keygen.js +0 -3
  41. package/test/block.js +0 -65
  42. package/test/clock.test.js +0 -694
  43. package/test/db-index.test.js +0 -261
  44. package/test/fireproof.test.js +0 -493
  45. package/test/fulltext.test.js +0 -66
  46. package/test/helpers.js +0 -45
  47. package/test/hydrator.test.js +0 -81
  48. package/test/listener.test.js +0 -102
  49. package/test/prolly.test.js +0 -190
  50. package/test/proofs.test.js +0 -53
  51. package/test/reproduce-fixture-bug.test.js +0 -65
  52. 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
- }