@haex-space/vault-sdk 4.7.1 → 4.8.1

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/vue.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { S as StorageAPI } from './client-BlUizM-l.mjs';
1
+ import { S as StorageAPI } from './client-DOAj36ga.mjs';
2
2
  import { HaexVaultSdk } from './index.mjs';
3
3
  import * as drizzle_orm_sqlite_proxy from 'drizzle-orm/sqlite-proxy';
4
4
  import { Ref } from 'vue';
package/dist/vue.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { S as StorageAPI } from './client--CgEtJ4G.js';
1
+ import { S as StorageAPI } from './client-CNbwFQjB.js';
2
2
  import { HaexVaultSdk } from './index.js';
3
3
  import * as drizzle_orm_sqlite_proxy from 'drizzle-orm/sqlite-proxy';
4
4
  import { Ref } from 'vue';
package/dist/vue.js CHANGED
@@ -968,7 +968,8 @@ var FilesystemAPI = class {
968
968
  this.client = client;
969
969
  }
970
970
  /**
971
- * Opens a save file dialog and saves the provided data to the selected location
971
+ * Opens a save file dialog and saves the provided data to the selected location.
972
+ * Waits for the user without the request timeout.
972
973
  * @param data The file data as Uint8Array
973
974
  * @param options Options for the save dialog
974
975
  * @returns The path where the file was saved, or null if cancelled
@@ -982,7 +983,8 @@ var FilesystemAPI = class {
982
983
  defaultPath: options.defaultPath,
983
984
  title: options.title,
984
985
  filters: options.filters
985
- }
986
+ },
987
+ { timeout: null }
986
988
  );
987
989
  return result;
988
990
  }
@@ -1102,25 +1104,27 @@ var FilesystemAPI = class {
1102
1104
  );
1103
1105
  }
1104
1106
  /**
1105
- * Open a folder selection dialog
1107
+ * Open a folder selection dialog; waits for the user without the request timeout
1106
1108
  * @param options Dialog options
1107
1109
  * @returns Selected folder path, or null if cancelled
1108
1110
  */
1109
1111
  async selectFolder(options = {}) {
1110
1112
  return this.client.request(
1111
1113
  FILESYSTEM_COMMANDS.selectFolder,
1112
- options
1114
+ options,
1115
+ { timeout: null }
1113
1116
  );
1114
1117
  }
1115
1118
  /**
1116
- * Open a file selection dialog
1119
+ * Open a file selection dialog; waits for the user without the request timeout
1117
1120
  * @param options Dialog options
1118
1121
  * @returns Selected file paths, or null if cancelled
1119
1122
  */
1120
1123
  async selectFile(options = {}) {
1121
1124
  return this.client.request(
1122
1125
  FILESYSTEM_COMMANDS.selectFile,
1123
- options
1126
+ options,
1127
+ { timeout: null }
1124
1128
  );
1125
1129
  }
1126
1130
  /**
@@ -2043,22 +2047,45 @@ var ModelsAPI = class {
2043
2047
  * `cancelled` with the error. Errors of the start itself (an invalid job, a refused model or
2044
2048
  * consent, no fitting model) reject. The end can arrive before the start answers; it is kept
2045
2049
  * until then.
2046
- */
2047
- async runAsync(job) {
2050
+ *
2051
+ * Aborting `signal` asks to cancel the job, which then ends as `cancelled`; a job that had
2052
+ * already ended keeps its actual end. A signal that is already aborted rejects with its reason
2053
+ * and starts no job. If the cancel request fails, the run rejects with that error and the job
2054
+ * keeps running on the host; if it reports an unknown job, the run rejects with an error.
2055
+ */
2056
+ async runAsync(job, options = {}) {
2057
+ const { signal } = options;
2058
+ if (signal?.aborted) throw signal.reason;
2048
2059
  const ended = /* @__PURE__ */ new Map();
2049
2060
  let waiting = null;
2050
2061
  const unsubscribe = this.onCompleted((completion) => {
2051
2062
  if (waiting && completion.jobId === waiting.jobId) waiting.resolve(completion);
2052
2063
  else ended.set(completion.jobId, completion);
2053
2064
  });
2065
+ let detach = () => {
2066
+ };
2054
2067
  try {
2055
2068
  const { jobId } = await this.startAsync(job);
2056
- return await new Promise((resolve) => {
2069
+ return await new Promise((resolve, reject) => {
2057
2070
  const early = ended.get(jobId);
2058
- if (early) resolve(early);
2059
- else waiting = { jobId, resolve };
2071
+ if (early) return resolve(early);
2072
+ waiting = { jobId, resolve };
2073
+ if (!signal) return;
2074
+ const cancel = async () => {
2075
+ try {
2076
+ if (!await this.cancelAsync(jobId)) {
2077
+ reject(new Error("The model job could not be cancelled"));
2078
+ }
2079
+ } catch (error) {
2080
+ reject(error);
2081
+ }
2082
+ };
2083
+ if (signal.aborted) return cancel();
2084
+ signal.addEventListener("abort", cancel, { once: true });
2085
+ detach = () => signal.removeEventListener("abort", cancel);
2060
2086
  });
2061
2087
  } finally {
2088
+ detach();
2062
2089
  unsubscribe();
2063
2090
  }
2064
2091
  }