web-push-notifications 3.109.0 → 3.113.1

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.
@@ -0,0 +1,48 @@
1
+ import { type ElementPickerRequest } from '../../core/elementPickerRequest';
2
+ export declare const ELEMENT_PICKER_MESSAGE_SOURCE = "pushwoosh-element-picker";
3
+ export type ElementPickerMessage = {
4
+ source: typeof ELEMENT_PICKER_MESSAGE_SOURCE;
5
+ type: 'ready' | 'selected' | 'cancelled';
6
+ nonce: string;
7
+ applicationCode: string;
8
+ selector?: string;
9
+ };
10
+ /** Highlights the element under the cursor and sends the selector of the clicked one back to the Control Panel. */
11
+ export declare class ElementPicker {
12
+ private readonly request;
13
+ private readonly getApplicationCode;
14
+ private readonly win;
15
+ private readonly host;
16
+ private readonly shadow;
17
+ private readonly hoverBox;
18
+ private readonly matchBoxes;
19
+ private readonly toolbar;
20
+ private hovered;
21
+ private picked;
22
+ private similar;
23
+ private result;
24
+ private stops;
25
+ constructor(request: ElementPickerRequest, getApplicationCode: () => string, win?: Window);
26
+ run(): void;
27
+ private get connected();
28
+ private post;
29
+ private box;
30
+ private listen;
31
+ private pick;
32
+ private unpick;
33
+ private toParent;
34
+ private compute;
35
+ private place;
36
+ private position;
37
+ private render;
38
+ private matchesText;
39
+ private noSelectorText;
40
+ private buttons;
41
+ private toggleSimilar;
42
+ private copy;
43
+ private submit;
44
+ private cancel;
45
+ /** Removes the overlay and gives the page its clicks back; the request stays for the next page. */
46
+ stop(): void;
47
+ private finish;
48
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,16 @@
1
+ import { type ElementPickerMode } from '../../core/elementPickerRequest';
2
+ export type BuiltSelector = {
3
+ selector: string;
4
+ count: number;
5
+ };
6
+ export declare function isStableToken(value: string): boolean;
7
+ export declare function isSimpleSelector(selector: string, element: Element): boolean;
8
+ /** Selectors of the element itself, most stable first; each is one compound selector without combinators. */
9
+ export declare function ownCandidates(element: Element): Array<string>;
10
+ /**
11
+ * The most stable selector that matches only this element. `embedded` keeps to one compound selector,
12
+ * the only form an inline campaign accepts, and returns null when the element has none.
13
+ */
14
+ export declare function buildSelector(element: Element, mode: ElementPickerMode, root?: Document): BuiltSelector | null;
15
+ /** A class selector shared by this element and its look-alikes ("every Add to cart button"), or null. */
16
+ export declare function buildSimilarSelector(element: Element, root?: Document): BuiltSelector | null;
@@ -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;
@@ -26,6 +26,8 @@ export declare class WebPopupsWidget implements IWebPopupsPublicApi {
26
26
  private autoShowEnabled;
27
27
  private colorScheme;
28
28
  private isNavigationSubscribed;
29
+ private stopClickWatch;
30
+ private badClickSelectors;
29
31
  private openPopupsCount;
30
32
  private bodyOverflowBeforeLock;
31
33
  /** Built once from `pw`: the device-API side of the choice/rating/subscribe slots. */
@@ -89,23 +91,32 @@ export declare class WebPopupsWidget implements IWebPopupsPublicApi {
89
91
  private canAutoDisplay;
90
92
  /** What any kind needs to show by itself; kind-specific checks stay with the caller. */
91
93
  private isAutoEligible;
94
+ /** The conditions a popup shown without show() passes, whatever its trigger. */
95
+ private passesDisplayConditions;
92
96
  /** What a waiting or queued popup must still pass: the page, the push permission and the countdown. */
93
97
  private isStillEligible;
94
98
  private isAutoTrigger;
99
+ private watchClickTriggers;
100
+ private onTriggerClick;
101
+ private isClickTarget;
102
+ private arm;
95
103
  private armDelay;
104
+ private armScrollDepth;
105
+ private armExitIntent;
106
+ private enqueueArmed;
96
107
  /**
97
108
  * VISIT is reported once per page load, when the popup is armed for the
98
109
  * current page — the same moment as before the queue existed.
99
110
  */
100
111
  private recordVisit;
101
- /** Ordering: shorter delay first, then the order the server returned them. */
112
+ /** Ordering: shorter delay first (SCROLL and EXIT_INTENT count as 0), then the order the server returned them. */
102
113
  private insertIntoQueue;
103
114
  /**
104
115
  * Return waiting and queued popups that stopped matching the page or the push permission, or whose countdown
105
116
  * passed, to `idle`; a returning visitor re-arms them with a full delay.
106
117
  */
107
118
  private releaseUnmatchedPending;
108
- /** Clear an entry's armed timer and queue slot, leaving its state to the caller. */
119
+ /** Clear an entry's armed timer, trigger listeners and queue slot, leaving its state to the caller. */
109
120
  private detachFromAutoPipeline;
110
121
  /** Show the head of the queue if the display slot is free. */
111
122
  private drain;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,5 @@
1
+ import { type WebPopup } from './types';
2
+ export declare const isClickWebPopup: (popup: WebPopup) => boolean;
3
+ /** Whether the click landed on an element matching the selector or inside one. Throws on an invalid selector. */
4
+ export declare function clickMatchesSelector(event: Event, selector: string): boolean;
5
+ export declare function watchClicks(onClick: (event: MouseEvent) => void): () => void;
@@ -0,0 +1,6 @@
1
+ import { type WebPopup } from './types';
2
+ export type ExitIntentFormFactor = 'DESKTOP' | 'MOBILE';
3
+ /** Returns whether a popup is now on screen: Back that showed nothing must still leave. */
4
+ export type ExitIntentHandler = () => boolean;
5
+ export declare const isExitIntentWebPopup: (popup: WebPopup) => boolean;
6
+ export declare function watchExitIntent(formFactor: ExitIntentFormFactor, onExit: ExitIntentHandler): () => void;
@@ -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' | 'EXIT_INTENT' | 'CLICK' | (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 listeners of a waiting SCROLL or EXIT_INTENT popup. */
96
+ stopTriggerWatch: (() => 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[];