@haex-space/vault-sdk 4.7.1 → 4.8.0
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 +7 -3
- package/dist/{client-BlUizM-l.d.mts → client-D9zisRb8.d.mts} +9 -2
- package/dist/{client--CgEtJ4G.d.ts → client-DiqylZ59.d.ts} +9 -2
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +27 -4
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +27 -4
- package/dist/index.mjs.map +1 -1
- package/dist/react.d.mts +1 -1
- package/dist/react.d.ts +1 -1
- package/dist/react.js +28 -5
- package/dist/react.js.map +1 -1
- package/dist/react.mjs +28 -5
- package/dist/react.mjs.map +1 -1
- package/dist/runtime/nuxt.plugin.client.js +28 -5
- package/dist/runtime/nuxt.plugin.client.js.map +1 -1
- package/dist/runtime/nuxt.plugin.client.mjs +28 -5
- package/dist/runtime/nuxt.plugin.client.mjs.map +1 -1
- package/dist/svelte.d.mts +1 -1
- package/dist/svelte.d.ts +1 -1
- package/dist/svelte.js +28 -5
- package/dist/svelte.js.map +1 -1
- package/dist/svelte.mjs +28 -5
- package/dist/svelte.mjs.map +1 -1
- package/dist/vue.d.mts +1 -1
- package/dist/vue.d.ts +1 -1
- package/dist/vue.js +28 -5
- package/dist/vue.js.map +1 -1
- package/dist/vue.mjs +28 -5
- package/dist/vue.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -2483,22 +2483,45 @@ var ModelsAPI = class {
|
|
|
2483
2483
|
* `cancelled` with the error. Errors of the start itself (an invalid job, a refused model or
|
|
2484
2484
|
* consent, no fitting model) reject. The end can arrive before the start answers; it is kept
|
|
2485
2485
|
* until then.
|
|
2486
|
+
*
|
|
2487
|
+
* Aborting `signal` asks to cancel the job, which then ends as `cancelled`; a job that had
|
|
2488
|
+
* already ended keeps its actual end. A signal that is already aborted rejects with its reason
|
|
2489
|
+
* and starts no job. If the cancel request fails, the run rejects with that error and the job
|
|
2490
|
+
* keeps running on the host; if it reports an unknown job, the run rejects with an error.
|
|
2486
2491
|
*/
|
|
2487
|
-
async runAsync(job) {
|
|
2492
|
+
async runAsync(job, options = {}) {
|
|
2493
|
+
const { signal } = options;
|
|
2494
|
+
if (signal?.aborted) throw signal.reason;
|
|
2488
2495
|
const ended = /* @__PURE__ */ new Map();
|
|
2489
2496
|
let waiting = null;
|
|
2490
2497
|
const unsubscribe = this.onCompleted((completion) => {
|
|
2491
2498
|
if (waiting && completion.jobId === waiting.jobId) waiting.resolve(completion);
|
|
2492
2499
|
else ended.set(completion.jobId, completion);
|
|
2493
2500
|
});
|
|
2501
|
+
let detach = () => {
|
|
2502
|
+
};
|
|
2494
2503
|
try {
|
|
2495
2504
|
const { jobId } = await this.startAsync(job);
|
|
2496
|
-
return await new Promise((resolve) => {
|
|
2505
|
+
return await new Promise((resolve, reject) => {
|
|
2497
2506
|
const early = ended.get(jobId);
|
|
2498
|
-
if (early) resolve(early);
|
|
2499
|
-
|
|
2507
|
+
if (early) return resolve(early);
|
|
2508
|
+
waiting = { jobId, resolve };
|
|
2509
|
+
if (!signal) return;
|
|
2510
|
+
const cancel = async () => {
|
|
2511
|
+
try {
|
|
2512
|
+
if (!await this.cancelAsync(jobId)) {
|
|
2513
|
+
reject(new Error("The model job could not be cancelled"));
|
|
2514
|
+
}
|
|
2515
|
+
} catch (error) {
|
|
2516
|
+
reject(error);
|
|
2517
|
+
}
|
|
2518
|
+
};
|
|
2519
|
+
if (signal.aborted) return cancel();
|
|
2520
|
+
signal.addEventListener("abort", cancel, { once: true });
|
|
2521
|
+
detach = () => signal.removeEventListener("abort", cancel);
|
|
2500
2522
|
});
|
|
2501
2523
|
} finally {
|
|
2524
|
+
detach();
|
|
2502
2525
|
unsubscribe();
|
|
2503
2526
|
}
|
|
2504
2527
|
}
|