@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.
package/dist/index.mjs CHANGED
@@ -485,7 +485,19 @@ var HAEXTENSION_METHODS = {
485
485
  filesystem: {
486
486
  saveFile: "haextension:filesystem:save-file",
487
487
  openFile: "haextension:filesystem:open-file",
488
- showImage: "haextension:filesystem:show-image"
488
+ showImage: "haextension:filesystem:show-image",
489
+ // Generic FS operations (Phase 2)
490
+ readFile: "haextension:filesystem:read-file",
491
+ writeFile: "haextension:filesystem:write-file",
492
+ readDir: "haextension:filesystem:read-dir",
493
+ mkdir: "haextension:filesystem:mkdir",
494
+ remove: "haextension:filesystem:remove",
495
+ exists: "haextension:filesystem:exists",
496
+ stat: "haextension:filesystem:stat",
497
+ selectFolder: "haextension:filesystem:select-folder",
498
+ selectFile: "haextension:filesystem:select-file",
499
+ rename: "haextension:filesystem:rename",
500
+ copy: "haextension:filesystem:copy"
489
501
  },
490
502
  filesync: {
491
503
  // Spaces
@@ -1075,6 +1087,136 @@ var FilesystemAPI = class {
1075
1087
  );
1076
1088
  return result;
1077
1089
  }
1090
+ // ==========================================================================
1091
+ // Generic Filesystem Operations (Phase 2)
1092
+ // ==========================================================================
1093
+ /**
1094
+ * Read file contents
1095
+ * @param path Absolute path to the file
1096
+ * @returns File contents as Uint8Array
1097
+ */
1098
+ async readFile(path) {
1099
+ const base64 = await this.client.request(
1100
+ HAEXTENSION_METHODS.filesystem.readFile,
1101
+ { path }
1102
+ );
1103
+ const binary = atob(base64);
1104
+ const bytes = new Uint8Array(binary.length);
1105
+ for (let i = 0; i < binary.length; i++) {
1106
+ bytes[i] = binary.charCodeAt(i);
1107
+ }
1108
+ return bytes;
1109
+ }
1110
+ /**
1111
+ * Write file contents
1112
+ * @param path Absolute path to the file
1113
+ * @param data File contents as Uint8Array
1114
+ */
1115
+ async writeFile(path, data) {
1116
+ const base64 = btoa(String.fromCharCode(...data));
1117
+ await this.client.request(
1118
+ HAEXTENSION_METHODS.filesystem.writeFile,
1119
+ { path, data: base64 }
1120
+ );
1121
+ }
1122
+ /**
1123
+ * Read directory contents
1124
+ * @param path Absolute path to the directory
1125
+ * @returns Array of directory entries
1126
+ */
1127
+ async readDir(path) {
1128
+ return this.client.request(
1129
+ HAEXTENSION_METHODS.filesystem.readDir,
1130
+ { path }
1131
+ );
1132
+ }
1133
+ /**
1134
+ * Create a directory (and parent directories if needed)
1135
+ * @param path Absolute path to create
1136
+ */
1137
+ async mkdir(path) {
1138
+ await this.client.request(
1139
+ HAEXTENSION_METHODS.filesystem.mkdir,
1140
+ { path }
1141
+ );
1142
+ }
1143
+ /**
1144
+ * Remove a file or directory
1145
+ * @param path Absolute path to remove
1146
+ * @param recursive If true, remove directories recursively
1147
+ */
1148
+ async remove(path, recursive = false) {
1149
+ await this.client.request(
1150
+ HAEXTENSION_METHODS.filesystem.remove,
1151
+ { path, recursive }
1152
+ );
1153
+ }
1154
+ /**
1155
+ * Check if a path exists
1156
+ * @param path Absolute path to check
1157
+ * @returns True if the path exists
1158
+ */
1159
+ async exists(path) {
1160
+ return this.client.request(
1161
+ HAEXTENSION_METHODS.filesystem.exists,
1162
+ { path }
1163
+ );
1164
+ }
1165
+ /**
1166
+ * Get file/directory metadata
1167
+ * @param path Absolute path
1168
+ * @returns File metadata
1169
+ */
1170
+ async stat(path) {
1171
+ return this.client.request(
1172
+ HAEXTENSION_METHODS.filesystem.stat,
1173
+ { path }
1174
+ );
1175
+ }
1176
+ /**
1177
+ * Open a folder selection dialog
1178
+ * @param options Dialog options
1179
+ * @returns Selected folder path, or null if cancelled
1180
+ */
1181
+ async selectFolder(options = {}) {
1182
+ return this.client.request(
1183
+ HAEXTENSION_METHODS.filesystem.selectFolder,
1184
+ options
1185
+ );
1186
+ }
1187
+ /**
1188
+ * Open a file selection dialog
1189
+ * @param options Dialog options
1190
+ * @returns Selected file paths, or null if cancelled
1191
+ */
1192
+ async selectFile(options = {}) {
1193
+ return this.client.request(
1194
+ HAEXTENSION_METHODS.filesystem.selectFile,
1195
+ options
1196
+ );
1197
+ }
1198
+ /**
1199
+ * Rename/move a file or directory
1200
+ * @param from Source path
1201
+ * @param to Destination path
1202
+ */
1203
+ async rename(from, to) {
1204
+ await this.client.request(
1205
+ HAEXTENSION_METHODS.filesystem.rename,
1206
+ { from, to }
1207
+ );
1208
+ }
1209
+ /**
1210
+ * Copy a file
1211
+ * @param from Source path
1212
+ * @param to Destination path
1213
+ */
1214
+ async copy(from, to) {
1215
+ await this.client.request(
1216
+ HAEXTENSION_METHODS.filesystem.copy,
1217
+ { from, to }
1218
+ );
1219
+ }
1078
1220
  };
1079
1221
 
1080
1222
  // src/api/web.ts
@@ -1569,7 +1711,20 @@ var TAURI_COMMANDS = {
1569
1711
  filesystem: {
1570
1712
  saveFile: "webview_extension_fs_save_file",
1571
1713
  openFile: "webview_extension_fs_open_file",
1572
- showImage: "webview_extension_fs_show_image"
1714
+ showImage: "webview_extension_fs_show_image",
1715
+ // Generic filesystem operations (no webview_ prefix because they're global)
1716
+ // Permission checks happen in the message handler layer
1717
+ readFile: "filesystem_read_file",
1718
+ writeFile: "filesystem_write_file",
1719
+ readDir: "filesystem_read_dir",
1720
+ mkdir: "filesystem_mkdir",
1721
+ remove: "filesystem_remove",
1722
+ exists: "filesystem_exists",
1723
+ stat: "filesystem_stat",
1724
+ selectFolder: "filesystem_select_folder",
1725
+ selectFile: "filesystem_select_file",
1726
+ rename: "filesystem_rename",
1727
+ copy: "filesystem_copy"
1573
1728
  },
1574
1729
  external: {
1575
1730
  // Response handling (called by extensions running in WebView)