@danxbot/ui 7.9.3 → 7.9.4

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/index.js CHANGED
@@ -49375,8 +49375,50 @@ class T6 {
49375
49375
  () => this.transport.observeConnection((t) => this.onConnectionState(t)),
49376
49376
  () => {
49377
49377
  }
49378
- ), this.timer = setInterval(() => this.tick(), this.options.keepaliveIntervalMs));
49378
+ ), this.timer = setInterval(() => this.tick(), this.options.keepaliveIntervalMs), typeof document < "u" && document.addEventListener("visibilitychange", this.handleVisibilityChange), typeof window < "u" && window.addEventListener("pageshow", this.handlePageShow));
49379
49379
  }
49380
+ /**
49381
+ * The document became visible again, or the page was restored from the
49382
+ * back/forward cache — either way, a gap of UNKNOWN length just ended.
49383
+ *
49384
+ * `pusher:subscription_succeeded`/`state_change` (what `onConnectionState`
49385
+ * listens for) is the transport TELLING us the socket dropped and came
49386
+ * back. It is not the only way a gap happens: the OS suspending the
49387
+ * machine, or the browser freezing a backgrounded tab under memory
49388
+ * pressure, pauses this process's OWN timers along with everything else —
49389
+ * including whatever ping/pong loop the transport uses to notice its own
49390
+ * connection died. A transport that never got to run its detection code
49391
+ * has nothing to report, so `connectionState()` can read "connected"
49392
+ * throughout a gap the socket did not actually survive, and `tick()`'s own
49393
+ * `isDead()` check — which trusts that string — has nothing to catch.
49394
+ *
49395
+ * Pusher has no event replay. Broadcasting is also gated server-side on a
49396
+ * short-TTL registration (`PusherSubscriptionService`, 300s) that a long
49397
+ * enough gap can outlive on its own. Either way, "did we actually miss
49398
+ * anything" has no answer worth computing — the same reasoning
49399
+ * `onConnectionState`'s reconnect branch already acts on — so becoming
49400
+ * visible again is treated exactly like a reconnect: every entry is
49401
+ * resubscribed (which the SubscriptionRegistry itself dedupes against
49402
+ * one that is still genuinely healthy — a resubscribe is bounded, cheap,
49403
+ * and correctness-preserving even when it turns out to have been
49404
+ * unnecessary), and the epoch bumps on each success, which is what
49405
+ * drives every mounted read (`reads/refetch.ts`'s `onEpoch`) to reissue
49406
+ * the request it already made.
49407
+ */
49408
+ onResume() {
49409
+ if (!this.disposed) {
49410
+ for (const t of this.entries.values())
49411
+ t.subscribers !== 0 && (this.clearRetry(t), t.attempts = 0, this.subscribeEntry(t, !0));
49412
+ this.notifyHealth();
49413
+ }
49414
+ }
49415
+ handleVisibilityChange = () => {
49416
+ typeof document < "u" && document.visibilityState === "visible" && this.onResume();
49417
+ };
49418
+ /** `event.persisted` is a bfcache restore — a full page resume with no `visibilitychange` of its own. */
49419
+ handlePageShow = (t) => {
49420
+ t.persisted && this.onResume();
49421
+ };
49380
49422
  /**
49381
49423
  * Stop the timers. REVERSIBLE, and it keeps every entry and every channel.
49382
49424
  *
@@ -49393,7 +49435,7 @@ class T6 {
49393
49435
  * switch is the one place either of those happens, and it has its own method.
49394
49436
  */
49395
49437
  stop() {
49396
- this.started = !1, this.timer !== null && (clearInterval(this.timer), this.timer = null), this.stopConnectionObserver?.(), this.stopConnectionObserver = null;
49438
+ this.started = !1, this.timer !== null && (clearInterval(this.timer), this.timer = null), this.stopConnectionObserver?.(), this.stopConnectionObserver = null, typeof document < "u" && document.removeEventListener("visibilitychange", this.handleVisibilityChange), typeof window < "u" && window.removeEventListener("pageshow", this.handlePageShow);
49397
49439
  for (const t of this.entries.values()) this.clearRetry(t);
49398
49440
  }
49399
49441
  /**
@@ -49577,9 +49619,7 @@ class T6 {
49577
49619
  this.diagnose({ kind: "disconnected", message: t }), this.notifyHealth();
49578
49620
  return;
49579
49621
  }
49580
- for (const n of this.entries.values())
49581
- n.subscribers !== 0 && (this.clearRetry(n), n.attempts = 0, this.subscribeEntry(n, !0));
49582
- this.notifyHealth();
49622
+ this.onResume();
49583
49623
  }
49584
49624
  }
49585
49625
  /* --- Channels and delivery ----------------------------------------------- */