@fireproof/core 0.18.0 → 0.19.0-dev-use-fix

Sign up to get free protection for your applications and to get access to all the features.
Files changed (85) hide show
  1. package/README.md +29 -15
  2. package/chunk-AZVWSRER.js +208 -0
  3. package/chunk-AZVWSRER.js.map +1 -0
  4. package/chunk-H3A2HMMM.js +164 -0
  5. package/chunk-H3A2HMMM.js.map +1 -0
  6. package/chunk-NZNG6TQT.js +370 -0
  7. package/chunk-NZNG6TQT.js.map +1 -0
  8. package/chunk-VZGT7ZYP.js +22 -0
  9. package/chunk-VZGT7ZYP.js.map +1 -0
  10. package/chunk-ZHO4NMWL.js +39 -0
  11. package/chunk-ZHO4NMWL.js.map +1 -0
  12. package/index.cjs +4706 -0
  13. package/index.cjs.map +1 -0
  14. package/index.d.cts +1012 -0
  15. package/index.d.ts +1012 -0
  16. package/index.js +2856 -0
  17. package/index.js.map +1 -0
  18. package/metafile-cjs.json +1 -0
  19. package/metafile-esm.json +1 -0
  20. package/node-sys-container-E7LADX2Z.js +29 -0
  21. package/node-sys-container-E7LADX2Z.js.map +1 -0
  22. package/package.json +23 -109
  23. package/sqlite-data-store-3ST7XOLX.js +120 -0
  24. package/sqlite-data-store-3ST7XOLX.js.map +1 -0
  25. package/sqlite-meta-store-QOIMCSJ7.js +137 -0
  26. package/sqlite-meta-store-QOIMCSJ7.js.map +1 -0
  27. package/sqlite-wal-store-JFBQPOYT.js +123 -0
  28. package/sqlite-wal-store-JFBQPOYT.js.map +1 -0
  29. package/store-file-CSS5THFH.js +193 -0
  30. package/store-file-CSS5THFH.js.map +1 -0
  31. package/store-indexdb-DR4HELVP.js +20 -0
  32. package/store-indexdb-DR4HELVP.js.map +1 -0
  33. package/store-sql-BG6SMGQJ.js +344 -0
  34. package/store-sql-BG6SMGQJ.js.map +1 -0
  35. package/tests/blockstore/loader.test.ts +265 -0
  36. package/tests/blockstore/store.test.ts +164 -0
  37. package/tests/blockstore/transaction.test.ts +121 -0
  38. package/tests/fireproof/config.test.ts +212 -0
  39. package/tests/fireproof/crdt.test.ts +434 -0
  40. package/tests/fireproof/database.test.ts +466 -0
  41. package/tests/fireproof/fireproof.test.ts +602 -0
  42. package/tests/fireproof/hello.test.ts +54 -0
  43. package/tests/fireproof/indexer.test.ts +389 -0
  44. package/tests/helpers.ts +81 -0
  45. package/tests/react/useFireproof.test.tsx +19 -0
  46. package/tests/www/gallery.html +132 -0
  47. package/tests/www/iife.html +42 -0
  48. package/tests/www/todo-aws.html +232 -0
  49. package/tests/www/todo-ipfs.html +213 -0
  50. package/tests/www/todo-local.html +214 -0
  51. package/tests/www/todo-netlify.html +227 -0
  52. package/tests/www/todo.html +236 -0
  53. package/dist/browser/fireproof.cjs +0 -1172
  54. package/dist/browser/fireproof.cjs.map +0 -1
  55. package/dist/browser/fireproof.d.cts +0 -268
  56. package/dist/browser/fireproof.d.ts +0 -268
  57. package/dist/browser/fireproof.global.js +0 -24178
  58. package/dist/browser/fireproof.global.js.map +0 -1
  59. package/dist/browser/fireproof.js +0 -1147
  60. package/dist/browser/fireproof.js.map +0 -1
  61. package/dist/browser/metafile-cjs.json +0 -1
  62. package/dist/browser/metafile-esm.json +0 -1
  63. package/dist/browser/metafile-iife.json +0 -1
  64. package/dist/memory/fireproof.cjs +0 -1172
  65. package/dist/memory/fireproof.cjs.map +0 -1
  66. package/dist/memory/fireproof.d.cts +0 -268
  67. package/dist/memory/fireproof.d.ts +0 -268
  68. package/dist/memory/fireproof.global.js +0 -24178
  69. package/dist/memory/fireproof.global.js.map +0 -1
  70. package/dist/memory/fireproof.js +0 -1147
  71. package/dist/memory/fireproof.js.map +0 -1
  72. package/dist/memory/metafile-cjs.json +0 -1
  73. package/dist/memory/metafile-esm.json +0 -1
  74. package/dist/memory/metafile-iife.json +0 -1
  75. package/dist/node/fireproof.cjs +0 -1172
  76. package/dist/node/fireproof.cjs.map +0 -1
  77. package/dist/node/fireproof.d.cts +0 -268
  78. package/dist/node/fireproof.d.ts +0 -268
  79. package/dist/node/fireproof.global.js +0 -38540
  80. package/dist/node/fireproof.global.js.map +0 -1
  81. package/dist/node/fireproof.js +0 -1138
  82. package/dist/node/fireproof.js.map +0 -1
  83. package/dist/node/metafile-cjs.json +0 -1
  84. package/dist/node/metafile-esm.json +0 -1
  85. package/dist/node/metafile-iife.json +0 -1
@@ -1,268 +0,0 @@
1
- import { Link, Block } from 'multiformats';
2
- import { EventLink } from '@web3-storage/pail/clock/api';
3
- import { Operation } from '@web3-storage/pail/crdt/api';
4
- import { DbMeta, CryptoOpts, StoreOpts, EncryptedBlockstore, TransactionMeta } from '@fireproof/encrypted-blockstore';
5
- import { ProllyNode as ProllyNode$1 } from 'prolly-trees/db-index';
6
-
7
- type ConfigOpts = {
8
- public?: boolean;
9
- meta?: DbMeta;
10
- persistIndexes?: boolean;
11
- autoCompact?: number;
12
- crypto?: CryptoOpts;
13
- store?: StoreOpts;
14
- };
15
- type ClockLink = EventLink<Operation>;
16
- type ClockHead = ClockLink[];
17
- type DocFragment = Uint8Array | string | number | boolean | null | AnyLink | DocFragment[] | {
18
- [key: string]: DocFragment;
19
- };
20
- type DocRecord<T> = {
21
- [K in keyof T]: DocFragment;
22
- };
23
- type DocFiles = Record<string, DocFileMeta | File>;
24
- type DocBase = {
25
- _id?: string;
26
- _files?: DocFiles;
27
- _publicFiles?: DocFiles;
28
- };
29
- type Doc<T extends DocRecord<T> = {}> = DocBase & T;
30
- type DocFileMeta = {
31
- type: string;
32
- size: number;
33
- cid: AnyLink;
34
- car?: AnyLink;
35
- url?: string;
36
- file?: () => Promise<File>;
37
- };
38
- type DocUpdate = {
39
- key: string;
40
- value?: Record<string, any>;
41
- del?: boolean;
42
- clock?: AnyLink;
43
- };
44
- type DocValue = {
45
- doc?: DocBase;
46
- del?: boolean;
47
- cid?: AnyLink;
48
- };
49
- type IndexKey = [string, string] | string;
50
- type IndexUpdate = {
51
- key: IndexKey;
52
- value?: DocFragment;
53
- del?: boolean;
54
- };
55
- type IndexRow<T extends DocRecord<T> = {}> = {
56
- id: string;
57
- key: IndexKey;
58
- row?: DocFragment;
59
- doc?: Doc<T> | null;
60
- value?: DocFragment;
61
- del?: boolean;
62
- };
63
- type CRDTMeta = {
64
- head: ClockHead;
65
- };
66
- type IdxMeta = {
67
- byId: AnyLink;
68
- byKey: AnyLink;
69
- map: string;
70
- name: string;
71
- head: ClockHead;
72
- };
73
- type IdxMetaMap = {
74
- indexes: Map<string, IdxMeta>;
75
- };
76
- type QueryOpts = {
77
- descending?: boolean;
78
- limit?: number;
79
- includeDocs?: boolean;
80
- range?: [IndexKey, IndexKey];
81
- key?: DocFragment;
82
- keys?: DocFragment[];
83
- prefix?: DocFragment | [DocFragment];
84
- };
85
- type AnyLink = Link<unknown, number, number, 1 | 0>;
86
- type AnyBlock = {
87
- cid: AnyLink;
88
- bytes: Uint8Array;
89
- };
90
- type AnyDecodedBlock = {
91
- cid: AnyLink;
92
- bytes: Uint8Array;
93
- value: any;
94
- };
95
- type EmitFn = (k: DocFragment, v?: DocFragment) => void;
96
- type MapFn = <T extends DocRecord<T> = {}>(doc: Doc<T>, emit: EmitFn) => DocFragment | void;
97
- type ChangesOptions = {
98
- dirty?: boolean;
99
- limit?: number;
100
- };
101
- type ChangesResponse<T extends DocRecord<T> = {}> = {
102
- clock: ClockHead;
103
- rows: {
104
- key: string;
105
- value: Doc<T>;
106
- }[];
107
- };
108
- type DbResponse = {
109
- id: string;
110
- clock: ClockHead;
111
- };
112
-
113
- type WriteQueue = {
114
- push(task: DocUpdate): Promise<CRDTMeta>;
115
- };
116
-
117
- declare class IndexTree {
118
- cid: AnyLink | null;
119
- root: ProllyNode | null;
120
- }
121
- interface ProllyNode extends ProllyNode$1 {
122
- getAllEntries<T extends DocRecord<T> = {}>(): PromiseLike<{
123
- [x: string]: any;
124
- result: IndexRow<T>[];
125
- }>;
126
- getMany(removeIds: string[]): Promise<{
127
- [x: string]: any;
128
- result: IndexKey[];
129
- }>;
130
- range<T extends DocRecord<T> = {}>(a: IndexKey, b: IndexKey): Promise<{
131
- result: IndexRow<T>[];
132
- }>;
133
- get<T extends DocRecord<T> = {}>(key: string): Promise<{
134
- result: IndexRow<T>[];
135
- }>;
136
- bulk(bulk: IndexUpdate[]): PromiseLike<{
137
- root: ProllyNode | null;
138
- blocks: Block[];
139
- }>;
140
- address: Promise<Link>;
141
- distance: number;
142
- compare: (a: any, b: any) => number;
143
- cache: any;
144
- block: Promise<Block>;
145
- }
146
-
147
- declare class Index {
148
- blockstore: EncryptedBlockstore;
149
- crdt: CRDT;
150
- name: string | null;
151
- mapFn: MapFn | null;
152
- mapFnString: string;
153
- byKey: IndexTree;
154
- byId: IndexTree;
155
- indexHead: ClockHead | undefined;
156
- includeDocsDefault: boolean;
157
- initError: Error | null;
158
- ready: Promise<void>;
159
- constructor(crdt: CRDT, name: string, mapFn?: MapFn, meta?: IdxMeta);
160
- applyMapFn<T extends DocRecord<T> = {}>(name: string, mapFn?: MapFn, meta?: IdxMeta): void;
161
- query<T extends DocRecord<T> = {}>(opts?: QueryOpts): Promise<{
162
- rows: IndexRow<T>[];
163
- }>;
164
- _resetIndex(): void;
165
- _hydrateIndex(): Promise<void>;
166
- _updateIndex(): Promise<TransactionMeta>;
167
- }
168
-
169
- type ApplyHeadTask = {
170
- newHead: ClockHead;
171
- prevHead: ClockHead;
172
- updates: DocUpdate[] | null;
173
- };
174
- type ApplyHeadQueue = {
175
- push(task: ApplyHeadTask): AsyncGenerator<{
176
- updates: DocUpdate[];
177
- all: boolean;
178
- }, void, unknown>;
179
- size(): number;
180
- };
181
-
182
- declare class CRDTClock {
183
- head: ClockHead;
184
- zoomers: Set<() => void>;
185
- watchers: Set<(updates: DocUpdate[]) => void>;
186
- emptyWatchers: Set<() => void>;
187
- blockstore: EncryptedBlockstore | null;
188
- applyHeadQueue: ApplyHeadQueue;
189
- constructor();
190
- setHead(head: ClockHead): void;
191
- applyHead(newHead: ClockHead, prevHead: ClockHead, updates?: DocUpdate[] | null): Promise<void>;
192
- processUpdates(updatesAcc: DocUpdate[], all: boolean, prevHead: ClockHead): Promise<void>;
193
- notifyWatchers(updates: DocUpdate[]): void;
194
- onTick(fn: (updates: DocUpdate[]) => void): void;
195
- onTock(fn: () => void): void;
196
- onZoom(fn: () => void): void;
197
- int_applyHead(newHead: ClockHead, prevHead: ClockHead, localUpdates: boolean): Promise<void>;
198
- }
199
-
200
- declare class CRDT {
201
- name: string | null;
202
- opts: ConfigOpts;
203
- ready: Promise<void>;
204
- blockstore: EncryptedBlockstore;
205
- indexBlockstore: EncryptedBlockstore;
206
- indexers: Map<string, Index>;
207
- clock: CRDTClock;
208
- constructor(name?: string, opts?: ConfigOpts);
209
- bulk(updates: DocUpdate[]): Promise<CRDTMeta>;
210
- allDocs(): Promise<{
211
- result: DocUpdate[];
212
- head: ClockHead;
213
- }>;
214
- vis(): Promise<string>;
215
- getBlock(cidString: string): Promise<Block>;
216
- get(key: string): Promise<DocValue | null>;
217
- changes(since?: ClockHead, opts?: ChangesOptions): Promise<{
218
- result: DocUpdate[];
219
- head: ClockHead;
220
- }>;
221
- compact(): Promise<void>;
222
- }
223
-
224
- type DbName = string | null;
225
- declare class Database {
226
- static databases: Map<string, Database>;
227
- name: DbName;
228
- opts: ConfigOpts;
229
- _listening: boolean;
230
- _listeners: Set<ListenerFn>;
231
- _noupdate_listeners: Set<ListenerFn>;
232
- _crdt: CRDT;
233
- _writeQueue: WriteQueue;
234
- blockstore: EncryptedBlockstore;
235
- constructor(name?: string, opts?: ConfigOpts);
236
- get<T extends DocRecord<T> = {}>(id: string): Promise<Doc<T>>;
237
- put<T extends DocRecord<T> = {}>(doc: Doc<T>): Promise<DbResponse>;
238
- del(id: string): Promise<DbResponse>;
239
- changes<T extends DocRecord<T> = {}>(since?: ClockHead, opts?: ChangesOptions): Promise<ChangesResponse<T>>;
240
- allDocs<T extends DocRecord<T> = {}>(): Promise<{
241
- rows: {
242
- key: string;
243
- value: Doc<T>;
244
- }[];
245
- clock: ClockHead;
246
- }>;
247
- allDocuments<T extends DocRecord<T> = {}>(): Promise<{
248
- rows: {
249
- key: string;
250
- value: Doc<T>;
251
- }[];
252
- clock: ClockHead;
253
- }>;
254
- subscribe(listener: ListenerFn | NoUpdateListenerFn, updates?: boolean): () => void;
255
- query<T extends DocRecord<T> = {}>(field: string | MapFn, opts?: QueryOpts): Promise<{
256
- rows: IndexRow<T>[];
257
- }>;
258
- compact(): Promise<void>;
259
- _notify(updates: DocUpdate[]): Promise<void>;
260
- _no_update_notify(): Promise<void>;
261
- }
262
- type UpdateListenerFn = <T extends DocRecord<T>>(docs: Doc<T>[]) => Promise<void> | void;
263
- type NoUpdateListenerFn = () => Promise<void> | void;
264
- type ListenerFn = UpdateListenerFn | NoUpdateListenerFn;
265
- declare function fireproof(name: string, opts?: ConfigOpts): Database;
266
-
267
- export { type AnyBlock, type AnyDecodedBlock, type AnyLink, type CRDTMeta, type ChangesOptions, type ChangesResponse, type ClockHead, type ClockLink, type ConfigOpts, Database, type DbResponse, type Doc, type DocBase, type DocFileMeta, type DocFiles, type DocFragment, type DocRecord, type DocUpdate, type DocValue, type IdxMeta, type IdxMetaMap, type IndexKey, type IndexRow, type IndexUpdate, type MapFn, type QueryOpts, fireproof };
268
- declare module '@fireproof/core'