@crdt-sync/core 0.1.1 → 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/dist/index.d.mts +233 -0
- package/dist/index.d.ts +233 -5
- package/dist/index.js +220 -6
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +194 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +12 -3
- package/pkg/bundler/README.md +346 -0
- package/pkg/bundler/crdt_sync.d.ts +95 -0
- package/pkg/bundler/crdt_sync.js +9 -0
- package/pkg/bundler/crdt_sync_bg.js +430 -0
- package/pkg/bundler/crdt_sync_bg.wasm +0 -0
- package/pkg/bundler/crdt_sync_bg.wasm.d.ts +25 -0
- package/pkg/bundler/package.json +30 -0
- package/pkg/web/README.md +346 -0
- package/pkg/web/crdt_sync.d.ts +145 -0
- package/pkg/web/crdt_sync.js +529 -0
- package/pkg/web/crdt_sync_bg.wasm +0 -0
- package/pkg/web/crdt_sync_bg.wasm.d.ts +25 -0
- package/pkg/web/package.json +28 -0
- package/dist/CrdtStateProxy.d.ts +0 -119
- package/dist/CrdtStateProxy.d.ts.map +0 -1
- package/dist/CrdtStateProxy.js +0 -120
- package/dist/CrdtStateProxy.js.map +0 -1
- package/dist/WebSocketManager.d.ts +0 -115
- package/dist/WebSocketManager.d.ts.map +0 -1
- package/dist/WebSocketManager.js +0 -179
- package/dist/WebSocketManager.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* A WebAssembly-compatible wrapper around [`StateStore`].
|
|
6
|
+
*
|
|
7
|
+
* Methods accept and return JSON-encoded strings at the Wasm boundary so that
|
|
8
|
+
* [`Envelope`] payloads and CRDT values can be exchanged between Rust and
|
|
9
|
+
* JavaScript without sharing memory structures directly.
|
|
10
|
+
*/
|
|
11
|
+
export class WasmStateStore {
|
|
12
|
+
free(): void;
|
|
13
|
+
[Symbol.dispose](): void;
|
|
14
|
+
/**
|
|
15
|
+
* Apply a remote [`Envelope`] (serialised as a JSON string) to this store.
|
|
16
|
+
*
|
|
17
|
+
* Throws a JavaScript error if the JSON cannot be deserialised.
|
|
18
|
+
*/
|
|
19
|
+
apply_envelope(envelope_json: string): void;
|
|
20
|
+
/**
|
|
21
|
+
* Return the current Lamport clock value.
|
|
22
|
+
*
|
|
23
|
+
* Returned as `f64` because JavaScript's `Number` type cannot safely
|
|
24
|
+
* represent all `u64` values. Values up to `2^53 − 1`
|
|
25
|
+
* (`Number.MAX_SAFE_INTEGER`) are represented exactly. For distributed
|
|
26
|
+
* systems that could conceivably tick the clock beyond that threshold,
|
|
27
|
+
* treat the returned value as approximate or use `BigInt` on the JS side.
|
|
28
|
+
*/
|
|
29
|
+
clock(): number;
|
|
30
|
+
/**
|
|
31
|
+
* Read the current value of a named LWW register as a JSON string.
|
|
32
|
+
*
|
|
33
|
+
* Returns `undefined` in JavaScript if the key has never been written.
|
|
34
|
+
*/
|
|
35
|
+
get_register(key: string): string | undefined;
|
|
36
|
+
/**
|
|
37
|
+
* Create a new `WasmStateStore` for the given node identifier.
|
|
38
|
+
*/
|
|
39
|
+
constructor(node_id: string);
|
|
40
|
+
/**
|
|
41
|
+
* Delete the element at visible `index` in the named RGA sequence.
|
|
42
|
+
*
|
|
43
|
+
* Returns the resulting [`Envelope`] as a JSON string, or `undefined` if
|
|
44
|
+
* `index` is out of bounds.
|
|
45
|
+
*/
|
|
46
|
+
seq_delete(key: string, index: number): string | undefined;
|
|
47
|
+
/**
|
|
48
|
+
* Insert a JSON-encoded element at `index` in the named RGA sequence.
|
|
49
|
+
*
|
|
50
|
+
* Returns the resulting [`Envelope`] as a JSON string.
|
|
51
|
+
*/
|
|
52
|
+
seq_insert(key: string, index: number, value_json: string): string;
|
|
53
|
+
/**
|
|
54
|
+
* Return all visible elements of the named sequence as a JSON array string.
|
|
55
|
+
*
|
|
56
|
+
* Throws a JavaScript error if serialisation fails.
|
|
57
|
+
*/
|
|
58
|
+
seq_items(key: string): string;
|
|
59
|
+
/**
|
|
60
|
+
* Return the number of visible elements in the named sequence.
|
|
61
|
+
*/
|
|
62
|
+
seq_len(key: string): number;
|
|
63
|
+
/**
|
|
64
|
+
* Add a JSON-encoded element to the named OR-Set.
|
|
65
|
+
*
|
|
66
|
+
* Returns the resulting [`Envelope`] as a JSON string.
|
|
67
|
+
*/
|
|
68
|
+
set_add(key: string, value_json: string): string;
|
|
69
|
+
/**
|
|
70
|
+
* Returns `true` if the named OR-Set contains the JSON-encoded `value`.
|
|
71
|
+
*/
|
|
72
|
+
set_contains(key: string, value_json: string): boolean;
|
|
73
|
+
/**
|
|
74
|
+
* Return all elements of the named OR-Set as a JSON array string.
|
|
75
|
+
*
|
|
76
|
+
* Throws a JavaScript error if serialisation fails.
|
|
77
|
+
*/
|
|
78
|
+
set_items(key: string): string;
|
|
79
|
+
/**
|
|
80
|
+
* Write a JSON-encoded value to the named LWW register.
|
|
81
|
+
*
|
|
82
|
+
* Returns the resulting [`Envelope`] serialised as a JSON string, ready
|
|
83
|
+
* to broadcast to peer nodes.
|
|
84
|
+
*/
|
|
85
|
+
set_register(key: string, value_json: string): string;
|
|
86
|
+
/**
|
|
87
|
+
* Remove a JSON-encoded element from the named OR-Set.
|
|
88
|
+
*
|
|
89
|
+
* Returns the resulting [`Envelope`] as a JSON string, or `undefined` if
|
|
90
|
+
* the element was not present in the set.
|
|
91
|
+
*
|
|
92
|
+
* Throws a JavaScript error if `value_json` is not valid JSON.
|
|
93
|
+
*/
|
|
94
|
+
set_remove(key: string, value_json: string): string | undefined;
|
|
95
|
+
}
|
|
@@ -0,0 +1,430 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A WebAssembly-compatible wrapper around [`StateStore`].
|
|
3
|
+
*
|
|
4
|
+
* Methods accept and return JSON-encoded strings at the Wasm boundary so that
|
|
5
|
+
* [`Envelope`] payloads and CRDT values can be exchanged between Rust and
|
|
6
|
+
* JavaScript without sharing memory structures directly.
|
|
7
|
+
*/
|
|
8
|
+
export class WasmStateStore {
|
|
9
|
+
__destroy_into_raw() {
|
|
10
|
+
const ptr = this.__wbg_ptr;
|
|
11
|
+
this.__wbg_ptr = 0;
|
|
12
|
+
WasmStateStoreFinalization.unregister(this);
|
|
13
|
+
return ptr;
|
|
14
|
+
}
|
|
15
|
+
free() {
|
|
16
|
+
const ptr = this.__destroy_into_raw();
|
|
17
|
+
wasm.__wbg_wasmstatestore_free(ptr, 0);
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Apply a remote [`Envelope`] (serialised as a JSON string) to this store.
|
|
21
|
+
*
|
|
22
|
+
* Throws a JavaScript error if the JSON cannot be deserialised.
|
|
23
|
+
* @param {string} envelope_json
|
|
24
|
+
*/
|
|
25
|
+
apply_envelope(envelope_json) {
|
|
26
|
+
const ptr0 = passStringToWasm0(envelope_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
27
|
+
const len0 = WASM_VECTOR_LEN;
|
|
28
|
+
const ret = wasm.wasmstatestore_apply_envelope(this.__wbg_ptr, ptr0, len0);
|
|
29
|
+
if (ret[1]) {
|
|
30
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Return the current Lamport clock value.
|
|
35
|
+
*
|
|
36
|
+
* Returned as `f64` because JavaScript's `Number` type cannot safely
|
|
37
|
+
* represent all `u64` values. Values up to `2^53 − 1`
|
|
38
|
+
* (`Number.MAX_SAFE_INTEGER`) are represented exactly. For distributed
|
|
39
|
+
* systems that could conceivably tick the clock beyond that threshold,
|
|
40
|
+
* treat the returned value as approximate or use `BigInt` on the JS side.
|
|
41
|
+
* @returns {number}
|
|
42
|
+
*/
|
|
43
|
+
clock() {
|
|
44
|
+
const ret = wasm.wasmstatestore_clock(this.__wbg_ptr);
|
|
45
|
+
return ret;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Read the current value of a named LWW register as a JSON string.
|
|
49
|
+
*
|
|
50
|
+
* Returns `undefined` in JavaScript if the key has never been written.
|
|
51
|
+
* @param {string} key
|
|
52
|
+
* @returns {string | undefined}
|
|
53
|
+
*/
|
|
54
|
+
get_register(key) {
|
|
55
|
+
const ptr0 = passStringToWasm0(key, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
56
|
+
const len0 = WASM_VECTOR_LEN;
|
|
57
|
+
const ret = wasm.wasmstatestore_get_register(this.__wbg_ptr, ptr0, len0);
|
|
58
|
+
let v2;
|
|
59
|
+
if (ret[0] !== 0) {
|
|
60
|
+
v2 = getStringFromWasm0(ret[0], ret[1]).slice();
|
|
61
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
62
|
+
}
|
|
63
|
+
return v2;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Create a new `WasmStateStore` for the given node identifier.
|
|
67
|
+
* @param {string} node_id
|
|
68
|
+
*/
|
|
69
|
+
constructor(node_id) {
|
|
70
|
+
const ptr0 = passStringToWasm0(node_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
71
|
+
const len0 = WASM_VECTOR_LEN;
|
|
72
|
+
const ret = wasm.wasmstatestore_new(ptr0, len0);
|
|
73
|
+
this.__wbg_ptr = ret >>> 0;
|
|
74
|
+
WasmStateStoreFinalization.register(this, this.__wbg_ptr, this);
|
|
75
|
+
return this;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Delete the element at visible `index` in the named RGA sequence.
|
|
79
|
+
*
|
|
80
|
+
* Returns the resulting [`Envelope`] as a JSON string, or `undefined` if
|
|
81
|
+
* `index` is out of bounds.
|
|
82
|
+
* @param {string} key
|
|
83
|
+
* @param {number} index
|
|
84
|
+
* @returns {string | undefined}
|
|
85
|
+
*/
|
|
86
|
+
seq_delete(key, index) {
|
|
87
|
+
const ptr0 = passStringToWasm0(key, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
88
|
+
const len0 = WASM_VECTOR_LEN;
|
|
89
|
+
const ret = wasm.wasmstatestore_seq_delete(this.__wbg_ptr, ptr0, len0, index);
|
|
90
|
+
let v2;
|
|
91
|
+
if (ret[0] !== 0) {
|
|
92
|
+
v2 = getStringFromWasm0(ret[0], ret[1]).slice();
|
|
93
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
94
|
+
}
|
|
95
|
+
return v2;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Insert a JSON-encoded element at `index` in the named RGA sequence.
|
|
99
|
+
*
|
|
100
|
+
* Returns the resulting [`Envelope`] as a JSON string.
|
|
101
|
+
* @param {string} key
|
|
102
|
+
* @param {number} index
|
|
103
|
+
* @param {string} value_json
|
|
104
|
+
* @returns {string}
|
|
105
|
+
*/
|
|
106
|
+
seq_insert(key, index, value_json) {
|
|
107
|
+
let deferred4_0;
|
|
108
|
+
let deferred4_1;
|
|
109
|
+
try {
|
|
110
|
+
const ptr0 = passStringToWasm0(key, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
111
|
+
const len0 = WASM_VECTOR_LEN;
|
|
112
|
+
const ptr1 = passStringToWasm0(value_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
113
|
+
const len1 = WASM_VECTOR_LEN;
|
|
114
|
+
const ret = wasm.wasmstatestore_seq_insert(this.__wbg_ptr, ptr0, len0, index, ptr1, len1);
|
|
115
|
+
var ptr3 = ret[0];
|
|
116
|
+
var len3 = ret[1];
|
|
117
|
+
if (ret[3]) {
|
|
118
|
+
ptr3 = 0; len3 = 0;
|
|
119
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
120
|
+
}
|
|
121
|
+
deferred4_0 = ptr3;
|
|
122
|
+
deferred4_1 = len3;
|
|
123
|
+
return getStringFromWasm0(ptr3, len3);
|
|
124
|
+
} finally {
|
|
125
|
+
wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Return all visible elements of the named sequence as a JSON array string.
|
|
130
|
+
*
|
|
131
|
+
* Throws a JavaScript error if serialisation fails.
|
|
132
|
+
* @param {string} key
|
|
133
|
+
* @returns {string}
|
|
134
|
+
*/
|
|
135
|
+
seq_items(key) {
|
|
136
|
+
let deferred3_0;
|
|
137
|
+
let deferred3_1;
|
|
138
|
+
try {
|
|
139
|
+
const ptr0 = passStringToWasm0(key, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
140
|
+
const len0 = WASM_VECTOR_LEN;
|
|
141
|
+
const ret = wasm.wasmstatestore_seq_items(this.__wbg_ptr, ptr0, len0);
|
|
142
|
+
var ptr2 = ret[0];
|
|
143
|
+
var len2 = ret[1];
|
|
144
|
+
if (ret[3]) {
|
|
145
|
+
ptr2 = 0; len2 = 0;
|
|
146
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
147
|
+
}
|
|
148
|
+
deferred3_0 = ptr2;
|
|
149
|
+
deferred3_1 = len2;
|
|
150
|
+
return getStringFromWasm0(ptr2, len2);
|
|
151
|
+
} finally {
|
|
152
|
+
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* Return the number of visible elements in the named sequence.
|
|
157
|
+
* @param {string} key
|
|
158
|
+
* @returns {number}
|
|
159
|
+
*/
|
|
160
|
+
seq_len(key) {
|
|
161
|
+
const ptr0 = passStringToWasm0(key, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
162
|
+
const len0 = WASM_VECTOR_LEN;
|
|
163
|
+
const ret = wasm.wasmstatestore_seq_len(this.__wbg_ptr, ptr0, len0);
|
|
164
|
+
return ret >>> 0;
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* Add a JSON-encoded element to the named OR-Set.
|
|
168
|
+
*
|
|
169
|
+
* Returns the resulting [`Envelope`] as a JSON string.
|
|
170
|
+
* @param {string} key
|
|
171
|
+
* @param {string} value_json
|
|
172
|
+
* @returns {string}
|
|
173
|
+
*/
|
|
174
|
+
set_add(key, value_json) {
|
|
175
|
+
let deferred4_0;
|
|
176
|
+
let deferred4_1;
|
|
177
|
+
try {
|
|
178
|
+
const ptr0 = passStringToWasm0(key, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
179
|
+
const len0 = WASM_VECTOR_LEN;
|
|
180
|
+
const ptr1 = passStringToWasm0(value_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
181
|
+
const len1 = WASM_VECTOR_LEN;
|
|
182
|
+
const ret = wasm.wasmstatestore_set_add(this.__wbg_ptr, ptr0, len0, ptr1, len1);
|
|
183
|
+
var ptr3 = ret[0];
|
|
184
|
+
var len3 = ret[1];
|
|
185
|
+
if (ret[3]) {
|
|
186
|
+
ptr3 = 0; len3 = 0;
|
|
187
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
188
|
+
}
|
|
189
|
+
deferred4_0 = ptr3;
|
|
190
|
+
deferred4_1 = len3;
|
|
191
|
+
return getStringFromWasm0(ptr3, len3);
|
|
192
|
+
} finally {
|
|
193
|
+
wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
/**
|
|
197
|
+
* Returns `true` if the named OR-Set contains the JSON-encoded `value`.
|
|
198
|
+
* @param {string} key
|
|
199
|
+
* @param {string} value_json
|
|
200
|
+
* @returns {boolean}
|
|
201
|
+
*/
|
|
202
|
+
set_contains(key, value_json) {
|
|
203
|
+
const ptr0 = passStringToWasm0(key, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
204
|
+
const len0 = WASM_VECTOR_LEN;
|
|
205
|
+
const ptr1 = passStringToWasm0(value_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
206
|
+
const len1 = WASM_VECTOR_LEN;
|
|
207
|
+
const ret = wasm.wasmstatestore_set_contains(this.__wbg_ptr, ptr0, len0, ptr1, len1);
|
|
208
|
+
return ret !== 0;
|
|
209
|
+
}
|
|
210
|
+
/**
|
|
211
|
+
* Return all elements of the named OR-Set as a JSON array string.
|
|
212
|
+
*
|
|
213
|
+
* Throws a JavaScript error if serialisation fails.
|
|
214
|
+
* @param {string} key
|
|
215
|
+
* @returns {string}
|
|
216
|
+
*/
|
|
217
|
+
set_items(key) {
|
|
218
|
+
let deferred3_0;
|
|
219
|
+
let deferred3_1;
|
|
220
|
+
try {
|
|
221
|
+
const ptr0 = passStringToWasm0(key, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
222
|
+
const len0 = WASM_VECTOR_LEN;
|
|
223
|
+
const ret = wasm.wasmstatestore_set_items(this.__wbg_ptr, ptr0, len0);
|
|
224
|
+
var ptr2 = ret[0];
|
|
225
|
+
var len2 = ret[1];
|
|
226
|
+
if (ret[3]) {
|
|
227
|
+
ptr2 = 0; len2 = 0;
|
|
228
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
229
|
+
}
|
|
230
|
+
deferred3_0 = ptr2;
|
|
231
|
+
deferred3_1 = len2;
|
|
232
|
+
return getStringFromWasm0(ptr2, len2);
|
|
233
|
+
} finally {
|
|
234
|
+
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
/**
|
|
238
|
+
* Write a JSON-encoded value to the named LWW register.
|
|
239
|
+
*
|
|
240
|
+
* Returns the resulting [`Envelope`] serialised as a JSON string, ready
|
|
241
|
+
* to broadcast to peer nodes.
|
|
242
|
+
* @param {string} key
|
|
243
|
+
* @param {string} value_json
|
|
244
|
+
* @returns {string}
|
|
245
|
+
*/
|
|
246
|
+
set_register(key, value_json) {
|
|
247
|
+
let deferred4_0;
|
|
248
|
+
let deferred4_1;
|
|
249
|
+
try {
|
|
250
|
+
const ptr0 = passStringToWasm0(key, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
251
|
+
const len0 = WASM_VECTOR_LEN;
|
|
252
|
+
const ptr1 = passStringToWasm0(value_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
253
|
+
const len1 = WASM_VECTOR_LEN;
|
|
254
|
+
const ret = wasm.wasmstatestore_set_register(this.__wbg_ptr, ptr0, len0, ptr1, len1);
|
|
255
|
+
var ptr3 = ret[0];
|
|
256
|
+
var len3 = ret[1];
|
|
257
|
+
if (ret[3]) {
|
|
258
|
+
ptr3 = 0; len3 = 0;
|
|
259
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
260
|
+
}
|
|
261
|
+
deferred4_0 = ptr3;
|
|
262
|
+
deferred4_1 = len3;
|
|
263
|
+
return getStringFromWasm0(ptr3, len3);
|
|
264
|
+
} finally {
|
|
265
|
+
wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
/**
|
|
269
|
+
* Remove a JSON-encoded element from the named OR-Set.
|
|
270
|
+
*
|
|
271
|
+
* Returns the resulting [`Envelope`] as a JSON string, or `undefined` if
|
|
272
|
+
* the element was not present in the set.
|
|
273
|
+
*
|
|
274
|
+
* Throws a JavaScript error if `value_json` is not valid JSON.
|
|
275
|
+
* @param {string} key
|
|
276
|
+
* @param {string} value_json
|
|
277
|
+
* @returns {string | undefined}
|
|
278
|
+
*/
|
|
279
|
+
set_remove(key, value_json) {
|
|
280
|
+
const ptr0 = passStringToWasm0(key, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
281
|
+
const len0 = WASM_VECTOR_LEN;
|
|
282
|
+
const ptr1 = passStringToWasm0(value_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
283
|
+
const len1 = WASM_VECTOR_LEN;
|
|
284
|
+
const ret = wasm.wasmstatestore_set_remove(this.__wbg_ptr, ptr0, len0, ptr1, len1);
|
|
285
|
+
if (ret[3]) {
|
|
286
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
287
|
+
}
|
|
288
|
+
let v3;
|
|
289
|
+
if (ret[0] !== 0) {
|
|
290
|
+
v3 = getStringFromWasm0(ret[0], ret[1]).slice();
|
|
291
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
292
|
+
}
|
|
293
|
+
return v3;
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
if (Symbol.dispose) WasmStateStore.prototype[Symbol.dispose] = WasmStateStore.prototype.free;
|
|
297
|
+
export function __wbg___wbindgen_throw_df03e93053e0f4bc(arg0, arg1) {
|
|
298
|
+
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
299
|
+
}
|
|
300
|
+
export function __wbg_getRandomValues_3dda8830c2565714() { return handleError(function (arg0, arg1) {
|
|
301
|
+
globalThis.crypto.getRandomValues(getArrayU8FromWasm0(arg0, arg1));
|
|
302
|
+
}, arguments); }
|
|
303
|
+
export function __wbindgen_cast_0000000000000001(arg0, arg1) {
|
|
304
|
+
// Cast intrinsic for `Ref(String) -> Externref`.
|
|
305
|
+
const ret = getStringFromWasm0(arg0, arg1);
|
|
306
|
+
return ret;
|
|
307
|
+
}
|
|
308
|
+
export function __wbindgen_init_externref_table() {
|
|
309
|
+
const table = wasm.__wbindgen_externrefs;
|
|
310
|
+
const offset = table.grow(4);
|
|
311
|
+
table.set(0, undefined);
|
|
312
|
+
table.set(offset + 0, undefined);
|
|
313
|
+
table.set(offset + 1, null);
|
|
314
|
+
table.set(offset + 2, true);
|
|
315
|
+
table.set(offset + 3, false);
|
|
316
|
+
}
|
|
317
|
+
const WasmStateStoreFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
318
|
+
? { register: () => {}, unregister: () => {} }
|
|
319
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_wasmstatestore_free(ptr >>> 0, 1));
|
|
320
|
+
|
|
321
|
+
function addToExternrefTable0(obj) {
|
|
322
|
+
const idx = wasm.__externref_table_alloc();
|
|
323
|
+
wasm.__wbindgen_externrefs.set(idx, obj);
|
|
324
|
+
return idx;
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
function getArrayU8FromWasm0(ptr, len) {
|
|
328
|
+
ptr = ptr >>> 0;
|
|
329
|
+
return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
function getStringFromWasm0(ptr, len) {
|
|
333
|
+
ptr = ptr >>> 0;
|
|
334
|
+
return decodeText(ptr, len);
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
let cachedUint8ArrayMemory0 = null;
|
|
338
|
+
function getUint8ArrayMemory0() {
|
|
339
|
+
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
|
|
340
|
+
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
|
|
341
|
+
}
|
|
342
|
+
return cachedUint8ArrayMemory0;
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
function handleError(f, args) {
|
|
346
|
+
try {
|
|
347
|
+
return f.apply(this, args);
|
|
348
|
+
} catch (e) {
|
|
349
|
+
const idx = addToExternrefTable0(e);
|
|
350
|
+
wasm.__wbindgen_exn_store(idx);
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
function passStringToWasm0(arg, malloc, realloc) {
|
|
355
|
+
if (realloc === undefined) {
|
|
356
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
357
|
+
const ptr = malloc(buf.length, 1) >>> 0;
|
|
358
|
+
getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
|
|
359
|
+
WASM_VECTOR_LEN = buf.length;
|
|
360
|
+
return ptr;
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
let len = arg.length;
|
|
364
|
+
let ptr = malloc(len, 1) >>> 0;
|
|
365
|
+
|
|
366
|
+
const mem = getUint8ArrayMemory0();
|
|
367
|
+
|
|
368
|
+
let offset = 0;
|
|
369
|
+
|
|
370
|
+
for (; offset < len; offset++) {
|
|
371
|
+
const code = arg.charCodeAt(offset);
|
|
372
|
+
if (code > 0x7F) break;
|
|
373
|
+
mem[ptr + offset] = code;
|
|
374
|
+
}
|
|
375
|
+
if (offset !== len) {
|
|
376
|
+
if (offset !== 0) {
|
|
377
|
+
arg = arg.slice(offset);
|
|
378
|
+
}
|
|
379
|
+
ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
|
|
380
|
+
const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
|
|
381
|
+
const ret = cachedTextEncoder.encodeInto(arg, view);
|
|
382
|
+
|
|
383
|
+
offset += ret.written;
|
|
384
|
+
ptr = realloc(ptr, len, offset, 1) >>> 0;
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
WASM_VECTOR_LEN = offset;
|
|
388
|
+
return ptr;
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
function takeFromExternrefTable0(idx) {
|
|
392
|
+
const value = wasm.__wbindgen_externrefs.get(idx);
|
|
393
|
+
wasm.__externref_table_dealloc(idx);
|
|
394
|
+
return value;
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
398
|
+
cachedTextDecoder.decode();
|
|
399
|
+
const MAX_SAFARI_DECODE_BYTES = 2146435072;
|
|
400
|
+
let numBytesDecoded = 0;
|
|
401
|
+
function decodeText(ptr, len) {
|
|
402
|
+
numBytesDecoded += len;
|
|
403
|
+
if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
|
|
404
|
+
cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
405
|
+
cachedTextDecoder.decode();
|
|
406
|
+
numBytesDecoded = len;
|
|
407
|
+
}
|
|
408
|
+
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
const cachedTextEncoder = new TextEncoder();
|
|
412
|
+
|
|
413
|
+
if (!('encodeInto' in cachedTextEncoder)) {
|
|
414
|
+
cachedTextEncoder.encodeInto = function (arg, view) {
|
|
415
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
416
|
+
view.set(buf);
|
|
417
|
+
return {
|
|
418
|
+
read: arg.length,
|
|
419
|
+
written: buf.length
|
|
420
|
+
};
|
|
421
|
+
};
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
let WASM_VECTOR_LEN = 0;
|
|
425
|
+
|
|
426
|
+
|
|
427
|
+
let wasm;
|
|
428
|
+
export function __wbg_set_wasm(val) {
|
|
429
|
+
wasm = val;
|
|
430
|
+
}
|
|
Binary file
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
export const memory: WebAssembly.Memory;
|
|
4
|
+
export const __wbg_wasmstatestore_free: (a: number, b: number) => void;
|
|
5
|
+
export const wasmstatestore_apply_envelope: (a: number, b: number, c: number) => [number, number];
|
|
6
|
+
export const wasmstatestore_clock: (a: number) => number;
|
|
7
|
+
export const wasmstatestore_get_register: (a: number, b: number, c: number) => [number, number];
|
|
8
|
+
export const wasmstatestore_new: (a: number, b: number) => number;
|
|
9
|
+
export const wasmstatestore_seq_delete: (a: number, b: number, c: number, d: number) => [number, number];
|
|
10
|
+
export const wasmstatestore_seq_insert: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number, number, number];
|
|
11
|
+
export const wasmstatestore_seq_items: (a: number, b: number, c: number) => [number, number, number, number];
|
|
12
|
+
export const wasmstatestore_seq_len: (a: number, b: number, c: number) => number;
|
|
13
|
+
export const wasmstatestore_set_add: (a: number, b: number, c: number, d: number, e: number) => [number, number, number, number];
|
|
14
|
+
export const wasmstatestore_set_contains: (a: number, b: number, c: number, d: number, e: number) => number;
|
|
15
|
+
export const wasmstatestore_set_items: (a: number, b: number, c: number) => [number, number, number, number];
|
|
16
|
+
export const wasmstatestore_set_register: (a: number, b: number, c: number, d: number, e: number) => [number, number, number, number];
|
|
17
|
+
export const wasmstatestore_set_remove: (a: number, b: number, c: number, d: number, e: number) => [number, number, number, number];
|
|
18
|
+
export const __wbindgen_exn_store: (a: number) => void;
|
|
19
|
+
export const __externref_table_alloc: () => number;
|
|
20
|
+
export const __wbindgen_externrefs: WebAssembly.Table;
|
|
21
|
+
export const __wbindgen_malloc: (a: number, b: number) => number;
|
|
22
|
+
export const __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
|
|
23
|
+
export const __externref_table_dealloc: (a: number) => void;
|
|
24
|
+
export const __wbindgen_free: (a: number, b: number, c: number) => void;
|
|
25
|
+
export const __wbindgen_start: () => void;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "crdt-sync",
|
|
3
|
+
"type": "module",
|
|
4
|
+
"description": "A generic state synchronization engine based on CRDTs (Conflict-free Replicated Data Types) for keeping distributed state in harmony without conflicts.",
|
|
5
|
+
"version": "0.1.0",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "https://github.com/franruedaesq/CRDT-sync"
|
|
10
|
+
},
|
|
11
|
+
"files": [
|
|
12
|
+
"crdt_sync_bg.wasm",
|
|
13
|
+
"crdt_sync.js",
|
|
14
|
+
"crdt_sync_bg.js",
|
|
15
|
+
"crdt_sync.d.ts"
|
|
16
|
+
],
|
|
17
|
+
"main": "crdt_sync.js",
|
|
18
|
+
"types": "crdt_sync.d.ts",
|
|
19
|
+
"sideEffects": [
|
|
20
|
+
"./crdt_sync.js",
|
|
21
|
+
"./snippets/*"
|
|
22
|
+
],
|
|
23
|
+
"keywords": [
|
|
24
|
+
"crdt",
|
|
25
|
+
"sync",
|
|
26
|
+
"distributed",
|
|
27
|
+
"state",
|
|
28
|
+
"conflict-free"
|
|
29
|
+
]
|
|
30
|
+
}
|