@diaryx/wasm-node 1.1.0-dev.4c342c8 → 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/README.md CHANGED
@@ -360,72 +360,6 @@ CRDT operations use `doc_type` to specify which document to operate on:
360
360
  | `body` | file path | Per-file body content (e.g., `notes/a.md`) |
361
361
 
362
362
 
363
- ## Node.js / Obsidian / Electron Usage
364
-
365
- The `@diaryx/wasm-node` npm package is a build of this crate without browser-specific storage backends. It's published automatically by CI and works in any JavaScript environment that supports WebAssembly.
366
-
367
- ### Setup
368
-
369
- ```javascript
370
- import init, { DiaryxBackend } from '@diaryx/wasm-node';
371
- import fs from 'fs';
372
-
373
- // Load WASM binary and initialize
374
- const wasmPath = new URL('./diaryx_wasm_bg.wasm', import.meta.url);
375
- await init(fs.readFileSync(wasmPath));
376
-
377
- // Create backend with JavaScript filesystem callbacks
378
- const backend = DiaryxBackend.createFromJsFileSystem({
379
- readToString: (path) => fs.promises.readFile(path, 'utf8'),
380
- writeFile: (path, content) => fs.promises.writeFile(path, content),
381
- exists: (path) => fs.promises.access(path).then(() => true).catch(() => false),
382
- isDir: (path) => fs.promises.stat(path).then(s => s.isDirectory()).catch(() => false),
383
- listFiles: (dir) => fs.promises.readdir(dir),
384
- listMdFiles: (dir) => fs.promises.readdir(dir).then(f => f.filter(n => n.endsWith('.md'))),
385
- createDirAll: (path) => fs.promises.mkdir(path, { recursive: true }),
386
- moveFile: (from, to) => fs.promises.rename(from, to),
387
- deleteFile: (path) => fs.promises.unlink(path),
388
- readBinary: (path) => fs.promises.readFile(path),
389
- writeBinary: (path, data) => fs.promises.writeFile(path, data),
390
- });
391
- ```
392
-
393
- ### Obsidian Plugin Integration
394
-
395
- For Obsidian plugins, bridge the Vault adapter API:
396
-
397
- ```javascript
398
- const backend = DiaryxBackend.createFromJsFileSystem({
399
- readToString: (path) => app.vault.adapter.read(path),
400
- writeFile: (path, content) => app.vault.adapter.write(path, content),
401
- exists: (path) => app.vault.adapter.exists(path),
402
- isDir: (path) => app.vault.adapter.stat(path).then(s => s?.type === 'folder'),
403
- listFiles: (dir) => app.vault.adapter.list(dir).then(r => [...r.files, ...r.folders]),
404
- listMdFiles: (dir) => app.vault.adapter.list(dir).then(r => r.files.filter(f => f.endsWith('.md'))),
405
- createDirAll: (path) => app.vault.adapter.mkdir(path),
406
- moveFile: (from, to) => app.vault.adapter.rename(from, to),
407
- deleteFile: (path) => app.vault.adapter.remove(path),
408
- readBinary: (path) => app.vault.adapter.readBinary(path),
409
- writeBinary: (path, data) => app.vault.adapter.writeBinary(path, data),
410
- });
411
- ```
412
-
413
- ### Reacting to External File Moves
414
-
415
- When an external tool (Obsidian, VS Code, etc.) has already moved a file, use `SyncMoveMetadata` to update the workspace hierarchy metadata without re-doing the filesystem move:
416
-
417
- ```javascript
418
- // Obsidian fires this after a file is moved/renamed
419
- app.vault.on('rename', async (file, oldPath) => {
420
- await backend.executeJs({
421
- type: 'SyncMoveMetadata',
422
- params: { old_path: oldPath, new_path: file.path }
423
- });
424
- });
425
- ```
426
-
427
- This updates `contents` in the old and new parent indexes and `part_of` in the moved file.
428
-
429
363
  ## Error Handling
430
364
 
431
365
  All methods return `Result<T, JsValue>` for JavaScript interop. Errors are converted to JavaScript exceptions with descriptive messages.
package/diaryx_wasm.d.ts CHANGED
@@ -120,24 +120,6 @@ export class DiaryxBackend {
120
120
  * Create backend with specific storage type.
121
121
  */
122
122
  static create(storage_type: string): Promise<DiaryxBackend>;
123
- /**
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
- */
140
- static createFromJsFileSystem(callbacks: any): DiaryxBackend;
141
123
  /**
142
124
  * Create a new DiaryxBackend with in-memory storage.
143
125
  *
@@ -293,11 +275,11 @@ export class DiaryxBackend {
293
275
  */
294
276
  onFileSystemEvent(callback: Function): bigint;
295
277
  /**
296
- * Parse a Day One export (ZIP or JSON) and return entries as JSON.
278
+ * Parse a Day One `Journal.json` file and return entries as JSON.
297
279
  *
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).
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.
301
283
  *
302
284
  * ## Example
303
285
  * ```javascript
@@ -517,8 +499,6 @@ export interface InitOutput {
517
499
  readonly __wbg_wasmsyncclient_free: (a: number, b: number) => void;
518
500
  readonly jsasyncfilesystem_has_callback: (a: number, b: number, c: number) => number;
519
501
  readonly jsasyncfilesystem_new: (a: any) => number;
520
- readonly now_timestamp: () => [number, number];
521
- readonly today_formatted: (a: number, b: number) => [number, number];
522
502
  readonly wasmsyncclient_focusFiles: (a: number, b: number, c: number) => void;
523
503
  readonly wasmsyncclient_getServerUrl: (a: number) => [number, number];
524
504
  readonly wasmsyncclient_getWorkspaceId: (a: number) => [number, number];
@@ -537,9 +517,9 @@ export interface InitOutput {
537
517
  readonly wasmsyncclient_setSessionCode: (a: number, b: number, c: number) => void;
538
518
  readonly wasmsyncclient_syncBodyFiles: (a: number, b: number, c: number) => any;
539
519
  readonly wasmsyncclient_unfocusFiles: (a: number, b: number, c: number) => void;
520
+ readonly init: () => void;
540
521
  readonly __wbg_diaryxbackend_free: (a: number, b: number) => void;
541
522
  readonly diaryxbackend_create: (a: number, b: number) => any;
542
- readonly diaryxbackend_createFromJsFileSystem: (a: any) => [number, number, number];
543
523
  readonly diaryxbackend_createInMemory: () => [number, number, number];
544
524
  readonly diaryxbackend_createSyncClient: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => number;
545
525
  readonly diaryxbackend_emitFileSystemEvent: (a: number, b: number, c: number) => [number, number];
@@ -557,7 +537,8 @@ export interface InitOutput {
557
537
  readonly diaryxbackend_saveConfig: (a: number, b: any) => any;
558
538
  readonly diaryxbackend_setCrdtEnabled: (a: number, b: number) => void;
559
539
  readonly diaryxbackend_writeBinary: (a: number, b: number, c: number, d: any) => any;
560
- readonly init: () => void;
540
+ readonly now_timestamp: () => [number, number];
541
+ readonly today_formatted: (a: number, b: number) => [number, number];
561
542
  readonly wasm_bindgen__closure__destroy__h358403ff5b31de35: (a: number, b: number) => void;
562
543
  readonly wasm_bindgen__convert__closures_____invoke__h9824f9855d7aa260: (a: number, b: number, c: any, d: any) => void;
563
544
  readonly wasm_bindgen__convert__closures_____invoke__h4b881ac518a5291a: (a: number, b: number, c: any) => void;
package/diaryx_wasm.js CHANGED
@@ -48,32 +48,6 @@ export class DiaryxBackend {
48
48
  const ret = wasm.diaryxbackend_create(ptr0, len0);
49
49
  return ret;
50
50
  }
51
- /**
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
- * @param {any} callbacks
68
- * @returns {DiaryxBackend}
69
- */
70
- static createFromJsFileSystem(callbacks) {
71
- const ret = wasm.diaryxbackend_createFromJsFileSystem(callbacks);
72
- if (ret[2]) {
73
- throw takeFromExternrefTable0(ret[1]);
74
- }
75
- return DiaryxBackend.__wrap(ret[0]);
76
- }
77
51
  /**
78
52
  * Create a new DiaryxBackend with in-memory storage.
79
53
  *
@@ -295,11 +269,11 @@ export class DiaryxBackend {
295
269
  return BigInt.asUintN(64, ret);
296
270
  }
297
271
  /**
298
- * Parse a Day One export (ZIP or JSON) and return entries as JSON.
272
+ * Parse a Day One `Journal.json` file and return entries as JSON.
299
273
  *
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).
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.
303
277
  *
304
278
  * ## Example
305
279
  * ```javascript
@@ -859,10 +833,6 @@ function __wbg_get_imports() {
859
833
  __wbg__wbg_cb_unref_d9b87ff7982e3b21: function(arg0) {
860
834
  arg0._wbg_cb_unref();
861
835
  },
862
- __wbg_apply_ada2ee1a60ac7b3c: function() { return handleError(function (arg0, arg1, arg2) {
863
- const ret = arg0.apply(arg1, arg2);
864
- return ret;
865
- }, arguments); },
866
836
  __wbg_call_389efe28435a9388: function() { return handleError(function (arg0, arg1) {
867
837
  const ret = arg0.call(arg1);
868
838
  return ret;
@@ -871,14 +841,6 @@ function __wbg_get_imports() {
871
841
  const ret = arg0.call(arg1, arg2);
872
842
  return ret;
873
843
  }, arguments); },
874
- __wbg_call_812d25f1510c13c8: function() { return handleError(function (arg0, arg1, arg2, arg3) {
875
- const ret = arg0.call(arg1, arg2, arg3);
876
- return ret;
877
- }, arguments); },
878
- __wbg_call_e8c868596c950cf6: function() { return handleError(function (arg0, arg1, arg2, arg3, arg4) {
879
- const ret = arg0.call(arg1, arg2, arg3, arg4);
880
- return ret;
881
- }, arguments); },
882
844
  __wbg_crypto_86f2631e91b51511: function(arg0) {
883
845
  const ret = arg0.crypto;
884
846
  return ret;
@@ -947,26 +909,6 @@ function __wbg_get_imports() {
947
909
  const ret = result;
948
910
  return ret;
949
911
  },
950
- __wbg_instanceof_Object_1c6af87502b733ed: function(arg0) {
951
- let result;
952
- try {
953
- result = arg0 instanceof Object;
954
- } catch (_) {
955
- result = false;
956
- }
957
- const ret = result;
958
- return ret;
959
- },
960
- __wbg_instanceof_Promise_0094681e3519d6ec: function(arg0) {
961
- let result;
962
- try {
963
- result = arg0 instanceof Promise;
964
- } catch (_) {
965
- result = false;
966
- }
967
- const ret = result;
968
- return ret;
969
- },
970
912
  __wbg_instanceof_Uint8Array_9b9075935c74707c: function(arg0) {
971
913
  let result;
972
914
  try {
@@ -1081,10 +1023,6 @@ function __wbg_get_imports() {
1081
1023
  __wbg_prototypesetcall_bdcdcc5842e4d77d: function(arg0, arg1, arg2) {
1082
1024
  Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), arg2);
1083
1025
  },
1084
- __wbg_push_8ffdcb2063340ba5: function(arg0, arg1) {
1085
- const ret = arg0.push(arg1);
1086
- return ret;
1087
- },
1088
1026
  __wbg_queueMicrotask_0aa0a927f78f5d98: function(arg0) {
1089
1027
  const ret = arg0.queueMicrotask;
1090
1028
  return ret;
@@ -1110,9 +1048,6 @@ function __wbg_get_imports() {
1110
1048
  __wbg_set_3f1d0b984ed272ed: function(arg0, arg1, arg2) {
1111
1049
  arg0[arg1] = arg2;
1112
1050
  },
1113
- __wbg_set_cc56eefd2dd91957: function(arg0, arg1, arg2) {
1114
- arg0.set(getArrayU8FromWasm0(arg1, arg2));
1115
- },
1116
1051
  __wbg_set_f43e577aea94465b: function(arg0, arg1, arg2) {
1117
1052
  arg0[arg1 >>> 0] = arg2;
1118
1053
  },
@@ -1140,18 +1075,10 @@ function __wbg_get_imports() {
1140
1075
  const ret = arg0.subarray(arg1 >>> 0, arg2 >>> 0);
1141
1076
  return ret;
1142
1077
  },
1143
- __wbg_then_0d9fe2c7b1857d32: function(arg0, arg1, arg2) {
1144
- const ret = arg0.then(arg1, arg2);
1145
- return ret;
1146
- },
1147
1078
  __wbg_then_b9e7b3b5f1a9e1b5: function(arg0, arg1) {
1148
1079
  const ret = arg0.then(arg1);
1149
1080
  return ret;
1150
1081
  },
1151
- __wbg_toString_964ff7fe6eca8362: function(arg0) {
1152
- const ret = arg0.toString();
1153
- return ret;
1154
- },
1155
1082
  __wbg_value_0546255b415e96c1: function(arg0) {
1156
1083
  const ret = arg0.value;
1157
1084
  return ret;
@@ -1164,7 +1091,7 @@ function __wbg_get_imports() {
1164
1091
  console.warn(arg0, arg1, arg2, arg3);
1165
1092
  },
1166
1093
  __wbindgen_cast_0000000000000001: function(arg0, arg1) {
1167
- // Cast intrinsic for `Closure(Closure { dtor_idx: 669, function: Function { arguments: [Externref], shim_idx: 670, 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`.
1168
1095
  const ret = makeMutClosure(arg0, arg1, wasm.wasm_bindgen__closure__destroy__h358403ff5b31de35, wasm_bindgen__convert__closures_____invoke__h4b881ac518a5291a);
1169
1096
  return ret;
1170
1097
  },
Binary file
@@ -5,8 +5,6 @@ export const __wbg_jsasyncfilesystem_free: (a: number, b: number) => void;
5
5
  export const __wbg_wasmsyncclient_free: (a: number, b: number) => void;
6
6
  export const jsasyncfilesystem_has_callback: (a: number, b: number, c: number) => number;
7
7
  export const jsasyncfilesystem_new: (a: any) => number;
8
- export const now_timestamp: () => [number, number];
9
- export const today_formatted: (a: number, b: number) => [number, number];
10
8
  export const wasmsyncclient_focusFiles: (a: number, b: number, c: number) => void;
11
9
  export const wasmsyncclient_getServerUrl: (a: number) => [number, number];
12
10
  export const wasmsyncclient_getWorkspaceId: (a: number) => [number, number];
@@ -25,9 +23,9 @@ export const wasmsyncclient_queueLocalUpdate: (a: number, b: number, c: number,
25
23
  export const wasmsyncclient_setSessionCode: (a: number, b: number, c: number) => void;
26
24
  export const wasmsyncclient_syncBodyFiles: (a: number, b: number, c: number) => any;
27
25
  export const wasmsyncclient_unfocusFiles: (a: number, b: number, c: number) => void;
26
+ export const init: () => void;
28
27
  export const __wbg_diaryxbackend_free: (a: number, b: number) => void;
29
28
  export const diaryxbackend_create: (a: number, b: number) => any;
30
- export const diaryxbackend_createFromJsFileSystem: (a: any) => [number, number, number];
31
29
  export const diaryxbackend_createInMemory: () => [number, number, number];
32
30
  export const diaryxbackend_createSyncClient: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => number;
33
31
  export const diaryxbackend_emitFileSystemEvent: (a: number, b: number, c: number) => [number, number];
@@ -45,7 +43,8 @@ export const diaryxbackend_readBinary: (a: number, b: number, c: number) => any;
45
43
  export const diaryxbackend_saveConfig: (a: number, b: any) => any;
46
44
  export const diaryxbackend_setCrdtEnabled: (a: number, b: number) => void;
47
45
  export const diaryxbackend_writeBinary: (a: number, b: number, c: number, d: any) => any;
48
- export const init: () => void;
46
+ export const now_timestamp: () => [number, number];
47
+ export const today_formatted: (a: number, b: number) => [number, number];
49
48
  export const wasm_bindgen__closure__destroy__h358403ff5b31de35: (a: number, b: number) => void;
50
49
  export const wasm_bindgen__convert__closures_____invoke__h9824f9855d7aa260: (a: number, b: number, c: any, d: any) => void;
51
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.1.0-dev.4c342c8",
5
+ "version": "1.1.0-dev.4fa69f2",
6
6
  "license": "SEE LICENSE IN ../../LICENSE.md",
7
7
  "repository": {
8
8
  "type": "git",