@haex-space/vault-sdk 4.0.0 → 4.1.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.
Files changed (42) hide show
  1. package/dist/cli/index.mjs.map +1 -1
  2. package/dist/{client-C6pEREPM.d.ts → client-CD5QZi7F.d.ts} +29 -10
  3. package/dist/{client-GdCi-m2s.d.mts → client-Cx4ZyQFL.d.mts} +29 -10
  4. package/dist/index.d.mts +9 -6
  5. package/dist/index.d.ts +9 -6
  6. package/dist/index.js +57 -13
  7. package/dist/index.js.map +1 -1
  8. package/dist/index.mjs +56 -12
  9. package/dist/index.mjs.map +1 -1
  10. package/dist/node.d.mts +1 -1
  11. package/dist/node.d.ts +1 -1
  12. package/dist/node.mjs +1 -1
  13. package/dist/node.mjs.map +1 -1
  14. package/dist/nuxt.js +1 -1
  15. package/dist/nuxt.js.map +1 -1
  16. package/dist/react.d.mts +2 -2
  17. package/dist/react.d.ts +2 -2
  18. package/dist/react.js +57 -13
  19. package/dist/react.js.map +1 -1
  20. package/dist/react.mjs +56 -12
  21. package/dist/react.mjs.map +1 -1
  22. package/dist/runtime/nuxt.plugin.client.d.mts +2 -2
  23. package/dist/runtime/nuxt.plugin.client.d.ts +2 -2
  24. package/dist/runtime/nuxt.plugin.client.js +55 -11
  25. package/dist/runtime/nuxt.plugin.client.js.map +1 -1
  26. package/dist/runtime/nuxt.plugin.client.mjs +55 -11
  27. package/dist/runtime/nuxt.plugin.client.mjs.map +1 -1
  28. package/dist/svelte.d.mts +2 -2
  29. package/dist/svelte.d.ts +2 -2
  30. package/dist/svelte.js +57 -13
  31. package/dist/svelte.js.map +1 -1
  32. package/dist/svelte.mjs +56 -12
  33. package/dist/svelte.mjs.map +1 -1
  34. package/dist/{types-Ba4G6ZpC.d.mts → types-BwFKGH70.d.mts} +1 -1
  35. package/dist/{types-Ba4G6ZpC.d.ts → types-BwFKGH70.d.ts} +1 -1
  36. package/dist/vue.d.mts +2 -2
  37. package/dist/vue.d.ts +2 -2
  38. package/dist/vue.js +57 -13
  39. package/dist/vue.js.map +1 -1
  40. package/dist/vue.mjs +56 -12
  41. package/dist/vue.mjs.map +1 -1
  42. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -12,9 +12,9 @@ var __export = (target, all) => {
12
12
  __defProp(target, name, { get: all[name], enumerable: true });
13
13
  };
14
14
 
15
- // node_modules/.pnpm/tsup@8.5.1_jiti@2.7.0_postcss@8.5.28_typescript@6.0.3_yaml@2.9.0/node_modules/tsup/assets/cjs_shims.js
15
+ // node_modules/.pnpm/tsup@8.5.1_jiti@2.7.0_postcss@8.5.29_typescript@6.0.3_yaml@2.9.0/node_modules/tsup/assets/cjs_shims.js
16
16
  var init_cjs_shims = __esm({
17
- "node_modules/.pnpm/tsup@8.5.1_jiti@2.7.0_postcss@8.5.28_typescript@6.0.3_yaml@2.9.0/node_modules/tsup/assets/cjs_shims.js"() {
17
+ "node_modules/.pnpm/tsup@8.5.1_jiti@2.7.0_postcss@8.5.29_typescript@6.0.3_yaml@2.9.0/node_modules/tsup/assets/cjs_shims.js"() {
18
18
  }
19
19
  });
20
20
 
@@ -1111,6 +1111,8 @@ var SHELL_COMMANDS = {
1111
1111
  create: "extension_shell_create",
1112
1112
  /** Write data to a shell session's stdin */
1113
1113
  write: "extension_shell_write",
1114
+ /** Acknowledge `shell:output` events handed on (backpressure; sent by the SDK itself) */
1115
+ ack: "extension_shell_ack",
1114
1116
  /** Resize a shell session's terminal */
1115
1117
  resize: "extension_shell_resize",
1116
1118
  /** Close a shell session */
@@ -1153,9 +1155,9 @@ var MAIL_COMMANDS = {
1153
1155
  sendMessage: "extension_mail_send_message",
1154
1156
  /** Build RFC822 bytes without sending (for Drafts via APPEND) */
1155
1157
  buildRfc822: "extension_mail_build_rfc822",
1156
- /** Start (or replace) a background poll watch for an account/mailbox */
1158
+ /** Start (or replace) a background new-mail watch for an account/mailbox */
1157
1159
  startWatch: "extension_mail_start_watch",
1158
- /** Stop a background poll watch */
1160
+ /** Stop a background new-mail watch */
1159
1161
  stopWatch: "extension_mail_stop_watch"
1160
1162
  };
1161
1163
 
@@ -2080,9 +2082,44 @@ var SpacesAPI = class {
2080
2082
 
2081
2083
  // src/api/shell.ts
2082
2084
  init_cjs_shims();
2085
+ var NOT_SUPPORTED = 8e3;
2086
+ function isUnsupported(error) {
2087
+ if (error?.code === NOT_SUPPORTED) return true;
2088
+ return typeof error === "string" && /\bcommand (\S+ )?not found\b/i.test(error);
2089
+ }
2083
2090
  var ShellAPI = class {
2084
2091
  constructor(sdk) {
2085
2092
  this.sdk = sdk;
2093
+ /** `shell:output` events per session handed on but not yet acknowledged. */
2094
+ this.unacknowledged = /* @__PURE__ */ new Map();
2095
+ this.flushScheduled = false;
2096
+ /** The host does not know `extension_shell_ack` (it reads output without backpressure). */
2097
+ this.ackUnsupported = false;
2098
+ this.sdk.on(SHELL_EVENTS.OUTPUT, (event) => this.acknowledge(event));
2099
+ }
2100
+ /**
2101
+ * Backpressure: the host keeps reading a shell's output only while this frame has few
2102
+ * events open, so a shell that writes fast waits instead of flooding the page. The SDK
2103
+ * acknowledges every event once the listeners have had it, in one request per session and
2104
+ * task.
2105
+ */
2106
+ acknowledge(event) {
2107
+ const sessionId = event.data?.sessionId;
2108
+ if (this.ackUnsupported || typeof sessionId !== "string") return;
2109
+ this.unacknowledged.set(sessionId, (this.unacknowledged.get(sessionId) ?? 0) + 1);
2110
+ if (this.flushScheduled) return;
2111
+ this.flushScheduled = true;
2112
+ queueMicrotask(() => this.flushAcknowledgements());
2113
+ }
2114
+ flushAcknowledgements() {
2115
+ this.flushScheduled = false;
2116
+ const counts = [...this.unacknowledged];
2117
+ this.unacknowledged.clear();
2118
+ for (const [sessionId, count] of counts) {
2119
+ this.sdk.request(SHELL_COMMANDS.ack, { sessionId, count }).catch((error) => {
2120
+ if (isUnsupported(error)) this.ackUnsupported = true;
2121
+ });
2122
+ }
2086
2123
  }
2087
2124
  /**
2088
2125
  * List available shell environments on the host system.
@@ -2300,22 +2337,29 @@ var MailAPI = class {
2300
2337
  });
2301
2338
  }
2302
2339
  /**
2303
- * Start (or replace) a background poll watch for `accountId`/`mailboxName`.
2304
- * The host resolves credentials itself from `accountId` — no `ImapConfig`
2305
- * is passed in. Requires `mail` permission with action `poll` on the
2306
- * account's IMAP host (prompted on first call, same as `fetch`/`send`).
2340
+ * Start (or replace) a background watch for `accountId`/`mailboxName`.
2341
+ * Requires `mail` permission with action `poll` on the account's IMAP
2342
+ * host (`imap.host` when passed; prompted on first call, same as
2343
+ * `fetch`/`send`).
2344
+ *
2345
+ * Pass the account's `imap` config, as for every other mail call: the host
2346
+ * keeps the credentials in memory for as long as the watch runs and never
2347
+ * stores them. Hosts that wait with IMAP IDLE are told about new mail by the
2348
+ * server; `intervalSeconds` (clamped host-side to [30, 3600]) is the polling
2349
+ * interval for servers without IDLE. Listen for results via `onNewMessages`.
2307
2350
  *
2308
- * `intervalSeconds` is clamped host-side to [30, 3600]. Listen for
2309
- * results via `onNewMessages`.
2351
+ * `imap` is optional for hosts that resolve the credentials themselves from
2352
+ * `accountId`; holzi requires it.
2310
2353
  */
2311
- async startWatchingAsync(accountId, mailboxName, intervalSeconds) {
2354
+ async startWatchingAsync(accountId, mailboxName, intervalSeconds, imap) {
2312
2355
  return this.client.request(MAIL_COMMANDS.startWatch, {
2313
2356
  accountId,
2314
2357
  mailboxName,
2315
- intervalSeconds
2358
+ intervalSeconds,
2359
+ imap
2316
2360
  });
2317
2361
  }
2318
- /** Stop a background poll watch previously started with `startWatchingAsync`. */
2362
+ /** Stop a background watch previously started with `startWatchingAsync`. */
2319
2363
  async stopWatchingAsync(accountId, mailboxName) {
2320
2364
  return this.client.request(MAIL_COMMANDS.stopWatch, {
2321
2365
  accountId,