@bobfrankston/rmfmail 1.1.29 → 1.1.31

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.
@@ -7217,6 +7217,12 @@ var NativeImapClient = class {
7217
7217
  _connected = false;
7218
7218
  idleTag = null;
7219
7219
  idleCallback = null;
7220
+ /** Fires when the SELECTED mailbox loses messages while parked in IDLE —
7221
+ * an EXISTS decrease, or an unsolicited `* EXPUNGE` / `* VANISHED`
7222
+ * (RFC 5465 NOTIFY SELECTED MessageExpunge). Lets the caller reconcile
7223
+ * a server-side deletion in real time instead of waiting for the next
7224
+ * periodic poll. Distinct from `idleCallback` (new mail only). */
7225
+ idleExpungeCallback = null;
7220
7226
  idleRefreshTimer = null;
7221
7227
  /** RFC 5465 NOTIFY: fires on unsolicited STATUS responses for non-selected
7222
7228
  * mailboxes (the server pushes these when the client has issued NOTIFY
@@ -7834,8 +7840,9 @@ var NativeImapClient = class {
7834
7840
  }
7835
7841
  }
7836
7842
  // ── IDLE ──
7837
- async startIdle(onNewMail) {
7843
+ async startIdle(onNewMail, onExpunge) {
7838
7844
  this.idleCallback = onNewMail;
7845
+ this.idleExpungeCallback = onExpunge ?? null;
7839
7846
  this.idleStopped = false;
7840
7847
  const beginIdleCycle = async () => {
7841
7848
  const tag = nextTag();
@@ -7862,6 +7869,7 @@ var NativeImapClient = class {
7862
7869
  const tag = this.idleTag;
7863
7870
  this.idleTag = null;
7864
7871
  this.idleCallback = null;
7872
+ this.idleExpungeCallback = null;
7865
7873
  if (tag) {
7866
7874
  const waitTag = this.waitForTagged(tag);
7867
7875
  try {
@@ -8306,9 +8314,20 @@ var NativeImapClient = class {
8306
8314
  const newCount = count - this.mailboxInfo.exists;
8307
8315
  this.mailboxInfo.exists = count;
8308
8316
  this.idleCallback(newCount);
8317
+ } else if (count < this.mailboxInfo.exists) {
8318
+ this.mailboxInfo.exists = count;
8319
+ if (this.idleExpungeCallback)
8320
+ this.idleExpungeCallback();
8309
8321
  }
8310
8322
  continue;
8311
8323
  }
8324
+ if (this.idleTag && resp.tag === "*" && (resp.type === "EXPUNGE" || resp.type === "VANISHED")) {
8325
+ if (this.mailboxInfo.exists > 0)
8326
+ this.mailboxInfo.exists--;
8327
+ if (this.idleExpungeCallback)
8328
+ this.idleExpungeCallback();
8329
+ continue;
8330
+ }
8312
8331
  if (this.idleTag && resp.tag === "*" && resp.type === "STATUS" && this.onMailboxStatus) {
8313
8332
  const parsed = parseStatusResponseFull(resp.text);
8314
8333
  if (parsed) {
@@ -8828,7 +8847,7 @@ var CompatImapClient = class {
8828
8847
  this.native.onMailboxStatus = opts.onMailboxStatus;
8829
8848
  if (opts?.notifySpec)
8830
8849
  await this.native.notify(opts.notifySpec);
8831
- return this.native.startIdle(onNew);
8850
+ return this.native.startIdle(onNew, opts?.onExpunge);
8832
8851
  }
8833
8852
  /** Copy a message to another server (cross-account) */
8834
8853
  async moveMessageToServer(msg, fromMailbox, targetClient, toMailbox) {