@diaryx/wasm-node 0.11.0 → 0.11.1-dev.0fde73f
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/diaryx_wasm.d.ts +88 -340
- package/diaryx_wasm.js +122 -450
- package/diaryx_wasm_bg.wasm +0 -0
- package/diaryx_wasm_bg.wasm.d.ts +19 -41
- package/package.json +1 -1
- package/diaryx_wasm_bg.js +0 -1600
package/diaryx_wasm_bg.js
DELETED
|
@@ -1,1600 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Unified async backend with native storage.
|
|
3
|
-
*
|
|
4
|
-
* This is the main entry point for all workspace operations in WASM.
|
|
5
|
-
* It wraps either OPFS or IndexedDB storage and provides a complete
|
|
6
|
-
* async API for workspace, entry, search, and validation operations.
|
|
7
|
-
*
|
|
8
|
-
* ## Usage
|
|
9
|
-
*
|
|
10
|
-
* All operations go through `execute()` or `executeJs()`:
|
|
11
|
-
*
|
|
12
|
-
* ```javascript
|
|
13
|
-
* const backend = await DiaryxBackend.createOpfs();
|
|
14
|
-
* const response = await backend.executeJs({
|
|
15
|
-
* type: 'GetEntry',
|
|
16
|
-
* params: { path: 'workspace/notes.md' }
|
|
17
|
-
* });
|
|
18
|
-
* ```
|
|
19
|
-
*/
|
|
20
|
-
export class DiaryxBackend {
|
|
21
|
-
static __wrap(ptr) {
|
|
22
|
-
ptr = ptr >>> 0;
|
|
23
|
-
const obj = Object.create(DiaryxBackend.prototype);
|
|
24
|
-
obj.__wbg_ptr = ptr;
|
|
25
|
-
DiaryxBackendFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
26
|
-
return obj;
|
|
27
|
-
}
|
|
28
|
-
__destroy_into_raw() {
|
|
29
|
-
const ptr = this.__wbg_ptr;
|
|
30
|
-
this.__wbg_ptr = 0;
|
|
31
|
-
DiaryxBackendFinalization.unregister(this);
|
|
32
|
-
return ptr;
|
|
33
|
-
}
|
|
34
|
-
free() {
|
|
35
|
-
const ptr = this.__destroy_into_raw();
|
|
36
|
-
wasm.__wbg_diaryxbackend_free(ptr, 0);
|
|
37
|
-
}
|
|
38
|
-
/**
|
|
39
|
-
* Create backend with specific storage type.
|
|
40
|
-
* @param {string} storage_type
|
|
41
|
-
* @returns {Promise<DiaryxBackend>}
|
|
42
|
-
*/
|
|
43
|
-
static create(storage_type) {
|
|
44
|
-
const ptr0 = passStringToWasm0(storage_type, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
45
|
-
const len0 = WASM_VECTOR_LEN;
|
|
46
|
-
const ret = wasm.diaryxbackend_create(ptr0, len0);
|
|
47
|
-
return ret;
|
|
48
|
-
}
|
|
49
|
-
/**
|
|
50
|
-
* Create a new DiaryxBackend with in-memory storage.
|
|
51
|
-
*
|
|
52
|
-
* This is used for guest mode in share sessions. Files are stored
|
|
53
|
-
* only in memory and are cleared when the session ends.
|
|
54
|
-
*
|
|
55
|
-
* ## Use Cases
|
|
56
|
-
* - Guest mode in share sessions (web)
|
|
57
|
-
* - Testing
|
|
58
|
-
*
|
|
59
|
-
* ## Example
|
|
60
|
-
* ```javascript
|
|
61
|
-
* const backend = DiaryxBackend.createInMemory();
|
|
62
|
-
* // Files are stored in memory only
|
|
63
|
-
* ```
|
|
64
|
-
* @returns {DiaryxBackend}
|
|
65
|
-
*/
|
|
66
|
-
static createInMemory() {
|
|
67
|
-
const ret = wasm.diaryxbackend_createInMemory();
|
|
68
|
-
if (ret[2]) {
|
|
69
|
-
throw takeFromExternrefTable0(ret[1]);
|
|
70
|
-
}
|
|
71
|
-
return DiaryxBackend.__wrap(ret[0]);
|
|
72
|
-
}
|
|
73
|
-
/**
|
|
74
|
-
* Create a new sync client for the given server and workspace.
|
|
75
|
-
*
|
|
76
|
-
* This creates a `WasmSyncClient` that wraps `SyncClient<CallbackTransport>`.
|
|
77
|
-
* JavaScript manages WebSocket connections while Rust handles all sync logic.
|
|
78
|
-
*
|
|
79
|
-
* ## Example
|
|
80
|
-
*
|
|
81
|
-
* ```javascript
|
|
82
|
-
* const client = backend.createSyncClient(
|
|
83
|
-
* 'wss://sync.example.com/sync',
|
|
84
|
-
* 'my-workspace-id',
|
|
85
|
-
* 'auth-token-optional'
|
|
86
|
-
* );
|
|
87
|
-
*
|
|
88
|
-
* // Get URLs and create WebSocket connections
|
|
89
|
-
* const metaUrl = client.getMetadataUrl();
|
|
90
|
-
* const bodyUrl = client.getBodyUrl();
|
|
91
|
-
*
|
|
92
|
-
* // Create WebSockets and connect them to the client
|
|
93
|
-
* const metaWs = new WebSocket(metaUrl);
|
|
94
|
-
* metaWs.binaryType = 'arraybuffer';
|
|
95
|
-
* metaWs.onopen = () => client.markMetadataConnected();
|
|
96
|
-
* metaWs.onclose = () => client.markMetadataDisconnected();
|
|
97
|
-
* metaWs.onmessage = async (e) => {
|
|
98
|
-
* const response = await client.injectMetadataMessage(new Uint8Array(e.data));
|
|
99
|
-
* if (response) metaWs.send(response);
|
|
100
|
-
* };
|
|
101
|
-
* // Similar for body WebSocket...
|
|
102
|
-
*
|
|
103
|
-
* // Poll for outgoing messages
|
|
104
|
-
* setInterval(() => {
|
|
105
|
-
* let msg;
|
|
106
|
-
* while ((msg = client.pollMetadataOutgoing())) metaWs.send(msg);
|
|
107
|
-
* while ((msg = client.pollBodyOutgoing())) bodyWs.send(msg);
|
|
108
|
-
* }, 50);
|
|
109
|
-
*
|
|
110
|
-
* // Start sync
|
|
111
|
-
* await client.start();
|
|
112
|
-
* ```
|
|
113
|
-
* @param {string} server_url
|
|
114
|
-
* @param {string} workspace_id
|
|
115
|
-
* @param {string | null} [auth_token]
|
|
116
|
-
* @returns {WasmSyncClient}
|
|
117
|
-
*/
|
|
118
|
-
createSyncClient(server_url, workspace_id, auth_token) {
|
|
119
|
-
const ptr0 = passStringToWasm0(server_url, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
120
|
-
const len0 = WASM_VECTOR_LEN;
|
|
121
|
-
const ptr1 = passStringToWasm0(workspace_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
122
|
-
const len1 = WASM_VECTOR_LEN;
|
|
123
|
-
var ptr2 = isLikeNone(auth_token) ? 0 : passStringToWasm0(auth_token, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
124
|
-
var len2 = WASM_VECTOR_LEN;
|
|
125
|
-
const ret = wasm.diaryxbackend_createSyncClient(this.__wbg_ptr, ptr0, len0, ptr1, len1, ptr2, len2);
|
|
126
|
-
return WasmSyncClient.__wrap(ret);
|
|
127
|
-
}
|
|
128
|
-
/**
|
|
129
|
-
* Emit a filesystem event.
|
|
130
|
-
*
|
|
131
|
-
* This is primarily used internally but can be called from JavaScript
|
|
132
|
-
* to manually trigger events (e.g., for testing or manual sync scenarios).
|
|
133
|
-
*
|
|
134
|
-
* The event should be a JSON string matching the FileSystemEvent format.
|
|
135
|
-
*
|
|
136
|
-
* ## Example
|
|
137
|
-
*
|
|
138
|
-
* ```javascript
|
|
139
|
-
* backend.emitFileSystemEvent(JSON.stringify({
|
|
140
|
-
* type: 'FileCreated',
|
|
141
|
-
* path: 'workspace/notes.md',
|
|
142
|
-
* frontmatter: { title: 'Notes' }
|
|
143
|
-
* }));
|
|
144
|
-
* ```
|
|
145
|
-
* @param {string} event_json
|
|
146
|
-
*/
|
|
147
|
-
emitFileSystemEvent(event_json) {
|
|
148
|
-
const ptr0 = passStringToWasm0(event_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
149
|
-
const len0 = WASM_VECTOR_LEN;
|
|
150
|
-
const ret = wasm.diaryxbackend_emitFileSystemEvent(this.__wbg_ptr, ptr0, len0);
|
|
151
|
-
if (ret[1]) {
|
|
152
|
-
throw takeFromExternrefTable0(ret[0]);
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
/**
|
|
156
|
-
* Get the number of active event subscriptions.
|
|
157
|
-
* @returns {number}
|
|
158
|
-
*/
|
|
159
|
-
eventSubscriberCount() {
|
|
160
|
-
const ret = wasm.diaryxbackend_eventSubscriberCount(this.__wbg_ptr);
|
|
161
|
-
return ret >>> 0;
|
|
162
|
-
}
|
|
163
|
-
/**
|
|
164
|
-
* Execute a command and return the response as JSON string.
|
|
165
|
-
*
|
|
166
|
-
* This is the primary unified API for all operations.
|
|
167
|
-
*
|
|
168
|
-
* ## Example
|
|
169
|
-
* ```javascript
|
|
170
|
-
* const command = { type: 'GetEntry', params: { path: 'workspace/notes.md' } };
|
|
171
|
-
* const responseJson = await backend.execute(JSON.stringify(command));
|
|
172
|
-
* const response = JSON.parse(responseJson);
|
|
173
|
-
* ```
|
|
174
|
-
* @param {string} command_json
|
|
175
|
-
* @returns {Promise<string>}
|
|
176
|
-
*/
|
|
177
|
-
execute(command_json) {
|
|
178
|
-
const ptr0 = passStringToWasm0(command_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
179
|
-
const len0 = WASM_VECTOR_LEN;
|
|
180
|
-
const ret = wasm.diaryxbackend_execute(this.__wbg_ptr, ptr0, len0);
|
|
181
|
-
return ret;
|
|
182
|
-
}
|
|
183
|
-
/**
|
|
184
|
-
* Execute a command from a JavaScript object directly.
|
|
185
|
-
*
|
|
186
|
-
* This avoids JSON serialization overhead for better performance.
|
|
187
|
-
* @param {any} command
|
|
188
|
-
* @returns {Promise<any>}
|
|
189
|
-
*/
|
|
190
|
-
executeJs(command) {
|
|
191
|
-
const ret = wasm.diaryxbackend_executeJs(this.__wbg_ptr, command);
|
|
192
|
-
return ret;
|
|
193
|
-
}
|
|
194
|
-
/**
|
|
195
|
-
* Get initial body sync step1 message for a document.
|
|
196
|
-
*
|
|
197
|
-
* Returns a Uint8Array containing the Y-sync step1 message for
|
|
198
|
-
* the specified document's body content.
|
|
199
|
-
*
|
|
200
|
-
* ## Example
|
|
201
|
-
* ```javascript
|
|
202
|
-
* const step1 = backend.getBodySyncStep1("notes/my-note.md");
|
|
203
|
-
* // Frame it for multiplexed connection and send
|
|
204
|
-
* ```
|
|
205
|
-
* @param {string} doc_name
|
|
206
|
-
* @returns {Uint8Array}
|
|
207
|
-
*/
|
|
208
|
-
getBodySyncStep1(doc_name) {
|
|
209
|
-
const ptr0 = passStringToWasm0(doc_name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
210
|
-
const len0 = WASM_VECTOR_LEN;
|
|
211
|
-
const ret = wasm.diaryxbackend_getBodySyncStep1(this.__wbg_ptr, ptr0, len0);
|
|
212
|
-
return ret;
|
|
213
|
-
}
|
|
214
|
-
/**
|
|
215
|
-
* Get the current configuration from root index frontmatter.
|
|
216
|
-
* Config keys are stored as `diaryx_*` properties.
|
|
217
|
-
* @returns {Promise<any>}
|
|
218
|
-
*/
|
|
219
|
-
getConfig() {
|
|
220
|
-
const ret = wasm.diaryxbackend_getConfig(this.__wbg_ptr);
|
|
221
|
-
return ret;
|
|
222
|
-
}
|
|
223
|
-
/**
|
|
224
|
-
* Get initial workspace sync step1 message.
|
|
225
|
-
*
|
|
226
|
-
* Returns a Uint8Array containing the Y-sync step1 message to send
|
|
227
|
-
* over the WebSocket to initiate workspace metadata sync.
|
|
228
|
-
*
|
|
229
|
-
* ## Example
|
|
230
|
-
* ```javascript
|
|
231
|
-
* const step1 = backend.getWorkspaceSyncStep1();
|
|
232
|
-
* ws.send(step1);
|
|
233
|
-
* ```
|
|
234
|
-
* @returns {Uint8Array}
|
|
235
|
-
*/
|
|
236
|
-
getWorkspaceSyncStep1() {
|
|
237
|
-
const ret = wasm.diaryxbackend_getWorkspaceSyncStep1(this.__wbg_ptr);
|
|
238
|
-
return ret;
|
|
239
|
-
}
|
|
240
|
-
/**
|
|
241
|
-
* Check if this backend has native sync support.
|
|
242
|
-
*
|
|
243
|
-
* For WASM, this always returns false. The new `createSyncClient()` API
|
|
244
|
-
* provides a unified approach that works across all platforms.
|
|
245
|
-
* @returns {boolean}
|
|
246
|
-
*/
|
|
247
|
-
hasNativeSync() {
|
|
248
|
-
const ret = wasm.diaryxbackend_hasNativeSync(this.__wbg_ptr);
|
|
249
|
-
return ret !== 0;
|
|
250
|
-
}
|
|
251
|
-
/**
|
|
252
|
-
* Check if there are pending outgoing sync messages.
|
|
253
|
-
* @returns {boolean}
|
|
254
|
-
*/
|
|
255
|
-
hasOutgoingSyncMessages() {
|
|
256
|
-
const ret = wasm.diaryxbackend_hasOutgoingSyncMessages(this.__wbg_ptr);
|
|
257
|
-
return ret !== 0;
|
|
258
|
-
}
|
|
259
|
-
/**
|
|
260
|
-
* Inject an incoming body sync message.
|
|
261
|
-
*
|
|
262
|
-
* Call this when the WebSocket receives a message for a body document.
|
|
263
|
-
* The message should already be unframed (doc_name extracted separately).
|
|
264
|
-
* Returns a response message to send back, or null if no response is needed.
|
|
265
|
-
*
|
|
266
|
-
* ## Example
|
|
267
|
-
* ```javascript
|
|
268
|
-
* // After unframing the multiplexed message:
|
|
269
|
-
* const response = await backend.injectBodySyncMessage(docName, data, true);
|
|
270
|
-
* if (response) ws.send(frameBodyMessage(docName, response));
|
|
271
|
-
* ```
|
|
272
|
-
* @param {string} doc_name
|
|
273
|
-
* @param {Uint8Array} message
|
|
274
|
-
* @param {boolean} write_to_disk
|
|
275
|
-
* @returns {Promise<any>}
|
|
276
|
-
*/
|
|
277
|
-
injectBodySyncMessage(doc_name, message, write_to_disk) {
|
|
278
|
-
const ptr0 = passStringToWasm0(doc_name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
279
|
-
const len0 = WASM_VECTOR_LEN;
|
|
280
|
-
const ptr1 = passArray8ToWasm0(message, wasm.__wbindgen_malloc);
|
|
281
|
-
const len1 = WASM_VECTOR_LEN;
|
|
282
|
-
const ret = wasm.diaryxbackend_injectBodySyncMessage(this.__wbg_ptr, ptr0, len0, ptr1, len1, write_to_disk);
|
|
283
|
-
return ret;
|
|
284
|
-
}
|
|
285
|
-
/**
|
|
286
|
-
* Inject an incoming workspace sync message.
|
|
287
|
-
*
|
|
288
|
-
* Call this when the WebSocket receives a message for the workspace
|
|
289
|
-
* (metadata) connection. Returns a response message to send back,
|
|
290
|
-
* or null if no response is needed.
|
|
291
|
-
*
|
|
292
|
-
* ## Example
|
|
293
|
-
* ```javascript
|
|
294
|
-
* ws.onmessage = (event) => {
|
|
295
|
-
* const data = new Uint8Array(event.data);
|
|
296
|
-
* const response = backend.injectWorkspaceSyncMessage(data, true);
|
|
297
|
-
* if (response) ws.send(response);
|
|
298
|
-
* };
|
|
299
|
-
* ```
|
|
300
|
-
* @param {Uint8Array} message
|
|
301
|
-
* @param {boolean} write_to_disk
|
|
302
|
-
* @returns {Promise<any>}
|
|
303
|
-
*/
|
|
304
|
-
injectWorkspaceSyncMessage(message, write_to_disk) {
|
|
305
|
-
const ptr0 = passArray8ToWasm0(message, wasm.__wbindgen_malloc);
|
|
306
|
-
const len0 = WASM_VECTOR_LEN;
|
|
307
|
-
const ret = wasm.diaryxbackend_injectWorkspaceSyncMessage(this.__wbg_ptr, ptr0, len0, write_to_disk);
|
|
308
|
-
return ret;
|
|
309
|
-
}
|
|
310
|
-
/**
|
|
311
|
-
* Unsubscribe from filesystem events.
|
|
312
|
-
*
|
|
313
|
-
* Returns `true` if the subscription was found and removed.
|
|
314
|
-
*
|
|
315
|
-
* ## Example
|
|
316
|
-
*
|
|
317
|
-
* ```javascript
|
|
318
|
-
* const id = backend.onFileSystemEvent(handler);
|
|
319
|
-
* // ... later ...
|
|
320
|
-
* const removed = backend.offFileSystemEvent(id);
|
|
321
|
-
* console.log('Subscription removed:', removed);
|
|
322
|
-
* ```
|
|
323
|
-
* @param {bigint} id
|
|
324
|
-
* @returns {boolean}
|
|
325
|
-
*/
|
|
326
|
-
offFileSystemEvent(id) {
|
|
327
|
-
const ret = wasm.diaryxbackend_offFileSystemEvent(this.__wbg_ptr, id);
|
|
328
|
-
return ret !== 0;
|
|
329
|
-
}
|
|
330
|
-
/**
|
|
331
|
-
* Subscribe to filesystem events.
|
|
332
|
-
*
|
|
333
|
-
* The callback will be invoked with a JSON-serialized FileSystemEvent
|
|
334
|
-
* whenever filesystem operations occur (create, delete, rename, move, etc.).
|
|
335
|
-
*
|
|
336
|
-
* Returns a subscription ID that can be used to unsubscribe later.
|
|
337
|
-
*
|
|
338
|
-
* ## Example
|
|
339
|
-
*
|
|
340
|
-
* ```javascript
|
|
341
|
-
* const id = backend.onFileSystemEvent((eventJson) => {
|
|
342
|
-
* const event = JSON.parse(eventJson);
|
|
343
|
-
* console.log('File event:', event.type, event.path);
|
|
344
|
-
* });
|
|
345
|
-
*
|
|
346
|
-
* // Later, to unsubscribe:
|
|
347
|
-
* backend.offFileSystemEvent(id);
|
|
348
|
-
* ```
|
|
349
|
-
* @param {Function} callback
|
|
350
|
-
* @returns {bigint}
|
|
351
|
-
*/
|
|
352
|
-
onFileSystemEvent(callback) {
|
|
353
|
-
const ret = wasm.diaryxbackend_onFileSystemEvent(this.__wbg_ptr, callback);
|
|
354
|
-
return BigInt.asUintN(64, ret);
|
|
355
|
-
}
|
|
356
|
-
/**
|
|
357
|
-
* Get count of pending outgoing sync messages.
|
|
358
|
-
* @returns {number}
|
|
359
|
-
*/
|
|
360
|
-
outgoingSyncMessageCount() {
|
|
361
|
-
const ret = wasm.diaryxbackend_outgoingSyncMessageCount(this.__wbg_ptr);
|
|
362
|
-
return ret >>> 0;
|
|
363
|
-
}
|
|
364
|
-
/**
|
|
365
|
-
* Poll for an outgoing sync message.
|
|
366
|
-
*
|
|
367
|
-
* Returns the next outgoing message as a JavaScript object with:
|
|
368
|
-
* - `docName`: Document name ("workspace" or file path)
|
|
369
|
-
* - `message`: Uint8Array message data
|
|
370
|
-
* - `isBody`: Boolean indicating body (true) or workspace (false)
|
|
371
|
-
*
|
|
372
|
-
* Returns null if no messages are queued.
|
|
373
|
-
*
|
|
374
|
-
* ## Example
|
|
375
|
-
* ```javascript
|
|
376
|
-
* setInterval(() => {
|
|
377
|
-
* let msg;
|
|
378
|
-
* while ((msg = backend.pollOutgoingSyncMessage()) !== null) {
|
|
379
|
-
* if (msg.isBody) {
|
|
380
|
-
* bodyWs.send(frameBodyMessage(msg.docName, msg.message));
|
|
381
|
-
* } else {
|
|
382
|
-
* workspaceWs.send(msg.message);
|
|
383
|
-
* }
|
|
384
|
-
* }
|
|
385
|
-
* }, 50);
|
|
386
|
-
* ```
|
|
387
|
-
* @returns {any}
|
|
388
|
-
*/
|
|
389
|
-
pollOutgoingSyncMessage() {
|
|
390
|
-
const ret = wasm.diaryxbackend_pollOutgoingSyncMessage(this.__wbg_ptr);
|
|
391
|
-
return ret;
|
|
392
|
-
}
|
|
393
|
-
/**
|
|
394
|
-
* Read binary file.
|
|
395
|
-
*
|
|
396
|
-
* Returns data as Uint8Array for efficient handling without base64 encoding.
|
|
397
|
-
* @param {string} path
|
|
398
|
-
* @returns {Promise<any>}
|
|
399
|
-
*/
|
|
400
|
-
readBinary(path) {
|
|
401
|
-
const ptr0 = passStringToWasm0(path, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
402
|
-
const len0 = WASM_VECTOR_LEN;
|
|
403
|
-
const ret = wasm.diaryxbackend_readBinary(this.__wbg_ptr, ptr0, len0);
|
|
404
|
-
return ret;
|
|
405
|
-
}
|
|
406
|
-
/**
|
|
407
|
-
* Save configuration to root index frontmatter.
|
|
408
|
-
* Config keys are stored as `diaryx_*` properties.
|
|
409
|
-
* @param {any} config_js
|
|
410
|
-
* @returns {Promise<any>}
|
|
411
|
-
*/
|
|
412
|
-
saveConfig(config_js) {
|
|
413
|
-
const ret = wasm.diaryxbackend_saveConfig(this.__wbg_ptr, config_js);
|
|
414
|
-
return ret;
|
|
415
|
-
}
|
|
416
|
-
/**
|
|
417
|
-
* Start sync session and set up event bridge.
|
|
418
|
-
*
|
|
419
|
-
* This wires up the sync manager's event callback to queue outgoing
|
|
420
|
-
* messages. Call this before connecting WebSocket.
|
|
421
|
-
*
|
|
422
|
-
* ## Example
|
|
423
|
-
* ```javascript
|
|
424
|
-
* backend.startSync();
|
|
425
|
-
* const ws = new WebSocket(url);
|
|
426
|
-
* // ... rest of setup
|
|
427
|
-
* ```
|
|
428
|
-
*/
|
|
429
|
-
startSync() {
|
|
430
|
-
wasm.diaryxbackend_startSync(this.__wbg_ptr);
|
|
431
|
-
}
|
|
432
|
-
/**
|
|
433
|
-
* Stop sync session.
|
|
434
|
-
*
|
|
435
|
-
* Clears the outgoing message queue. Call after disconnecting WebSocket.
|
|
436
|
-
*/
|
|
437
|
-
stopSync() {
|
|
438
|
-
wasm.diaryxbackend_stopSync(this.__wbg_ptr);
|
|
439
|
-
}
|
|
440
|
-
/**
|
|
441
|
-
* Write binary file.
|
|
442
|
-
*
|
|
443
|
-
* Accepts Uint8Array for efficient handling without base64 encoding.
|
|
444
|
-
* @param {string} path
|
|
445
|
-
* @param {Uint8Array} data
|
|
446
|
-
* @returns {Promise<any>}
|
|
447
|
-
*/
|
|
448
|
-
writeBinary(path, data) {
|
|
449
|
-
const ptr0 = passStringToWasm0(path, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
450
|
-
const len0 = WASM_VECTOR_LEN;
|
|
451
|
-
const ret = wasm.diaryxbackend_writeBinary(this.__wbg_ptr, ptr0, len0, data);
|
|
452
|
-
return ret;
|
|
453
|
-
}
|
|
454
|
-
}
|
|
455
|
-
if (Symbol.dispose) DiaryxBackend.prototype[Symbol.dispose] = DiaryxBackend.prototype.free;
|
|
456
|
-
|
|
457
|
-
/**
|
|
458
|
-
* An `AsyncFileSystem` implementation backed by JavaScript callbacks.
|
|
459
|
-
*
|
|
460
|
-
* This struct allows Rust code to use the async filesystem interface while
|
|
461
|
-
* delegating actual storage operations to JavaScript. This is useful for:
|
|
462
|
-
*
|
|
463
|
-
* - Using IndexedDB for persistent storage in browsers
|
|
464
|
-
* - Using OPFS (Origin Private File System) for better performance
|
|
465
|
-
* - Integrating with existing JavaScript storage solutions
|
|
466
|
-
* - Testing with mock filesystems
|
|
467
|
-
*
|
|
468
|
-
* ## Thread Safety
|
|
469
|
-
*
|
|
470
|
-
* This type is designed for single-threaded WASM environments. The callbacks
|
|
471
|
-
* JsValue is cloned into each async operation to satisfy Send requirements,
|
|
472
|
-
* but actual execution remains single-threaded.
|
|
473
|
-
*/
|
|
474
|
-
export class JsAsyncFileSystem {
|
|
475
|
-
__destroy_into_raw() {
|
|
476
|
-
const ptr = this.__wbg_ptr;
|
|
477
|
-
this.__wbg_ptr = 0;
|
|
478
|
-
JsAsyncFileSystemFinalization.unregister(this);
|
|
479
|
-
return ptr;
|
|
480
|
-
}
|
|
481
|
-
free() {
|
|
482
|
-
const ptr = this.__destroy_into_raw();
|
|
483
|
-
wasm.__wbg_jsasyncfilesystem_free(ptr, 0);
|
|
484
|
-
}
|
|
485
|
-
/**
|
|
486
|
-
* Check if the filesystem has a specific callback.
|
|
487
|
-
* @param {string} name
|
|
488
|
-
* @returns {boolean}
|
|
489
|
-
*/
|
|
490
|
-
has_callback(name) {
|
|
491
|
-
const ptr0 = passStringToWasm0(name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
492
|
-
const len0 = WASM_VECTOR_LEN;
|
|
493
|
-
const ret = wasm.jsasyncfilesystem_has_callback(this.__wbg_ptr, ptr0, len0);
|
|
494
|
-
return ret !== 0;
|
|
495
|
-
}
|
|
496
|
-
/**
|
|
497
|
-
* Create a new JsAsyncFileSystem with the provided callbacks.
|
|
498
|
-
*
|
|
499
|
-
* The callbacks object should implement the `JsFileSystemCallbacks` interface.
|
|
500
|
-
* All callbacks are optional - missing callbacks will cause operations to fail
|
|
501
|
-
* with appropriate errors.
|
|
502
|
-
* @param {any} callbacks
|
|
503
|
-
*/
|
|
504
|
-
constructor(callbacks) {
|
|
505
|
-
const ret = wasm.jsasyncfilesystem_new(callbacks);
|
|
506
|
-
this.__wbg_ptr = ret >>> 0;
|
|
507
|
-
JsAsyncFileSystemFinalization.register(this, this.__wbg_ptr, this);
|
|
508
|
-
return this;
|
|
509
|
-
}
|
|
510
|
-
}
|
|
511
|
-
if (Symbol.dispose) JsAsyncFileSystem.prototype[Symbol.dispose] = JsAsyncFileSystem.prototype.free;
|
|
512
|
-
|
|
513
|
-
/**
|
|
514
|
-
* WASM sync client wrapper for JavaScript integration.
|
|
515
|
-
*
|
|
516
|
-
* This struct wraps a `SyncClient<CallbackTransport>` and exposes its
|
|
517
|
-
* functionality to JavaScript via wasm-bindgen. It manages two transports
|
|
518
|
-
* (metadata and body) and provides methods for:
|
|
519
|
-
*
|
|
520
|
-
* - Getting WebSocket URLs for connection
|
|
521
|
-
* - Notifying connection status changes
|
|
522
|
-
* - Injecting incoming messages
|
|
523
|
-
* - Polling for outgoing messages
|
|
524
|
-
* - Starting and stopping sync
|
|
525
|
-
*/
|
|
526
|
-
export class WasmSyncClient {
|
|
527
|
-
static __wrap(ptr) {
|
|
528
|
-
ptr = ptr >>> 0;
|
|
529
|
-
const obj = Object.create(WasmSyncClient.prototype);
|
|
530
|
-
obj.__wbg_ptr = ptr;
|
|
531
|
-
WasmSyncClientFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
532
|
-
return obj;
|
|
533
|
-
}
|
|
534
|
-
__destroy_into_raw() {
|
|
535
|
-
const ptr = this.__wbg_ptr;
|
|
536
|
-
this.__wbg_ptr = 0;
|
|
537
|
-
WasmSyncClientFinalization.unregister(this);
|
|
538
|
-
return ptr;
|
|
539
|
-
}
|
|
540
|
-
free() {
|
|
541
|
-
const ptr = this.__destroy_into_raw();
|
|
542
|
-
wasm.__wbg_wasmsyncclient_free(ptr, 0);
|
|
543
|
-
}
|
|
544
|
-
/**
|
|
545
|
-
* Focus on specific files for sync.
|
|
546
|
-
*
|
|
547
|
-
* Sends a focus message to the server indicating which files the client
|
|
548
|
-
* is currently interested in syncing. Other clients will receive a
|
|
549
|
-
* `focus_list_changed` notification and can subscribe to sync updates
|
|
550
|
-
* for these files.
|
|
551
|
-
*
|
|
552
|
-
* Call this when a file is opened in the editor.
|
|
553
|
-
*
|
|
554
|
-
* ## Example
|
|
555
|
-
* ```javascript
|
|
556
|
-
* // User opens a file
|
|
557
|
-
* client.focusFiles(["workspace/notes.md"]);
|
|
558
|
-
* ```
|
|
559
|
-
* @param {string[]} files
|
|
560
|
-
*/
|
|
561
|
-
focusFiles(files) {
|
|
562
|
-
const ptr0 = passArrayJsValueToWasm0(files, wasm.__wbindgen_malloc);
|
|
563
|
-
const len0 = WASM_VECTOR_LEN;
|
|
564
|
-
wasm.wasmsyncclient_focusFiles(this.__wbg_ptr, ptr0, len0);
|
|
565
|
-
}
|
|
566
|
-
/**
|
|
567
|
-
* Get the initial SyncStep1 message for a body document.
|
|
568
|
-
*
|
|
569
|
-
* Returns a Uint8Array containing the framed message to send via WebSocket.
|
|
570
|
-
* @param {string} doc_name
|
|
571
|
-
* @returns {Uint8Array}
|
|
572
|
-
*/
|
|
573
|
-
getBodySyncStep1(doc_name) {
|
|
574
|
-
const ptr0 = passStringToWasm0(doc_name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
575
|
-
const len0 = WASM_VECTOR_LEN;
|
|
576
|
-
const ret = wasm.wasmsyncclient_getBodySyncStep1(this.__wbg_ptr, ptr0, len0);
|
|
577
|
-
return ret;
|
|
578
|
-
}
|
|
579
|
-
/**
|
|
580
|
-
* Get the WebSocket URL for the body connection.
|
|
581
|
-
*
|
|
582
|
-
* Returns null if sync hasn't been configured.
|
|
583
|
-
* @returns {string | undefined}
|
|
584
|
-
*/
|
|
585
|
-
getBodyUrl() {
|
|
586
|
-
const ret = wasm.wasmsyncclient_getBodyUrl(this.__wbg_ptr);
|
|
587
|
-
let v1;
|
|
588
|
-
if (ret[0] !== 0) {
|
|
589
|
-
v1 = getStringFromWasm0(ret[0], ret[1]).slice();
|
|
590
|
-
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
591
|
-
}
|
|
592
|
-
return v1;
|
|
593
|
-
}
|
|
594
|
-
/**
|
|
595
|
-
* Get the WebSocket URL for the metadata connection.
|
|
596
|
-
*
|
|
597
|
-
* Returns null if sync hasn't been configured.
|
|
598
|
-
* @returns {string | undefined}
|
|
599
|
-
*/
|
|
600
|
-
getMetadataUrl() {
|
|
601
|
-
const ret = wasm.wasmsyncclient_getMetadataUrl(this.__wbg_ptr);
|
|
602
|
-
let v1;
|
|
603
|
-
if (ret[0] !== 0) {
|
|
604
|
-
v1 = getStringFromWasm0(ret[0], ret[1]).slice();
|
|
605
|
-
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
606
|
-
}
|
|
607
|
-
return v1;
|
|
608
|
-
}
|
|
609
|
-
/**
|
|
610
|
-
* Get the server URL.
|
|
611
|
-
* @returns {string}
|
|
612
|
-
*/
|
|
613
|
-
getServerUrl() {
|
|
614
|
-
let deferred1_0;
|
|
615
|
-
let deferred1_1;
|
|
616
|
-
try {
|
|
617
|
-
const ret = wasm.wasmsyncclient_getServerUrl(this.__wbg_ptr);
|
|
618
|
-
deferred1_0 = ret[0];
|
|
619
|
-
deferred1_1 = ret[1];
|
|
620
|
-
return getStringFromWasm0(ret[0], ret[1]);
|
|
621
|
-
} finally {
|
|
622
|
-
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
623
|
-
}
|
|
624
|
-
}
|
|
625
|
-
/**
|
|
626
|
-
* Get the workspace ID.
|
|
627
|
-
* @returns {string}
|
|
628
|
-
*/
|
|
629
|
-
getWorkspaceId() {
|
|
630
|
-
let deferred1_0;
|
|
631
|
-
let deferred1_1;
|
|
632
|
-
try {
|
|
633
|
-
const ret = wasm.wasmsyncclient_getWorkspaceId(this.__wbg_ptr);
|
|
634
|
-
deferred1_0 = ret[0];
|
|
635
|
-
deferred1_1 = ret[1];
|
|
636
|
-
return getStringFromWasm0(ret[0], ret[1]);
|
|
637
|
-
} finally {
|
|
638
|
-
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
639
|
-
}
|
|
640
|
-
}
|
|
641
|
-
/**
|
|
642
|
-
* Get the initial SyncStep1 message for workspace sync.
|
|
643
|
-
*
|
|
644
|
-
* Returns a Uint8Array containing the message to send via WebSocket.
|
|
645
|
-
* @returns {Uint8Array}
|
|
646
|
-
*/
|
|
647
|
-
getWorkspaceSyncStep1() {
|
|
648
|
-
const ret = wasm.wasmsyncclient_getWorkspaceSyncStep1(this.__wbg_ptr);
|
|
649
|
-
return ret;
|
|
650
|
-
}
|
|
651
|
-
/**
|
|
652
|
-
* Check if there are pending body outgoing messages.
|
|
653
|
-
* @returns {boolean}
|
|
654
|
-
*/
|
|
655
|
-
hasBodyOutgoing() {
|
|
656
|
-
const ret = wasm.wasmsyncclient_hasBodyOutgoing(this.__wbg_ptr);
|
|
657
|
-
return ret !== 0;
|
|
658
|
-
}
|
|
659
|
-
/**
|
|
660
|
-
* Check if there are pending body outgoing text messages.
|
|
661
|
-
* @returns {boolean}
|
|
662
|
-
*/
|
|
663
|
-
hasBodyOutgoingText() {
|
|
664
|
-
const ret = wasm.wasmsyncclient_hasBodyOutgoingText(this.__wbg_ptr);
|
|
665
|
-
return ret !== 0;
|
|
666
|
-
}
|
|
667
|
-
/**
|
|
668
|
-
* Check if there are pending metadata outgoing messages.
|
|
669
|
-
* @returns {boolean}
|
|
670
|
-
*/
|
|
671
|
-
hasMetadataOutgoing() {
|
|
672
|
-
const ret = wasm.wasmsyncclient_hasMetadataOutgoing(this.__wbg_ptr);
|
|
673
|
-
return ret !== 0;
|
|
674
|
-
}
|
|
675
|
-
/**
|
|
676
|
-
* Inject an incoming body message.
|
|
677
|
-
*
|
|
678
|
-
* Call this when the body WebSocket receives a message.
|
|
679
|
-
* The message should already be unframed (doc_name extracted separately).
|
|
680
|
-
* Returns a Promise that resolves to a Uint8Array response (or null).
|
|
681
|
-
* @param {string} doc_name
|
|
682
|
-
* @param {Uint8Array} message
|
|
683
|
-
* @returns {Promise<any>}
|
|
684
|
-
*/
|
|
685
|
-
injectBodyMessage(doc_name, message) {
|
|
686
|
-
const ptr0 = passStringToWasm0(doc_name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
687
|
-
const len0 = WASM_VECTOR_LEN;
|
|
688
|
-
const ptr1 = passArray8ToWasm0(message, wasm.__wbindgen_malloc);
|
|
689
|
-
const len1 = WASM_VECTOR_LEN;
|
|
690
|
-
const ret = wasm.wasmsyncclient_injectBodyMessage(this.__wbg_ptr, ptr0, len0, ptr1, len1);
|
|
691
|
-
return ret;
|
|
692
|
-
}
|
|
693
|
-
/**
|
|
694
|
-
* Inject an incoming metadata message.
|
|
695
|
-
*
|
|
696
|
-
* Call this when the metadata WebSocket receives a message.
|
|
697
|
-
* Returns a Promise that resolves to a Uint8Array response (or null).
|
|
698
|
-
*
|
|
699
|
-
* The response should be sent back via the WebSocket if not null.
|
|
700
|
-
* @param {Uint8Array} message
|
|
701
|
-
* @returns {Promise<any>}
|
|
702
|
-
*/
|
|
703
|
-
injectMetadataMessage(message) {
|
|
704
|
-
const ptr0 = passArray8ToWasm0(message, wasm.__wbindgen_malloc);
|
|
705
|
-
const len0 = WASM_VECTOR_LEN;
|
|
706
|
-
const ret = wasm.wasmsyncclient_injectMetadataMessage(this.__wbg_ptr, ptr0, len0);
|
|
707
|
-
return ret;
|
|
708
|
-
}
|
|
709
|
-
/**
|
|
710
|
-
* Check if the body connection is established.
|
|
711
|
-
* @returns {boolean}
|
|
712
|
-
*/
|
|
713
|
-
isBodyConnected() {
|
|
714
|
-
const ret = wasm.wasmsyncclient_isBodyConnected(this.__wbg_ptr);
|
|
715
|
-
return ret !== 0;
|
|
716
|
-
}
|
|
717
|
-
/**
|
|
718
|
-
* Check if both connections are established.
|
|
719
|
-
* @returns {boolean}
|
|
720
|
-
*/
|
|
721
|
-
isConnected() {
|
|
722
|
-
const ret = wasm.wasmsyncclient_isConnected(this.__wbg_ptr);
|
|
723
|
-
return ret !== 0;
|
|
724
|
-
}
|
|
725
|
-
/**
|
|
726
|
-
* Check if the metadata connection is established.
|
|
727
|
-
* @returns {boolean}
|
|
728
|
-
*/
|
|
729
|
-
isMetadataConnected() {
|
|
730
|
-
const ret = wasm.wasmsyncclient_isMetadataConnected(this.__wbg_ptr);
|
|
731
|
-
return ret !== 0;
|
|
732
|
-
}
|
|
733
|
-
/**
|
|
734
|
-
* Check if the sync client is running.
|
|
735
|
-
* @returns {boolean}
|
|
736
|
-
*/
|
|
737
|
-
isRunning() {
|
|
738
|
-
const ret = wasm.wasmsyncclient_isRunning(this.__wbg_ptr);
|
|
739
|
-
return ret !== 0;
|
|
740
|
-
}
|
|
741
|
-
/**
|
|
742
|
-
* Mark the body connection as connected.
|
|
743
|
-
*
|
|
744
|
-
* Call this when the body WebSocket opens.
|
|
745
|
-
*/
|
|
746
|
-
markBodyConnected() {
|
|
747
|
-
wasm.wasmsyncclient_markBodyConnected(this.__wbg_ptr);
|
|
748
|
-
}
|
|
749
|
-
/**
|
|
750
|
-
* Mark the body connection as disconnected.
|
|
751
|
-
*
|
|
752
|
-
* Call this when the body WebSocket closes.
|
|
753
|
-
*/
|
|
754
|
-
markBodyDisconnected() {
|
|
755
|
-
wasm.wasmsyncclient_markBodyDisconnected(this.__wbg_ptr);
|
|
756
|
-
}
|
|
757
|
-
/**
|
|
758
|
-
* Mark the metadata connection as connected.
|
|
759
|
-
*
|
|
760
|
-
* Call this when the metadata WebSocket opens.
|
|
761
|
-
*/
|
|
762
|
-
markMetadataConnected() {
|
|
763
|
-
wasm.wasmsyncclient_markMetadataConnected(this.__wbg_ptr);
|
|
764
|
-
}
|
|
765
|
-
/**
|
|
766
|
-
* Mark the metadata connection as disconnected.
|
|
767
|
-
*
|
|
768
|
-
* Call this when the metadata WebSocket closes.
|
|
769
|
-
*/
|
|
770
|
-
markMetadataDisconnected() {
|
|
771
|
-
wasm.wasmsyncclient_markMetadataDisconnected(this.__wbg_ptr);
|
|
772
|
-
}
|
|
773
|
-
/**
|
|
774
|
-
* Poll for an outgoing body message.
|
|
775
|
-
*
|
|
776
|
-
* Returns a Uint8Array if there's a message to send, null otherwise.
|
|
777
|
-
* The message is already framed with the document name.
|
|
778
|
-
* @returns {Uint8Array | undefined}
|
|
779
|
-
*/
|
|
780
|
-
pollBodyOutgoing() {
|
|
781
|
-
const ret = wasm.wasmsyncclient_pollBodyOutgoing(this.__wbg_ptr);
|
|
782
|
-
return ret;
|
|
783
|
-
}
|
|
784
|
-
/**
|
|
785
|
-
* Poll for an outgoing body text message (for focus/unfocus).
|
|
786
|
-
*
|
|
787
|
-
* Returns a string if there's a text message to send, null otherwise.
|
|
788
|
-
* JavaScript should call this in a polling loop and send any messages
|
|
789
|
-
* via the body WebSocket as text frames.
|
|
790
|
-
* @returns {string | undefined}
|
|
791
|
-
*/
|
|
792
|
-
pollBodyOutgoingText() {
|
|
793
|
-
const ret = wasm.wasmsyncclient_pollBodyOutgoingText(this.__wbg_ptr);
|
|
794
|
-
let v1;
|
|
795
|
-
if (ret[0] !== 0) {
|
|
796
|
-
v1 = getStringFromWasm0(ret[0], ret[1]).slice();
|
|
797
|
-
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
798
|
-
}
|
|
799
|
-
return v1;
|
|
800
|
-
}
|
|
801
|
-
/**
|
|
802
|
-
* Poll for an outgoing metadata message.
|
|
803
|
-
*
|
|
804
|
-
* Returns a Uint8Array if there's a message to send, null otherwise.
|
|
805
|
-
* JavaScript should call this in a polling loop and send any messages
|
|
806
|
-
* via the metadata WebSocket.
|
|
807
|
-
* @returns {Uint8Array | undefined}
|
|
808
|
-
*/
|
|
809
|
-
pollMetadataOutgoing() {
|
|
810
|
-
const ret = wasm.wasmsyncclient_pollMetadataOutgoing(this.__wbg_ptr);
|
|
811
|
-
return ret;
|
|
812
|
-
}
|
|
813
|
-
/**
|
|
814
|
-
* Queue a body update message for sending.
|
|
815
|
-
*
|
|
816
|
-
* This creates a Y-sync Update message for the given document
|
|
817
|
-
* and queues it for sending via the body WebSocket.
|
|
818
|
-
* @param {string} doc_name
|
|
819
|
-
* @param {string} content
|
|
820
|
-
*/
|
|
821
|
-
queueBodyUpdate(doc_name, content) {
|
|
822
|
-
const ptr0 = passStringToWasm0(doc_name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
823
|
-
const len0 = WASM_VECTOR_LEN;
|
|
824
|
-
const ptr1 = passStringToWasm0(content, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
825
|
-
const len1 = WASM_VECTOR_LEN;
|
|
826
|
-
const ret = wasm.wasmsyncclient_queueBodyUpdate(this.__wbg_ptr, ptr0, len0, ptr1, len1);
|
|
827
|
-
if (ret[1]) {
|
|
828
|
-
throw takeFromExternrefTable0(ret[0]);
|
|
829
|
-
}
|
|
830
|
-
}
|
|
831
|
-
/**
|
|
832
|
-
* Queue a workspace update message for sending.
|
|
833
|
-
*
|
|
834
|
-
* This creates a Y-sync Update message from the current workspace state
|
|
835
|
-
* and queues it for sending via the metadata WebSocket.
|
|
836
|
-
*/
|
|
837
|
-
queueWorkspaceUpdate() {
|
|
838
|
-
const ret = wasm.wasmsyncclient_queueWorkspaceUpdate(this.__wbg_ptr);
|
|
839
|
-
if (ret[1]) {
|
|
840
|
-
throw takeFromExternrefTable0(ret[0]);
|
|
841
|
-
}
|
|
842
|
-
}
|
|
843
|
-
/**
|
|
844
|
-
* Start the sync session.
|
|
845
|
-
*
|
|
846
|
-
* This should be called after both WebSocket connections are established.
|
|
847
|
-
* It sends the initial SyncStep1 messages and subscribes to all body docs.
|
|
848
|
-
*
|
|
849
|
-
* Returns a Promise that resolves when initial sync messages are sent.
|
|
850
|
-
* @returns {Promise<any>}
|
|
851
|
-
*/
|
|
852
|
-
start() {
|
|
853
|
-
const ret = wasm.wasmsyncclient_start(this.__wbg_ptr);
|
|
854
|
-
return ret;
|
|
855
|
-
}
|
|
856
|
-
/**
|
|
857
|
-
* Stop the sync session.
|
|
858
|
-
*
|
|
859
|
-
* Clears all pending messages and resets state.
|
|
860
|
-
*/
|
|
861
|
-
stop() {
|
|
862
|
-
wasm.wasmsyncclient_stop(this.__wbg_ptr);
|
|
863
|
-
}
|
|
864
|
-
/**
|
|
865
|
-
* Subscribe to body sync for the currently focused files.
|
|
866
|
-
*
|
|
867
|
-
* This sends SyncStep1 messages for all files in the provided list.
|
|
868
|
-
* Call this after receiving a `focus_list_changed` message from the server.
|
|
869
|
-
*
|
|
870
|
-
* ## Example
|
|
871
|
-
* ```javascript
|
|
872
|
-
* // Received focus_list_changed event
|
|
873
|
-
* const files = event.files;
|
|
874
|
-
* client.subscribeBodies(files);
|
|
875
|
-
* ```
|
|
876
|
-
* @param {string[]} files
|
|
877
|
-
*/
|
|
878
|
-
subscribeBodies(files) {
|
|
879
|
-
const ptr0 = passArrayJsValueToWasm0(files, wasm.__wbindgen_malloc);
|
|
880
|
-
const len0 = WASM_VECTOR_LEN;
|
|
881
|
-
wasm.wasmsyncclient_subscribeBodies(this.__wbg_ptr, ptr0, len0);
|
|
882
|
-
}
|
|
883
|
-
/**
|
|
884
|
-
* Subscribe to body sync for a specific document.
|
|
885
|
-
*
|
|
886
|
-
* This queues a SyncStep1 message for the given document.
|
|
887
|
-
* Call this when a new file is created or when opening a file for editing.
|
|
888
|
-
* @param {string} doc_name
|
|
889
|
-
*/
|
|
890
|
-
subscribeBody(doc_name) {
|
|
891
|
-
const ptr0 = passStringToWasm0(doc_name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
892
|
-
const len0 = WASM_VECTOR_LEN;
|
|
893
|
-
wasm.wasmsyncclient_subscribeBody(this.__wbg_ptr, ptr0, len0);
|
|
894
|
-
}
|
|
895
|
-
/**
|
|
896
|
-
* Unfocus specific files.
|
|
897
|
-
*
|
|
898
|
-
* Sends an unfocus message to the server indicating the client is no
|
|
899
|
-
* longer interested in syncing these files.
|
|
900
|
-
*
|
|
901
|
-
* Call this when a file is closed in the editor.
|
|
902
|
-
*
|
|
903
|
-
* ## Example
|
|
904
|
-
* ```javascript
|
|
905
|
-
* // User closes a file
|
|
906
|
-
* client.unfocusFiles(["workspace/notes.md"]);
|
|
907
|
-
* ```
|
|
908
|
-
* @param {string[]} files
|
|
909
|
-
*/
|
|
910
|
-
unfocusFiles(files) {
|
|
911
|
-
const ptr0 = passArrayJsValueToWasm0(files, wasm.__wbindgen_malloc);
|
|
912
|
-
const len0 = WASM_VECTOR_LEN;
|
|
913
|
-
wasm.wasmsyncclient_unfocusFiles(this.__wbg_ptr, ptr0, len0);
|
|
914
|
-
}
|
|
915
|
-
}
|
|
916
|
-
if (Symbol.dispose) WasmSyncClient.prototype[Symbol.dispose] = WasmSyncClient.prototype.free;
|
|
917
|
-
|
|
918
|
-
/**
|
|
919
|
-
* Initialize the WASM module. Called automatically on module load.
|
|
920
|
-
*/
|
|
921
|
-
export function init() {
|
|
922
|
-
wasm.init();
|
|
923
|
-
}
|
|
924
|
-
|
|
925
|
-
/**
|
|
926
|
-
* Generate an ISO 8601 timestamp for the current time.
|
|
927
|
-
* @returns {string}
|
|
928
|
-
*/
|
|
929
|
-
export function now_timestamp() {
|
|
930
|
-
let deferred1_0;
|
|
931
|
-
let deferred1_1;
|
|
932
|
-
try {
|
|
933
|
-
const ret = wasm.now_timestamp();
|
|
934
|
-
deferred1_0 = ret[0];
|
|
935
|
-
deferred1_1 = ret[1];
|
|
936
|
-
return getStringFromWasm0(ret[0], ret[1]);
|
|
937
|
-
} finally {
|
|
938
|
-
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
939
|
-
}
|
|
940
|
-
}
|
|
941
|
-
|
|
942
|
-
/**
|
|
943
|
-
* Generate a formatted date string for the current date.
|
|
944
|
-
* @param {string} format
|
|
945
|
-
* @returns {string}
|
|
946
|
-
*/
|
|
947
|
-
export function today_formatted(format) {
|
|
948
|
-
let deferred2_0;
|
|
949
|
-
let deferred2_1;
|
|
950
|
-
try {
|
|
951
|
-
const ptr0 = passStringToWasm0(format, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
952
|
-
const len0 = WASM_VECTOR_LEN;
|
|
953
|
-
const ret = wasm.today_formatted(ptr0, len0);
|
|
954
|
-
deferred2_0 = ret[0];
|
|
955
|
-
deferred2_1 = ret[1];
|
|
956
|
-
return getStringFromWasm0(ret[0], ret[1]);
|
|
957
|
-
} finally {
|
|
958
|
-
wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
|
|
959
|
-
}
|
|
960
|
-
}
|
|
961
|
-
export function __wbg_Error_8c4e43fe74559d73(arg0, arg1) {
|
|
962
|
-
const ret = Error(getStringFromWasm0(arg0, arg1));
|
|
963
|
-
return ret;
|
|
964
|
-
}
|
|
965
|
-
export function __wbg_Number_04624de7d0e8332d(arg0) {
|
|
966
|
-
const ret = Number(arg0);
|
|
967
|
-
return ret;
|
|
968
|
-
}
|
|
969
|
-
export function __wbg_String_8f0eb39a4a4c2f66(arg0, arg1) {
|
|
970
|
-
const ret = String(arg1);
|
|
971
|
-
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
972
|
-
const len1 = WASM_VECTOR_LEN;
|
|
973
|
-
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
974
|
-
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
975
|
-
}
|
|
976
|
-
export function __wbg___wbindgen_bigint_get_as_i64_8fcf4ce7f1ca72a2(arg0, arg1) {
|
|
977
|
-
const v = arg1;
|
|
978
|
-
const ret = typeof(v) === 'bigint' ? v : undefined;
|
|
979
|
-
getDataViewMemory0().setBigInt64(arg0 + 8 * 1, isLikeNone(ret) ? BigInt(0) : ret, true);
|
|
980
|
-
getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
|
|
981
|
-
}
|
|
982
|
-
export function __wbg___wbindgen_boolean_get_bbbb1c18aa2f5e25(arg0) {
|
|
983
|
-
const v = arg0;
|
|
984
|
-
const ret = typeof(v) === 'boolean' ? v : undefined;
|
|
985
|
-
return isLikeNone(ret) ? 0xFFFFFF : ret ? 1 : 0;
|
|
986
|
-
}
|
|
987
|
-
export function __wbg___wbindgen_debug_string_0bc8482c6e3508ae(arg0, arg1) {
|
|
988
|
-
const ret = debugString(arg1);
|
|
989
|
-
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
990
|
-
const len1 = WASM_VECTOR_LEN;
|
|
991
|
-
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
992
|
-
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
993
|
-
}
|
|
994
|
-
export function __wbg___wbindgen_in_47fa6863be6f2f25(arg0, arg1) {
|
|
995
|
-
const ret = arg0 in arg1;
|
|
996
|
-
return ret;
|
|
997
|
-
}
|
|
998
|
-
export function __wbg___wbindgen_is_bigint_31b12575b56f32fc(arg0) {
|
|
999
|
-
const ret = typeof(arg0) === 'bigint';
|
|
1000
|
-
return ret;
|
|
1001
|
-
}
|
|
1002
|
-
export function __wbg___wbindgen_is_function_0095a73b8b156f76(arg0) {
|
|
1003
|
-
const ret = typeof(arg0) === 'function';
|
|
1004
|
-
return ret;
|
|
1005
|
-
}
|
|
1006
|
-
export function __wbg___wbindgen_is_object_5ae8e5880f2c1fbd(arg0) {
|
|
1007
|
-
const val = arg0;
|
|
1008
|
-
const ret = typeof(val) === 'object' && val !== null;
|
|
1009
|
-
return ret;
|
|
1010
|
-
}
|
|
1011
|
-
export function __wbg___wbindgen_is_string_cd444516edc5b180(arg0) {
|
|
1012
|
-
const ret = typeof(arg0) === 'string';
|
|
1013
|
-
return ret;
|
|
1014
|
-
}
|
|
1015
|
-
export function __wbg___wbindgen_is_undefined_9e4d92534c42d778(arg0) {
|
|
1016
|
-
const ret = arg0 === undefined;
|
|
1017
|
-
return ret;
|
|
1018
|
-
}
|
|
1019
|
-
export function __wbg___wbindgen_jsval_eq_11888390b0186270(arg0, arg1) {
|
|
1020
|
-
const ret = arg0 === arg1;
|
|
1021
|
-
return ret;
|
|
1022
|
-
}
|
|
1023
|
-
export function __wbg___wbindgen_jsval_loose_eq_9dd77d8cd6671811(arg0, arg1) {
|
|
1024
|
-
const ret = arg0 == arg1;
|
|
1025
|
-
return ret;
|
|
1026
|
-
}
|
|
1027
|
-
export function __wbg___wbindgen_number_get_8ff4255516ccad3e(arg0, arg1) {
|
|
1028
|
-
const obj = arg1;
|
|
1029
|
-
const ret = typeof(obj) === 'number' ? obj : undefined;
|
|
1030
|
-
getDataViewMemory0().setFloat64(arg0 + 8 * 1, isLikeNone(ret) ? 0 : ret, true);
|
|
1031
|
-
getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
|
|
1032
|
-
}
|
|
1033
|
-
export function __wbg___wbindgen_string_get_72fb696202c56729(arg0, arg1) {
|
|
1034
|
-
const obj = arg1;
|
|
1035
|
-
const ret = typeof(obj) === 'string' ? obj : undefined;
|
|
1036
|
-
var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1037
|
-
var len1 = WASM_VECTOR_LEN;
|
|
1038
|
-
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
1039
|
-
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
1040
|
-
}
|
|
1041
|
-
export function __wbg___wbindgen_throw_be289d5034ed271b(arg0, arg1) {
|
|
1042
|
-
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
1043
|
-
}
|
|
1044
|
-
export function __wbg__wbg_cb_unref_d9b87ff7982e3b21(arg0) {
|
|
1045
|
-
arg0._wbg_cb_unref();
|
|
1046
|
-
}
|
|
1047
|
-
export function __wbg_call_389efe28435a9388() { return handleError(function (arg0, arg1) {
|
|
1048
|
-
const ret = arg0.call(arg1);
|
|
1049
|
-
return ret;
|
|
1050
|
-
}, arguments); }
|
|
1051
|
-
export function __wbg_call_4708e0c13bdc8e95() { return handleError(function (arg0, arg1, arg2) {
|
|
1052
|
-
const ret = arg0.call(arg1, arg2);
|
|
1053
|
-
return ret;
|
|
1054
|
-
}, arguments); }
|
|
1055
|
-
export function __wbg_crypto_86f2631e91b51511(arg0) {
|
|
1056
|
-
const ret = arg0.crypto;
|
|
1057
|
-
return ret;
|
|
1058
|
-
}
|
|
1059
|
-
export function __wbg_debug_46a93995fc6f8820(arg0, arg1, arg2, arg3) {
|
|
1060
|
-
console.debug(arg0, arg1, arg2, arg3);
|
|
1061
|
-
}
|
|
1062
|
-
export function __wbg_diaryxbackend_new(arg0) {
|
|
1063
|
-
const ret = DiaryxBackend.__wrap(arg0);
|
|
1064
|
-
return ret;
|
|
1065
|
-
}
|
|
1066
|
-
export function __wbg_done_57b39ecd9addfe81(arg0) {
|
|
1067
|
-
const ret = arg0.done;
|
|
1068
|
-
return ret;
|
|
1069
|
-
}
|
|
1070
|
-
export function __wbg_entries_58c7934c745daac7(arg0) {
|
|
1071
|
-
const ret = Object.entries(arg0);
|
|
1072
|
-
return ret;
|
|
1073
|
-
}
|
|
1074
|
-
export function __wbg_error_794d0ffc9d00d5c3(arg0, arg1, arg2, arg3) {
|
|
1075
|
-
console.error(arg0, arg1, arg2, arg3);
|
|
1076
|
-
}
|
|
1077
|
-
export function __wbg_getRandomValues_b3f15fcbfabb0f8b() { return handleError(function (arg0, arg1) {
|
|
1078
|
-
arg0.getRandomValues(arg1);
|
|
1079
|
-
}, arguments); }
|
|
1080
|
-
export function __wbg_getTime_1e3cd1391c5c3995(arg0) {
|
|
1081
|
-
const ret = arg0.getTime();
|
|
1082
|
-
return ret;
|
|
1083
|
-
}
|
|
1084
|
-
export function __wbg_getTimezoneOffset_81776d10a4ec18a8(arg0) {
|
|
1085
|
-
const ret = arg0.getTimezoneOffset();
|
|
1086
|
-
return ret;
|
|
1087
|
-
}
|
|
1088
|
-
export function __wbg_get_9b94d73e6221f75c(arg0, arg1) {
|
|
1089
|
-
const ret = arg0[arg1 >>> 0];
|
|
1090
|
-
return ret;
|
|
1091
|
-
}
|
|
1092
|
-
export function __wbg_get_b3ed3ad4be2bc8ac() { return handleError(function (arg0, arg1) {
|
|
1093
|
-
const ret = Reflect.get(arg0, arg1);
|
|
1094
|
-
return ret;
|
|
1095
|
-
}, arguments); }
|
|
1096
|
-
export function __wbg_get_with_ref_key_1dc361bd10053bfe(arg0, arg1) {
|
|
1097
|
-
const ret = arg0[arg1];
|
|
1098
|
-
return ret;
|
|
1099
|
-
}
|
|
1100
|
-
export function __wbg_info_9e602cf10c5c690b(arg0, arg1, arg2, arg3) {
|
|
1101
|
-
console.info(arg0, arg1, arg2, arg3);
|
|
1102
|
-
}
|
|
1103
|
-
export function __wbg_instanceof_ArrayBuffer_c367199e2fa2aa04(arg0) {
|
|
1104
|
-
let result;
|
|
1105
|
-
try {
|
|
1106
|
-
result = arg0 instanceof ArrayBuffer;
|
|
1107
|
-
} catch (_) {
|
|
1108
|
-
result = false;
|
|
1109
|
-
}
|
|
1110
|
-
const ret = result;
|
|
1111
|
-
return ret;
|
|
1112
|
-
}
|
|
1113
|
-
export function __wbg_instanceof_Map_53af74335dec57f4(arg0) {
|
|
1114
|
-
let result;
|
|
1115
|
-
try {
|
|
1116
|
-
result = arg0 instanceof Map;
|
|
1117
|
-
} catch (_) {
|
|
1118
|
-
result = false;
|
|
1119
|
-
}
|
|
1120
|
-
const ret = result;
|
|
1121
|
-
return ret;
|
|
1122
|
-
}
|
|
1123
|
-
export function __wbg_instanceof_Uint8Array_9b9075935c74707c(arg0) {
|
|
1124
|
-
let result;
|
|
1125
|
-
try {
|
|
1126
|
-
result = arg0 instanceof Uint8Array;
|
|
1127
|
-
} catch (_) {
|
|
1128
|
-
result = false;
|
|
1129
|
-
}
|
|
1130
|
-
const ret = result;
|
|
1131
|
-
return ret;
|
|
1132
|
-
}
|
|
1133
|
-
export function __wbg_isArray_d314bb98fcf08331(arg0) {
|
|
1134
|
-
const ret = Array.isArray(arg0);
|
|
1135
|
-
return ret;
|
|
1136
|
-
}
|
|
1137
|
-
export function __wbg_isSafeInteger_bfbc7332a9768d2a(arg0) {
|
|
1138
|
-
const ret = Number.isSafeInteger(arg0);
|
|
1139
|
-
return ret;
|
|
1140
|
-
}
|
|
1141
|
-
export function __wbg_iterator_6ff6560ca1568e55() {
|
|
1142
|
-
const ret = Symbol.iterator;
|
|
1143
|
-
return ret;
|
|
1144
|
-
}
|
|
1145
|
-
export function __wbg_length_32ed9a279acd054c(arg0) {
|
|
1146
|
-
const ret = arg0.length;
|
|
1147
|
-
return ret;
|
|
1148
|
-
}
|
|
1149
|
-
export function __wbg_length_35a7bace40f36eac(arg0) {
|
|
1150
|
-
const ret = arg0.length;
|
|
1151
|
-
return ret;
|
|
1152
|
-
}
|
|
1153
|
-
export function __wbg_log_24aba2a6d8990b35(arg0, arg1, arg2, arg3) {
|
|
1154
|
-
console.log(arg0, arg1, arg2, arg3);
|
|
1155
|
-
}
|
|
1156
|
-
export function __wbg_msCrypto_d562bbe83e0d4b91(arg0) {
|
|
1157
|
-
const ret = arg0.msCrypto;
|
|
1158
|
-
return ret;
|
|
1159
|
-
}
|
|
1160
|
-
export function __wbg_new_0_73afc35eb544e539() {
|
|
1161
|
-
const ret = new Date();
|
|
1162
|
-
return ret;
|
|
1163
|
-
}
|
|
1164
|
-
export function __wbg_new_245cd5c49157e602(arg0) {
|
|
1165
|
-
const ret = new Date(arg0);
|
|
1166
|
-
return ret;
|
|
1167
|
-
}
|
|
1168
|
-
export function __wbg_new_361308b2356cecd0() {
|
|
1169
|
-
const ret = new Object();
|
|
1170
|
-
return ret;
|
|
1171
|
-
}
|
|
1172
|
-
export function __wbg_new_3eb36ae241fe6f44() {
|
|
1173
|
-
const ret = new Array();
|
|
1174
|
-
return ret;
|
|
1175
|
-
}
|
|
1176
|
-
export function __wbg_new_b5d9e2fb389fef91(arg0, arg1) {
|
|
1177
|
-
try {
|
|
1178
|
-
var state0 = {a: arg0, b: arg1};
|
|
1179
|
-
var cb0 = (arg0, arg1) => {
|
|
1180
|
-
const a = state0.a;
|
|
1181
|
-
state0.a = 0;
|
|
1182
|
-
try {
|
|
1183
|
-
return wasm_bindgen__convert__closures_____invoke__h4ffe3e306d53c3fd(a, state0.b, arg0, arg1);
|
|
1184
|
-
} finally {
|
|
1185
|
-
state0.a = a;
|
|
1186
|
-
}
|
|
1187
|
-
};
|
|
1188
|
-
const ret = new Promise(cb0);
|
|
1189
|
-
return ret;
|
|
1190
|
-
} finally {
|
|
1191
|
-
state0.a = state0.b = 0;
|
|
1192
|
-
}
|
|
1193
|
-
}
|
|
1194
|
-
export function __wbg_new_dca287b076112a51() {
|
|
1195
|
-
const ret = new Map();
|
|
1196
|
-
return ret;
|
|
1197
|
-
}
|
|
1198
|
-
export function __wbg_new_dd2b680c8bf6ae29(arg0) {
|
|
1199
|
-
const ret = new Uint8Array(arg0);
|
|
1200
|
-
return ret;
|
|
1201
|
-
}
|
|
1202
|
-
export function __wbg_new_from_slice_a3d2629dc1826784(arg0, arg1) {
|
|
1203
|
-
const ret = new Uint8Array(getArrayU8FromWasm0(arg0, arg1));
|
|
1204
|
-
return ret;
|
|
1205
|
-
}
|
|
1206
|
-
export function __wbg_new_no_args_1c7c842f08d00ebb(arg0, arg1) {
|
|
1207
|
-
const ret = new Function(getStringFromWasm0(arg0, arg1));
|
|
1208
|
-
return ret;
|
|
1209
|
-
}
|
|
1210
|
-
export function __wbg_new_with_length_a2c39cbe88fd8ff1(arg0) {
|
|
1211
|
-
const ret = new Uint8Array(arg0 >>> 0);
|
|
1212
|
-
return ret;
|
|
1213
|
-
}
|
|
1214
|
-
export function __wbg_next_3482f54c49e8af19() { return handleError(function (arg0) {
|
|
1215
|
-
const ret = arg0.next();
|
|
1216
|
-
return ret;
|
|
1217
|
-
}, arguments); }
|
|
1218
|
-
export function __wbg_next_418f80d8f5303233(arg0) {
|
|
1219
|
-
const ret = arg0.next;
|
|
1220
|
-
return ret;
|
|
1221
|
-
}
|
|
1222
|
-
export function __wbg_node_e1f24f89a7336c2e(arg0) {
|
|
1223
|
-
const ret = arg0.node;
|
|
1224
|
-
return ret;
|
|
1225
|
-
}
|
|
1226
|
-
export function __wbg_parse_708461a1feddfb38() { return handleError(function (arg0, arg1) {
|
|
1227
|
-
const ret = JSON.parse(getStringFromWasm0(arg0, arg1));
|
|
1228
|
-
return ret;
|
|
1229
|
-
}, arguments); }
|
|
1230
|
-
export function __wbg_process_3975fd6c72f520aa(arg0) {
|
|
1231
|
-
const ret = arg0.process;
|
|
1232
|
-
return ret;
|
|
1233
|
-
}
|
|
1234
|
-
export function __wbg_prototypesetcall_bdcdcc5842e4d77d(arg0, arg1, arg2) {
|
|
1235
|
-
Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), arg2);
|
|
1236
|
-
}
|
|
1237
|
-
export function __wbg_queueMicrotask_0aa0a927f78f5d98(arg0) {
|
|
1238
|
-
const ret = arg0.queueMicrotask;
|
|
1239
|
-
return ret;
|
|
1240
|
-
}
|
|
1241
|
-
export function __wbg_queueMicrotask_5bb536982f78a56f(arg0) {
|
|
1242
|
-
queueMicrotask(arg0);
|
|
1243
|
-
}
|
|
1244
|
-
export function __wbg_randomFillSync_f8c153b79f285817() { return handleError(function (arg0, arg1) {
|
|
1245
|
-
arg0.randomFillSync(arg1);
|
|
1246
|
-
}, arguments); }
|
|
1247
|
-
export function __wbg_require_b74f47fc2d022fd6() { return handleError(function () {
|
|
1248
|
-
const ret = module.require;
|
|
1249
|
-
return ret;
|
|
1250
|
-
}, arguments); }
|
|
1251
|
-
export function __wbg_resolve_002c4b7d9d8f6b64(arg0) {
|
|
1252
|
-
const ret = Promise.resolve(arg0);
|
|
1253
|
-
return ret;
|
|
1254
|
-
}
|
|
1255
|
-
export function __wbg_set_1eb0999cf5d27fc8(arg0, arg1, arg2) {
|
|
1256
|
-
const ret = arg0.set(arg1, arg2);
|
|
1257
|
-
return ret;
|
|
1258
|
-
}
|
|
1259
|
-
export function __wbg_set_3f1d0b984ed272ed(arg0, arg1, arg2) {
|
|
1260
|
-
arg0[arg1] = arg2;
|
|
1261
|
-
}
|
|
1262
|
-
export function __wbg_set_6cb8631f80447a67() { return handleError(function (arg0, arg1, arg2) {
|
|
1263
|
-
const ret = Reflect.set(arg0, arg1, arg2);
|
|
1264
|
-
return ret;
|
|
1265
|
-
}, arguments); }
|
|
1266
|
-
export function __wbg_set_f43e577aea94465b(arg0, arg1, arg2) {
|
|
1267
|
-
arg0[arg1 >>> 0] = arg2;
|
|
1268
|
-
}
|
|
1269
|
-
export function __wbg_static_accessor_GLOBAL_12837167ad935116() {
|
|
1270
|
-
const ret = typeof global === 'undefined' ? null : global;
|
|
1271
|
-
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
|
1272
|
-
}
|
|
1273
|
-
export function __wbg_static_accessor_GLOBAL_THIS_e628e89ab3b1c95f() {
|
|
1274
|
-
const ret = typeof globalThis === 'undefined' ? null : globalThis;
|
|
1275
|
-
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
|
1276
|
-
}
|
|
1277
|
-
export function __wbg_static_accessor_SELF_a621d3dfbb60d0ce() {
|
|
1278
|
-
const ret = typeof self === 'undefined' ? null : self;
|
|
1279
|
-
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
|
1280
|
-
}
|
|
1281
|
-
export function __wbg_static_accessor_WINDOW_f8727f0cf888e0bd() {
|
|
1282
|
-
const ret = typeof window === 'undefined' ? null : window;
|
|
1283
|
-
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
|
1284
|
-
}
|
|
1285
|
-
export function __wbg_stringify_8d1cc6ff383e8bae() { return handleError(function (arg0) {
|
|
1286
|
-
const ret = JSON.stringify(arg0);
|
|
1287
|
-
return ret;
|
|
1288
|
-
}, arguments); }
|
|
1289
|
-
export function __wbg_subarray_a96e1fef17ed23cb(arg0, arg1, arg2) {
|
|
1290
|
-
const ret = arg0.subarray(arg1 >>> 0, arg2 >>> 0);
|
|
1291
|
-
return ret;
|
|
1292
|
-
}
|
|
1293
|
-
export function __wbg_then_b9e7b3b5f1a9e1b5(arg0, arg1) {
|
|
1294
|
-
const ret = arg0.then(arg1);
|
|
1295
|
-
return ret;
|
|
1296
|
-
}
|
|
1297
|
-
export function __wbg_value_0546255b415e96c1(arg0) {
|
|
1298
|
-
const ret = arg0.value;
|
|
1299
|
-
return ret;
|
|
1300
|
-
}
|
|
1301
|
-
export function __wbg_versions_4e31226f5e8dc909(arg0) {
|
|
1302
|
-
const ret = arg0.versions;
|
|
1303
|
-
return ret;
|
|
1304
|
-
}
|
|
1305
|
-
export function __wbg_warn_a40b971467b219c7(arg0, arg1, arg2, arg3) {
|
|
1306
|
-
console.warn(arg0, arg1, arg2, arg3);
|
|
1307
|
-
}
|
|
1308
|
-
export function __wbindgen_cast_0000000000000001(arg0, arg1) {
|
|
1309
|
-
// Cast intrinsic for `Closure(Closure { dtor_idx: 550, function: Function { arguments: [Externref], shim_idx: 551, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
|
|
1310
|
-
const ret = makeMutClosure(arg0, arg1, wasm.wasm_bindgen__closure__destroy__hcf0c613855ef990f, wasm_bindgen__convert__closures_____invoke__hf4ed7050e4f49b30);
|
|
1311
|
-
return ret;
|
|
1312
|
-
}
|
|
1313
|
-
export function __wbindgen_cast_0000000000000002(arg0) {
|
|
1314
|
-
// Cast intrinsic for `F64 -> Externref`.
|
|
1315
|
-
const ret = arg0;
|
|
1316
|
-
return ret;
|
|
1317
|
-
}
|
|
1318
|
-
export function __wbindgen_cast_0000000000000003(arg0) {
|
|
1319
|
-
// Cast intrinsic for `I64 -> Externref`.
|
|
1320
|
-
const ret = arg0;
|
|
1321
|
-
return ret;
|
|
1322
|
-
}
|
|
1323
|
-
export function __wbindgen_cast_0000000000000004(arg0, arg1) {
|
|
1324
|
-
// Cast intrinsic for `Ref(Slice(U8)) -> NamedExternref("Uint8Array")`.
|
|
1325
|
-
const ret = getArrayU8FromWasm0(arg0, arg1);
|
|
1326
|
-
return ret;
|
|
1327
|
-
}
|
|
1328
|
-
export function __wbindgen_cast_0000000000000005(arg0, arg1) {
|
|
1329
|
-
// Cast intrinsic for `Ref(String) -> Externref`.
|
|
1330
|
-
const ret = getStringFromWasm0(arg0, arg1);
|
|
1331
|
-
return ret;
|
|
1332
|
-
}
|
|
1333
|
-
export function __wbindgen_cast_0000000000000006(arg0) {
|
|
1334
|
-
// Cast intrinsic for `U64 -> Externref`.
|
|
1335
|
-
const ret = BigInt.asUintN(64, arg0);
|
|
1336
|
-
return ret;
|
|
1337
|
-
}
|
|
1338
|
-
export function __wbindgen_init_externref_table() {
|
|
1339
|
-
const table = wasm.__wbindgen_externrefs;
|
|
1340
|
-
const offset = table.grow(4);
|
|
1341
|
-
table.set(0, undefined);
|
|
1342
|
-
table.set(offset + 0, undefined);
|
|
1343
|
-
table.set(offset + 1, null);
|
|
1344
|
-
table.set(offset + 2, true);
|
|
1345
|
-
table.set(offset + 3, false);
|
|
1346
|
-
}
|
|
1347
|
-
function wasm_bindgen__convert__closures_____invoke__hf4ed7050e4f49b30(arg0, arg1, arg2) {
|
|
1348
|
-
wasm.wasm_bindgen__convert__closures_____invoke__hf4ed7050e4f49b30(arg0, arg1, arg2);
|
|
1349
|
-
}
|
|
1350
|
-
|
|
1351
|
-
function wasm_bindgen__convert__closures_____invoke__h4ffe3e306d53c3fd(arg0, arg1, arg2, arg3) {
|
|
1352
|
-
wasm.wasm_bindgen__convert__closures_____invoke__h4ffe3e306d53c3fd(arg0, arg1, arg2, arg3);
|
|
1353
|
-
}
|
|
1354
|
-
|
|
1355
|
-
const DiaryxBackendFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
1356
|
-
? { register: () => {}, unregister: () => {} }
|
|
1357
|
-
: new FinalizationRegistry(ptr => wasm.__wbg_diaryxbackend_free(ptr >>> 0, 1));
|
|
1358
|
-
const JsAsyncFileSystemFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
1359
|
-
? { register: () => {}, unregister: () => {} }
|
|
1360
|
-
: new FinalizationRegistry(ptr => wasm.__wbg_jsasyncfilesystem_free(ptr >>> 0, 1));
|
|
1361
|
-
const WasmSyncClientFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
1362
|
-
? { register: () => {}, unregister: () => {} }
|
|
1363
|
-
: new FinalizationRegistry(ptr => wasm.__wbg_wasmsyncclient_free(ptr >>> 0, 1));
|
|
1364
|
-
|
|
1365
|
-
function addToExternrefTable0(obj) {
|
|
1366
|
-
const idx = wasm.__externref_table_alloc();
|
|
1367
|
-
wasm.__wbindgen_externrefs.set(idx, obj);
|
|
1368
|
-
return idx;
|
|
1369
|
-
}
|
|
1370
|
-
|
|
1371
|
-
const CLOSURE_DTORS = (typeof FinalizationRegistry === 'undefined')
|
|
1372
|
-
? { register: () => {}, unregister: () => {} }
|
|
1373
|
-
: new FinalizationRegistry(state => state.dtor(state.a, state.b));
|
|
1374
|
-
|
|
1375
|
-
function debugString(val) {
|
|
1376
|
-
// primitive types
|
|
1377
|
-
const type = typeof val;
|
|
1378
|
-
if (type == 'number' || type == 'boolean' || val == null) {
|
|
1379
|
-
return `${val}`;
|
|
1380
|
-
}
|
|
1381
|
-
if (type == 'string') {
|
|
1382
|
-
return `"${val}"`;
|
|
1383
|
-
}
|
|
1384
|
-
if (type == 'symbol') {
|
|
1385
|
-
const description = val.description;
|
|
1386
|
-
if (description == null) {
|
|
1387
|
-
return 'Symbol';
|
|
1388
|
-
} else {
|
|
1389
|
-
return `Symbol(${description})`;
|
|
1390
|
-
}
|
|
1391
|
-
}
|
|
1392
|
-
if (type == 'function') {
|
|
1393
|
-
const name = val.name;
|
|
1394
|
-
if (typeof name == 'string' && name.length > 0) {
|
|
1395
|
-
return `Function(${name})`;
|
|
1396
|
-
} else {
|
|
1397
|
-
return 'Function';
|
|
1398
|
-
}
|
|
1399
|
-
}
|
|
1400
|
-
// objects
|
|
1401
|
-
if (Array.isArray(val)) {
|
|
1402
|
-
const length = val.length;
|
|
1403
|
-
let debug = '[';
|
|
1404
|
-
if (length > 0) {
|
|
1405
|
-
debug += debugString(val[0]);
|
|
1406
|
-
}
|
|
1407
|
-
for(let i = 1; i < length; i++) {
|
|
1408
|
-
debug += ', ' + debugString(val[i]);
|
|
1409
|
-
}
|
|
1410
|
-
debug += ']';
|
|
1411
|
-
return debug;
|
|
1412
|
-
}
|
|
1413
|
-
// Test for built-in
|
|
1414
|
-
const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val));
|
|
1415
|
-
let className;
|
|
1416
|
-
if (builtInMatches && builtInMatches.length > 1) {
|
|
1417
|
-
className = builtInMatches[1];
|
|
1418
|
-
} else {
|
|
1419
|
-
// Failed to match the standard '[object ClassName]'
|
|
1420
|
-
return toString.call(val);
|
|
1421
|
-
}
|
|
1422
|
-
if (className == 'Object') {
|
|
1423
|
-
// we're a user defined class or Object
|
|
1424
|
-
// JSON.stringify avoids problems with cycles, and is generally much
|
|
1425
|
-
// easier than looping through ownProperties of `val`.
|
|
1426
|
-
try {
|
|
1427
|
-
return 'Object(' + JSON.stringify(val) + ')';
|
|
1428
|
-
} catch (_) {
|
|
1429
|
-
return 'Object';
|
|
1430
|
-
}
|
|
1431
|
-
}
|
|
1432
|
-
// errors
|
|
1433
|
-
if (val instanceof Error) {
|
|
1434
|
-
return `${val.name}: ${val.message}\n${val.stack}`;
|
|
1435
|
-
}
|
|
1436
|
-
// TODO we could test for more things here, like `Set`s and `Map`s.
|
|
1437
|
-
return className;
|
|
1438
|
-
}
|
|
1439
|
-
|
|
1440
|
-
function getArrayU8FromWasm0(ptr, len) {
|
|
1441
|
-
ptr = ptr >>> 0;
|
|
1442
|
-
return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
|
|
1443
|
-
}
|
|
1444
|
-
|
|
1445
|
-
let cachedDataViewMemory0 = null;
|
|
1446
|
-
function getDataViewMemory0() {
|
|
1447
|
-
if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
|
|
1448
|
-
cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
|
|
1449
|
-
}
|
|
1450
|
-
return cachedDataViewMemory0;
|
|
1451
|
-
}
|
|
1452
|
-
|
|
1453
|
-
function getStringFromWasm0(ptr, len) {
|
|
1454
|
-
ptr = ptr >>> 0;
|
|
1455
|
-
return decodeText(ptr, len);
|
|
1456
|
-
}
|
|
1457
|
-
|
|
1458
|
-
let cachedUint8ArrayMemory0 = null;
|
|
1459
|
-
function getUint8ArrayMemory0() {
|
|
1460
|
-
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
|
|
1461
|
-
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
|
|
1462
|
-
}
|
|
1463
|
-
return cachedUint8ArrayMemory0;
|
|
1464
|
-
}
|
|
1465
|
-
|
|
1466
|
-
function handleError(f, args) {
|
|
1467
|
-
try {
|
|
1468
|
-
return f.apply(this, args);
|
|
1469
|
-
} catch (e) {
|
|
1470
|
-
const idx = addToExternrefTable0(e);
|
|
1471
|
-
wasm.__wbindgen_exn_store(idx);
|
|
1472
|
-
}
|
|
1473
|
-
}
|
|
1474
|
-
|
|
1475
|
-
function isLikeNone(x) {
|
|
1476
|
-
return x === undefined || x === null;
|
|
1477
|
-
}
|
|
1478
|
-
|
|
1479
|
-
function makeMutClosure(arg0, arg1, dtor, f) {
|
|
1480
|
-
const state = { a: arg0, b: arg1, cnt: 1, dtor };
|
|
1481
|
-
const real = (...args) => {
|
|
1482
|
-
|
|
1483
|
-
// First up with a closure we increment the internal reference
|
|
1484
|
-
// count. This ensures that the Rust closure environment won't
|
|
1485
|
-
// be deallocated while we're invoking it.
|
|
1486
|
-
state.cnt++;
|
|
1487
|
-
const a = state.a;
|
|
1488
|
-
state.a = 0;
|
|
1489
|
-
try {
|
|
1490
|
-
return f(a, state.b, ...args);
|
|
1491
|
-
} finally {
|
|
1492
|
-
state.a = a;
|
|
1493
|
-
real._wbg_cb_unref();
|
|
1494
|
-
}
|
|
1495
|
-
};
|
|
1496
|
-
real._wbg_cb_unref = () => {
|
|
1497
|
-
if (--state.cnt === 0) {
|
|
1498
|
-
state.dtor(state.a, state.b);
|
|
1499
|
-
state.a = 0;
|
|
1500
|
-
CLOSURE_DTORS.unregister(state);
|
|
1501
|
-
}
|
|
1502
|
-
};
|
|
1503
|
-
CLOSURE_DTORS.register(real, state, state);
|
|
1504
|
-
return real;
|
|
1505
|
-
}
|
|
1506
|
-
|
|
1507
|
-
function passArray8ToWasm0(arg, malloc) {
|
|
1508
|
-
const ptr = malloc(arg.length * 1, 1) >>> 0;
|
|
1509
|
-
getUint8ArrayMemory0().set(arg, ptr / 1);
|
|
1510
|
-
WASM_VECTOR_LEN = arg.length;
|
|
1511
|
-
return ptr;
|
|
1512
|
-
}
|
|
1513
|
-
|
|
1514
|
-
function passArrayJsValueToWasm0(array, malloc) {
|
|
1515
|
-
const ptr = malloc(array.length * 4, 4) >>> 0;
|
|
1516
|
-
for (let i = 0; i < array.length; i++) {
|
|
1517
|
-
const add = addToExternrefTable0(array[i]);
|
|
1518
|
-
getDataViewMemory0().setUint32(ptr + 4 * i, add, true);
|
|
1519
|
-
}
|
|
1520
|
-
WASM_VECTOR_LEN = array.length;
|
|
1521
|
-
return ptr;
|
|
1522
|
-
}
|
|
1523
|
-
|
|
1524
|
-
function passStringToWasm0(arg, malloc, realloc) {
|
|
1525
|
-
if (realloc === undefined) {
|
|
1526
|
-
const buf = cachedTextEncoder.encode(arg);
|
|
1527
|
-
const ptr = malloc(buf.length, 1) >>> 0;
|
|
1528
|
-
getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
|
|
1529
|
-
WASM_VECTOR_LEN = buf.length;
|
|
1530
|
-
return ptr;
|
|
1531
|
-
}
|
|
1532
|
-
|
|
1533
|
-
let len = arg.length;
|
|
1534
|
-
let ptr = malloc(len, 1) >>> 0;
|
|
1535
|
-
|
|
1536
|
-
const mem = getUint8ArrayMemory0();
|
|
1537
|
-
|
|
1538
|
-
let offset = 0;
|
|
1539
|
-
|
|
1540
|
-
for (; offset < len; offset++) {
|
|
1541
|
-
const code = arg.charCodeAt(offset);
|
|
1542
|
-
if (code > 0x7F) break;
|
|
1543
|
-
mem[ptr + offset] = code;
|
|
1544
|
-
}
|
|
1545
|
-
if (offset !== len) {
|
|
1546
|
-
if (offset !== 0) {
|
|
1547
|
-
arg = arg.slice(offset);
|
|
1548
|
-
}
|
|
1549
|
-
ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
|
|
1550
|
-
const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
|
|
1551
|
-
const ret = cachedTextEncoder.encodeInto(arg, view);
|
|
1552
|
-
|
|
1553
|
-
offset += ret.written;
|
|
1554
|
-
ptr = realloc(ptr, len, offset, 1) >>> 0;
|
|
1555
|
-
}
|
|
1556
|
-
|
|
1557
|
-
WASM_VECTOR_LEN = offset;
|
|
1558
|
-
return ptr;
|
|
1559
|
-
}
|
|
1560
|
-
|
|
1561
|
-
function takeFromExternrefTable0(idx) {
|
|
1562
|
-
const value = wasm.__wbindgen_externrefs.get(idx);
|
|
1563
|
-
wasm.__externref_table_dealloc(idx);
|
|
1564
|
-
return value;
|
|
1565
|
-
}
|
|
1566
|
-
|
|
1567
|
-
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
1568
|
-
cachedTextDecoder.decode();
|
|
1569
|
-
const MAX_SAFARI_DECODE_BYTES = 2146435072;
|
|
1570
|
-
let numBytesDecoded = 0;
|
|
1571
|
-
function decodeText(ptr, len) {
|
|
1572
|
-
numBytesDecoded += len;
|
|
1573
|
-
if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
|
|
1574
|
-
cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
1575
|
-
cachedTextDecoder.decode();
|
|
1576
|
-
numBytesDecoded = len;
|
|
1577
|
-
}
|
|
1578
|
-
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
|
1579
|
-
}
|
|
1580
|
-
|
|
1581
|
-
const cachedTextEncoder = new TextEncoder();
|
|
1582
|
-
|
|
1583
|
-
if (!('encodeInto' in cachedTextEncoder)) {
|
|
1584
|
-
cachedTextEncoder.encodeInto = function (arg, view) {
|
|
1585
|
-
const buf = cachedTextEncoder.encode(arg);
|
|
1586
|
-
view.set(buf);
|
|
1587
|
-
return {
|
|
1588
|
-
read: arg.length,
|
|
1589
|
-
written: buf.length
|
|
1590
|
-
};
|
|
1591
|
-
};
|
|
1592
|
-
}
|
|
1593
|
-
|
|
1594
|
-
let WASM_VECTOR_LEN = 0;
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
let wasm;
|
|
1598
|
-
export function __wbg_set_wasm(val) {
|
|
1599
|
-
wasm = val;
|
|
1600
|
-
}
|