@loro-dev/flock-wasm 0.1.4 → 0.2.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/README.md +10 -19
- package/base64/flock_wasm.js +41 -35
- package/base64/index.d.ts +5 -10
- package/base64/index.js +12 -26
- package/base64/wasm.d.ts +4 -2
- package/base64/wasm.js +1 -1
- package/bundler/flock_wasm.d.ts +11 -17
- package/bundler/flock_wasm_bg.js +41 -35
- package/bundler/flock_wasm_bg.wasm +0 -0
- package/bundler/flock_wasm_bg.wasm.d.ts +5 -3
- package/bundler/index.d.ts +5 -10
- package/bundler/index.js +12 -26
- package/bundler/wasm.d.ts +4 -2
- package/nodejs/flock_wasm.d.ts +11 -17
- package/nodejs/flock_wasm.js +41 -35
- package/nodejs/flock_wasm_bg.wasm +0 -0
- package/nodejs/flock_wasm_bg.wasm.d.ts +5 -3
- package/nodejs/index.d.ts +5 -10
- package/nodejs/index.js +12 -26
- package/nodejs/wasm.d.ts +4 -2
- package/package.json +1 -1
- package/web/flock_wasm.d.ts +16 -20
- package/web/flock_wasm.js +41 -35
- package/web/flock_wasm_bg.wasm +0 -0
- package/web/flock_wasm_bg.wasm.d.ts +5 -3
- package/web/index.d.ts +5 -10
- package/web/index.js +12 -26
- package/web/wasm.d.ts +4 -2
package/bundler/flock_wasm.d.ts
CHANGED
|
@@ -1,12 +1,5 @@
|
|
|
1
1
|
/* tslint:disable */
|
|
2
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
3
|
/**
|
|
11
4
|
* Drains the pending callback queue, invoking all enqueued callbacks.
|
|
12
5
|
*
|
|
@@ -17,6 +10,13 @@ export function start(): void;
|
|
|
17
10
|
* the error is propagated to JavaScript after the current batch completes.
|
|
18
11
|
*/
|
|
19
12
|
export function callPendingEvents(): void;
|
|
13
|
+
/**
|
|
14
|
+
* Initializes the WASM module.
|
|
15
|
+
*
|
|
16
|
+
* This function is automatically called when the WASM module is loaded.
|
|
17
|
+
* It sets up the panic hook to route Rust panics to the JavaScript console.
|
|
18
|
+
*/
|
|
19
|
+
export function start(): void;
|
|
20
20
|
/**
|
|
21
21
|
* The main WASM-exposed flock instance.
|
|
22
22
|
*
|
|
@@ -55,6 +55,7 @@ export class RawFlock {
|
|
|
55
55
|
* Returns an error if arguments are invalid or serialization fails.
|
|
56
56
|
*/
|
|
57
57
|
exportJson(from: any, prune_tombstones_before: any, peer_id: any): any;
|
|
58
|
+
importFile(bytes: Uint8Array): void;
|
|
58
59
|
/**
|
|
59
60
|
* Imports a JSON bundle into this flock instance.
|
|
60
61
|
*
|
|
@@ -62,15 +63,11 @@ export class RawFlock {
|
|
|
62
63
|
*
|
|
63
64
|
* * `bundle` - The export bundle to import
|
|
64
65
|
*
|
|
65
|
-
* # Returns
|
|
66
|
-
*
|
|
67
|
-
* An import report containing counts of accepted and skipped entries.
|
|
68
|
-
*
|
|
69
66
|
* # Errors
|
|
70
67
|
*
|
|
71
68
|
* Returns an error if the bundle is invalid or import fails.
|
|
72
69
|
*/
|
|
73
|
-
importJson(bundle: any):
|
|
70
|
+
importJson(bundle: any): void;
|
|
74
71
|
/**
|
|
75
72
|
* Sets a new peer ID for this flock instance.
|
|
76
73
|
*
|
|
@@ -205,15 +202,11 @@ export class RawFlock {
|
|
|
205
202
|
*
|
|
206
203
|
* * `other` - The other flock instance to merge from
|
|
207
204
|
*
|
|
208
|
-
* # Returns
|
|
209
|
-
*
|
|
210
|
-
* An import report containing counts of accepted and skipped entries.
|
|
211
|
-
*
|
|
212
205
|
* # Errors
|
|
213
206
|
*
|
|
214
207
|
* Returns an error if the merge operation fails.
|
|
215
208
|
*/
|
|
216
|
-
merge(other: RawFlock):
|
|
209
|
+
merge(other: RawFlock): void;
|
|
217
210
|
/**
|
|
218
211
|
* Deletes the value at the specified key (creates a tombstone).
|
|
219
212
|
*
|
|
@@ -244,6 +237,7 @@ export class RawFlock {
|
|
|
244
237
|
* Returns an error if serialization fails.
|
|
245
238
|
*/
|
|
246
239
|
version(): any;
|
|
240
|
+
isEmpty(): boolean;
|
|
247
241
|
/**
|
|
248
242
|
* Creates a new flock instance from a file bytes array.
|
|
249
243
|
*
|
package/bundler/flock_wasm_bg.js
CHANGED
|
@@ -205,16 +205,6 @@ function debugString(val) {
|
|
|
205
205
|
// TODO we could test for more things here, like `Set`s and `Map`s.
|
|
206
206
|
return className;
|
|
207
207
|
}
|
|
208
|
-
/**
|
|
209
|
-
* Initializes the WASM module.
|
|
210
|
-
*
|
|
211
|
-
* This function is automatically called when the WASM module is loaded.
|
|
212
|
-
* It sets up the panic hook to route Rust panics to the JavaScript console.
|
|
213
|
-
*/
|
|
214
|
-
export function start() {
|
|
215
|
-
wasm.start();
|
|
216
|
-
}
|
|
217
|
-
|
|
218
208
|
/**
|
|
219
209
|
* Drains the pending callback queue, invoking all enqueued callbacks.
|
|
220
210
|
*
|
|
@@ -228,6 +218,16 @@ export function callPendingEvents() {
|
|
|
228
218
|
wasm.callPendingEvents();
|
|
229
219
|
}
|
|
230
220
|
|
|
221
|
+
/**
|
|
222
|
+
* Initializes the WASM module.
|
|
223
|
+
*
|
|
224
|
+
* This function is automatically called when the WASM module is loaded.
|
|
225
|
+
* It sets up the panic hook to route Rust panics to the JavaScript console.
|
|
226
|
+
*/
|
|
227
|
+
export function start() {
|
|
228
|
+
wasm.start();
|
|
229
|
+
}
|
|
230
|
+
|
|
231
231
|
function takeFromExternrefTable0(idx) {
|
|
232
232
|
const value = wasm.__wbindgen_export_4.get(idx);
|
|
233
233
|
wasm.__externref_table_dealloc(idx);
|
|
@@ -239,20 +239,20 @@ function getArrayU8FromWasm0(ptr, len) {
|
|
|
239
239
|
return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
|
|
240
240
|
}
|
|
241
241
|
|
|
242
|
-
function _assertClass(instance, klass) {
|
|
243
|
-
if (!(instance instanceof klass)) {
|
|
244
|
-
throw new Error(`expected instance of ${klass.name}`);
|
|
245
|
-
}
|
|
246
|
-
}
|
|
247
|
-
|
|
248
242
|
function passArray8ToWasm0(arg, malloc) {
|
|
249
243
|
const ptr = malloc(arg.length * 1, 1) >>> 0;
|
|
250
244
|
getUint8ArrayMemory0().set(arg, ptr / 1);
|
|
251
245
|
WASM_VECTOR_LEN = arg.length;
|
|
252
246
|
return ptr;
|
|
253
247
|
}
|
|
248
|
+
|
|
249
|
+
function _assertClass(instance, klass) {
|
|
250
|
+
if (!(instance instanceof klass)) {
|
|
251
|
+
throw new Error(`expected instance of ${klass.name}`);
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
254
|
function __wbg_adapter_56(arg0, arg1, arg2) {
|
|
255
|
-
wasm.
|
|
255
|
+
wasm.closure32_externref_shim(arg0, arg1, arg2);
|
|
256
256
|
}
|
|
257
257
|
|
|
258
258
|
const RawFlockFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
@@ -341,6 +341,17 @@ export class RawFlock {
|
|
|
341
341
|
}
|
|
342
342
|
return takeFromExternrefTable0(ret[0]);
|
|
343
343
|
}
|
|
344
|
+
/**
|
|
345
|
+
* @param {Uint8Array} bytes
|
|
346
|
+
*/
|
|
347
|
+
importFile(bytes) {
|
|
348
|
+
const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_malloc);
|
|
349
|
+
const len0 = WASM_VECTOR_LEN;
|
|
350
|
+
const ret = wasm.rawflock_importFile(this.__wbg_ptr, ptr0, len0);
|
|
351
|
+
if (ret[1]) {
|
|
352
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
353
|
+
}
|
|
354
|
+
}
|
|
344
355
|
/**
|
|
345
356
|
* Imports a JSON bundle into this flock instance.
|
|
346
357
|
*
|
|
@@ -348,22 +359,16 @@ export class RawFlock {
|
|
|
348
359
|
*
|
|
349
360
|
* * `bundle` - The export bundle to import
|
|
350
361
|
*
|
|
351
|
-
* # Returns
|
|
352
|
-
*
|
|
353
|
-
* An import report containing counts of accepted and skipped entries.
|
|
354
|
-
*
|
|
355
362
|
* # Errors
|
|
356
363
|
*
|
|
357
364
|
* Returns an error if the bundle is invalid or import fails.
|
|
358
365
|
* @param {any} bundle
|
|
359
|
-
* @returns {any}
|
|
360
366
|
*/
|
|
361
367
|
importJson(bundle) {
|
|
362
368
|
const ret = wasm.rawflock_importJson(this.__wbg_ptr, bundle);
|
|
363
|
-
if (ret[
|
|
364
|
-
throw takeFromExternrefTable0(ret[
|
|
369
|
+
if (ret[1]) {
|
|
370
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
365
371
|
}
|
|
366
|
-
return takeFromExternrefTable0(ret[0]);
|
|
367
372
|
}
|
|
368
373
|
/**
|
|
369
374
|
* Sets a new peer ID for this flock instance.
|
|
@@ -571,23 +576,17 @@ export class RawFlock {
|
|
|
571
576
|
*
|
|
572
577
|
* * `other` - The other flock instance to merge from
|
|
573
578
|
*
|
|
574
|
-
* # Returns
|
|
575
|
-
*
|
|
576
|
-
* An import report containing counts of accepted and skipped entries.
|
|
577
|
-
*
|
|
578
579
|
* # Errors
|
|
579
580
|
*
|
|
580
581
|
* Returns an error if the merge operation fails.
|
|
581
582
|
* @param {RawFlock} other
|
|
582
|
-
* @returns {any}
|
|
583
583
|
*/
|
|
584
584
|
merge(other) {
|
|
585
585
|
_assertClass(other, RawFlock);
|
|
586
586
|
const ret = wasm.rawflock_merge(this.__wbg_ptr, other.__wbg_ptr);
|
|
587
|
-
if (ret[
|
|
588
|
-
throw takeFromExternrefTable0(ret[
|
|
587
|
+
if (ret[1]) {
|
|
588
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
589
589
|
}
|
|
590
|
-
return takeFromExternrefTable0(ret[0]);
|
|
591
590
|
}
|
|
592
591
|
/**
|
|
593
592
|
* Deletes the value at the specified key (creates a tombstone).
|
|
@@ -645,6 +644,13 @@ export class RawFlock {
|
|
|
645
644
|
}
|
|
646
645
|
return takeFromExternrefTable0(ret[0]);
|
|
647
646
|
}
|
|
647
|
+
/**
|
|
648
|
+
* @returns {boolean}
|
|
649
|
+
*/
|
|
650
|
+
isEmpty() {
|
|
651
|
+
const ret = wasm.rawflock_isEmpty(this.__wbg_ptr);
|
|
652
|
+
return ret !== 0;
|
|
653
|
+
}
|
|
648
654
|
/**
|
|
649
655
|
* Creates a new flock instance from a file bytes array.
|
|
650
656
|
*
|
|
@@ -1008,8 +1014,8 @@ export function __wbindgen_cb_drop(arg0) {
|
|
|
1008
1014
|
return ret;
|
|
1009
1015
|
};
|
|
1010
1016
|
|
|
1011
|
-
export function
|
|
1012
|
-
const ret = makeMutClosure(arg0, arg1,
|
|
1017
|
+
export function __wbindgen_closure_wrapper229(arg0, arg1, arg2) {
|
|
1018
|
+
const ret = makeMutClosure(arg0, arg1, 33, __wbg_adapter_56);
|
|
1013
1019
|
return ret;
|
|
1014
1020
|
};
|
|
1015
1021
|
|
|
Binary file
|
|
@@ -11,10 +11,12 @@ export const rawflock_fromJson: (a: any, b: number, c: number) => [number, numbe
|
|
|
11
11
|
export const rawflock_get: (a: number, b: any) => [number, number, number];
|
|
12
12
|
export const rawflock_getEntry: (a: number, b: any) => [number, number, number];
|
|
13
13
|
export const rawflock_getMaxPhysicalTime: (a: number) => number;
|
|
14
|
-
export const
|
|
14
|
+
export const rawflock_importFile: (a: number, b: number, c: number) => [number, number];
|
|
15
|
+
export const rawflock_importJson: (a: number, b: any) => [number, number];
|
|
15
16
|
export const rawflock_inclusiveVersion: (a: number) => [number, number, number];
|
|
17
|
+
export const rawflock_isEmpty: (a: number) => number;
|
|
16
18
|
export const rawflock_isInTxn: (a: number) => number;
|
|
17
|
-
export const rawflock_merge: (a: number, b: number) => [number, number
|
|
19
|
+
export const rawflock_merge: (a: number, b: number) => [number, number];
|
|
18
20
|
export const rawflock_new: (a: number, b: number) => [number, number, number];
|
|
19
21
|
export const rawflock_peerId: (a: number) => [number, number];
|
|
20
22
|
export const rawflock_put: (a: number, b: any, c: any, d: any) => [number, number];
|
|
@@ -36,5 +38,5 @@ export const __wbindgen_export_4: WebAssembly.Table;
|
|
|
36
38
|
export const __wbindgen_free: (a: number, b: number, c: number) => void;
|
|
37
39
|
export const __wbindgen_export_6: WebAssembly.Table;
|
|
38
40
|
export const __externref_table_dealloc: (a: number) => void;
|
|
39
|
-
export const
|
|
41
|
+
export const closure32_externref_shim: (a: number, b: number, c: any) => void;
|
|
40
42
|
export const __wbindgen_start: () => void;
|
package/bundler/index.d.ts
CHANGED
|
@@ -67,13 +67,6 @@ export type ImportDecision = ImportAccept | ImportSkip | ImportPayload | void;
|
|
|
67
67
|
export type ImportHooks = {
|
|
68
68
|
preprocess?: (context: ImportHookContext, payload: ImportPayload) => MaybePromise<ImportDecision>;
|
|
69
69
|
};
|
|
70
|
-
export type ImportReport = {
|
|
71
|
-
accepted: number;
|
|
72
|
-
skipped: Array<{
|
|
73
|
-
key: KeyPart[];
|
|
74
|
-
reason: string;
|
|
75
|
-
}>;
|
|
76
|
-
};
|
|
77
70
|
export type PutPayload = ExportPayload;
|
|
78
71
|
export type PutHookContext = {
|
|
79
72
|
key: KeyPart[];
|
|
@@ -126,6 +119,7 @@ export declare class Flock {
|
|
|
126
119
|
private static fromInner;
|
|
127
120
|
static fromJson(bundle: ExportBundle, peerId: string): Flock;
|
|
128
121
|
static fromFile(bytes: Uint8Array, peerId?: string): Flock;
|
|
122
|
+
isEmpty(): boolean;
|
|
129
123
|
checkInvariants(): void;
|
|
130
124
|
setPeerId(peerId: string): void;
|
|
131
125
|
private putWithMetaInternal;
|
|
@@ -183,9 +177,10 @@ export declare class Flock {
|
|
|
183
177
|
exportJson(options: ExportOptions): Promise<ExportBundle>;
|
|
184
178
|
private importJsonInternal;
|
|
185
179
|
private importJsonWithHooks;
|
|
186
|
-
importJson(bundle: ExportBundle):
|
|
187
|
-
importJson(options: ImportOptions): Promise<
|
|
188
|
-
|
|
180
|
+
importJson(bundle: ExportBundle): void;
|
|
181
|
+
importJson(options: ImportOptions): Promise<void>;
|
|
182
|
+
importFile(bytes: Uint8Array): void;
|
|
183
|
+
importJsonStr(bundle: string): void;
|
|
189
184
|
getMaxPhysicalTime(): number;
|
|
190
185
|
peerId(): string;
|
|
191
186
|
kvToJson(): ExportBundle;
|
package/bundler/index.js
CHANGED
|
@@ -241,7 +241,7 @@ function decodeVersionVectorBinary(bytes) {
|
|
|
241
241
|
return decodeLegacyVersionVector(bytes);
|
|
242
242
|
}
|
|
243
243
|
function encodeVersionVectorForFfi(vv) {
|
|
244
|
-
if (!vv) {
|
|
244
|
+
if (!vv || Object.keys(vv).length === 0) {
|
|
245
245
|
return undefined;
|
|
246
246
|
}
|
|
247
247
|
const raw = {};
|
|
@@ -502,20 +502,6 @@ function normalizeImportDecision(decision) {
|
|
|
502
502
|
}
|
|
503
503
|
return { accept: true };
|
|
504
504
|
}
|
|
505
|
-
function decodeImportReport(raw) {
|
|
506
|
-
if (!raw || typeof raw !== "object") {
|
|
507
|
-
return { accepted: 0, skipped: [] };
|
|
508
|
-
}
|
|
509
|
-
const report = raw;
|
|
510
|
-
const accepted = typeof report.accepted === "number" ? report.accepted : 0;
|
|
511
|
-
const skippedRaw = Array.isArray(report.skipped) ? report.skipped : [];
|
|
512
|
-
const skipped = skippedRaw.map((entry) => {
|
|
513
|
-
const key = entry && Array.isArray(entry.key) ? entry.key : [];
|
|
514
|
-
const reason = entry && typeof entry.reason === "string" ? entry.reason : "unknown";
|
|
515
|
-
return { key, reason };
|
|
516
|
-
});
|
|
517
|
-
return { accepted, skipped };
|
|
518
|
-
}
|
|
519
505
|
function cloneBundle(bundle) {
|
|
520
506
|
const next = { version: bundle.version, entries: {} };
|
|
521
507
|
for (const [key, record] of Object.entries(bundle.entries)) {
|
|
@@ -576,6 +562,9 @@ export class Flock {
|
|
|
576
562
|
const inner = RawFlock.fromFile(normalizePeerId(peerId), bytes);
|
|
577
563
|
return Flock.fromInner(inner);
|
|
578
564
|
}
|
|
565
|
+
isEmpty() {
|
|
566
|
+
return this.inner.isEmpty();
|
|
567
|
+
}
|
|
579
568
|
checkInvariants() {
|
|
580
569
|
void this.version();
|
|
581
570
|
void this.inclusiveVersion();
|
|
@@ -647,7 +636,7 @@ export class Flock {
|
|
|
647
636
|
}
|
|
648
637
|
merge(other) {
|
|
649
638
|
this.eventBatcher.beforeImport();
|
|
650
|
-
|
|
639
|
+
this.inner.merge(other.inner);
|
|
651
640
|
}
|
|
652
641
|
/**
|
|
653
642
|
* Returns the exclusive/visible version vector.
|
|
@@ -706,13 +695,11 @@ export class Flock {
|
|
|
706
695
|
}
|
|
707
696
|
importJsonInternal(bundle) {
|
|
708
697
|
this.eventBatcher.beforeImport();
|
|
709
|
-
|
|
710
|
-
return decodeImportReport(report);
|
|
698
|
+
this.inner.importJson(bundle);
|
|
711
699
|
}
|
|
712
700
|
async importJsonWithHooks(options) {
|
|
713
701
|
const preprocess = options.hooks?.preprocess;
|
|
714
702
|
const working = preprocess ? cloneBundle(options.bundle) : options.bundle;
|
|
715
|
-
const skippedByHooks = [];
|
|
716
703
|
if (preprocess) {
|
|
717
704
|
for (const key of Object.keys(working.entries)) {
|
|
718
705
|
const record = working.entries[key];
|
|
@@ -724,18 +711,13 @@ export class Flock {
|
|
|
724
711
|
const decision = await preprocess(context, clonePayload(basePayload));
|
|
725
712
|
const normalized = normalizeImportDecision(decision);
|
|
726
713
|
if (!normalized.accept) {
|
|
727
|
-
skippedByHooks.push({ key: context.key, reason: normalized.reason });
|
|
728
714
|
delete working.entries[key];
|
|
729
715
|
continue;
|
|
730
716
|
}
|
|
731
717
|
working.entries[key] = buildRecord(record.c, basePayload);
|
|
732
718
|
}
|
|
733
719
|
}
|
|
734
|
-
|
|
735
|
-
return {
|
|
736
|
-
accepted: coreReport.accepted,
|
|
737
|
-
skipped: skippedByHooks.concat(coreReport.skipped),
|
|
738
|
-
};
|
|
720
|
+
this.importJsonInternal(working);
|
|
739
721
|
}
|
|
740
722
|
importJson(arg) {
|
|
741
723
|
if (isImportOptions(arg)) {
|
|
@@ -743,9 +725,13 @@ export class Flock {
|
|
|
743
725
|
}
|
|
744
726
|
return this.importJsonInternal(arg);
|
|
745
727
|
}
|
|
728
|
+
importFile(bytes) {
|
|
729
|
+
this.eventBatcher.beforeImport();
|
|
730
|
+
this.inner.importFile(bytes);
|
|
731
|
+
}
|
|
746
732
|
importJsonStr(bundle) {
|
|
747
733
|
const parsed = JSON.parse(bundle);
|
|
748
|
-
|
|
734
|
+
this.importJson(parsed);
|
|
749
735
|
}
|
|
750
736
|
getMaxPhysicalTime() {
|
|
751
737
|
return Number(this.inner.getMaxPhysicalTime());
|
package/bundler/wasm.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ export declare class RawFlock {
|
|
|
2
2
|
constructor(peerId: string);
|
|
3
3
|
static fromJson(bundle: unknown, peerId: string): RawFlock;
|
|
4
4
|
static fromFile(peerId: string, bytes: Uint8Array): RawFlock;
|
|
5
|
+
isEmpty(): boolean;
|
|
5
6
|
peerId(): string;
|
|
6
7
|
setPeerId(peerId: string): void;
|
|
7
8
|
getMaxPhysicalTime(): number;
|
|
@@ -21,8 +22,9 @@ export declare class RawFlock {
|
|
|
21
22
|
pruneTombstonesBefore?: number,
|
|
22
23
|
peerId?: string,
|
|
23
24
|
): unknown;
|
|
24
|
-
importJson(bundle: unknown):
|
|
25
|
-
|
|
25
|
+
importJson(bundle: unknown): void;
|
|
26
|
+
importFile(bytes: Uint8Array): void;
|
|
27
|
+
merge(other: RawFlock): void;
|
|
26
28
|
version(): unknown;
|
|
27
29
|
inclusiveVersion(): unknown;
|
|
28
30
|
exportFile(): Uint8Array;
|
package/nodejs/flock_wasm.d.ts
CHANGED
|
@@ -1,12 +1,5 @@
|
|
|
1
1
|
/* tslint:disable */
|
|
2
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
3
|
/**
|
|
11
4
|
* Drains the pending callback queue, invoking all enqueued callbacks.
|
|
12
5
|
*
|
|
@@ -17,6 +10,13 @@ export function start(): void;
|
|
|
17
10
|
* the error is propagated to JavaScript after the current batch completes.
|
|
18
11
|
*/
|
|
19
12
|
export function callPendingEvents(): void;
|
|
13
|
+
/**
|
|
14
|
+
* Initializes the WASM module.
|
|
15
|
+
*
|
|
16
|
+
* This function is automatically called when the WASM module is loaded.
|
|
17
|
+
* It sets up the panic hook to route Rust panics to the JavaScript console.
|
|
18
|
+
*/
|
|
19
|
+
export function start(): void;
|
|
20
20
|
/**
|
|
21
21
|
* The main WASM-exposed flock instance.
|
|
22
22
|
*
|
|
@@ -55,6 +55,7 @@ export class RawFlock {
|
|
|
55
55
|
* Returns an error if arguments are invalid or serialization fails.
|
|
56
56
|
*/
|
|
57
57
|
exportJson(from: any, prune_tombstones_before: any, peer_id: any): any;
|
|
58
|
+
importFile(bytes: Uint8Array): void;
|
|
58
59
|
/**
|
|
59
60
|
* Imports a JSON bundle into this flock instance.
|
|
60
61
|
*
|
|
@@ -62,15 +63,11 @@ export class RawFlock {
|
|
|
62
63
|
*
|
|
63
64
|
* * `bundle` - The export bundle to import
|
|
64
65
|
*
|
|
65
|
-
* # Returns
|
|
66
|
-
*
|
|
67
|
-
* An import report containing counts of accepted and skipped entries.
|
|
68
|
-
*
|
|
69
66
|
* # Errors
|
|
70
67
|
*
|
|
71
68
|
* Returns an error if the bundle is invalid or import fails.
|
|
72
69
|
*/
|
|
73
|
-
importJson(bundle: any):
|
|
70
|
+
importJson(bundle: any): void;
|
|
74
71
|
/**
|
|
75
72
|
* Sets a new peer ID for this flock instance.
|
|
76
73
|
*
|
|
@@ -205,15 +202,11 @@ export class RawFlock {
|
|
|
205
202
|
*
|
|
206
203
|
* * `other` - The other flock instance to merge from
|
|
207
204
|
*
|
|
208
|
-
* # Returns
|
|
209
|
-
*
|
|
210
|
-
* An import report containing counts of accepted and skipped entries.
|
|
211
|
-
*
|
|
212
205
|
* # Errors
|
|
213
206
|
*
|
|
214
207
|
* Returns an error if the merge operation fails.
|
|
215
208
|
*/
|
|
216
|
-
merge(other: RawFlock):
|
|
209
|
+
merge(other: RawFlock): void;
|
|
217
210
|
/**
|
|
218
211
|
* Deletes the value at the specified key (creates a tombstone).
|
|
219
212
|
*
|
|
@@ -244,6 +237,7 @@ export class RawFlock {
|
|
|
244
237
|
* Returns an error if serialization fails.
|
|
245
238
|
*/
|
|
246
239
|
version(): any;
|
|
240
|
+
isEmpty(): boolean;
|
|
247
241
|
/**
|
|
248
242
|
* Creates a new flock instance from a file bytes array.
|
|
249
243
|
*
|
package/nodejs/flock_wasm.js
CHANGED
|
@@ -201,16 +201,6 @@ function debugString(val) {
|
|
|
201
201
|
// TODO we could test for more things here, like `Set`s and `Map`s.
|
|
202
202
|
return className;
|
|
203
203
|
}
|
|
204
|
-
/**
|
|
205
|
-
* Initializes the WASM module.
|
|
206
|
-
*
|
|
207
|
-
* This function is automatically called when the WASM module is loaded.
|
|
208
|
-
* It sets up the panic hook to route Rust panics to the JavaScript console.
|
|
209
|
-
*/
|
|
210
|
-
module.exports.start = function() {
|
|
211
|
-
wasm.start();
|
|
212
|
-
};
|
|
213
|
-
|
|
214
204
|
/**
|
|
215
205
|
* Drains the pending callback queue, invoking all enqueued callbacks.
|
|
216
206
|
*
|
|
@@ -224,6 +214,16 @@ module.exports.callPendingEvents = function() {
|
|
|
224
214
|
wasm.callPendingEvents();
|
|
225
215
|
};
|
|
226
216
|
|
|
217
|
+
/**
|
|
218
|
+
* Initializes the WASM module.
|
|
219
|
+
*
|
|
220
|
+
* This function is automatically called when the WASM module is loaded.
|
|
221
|
+
* It sets up the panic hook to route Rust panics to the JavaScript console.
|
|
222
|
+
*/
|
|
223
|
+
module.exports.start = function() {
|
|
224
|
+
wasm.start();
|
|
225
|
+
};
|
|
226
|
+
|
|
227
227
|
function takeFromExternrefTable0(idx) {
|
|
228
228
|
const value = wasm.__wbindgen_export_4.get(idx);
|
|
229
229
|
wasm.__externref_table_dealloc(idx);
|
|
@@ -235,20 +235,20 @@ function getArrayU8FromWasm0(ptr, len) {
|
|
|
235
235
|
return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
|
|
236
236
|
}
|
|
237
237
|
|
|
238
|
-
function _assertClass(instance, klass) {
|
|
239
|
-
if (!(instance instanceof klass)) {
|
|
240
|
-
throw new Error(`expected instance of ${klass.name}`);
|
|
241
|
-
}
|
|
242
|
-
}
|
|
243
|
-
|
|
244
238
|
function passArray8ToWasm0(arg, malloc) {
|
|
245
239
|
const ptr = malloc(arg.length * 1, 1) >>> 0;
|
|
246
240
|
getUint8ArrayMemory0().set(arg, ptr / 1);
|
|
247
241
|
WASM_VECTOR_LEN = arg.length;
|
|
248
242
|
return ptr;
|
|
249
243
|
}
|
|
244
|
+
|
|
245
|
+
function _assertClass(instance, klass) {
|
|
246
|
+
if (!(instance instanceof klass)) {
|
|
247
|
+
throw new Error(`expected instance of ${klass.name}`);
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
250
|
function __wbg_adapter_56(arg0, arg1, arg2) {
|
|
251
|
-
wasm.
|
|
251
|
+
wasm.closure32_externref_shim(arg0, arg1, arg2);
|
|
252
252
|
}
|
|
253
253
|
|
|
254
254
|
const RawFlockFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
@@ -337,6 +337,17 @@ class RawFlock {
|
|
|
337
337
|
}
|
|
338
338
|
return takeFromExternrefTable0(ret[0]);
|
|
339
339
|
}
|
|
340
|
+
/**
|
|
341
|
+
* @param {Uint8Array} bytes
|
|
342
|
+
*/
|
|
343
|
+
importFile(bytes) {
|
|
344
|
+
const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_malloc);
|
|
345
|
+
const len0 = WASM_VECTOR_LEN;
|
|
346
|
+
const ret = wasm.rawflock_importFile(this.__wbg_ptr, ptr0, len0);
|
|
347
|
+
if (ret[1]) {
|
|
348
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
349
|
+
}
|
|
350
|
+
}
|
|
340
351
|
/**
|
|
341
352
|
* Imports a JSON bundle into this flock instance.
|
|
342
353
|
*
|
|
@@ -344,22 +355,16 @@ class RawFlock {
|
|
|
344
355
|
*
|
|
345
356
|
* * `bundle` - The export bundle to import
|
|
346
357
|
*
|
|
347
|
-
* # Returns
|
|
348
|
-
*
|
|
349
|
-
* An import report containing counts of accepted and skipped entries.
|
|
350
|
-
*
|
|
351
358
|
* # Errors
|
|
352
359
|
*
|
|
353
360
|
* Returns an error if the bundle is invalid or import fails.
|
|
354
361
|
* @param {any} bundle
|
|
355
|
-
* @returns {any}
|
|
356
362
|
*/
|
|
357
363
|
importJson(bundle) {
|
|
358
364
|
const ret = wasm.rawflock_importJson(this.__wbg_ptr, bundle);
|
|
359
|
-
if (ret[
|
|
360
|
-
throw takeFromExternrefTable0(ret[
|
|
365
|
+
if (ret[1]) {
|
|
366
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
361
367
|
}
|
|
362
|
-
return takeFromExternrefTable0(ret[0]);
|
|
363
368
|
}
|
|
364
369
|
/**
|
|
365
370
|
* Sets a new peer ID for this flock instance.
|
|
@@ -567,23 +572,17 @@ class RawFlock {
|
|
|
567
572
|
*
|
|
568
573
|
* * `other` - The other flock instance to merge from
|
|
569
574
|
*
|
|
570
|
-
* # Returns
|
|
571
|
-
*
|
|
572
|
-
* An import report containing counts of accepted and skipped entries.
|
|
573
|
-
*
|
|
574
575
|
* # Errors
|
|
575
576
|
*
|
|
576
577
|
* Returns an error if the merge operation fails.
|
|
577
578
|
* @param {RawFlock} other
|
|
578
|
-
* @returns {any}
|
|
579
579
|
*/
|
|
580
580
|
merge(other) {
|
|
581
581
|
_assertClass(other, RawFlock);
|
|
582
582
|
const ret = wasm.rawflock_merge(this.__wbg_ptr, other.__wbg_ptr);
|
|
583
|
-
if (ret[
|
|
584
|
-
throw takeFromExternrefTable0(ret[
|
|
583
|
+
if (ret[1]) {
|
|
584
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
585
585
|
}
|
|
586
|
-
return takeFromExternrefTable0(ret[0]);
|
|
587
586
|
}
|
|
588
587
|
/**
|
|
589
588
|
* Deletes the value at the specified key (creates a tombstone).
|
|
@@ -641,6 +640,13 @@ class RawFlock {
|
|
|
641
640
|
}
|
|
642
641
|
return takeFromExternrefTable0(ret[0]);
|
|
643
642
|
}
|
|
643
|
+
/**
|
|
644
|
+
* @returns {boolean}
|
|
645
|
+
*/
|
|
646
|
+
isEmpty() {
|
|
647
|
+
const ret = wasm.rawflock_isEmpty(this.__wbg_ptr);
|
|
648
|
+
return ret !== 0;
|
|
649
|
+
}
|
|
644
650
|
/**
|
|
645
651
|
* Creates a new flock instance from a file bytes array.
|
|
646
652
|
*
|
|
@@ -1005,8 +1011,8 @@ module.exports.__wbindgen_cb_drop = function(arg0) {
|
|
|
1005
1011
|
return ret;
|
|
1006
1012
|
};
|
|
1007
1013
|
|
|
1008
|
-
module.exports.
|
|
1009
|
-
const ret = makeMutClosure(arg0, arg1,
|
|
1014
|
+
module.exports.__wbindgen_closure_wrapper229 = function(arg0, arg1, arg2) {
|
|
1015
|
+
const ret = makeMutClosure(arg0, arg1, 33, __wbg_adapter_56);
|
|
1010
1016
|
return ret;
|
|
1011
1017
|
};
|
|
1012
1018
|
|
|
Binary file
|
|
@@ -11,10 +11,12 @@ export const rawflock_fromJson: (a: any, b: number, c: number) => [number, numbe
|
|
|
11
11
|
export const rawflock_get: (a: number, b: any) => [number, number, number];
|
|
12
12
|
export const rawflock_getEntry: (a: number, b: any) => [number, number, number];
|
|
13
13
|
export const rawflock_getMaxPhysicalTime: (a: number) => number;
|
|
14
|
-
export const
|
|
14
|
+
export const rawflock_importFile: (a: number, b: number, c: number) => [number, number];
|
|
15
|
+
export const rawflock_importJson: (a: number, b: any) => [number, number];
|
|
15
16
|
export const rawflock_inclusiveVersion: (a: number) => [number, number, number];
|
|
17
|
+
export const rawflock_isEmpty: (a: number) => number;
|
|
16
18
|
export const rawflock_isInTxn: (a: number) => number;
|
|
17
|
-
export const rawflock_merge: (a: number, b: number) => [number, number
|
|
19
|
+
export const rawflock_merge: (a: number, b: number) => [number, number];
|
|
18
20
|
export const rawflock_new: (a: number, b: number) => [number, number, number];
|
|
19
21
|
export const rawflock_peerId: (a: number) => [number, number];
|
|
20
22
|
export const rawflock_put: (a: number, b: any, c: any, d: any) => [number, number];
|
|
@@ -36,5 +38,5 @@ export const __wbindgen_export_4: WebAssembly.Table;
|
|
|
36
38
|
export const __wbindgen_free: (a: number, b: number, c: number) => void;
|
|
37
39
|
export const __wbindgen_export_6: WebAssembly.Table;
|
|
38
40
|
export const __externref_table_dealloc: (a: number) => void;
|
|
39
|
-
export const
|
|
41
|
+
export const closure32_externref_shim: (a: number, b: number, c: any) => void;
|
|
40
42
|
export const __wbindgen_start: () => void;
|