@braze/web-sdk 5.5.0 → 5.6.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.
- package/index.d.ts +109 -7
- package/package.json +1 -1
- package/shared-lib/encoding-utils.js +1 -1
- package/shared-lib/event-types.js +33 -31
- package/shared-lib/guid.js +3 -3
- package/shared-lib/indexed-db-adapter.js +20 -20
- package/shared-lib/logger.js +18 -18
- package/shared-lib/supported-options.js +24 -24
- package/src/Banner/banner-factory.js +14 -0
- package/src/Banner/banner-provider-factory.js +19 -0
- package/src/Banner/banner-provider.js +198 -0
- package/src/Banner/banner.js +30 -0
- package/src/Banner/display/banner-to-html.js +57 -0
- package/src/Banner/display/destroy-banner-html.js +7 -0
- package/src/Banner/display/detect-banner-impressions.js +28 -0
- package/src/Banner/get-all-banners.js +13 -0
- package/src/Banner/get-banner.js +19 -0
- package/src/Banner/index.js +7 -0
- package/src/Banner/log-banner-click.js +22 -0
- package/src/Banner/log-banner-impressions.js +31 -0
- package/src/Banner/request-banners-refresh.js +35 -0
- package/src/Banner/subscribe-to-banners-updates.js +23 -0
- package/src/Banner/types.js +1 -0
- package/src/Banner/ui/insert-banner.js +24 -0
- package/src/Card/card-manager-factory.js +10 -10
- package/src/Card/card-manager.js +54 -52
- package/src/Card/display/card-display.js +77 -91
- package/src/Card/log-card-click.js +6 -6
- package/src/Card/log-card-dismissal.js +6 -5
- package/src/Card/log-card-impressions.js +11 -11
- package/src/Card/models/captioned-image.js +21 -21
- package/src/Card/models/card.js +99 -99
- package/src/Card/models/classic-card.js +21 -21
- package/src/Card/models/control-card.js +11 -11
- package/src/Card/models/image-only.js +19 -19
- package/src/Card/util/card-factory.js +58 -58
- package/src/ContentCards/content-cards-provider-factory.js +14 -14
- package/src/ContentCards/content-cards-provider.js +261 -263
- package/src/ContentCards/content-cards.js +5 -5
- package/src/ContentCards/get-cached-content-cards.js +3 -3
- package/src/ContentCards/request-content-cards-refresh.js +4 -4
- package/src/ContentCards/subscribe-to-content-cards-updates.js +13 -13
- package/src/ContentCards/ui/hide-content-cards.js +7 -7
- package/src/ContentCards/ui/show-content-cards.js +52 -52
- package/src/ContentCards/ui/toggle-content-cards.js +4 -4
- package/src/Core/add-sdk-metadata.js +9 -9
- package/src/Core/change-user.js +14 -14
- package/src/Core/destroy.js +3 -3
- package/src/Core/disable-sdk.js +13 -13
- package/src/Core/enable-sdk.js +9 -9
- package/src/Core/get-device-id.js +10 -10
- package/src/Core/get-user.js +2 -2
- package/src/Core/handle-braze-action.js +53 -53
- package/src/Core/initialize.js +2 -2
- package/src/Core/is-disabled.js +2 -2
- package/src/Core/is-initialized.js +2 -2
- package/src/Core/log-custom-event.js +27 -27
- package/src/Core/log-purchase.js +38 -38
- package/src/Core/open-session.js +18 -18
- package/src/Core/remove-all-subscriptions.js +2 -2
- package/src/Core/remove-subscription.js +3 -3
- package/src/Core/request-immediate-data-flush.js +5 -5
- package/src/Core/set-logger.js +2 -2
- package/src/Core/set-sdk-authentication-signature.js +6 -6
- package/src/Core/subscribe-to-sdk-authentication-failures.js +5 -5
- package/src/Core/toggle-logging.js +2 -2
- package/src/Core/wipe-data.js +10 -10
- package/src/FeatureFlags/feature-flag-factory.js +13 -13
- package/src/FeatureFlags/feature-flag.js +10 -10
- package/src/FeatureFlags/feature-flags-provider-factory.js +13 -14
- package/src/FeatureFlags/feature-flags-provider.js +118 -116
- package/src/FeatureFlags/get-all-feature-flags.js +10 -10
- package/src/FeatureFlags/get-feature-flag.js +9 -9
- package/src/FeatureFlags/log-feature-flag-impression.js +18 -18
- package/src/FeatureFlags/refresh-feature-flags.js +6 -6
- package/src/FeatureFlags/subscribe-to-feature-flags-updates.js +9 -9
- package/src/Feed/feed-provider-factory.js +12 -12
- package/src/Feed/feed-provider.js +59 -59
- package/src/Feed/feed.js +4 -4
- package/src/Feed/get-cached-feed.js +3 -3
- package/src/Feed/log-feed-displayed.js +5 -5
- package/src/Feed/request-feed-refresh.js +3 -3
- package/src/Feed/subscribe-to-feed-updates.js +4 -4
- package/src/Feed/ui/hide-feed.js +5 -5
- package/src/Feed/ui/show-feed.js +53 -53
- package/src/Feed/ui/toggle-feed.js +4 -4
- package/src/InAppMessage/defer-in-app-message.js +9 -9
- package/src/InAppMessage/display/html-message-display-utils.js +18 -164
- package/src/InAppMessage/display/html-message-to-html.js +55 -62
- package/src/InAppMessage/display/in-app-message-to-html.js +74 -74
- package/src/InAppMessage/display/modal-utils.js +17 -17
- package/src/InAppMessage/get-deferred-in-app-message.js +2 -2
- package/src/InAppMessage/in-app-message-factory.js +61 -61
- package/src/InAppMessage/in-app-message-manager-factory.js +9 -9
- package/src/InAppMessage/in-app-message-manager.js +158 -156
- package/src/InAppMessage/log-in-app-message-button-click.js +16 -16
- package/src/InAppMessage/log-in-app-message-click.js +11 -11
- package/src/InAppMessage/log-in-app-message-html-click.js +15 -15
- package/src/InAppMessage/log-in-app-message-impression.js +6 -6
- package/src/InAppMessage/models/control-message.js +15 -8
- package/src/InAppMessage/models/full-screen-message.js +34 -34
- package/src/InAppMessage/models/html-message.js +23 -23
- package/src/InAppMessage/models/in-app-message-button.js +10 -10
- package/src/InAppMessage/models/in-app-message.js +155 -155
- package/src/InAppMessage/models/modal-message.js +33 -33
- package/src/InAppMessage/models/slide-up-message.js +35 -35
- package/src/InAppMessage/models/templated-in-app-message.js +8 -8
- package/src/InAppMessage/subscribe-to-in-app-message.js +3 -3
- package/src/InAppMessage/ui/automatically-show-in-app-messages.js +6 -6
- package/src/InAppMessage/ui/show-in-app-message.js +103 -103
- package/src/Push/is-push-blocked.js +2 -2
- package/src/Push/is-push-permission-granted.js +2 -2
- package/src/Push/is-push-supported.js +2 -2
- package/src/Push/push-manager-factory.js +25 -25
- package/src/Push/push-manager.js +176 -176
- package/src/Push/request-push-permission.js +8 -8
- package/src/Push/unregister-push.js +4 -4
- package/src/Push/utils/push-utils.js +4 -4
- package/src/User/user-manager.js +38 -38
- package/src/User/user.js +95 -92
- package/src/common/base-feed.js +9 -9
- package/src/common/base-provider.js +2 -2
- package/src/common/constants.js +1 -0
- package/src/common/detect-impression.js +18 -0
- package/src/common/event-logger.js +22 -22
- package/src/common/feed-display.js +53 -53
- package/src/index.js +1 -0
- package/src/l10n/l10n-manager-factory.js +15 -15
- package/src/l10n/l10n-manager.js +4 -4
- package/src/managers/auth-manager.js +38 -38
- package/src/managers/braze-instance.js +212 -212
- package/src/managers/device-manager.js +30 -30
- package/src/managers/network-manager.js +234 -235
- package/src/managers/server-config-manager.js +99 -83
- package/src/managers/session-manager.js +46 -50
- package/src/managers/storage-manager-factory.js +13 -13
- package/src/managers/storage-manager.js +182 -180
- package/src/managers/subscription-manager.js +12 -12
- package/src/managers/utils.js +4 -4
- package/src/models/backend-errors.js +5 -5
- package/src/models/braze-event.js +9 -9
- package/src/models/device.js +2 -2
- package/src/models/identifier.js +15 -15
- package/src/models/push-token.js +10 -10
- package/src/models/request-result.js +4 -4
- package/src/models/server-config.js +38 -34
- package/src/request-controller.js +228 -228
- package/src/triggers/models/custom-event-data.js +5 -5
- package/src/triggers/models/custom-event-property-data.js +6 -6
- package/src/triggers/models/filter-set.js +10 -10
- package/src/triggers/models/filter.js +66 -66
- package/src/triggers/models/in-app-message-click-data.js +10 -10
- package/src/triggers/models/purchase-data.js +2 -2
- package/src/triggers/models/purchase-property-data.js +6 -6
- package/src/triggers/models/push-click-data.js +5 -5
- package/src/triggers/models/trigger-condition.js +46 -46
- package/src/triggers/models/trigger-events.js +4 -4
- package/src/triggers/models/trigger.js +33 -33
- package/src/triggers/triggers-provider-factory.js +16 -16
- package/src/triggers/triggers-provider.js +156 -154
- package/src/ui/js/attach-css.js +7 -7
- package/src/ui/js/banner-css.js +11 -0
- package/src/ui/js/feed-css.js +4 -4
- package/src/ui/js/iam-css.js +4 -4
- package/src/ui/js/index.js +1 -0
- package/src/ui/js/load-font-awesome.js +8 -8
- package/src/util/base-device-parser.js +9 -9
- package/src/util/braze-actions.js +32 -32
- package/src/util/browser-detector.js +31 -30
- package/src/util/client-hints-parser.js +10 -10
- package/src/util/code-utils.js +5 -5
- package/src/util/component-utils.js +5 -5
- package/src/util/deprecation-utils.js +3 -3
- package/src/util/device-constants.js +1 -1
- package/src/util/dom-utils.js +13 -13
- package/src/util/html-display-utils.js +158 -0
- package/src/util/key-codes.js +1 -1
- package/src/util/net.js +21 -21
- package/src/util/request-header-utils.js +31 -30
- package/src/util/string-utils.js +2 -2
- package/src/util/user-agent-parser.js +18 -18
- package/src/util/validation-utils.js +89 -85
- package/src/util/window-utils.js +3 -3
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { InternalEventTypes as
|
|
1
|
+
import r from "../managers/braze-instance.js";
|
|
2
|
+
import { InternalEventTypes as dr } from "../../shared-lib/index.js";
|
|
3
3
|
export function logFeedDisplayed() {
|
|
4
|
-
var
|
|
5
|
-
if (
|
|
6
|
-
return null === (
|
|
4
|
+
var e;
|
|
5
|
+
if (r.rr())
|
|
6
|
+
return null === (e = r.g()) || void 0 === e ? void 0 : e.zr(dr.Fr).ss;
|
|
7
7
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
1
|
+
import r from "../managers/braze-instance.js";
|
|
2
|
+
import ie from "./feed-provider-factory.js";
|
|
3
3
|
export function requestFeedRefresh() {
|
|
4
|
-
if (
|
|
4
|
+
if (r.rr()) return ie.m().zi();
|
|
5
5
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
export function subscribeToFeedUpdates(
|
|
4
|
-
if (
|
|
1
|
+
import r from "../managers/braze-instance.js";
|
|
2
|
+
import ie from "./feed-provider-factory.js";
|
|
3
|
+
export function subscribeToFeedUpdates(e) {
|
|
4
|
+
if (r.rr()) return ie.m().Fs(e);
|
|
5
5
|
}
|
package/src/Feed/ui/hide-feed.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { destroyFeedHtml as
|
|
1
|
+
import r from "../../managers/braze-instance.js";
|
|
2
|
+
import { destroyFeedHtml as ee } from "../../common/feed-display.js";
|
|
3
3
|
export function destroyFeed() {
|
|
4
|
-
if (!
|
|
5
|
-
const
|
|
6
|
-
for (let
|
|
4
|
+
if (!r.rr()) return;
|
|
5
|
+
const e = document.querySelectorAll(".ab-feed");
|
|
6
|
+
for (let o = 0; o < e.length; o++) ee(e[o]);
|
|
7
7
|
}
|
package/src/Feed/ui/show-feed.js
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
import
|
|
1
|
+
import r, { OPTIONS as z } from "../../managers/braze-instance.js";
|
|
2
2
|
import {
|
|
3
|
-
destroyFeedHtml as
|
|
4
|
-
detectFeedImpressions as
|
|
5
|
-
feedToHtml as
|
|
6
|
-
LAST_REQUESTED_REFRESH_DATA_ATTRIBUTE as
|
|
7
|
-
refreshFeed as
|
|
8
|
-
registerFeedSubscriptionId as
|
|
9
|
-
updateFeedCards as
|
|
3
|
+
destroyFeedHtml as ee,
|
|
4
|
+
detectFeedImpressions as nn,
|
|
5
|
+
feedToHtml as tn,
|
|
6
|
+
LAST_REQUESTED_REFRESH_DATA_ATTRIBUTE as en,
|
|
7
|
+
refreshFeed as on,
|
|
8
|
+
registerFeedSubscriptionId as rn,
|
|
9
|
+
updateFeedCards as an,
|
|
10
10
|
} from "../../common/feed-display.js";
|
|
11
11
|
import { Feed, logFeedDisplayed, subscribeToFeedUpdates } from "../index.js";
|
|
12
|
-
import
|
|
12
|
+
import ie from "../feed-provider-factory.js";
|
|
13
13
|
import { intersection as te } from "../../util/code-utils.js";
|
|
14
|
-
import { setCardHeight as
|
|
15
|
-
import { setupFeedUI as
|
|
16
|
-
import { logger as
|
|
17
|
-
export function showFeed(t, n
|
|
18
|
-
if (!
|
|
19
|
-
|
|
20
|
-
const
|
|
14
|
+
import { setCardHeight as sn } from "../../Card/display/card-display.js";
|
|
15
|
+
import { setupFeedUI as fn } from "../../ui/js/index.js";
|
|
16
|
+
import { logger as N } from "../../../shared-lib/index.js";
|
|
17
|
+
export function showFeed(e, t, n) {
|
|
18
|
+
if (!r.rr()) return;
|
|
19
|
+
fn();
|
|
20
|
+
const o = (e, t) => {
|
|
21
21
|
if (null == t) return e;
|
|
22
22
|
const n = [];
|
|
23
23
|
for (let e = 0; e < t.length; e++) n.push(t[e].toLowerCase());
|
|
@@ -30,67 +30,67 @@ export function showFeed(t, n, o) {
|
|
|
30
30
|
}
|
|
31
31
|
return o;
|
|
32
32
|
},
|
|
33
|
-
|
|
34
|
-
let
|
|
35
|
-
null ==
|
|
36
|
-
let
|
|
37
|
-
|
|
38
|
-
null ==
|
|
39
|
-
? ((
|
|
40
|
-
|
|
41
|
-
(
|
|
42
|
-
: (
|
|
43
|
-
const
|
|
44
|
-
if (
|
|
45
|
-
(null ==
|
|
46
|
-
new Date().valueOf() -
|
|
47
|
-
(
|
|
48
|
-
`Cached feed was older than max TTL of ${Feed.
|
|
33
|
+
i = r.sr(z.tn) || r.sr(z.en) || !1;
|
|
34
|
+
let s = !1;
|
|
35
|
+
null == e && ((e = document.body), (s = !0));
|
|
36
|
+
let l,
|
|
37
|
+
f = !1;
|
|
38
|
+
null == t
|
|
39
|
+
? ((l = ie.m().Je()),
|
|
40
|
+
an(l, o(l.cards, n), l.lastUpdated, null, i),
|
|
41
|
+
(f = !0))
|
|
42
|
+
: (l = new Feed(o(t, n), new Date()));
|
|
43
|
+
const a = tn(l, i, s);
|
|
44
|
+
if (f) {
|
|
45
|
+
(null == l.lastUpdated ||
|
|
46
|
+
new Date().valueOf() - l.lastUpdated.valueOf() > Feed.ar) &&
|
|
47
|
+
(N.info(
|
|
48
|
+
`Cached feed was older than max TTL of ${Feed.ar} ms, requesting an update from the server.`,
|
|
49
49
|
),
|
|
50
|
-
|
|
50
|
+
on(l, a));
|
|
51
51
|
const e = new Date().valueOf(),
|
|
52
52
|
t = subscribeToFeedUpdates(function (t) {
|
|
53
|
-
const
|
|
54
|
-
if (null !=
|
|
53
|
+
const r = a.querySelectorAll(".ab-refresh-button")[0];
|
|
54
|
+
if (null != r) {
|
|
55
55
|
let t = 500;
|
|
56
56
|
t -= new Date().valueOf() - e;
|
|
57
|
-
const
|
|
58
|
-
if (
|
|
59
|
-
const e = parseInt(
|
|
57
|
+
const n = a.getAttribute(en);
|
|
58
|
+
if (n) {
|
|
59
|
+
const e = parseInt(n);
|
|
60
60
|
isNaN(e) || (t -= new Date().valueOf() - e);
|
|
61
61
|
}
|
|
62
62
|
setTimeout(
|
|
63
63
|
function () {
|
|
64
|
-
|
|
64
|
+
r.className = r.className.replace(/fa-spin/g, "");
|
|
65
65
|
},
|
|
66
66
|
Math.max(t, 0),
|
|
67
67
|
);
|
|
68
68
|
}
|
|
69
|
-
|
|
69
|
+
an(l, o(t.cards, n), t.lastUpdated, a, i);
|
|
70
70
|
});
|
|
71
|
-
|
|
71
|
+
rn(t, a);
|
|
72
72
|
}
|
|
73
|
-
const
|
|
73
|
+
const u = (e) => {
|
|
74
74
|
const t = e.querySelectorAll(".ab-feed");
|
|
75
75
|
let n = null;
|
|
76
76
|
for (let o = 0; o < t.length; o++) t[o].parentNode === e && (n = t[o]);
|
|
77
77
|
null != n
|
|
78
|
-
? (
|
|
79
|
-
: e.appendChild(
|
|
78
|
+
? (ee(n), n.parentNode && n.parentNode.replaceChild(a, n))
|
|
79
|
+
: e.appendChild(a),
|
|
80
80
|
setTimeout(function () {
|
|
81
|
-
|
|
81
|
+
a.className = a.className.replace("ab-hide", "ab-show");
|
|
82
82
|
}, 0),
|
|
83
|
-
|
|
83
|
+
s && a.focus(),
|
|
84
84
|
logFeedDisplayed(),
|
|
85
|
-
|
|
86
|
-
|
|
85
|
+
nn(l, a),
|
|
86
|
+
l && sn(l.cards, e);
|
|
87
87
|
};
|
|
88
|
-
var
|
|
89
|
-
null !=
|
|
90
|
-
?
|
|
88
|
+
var d;
|
|
89
|
+
null != e
|
|
90
|
+
? u(e)
|
|
91
91
|
: (window.onload =
|
|
92
|
-
((
|
|
92
|
+
((d = window.onload),
|
|
93
93
|
function () {
|
|
94
|
-
"function" == typeof
|
|
94
|
+
"function" == typeof d && d(new Event("oldLoad")), u(document.body);
|
|
95
95
|
}));
|
|
96
96
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import
|
|
1
|
+
import r from "../../managers/braze-instance.js";
|
|
2
2
|
import { destroyFeed, showFeed } from "../index.js";
|
|
3
|
-
export function toggleFeed(o, n
|
|
4
|
-
|
|
3
|
+
export function toggleFeed(e, o, n) {
|
|
4
|
+
r.rr() &&
|
|
5
5
|
(document.querySelectorAll(".ab-feed").length > 0
|
|
6
6
|
? destroyFeed()
|
|
7
|
-
: showFeed(o, n
|
|
7
|
+
: showFeed(e, o, n));
|
|
8
8
|
}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import InAppMessage from "./models/in-app-message.js";
|
|
2
|
-
import
|
|
2
|
+
import r from "../managers/braze-instance.js";
|
|
3
3
|
import ControlMessage from "./models/control-message.js";
|
|
4
|
-
import { logger as
|
|
4
|
+
import { logger as N } from "../../shared-lib/index.js";
|
|
5
5
|
import se from "./in-app-message-manager-factory.js";
|
|
6
|
-
export function deferInAppMessage(
|
|
7
|
-
if (
|
|
8
|
-
return
|
|
9
|
-
? (
|
|
10
|
-
:
|
|
11
|
-
? se.
|
|
12
|
-
: (
|
|
6
|
+
export function deferInAppMessage(e) {
|
|
7
|
+
if (r.rr())
|
|
8
|
+
return e instanceof ControlMessage
|
|
9
|
+
? (N.info("Not deferring since this is a ControlMessage."), !1)
|
|
10
|
+
: e instanceof InAppMessage
|
|
11
|
+
? se.ea().Me(e)
|
|
12
|
+
: (N.info("Not an instance of InAppMessage, ignoring."), !1);
|
|
13
13
|
}
|
|
@@ -1,172 +1,26 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { parseQueryStringKeyValues as ut } from "../../util/url-utils.js";
|
|
4
|
-
import { WindowUtils as eo } from "../../util/window-utils.js";
|
|
1
|
+
import { parseQueryStringKeyValues as ll } from "../../util/url-utils.js";
|
|
2
|
+
import { WindowUtils as no } from "../../util/window-utils.js";
|
|
5
3
|
import { logInAppMessageHtmlClick } from "../log-in-app-message-html-click.js";
|
|
6
4
|
import InAppMessage from "../models/in-app-message.js";
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
return (i) => {
|
|
14
|
-
if (null != n && "function" == typeof n && !1 === n.bind(e)(i)) return;
|
|
15
|
-
let u = ut(s).abButtonId;
|
|
5
|
+
export const buildHtmlClickHandler = (l, t, i, o) => {
|
|
6
|
+
const r = i.getAttribute("href"),
|
|
7
|
+
e = i.onclick;
|
|
8
|
+
return (n) => {
|
|
9
|
+
if (null != e && "function" == typeof e && !1 === e.bind(i)(n)) return;
|
|
10
|
+
let s = ll(r).abButtonId;
|
|
16
11
|
if (
|
|
17
|
-
((null !=
|
|
18
|
-
null !=
|
|
12
|
+
((null != s && "" !== s) || (s = i.getAttribute("id") || void 0),
|
|
13
|
+
null != r && "" !== r && 0 !== r.indexOf("#"))
|
|
19
14
|
) {
|
|
20
|
-
const
|
|
15
|
+
const e =
|
|
21
16
|
"blank" ===
|
|
22
|
-
(
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
logInAppMessageHtmlClick(
|
|
17
|
+
(i.getAttribute("target") || "").toLowerCase().replace("_", ""),
|
|
18
|
+
m = o || l.openTarget === InAppMessage.OpenTarget.BLANK || e,
|
|
19
|
+
u = () => {
|
|
20
|
+
logInAppMessageHtmlClick(l, s, r), no.openUri(r, m, n);
|
|
26
21
|
};
|
|
27
|
-
|
|
28
|
-
} else logInAppMessageHtmlClick(
|
|
29
|
-
return
|
|
22
|
+
m ? u() : l.ll(t, u);
|
|
23
|
+
} else logInAppMessageHtmlClick(l, s, r || void 0);
|
|
24
|
+
return n.stopPropagation(), !1;
|
|
30
25
|
};
|
|
31
26
|
};
|
|
32
|
-
export const applyNonceToDynamicallyCreatedTags = (t, r, e) => {
|
|
33
|
-
const o = `([\\w]+)\\s*=\\s*document.createElement\\(['"]${e}['"]\\)`,
|
|
34
|
-
s = t.match(new RegExp(o));
|
|
35
|
-
if (s) {
|
|
36
|
-
const e = `${s[1]}.setAttribute("nonce", "${r}")`;
|
|
37
|
-
return `${t.slice(0, s.index + s[0].length)};${e};${t.slice(
|
|
38
|
-
s.index + s[0].length,
|
|
39
|
-
)}`;
|
|
40
|
-
}
|
|
41
|
-
return null;
|
|
42
|
-
};
|
|
43
|
-
export const buildBrazeBridge = (t, o, s) => {
|
|
44
|
-
const n = {
|
|
45
|
-
closeMessage: function () {
|
|
46
|
-
t.Cr(o);
|
|
47
|
-
},
|
|
48
|
-
logClick: function () {
|
|
49
|
-
logInAppMessageHtmlClick(t, ...arguments);
|
|
50
|
-
},
|
|
51
|
-
display: {},
|
|
52
|
-
web: {},
|
|
53
|
-
},
|
|
54
|
-
requestPushPermission = function () {
|
|
55
|
-
return function () {
|
|
56
|
-
const t = arguments;
|
|
57
|
-
import("../../Push/request-push-permission.js").then((o) => {
|
|
58
|
-
e.so()
|
|
59
|
-
? o.requestPushPermission(...Array.prototype.slice.call(t))
|
|
60
|
-
: r.error(_);
|
|
61
|
-
});
|
|
62
|
-
};
|
|
63
|
-
},
|
|
64
|
-
i = {
|
|
65
|
-
requestImmediateDataFlush: function () {
|
|
66
|
-
const t = arguments;
|
|
67
|
-
import("../../Core/request-immediate-data-flush.js").then(
|
|
68
|
-
({ requestImmediateDataFlush: requestImmediateDataFlush }) => {
|
|
69
|
-
e.so()
|
|
70
|
-
? requestImmediateDataFlush(...Array.prototype.slice.call(t))
|
|
71
|
-
: r.error(_);
|
|
72
|
-
},
|
|
73
|
-
);
|
|
74
|
-
},
|
|
75
|
-
logCustomEvent: function () {
|
|
76
|
-
const t = arguments;
|
|
77
|
-
import("../../Core/log-custom-event.js").then(
|
|
78
|
-
({ logCustomEvent: logCustomEvent }) => {
|
|
79
|
-
if (!e.so()) return void r.error(_);
|
|
80
|
-
logCustomEvent(...Array.prototype.slice.call(t));
|
|
81
|
-
},
|
|
82
|
-
);
|
|
83
|
-
},
|
|
84
|
-
logPurchase: function () {
|
|
85
|
-
const t = arguments;
|
|
86
|
-
import("../../Core/log-purchase.js").then(
|
|
87
|
-
({ logPurchase: logPurchase }) => {
|
|
88
|
-
if (!e.so()) return void r.error(_);
|
|
89
|
-
logPurchase(...Array.prototype.slice.call(t));
|
|
90
|
-
},
|
|
91
|
-
);
|
|
92
|
-
},
|
|
93
|
-
unregisterPush: function () {
|
|
94
|
-
const t = arguments;
|
|
95
|
-
import("../../Push/unregister-push.js").then(
|
|
96
|
-
({ unregisterPush: unregisterPush }) => {
|
|
97
|
-
e.so()
|
|
98
|
-
? unregisterPush(...Array.prototype.slice.call(t))
|
|
99
|
-
: r.error(_);
|
|
100
|
-
},
|
|
101
|
-
);
|
|
102
|
-
},
|
|
103
|
-
requestPushPermission: requestPushPermission(),
|
|
104
|
-
changeUser: function () {
|
|
105
|
-
const t = arguments;
|
|
106
|
-
import("../../Core/change-user.js").then(
|
|
107
|
-
({ changeUser: changeUser }) => {
|
|
108
|
-
if (!e.so()) return void r.error(_);
|
|
109
|
-
changeUser(...Array.prototype.slice.call(t));
|
|
110
|
-
},
|
|
111
|
-
);
|
|
112
|
-
},
|
|
113
|
-
},
|
|
114
|
-
u = function (t) {
|
|
115
|
-
return function () {
|
|
116
|
-
i[t](...Array.prototype.slice.call(arguments));
|
|
117
|
-
};
|
|
118
|
-
};
|
|
119
|
-
for (const t of to(i)) n[t] = u(t);
|
|
120
|
-
const c = [
|
|
121
|
-
"setFirstName",
|
|
122
|
-
"setLastName",
|
|
123
|
-
"setEmail",
|
|
124
|
-
"setGender",
|
|
125
|
-
"setDateOfBirth",
|
|
126
|
-
"setCountry",
|
|
127
|
-
"setHomeCity",
|
|
128
|
-
"setEmailNotificationSubscriptionType",
|
|
129
|
-
"setLanguage",
|
|
130
|
-
"addAlias",
|
|
131
|
-
"setPushNotificationSubscriptionType",
|
|
132
|
-
"setPhoneNumber",
|
|
133
|
-
"setCustomUserAttribute",
|
|
134
|
-
"addToCustomAttributeArray",
|
|
135
|
-
"removeFromCustomAttributeArray",
|
|
136
|
-
"incrementCustomUserAttribute",
|
|
137
|
-
"setCustomLocationAttribute",
|
|
138
|
-
"addToSubscriptionGroup",
|
|
139
|
-
"removeFromSubscriptionGroup",
|
|
140
|
-
],
|
|
141
|
-
a = function (t) {
|
|
142
|
-
return function () {
|
|
143
|
-
const r = ro();
|
|
144
|
-
r && r[t](...Array.prototype.slice.call(arguments));
|
|
145
|
-
};
|
|
146
|
-
},
|
|
147
|
-
m = {};
|
|
148
|
-
for (let t = 0; t < c.length; t++) m[c[t]] = a(c[t]);
|
|
149
|
-
n.getUser = function () {
|
|
150
|
-
return m;
|
|
151
|
-
};
|
|
152
|
-
const l = { showFeed: s },
|
|
153
|
-
f = function (r) {
|
|
154
|
-
return function () {
|
|
155
|
-
const e = arguments;
|
|
156
|
-
t.Cr(o, function () {
|
|
157
|
-
l[r](...Array.prototype.slice.call(e));
|
|
158
|
-
});
|
|
159
|
-
};
|
|
160
|
-
},
|
|
161
|
-
p = n.display;
|
|
162
|
-
for (const t of to(l)) p[t] = f(t);
|
|
163
|
-
const d = { registerAppboyPushMessages: requestPushPermission() },
|
|
164
|
-
g = function (t) {
|
|
165
|
-
return function () {
|
|
166
|
-
d[t](...Array.prototype.slice.call(arguments));
|
|
167
|
-
};
|
|
168
|
-
},
|
|
169
|
-
h = n.web;
|
|
170
|
-
for (const t of to(d)) h[t] = g(t);
|
|
171
|
-
return n;
|
|
172
|
-
};
|
|
@@ -1,81 +1,74 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { InAppMessage } from "../index.js";
|
|
3
|
-
import { OperatingSystems as
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
c.setAttribute("title", "Modal Message"),
|
|
12
|
-
s && (c.style.zIndex = (s + 1).toString());
|
|
13
|
-
let r = null;
|
|
14
|
-
if (null != l) {
|
|
15
|
-
(r = document.createElement("html")), (r.innerHTML = t.message || "");
|
|
16
|
-
const e = r.getElementsByTagName("style");
|
|
17
|
-
for (let t = 0; t < e.length; t++) e[t].setAttribute("nonce", l);
|
|
18
|
-
const n = r.getElementsByTagName("script");
|
|
19
|
-
for (let t = 0; t < n.length; t++) {
|
|
20
|
-
n[t].setAttribute("nonce", l),
|
|
21
|
-
(n[t].innerHTML = n[t].innerHTML.replace(
|
|
22
|
-
/<style>/g,
|
|
23
|
-
`<style nonce='${l}'>`,
|
|
24
|
-
));
|
|
25
|
-
const e = lt(n[t].innerHTML, l, "script");
|
|
26
|
-
e && (n[t].innerHTML = e);
|
|
27
|
-
const o = lt(n[t].innerHTML, l, "style");
|
|
28
|
-
o && (n[t].innerHTML = o);
|
|
29
|
-
}
|
|
30
|
-
}
|
|
1
|
+
import ro from "../../util/browser-detector.js";
|
|
2
|
+
import { InAppMessage, logInAppMessageHtmlClick } from "../index.js";
|
|
3
|
+
import { OperatingSystems as so } from "../../util/device-constants.js";
|
|
4
|
+
import { buildHtmlClickHandler as ct } from "./html-message-display-utils.js";
|
|
5
|
+
import { attachHtmlToIframeWithNonce as m } from "../../util/html-display-utils.js";
|
|
6
|
+
import { buildBrazeBridge as b } from "../../util/html-display-utils.js";
|
|
7
|
+
export default function dt(t, e, o, s, n, i) {
|
|
8
|
+
const l = document.createElement("iframe");
|
|
9
|
+
l.setAttribute("title", "Modal Message"),
|
|
10
|
+
n && (l.style.zIndex = (n + 1).toString());
|
|
31
11
|
if (
|
|
32
|
-
((
|
|
33
|
-
(
|
|
34
|
-
const
|
|
35
|
-
|
|
36
|
-
const
|
|
37
|
-
if (null !=
|
|
38
|
-
if (t.
|
|
12
|
+
(m(l, t.message, i),
|
|
13
|
+
(l.onload = () => {
|
|
14
|
+
const n = l.contentWindow;
|
|
15
|
+
n.focus();
|
|
16
|
+
const a = n.document.getElementsByTagName("head")[0];
|
|
17
|
+
if (null != a) {
|
|
18
|
+
if (t.Oe()) {
|
|
39
19
|
const e = document.createElement("style");
|
|
40
20
|
(e.innerHTML = t.css || ""),
|
|
41
|
-
(e.id = t.
|
|
42
|
-
null !=
|
|
43
|
-
|
|
21
|
+
(e.id = t._e() || ""),
|
|
22
|
+
null != i && e.setAttribute("nonce", i),
|
|
23
|
+
a.appendChild(e);
|
|
44
24
|
}
|
|
45
|
-
const e =
|
|
46
|
-
null != e && (e.setAttribute("target", "_parent"),
|
|
25
|
+
const e = n.document.createElement("base");
|
|
26
|
+
null != e && (e.setAttribute("target", "_parent"), a.appendChild(e));
|
|
47
27
|
}
|
|
48
|
-
const
|
|
49
|
-
|
|
50
|
-
const
|
|
28
|
+
const r = n.document.getElementsByTagName("title");
|
|
29
|
+
r && r.length > 0 && l.setAttribute("title", r[0].textContent || "");
|
|
30
|
+
const c = Object.assign(
|
|
31
|
+
Object.assign(
|
|
32
|
+
{},
|
|
33
|
+
b(l, e, (e, o) => t.ll(e, o)),
|
|
34
|
+
),
|
|
35
|
+
{
|
|
36
|
+
closeMessage: function () {
|
|
37
|
+
t.ll(l);
|
|
38
|
+
},
|
|
39
|
+
logClick: function () {
|
|
40
|
+
logInAppMessageHtmlClick(t, ...arguments);
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
);
|
|
51
44
|
if (
|
|
52
|
-
((
|
|
45
|
+
((n.appboyBridge = c), (n.brazeBridge = c), t.Ke !== InAppMessage.Qe.Le)
|
|
53
46
|
) {
|
|
54
|
-
const e =
|
|
55
|
-
for (let
|
|
56
|
-
const
|
|
57
|
-
for (let e = 0; e <
|
|
47
|
+
const e = n.document.getElementsByTagName("a");
|
|
48
|
+
for (let o = 0; o < e.length; o++) e[o].onclick = ct(t, l, e[o], s);
|
|
49
|
+
const o = n.document.getElementsByTagName("button");
|
|
50
|
+
for (let e = 0; e < o.length; e++) o[e].onclick = ct(t, l, o[e], s);
|
|
58
51
|
}
|
|
59
|
-
const
|
|
60
|
-
if (null !=
|
|
61
|
-
t.
|
|
52
|
+
const m = n.document.body;
|
|
53
|
+
if (null != m) {
|
|
54
|
+
t.Ve() && (m.id = t.htmlId || "");
|
|
62
55
|
const e = document.createElement("hidden");
|
|
63
|
-
(e.onclick =
|
|
56
|
+
(e.onclick = c.closeMessage),
|
|
64
57
|
(e.className = "ab-programmatic-close-button"),
|
|
65
|
-
|
|
58
|
+
m.appendChild(e);
|
|
66
59
|
}
|
|
67
|
-
|
|
68
|
-
-1 !==
|
|
69
|
-
((
|
|
60
|
+
n.dispatchEvent(new CustomEvent("ab.BridgeReady")),
|
|
61
|
+
-1 !== l.className.indexOf("ab-start-hidden") &&
|
|
62
|
+
((l.className = l.className.replace("ab-start-hidden", "")), o(l));
|
|
70
63
|
}),
|
|
71
|
-
(
|
|
64
|
+
(l.className =
|
|
72
65
|
"ab-in-app-message ab-start-hidden ab-html-message ab-modal-interactions"),
|
|
73
|
-
|
|
66
|
+
ro.OS === so.ao)
|
|
74
67
|
) {
|
|
75
68
|
const e = document.createElement("div");
|
|
76
69
|
return (
|
|
77
|
-
(e.className = "ab-ios-scroll-wrapper"), e.appendChild(
|
|
70
|
+
(e.className = "ab-ios-scroll-wrapper"), e.appendChild(l), (t.We = e), e
|
|
78
71
|
);
|
|
79
72
|
}
|
|
80
|
-
return (t.
|
|
73
|
+
return (t.We = l), l;
|
|
81
74
|
}
|