UNPKG

web-push-notifications

Version:
89 lines (88 loc) 3.44 kB
import { type IWebPopupsPublicApi, type WebPopupsPublicState } from './types'; import { type Pushwoosh } from '../../core/Pushwoosh'; export declare class WebPopupsWidget implements IWebPopupsPublicApi { private readonly pw; private isRecurringVisitor; /** Every popup the server returned, keyed by code. Never pruned. */ private readonly entries; /** Codes whose delay has elapsed, waiting for the display slot. */ private readonly queue; /** The single popup on screen, if any. */ private visible; private drainTimeoutId; private autoShowEnabled; private isNavigationSubscribed; private openPopupsCount; private bodyOverflowBeforeLock; private readyResolve; private readonly readyPromise; constructor(pw: Pushwoosh); run(): Promise<void>; /** * Show a popup immediately, ignoring EVERY display condition: delay, page * rules, device_type, visitors_type, frequency capping and trigger_type. * An already visible popup is closed to make room. * * Stats and frequency bookkeeping are recorded exactly as for an automatic * display. Never rejects: resolves false and logs the reason on failure. */ show(code: string): Promise<boolean>; /** * Hide the visible popup, optionally only if it is the given one. * Returns false when nothing was hidden. */ hide(code?: string): boolean; /** * Hide the visible popup and dismiss everything still pending for this page * load. show() keeps working afterwards. */ hideAll(): boolean; isVisible(code?: string): boolean; getVisibleCode(): string | null; getAvailableCodes(): Array<string>; getState(): WebPopupsPublicState; /** * Resolve the entry's renderable content, fetching it at most once. A failed * fetch clears the memo so a later show() can retry. */ private ensureContent; private loadContent; private loadedCodes; private renderForCurrentPage; private canAutoDisplay; private isAutoTrigger; private armDelay; /** * VISIT is reported once per page load, when the popup is armed for the * current page — the same moment as before the queue existed. */ private recordVisit; /** Ordering: shorter delay first, then the order the server returned them. */ private insertIntoQueue; /** * Release popups whose page rules stopped matching, both the ones still * waiting out their delay and the ones already queued. They return to `idle` * and are re-armed with a full delay if the visitor comes back. */ private releaseUnmatchedPending; /** Clear an entry's armed timer and queue slot, leaving its state to the caller. */ private detachFromAutoPipeline; /** Show the head of the queue if the display slot is free. */ private drain; private scheduleDrain; private cancelScheduledDrain; private present; private renderSubscriptionForm; private lockBodyScroll; private unlockBodyScroll; private subscribeToNavigation; private checkStrongCondition; private checkSoftCondition; private checkCanBeShownByDeviceTypeCondition; private checkCanBeShownByFrequencyCondition; private checkCanBeShownByMatchingPagesCondition; private matchPageRule; private checkCanBeShownByVisitorsTypeCondition; private markAsShown; private getSessionStorageKey; }