@loro-dev/flock-wasm 0.1.1 → 0.1.3
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/base64/flock_wasm.js +19 -14
- package/base64/index.d.ts +11 -6
- package/base64/index.js +13 -8
- package/base64/wasm.js +1 -1
- package/bundler/flock_wasm.d.ts +16 -11
- package/bundler/flock_wasm.js +197 -4
- package/bundler/flock_wasm_bg.js +19 -14
- package/bundler/flock_wasm_bg.wasm +0 -0
- package/bundler/index.d.ts +11 -6
- package/bundler/index.js +13 -8
- package/nodejs/flock_wasm.d.ts +16 -11
- package/nodejs/flock_wasm.js +19 -14
- package/nodejs/flock_wasm_bg.wasm +0 -0
- package/nodejs/index.d.ts +11 -6
- package/nodejs/index.js +21 -16
- package/package.json +2 -1
- package/web/flock_wasm.d.ts +16 -11
- package/web/flock_wasm.js +19 -14
- package/web/flock_wasm_bg.wasm +0 -0
- package/web/index.d.ts +11 -6
- package/web/index.js +13 -8
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
|
*
|
|
@@ -120,8 +120,11 @@ export class RawFlock {
|
|
|
120
120
|
/**
|
|
121
121
|
* Returns the inclusive version vector for this flock.
|
|
122
122
|
*
|
|
123
|
-
*
|
|
124
|
-
*
|
|
123
|
+
* This vector tracks max seen clocks per peer for the current process
|
|
124
|
+
* lifetime (open/import/local writes), including peers that may no longer
|
|
125
|
+
* own visible entries.
|
|
126
|
+
*
|
|
127
|
+
* Use this vector for completeness checks, not incremental export baselines.
|
|
125
128
|
*
|
|
126
129
|
* # Errors
|
|
127
130
|
*
|
|
@@ -231,8 +234,10 @@ export class RawFlock {
|
|
|
231
234
|
/**
|
|
232
235
|
* Returns the exclusive version vector for this flock.
|
|
233
236
|
*
|
|
234
|
-
*
|
|
235
|
-
*
|
|
237
|
+
* This vector only includes peers that currently own at least one visible
|
|
238
|
+
* entry (excluding tombstones and shadowed entries).
|
|
239
|
+
*
|
|
240
|
+
* Use this vector as the baseline for incremental export/replication.
|
|
236
241
|
*
|
|
237
242
|
* # Errors
|
|
238
243
|
*
|
package/bundler/flock_wasm.js
CHANGED
|
@@ -1,5 +1,198 @@
|
|
|
1
|
-
import * as
|
|
2
|
-
|
|
1
|
+
import * as wasmModule from "./flock_wasm_bg.wasm";
|
|
2
|
+
import * as wasmBg from "./flock_wasm_bg.js";
|
|
3
3
|
import { __wbg_set_wasm } from "./flock_wasm_bg.js";
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
|
|
5
|
+
export * from "./flock_wasm_bg.js";
|
|
6
|
+
|
|
7
|
+
let wasm;
|
|
8
|
+
let initPromise;
|
|
9
|
+
|
|
10
|
+
function isRecordLike(value) {
|
|
11
|
+
return (typeof value === "object" || typeof value === "function") && value !== null;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
function toWasmExports(value) {
|
|
15
|
+
if (value instanceof WebAssembly.Instance) {
|
|
16
|
+
return value.exports;
|
|
17
|
+
}
|
|
18
|
+
if (!isRecordLike(value)) {
|
|
19
|
+
return undefined;
|
|
20
|
+
}
|
|
21
|
+
if (value.memory instanceof WebAssembly.Memory) {
|
|
22
|
+
return value;
|
|
23
|
+
}
|
|
24
|
+
return undefined;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function pickExistingWasmExports(value) {
|
|
28
|
+
const queue = [value];
|
|
29
|
+
const seen = new Set();
|
|
30
|
+
while (queue.length > 0) {
|
|
31
|
+
const current = queue.shift();
|
|
32
|
+
const exports = toWasmExports(current);
|
|
33
|
+
if (exports !== undefined) {
|
|
34
|
+
return exports;
|
|
35
|
+
}
|
|
36
|
+
if (!isRecordLike(current)) {
|
|
37
|
+
continue;
|
|
38
|
+
}
|
|
39
|
+
if (seen.has(current)) {
|
|
40
|
+
continue;
|
|
41
|
+
}
|
|
42
|
+
seen.add(current);
|
|
43
|
+
if ("default" in current) {
|
|
44
|
+
queue.push(current.default);
|
|
45
|
+
}
|
|
46
|
+
if ("instance" in current) {
|
|
47
|
+
queue.push(current.instance);
|
|
48
|
+
}
|
|
49
|
+
if ("module" in current) {
|
|
50
|
+
queue.push(current.module);
|
|
51
|
+
}
|
|
52
|
+
if ("exports" in current) {
|
|
53
|
+
queue.push(current.exports);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
return undefined;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
function resolveModuleSource(moduleSource) {
|
|
60
|
+
if (typeof moduleSource !== "string") {
|
|
61
|
+
return moduleSource;
|
|
62
|
+
}
|
|
63
|
+
if (typeof URL !== "function") {
|
|
64
|
+
return moduleSource;
|
|
65
|
+
}
|
|
66
|
+
try {
|
|
67
|
+
return new URL(moduleSource);
|
|
68
|
+
} catch (_error) {
|
|
69
|
+
return new URL(moduleSource, import.meta.url);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
async function readFileUrlBytes(fileUrl) {
|
|
74
|
+
const { readFile } = await import("node:fs/promises");
|
|
75
|
+
const { fileURLToPath } = await import("node:url");
|
|
76
|
+
const filePath = fileURLToPath(fileUrl);
|
|
77
|
+
return readFile(filePath);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
async function instantiateWasm(moduleSource) {
|
|
81
|
+
if (moduleSource && typeof moduleSource.then === "function") {
|
|
82
|
+
moduleSource = await moduleSource;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
const existing = pickExistingWasmExports(moduleSource);
|
|
86
|
+
if (existing !== undefined) {
|
|
87
|
+
return existing;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
// Some bundlers expose wasm assets as namespace objects with a default export.
|
|
91
|
+
if (isRecordLike(moduleSource)) {
|
|
92
|
+
const nestedCandidates = [
|
|
93
|
+
"default",
|
|
94
|
+
"module_or_path",
|
|
95
|
+
"module",
|
|
96
|
+
"wasm",
|
|
97
|
+
"url",
|
|
98
|
+
];
|
|
99
|
+
for (const key of nestedCandidates) {
|
|
100
|
+
if (!(key in moduleSource)) {
|
|
101
|
+
continue;
|
|
102
|
+
}
|
|
103
|
+
const nested = moduleSource[key];
|
|
104
|
+
if (nested === undefined || nested === moduleSource) {
|
|
105
|
+
continue;
|
|
106
|
+
}
|
|
107
|
+
return instantiateWasm(nested);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
const imports = { "./flock_wasm_bg.js": wasmBg };
|
|
112
|
+
|
|
113
|
+
if (moduleSource instanceof WebAssembly.Module) {
|
|
114
|
+
return new WebAssembly.Instance(moduleSource, imports).exports;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
if (
|
|
118
|
+
moduleSource instanceof ArrayBuffer ||
|
|
119
|
+
ArrayBuffer.isView(moduleSource)
|
|
120
|
+
) {
|
|
121
|
+
const result = await WebAssembly.instantiate(moduleSource, imports);
|
|
122
|
+
if (result instanceof WebAssembly.Instance) {
|
|
123
|
+
return result.exports;
|
|
124
|
+
}
|
|
125
|
+
return result.instance.exports;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
if (
|
|
129
|
+
typeof Response === "function" &&
|
|
130
|
+
moduleSource instanceof Response
|
|
131
|
+
) {
|
|
132
|
+
if (typeof WebAssembly.instantiateStreaming === "function") {
|
|
133
|
+
try {
|
|
134
|
+
const responseForStreaming = moduleSource.clone();
|
|
135
|
+
const streaming = await WebAssembly.instantiateStreaming(
|
|
136
|
+
responseForStreaming,
|
|
137
|
+
imports,
|
|
138
|
+
);
|
|
139
|
+
return streaming.instance.exports;
|
|
140
|
+
} catch (_error) {
|
|
141
|
+
// Fall back to arrayBuffer in runtimes with strict MIME handling.
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
const bytes = await moduleSource.arrayBuffer();
|
|
145
|
+
const result = await WebAssembly.instantiate(bytes, imports);
|
|
146
|
+
if (result instanceof WebAssembly.Instance) {
|
|
147
|
+
return result.exports;
|
|
148
|
+
}
|
|
149
|
+
return result.instance.exports;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
if (
|
|
153
|
+
typeof moduleSource === "string" ||
|
|
154
|
+
(typeof URL === "function" && moduleSource instanceof URL) ||
|
|
155
|
+
(typeof Request === "function" && moduleSource instanceof Request)
|
|
156
|
+
) {
|
|
157
|
+
let requestTarget = moduleSource;
|
|
158
|
+
if (typeof moduleSource === "string") {
|
|
159
|
+
requestTarget = resolveModuleSource(moduleSource);
|
|
160
|
+
}
|
|
161
|
+
if (typeof URL === "function" && requestTarget instanceof URL && requestTarget.protocol === "file:") {
|
|
162
|
+
const bytes = await readFileUrlBytes(requestTarget);
|
|
163
|
+
return instantiateWasm(bytes);
|
|
164
|
+
}
|
|
165
|
+
if (typeof fetch !== "function") {
|
|
166
|
+
throw new TypeError("fetch is not available to load the wasm module");
|
|
167
|
+
}
|
|
168
|
+
return instantiateWasm(fetch(requestTarget));
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
throw new TypeError("Unsupported wasm module shape for flock-wasm bundler init");
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
async function __wbg_init(moduleOrExports = wasmModule) {
|
|
175
|
+
if (wasm !== undefined) {
|
|
176
|
+
return wasm;
|
|
177
|
+
}
|
|
178
|
+
if (initPromise !== undefined) {
|
|
179
|
+
return initPromise;
|
|
180
|
+
}
|
|
181
|
+
initPromise = (async () => {
|
|
182
|
+
const resolved = await instantiateWasm(moduleOrExports);
|
|
183
|
+
__wbg_set_wasm(resolved);
|
|
184
|
+
if (typeof resolved.__wbindgen_start === "function") {
|
|
185
|
+
resolved.__wbindgen_start();
|
|
186
|
+
}
|
|
187
|
+
wasm = resolved;
|
|
188
|
+
return wasm;
|
|
189
|
+
})();
|
|
190
|
+
try {
|
|
191
|
+
return await initPromise;
|
|
192
|
+
} catch (error) {
|
|
193
|
+
initPromise = undefined;
|
|
194
|
+
throw error;
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
export default __wbg_init;
|
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);
|
|
@@ -438,8 +438,11 @@ export class RawFlock {
|
|
|
438
438
|
/**
|
|
439
439
|
* Returns the inclusive version vector for this flock.
|
|
440
440
|
*
|
|
441
|
-
*
|
|
442
|
-
*
|
|
441
|
+
* This vector tracks max seen clocks per peer for the current process
|
|
442
|
+
* lifetime (open/import/local writes), including peers that may no longer
|
|
443
|
+
* own visible entries.
|
|
444
|
+
*
|
|
445
|
+
* Use this vector for completeness checks, not incremental export baselines.
|
|
443
446
|
*
|
|
444
447
|
* # Errors
|
|
445
448
|
*
|
|
@@ -625,8 +628,10 @@ export class RawFlock {
|
|
|
625
628
|
/**
|
|
626
629
|
* Returns the exclusive version vector for this flock.
|
|
627
630
|
*
|
|
628
|
-
*
|
|
629
|
-
*
|
|
631
|
+
* This vector only includes peers that currently own at least one visible
|
|
632
|
+
* entry (excluding tombstones and shadowed entries).
|
|
633
|
+
*
|
|
634
|
+
* Use this vector as the baseline for incremental export/replication.
|
|
630
635
|
*
|
|
631
636
|
* # Errors
|
|
632
637
|
*
|
|
Binary file
|
package/bundler/index.d.ts
CHANGED
|
@@ -156,18 +156,23 @@ export declare class Flock {
|
|
|
156
156
|
getEntry(key: KeyPart[]): EntryInfo | undefined;
|
|
157
157
|
merge(other: Flock): void;
|
|
158
158
|
/**
|
|
159
|
-
* Returns the exclusive version vector
|
|
160
|
-
*
|
|
161
|
-
*
|
|
159
|
+
* Returns the exclusive/visible version vector.
|
|
160
|
+
*
|
|
161
|
+
* Only peers that currently own at least one visible entry are included.
|
|
162
|
+
* This vector is consistent with current visible state and is the correct
|
|
163
|
+
* baseline for incremental export/replication.
|
|
162
164
|
*
|
|
163
165
|
* Use this version when sending to other peers for incremental sync.
|
|
164
166
|
*/
|
|
165
167
|
version(): VersionVector;
|
|
166
168
|
/**
|
|
167
|
-
* Returns the inclusive version vector
|
|
168
|
-
*
|
|
169
|
+
* Returns the inclusive/max-seen version vector.
|
|
170
|
+
*
|
|
171
|
+
* Tracks max seen clocks per peer for this process lifetime
|
|
172
|
+
* (open/import/local writes), including peers that may no longer own visible
|
|
173
|
+
* entries.
|
|
169
174
|
*
|
|
170
|
-
* Use this version
|
|
175
|
+
* Use this version for completeness checks, not incremental export baselines.
|
|
171
176
|
*/
|
|
172
177
|
inclusiveVersion(): VersionVector;
|
|
173
178
|
private exportJsonInternal;
|
package/bundler/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { RawFlock, callPendingEvents } from "./wasm";
|
|
2
|
-
import { EventBatcher } from "./event-batcher";
|
|
1
|
+
import { RawFlock, callPendingEvents } from "./wasm.js";
|
|
2
|
+
import { EventBatcher } from "./event-batcher.js";
|
|
3
3
|
export function encodeVersionVector(vector) {
|
|
4
4
|
return encodeVersionVectorBinary(vector);
|
|
5
5
|
}
|
|
@@ -650,9 +650,11 @@ export class Flock {
|
|
|
650
650
|
void this.inner.merge(other.inner);
|
|
651
651
|
}
|
|
652
652
|
/**
|
|
653
|
-
* Returns the exclusive version vector
|
|
654
|
-
*
|
|
655
|
-
*
|
|
653
|
+
* Returns the exclusive/visible version vector.
|
|
654
|
+
*
|
|
655
|
+
* Only peers that currently own at least one visible entry are included.
|
|
656
|
+
* This vector is consistent with current visible state and is the correct
|
|
657
|
+
* baseline for incremental export/replication.
|
|
656
658
|
*
|
|
657
659
|
* Use this version when sending to other peers for incremental sync.
|
|
658
660
|
*/
|
|
@@ -660,10 +662,13 @@ export class Flock {
|
|
|
660
662
|
return decodeVersionVectorFromRaw(this.inner.version());
|
|
661
663
|
}
|
|
662
664
|
/**
|
|
663
|
-
* Returns the inclusive version vector
|
|
664
|
-
*
|
|
665
|
+
* Returns the inclusive/max-seen version vector.
|
|
666
|
+
*
|
|
667
|
+
* Tracks max seen clocks per peer for this process lifetime
|
|
668
|
+
* (open/import/local writes), including peers that may no longer own visible
|
|
669
|
+
* entries.
|
|
665
670
|
*
|
|
666
|
-
* Use this version
|
|
671
|
+
* Use this version for completeness checks, not incremental export baselines.
|
|
667
672
|
*/
|
|
668
673
|
inclusiveVersion() {
|
|
669
674
|
return decodeVersionVectorFromRaw(this.inner.inclusiveVersion());
|
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
|
*
|
|
@@ -120,8 +120,11 @@ export class RawFlock {
|
|
|
120
120
|
/**
|
|
121
121
|
* Returns the inclusive version vector for this flock.
|
|
122
122
|
*
|
|
123
|
-
*
|
|
124
|
-
*
|
|
123
|
+
* This vector tracks max seen clocks per peer for the current process
|
|
124
|
+
* lifetime (open/import/local writes), including peers that may no longer
|
|
125
|
+
* own visible entries.
|
|
126
|
+
*
|
|
127
|
+
* Use this vector for completeness checks, not incremental export baselines.
|
|
125
128
|
*
|
|
126
129
|
* # Errors
|
|
127
130
|
*
|
|
@@ -231,8 +234,10 @@ export class RawFlock {
|
|
|
231
234
|
/**
|
|
232
235
|
* Returns the exclusive version vector for this flock.
|
|
233
236
|
*
|
|
234
|
-
*
|
|
235
|
-
*
|
|
237
|
+
* This vector only includes peers that currently own at least one visible
|
|
238
|
+
* entry (excluding tombstones and shadowed entries).
|
|
239
|
+
*
|
|
240
|
+
* Use this vector as the baseline for incremental export/replication.
|
|
236
241
|
*
|
|
237
242
|
* # Errors
|
|
238
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);
|
|
@@ -434,8 +434,11 @@ class RawFlock {
|
|
|
434
434
|
/**
|
|
435
435
|
* Returns the inclusive version vector for this flock.
|
|
436
436
|
*
|
|
437
|
-
*
|
|
438
|
-
*
|
|
437
|
+
* This vector tracks max seen clocks per peer for the current process
|
|
438
|
+
* lifetime (open/import/local writes), including peers that may no longer
|
|
439
|
+
* own visible entries.
|
|
440
|
+
*
|
|
441
|
+
* Use this vector for completeness checks, not incremental export baselines.
|
|
439
442
|
*
|
|
440
443
|
* # Errors
|
|
441
444
|
*
|
|
@@ -621,8 +624,10 @@ class RawFlock {
|
|
|
621
624
|
/**
|
|
622
625
|
* Returns the exclusive version vector for this flock.
|
|
623
626
|
*
|
|
624
|
-
*
|
|
625
|
-
*
|
|
627
|
+
* This vector only includes peers that currently own at least one visible
|
|
628
|
+
* entry (excluding tombstones and shadowed entries).
|
|
629
|
+
*
|
|
630
|
+
* Use this vector as the baseline for incremental export/replication.
|
|
626
631
|
*
|
|
627
632
|
* # Errors
|
|
628
633
|
*
|
|
Binary file
|
package/nodejs/index.d.ts
CHANGED
|
@@ -156,18 +156,23 @@ export declare class Flock {
|
|
|
156
156
|
getEntry(key: KeyPart[]): EntryInfo | undefined;
|
|
157
157
|
merge(other: Flock): void;
|
|
158
158
|
/**
|
|
159
|
-
* Returns the exclusive version vector
|
|
160
|
-
*
|
|
161
|
-
*
|
|
159
|
+
* Returns the exclusive/visible version vector.
|
|
160
|
+
*
|
|
161
|
+
* Only peers that currently own at least one visible entry are included.
|
|
162
|
+
* This vector is consistent with current visible state and is the correct
|
|
163
|
+
* baseline for incremental export/replication.
|
|
162
164
|
*
|
|
163
165
|
* Use this version when sending to other peers for incremental sync.
|
|
164
166
|
*/
|
|
165
167
|
version(): VersionVector;
|
|
166
168
|
/**
|
|
167
|
-
* Returns the inclusive version vector
|
|
168
|
-
*
|
|
169
|
+
* Returns the inclusive/max-seen version vector.
|
|
170
|
+
*
|
|
171
|
+
* Tracks max seen clocks per peer for this process lifetime
|
|
172
|
+
* (open/import/local writes), including peers that may no longer own visible
|
|
173
|
+
* entries.
|
|
169
174
|
*
|
|
170
|
-
* Use this version
|
|
175
|
+
* Use this version for completeness checks, not incremental export baselines.
|
|
171
176
|
*/
|
|
172
177
|
inclusiveVersion(): VersionVector;
|
|
173
178
|
private exportJsonInternal;
|
package/nodejs/index.js
CHANGED
|
@@ -3,8 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.Flock = void 0;
|
|
4
4
|
exports.encodeVersionVector = encodeVersionVector;
|
|
5
5
|
exports.decodeVersionVector = decodeVersionVector;
|
|
6
|
-
const
|
|
7
|
-
const
|
|
6
|
+
const wasm_js_1 = require("./wasm.js");
|
|
7
|
+
const event_batcher_js_1 = require("./event-batcher.js");
|
|
8
8
|
function encodeVersionVector(vector) {
|
|
9
9
|
return encodeVersionVectorBinary(vector);
|
|
10
10
|
}
|
|
@@ -552,8 +552,8 @@ class Flock {
|
|
|
552
552
|
nativeSubscriberId;
|
|
553
553
|
eventBatcher;
|
|
554
554
|
constructor(peerId) {
|
|
555
|
-
this.inner = new
|
|
556
|
-
this.eventBatcher = new
|
|
555
|
+
this.inner = new wasm_js_1.RawFlock(normalizePeerId(peerId));
|
|
556
|
+
this.eventBatcher = new event_batcher_js_1.EventBatcher({
|
|
557
557
|
runtime: defaultEventBatcherRuntime,
|
|
558
558
|
emit: (source, events) => {
|
|
559
559
|
this.deliverBatch({ source, events });
|
|
@@ -565,7 +565,7 @@ class Flock {
|
|
|
565
565
|
flock.inner = inner;
|
|
566
566
|
flock.listeners = new Set();
|
|
567
567
|
flock.nativeSubscriberId = undefined;
|
|
568
|
-
flock.eventBatcher = new
|
|
568
|
+
flock.eventBatcher = new event_batcher_js_1.EventBatcher({
|
|
569
569
|
runtime: defaultEventBatcherRuntime,
|
|
570
570
|
emit: (source, events) => {
|
|
571
571
|
flock.deliverBatch({ source, events });
|
|
@@ -574,11 +574,11 @@ class Flock {
|
|
|
574
574
|
return flock;
|
|
575
575
|
}
|
|
576
576
|
static fromJson(bundle, peerId) {
|
|
577
|
-
const inner =
|
|
577
|
+
const inner = wasm_js_1.RawFlock.fromJson(bundle, normalizePeerId(peerId));
|
|
578
578
|
return Flock.fromInner(inner);
|
|
579
579
|
}
|
|
580
580
|
static fromFile(bytes, peerId) {
|
|
581
|
-
const inner =
|
|
581
|
+
const inner = wasm_js_1.RawFlock.fromFile(normalizePeerId(peerId), bytes);
|
|
582
582
|
return Flock.fromInner(inner);
|
|
583
583
|
}
|
|
584
584
|
checkInvariants() {
|
|
@@ -655,9 +655,11 @@ class Flock {
|
|
|
655
655
|
void this.inner.merge(other.inner);
|
|
656
656
|
}
|
|
657
657
|
/**
|
|
658
|
-
* Returns the exclusive version vector
|
|
659
|
-
*
|
|
660
|
-
*
|
|
658
|
+
* Returns the exclusive/visible version vector.
|
|
659
|
+
*
|
|
660
|
+
* Only peers that currently own at least one visible entry are included.
|
|
661
|
+
* This vector is consistent with current visible state and is the correct
|
|
662
|
+
* baseline for incremental export/replication.
|
|
661
663
|
*
|
|
662
664
|
* Use this version when sending to other peers for incremental sync.
|
|
663
665
|
*/
|
|
@@ -665,10 +667,13 @@ class Flock {
|
|
|
665
667
|
return decodeVersionVectorFromRaw(this.inner.version());
|
|
666
668
|
}
|
|
667
669
|
/**
|
|
668
|
-
* Returns the inclusive version vector
|
|
669
|
-
*
|
|
670
|
+
* Returns the inclusive/max-seen version vector.
|
|
671
|
+
*
|
|
672
|
+
* Tracks max seen clocks per peer for this process lifetime
|
|
673
|
+
* (open/import/local writes), including peers that may no longer own visible
|
|
674
|
+
* entries.
|
|
670
675
|
*
|
|
671
|
-
* Use this version
|
|
676
|
+
* Use this version for completeness checks, not incremental export baselines.
|
|
672
677
|
*/
|
|
673
678
|
inclusiveVersion() {
|
|
674
679
|
return decodeVersionVectorFromRaw(this.inner.inclusiveVersion());
|
|
@@ -816,7 +821,7 @@ class Flock {
|
|
|
816
821
|
return;
|
|
817
822
|
}
|
|
818
823
|
this.nativeSubscriberId = this.inner.subscribe((payload) => {
|
|
819
|
-
(0,
|
|
824
|
+
(0, wasm_js_1.callPendingEvents)();
|
|
820
825
|
const batch = decodeEventBatch(payload);
|
|
821
826
|
this.handleBatch(batch);
|
|
822
827
|
});
|
|
@@ -975,7 +980,7 @@ function decorateMethod(prototype, method) {
|
|
|
975
980
|
if (result && typeof result.then === "function") {
|
|
976
981
|
void result
|
|
977
982
|
.finally(() => {
|
|
978
|
-
(0,
|
|
983
|
+
(0, wasm_js_1.callPendingEvents)();
|
|
979
984
|
})
|
|
980
985
|
.catch(() => {
|
|
981
986
|
// Ignore: this promise is only for triggering pending event draining.
|
|
@@ -983,7 +988,7 @@ function decorateMethod(prototype, method) {
|
|
|
983
988
|
});
|
|
984
989
|
}
|
|
985
990
|
else {
|
|
986
|
-
(0,
|
|
991
|
+
(0, wasm_js_1.callPendingEvents)();
|
|
987
992
|
}
|
|
988
993
|
}
|
|
989
994
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@loro-dev/flock-wasm",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.3",
|
|
4
4
|
"description": "WASM bindings for flock-rs.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -30,6 +30,7 @@
|
|
|
30
30
|
"devDependencies": {
|
|
31
31
|
"@types/node": "^22.0.0",
|
|
32
32
|
"typescript": "^5.9.0",
|
|
33
|
+
"vite-plugin-wasm": "^3.5.0",
|
|
33
34
|
"vitest": "^3.2.4"
|
|
34
35
|
},
|
|
35
36
|
"license": "AGPL-3.0-only",
|