@diaryx/wasm-node 0.11.0-dev.449d9b2

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