@loro-dev/flock-wasm 0.1.0
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.
- package/LICENSE +661 -0
- package/README.md +26 -0
- package/base64/event-batcher.d.ts +37 -0
- package/base64/event-batcher.js +204 -0
- package/base64/flock_wasm.js +1158 -0
- package/base64/index.d.ts +268 -0
- package/base64/index.js +1012 -0
- package/base64/wasm.d.ts +37 -0
- package/base64/wasm.js +15 -0
- package/bundler/event-batcher.d.ts +37 -0
- package/bundler/event-batcher.js +204 -0
- package/bundler/flock_wasm.d.ts +313 -0
- package/bundler/flock_wasm.js +5 -0
- package/bundler/flock_wasm_bg.js +1119 -0
- package/bundler/flock_wasm_bg.wasm +0 -0
- package/bundler/flock_wasm_bg.wasm.d.ts +40 -0
- package/bundler/index.d.ts +268 -0
- package/bundler/index.js +1012 -0
- package/bundler/wasm.d.ts +37 -0
- package/bundler/wasm.js +4 -0
- package/nodejs/event-batcher.d.ts +37 -0
- package/nodejs/event-batcher.js +208 -0
- package/nodejs/flock_wasm.d.ts +313 -0
- package/nodejs/flock_wasm.js +1126 -0
- package/nodejs/flock_wasm_bg.wasm +0 -0
- package/nodejs/flock_wasm_bg.wasm.d.ts +40 -0
- package/nodejs/index.d.ts +268 -0
- package/nodejs/index.js +1018 -0
- package/nodejs/package.json +1 -0
- package/nodejs/wasm.d.ts +37 -0
- package/nodejs/wasm.js +2 -0
- package/package.json +50 -0
- package/web/event-batcher.d.ts +37 -0
- package/web/event-batcher.js +204 -0
- package/web/flock_wasm.d.ts +377 -0
- package/web/flock_wasm.js +1158 -0
- package/web/flock_wasm_bg.wasm +0 -0
- package/web/flock_wasm_bg.wasm.d.ts +40 -0
- package/web/index.d.ts +268 -0
- package/web/index.js +1012 -0
- package/web/wasm.d.ts +37 -0
- package/web/wasm.js +4 -0
|
@@ -0,0 +1,377 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
/**
|
|
4
|
+
* Initializes the WASM module.
|
|
5
|
+
*
|
|
6
|
+
* This function is automatically called when the WASM module is loaded.
|
|
7
|
+
* It sets up the panic hook to route Rust panics to the JavaScript console.
|
|
8
|
+
*/
|
|
9
|
+
export function start(): void;
|
|
10
|
+
/**
|
|
11
|
+
* Drains the pending callback queue, invoking all enqueued callbacks.
|
|
12
|
+
*
|
|
13
|
+
* This function is exported to JavaScript and can be called manually,
|
|
14
|
+
* but is typically invoked automatically via microtasks.
|
|
15
|
+
*
|
|
16
|
+
* Callbacks are invoked sequentially. If any callback throws an error,
|
|
17
|
+
* the error is propagated to JavaScript after the current batch completes.
|
|
18
|
+
*/
|
|
19
|
+
export function callPendingEvents(): void;
|
|
20
|
+
/**
|
|
21
|
+
* The main WASM-exposed flock instance.
|
|
22
|
+
*
|
|
23
|
+
* Wraps the underlying [`flock::Flock`] and provides JavaScript-compatible
|
|
24
|
+
* methods for all CRDT operations including put, get, delete, scan, merge,
|
|
25
|
+
* import/export, and event subscription.
|
|
26
|
+
*/
|
|
27
|
+
export class RawFlock {
|
|
28
|
+
free(): void;
|
|
29
|
+
/**
|
|
30
|
+
* Commits the current transaction.
|
|
31
|
+
*
|
|
32
|
+
* Flushes all buffered operations and delivers batched events.
|
|
33
|
+
*
|
|
34
|
+
* # Errors
|
|
35
|
+
*
|
|
36
|
+
* Returns an error if no transaction is active or if commit fails.
|
|
37
|
+
*/
|
|
38
|
+
txnCommit(): void;
|
|
39
|
+
exportFile(): Uint8Array;
|
|
40
|
+
/**
|
|
41
|
+
* Exports the current state as a JSON bundle.
|
|
42
|
+
*
|
|
43
|
+
* # Arguments
|
|
44
|
+
*
|
|
45
|
+
* * `from` - Optional version vector for incremental export
|
|
46
|
+
* * `prune_tombstones_before` - Optional timestamp to prune tombstones older than this
|
|
47
|
+
* * `peer_id` - Optional peer ID filter to only export entries from this peer
|
|
48
|
+
*
|
|
49
|
+
* # Returns
|
|
50
|
+
*
|
|
51
|
+
* An export bundle containing entries and version information.
|
|
52
|
+
*
|
|
53
|
+
* # Errors
|
|
54
|
+
*
|
|
55
|
+
* Returns an error if arguments are invalid or serialization fails.
|
|
56
|
+
*/
|
|
57
|
+
exportJson(from: any, prune_tombstones_before: any, peer_id: any): any;
|
|
58
|
+
/**
|
|
59
|
+
* Imports a JSON bundle into this flock instance.
|
|
60
|
+
*
|
|
61
|
+
* # Arguments
|
|
62
|
+
*
|
|
63
|
+
* * `bundle` - The export bundle to import
|
|
64
|
+
*
|
|
65
|
+
* # Returns
|
|
66
|
+
*
|
|
67
|
+
* An import report containing counts of accepted and skipped entries.
|
|
68
|
+
*
|
|
69
|
+
* # Errors
|
|
70
|
+
*
|
|
71
|
+
* Returns an error if the bundle is invalid or import fails.
|
|
72
|
+
*/
|
|
73
|
+
importJson(bundle: any): any;
|
|
74
|
+
/**
|
|
75
|
+
* Sets a new peer ID for this flock instance.
|
|
76
|
+
*
|
|
77
|
+
* # Arguments
|
|
78
|
+
*
|
|
79
|
+
* * `peer_id` - The new peer ID to set
|
|
80
|
+
*
|
|
81
|
+
* # Errors
|
|
82
|
+
*
|
|
83
|
+
* Returns an error if the peer ID is invalid.
|
|
84
|
+
*/
|
|
85
|
+
setPeerId(peer_id: string): void;
|
|
86
|
+
/**
|
|
87
|
+
* Unsubscribes from change events.
|
|
88
|
+
*
|
|
89
|
+
* # Arguments
|
|
90
|
+
*
|
|
91
|
+
* * `id` - The subscription ID returned from `subscribe`
|
|
92
|
+
*
|
|
93
|
+
* # Returns
|
|
94
|
+
*
|
|
95
|
+
* `true` if a subscription was removed, `false` if the ID was not found.
|
|
96
|
+
*/
|
|
97
|
+
unsubscribe(id: number): boolean;
|
|
98
|
+
/**
|
|
99
|
+
* Rolls back the current transaction.
|
|
100
|
+
*
|
|
101
|
+
* Discards all buffered operations since `txnBegin` was called.
|
|
102
|
+
* Note: Data changes are not rolled back, only event emission is affected.
|
|
103
|
+
*/
|
|
104
|
+
txnRollback(): void;
|
|
105
|
+
/**
|
|
106
|
+
* Stores a value with associated metadata at the specified key.
|
|
107
|
+
*
|
|
108
|
+
* # Arguments
|
|
109
|
+
*
|
|
110
|
+
* * `key` - The key as a JSON array
|
|
111
|
+
* * `value` - The value to store
|
|
112
|
+
* * `metadata` - Optional metadata object to associate with this entry
|
|
113
|
+
* * `now` - Optional timestamp in milliseconds
|
|
114
|
+
*
|
|
115
|
+
* # Errors
|
|
116
|
+
*
|
|
117
|
+
* Returns an error if any argument is invalid or the operation fails.
|
|
118
|
+
*/
|
|
119
|
+
putWithMeta(key: any, value: any, metadata: any, now: any): void;
|
|
120
|
+
/**
|
|
121
|
+
* Returns the inclusive version vector for this flock.
|
|
122
|
+
*
|
|
123
|
+
* The inclusive version includes all peers ever seen, even if their
|
|
124
|
+
* entries have been overridden by other peers.
|
|
125
|
+
*
|
|
126
|
+
* # Errors
|
|
127
|
+
*
|
|
128
|
+
* Returns an error if serialization fails.
|
|
129
|
+
*/
|
|
130
|
+
inclusiveVersion(): any;
|
|
131
|
+
/**
|
|
132
|
+
* Returns the maximum physical time across all entries in this flock.
|
|
133
|
+
*
|
|
134
|
+
* This is useful for determining a safe timestamp for tombstone pruning.
|
|
135
|
+
*/
|
|
136
|
+
getMaxPhysicalTime(): number;
|
|
137
|
+
/**
|
|
138
|
+
* Retrieves the value at the specified key.
|
|
139
|
+
*
|
|
140
|
+
* Returns `undefined` if the key doesn't exist or has been deleted.
|
|
141
|
+
*
|
|
142
|
+
* # Arguments
|
|
143
|
+
*
|
|
144
|
+
* * `key` - The key as a JSON array
|
|
145
|
+
*
|
|
146
|
+
* # Errors
|
|
147
|
+
*
|
|
148
|
+
* Returns an error if serialization of the result fails.
|
|
149
|
+
*/
|
|
150
|
+
get(key: any): any;
|
|
151
|
+
/**
|
|
152
|
+
* Creates a new WASM flock instance with the given peer ID.
|
|
153
|
+
*
|
|
154
|
+
* The instance is created in buffered mode with memtable enabled.
|
|
155
|
+
* Use transactions (`txnBegin` + `txnCommit`) to flush buffered writes explicitly.
|
|
156
|
+
*
|
|
157
|
+
* # Arguments
|
|
158
|
+
*
|
|
159
|
+
* * `peer_id` - The unique identifier for this peer
|
|
160
|
+
*
|
|
161
|
+
* # Errors
|
|
162
|
+
*
|
|
163
|
+
* Returns an error if the peer ID is invalid or if instance creation fails.
|
|
164
|
+
*/
|
|
165
|
+
constructor(peer_id: string);
|
|
166
|
+
/**
|
|
167
|
+
* Stores a value at the specified key.
|
|
168
|
+
*
|
|
169
|
+
* # Arguments
|
|
170
|
+
*
|
|
171
|
+
* * `key` - The key as a JSON array
|
|
172
|
+
* * `value` - The value to store (any JSON-serializable value)
|
|
173
|
+
* * `now` - Optional timestamp in milliseconds (uses current time if undefined)
|
|
174
|
+
*
|
|
175
|
+
* # Errors
|
|
176
|
+
*
|
|
177
|
+
* Returns an error if the key or value is invalid, or if the operation fails.
|
|
178
|
+
*/
|
|
179
|
+
put(key: any, value: any, now: any): void;
|
|
180
|
+
/**
|
|
181
|
+
* Scans entries within the specified bounds and prefix.
|
|
182
|
+
*
|
|
183
|
+
* # Arguments
|
|
184
|
+
*
|
|
185
|
+
* * `start` - Optional start bound (inclusive/exclusive/unbounded)
|
|
186
|
+
* * `end` - Optional end bound
|
|
187
|
+
* * `prefix` - Optional key prefix to filter by
|
|
188
|
+
*
|
|
189
|
+
* # Returns
|
|
190
|
+
*
|
|
191
|
+
* An array of scan rows containing keys, values, and raw records.
|
|
192
|
+
*
|
|
193
|
+
* # Errors
|
|
194
|
+
*
|
|
195
|
+
* Returns an error if scan bounds are invalid or serialization fails.
|
|
196
|
+
*/
|
|
197
|
+
scan(start: any, end: any, prefix: any): any;
|
|
198
|
+
/**
|
|
199
|
+
* Merges state from another flock instance into this one.
|
|
200
|
+
*
|
|
201
|
+
* # Arguments
|
|
202
|
+
*
|
|
203
|
+
* * `other` - The other flock instance to merge from
|
|
204
|
+
*
|
|
205
|
+
* # Returns
|
|
206
|
+
*
|
|
207
|
+
* An import report containing counts of accepted and skipped entries.
|
|
208
|
+
*
|
|
209
|
+
* # Errors
|
|
210
|
+
*
|
|
211
|
+
* Returns an error if the merge operation fails.
|
|
212
|
+
*/
|
|
213
|
+
merge(other: RawFlock): any;
|
|
214
|
+
/**
|
|
215
|
+
* Deletes the value at the specified key (creates a tombstone).
|
|
216
|
+
*
|
|
217
|
+
* # Arguments
|
|
218
|
+
*
|
|
219
|
+
* * `key` - The key as a JSON array
|
|
220
|
+
* * `now` - Optional timestamp in milliseconds
|
|
221
|
+
*
|
|
222
|
+
* # Errors
|
|
223
|
+
*
|
|
224
|
+
* Returns an error if the key is invalid or the operation fails.
|
|
225
|
+
*/
|
|
226
|
+
delete(key: any, now: any): void;
|
|
227
|
+
/**
|
|
228
|
+
* Returns the current peer ID of this flock instance.
|
|
229
|
+
*/
|
|
230
|
+
peerId(): string;
|
|
231
|
+
/**
|
|
232
|
+
* Returns the exclusive version vector for this flock.
|
|
233
|
+
*
|
|
234
|
+
* The exclusive version only includes peers that have at least one entry
|
|
235
|
+
* in the current state (excluding tombstones and overridden entries).
|
|
236
|
+
*
|
|
237
|
+
* # Errors
|
|
238
|
+
*
|
|
239
|
+
* Returns an error if serialization fails.
|
|
240
|
+
*/
|
|
241
|
+
version(): any;
|
|
242
|
+
/**
|
|
243
|
+
* Creates a new flock instance from a file bytes array.
|
|
244
|
+
*
|
|
245
|
+
* # Arguments
|
|
246
|
+
*
|
|
247
|
+
* * `peer_id` - The peer ID for the new instance
|
|
248
|
+
* * `bytes` - The file contents as a Uint8Array
|
|
249
|
+
*
|
|
250
|
+
* # Errors
|
|
251
|
+
*
|
|
252
|
+
* Returns an error if the file format is invalid or loading fails.
|
|
253
|
+
*/
|
|
254
|
+
static fromFile(peer_id: string, bytes: Uint8Array): RawFlock;
|
|
255
|
+
/**
|
|
256
|
+
* Creates a new flock instance from a JSON export bundle.
|
|
257
|
+
*
|
|
258
|
+
* # Arguments
|
|
259
|
+
*
|
|
260
|
+
* * `bundle` - The export bundle as a JavaScript object
|
|
261
|
+
* * `peer_id` - The peer ID for the new instance
|
|
262
|
+
*
|
|
263
|
+
* # Errors
|
|
264
|
+
*
|
|
265
|
+
* Returns an error if the bundle is invalid or import fails.
|
|
266
|
+
*/
|
|
267
|
+
static fromJson(bundle: any, peer_id: string): RawFlock;
|
|
268
|
+
/**
|
|
269
|
+
* Retrieves complete entry information including data, metadata, and clock.
|
|
270
|
+
*
|
|
271
|
+
* Returns `undefined` if the key doesn't exist.
|
|
272
|
+
*
|
|
273
|
+
* # Arguments
|
|
274
|
+
*
|
|
275
|
+
* * `key` - The key as a JSON array
|
|
276
|
+
*
|
|
277
|
+
* # Errors
|
|
278
|
+
*
|
|
279
|
+
* Returns an error if serialization of the result fails.
|
|
280
|
+
*/
|
|
281
|
+
getEntry(key: any): any;
|
|
282
|
+
/**
|
|
283
|
+
* Returns whether a transaction is currently active.
|
|
284
|
+
*/
|
|
285
|
+
isInTxn(): boolean;
|
|
286
|
+
/**
|
|
287
|
+
* Subscribes to change events from this flock instance.
|
|
288
|
+
*
|
|
289
|
+
* # Arguments
|
|
290
|
+
*
|
|
291
|
+
* * `listener` - A JavaScript function that will be called with event batches
|
|
292
|
+
*
|
|
293
|
+
* # Returns
|
|
294
|
+
*
|
|
295
|
+
* A subscription ID that can be used to unsubscribe later.
|
|
296
|
+
*
|
|
297
|
+
* # Errors
|
|
298
|
+
*
|
|
299
|
+
* Returns an error if the subscription fails or the ID overflows.
|
|
300
|
+
*/
|
|
301
|
+
subscribe(listener: Function): number;
|
|
302
|
+
/**
|
|
303
|
+
* Begins a transaction.
|
|
304
|
+
*
|
|
305
|
+
* All subsequent put/delete operations will be buffered until `txnCommit`
|
|
306
|
+
* is called. Events will be batched and delivered as a single batch on commit.
|
|
307
|
+
*
|
|
308
|
+
* # Errors
|
|
309
|
+
*
|
|
310
|
+
* Returns an error if a transaction is already active or if begin fails.
|
|
311
|
+
*/
|
|
312
|
+
txnBegin(): void;
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
|
|
316
|
+
|
|
317
|
+
export interface InitOutput {
|
|
318
|
+
readonly memory: WebAssembly.Memory;
|
|
319
|
+
readonly __wbg_rawflock_free: (a: number, b: number) => void;
|
|
320
|
+
readonly callPendingEvents: () => void;
|
|
321
|
+
readonly rawflock_delete: (a: number, b: any, c: any) => [number, number];
|
|
322
|
+
readonly rawflock_exportFile: (a: number) => [number, number, number, number];
|
|
323
|
+
readonly rawflock_exportJson: (a: number, b: any, c: any, d: any) => [number, number, number];
|
|
324
|
+
readonly rawflock_fromFile: (a: number, b: number, c: number, d: number) => [number, number, number];
|
|
325
|
+
readonly rawflock_fromJson: (a: any, b: number, c: number) => [number, number, number];
|
|
326
|
+
readonly rawflock_get: (a: number, b: any) => [number, number, number];
|
|
327
|
+
readonly rawflock_getEntry: (a: number, b: any) => [number, number, number];
|
|
328
|
+
readonly rawflock_getMaxPhysicalTime: (a: number) => number;
|
|
329
|
+
readonly rawflock_importJson: (a: number, b: any) => [number, number, number];
|
|
330
|
+
readonly rawflock_inclusiveVersion: (a: number) => [number, number, number];
|
|
331
|
+
readonly rawflock_isInTxn: (a: number) => number;
|
|
332
|
+
readonly rawflock_merge: (a: number, b: number) => [number, number, number];
|
|
333
|
+
readonly rawflock_new: (a: number, b: number) => [number, number, number];
|
|
334
|
+
readonly rawflock_peerId: (a: number) => [number, number];
|
|
335
|
+
readonly rawflock_put: (a: number, b: any, c: any, d: any) => [number, number];
|
|
336
|
+
readonly rawflock_putWithMeta: (a: number, b: any, c: any, d: any, e: any) => [number, number];
|
|
337
|
+
readonly rawflock_scan: (a: number, b: any, c: any, d: any) => [number, number, number];
|
|
338
|
+
readonly rawflock_setPeerId: (a: number, b: number, c: number) => [number, number];
|
|
339
|
+
readonly rawflock_subscribe: (a: number, b: any) => [number, number, number];
|
|
340
|
+
readonly rawflock_txnBegin: (a: number) => [number, number];
|
|
341
|
+
readonly rawflock_txnCommit: (a: number) => [number, number];
|
|
342
|
+
readonly rawflock_txnRollback: (a: number) => void;
|
|
343
|
+
readonly rawflock_unsubscribe: (a: number, b: number) => number;
|
|
344
|
+
readonly rawflock_version: (a: number) => [number, number, number];
|
|
345
|
+
readonly start: () => void;
|
|
346
|
+
readonly __wbindgen_malloc: (a: number, b: number) => number;
|
|
347
|
+
readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
|
|
348
|
+
readonly __wbindgen_exn_store: (a: number) => void;
|
|
349
|
+
readonly __externref_table_alloc: () => number;
|
|
350
|
+
readonly __wbindgen_export_4: WebAssembly.Table;
|
|
351
|
+
readonly __wbindgen_free: (a: number, b: number, c: number) => void;
|
|
352
|
+
readonly __wbindgen_export_6: WebAssembly.Table;
|
|
353
|
+
readonly __externref_table_dealloc: (a: number) => void;
|
|
354
|
+
readonly closure38_externref_shim: (a: number, b: number, c: any) => void;
|
|
355
|
+
readonly __wbindgen_start: () => void;
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
export type SyncInitInput = BufferSource | WebAssembly.Module;
|
|
359
|
+
/**
|
|
360
|
+
* Instantiates the given `module`, which can either be bytes or
|
|
361
|
+
* a precompiled `WebAssembly.Module`.
|
|
362
|
+
*
|
|
363
|
+
* @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated.
|
|
364
|
+
*
|
|
365
|
+
* @returns {InitOutput}
|
|
366
|
+
*/
|
|
367
|
+
export function initSync(module: { module: SyncInitInput } | SyncInitInput): InitOutput;
|
|
368
|
+
|
|
369
|
+
/**
|
|
370
|
+
* If `module_or_path` is {RequestInfo} or {URL}, makes a request and
|
|
371
|
+
* for everything else, calls `WebAssembly.instantiate` directly.
|
|
372
|
+
*
|
|
373
|
+
* @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated.
|
|
374
|
+
*
|
|
375
|
+
* @returns {Promise<InitOutput>}
|
|
376
|
+
*/
|
|
377
|
+
export default function __wbg_init (module_or_path?: { module_or_path: InitInput | Promise<InitInput> } | InitInput | Promise<InitInput>): Promise<InitOutput>;
|