@diaryx/wasm 1.2.0-dev.d069796 → 1.2.1-dev.5be7aae

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
  /**
@@ -380,13 +273,9 @@ export class DiaryxBackend {
380
273
  */
381
274
  saveConfig(config_js: any): Promise<any>;
382
275
  /**
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).
276
+ * No-op CrdtFs is not used; sync handled by Extism plugin.
388
277
  */
389
- setCrdtEnabled(enabled: boolean): void;
278
+ setCrdtEnabled(_enabled: boolean): void;
390
279
  /**
391
280
  * Write binary file.
392
281
  *
@@ -495,118 +384,6 @@ export class OpfsFileSystem {
495
384
  static createWithName(root_name: string): Promise<OpfsFileSystem>;
496
385
  }
497
386
 
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
387
  /**
611
388
  * Initialize the WASM module. Called automatically on module load.
612
389
  */
@@ -626,32 +403,13 @@ export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembl
626
403
 
627
404
  export interface InitOutput {
628
405
  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
406
  readonly __wbg_indexeddbfilesystem_free: (a: number, b: number) => void;
407
+ readonly __wbg_jsasyncfilesystem_free: (a: number, b: number) => void;
652
408
  readonly __wbg_opfsfilesystem_free: (a: number, b: number) => void;
653
409
  readonly indexeddbfilesystem_create: () => any;
654
410
  readonly indexeddbfilesystem_createWithName: (a: number, b: number) => any;
411
+ readonly jsasyncfilesystem_has_callback: (a: number, b: number, c: number) => number;
412
+ readonly jsasyncfilesystem_new: (a: any) => number;
655
413
  readonly opfsfilesystem_create: () => any;
656
414
  readonly opfsfilesystem_createWithName: (a: number, b: number) => any;
657
415
  readonly __wbg_diaryxbackend_free: (a: number, b: number) => void;
@@ -661,14 +419,12 @@ export interface InitOutput {
661
419
  readonly diaryxbackend_createInMemory: () => [number, number, number];
662
420
  readonly diaryxbackend_createIndexedDb: (a: number, b: number) => any;
663
421
  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
422
  readonly diaryxbackend_emitFileSystemEvent: (a: number, b: number, c: number) => [number, number];
666
423
  readonly diaryxbackend_eventSubscriberCount: (a: number) => number;
667
424
  readonly diaryxbackend_execute: (a: number, b: number, c: number) => any;
668
425
  readonly diaryxbackend_executeJs: (a: number, b: any) => any;
669
426
  readonly diaryxbackend_getConfig: (a: number) => any;
670
427
  readonly diaryxbackend_hasNativeSync: (a: number) => number;
671
- readonly diaryxbackend_isCrdtEnabled: (a: number) => number;
672
428
  readonly diaryxbackend_offFileSystemEvent: (a: number, b: bigint) => number;
673
429
  readonly diaryxbackend_onFileSystemEvent: (a: number, b: any) => bigint;
674
430
  readonly diaryxbackend_parseDayOneJson: (a: number, b: number, c: number) => [number, number, number, number];
@@ -677,17 +433,18 @@ export interface InitOutput {
677
433
  readonly diaryxbackend_saveConfig: (a: number, b: any) => any;
678
434
  readonly diaryxbackend_setCrdtEnabled: (a: number, b: number) => void;
679
435
  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
- readonly fsafilesystem_fromHandle: (a: any) => number;
436
+ readonly diaryxbackend_isCrdtEnabled: (a: number) => number;
683
437
  readonly now_timestamp: () => [number, number];
684
438
  readonly today_formatted: (a: number, b: number) => [number, number];
685
- readonly wasm_bindgen__closure__destroy__h4c3bc21aabb0cdba: (a: number, b: number) => void;
439
+ readonly __wbg_fsafilesystem_free: (a: number, b: number) => void;
440
+ readonly fsafilesystem_fromHandle: (a: any) => number;
441
+ readonly init: () => void;
442
+ readonly wasm_bindgen__closure__destroy__h3b6f5678e47fdf3b: (a: number, b: number) => void;
686
443
  readonly wasm_bindgen__closure__destroy__h54a6b627d1123dca: (a: number, b: number) => void;
687
444
  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];
445
+ readonly wasm_bindgen__convert__closures_____invoke__h6a0a4f4deaf55cd8: (a: number, b: number, c: any) => [number, number];
689
446
  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;
447
+ readonly wasm_bindgen__convert__closures_____invoke__hfced64173fa633ca: (a: number, b: number, c: any) => void;
691
448
  readonly wasm_bindgen__convert__closures_____invoke__h7d21c95eeb3011e3: (a: number, b: number, c: any) => void;
692
449
  readonly wasm_bindgen__convert__closures_____invoke__h359356b1e0b37746: (a: number, b: number, c: any) => void;
693
450
  readonly __wbindgen_malloc: (a: number, b: number) => number;
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
  /**
@@ -461,15 +341,11 @@ export class DiaryxBackend {
461
341
  return ret;
462
342
  }
463
343
  /**
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
344
+ * No-op CrdtFs is not used; sync handled by Extism plugin.
345
+ * @param {boolean} _enabled
470
346
  */
471
- setCrdtEnabled(enabled) {
472
- wasm.diaryxbackend_setCrdtEnabled(this.__wbg_ptr, enabled);
347
+ setCrdtEnabled(_enabled) {
348
+ wasm.diaryxbackend_setCrdtEnabled(this.__wbg_ptr, _enabled);
473
349
  }
474
350
  /**
475
351
  * Write binary file.
@@ -682,257 +558,6 @@ export class OpfsFileSystem {
682
558
  }
683
559
  if (Symbol.dispose) OpfsFileSystem.prototype[Symbol.dispose] = OpfsFileSystem.prototype.free;
684
560
 
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
561
  /**
937
562
  * Initialize the WASM module. Called automatically on module load.
938
563
  */
@@ -1076,10 +701,6 @@ function __wbg_get_imports() {
1076
701
  __wbg_advance_92b0e42f9cd4e26b: function() { return handleError(function (arg0, arg1) {
1077
702
  arg0.advance(arg1 >>> 0);
1078
703
  }, 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
704
  __wbg_apply_ada2ee1a60ac7b3c: function() { return handleError(function (arg0, arg1, arg2) {
1084
705
  const ret = arg0.apply(arg1, arg2);
1085
706
  return ret;
@@ -1116,10 +737,6 @@ function __wbg_get_imports() {
1116
737
  const ret = arg0.createWritable(arg1);
1117
738
  return ret;
1118
739
  },
1119
- __wbg_crypto_86f2631e91b51511: function(arg0) {
1120
- const ret = arg0.crypto;
1121
- return ret;
1122
- },
1123
740
  __wbg_debug_46a93995fc6f8820: function(arg0, arg1, arg2, arg3) {
1124
741
  console.debug(arg0, arg1, arg2, arg3);
1125
742
  },
@@ -1161,6 +778,10 @@ function __wbg_get_imports() {
1161
778
  __wbg_error_794d0ffc9d00d5c3: function(arg0, arg1, arg2, arg3) {
1162
779
  console.error(arg0, arg1, arg2, arg3);
1163
780
  },
781
+ __wbg_fromCodePoint_22365db7b7d6ac39: function() { return handleError(function (arg0) {
782
+ const ret = String.fromCodePoint(arg0 >>> 0);
783
+ return ret;
784
+ }, arguments); },
1164
785
  __wbg_from_bddd64e7d5ff6941: function(arg0) {
1165
786
  const ret = Array.from(arg0);
1166
787
  return ret;
@@ -1177,9 +798,6 @@ function __wbg_get_imports() {
1177
798
  const ret = arg0.getFile();
1178
799
  return ret;
1179
800
  },
1180
- __wbg_getRandomValues_b3f15fcbfabb0f8b: function() { return handleError(function (arg0, arg1) {
1181
- arg0.getRandomValues(arg1);
1182
- }, arguments); },
1183
801
  __wbg_getTime_1e3cd1391c5c3995: function(arg0) {
1184
802
  const ret = arg0.getTime();
1185
803
  return ret;
@@ -1407,10 +1025,6 @@ function __wbg_get_imports() {
1407
1025
  __wbg_log_24aba2a6d8990b35: function(arg0, arg1, arg2, arg3) {
1408
1026
  console.log(arg0, arg1, arg2, arg3);
1409
1027
  },
1410
- __wbg_msCrypto_d562bbe83e0d4b91: function(arg0) {
1411
- const ret = arg0.msCrypto;
1412
- return ret;
1413
- },
1414
1028
  __wbg_name_242753e5110cd756: function(arg0, arg1) {
1415
1029
  const ret = arg1.name;
1416
1030
  const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
@@ -1496,10 +1110,6 @@ function __wbg_get_imports() {
1496
1110
  const ret = arg0.next;
1497
1111
  return ret;
1498
1112
  },
1499
- __wbg_node_e1f24f89a7336c2e: function(arg0) {
1500
- const ret = arg0.node;
1501
- return ret;
1502
- },
1503
1113
  __wbg_objectStoreNames_d2c5d2377420ad78: function(arg0) {
1504
1114
  const ret = arg0.objectStoreNames;
1505
1115
  return ret;
@@ -1531,10 +1141,6 @@ function __wbg_get_imports() {
1531
1141
  __wbg_preventDefault_cdcfcd7e301b9702: function(arg0) {
1532
1142
  arg0.preventDefault();
1533
1143
  },
1534
- __wbg_process_3975fd6c72f520aa: function(arg0) {
1535
- const ret = arg0.process;
1536
- return ret;
1537
- },
1538
1144
  __wbg_prototypesetcall_bdcdcc5842e4d77d: function(arg0, arg1, arg2) {
1539
1145
  Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), arg2);
1540
1146
  },
@@ -1553,17 +1159,10 @@ function __wbg_get_imports() {
1553
1159
  __wbg_queueMicrotask_5bb536982f78a56f: function(arg0) {
1554
1160
  queueMicrotask(arg0);
1555
1161
  },
1556
- __wbg_randomFillSync_f8c153b79f285817: function() { return handleError(function (arg0, arg1) {
1557
- arg0.randomFillSync(arg1);
1558
- }, arguments); },
1559
1162
  __wbg_removeEntry_d1cc9710704217eb: function(arg0, arg1, arg2) {
1560
1163
  const ret = arg0.removeEntry(getStringFromWasm0(arg1, arg2));
1561
1164
  return ret;
1562
1165
  },
1563
- __wbg_require_b74f47fc2d022fd6: function() { return handleError(function () {
1564
- const ret = module.require;
1565
- return ret;
1566
- }, arguments); },
1567
1166
  __wbg_resolve_002c4b7d9d8f6b64: function(arg0) {
1568
1167
  const ret = Promise.resolve(arg0);
1569
1168
  return ret;
@@ -1634,10 +1233,6 @@ function __wbg_get_imports() {
1634
1233
  const ret = JSON.stringify(arg0);
1635
1234
  return ret;
1636
1235
  }, arguments); },
1637
- __wbg_subarray_a96e1fef17ed23cb: function(arg0, arg1, arg2) {
1638
- const ret = arg0.subarray(arg1 >>> 0, arg2 >>> 0);
1639
- return ret;
1640
- },
1641
1236
  __wbg_target_521be630ab05b11e: function(arg0) {
1642
1237
  const ret = arg0.target;
1643
1238
  return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
@@ -1666,10 +1261,6 @@ function __wbg_get_imports() {
1666
1261
  const ret = arg0.value;
1667
1262
  return ret;
1668
1263
  },
1669
- __wbg_versions_4e31226f5e8dc909: function(arg0) {
1670
- const ret = arg0.versions;
1671
- return ret;
1672
- },
1673
1264
  __wbg_warn_a40b971467b219c7: function(arg0, arg1, arg2, arg3) {
1674
1265
  console.warn(arg0, arg1, arg2, arg3);
1675
1266
  },
@@ -1678,22 +1269,22 @@ function __wbg_get_imports() {
1678
1269
  return ret;
1679
1270
  }, arguments); },
1680
1271
  __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);
1272
+ // Cast intrinsic for `Closure(Closure { dtor_idx: 355, function: Function { arguments: [NamedExternref("Event")], shim_idx: 542, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
1273
+ const ret = makeMutClosure(arg0, arg1, wasm.wasm_bindgen__closure__destroy__h3b6f5678e47fdf3b, wasm_bindgen__convert__closures_____invoke__h6a0a4f4deaf55cd8);
1683
1274
  return ret;
1684
1275
  },
1685
1276
  __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);
1277
+ // Cast intrinsic for `Closure(Closure { dtor_idx: 355, function: Function { arguments: [NamedExternref("IDBVersionChangeEvent")], shim_idx: 543, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
1278
+ const ret = makeMutClosure(arg0, arg1, wasm.wasm_bindgen__closure__destroy__h3b6f5678e47fdf3b, wasm_bindgen__convert__closures_____invoke__hfced64173fa633ca);
1688
1279
  return ret;
1689
1280
  },
1690
1281
  __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`.
1282
+ // Cast intrinsic for `Closure(Closure { dtor_idx: 600, function: Function { arguments: [NamedExternref("Event")], shim_idx: 601, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
1692
1283
  const ret = makeMutClosure(arg0, arg1, wasm.wasm_bindgen__closure__destroy__h54a6b627d1123dca, wasm_bindgen__convert__closures_____invoke__h7d21c95eeb3011e3);
1693
1284
  return ret;
1694
1285
  },
1695
1286
  __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`.
1287
+ // Cast intrinsic for `Closure(Closure { dtor_idx: 626, function: Function { arguments: [Externref], shim_idx: 627, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
1697
1288
  const ret = makeMutClosure(arg0, arg1, wasm.wasm_bindgen__closure__destroy__h440f08373ff30a05, wasm_bindgen__convert__closures_____invoke__h359356b1e0b37746);
1698
1289
  return ret;
1699
1290
  },
@@ -1708,16 +1299,11 @@ function __wbg_get_imports() {
1708
1299
  return ret;
1709
1300
  },
1710
1301
  __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
1302
  // Cast intrinsic for `Ref(String) -> Externref`.
1717
1303
  const ret = getStringFromWasm0(arg0, arg1);
1718
1304
  return ret;
1719
1305
  },
1720
- __wbindgen_cast_0000000000000009: function(arg0) {
1306
+ __wbindgen_cast_0000000000000008: function(arg0) {
1721
1307
  // Cast intrinsic for `U64 -> Externref`.
1722
1308
  const ret = BigInt.asUintN(64, arg0);
1723
1309
  return ret;
@@ -1738,8 +1324,8 @@ function __wbg_get_imports() {
1738
1324
  };
1739
1325
  }
1740
1326
 
1741
- function wasm_bindgen__convert__closures_____invoke__h307b88b750192cbb(arg0, arg1, arg2) {
1742
- wasm.wasm_bindgen__convert__closures_____invoke__h307b88b750192cbb(arg0, arg1, arg2);
1327
+ function wasm_bindgen__convert__closures_____invoke__hfced64173fa633ca(arg0, arg1, arg2) {
1328
+ wasm.wasm_bindgen__convert__closures_____invoke__hfced64173fa633ca(arg0, arg1, arg2);
1743
1329
  }
1744
1330
 
1745
1331
  function wasm_bindgen__convert__closures_____invoke__h7d21c95eeb3011e3(arg0, arg1, arg2) {
@@ -1750,8 +1336,8 @@ function wasm_bindgen__convert__closures_____invoke__h359356b1e0b37746(arg0, arg
1750
1336
  wasm.wasm_bindgen__convert__closures_____invoke__h359356b1e0b37746(arg0, arg1, arg2);
1751
1337
  }
1752
1338
 
1753
- function wasm_bindgen__convert__closures_____invoke__hc73185828886e792(arg0, arg1, arg2) {
1754
- const ret = wasm.wasm_bindgen__convert__closures_____invoke__hc73185828886e792(arg0, arg1, arg2);
1339
+ function wasm_bindgen__convert__closures_____invoke__h6a0a4f4deaf55cd8(arg0, arg1, arg2) {
1340
+ const ret = wasm.wasm_bindgen__convert__closures_____invoke__h6a0a4f4deaf55cd8(arg0, arg1, arg2);
1755
1341
  if (ret[1]) {
1756
1342
  throw takeFromExternrefTable0(ret[0]);
1757
1343
  }
@@ -1781,9 +1367,6 @@ const JsAsyncFileSystemFinalization = (typeof FinalizationRegistry === 'undefine
1781
1367
  const OpfsFileSystemFinalization = (typeof FinalizationRegistry === 'undefined')
1782
1368
  ? { register: () => {}, unregister: () => {} }
1783
1369
  : 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
1370
 
1788
1371
  function addToExternrefTable0(obj) {
1789
1372
  const idx = wasm.__externref_table_alloc();
@@ -1934,16 +1517,6 @@ function passArray8ToWasm0(arg, malloc) {
1934
1517
  return ptr;
1935
1518
  }
1936
1519
 
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
1520
  function passStringToWasm0(arg, malloc, realloc) {
1948
1521
  if (realloc === undefined) {
1949
1522
  const buf = cachedTextEncoder.encode(arg);
@@ -1,32 +1,13 @@
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
4
  export const __wbg_indexeddbfilesystem_free: (a: number, b: number) => void;
5
+ export const __wbg_jsasyncfilesystem_free: (a: number, b: number) => void;
27
6
  export const __wbg_opfsfilesystem_free: (a: number, b: number) => void;
28
7
  export const indexeddbfilesystem_create: () => any;
29
8
  export const indexeddbfilesystem_createWithName: (a: number, b: number) => any;
9
+ export const jsasyncfilesystem_has_callback: (a: number, b: number, c: number) => number;
10
+ export const jsasyncfilesystem_new: (a: any) => number;
30
11
  export const opfsfilesystem_create: () => any;
31
12
  export const opfsfilesystem_createWithName: (a: number, b: number) => any;
32
13
  export const __wbg_diaryxbackend_free: (a: number, b: number) => void;
@@ -36,14 +17,12 @@ export const diaryxbackend_createFromJsFileSystem: (a: any) => [number, number,
36
17
  export const diaryxbackend_createInMemory: () => [number, number, number];
37
18
  export const diaryxbackend_createIndexedDb: (a: number, b: number) => any;
38
19
  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
20
  export const diaryxbackend_emitFileSystemEvent: (a: number, b: number, c: number) => [number, number];
41
21
  export const diaryxbackend_eventSubscriberCount: (a: number) => number;
42
22
  export const diaryxbackend_execute: (a: number, b: number, c: number) => any;
43
23
  export const diaryxbackend_executeJs: (a: number, b: any) => any;
44
24
  export const diaryxbackend_getConfig: (a: number) => any;
45
25
  export const diaryxbackend_hasNativeSync: (a: number) => number;
46
- export const diaryxbackend_isCrdtEnabled: (a: number) => number;
47
26
  export const diaryxbackend_offFileSystemEvent: (a: number, b: bigint) => number;
48
27
  export const diaryxbackend_onFileSystemEvent: (a: number, b: any) => bigint;
49
28
  export const diaryxbackend_parseDayOneJson: (a: number, b: number, c: number) => [number, number, number, number];
@@ -52,17 +31,18 @@ export const diaryxbackend_readBinary: (a: number, b: number, c: number) => any;
52
31
  export const diaryxbackend_saveConfig: (a: number, b: any) => any;
53
32
  export const diaryxbackend_setCrdtEnabled: (a: number, b: number) => void;
54
33
  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
- export const fsafilesystem_fromHandle: (a: any) => number;
34
+ export const diaryxbackend_isCrdtEnabled: (a: number) => number;
58
35
  export const now_timestamp: () => [number, number];
59
36
  export const today_formatted: (a: number, b: number) => [number, number];
60
- export const wasm_bindgen__closure__destroy__h4c3bc21aabb0cdba: (a: number, b: number) => void;
37
+ export const __wbg_fsafilesystem_free: (a: number, b: number) => void;
38
+ export const fsafilesystem_fromHandle: (a: any) => number;
39
+ export const init: () => void;
40
+ export const wasm_bindgen__closure__destroy__h3b6f5678e47fdf3b: (a: number, b: number) => void;
61
41
  export const wasm_bindgen__closure__destroy__h54a6b627d1123dca: (a: number, b: number) => void;
62
42
  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];
43
+ export const wasm_bindgen__convert__closures_____invoke__h6a0a4f4deaf55cd8: (a: number, b: number, c: any) => [number, number];
64
44
  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;
45
+ export const wasm_bindgen__convert__closures_____invoke__hfced64173fa633ca: (a: number, b: number, c: any) => void;
66
46
  export const wasm_bindgen__convert__closures_____invoke__h7d21c95eeb3011e3: (a: number, b: number, c: any) => void;
67
47
  export const wasm_bindgen__convert__closures_____invoke__h359356b1e0b37746: (a: number, b: number, c: any) => void;
68
48
  export const __wbindgen_malloc: (a: number, b: number) => number;
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.5be7aae",
6
6
  "license": "SEE LICENSE IN ../../LICENSE.md",
7
7
  "repository": {
8
8
  "type": "git",