@fireproof/core 0.10.0-dev → 0.10.1-dev

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 (90) hide show
  1. package/package.json +5 -1
  2. package/.eslintrc.cjs +0 -37
  3. package/.vscode/launch.json +0 -12
  4. package/dist/crdt-helpers.browser.js +0 -4961
  5. package/dist/crdt-helpers.browser.js.map +0 -7
  6. package/dist/crdt-helpers.cjs.js +0 -4823
  7. package/dist/crdt-helpers.cjs.js.map +0 -7
  8. package/dist/crdt-helpers.esm.js +0 -4788
  9. package/dist/crdt-helpers.esm.js.map +0 -7
  10. package/dist/crdt.browser.js +0 -18214
  11. package/dist/crdt.browser.js.map +0 -7
  12. package/dist/crdt.cjs.js +0 -8692
  13. package/dist/crdt.cjs.js.map +0 -7
  14. package/dist/crdt.esm.js +0 -8682
  15. package/dist/crdt.esm.js.map +0 -7
  16. package/dist/database.browser.js +0 -18867
  17. package/dist/database.browser.js.map +0 -7
  18. package/dist/database.cjs.js +0 -9296
  19. package/dist/database.cjs.js.map +0 -7
  20. package/dist/database.esm.js +0 -9288
  21. package/dist/database.esm.js.map +0 -7
  22. package/dist/loader-helpers.browser.js +0 -6943
  23. package/dist/loader-helpers.browser.js.map +0 -7
  24. package/dist/loader-helpers.cjs.js +0 -4419
  25. package/dist/loader-helpers.cjs.js.map +0 -7
  26. package/dist/loader-helpers.esm.js +0 -4408
  27. package/dist/loader-helpers.esm.js.map +0 -7
  28. package/dist/loader.browser.js +0 -15968
  29. package/dist/loader.browser.js.map +0 -7
  30. package/dist/loader.cjs.js +0 -6667
  31. package/dist/loader.cjs.js.map +0 -7
  32. package/dist/loader.esm.js +0 -6657
  33. package/dist/loader.esm.js.map +0 -7
  34. package/dist/store-browser.browser.js +0 -1414
  35. package/dist/store-browser.browser.js.map +0 -7
  36. package/dist/store-browser.cjs.js +0 -1387
  37. package/dist/store-browser.cjs.js.map +0 -7
  38. package/dist/store-browser.esm.js +0 -1358
  39. package/dist/store-browser.esm.js.map +0 -7
  40. package/dist/store-fs.browser.js +0 -16142
  41. package/dist/store-fs.browser.js.map +0 -7
  42. package/dist/store-fs.cjs.js +0 -1171
  43. package/dist/store-fs.cjs.js.map +0 -7
  44. package/dist/store-fs.esm.js +0 -1143
  45. package/dist/store-fs.esm.js.map +0 -7
  46. package/dist/store.browser.js +0 -1113
  47. package/dist/store.browser.js.map +0 -7
  48. package/dist/store.cjs.js +0 -1126
  49. package/dist/store.cjs.js.map +0 -7
  50. package/dist/store.esm.js +0 -1097
  51. package/dist/store.esm.js.map +0 -7
  52. package/dist/transaction.browser.js +0 -17241
  53. package/dist/transaction.browser.js.map +0 -7
  54. package/dist/transaction.cjs.js +0 -7842
  55. package/dist/transaction.cjs.js.map +0 -7
  56. package/dist/transaction.esm.js +0 -7831
  57. package/dist/transaction.esm.js.map +0 -7
  58. package/dist/types.d.browser.js +0 -4
  59. package/dist/types.d.browser.js.map +0 -7
  60. package/dist/types.d.cjs.js +0 -19
  61. package/dist/types.d.cjs.js.map +0 -7
  62. package/dist/types.d.esm.js +0 -1
  63. package/dist/types.d.esm.js.map +0 -7
  64. package/scripts/analyze.js +0 -31
  65. package/scripts/build.js +0 -20
  66. package/scripts/serve.js +0 -20
  67. package/scripts/settings.js +0 -65
  68. package/scripts/test.js +0 -14
  69. package/src/crdt-helpers.ts +0 -89
  70. package/src/crdt.ts +0 -45
  71. package/src/database.ts +0 -61
  72. package/src/fireproof.ts +0 -6
  73. package/src/loader-helpers.ts +0 -53
  74. package/src/loader.ts +0 -66
  75. package/src/store-browser.ts +0 -76
  76. package/src/store-fs.ts +0 -51
  77. package/src/store.ts +0 -32
  78. package/src/transaction.ts +0 -68
  79. package/src/types.d.ts +0 -38
  80. package/test/crdt.test.js +0 -142
  81. package/test/database.test.js +0 -144
  82. package/test/fireproof.test.js +0 -50
  83. package/test/globals.d.ts +0 -4
  84. package/test/hello.test.js +0 -9
  85. package/test/helpers.js +0 -34
  86. package/test/loader.test.js +0 -112
  87. package/test/store-fs.test.js +0 -105
  88. package/test/transaction.test.js +0 -90
  89. package/tsconfig.json +0 -18
  90. package/webpack.config.cjs +0 -17
@@ -1,105 +0,0 @@
1
- /* eslint-disable @typescript-eslint/no-unsafe-assignment */
2
- /* eslint-disable @typescript-eslint/no-unsafe-call */
3
- /* eslint-disable @typescript-eslint/no-unsafe-member-access */
4
- /* eslint-disable mocha/max-top-level-suites */
5
- /* eslint-disable @typescript-eslint/no-unsafe-argument */
6
- import { join } from 'node:path'
7
- import { readFile } from 'node:fs/promises'
8
-
9
- import { CID } from 'multiformats'
10
-
11
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
12
- import { assert, matches, equals } from './helpers.js'
13
-
14
- import { CarStoreFS, defaultConfig, HeaderStoreFS } from '../dist/store-fs.esm.js'
15
-
16
- const decoder = new TextDecoder('utf-8')
17
-
18
- describe('CarStoreFS', function () {
19
- /** @type {CarStoreFS} */
20
- let loader
21
- beforeEach(function () {
22
- loader = new CarStoreFS('test')
23
- })
24
- it('should have a name', function () {
25
- equals(loader.name, 'test')
26
- })
27
- it('should save a car', async function () {
28
- const car = {
29
- cid: 'cid',
30
- bytes: new Uint8Array([55, 56, 57])
31
- }
32
- await loader.save(car)
33
- const path = join(defaultConfig.dataDir, loader.name, car.cid + '.car')
34
- const data = await readFile(path)
35
- equals(data.toString(), decoder.decode(car.bytes))
36
- })
37
- })
38
-
39
- describe('CarStoreFS with a saved car', function () {
40
- /** @type {CarStoreFS} */
41
- let loader, car
42
- beforeEach(async function () {
43
- loader = new CarStoreFS('test2')
44
- car = {
45
- cid: 'cid',
46
- bytes: new Uint8Array([55, 56, 57, 80])
47
- }
48
- await loader.save(car)
49
- })
50
- it('should have a car', async function () {
51
- const path = join(defaultConfig.dataDir, loader.name, car.cid + '.car')
52
- const data = await readFile(path)
53
- equals(data.toString(), decoder.decode(car.bytes))
54
- })
55
- it('should load a car', async function () {
56
- const loaded = await loader.load(car.cid)
57
- equals(loaded.cid, car.cid)
58
- equals(loaded.bytes.constructor.name, 'Uint8Array')
59
- equals(loaded.bytes.toString(), car.bytes.toString())
60
- })
61
- })
62
-
63
- describe('HeaderStoreFS', function () {
64
- /** @type {HeaderStoreFS} */
65
- let loader
66
- beforeEach(function () {
67
- loader = new HeaderStoreFS('test')
68
- })
69
- it('should have a name', function () {
70
- equals(loader.name, 'test')
71
- })
72
- it('should save a header', async function () {
73
- const cid = CID.parse('bafybeia4luuns6dgymy5kau5rm7r4qzrrzg6cglpzpogussprpy42cmcn4')
74
- await loader.save(cid)
75
- const path = join(defaultConfig.dataDir, loader.name, 'main.json')
76
- const file = await readFile(path)
77
- const header = JSON.parse(file.toString())
78
- assert(header)
79
- assert(header.car)
80
- equals(header.car, cid.toString())
81
- })
82
- })
83
-
84
- describe('HeaderStoreFS with a saved header', function () {
85
- /** @type {HeaderStoreFS} */
86
- let loader
87
- beforeEach(async function () {
88
- loader = new HeaderStoreFS('test-saved-header')
89
- const cid = CID.parse('bafybeia4luuns6dgymy5kau5rm7r4qzrrzg6cglpzpogussprpy42cmcn4')
90
- await loader.save(cid)
91
- })
92
- it('should have a header', async function () {
93
- const path = join(defaultConfig.dataDir, loader.name, 'main.json')
94
- const data = await readFile(path)
95
- matches(data, /car/)
96
- const header = JSON.parse(data.toString())
97
- assert(header)
98
- assert(header.car)
99
- })
100
- it('should load a header', async function () {
101
- const loaded = await loader.load()
102
- assert(loaded)
103
- assert(loaded.car)
104
- })
105
- })
@@ -1,90 +0,0 @@
1
- /* eslint-disable @typescript-eslint/no-unsafe-return */
2
- /* eslint-disable @typescript-eslint/no-unsafe-call */
3
- /* eslint-disable @typescript-eslint/no-unsafe-assignment */
4
- /* eslint-disable @typescript-eslint/no-unsafe-member-access */
5
- /* eslint-disable @typescript-eslint/require-await */
6
- /* eslint-disable mocha/max-top-level-suites */
7
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
8
- import { assert, equals, notEquals, matches, equalsJSON } from './helpers.js'
9
- import { TransactionBlockstore as Blockstore, Transaction } from '../dist/transaction.esm.js'
10
-
11
- describe('Fresh TransactionBlockstore', function () {
12
- /** @type {Blockstore} */
13
- let blocks
14
- beforeEach(function () {
15
- blocks = new Blockstore()
16
- })
17
- it('should not have a name', function () {
18
- assert(!blocks.name)
19
- })
20
- it('should not have a loader', function () {
21
- assert(!blocks._loader)
22
- })
23
- it('should not put', async function () {
24
- const e = await blocks.put('key', 'value').catch(e => e)
25
- matches(e.message, /transaction/)
26
- })
27
- it('should yield a transaction', async function () {
28
- const txR = await blocks.transaction((tblocks) => {
29
- assert(tblocks)
30
- assert(tblocks instanceof Transaction)
31
- return { head: [] }
32
- })
33
- assert(txR)
34
- equalsJSON(txR, { head: [] })
35
- })
36
- })
37
-
38
- describe('TransactionBlockstore with name', function () {
39
- /** @type {Blockstore} */
40
- let blocks
41
- beforeEach(function () {
42
- blocks = new Blockstore('test')
43
- })
44
- it('should have a name', function () {
45
- equals(blocks.name, 'test')
46
- })
47
- it('should have a loader', function () {
48
- assert(blocks.loader)
49
- })
50
- it('should get from loader', async function () {
51
- blocks.loader.getBlock = async (cid) => {
52
- return { cid, bytes: 'bytes' }
53
- }
54
- const value = await blocks.get('key')
55
- equalsJSON(value, { cid: 'key', bytes: 'bytes' })
56
- })
57
- })
58
-
59
- describe('A transaction', function () {
60
- /** @type {Transaction} */
61
- let tblocks, blocks
62
- beforeEach(async function () {
63
- blocks = new Blockstore()
64
- tblocks = new Transaction(blocks)
65
- blocks.transactions.add(tblocks)
66
- })
67
- it('should put and get', async function () {
68
- await tblocks.put('key', 'bytes')
69
- assert(blocks.transactions.has(tblocks))
70
- const got = await tblocks.get('key')
71
- assert(got)
72
- equals(got.cid, 'key')
73
- equals(got.bytes, 'bytes')
74
- })
75
- })
76
-
77
- describe('TransactionBlockstore with a completed transaction', function () {
78
- let blocks
79
- beforeEach(async function () {
80
- blocks = new Blockstore()
81
- await blocks.transaction(async (tblocks) => {
82
- return await tblocks.put('key', 'value')
83
- })
84
- })
85
- it('should get', async function () {
86
- const value = await blocks.get('key')
87
- equals(value.cid, 'key')
88
- equals(value.bytes, 'value')
89
- })
90
- })
package/tsconfig.json DELETED
@@ -1,18 +0,0 @@
1
- {
2
- "include": ["src", "test", ".eslintrc.cjs", "scripts"],
3
- "compilerOptions": {
4
- "module": "esnext",
5
- "target": "esnext",
6
- "lib": ["dom", "dom.iterable", "esnext"],
7
- "declaration": true,
8
- "strict": true,
9
- "moduleResolution": "node",
10
- "jsx": "react",
11
- "skipLibCheck": true,
12
- "esModuleInterop": true,
13
- "emitDeclarationOnly": true,
14
- "outDir": "dist",
15
- "rootDir": "src",
16
- "forceConsistentCasingInFileNames": true
17
- }
18
- }
@@ -1,17 +0,0 @@
1
- module.exports = {
2
- module: {
3
- rules: [
4
- {
5
- test: /\.tsx?$/,
6
- use: 'ts-loader',
7
- exclude: /node_modules/
8
- }
9
- ]
10
- },
11
- resolve: {
12
- extensions: ['.tsx', '.ts', '.js'],
13
- fallback: {
14
- assert: require.resolve('browser-assert')
15
- }
16
- }
17
- }