@haex-space/vault-sdk 2.5.42 → 2.5.43

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.
@@ -72,7 +72,19 @@ var HAEXTENSION_METHODS = {
72
72
  filesystem: {
73
73
  saveFile: "haextension:filesystem:save-file",
74
74
  openFile: "haextension:filesystem:open-file",
75
- showImage: "haextension:filesystem:show-image"
75
+ showImage: "haextension:filesystem:show-image",
76
+ // Generic FS operations (Phase 2)
77
+ readFile: "haextension:filesystem:read-file",
78
+ writeFile: "haextension:filesystem:write-file",
79
+ readDir: "haextension:filesystem:read-dir",
80
+ mkdir: "haextension:filesystem:mkdir",
81
+ remove: "haextension:filesystem:remove",
82
+ exists: "haextension:filesystem:exists",
83
+ stat: "haextension:filesystem:stat",
84
+ selectFolder: "haextension:filesystem:select-folder",
85
+ selectFile: "haextension:filesystem:select-file",
86
+ rename: "haextension:filesystem:rename",
87
+ copy: "haextension:filesystem:copy"
76
88
  },
77
89
  filesync: {
78
90
  // Spaces
@@ -620,6 +632,136 @@ var FilesystemAPI = class {
620
632
  );
621
633
  return result;
622
634
  }
635
+ // ==========================================================================
636
+ // Generic Filesystem Operations (Phase 2)
637
+ // ==========================================================================
638
+ /**
639
+ * Read file contents
640
+ * @param path Absolute path to the file
641
+ * @returns File contents as Uint8Array
642
+ */
643
+ async readFile(path) {
644
+ const base64 = await this.client.request(
645
+ HAEXTENSION_METHODS.filesystem.readFile,
646
+ { path }
647
+ );
648
+ const binary = atob(base64);
649
+ const bytes = new Uint8Array(binary.length);
650
+ for (let i = 0; i < binary.length; i++) {
651
+ bytes[i] = binary.charCodeAt(i);
652
+ }
653
+ return bytes;
654
+ }
655
+ /**
656
+ * Write file contents
657
+ * @param path Absolute path to the file
658
+ * @param data File contents as Uint8Array
659
+ */
660
+ async writeFile(path, data) {
661
+ const base64 = btoa(String.fromCharCode(...data));
662
+ await this.client.request(
663
+ HAEXTENSION_METHODS.filesystem.writeFile,
664
+ { path, data: base64 }
665
+ );
666
+ }
667
+ /**
668
+ * Read directory contents
669
+ * @param path Absolute path to the directory
670
+ * @returns Array of directory entries
671
+ */
672
+ async readDir(path) {
673
+ return this.client.request(
674
+ HAEXTENSION_METHODS.filesystem.readDir,
675
+ { path }
676
+ );
677
+ }
678
+ /**
679
+ * Create a directory (and parent directories if needed)
680
+ * @param path Absolute path to create
681
+ */
682
+ async mkdir(path) {
683
+ await this.client.request(
684
+ HAEXTENSION_METHODS.filesystem.mkdir,
685
+ { path }
686
+ );
687
+ }
688
+ /**
689
+ * Remove a file or directory
690
+ * @param path Absolute path to remove
691
+ * @param recursive If true, remove directories recursively
692
+ */
693
+ async remove(path, recursive = false) {
694
+ await this.client.request(
695
+ HAEXTENSION_METHODS.filesystem.remove,
696
+ { path, recursive }
697
+ );
698
+ }
699
+ /**
700
+ * Check if a path exists
701
+ * @param path Absolute path to check
702
+ * @returns True if the path exists
703
+ */
704
+ async exists(path) {
705
+ return this.client.request(
706
+ HAEXTENSION_METHODS.filesystem.exists,
707
+ { path }
708
+ );
709
+ }
710
+ /**
711
+ * Get file/directory metadata
712
+ * @param path Absolute path
713
+ * @returns File metadata
714
+ */
715
+ async stat(path) {
716
+ return this.client.request(
717
+ HAEXTENSION_METHODS.filesystem.stat,
718
+ { path }
719
+ );
720
+ }
721
+ /**
722
+ * Open a folder selection dialog
723
+ * @param options Dialog options
724
+ * @returns Selected folder path, or null if cancelled
725
+ */
726
+ async selectFolder(options = {}) {
727
+ return this.client.request(
728
+ HAEXTENSION_METHODS.filesystem.selectFolder,
729
+ options
730
+ );
731
+ }
732
+ /**
733
+ * Open a file selection dialog
734
+ * @param options Dialog options
735
+ * @returns Selected file paths, or null if cancelled
736
+ */
737
+ async selectFile(options = {}) {
738
+ return this.client.request(
739
+ HAEXTENSION_METHODS.filesystem.selectFile,
740
+ options
741
+ );
742
+ }
743
+ /**
744
+ * Rename/move a file or directory
745
+ * @param from Source path
746
+ * @param to Destination path
747
+ */
748
+ async rename(from, to) {
749
+ await this.client.request(
750
+ HAEXTENSION_METHODS.filesystem.rename,
751
+ { from, to }
752
+ );
753
+ }
754
+ /**
755
+ * Copy a file
756
+ * @param from Source path
757
+ * @param to Destination path
758
+ */
759
+ async copy(from, to) {
760
+ await this.client.request(
761
+ HAEXTENSION_METHODS.filesystem.copy,
762
+ { from, to }
763
+ );
764
+ }
623
765
  };
624
766
 
625
767
  // src/api/web.ts
@@ -1188,8 +1330,7 @@ var TAURI_COMMANDS = {
1188
1330
  filesystem: {
1189
1331
  saveFile: "webview_extension_fs_save_file",
1190
1332
  openFile: "webview_extension_fs_open_file",
1191
- showImage: "webview_extension_fs_show_image"
1192
- },
1333
+ showImage: "webview_extension_fs_show_image"},
1193
1334
  external: {
1194
1335
  // Response handling (called by extensions running in WebView)
1195
1336
  respond: "webview_extension_external_respond"},