@diaryx/wasm-node 1.2.1-dev.50eabc8 → 1.2.1-dev.ddf29e2
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 +15 -21
- package/diaryx_wasm.d.ts +14 -222
- package/diaryx_wasm.js +18 -406
- package/diaryx_wasm_bg.wasm +0 -0
- package/diaryx_wasm_bg.wasm.d.ts +10 -30
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -47,31 +47,25 @@ Current filesystem test suites live in:
|
|
|
47
47
|
|
|
48
48
|
## Architecture
|
|
49
49
|
|
|
50
|
-
|
|
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
|
-
|
|
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
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
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,82 +122,12 @@ export class DiaryxBackend {
|
|
|
122
122
|
static create(storage_type: string): Promise<DiaryxBackend>;
|
|
123
123
|
/**
|
|
124
124
|
* Create a new DiaryxBackend backed by JavaScript filesystem callbacks.
|
|
125
|
-
*
|
|
126
|
-
* This is the primary way to use diaryx from non-browser environments
|
|
127
|
-
* (Node.js, Obsidian, Electron). The `callbacks` object must implement
|
|
128
|
-
* the `JsFileSystemCallbacks` interface.
|
|
129
|
-
*
|
|
130
|
-
* ## Example
|
|
131
|
-
* ```javascript
|
|
132
|
-
* const backend = DiaryxBackend.createFromJsFileSystem({
|
|
133
|
-
* readToString: async (path) => fs.readFile(path, 'utf8'),
|
|
134
|
-
* writeFile: async (path, content) => fs.writeFile(path, content),
|
|
135
|
-
* exists: async (path) => fs.access(path).then(() => true).catch(() => false),
|
|
136
|
-
* // ... other callbacks
|
|
137
|
-
* });
|
|
138
|
-
* ```
|
|
139
125
|
*/
|
|
140
126
|
static createFromJsFileSystem(callbacks: any): DiaryxBackend;
|
|
141
127
|
/**
|
|
142
128
|
* Create a new DiaryxBackend with in-memory storage.
|
|
143
|
-
*
|
|
144
|
-
* This is used for guest mode in share sessions. Files are stored
|
|
145
|
-
* only in memory and are cleared when the session ends.
|
|
146
|
-
*
|
|
147
|
-
* ## Use Cases
|
|
148
|
-
* - Guest mode in share sessions (web)
|
|
149
|
-
* - Testing
|
|
150
|
-
*
|
|
151
|
-
* ## Example
|
|
152
|
-
* ```javascript
|
|
153
|
-
* const backend = DiaryxBackend.createInMemory();
|
|
154
|
-
* // Files are stored in memory only
|
|
155
|
-
* ```
|
|
156
129
|
*/
|
|
157
130
|
static createInMemory(): DiaryxBackend;
|
|
158
|
-
/**
|
|
159
|
-
* Create a new sync client for the given server and workspace.
|
|
160
|
-
*
|
|
161
|
-
* Creates a `WasmSyncClient` backed by the shared `SyncSession` protocol
|
|
162
|
-
* handler. JavaScript manages the WebSocket while Rust handles all sync
|
|
163
|
-
* protocol logic (handshake, message routing, framing).
|
|
164
|
-
*
|
|
165
|
-
* ## Example
|
|
166
|
-
*
|
|
167
|
-
* ```javascript
|
|
168
|
-
* const client = backend.createSyncClient(
|
|
169
|
-
* 'https://sync.example.com',
|
|
170
|
-
* 'my-workspace-id',
|
|
171
|
-
* 'auth-token-optional'
|
|
172
|
-
* );
|
|
173
|
-
*
|
|
174
|
-
* // Get the WebSocket URL
|
|
175
|
-
* const wsUrl = client.getWsUrl();
|
|
176
|
-
* const ws = new WebSocket(wsUrl);
|
|
177
|
-
* ws.binaryType = 'arraybuffer';
|
|
178
|
-
*
|
|
179
|
-
* ws.onopen = async () => {
|
|
180
|
-
* await client.onConnected();
|
|
181
|
-
* // Drain outgoing messages
|
|
182
|
-
* let msg;
|
|
183
|
-
* while ((msg = client.pollOutgoingBinary())) ws.send(msg);
|
|
184
|
-
* while ((msg = client.pollOutgoingText())) ws.send(msg);
|
|
185
|
-
* };
|
|
186
|
-
*
|
|
187
|
-
* ws.onmessage = async (e) => {
|
|
188
|
-
* if (typeof e.data === 'string') {
|
|
189
|
-
* await client.onTextMessage(e.data);
|
|
190
|
-
* } else {
|
|
191
|
-
* await client.onBinaryMessage(new Uint8Array(e.data));
|
|
192
|
-
* }
|
|
193
|
-
* // Drain outgoing messages and events
|
|
194
|
-
* let msg;
|
|
195
|
-
* while ((msg = client.pollOutgoingBinary())) ws.send(msg);
|
|
196
|
-
* while ((msg = client.pollOutgoingText())) ws.send(msg);
|
|
197
|
-
* };
|
|
198
|
-
* ```
|
|
199
|
-
*/
|
|
200
|
-
createSyncClient(server_url: string, workspace_id: string, auth_token?: string | null): WasmSyncClient;
|
|
201
131
|
/**
|
|
202
132
|
* Emit a filesystem event.
|
|
203
133
|
*
|
|
@@ -247,13 +177,11 @@ export class DiaryxBackend {
|
|
|
247
177
|
getConfig(): Promise<any>;
|
|
248
178
|
/**
|
|
249
179
|
* Check if this backend has native sync support.
|
|
250
|
-
*
|
|
251
|
-
* For WASM, this always returns false. The new `createSyncClient()` API
|
|
252
|
-
* provides a unified approach that works across all platforms.
|
|
180
|
+
* Always false — sync is handled by the Extism sync plugin loaded at runtime.
|
|
253
181
|
*/
|
|
254
182
|
hasNativeSync(): boolean;
|
|
255
183
|
/**
|
|
256
|
-
*
|
|
184
|
+
* Always returns false — CrdtFs is not used; sync handled by Extism plugin.
|
|
257
185
|
*/
|
|
258
186
|
isCrdtEnabled(): boolean;
|
|
259
187
|
/**
|
|
@@ -333,13 +261,9 @@ export class DiaryxBackend {
|
|
|
333
261
|
*/
|
|
334
262
|
saveConfig(config_js: any): Promise<any>;
|
|
335
263
|
/**
|
|
336
|
-
*
|
|
337
|
-
*
|
|
338
|
-
* When disabled, file writes pass through to storage without updating CRDTs.
|
|
339
|
-
* CrdtFs starts disabled by default and should be enabled after sync
|
|
340
|
-
* handshake completes (or immediately in local-only mode).
|
|
264
|
+
* No-op — CrdtFs is not used; sync handled by Extism plugin.
|
|
341
265
|
*/
|
|
342
|
-
setCrdtEnabled(
|
|
266
|
+
setCrdtEnabled(_enabled: boolean): void;
|
|
343
267
|
/**
|
|
344
268
|
* Write binary file.
|
|
345
269
|
*
|
|
@@ -382,118 +306,6 @@ export class JsAsyncFileSystem {
|
|
|
382
306
|
constructor(callbacks: any);
|
|
383
307
|
}
|
|
384
308
|
|
|
385
|
-
/**
|
|
386
|
-
* WASM sync client backed by the shared SyncSession protocol handler.
|
|
387
|
-
*
|
|
388
|
-
* JavaScript feeds WebSocket events in via `onConnected()`, `onBinaryMessage()`,
|
|
389
|
-
* etc. The client processes them through `SyncSession` and queues outgoing
|
|
390
|
-
* messages/events for JavaScript to poll.
|
|
391
|
-
*/
|
|
392
|
-
export class WasmSyncClient {
|
|
393
|
-
private constructor();
|
|
394
|
-
free(): void;
|
|
395
|
-
[Symbol.dispose](): void;
|
|
396
|
-
/**
|
|
397
|
-
* Send a focus message for specific files.
|
|
398
|
-
*
|
|
399
|
-
* Other clients will be notified which files this client is interested in.
|
|
400
|
-
*/
|
|
401
|
-
focusFiles(files: string[]): void;
|
|
402
|
-
/**
|
|
403
|
-
* Get the server URL.
|
|
404
|
-
*/
|
|
405
|
-
getServerUrl(): string;
|
|
406
|
-
/**
|
|
407
|
-
* Get the workspace ID.
|
|
408
|
-
*/
|
|
409
|
-
getWorkspaceId(): string;
|
|
410
|
-
/**
|
|
411
|
-
* Get the WebSocket URL for the v2 sync connection.
|
|
412
|
-
*
|
|
413
|
-
* Returns a URL like `wss://sync.example.com/sync2?token=...&session=...`
|
|
414
|
-
*/
|
|
415
|
-
getWsUrl(): string;
|
|
416
|
-
/**
|
|
417
|
-
* Check if there are pending events.
|
|
418
|
-
*/
|
|
419
|
-
hasEvents(): boolean;
|
|
420
|
-
/**
|
|
421
|
-
* Check if there are pending outgoing messages or events.
|
|
422
|
-
*/
|
|
423
|
-
hasOutgoing(): boolean;
|
|
424
|
-
/**
|
|
425
|
-
* Inject an incoming binary WebSocket message.
|
|
426
|
-
*
|
|
427
|
-
* Returns a Promise that resolves when processing is complete.
|
|
428
|
-
* After this, poll outgoing queues.
|
|
429
|
-
*/
|
|
430
|
-
onBinaryMessage(data: Uint8Array): Promise<any>;
|
|
431
|
-
/**
|
|
432
|
-
* Notify that the WebSocket connected.
|
|
433
|
-
*
|
|
434
|
-
* Triggers workspace SyncStep1 and handshake. After calling this,
|
|
435
|
-
* poll `pollOutgoingBinary()` / `pollOutgoingText()` to get messages to send.
|
|
436
|
-
*/
|
|
437
|
-
onConnected(): Promise<any>;
|
|
438
|
-
/**
|
|
439
|
-
* Notify that the WebSocket disconnected.
|
|
440
|
-
*/
|
|
441
|
-
onDisconnected(): Promise<any>;
|
|
442
|
-
/**
|
|
443
|
-
* Notify that a snapshot was downloaded and imported.
|
|
444
|
-
*
|
|
445
|
-
* Call this after handling a `downloadSnapshot` event.
|
|
446
|
-
*/
|
|
447
|
-
onSnapshotImported(): Promise<any>;
|
|
448
|
-
/**
|
|
449
|
-
* Inject an incoming text WebSocket message (JSON control message).
|
|
450
|
-
*
|
|
451
|
-
* Returns a Promise that resolves when processing is complete.
|
|
452
|
-
*/
|
|
453
|
-
onTextMessage(text: string): Promise<any>;
|
|
454
|
-
/**
|
|
455
|
-
* Poll for a JSON-serialized event.
|
|
456
|
-
*
|
|
457
|
-
* Returns a JSON string representing a SyncEvent, or null.
|
|
458
|
-
*/
|
|
459
|
-
pollEvent(): string | undefined;
|
|
460
|
-
/**
|
|
461
|
-
* Poll for an outgoing binary message.
|
|
462
|
-
*
|
|
463
|
-
* Returns a Uint8Array if there's a message to send, null otherwise.
|
|
464
|
-
*/
|
|
465
|
-
pollOutgoingBinary(): Uint8Array | undefined;
|
|
466
|
-
/**
|
|
467
|
-
* Poll for an outgoing text message.
|
|
468
|
-
*
|
|
469
|
-
* Returns a string if there's a message to send, null otherwise.
|
|
470
|
-
*/
|
|
471
|
-
pollOutgoingText(): string | undefined;
|
|
472
|
-
/**
|
|
473
|
-
* Queue a local CRDT update for sending to the server.
|
|
474
|
-
*
|
|
475
|
-
* Call this when local CRDT changes need to be synced.
|
|
476
|
-
*/
|
|
477
|
-
queueLocalUpdate(doc_id: string, data: Uint8Array): Promise<any>;
|
|
478
|
-
/**
|
|
479
|
-
* Set a share session code.
|
|
480
|
-
*
|
|
481
|
-
* Call this before connecting to join a share session.
|
|
482
|
-
*/
|
|
483
|
-
setSessionCode(code: string): void;
|
|
484
|
-
/**
|
|
485
|
-
* Request body sync for specific files (lazy sync on demand).
|
|
486
|
-
*
|
|
487
|
-
* Sends SyncBodyFiles event through the session to initiate body
|
|
488
|
-
* SyncStep1 for just the requested files, rather than all files.
|
|
489
|
-
*/
|
|
490
|
-
syncBodyFiles(file_paths: string[]): Promise<any>;
|
|
491
|
-
/**
|
|
492
|
-
* Send an unfocus message for specific files.
|
|
493
|
-
*/
|
|
494
|
-
unfocusFiles(files: string[]): void;
|
|
495
|
-
}
|
|
496
|
-
|
|
497
309
|
/**
|
|
498
310
|
* Initialize the WASM module. Called automatically on module load.
|
|
499
311
|
*/
|
|
@@ -513,43 +325,17 @@ export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembl
|
|
|
513
325
|
|
|
514
326
|
export interface InitOutput {
|
|
515
327
|
readonly memory: WebAssembly.Memory;
|
|
516
|
-
readonly __wbg_jsasyncfilesystem_free: (a: number, b: number) => void;
|
|
517
|
-
readonly jsasyncfilesystem_has_callback: (a: number, b: number, c: number) => number;
|
|
518
|
-
readonly jsasyncfilesystem_new: (a: any) => number;
|
|
519
|
-
readonly init: () => void;
|
|
520
|
-
readonly __wbg_wasmsyncclient_free: (a: number, b: number) => void;
|
|
521
|
-
readonly now_timestamp: () => [number, number];
|
|
522
|
-
readonly today_formatted: (a: number, b: number) => [number, number];
|
|
523
|
-
readonly wasmsyncclient_focusFiles: (a: number, b: number, c: number) => void;
|
|
524
|
-
readonly wasmsyncclient_getServerUrl: (a: number) => [number, number];
|
|
525
|
-
readonly wasmsyncclient_getWorkspaceId: (a: number) => [number, number];
|
|
526
|
-
readonly wasmsyncclient_getWsUrl: (a: number) => [number, number];
|
|
527
|
-
readonly wasmsyncclient_hasEvents: (a: number) => number;
|
|
528
|
-
readonly wasmsyncclient_hasOutgoing: (a: number) => number;
|
|
529
|
-
readonly wasmsyncclient_onBinaryMessage: (a: number, b: number, c: number) => any;
|
|
530
|
-
readonly wasmsyncclient_onConnected: (a: number) => any;
|
|
531
|
-
readonly wasmsyncclient_onDisconnected: (a: number) => any;
|
|
532
|
-
readonly wasmsyncclient_onSnapshotImported: (a: number) => any;
|
|
533
|
-
readonly wasmsyncclient_onTextMessage: (a: number, b: number, c: number) => any;
|
|
534
|
-
readonly wasmsyncclient_pollEvent: (a: number) => [number, number];
|
|
535
|
-
readonly wasmsyncclient_pollOutgoingBinary: (a: number) => any;
|
|
536
|
-
readonly wasmsyncclient_pollOutgoingText: (a: number) => [number, number];
|
|
537
|
-
readonly wasmsyncclient_queueLocalUpdate: (a: number, b: number, c: number, d: number, e: number) => any;
|
|
538
|
-
readonly wasmsyncclient_setSessionCode: (a: number, b: number, c: number) => void;
|
|
539
|
-
readonly wasmsyncclient_syncBodyFiles: (a: number, b: number, c: number) => any;
|
|
540
|
-
readonly wasmsyncclient_unfocusFiles: (a: number, b: number, c: number) => void;
|
|
541
328
|
readonly __wbg_diaryxbackend_free: (a: number, b: number) => void;
|
|
329
|
+
readonly __wbg_jsasyncfilesystem_free: (a: number, b: number) => void;
|
|
542
330
|
readonly diaryxbackend_create: (a: number, b: number) => any;
|
|
543
331
|
readonly diaryxbackend_createFromJsFileSystem: (a: any) => [number, number, number];
|
|
544
332
|
readonly diaryxbackend_createInMemory: () => [number, number, number];
|
|
545
|
-
readonly diaryxbackend_createSyncClient: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => number;
|
|
546
333
|
readonly diaryxbackend_emitFileSystemEvent: (a: number, b: number, c: number) => [number, number];
|
|
547
334
|
readonly diaryxbackend_eventSubscriberCount: (a: number) => number;
|
|
548
335
|
readonly diaryxbackend_execute: (a: number, b: number, c: number) => any;
|
|
549
336
|
readonly diaryxbackend_executeJs: (a: number, b: any) => any;
|
|
550
337
|
readonly diaryxbackend_getConfig: (a: number) => any;
|
|
551
338
|
readonly diaryxbackend_hasNativeSync: (a: number) => number;
|
|
552
|
-
readonly diaryxbackend_isCrdtEnabled: (a: number) => number;
|
|
553
339
|
readonly diaryxbackend_offFileSystemEvent: (a: number, b: bigint) => number;
|
|
554
340
|
readonly diaryxbackend_onFileSystemEvent: (a: number, b: any) => bigint;
|
|
555
341
|
readonly diaryxbackend_parseDayOneJson: (a: number, b: number, c: number) => [number, number, number, number];
|
|
@@ -558,9 +344,15 @@ export interface InitOutput {
|
|
|
558
344
|
readonly diaryxbackend_saveConfig: (a: number, b: any) => any;
|
|
559
345
|
readonly diaryxbackend_setCrdtEnabled: (a: number, b: number) => void;
|
|
560
346
|
readonly diaryxbackend_writeBinary: (a: number, b: number, c: number, d: any) => any;
|
|
561
|
-
readonly
|
|
562
|
-
readonly
|
|
563
|
-
readonly
|
|
347
|
+
readonly jsasyncfilesystem_has_callback: (a: number, b: number, c: number) => number;
|
|
348
|
+
readonly jsasyncfilesystem_new: (a: any) => number;
|
|
349
|
+
readonly now_timestamp: () => [number, number];
|
|
350
|
+
readonly today_formatted: (a: number, b: number) => [number, number];
|
|
351
|
+
readonly diaryxbackend_isCrdtEnabled: (a: number) => number;
|
|
352
|
+
readonly init: () => void;
|
|
353
|
+
readonly wasm_bindgen__closure__destroy__hdba164d367f73b05: (a: number, b: number) => void;
|
|
354
|
+
readonly wasm_bindgen__convert__closures_____invoke__h0d59e9d6e6af2fb0: (a: number, b: number, c: any, d: any) => void;
|
|
355
|
+
readonly wasm_bindgen__convert__closures_____invoke__hf7b661626d016918: (a: number, b: number, c: any) => void;
|
|
564
356
|
readonly __wbindgen_malloc: (a: number, b: number) => number;
|
|
565
357
|
readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
|
|
566
358
|
readonly __wbindgen_exn_store: (a: number) => void;
|
package/diaryx_wasm.js
CHANGED
|
@@ -50,20 +50,6 @@ export class DiaryxBackend {
|
|
|
50
50
|
}
|
|
51
51
|
/**
|
|
52
52
|
* Create a new DiaryxBackend backed by JavaScript filesystem callbacks.
|
|
53
|
-
*
|
|
54
|
-
* This is the primary way to use diaryx from non-browser environments
|
|
55
|
-
* (Node.js, Obsidian, Electron). The `callbacks` object must implement
|
|
56
|
-
* the `JsFileSystemCallbacks` interface.
|
|
57
|
-
*
|
|
58
|
-
* ## Example
|
|
59
|
-
* ```javascript
|
|
60
|
-
* const backend = DiaryxBackend.createFromJsFileSystem({
|
|
61
|
-
* readToString: async (path) => fs.readFile(path, 'utf8'),
|
|
62
|
-
* writeFile: async (path, content) => fs.writeFile(path, content),
|
|
63
|
-
* exists: async (path) => fs.access(path).then(() => true).catch(() => false),
|
|
64
|
-
* // ... other callbacks
|
|
65
|
-
* });
|
|
66
|
-
* ```
|
|
67
53
|
* @param {any} callbacks
|
|
68
54
|
* @returns {DiaryxBackend}
|
|
69
55
|
*/
|
|
@@ -76,19 +62,6 @@ export class DiaryxBackend {
|
|
|
76
62
|
}
|
|
77
63
|
/**
|
|
78
64
|
* Create a new DiaryxBackend with in-memory storage.
|
|
79
|
-
*
|
|
80
|
-
* This is used for guest mode in share sessions. Files are stored
|
|
81
|
-
* only in memory and are cleared when the session ends.
|
|
82
|
-
*
|
|
83
|
-
* ## Use Cases
|
|
84
|
-
* - Guest mode in share sessions (web)
|
|
85
|
-
* - Testing
|
|
86
|
-
*
|
|
87
|
-
* ## Example
|
|
88
|
-
* ```javascript
|
|
89
|
-
* const backend = DiaryxBackend.createInMemory();
|
|
90
|
-
* // Files are stored in memory only
|
|
91
|
-
* ```
|
|
92
65
|
* @returns {DiaryxBackend}
|
|
93
66
|
*/
|
|
94
67
|
static createInMemory() {
|
|
@@ -98,62 +71,6 @@ export class DiaryxBackend {
|
|
|
98
71
|
}
|
|
99
72
|
return DiaryxBackend.__wrap(ret[0]);
|
|
100
73
|
}
|
|
101
|
-
/**
|
|
102
|
-
* Create a new sync client for the given server and workspace.
|
|
103
|
-
*
|
|
104
|
-
* Creates a `WasmSyncClient` backed by the shared `SyncSession` protocol
|
|
105
|
-
* handler. JavaScript manages the WebSocket while Rust handles all sync
|
|
106
|
-
* protocol logic (handshake, message routing, framing).
|
|
107
|
-
*
|
|
108
|
-
* ## Example
|
|
109
|
-
*
|
|
110
|
-
* ```javascript
|
|
111
|
-
* const client = backend.createSyncClient(
|
|
112
|
-
* 'https://sync.example.com',
|
|
113
|
-
* 'my-workspace-id',
|
|
114
|
-
* 'auth-token-optional'
|
|
115
|
-
* );
|
|
116
|
-
*
|
|
117
|
-
* // Get the WebSocket URL
|
|
118
|
-
* const wsUrl = client.getWsUrl();
|
|
119
|
-
* const ws = new WebSocket(wsUrl);
|
|
120
|
-
* ws.binaryType = 'arraybuffer';
|
|
121
|
-
*
|
|
122
|
-
* ws.onopen = async () => {
|
|
123
|
-
* await client.onConnected();
|
|
124
|
-
* // Drain outgoing messages
|
|
125
|
-
* let msg;
|
|
126
|
-
* while ((msg = client.pollOutgoingBinary())) ws.send(msg);
|
|
127
|
-
* while ((msg = client.pollOutgoingText())) ws.send(msg);
|
|
128
|
-
* };
|
|
129
|
-
*
|
|
130
|
-
* ws.onmessage = async (e) => {
|
|
131
|
-
* if (typeof e.data === 'string') {
|
|
132
|
-
* await client.onTextMessage(e.data);
|
|
133
|
-
* } else {
|
|
134
|
-
* await client.onBinaryMessage(new Uint8Array(e.data));
|
|
135
|
-
* }
|
|
136
|
-
* // Drain outgoing messages and events
|
|
137
|
-
* let msg;
|
|
138
|
-
* while ((msg = client.pollOutgoingBinary())) ws.send(msg);
|
|
139
|
-
* while ((msg = client.pollOutgoingText())) ws.send(msg);
|
|
140
|
-
* };
|
|
141
|
-
* ```
|
|
142
|
-
* @param {string} server_url
|
|
143
|
-
* @param {string} workspace_id
|
|
144
|
-
* @param {string | null} [auth_token]
|
|
145
|
-
* @returns {WasmSyncClient}
|
|
146
|
-
*/
|
|
147
|
-
createSyncClient(server_url, workspace_id, auth_token) {
|
|
148
|
-
const ptr0 = passStringToWasm0(server_url, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
149
|
-
const len0 = WASM_VECTOR_LEN;
|
|
150
|
-
const ptr1 = passStringToWasm0(workspace_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
151
|
-
const len1 = WASM_VECTOR_LEN;
|
|
152
|
-
var ptr2 = isLikeNone(auth_token) ? 0 : passStringToWasm0(auth_token, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
153
|
-
var len2 = WASM_VECTOR_LEN;
|
|
154
|
-
const ret = wasm.diaryxbackend_createSyncClient(this.__wbg_ptr, ptr0, len0, ptr1, len1, ptr2, len2);
|
|
155
|
-
return WasmSyncClient.__wrap(ret);
|
|
156
|
-
}
|
|
157
74
|
/**
|
|
158
75
|
* Emit a filesystem event.
|
|
159
76
|
*
|
|
@@ -231,9 +148,7 @@ export class DiaryxBackend {
|
|
|
231
148
|
}
|
|
232
149
|
/**
|
|
233
150
|
* Check if this backend has native sync support.
|
|
234
|
-
*
|
|
235
|
-
* For WASM, this always returns false. The new `createSyncClient()` API
|
|
236
|
-
* provides a unified approach that works across all platforms.
|
|
151
|
+
* Always false — sync is handled by the Extism sync plugin loaded at runtime.
|
|
237
152
|
* @returns {boolean}
|
|
238
153
|
*/
|
|
239
154
|
hasNativeSync() {
|
|
@@ -241,11 +156,11 @@ export class DiaryxBackend {
|
|
|
241
156
|
return ret !== 0;
|
|
242
157
|
}
|
|
243
158
|
/**
|
|
244
|
-
*
|
|
159
|
+
* Always returns false — CrdtFs is not used; sync handled by Extism plugin.
|
|
245
160
|
* @returns {boolean}
|
|
246
161
|
*/
|
|
247
162
|
isCrdtEnabled() {
|
|
248
|
-
const ret = wasm.
|
|
163
|
+
const ret = wasm.diaryxbackend_hasNativeSync(this.__wbg_ptr);
|
|
249
164
|
return ret !== 0;
|
|
250
165
|
}
|
|
251
166
|
/**
|
|
@@ -392,15 +307,11 @@ export class DiaryxBackend {
|
|
|
392
307
|
return ret;
|
|
393
308
|
}
|
|
394
309
|
/**
|
|
395
|
-
*
|
|
396
|
-
*
|
|
397
|
-
* When disabled, file writes pass through to storage without updating CRDTs.
|
|
398
|
-
* CrdtFs starts disabled by default and should be enabled after sync
|
|
399
|
-
* handshake completes (or immediately in local-only mode).
|
|
400
|
-
* @param {boolean} enabled
|
|
310
|
+
* No-op — CrdtFs is not used; sync handled by Extism plugin.
|
|
311
|
+
* @param {boolean} _enabled
|
|
401
312
|
*/
|
|
402
|
-
setCrdtEnabled(
|
|
403
|
-
wasm.diaryxbackend_setCrdtEnabled(this.__wbg_ptr,
|
|
313
|
+
setCrdtEnabled(_enabled) {
|
|
314
|
+
wasm.diaryxbackend_setCrdtEnabled(this.__wbg_ptr, _enabled);
|
|
404
315
|
}
|
|
405
316
|
/**
|
|
406
317
|
* Write binary file.
|
|
@@ -475,257 +386,6 @@ export class JsAsyncFileSystem {
|
|
|
475
386
|
}
|
|
476
387
|
if (Symbol.dispose) JsAsyncFileSystem.prototype[Symbol.dispose] = JsAsyncFileSystem.prototype.free;
|
|
477
388
|
|
|
478
|
-
/**
|
|
479
|
-
* WASM sync client backed by the shared SyncSession protocol handler.
|
|
480
|
-
*
|
|
481
|
-
* JavaScript feeds WebSocket events in via `onConnected()`, `onBinaryMessage()`,
|
|
482
|
-
* etc. The client processes them through `SyncSession` and queues outgoing
|
|
483
|
-
* messages/events for JavaScript to poll.
|
|
484
|
-
*/
|
|
485
|
-
export class WasmSyncClient {
|
|
486
|
-
static __wrap(ptr) {
|
|
487
|
-
ptr = ptr >>> 0;
|
|
488
|
-
const obj = Object.create(WasmSyncClient.prototype);
|
|
489
|
-
obj.__wbg_ptr = ptr;
|
|
490
|
-
WasmSyncClientFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
491
|
-
return obj;
|
|
492
|
-
}
|
|
493
|
-
__destroy_into_raw() {
|
|
494
|
-
const ptr = this.__wbg_ptr;
|
|
495
|
-
this.__wbg_ptr = 0;
|
|
496
|
-
WasmSyncClientFinalization.unregister(this);
|
|
497
|
-
return ptr;
|
|
498
|
-
}
|
|
499
|
-
free() {
|
|
500
|
-
const ptr = this.__destroy_into_raw();
|
|
501
|
-
wasm.__wbg_wasmsyncclient_free(ptr, 0);
|
|
502
|
-
}
|
|
503
|
-
/**
|
|
504
|
-
* Send a focus message for specific files.
|
|
505
|
-
*
|
|
506
|
-
* Other clients will be notified which files this client is interested in.
|
|
507
|
-
* @param {string[]} files
|
|
508
|
-
*/
|
|
509
|
-
focusFiles(files) {
|
|
510
|
-
const ptr0 = passArrayJsValueToWasm0(files, wasm.__wbindgen_malloc);
|
|
511
|
-
const len0 = WASM_VECTOR_LEN;
|
|
512
|
-
wasm.wasmsyncclient_focusFiles(this.__wbg_ptr, ptr0, len0);
|
|
513
|
-
}
|
|
514
|
-
/**
|
|
515
|
-
* Get the server URL.
|
|
516
|
-
* @returns {string}
|
|
517
|
-
*/
|
|
518
|
-
getServerUrl() {
|
|
519
|
-
let deferred1_0;
|
|
520
|
-
let deferred1_1;
|
|
521
|
-
try {
|
|
522
|
-
const ret = wasm.wasmsyncclient_getServerUrl(this.__wbg_ptr);
|
|
523
|
-
deferred1_0 = ret[0];
|
|
524
|
-
deferred1_1 = ret[1];
|
|
525
|
-
return getStringFromWasm0(ret[0], ret[1]);
|
|
526
|
-
} finally {
|
|
527
|
-
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
528
|
-
}
|
|
529
|
-
}
|
|
530
|
-
/**
|
|
531
|
-
* Get the workspace ID.
|
|
532
|
-
* @returns {string}
|
|
533
|
-
*/
|
|
534
|
-
getWorkspaceId() {
|
|
535
|
-
let deferred1_0;
|
|
536
|
-
let deferred1_1;
|
|
537
|
-
try {
|
|
538
|
-
const ret = wasm.wasmsyncclient_getWorkspaceId(this.__wbg_ptr);
|
|
539
|
-
deferred1_0 = ret[0];
|
|
540
|
-
deferred1_1 = ret[1];
|
|
541
|
-
return getStringFromWasm0(ret[0], ret[1]);
|
|
542
|
-
} finally {
|
|
543
|
-
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
544
|
-
}
|
|
545
|
-
}
|
|
546
|
-
/**
|
|
547
|
-
* Get the WebSocket URL for the v2 sync connection.
|
|
548
|
-
*
|
|
549
|
-
* Returns a URL like `wss://sync.example.com/sync2?token=...&session=...`
|
|
550
|
-
* @returns {string}
|
|
551
|
-
*/
|
|
552
|
-
getWsUrl() {
|
|
553
|
-
let deferred1_0;
|
|
554
|
-
let deferred1_1;
|
|
555
|
-
try {
|
|
556
|
-
const ret = wasm.wasmsyncclient_getWsUrl(this.__wbg_ptr);
|
|
557
|
-
deferred1_0 = ret[0];
|
|
558
|
-
deferred1_1 = ret[1];
|
|
559
|
-
return getStringFromWasm0(ret[0], ret[1]);
|
|
560
|
-
} finally {
|
|
561
|
-
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
562
|
-
}
|
|
563
|
-
}
|
|
564
|
-
/**
|
|
565
|
-
* Check if there are pending events.
|
|
566
|
-
* @returns {boolean}
|
|
567
|
-
*/
|
|
568
|
-
hasEvents() {
|
|
569
|
-
const ret = wasm.wasmsyncclient_hasEvents(this.__wbg_ptr);
|
|
570
|
-
return ret !== 0;
|
|
571
|
-
}
|
|
572
|
-
/**
|
|
573
|
-
* Check if there are pending outgoing messages or events.
|
|
574
|
-
* @returns {boolean}
|
|
575
|
-
*/
|
|
576
|
-
hasOutgoing() {
|
|
577
|
-
const ret = wasm.wasmsyncclient_hasOutgoing(this.__wbg_ptr);
|
|
578
|
-
return ret !== 0;
|
|
579
|
-
}
|
|
580
|
-
/**
|
|
581
|
-
* Inject an incoming binary WebSocket message.
|
|
582
|
-
*
|
|
583
|
-
* Returns a Promise that resolves when processing is complete.
|
|
584
|
-
* After this, poll outgoing queues.
|
|
585
|
-
* @param {Uint8Array} data
|
|
586
|
-
* @returns {Promise<any>}
|
|
587
|
-
*/
|
|
588
|
-
onBinaryMessage(data) {
|
|
589
|
-
const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_malloc);
|
|
590
|
-
const len0 = WASM_VECTOR_LEN;
|
|
591
|
-
const ret = wasm.wasmsyncclient_onBinaryMessage(this.__wbg_ptr, ptr0, len0);
|
|
592
|
-
return ret;
|
|
593
|
-
}
|
|
594
|
-
/**
|
|
595
|
-
* Notify that the WebSocket connected.
|
|
596
|
-
*
|
|
597
|
-
* Triggers workspace SyncStep1 and handshake. After calling this,
|
|
598
|
-
* poll `pollOutgoingBinary()` / `pollOutgoingText()` to get messages to send.
|
|
599
|
-
* @returns {Promise<any>}
|
|
600
|
-
*/
|
|
601
|
-
onConnected() {
|
|
602
|
-
const ret = wasm.wasmsyncclient_onConnected(this.__wbg_ptr);
|
|
603
|
-
return ret;
|
|
604
|
-
}
|
|
605
|
-
/**
|
|
606
|
-
* Notify that the WebSocket disconnected.
|
|
607
|
-
* @returns {Promise<any>}
|
|
608
|
-
*/
|
|
609
|
-
onDisconnected() {
|
|
610
|
-
const ret = wasm.wasmsyncclient_onDisconnected(this.__wbg_ptr);
|
|
611
|
-
return ret;
|
|
612
|
-
}
|
|
613
|
-
/**
|
|
614
|
-
* Notify that a snapshot was downloaded and imported.
|
|
615
|
-
*
|
|
616
|
-
* Call this after handling a `downloadSnapshot` event.
|
|
617
|
-
* @returns {Promise<any>}
|
|
618
|
-
*/
|
|
619
|
-
onSnapshotImported() {
|
|
620
|
-
const ret = wasm.wasmsyncclient_onSnapshotImported(this.__wbg_ptr);
|
|
621
|
-
return ret;
|
|
622
|
-
}
|
|
623
|
-
/**
|
|
624
|
-
* Inject an incoming text WebSocket message (JSON control message).
|
|
625
|
-
*
|
|
626
|
-
* Returns a Promise that resolves when processing is complete.
|
|
627
|
-
* @param {string} text
|
|
628
|
-
* @returns {Promise<any>}
|
|
629
|
-
*/
|
|
630
|
-
onTextMessage(text) {
|
|
631
|
-
const ptr0 = passStringToWasm0(text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
632
|
-
const len0 = WASM_VECTOR_LEN;
|
|
633
|
-
const ret = wasm.wasmsyncclient_onTextMessage(this.__wbg_ptr, ptr0, len0);
|
|
634
|
-
return ret;
|
|
635
|
-
}
|
|
636
|
-
/**
|
|
637
|
-
* Poll for a JSON-serialized event.
|
|
638
|
-
*
|
|
639
|
-
* Returns a JSON string representing a SyncEvent, or null.
|
|
640
|
-
* @returns {string | undefined}
|
|
641
|
-
*/
|
|
642
|
-
pollEvent() {
|
|
643
|
-
const ret = wasm.wasmsyncclient_pollEvent(this.__wbg_ptr);
|
|
644
|
-
let v1;
|
|
645
|
-
if (ret[0] !== 0) {
|
|
646
|
-
v1 = getStringFromWasm0(ret[0], ret[1]).slice();
|
|
647
|
-
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
648
|
-
}
|
|
649
|
-
return v1;
|
|
650
|
-
}
|
|
651
|
-
/**
|
|
652
|
-
* Poll for an outgoing binary message.
|
|
653
|
-
*
|
|
654
|
-
* Returns a Uint8Array if there's a message to send, null otherwise.
|
|
655
|
-
* @returns {Uint8Array | undefined}
|
|
656
|
-
*/
|
|
657
|
-
pollOutgoingBinary() {
|
|
658
|
-
const ret = wasm.wasmsyncclient_pollOutgoingBinary(this.__wbg_ptr);
|
|
659
|
-
return ret;
|
|
660
|
-
}
|
|
661
|
-
/**
|
|
662
|
-
* Poll for an outgoing text message.
|
|
663
|
-
*
|
|
664
|
-
* Returns a string if there's a message to send, null otherwise.
|
|
665
|
-
* @returns {string | undefined}
|
|
666
|
-
*/
|
|
667
|
-
pollOutgoingText() {
|
|
668
|
-
const ret = wasm.wasmsyncclient_pollOutgoingText(this.__wbg_ptr);
|
|
669
|
-
let v1;
|
|
670
|
-
if (ret[0] !== 0) {
|
|
671
|
-
v1 = getStringFromWasm0(ret[0], ret[1]).slice();
|
|
672
|
-
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
673
|
-
}
|
|
674
|
-
return v1;
|
|
675
|
-
}
|
|
676
|
-
/**
|
|
677
|
-
* Queue a local CRDT update for sending to the server.
|
|
678
|
-
*
|
|
679
|
-
* Call this when local CRDT changes need to be synced.
|
|
680
|
-
* @param {string} doc_id
|
|
681
|
-
* @param {Uint8Array} data
|
|
682
|
-
* @returns {Promise<any>}
|
|
683
|
-
*/
|
|
684
|
-
queueLocalUpdate(doc_id, data) {
|
|
685
|
-
const ptr0 = passStringToWasm0(doc_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
686
|
-
const len0 = WASM_VECTOR_LEN;
|
|
687
|
-
const ptr1 = passArray8ToWasm0(data, wasm.__wbindgen_malloc);
|
|
688
|
-
const len1 = WASM_VECTOR_LEN;
|
|
689
|
-
const ret = wasm.wasmsyncclient_queueLocalUpdate(this.__wbg_ptr, ptr0, len0, ptr1, len1);
|
|
690
|
-
return ret;
|
|
691
|
-
}
|
|
692
|
-
/**
|
|
693
|
-
* Set a share session code.
|
|
694
|
-
*
|
|
695
|
-
* Call this before connecting to join a share session.
|
|
696
|
-
* @param {string} code
|
|
697
|
-
*/
|
|
698
|
-
setSessionCode(code) {
|
|
699
|
-
const ptr0 = passStringToWasm0(code, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
700
|
-
const len0 = WASM_VECTOR_LEN;
|
|
701
|
-
wasm.wasmsyncclient_setSessionCode(this.__wbg_ptr, ptr0, len0);
|
|
702
|
-
}
|
|
703
|
-
/**
|
|
704
|
-
* Request body sync for specific files (lazy sync on demand).
|
|
705
|
-
*
|
|
706
|
-
* Sends SyncBodyFiles event through the session to initiate body
|
|
707
|
-
* SyncStep1 for just the requested files, rather than all files.
|
|
708
|
-
* @param {string[]} file_paths
|
|
709
|
-
* @returns {Promise<any>}
|
|
710
|
-
*/
|
|
711
|
-
syncBodyFiles(file_paths) {
|
|
712
|
-
const ptr0 = passArrayJsValueToWasm0(file_paths, wasm.__wbindgen_malloc);
|
|
713
|
-
const len0 = WASM_VECTOR_LEN;
|
|
714
|
-
const ret = wasm.wasmsyncclient_syncBodyFiles(this.__wbg_ptr, ptr0, len0);
|
|
715
|
-
return ret;
|
|
716
|
-
}
|
|
717
|
-
/**
|
|
718
|
-
* Send an unfocus message for specific files.
|
|
719
|
-
* @param {string[]} files
|
|
720
|
-
*/
|
|
721
|
-
unfocusFiles(files) {
|
|
722
|
-
const ptr0 = passArrayJsValueToWasm0(files, wasm.__wbindgen_malloc);
|
|
723
|
-
const len0 = WASM_VECTOR_LEN;
|
|
724
|
-
wasm.wasmsyncclient_unfocusFiles(this.__wbg_ptr, ptr0, len0);
|
|
725
|
-
}
|
|
726
|
-
}
|
|
727
|
-
if (Symbol.dispose) WasmSyncClient.prototype[Symbol.dispose] = WasmSyncClient.prototype.free;
|
|
728
|
-
|
|
729
389
|
/**
|
|
730
390
|
* Initialize the WASM module. Called automatically on module load.
|
|
731
391
|
*/
|
|
@@ -879,10 +539,6 @@ function __wbg_get_imports() {
|
|
|
879
539
|
const ret = arg0.call(arg1, arg2, arg3, arg4);
|
|
880
540
|
return ret;
|
|
881
541
|
}, arguments); },
|
|
882
|
-
__wbg_crypto_86f2631e91b51511: function(arg0) {
|
|
883
|
-
const ret = arg0.crypto;
|
|
884
|
-
return ret;
|
|
885
|
-
},
|
|
886
542
|
__wbg_debug_46a93995fc6f8820: function(arg0, arg1, arg2, arg3) {
|
|
887
543
|
console.debug(arg0, arg1, arg2, arg3);
|
|
888
544
|
},
|
|
@@ -901,8 +557,9 @@ function __wbg_get_imports() {
|
|
|
901
557
|
__wbg_error_794d0ffc9d00d5c3: function(arg0, arg1, arg2, arg3) {
|
|
902
558
|
console.error(arg0, arg1, arg2, arg3);
|
|
903
559
|
},
|
|
904
|
-
|
|
905
|
-
|
|
560
|
+
__wbg_fromCodePoint_22365db7b7d6ac39: function() { return handleError(function (arg0) {
|
|
561
|
+
const ret = String.fromCodePoint(arg0 >>> 0);
|
|
562
|
+
return ret;
|
|
906
563
|
}, arguments); },
|
|
907
564
|
__wbg_getTime_1e3cd1391c5c3995: function(arg0) {
|
|
908
565
|
const ret = arg0.getTime();
|
|
@@ -1000,10 +657,6 @@ function __wbg_get_imports() {
|
|
|
1000
657
|
__wbg_log_24aba2a6d8990b35: function(arg0, arg1, arg2, arg3) {
|
|
1001
658
|
console.log(arg0, arg1, arg2, arg3);
|
|
1002
659
|
},
|
|
1003
|
-
__wbg_msCrypto_d562bbe83e0d4b91: function(arg0) {
|
|
1004
|
-
const ret = arg0.msCrypto;
|
|
1005
|
-
return ret;
|
|
1006
|
-
},
|
|
1007
660
|
__wbg_new_0_73afc35eb544e539: function() {
|
|
1008
661
|
const ret = new Date();
|
|
1009
662
|
return ret;
|
|
@@ -1027,7 +680,7 @@ function __wbg_get_imports() {
|
|
|
1027
680
|
const a = state0.a;
|
|
1028
681
|
state0.a = 0;
|
|
1029
682
|
try {
|
|
1030
|
-
return
|
|
683
|
+
return wasm_bindgen__convert__closures_____invoke__h0d59e9d6e6af2fb0(a, state0.b, arg0, arg1);
|
|
1031
684
|
} finally {
|
|
1032
685
|
state0.a = a;
|
|
1033
686
|
}
|
|
@@ -1066,18 +719,10 @@ function __wbg_get_imports() {
|
|
|
1066
719
|
const ret = arg0.next;
|
|
1067
720
|
return ret;
|
|
1068
721
|
},
|
|
1069
|
-
__wbg_node_e1f24f89a7336c2e: function(arg0) {
|
|
1070
|
-
const ret = arg0.node;
|
|
1071
|
-
return ret;
|
|
1072
|
-
},
|
|
1073
722
|
__wbg_parse_708461a1feddfb38: function() { return handleError(function (arg0, arg1) {
|
|
1074
723
|
const ret = JSON.parse(getStringFromWasm0(arg0, arg1));
|
|
1075
724
|
return ret;
|
|
1076
725
|
}, arguments); },
|
|
1077
|
-
__wbg_process_3975fd6c72f520aa: function(arg0) {
|
|
1078
|
-
const ret = arg0.process;
|
|
1079
|
-
return ret;
|
|
1080
|
-
},
|
|
1081
726
|
__wbg_prototypesetcall_bdcdcc5842e4d77d: function(arg0, arg1, arg2) {
|
|
1082
727
|
Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), arg2);
|
|
1083
728
|
},
|
|
@@ -1092,13 +737,6 @@ function __wbg_get_imports() {
|
|
|
1092
737
|
__wbg_queueMicrotask_5bb536982f78a56f: function(arg0) {
|
|
1093
738
|
queueMicrotask(arg0);
|
|
1094
739
|
},
|
|
1095
|
-
__wbg_randomFillSync_f8c153b79f285817: function() { return handleError(function (arg0, arg1) {
|
|
1096
|
-
arg0.randomFillSync(arg1);
|
|
1097
|
-
}, arguments); },
|
|
1098
|
-
__wbg_require_b74f47fc2d022fd6: function() { return handleError(function () {
|
|
1099
|
-
const ret = module.require;
|
|
1100
|
-
return ret;
|
|
1101
|
-
}, arguments); },
|
|
1102
740
|
__wbg_resolve_002c4b7d9d8f6b64: function(arg0) {
|
|
1103
741
|
const ret = Promise.resolve(arg0);
|
|
1104
742
|
return ret;
|
|
@@ -1136,10 +774,6 @@ function __wbg_get_imports() {
|
|
|
1136
774
|
const ret = JSON.stringify(arg0);
|
|
1137
775
|
return ret;
|
|
1138
776
|
}, arguments); },
|
|
1139
|
-
__wbg_subarray_a96e1fef17ed23cb: function(arg0, arg1, arg2) {
|
|
1140
|
-
const ret = arg0.subarray(arg1 >>> 0, arg2 >>> 0);
|
|
1141
|
-
return ret;
|
|
1142
|
-
},
|
|
1143
777
|
__wbg_then_0d9fe2c7b1857d32: function(arg0, arg1, arg2) {
|
|
1144
778
|
const ret = arg0.then(arg1, arg2);
|
|
1145
779
|
return ret;
|
|
@@ -1156,16 +790,12 @@ function __wbg_get_imports() {
|
|
|
1156
790
|
const ret = arg0.value;
|
|
1157
791
|
return ret;
|
|
1158
792
|
},
|
|
1159
|
-
__wbg_versions_4e31226f5e8dc909: function(arg0) {
|
|
1160
|
-
const ret = arg0.versions;
|
|
1161
|
-
return ret;
|
|
1162
|
-
},
|
|
1163
793
|
__wbg_warn_a40b971467b219c7: function(arg0, arg1, arg2, arg3) {
|
|
1164
794
|
console.warn(arg0, arg1, arg2, arg3);
|
|
1165
795
|
},
|
|
1166
796
|
__wbindgen_cast_0000000000000001: function(arg0, arg1) {
|
|
1167
|
-
// Cast intrinsic for `Closure(Closure { dtor_idx:
|
|
1168
|
-
const ret = makeMutClosure(arg0, arg1, wasm.
|
|
797
|
+
// Cast intrinsic for `Closure(Closure { dtor_idx: 427, function: Function { arguments: [Externref], shim_idx: 428, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
|
|
798
|
+
const ret = makeMutClosure(arg0, arg1, wasm.wasm_bindgen__closure__destroy__hdba164d367f73b05, wasm_bindgen__convert__closures_____invoke__hf7b661626d016918);
|
|
1169
799
|
return ret;
|
|
1170
800
|
},
|
|
1171
801
|
__wbindgen_cast_0000000000000002: function(arg0) {
|
|
@@ -1179,16 +809,11 @@ function __wbg_get_imports() {
|
|
|
1179
809
|
return ret;
|
|
1180
810
|
},
|
|
1181
811
|
__wbindgen_cast_0000000000000004: function(arg0, arg1) {
|
|
1182
|
-
// Cast intrinsic for `Ref(Slice(U8)) -> NamedExternref("Uint8Array")`.
|
|
1183
|
-
const ret = getArrayU8FromWasm0(arg0, arg1);
|
|
1184
|
-
return ret;
|
|
1185
|
-
},
|
|
1186
|
-
__wbindgen_cast_0000000000000005: function(arg0, arg1) {
|
|
1187
812
|
// Cast intrinsic for `Ref(String) -> Externref`.
|
|
1188
813
|
const ret = getStringFromWasm0(arg0, arg1);
|
|
1189
814
|
return ret;
|
|
1190
815
|
},
|
|
1191
|
-
|
|
816
|
+
__wbindgen_cast_0000000000000005: function(arg0) {
|
|
1192
817
|
// Cast intrinsic for `U64 -> Externref`.
|
|
1193
818
|
const ret = BigInt.asUintN(64, arg0);
|
|
1194
819
|
return ret;
|
|
@@ -1209,12 +834,12 @@ function __wbg_get_imports() {
|
|
|
1209
834
|
};
|
|
1210
835
|
}
|
|
1211
836
|
|
|
1212
|
-
function
|
|
1213
|
-
wasm.
|
|
837
|
+
function wasm_bindgen__convert__closures_____invoke__hf7b661626d016918(arg0, arg1, arg2) {
|
|
838
|
+
wasm.wasm_bindgen__convert__closures_____invoke__hf7b661626d016918(arg0, arg1, arg2);
|
|
1214
839
|
}
|
|
1215
840
|
|
|
1216
|
-
function
|
|
1217
|
-
wasm.
|
|
841
|
+
function wasm_bindgen__convert__closures_____invoke__h0d59e9d6e6af2fb0(arg0, arg1, arg2, arg3) {
|
|
842
|
+
wasm.wasm_bindgen__convert__closures_____invoke__h0d59e9d6e6af2fb0(arg0, arg1, arg2, arg3);
|
|
1218
843
|
}
|
|
1219
844
|
|
|
1220
845
|
const DiaryxBackendFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
@@ -1223,9 +848,6 @@ const DiaryxBackendFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
|
1223
848
|
const JsAsyncFileSystemFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
1224
849
|
? { register: () => {}, unregister: () => {} }
|
|
1225
850
|
: new FinalizationRegistry(ptr => wasm.__wbg_jsasyncfilesystem_free(ptr >>> 0, 1));
|
|
1226
|
-
const WasmSyncClientFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
1227
|
-
? { register: () => {}, unregister: () => {} }
|
|
1228
|
-
: new FinalizationRegistry(ptr => wasm.__wbg_wasmsyncclient_free(ptr >>> 0, 1));
|
|
1229
851
|
|
|
1230
852
|
function addToExternrefTable0(obj) {
|
|
1231
853
|
const idx = wasm.__externref_table_alloc();
|
|
@@ -1376,16 +998,6 @@ function passArray8ToWasm0(arg, malloc) {
|
|
|
1376
998
|
return ptr;
|
|
1377
999
|
}
|
|
1378
1000
|
|
|
1379
|
-
function passArrayJsValueToWasm0(array, malloc) {
|
|
1380
|
-
const ptr = malloc(array.length * 4, 4) >>> 0;
|
|
1381
|
-
for (let i = 0; i < array.length; i++) {
|
|
1382
|
-
const add = addToExternrefTable0(array[i]);
|
|
1383
|
-
getDataViewMemory0().setUint32(ptr + 4 * i, add, true);
|
|
1384
|
-
}
|
|
1385
|
-
WASM_VECTOR_LEN = array.length;
|
|
1386
|
-
return ptr;
|
|
1387
|
-
}
|
|
1388
|
-
|
|
1389
1001
|
function passStringToWasm0(arg, malloc, realloc) {
|
|
1390
1002
|
if (realloc === undefined) {
|
|
1391
1003
|
const buf = cachedTextEncoder.encode(arg);
|
package/diaryx_wasm_bg.wasm
CHANGED
|
Binary file
|
package/diaryx_wasm_bg.wasm.d.ts
CHANGED
|
@@ -1,43 +1,17 @@
|
|
|
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 jsasyncfilesystem_has_callback: (a: number, b: number, c: number) => number;
|
|
6
|
-
export const jsasyncfilesystem_new: (a: any) => number;
|
|
7
|
-
export const init: () => void;
|
|
8
|
-
export const __wbg_wasmsyncclient_free: (a: number, b: number) => void;
|
|
9
|
-
export const now_timestamp: () => [number, number];
|
|
10
|
-
export const today_formatted: (a: number, b: number) => [number, number];
|
|
11
|
-
export const wasmsyncclient_focusFiles: (a: number, b: number, c: number) => void;
|
|
12
|
-
export const wasmsyncclient_getServerUrl: (a: number) => [number, number];
|
|
13
|
-
export const wasmsyncclient_getWorkspaceId: (a: number) => [number, number];
|
|
14
|
-
export const wasmsyncclient_getWsUrl: (a: number) => [number, number];
|
|
15
|
-
export const wasmsyncclient_hasEvents: (a: number) => number;
|
|
16
|
-
export const wasmsyncclient_hasOutgoing: (a: number) => number;
|
|
17
|
-
export const wasmsyncclient_onBinaryMessage: (a: number, b: number, c: number) => any;
|
|
18
|
-
export const wasmsyncclient_onConnected: (a: number) => any;
|
|
19
|
-
export const wasmsyncclient_onDisconnected: (a: number) => any;
|
|
20
|
-
export const wasmsyncclient_onSnapshotImported: (a: number) => any;
|
|
21
|
-
export const wasmsyncclient_onTextMessage: (a: number, b: number, c: number) => any;
|
|
22
|
-
export const wasmsyncclient_pollEvent: (a: number) => [number, number];
|
|
23
|
-
export const wasmsyncclient_pollOutgoingBinary: (a: number) => any;
|
|
24
|
-
export const wasmsyncclient_pollOutgoingText: (a: number) => [number, number];
|
|
25
|
-
export const wasmsyncclient_queueLocalUpdate: (a: number, b: number, c: number, d: number, e: number) => any;
|
|
26
|
-
export const wasmsyncclient_setSessionCode: (a: number, b: number, c: number) => void;
|
|
27
|
-
export const wasmsyncclient_syncBodyFiles: (a: number, b: number, c: number) => any;
|
|
28
|
-
export const wasmsyncclient_unfocusFiles: (a: number, b: number, c: number) => void;
|
|
29
4
|
export const __wbg_diaryxbackend_free: (a: number, b: number) => void;
|
|
5
|
+
export const __wbg_jsasyncfilesystem_free: (a: number, b: number) => void;
|
|
30
6
|
export const diaryxbackend_create: (a: number, b: number) => any;
|
|
31
7
|
export const diaryxbackend_createFromJsFileSystem: (a: any) => [number, number, number];
|
|
32
8
|
export const diaryxbackend_createInMemory: () => [number, number, number];
|
|
33
|
-
export const diaryxbackend_createSyncClient: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => number;
|
|
34
9
|
export const diaryxbackend_emitFileSystemEvent: (a: number, b: number, c: number) => [number, number];
|
|
35
10
|
export const diaryxbackend_eventSubscriberCount: (a: number) => number;
|
|
36
11
|
export const diaryxbackend_execute: (a: number, b: number, c: number) => any;
|
|
37
12
|
export const diaryxbackend_executeJs: (a: number, b: any) => any;
|
|
38
13
|
export const diaryxbackend_getConfig: (a: number) => any;
|
|
39
14
|
export const diaryxbackend_hasNativeSync: (a: number) => number;
|
|
40
|
-
export const diaryxbackend_isCrdtEnabled: (a: number) => number;
|
|
41
15
|
export const diaryxbackend_offFileSystemEvent: (a: number, b: bigint) => number;
|
|
42
16
|
export const diaryxbackend_onFileSystemEvent: (a: number, b: any) => bigint;
|
|
43
17
|
export const diaryxbackend_parseDayOneJson: (a: number, b: number, c: number) => [number, number, number, number];
|
|
@@ -46,9 +20,15 @@ export const diaryxbackend_readBinary: (a: number, b: number, c: number) => any;
|
|
|
46
20
|
export const diaryxbackend_saveConfig: (a: number, b: any) => any;
|
|
47
21
|
export const diaryxbackend_setCrdtEnabled: (a: number, b: number) => void;
|
|
48
22
|
export const diaryxbackend_writeBinary: (a: number, b: number, c: number, d: any) => any;
|
|
49
|
-
export const
|
|
50
|
-
export const
|
|
51
|
-
export const
|
|
23
|
+
export const jsasyncfilesystem_has_callback: (a: number, b: number, c: number) => number;
|
|
24
|
+
export const jsasyncfilesystem_new: (a: any) => number;
|
|
25
|
+
export const now_timestamp: () => [number, number];
|
|
26
|
+
export const today_formatted: (a: number, b: number) => [number, number];
|
|
27
|
+
export const diaryxbackend_isCrdtEnabled: (a: number) => number;
|
|
28
|
+
export const init: () => void;
|
|
29
|
+
export const wasm_bindgen__closure__destroy__hdba164d367f73b05: (a: number, b: number) => void;
|
|
30
|
+
export const wasm_bindgen__convert__closures_____invoke__h0d59e9d6e6af2fb0: (a: number, b: number, c: any, d: any) => void;
|
|
31
|
+
export const wasm_bindgen__convert__closures_____invoke__hf7b661626d016918: (a: number, b: number, c: any) => void;
|
|
52
32
|
export const __wbindgen_malloc: (a: number, b: number) => number;
|
|
53
33
|
export const __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
|
|
54
34
|
export const __wbindgen_exn_store: (a: number) => void;
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@diaryx/wasm-node",
|
|
3
3
|
"type": "module",
|
|
4
4
|
"description": "WebAssembly bindings for Diaryx core functionality",
|
|
5
|
-
"version": "1.2.1-dev.
|
|
5
|
+
"version": "1.2.1-dev.ddf29e2",
|
|
6
6
|
"license": "SEE LICENSE IN ../../LICENSE.md",
|
|
7
7
|
"repository": {
|
|
8
8
|
"type": "git",
|