@haex-space/vault-sdk 3.5.0 → 3.6.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/dist/svelte.mjs CHANGED
@@ -417,6 +417,10 @@ var SHELL_EVENTS = {
417
417
  /** Shell session has exited */
418
418
  EXIT: "shell:exit"
419
419
  };
420
+ var MAIL_EVENTS = {
421
+ /** A watched mailbox's UID high-water mark advanced — new mail arrived. */
422
+ NEW_MESSAGES: "mail:new-messages"
423
+ };
420
424
 
421
425
  // src/types.ts
422
426
  var DEFAULT_TIMEOUT = 3e4;
@@ -689,7 +693,11 @@ var MAIL_COMMANDS = {
689
693
  /** SMTP send. Returns the assigned Message-ID. */
690
694
  sendMessage: "extension_mail_send_message",
691
695
  /** Build RFC822 bytes without sending (for Drafts via APPEND) */
692
- buildRfc822: "extension_mail_build_rfc822"
696
+ buildRfc822: "extension_mail_build_rfc822",
697
+ /** Start (or replace) a background poll watch for an account/mailbox */
698
+ startWatch: "extension_mail_start_watch",
699
+ /** Stop a background poll watch */
700
+ stopWatch: "extension_mail_stop_watch"
693
701
  };
694
702
 
695
703
  // src/commands/notifications.ts
@@ -1787,6 +1795,41 @@ var MailAPI = class {
1787
1795
  message
1788
1796
  });
1789
1797
  }
1798
+ /**
1799
+ * Start (or replace) a background poll watch for `accountId`/`mailboxName`.
1800
+ * The host resolves credentials itself from `accountId` — no `ImapConfig`
1801
+ * is passed in. Requires `mail` permission with action `poll` on the
1802
+ * account's IMAP host (prompted on first call, same as `fetch`/`send`).
1803
+ *
1804
+ * `intervalSeconds` is clamped host-side to [30, 3600]. Listen for
1805
+ * results via `onNewMessages`.
1806
+ */
1807
+ async startWatchingAsync(accountId, mailboxName, intervalSeconds) {
1808
+ return this.client.request(MAIL_COMMANDS.startWatch, {
1809
+ accountId,
1810
+ mailboxName,
1811
+ intervalSeconds
1812
+ });
1813
+ }
1814
+ /** Stop a background poll watch previously started with `startWatchingAsync`. */
1815
+ async stopWatchingAsync(accountId, mailboxName) {
1816
+ return this.client.request(MAIL_COMMANDS.stopWatch, {
1817
+ accountId,
1818
+ mailboxName
1819
+ });
1820
+ }
1821
+ /**
1822
+ * Register a callback for new-mail notifications from any active watch.
1823
+ * `event.data` is a `MailNewMessagesEvent` — check `accountId`/`mailboxName`
1824
+ * before refreshing if watching more than one account.
1825
+ */
1826
+ onNewMessages(callback) {
1827
+ this.client.on(MAIL_EVENTS.NEW_MESSAGES, callback);
1828
+ }
1829
+ /** Remove a new-mail callback registered with `onNewMessages`. */
1830
+ offNewMessages(callback) {
1831
+ this.client.off(MAIL_EVENTS.NEW_MESSAGES, callback);
1832
+ }
1790
1833
  };
1791
1834
 
1792
1835
  // src/api/notifications.ts
@@ -1989,6 +2032,7 @@ async function setupTauriEventListeners(ctx, log, onEvent, onContextChange) {
1989
2032
  EXTERNAL_EVENTS.REQUEST,
1990
2033
  EXTERNAL_EVENTS.ACTION_REQUEST,
1991
2034
  NOTIFICATION_EVENTS.CLICK,
2035
+ MAIL_EVENTS.NEW_MESSAGES,
1992
2036
  ...Object.values(LOCALSEND_EVENTS)
1993
2037
  ]) {
1994
2038
  await forwardEvent(listen, log, onEvent, listenOptions, eventName);