web-push-notifications 3.92.0 → 3.98.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.
- package/CHANGELOG.md +116 -0
- package/core/Pushwoosh.d.ts +19 -0
- package/core/Pushwoosh.types.d.ts +2 -0
- package/core/__tests__/loadWebPopupsWidget.test.d.ts +1 -0
- package/core/__tests__/reportPushPermissionChange.test.d.ts +1 -0
- package/core/__tests__/settlesWithin.test.d.ts +1 -0
- package/core/constants.d.ts +3 -0
- package/core/events.types.d.ts +3 -0
- package/core/functions.d.ts +2 -0
- package/core/recommendationsLoader.d.ts +5 -0
- package/core/resolveInitParams.d.ts +7 -0
- package/modules/Api/Api.d.ts +12 -3
- package/modules/ApiClient/ApiClient.d.ts +4 -1
- package/modules/ApiClient/ApiClient.types.d.ts +8 -2
- package/modules/Data/Data.d.ts +5 -0
- package/modules/FeatureFlags/FeatureFlag.d.ts +12 -0
- package/modules/FeatureFlags/FeatureFlags.d.ts +57 -0
- package/modules/FeatureFlags/FeatureFlags.types.d.ts +19 -0
- package/modules/FeatureFlags/__tests__/FeatureFlags.test.d.ts +1 -0
- package/modules/FeatureFlags/featureFlagsUrl.d.ts +1 -0
- package/modules/InboxMessagesPublic.d.ts +3 -1
- package/modules/Recommendations/Recommendations.d.ts +30 -0
- package/modules/Recommendations/Recommendations.types.d.ts +55 -0
- package/modules/Recommendations/__tests__/Recommendations.test.d.ts +1 -0
- package/npm.js +1 -1
- package/npm.js.map +1 -1
- package/package.json +2 -2
- package/pushwoosh-widget-recommendations.d.ts +1 -0
- package/service-worker.js +1 -1
- package/service-worker.js.map +1 -1
- package/services/PushService/__tests__/pushPermissionStatus.test.d.ts +1 -0
- package/services/PushService/pushPermissionStatus.d.ts +3 -0
- package/widget-inbox.js +1 -1
- package/widget-inbox.js.map +1 -1
- package/widget-recommendations.d.ts +1 -0
- package/widget-recommendations.js +2 -0
- package/widget-recommendations.js.map +1 -0
- package/widget-subscription-button.js.map +1 -1
- package/widget-subscription.js.map +1 -1
- package/widget-web-popups.js +1 -1
- package/widget-web-popups.js.map +1 -1
- package/widgets/Recommendations/RecommendationsWidget.d.ts +20 -0
- package/widgets/Recommendations/__tests__/RecommendationsWidget.test.d.ts +1 -0
- package/widgets/Recommendations/styles.d.ts +1 -0
- package/widgets/WebPopups/EmbeddedWebPopups.d.ts +37 -0
- package/widgets/WebPopups/WebPopupsWidget.d.ts +15 -2
- package/widgets/WebPopups/__tests__/WebPopupsWidget.test.d.ts +1 -0
- package/widgets/WebPopups/__tests__/embedded.test.d.ts +1 -0
- package/widgets/WebPopups/__tests__/embeddedRenderer.test.d.ts +1 -0
- package/widgets/WebPopups/constants.d.ts +1 -0
- package/widgets/WebPopups/embeddedRenderer.d.ts +4 -0
- package/widgets/WebPopups/types.d.ts +8 -1
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { type Recommendations } from '../../modules/Recommendations/Recommendations';
|
|
2
|
+
import { type IRecommendationsRequest } from '../../modules/Recommendations/Recommendations.types';
|
|
3
|
+
export declare const CONTAINER_SELECTOR = "[data-pw-recommendations]";
|
|
4
|
+
export type TRecommendationsState = 'loading' | 'ready' | 'empty' | 'error';
|
|
5
|
+
/** The block's request, read from its data attributes. */
|
|
6
|
+
export declare function readRequest(el: HTMLElement): IRecommendationsRequest;
|
|
7
|
+
export declare class RecommendationsWidget {
|
|
8
|
+
private readonly recommendations;
|
|
9
|
+
private readonly root;
|
|
10
|
+
private readonly generations;
|
|
11
|
+
private observer?;
|
|
12
|
+
constructor(recommendations: Recommendations, root?: Document);
|
|
13
|
+
run(): void;
|
|
14
|
+
stop(): void;
|
|
15
|
+
render(el: HTMLElement): Promise<void>;
|
|
16
|
+
private build;
|
|
17
|
+
private card;
|
|
18
|
+
private setState;
|
|
19
|
+
private onMutations;
|
|
20
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const RECOMMENDATIONS_STYLES = "\n:host { display: block; font-family: var(--pw-reco-font, inherit); }\n.title { margin: 0 0 12px; font-size: 1.25em; font-weight: 600; }\n.grid {\n display: grid;\n gap: 16px;\n grid-template-columns: repeat(var(--pw-reco-columns, auto-fill), minmax(140px, 1fr));\n}\n@media (max-width: 600px) {\n .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }\n}\n.card { display: flex; flex-direction: column; gap: 6px; color: inherit; text-decoration: none; }\n.image {\n width: 100%;\n aspect-ratio: 1;\n object-fit: cover;\n border-radius: var(--pw-reco-radius, 8px);\n background: rgba(0, 0, 0, 0.04);\n}\n.name { overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }\n.price { color: var(--pw-reco-accent, currentColor); font-weight: 600; }\n.old { margin-left: 6px; font-weight: 400; text-decoration: line-through; opacity: 0.6; }\n";
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { type WebPopupParams } from '@pushwoosh/websdk-common/web-popups';
|
|
2
|
+
import { type WebPopup, type WebPopupEntry, type WebPopupShowTrigger } from './types';
|
|
3
|
+
export declare const isEmbeddedWebPopup: (popup: WebPopup) => boolean;
|
|
4
|
+
/** What the blocks need from the widget: page rules, rendering and stats live there. */
|
|
5
|
+
export type EmbeddedWebPopupsDeps = {
|
|
6
|
+
matchesPage: (popup: WebPopup) => boolean;
|
|
7
|
+
render: (container: HTMLElement, params: WebPopupParams) => void;
|
|
8
|
+
unmount: (container: HTMLElement) => void;
|
|
9
|
+
recordVisit: (entry: WebPopupEntry) => void;
|
|
10
|
+
recordImpression: (code: string) => void;
|
|
11
|
+
recordFormViews: (code: string, params: WebPopupParams) => void;
|
|
12
|
+
dispatchShown: (code: string, trigger: WebPopupShowTrigger) => void;
|
|
13
|
+
};
|
|
14
|
+
/** EMBEDDED campaigns render inside the site's own elements: no delay, queue,
|
|
15
|
+
* frequency or display slot — every eligible one renders. */
|
|
16
|
+
export declare class EmbeddedWebPopups {
|
|
17
|
+
private readonly deps;
|
|
18
|
+
/** Blocks on the page, keyed by campaign code. */
|
|
19
|
+
private readonly blocks;
|
|
20
|
+
/** Campaigns already seen (IMPRESSION + form views reported) during this page load. */
|
|
21
|
+
private readonly viewed;
|
|
22
|
+
/** Campaigns whose auto placement was already skipped with a log during this page load. */
|
|
23
|
+
private readonly autoSkipLogged;
|
|
24
|
+
constructor(deps: EmbeddedWebPopupsDeps);
|
|
25
|
+
/** Bring the blocks in line with the current page; called on load and on every navigation. */
|
|
26
|
+
syncWithPage(entries: Iterable<WebPopupEntry>, canAutoShow: (entry: WebPopupEntry) => boolean): void;
|
|
27
|
+
/** Render on demand; false when there is no element to render into. */
|
|
28
|
+
show(entry: WebPopupEntry, content: WebPopupParams): boolean;
|
|
29
|
+
private place;
|
|
30
|
+
private firstBlockAfter;
|
|
31
|
+
private remove;
|
|
32
|
+
private findContainer;
|
|
33
|
+
private logSkip;
|
|
34
|
+
private reportShown;
|
|
35
|
+
private watchFirstView;
|
|
36
|
+
private reportViewed;
|
|
37
|
+
}
|
|
@@ -5,6 +5,8 @@ export declare class WebPopupsWidget implements IWebPopupsPublicApi {
|
|
|
5
5
|
private isRecurringVisitor;
|
|
6
6
|
/** Every popup the server returned, keyed by code. Never pruned. */
|
|
7
7
|
private readonly entries;
|
|
8
|
+
/** Contents shown by their own code, outside of any campaign; never auto-displayed. */
|
|
9
|
+
private readonly contentEntries;
|
|
8
10
|
/** Codes whose delay has elapsed, waiting for the display slot. */
|
|
9
11
|
private readonly queue;
|
|
10
12
|
/** The single popup on screen, if any. */
|
|
@@ -17,6 +19,8 @@ export declare class WebPopupsWidget implements IWebPopupsPublicApi {
|
|
|
17
19
|
private bodyOverflowBeforeLock;
|
|
18
20
|
/** Built once from `pw`: the device-API side of the choice/rating/subscribe slots. */
|
|
19
21
|
private readonly submitHandlers;
|
|
22
|
+
/** EMBEDDED campaigns: blocks inside page elements, outside the popup pipeline. */
|
|
23
|
+
private readonly embedded;
|
|
20
24
|
private readyResolve;
|
|
21
25
|
private readonly readyPromise;
|
|
22
26
|
constructor(pw: Pushwoosh);
|
|
@@ -26,8 +30,10 @@ export declare class WebPopupsWidget implements IWebPopupsPublicApi {
|
|
|
26
30
|
* rules, device_type, visitors_type, frequency capping and trigger_type.
|
|
27
31
|
* An already visible popup is closed to make room.
|
|
28
32
|
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
33
|
+
* `code` is a campaign code or, failing that, a content code, which records no stats or frequency.
|
|
34
|
+
* EMBEDDED: renders into the first css_selector match (false when none), leaves the visible popup alone
|
|
35
|
+
* and stays across SPA navigation until its element leaves the page; see public/index.d.ts.
|
|
36
|
+
* Never rejects: resolves false and logs the reason on failure.
|
|
31
37
|
*/
|
|
32
38
|
show(code: string): Promise<boolean>;
|
|
33
39
|
/**
|
|
@@ -44,15 +50,20 @@ export declare class WebPopupsWidget implements IWebPopupsPublicApi {
|
|
|
44
50
|
getVisibleCode(): string | null;
|
|
45
51
|
getAvailableCodes(): Array<string>;
|
|
46
52
|
getState(): WebPopupsPublicState;
|
|
53
|
+
private createEntry;
|
|
54
|
+
private getContentEntry;
|
|
47
55
|
/**
|
|
48
56
|
* Resolve the entry's renderable content, fetching it at most once. A failed
|
|
49
57
|
* fetch clears the memo so a later show() can retry.
|
|
50
58
|
*/
|
|
51
59
|
private ensureContent;
|
|
52
60
|
private loadContent;
|
|
61
|
+
private shouldPrefetchContent;
|
|
53
62
|
private loadedCodes;
|
|
54
63
|
private renderForCurrentPage;
|
|
55
64
|
private canAutoDisplay;
|
|
65
|
+
/** What any kind needs to show by itself; kind-specific checks stay with the caller. */
|
|
66
|
+
private isAutoEligible;
|
|
56
67
|
private isAutoTrigger;
|
|
57
68
|
private armDelay;
|
|
58
69
|
/**
|
|
@@ -75,6 +86,7 @@ export declare class WebPopupsWidget implements IWebPopupsPublicApi {
|
|
|
75
86
|
private scheduleDrain;
|
|
76
87
|
private cancelScheduledDrain;
|
|
77
88
|
private present;
|
|
89
|
+
private recordSubscriptionFormViews;
|
|
78
90
|
private lockBodyScroll;
|
|
79
91
|
private unlockBodyScroll;
|
|
80
92
|
private subscribeToNavigation;
|
|
@@ -86,6 +98,7 @@ export declare class WebPopupsWidget implements IWebPopupsPublicApi {
|
|
|
86
98
|
private checkCanBeShownByMatchingPagesCondition;
|
|
87
99
|
private matchPageRule;
|
|
88
100
|
private checkCanBeShownByVisitorsTypeCondition;
|
|
101
|
+
private recordPopupShownEvent;
|
|
89
102
|
private markAsShown;
|
|
90
103
|
private getSessionStorageKey;
|
|
91
104
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -2,4 +2,5 @@ export declare const WEB_POPUPS_WIDGET_NAMESPACE = "pushwoosh-web-popups";
|
|
|
2
2
|
export declare const WEB_POPUPS_LOG_PREFIX = "[WebPopups]";
|
|
3
3
|
export declare const POPUP_HOST_Z_INDEX = 2147483647;
|
|
4
4
|
export declare const QUEUE_GAP_MS = 400;
|
|
5
|
+
export declare const EMBEDDED_ORDER_ATTRIBUTE = "data-pushwoosh-embedded-order";
|
|
5
6
|
export declare const SUBSCRIPTION_FORMS_API_URL = "https://subscription-form.svc-nue.pushwoosh.com/api/v1";
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { type WebPopupColorSchemePref, type WebPopupParams } from '@pushwoosh/websdk-common/web-popups';
|
|
2
|
+
import { type WebPopupSubmitHandlers } from './renderer';
|
|
3
|
+
/** Mount an EMBEDDED campaign inline; unmount it with `unmountWebPopup`. */
|
|
4
|
+
export declare const renderEmbeddedWebPopup: (container: HTMLElement, params: WebPopupParams, handlers: WebPopupSubmitHandlers, colorScheme?: WebPopupColorSchemePref) => void;
|
|
@@ -24,6 +24,7 @@ export type PageRule = {
|
|
|
24
24
|
operator: PageRuleOperator;
|
|
25
25
|
};
|
|
26
26
|
export type WebPopupTriggerType = 'PAGE_LOAD' | 'API' | (string & {});
|
|
27
|
+
export type WebPopupDisplayKind = 'POPUP' | 'EMBEDDED' | (string & {});
|
|
27
28
|
export type WebPopup = {
|
|
28
29
|
code: string;
|
|
29
30
|
popup_form_content_code: string;
|
|
@@ -35,6 +36,8 @@ export type WebPopup = {
|
|
|
35
36
|
delay: number;
|
|
36
37
|
frequency: 'ONCE' | 'ONCE_PER_SESSION' | 'EVERY_VISIT';
|
|
37
38
|
trigger_type?: WebPopupTriggerType;
|
|
39
|
+
kind?: WebPopupDisplayKind;
|
|
40
|
+
css_selector?: string;
|
|
38
41
|
};
|
|
39
42
|
/**
|
|
40
43
|
* Where a popup is in the automatic display pipeline for the current page load.
|
|
@@ -46,6 +49,8 @@ export type WebPopup = {
|
|
|
46
49
|
export type WebPopupEntryState = 'idle' | 'waiting' | 'queued' | 'visible' | 'done';
|
|
47
50
|
/** Everything the widget knows about one popup, for the whole page load. */
|
|
48
51
|
export type WebPopupEntry = {
|
|
52
|
+
/** 'content': a bare popup content code opened via show(), e.g. from the inbox; no campaign behind it. */
|
|
53
|
+
kind: 'campaign' | 'content';
|
|
49
54
|
popup: WebPopup;
|
|
50
55
|
/** Index in the server response — the ordering tiebreaker after `delay`. */
|
|
51
56
|
order: number;
|
|
@@ -54,8 +59,10 @@ export type WebPopupEntry = {
|
|
|
54
59
|
content: WebPopupParams | null;
|
|
55
60
|
/** In-flight fetch, memoised so run() and show() never duplicate a request. */
|
|
56
61
|
loading: Promise<WebPopupParams | null> | null;
|
|
57
|
-
/** device_type + visitors_type
|
|
62
|
+
/** device_type + visitors_type, evaluated exactly once in run(). */
|
|
58
63
|
passedStrongConditions: boolean;
|
|
64
|
+
/** Frequency capping, evaluated exactly once in run(); only POPUP obeys it. */
|
|
65
|
+
passedFrequency: boolean;
|
|
59
66
|
/** Armed delay timer while state === 'waiting'. */
|
|
60
67
|
timeoutId: number | null;
|
|
61
68
|
/** VISIT already reported for this page load. */
|