@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
@@ -58,7 +58,7 @@ declare const SHELL_EVENTS: {
58
58
  };
59
59
  type ShellEvent = typeof SHELL_EVENTS[keyof typeof SHELL_EVENTS];
60
60
  /**
61
- * Events for background mail-poll watches (`mail.startWatchingAsync`).
61
+ * Events for background mail watches (`mail.startWatchingAsync`).
62
62
  */
63
63
  declare const MAIL_EVENTS: {
64
64
  /** A watched mailbox's UID high-water mark advanced — new mail arrived. */
@@ -58,7 +58,7 @@ declare const SHELL_EVENTS: {
58
58
  };
59
59
  type ShellEvent = typeof SHELL_EVENTS[keyof typeof SHELL_EVENTS];
60
60
  /**
61
- * Events for background mail-poll watches (`mail.startWatchingAsync`).
61
+ * Events for background mail watches (`mail.startWatchingAsync`).
62
62
  */
63
63
  declare const MAIL_EVENTS: {
64
64
  /** A watched mailbox's UID high-water mark advanced — new mail arrived. */
package/dist/vue.d.mts CHANGED
@@ -1,7 +1,7 @@
1
- import { H as HaexVaultSdk, S as StorageAPI } from './client-GdCi-m2s.mjs';
1
+ import { H as HaexVaultSdk, S as StorageAPI } from './client-Cx4ZyQFL.mjs';
2
2
  import * as drizzle_orm_sqlite_proxy from 'drizzle-orm/sqlite-proxy';
3
3
  import { Ref } from 'vue';
4
- import { H as HaexHubConfig } from './types-Ba4G6ZpC.mjs';
4
+ import { H as HaexHubConfig } from './types-BwFKGH70.mjs';
5
5
 
6
6
  /**
7
7
  * Vue 3 composable for HaexVault SDK
package/dist/vue.d.ts CHANGED
@@ -1,7 +1,7 @@
1
- import { H as HaexVaultSdk, S as StorageAPI } from './client-C6pEREPM.js';
1
+ import { H as HaexVaultSdk, S as StorageAPI } from './client-CD5QZi7F.js';
2
2
  import * as drizzle_orm_sqlite_proxy from 'drizzle-orm/sqlite-proxy';
3
3
  import { Ref } from 'vue';
4
- import { H as HaexHubConfig } from './types-Ba4G6ZpC.js';
4
+ import { H as HaexHubConfig } from './types-BwFKGH70.js';
5
5
 
6
6
  /**
7
7
  * Vue 3 composable for HaexVault SDK
package/dist/vue.js CHANGED
@@ -8,9 +8,9 @@ var __esm = (fn, res) => function __init() {
8
8
  return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
9
9
  };
10
10
 
11
- // 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
11
+ // 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
12
12
  var init_cjs_shims = __esm({
13
- "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"() {
13
+ "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"() {
14
14
  }
15
15
  });
16
16
 
@@ -718,6 +718,8 @@ var SHELL_COMMANDS = {
718
718
  create: "extension_shell_create",
719
719
  /** Write data to a shell session's stdin */
720
720
  write: "extension_shell_write",
721
+ /** Acknowledge `shell:output` events handed on (backpressure; sent by the SDK itself) */
722
+ ack: "extension_shell_ack",
721
723
  /** Resize a shell session's terminal */
722
724
  resize: "extension_shell_resize",
723
725
  /** Close a shell session */
@@ -760,9 +762,9 @@ var MAIL_COMMANDS = {
760
762
  sendMessage: "extension_mail_send_message",
761
763
  /** Build RFC822 bytes without sending (for Drafts via APPEND) */
762
764
  buildRfc822: "extension_mail_build_rfc822",
763
- /** Start (or replace) a background poll watch for an account/mailbox */
765
+ /** Start (or replace) a background new-mail watch for an account/mailbox */
764
766
  startWatch: "extension_mail_start_watch",
765
- /** Stop a background poll watch */
767
+ /** Stop a background new-mail watch */
766
768
  stopWatch: "extension_mail_stop_watch"
767
769
  };
768
770
 
@@ -1660,9 +1662,44 @@ var SpacesAPI = class {
1660
1662
 
1661
1663
  // src/api/shell.ts
1662
1664
  init_cjs_shims();
1665
+ var NOT_SUPPORTED = 8e3;
1666
+ function isUnsupported(error) {
1667
+ if (error?.code === NOT_SUPPORTED) return true;
1668
+ return typeof error === "string" && /\bcommand (\S+ )?not found\b/i.test(error);
1669
+ }
1663
1670
  var ShellAPI = class {
1664
1671
  constructor(sdk) {
1665
1672
  this.sdk = sdk;
1673
+ /** `shell:output` events per session handed on but not yet acknowledged. */
1674
+ this.unacknowledged = /* @__PURE__ */ new Map();
1675
+ this.flushScheduled = false;
1676
+ /** The host does not know `extension_shell_ack` (it reads output without backpressure). */
1677
+ this.ackUnsupported = false;
1678
+ this.sdk.on(SHELL_EVENTS.OUTPUT, (event) => this.acknowledge(event));
1679
+ }
1680
+ /**
1681
+ * Backpressure: the host keeps reading a shell's output only while this frame has few
1682
+ * events open, so a shell that writes fast waits instead of flooding the page. The SDK
1683
+ * acknowledges every event once the listeners have had it, in one request per session and
1684
+ * task.
1685
+ */
1686
+ acknowledge(event) {
1687
+ const sessionId = event.data?.sessionId;
1688
+ if (this.ackUnsupported || typeof sessionId !== "string") return;
1689
+ this.unacknowledged.set(sessionId, (this.unacknowledged.get(sessionId) ?? 0) + 1);
1690
+ if (this.flushScheduled) return;
1691
+ this.flushScheduled = true;
1692
+ queueMicrotask(() => this.flushAcknowledgements());
1693
+ }
1694
+ flushAcknowledgements() {
1695
+ this.flushScheduled = false;
1696
+ const counts = [...this.unacknowledged];
1697
+ this.unacknowledged.clear();
1698
+ for (const [sessionId, count] of counts) {
1699
+ this.sdk.request(SHELL_COMMANDS.ack, { sessionId, count }).catch((error) => {
1700
+ if (isUnsupported(error)) this.ackUnsupported = true;
1701
+ });
1702
+ }
1666
1703
  }
1667
1704
  /**
1668
1705
  * List available shell environments on the host system.
@@ -1880,22 +1917,29 @@ var MailAPI = class {
1880
1917
  });
1881
1918
  }
1882
1919
  /**
1883
- * Start (or replace) a background poll watch for `accountId`/`mailboxName`.
1884
- * The host resolves credentials itself from `accountId` — no `ImapConfig`
1885
- * is passed in. Requires `mail` permission with action `poll` on the
1886
- * account's IMAP host (prompted on first call, same as `fetch`/`send`).
1920
+ * Start (or replace) a background watch for `accountId`/`mailboxName`.
1921
+ * Requires `mail` permission with action `poll` on the account's IMAP
1922
+ * host (`imap.host` when passed; prompted on first call, same as
1923
+ * `fetch`/`send`).
1924
+ *
1925
+ * Pass the account's `imap` config, as for every other mail call: the host
1926
+ * keeps the credentials in memory for as long as the watch runs and never
1927
+ * stores them. Hosts that wait with IMAP IDLE are told about new mail by the
1928
+ * server; `intervalSeconds` (clamped host-side to [30, 3600]) is the polling
1929
+ * interval for servers without IDLE. Listen for results via `onNewMessages`.
1887
1930
  *
1888
- * `intervalSeconds` is clamped host-side to [30, 3600]. Listen for
1889
- * results via `onNewMessages`.
1931
+ * `imap` is optional for hosts that resolve the credentials themselves from
1932
+ * `accountId`; holzi requires it.
1890
1933
  */
1891
- async startWatchingAsync(accountId, mailboxName, intervalSeconds) {
1934
+ async startWatchingAsync(accountId, mailboxName, intervalSeconds, imap) {
1892
1935
  return this.client.request(MAIL_COMMANDS.startWatch, {
1893
1936
  accountId,
1894
1937
  mailboxName,
1895
- intervalSeconds
1938
+ intervalSeconds,
1939
+ imap
1896
1940
  });
1897
1941
  }
1898
- /** Stop a background poll watch previously started with `startWatchingAsync`. */
1942
+ /** Stop a background watch previously started with `startWatchingAsync`. */
1899
1943
  async stopWatchingAsync(accountId, mailboxName) {
1900
1944
  return this.client.request(MAIL_COMMANDS.stopWatch, {
1901
1945
  accountId,