@diaryx/wasm 1.2.0-dev.d069796 → 1.2.1-dev.34fd175

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/README.md CHANGED
@@ -47,31 +47,25 @@ Current filesystem test suites live in:
47
47
 
48
48
  ## Architecture
49
49
 
50
- The crate provides typed class-based APIs that wrap `diaryx_core` functionality:
50
+ `diaryx_wasm` depends only on `diaryx_core`. The main entry point is `DiaryxBackend`,
51
+ which provides a unified command API (`execute()`/`executeJs()`) backed by native
52
+ browser storage (OPFS, IndexedDB, File System Access API).
51
53
 
54
+ Sync and publish functionality are provided by Extism guest plugins
55
+ (`diaryx_sync.wasm`, `diaryx_publish.wasm`) loaded at runtime by the browser
56
+ plugin manager. CRDT commands are routed to the sync plugin via the frontend
57
+ command router before reaching the WASM backend.
52
58
 
53
- | Class | Purpose |
54
- | ----------------------- | ----------------------------------------- |
55
- | `DiaryxWorkspace` | Workspace tree operations |
56
- | `DiaryxEntry` | Entry CRUD operations |
57
- | `DiaryxFrontmatter` | Frontmatter manipulation |
58
- | `DiaryxSearch` | Workspace search |
59
- | `DiaryxTemplate` | Template management |
60
- | `DiaryxValidation` | Link integrity validation and fixing |
61
- | `DiaryxExport` | Export with audience filtering |
62
- | `DiaryxAttachment` | Attachment upload/download |
63
- | `DiaryxFilesystem` | Low-level filesystem operations (sync) |
64
- | `DiaryxAsyncFilesystem` | Async filesystem operations with Promises |
65
- | `Diaryx` | Unified command API (includes CRDT ops) |
59
+ ### Storage Backends
66
60
 
61
+ Unlike the CLI and Tauri backends which use `RealFileSystem` (native filesystem),
62
+ the WASM backend supports several browser storage backends:
67
63
 
68
- ### In-Memory Filesystem
69
-
70
- Unlike the CLI and Tauri backends which use `RealFileSystem` (native filesystem), the WASM backend uses `InMemoryFileSystem`. This allows the web app to:
71
-
72
- 1. Load files from IndexedDB on startup
73
- 2. Operate entirely in memory during use
74
- 3. Persist changes back to IndexedDB
64
+ - **OPFS** — Origin Private File System (default)
65
+ - **IndexedDB** — IndexedDB-based filesystem
66
+ - **File System Access** User-selected directory on the real filesystem
67
+ - **In-Memory** — Used for guest mode in share sessions
68
+ - **JavaScript** Bridged to external JS filesystem (Node.js, Obsidian, Electron)
75
69
 
76
70
  ## API Reference
77
71
 
package/diaryx_wasm.d.ts CHANGED
@@ -122,129 +122,24 @@ export class DiaryxBackend {
122
122
  static create(storage_type: string): Promise<DiaryxBackend>;
123
123
  /**
124
124
  * Create a new DiaryxBackend from a user-selected directory handle.
125
- *
126
- * This uses the File System Access API to read/write files directly
127
- * on the user's filesystem. The handle must be obtained from
128
- * `window.showDirectoryPicker()` in JavaScript.
129
- *
130
- * ## Browser Support
131
- * - Chrome/Edge: ✅ Supported
132
- * - Firefox: ❌ Not supported
133
- * - Safari: ❌ Not supported
134
- *
135
- * ## Example
136
- * ```javascript
137
- * // User must trigger this via a gesture (click/keypress)
138
- * const dirHandle = await window.showDirectoryPicker();
139
- * const backend = await DiaryxBackend.createFromDirectoryHandle(dirHandle);
140
- * ```
141
125
  */
142
126
  static createFromDirectoryHandle(handle: FileSystemDirectoryHandle): DiaryxBackend;
143
127
  /**
144
128
  * Create a new DiaryxBackend backed by JavaScript filesystem callbacks.
145
- *
146
- * This is the primary way to use diaryx from non-browser environments
147
- * (Node.js, Obsidian, Electron). The `callbacks` object must implement
148
- * the `JsFileSystemCallbacks` interface.
149
- *
150
- * ## Example
151
- * ```javascript
152
- * const backend = DiaryxBackend.createFromJsFileSystem({
153
- * readToString: async (path) => fs.readFile(path, 'utf8'),
154
- * writeFile: async (path, content) => fs.writeFile(path, content),
155
- * exists: async (path) => fs.access(path).then(() => true).catch(() => false),
156
- * // ... other callbacks
157
- * });
158
- * ```
159
129
  */
160
130
  static createFromJsFileSystem(callbacks: any): DiaryxBackend;
161
131
  /**
162
132
  * Create a new DiaryxBackend with in-memory storage.
163
- *
164
- * This is used for guest mode in share sessions. Files are stored
165
- * only in memory and are cleared when the session ends.
166
- *
167
- * ## Use Cases
168
- * - Guest mode in share sessions (web)
169
- * - Testing
170
- *
171
- * ## Example
172
- * ```javascript
173
- * const backend = DiaryxBackend.createInMemory();
174
- * // Files are stored in memory only
175
- * ```
176
133
  */
177
134
  static createInMemory(): DiaryxBackend;
178
135
  /**
179
136
  * Create a new DiaryxBackend with IndexedDB storage.
180
- *
181
- * When `db_name` is provided, uses `"diaryx-{db_name}"` as the database name,
182
- * allowing per-workspace isolation. When `None`, uses the legacy database name.
183
- *
184
- * This attempts to use persistent SQLite-based CRDT storage (via sql.js).
185
- * If SQLite storage is not available, falls back to in-memory CRDT storage.
186
137
  */
187
138
  static createIndexedDb(db_name?: string | null): Promise<DiaryxBackend>;
188
139
  /**
189
140
  * Create a new DiaryxBackend with OPFS storage.
190
- *
191
- * This attempts to use persistent SQLite-based CRDT storage (via sql.js).
192
- * If SQLite storage is not available (JS bridge not initialized), falls back
193
- * to in-memory CRDT storage.
194
- *
195
- * For persistent CRDT storage, call `initializeSqliteStorage()` in JavaScript
196
- * before creating the backend:
197
- *
198
- * ```javascript
199
- * import { initializeSqliteStorage } from './lib/storage/sqliteStorageBridge.js';
200
- * await initializeSqliteStorage();
201
- * const backend = await DiaryxBackend.createOpfs('My Journal');
202
- * ```
203
141
  */
204
142
  static createOpfs(root_name?: string | null): Promise<DiaryxBackend>;
205
- /**
206
- * Create a new sync client for the given server and workspace.
207
- *
208
- * Creates a `WasmSyncClient` backed by the shared `SyncSession` protocol
209
- * handler. JavaScript manages the WebSocket while Rust handles all sync
210
- * protocol logic (handshake, message routing, framing).
211
- *
212
- * ## Example
213
- *
214
- * ```javascript
215
- * const client = backend.createSyncClient(
216
- * 'https://sync.example.com',
217
- * 'my-workspace-id',
218
- * 'auth-token-optional'
219
- * );
220
- *
221
- * // Get the WebSocket URL
222
- * const wsUrl = client.getWsUrl();
223
- * const ws = new WebSocket(wsUrl);
224
- * ws.binaryType = 'arraybuffer';
225
- *
226
- * ws.onopen = async () => {
227
- * await client.onConnected();
228
- * // Drain outgoing messages
229
- * let msg;
230
- * while ((msg = client.pollOutgoingBinary())) ws.send(msg);
231
- * while ((msg = client.pollOutgoingText())) ws.send(msg);
232
- * };
233
- *
234
- * ws.onmessage = async (e) => {
235
- * if (typeof e.data === 'string') {
236
- * await client.onTextMessage(e.data);
237
- * } else {
238
- * await client.onBinaryMessage(new Uint8Array(e.data));
239
- * }
240
- * // Drain outgoing messages and events
241
- * let msg;
242
- * while ((msg = client.pollOutgoingBinary())) ws.send(msg);
243
- * while ((msg = client.pollOutgoingText())) ws.send(msg);
244
- * };
245
- * ```
246
- */
247
- createSyncClient(server_url: string, workspace_id: string, auth_token?: string | null): WasmSyncClient;
248
143
  /**
249
144
  * Emit a filesystem event.
250
145
  *
@@ -294,13 +189,11 @@ export class DiaryxBackend {
294
189
  getConfig(): Promise<any>;
295
190
  /**
296
191
  * Check if this backend has native sync support.
297
- *
298
- * For WASM, this always returns false. The new `createSyncClient()` API
299
- * provides a unified approach that works across all platforms.
192
+ * Always false — sync is handled by the Extism sync plugin loaded at runtime.
300
193
  */
301
194
  hasNativeSync(): boolean;
302
195
  /**
303
- * Check whether CrdtFs is currently enabled.
196
+ * Always returns false — CrdtFs is not used; sync handled by Extism plugin.
304
197
  */
305
198
  isCrdtEnabled(): boolean;
306
199
  /**
@@ -339,35 +232,6 @@ export class DiaryxBackend {
339
232
  * ```
340
233
  */
341
234
  onFileSystemEvent(callback: Function): bigint;
342
- /**
343
- * Parse a Day One export (ZIP or JSON) and return entries as JSON.
344
- *
345
- * Auto-detects the format: ZIP files (with media directories) have
346
- * attachments populated with binary data. Plain JSON files are parsed
347
- * with empty attachment data (backward compatible).
348
- *
349
- * ## Example
350
- * ```javascript
351
- * const bytes = new Uint8Array(await file.arrayBuffer());
352
- * const result = backend.parseDayOneJson(bytes);
353
- * const { entries, errors } = JSON.parse(result);
354
- * ```
355
- */
356
- parseDayOneJson(bytes: Uint8Array): string;
357
- /**
358
- * Parse a single markdown file and return the entry as JSON.
359
- *
360
- * Takes the raw bytes of a `.md` file and its filename, and returns
361
- * a JSON-serialized `ImportedEntry`.
362
- *
363
- * ## Example
364
- * ```javascript
365
- * const bytes = new Uint8Array(await file.arrayBuffer());
366
- * const entryJson = backend.parseMarkdownFile(bytes, file.name);
367
- * const entry = JSON.parse(entryJson);
368
- * ```
369
- */
370
- parseMarkdownFile(bytes: Uint8Array, filename: string): string;
371
235
  /**
372
236
  * Read binary file.
373
237
  *
@@ -380,13 +244,9 @@ export class DiaryxBackend {
380
244
  */
381
245
  saveConfig(config_js: any): Promise<any>;
382
246
  /**
383
- * Enable or disable the CrdtFs decorator.
384
- *
385
- * When disabled, file writes pass through to storage without updating CRDTs.
386
- * CrdtFs starts disabled by default and should be enabled after sync
387
- * handshake completes (or immediately in local-only mode).
247
+ * No-op CrdtFs is not used; sync handled by Extism plugin.
388
248
  */
389
- setCrdtEnabled(enabled: boolean): void;
249
+ setCrdtEnabled(_enabled: boolean): void;
390
250
  /**
391
251
  * Write binary file.
392
252
  *
@@ -495,118 +355,6 @@ export class OpfsFileSystem {
495
355
  static createWithName(root_name: string): Promise<OpfsFileSystem>;
496
356
  }
497
357
 
498
- /**
499
- * WASM sync client backed by the shared SyncSession protocol handler.
500
- *
501
- * JavaScript feeds WebSocket events in via `onConnected()`, `onBinaryMessage()`,
502
- * etc. The client processes them through `SyncSession` and queues outgoing
503
- * messages/events for JavaScript to poll.
504
- */
505
- export class WasmSyncClient {
506
- private constructor();
507
- free(): void;
508
- [Symbol.dispose](): void;
509
- /**
510
- * Send a focus message for specific files.
511
- *
512
- * Other clients will be notified which files this client is interested in.
513
- */
514
- focusFiles(files: string[]): void;
515
- /**
516
- * Get the server URL.
517
- */
518
- getServerUrl(): string;
519
- /**
520
- * Get the workspace ID.
521
- */
522
- getWorkspaceId(): string;
523
- /**
524
- * Get the WebSocket URL for the v2 sync connection.
525
- *
526
- * Returns a URL like `wss://sync.example.com/sync2?token=...&session=...`
527
- */
528
- getWsUrl(): string;
529
- /**
530
- * Check if there are pending events.
531
- */
532
- hasEvents(): boolean;
533
- /**
534
- * Check if there are pending outgoing messages or events.
535
- */
536
- hasOutgoing(): boolean;
537
- /**
538
- * Inject an incoming binary WebSocket message.
539
- *
540
- * Returns a Promise that resolves when processing is complete.
541
- * After this, poll outgoing queues.
542
- */
543
- onBinaryMessage(data: Uint8Array): Promise<any>;
544
- /**
545
- * Notify that the WebSocket connected.
546
- *
547
- * Triggers workspace SyncStep1 and handshake. After calling this,
548
- * poll `pollOutgoingBinary()` / `pollOutgoingText()` to get messages to send.
549
- */
550
- onConnected(): Promise<any>;
551
- /**
552
- * Notify that the WebSocket disconnected.
553
- */
554
- onDisconnected(): Promise<any>;
555
- /**
556
- * Notify that a snapshot was downloaded and imported.
557
- *
558
- * Call this after handling a `downloadSnapshot` event.
559
- */
560
- onSnapshotImported(): Promise<any>;
561
- /**
562
- * Inject an incoming text WebSocket message (JSON control message).
563
- *
564
- * Returns a Promise that resolves when processing is complete.
565
- */
566
- onTextMessage(text: string): Promise<any>;
567
- /**
568
- * Poll for a JSON-serialized event.
569
- *
570
- * Returns a JSON string representing a SyncEvent, or null.
571
- */
572
- pollEvent(): string | undefined;
573
- /**
574
- * Poll for an outgoing binary message.
575
- *
576
- * Returns a Uint8Array if there's a message to send, null otherwise.
577
- */
578
- pollOutgoingBinary(): Uint8Array | undefined;
579
- /**
580
- * Poll for an outgoing text message.
581
- *
582
- * Returns a string if there's a message to send, null otherwise.
583
- */
584
- pollOutgoingText(): string | undefined;
585
- /**
586
- * Queue a local CRDT update for sending to the server.
587
- *
588
- * Call this when local CRDT changes need to be synced.
589
- */
590
- queueLocalUpdate(doc_id: string, data: Uint8Array): Promise<any>;
591
- /**
592
- * Set a share session code.
593
- *
594
- * Call this before connecting to join a share session.
595
- */
596
- setSessionCode(code: string): void;
597
- /**
598
- * Request body sync for specific files (lazy sync on demand).
599
- *
600
- * Sends SyncBodyFiles event through the session to initiate body
601
- * SyncStep1 for just the requested files, rather than all files.
602
- */
603
- syncBodyFiles(file_paths: string[]): Promise<any>;
604
- /**
605
- * Send an unfocus message for specific files.
606
- */
607
- unfocusFiles(files: string[]): void;
608
- }
609
-
610
358
  /**
611
359
  * Initialize the WASM module. Called automatically on module load.
612
360
  */
@@ -626,70 +374,48 @@ export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembl
626
374
 
627
375
  export interface InitOutput {
628
376
  readonly memory: WebAssembly.Memory;
629
- readonly __wbg_jsasyncfilesystem_free: (a: number, b: number) => void;
630
- readonly __wbg_wasmsyncclient_free: (a: number, b: number) => void;
631
- readonly jsasyncfilesystem_has_callback: (a: number, b: number, c: number) => number;
632
- readonly jsasyncfilesystem_new: (a: any) => number;
633
- readonly wasmsyncclient_focusFiles: (a: number, b: number, c: number) => void;
634
- readonly wasmsyncclient_getServerUrl: (a: number) => [number, number];
635
- readonly wasmsyncclient_getWorkspaceId: (a: number) => [number, number];
636
- readonly wasmsyncclient_getWsUrl: (a: number) => [number, number];
637
- readonly wasmsyncclient_hasEvents: (a: number) => number;
638
- readonly wasmsyncclient_hasOutgoing: (a: number) => number;
639
- readonly wasmsyncclient_onBinaryMessage: (a: number, b: number, c: number) => any;
640
- readonly wasmsyncclient_onConnected: (a: number) => any;
641
- readonly wasmsyncclient_onDisconnected: (a: number) => any;
642
- readonly wasmsyncclient_onSnapshotImported: (a: number) => any;
643
- readonly wasmsyncclient_onTextMessage: (a: number, b: number, c: number) => any;
644
- readonly wasmsyncclient_pollEvent: (a: number) => [number, number];
645
- readonly wasmsyncclient_pollOutgoingBinary: (a: number) => any;
646
- readonly wasmsyncclient_pollOutgoingText: (a: number) => [number, number];
647
- readonly wasmsyncclient_queueLocalUpdate: (a: number, b: number, c: number, d: number, e: number) => any;
648
- readonly wasmsyncclient_setSessionCode: (a: number, b: number, c: number) => void;
649
- readonly wasmsyncclient_syncBodyFiles: (a: number, b: number, c: number) => any;
650
- readonly wasmsyncclient_unfocusFiles: (a: number, b: number, c: number) => void;
651
- readonly __wbg_indexeddbfilesystem_free: (a: number, b: number) => void;
652
- readonly __wbg_opfsfilesystem_free: (a: number, b: number) => void;
653
- readonly indexeddbfilesystem_create: () => any;
654
- readonly indexeddbfilesystem_createWithName: (a: number, b: number) => any;
655
- readonly opfsfilesystem_create: () => any;
656
- readonly opfsfilesystem_createWithName: (a: number, b: number) => any;
657
377
  readonly __wbg_diaryxbackend_free: (a: number, b: number) => void;
378
+ readonly __wbg_fsafilesystem_free: (a: number, b: number) => void;
379
+ readonly __wbg_indexeddbfilesystem_free: (a: number, b: number) => void;
380
+ readonly __wbg_jsasyncfilesystem_free: (a: number, b: number) => void;
658
381
  readonly diaryxbackend_create: (a: number, b: number) => any;
659
382
  readonly diaryxbackend_createFromDirectoryHandle: (a: any) => [number, number, number];
660
383
  readonly diaryxbackend_createFromJsFileSystem: (a: any) => [number, number, number];
661
384
  readonly diaryxbackend_createInMemory: () => [number, number, number];
662
385
  readonly diaryxbackend_createIndexedDb: (a: number, b: number) => any;
663
386
  readonly diaryxbackend_createOpfs: (a: number, b: number) => any;
664
- readonly diaryxbackend_createSyncClient: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => number;
665
387
  readonly diaryxbackend_emitFileSystemEvent: (a: number, b: number, c: number) => [number, number];
666
388
  readonly diaryxbackend_eventSubscriberCount: (a: number) => number;
667
389
  readonly diaryxbackend_execute: (a: number, b: number, c: number) => any;
668
390
  readonly diaryxbackend_executeJs: (a: number, b: any) => any;
669
391
  readonly diaryxbackend_getConfig: (a: number) => any;
670
392
  readonly diaryxbackend_hasNativeSync: (a: number) => number;
671
- readonly diaryxbackend_isCrdtEnabled: (a: number) => number;
672
393
  readonly diaryxbackend_offFileSystemEvent: (a: number, b: bigint) => number;
673
394
  readonly diaryxbackend_onFileSystemEvent: (a: number, b: any) => bigint;
674
- readonly diaryxbackend_parseDayOneJson: (a: number, b: number, c: number) => [number, number, number, number];
675
- readonly diaryxbackend_parseMarkdownFile: (a: number, b: number, c: number, d: number, e: number) => [number, number, number, number];
676
395
  readonly diaryxbackend_readBinary: (a: number, b: number, c: number) => any;
677
396
  readonly diaryxbackend_saveConfig: (a: number, b: any) => any;
678
397
  readonly diaryxbackend_setCrdtEnabled: (a: number, b: number) => void;
679
398
  readonly diaryxbackend_writeBinary: (a: number, b: number, c: number, d: any) => any;
680
- readonly init: () => void;
681
- readonly __wbg_fsafilesystem_free: (a: number, b: number) => void;
682
399
  readonly fsafilesystem_fromHandle: (a: any) => number;
400
+ readonly indexeddbfilesystem_create: () => any;
401
+ readonly indexeddbfilesystem_createWithName: (a: number, b: number) => any;
402
+ readonly jsasyncfilesystem_has_callback: (a: number, b: number, c: number) => number;
683
403
  readonly now_timestamp: () => [number, number];
404
+ readonly opfsfilesystem_create: () => any;
405
+ readonly opfsfilesystem_createWithName: (a: number, b: number) => any;
684
406
  readonly today_formatted: (a: number, b: number) => [number, number];
685
- readonly wasm_bindgen__closure__destroy__h4c3bc21aabb0cdba: (a: number, b: number) => void;
686
- readonly wasm_bindgen__closure__destroy__h54a6b627d1123dca: (a: number, b: number) => void;
687
- readonly wasm_bindgen__closure__destroy__h440f08373ff30a05: (a: number, b: number) => void;
688
- readonly wasm_bindgen__convert__closures_____invoke__hc73185828886e792: (a: number, b: number, c: any) => [number, number];
689
- readonly wasm_bindgen__convert__closures_____invoke__h4e796b59e8c15a06: (a: number, b: number, c: any, d: any) => void;
690
- readonly wasm_bindgen__convert__closures_____invoke__h307b88b750192cbb: (a: number, b: number, c: any) => void;
691
- readonly wasm_bindgen__convert__closures_____invoke__h7d21c95eeb3011e3: (a: number, b: number, c: any) => void;
692
- readonly wasm_bindgen__convert__closures_____invoke__h359356b1e0b37746: (a: number, b: number, c: any) => void;
407
+ readonly diaryxbackend_isCrdtEnabled: (a: number) => number;
408
+ readonly init: () => void;
409
+ readonly jsasyncfilesystem_new: (a: any) => number;
410
+ readonly __wbg_opfsfilesystem_free: (a: number, b: number) => void;
411
+ readonly wasm_bindgen__closure__destroy__h0b58a0de6909981f: (a: number, b: number) => void;
412
+ readonly wasm_bindgen__closure__destroy__h7f33266e75cf6c88: (a: number, b: number) => void;
413
+ readonly wasm_bindgen__closure__destroy__h01a79603ee5b54a9: (a: number, b: number) => void;
414
+ readonly wasm_bindgen__convert__closures_____invoke__h0da01443bd011173: (a: number, b: number, c: any) => [number, number];
415
+ readonly wasm_bindgen__convert__closures_____invoke__h9414502ef6926694: (a: number, b: number, c: any, d: any) => void;
416
+ readonly wasm_bindgen__convert__closures_____invoke__hcc870e2a76176fd3: (a: number, b: number, c: any) => void;
417
+ readonly wasm_bindgen__convert__closures_____invoke__hd537ace161e76dda: (a: number, b: number, c: any) => void;
418
+ readonly wasm_bindgen__convert__closures_____invoke__h66d99b5cef8fbea8: (a: number, b: number, c: any) => void;
693
419
  readonly __wbindgen_malloc: (a: number, b: number) => number;
694
420
  readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
695
421
  readonly __wbindgen_exn_store: (a: number) => void;
package/diaryx_wasm.js CHANGED
@@ -50,22 +50,6 @@ export class DiaryxBackend {
50
50
  }
51
51
  /**
52
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
53
  * @param {FileSystemDirectoryHandle} handle
70
54
  * @returns {DiaryxBackend}
71
55
  */
@@ -78,20 +62,6 @@ export class DiaryxBackend {
78
62
  }
79
63
  /**
80
64
  * Create a new DiaryxBackend backed by JavaScript filesystem callbacks.
81
- *
82
- * This is the primary way to use diaryx from non-browser environments
83
- * (Node.js, Obsidian, Electron). The `callbacks` object must implement
84
- * the `JsFileSystemCallbacks` interface.
85
- *
86
- * ## Example
87
- * ```javascript
88
- * const backend = DiaryxBackend.createFromJsFileSystem({
89
- * readToString: async (path) => fs.readFile(path, 'utf8'),
90
- * writeFile: async (path, content) => fs.writeFile(path, content),
91
- * exists: async (path) => fs.access(path).then(() => true).catch(() => false),
92
- * // ... other callbacks
93
- * });
94
- * ```
95
65
  * @param {any} callbacks
96
66
  * @returns {DiaryxBackend}
97
67
  */
@@ -104,19 +74,6 @@ export class DiaryxBackend {
104
74
  }
105
75
  /**
106
76
  * Create a new DiaryxBackend with in-memory storage.
107
- *
108
- * This is used for guest mode in share sessions. Files are stored
109
- * only in memory and are cleared when the session ends.
110
- *
111
- * ## Use Cases
112
- * - Guest mode in share sessions (web)
113
- * - Testing
114
- *
115
- * ## Example
116
- * ```javascript
117
- * const backend = DiaryxBackend.createInMemory();
118
- * // Files are stored in memory only
119
- * ```
120
77
  * @returns {DiaryxBackend}
121
78
  */
122
79
  static createInMemory() {
@@ -128,12 +85,6 @@ export class DiaryxBackend {
128
85
  }
129
86
  /**
130
87
  * Create a new DiaryxBackend with IndexedDB storage.
131
- *
132
- * When `db_name` is provided, uses `"diaryx-{db_name}"` as the database name,
133
- * allowing per-workspace isolation. When `None`, uses the legacy database name.
134
- *
135
- * This attempts to use persistent SQLite-based CRDT storage (via sql.js).
136
- * If SQLite storage is not available, falls back to in-memory CRDT storage.
137
88
  * @param {string | null} [db_name]
138
89
  * @returns {Promise<DiaryxBackend>}
139
90
  */
@@ -145,19 +96,6 @@ export class DiaryxBackend {
145
96
  }
146
97
  /**
147
98
  * Create a new DiaryxBackend with OPFS storage.
148
- *
149
- * This attempts to use persistent SQLite-based CRDT storage (via sql.js).
150
- * If SQLite storage is not available (JS bridge not initialized), falls back
151
- * to in-memory CRDT storage.
152
- *
153
- * For persistent CRDT storage, call `initializeSqliteStorage()` in JavaScript
154
- * before creating the backend:
155
- *
156
- * ```javascript
157
- * import { initializeSqliteStorage } from './lib/storage/sqliteStorageBridge.js';
158
- * await initializeSqliteStorage();
159
- * const backend = await DiaryxBackend.createOpfs('My Journal');
160
- * ```
161
99
  * @param {string | null} [root_name]
162
100
  * @returns {Promise<DiaryxBackend>}
163
101
  */
@@ -167,62 +105,6 @@ export class DiaryxBackend {
167
105
  const ret = wasm.diaryxbackend_createOpfs(ptr0, len0);
168
106
  return ret;
169
107
  }
170
- /**
171
- * Create a new sync client for the given server and workspace.
172
- *
173
- * Creates a `WasmSyncClient` backed by the shared `SyncSession` protocol
174
- * handler. JavaScript manages the WebSocket while Rust handles all sync
175
- * protocol logic (handshake, message routing, framing).
176
- *
177
- * ## Example
178
- *
179
- * ```javascript
180
- * const client = backend.createSyncClient(
181
- * 'https://sync.example.com',
182
- * 'my-workspace-id',
183
- * 'auth-token-optional'
184
- * );
185
- *
186
- * // Get the WebSocket URL
187
- * const wsUrl = client.getWsUrl();
188
- * const ws = new WebSocket(wsUrl);
189
- * ws.binaryType = 'arraybuffer';
190
- *
191
- * ws.onopen = async () => {
192
- * await client.onConnected();
193
- * // Drain outgoing messages
194
- * let msg;
195
- * while ((msg = client.pollOutgoingBinary())) ws.send(msg);
196
- * while ((msg = client.pollOutgoingText())) ws.send(msg);
197
- * };
198
- *
199
- * ws.onmessage = async (e) => {
200
- * if (typeof e.data === 'string') {
201
- * await client.onTextMessage(e.data);
202
- * } else {
203
- * await client.onBinaryMessage(new Uint8Array(e.data));
204
- * }
205
- * // Drain outgoing messages and events
206
- * let msg;
207
- * while ((msg = client.pollOutgoingBinary())) ws.send(msg);
208
- * while ((msg = client.pollOutgoingText())) ws.send(msg);
209
- * };
210
- * ```
211
- * @param {string} server_url
212
- * @param {string} workspace_id
213
- * @param {string | null} [auth_token]
214
- * @returns {WasmSyncClient}
215
- */
216
- createSyncClient(server_url, workspace_id, auth_token) {
217
- const ptr0 = passStringToWasm0(server_url, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
218
- const len0 = WASM_VECTOR_LEN;
219
- const ptr1 = passStringToWasm0(workspace_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
220
- const len1 = WASM_VECTOR_LEN;
221
- var ptr2 = isLikeNone(auth_token) ? 0 : passStringToWasm0(auth_token, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
222
- var len2 = WASM_VECTOR_LEN;
223
- const ret = wasm.diaryxbackend_createSyncClient(this.__wbg_ptr, ptr0, len0, ptr1, len1, ptr2, len2);
224
- return WasmSyncClient.__wrap(ret);
225
- }
226
108
  /**
227
109
  * Emit a filesystem event.
228
110
  *
@@ -300,9 +182,7 @@ export class DiaryxBackend {
300
182
  }
301
183
  /**
302
184
  * Check if this backend has native sync support.
303
- *
304
- * For WASM, this always returns false. The new `createSyncClient()` API
305
- * provides a unified approach that works across all platforms.
185
+ * Always false — sync is handled by the Extism sync plugin loaded at runtime.
306
186
  * @returns {boolean}
307
187
  */
308
188
  hasNativeSync() {
@@ -310,11 +190,11 @@ export class DiaryxBackend {
310
190
  return ret !== 0;
311
191
  }
312
192
  /**
313
- * Check whether CrdtFs is currently enabled.
193
+ * Always returns false — CrdtFs is not used; sync handled by Extism plugin.
314
194
  * @returns {boolean}
315
195
  */
316
196
  isCrdtEnabled() {
317
- const ret = wasm.diaryxbackend_isCrdtEnabled(this.__wbg_ptr);
197
+ const ret = wasm.diaryxbackend_hasNativeSync(this.__wbg_ptr);
318
198
  return ret !== 0;
319
199
  }
320
200
  /**
@@ -363,80 +243,6 @@ export class DiaryxBackend {
363
243
  const ret = wasm.diaryxbackend_onFileSystemEvent(this.__wbg_ptr, callback);
364
244
  return BigInt.asUintN(64, ret);
365
245
  }
366
- /**
367
- * Parse a Day One export (ZIP or JSON) and return entries as JSON.
368
- *
369
- * Auto-detects the format: ZIP files (with media directories) have
370
- * attachments populated with binary data. Plain JSON files are parsed
371
- * with empty attachment data (backward compatible).
372
- *
373
- * ## Example
374
- * ```javascript
375
- * const bytes = new Uint8Array(await file.arrayBuffer());
376
- * const result = backend.parseDayOneJson(bytes);
377
- * const { entries, errors } = JSON.parse(result);
378
- * ```
379
- * @param {Uint8Array} bytes
380
- * @returns {string}
381
- */
382
- parseDayOneJson(bytes) {
383
- let deferred3_0;
384
- let deferred3_1;
385
- try {
386
- const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_malloc);
387
- const len0 = WASM_VECTOR_LEN;
388
- const ret = wasm.diaryxbackend_parseDayOneJson(this.__wbg_ptr, ptr0, len0);
389
- var ptr2 = ret[0];
390
- var len2 = ret[1];
391
- if (ret[3]) {
392
- ptr2 = 0; len2 = 0;
393
- throw takeFromExternrefTable0(ret[2]);
394
- }
395
- deferred3_0 = ptr2;
396
- deferred3_1 = len2;
397
- return getStringFromWasm0(ptr2, len2);
398
- } finally {
399
- wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
400
- }
401
- }
402
- /**
403
- * Parse a single markdown file and return the entry as JSON.
404
- *
405
- * Takes the raw bytes of a `.md` file and its filename, and returns
406
- * a JSON-serialized `ImportedEntry`.
407
- *
408
- * ## Example
409
- * ```javascript
410
- * const bytes = new Uint8Array(await file.arrayBuffer());
411
- * const entryJson = backend.parseMarkdownFile(bytes, file.name);
412
- * const entry = JSON.parse(entryJson);
413
- * ```
414
- * @param {Uint8Array} bytes
415
- * @param {string} filename
416
- * @returns {string}
417
- */
418
- parseMarkdownFile(bytes, filename) {
419
- let deferred4_0;
420
- let deferred4_1;
421
- try {
422
- const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_malloc);
423
- const len0 = WASM_VECTOR_LEN;
424
- const ptr1 = passStringToWasm0(filename, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
425
- const len1 = WASM_VECTOR_LEN;
426
- const ret = wasm.diaryxbackend_parseMarkdownFile(this.__wbg_ptr, ptr0, len0, ptr1, len1);
427
- var ptr3 = ret[0];
428
- var len3 = ret[1];
429
- if (ret[3]) {
430
- ptr3 = 0; len3 = 0;
431
- throw takeFromExternrefTable0(ret[2]);
432
- }
433
- deferred4_0 = ptr3;
434
- deferred4_1 = len3;
435
- return getStringFromWasm0(ptr3, len3);
436
- } finally {
437
- wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
438
- }
439
- }
440
246
  /**
441
247
  * Read binary file.
442
248
  *
@@ -461,15 +267,11 @@ export class DiaryxBackend {
461
267
  return ret;
462
268
  }
463
269
  /**
464
- * Enable or disable the CrdtFs decorator.
465
- *
466
- * When disabled, file writes pass through to storage without updating CRDTs.
467
- * CrdtFs starts disabled by default and should be enabled after sync
468
- * handshake completes (or immediately in local-only mode).
469
- * @param {boolean} enabled
270
+ * No-op CrdtFs is not used; sync handled by Extism plugin.
271
+ * @param {boolean} _enabled
470
272
  */
471
- setCrdtEnabled(enabled) {
472
- wasm.diaryxbackend_setCrdtEnabled(this.__wbg_ptr, enabled);
273
+ setCrdtEnabled(_enabled) {
274
+ wasm.diaryxbackend_setCrdtEnabled(this.__wbg_ptr, _enabled);
473
275
  }
474
276
  /**
475
277
  * Write binary file.
@@ -682,257 +484,6 @@ export class OpfsFileSystem {
682
484
  }
683
485
  if (Symbol.dispose) OpfsFileSystem.prototype[Symbol.dispose] = OpfsFileSystem.prototype.free;
684
486
 
685
- /**
686
- * WASM sync client backed by the shared SyncSession protocol handler.
687
- *
688
- * JavaScript feeds WebSocket events in via `onConnected()`, `onBinaryMessage()`,
689
- * etc. The client processes them through `SyncSession` and queues outgoing
690
- * messages/events for JavaScript to poll.
691
- */
692
- export class WasmSyncClient {
693
- static __wrap(ptr) {
694
- ptr = ptr >>> 0;
695
- const obj = Object.create(WasmSyncClient.prototype);
696
- obj.__wbg_ptr = ptr;
697
- WasmSyncClientFinalization.register(obj, obj.__wbg_ptr, obj);
698
- return obj;
699
- }
700
- __destroy_into_raw() {
701
- const ptr = this.__wbg_ptr;
702
- this.__wbg_ptr = 0;
703
- WasmSyncClientFinalization.unregister(this);
704
- return ptr;
705
- }
706
- free() {
707
- const ptr = this.__destroy_into_raw();
708
- wasm.__wbg_wasmsyncclient_free(ptr, 0);
709
- }
710
- /**
711
- * Send a focus message for specific files.
712
- *
713
- * Other clients will be notified which files this client is interested in.
714
- * @param {string[]} files
715
- */
716
- focusFiles(files) {
717
- const ptr0 = passArrayJsValueToWasm0(files, wasm.__wbindgen_malloc);
718
- const len0 = WASM_VECTOR_LEN;
719
- wasm.wasmsyncclient_focusFiles(this.__wbg_ptr, ptr0, len0);
720
- }
721
- /**
722
- * Get the server URL.
723
- * @returns {string}
724
- */
725
- getServerUrl() {
726
- let deferred1_0;
727
- let deferred1_1;
728
- try {
729
- const ret = wasm.wasmsyncclient_getServerUrl(this.__wbg_ptr);
730
- deferred1_0 = ret[0];
731
- deferred1_1 = ret[1];
732
- return getStringFromWasm0(ret[0], ret[1]);
733
- } finally {
734
- wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
735
- }
736
- }
737
- /**
738
- * Get the workspace ID.
739
- * @returns {string}
740
- */
741
- getWorkspaceId() {
742
- let deferred1_0;
743
- let deferred1_1;
744
- try {
745
- const ret = wasm.wasmsyncclient_getWorkspaceId(this.__wbg_ptr);
746
- deferred1_0 = ret[0];
747
- deferred1_1 = ret[1];
748
- return getStringFromWasm0(ret[0], ret[1]);
749
- } finally {
750
- wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
751
- }
752
- }
753
- /**
754
- * Get the WebSocket URL for the v2 sync connection.
755
- *
756
- * Returns a URL like `wss://sync.example.com/sync2?token=...&session=...`
757
- * @returns {string}
758
- */
759
- getWsUrl() {
760
- let deferred1_0;
761
- let deferred1_1;
762
- try {
763
- const ret = wasm.wasmsyncclient_getWsUrl(this.__wbg_ptr);
764
- deferred1_0 = ret[0];
765
- deferred1_1 = ret[1];
766
- return getStringFromWasm0(ret[0], ret[1]);
767
- } finally {
768
- wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
769
- }
770
- }
771
- /**
772
- * Check if there are pending events.
773
- * @returns {boolean}
774
- */
775
- hasEvents() {
776
- const ret = wasm.wasmsyncclient_hasEvents(this.__wbg_ptr);
777
- return ret !== 0;
778
- }
779
- /**
780
- * Check if there are pending outgoing messages or events.
781
- * @returns {boolean}
782
- */
783
- hasOutgoing() {
784
- const ret = wasm.wasmsyncclient_hasOutgoing(this.__wbg_ptr);
785
- return ret !== 0;
786
- }
787
- /**
788
- * Inject an incoming binary WebSocket message.
789
- *
790
- * Returns a Promise that resolves when processing is complete.
791
- * After this, poll outgoing queues.
792
- * @param {Uint8Array} data
793
- * @returns {Promise<any>}
794
- */
795
- onBinaryMessage(data) {
796
- const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_malloc);
797
- const len0 = WASM_VECTOR_LEN;
798
- const ret = wasm.wasmsyncclient_onBinaryMessage(this.__wbg_ptr, ptr0, len0);
799
- return ret;
800
- }
801
- /**
802
- * Notify that the WebSocket connected.
803
- *
804
- * Triggers workspace SyncStep1 and handshake. After calling this,
805
- * poll `pollOutgoingBinary()` / `pollOutgoingText()` to get messages to send.
806
- * @returns {Promise<any>}
807
- */
808
- onConnected() {
809
- const ret = wasm.wasmsyncclient_onConnected(this.__wbg_ptr);
810
- return ret;
811
- }
812
- /**
813
- * Notify that the WebSocket disconnected.
814
- * @returns {Promise<any>}
815
- */
816
- onDisconnected() {
817
- const ret = wasm.wasmsyncclient_onDisconnected(this.__wbg_ptr);
818
- return ret;
819
- }
820
- /**
821
- * Notify that a snapshot was downloaded and imported.
822
- *
823
- * Call this after handling a `downloadSnapshot` event.
824
- * @returns {Promise<any>}
825
- */
826
- onSnapshotImported() {
827
- const ret = wasm.wasmsyncclient_onSnapshotImported(this.__wbg_ptr);
828
- return ret;
829
- }
830
- /**
831
- * Inject an incoming text WebSocket message (JSON control message).
832
- *
833
- * Returns a Promise that resolves when processing is complete.
834
- * @param {string} text
835
- * @returns {Promise<any>}
836
- */
837
- onTextMessage(text) {
838
- const ptr0 = passStringToWasm0(text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
839
- const len0 = WASM_VECTOR_LEN;
840
- const ret = wasm.wasmsyncclient_onTextMessage(this.__wbg_ptr, ptr0, len0);
841
- return ret;
842
- }
843
- /**
844
- * Poll for a JSON-serialized event.
845
- *
846
- * Returns a JSON string representing a SyncEvent, or null.
847
- * @returns {string | undefined}
848
- */
849
- pollEvent() {
850
- const ret = wasm.wasmsyncclient_pollEvent(this.__wbg_ptr);
851
- let v1;
852
- if (ret[0] !== 0) {
853
- v1 = getStringFromWasm0(ret[0], ret[1]).slice();
854
- wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
855
- }
856
- return v1;
857
- }
858
- /**
859
- * Poll for an outgoing binary message.
860
- *
861
- * Returns a Uint8Array if there's a message to send, null otherwise.
862
- * @returns {Uint8Array | undefined}
863
- */
864
- pollOutgoingBinary() {
865
- const ret = wasm.wasmsyncclient_pollOutgoingBinary(this.__wbg_ptr);
866
- return ret;
867
- }
868
- /**
869
- * Poll for an outgoing text message.
870
- *
871
- * Returns a string if there's a message to send, null otherwise.
872
- * @returns {string | undefined}
873
- */
874
- pollOutgoingText() {
875
- const ret = wasm.wasmsyncclient_pollOutgoingText(this.__wbg_ptr);
876
- let v1;
877
- if (ret[0] !== 0) {
878
- v1 = getStringFromWasm0(ret[0], ret[1]).slice();
879
- wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
880
- }
881
- return v1;
882
- }
883
- /**
884
- * Queue a local CRDT update for sending to the server.
885
- *
886
- * Call this when local CRDT changes need to be synced.
887
- * @param {string} doc_id
888
- * @param {Uint8Array} data
889
- * @returns {Promise<any>}
890
- */
891
- queueLocalUpdate(doc_id, data) {
892
- const ptr0 = passStringToWasm0(doc_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
893
- const len0 = WASM_VECTOR_LEN;
894
- const ptr1 = passArray8ToWasm0(data, wasm.__wbindgen_malloc);
895
- const len1 = WASM_VECTOR_LEN;
896
- const ret = wasm.wasmsyncclient_queueLocalUpdate(this.__wbg_ptr, ptr0, len0, ptr1, len1);
897
- return ret;
898
- }
899
- /**
900
- * Set a share session code.
901
- *
902
- * Call this before connecting to join a share session.
903
- * @param {string} code
904
- */
905
- setSessionCode(code) {
906
- const ptr0 = passStringToWasm0(code, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
907
- const len0 = WASM_VECTOR_LEN;
908
- wasm.wasmsyncclient_setSessionCode(this.__wbg_ptr, ptr0, len0);
909
- }
910
- /**
911
- * Request body sync for specific files (lazy sync on demand).
912
- *
913
- * Sends SyncBodyFiles event through the session to initiate body
914
- * SyncStep1 for just the requested files, rather than all files.
915
- * @param {string[]} file_paths
916
- * @returns {Promise<any>}
917
- */
918
- syncBodyFiles(file_paths) {
919
- const ptr0 = passArrayJsValueToWasm0(file_paths, wasm.__wbindgen_malloc);
920
- const len0 = WASM_VECTOR_LEN;
921
- const ret = wasm.wasmsyncclient_syncBodyFiles(this.__wbg_ptr, ptr0, len0);
922
- return ret;
923
- }
924
- /**
925
- * Send an unfocus message for specific files.
926
- * @param {string[]} files
927
- */
928
- unfocusFiles(files) {
929
- const ptr0 = passArrayJsValueToWasm0(files, wasm.__wbindgen_malloc);
930
- const len0 = WASM_VECTOR_LEN;
931
- wasm.wasmsyncclient_unfocusFiles(this.__wbg_ptr, ptr0, len0);
932
- }
933
- }
934
- if (Symbol.dispose) WasmSyncClient.prototype[Symbol.dispose] = WasmSyncClient.prototype.free;
935
-
936
487
  /**
937
488
  * Initialize the WASM module. Called automatically on module load.
938
489
  */
@@ -1076,10 +627,6 @@ function __wbg_get_imports() {
1076
627
  __wbg_advance_92b0e42f9cd4e26b: function() { return handleError(function (arg0, arg1) {
1077
628
  arg0.advance(arg1 >>> 0);
1078
629
  }, arguments); },
1079
- __wbg_apply_2e22c45cb4f12415: function() { return handleError(function (arg0, arg1, arg2) {
1080
- const ret = Reflect.apply(arg0, arg1, arg2);
1081
- return ret;
1082
- }, arguments); },
1083
630
  __wbg_apply_ada2ee1a60ac7b3c: function() { return handleError(function (arg0, arg1, arg2) {
1084
631
  const ret = arg0.apply(arg1, arg2);
1085
632
  return ret;
@@ -1116,10 +663,6 @@ function __wbg_get_imports() {
1116
663
  const ret = arg0.createWritable(arg1);
1117
664
  return ret;
1118
665
  },
1119
- __wbg_crypto_86f2631e91b51511: function(arg0) {
1120
- const ret = arg0.crypto;
1121
- return ret;
1122
- },
1123
666
  __wbg_debug_46a93995fc6f8820: function(arg0, arg1, arg2, arg3) {
1124
667
  console.debug(arg0, arg1, arg2, arg3);
1125
668
  },
@@ -1161,6 +704,10 @@ function __wbg_get_imports() {
1161
704
  __wbg_error_794d0ffc9d00d5c3: function(arg0, arg1, arg2, arg3) {
1162
705
  console.error(arg0, arg1, arg2, arg3);
1163
706
  },
707
+ __wbg_fromCodePoint_22365db7b7d6ac39: function() { return handleError(function (arg0) {
708
+ const ret = String.fromCodePoint(arg0 >>> 0);
709
+ return ret;
710
+ }, arguments); },
1164
711
  __wbg_from_bddd64e7d5ff6941: function(arg0) {
1165
712
  const ret = Array.from(arg0);
1166
713
  return ret;
@@ -1177,9 +724,6 @@ function __wbg_get_imports() {
1177
724
  const ret = arg0.getFile();
1178
725
  return ret;
1179
726
  },
1180
- __wbg_getRandomValues_b3f15fcbfabb0f8b: function() { return handleError(function (arg0, arg1) {
1181
- arg0.getRandomValues(arg1);
1182
- }, arguments); },
1183
727
  __wbg_getTime_1e3cd1391c5c3995: function(arg0) {
1184
728
  const ret = arg0.getTime();
1185
729
  return ret;
@@ -1407,10 +951,6 @@ function __wbg_get_imports() {
1407
951
  __wbg_log_24aba2a6d8990b35: function(arg0, arg1, arg2, arg3) {
1408
952
  console.log(arg0, arg1, arg2, arg3);
1409
953
  },
1410
- __wbg_msCrypto_d562bbe83e0d4b91: function(arg0) {
1411
- const ret = arg0.msCrypto;
1412
- return ret;
1413
- },
1414
954
  __wbg_name_242753e5110cd756: function(arg0, arg1) {
1415
955
  const ret = arg1.name;
1416
956
  const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
@@ -1445,7 +985,7 @@ function __wbg_get_imports() {
1445
985
  const a = state0.a;
1446
986
  state0.a = 0;
1447
987
  try {
1448
- return wasm_bindgen__convert__closures_____invoke__h4e796b59e8c15a06(a, state0.b, arg0, arg1);
988
+ return wasm_bindgen__convert__closures_____invoke__h9414502ef6926694(a, state0.b, arg0, arg1);
1449
989
  } finally {
1450
990
  state0.a = a;
1451
991
  }
@@ -1496,10 +1036,6 @@ function __wbg_get_imports() {
1496
1036
  const ret = arg0.next;
1497
1037
  return ret;
1498
1038
  },
1499
- __wbg_node_e1f24f89a7336c2e: function(arg0) {
1500
- const ret = arg0.node;
1501
- return ret;
1502
- },
1503
1039
  __wbg_objectStoreNames_d2c5d2377420ad78: function(arg0) {
1504
1040
  const ret = arg0.objectStoreNames;
1505
1041
  return ret;
@@ -1531,10 +1067,6 @@ function __wbg_get_imports() {
1531
1067
  __wbg_preventDefault_cdcfcd7e301b9702: function(arg0) {
1532
1068
  arg0.preventDefault();
1533
1069
  },
1534
- __wbg_process_3975fd6c72f520aa: function(arg0) {
1535
- const ret = arg0.process;
1536
- return ret;
1537
- },
1538
1070
  __wbg_prototypesetcall_bdcdcc5842e4d77d: function(arg0, arg1, arg2) {
1539
1071
  Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), arg2);
1540
1072
  },
@@ -1553,17 +1085,10 @@ function __wbg_get_imports() {
1553
1085
  __wbg_queueMicrotask_5bb536982f78a56f: function(arg0) {
1554
1086
  queueMicrotask(arg0);
1555
1087
  },
1556
- __wbg_randomFillSync_f8c153b79f285817: function() { return handleError(function (arg0, arg1) {
1557
- arg0.randomFillSync(arg1);
1558
- }, arguments); },
1559
1088
  __wbg_removeEntry_d1cc9710704217eb: function(arg0, arg1, arg2) {
1560
1089
  const ret = arg0.removeEntry(getStringFromWasm0(arg1, arg2));
1561
1090
  return ret;
1562
1091
  },
1563
- __wbg_require_b74f47fc2d022fd6: function() { return handleError(function () {
1564
- const ret = module.require;
1565
- return ret;
1566
- }, arguments); },
1567
1092
  __wbg_resolve_002c4b7d9d8f6b64: function(arg0) {
1568
1093
  const ret = Promise.resolve(arg0);
1569
1094
  return ret;
@@ -1634,10 +1159,6 @@ function __wbg_get_imports() {
1634
1159
  const ret = JSON.stringify(arg0);
1635
1160
  return ret;
1636
1161
  }, arguments); },
1637
- __wbg_subarray_a96e1fef17ed23cb: function(arg0, arg1, arg2) {
1638
- const ret = arg0.subarray(arg1 >>> 0, arg2 >>> 0);
1639
- return ret;
1640
- },
1641
1162
  __wbg_target_521be630ab05b11e: function(arg0) {
1642
1163
  const ret = arg0.target;
1643
1164
  return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
@@ -1666,10 +1187,6 @@ function __wbg_get_imports() {
1666
1187
  const ret = arg0.value;
1667
1188
  return ret;
1668
1189
  },
1669
- __wbg_versions_4e31226f5e8dc909: function(arg0) {
1670
- const ret = arg0.versions;
1671
- return ret;
1672
- },
1673
1190
  __wbg_warn_a40b971467b219c7: function(arg0, arg1, arg2, arg3) {
1674
1191
  console.warn(arg0, arg1, arg2, arg3);
1675
1192
  },
@@ -1678,23 +1195,23 @@ function __wbg_get_imports() {
1678
1195
  return ret;
1679
1196
  }, arguments); },
1680
1197
  __wbindgen_cast_0000000000000001: function(arg0, arg1) {
1681
- // Cast intrinsic for `Closure(Closure { dtor_idx: 724, function: Function { arguments: [NamedExternref("Event")], shim_idx: 675, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
1682
- const ret = makeMutClosure(arg0, arg1, wasm.wasm_bindgen__closure__destroy__h4c3bc21aabb0cdba, wasm_bindgen__convert__closures_____invoke__hc73185828886e792);
1198
+ // Cast intrinsic for `Closure(Closure { dtor_idx: 1, function: Function { arguments: [NamedExternref("Event")], shim_idx: 2, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
1199
+ const ret = makeMutClosure(arg0, arg1, wasm.wasm_bindgen__closure__destroy__h0b58a0de6909981f, wasm_bindgen__convert__closures_____invoke__h0da01443bd011173);
1683
1200
  return ret;
1684
1201
  },
1685
1202
  __wbindgen_cast_0000000000000002: function(arg0, arg1) {
1686
- // Cast intrinsic for `Closure(Closure { dtor_idx: 724, function: Function { arguments: [NamedExternref("IDBVersionChangeEvent")], shim_idx: 674, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
1687
- const ret = makeMutClosure(arg0, arg1, wasm.wasm_bindgen__closure__destroy__h4c3bc21aabb0cdba, wasm_bindgen__convert__closures_____invoke__h307b88b750192cbb);
1203
+ // Cast intrinsic for `Closure(Closure { dtor_idx: 1, function: Function { arguments: [NamedExternref("IDBVersionChangeEvent")], shim_idx: 3, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
1204
+ const ret = makeMutClosure(arg0, arg1, wasm.wasm_bindgen__closure__destroy__h0b58a0de6909981f, wasm_bindgen__convert__closures_____invoke__hcc870e2a76176fd3);
1688
1205
  return ret;
1689
1206
  },
1690
1207
  __wbindgen_cast_0000000000000003: function(arg0, arg1) {
1691
- // Cast intrinsic for `Closure(Closure { dtor_idx: 843, function: Function { arguments: [NamedExternref("Event")], shim_idx: 844, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
1692
- const ret = makeMutClosure(arg0, arg1, wasm.wasm_bindgen__closure__destroy__h54a6b627d1123dca, wasm_bindgen__convert__closures_____invoke__h7d21c95eeb3011e3);
1208
+ // Cast intrinsic for `Closure(Closure { dtor_idx: 521, function: Function { arguments: [NamedExternref("Event")], shim_idx: 522, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
1209
+ const ret = makeMutClosure(arg0, arg1, wasm.wasm_bindgen__closure__destroy__h7f33266e75cf6c88, wasm_bindgen__convert__closures_____invoke__hd537ace161e76dda);
1693
1210
  return ret;
1694
1211
  },
1695
1212
  __wbindgen_cast_0000000000000004: function(arg0, arg1) {
1696
- // Cast intrinsic for `Closure(Closure { dtor_idx: 869, function: Function { arguments: [Externref], shim_idx: 870, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
1697
- const ret = makeMutClosure(arg0, arg1, wasm.wasm_bindgen__closure__destroy__h440f08373ff30a05, wasm_bindgen__convert__closures_____invoke__h359356b1e0b37746);
1213
+ // Cast intrinsic for `Closure(Closure { dtor_idx: 537, function: Function { arguments: [Externref], shim_idx: 538, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
1214
+ const ret = makeMutClosure(arg0, arg1, wasm.wasm_bindgen__closure__destroy__h01a79603ee5b54a9, wasm_bindgen__convert__closures_____invoke__h66d99b5cef8fbea8);
1698
1215
  return ret;
1699
1216
  },
1700
1217
  __wbindgen_cast_0000000000000005: function(arg0) {
@@ -1708,16 +1225,11 @@ function __wbg_get_imports() {
1708
1225
  return ret;
1709
1226
  },
1710
1227
  __wbindgen_cast_0000000000000007: function(arg0, arg1) {
1711
- // Cast intrinsic for `Ref(Slice(U8)) -> NamedExternref("Uint8Array")`.
1712
- const ret = getArrayU8FromWasm0(arg0, arg1);
1713
- return ret;
1714
- },
1715
- __wbindgen_cast_0000000000000008: function(arg0, arg1) {
1716
1228
  // Cast intrinsic for `Ref(String) -> Externref`.
1717
1229
  const ret = getStringFromWasm0(arg0, arg1);
1718
1230
  return ret;
1719
1231
  },
1720
- __wbindgen_cast_0000000000000009: function(arg0) {
1232
+ __wbindgen_cast_0000000000000008: function(arg0) {
1721
1233
  // Cast intrinsic for `U64 -> Externref`.
1722
1234
  const ret = BigInt.asUintN(64, arg0);
1723
1235
  return ret;
@@ -1738,27 +1250,27 @@ function __wbg_get_imports() {
1738
1250
  };
1739
1251
  }
1740
1252
 
1741
- function wasm_bindgen__convert__closures_____invoke__h307b88b750192cbb(arg0, arg1, arg2) {
1742
- wasm.wasm_bindgen__convert__closures_____invoke__h307b88b750192cbb(arg0, arg1, arg2);
1253
+ function wasm_bindgen__convert__closures_____invoke__hcc870e2a76176fd3(arg0, arg1, arg2) {
1254
+ wasm.wasm_bindgen__convert__closures_____invoke__hcc870e2a76176fd3(arg0, arg1, arg2);
1743
1255
  }
1744
1256
 
1745
- function wasm_bindgen__convert__closures_____invoke__h7d21c95eeb3011e3(arg0, arg1, arg2) {
1746
- wasm.wasm_bindgen__convert__closures_____invoke__h7d21c95eeb3011e3(arg0, arg1, arg2);
1257
+ function wasm_bindgen__convert__closures_____invoke__hd537ace161e76dda(arg0, arg1, arg2) {
1258
+ wasm.wasm_bindgen__convert__closures_____invoke__hd537ace161e76dda(arg0, arg1, arg2);
1747
1259
  }
1748
1260
 
1749
- function wasm_bindgen__convert__closures_____invoke__h359356b1e0b37746(arg0, arg1, arg2) {
1750
- wasm.wasm_bindgen__convert__closures_____invoke__h359356b1e0b37746(arg0, arg1, arg2);
1261
+ function wasm_bindgen__convert__closures_____invoke__h66d99b5cef8fbea8(arg0, arg1, arg2) {
1262
+ wasm.wasm_bindgen__convert__closures_____invoke__h66d99b5cef8fbea8(arg0, arg1, arg2);
1751
1263
  }
1752
1264
 
1753
- function wasm_bindgen__convert__closures_____invoke__hc73185828886e792(arg0, arg1, arg2) {
1754
- const ret = wasm.wasm_bindgen__convert__closures_____invoke__hc73185828886e792(arg0, arg1, arg2);
1265
+ function wasm_bindgen__convert__closures_____invoke__h0da01443bd011173(arg0, arg1, arg2) {
1266
+ const ret = wasm.wasm_bindgen__convert__closures_____invoke__h0da01443bd011173(arg0, arg1, arg2);
1755
1267
  if (ret[1]) {
1756
1268
  throw takeFromExternrefTable0(ret[0]);
1757
1269
  }
1758
1270
  }
1759
1271
 
1760
- function wasm_bindgen__convert__closures_____invoke__h4e796b59e8c15a06(arg0, arg1, arg2, arg3) {
1761
- wasm.wasm_bindgen__convert__closures_____invoke__h4e796b59e8c15a06(arg0, arg1, arg2, arg3);
1272
+ function wasm_bindgen__convert__closures_____invoke__h9414502ef6926694(arg0, arg1, arg2, arg3) {
1273
+ wasm.wasm_bindgen__convert__closures_____invoke__h9414502ef6926694(arg0, arg1, arg2, arg3);
1762
1274
  }
1763
1275
 
1764
1276
 
@@ -1781,9 +1293,6 @@ const JsAsyncFileSystemFinalization = (typeof FinalizationRegistry === 'undefine
1781
1293
  const OpfsFileSystemFinalization = (typeof FinalizationRegistry === 'undefined')
1782
1294
  ? { register: () => {}, unregister: () => {} }
1783
1295
  : new FinalizationRegistry(ptr => wasm.__wbg_opfsfilesystem_free(ptr >>> 0, 1));
1784
- const WasmSyncClientFinalization = (typeof FinalizationRegistry === 'undefined')
1785
- ? { register: () => {}, unregister: () => {} }
1786
- : new FinalizationRegistry(ptr => wasm.__wbg_wasmsyncclient_free(ptr >>> 0, 1));
1787
1296
 
1788
1297
  function addToExternrefTable0(obj) {
1789
1298
  const idx = wasm.__externref_table_alloc();
@@ -1927,23 +1436,6 @@ function makeMutClosure(arg0, arg1, dtor, f) {
1927
1436
  return real;
1928
1437
  }
1929
1438
 
1930
- function passArray8ToWasm0(arg, malloc) {
1931
- const ptr = malloc(arg.length * 1, 1) >>> 0;
1932
- getUint8ArrayMemory0().set(arg, ptr / 1);
1933
- WASM_VECTOR_LEN = arg.length;
1934
- return ptr;
1935
- }
1936
-
1937
- function passArrayJsValueToWasm0(array, malloc) {
1938
- const ptr = malloc(array.length * 4, 4) >>> 0;
1939
- for (let i = 0; i < array.length; i++) {
1940
- const add = addToExternrefTable0(array[i]);
1941
- getDataViewMemory0().setUint32(ptr + 4 * i, add, true);
1942
- }
1943
- WASM_VECTOR_LEN = array.length;
1944
- return ptr;
1945
- }
1946
-
1947
1439
  function passStringToWasm0(arg, malloc, realloc) {
1948
1440
  if (realloc === undefined) {
1949
1441
  const buf = cachedTextEncoder.encode(arg);
@@ -1,70 +1,48 @@
1
1
  /* tslint:disable */
2
2
  /* eslint-disable */
3
3
  export const memory: WebAssembly.Memory;
4
- export const __wbg_jsasyncfilesystem_free: (a: number, b: number) => void;
5
- export const __wbg_wasmsyncclient_free: (a: number, b: number) => void;
6
- export const jsasyncfilesystem_has_callback: (a: number, b: number, c: number) => number;
7
- export const jsasyncfilesystem_new: (a: any) => number;
8
- export const wasmsyncclient_focusFiles: (a: number, b: number, c: number) => void;
9
- export const wasmsyncclient_getServerUrl: (a: number) => [number, number];
10
- export const wasmsyncclient_getWorkspaceId: (a: number) => [number, number];
11
- export const wasmsyncclient_getWsUrl: (a: number) => [number, number];
12
- export const wasmsyncclient_hasEvents: (a: number) => number;
13
- export const wasmsyncclient_hasOutgoing: (a: number) => number;
14
- export const wasmsyncclient_onBinaryMessage: (a: number, b: number, c: number) => any;
15
- export const wasmsyncclient_onConnected: (a: number) => any;
16
- export const wasmsyncclient_onDisconnected: (a: number) => any;
17
- export const wasmsyncclient_onSnapshotImported: (a: number) => any;
18
- export const wasmsyncclient_onTextMessage: (a: number, b: number, c: number) => any;
19
- export const wasmsyncclient_pollEvent: (a: number) => [number, number];
20
- export const wasmsyncclient_pollOutgoingBinary: (a: number) => any;
21
- export const wasmsyncclient_pollOutgoingText: (a: number) => [number, number];
22
- export const wasmsyncclient_queueLocalUpdate: (a: number, b: number, c: number, d: number, e: number) => any;
23
- export const wasmsyncclient_setSessionCode: (a: number, b: number, c: number) => void;
24
- export const wasmsyncclient_syncBodyFiles: (a: number, b: number, c: number) => any;
25
- export const wasmsyncclient_unfocusFiles: (a: number, b: number, c: number) => void;
26
- export const __wbg_indexeddbfilesystem_free: (a: number, b: number) => void;
27
- export const __wbg_opfsfilesystem_free: (a: number, b: number) => void;
28
- export const indexeddbfilesystem_create: () => any;
29
- export const indexeddbfilesystem_createWithName: (a: number, b: number) => any;
30
- export const opfsfilesystem_create: () => any;
31
- export const opfsfilesystem_createWithName: (a: number, b: number) => any;
32
4
  export const __wbg_diaryxbackend_free: (a: number, b: number) => void;
5
+ export const __wbg_fsafilesystem_free: (a: number, b: number) => void;
6
+ export const __wbg_indexeddbfilesystem_free: (a: number, b: number) => void;
7
+ export const __wbg_jsasyncfilesystem_free: (a: number, b: number) => void;
33
8
  export const diaryxbackend_create: (a: number, b: number) => any;
34
9
  export const diaryxbackend_createFromDirectoryHandle: (a: any) => [number, number, number];
35
10
  export const diaryxbackend_createFromJsFileSystem: (a: any) => [number, number, number];
36
11
  export const diaryxbackend_createInMemory: () => [number, number, number];
37
12
  export const diaryxbackend_createIndexedDb: (a: number, b: number) => any;
38
13
  export const diaryxbackend_createOpfs: (a: number, b: number) => any;
39
- export const diaryxbackend_createSyncClient: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => number;
40
14
  export const diaryxbackend_emitFileSystemEvent: (a: number, b: number, c: number) => [number, number];
41
15
  export const diaryxbackend_eventSubscriberCount: (a: number) => number;
42
16
  export const diaryxbackend_execute: (a: number, b: number, c: number) => any;
43
17
  export const diaryxbackend_executeJs: (a: number, b: any) => any;
44
18
  export const diaryxbackend_getConfig: (a: number) => any;
45
19
  export const diaryxbackend_hasNativeSync: (a: number) => number;
46
- export const diaryxbackend_isCrdtEnabled: (a: number) => number;
47
20
  export const diaryxbackend_offFileSystemEvent: (a: number, b: bigint) => number;
48
21
  export const diaryxbackend_onFileSystemEvent: (a: number, b: any) => bigint;
49
- export const diaryxbackend_parseDayOneJson: (a: number, b: number, c: number) => [number, number, number, number];
50
- export const diaryxbackend_parseMarkdownFile: (a: number, b: number, c: number, d: number, e: number) => [number, number, number, number];
51
22
  export const diaryxbackend_readBinary: (a: number, b: number, c: number) => any;
52
23
  export const diaryxbackend_saveConfig: (a: number, b: any) => any;
53
24
  export const diaryxbackend_setCrdtEnabled: (a: number, b: number) => void;
54
25
  export const diaryxbackend_writeBinary: (a: number, b: number, c: number, d: any) => any;
55
- export const init: () => void;
56
- export const __wbg_fsafilesystem_free: (a: number, b: number) => void;
57
26
  export const fsafilesystem_fromHandle: (a: any) => number;
27
+ export const indexeddbfilesystem_create: () => any;
28
+ export const indexeddbfilesystem_createWithName: (a: number, b: number) => any;
29
+ export const jsasyncfilesystem_has_callback: (a: number, b: number, c: number) => number;
58
30
  export const now_timestamp: () => [number, number];
31
+ export const opfsfilesystem_create: () => any;
32
+ export const opfsfilesystem_createWithName: (a: number, b: number) => any;
59
33
  export const today_formatted: (a: number, b: number) => [number, number];
60
- export const wasm_bindgen__closure__destroy__h4c3bc21aabb0cdba: (a: number, b: number) => void;
61
- export const wasm_bindgen__closure__destroy__h54a6b627d1123dca: (a: number, b: number) => void;
62
- export const wasm_bindgen__closure__destroy__h440f08373ff30a05: (a: number, b: number) => void;
63
- export const wasm_bindgen__convert__closures_____invoke__hc73185828886e792: (a: number, b: number, c: any) => [number, number];
64
- export const wasm_bindgen__convert__closures_____invoke__h4e796b59e8c15a06: (a: number, b: number, c: any, d: any) => void;
65
- export const wasm_bindgen__convert__closures_____invoke__h307b88b750192cbb: (a: number, b: number, c: any) => void;
66
- export const wasm_bindgen__convert__closures_____invoke__h7d21c95eeb3011e3: (a: number, b: number, c: any) => void;
67
- export const wasm_bindgen__convert__closures_____invoke__h359356b1e0b37746: (a: number, b: number, c: any) => void;
34
+ export const diaryxbackend_isCrdtEnabled: (a: number) => number;
35
+ export const init: () => void;
36
+ export const jsasyncfilesystem_new: (a: any) => number;
37
+ export const __wbg_opfsfilesystem_free: (a: number, b: number) => void;
38
+ export const wasm_bindgen__closure__destroy__h0b58a0de6909981f: (a: number, b: number) => void;
39
+ export const wasm_bindgen__closure__destroy__h7f33266e75cf6c88: (a: number, b: number) => void;
40
+ export const wasm_bindgen__closure__destroy__h01a79603ee5b54a9: (a: number, b: number) => void;
41
+ export const wasm_bindgen__convert__closures_____invoke__h0da01443bd011173: (a: number, b: number, c: any) => [number, number];
42
+ export const wasm_bindgen__convert__closures_____invoke__h9414502ef6926694: (a: number, b: number, c: any, d: any) => void;
43
+ export const wasm_bindgen__convert__closures_____invoke__hcc870e2a76176fd3: (a: number, b: number, c: any) => void;
44
+ export const wasm_bindgen__convert__closures_____invoke__hd537ace161e76dda: (a: number, b: number, c: any) => void;
45
+ export const wasm_bindgen__convert__closures_____invoke__h66d99b5cef8fbea8: (a: number, b: number, c: any) => void;
68
46
  export const __wbindgen_malloc: (a: number, b: number) => number;
69
47
  export const __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
70
48
  export const __wbindgen_exn_store: (a: number) => void;
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@diaryx/wasm",
3
3
  "type": "module",
4
4
  "description": "WebAssembly bindings for Diaryx core functionality",
5
- "version": "1.2.0-dev.d069796",
5
+ "version": "1.2.1-dev.34fd175",
6
6
  "license": "SEE LICENSE IN ../../LICENSE.md",
7
7
  "repository": {
8
8
  "type": "git",