@haex-space/vault-sdk 2.5.74 → 2.5.77

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/dist/index.mjs CHANGED
@@ -373,7 +373,9 @@ var HAEXTENSION_EVENTS = {
373
373
  /** Context (theme, locale, platform) has changed */
374
374
  CONTEXT_CHANGED: "haextension:context:changed",
375
375
  /** Search request from HaexHub */
376
- SEARCH_REQUEST: "haextension:search:request"
376
+ SEARCH_REQUEST: "haextension:search:request",
377
+ /** File system change detected (from native file watcher) */
378
+ FILE_CHANGED: "filesync:file-changed"
377
379
  };
378
380
  var EXTERNAL_EVENTS = {
379
381
  /** External request from authorized client */
@@ -546,7 +548,14 @@ var FILESYSTEM_COMMANDS = {
546
548
  /** Rename file or directory */
547
549
  rename: "extension_filesystem_rename",
548
550
  /** Copy file or directory */
549
- copy: "extension_filesystem_copy"
551
+ copy: "extension_filesystem_copy",
552
+ // File watcher operations
553
+ /** Start watching a directory for changes */
554
+ watch: "extension_filesystem_watch",
555
+ /** Stop watching a directory */
556
+ unwatch: "extension_filesystem_unwatch",
557
+ /** Check if a directory is being watched */
558
+ isWatching: "extension_filesystem_is_watching"
550
559
  };
551
560
 
552
561
  // src/commands/externalBridge.ts
@@ -1149,6 +1158,42 @@ var FilesystemAPI = class {
1149
1158
  { from, to }
1150
1159
  );
1151
1160
  }
1161
+ // ==========================================================================
1162
+ // File Watcher Operations
1163
+ // ==========================================================================
1164
+ /**
1165
+ * Start watching a directory for file changes
1166
+ * When files change, the "filesync:file-changed" event is emitted
1167
+ * @param ruleId Unique identifier for this watch (e.g., sync rule ID)
1168
+ * @param path Absolute path to the directory to watch
1169
+ */
1170
+ async watch(ruleId, path) {
1171
+ await this.client.request(
1172
+ FILESYSTEM_COMMANDS.watch,
1173
+ { ruleId, path }
1174
+ );
1175
+ }
1176
+ /**
1177
+ * Stop watching a directory
1178
+ * @param ruleId The rule ID that was used when starting the watch
1179
+ */
1180
+ async unwatch(ruleId) {
1181
+ await this.client.request(
1182
+ FILESYSTEM_COMMANDS.unwatch,
1183
+ { ruleId }
1184
+ );
1185
+ }
1186
+ /**
1187
+ * Check if a directory is currently being watched
1188
+ * @param ruleId The rule ID to check
1189
+ * @returns True if the directory is being watched
1190
+ */
1191
+ async isWatching(ruleId) {
1192
+ return this.client.request(
1193
+ FILESYSTEM_COMMANDS.isWatching,
1194
+ { ruleId }
1195
+ );
1196
+ }
1152
1197
  };
1153
1198
 
1154
1199
  // src/api/web.ts
@@ -1582,6 +1627,26 @@ async function setupTauriEventListeners(ctx, log, onEvent, onContextChange) {
1582
1627
  console.error("[HaexVault SDK] Failed to setup external request listener:", error);
1583
1628
  log("Failed to setup external request listener:", error);
1584
1629
  }
1630
+ try {
1631
+ await listen(HAEXTENSION_EVENTS.FILE_CHANGED, (event) => {
1632
+ console.log("[HaexVault SDK] File change event received:", event.payload);
1633
+ log("Received file change event:", event);
1634
+ if (event.payload) {
1635
+ const payload = event.payload;
1636
+ onEvent({
1637
+ type: HAEXTENSION_EVENTS.FILE_CHANGED,
1638
+ ruleId: payload.ruleId,
1639
+ changeType: payload.changeType,
1640
+ path: payload.path,
1641
+ timestamp: Date.now()
1642
+ });
1643
+ }
1644
+ });
1645
+ console.log("[HaexVault SDK] File change listener registered successfully");
1646
+ } catch (error) {
1647
+ console.error("[HaexVault SDK] Failed to setup file change listener:", error);
1648
+ log("Failed to setup file change listener:", error);
1649
+ }
1585
1650
  }
1586
1651
  async function initIframeMode(ctx, log, messageHandler, request) {
1587
1652
  if (!isInIframe()) {