web-push-notifications 3.108.1 → 3.110.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.
@@ -18,7 +18,7 @@ export declare class WebPopupsWidget implements IWebPopupsPublicApi {
18
18
  private readonly shownPlacements;
19
19
  /** The application has placements, or a postEvent response brought some: pull them on every navigation. */
20
20
  private placementsActive;
21
- /** Codes whose delay has elapsed, waiting for the display slot. */
21
+ /** Codes whose delay has elapsed or scroll depth is reached, waiting for the display slot. */
22
22
  private readonly queue;
23
23
  /** The single popup on screen, if any. */
24
24
  private visible;
@@ -92,20 +92,23 @@ export declare class WebPopupsWidget implements IWebPopupsPublicApi {
92
92
  /** What a waiting or queued popup must still pass: the page, the push permission and the countdown. */
93
93
  private isStillEligible;
94
94
  private isAutoTrigger;
95
+ private arm;
95
96
  private armDelay;
97
+ private armScrollDepth;
98
+ private enqueueArmed;
96
99
  /**
97
100
  * VISIT is reported once per page load, when the popup is armed for the
98
101
  * current page — the same moment as before the queue existed.
99
102
  */
100
103
  private recordVisit;
101
- /** Ordering: shorter delay first, then the order the server returned them. */
104
+ /** Ordering: shorter delay first (a SCROLL popup counts as 0), then the order the server returned them. */
102
105
  private insertIntoQueue;
103
106
  /**
104
107
  * Return waiting and queued popups that stopped matching the page or the push permission, or whose countdown
105
108
  * passed, to `idle`; a returning visitor re-arms them with a full delay.
106
109
  */
107
110
  private releaseUnmatchedPending;
108
- /** Clear an entry's armed timer and queue slot, leaving its state to the caller. */
111
+ /** Clear an entry's armed timer, scroll listeners and queue slot, leaving its state to the caller. */
109
112
  private detachFromAutoPipeline;
110
113
  /** Show the head of the queue if the display slot is free. */
111
114
  private drain;
@@ -0,0 +1,5 @@
1
+ import { type WebPopup } from './types';
2
+ export declare const isScrollWebPopup: (popup: WebPopup) => boolean;
3
+ /** The depth a SCROLL popup waits for, 0–100: absent, negative or not a number shows it at once. */
4
+ export declare function scrollThreshold(popup: WebPopup): number;
5
+ export declare function watchScrollDepth(threshold: number, onReached: () => void): (() => void) | null;
@@ -43,7 +43,7 @@ export type PageRule = {
43
43
  path: string;
44
44
  operator: PageRuleOperator;
45
45
  };
46
- export type WebPopupTriggerType = 'PAGE_LOAD' | 'API' | (string & {});
46
+ export type WebPopupTriggerType = 'PAGE_LOAD' | 'API' | 'SCROLL' | (string & {});
47
47
  export type WebPopupDisplayKind = 'POPUP' | 'EMBEDDED' | (string & {});
48
48
  export type WebPopup = {
49
49
  code: string;
@@ -56,6 +56,7 @@ export type WebPopup = {
56
56
  delay: number;
57
57
  frequency: 'ONCE' | 'ONCE_PER_SESSION' | 'EVERY_VISIT';
58
58
  trigger_type?: WebPopupTriggerType;
59
+ scroll_depth?: number;
59
60
  kind?: WebPopupDisplayKind;
60
61
  css_selector?: string;
61
62
  push_permission_status?: string;
@@ -63,8 +64,8 @@ export type WebPopup = {
63
64
  /**
64
65
  * Where a popup is in the automatic display pipeline for the current page load.
65
66
  *
66
- * `idle` -> `waiting` (delay timer armed) -> `queued` (delay served, waiting for
67
- * the display slot) -> `visible` -> `done`. Navigation can send a `waiting` or
67
+ * `idle` -> `waiting` (delay timer or scroll depth armed) -> `queued` (delay served or depth
68
+ * reached, waiting for the display slot) -> `visible` -> `done`. Navigation can send a `waiting` or
68
69
  * `queued` popup back to `idle` when its page rules stop matching.
69
70
  */
70
71
  export type WebPopupEntryState = 'idle' | 'waiting' | 'queued' | 'visible' | 'done';
@@ -91,6 +92,8 @@ export type WebPopupEntry = {
91
92
  passedFrequency: boolean;
92
93
  /** Armed delay timer while state === 'waiting'. */
93
94
  timeoutId: number | null;
95
+ /** Removes the scroll depth listeners of a waiting SCROLL popup. */
96
+ stopScrollWatch: (() => void) | null;
94
97
  /** VISIT already reported for this page load. */
95
98
  visitRecorded: boolean;
96
99
  };
@@ -107,9 +110,9 @@ export type VisibleWebPopup = {
107
110
  export type WebPopupsPublicState = {
108
111
  /** Code of the popup on screen, if any. */
109
112
  visible: string | null;
110
- /** Delay served, waiting for the display slot. */
113
+ /** Delay served or scroll depth reached, waiting for the display slot. */
111
114
  queued: string[];
112
- /** Delay timer armed for the current page. */
115
+ /** Delay timer or scroll depth armed for the current page. */
113
116
  waiting: string[];
114
117
  /** Every code the server returned for this device. */
115
118
  available: string[];