/** * @oxpulse/chat-widget — Reconnector + BackoffStrategy (W2.2 slice 5). */ import { isAuthError } from '../utils/auth.js'; /** * Exponential backoff: attempt 0=0ms, 1=1s, 2=2s, 3=4s, 4=8s (cap). * Attempt 5+: 8s ±20% jitter. */ export declare class BackoffStrategy { delayMs(attempt: number): number; shouldGiveUp(attempt: number): boolean; reset(): void; shouldRetryOnAuthError(): boolean; } /** * CM1: SubscribeFn accepts an onError callback for async error surfacing. * Sync throws are also caught via try/catch in #scheduleAttempt. */ export type SubscribeFn = (roomId: string, onError: (err: unknown) => void) => (() => void); export interface ReconnectorOptions { container: HTMLElement; host: EventTarget; signal?: AbortSignal; /** BCP-47 tag or an already-resolved Locale. Optional — defaults via resolveLocale(). */ lang?: string; } /** * Manages reconnect banners and retry loops for the chat widget. * * notifyAuthExpired() → role="alert" aria-live="assertive" (action required) * notifyNetworkLost(n) → role="status" aria-live="polite" (auto-retry) * notifyReconnected() → brief toast, auto-hides after 2s * notifyGivenUp() → "Reconnect manually" button * clear() → removes banner + stops loop * destroy() → full cleanup: timers, banner, window listeners * * Design M1: Banner DOM node is created once and mutated in-place across state * transitions so aria-live region survives — screen readers receive all announcements. */ export declare class Reconnector { #private; constructor(opts: ReconnectorOptions); notifyAuthExpired(): void; notifyNetworkLost(attempt: number): void; notifyReconnected(): void; notifyGivenUp(): void; clear(): void; /** * Full cleanup: timers, banner DOM, window listeners, abort signal listener. * CM2: Called by AbortSignal abort event (once) and by element disconnectedCallback. */ destroy(): void; startReconnectLoop(subscribeFn: SubscribeFn, roomId: string): void; /** * Genuine teardown: cancel the pending retry timer AND tear down the live * subscription. Callers that want the subscription gone — clear() (room-change / * reset), destroy(), notifyAuthExpired() (the current sub is invalid). A caller * that only wants to stop the retry timer (notifyReconnected) uses * #cancelRetryTimer() instead — tearing down here would kill the fresh sub. */ stopReconnectLoop(): void; } /** @internal Not part of the package's public API surface; not re-exported from index.ts. Kept exported for cross-file use within the package. */ export { isAuthError }; //# sourceMappingURL=reconnect.d.ts.map