@fireproof/core 0.20.0-dev-preview-40 → 0.20.0-dev-preview-50

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 (45) hide show
  1. package/README.md +6 -4
  2. package/deno/index.js +2 -2
  3. package/deno/index.js.map +1 -1
  4. package/deno.json +3 -2
  5. package/index.cjs +955 -599
  6. package/index.cjs.map +1 -1
  7. package/index.d.cts +334 -127
  8. package/index.d.ts +334 -127
  9. package/index.js +939 -582
  10. package/index.js.map +1 -1
  11. package/indexeddb/index.cjs.map +1 -1
  12. package/indexeddb/index.js.map +1 -1
  13. package/indexeddb/metafile-cjs.json +1 -1
  14. package/indexeddb/metafile-esm.json +1 -1
  15. package/metafile-cjs.json +1 -1
  16. package/metafile-esm.json +1 -1
  17. package/package.json +7 -5
  18. package/react/index.cjs +17 -9
  19. package/react/index.cjs.map +1 -1
  20. package/react/index.d.cts +5 -4
  21. package/react/index.d.ts +5 -4
  22. package/react/index.js +17 -9
  23. package/react/index.js.map +1 -1
  24. package/react/metafile-cjs.json +1 -1
  25. package/react/metafile-esm.json +1 -1
  26. package/tests/blockstore/interceptor-gateway.test.ts +15 -1
  27. package/tests/blockstore/keyed-crypto-indexeddb-file.test.ts +8 -18
  28. package/tests/blockstore/keyed-crypto.test.ts +31 -53
  29. package/tests/blockstore/loader.test.ts +21 -19
  30. package/tests/blockstore/store.test.ts +52 -56
  31. package/tests/blockstore/transaction.test.ts +13 -11
  32. package/tests/fireproof/all-gateway.test.ts +53 -50
  33. package/tests/fireproof/attachable.test.ts +356 -0
  34. package/tests/fireproof/crdt.test.ts +100 -60
  35. package/tests/fireproof/database.test.ts +95 -54
  36. package/tests/fireproof/fireproof.test.ts +58 -55
  37. package/tests/fireproof/hello.test.ts +4 -4
  38. package/tests/fireproof/indexer.test.ts +44 -44
  39. package/tests/fireproof/stable-cid.test.ts +69 -0
  40. package/tests/fireproof/utils.test.ts +21 -10
  41. package/tests/gateway/file/loader-config.test.ts +25 -25
  42. package/tests/gateway/fp-envelope-serialize.test.ts +8 -8
  43. package/tests/gateway/indexeddb/loader-config.test.ts +6 -6
  44. package/tests/helpers.ts +81 -2
  45. package/tests/react/useFireproof.test.tsx +59 -17
package/README.md CHANGED
@@ -7,9 +7,11 @@
7
7
  </a>
8
8
  </p>
9
9
 
10
- ### No setup: write features first, access your data anywhere
10
+ ### Build first, sync later: perfect for AI-generated apps and rapid prototypes
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 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.
12
+ Fireproof is an embedded document ledger that lets you build full-stack apps in a single file. This makes it ideal for AI code generation and rapid prototyping - just write your features and access your data anywhere.
13
+
14
+ [Point AI coders to these docs.](https://use-fireproof.com/llms-full.txt)
13
15
 
14
16
  ### JavaScript quick start
15
17
 
@@ -44,7 +46,7 @@ import { useFireproof } from 'use-fireproof'
44
46
  function App() {
45
47
  const { useLiveQuery, useDocument } = useFireproof("my-db-name")
46
48
  const completedTodos = useLiveQuery('completed', { limit: 10 })
47
- const [newTodo, setNewTodo, saveNewTodo] = useDocument(() => ({type: 'todo', text: '', completed: false, created: Date.now() }))
49
+ const { doc, merge, save } = useDocument(() => ({type: 'todo', text: '', completed: false, created: Date.now() }))
48
50
  ```
49
51
 
50
52
  Read the [step-by-step React tutorial](https://use-fireproof.com/docs/react-tutorial) to get started.
@@ -161,7 +163,7 @@ deno run --config node_modules/@fireproof/core/deno.json --allow-read --allow-wr
161
163
  Caution it will be pushed directly
162
164
 
163
165
  ```shell
164
- pnpm run build:doc
166
+ pnpm run build:docs
165
167
  ```
166
168
 
167
169
  ## Thanks 🙏
package/deno/index.js CHANGED
@@ -9,7 +9,7 @@ var DenoFileSystem = class {
9
9
  }
10
10
  async readdir(path) {
11
11
  const ret = [];
12
- for await (const dirEntry of this.fs.readdir(path)) {
12
+ for await (const dirEntry of this.fs.readDir(path)) {
13
13
  ret.push(dirEntry.name);
14
14
  }
15
15
  return ret;
@@ -43,7 +43,7 @@ var DenoFileSystem = class {
43
43
  };
44
44
  }
45
45
  async unlink(path) {
46
- return this.fs?.unlink(path);
46
+ return this.fs?.remove(path);
47
47
  }
48
48
  async writefile(path, data) {
49
49
  return this.fs?.writeFile(path, Buffer.from(data));
package/deno/index.js.map CHANGED
@@ -1 +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"]}
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 remove: 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?.remove(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"]}
package/deno.json CHANGED
@@ -1,13 +1,14 @@
1
1
  {
2
2
  "imports": {
3
3
  "@fireproof/core": "./index.js",
4
+ "@adviser/cement": "npm:@adviser/cement@~0.3.20",
5
+ "@fireproof/vendor": "npm:@fireproof/vendor@~2.0.1",
4
6
  "@ipld/car": "npm:@ipld/car@^5.4.0",
5
7
  "@ipld/dag-cbor": "npm:@ipld/dag-cbor@^9.2.2",
6
8
  "@ipld/dag-json": "npm:@ipld/dag-json@^10.2.3",
7
- "@fireproof/vendor": "npm:@fireproof/vendor@^1.1.0-dev",
8
9
  "cborg": "npm:cborg@^4.2.8",
9
10
  "ipfs-unixfs-exporter": "npm:ipfs-unixfs-exporter@^13.6.1",
10
- "multiformats": "npm:multiformats@^13.3.1",
11
+ "multiformats": "npm:multiformats@^13.3.2",
11
12
  "@ipld/unixfs": "npm:@ipld/unixfs@^3.0.0",
12
13
  "charwise": "npm:charwise@^3.0.1",
13
14
  "prolly-trees": "npm:prolly-trees@^1.0.4",