@diaryx/wasm-node 1.2.0 → 1.2.1-dev.34fd175
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +15 -21
- package/diaryx_wasm.d.ts +11 -250
- package/diaryx_wasm.js +18 -487
- package/diaryx_wasm_bg.wasm +0 -0
- package/diaryx_wasm_bg.wasm.d.ts +7 -29
- 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
|
/**
|
|
@@ -292,35 +220,6 @@ export class DiaryxBackend {
|
|
|
292
220
|
* ```
|
|
293
221
|
*/
|
|
294
222
|
onFileSystemEvent(callback: Function): bigint;
|
|
295
|
-
/**
|
|
296
|
-
* Parse a Day One export (ZIP or JSON) and return entries as JSON.
|
|
297
|
-
*
|
|
298
|
-
* Auto-detects the format: ZIP files (with media directories) have
|
|
299
|
-
* attachments populated with binary data. Plain JSON files are parsed
|
|
300
|
-
* with empty attachment data (backward compatible).
|
|
301
|
-
*
|
|
302
|
-
* ## Example
|
|
303
|
-
* ```javascript
|
|
304
|
-
* const bytes = new Uint8Array(await file.arrayBuffer());
|
|
305
|
-
* const result = backend.parseDayOneJson(bytes);
|
|
306
|
-
* const { entries, errors } = JSON.parse(result);
|
|
307
|
-
* ```
|
|
308
|
-
*/
|
|
309
|
-
parseDayOneJson(bytes: Uint8Array): string;
|
|
310
|
-
/**
|
|
311
|
-
* Parse a single markdown file and return the entry as JSON.
|
|
312
|
-
*
|
|
313
|
-
* Takes the raw bytes of a `.md` file and its filename, and returns
|
|
314
|
-
* a JSON-serialized `ImportedEntry`.
|
|
315
|
-
*
|
|
316
|
-
* ## Example
|
|
317
|
-
* ```javascript
|
|
318
|
-
* const bytes = new Uint8Array(await file.arrayBuffer());
|
|
319
|
-
* const entryJson = backend.parseMarkdownFile(bytes, file.name);
|
|
320
|
-
* const entry = JSON.parse(entryJson);
|
|
321
|
-
* ```
|
|
322
|
-
*/
|
|
323
|
-
parseMarkdownFile(bytes: Uint8Array, filename: string): string;
|
|
324
223
|
/**
|
|
325
224
|
* Read binary file.
|
|
326
225
|
*
|
|
@@ -333,13 +232,9 @@ export class DiaryxBackend {
|
|
|
333
232
|
*/
|
|
334
233
|
saveConfig(config_js: any): Promise<any>;
|
|
335
234
|
/**
|
|
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).
|
|
235
|
+
* No-op — CrdtFs is not used; sync handled by Extism plugin.
|
|
341
236
|
*/
|
|
342
|
-
setCrdtEnabled(
|
|
237
|
+
setCrdtEnabled(_enabled: boolean): void;
|
|
343
238
|
/**
|
|
344
239
|
* Write binary file.
|
|
345
240
|
*
|
|
@@ -382,118 +277,6 @@ export class JsAsyncFileSystem {
|
|
|
382
277
|
constructor(callbacks: any);
|
|
383
278
|
}
|
|
384
279
|
|
|
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
280
|
/**
|
|
498
281
|
* Initialize the WASM module. Called automatically on module load.
|
|
499
282
|
*/
|
|
@@ -513,54 +296,32 @@ export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembl
|
|
|
513
296
|
|
|
514
297
|
export interface InitOutput {
|
|
515
298
|
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
299
|
readonly __wbg_diaryxbackend_free: (a: number, b: number) => void;
|
|
300
|
+
readonly __wbg_jsasyncfilesystem_free: (a: number, b: number) => void;
|
|
520
301
|
readonly diaryxbackend_create: (a: number, b: number) => any;
|
|
521
302
|
readonly diaryxbackend_createFromJsFileSystem: (a: any) => [number, number, number];
|
|
522
303
|
readonly diaryxbackend_createInMemory: () => [number, number, number];
|
|
523
|
-
readonly diaryxbackend_createSyncClient: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => number;
|
|
524
304
|
readonly diaryxbackend_emitFileSystemEvent: (a: number, b: number, c: number) => [number, number];
|
|
525
305
|
readonly diaryxbackend_eventSubscriberCount: (a: number) => number;
|
|
526
306
|
readonly diaryxbackend_execute: (a: number, b: number, c: number) => any;
|
|
527
307
|
readonly diaryxbackend_executeJs: (a: number, b: any) => any;
|
|
528
308
|
readonly diaryxbackend_getConfig: (a: number) => any;
|
|
529
309
|
readonly diaryxbackend_hasNativeSync: (a: number) => number;
|
|
530
|
-
readonly diaryxbackend_isCrdtEnabled: (a: number) => number;
|
|
531
310
|
readonly diaryxbackend_offFileSystemEvent: (a: number, b: bigint) => number;
|
|
532
311
|
readonly diaryxbackend_onFileSystemEvent: (a: number, b: any) => bigint;
|
|
533
|
-
readonly diaryxbackend_parseDayOneJson: (a: number, b: number, c: number) => [number, number, number, number];
|
|
534
|
-
readonly diaryxbackend_parseMarkdownFile: (a: number, b: number, c: number, d: number, e: number) => [number, number, number, number];
|
|
535
312
|
readonly diaryxbackend_readBinary: (a: number, b: number, c: number) => any;
|
|
536
313
|
readonly diaryxbackend_saveConfig: (a: number, b: any) => any;
|
|
537
314
|
readonly diaryxbackend_setCrdtEnabled: (a: number, b: number) => void;
|
|
538
315
|
readonly diaryxbackend_writeBinary: (a: number, b: number, c: number, d: any) => any;
|
|
539
|
-
readonly
|
|
316
|
+
readonly jsasyncfilesystem_has_callback: (a: number, b: number, c: number) => number;
|
|
317
|
+
readonly jsasyncfilesystem_new: (a: any) => number;
|
|
540
318
|
readonly now_timestamp: () => [number, number];
|
|
541
319
|
readonly today_formatted: (a: number, b: number) => [number, number];
|
|
542
|
-
readonly
|
|
543
|
-
readonly wasmsyncclient_getServerUrl: (a: number) => [number, number];
|
|
544
|
-
readonly wasmsyncclient_getWorkspaceId: (a: number) => [number, number];
|
|
545
|
-
readonly wasmsyncclient_getWsUrl: (a: number) => [number, number];
|
|
546
|
-
readonly wasmsyncclient_hasEvents: (a: number) => number;
|
|
547
|
-
readonly wasmsyncclient_hasOutgoing: (a: number) => number;
|
|
548
|
-
readonly wasmsyncclient_onBinaryMessage: (a: number, b: number, c: number) => any;
|
|
549
|
-
readonly wasmsyncclient_onConnected: (a: number) => any;
|
|
550
|
-
readonly wasmsyncclient_onDisconnected: (a: number) => any;
|
|
551
|
-
readonly wasmsyncclient_onSnapshotImported: (a: number) => any;
|
|
552
|
-
readonly wasmsyncclient_onTextMessage: (a: number, b: number, c: number) => any;
|
|
553
|
-
readonly wasmsyncclient_pollEvent: (a: number) => [number, number];
|
|
554
|
-
readonly wasmsyncclient_pollOutgoingBinary: (a: number) => any;
|
|
555
|
-
readonly wasmsyncclient_pollOutgoingText: (a: number) => [number, number];
|
|
556
|
-
readonly wasmsyncclient_queueLocalUpdate: (a: number, b: number, c: number, d: number, e: number) => any;
|
|
557
|
-
readonly wasmsyncclient_setSessionCode: (a: number, b: number, c: number) => void;
|
|
558
|
-
readonly wasmsyncclient_syncBodyFiles: (a: number, b: number, c: number) => any;
|
|
559
|
-
readonly wasmsyncclient_unfocusFiles: (a: number, b: number, c: number) => void;
|
|
320
|
+
readonly diaryxbackend_isCrdtEnabled: (a: number) => number;
|
|
560
321
|
readonly init: () => void;
|
|
561
|
-
readonly
|
|
562
|
-
readonly
|
|
563
|
-
readonly
|
|
322
|
+
readonly wasm_bindgen__closure__destroy__hd85d1c53d3986156: (a: number, b: number) => void;
|
|
323
|
+
readonly wasm_bindgen__convert__closures_____invoke__h84dc1ad6ea1f6222: (a: number, b: number, c: any, d: any) => void;
|
|
324
|
+
readonly wasm_bindgen__convert__closures_____invoke__h488249baddabe63e: (a: number, b: number, c: any) => void;
|
|
564
325
|
readonly __wbindgen_malloc: (a: number, b: number) => number;
|
|
565
326
|
readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
|
|
566
327
|
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
|
/**
|
|
@@ -294,80 +209,6 @@ export class DiaryxBackend {
|
|
|
294
209
|
const ret = wasm.diaryxbackend_onFileSystemEvent(this.__wbg_ptr, callback);
|
|
295
210
|
return BigInt.asUintN(64, ret);
|
|
296
211
|
}
|
|
297
|
-
/**
|
|
298
|
-
* Parse a Day One export (ZIP or JSON) and return entries as JSON.
|
|
299
|
-
*
|
|
300
|
-
* Auto-detects the format: ZIP files (with media directories) have
|
|
301
|
-
* attachments populated with binary data. Plain JSON files are parsed
|
|
302
|
-
* with empty attachment data (backward compatible).
|
|
303
|
-
*
|
|
304
|
-
* ## Example
|
|
305
|
-
* ```javascript
|
|
306
|
-
* const bytes = new Uint8Array(await file.arrayBuffer());
|
|
307
|
-
* const result = backend.parseDayOneJson(bytes);
|
|
308
|
-
* const { entries, errors } = JSON.parse(result);
|
|
309
|
-
* ```
|
|
310
|
-
* @param {Uint8Array} bytes
|
|
311
|
-
* @returns {string}
|
|
312
|
-
*/
|
|
313
|
-
parseDayOneJson(bytes) {
|
|
314
|
-
let deferred3_0;
|
|
315
|
-
let deferred3_1;
|
|
316
|
-
try {
|
|
317
|
-
const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_malloc);
|
|
318
|
-
const len0 = WASM_VECTOR_LEN;
|
|
319
|
-
const ret = wasm.diaryxbackend_parseDayOneJson(this.__wbg_ptr, ptr0, len0);
|
|
320
|
-
var ptr2 = ret[0];
|
|
321
|
-
var len2 = ret[1];
|
|
322
|
-
if (ret[3]) {
|
|
323
|
-
ptr2 = 0; len2 = 0;
|
|
324
|
-
throw takeFromExternrefTable0(ret[2]);
|
|
325
|
-
}
|
|
326
|
-
deferred3_0 = ptr2;
|
|
327
|
-
deferred3_1 = len2;
|
|
328
|
-
return getStringFromWasm0(ptr2, len2);
|
|
329
|
-
} finally {
|
|
330
|
-
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
331
|
-
}
|
|
332
|
-
}
|
|
333
|
-
/**
|
|
334
|
-
* Parse a single markdown file and return the entry as JSON.
|
|
335
|
-
*
|
|
336
|
-
* Takes the raw bytes of a `.md` file and its filename, and returns
|
|
337
|
-
* a JSON-serialized `ImportedEntry`.
|
|
338
|
-
*
|
|
339
|
-
* ## Example
|
|
340
|
-
* ```javascript
|
|
341
|
-
* const bytes = new Uint8Array(await file.arrayBuffer());
|
|
342
|
-
* const entryJson = backend.parseMarkdownFile(bytes, file.name);
|
|
343
|
-
* const entry = JSON.parse(entryJson);
|
|
344
|
-
* ```
|
|
345
|
-
* @param {Uint8Array} bytes
|
|
346
|
-
* @param {string} filename
|
|
347
|
-
* @returns {string}
|
|
348
|
-
*/
|
|
349
|
-
parseMarkdownFile(bytes, filename) {
|
|
350
|
-
let deferred4_0;
|
|
351
|
-
let deferred4_1;
|
|
352
|
-
try {
|
|
353
|
-
const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_malloc);
|
|
354
|
-
const len0 = WASM_VECTOR_LEN;
|
|
355
|
-
const ptr1 = passStringToWasm0(filename, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
356
|
-
const len1 = WASM_VECTOR_LEN;
|
|
357
|
-
const ret = wasm.diaryxbackend_parseMarkdownFile(this.__wbg_ptr, ptr0, len0, ptr1, len1);
|
|
358
|
-
var ptr3 = ret[0];
|
|
359
|
-
var len3 = ret[1];
|
|
360
|
-
if (ret[3]) {
|
|
361
|
-
ptr3 = 0; len3 = 0;
|
|
362
|
-
throw takeFromExternrefTable0(ret[2]);
|
|
363
|
-
}
|
|
364
|
-
deferred4_0 = ptr3;
|
|
365
|
-
deferred4_1 = len3;
|
|
366
|
-
return getStringFromWasm0(ptr3, len3);
|
|
367
|
-
} finally {
|
|
368
|
-
wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
|
|
369
|
-
}
|
|
370
|
-
}
|
|
371
212
|
/**
|
|
372
213
|
* Read binary file.
|
|
373
214
|
*
|
|
@@ -392,15 +233,11 @@ export class DiaryxBackend {
|
|
|
392
233
|
return ret;
|
|
393
234
|
}
|
|
394
235
|
/**
|
|
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
|
|
236
|
+
* No-op — CrdtFs is not used; sync handled by Extism plugin.
|
|
237
|
+
* @param {boolean} _enabled
|
|
401
238
|
*/
|
|
402
|
-
setCrdtEnabled(
|
|
403
|
-
wasm.diaryxbackend_setCrdtEnabled(this.__wbg_ptr,
|
|
239
|
+
setCrdtEnabled(_enabled) {
|
|
240
|
+
wasm.diaryxbackend_setCrdtEnabled(this.__wbg_ptr, _enabled);
|
|
404
241
|
}
|
|
405
242
|
/**
|
|
406
243
|
* Write binary file.
|
|
@@ -475,257 +312,6 @@ export class JsAsyncFileSystem {
|
|
|
475
312
|
}
|
|
476
313
|
if (Symbol.dispose) JsAsyncFileSystem.prototype[Symbol.dispose] = JsAsyncFileSystem.prototype.free;
|
|
477
314
|
|
|
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
315
|
/**
|
|
730
316
|
* Initialize the WASM module. Called automatically on module load.
|
|
731
317
|
*/
|
|
@@ -879,10 +465,6 @@ function __wbg_get_imports() {
|
|
|
879
465
|
const ret = arg0.call(arg1, arg2, arg3, arg4);
|
|
880
466
|
return ret;
|
|
881
467
|
}, arguments); },
|
|
882
|
-
__wbg_crypto_86f2631e91b51511: function(arg0) {
|
|
883
|
-
const ret = arg0.crypto;
|
|
884
|
-
return ret;
|
|
885
|
-
},
|
|
886
468
|
__wbg_debug_46a93995fc6f8820: function(arg0, arg1, arg2, arg3) {
|
|
887
469
|
console.debug(arg0, arg1, arg2, arg3);
|
|
888
470
|
},
|
|
@@ -901,8 +483,9 @@ function __wbg_get_imports() {
|
|
|
901
483
|
__wbg_error_794d0ffc9d00d5c3: function(arg0, arg1, arg2, arg3) {
|
|
902
484
|
console.error(arg0, arg1, arg2, arg3);
|
|
903
485
|
},
|
|
904
|
-
|
|
905
|
-
|
|
486
|
+
__wbg_fromCodePoint_22365db7b7d6ac39: function() { return handleError(function (arg0) {
|
|
487
|
+
const ret = String.fromCodePoint(arg0 >>> 0);
|
|
488
|
+
return ret;
|
|
906
489
|
}, arguments); },
|
|
907
490
|
__wbg_getTime_1e3cd1391c5c3995: function(arg0) {
|
|
908
491
|
const ret = arg0.getTime();
|
|
@@ -1000,10 +583,6 @@ function __wbg_get_imports() {
|
|
|
1000
583
|
__wbg_log_24aba2a6d8990b35: function(arg0, arg1, arg2, arg3) {
|
|
1001
584
|
console.log(arg0, arg1, arg2, arg3);
|
|
1002
585
|
},
|
|
1003
|
-
__wbg_msCrypto_d562bbe83e0d4b91: function(arg0) {
|
|
1004
|
-
const ret = arg0.msCrypto;
|
|
1005
|
-
return ret;
|
|
1006
|
-
},
|
|
1007
586
|
__wbg_new_0_73afc35eb544e539: function() {
|
|
1008
587
|
const ret = new Date();
|
|
1009
588
|
return ret;
|
|
@@ -1027,7 +606,7 @@ function __wbg_get_imports() {
|
|
|
1027
606
|
const a = state0.a;
|
|
1028
607
|
state0.a = 0;
|
|
1029
608
|
try {
|
|
1030
|
-
return
|
|
609
|
+
return wasm_bindgen__convert__closures_____invoke__h84dc1ad6ea1f6222(a, state0.b, arg0, arg1);
|
|
1031
610
|
} finally {
|
|
1032
611
|
state0.a = a;
|
|
1033
612
|
}
|
|
@@ -1066,18 +645,10 @@ function __wbg_get_imports() {
|
|
|
1066
645
|
const ret = arg0.next;
|
|
1067
646
|
return ret;
|
|
1068
647
|
},
|
|
1069
|
-
__wbg_node_e1f24f89a7336c2e: function(arg0) {
|
|
1070
|
-
const ret = arg0.node;
|
|
1071
|
-
return ret;
|
|
1072
|
-
},
|
|
1073
648
|
__wbg_parse_708461a1feddfb38: function() { return handleError(function (arg0, arg1) {
|
|
1074
649
|
const ret = JSON.parse(getStringFromWasm0(arg0, arg1));
|
|
1075
650
|
return ret;
|
|
1076
651
|
}, arguments); },
|
|
1077
|
-
__wbg_process_3975fd6c72f520aa: function(arg0) {
|
|
1078
|
-
const ret = arg0.process;
|
|
1079
|
-
return ret;
|
|
1080
|
-
},
|
|
1081
652
|
__wbg_prototypesetcall_bdcdcc5842e4d77d: function(arg0, arg1, arg2) {
|
|
1082
653
|
Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), arg2);
|
|
1083
654
|
},
|
|
@@ -1092,13 +663,6 @@ function __wbg_get_imports() {
|
|
|
1092
663
|
__wbg_queueMicrotask_5bb536982f78a56f: function(arg0) {
|
|
1093
664
|
queueMicrotask(arg0);
|
|
1094
665
|
},
|
|
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
666
|
__wbg_resolve_002c4b7d9d8f6b64: function(arg0) {
|
|
1103
667
|
const ret = Promise.resolve(arg0);
|
|
1104
668
|
return ret;
|
|
@@ -1136,10 +700,6 @@ function __wbg_get_imports() {
|
|
|
1136
700
|
const ret = JSON.stringify(arg0);
|
|
1137
701
|
return ret;
|
|
1138
702
|
}, arguments); },
|
|
1139
|
-
__wbg_subarray_a96e1fef17ed23cb: function(arg0, arg1, arg2) {
|
|
1140
|
-
const ret = arg0.subarray(arg1 >>> 0, arg2 >>> 0);
|
|
1141
|
-
return ret;
|
|
1142
|
-
},
|
|
1143
703
|
__wbg_then_0d9fe2c7b1857d32: function(arg0, arg1, arg2) {
|
|
1144
704
|
const ret = arg0.then(arg1, arg2);
|
|
1145
705
|
return ret;
|
|
@@ -1156,16 +716,12 @@ function __wbg_get_imports() {
|
|
|
1156
716
|
const ret = arg0.value;
|
|
1157
717
|
return ret;
|
|
1158
718
|
},
|
|
1159
|
-
__wbg_versions_4e31226f5e8dc909: function(arg0) {
|
|
1160
|
-
const ret = arg0.versions;
|
|
1161
|
-
return ret;
|
|
1162
|
-
},
|
|
1163
719
|
__wbg_warn_a40b971467b219c7: function(arg0, arg1, arg2, arg3) {
|
|
1164
720
|
console.warn(arg0, arg1, arg2, arg3);
|
|
1165
721
|
},
|
|
1166
722
|
__wbindgen_cast_0000000000000001: function(arg0, arg1) {
|
|
1167
|
-
// Cast intrinsic for `Closure(Closure { dtor_idx:
|
|
1168
|
-
const ret = makeMutClosure(arg0, arg1, wasm.
|
|
723
|
+
// Cast intrinsic for `Closure(Closure { dtor_idx: 395, function: Function { arguments: [Externref], shim_idx: 396, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
|
|
724
|
+
const ret = makeMutClosure(arg0, arg1, wasm.wasm_bindgen__closure__destroy__hd85d1c53d3986156, wasm_bindgen__convert__closures_____invoke__h488249baddabe63e);
|
|
1169
725
|
return ret;
|
|
1170
726
|
},
|
|
1171
727
|
__wbindgen_cast_0000000000000002: function(arg0) {
|
|
@@ -1179,16 +735,11 @@ function __wbg_get_imports() {
|
|
|
1179
735
|
return ret;
|
|
1180
736
|
},
|
|
1181
737
|
__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
738
|
// Cast intrinsic for `Ref(String) -> Externref`.
|
|
1188
739
|
const ret = getStringFromWasm0(arg0, arg1);
|
|
1189
740
|
return ret;
|
|
1190
741
|
},
|
|
1191
|
-
|
|
742
|
+
__wbindgen_cast_0000000000000005: function(arg0) {
|
|
1192
743
|
// Cast intrinsic for `U64 -> Externref`.
|
|
1193
744
|
const ret = BigInt.asUintN(64, arg0);
|
|
1194
745
|
return ret;
|
|
@@ -1209,12 +760,12 @@ function __wbg_get_imports() {
|
|
|
1209
760
|
};
|
|
1210
761
|
}
|
|
1211
762
|
|
|
1212
|
-
function
|
|
1213
|
-
wasm.
|
|
763
|
+
function wasm_bindgen__convert__closures_____invoke__h488249baddabe63e(arg0, arg1, arg2) {
|
|
764
|
+
wasm.wasm_bindgen__convert__closures_____invoke__h488249baddabe63e(arg0, arg1, arg2);
|
|
1214
765
|
}
|
|
1215
766
|
|
|
1216
|
-
function
|
|
1217
|
-
wasm.
|
|
767
|
+
function wasm_bindgen__convert__closures_____invoke__h84dc1ad6ea1f6222(arg0, arg1, arg2, arg3) {
|
|
768
|
+
wasm.wasm_bindgen__convert__closures_____invoke__h84dc1ad6ea1f6222(arg0, arg1, arg2, arg3);
|
|
1218
769
|
}
|
|
1219
770
|
|
|
1220
771
|
const DiaryxBackendFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
@@ -1223,9 +774,6 @@ const DiaryxBackendFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
|
1223
774
|
const JsAsyncFileSystemFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
1224
775
|
? { register: () => {}, unregister: () => {} }
|
|
1225
776
|
: 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
777
|
|
|
1230
778
|
function addToExternrefTable0(obj) {
|
|
1231
779
|
const idx = wasm.__externref_table_alloc();
|
|
@@ -1369,23 +917,6 @@ function makeMutClosure(arg0, arg1, dtor, f) {
|
|
|
1369
917
|
return real;
|
|
1370
918
|
}
|
|
1371
919
|
|
|
1372
|
-
function passArray8ToWasm0(arg, malloc) {
|
|
1373
|
-
const ptr = malloc(arg.length * 1, 1) >>> 0;
|
|
1374
|
-
getUint8ArrayMemory0().set(arg, ptr / 1);
|
|
1375
|
-
WASM_VECTOR_LEN = arg.length;
|
|
1376
|
-
return ptr;
|
|
1377
|
-
}
|
|
1378
|
-
|
|
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
920
|
function passStringToWasm0(arg, malloc, realloc) {
|
|
1390
921
|
if (realloc === undefined) {
|
|
1391
922
|
const buf = cachedTextEncoder.encode(arg);
|
package/diaryx_wasm_bg.wasm
CHANGED
|
Binary file
|
package/diaryx_wasm_bg.wasm.d.ts
CHANGED
|
@@ -1,54 +1,32 @@
|
|
|
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
4
|
export const __wbg_diaryxbackend_free: (a: number, b: number) => void;
|
|
5
|
+
export const __wbg_jsasyncfilesystem_free: (a: number, b: number) => void;
|
|
8
6
|
export const diaryxbackend_create: (a: number, b: number) => any;
|
|
9
7
|
export const diaryxbackend_createFromJsFileSystem: (a: any) => [number, number, number];
|
|
10
8
|
export const diaryxbackend_createInMemory: () => [number, number, number];
|
|
11
|
-
export const diaryxbackend_createSyncClient: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => number;
|
|
12
9
|
export const diaryxbackend_emitFileSystemEvent: (a: number, b: number, c: number) => [number, number];
|
|
13
10
|
export const diaryxbackend_eventSubscriberCount: (a: number) => number;
|
|
14
11
|
export const diaryxbackend_execute: (a: number, b: number, c: number) => any;
|
|
15
12
|
export const diaryxbackend_executeJs: (a: number, b: any) => any;
|
|
16
13
|
export const diaryxbackend_getConfig: (a: number) => any;
|
|
17
14
|
export const diaryxbackend_hasNativeSync: (a: number) => number;
|
|
18
|
-
export const diaryxbackend_isCrdtEnabled: (a: number) => number;
|
|
19
15
|
export const diaryxbackend_offFileSystemEvent: (a: number, b: bigint) => number;
|
|
20
16
|
export const diaryxbackend_onFileSystemEvent: (a: number, b: any) => bigint;
|
|
21
|
-
export const diaryxbackend_parseDayOneJson: (a: number, b: number, c: number) => [number, number, number, number];
|
|
22
|
-
export const diaryxbackend_parseMarkdownFile: (a: number, b: number, c: number, d: number, e: number) => [number, number, number, number];
|
|
23
17
|
export const diaryxbackend_readBinary: (a: number, b: number, c: number) => any;
|
|
24
18
|
export const diaryxbackend_saveConfig: (a: number, b: any) => any;
|
|
25
19
|
export const diaryxbackend_setCrdtEnabled: (a: number, b: number) => void;
|
|
26
20
|
export const diaryxbackend_writeBinary: (a: number, b: number, c: number, d: any) => any;
|
|
27
|
-
export const
|
|
21
|
+
export const jsasyncfilesystem_has_callback: (a: number, b: number, c: number) => number;
|
|
22
|
+
export const jsasyncfilesystem_new: (a: any) => number;
|
|
28
23
|
export const now_timestamp: () => [number, number];
|
|
29
24
|
export const today_formatted: (a: number, b: number) => [number, number];
|
|
30
|
-
export const
|
|
31
|
-
export const wasmsyncclient_getServerUrl: (a: number) => [number, number];
|
|
32
|
-
export const wasmsyncclient_getWorkspaceId: (a: number) => [number, number];
|
|
33
|
-
export const wasmsyncclient_getWsUrl: (a: number) => [number, number];
|
|
34
|
-
export const wasmsyncclient_hasEvents: (a: number) => number;
|
|
35
|
-
export const wasmsyncclient_hasOutgoing: (a: number) => number;
|
|
36
|
-
export const wasmsyncclient_onBinaryMessage: (a: number, b: number, c: number) => any;
|
|
37
|
-
export const wasmsyncclient_onConnected: (a: number) => any;
|
|
38
|
-
export const wasmsyncclient_onDisconnected: (a: number) => any;
|
|
39
|
-
export const wasmsyncclient_onSnapshotImported: (a: number) => any;
|
|
40
|
-
export const wasmsyncclient_onTextMessage: (a: number, b: number, c: number) => any;
|
|
41
|
-
export const wasmsyncclient_pollEvent: (a: number) => [number, number];
|
|
42
|
-
export const wasmsyncclient_pollOutgoingBinary: (a: number) => any;
|
|
43
|
-
export const wasmsyncclient_pollOutgoingText: (a: number) => [number, number];
|
|
44
|
-
export const wasmsyncclient_queueLocalUpdate: (a: number, b: number, c: number, d: number, e: number) => any;
|
|
45
|
-
export const wasmsyncclient_setSessionCode: (a: number, b: number, c: number) => void;
|
|
46
|
-
export const wasmsyncclient_syncBodyFiles: (a: number, b: number, c: number) => any;
|
|
47
|
-
export const wasmsyncclient_unfocusFiles: (a: number, b: number, c: number) => void;
|
|
25
|
+
export const diaryxbackend_isCrdtEnabled: (a: number) => number;
|
|
48
26
|
export const init: () => void;
|
|
49
|
-
export const
|
|
50
|
-
export const
|
|
51
|
-
export const
|
|
27
|
+
export const wasm_bindgen__closure__destroy__hd85d1c53d3986156: (a: number, b: number) => void;
|
|
28
|
+
export const wasm_bindgen__convert__closures_____invoke__h84dc1ad6ea1f6222: (a: number, b: number, c: any, d: any) => void;
|
|
29
|
+
export const wasm_bindgen__convert__closures_____invoke__h488249baddabe63e: (a: number, b: number, c: any) => void;
|
|
52
30
|
export const __wbindgen_malloc: (a: number, b: number) => number;
|
|
53
31
|
export const __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
|
|
54
32
|
export const __wbindgen_exn_store: (a: number) => void;
|
package/package.json
CHANGED