@diaryx/wasm 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,2255 @@
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 from a user-selected directory handle.
53
+ *
54
+ * This uses the File System Access API to read/write files directly
55
+ * on the user's filesystem. The handle must be obtained from
56
+ * `window.showDirectoryPicker()` in JavaScript.
57
+ *
58
+ * ## Browser Support
59
+ * - Chrome/Edge: ✅ Supported
60
+ * - Firefox: ❌ Not supported
61
+ * - Safari: ❌ Not supported
62
+ *
63
+ * ## Example
64
+ * ```javascript
65
+ * // User must trigger this via a gesture (click/keypress)
66
+ * const dirHandle = await window.showDirectoryPicker();
67
+ * const backend = await DiaryxBackend.createFromDirectoryHandle(dirHandle);
68
+ * ```
69
+ * @param {FileSystemDirectoryHandle} handle
70
+ * @returns {DiaryxBackend}
71
+ */
72
+ static createFromDirectoryHandle(handle) {
73
+ const ret = wasm.diaryxbackend_createFromDirectoryHandle(handle);
74
+ if (ret[2]) {
75
+ throw takeFromExternrefTable0(ret[1]);
76
+ }
77
+ return DiaryxBackend.__wrap(ret[0]);
78
+ }
79
+ /**
80
+ * Create a new DiaryxBackend with in-memory storage.
81
+ *
82
+ * This is used for guest mode in share sessions. Files are stored
83
+ * only in memory and are cleared when the session ends.
84
+ *
85
+ * ## Use Cases
86
+ * - Guest mode in share sessions (web)
87
+ * - Testing
88
+ *
89
+ * ## Example
90
+ * ```javascript
91
+ * const backend = DiaryxBackend.createInMemory();
92
+ * // Files are stored in memory only
93
+ * ```
94
+ * @returns {DiaryxBackend}
95
+ */
96
+ static createInMemory() {
97
+ const ret = wasm.diaryxbackend_createInMemory();
98
+ if (ret[2]) {
99
+ throw takeFromExternrefTable0(ret[1]);
100
+ }
101
+ return DiaryxBackend.__wrap(ret[0]);
102
+ }
103
+ /**
104
+ * Create a new DiaryxBackend with IndexedDB storage.
105
+ *
106
+ * This attempts to use persistent SQLite-based CRDT storage (via sql.js).
107
+ * If SQLite storage is not available, falls back to in-memory CRDT storage.
108
+ * @returns {Promise<DiaryxBackend>}
109
+ */
110
+ static createIndexedDb() {
111
+ const ret = wasm.diaryxbackend_createIndexedDb();
112
+ return ret;
113
+ }
114
+ /**
115
+ * Create a new DiaryxBackend with OPFS storage.
116
+ *
117
+ * This attempts to use persistent SQLite-based CRDT storage (via sql.js).
118
+ * If SQLite storage is not available (JS bridge not initialized), falls back
119
+ * to in-memory CRDT storage.
120
+ *
121
+ * For persistent CRDT storage, call `initializeSqliteStorage()` in JavaScript
122
+ * before creating the backend:
123
+ *
124
+ * ```javascript
125
+ * import { initializeSqliteStorage } from './lib/storage/sqliteStorageBridge.js';
126
+ * await initializeSqliteStorage();
127
+ * const backend = await DiaryxBackend.createOpfs();
128
+ * ```
129
+ * @returns {Promise<DiaryxBackend>}
130
+ */
131
+ static createOpfs() {
132
+ const ret = wasm.diaryxbackend_createOpfs();
133
+ return ret;
134
+ }
135
+ /**
136
+ * Create a new sync client for the given server and workspace.
137
+ *
138
+ * This creates a `WasmSyncClient` that wraps `SyncClient<CallbackTransport>`.
139
+ * JavaScript manages WebSocket connections while Rust handles all sync logic.
140
+ *
141
+ * ## Example
142
+ *
143
+ * ```javascript
144
+ * const client = backend.createSyncClient(
145
+ * 'wss://sync.example.com/sync',
146
+ * 'my-workspace-id',
147
+ * 'auth-token-optional'
148
+ * );
149
+ *
150
+ * // Get URLs and create WebSocket connections
151
+ * const metaUrl = client.getMetadataUrl();
152
+ * const bodyUrl = client.getBodyUrl();
153
+ *
154
+ * // Create WebSockets and connect them to the client
155
+ * const metaWs = new WebSocket(metaUrl);
156
+ * metaWs.binaryType = 'arraybuffer';
157
+ * metaWs.onopen = () => client.markMetadataConnected();
158
+ * metaWs.onclose = () => client.markMetadataDisconnected();
159
+ * metaWs.onmessage = async (e) => {
160
+ * const response = await client.injectMetadataMessage(new Uint8Array(e.data));
161
+ * if (response) metaWs.send(response);
162
+ * };
163
+ * // Similar for body WebSocket...
164
+ *
165
+ * // Poll for outgoing messages
166
+ * setInterval(() => {
167
+ * let msg;
168
+ * while ((msg = client.pollMetadataOutgoing())) metaWs.send(msg);
169
+ * while ((msg = client.pollBodyOutgoing())) bodyWs.send(msg);
170
+ * }, 50);
171
+ *
172
+ * // Start sync
173
+ * await client.start();
174
+ * ```
175
+ * @param {string} server_url
176
+ * @param {string} workspace_id
177
+ * @param {string | null} [auth_token]
178
+ * @returns {WasmSyncClient}
179
+ */
180
+ createSyncClient(server_url, workspace_id, auth_token) {
181
+ const ptr0 = passStringToWasm0(server_url, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
182
+ const len0 = WASM_VECTOR_LEN;
183
+ const ptr1 = passStringToWasm0(workspace_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
184
+ const len1 = WASM_VECTOR_LEN;
185
+ var ptr2 = isLikeNone(auth_token) ? 0 : passStringToWasm0(auth_token, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
186
+ var len2 = WASM_VECTOR_LEN;
187
+ const ret = wasm.diaryxbackend_createSyncClient(this.__wbg_ptr, ptr0, len0, ptr1, len1, ptr2, len2);
188
+ return WasmSyncClient.__wrap(ret);
189
+ }
190
+ /**
191
+ * Emit a filesystem event.
192
+ *
193
+ * This is primarily used internally but can be called from JavaScript
194
+ * to manually trigger events (e.g., for testing or manual sync scenarios).
195
+ *
196
+ * The event should be a JSON string matching the FileSystemEvent format.
197
+ *
198
+ * ## Example
199
+ *
200
+ * ```javascript
201
+ * backend.emitFileSystemEvent(JSON.stringify({
202
+ * type: 'FileCreated',
203
+ * path: 'workspace/notes.md',
204
+ * frontmatter: { title: 'Notes' }
205
+ * }));
206
+ * ```
207
+ * @param {string} event_json
208
+ */
209
+ emitFileSystemEvent(event_json) {
210
+ const ptr0 = passStringToWasm0(event_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
211
+ const len0 = WASM_VECTOR_LEN;
212
+ const ret = wasm.diaryxbackend_emitFileSystemEvent(this.__wbg_ptr, ptr0, len0);
213
+ if (ret[1]) {
214
+ throw takeFromExternrefTable0(ret[0]);
215
+ }
216
+ }
217
+ /**
218
+ * Get the number of active event subscriptions.
219
+ * @returns {number}
220
+ */
221
+ eventSubscriberCount() {
222
+ const ret = wasm.diaryxbackend_eventSubscriberCount(this.__wbg_ptr);
223
+ return ret >>> 0;
224
+ }
225
+ /**
226
+ * Execute a command and return the response as JSON string.
227
+ *
228
+ * This is the primary unified API for all operations.
229
+ *
230
+ * ## Example
231
+ * ```javascript
232
+ * const command = { type: 'GetEntry', params: { path: 'workspace/notes.md' } };
233
+ * const responseJson = await backend.execute(JSON.stringify(command));
234
+ * const response = JSON.parse(responseJson);
235
+ * ```
236
+ * @param {string} command_json
237
+ * @returns {Promise<string>}
238
+ */
239
+ execute(command_json) {
240
+ const ptr0 = passStringToWasm0(command_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
241
+ const len0 = WASM_VECTOR_LEN;
242
+ const ret = wasm.diaryxbackend_execute(this.__wbg_ptr, ptr0, len0);
243
+ return ret;
244
+ }
245
+ /**
246
+ * Execute a command from a JavaScript object directly.
247
+ *
248
+ * This avoids JSON serialization overhead for better performance.
249
+ * @param {any} command
250
+ * @returns {Promise<any>}
251
+ */
252
+ executeJs(command) {
253
+ const ret = wasm.diaryxbackend_executeJs(this.__wbg_ptr, command);
254
+ return ret;
255
+ }
256
+ /**
257
+ * Get initial body sync step1 message for a document.
258
+ *
259
+ * Returns a Uint8Array containing the Y-sync step1 message for
260
+ * the specified document's body content.
261
+ *
262
+ * ## Example
263
+ * ```javascript
264
+ * const step1 = backend.getBodySyncStep1("notes/my-note.md");
265
+ * // Frame it for multiplexed connection and send
266
+ * ```
267
+ * @param {string} doc_name
268
+ * @returns {Uint8Array}
269
+ */
270
+ getBodySyncStep1(doc_name) {
271
+ const ptr0 = passStringToWasm0(doc_name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
272
+ const len0 = WASM_VECTOR_LEN;
273
+ const ret = wasm.diaryxbackend_getBodySyncStep1(this.__wbg_ptr, ptr0, len0);
274
+ return ret;
275
+ }
276
+ /**
277
+ * Get the current configuration from root index frontmatter.
278
+ * Config keys are stored as `diaryx_*` properties.
279
+ * @returns {Promise<any>}
280
+ */
281
+ getConfig() {
282
+ const ret = wasm.diaryxbackend_getConfig(this.__wbg_ptr);
283
+ return ret;
284
+ }
285
+ /**
286
+ * Get initial workspace sync step1 message.
287
+ *
288
+ * Returns a Uint8Array containing the Y-sync step1 message to send
289
+ * over the WebSocket to initiate workspace metadata sync.
290
+ *
291
+ * ## Example
292
+ * ```javascript
293
+ * const step1 = backend.getWorkspaceSyncStep1();
294
+ * ws.send(step1);
295
+ * ```
296
+ * @returns {Uint8Array}
297
+ */
298
+ getWorkspaceSyncStep1() {
299
+ const ret = wasm.diaryxbackend_getWorkspaceSyncStep1(this.__wbg_ptr);
300
+ return ret;
301
+ }
302
+ /**
303
+ * Check if this backend has native sync support.
304
+ *
305
+ * For WASM, this always returns false. The new `createSyncClient()` API
306
+ * provides a unified approach that works across all platforms.
307
+ * @returns {boolean}
308
+ */
309
+ hasNativeSync() {
310
+ const ret = wasm.diaryxbackend_hasNativeSync(this.__wbg_ptr);
311
+ return ret !== 0;
312
+ }
313
+ /**
314
+ * Check if there are pending outgoing sync messages.
315
+ * @returns {boolean}
316
+ */
317
+ hasOutgoingSyncMessages() {
318
+ const ret = wasm.diaryxbackend_hasOutgoingSyncMessages(this.__wbg_ptr);
319
+ return ret !== 0;
320
+ }
321
+ /**
322
+ * Inject an incoming body sync message.
323
+ *
324
+ * Call this when the WebSocket receives a message for a body document.
325
+ * The message should already be unframed (doc_name extracted separately).
326
+ * Returns a response message to send back, or null if no response is needed.
327
+ *
328
+ * ## Example
329
+ * ```javascript
330
+ * // After unframing the multiplexed message:
331
+ * const response = await backend.injectBodySyncMessage(docName, data, true);
332
+ * if (response) ws.send(frameBodyMessage(docName, response));
333
+ * ```
334
+ * @param {string} doc_name
335
+ * @param {Uint8Array} message
336
+ * @param {boolean} write_to_disk
337
+ * @returns {Promise<any>}
338
+ */
339
+ injectBodySyncMessage(doc_name, message, write_to_disk) {
340
+ const ptr0 = passStringToWasm0(doc_name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
341
+ const len0 = WASM_VECTOR_LEN;
342
+ const ptr1 = passArray8ToWasm0(message, wasm.__wbindgen_malloc);
343
+ const len1 = WASM_VECTOR_LEN;
344
+ const ret = wasm.diaryxbackend_injectBodySyncMessage(this.__wbg_ptr, ptr0, len0, ptr1, len1, write_to_disk);
345
+ return ret;
346
+ }
347
+ /**
348
+ * Inject an incoming workspace sync message.
349
+ *
350
+ * Call this when the WebSocket receives a message for the workspace
351
+ * (metadata) connection. Returns a response message to send back,
352
+ * or null if no response is needed.
353
+ *
354
+ * ## Example
355
+ * ```javascript
356
+ * ws.onmessage = (event) => {
357
+ * const data = new Uint8Array(event.data);
358
+ * const response = backend.injectWorkspaceSyncMessage(data, true);
359
+ * if (response) ws.send(response);
360
+ * };
361
+ * ```
362
+ * @param {Uint8Array} message
363
+ * @param {boolean} write_to_disk
364
+ * @returns {Promise<any>}
365
+ */
366
+ injectWorkspaceSyncMessage(message, write_to_disk) {
367
+ const ptr0 = passArray8ToWasm0(message, wasm.__wbindgen_malloc);
368
+ const len0 = WASM_VECTOR_LEN;
369
+ const ret = wasm.diaryxbackend_injectWorkspaceSyncMessage(this.__wbg_ptr, ptr0, len0, write_to_disk);
370
+ return ret;
371
+ }
372
+ /**
373
+ * Unsubscribe from filesystem events.
374
+ *
375
+ * Returns `true` if the subscription was found and removed.
376
+ *
377
+ * ## Example
378
+ *
379
+ * ```javascript
380
+ * const id = backend.onFileSystemEvent(handler);
381
+ * // ... later ...
382
+ * const removed = backend.offFileSystemEvent(id);
383
+ * console.log('Subscription removed:', removed);
384
+ * ```
385
+ * @param {bigint} id
386
+ * @returns {boolean}
387
+ */
388
+ offFileSystemEvent(id) {
389
+ const ret = wasm.diaryxbackend_offFileSystemEvent(this.__wbg_ptr, id);
390
+ return ret !== 0;
391
+ }
392
+ /**
393
+ * Subscribe to filesystem events.
394
+ *
395
+ * The callback will be invoked with a JSON-serialized FileSystemEvent
396
+ * whenever filesystem operations occur (create, delete, rename, move, etc.).
397
+ *
398
+ * Returns a subscription ID that can be used to unsubscribe later.
399
+ *
400
+ * ## Example
401
+ *
402
+ * ```javascript
403
+ * const id = backend.onFileSystemEvent((eventJson) => {
404
+ * const event = JSON.parse(eventJson);
405
+ * console.log('File event:', event.type, event.path);
406
+ * });
407
+ *
408
+ * // Later, to unsubscribe:
409
+ * backend.offFileSystemEvent(id);
410
+ * ```
411
+ * @param {Function} callback
412
+ * @returns {bigint}
413
+ */
414
+ onFileSystemEvent(callback) {
415
+ const ret = wasm.diaryxbackend_onFileSystemEvent(this.__wbg_ptr, callback);
416
+ return BigInt.asUintN(64, ret);
417
+ }
418
+ /**
419
+ * Get count of pending outgoing sync messages.
420
+ * @returns {number}
421
+ */
422
+ outgoingSyncMessageCount() {
423
+ const ret = wasm.diaryxbackend_outgoingSyncMessageCount(this.__wbg_ptr);
424
+ return ret >>> 0;
425
+ }
426
+ /**
427
+ * Poll for an outgoing sync message.
428
+ *
429
+ * Returns the next outgoing message as a JavaScript object with:
430
+ * - `docName`: Document name ("workspace" or file path)
431
+ * - `message`: Uint8Array message data
432
+ * - `isBody`: Boolean indicating body (true) or workspace (false)
433
+ *
434
+ * Returns null if no messages are queued.
435
+ *
436
+ * ## Example
437
+ * ```javascript
438
+ * setInterval(() => {
439
+ * let msg;
440
+ * while ((msg = backend.pollOutgoingSyncMessage()) !== null) {
441
+ * if (msg.isBody) {
442
+ * bodyWs.send(frameBodyMessage(msg.docName, msg.message));
443
+ * } else {
444
+ * workspaceWs.send(msg.message);
445
+ * }
446
+ * }
447
+ * }, 50);
448
+ * ```
449
+ * @returns {any}
450
+ */
451
+ pollOutgoingSyncMessage() {
452
+ const ret = wasm.diaryxbackend_pollOutgoingSyncMessage(this.__wbg_ptr);
453
+ return ret;
454
+ }
455
+ /**
456
+ * Read binary file.
457
+ *
458
+ * Returns data as Uint8Array for efficient handling without base64 encoding.
459
+ * @param {string} path
460
+ * @returns {Promise<any>}
461
+ */
462
+ readBinary(path) {
463
+ const ptr0 = passStringToWasm0(path, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
464
+ const len0 = WASM_VECTOR_LEN;
465
+ const ret = wasm.diaryxbackend_readBinary(this.__wbg_ptr, ptr0, len0);
466
+ return ret;
467
+ }
468
+ /**
469
+ * Save configuration to root index frontmatter.
470
+ * Config keys are stored as `diaryx_*` properties.
471
+ * @param {any} config_js
472
+ * @returns {Promise<any>}
473
+ */
474
+ saveConfig(config_js) {
475
+ const ret = wasm.diaryxbackend_saveConfig(this.__wbg_ptr, config_js);
476
+ return ret;
477
+ }
478
+ /**
479
+ * Start sync session and set up event bridge.
480
+ *
481
+ * This wires up the sync manager's event callback to queue outgoing
482
+ * messages. Call this before connecting WebSocket.
483
+ *
484
+ * ## Example
485
+ * ```javascript
486
+ * backend.startSync();
487
+ * const ws = new WebSocket(url);
488
+ * // ... rest of setup
489
+ * ```
490
+ */
491
+ startSync() {
492
+ wasm.diaryxbackend_startSync(this.__wbg_ptr);
493
+ }
494
+ /**
495
+ * Stop sync session.
496
+ *
497
+ * Clears the outgoing message queue. Call after disconnecting WebSocket.
498
+ */
499
+ stopSync() {
500
+ wasm.diaryxbackend_stopSync(this.__wbg_ptr);
501
+ }
502
+ /**
503
+ * Write binary file.
504
+ *
505
+ * Accepts Uint8Array for efficient handling without base64 encoding.
506
+ * @param {string} path
507
+ * @param {Uint8Array} data
508
+ * @returns {Promise<any>}
509
+ */
510
+ writeBinary(path, data) {
511
+ const ptr0 = passStringToWasm0(path, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
512
+ const len0 = WASM_VECTOR_LEN;
513
+ const ret = wasm.diaryxbackend_writeBinary(this.__wbg_ptr, ptr0, len0, data);
514
+ return ret;
515
+ }
516
+ }
517
+ if (Symbol.dispose) DiaryxBackend.prototype[Symbol.dispose] = DiaryxBackend.prototype.free;
518
+
519
+ /**
520
+ * AsyncFileSystem implementation backed by File System Access API.
521
+ *
522
+ * Allows editing files directly on the user's filesystem in a directory
523
+ * they select via `showDirectoryPicker()`.
524
+ */
525
+ export class FsaFileSystem {
526
+ static __wrap(ptr) {
527
+ ptr = ptr >>> 0;
528
+ const obj = Object.create(FsaFileSystem.prototype);
529
+ obj.__wbg_ptr = ptr;
530
+ FsaFileSystemFinalization.register(obj, obj.__wbg_ptr, obj);
531
+ return obj;
532
+ }
533
+ __destroy_into_raw() {
534
+ const ptr = this.__wbg_ptr;
535
+ this.__wbg_ptr = 0;
536
+ FsaFileSystemFinalization.unregister(this);
537
+ return ptr;
538
+ }
539
+ free() {
540
+ const ptr = this.__destroy_into_raw();
541
+ wasm.__wbg_fsafilesystem_free(ptr, 0);
542
+ }
543
+ /**
544
+ * Create a new FsaFileSystem from a user-selected directory handle.
545
+ *
546
+ * The handle must be obtained from `window.showDirectoryPicker()` in JavaScript.
547
+ * @param {FileSystemDirectoryHandle} handle
548
+ * @returns {FsaFileSystem}
549
+ */
550
+ static fromHandle(handle) {
551
+ const ret = wasm.fsafilesystem_fromHandle(handle);
552
+ return FsaFileSystem.__wrap(ret);
553
+ }
554
+ }
555
+ if (Symbol.dispose) FsaFileSystem.prototype[Symbol.dispose] = FsaFileSystem.prototype.free;
556
+
557
+ /**
558
+ * AsyncFileSystem implementation backed by IndexedDB.
559
+ *
560
+ * Used as a fallback for browsers that don't support OPFS or when
561
+ * running outside a Web Worker context (where OPFS sync access isn't available).
562
+ */
563
+ export class IndexedDbFileSystem {
564
+ static __wrap(ptr) {
565
+ ptr = ptr >>> 0;
566
+ const obj = Object.create(IndexedDbFileSystem.prototype);
567
+ obj.__wbg_ptr = ptr;
568
+ IndexedDbFileSystemFinalization.register(obj, obj.__wbg_ptr, obj);
569
+ return obj;
570
+ }
571
+ __destroy_into_raw() {
572
+ const ptr = this.__wbg_ptr;
573
+ this.__wbg_ptr = 0;
574
+ IndexedDbFileSystemFinalization.unregister(this);
575
+ return ptr;
576
+ }
577
+ free() {
578
+ const ptr = this.__destroy_into_raw();
579
+ wasm.__wbg_indexeddbfilesystem_free(ptr, 0);
580
+ }
581
+ /**
582
+ * Create a new IndexedDbFileSystem.
583
+ *
584
+ * Opens or creates the IndexedDB database with the required object stores.
585
+ * @returns {Promise<IndexedDbFileSystem>}
586
+ */
587
+ static create() {
588
+ const ret = wasm.indexeddbfilesystem_create();
589
+ return ret;
590
+ }
591
+ }
592
+ if (Symbol.dispose) IndexedDbFileSystem.prototype[Symbol.dispose] = IndexedDbFileSystem.prototype.free;
593
+
594
+ /**
595
+ * An `AsyncFileSystem` implementation backed by JavaScript callbacks.
596
+ *
597
+ * This struct allows Rust code to use the async filesystem interface while
598
+ * delegating actual storage operations to JavaScript. This is useful for:
599
+ *
600
+ * - Using IndexedDB for persistent storage in browsers
601
+ * - Using OPFS (Origin Private File System) for better performance
602
+ * - Integrating with existing JavaScript storage solutions
603
+ * - Testing with mock filesystems
604
+ *
605
+ * ## Thread Safety
606
+ *
607
+ * This type is designed for single-threaded WASM environments. The callbacks
608
+ * JsValue is cloned into each async operation to satisfy Send requirements,
609
+ * but actual execution remains single-threaded.
610
+ */
611
+ export class JsAsyncFileSystem {
612
+ __destroy_into_raw() {
613
+ const ptr = this.__wbg_ptr;
614
+ this.__wbg_ptr = 0;
615
+ JsAsyncFileSystemFinalization.unregister(this);
616
+ return ptr;
617
+ }
618
+ free() {
619
+ const ptr = this.__destroy_into_raw();
620
+ wasm.__wbg_jsasyncfilesystem_free(ptr, 0);
621
+ }
622
+ /**
623
+ * Check if the filesystem has a specific callback.
624
+ * @param {string} name
625
+ * @returns {boolean}
626
+ */
627
+ has_callback(name) {
628
+ const ptr0 = passStringToWasm0(name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
629
+ const len0 = WASM_VECTOR_LEN;
630
+ const ret = wasm.jsasyncfilesystem_has_callback(this.__wbg_ptr, ptr0, len0);
631
+ return ret !== 0;
632
+ }
633
+ /**
634
+ * Create a new JsAsyncFileSystem with the provided callbacks.
635
+ *
636
+ * The callbacks object should implement the `JsFileSystemCallbacks` interface.
637
+ * All callbacks are optional - missing callbacks will cause operations to fail
638
+ * with appropriate errors.
639
+ * @param {any} callbacks
640
+ */
641
+ constructor(callbacks) {
642
+ const ret = wasm.jsasyncfilesystem_new(callbacks);
643
+ this.__wbg_ptr = ret >>> 0;
644
+ JsAsyncFileSystemFinalization.register(this, this.__wbg_ptr, this);
645
+ return this;
646
+ }
647
+ }
648
+ if (Symbol.dispose) JsAsyncFileSystem.prototype[Symbol.dispose] = JsAsyncFileSystem.prototype.free;
649
+
650
+ /**
651
+ * AsyncFileSystem implementation backed by OPFS (Origin Private File System).
652
+ *
653
+ * Uses the browser's private file system for persistent storage.
654
+ * All operations are async and work directly with browser storage.
655
+ */
656
+ export class OpfsFileSystem {
657
+ static __wrap(ptr) {
658
+ ptr = ptr >>> 0;
659
+ const obj = Object.create(OpfsFileSystem.prototype);
660
+ obj.__wbg_ptr = ptr;
661
+ OpfsFileSystemFinalization.register(obj, obj.__wbg_ptr, obj);
662
+ return obj;
663
+ }
664
+ __destroy_into_raw() {
665
+ const ptr = this.__wbg_ptr;
666
+ this.__wbg_ptr = 0;
667
+ OpfsFileSystemFinalization.unregister(this);
668
+ return ptr;
669
+ }
670
+ free() {
671
+ const ptr = this.__destroy_into_raw();
672
+ wasm.__wbg_opfsfilesystem_free(ptr, 0);
673
+ }
674
+ /**
675
+ * Create a new OpfsFileSystem with the default app directory.
676
+ *
677
+ * This creates a "diaryx" directory in the origin-private file system.
678
+ * @returns {Promise<OpfsFileSystem>}
679
+ */
680
+ static create() {
681
+ const ret = wasm.opfsfilesystem_create();
682
+ return ret;
683
+ }
684
+ /**
685
+ * Create a new OpfsFileSystem with a custom root directory name.
686
+ * @param {string} root_name
687
+ * @returns {Promise<OpfsFileSystem>}
688
+ */
689
+ static createWithName(root_name) {
690
+ const ptr0 = passStringToWasm0(root_name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
691
+ const len0 = WASM_VECTOR_LEN;
692
+ const ret = wasm.opfsfilesystem_createWithName(ptr0, len0);
693
+ return ret;
694
+ }
695
+ }
696
+ if (Symbol.dispose) OpfsFileSystem.prototype[Symbol.dispose] = OpfsFileSystem.prototype.free;
697
+
698
+ /**
699
+ * WASM sync client wrapper for JavaScript integration.
700
+ *
701
+ * This struct wraps a `SyncClient<CallbackTransport>` and exposes its
702
+ * functionality to JavaScript via wasm-bindgen. It manages two transports
703
+ * (metadata and body) and provides methods for:
704
+ *
705
+ * - Getting WebSocket URLs for connection
706
+ * - Notifying connection status changes
707
+ * - Injecting incoming messages
708
+ * - Polling for outgoing messages
709
+ * - Starting and stopping sync
710
+ */
711
+ export class WasmSyncClient {
712
+ static __wrap(ptr) {
713
+ ptr = ptr >>> 0;
714
+ const obj = Object.create(WasmSyncClient.prototype);
715
+ obj.__wbg_ptr = ptr;
716
+ WasmSyncClientFinalization.register(obj, obj.__wbg_ptr, obj);
717
+ return obj;
718
+ }
719
+ __destroy_into_raw() {
720
+ const ptr = this.__wbg_ptr;
721
+ this.__wbg_ptr = 0;
722
+ WasmSyncClientFinalization.unregister(this);
723
+ return ptr;
724
+ }
725
+ free() {
726
+ const ptr = this.__destroy_into_raw();
727
+ wasm.__wbg_wasmsyncclient_free(ptr, 0);
728
+ }
729
+ /**
730
+ * Focus on specific files for sync.
731
+ *
732
+ * Sends a focus message to the server indicating which files the client
733
+ * is currently interested in syncing. Other clients will receive a
734
+ * `focus_list_changed` notification and can subscribe to sync updates
735
+ * for these files.
736
+ *
737
+ * Call this when a file is opened in the editor.
738
+ *
739
+ * ## Example
740
+ * ```javascript
741
+ * // User opens a file
742
+ * client.focusFiles(["workspace/notes.md"]);
743
+ * ```
744
+ * @param {string[]} files
745
+ */
746
+ focusFiles(files) {
747
+ const ptr0 = passArrayJsValueToWasm0(files, wasm.__wbindgen_malloc);
748
+ const len0 = WASM_VECTOR_LEN;
749
+ wasm.wasmsyncclient_focusFiles(this.__wbg_ptr, ptr0, len0);
750
+ }
751
+ /**
752
+ * Get the initial SyncStep1 message for a body document.
753
+ *
754
+ * Returns a Uint8Array containing the framed message to send via WebSocket.
755
+ * @param {string} doc_name
756
+ * @returns {Uint8Array}
757
+ */
758
+ getBodySyncStep1(doc_name) {
759
+ const ptr0 = passStringToWasm0(doc_name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
760
+ const len0 = WASM_VECTOR_LEN;
761
+ const ret = wasm.wasmsyncclient_getBodySyncStep1(this.__wbg_ptr, ptr0, len0);
762
+ return ret;
763
+ }
764
+ /**
765
+ * Get the WebSocket URL for the body connection.
766
+ *
767
+ * Returns null if sync hasn't been configured.
768
+ * @returns {string | undefined}
769
+ */
770
+ getBodyUrl() {
771
+ const ret = wasm.wasmsyncclient_getBodyUrl(this.__wbg_ptr);
772
+ let v1;
773
+ if (ret[0] !== 0) {
774
+ v1 = getStringFromWasm0(ret[0], ret[1]).slice();
775
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
776
+ }
777
+ return v1;
778
+ }
779
+ /**
780
+ * Get the WebSocket URL for the metadata connection.
781
+ *
782
+ * Returns null if sync hasn't been configured.
783
+ * @returns {string | undefined}
784
+ */
785
+ getMetadataUrl() {
786
+ const ret = wasm.wasmsyncclient_getMetadataUrl(this.__wbg_ptr);
787
+ let v1;
788
+ if (ret[0] !== 0) {
789
+ v1 = getStringFromWasm0(ret[0], ret[1]).slice();
790
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
791
+ }
792
+ return v1;
793
+ }
794
+ /**
795
+ * Get the server URL.
796
+ * @returns {string}
797
+ */
798
+ getServerUrl() {
799
+ let deferred1_0;
800
+ let deferred1_1;
801
+ try {
802
+ const ret = wasm.wasmsyncclient_getServerUrl(this.__wbg_ptr);
803
+ deferred1_0 = ret[0];
804
+ deferred1_1 = ret[1];
805
+ return getStringFromWasm0(ret[0], ret[1]);
806
+ } finally {
807
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
808
+ }
809
+ }
810
+ /**
811
+ * Get the workspace ID.
812
+ * @returns {string}
813
+ */
814
+ getWorkspaceId() {
815
+ let deferred1_0;
816
+ let deferred1_1;
817
+ try {
818
+ const ret = wasm.wasmsyncclient_getWorkspaceId(this.__wbg_ptr);
819
+ deferred1_0 = ret[0];
820
+ deferred1_1 = ret[1];
821
+ return getStringFromWasm0(ret[0], ret[1]);
822
+ } finally {
823
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
824
+ }
825
+ }
826
+ /**
827
+ * Get the initial SyncStep1 message for workspace sync.
828
+ *
829
+ * Returns a Uint8Array containing the message to send via WebSocket.
830
+ * @returns {Uint8Array}
831
+ */
832
+ getWorkspaceSyncStep1() {
833
+ const ret = wasm.wasmsyncclient_getWorkspaceSyncStep1(this.__wbg_ptr);
834
+ return ret;
835
+ }
836
+ /**
837
+ * Check if there are pending body outgoing messages.
838
+ * @returns {boolean}
839
+ */
840
+ hasBodyOutgoing() {
841
+ const ret = wasm.wasmsyncclient_hasBodyOutgoing(this.__wbg_ptr);
842
+ return ret !== 0;
843
+ }
844
+ /**
845
+ * Check if there are pending body outgoing text messages.
846
+ * @returns {boolean}
847
+ */
848
+ hasBodyOutgoingText() {
849
+ const ret = wasm.wasmsyncclient_hasBodyOutgoingText(this.__wbg_ptr);
850
+ return ret !== 0;
851
+ }
852
+ /**
853
+ * Check if there are pending metadata outgoing messages.
854
+ * @returns {boolean}
855
+ */
856
+ hasMetadataOutgoing() {
857
+ const ret = wasm.wasmsyncclient_hasMetadataOutgoing(this.__wbg_ptr);
858
+ return ret !== 0;
859
+ }
860
+ /**
861
+ * Inject an incoming body message.
862
+ *
863
+ * Call this when the body WebSocket receives a message.
864
+ * The message should already be unframed (doc_name extracted separately).
865
+ * Returns a Promise that resolves to a Uint8Array response (or null).
866
+ * @param {string} doc_name
867
+ * @param {Uint8Array} message
868
+ * @returns {Promise<any>}
869
+ */
870
+ injectBodyMessage(doc_name, message) {
871
+ const ptr0 = passStringToWasm0(doc_name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
872
+ const len0 = WASM_VECTOR_LEN;
873
+ const ptr1 = passArray8ToWasm0(message, wasm.__wbindgen_malloc);
874
+ const len1 = WASM_VECTOR_LEN;
875
+ const ret = wasm.wasmsyncclient_injectBodyMessage(this.__wbg_ptr, ptr0, len0, ptr1, len1);
876
+ return ret;
877
+ }
878
+ /**
879
+ * Inject an incoming metadata message.
880
+ *
881
+ * Call this when the metadata WebSocket receives a message.
882
+ * Returns a Promise that resolves to a Uint8Array response (or null).
883
+ *
884
+ * The response should be sent back via the WebSocket if not null.
885
+ * @param {Uint8Array} message
886
+ * @returns {Promise<any>}
887
+ */
888
+ injectMetadataMessage(message) {
889
+ const ptr0 = passArray8ToWasm0(message, wasm.__wbindgen_malloc);
890
+ const len0 = WASM_VECTOR_LEN;
891
+ const ret = wasm.wasmsyncclient_injectMetadataMessage(this.__wbg_ptr, ptr0, len0);
892
+ return ret;
893
+ }
894
+ /**
895
+ * Check if the body connection is established.
896
+ * @returns {boolean}
897
+ */
898
+ isBodyConnected() {
899
+ const ret = wasm.wasmsyncclient_isBodyConnected(this.__wbg_ptr);
900
+ return ret !== 0;
901
+ }
902
+ /**
903
+ * Check if both connections are established.
904
+ * @returns {boolean}
905
+ */
906
+ isConnected() {
907
+ const ret = wasm.wasmsyncclient_isConnected(this.__wbg_ptr);
908
+ return ret !== 0;
909
+ }
910
+ /**
911
+ * Check if the metadata connection is established.
912
+ * @returns {boolean}
913
+ */
914
+ isMetadataConnected() {
915
+ const ret = wasm.wasmsyncclient_isMetadataConnected(this.__wbg_ptr);
916
+ return ret !== 0;
917
+ }
918
+ /**
919
+ * Check if the sync client is running.
920
+ * @returns {boolean}
921
+ */
922
+ isRunning() {
923
+ const ret = wasm.wasmsyncclient_isRunning(this.__wbg_ptr);
924
+ return ret !== 0;
925
+ }
926
+ /**
927
+ * Mark the body connection as connected.
928
+ *
929
+ * Call this when the body WebSocket opens.
930
+ */
931
+ markBodyConnected() {
932
+ wasm.wasmsyncclient_markBodyConnected(this.__wbg_ptr);
933
+ }
934
+ /**
935
+ * Mark the body connection as disconnected.
936
+ *
937
+ * Call this when the body WebSocket closes.
938
+ */
939
+ markBodyDisconnected() {
940
+ wasm.wasmsyncclient_markBodyDisconnected(this.__wbg_ptr);
941
+ }
942
+ /**
943
+ * Mark the metadata connection as connected.
944
+ *
945
+ * Call this when the metadata WebSocket opens.
946
+ */
947
+ markMetadataConnected() {
948
+ wasm.wasmsyncclient_markMetadataConnected(this.__wbg_ptr);
949
+ }
950
+ /**
951
+ * Mark the metadata connection as disconnected.
952
+ *
953
+ * Call this when the metadata WebSocket closes.
954
+ */
955
+ markMetadataDisconnected() {
956
+ wasm.wasmsyncclient_markMetadataDisconnected(this.__wbg_ptr);
957
+ }
958
+ /**
959
+ * Poll for an outgoing body message.
960
+ *
961
+ * Returns a Uint8Array if there's a message to send, null otherwise.
962
+ * The message is already framed with the document name.
963
+ * @returns {Uint8Array | undefined}
964
+ */
965
+ pollBodyOutgoing() {
966
+ const ret = wasm.wasmsyncclient_pollBodyOutgoing(this.__wbg_ptr);
967
+ return ret;
968
+ }
969
+ /**
970
+ * Poll for an outgoing body text message (for focus/unfocus).
971
+ *
972
+ * Returns a string if there's a text message to send, null otherwise.
973
+ * JavaScript should call this in a polling loop and send any messages
974
+ * via the body WebSocket as text frames.
975
+ * @returns {string | undefined}
976
+ */
977
+ pollBodyOutgoingText() {
978
+ const ret = wasm.wasmsyncclient_pollBodyOutgoingText(this.__wbg_ptr);
979
+ let v1;
980
+ if (ret[0] !== 0) {
981
+ v1 = getStringFromWasm0(ret[0], ret[1]).slice();
982
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
983
+ }
984
+ return v1;
985
+ }
986
+ /**
987
+ * Poll for an outgoing metadata message.
988
+ *
989
+ * Returns a Uint8Array if there's a message to send, null otherwise.
990
+ * JavaScript should call this in a polling loop and send any messages
991
+ * via the metadata WebSocket.
992
+ * @returns {Uint8Array | undefined}
993
+ */
994
+ pollMetadataOutgoing() {
995
+ const ret = wasm.wasmsyncclient_pollMetadataOutgoing(this.__wbg_ptr);
996
+ return ret;
997
+ }
998
+ /**
999
+ * Queue a body update message for sending.
1000
+ *
1001
+ * This creates a Y-sync Update message for the given document
1002
+ * and queues it for sending via the body WebSocket.
1003
+ * @param {string} doc_name
1004
+ * @param {string} content
1005
+ */
1006
+ queueBodyUpdate(doc_name, content) {
1007
+ const ptr0 = passStringToWasm0(doc_name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1008
+ const len0 = WASM_VECTOR_LEN;
1009
+ const ptr1 = passStringToWasm0(content, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1010
+ const len1 = WASM_VECTOR_LEN;
1011
+ const ret = wasm.wasmsyncclient_queueBodyUpdate(this.__wbg_ptr, ptr0, len0, ptr1, len1);
1012
+ if (ret[1]) {
1013
+ throw takeFromExternrefTable0(ret[0]);
1014
+ }
1015
+ }
1016
+ /**
1017
+ * Queue a workspace update message for sending.
1018
+ *
1019
+ * This creates a Y-sync Update message from the current workspace state
1020
+ * and queues it for sending via the metadata WebSocket.
1021
+ */
1022
+ queueWorkspaceUpdate() {
1023
+ const ret = wasm.wasmsyncclient_queueWorkspaceUpdate(this.__wbg_ptr);
1024
+ if (ret[1]) {
1025
+ throw takeFromExternrefTable0(ret[0]);
1026
+ }
1027
+ }
1028
+ /**
1029
+ * Start the sync session.
1030
+ *
1031
+ * This should be called after both WebSocket connections are established.
1032
+ * It sends the initial SyncStep1 messages and subscribes to all body docs.
1033
+ *
1034
+ * Returns a Promise that resolves when initial sync messages are sent.
1035
+ * @returns {Promise<any>}
1036
+ */
1037
+ start() {
1038
+ const ret = wasm.wasmsyncclient_start(this.__wbg_ptr);
1039
+ return ret;
1040
+ }
1041
+ /**
1042
+ * Stop the sync session.
1043
+ *
1044
+ * Clears all pending messages and resets state.
1045
+ */
1046
+ stop() {
1047
+ wasm.wasmsyncclient_stop(this.__wbg_ptr);
1048
+ }
1049
+ /**
1050
+ * Subscribe to body sync for the currently focused files.
1051
+ *
1052
+ * This sends SyncStep1 messages for all files in the provided list.
1053
+ * Call this after receiving a `focus_list_changed` message from the server.
1054
+ *
1055
+ * ## Example
1056
+ * ```javascript
1057
+ * // Received focus_list_changed event
1058
+ * const files = event.files;
1059
+ * client.subscribeBodies(files);
1060
+ * ```
1061
+ * @param {string[]} files
1062
+ */
1063
+ subscribeBodies(files) {
1064
+ const ptr0 = passArrayJsValueToWasm0(files, wasm.__wbindgen_malloc);
1065
+ const len0 = WASM_VECTOR_LEN;
1066
+ wasm.wasmsyncclient_subscribeBodies(this.__wbg_ptr, ptr0, len0);
1067
+ }
1068
+ /**
1069
+ * Subscribe to body sync for a specific document.
1070
+ *
1071
+ * This queues a SyncStep1 message for the given document.
1072
+ * Call this when a new file is created or when opening a file for editing.
1073
+ * @param {string} doc_name
1074
+ */
1075
+ subscribeBody(doc_name) {
1076
+ const ptr0 = passStringToWasm0(doc_name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1077
+ const len0 = WASM_VECTOR_LEN;
1078
+ wasm.wasmsyncclient_subscribeBody(this.__wbg_ptr, ptr0, len0);
1079
+ }
1080
+ /**
1081
+ * Unfocus specific files.
1082
+ *
1083
+ * Sends an unfocus message to the server indicating the client is no
1084
+ * longer interested in syncing these files.
1085
+ *
1086
+ * Call this when a file is closed in the editor.
1087
+ *
1088
+ * ## Example
1089
+ * ```javascript
1090
+ * // User closes a file
1091
+ * client.unfocusFiles(["workspace/notes.md"]);
1092
+ * ```
1093
+ * @param {string[]} files
1094
+ */
1095
+ unfocusFiles(files) {
1096
+ const ptr0 = passArrayJsValueToWasm0(files, wasm.__wbindgen_malloc);
1097
+ const len0 = WASM_VECTOR_LEN;
1098
+ wasm.wasmsyncclient_unfocusFiles(this.__wbg_ptr, ptr0, len0);
1099
+ }
1100
+ }
1101
+ if (Symbol.dispose) WasmSyncClient.prototype[Symbol.dispose] = WasmSyncClient.prototype.free;
1102
+
1103
+ /**
1104
+ * Initialize the WASM module. Called automatically on module load.
1105
+ */
1106
+ export function init() {
1107
+ wasm.init();
1108
+ }
1109
+
1110
+ /**
1111
+ * Generate an ISO 8601 timestamp for the current time.
1112
+ * @returns {string}
1113
+ */
1114
+ export function now_timestamp() {
1115
+ let deferred1_0;
1116
+ let deferred1_1;
1117
+ try {
1118
+ const ret = wasm.now_timestamp();
1119
+ deferred1_0 = ret[0];
1120
+ deferred1_1 = ret[1];
1121
+ return getStringFromWasm0(ret[0], ret[1]);
1122
+ } finally {
1123
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
1124
+ }
1125
+ }
1126
+
1127
+ /**
1128
+ * Generate a formatted date string for the current date.
1129
+ * @param {string} format
1130
+ * @returns {string}
1131
+ */
1132
+ export function today_formatted(format) {
1133
+ let deferred2_0;
1134
+ let deferred2_1;
1135
+ try {
1136
+ const ptr0 = passStringToWasm0(format, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1137
+ const len0 = WASM_VECTOR_LEN;
1138
+ const ret = wasm.today_formatted(ptr0, len0);
1139
+ deferred2_0 = ret[0];
1140
+ deferred2_1 = ret[1];
1141
+ return getStringFromWasm0(ret[0], ret[1]);
1142
+ } finally {
1143
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
1144
+ }
1145
+ }
1146
+
1147
+ function __wbg_get_imports() {
1148
+ const import0 = {
1149
+ __proto__: null,
1150
+ __wbg_Error_8c4e43fe74559d73: function(arg0, arg1) {
1151
+ const ret = Error(getStringFromWasm0(arg0, arg1));
1152
+ return ret;
1153
+ },
1154
+ __wbg_Number_04624de7d0e8332d: function(arg0) {
1155
+ const ret = Number(arg0);
1156
+ return ret;
1157
+ },
1158
+ __wbg_String_8f0eb39a4a4c2f66: function(arg0, arg1) {
1159
+ const ret = String(arg1);
1160
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1161
+ const len1 = WASM_VECTOR_LEN;
1162
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
1163
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
1164
+ },
1165
+ __wbg___wbindgen_bigint_get_as_i64_8fcf4ce7f1ca72a2: function(arg0, arg1) {
1166
+ const v = arg1;
1167
+ const ret = typeof(v) === 'bigint' ? v : undefined;
1168
+ getDataViewMemory0().setBigInt64(arg0 + 8 * 1, isLikeNone(ret) ? BigInt(0) : ret, true);
1169
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
1170
+ },
1171
+ __wbg___wbindgen_boolean_get_bbbb1c18aa2f5e25: function(arg0) {
1172
+ const v = arg0;
1173
+ const ret = typeof(v) === 'boolean' ? v : undefined;
1174
+ return isLikeNone(ret) ? 0xFFFFFF : ret ? 1 : 0;
1175
+ },
1176
+ __wbg___wbindgen_debug_string_0bc8482c6e3508ae: function(arg0, arg1) {
1177
+ const ret = debugString(arg1);
1178
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1179
+ const len1 = WASM_VECTOR_LEN;
1180
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
1181
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
1182
+ },
1183
+ __wbg___wbindgen_in_47fa6863be6f2f25: function(arg0, arg1) {
1184
+ const ret = arg0 in arg1;
1185
+ return ret;
1186
+ },
1187
+ __wbg___wbindgen_is_bigint_31b12575b56f32fc: function(arg0) {
1188
+ const ret = typeof(arg0) === 'bigint';
1189
+ return ret;
1190
+ },
1191
+ __wbg___wbindgen_is_function_0095a73b8b156f76: function(arg0) {
1192
+ const ret = typeof(arg0) === 'function';
1193
+ return ret;
1194
+ },
1195
+ __wbg___wbindgen_is_null_ac34f5003991759a: function(arg0) {
1196
+ const ret = arg0 === null;
1197
+ return ret;
1198
+ },
1199
+ __wbg___wbindgen_is_object_5ae8e5880f2c1fbd: function(arg0) {
1200
+ const val = arg0;
1201
+ const ret = typeof(val) === 'object' && val !== null;
1202
+ return ret;
1203
+ },
1204
+ __wbg___wbindgen_is_string_cd444516edc5b180: function(arg0) {
1205
+ const ret = typeof(arg0) === 'string';
1206
+ return ret;
1207
+ },
1208
+ __wbg___wbindgen_is_undefined_9e4d92534c42d778: function(arg0) {
1209
+ const ret = arg0 === undefined;
1210
+ return ret;
1211
+ },
1212
+ __wbg___wbindgen_jsval_eq_11888390b0186270: function(arg0, arg1) {
1213
+ const ret = arg0 === arg1;
1214
+ return ret;
1215
+ },
1216
+ __wbg___wbindgen_jsval_loose_eq_9dd77d8cd6671811: function(arg0, arg1) {
1217
+ const ret = arg0 == arg1;
1218
+ return ret;
1219
+ },
1220
+ __wbg___wbindgen_number_get_8ff4255516ccad3e: function(arg0, arg1) {
1221
+ const obj = arg1;
1222
+ const ret = typeof(obj) === 'number' ? obj : undefined;
1223
+ getDataViewMemory0().setFloat64(arg0 + 8 * 1, isLikeNone(ret) ? 0 : ret, true);
1224
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
1225
+ },
1226
+ __wbg___wbindgen_string_get_72fb696202c56729: function(arg0, arg1) {
1227
+ const obj = arg1;
1228
+ const ret = typeof(obj) === 'string' ? obj : undefined;
1229
+ var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1230
+ var len1 = WASM_VECTOR_LEN;
1231
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
1232
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
1233
+ },
1234
+ __wbg___wbindgen_throw_be289d5034ed271b: function(arg0, arg1) {
1235
+ throw new Error(getStringFromWasm0(arg0, arg1));
1236
+ },
1237
+ __wbg__wbg_cb_unref_d9b87ff7982e3b21: function(arg0) {
1238
+ arg0._wbg_cb_unref();
1239
+ },
1240
+ __wbg_abort_5151361027dc87df: function() { return handleError(function (arg0) {
1241
+ arg0.abort();
1242
+ }, arguments); },
1243
+ __wbg_advance_92b0e42f9cd4e26b: function() { return handleError(function (arg0, arg1) {
1244
+ arg0.advance(arg1 >>> 0);
1245
+ }, arguments); },
1246
+ __wbg_apply_2e22c45cb4f12415: function() { return handleError(function (arg0, arg1, arg2) {
1247
+ const ret = Reflect.apply(arg0, arg1, arg2);
1248
+ return ret;
1249
+ }, arguments); },
1250
+ __wbg_arrayBuffer_05ce1af23e9064e8: function(arg0) {
1251
+ const ret = arg0.arrayBuffer();
1252
+ return ret;
1253
+ },
1254
+ __wbg_call_389efe28435a9388: function() { return handleError(function (arg0, arg1) {
1255
+ const ret = arg0.call(arg1);
1256
+ return ret;
1257
+ }, arguments); },
1258
+ __wbg_call_4708e0c13bdc8e95: function() { return handleError(function (arg0, arg1, arg2) {
1259
+ const ret = arg0.call(arg1, arg2);
1260
+ return ret;
1261
+ }, arguments); },
1262
+ __wbg_close_83fb809aca3de7f9: function(arg0) {
1263
+ const ret = arg0.close();
1264
+ return ret;
1265
+ },
1266
+ __wbg_createObjectStore_f75f59d55a549868: function() { return handleError(function (arg0, arg1, arg2, arg3) {
1267
+ const ret = arg0.createObjectStore(getStringFromWasm0(arg1, arg2), arg3);
1268
+ return ret;
1269
+ }, arguments); },
1270
+ __wbg_createWritable_6c6623bddc203fe6: function(arg0, arg1) {
1271
+ const ret = arg0.createWritable(arg1);
1272
+ return ret;
1273
+ },
1274
+ __wbg_crypto_86f2631e91b51511: function(arg0) {
1275
+ const ret = arg0.crypto;
1276
+ return ret;
1277
+ },
1278
+ __wbg_debug_46a93995fc6f8820: function(arg0, arg1, arg2, arg3) {
1279
+ console.debug(arg0, arg1, arg2, arg3);
1280
+ },
1281
+ __wbg_delete_d6d7f750bd9ed2cd: function() { return handleError(function (arg0, arg1) {
1282
+ const ret = arg0.delete(arg1);
1283
+ return ret;
1284
+ }, arguments); },
1285
+ __wbg_diaryxbackend_new: function(arg0) {
1286
+ const ret = DiaryxBackend.__wrap(arg0);
1287
+ return ret;
1288
+ },
1289
+ __wbg_done_57b39ecd9addfe81: function(arg0) {
1290
+ const ret = arg0.done;
1291
+ return ret;
1292
+ },
1293
+ __wbg_entries_04a4b982351a717f: function(arg0) {
1294
+ const ret = arg0.entries();
1295
+ return ret;
1296
+ },
1297
+ __wbg_entries_58c7934c745daac7: function(arg0) {
1298
+ const ret = Object.entries(arg0);
1299
+ return ret;
1300
+ },
1301
+ __wbg_error_6afb95c784775817: function() { return handleError(function (arg0) {
1302
+ const ret = arg0.error;
1303
+ return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
1304
+ }, arguments); },
1305
+ __wbg_error_7534b8e9a36f1ab4: function(arg0, arg1) {
1306
+ let deferred0_0;
1307
+ let deferred0_1;
1308
+ try {
1309
+ deferred0_0 = arg0;
1310
+ deferred0_1 = arg1;
1311
+ console.error(getStringFromWasm0(arg0, arg1));
1312
+ } finally {
1313
+ wasm.__wbindgen_free(deferred0_0, deferred0_1, 1);
1314
+ }
1315
+ },
1316
+ __wbg_error_794d0ffc9d00d5c3: function(arg0, arg1, arg2, arg3) {
1317
+ console.error(arg0, arg1, arg2, arg3);
1318
+ },
1319
+ __wbg_from_bddd64e7d5ff6941: function(arg0) {
1320
+ const ret = Array.from(arg0);
1321
+ return ret;
1322
+ },
1323
+ __wbg_getDirectoryHandle_87ce8ca53cf4d8dc: function(arg0, arg1, arg2, arg3) {
1324
+ const ret = arg0.getDirectoryHandle(getStringFromWasm0(arg1, arg2), arg3);
1325
+ return ret;
1326
+ },
1327
+ __wbg_getFileHandle_ff4ab917b45affb3: function(arg0, arg1, arg2, arg3) {
1328
+ const ret = arg0.getFileHandle(getStringFromWasm0(arg1, arg2), arg3);
1329
+ return ret;
1330
+ },
1331
+ __wbg_getFile_115354fc950edc88: function(arg0) {
1332
+ const ret = arg0.getFile();
1333
+ return ret;
1334
+ },
1335
+ __wbg_getRandomValues_b3f15fcbfabb0f8b: function() { return handleError(function (arg0, arg1) {
1336
+ arg0.getRandomValues(arg1);
1337
+ }, arguments); },
1338
+ __wbg_getTime_1e3cd1391c5c3995: function(arg0) {
1339
+ const ret = arg0.getTime();
1340
+ return ret;
1341
+ },
1342
+ __wbg_getTimezoneOffset_81776d10a4ec18a8: function(arg0) {
1343
+ const ret = arg0.getTimezoneOffset();
1344
+ return ret;
1345
+ },
1346
+ __wbg_get_5e856edb32ac1289: function() { return handleError(function (arg0, arg1) {
1347
+ const ret = arg0.get(arg1);
1348
+ return ret;
1349
+ }, arguments); },
1350
+ __wbg_get_626204a85e34f823: function(arg0, arg1, arg2) {
1351
+ const ret = arg1[arg2 >>> 0];
1352
+ var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1353
+ var len1 = WASM_VECTOR_LEN;
1354
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
1355
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
1356
+ },
1357
+ __wbg_get_9b94d73e6221f75c: function(arg0, arg1) {
1358
+ const ret = arg0[arg1 >>> 0];
1359
+ return ret;
1360
+ },
1361
+ __wbg_get_b3ed3ad4be2bc8ac: function() { return handleError(function (arg0, arg1) {
1362
+ const ret = Reflect.get(arg0, arg1);
1363
+ return ret;
1364
+ }, arguments); },
1365
+ __wbg_get_with_ref_key_1dc361bd10053bfe: function(arg0, arg1) {
1366
+ const ret = arg0[arg1];
1367
+ return ret;
1368
+ },
1369
+ __wbg_indexedDB_782f0610ea9fb144: function() { return handleError(function (arg0) {
1370
+ const ret = arg0.indexedDB;
1371
+ return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
1372
+ }, arguments); },
1373
+ __wbg_indexedDB_9ddfb31df70de83b: function() { return handleError(function (arg0) {
1374
+ const ret = arg0.indexedDB;
1375
+ return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
1376
+ }, arguments); },
1377
+ __wbg_indexeddbfilesystem_new: function(arg0) {
1378
+ const ret = IndexedDbFileSystem.__wrap(arg0);
1379
+ return ret;
1380
+ },
1381
+ __wbg_info_9e602cf10c5c690b: function(arg0, arg1, arg2, arg3) {
1382
+ console.info(arg0, arg1, arg2, arg3);
1383
+ },
1384
+ __wbg_instanceof_ArrayBuffer_c367199e2fa2aa04: function(arg0) {
1385
+ let result;
1386
+ try {
1387
+ result = arg0 instanceof ArrayBuffer;
1388
+ } catch (_) {
1389
+ result = false;
1390
+ }
1391
+ const ret = result;
1392
+ return ret;
1393
+ },
1394
+ __wbg_instanceof_DomException_99c177193e554b75: function(arg0) {
1395
+ let result;
1396
+ try {
1397
+ result = arg0 instanceof DOMException;
1398
+ } catch (_) {
1399
+ result = false;
1400
+ }
1401
+ const ret = result;
1402
+ return ret;
1403
+ },
1404
+ __wbg_instanceof_FileSystemDirectoryHandle_56a167039d614548: function(arg0) {
1405
+ let result;
1406
+ try {
1407
+ result = arg0 instanceof FileSystemDirectoryHandle;
1408
+ } catch (_) {
1409
+ result = false;
1410
+ }
1411
+ const ret = result;
1412
+ return ret;
1413
+ },
1414
+ __wbg_instanceof_FileSystemFileHandle_fd8948f4bac4e78a: function(arg0) {
1415
+ let result;
1416
+ try {
1417
+ result = arg0 instanceof FileSystemFileHandle;
1418
+ } catch (_) {
1419
+ result = false;
1420
+ }
1421
+ const ret = result;
1422
+ return ret;
1423
+ },
1424
+ __wbg_instanceof_IdbCursor_2d04e6672d862a60: function(arg0) {
1425
+ let result;
1426
+ try {
1427
+ result = arg0 instanceof IDBCursor;
1428
+ } catch (_) {
1429
+ result = false;
1430
+ }
1431
+ const ret = result;
1432
+ return ret;
1433
+ },
1434
+ __wbg_instanceof_IdbDatabase_8d723b3ff4761c2d: function(arg0) {
1435
+ let result;
1436
+ try {
1437
+ result = arg0 instanceof IDBDatabase;
1438
+ } catch (_) {
1439
+ result = false;
1440
+ }
1441
+ const ret = result;
1442
+ return ret;
1443
+ },
1444
+ __wbg_instanceof_IdbOpenDbRequest_e476921a744b955b: function(arg0) {
1445
+ let result;
1446
+ try {
1447
+ result = arg0 instanceof IDBOpenDBRequest;
1448
+ } catch (_) {
1449
+ result = false;
1450
+ }
1451
+ const ret = result;
1452
+ return ret;
1453
+ },
1454
+ __wbg_instanceof_IdbRequest_6388508cc77f8da0: function(arg0) {
1455
+ let result;
1456
+ try {
1457
+ result = arg0 instanceof IDBRequest;
1458
+ } catch (_) {
1459
+ result = false;
1460
+ }
1461
+ const ret = result;
1462
+ return ret;
1463
+ },
1464
+ __wbg_instanceof_Map_53af74335dec57f4: function(arg0) {
1465
+ let result;
1466
+ try {
1467
+ result = arg0 instanceof Map;
1468
+ } catch (_) {
1469
+ result = false;
1470
+ }
1471
+ const ret = result;
1472
+ return ret;
1473
+ },
1474
+ __wbg_instanceof_Promise_0094681e3519d6ec: function(arg0) {
1475
+ let result;
1476
+ try {
1477
+ result = arg0 instanceof Promise;
1478
+ } catch (_) {
1479
+ result = false;
1480
+ }
1481
+ const ret = result;
1482
+ return ret;
1483
+ },
1484
+ __wbg_instanceof_TypeError_45484a0407e7f588: function(arg0) {
1485
+ let result;
1486
+ try {
1487
+ result = arg0 instanceof TypeError;
1488
+ } catch (_) {
1489
+ result = false;
1490
+ }
1491
+ const ret = result;
1492
+ return ret;
1493
+ },
1494
+ __wbg_instanceof_Uint8Array_9b9075935c74707c: function(arg0) {
1495
+ let result;
1496
+ try {
1497
+ result = arg0 instanceof Uint8Array;
1498
+ } catch (_) {
1499
+ result = false;
1500
+ }
1501
+ const ret = result;
1502
+ return ret;
1503
+ },
1504
+ __wbg_instanceof_Window_ed49b2db8df90359: function(arg0) {
1505
+ let result;
1506
+ try {
1507
+ result = arg0 instanceof Window;
1508
+ } catch (_) {
1509
+ result = false;
1510
+ }
1511
+ const ret = result;
1512
+ return ret;
1513
+ },
1514
+ __wbg_instanceof_WorkerGlobalScope_07b9d5514ff0156e: function(arg0) {
1515
+ let result;
1516
+ try {
1517
+ result = arg0 instanceof WorkerGlobalScope;
1518
+ } catch (_) {
1519
+ result = false;
1520
+ }
1521
+ const ret = result;
1522
+ return ret;
1523
+ },
1524
+ __wbg_isArray_d314bb98fcf08331: function(arg0) {
1525
+ const ret = Array.isArray(arg0);
1526
+ return ret;
1527
+ },
1528
+ __wbg_isSafeInteger_bfbc7332a9768d2a: function(arg0) {
1529
+ const ret = Number.isSafeInteger(arg0);
1530
+ return ret;
1531
+ },
1532
+ __wbg_iterator_6ff6560ca1568e55: function() {
1533
+ const ret = Symbol.iterator;
1534
+ return ret;
1535
+ },
1536
+ __wbg_key_c27cb3b734638d81: function() { return handleError(function (arg0) {
1537
+ const ret = arg0.key;
1538
+ return ret;
1539
+ }, arguments); },
1540
+ __wbg_length_32ed9a279acd054c: function(arg0) {
1541
+ const ret = arg0.length;
1542
+ return ret;
1543
+ },
1544
+ __wbg_length_35a7bace40f36eac: function(arg0) {
1545
+ const ret = arg0.length;
1546
+ return ret;
1547
+ },
1548
+ __wbg_length_4c6eb4059a3635c9: function(arg0) {
1549
+ const ret = arg0.length;
1550
+ return ret;
1551
+ },
1552
+ __wbg_log_24aba2a6d8990b35: function(arg0, arg1, arg2, arg3) {
1553
+ console.log(arg0, arg1, arg2, arg3);
1554
+ },
1555
+ __wbg_msCrypto_d562bbe83e0d4b91: function(arg0) {
1556
+ const ret = arg0.msCrypto;
1557
+ return ret;
1558
+ },
1559
+ __wbg_name_242753e5110cd756: function(arg0, arg1) {
1560
+ const ret = arg1.name;
1561
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1562
+ const len1 = WASM_VECTOR_LEN;
1563
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
1564
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
1565
+ },
1566
+ __wbg_new_0_73afc35eb544e539: function() {
1567
+ const ret = new Date();
1568
+ return ret;
1569
+ },
1570
+ __wbg_new_245cd5c49157e602: function(arg0) {
1571
+ const ret = new Date(arg0);
1572
+ return ret;
1573
+ },
1574
+ __wbg_new_361308b2356cecd0: function() {
1575
+ const ret = new Object();
1576
+ return ret;
1577
+ },
1578
+ __wbg_new_3eb36ae241fe6f44: function() {
1579
+ const ret = new Array();
1580
+ return ret;
1581
+ },
1582
+ __wbg_new_8a6f238a6ece86ea: function() {
1583
+ const ret = new Error();
1584
+ return ret;
1585
+ },
1586
+ __wbg_new_b5d9e2fb389fef91: function(arg0, arg1) {
1587
+ try {
1588
+ var state0 = {a: arg0, b: arg1};
1589
+ var cb0 = (arg0, arg1) => {
1590
+ const a = state0.a;
1591
+ state0.a = 0;
1592
+ try {
1593
+ return wasm_bindgen__convert__closures_____invoke__hcef8d709b492a91f(a, state0.b, arg0, arg1);
1594
+ } finally {
1595
+ state0.a = a;
1596
+ }
1597
+ };
1598
+ const ret = new Promise(cb0);
1599
+ return ret;
1600
+ } finally {
1601
+ state0.a = state0.b = 0;
1602
+ }
1603
+ },
1604
+ __wbg_new_dca287b076112a51: function() {
1605
+ const ret = new Map();
1606
+ return ret;
1607
+ },
1608
+ __wbg_new_dd2b680c8bf6ae29: function(arg0) {
1609
+ const ret = new Uint8Array(arg0);
1610
+ return ret;
1611
+ },
1612
+ __wbg_new_from_slice_a3d2629dc1826784: function(arg0, arg1) {
1613
+ const ret = new Uint8Array(getArrayU8FromWasm0(arg0, arg1));
1614
+ return ret;
1615
+ },
1616
+ __wbg_new_no_args_1c7c842f08d00ebb: function(arg0, arg1) {
1617
+ const ret = new Function(getStringFromWasm0(arg0, arg1));
1618
+ return ret;
1619
+ },
1620
+ __wbg_new_with_length_1763c527b2923202: function(arg0) {
1621
+ const ret = new Array(arg0 >>> 0);
1622
+ return ret;
1623
+ },
1624
+ __wbg_new_with_length_a2c39cbe88fd8ff1: function(arg0) {
1625
+ const ret = new Uint8Array(arg0 >>> 0);
1626
+ return ret;
1627
+ },
1628
+ __wbg_new_with_u8_array_sequence_fd1dafbce0db92f4: function() { return handleError(function (arg0, arg1, arg2) {
1629
+ const ret = new File(arg0, getStringFromWasm0(arg1, arg2));
1630
+ return ret;
1631
+ }, arguments); },
1632
+ __wbg_next_0a5e0f8af98146aa: function() { return handleError(function (arg0) {
1633
+ const ret = arg0.next();
1634
+ return ret;
1635
+ }, arguments); },
1636
+ __wbg_next_3482f54c49e8af19: function() { return handleError(function (arg0) {
1637
+ const ret = arg0.next();
1638
+ return ret;
1639
+ }, arguments); },
1640
+ __wbg_next_418f80d8f5303233: function(arg0) {
1641
+ const ret = arg0.next;
1642
+ return ret;
1643
+ },
1644
+ __wbg_node_e1f24f89a7336c2e: function(arg0) {
1645
+ const ret = arg0.node;
1646
+ return ret;
1647
+ },
1648
+ __wbg_objectStoreNames_d2c5d2377420ad78: function(arg0) {
1649
+ const ret = arg0.objectStoreNames;
1650
+ return ret;
1651
+ },
1652
+ __wbg_objectStore_d56e603390dcc165: function() { return handleError(function (arg0, arg1, arg2) {
1653
+ const ret = arg0.objectStore(getStringFromWasm0(arg1, arg2));
1654
+ return ret;
1655
+ }, arguments); },
1656
+ __wbg_openCursor_500d2e73adae3a19: function() { return handleError(function (arg0, arg1, arg2) {
1657
+ const ret = arg0.openCursor(arg1, __wbindgen_enum_IdbCursorDirection[arg2]);
1658
+ return ret;
1659
+ }, arguments); },
1660
+ __wbg_openCursor_73adc695cace4477: function() { return handleError(function (arg0, arg1, arg2) {
1661
+ const ret = arg0.openCursor(arg1, __wbindgen_enum_IdbCursorDirection[arg2]);
1662
+ return ret;
1663
+ }, arguments); },
1664
+ __wbg_open_82db86fd5b087109: function() { return handleError(function (arg0, arg1, arg2, arg3) {
1665
+ const ret = arg0.open(getStringFromWasm0(arg1, arg2), arg3 >>> 0);
1666
+ return ret;
1667
+ }, arguments); },
1668
+ __wbg_opfsfilesystem_new: function(arg0) {
1669
+ const ret = OpfsFileSystem.__wrap(arg0);
1670
+ return ret;
1671
+ },
1672
+ __wbg_parse_708461a1feddfb38: function() { return handleError(function (arg0, arg1) {
1673
+ const ret = JSON.parse(getStringFromWasm0(arg0, arg1));
1674
+ return ret;
1675
+ }, arguments); },
1676
+ __wbg_preventDefault_cdcfcd7e301b9702: function(arg0) {
1677
+ arg0.preventDefault();
1678
+ },
1679
+ __wbg_process_3975fd6c72f520aa: function(arg0) {
1680
+ const ret = arg0.process;
1681
+ return ret;
1682
+ },
1683
+ __wbg_prototypesetcall_bdcdcc5842e4d77d: function(arg0, arg1, arg2) {
1684
+ Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), arg2);
1685
+ },
1686
+ __wbg_push_8ffdcb2063340ba5: function(arg0, arg1) {
1687
+ const ret = arg0.push(arg1);
1688
+ return ret;
1689
+ },
1690
+ __wbg_put_b34701a38436f20a: function() { return handleError(function (arg0, arg1, arg2) {
1691
+ const ret = arg0.put(arg1, arg2);
1692
+ return ret;
1693
+ }, arguments); },
1694
+ __wbg_queueMicrotask_0aa0a927f78f5d98: function(arg0) {
1695
+ const ret = arg0.queueMicrotask;
1696
+ return ret;
1697
+ },
1698
+ __wbg_queueMicrotask_5bb536982f78a56f: function(arg0) {
1699
+ queueMicrotask(arg0);
1700
+ },
1701
+ __wbg_randomFillSync_f8c153b79f285817: function() { return handleError(function (arg0, arg1) {
1702
+ arg0.randomFillSync(arg1);
1703
+ }, arguments); },
1704
+ __wbg_removeEntry_d1cc9710704217eb: function(arg0, arg1, arg2) {
1705
+ const ret = arg0.removeEntry(getStringFromWasm0(arg1, arg2));
1706
+ return ret;
1707
+ },
1708
+ __wbg_require_b74f47fc2d022fd6: function() { return handleError(function () {
1709
+ const ret = module.require;
1710
+ return ret;
1711
+ }, arguments); },
1712
+ __wbg_resolve_002c4b7d9d8f6b64: function(arg0) {
1713
+ const ret = Promise.resolve(arg0);
1714
+ return ret;
1715
+ },
1716
+ __wbg_result_233b2d68aae87a05: function() { return handleError(function (arg0) {
1717
+ const ret = arg0.result;
1718
+ return ret;
1719
+ }, arguments); },
1720
+ __wbg_set_1eb0999cf5d27fc8: function(arg0, arg1, arg2) {
1721
+ const ret = arg0.set(arg1, arg2);
1722
+ return ret;
1723
+ },
1724
+ __wbg_set_3f1d0b984ed272ed: function(arg0, arg1, arg2) {
1725
+ arg0[arg1] = arg2;
1726
+ },
1727
+ __wbg_set_6cb8631f80447a67: function() { return handleError(function (arg0, arg1, arg2) {
1728
+ const ret = Reflect.set(arg0, arg1, arg2);
1729
+ return ret;
1730
+ }, arguments); },
1731
+ __wbg_set_cc56eefd2dd91957: function(arg0, arg1, arg2) {
1732
+ arg0.set(getArrayU8FromWasm0(arg1, arg2));
1733
+ },
1734
+ __wbg_set_create_1f902c5936adde7d: function(arg0, arg1) {
1735
+ arg0.create = arg1 !== 0;
1736
+ },
1737
+ __wbg_set_create_c95ddca018fac9ce: function(arg0, arg1) {
1738
+ arg0.create = arg1 !== 0;
1739
+ },
1740
+ __wbg_set_f43e577aea94465b: function(arg0, arg1, arg2) {
1741
+ arg0[arg1 >>> 0] = arg2;
1742
+ },
1743
+ __wbg_set_keep_existing_data_ac7fffea75f37b19: function(arg0, arg1) {
1744
+ arg0.keepExistingData = arg1 !== 0;
1745
+ },
1746
+ __wbg_set_onerror_dc0e606b09e1792f: function(arg0, arg1) {
1747
+ arg0.onerror = arg1;
1748
+ },
1749
+ __wbg_set_onsuccess_0edec1acb4124784: function(arg0, arg1) {
1750
+ arg0.onsuccess = arg1;
1751
+ },
1752
+ __wbg_set_onupgradeneeded_c887b74722b6ce77: function(arg0, arg1) {
1753
+ arg0.onupgradeneeded = arg1;
1754
+ },
1755
+ __wbg_size_e05d31cc6049815f: function(arg0) {
1756
+ const ret = arg0.size;
1757
+ return ret;
1758
+ },
1759
+ __wbg_stack_0ed75d68575b0f3c: function(arg0, arg1) {
1760
+ const ret = arg1.stack;
1761
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1762
+ const len1 = WASM_VECTOR_LEN;
1763
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
1764
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
1765
+ },
1766
+ __wbg_static_accessor_GLOBAL_12837167ad935116: function() {
1767
+ const ret = typeof global === 'undefined' ? null : global;
1768
+ return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
1769
+ },
1770
+ __wbg_static_accessor_GLOBAL_THIS_e628e89ab3b1c95f: function() {
1771
+ const ret = typeof globalThis === 'undefined' ? null : globalThis;
1772
+ return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
1773
+ },
1774
+ __wbg_static_accessor_SELF_a621d3dfbb60d0ce: function() {
1775
+ const ret = typeof self === 'undefined' ? null : self;
1776
+ return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
1777
+ },
1778
+ __wbg_static_accessor_WINDOW_f8727f0cf888e0bd: function() {
1779
+ const ret = typeof window === 'undefined' ? null : window;
1780
+ return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
1781
+ },
1782
+ __wbg_stringify_8d1cc6ff383e8bae: function() { return handleError(function (arg0) {
1783
+ const ret = JSON.stringify(arg0);
1784
+ return ret;
1785
+ }, arguments); },
1786
+ __wbg_subarray_a96e1fef17ed23cb: function(arg0, arg1, arg2) {
1787
+ const ret = arg0.subarray(arg1 >>> 0, arg2 >>> 0);
1788
+ return ret;
1789
+ },
1790
+ __wbg_target_521be630ab05b11e: function(arg0) {
1791
+ const ret = arg0.target;
1792
+ return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
1793
+ },
1794
+ __wbg_then_0d9fe2c7b1857d32: function(arg0, arg1, arg2) {
1795
+ const ret = arg0.then(arg1, arg2);
1796
+ return ret;
1797
+ },
1798
+ __wbg_then_b9e7b3b5f1a9e1b5: function(arg0, arg1) {
1799
+ const ret = arg0.then(arg1);
1800
+ return ret;
1801
+ },
1802
+ __wbg_transaction_5124caf7db668498: function(arg0) {
1803
+ const ret = arg0.transaction;
1804
+ return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
1805
+ },
1806
+ __wbg_transaction_c407989db8e62119: function() { return handleError(function (arg0, arg1, arg2) {
1807
+ const ret = arg0.transaction(arg1, __wbindgen_enum_IdbTransactionMode[arg2]);
1808
+ return ret;
1809
+ }, arguments); },
1810
+ __wbg_value_0546255b415e96c1: function(arg0) {
1811
+ const ret = arg0.value;
1812
+ return ret;
1813
+ },
1814
+ __wbg_versions_4e31226f5e8dc909: function(arg0) {
1815
+ const ret = arg0.versions;
1816
+ return ret;
1817
+ },
1818
+ __wbg_warn_a40b971467b219c7: function(arg0, arg1, arg2, arg3) {
1819
+ console.warn(arg0, arg1, arg2, arg3);
1820
+ },
1821
+ __wbg_write_18bb6149b26694db: function() { return handleError(function (arg0, arg1) {
1822
+ const ret = arg0.write(arg1);
1823
+ return ret;
1824
+ }, arguments); },
1825
+ __wbindgen_cast_0000000000000001: function(arg0, arg1) {
1826
+ // Cast intrinsic for `Closure(Closure { dtor_idx: 606, function: Function { arguments: [NamedExternref("Event")], shim_idx: 609, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
1827
+ const ret = makeMutClosure(arg0, arg1, wasm.wasm_bindgen__closure__destroy__h137d52471f521a66, wasm_bindgen__convert__closures_____invoke__h23e9ca6af2643a78);
1828
+ return ret;
1829
+ },
1830
+ __wbindgen_cast_0000000000000002: function(arg0, arg1) {
1831
+ // Cast intrinsic for `Closure(Closure { dtor_idx: 606, function: Function { arguments: [NamedExternref("IDBVersionChangeEvent")], shim_idx: 607, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
1832
+ const ret = makeMutClosure(arg0, arg1, wasm.wasm_bindgen__closure__destroy__h137d52471f521a66, wasm_bindgen__convert__closures_____invoke__hb2c8b70415be0174);
1833
+ return ret;
1834
+ },
1835
+ __wbindgen_cast_0000000000000003: function(arg0, arg1) {
1836
+ // Cast intrinsic for `Closure(Closure { dtor_idx: 710, function: Function { arguments: [NamedExternref("Event")], shim_idx: 711, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
1837
+ const ret = makeMutClosure(arg0, arg1, wasm.wasm_bindgen__closure__destroy__h4b2a5ceca2370348, wasm_bindgen__convert__closures_____invoke__h1598c516b2d5b326);
1838
+ return ret;
1839
+ },
1840
+ __wbindgen_cast_0000000000000004: function(arg0, arg1) {
1841
+ // Cast intrinsic for `Closure(Closure { dtor_idx: 736, function: Function { arguments: [Externref], shim_idx: 737, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
1842
+ const ret = makeMutClosure(arg0, arg1, wasm.wasm_bindgen__closure__destroy__hf59ea51dfabf38c5, wasm_bindgen__convert__closures_____invoke__ha6231ef7710d1c67);
1843
+ return ret;
1844
+ },
1845
+ __wbindgen_cast_0000000000000005: function(arg0) {
1846
+ // Cast intrinsic for `F64 -> Externref`.
1847
+ const ret = arg0;
1848
+ return ret;
1849
+ },
1850
+ __wbindgen_cast_0000000000000006: function(arg0) {
1851
+ // Cast intrinsic for `I64 -> Externref`.
1852
+ const ret = arg0;
1853
+ return ret;
1854
+ },
1855
+ __wbindgen_cast_0000000000000007: function(arg0, arg1) {
1856
+ // Cast intrinsic for `Ref(Slice(U8)) -> NamedExternref("Uint8Array")`.
1857
+ const ret = getArrayU8FromWasm0(arg0, arg1);
1858
+ return ret;
1859
+ },
1860
+ __wbindgen_cast_0000000000000008: function(arg0, arg1) {
1861
+ // Cast intrinsic for `Ref(String) -> Externref`.
1862
+ const ret = getStringFromWasm0(arg0, arg1);
1863
+ return ret;
1864
+ },
1865
+ __wbindgen_cast_0000000000000009: function(arg0) {
1866
+ // Cast intrinsic for `U64 -> Externref`.
1867
+ const ret = BigInt.asUintN(64, arg0);
1868
+ return ret;
1869
+ },
1870
+ __wbindgen_init_externref_table: function() {
1871
+ const table = wasm.__wbindgen_externrefs;
1872
+ const offset = table.grow(4);
1873
+ table.set(0, undefined);
1874
+ table.set(offset + 0, undefined);
1875
+ table.set(offset + 1, null);
1876
+ table.set(offset + 2, true);
1877
+ table.set(offset + 3, false);
1878
+ },
1879
+ };
1880
+ return {
1881
+ __proto__: null,
1882
+ "./diaryx_wasm_bg.js": import0,
1883
+ };
1884
+ }
1885
+
1886
+ function wasm_bindgen__convert__closures_____invoke__hb2c8b70415be0174(arg0, arg1, arg2) {
1887
+ wasm.wasm_bindgen__convert__closures_____invoke__hb2c8b70415be0174(arg0, arg1, arg2);
1888
+ }
1889
+
1890
+ function wasm_bindgen__convert__closures_____invoke__h1598c516b2d5b326(arg0, arg1, arg2) {
1891
+ wasm.wasm_bindgen__convert__closures_____invoke__h1598c516b2d5b326(arg0, arg1, arg2);
1892
+ }
1893
+
1894
+ function wasm_bindgen__convert__closures_____invoke__ha6231ef7710d1c67(arg0, arg1, arg2) {
1895
+ wasm.wasm_bindgen__convert__closures_____invoke__ha6231ef7710d1c67(arg0, arg1, arg2);
1896
+ }
1897
+
1898
+ function wasm_bindgen__convert__closures_____invoke__h23e9ca6af2643a78(arg0, arg1, arg2) {
1899
+ const ret = wasm.wasm_bindgen__convert__closures_____invoke__h23e9ca6af2643a78(arg0, arg1, arg2);
1900
+ if (ret[1]) {
1901
+ throw takeFromExternrefTable0(ret[0]);
1902
+ }
1903
+ }
1904
+
1905
+ function wasm_bindgen__convert__closures_____invoke__hcef8d709b492a91f(arg0, arg1, arg2, arg3) {
1906
+ wasm.wasm_bindgen__convert__closures_____invoke__hcef8d709b492a91f(arg0, arg1, arg2, arg3);
1907
+ }
1908
+
1909
+
1910
+ const __wbindgen_enum_IdbCursorDirection = ["next", "nextunique", "prev", "prevunique"];
1911
+
1912
+
1913
+ const __wbindgen_enum_IdbTransactionMode = ["readonly", "readwrite", "versionchange", "readwriteflush", "cleanup"];
1914
+ const DiaryxBackendFinalization = (typeof FinalizationRegistry === 'undefined')
1915
+ ? { register: () => {}, unregister: () => {} }
1916
+ : new FinalizationRegistry(ptr => wasm.__wbg_diaryxbackend_free(ptr >>> 0, 1));
1917
+ const FsaFileSystemFinalization = (typeof FinalizationRegistry === 'undefined')
1918
+ ? { register: () => {}, unregister: () => {} }
1919
+ : new FinalizationRegistry(ptr => wasm.__wbg_fsafilesystem_free(ptr >>> 0, 1));
1920
+ const IndexedDbFileSystemFinalization = (typeof FinalizationRegistry === 'undefined')
1921
+ ? { register: () => {}, unregister: () => {} }
1922
+ : new FinalizationRegistry(ptr => wasm.__wbg_indexeddbfilesystem_free(ptr >>> 0, 1));
1923
+ const JsAsyncFileSystemFinalization = (typeof FinalizationRegistry === 'undefined')
1924
+ ? { register: () => {}, unregister: () => {} }
1925
+ : new FinalizationRegistry(ptr => wasm.__wbg_jsasyncfilesystem_free(ptr >>> 0, 1));
1926
+ const OpfsFileSystemFinalization = (typeof FinalizationRegistry === 'undefined')
1927
+ ? { register: () => {}, unregister: () => {} }
1928
+ : new FinalizationRegistry(ptr => wasm.__wbg_opfsfilesystem_free(ptr >>> 0, 1));
1929
+ const WasmSyncClientFinalization = (typeof FinalizationRegistry === 'undefined')
1930
+ ? { register: () => {}, unregister: () => {} }
1931
+ : new FinalizationRegistry(ptr => wasm.__wbg_wasmsyncclient_free(ptr >>> 0, 1));
1932
+
1933
+ function addToExternrefTable0(obj) {
1934
+ const idx = wasm.__externref_table_alloc();
1935
+ wasm.__wbindgen_externrefs.set(idx, obj);
1936
+ return idx;
1937
+ }
1938
+
1939
+ const CLOSURE_DTORS = (typeof FinalizationRegistry === 'undefined')
1940
+ ? { register: () => {}, unregister: () => {} }
1941
+ : new FinalizationRegistry(state => state.dtor(state.a, state.b));
1942
+
1943
+ function debugString(val) {
1944
+ // primitive types
1945
+ const type = typeof val;
1946
+ if (type == 'number' || type == 'boolean' || val == null) {
1947
+ return `${val}`;
1948
+ }
1949
+ if (type == 'string') {
1950
+ return `"${val}"`;
1951
+ }
1952
+ if (type == 'symbol') {
1953
+ const description = val.description;
1954
+ if (description == null) {
1955
+ return 'Symbol';
1956
+ } else {
1957
+ return `Symbol(${description})`;
1958
+ }
1959
+ }
1960
+ if (type == 'function') {
1961
+ const name = val.name;
1962
+ if (typeof name == 'string' && name.length > 0) {
1963
+ return `Function(${name})`;
1964
+ } else {
1965
+ return 'Function';
1966
+ }
1967
+ }
1968
+ // objects
1969
+ if (Array.isArray(val)) {
1970
+ const length = val.length;
1971
+ let debug = '[';
1972
+ if (length > 0) {
1973
+ debug += debugString(val[0]);
1974
+ }
1975
+ for(let i = 1; i < length; i++) {
1976
+ debug += ', ' + debugString(val[i]);
1977
+ }
1978
+ debug += ']';
1979
+ return debug;
1980
+ }
1981
+ // Test for built-in
1982
+ const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val));
1983
+ let className;
1984
+ if (builtInMatches && builtInMatches.length > 1) {
1985
+ className = builtInMatches[1];
1986
+ } else {
1987
+ // Failed to match the standard '[object ClassName]'
1988
+ return toString.call(val);
1989
+ }
1990
+ if (className == 'Object') {
1991
+ // we're a user defined class or Object
1992
+ // JSON.stringify avoids problems with cycles, and is generally much
1993
+ // easier than looping through ownProperties of `val`.
1994
+ try {
1995
+ return 'Object(' + JSON.stringify(val) + ')';
1996
+ } catch (_) {
1997
+ return 'Object';
1998
+ }
1999
+ }
2000
+ // errors
2001
+ if (val instanceof Error) {
2002
+ return `${val.name}: ${val.message}\n${val.stack}`;
2003
+ }
2004
+ // TODO we could test for more things here, like `Set`s and `Map`s.
2005
+ return className;
2006
+ }
2007
+
2008
+ function getArrayU8FromWasm0(ptr, len) {
2009
+ ptr = ptr >>> 0;
2010
+ return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
2011
+ }
2012
+
2013
+ let cachedDataViewMemory0 = null;
2014
+ function getDataViewMemory0() {
2015
+ if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
2016
+ cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
2017
+ }
2018
+ return cachedDataViewMemory0;
2019
+ }
2020
+
2021
+ function getStringFromWasm0(ptr, len) {
2022
+ ptr = ptr >>> 0;
2023
+ return decodeText(ptr, len);
2024
+ }
2025
+
2026
+ let cachedUint8ArrayMemory0 = null;
2027
+ function getUint8ArrayMemory0() {
2028
+ if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
2029
+ cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
2030
+ }
2031
+ return cachedUint8ArrayMemory0;
2032
+ }
2033
+
2034
+ function handleError(f, args) {
2035
+ try {
2036
+ return f.apply(this, args);
2037
+ } catch (e) {
2038
+ const idx = addToExternrefTable0(e);
2039
+ wasm.__wbindgen_exn_store(idx);
2040
+ }
2041
+ }
2042
+
2043
+ function isLikeNone(x) {
2044
+ return x === undefined || x === null;
2045
+ }
2046
+
2047
+ function makeMutClosure(arg0, arg1, dtor, f) {
2048
+ const state = { a: arg0, b: arg1, cnt: 1, dtor };
2049
+ const real = (...args) => {
2050
+
2051
+ // First up with a closure we increment the internal reference
2052
+ // count. This ensures that the Rust closure environment won't
2053
+ // be deallocated while we're invoking it.
2054
+ state.cnt++;
2055
+ const a = state.a;
2056
+ state.a = 0;
2057
+ try {
2058
+ return f(a, state.b, ...args);
2059
+ } finally {
2060
+ state.a = a;
2061
+ real._wbg_cb_unref();
2062
+ }
2063
+ };
2064
+ real._wbg_cb_unref = () => {
2065
+ if (--state.cnt === 0) {
2066
+ state.dtor(state.a, state.b);
2067
+ state.a = 0;
2068
+ CLOSURE_DTORS.unregister(state);
2069
+ }
2070
+ };
2071
+ CLOSURE_DTORS.register(real, state, state);
2072
+ return real;
2073
+ }
2074
+
2075
+ function passArray8ToWasm0(arg, malloc) {
2076
+ const ptr = malloc(arg.length * 1, 1) >>> 0;
2077
+ getUint8ArrayMemory0().set(arg, ptr / 1);
2078
+ WASM_VECTOR_LEN = arg.length;
2079
+ return ptr;
2080
+ }
2081
+
2082
+ function passArrayJsValueToWasm0(array, malloc) {
2083
+ const ptr = malloc(array.length * 4, 4) >>> 0;
2084
+ for (let i = 0; i < array.length; i++) {
2085
+ const add = addToExternrefTable0(array[i]);
2086
+ getDataViewMemory0().setUint32(ptr + 4 * i, add, true);
2087
+ }
2088
+ WASM_VECTOR_LEN = array.length;
2089
+ return ptr;
2090
+ }
2091
+
2092
+ function passStringToWasm0(arg, malloc, realloc) {
2093
+ if (realloc === undefined) {
2094
+ const buf = cachedTextEncoder.encode(arg);
2095
+ const ptr = malloc(buf.length, 1) >>> 0;
2096
+ getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
2097
+ WASM_VECTOR_LEN = buf.length;
2098
+ return ptr;
2099
+ }
2100
+
2101
+ let len = arg.length;
2102
+ let ptr = malloc(len, 1) >>> 0;
2103
+
2104
+ const mem = getUint8ArrayMemory0();
2105
+
2106
+ let offset = 0;
2107
+
2108
+ for (; offset < len; offset++) {
2109
+ const code = arg.charCodeAt(offset);
2110
+ if (code > 0x7F) break;
2111
+ mem[ptr + offset] = code;
2112
+ }
2113
+ if (offset !== len) {
2114
+ if (offset !== 0) {
2115
+ arg = arg.slice(offset);
2116
+ }
2117
+ ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
2118
+ const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
2119
+ const ret = cachedTextEncoder.encodeInto(arg, view);
2120
+
2121
+ offset += ret.written;
2122
+ ptr = realloc(ptr, len, offset, 1) >>> 0;
2123
+ }
2124
+
2125
+ WASM_VECTOR_LEN = offset;
2126
+ return ptr;
2127
+ }
2128
+
2129
+ function takeFromExternrefTable0(idx) {
2130
+ const value = wasm.__wbindgen_externrefs.get(idx);
2131
+ wasm.__externref_table_dealloc(idx);
2132
+ return value;
2133
+ }
2134
+
2135
+ let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
2136
+ cachedTextDecoder.decode();
2137
+ const MAX_SAFARI_DECODE_BYTES = 2146435072;
2138
+ let numBytesDecoded = 0;
2139
+ function decodeText(ptr, len) {
2140
+ numBytesDecoded += len;
2141
+ if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
2142
+ cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
2143
+ cachedTextDecoder.decode();
2144
+ numBytesDecoded = len;
2145
+ }
2146
+ return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
2147
+ }
2148
+
2149
+ const cachedTextEncoder = new TextEncoder();
2150
+
2151
+ if (!('encodeInto' in cachedTextEncoder)) {
2152
+ cachedTextEncoder.encodeInto = function (arg, view) {
2153
+ const buf = cachedTextEncoder.encode(arg);
2154
+ view.set(buf);
2155
+ return {
2156
+ read: arg.length,
2157
+ written: buf.length
2158
+ };
2159
+ };
2160
+ }
2161
+
2162
+ let WASM_VECTOR_LEN = 0;
2163
+
2164
+ let wasmModule, wasm;
2165
+ function __wbg_finalize_init(instance, module) {
2166
+ wasm = instance.exports;
2167
+ wasmModule = module;
2168
+ cachedDataViewMemory0 = null;
2169
+ cachedUint8ArrayMemory0 = null;
2170
+ wasm.__wbindgen_start();
2171
+ return wasm;
2172
+ }
2173
+
2174
+ async function __wbg_load(module, imports) {
2175
+ if (typeof Response === 'function' && module instanceof Response) {
2176
+ if (typeof WebAssembly.instantiateStreaming === 'function') {
2177
+ try {
2178
+ return await WebAssembly.instantiateStreaming(module, imports);
2179
+ } catch (e) {
2180
+ const validResponse = module.ok && expectedResponseType(module.type);
2181
+
2182
+ if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
2183
+ 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);
2184
+
2185
+ } else { throw e; }
2186
+ }
2187
+ }
2188
+
2189
+ const bytes = await module.arrayBuffer();
2190
+ return await WebAssembly.instantiate(bytes, imports);
2191
+ } else {
2192
+ const instance = await WebAssembly.instantiate(module, imports);
2193
+
2194
+ if (instance instanceof WebAssembly.Instance) {
2195
+ return { instance, module };
2196
+ } else {
2197
+ return instance;
2198
+ }
2199
+ }
2200
+
2201
+ function expectedResponseType(type) {
2202
+ switch (type) {
2203
+ case 'basic': case 'cors': case 'default': return true;
2204
+ }
2205
+ return false;
2206
+ }
2207
+ }
2208
+
2209
+ function initSync(module) {
2210
+ if (wasm !== undefined) return wasm;
2211
+
2212
+
2213
+ if (module !== undefined) {
2214
+ if (Object.getPrototypeOf(module) === Object.prototype) {
2215
+ ({module} = module)
2216
+ } else {
2217
+ console.warn('using deprecated parameters for `initSync()`; pass a single object instead')
2218
+ }
2219
+ }
2220
+
2221
+ const imports = __wbg_get_imports();
2222
+ if (!(module instanceof WebAssembly.Module)) {
2223
+ module = new WebAssembly.Module(module);
2224
+ }
2225
+ const instance = new WebAssembly.Instance(module, imports);
2226
+ return __wbg_finalize_init(instance, module);
2227
+ }
2228
+
2229
+ async function __wbg_init(module_or_path) {
2230
+ if (wasm !== undefined) return wasm;
2231
+
2232
+
2233
+ if (module_or_path !== undefined) {
2234
+ if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
2235
+ ({module_or_path} = module_or_path)
2236
+ } else {
2237
+ console.warn('using deprecated parameters for the initialization function; pass a single object instead')
2238
+ }
2239
+ }
2240
+
2241
+ if (module_or_path === undefined) {
2242
+ module_or_path = new URL('diaryx_wasm_bg.wasm', import.meta.url);
2243
+ }
2244
+ const imports = __wbg_get_imports();
2245
+
2246
+ if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {
2247
+ module_or_path = fetch(module_or_path);
2248
+ }
2249
+
2250
+ const { instance, module } = await __wbg_load(await module_or_path, imports);
2251
+
2252
+ return __wbg_finalize_init(instance, module);
2253
+ }
2254
+
2255
+ export { initSync, __wbg_init as default };