@fireproof/core 0.19.121-dev → 0.20.0-dev-preview-05
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +13 -12
- package/deno/index.d.ts +7 -0
- package/deno/index.js +66 -0
- package/deno/index.js.map +1 -0
- package/deno/metafile-esm.json +1 -0
- package/deno.json +3 -4
- package/index.cjs +1797 -1431
- package/index.cjs.map +1 -1
- package/index.d.cts +760 -381
- package/index.d.ts +760 -381
- package/index.js +1976 -913
- package/index.js.map +1 -1
- package/metafile-cjs.json +1 -1
- package/metafile-esm.json +1 -1
- package/node/{node-filesystem.cjs → index.cjs} +17 -6
- package/node/index.cjs.map +1 -0
- package/node/index.d.cts +7 -0
- package/node/index.d.ts +7 -0
- package/node/{node-filesystem.js → index.js} +25 -5
- package/node/index.js.map +1 -0
- package/node/metafile-cjs.json +1 -1
- package/node/metafile-esm.json +1 -1
- package/package.json +27 -17
- package/react/index.cjs +22 -22
- package/react/index.cjs.map +1 -1
- package/react/index.d.cts +7 -7
- package/react/index.d.ts +7 -7
- package/react/index.js +22 -22
- package/react/index.js.map +1 -1
- package/react/metafile-cjs.json +1 -1
- package/react/metafile-esm.json +1 -1
- package/tests/blockstore/fp-envelope.test.ts-off +65 -0
- package/tests/blockstore/interceptor-gateway.test.ts +122 -0
- package/tests/blockstore/keyed-crypto-indexdb-file.test.ts +130 -0
- package/tests/blockstore/keyed-crypto.test.ts +75 -118
- package/tests/blockstore/loader.test.ts +18 -9
- package/tests/blockstore/store.test.ts +40 -31
- package/tests/blockstore/transaction.test.ts +14 -13
- package/tests/fireproof/all-gateway.test.ts +286 -216
- package/tests/fireproof/cars/bafkreidxwt2nhvbl4fnqfw3ctlt6zbrir4kqwmjo5im6rf4q5si27kgo2i.ts +324 -316
- package/tests/fireproof/crdt.test.ts +78 -19
- package/tests/fireproof/fireproof.test.ts +111 -92
- package/tests/fireproof/hello.test.ts +21 -17
- package/tests/fireproof/indexer.test.ts +74 -50
- package/tests/fireproof/{database.test.ts → ledger.test.ts} +241 -45
- package/tests/fireproof/multiple-ledger.test.ts +2 -2
- package/tests/fireproof/utils.test.ts +47 -6
- package/tests/gateway/file/loader-config.test.ts +307 -0
- package/tests/gateway/fp-envelope-serialize.test.ts +256 -0
- package/tests/gateway/indexdb/loader-config.test.ts +79 -0
- package/tests/helpers.ts +44 -17
- package/tests/react/useFireproof.test.tsx +2 -2
- package/tests/www/gallery.html +2 -2
- package/tests/www/todo-aws.html +1 -1
- package/tests/www/todo-ipfs.html +1 -1
- package/tests/www/todo-local.html +1 -1
- package/tests/www/todo.html +25 -4
- package/web/index.cjs +218 -0
- package/web/index.cjs.map +1 -0
- package/web/index.d.cts +30 -0
- package/web/index.d.ts +30 -0
- package/web/index.js +195 -0
- package/web/index.js.map +1 -0
- package/web/metafile-cjs.json +1 -1
- package/web/metafile-esm.json +1 -1
- package/chunk-7EWIAXTM.js +0 -7
- package/chunk-7EWIAXTM.js.map +0 -1
- package/chunk-F4FC6B2T.js +0 -63
- package/chunk-F4FC6B2T.js.map +0 -1
- package/chunk-PZ5AY32C.js +0 -10
- package/chunk-PZ5AY32C.js.map +0 -1
- package/chunk-RXC4JGJT.js +0 -301
- package/chunk-RXC4JGJT.js.map +0 -1
- package/gateway-C62S56GY.js +0 -66
- package/gateway-C62S56GY.js.map +0 -1
- package/gateway-VVS4QWDA.js +0 -145
- package/gateway-VVS4QWDA.js.map +0 -1
- package/key-bag-file-PWZ3QE7B.js +0 -55
- package/key-bag-file-PWZ3QE7B.js.map +0 -1
- package/key-bag-indexdb-SYG3YD4D.js +0 -51
- package/key-bag-indexdb-SYG3YD4D.js.map +0 -1
- package/node/chunk-4A4RAVNS.js +0 -17
- package/node/chunk-4A4RAVNS.js.map +0 -1
- package/node/mem-filesystem.cjs +0 -72
- package/node/mem-filesystem.cjs.map +0 -1
- package/node/mem-filesystem.d.cts +0 -25
- package/node/mem-filesystem.d.ts +0 -25
- package/node/mem-filesystem.js +0 -40
- package/node/mem-filesystem.js.map +0 -1
- package/node/node-filesystem.cjs.map +0 -1
- package/node/node-filesystem.d.cts +0 -35
- package/node/node-filesystem.d.ts +0 -35
- package/node/node-filesystem.js.map +0 -1
- package/tests/fireproof/config.test.ts +0 -172
- package/utils-ZVVGAXFE.js +0 -13
- package/utils-ZVVGAXFE.js.map +0 -1
- package/web/gateway-impl.cjs +0 -183
- package/web/gateway-impl.cjs.map +0 -1
- package/web/gateway-impl.d.cts +0 -31
- package/web/gateway-impl.d.ts +0 -31
- package/web/gateway-impl.js +0 -162
- package/web/gateway-impl.js.map +0 -1
- /package/tests/blockstore/{fragment-gateway.test.ts → fragment-gateway.test.ts-off} +0 -0
package/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# <img src="https://fireproof.storage/static/img/flame.svg" alt="Fireproof logo" width="25"> [Fireproof](https://fireproof.storage) realtime
|
1
|
+
# <img src="https://fireproof.storage/static/img/flame.svg" alt="Fireproof logo" width="25"> [Fireproof](https://fireproof.storage) realtime ledger
|
2
2
|
|
3
3
|
<p align="right">
|
4
4
|
<img src="https://img.shields.io/bundlephobia/minzip/%40fireproof%2Fcore" alt="Package size">
|
@@ -9,11 +9,11 @@
|
|
9
9
|
|
10
10
|
### No setup: write features first, access your data anywhere
|
11
11
|
|
12
|
-
Add collaboration to any app with Fireproof. Access data from JavaScript servers and edge functions. Use live queries to update your UI automatically when the
|
12
|
+
Add collaboration to any app with Fireproof. Access data from JavaScript servers and edge functions. Use live queries to update your UI automatically when the ledger changes. [Connect realtime sync](https://www.npmjs.com/package/@fireproof/connect) and those changes will sync between browsers and backend functions. Apps built this way are multi-player by default.
|
13
13
|
|
14
14
|
### JavaScript quick start
|
15
15
|
|
16
|
-
The document
|
16
|
+
The document ledger API will feel familiar. Queries use dynamic indexes, and the ledger can refresh your UI, as seen in the `db.subscribe` call below, as well as the React liveQuery hook.
|
17
17
|
|
18
18
|
```js
|
19
19
|
import { fireproof } from "@fireproof/core";
|
@@ -32,34 +32,35 @@ beyonceDoc.hitSingles += 1;
|
|
32
32
|
await db.put(beyonceDoc);
|
33
33
|
```
|
34
34
|
|
35
|
-
Jump to the docs site [for JavaScript API basics.](https://use-fireproof.com/docs/
|
35
|
+
Jump to the docs site [for JavaScript API basics.](https://use-fireproof.com/docs/ledger-api/basics)
|
36
36
|
|
37
37
|
### Live data hooks for React
|
38
38
|
|
39
39
|
Fireproof [React hooks for live data](https://use-fireproof.com/docs/category/react-hooks) avoid boilerplate and make building collaborative apps a breeze.
|
40
40
|
|
41
41
|
```js
|
42
|
-
import {
|
42
|
+
import { useFireproof } from 'use-fireproof'
|
43
43
|
|
44
44
|
function App() {
|
45
|
+
const { useLiveQuery, useDocument } = useFireproof("my-db-name")
|
45
46
|
const completedTodos = useLiveQuery('completed', { limit: 10 })
|
46
|
-
const [newTodo,
|
47
|
+
const [newTodo, setNewTodo, saveNewTodo] = useDocument(() => ({type: 'todo', text: '', completed: false, created: Date.now() }))
|
47
48
|
```
|
48
49
|
|
49
50
|
Read the [step-by-step React tutorial](https://use-fireproof.com/docs/react-tutorial) to get started.
|
50
51
|
|
51
52
|
## Why choose Fireproof
|
52
53
|
|
53
|
-
Compared to other embedded
|
54
|
+
Compared to other embedded ledgers, Fireproof:
|
54
55
|
|
55
56
|
- is network aware, encrypted, and multi-writer safe
|
56
57
|
- is designed for real-time collaboration with CRDTs
|
57
58
|
- offers cryptographic causal integrity for all operations
|
58
59
|
- is built for the web, with a small package size and no wasm
|
59
60
|
|
60
|
-
Deliver interactive experiences without waiting on the backend. Fireproof runs in any cloud, browser, or edge environment, so your application can access data anywhere.
|
61
|
+
Deliver interactive experiences without waiting on the backend. Fireproof runs in any cloud, browser, or edge environment, so your application can access tamperproof data anywhere.
|
61
62
|
|
62
|
-
[Get the latest roadmap updates on our blog](https://fireproof.storage/blog/) or join our [Discord](https://discord.gg/cCryrNHePH) to collaborate. Read the docs to learn more about the
|
63
|
+
[Get the latest roadmap updates on our blog](https://fireproof.storage/blog/) or join our [Discord](https://discord.gg/cCryrNHePH) to collaborate. Read the docs to learn more about the ledger [architecture](https://use-fireproof.com/docs/architecture).
|
63
64
|
|
64
65
|
### Use cases
|
65
66
|
|
@@ -83,7 +84,7 @@ Get started with the React hooks:
|
|
83
84
|
npm install use-fireproof
|
84
85
|
```
|
85
86
|
|
86
|
-
or install the
|
87
|
+
or install the ledger in any JavaScript environment:
|
87
88
|
|
88
89
|
```sh
|
89
90
|
npm install @fireproof/core
|
@@ -95,7 +96,7 @@ The default build is optimized for browsers, to load the node build add `/node`:
|
|
95
96
|
import { fireproof } from "@fireproof/core/node";
|
96
97
|
```
|
97
98
|
|
98
|
-
Add the
|
99
|
+
Add the ledger to any web page via HTML script tag (global is `Fireproof`):
|
99
100
|
|
100
101
|
```html
|
101
102
|
<script src="https://cdn.jsdelivr.net/npm/@fireproof/core/dist/browser/fireproof.global.js"></script>
|
@@ -165,7 +166,7 @@ pnpm run build:doc
|
|
165
166
|
|
166
167
|
## Thanks 🙏
|
167
168
|
|
168
|
-
Fireproof is a synthesis of work done by people in the web community over the years. I couldn't even begin to name all the folks who made pivotal contributions. Without npm, React, and VS Code all this would have taken so much longer. Thanks to everyone who supported me getting into
|
169
|
+
Fireproof is a synthesis of work done by people in the web community over the years. I couldn't even begin to name all the folks who made pivotal contributions. Without npm, React, and VS Code all this would have taken so much longer. Thanks to everyone who supported me getting into ledger development via Apache CouchDB, one of the original document ledgers. The distinguishing work on immutable data-structures comes from the years of consideration [IPFS](https://ipfs.tech), [IPLD](https://ipld.io), and the [Filecoin APIs](https://docs.filecoin.io) have enjoyed.
|
169
170
|
|
170
171
|
Thanks to Alan Shaw and Mikeal Rogers without whom this project would have never got started. The core Merkle hash-tree clock is based on [Alan's Pail](https://github.com/alanshaw/pail), and you can see the repository history goes all the way back to work begun as a branch of that repo. Mikeal wrote [the prolly trees implementation](https://github.com/mikeal/prolly-trees).
|
171
172
|
|
package/deno/index.d.ts
ADDED
package/deno/index.js
ADDED
@@ -0,0 +1,66 @@
|
|
1
|
+
// src/runtime/gateways/file/deno/deno-filesystem.ts
|
2
|
+
var DenoFileSystem = class {
|
3
|
+
async start() {
|
4
|
+
this.fs = Deno;
|
5
|
+
return this;
|
6
|
+
}
|
7
|
+
async mkdir(path, options) {
|
8
|
+
return this.fs?.mkdir(path, options).then(() => path);
|
9
|
+
}
|
10
|
+
async readdir(path) {
|
11
|
+
const ret = [];
|
12
|
+
for await (const dirEntry of this.fs.readdir(path)) {
|
13
|
+
ret.push(dirEntry.name);
|
14
|
+
}
|
15
|
+
return ret;
|
16
|
+
}
|
17
|
+
async rm(path, options) {
|
18
|
+
return this.fs?.rm(path, options);
|
19
|
+
}
|
20
|
+
async copyFile(source, destination) {
|
21
|
+
return this.fs?.copyFile(source, destination);
|
22
|
+
}
|
23
|
+
async readfile(path) {
|
24
|
+
return this.fs.readFile(path);
|
25
|
+
}
|
26
|
+
async stat(path) {
|
27
|
+
const x = await this.fs.stat(path);
|
28
|
+
return {
|
29
|
+
isFile: () => x.isFile,
|
30
|
+
isDirectory: () => x.isDirectory,
|
31
|
+
isBlockDevice: () => !!x.isBlockDevice,
|
32
|
+
isCharacterDevice: () => !!x.isCharDevice,
|
33
|
+
isSymbolicLink: () => !!x.isSymlink,
|
34
|
+
isFIFO: () => !!x.isFifo,
|
35
|
+
isSocket: () => !!x.isSocket,
|
36
|
+
uid: x.uid,
|
37
|
+
gid: x.gid,
|
38
|
+
size: x.size,
|
39
|
+
atime: x.atime,
|
40
|
+
mtime: x.mtime,
|
41
|
+
ctime: x.birthtime,
|
42
|
+
birthtime: x.birthtime
|
43
|
+
};
|
44
|
+
}
|
45
|
+
async unlink(path) {
|
46
|
+
return this.fs?.unlink(path);
|
47
|
+
}
|
48
|
+
async writefile(path, data) {
|
49
|
+
return this.fs?.writeFile(path, Buffer.from(data));
|
50
|
+
}
|
51
|
+
};
|
52
|
+
|
53
|
+
// src/runtime/gateways/file/deno/get-sys-file-system.ts
|
54
|
+
import { ResolveOnce } from "@adviser/cement";
|
55
|
+
var nfs = new ResolveOnce();
|
56
|
+
async function getSysFileSystem(url) {
|
57
|
+
return nfs.once(async () => {
|
58
|
+
const nfs2 = new DenoFileSystem();
|
59
|
+
await nfs2.start();
|
60
|
+
return nfs2;
|
61
|
+
});
|
62
|
+
}
|
63
|
+
export {
|
64
|
+
getSysFileSystem
|
65
|
+
};
|
66
|
+
//# sourceMappingURL=index.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["../../../src/runtime/gateways/file/deno/deno-filesystem.ts","../../../src/runtime/gateways/file/deno/get-sys-file-system.ts"],"sourcesContent":["import type { FPStats, SysFileSystem } from \"@fireproof/core\";\n\nexport class DenoFileSystem implements SysFileSystem {\n fs?: {\n mkdir: typeof Deno.mkdir;\n readdir: typeof Deno.readDir;\n rm: typeof Deno.remove;\n copyFile: typeof Deno.copyFile;\n readFile: typeof Deno.readFile;\n stat: typeof Deno.stat;\n unlink: typeof Deno.remove;\n writeFile: typeof Deno.writeFile;\n };\n\n async start(): Promise<SysFileSystem> {\n this.fs = Deno as unknown as DenoFileSystem[\"fs\"];\n return this;\n }\n async mkdir(path: string, options?: { recursive: boolean }): Promise<string | undefined> {\n return this.fs?.mkdir(path, options).then(() => path);\n }\n async readdir(path: string): Promise<string[]> {\n const ret = [];\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n for await (const dirEntry of this.fs!.readdir(path)) {\n ret.push(dirEntry.name);\n }\n return ret;\n }\n async rm(path: string, options?: { recursive: boolean }): Promise<void> {\n return this.fs?.rm(path, options);\n }\n async copyFile(source: string, destination: string): Promise<void> {\n return this.fs?.copyFile(source, destination);\n }\n async readfile(path: string): Promise<Uint8Array> {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n return this.fs!.readFile(path);\n }\n async stat(path: string): Promise<FPStats> {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const x = await this.fs!.stat(path);\n return {\n isFile: () => x.isFile,\n isDirectory: () => x.isDirectory,\n isBlockDevice: () => !!x.isBlockDevice,\n isCharacterDevice: () => !!x.isCharDevice,\n isSymbolicLink: () => !!x.isSymlink,\n isFIFO: () => !!x.isFifo,\n isSocket: () => !!x.isSocket,\n uid: x.uid,\n gid: x.gid,\n size: x.size,\n atime: x.atime,\n mtime: x.mtime,\n ctime: x.birthtime,\n birthtime: x.birthtime,\n };\n }\n async unlink(path: string): Promise<void> {\n return this.fs?.unlink(path);\n }\n async writefile(path: string, data: Uint8Array | string): Promise<void> {\n return this.fs?.writeFile(path, Buffer.from(data));\n }\n}\n","import type { SysFileSystem } from \"@fireproof/core\";\nimport { DenoFileSystem } from \"./deno-filesystem.js\";\nimport { ResolveOnce, URI } from \"@adviser/cement\";\n\nconst nfs = new ResolveOnce<SysFileSystem>();\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\nexport async function getSysFileSystem(url: URI): Promise<SysFileSystem> {\n return nfs.once(async () => {\n const nfs = new DenoFileSystem();\n await nfs.start();\n return nfs;\n });\n}\n"],"mappings":";AAEO,IAAM,iBAAN,MAA8C;AAAA,EAYnD,MAAM,QAAgC;AACpC,SAAK,KAAK;AACV,WAAO;AAAA,EACT;AAAA,EACA,MAAM,MAAM,MAAc,SAA+D;AACvF,WAAO,KAAK,IAAI,MAAM,MAAM,OAAO,EAAE,KAAK,MAAM,IAAI;AAAA,EACtD;AAAA,EACA,MAAM,QAAQ,MAAiC;AAC7C,UAAM,MAAM,CAAC;AAEb,qBAAiB,YAAY,KAAK,GAAI,QAAQ,IAAI,GAAG;AACnD,UAAI,KAAK,SAAS,IAAI;AAAA,IACxB;AACA,WAAO;AAAA,EACT;AAAA,EACA,MAAM,GAAG,MAAc,SAAiD;AACtE,WAAO,KAAK,IAAI,GAAG,MAAM,OAAO;AAAA,EAClC;AAAA,EACA,MAAM,SAAS,QAAgB,aAAoC;AACjE,WAAO,KAAK,IAAI,SAAS,QAAQ,WAAW;AAAA,EAC9C;AAAA,EACA,MAAM,SAAS,MAAmC;AAEhD,WAAO,KAAK,GAAI,SAAS,IAAI;AAAA,EAC/B;AAAA,EACA,MAAM,KAAK,MAAgC;AAEzC,UAAM,IAAI,MAAM,KAAK,GAAI,KAAK,IAAI;AAClC,WAAO;AAAA,MACL,QAAQ,MAAM,EAAE;AAAA,MAChB,aAAa,MAAM,EAAE;AAAA,MACrB,eAAe,MAAM,CAAC,CAAC,EAAE;AAAA,MACzB,mBAAmB,MAAM,CAAC,CAAC,EAAE;AAAA,MAC7B,gBAAgB,MAAM,CAAC,CAAC,EAAE;AAAA,MAC1B,QAAQ,MAAM,CAAC,CAAC,EAAE;AAAA,MAClB,UAAU,MAAM,CAAC,CAAC,EAAE;AAAA,MACpB,KAAK,EAAE;AAAA,MACP,KAAK,EAAE;AAAA,MACP,MAAM,EAAE;AAAA,MACR,OAAO,EAAE;AAAA,MACT,OAAO,EAAE;AAAA,MACT,OAAO,EAAE;AAAA,MACT,WAAW,EAAE;AAAA,IACf;AAAA,EACF;AAAA,EACA,MAAM,OAAO,MAA6B;AACxC,WAAO,KAAK,IAAI,OAAO,IAAI;AAAA,EAC7B;AAAA,EACA,MAAM,UAAU,MAAc,MAA0C;AACtE,WAAO,KAAK,IAAI,UAAU,MAAM,OAAO,KAAK,IAAI,CAAC;AAAA,EACnD;AACF;;;AC/DA,SAAS,mBAAwB;AAEjC,IAAM,MAAM,IAAI,YAA2B;AAE3C,eAAsB,iBAAiB,KAAkC;AACvE,SAAO,IAAI,KAAK,YAAY;AAC1B,UAAMA,OAAM,IAAI,eAAe;AAC/B,UAAMA,KAAI,MAAM;AAChB,WAAOA;AAAA,EACT,CAAC;AACH;","names":["nfs"]}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"inputs":{"src/runtime/gateways/file/deno/deno-filesystem.ts":{"bytes":2181,"imports":[],"format":"esm"},"src/runtime/gateways/file/deno/get-sys-file-system.ts":{"bytes":462,"imports":[{"path":"src/runtime/gateways/file/deno/deno-filesystem.ts","kind":"import-statement","original":"./deno-filesystem.js"},{"path":"@adviser/cement","kind":"import-statement","external":true}],"format":"esm"},"src/runtime/gateways/file/deno/index.ts":{"bytes":61,"imports":[{"path":"src/runtime/gateways/file/deno/get-sys-file-system.ts","kind":"import-statement","original":"./get-sys-file-system.js"}],"format":"esm"}},"outputs":{"dist/fireproof-core/deno/index.js.map":{"imports":[],"exports":[],"inputs":{},"bytes":4331},"dist/fireproof-core/deno/index.js":{"imports":[{"path":"@adviser/cement","kind":"import-statement","external":true}],"exports":["getSysFileSystem"],"entryPoint":"src/runtime/gateways/file/deno/index.ts","inputs":{"src/runtime/gateways/file/deno/deno-filesystem.ts":{"bytesInOutput":1243},"src/runtime/gateways/file/deno/get-sys-file-system.ts":{"bytesInOutput":235},"src/runtime/gateways/file/deno/index.ts":{"bytesInOutput":0}},"bytes":1620}}}
|
package/deno.json
CHANGED
@@ -1,14 +1,13 @@
|
|
1
1
|
{
|
2
2
|
"imports": {
|
3
3
|
"@fireproof/core": "./index.js",
|
4
|
-
"@adviser/cement": "npm:@adviser/cement@^0.3.
|
5
|
-
"@fireproof/vendor": "npm:@fireproof/vendor@^1.0.
|
6
|
-
"@ipld/unixfs": "npm:@ipld/unixfs@^3.0.0",
|
4
|
+
"@adviser/cement": "npm:@adviser/cement@^0.3.5",
|
5
|
+
"@fireproof/vendor": "npm:@fireproof/vendor@^1.0.4",
|
7
6
|
"multiformats": "npm:multiformats@^13.3.1",
|
7
|
+
"@ipld/unixfs": "npm:@ipld/unixfs@^3.0.0",
|
8
8
|
"charwise": "npm:charwise@^3.0.1",
|
9
9
|
"prolly-trees": "npm:prolly-trees@^1.0.4",
|
10
10
|
"idb": "npm:idb@^8.0.1",
|
11
|
-
"memfs": "npm:memfs@^4.15.1",
|
12
11
|
"p-limit": "npm:p-limit@^6.2.0",
|
13
12
|
"p-map": "npm:p-map@^7.0.3",
|
14
13
|
"p-retry": "npm:p-retry@^6.2.1"
|