@diaryx/wasm-node 1.0.1 → 1.1.0-dev.4fa69f2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/diaryx_wasm.d.ts CHANGED
@@ -274,6 +274,35 @@ export class DiaryxBackend {
274
274
  * ```
275
275
  */
276
276
  onFileSystemEvent(callback: Function): bigint;
277
+ /**
278
+ * Parse a Day One `Journal.json` file and return entries as JSON.
279
+ *
280
+ * Takes the raw bytes of a `Journal.json` file and returns a JSON array
281
+ * of successfully parsed entries. Parse errors are returned in a separate
282
+ * `errors` array.
283
+ *
284
+ * ## Example
285
+ * ```javascript
286
+ * const bytes = new Uint8Array(await file.arrayBuffer());
287
+ * const result = backend.parseDayOneJson(bytes);
288
+ * const { entries, errors } = JSON.parse(result);
289
+ * ```
290
+ */
291
+ parseDayOneJson(bytes: Uint8Array): string;
292
+ /**
293
+ * Parse a single markdown file and return the entry as JSON.
294
+ *
295
+ * Takes the raw bytes of a `.md` file and its filename, and returns
296
+ * a JSON-serialized `ImportedEntry`.
297
+ *
298
+ * ## Example
299
+ * ```javascript
300
+ * const bytes = new Uint8Array(await file.arrayBuffer());
301
+ * const entryJson = backend.parseMarkdownFile(bytes, file.name);
302
+ * const entry = JSON.parse(entryJson);
303
+ * ```
304
+ */
305
+ parseMarkdownFile(bytes: Uint8Array, filename: string): string;
277
306
  /**
278
307
  * Read binary file.
279
308
  *
@@ -434,6 +463,13 @@ export class WasmSyncClient {
434
463
  * Call this before connecting to join a share session.
435
464
  */
436
465
  setSessionCode(code: string): void;
466
+ /**
467
+ * Request body sync for specific files (lazy sync on demand).
468
+ *
469
+ * Sends SyncBodyFiles event through the session to initiate body
470
+ * SyncStep1 for just the requested files, rather than all files.
471
+ */
472
+ syncBodyFiles(file_paths: string[]): Promise<any>;
437
473
  /**
438
474
  * Send an unfocus message for specific files.
439
475
  */
@@ -459,14 +495,30 @@ export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembl
459
495
 
460
496
  export interface InitOutput {
461
497
  readonly memory: WebAssembly.Memory;
462
- readonly now_timestamp: () => [number, number];
463
- readonly today_formatted: (a: number, b: number) => [number, number];
464
498
  readonly __wbg_jsasyncfilesystem_free: (a: number, b: number) => void;
499
+ readonly __wbg_wasmsyncclient_free: (a: number, b: number) => void;
465
500
  readonly jsasyncfilesystem_has_callback: (a: number, b: number, c: number) => number;
466
501
  readonly jsasyncfilesystem_new: (a: any) => number;
502
+ readonly wasmsyncclient_focusFiles: (a: number, b: number, c: number) => void;
503
+ readonly wasmsyncclient_getServerUrl: (a: number) => [number, number];
504
+ readonly wasmsyncclient_getWorkspaceId: (a: number) => [number, number];
505
+ readonly wasmsyncclient_getWsUrl: (a: number) => [number, number];
506
+ readonly wasmsyncclient_hasEvents: (a: number) => number;
507
+ readonly wasmsyncclient_hasOutgoing: (a: number) => number;
508
+ readonly wasmsyncclient_onBinaryMessage: (a: number, b: number, c: number) => any;
509
+ readonly wasmsyncclient_onConnected: (a: number) => any;
510
+ readonly wasmsyncclient_onDisconnected: (a: number) => any;
511
+ readonly wasmsyncclient_onSnapshotImported: (a: number) => any;
512
+ readonly wasmsyncclient_onTextMessage: (a: number, b: number, c: number) => any;
513
+ readonly wasmsyncclient_pollEvent: (a: number) => [number, number];
514
+ readonly wasmsyncclient_pollOutgoingBinary: (a: number) => any;
515
+ readonly wasmsyncclient_pollOutgoingText: (a: number) => [number, number];
516
+ readonly wasmsyncclient_queueLocalUpdate: (a: number, b: number, c: number, d: number, e: number) => any;
517
+ readonly wasmsyncclient_setSessionCode: (a: number, b: number, c: number) => void;
518
+ readonly wasmsyncclient_syncBodyFiles: (a: number, b: number, c: number) => any;
519
+ readonly wasmsyncclient_unfocusFiles: (a: number, b: number, c: number) => void;
467
520
  readonly init: () => void;
468
521
  readonly __wbg_diaryxbackend_free: (a: number, b: number) => void;
469
- readonly __wbg_wasmsyncclient_free: (a: number, b: number) => void;
470
522
  readonly diaryxbackend_create: (a: number, b: number) => any;
471
523
  readonly diaryxbackend_createInMemory: () => [number, number, number];
472
524
  readonly diaryxbackend_createSyncClient: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => number;
@@ -479,27 +531,14 @@ export interface InitOutput {
479
531
  readonly diaryxbackend_isCrdtEnabled: (a: number) => number;
480
532
  readonly diaryxbackend_offFileSystemEvent: (a: number, b: bigint) => number;
481
533
  readonly diaryxbackend_onFileSystemEvent: (a: number, b: any) => bigint;
534
+ readonly diaryxbackend_parseDayOneJson: (a: number, b: number, c: number) => [number, number, number, number];
535
+ readonly diaryxbackend_parseMarkdownFile: (a: number, b: number, c: number, d: number, e: number) => [number, number, number, number];
482
536
  readonly diaryxbackend_readBinary: (a: number, b: number, c: number) => any;
483
537
  readonly diaryxbackend_saveConfig: (a: number, b: any) => any;
484
538
  readonly diaryxbackend_setCrdtEnabled: (a: number, b: number) => void;
485
539
  readonly diaryxbackend_writeBinary: (a: number, b: number, c: number, d: any) => any;
486
- readonly wasmsyncclient_focusFiles: (a: number, b: number, c: number) => void;
487
- readonly wasmsyncclient_getServerUrl: (a: number) => [number, number];
488
- readonly wasmsyncclient_getWorkspaceId: (a: number) => [number, number];
489
- readonly wasmsyncclient_getWsUrl: (a: number) => [number, number];
490
- readonly wasmsyncclient_hasEvents: (a: number) => number;
491
- readonly wasmsyncclient_hasOutgoing: (a: number) => number;
492
- readonly wasmsyncclient_onBinaryMessage: (a: number, b: number, c: number) => any;
493
- readonly wasmsyncclient_onConnected: (a: number) => any;
494
- readonly wasmsyncclient_onDisconnected: (a: number) => any;
495
- readonly wasmsyncclient_onSnapshotImported: (a: number) => any;
496
- readonly wasmsyncclient_onTextMessage: (a: number, b: number, c: number) => any;
497
- readonly wasmsyncclient_pollEvent: (a: number) => [number, number];
498
- readonly wasmsyncclient_pollOutgoingBinary: (a: number) => any;
499
- readonly wasmsyncclient_pollOutgoingText: (a: number) => [number, number];
500
- readonly wasmsyncclient_queueLocalUpdate: (a: number, b: number, c: number, d: number, e: number) => any;
501
- readonly wasmsyncclient_setSessionCode: (a: number, b: number, c: number) => void;
502
- readonly wasmsyncclient_unfocusFiles: (a: number, b: number, c: number) => void;
540
+ readonly now_timestamp: () => [number, number];
541
+ readonly today_formatted: (a: number, b: number) => [number, number];
503
542
  readonly wasm_bindgen__closure__destroy__h358403ff5b31de35: (a: number, b: number) => void;
504
543
  readonly wasm_bindgen__convert__closures_____invoke__h9824f9855d7aa260: (a: number, b: number, c: any, d: any) => void;
505
544
  readonly wasm_bindgen__convert__closures_____invoke__h4b881ac518a5291a: (a: number, b: number, c: any) => void;
package/diaryx_wasm.js CHANGED
@@ -268,6 +268,80 @@ export class DiaryxBackend {
268
268
  const ret = wasm.diaryxbackend_onFileSystemEvent(this.__wbg_ptr, callback);
269
269
  return BigInt.asUintN(64, ret);
270
270
  }
271
+ /**
272
+ * Parse a Day One `Journal.json` file and return entries as JSON.
273
+ *
274
+ * Takes the raw bytes of a `Journal.json` file and returns a JSON array
275
+ * of successfully parsed entries. Parse errors are returned in a separate
276
+ * `errors` array.
277
+ *
278
+ * ## Example
279
+ * ```javascript
280
+ * const bytes = new Uint8Array(await file.arrayBuffer());
281
+ * const result = backend.parseDayOneJson(bytes);
282
+ * const { entries, errors } = JSON.parse(result);
283
+ * ```
284
+ * @param {Uint8Array} bytes
285
+ * @returns {string}
286
+ */
287
+ parseDayOneJson(bytes) {
288
+ let deferred3_0;
289
+ let deferred3_1;
290
+ try {
291
+ const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_malloc);
292
+ const len0 = WASM_VECTOR_LEN;
293
+ const ret = wasm.diaryxbackend_parseDayOneJson(this.__wbg_ptr, ptr0, len0);
294
+ var ptr2 = ret[0];
295
+ var len2 = ret[1];
296
+ if (ret[3]) {
297
+ ptr2 = 0; len2 = 0;
298
+ throw takeFromExternrefTable0(ret[2]);
299
+ }
300
+ deferred3_0 = ptr2;
301
+ deferred3_1 = len2;
302
+ return getStringFromWasm0(ptr2, len2);
303
+ } finally {
304
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
305
+ }
306
+ }
307
+ /**
308
+ * Parse a single markdown file and return the entry as JSON.
309
+ *
310
+ * Takes the raw bytes of a `.md` file and its filename, and returns
311
+ * a JSON-serialized `ImportedEntry`.
312
+ *
313
+ * ## Example
314
+ * ```javascript
315
+ * const bytes = new Uint8Array(await file.arrayBuffer());
316
+ * const entryJson = backend.parseMarkdownFile(bytes, file.name);
317
+ * const entry = JSON.parse(entryJson);
318
+ * ```
319
+ * @param {Uint8Array} bytes
320
+ * @param {string} filename
321
+ * @returns {string}
322
+ */
323
+ parseMarkdownFile(bytes, filename) {
324
+ let deferred4_0;
325
+ let deferred4_1;
326
+ try {
327
+ const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_malloc);
328
+ const len0 = WASM_VECTOR_LEN;
329
+ const ptr1 = passStringToWasm0(filename, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
330
+ const len1 = WASM_VECTOR_LEN;
331
+ const ret = wasm.diaryxbackend_parseMarkdownFile(this.__wbg_ptr, ptr0, len0, ptr1, len1);
332
+ var ptr3 = ret[0];
333
+ var len3 = ret[1];
334
+ if (ret[3]) {
335
+ ptr3 = 0; len3 = 0;
336
+ throw takeFromExternrefTable0(ret[2]);
337
+ }
338
+ deferred4_0 = ptr3;
339
+ deferred4_1 = len3;
340
+ return getStringFromWasm0(ptr3, len3);
341
+ } finally {
342
+ wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
343
+ }
344
+ }
271
345
  /**
272
346
  * Read binary file.
273
347
  *
@@ -600,6 +674,20 @@ export class WasmSyncClient {
600
674
  const len0 = WASM_VECTOR_LEN;
601
675
  wasm.wasmsyncclient_setSessionCode(this.__wbg_ptr, ptr0, len0);
602
676
  }
677
+ /**
678
+ * Request body sync for specific files (lazy sync on demand).
679
+ *
680
+ * Sends SyncBodyFiles event through the session to initiate body
681
+ * SyncStep1 for just the requested files, rather than all files.
682
+ * @param {string[]} file_paths
683
+ * @returns {Promise<any>}
684
+ */
685
+ syncBodyFiles(file_paths) {
686
+ const ptr0 = passArrayJsValueToWasm0(file_paths, wasm.__wbindgen_malloc);
687
+ const len0 = WASM_VECTOR_LEN;
688
+ const ret = wasm.wasmsyncclient_syncBodyFiles(this.__wbg_ptr, ptr0, len0);
689
+ return ret;
690
+ }
603
691
  /**
604
692
  * Send an unfocus message for specific files.
605
693
  * @param {string[]} files
@@ -1003,7 +1091,7 @@ function __wbg_get_imports() {
1003
1091
  console.warn(arg0, arg1, arg2, arg3);
1004
1092
  },
1005
1093
  __wbindgen_cast_0000000000000001: function(arg0, arg1) {
1006
- // Cast intrinsic for `Closure(Closure { dtor_idx: 614, function: Function { arguments: [Externref], shim_idx: 615, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
1094
+ // Cast intrinsic for `Closure(Closure { dtor_idx: 642, function: Function { arguments: [Externref], shim_idx: 643, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
1007
1095
  const ret = makeMutClosure(arg0, arg1, wasm.wasm_bindgen__closure__destroy__h358403ff5b31de35, wasm_bindgen__convert__closures_____invoke__h4b881ac518a5291a);
1008
1096
  return ret;
1009
1097
  },
Binary file
@@ -1,14 +1,30 @@
1
1
  /* tslint:disable */
2
2
  /* eslint-disable */
3
3
  export const memory: WebAssembly.Memory;
4
- export const now_timestamp: () => [number, number];
5
- export const today_formatted: (a: number, b: number) => [number, number];
6
4
  export const __wbg_jsasyncfilesystem_free: (a: number, b: number) => void;
5
+ export const __wbg_wasmsyncclient_free: (a: number, b: number) => void;
7
6
  export const jsasyncfilesystem_has_callback: (a: number, b: number, c: number) => number;
8
7
  export const jsasyncfilesystem_new: (a: any) => number;
8
+ export const wasmsyncclient_focusFiles: (a: number, b: number, c: number) => void;
9
+ export const wasmsyncclient_getServerUrl: (a: number) => [number, number];
10
+ export const wasmsyncclient_getWorkspaceId: (a: number) => [number, number];
11
+ export const wasmsyncclient_getWsUrl: (a: number) => [number, number];
12
+ export const wasmsyncclient_hasEvents: (a: number) => number;
13
+ export const wasmsyncclient_hasOutgoing: (a: number) => number;
14
+ export const wasmsyncclient_onBinaryMessage: (a: number, b: number, c: number) => any;
15
+ export const wasmsyncclient_onConnected: (a: number) => any;
16
+ export const wasmsyncclient_onDisconnected: (a: number) => any;
17
+ export const wasmsyncclient_onSnapshotImported: (a: number) => any;
18
+ export const wasmsyncclient_onTextMessage: (a: number, b: number, c: number) => any;
19
+ export const wasmsyncclient_pollEvent: (a: number) => [number, number];
20
+ export const wasmsyncclient_pollOutgoingBinary: (a: number) => any;
21
+ export const wasmsyncclient_pollOutgoingText: (a: number) => [number, number];
22
+ export const wasmsyncclient_queueLocalUpdate: (a: number, b: number, c: number, d: number, e: number) => any;
23
+ export const wasmsyncclient_setSessionCode: (a: number, b: number, c: number) => void;
24
+ export const wasmsyncclient_syncBodyFiles: (a: number, b: number, c: number) => any;
25
+ export const wasmsyncclient_unfocusFiles: (a: number, b: number, c: number) => void;
9
26
  export const init: () => void;
10
27
  export const __wbg_diaryxbackend_free: (a: number, b: number) => void;
11
- export const __wbg_wasmsyncclient_free: (a: number, b: number) => void;
12
28
  export const diaryxbackend_create: (a: number, b: number) => any;
13
29
  export const diaryxbackend_createInMemory: () => [number, number, number];
14
30
  export const diaryxbackend_createSyncClient: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => number;
@@ -21,27 +37,14 @@ export const diaryxbackend_hasNativeSync: (a: number) => number;
21
37
  export const diaryxbackend_isCrdtEnabled: (a: number) => number;
22
38
  export const diaryxbackend_offFileSystemEvent: (a: number, b: bigint) => number;
23
39
  export const diaryxbackend_onFileSystemEvent: (a: number, b: any) => bigint;
40
+ export const diaryxbackend_parseDayOneJson: (a: number, b: number, c: number) => [number, number, number, number];
41
+ export const diaryxbackend_parseMarkdownFile: (a: number, b: number, c: number, d: number, e: number) => [number, number, number, number];
24
42
  export const diaryxbackend_readBinary: (a: number, b: number, c: number) => any;
25
43
  export const diaryxbackend_saveConfig: (a: number, b: any) => any;
26
44
  export const diaryxbackend_setCrdtEnabled: (a: number, b: number) => void;
27
45
  export const diaryxbackend_writeBinary: (a: number, b: number, c: number, d: any) => any;
28
- export const wasmsyncclient_focusFiles: (a: number, b: number, c: number) => void;
29
- export const wasmsyncclient_getServerUrl: (a: number) => [number, number];
30
- export const wasmsyncclient_getWorkspaceId: (a: number) => [number, number];
31
- export const wasmsyncclient_getWsUrl: (a: number) => [number, number];
32
- export const wasmsyncclient_hasEvents: (a: number) => number;
33
- export const wasmsyncclient_hasOutgoing: (a: number) => number;
34
- export const wasmsyncclient_onBinaryMessage: (a: number, b: number, c: number) => any;
35
- export const wasmsyncclient_onConnected: (a: number) => any;
36
- export const wasmsyncclient_onDisconnected: (a: number) => any;
37
- export const wasmsyncclient_onSnapshotImported: (a: number) => any;
38
- export const wasmsyncclient_onTextMessage: (a: number, b: number, c: number) => any;
39
- export const wasmsyncclient_pollEvent: (a: number) => [number, number];
40
- export const wasmsyncclient_pollOutgoingBinary: (a: number) => any;
41
- export const wasmsyncclient_pollOutgoingText: (a: number) => [number, number];
42
- export const wasmsyncclient_queueLocalUpdate: (a: number, b: number, c: number, d: number, e: number) => any;
43
- export const wasmsyncclient_setSessionCode: (a: number, b: number, c: number) => void;
44
- export const wasmsyncclient_unfocusFiles: (a: number, b: number, c: number) => void;
46
+ export const now_timestamp: () => [number, number];
47
+ export const today_formatted: (a: number, b: number) => [number, number];
45
48
  export const wasm_bindgen__closure__destroy__h358403ff5b31de35: (a: number, b: number) => void;
46
49
  export const wasm_bindgen__convert__closures_____invoke__h9824f9855d7aa260: (a: number, b: number, c: any, d: any) => void;
47
50
  export const wasm_bindgen__convert__closures_____invoke__h4b881ac518a5291a: (a: number, b: number, c: any) => 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.0.1",
5
+ "version": "1.1.0-dev.4fa69f2",
6
6
  "license": "SEE LICENSE IN ../../LICENSE.md",
7
7
  "repository": {
8
8
  "type": "git",