@crdt-sync/core 0.3.1 → 0.3.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/dist/index.d.mts +33 -8
- package/dist/index.d.ts +33 -8
- package/dist/index.js +69 -10
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +69 -10
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -1
- package/pkg/web/crdt_sync.d.ts +134 -13
- package/pkg/web/crdt_sync.js +520 -21
package/pkg/web/crdt_sync.d.ts
CHANGED
|
@@ -1,24 +1,145 @@
|
|
|
1
1
|
/* tslint:disable */
|
|
2
2
|
/* eslint-disable */
|
|
3
|
+
|
|
3
4
|
/**
|
|
4
|
-
*
|
|
5
|
+
* A WebAssembly-compatible wrapper around [`StateStore`].
|
|
5
6
|
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
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.
|
|
8
10
|
*/
|
|
9
|
-
|
|
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
|
+
*/
|
|
11
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
|
+
*/
|
|
12
85
|
set_register(key: string, value_json: string): string;
|
|
13
|
-
|
|
14
|
-
|
|
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
|
+
}
|
|
96
|
+
|
|
97
|
+
export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
|
|
98
|
+
|
|
99
|
+
export interface InitOutput {
|
|
100
|
+
readonly memory: WebAssembly.Memory;
|
|
101
|
+
readonly __wbg_wasmstatestore_free: (a: number, b: number) => void;
|
|
102
|
+
readonly wasmstatestore_apply_envelope: (a: number, b: number, c: number) => [number, number];
|
|
103
|
+
readonly wasmstatestore_clock: (a: number) => number;
|
|
104
|
+
readonly wasmstatestore_get_register: (a: number, b: number, c: number) => [number, number];
|
|
105
|
+
readonly wasmstatestore_new: (a: number, b: number) => number;
|
|
106
|
+
readonly wasmstatestore_seq_delete: (a: number, b: number, c: number, d: number) => [number, number];
|
|
107
|
+
readonly wasmstatestore_seq_insert: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number, number, number];
|
|
108
|
+
readonly wasmstatestore_seq_items: (a: number, b: number, c: number) => [number, number, number, number];
|
|
109
|
+
readonly wasmstatestore_seq_len: (a: number, b: number, c: number) => number;
|
|
110
|
+
readonly wasmstatestore_set_add: (a: number, b: number, c: number, d: number, e: number) => [number, number, number, number];
|
|
111
|
+
readonly wasmstatestore_set_contains: (a: number, b: number, c: number, d: number, e: number) => number;
|
|
112
|
+
readonly wasmstatestore_set_items: (a: number, b: number, c: number) => [number, number, number, number];
|
|
113
|
+
readonly wasmstatestore_set_register: (a: number, b: number, c: number, d: number, e: number) => [number, number, number, number];
|
|
114
|
+
readonly wasmstatestore_set_remove: (a: number, b: number, c: number, d: number, e: number) => [number, number, number, number];
|
|
115
|
+
readonly __wbindgen_exn_store: (a: number) => void;
|
|
116
|
+
readonly __externref_table_alloc: () => number;
|
|
117
|
+
readonly __wbindgen_externrefs: WebAssembly.Table;
|
|
118
|
+
readonly __wbindgen_malloc: (a: number, b: number) => number;
|
|
119
|
+
readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
|
|
120
|
+
readonly __externref_table_dealloc: (a: number) => void;
|
|
121
|
+
readonly __wbindgen_free: (a: number, b: number, c: number) => void;
|
|
122
|
+
readonly __wbindgen_start: () => void;
|
|
15
123
|
}
|
|
16
124
|
|
|
17
|
-
export type
|
|
18
|
-
| RequestInfo
|
|
19
|
-
| URL
|
|
20
|
-
| Response
|
|
21
|
-
| BufferSource
|
|
22
|
-
| WebAssembly.Module;
|
|
125
|
+
export type SyncInitInput = BufferSource | WebAssembly.Module;
|
|
23
126
|
|
|
24
|
-
|
|
127
|
+
/**
|
|
128
|
+
* Instantiates the given `module`, which can either be bytes or
|
|
129
|
+
* a precompiled `WebAssembly.Module`.
|
|
130
|
+
*
|
|
131
|
+
* @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated.
|
|
132
|
+
*
|
|
133
|
+
* @returns {InitOutput}
|
|
134
|
+
*/
|
|
135
|
+
export function initSync(module: { module: SyncInitInput } | SyncInitInput): InitOutput;
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* If `module_or_path` is {RequestInfo} or {URL}, makes a request and
|
|
139
|
+
* for everything else, calls `WebAssembly.instantiate` directly.
|
|
140
|
+
*
|
|
141
|
+
* @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated.
|
|
142
|
+
*
|
|
143
|
+
* @returns {Promise<InitOutput>}
|
|
144
|
+
*/
|
|
145
|
+
export default function __wbg_init (module_or_path?: { module_or_path: InitInput | Promise<InitInput> } | InitInput | Promise<InitInput>): Promise<InitOutput>;
|