@braze/web-sdk 5.0.1 → 5.1.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/README.md +1 -1
- package/index.d.ts +10 -5
- package/package.json +1 -1
- package/shared-lib/encoding-utils.js +3 -3
- package/shared-lib/event-types.js +29 -29
- package/shared-lib/guid.js +3 -3
- package/shared-lib/index.js +6 -0
- package/shared-lib/indexed-db-adapter.js +70 -70
- package/shared-lib/logger.js +18 -18
- package/shared-lib/supported-options.js +21 -21
- package/src/Card/card-manager.js +43 -45
- package/src/Card/display/card-display.js +60 -60
- package/src/Card/log-card-click.js +4 -4
- package/src/Card/log-card-dismissal.js +2 -3
- package/src/Card/log-card-impressions.js +7 -7
- package/src/Card/models/captioned-image.js +21 -21
- package/src/Card/models/card.js +73 -73
- 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 +68 -68
- package/src/ContentCards/content-cards-provider-factory.js +3 -3
- package/src/ContentCards/content-cards-provider.js +255 -245
- package/src/ContentCards/content-cards.js +2 -2
- package/src/ContentCards/get-cached-content-cards.js +1 -1
- package/src/ContentCards/request-content-cards-refresh.js +1 -1
- package/src/ContentCards/subscribe-to-content-cards-updates.js +6 -6
- package/src/ContentCards/ui/hide-content-cards.js +1 -1
- package/src/ContentCards/ui/show-content-cards.js +24 -24
- package/src/ContentCards/ui/toggle-content-cards.js +1 -1
- package/src/Core/add-sdk-metadata.js +21 -19
- package/src/Core/change-user.js +10 -10
- package/src/Core/destroy.js +2 -2
- package/src/Core/disable-sdk.js +11 -11
- package/src/Core/enable-sdk.js +7 -7
- package/src/Core/get-device-id.js +6 -6
- package/src/Core/get-user.js +1 -1
- package/src/Core/handle-braze-action.js +41 -41
- package/src/Core/is-disabled.js +2 -2
- package/src/Core/log-custom-event.js +15 -15
- package/src/Core/log-purchase.js +31 -37
- package/src/Core/open-session.js +12 -12
- package/src/Core/remove-all-subscriptions.js +1 -1
- package/src/Core/remove-subscription.js +1 -1
- package/src/Core/request-immediate-data-flush.js +1 -1
- package/src/Core/set-logger.js +2 -2
- package/src/Core/set-sdk-authentication-signature.js +3 -3
- package/src/Core/subscribe-to-sdk-authentication-failures.js +6 -4
- package/src/Core/toggle-logging.js +2 -2
- package/src/Core/wipe-data.js +9 -9
- package/src/FeatureFlags/feature-flag-factory.js +12 -12
- package/src/FeatureFlags/feature-flag.js +10 -10
- package/src/FeatureFlags/feature-flags-provider-factory.js +3 -2
- package/src/FeatureFlags/feature-flags-provider.js +108 -80
- package/src/FeatureFlags/get-all-feature-flags.js +5 -5
- package/src/FeatureFlags/get-feature-flag.js +6 -6
- package/src/FeatureFlags/log-feature-flag-impression.js +15 -13
- package/src/FeatureFlags/refresh-feature-flags.js +1 -1
- package/src/FeatureFlags/subscribe-to-feature-flags-updates.js +7 -4
- package/src/Feed/feed-provider-factory.js +2 -2
- package/src/Feed/feed-provider.js +44 -44
- package/src/Feed/feed.js +1 -1
- package/src/Feed/get-cached-feed.js +1 -1
- package/src/Feed/log-feed-displayed.js +4 -4
- package/src/Feed/request-feed-refresh.js +1 -1
- package/src/Feed/subscribe-to-feed-updates.js +1 -1
- package/src/Feed/ui/hide-feed.js +1 -1
- package/src/Feed/ui/show-feed.js +28 -28
- package/src/Feed/ui/toggle-feed.js +1 -1
- package/src/InAppMessage/defer-in-app-message.js +5 -5
- package/src/InAppMessage/display/html-message-to-html.js +54 -54
- package/src/InAppMessage/display/in-app-message-to-html.js +79 -79
- package/src/InAppMessage/display/modal-utils.js +8 -8
- package/src/InAppMessage/get-deferred-in-app-message.js +1 -1
- package/src/InAppMessage/in-app-message-factory.js +49 -49
- package/src/InAppMessage/in-app-message-manager-factory.js +1 -1
- package/src/InAppMessage/in-app-message-manager.js +143 -138
- package/src/InAppMessage/log-in-app-message-button-click.js +12 -12
- package/src/InAppMessage/log-in-app-message-click.js +9 -9
- package/src/InAppMessage/log-in-app-message-html-click.js +12 -12
- package/src/InAppMessage/log-in-app-message-impression.js +6 -6
- package/src/InAppMessage/models/full-screen-message.js +33 -33
- package/src/InAppMessage/models/html-message.js +20 -20
- package/src/InAppMessage/models/in-app-message-button.js +6 -6
- package/src/InAppMessage/models/in-app-message.js +99 -99
- package/src/InAppMessage/models/modal-message.js +32 -32
- package/src/InAppMessage/models/slide-up-message.js +28 -28
- package/src/InAppMessage/models/templated-in-app-message.js +8 -8
- package/src/InAppMessage/subscribe-to-in-app-message.js +2 -2
- package/src/InAppMessage/ui/automatically-show-in-app-messages.js +4 -4
- package/src/InAppMessage/ui/show-in-app-message.js +81 -81
- package/src/Push/is-push-blocked.js +1 -1
- package/src/Push/is-push-permission-granted.js +1 -1
- package/src/Push/is-push-supported.js +1 -1
- package/src/Push/push-manager-factory.js +5 -5
- package/src/Push/push-manager.js +176 -173
- package/src/Push/request-push-permission.js +1 -1
- package/src/Push/unregister-push.js +1 -1
- package/src/Push/utils/push-utils.js +4 -4
- package/src/User/user-manager.js +29 -29
- package/src/User/user.js +72 -74
- package/src/common/base-feed.js +7 -7
- package/src/common/base-provider.js +1 -1
- package/src/common/constants.js +2 -0
- package/src/common/event-logger.js +21 -18
- package/src/common/feed-display.js +44 -44
- package/src/l10n/l10n-manager-factory.js +3 -3
- package/src/l10n/l10n-manager.js +7 -7
- package/src/managers/auth-manager.js +32 -32
- package/src/managers/braze-instance.js +188 -190
- package/src/managers/device-manager.js +28 -28
- package/src/managers/network-manager.js +189 -138
- package/src/managers/server-config-manager.js +69 -53
- package/src/managers/session-manager.js +34 -30
- package/src/managers/storage-manager-factory.js +16 -16
- package/src/managers/storage-manager.js +178 -163
- package/src/managers/subscription-manager.js +12 -12
- package/src/models/backend-errors.js +5 -5
- package/src/models/braze-event.js +4 -4
- package/src/models/device.js +2 -2
- package/src/models/identifier.js +34 -14
- package/src/models/push-token.js +8 -8
- package/src/models/request-result.js +3 -3
- package/src/models/server-config.js +32 -23
- package/src/request-controller.js +187 -179
- package/src/triggers/models/custom-event-data.js +7 -7
- package/src/triggers/models/custom-event-property-data.js +10 -10
- package/src/triggers/models/filter-set.js +13 -13
- package/src/triggers/models/filter.js +45 -45
- package/src/triggers/models/in-app-message-click-data.js +12 -12
- package/src/triggers/models/purchase-data.js +2 -2
- package/src/triggers/models/purchase-property-data.js +10 -10
- package/src/triggers/models/push-click-data.js +7 -7
- package/src/triggers/models/trigger-condition.js +57 -59
- package/src/triggers/models/trigger-events.js +4 -4
- package/src/triggers/models/trigger.js +38 -38
- package/src/triggers/triggers-provider-factory.js +4 -4
- package/src/triggers/triggers-provider.js +127 -130
- package/src/ui/js/attach-css.js +2 -2
- package/src/ui/js/iam-css.js +1 -1
- package/src/ui/js/load-font-awesome.js +1 -1
- package/src/util/base-device-parser.js +3 -3
- package/src/util/braze-actions.js +35 -35
- package/src/util/browser-detector.js +21 -21
- package/src/util/client-hints-parser.js +8 -8
- package/src/util/code-utils.js +2 -2
- package/src/util/component-utils.js +1 -1
- package/src/util/deprecation-utils.js +4 -4
- package/src/util/device-constants.js +1 -1
- package/src/util/dom-utils.js +18 -18
- package/src/util/key-codes.js +1 -1
- package/src/util/net.js +18 -18
- package/src/util/request-header-utils.js +39 -37
- package/src/util/string-utils.js +10 -10
- package/src/util/user-agent-parser.js +18 -18
- package/src/util/validation-utils.js +37 -39
- package/src/util/window-utils.js +3 -3
- package/shared-lib/braze-shared-lib.js +0 -8
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { isArray as
|
|
1
|
+
import { isArray as j } from "./code-utils.js";
|
|
2
2
|
export default class ge {
|
|
3
3
|
constructor() {}
|
|
4
4
|
tf() {}
|
|
5
5
|
ef() {}
|
|
6
|
-
|
|
6
|
+
Oa(t) {}
|
|
7
7
|
static rf(t, e) {
|
|
8
8
|
if (t && e)
|
|
9
|
-
if (((t = t.toLowerCase()),
|
|
9
|
+
if (((t = t.toLowerCase()), j(e.if))) {
|
|
10
10
|
for (let r = 0; r < e.if.length; r++)
|
|
11
11
|
if (-1 !== t.indexOf(e.if[r].toLowerCase())) return e.identity;
|
|
12
12
|
} else if (-1 !== t.indexOf(e.if.toLowerCase())) return e.identity;
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import r from "../../shared-lib/
|
|
2
|
-
import { getErrorMessage as
|
|
3
|
-
import { decodeBrazeActions as
|
|
1
|
+
import { logger as r } from "../../shared-lib/index.js";
|
|
2
|
+
import { getErrorMessage as si } from "./error-utils.js";
|
|
3
|
+
import { decodeBrazeActions as no } from "./string-utils.js";
|
|
4
4
|
import {
|
|
5
|
-
BRAZE_ACTION_URI_REGEX as
|
|
6
|
-
isValidBrazeActionType as
|
|
7
|
-
isValidBrazeActionJson as
|
|
5
|
+
BRAZE_ACTION_URI_REGEX as Z,
|
|
6
|
+
isValidBrazeActionType as io,
|
|
7
|
+
isValidBrazeActionJson as oo,
|
|
8
8
|
} from "./validation-utils.js";
|
|
9
9
|
export const BRAZE_ACTIONS = {
|
|
10
10
|
types: {
|
|
11
|
-
|
|
11
|
+
ro: "container",
|
|
12
12
|
logCustomEvent: "logCustomEvent",
|
|
13
13
|
setEmailNotificationSubscriptionType:
|
|
14
14
|
"setEmailNotificationSubscriptionType",
|
|
@@ -19,20 +19,20 @@ export const BRAZE_ACTIONS = {
|
|
|
19
19
|
removeFromSubscriptionGroup: "removeFromSubscriptionGroup",
|
|
20
20
|
addToCustomAttributeArray: "addToCustomAttributeArray",
|
|
21
21
|
removeFromCustomAttributeArray: "removeFromCustomAttributeArray",
|
|
22
|
-
|
|
23
|
-
|
|
22
|
+
no: "openLink",
|
|
23
|
+
ao: "openLinkInWebView",
|
|
24
24
|
},
|
|
25
|
-
properties: { type: "type",
|
|
25
|
+
properties: { type: "type", oo: "steps", eo: "args" },
|
|
26
26
|
};
|
|
27
27
|
export const INELIGIBLE_BRAZE_ACTION_URL_ERROR_TYPES = {
|
|
28
|
-
|
|
29
|
-
|
|
28
|
+
Xi: "unknownBrazeAction",
|
|
29
|
+
Zi: "noPushPrompt",
|
|
30
30
|
};
|
|
31
31
|
export const ineligibleBrazeActionURLErrorMessage = (t, o) => {
|
|
32
32
|
switch (t) {
|
|
33
|
-
case INELIGIBLE_BRAZE_ACTION_URL_ERROR_TYPES.
|
|
33
|
+
case INELIGIBLE_BRAZE_ACTION_URL_ERROR_TYPES.Xi:
|
|
34
34
|
return `${o} contains an unknown braze action type and will not be displayed.`;
|
|
35
|
-
case INELIGIBLE_BRAZE_ACTION_URL_ERROR_TYPES.
|
|
35
|
+
case INELIGIBLE_BRAZE_ACTION_URL_ERROR_TYPES.Zi:
|
|
36
36
|
return `${o} contains a push prompt braze action, but is not eligible for a push prompt. Ignoring.`;
|
|
37
37
|
default:
|
|
38
38
|
return "";
|
|
@@ -40,45 +40,45 @@ export const ineligibleBrazeActionURLErrorMessage = (t, o) => {
|
|
|
40
40
|
};
|
|
41
41
|
export function getDecodedBrazeAction(t) {
|
|
42
42
|
try {
|
|
43
|
-
const o = t.match(
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
if (null ==
|
|
47
|
-
return void r.
|
|
43
|
+
const o = t.match(Z),
|
|
44
|
+
n = o ? o[0].length : null,
|
|
45
|
+
e = n ? t.substring(n) : null;
|
|
46
|
+
if (null == n || n > t.length - 1 || !e)
|
|
47
|
+
return void r.error(
|
|
48
48
|
`Did not find base64 encoded brazeAction in url to process : ${t}`,
|
|
49
49
|
);
|
|
50
|
-
const i =
|
|
50
|
+
const i = no(e);
|
|
51
51
|
return i
|
|
52
52
|
? JSON.parse(i)
|
|
53
|
-
: void r.
|
|
53
|
+
: void r.error(`Failed to decode base64 encoded brazeAction: ${e}`);
|
|
54
54
|
} catch (o) {
|
|
55
|
-
return void r.
|
|
55
|
+
return void r.error(`Failed to process brazeAction URL ${t} : ${si(o)}`);
|
|
56
56
|
}
|
|
57
57
|
}
|
|
58
|
-
function
|
|
58
|
+
function so(t, o) {
|
|
59
59
|
let r = !1;
|
|
60
|
-
if (o) for (const
|
|
60
|
+
if (o) for (const n of o) if (((r = r || t(n)), r)) return !0;
|
|
61
61
|
return !1;
|
|
62
62
|
}
|
|
63
63
|
export function containsUnknownBrazeAction(t) {
|
|
64
64
|
const o = BRAZE_ACTIONS.properties.type,
|
|
65
|
-
r = BRAZE_ACTIONS.properties.
|
|
65
|
+
r = BRAZE_ACTIONS.properties.oo;
|
|
66
66
|
try {
|
|
67
67
|
if (null == t) return !0;
|
|
68
|
-
const
|
|
69
|
-
return
|
|
70
|
-
?
|
|
71
|
-
: !
|
|
68
|
+
const n = t[o];
|
|
69
|
+
return n === BRAZE_ACTIONS.types.ro
|
|
70
|
+
? so(containsUnknownBrazeAction, t[r])
|
|
71
|
+
: !io(n);
|
|
72
72
|
} catch (t) {
|
|
73
73
|
return !0;
|
|
74
74
|
}
|
|
75
75
|
}
|
|
76
76
|
export function containsPushPrimerBrazeAction(t) {
|
|
77
|
-
if (!t || !
|
|
77
|
+
if (!t || !oo(t)) return !1;
|
|
78
78
|
const o = BRAZE_ACTIONS.properties.type,
|
|
79
|
-
r = BRAZE_ACTIONS.properties.
|
|
80
|
-
|
|
81
|
-
return
|
|
82
|
-
?
|
|
83
|
-
:
|
|
79
|
+
r = BRAZE_ACTIONS.properties.oo,
|
|
80
|
+
n = t[o];
|
|
81
|
+
return n === BRAZE_ACTIONS.types.ro
|
|
82
|
+
? so(containsPushPrimerBrazeAction, t[r])
|
|
83
|
+
: n === BRAZE_ACTIONS.types.requestPushPermission;
|
|
84
84
|
}
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import { Browsers as
|
|
4
|
-
class
|
|
1
|
+
import ai from "./client-hints-parser.js";
|
|
2
|
+
import oi from "./user-agent-parser.js";
|
|
3
|
+
import { Browsers as gi, OperatingSystems as Y } from "./device-constants.js";
|
|
4
|
+
class ui {
|
|
5
5
|
constructor() {
|
|
6
|
-
const t = navigator.userAgentData ?
|
|
6
|
+
const t = navigator.userAgentData ? ai : oi;
|
|
7
7
|
(this.Sg = new t()),
|
|
8
8
|
(this.userAgent = navigator.userAgent),
|
|
9
9
|
(this.browser = this.Sg.tf()),
|
|
10
10
|
(this.version = this.Sg.ef()),
|
|
11
11
|
(this.OS = null),
|
|
12
|
-
this.
|
|
12
|
+
this.Oa().then((t) => (this.OS = t));
|
|
13
13
|
const i = navigator;
|
|
14
14
|
(this.language = (
|
|
15
15
|
i.userLanguage ||
|
|
@@ -18,18 +18,18 @@ class gi {
|
|
|
18
18
|
i.systemLanguage ||
|
|
19
19
|
""
|
|
20
20
|
).toLowerCase()),
|
|
21
|
-
(this.
|
|
21
|
+
(this.Qo = ui.vg(this.userAgent));
|
|
22
22
|
}
|
|
23
|
-
|
|
24
|
-
return this.browser ===
|
|
23
|
+
OE() {
|
|
24
|
+
return this.browser === gi.Bg;
|
|
25
25
|
}
|
|
26
|
-
|
|
26
|
+
Ga() {
|
|
27
27
|
return this.OS || null;
|
|
28
28
|
}
|
|
29
|
-
|
|
29
|
+
Oa() {
|
|
30
30
|
return this.OS
|
|
31
31
|
? Promise.resolve(this.OS)
|
|
32
|
-
: this.Sg.
|
|
32
|
+
: this.Sg.Oa(ui.Og).then((t) => ((this.OS = t), t));
|
|
33
33
|
}
|
|
34
34
|
static vg(t) {
|
|
35
35
|
t = t.toLowerCase();
|
|
@@ -55,9 +55,9 @@ class gi {
|
|
|
55
55
|
return !1;
|
|
56
56
|
}
|
|
57
57
|
}
|
|
58
|
-
|
|
59
|
-
{ string: navigator.platform, if: "Win", identity:
|
|
60
|
-
{ string: navigator.platform, if: "Mac", identity:
|
|
58
|
+
ui.Og = [
|
|
59
|
+
{ string: navigator.platform, if: "Win", identity: Y.Pg },
|
|
60
|
+
{ string: navigator.platform, if: "Mac", identity: Y.kg },
|
|
61
61
|
{ string: navigator.platform, if: "BlackBerry", identity: "BlackBerry" },
|
|
62
62
|
{ string: navigator.platform, if: "FreeBSD", identity: "FreeBSD" },
|
|
63
63
|
{ string: navigator.platform, if: "OpenBSD", identity: "OpenBSD" },
|
|
@@ -68,17 +68,17 @@ gi.Og = [
|
|
|
68
68
|
{
|
|
69
69
|
string: navigator.userAgent,
|
|
70
70
|
if: ["iPhone", "iPad", "iPod"],
|
|
71
|
-
identity:
|
|
71
|
+
identity: Y.io,
|
|
72
72
|
},
|
|
73
|
-
{ string: navigator.platform, if: "Pike v", identity:
|
|
73
|
+
{ string: navigator.platform, if: "Pike v", identity: Y.io },
|
|
74
74
|
{ string: navigator.userAgent, if: ["Web0S"], identity: "WebOS" },
|
|
75
75
|
{
|
|
76
76
|
string: navigator.platform,
|
|
77
77
|
if: ["Linux armv7l", "Android"],
|
|
78
|
-
identity:
|
|
78
|
+
identity: Y.xg,
|
|
79
79
|
},
|
|
80
|
-
{ string: navigator.userAgent, if: ["Android"], identity:
|
|
80
|
+
{ string: navigator.userAgent, if: ["Android"], identity: Y.xg },
|
|
81
81
|
{ string: navigator.platform, if: "Linux", identity: "Linux" },
|
|
82
82
|
];
|
|
83
|
-
const
|
|
84
|
-
export {
|
|
83
|
+
const X = new ui();
|
|
84
|
+
export { X as default, ui as BrowserDetector };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import ge from "./base-device-parser.js";
|
|
2
|
-
import { Browsers as
|
|
3
|
-
export default class
|
|
2
|
+
import { Browsers as gi } from "./device-constants.js";
|
|
3
|
+
export default class ai extends ge {
|
|
4
4
|
constructor() {
|
|
5
5
|
if (
|
|
6
6
|
(super(),
|
|
@@ -9,7 +9,7 @@ export default class ni extends ge {
|
|
|
9
9
|
(this.version = null),
|
|
10
10
|
this.userAgentData)
|
|
11
11
|
) {
|
|
12
|
-
const t = this.
|
|
12
|
+
const t = this.hc();
|
|
13
13
|
(this.browser = t.browser || "Unknown Browser"),
|
|
14
14
|
(this.version = t.version || "Unknown Version");
|
|
15
15
|
}
|
|
@@ -21,11 +21,11 @@ export default class ni extends ge {
|
|
|
21
21
|
ef() {
|
|
22
22
|
return this.version;
|
|
23
23
|
}
|
|
24
|
-
|
|
24
|
+
Oa(t) {
|
|
25
25
|
if (this.OS) return Promise.resolve(this.OS);
|
|
26
26
|
const s = (s) => {
|
|
27
27
|
for (let r = 0; r < t.length; r++) {
|
|
28
|
-
const i =
|
|
28
|
+
const i = ai.rf(s, t[r]);
|
|
29
29
|
if (i) return (this.OS = i), this.OS;
|
|
30
30
|
}
|
|
31
31
|
return s;
|
|
@@ -36,12 +36,12 @@ export default class ni extends ge {
|
|
|
36
36
|
.then((t) => (t.platform ? s(t.platform) : navigator.platform))
|
|
37
37
|
.catch(() => navigator.platform);
|
|
38
38
|
}
|
|
39
|
-
|
|
39
|
+
hc() {
|
|
40
40
|
const t = {},
|
|
41
41
|
s = this.userAgentData.brands;
|
|
42
42
|
if (s && s.length)
|
|
43
43
|
for (const r of s) {
|
|
44
|
-
const s = this.
|
|
44
|
+
const s = this.uc(gi),
|
|
45
45
|
i = r.brand.match(s);
|
|
46
46
|
if (i && i.length > 0) {
|
|
47
47
|
(t.browser = i[0]), (t.version = r.version);
|
|
@@ -50,7 +50,7 @@ export default class ni extends ge {
|
|
|
50
50
|
}
|
|
51
51
|
return t;
|
|
52
52
|
}
|
|
53
|
-
|
|
53
|
+
uc(t) {
|
|
54
54
|
const s = [];
|
|
55
55
|
for (const r in t) {
|
|
56
56
|
const i = r;
|
package/src/util/code-utils.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import r from "../../shared-lib/
|
|
1
|
+
import { logger as r } from "../../shared-lib/index.js";
|
|
2
2
|
export function values(t) {
|
|
3
3
|
const e = [];
|
|
4
4
|
let r;
|
|
@@ -13,7 +13,7 @@ export function validateValueIsFromEnum(t, e, n, o) {
|
|
|
13
13
|
const c = values(t);
|
|
14
14
|
return (
|
|
15
15
|
-1 !== c.indexOf(e) ||
|
|
16
|
-
(r.
|
|
16
|
+
(r.error(`${n} Valid values from ${o} are "${c.join('"/"')}".`), !1)
|
|
17
17
|
);
|
|
18
18
|
}
|
|
19
19
|
export function isArray(t) {
|
|
@@ -15,7 +15,7 @@ export function createCloseButton(t, o, e) {
|
|
|
15
15
|
return (
|
|
16
16
|
n.appendChild(r),
|
|
17
17
|
n.addEventListener("keydown", (t) => {
|
|
18
|
-
(t.keyCode !== at.
|
|
18
|
+
(t.keyCode !== at.To && t.keyCode !== at.Eo) ||
|
|
19
19
|
(e(), t.stopPropagation());
|
|
20
20
|
}),
|
|
21
21
|
(n.onclick = (t) => {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import r from "../../shared-lib/
|
|
2
|
-
export function logDeprecationWarning(e,
|
|
3
|
-
let
|
|
4
|
-
|
|
1
|
+
import { logger as r } from "../../shared-lib/index.js";
|
|
2
|
+
export function logDeprecationWarning(e, i, n) {
|
|
3
|
+
let t = `The '${e}' ${i} is deprecated.`;
|
|
4
|
+
n && (t += ` Please use '${n}' instead.`), r.warn(t);
|
|
5
5
|
}
|
package/src/util/dom-utils.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import r from "../../shared-lib/
|
|
2
|
-
import { getErrorMessage as
|
|
1
|
+
import { logger as r } from "../../shared-lib/index.js";
|
|
2
|
+
import { getErrorMessage as si } from "./error-utils.js";
|
|
3
3
|
export function _isInView(t, n = !1, e = !1, s = !1) {
|
|
4
4
|
if (null == t) return !1;
|
|
5
5
|
(n = n || !1), (e = e || !1);
|
|
@@ -18,33 +18,33 @@ export function _isInView(t, n = !1, e = !1, s = !1) {
|
|
|
18
18
|
!s)
|
|
19
19
|
);
|
|
20
20
|
}
|
|
21
|
-
export const DOMUtils = {
|
|
22
|
-
export const DIRECTIONS = {
|
|
21
|
+
export const DOMUtils = { dc: null, co: _isInView };
|
|
22
|
+
export const DIRECTIONS = { De: "up", Ee: "down", U: "left", V: "right" };
|
|
23
23
|
export function supportsPassive() {
|
|
24
|
-
if (null == DOMUtils.
|
|
25
|
-
DOMUtils.
|
|
24
|
+
if (null == DOMUtils.dc) {
|
|
25
|
+
DOMUtils.dc = !1;
|
|
26
26
|
try {
|
|
27
27
|
const t = Object.defineProperty({}, "passive", {
|
|
28
28
|
get: () => {
|
|
29
|
-
DOMUtils.
|
|
29
|
+
DOMUtils.dc = !0;
|
|
30
30
|
},
|
|
31
31
|
});
|
|
32
32
|
window.addEventListener("testPassive", () => {}, t),
|
|
33
33
|
window.removeEventListener("testPassive", () => {}, t);
|
|
34
34
|
} catch (t) {
|
|
35
|
-
r.
|
|
35
|
+
r.error(si(t));
|
|
36
36
|
}
|
|
37
37
|
}
|
|
38
|
-
return DOMUtils.
|
|
38
|
+
return DOMUtils.dc;
|
|
39
39
|
}
|
|
40
40
|
export function addPassiveEventListener(t, n, e = () => {}) {
|
|
41
41
|
t.addEventListener(n, e, !!supportsPassive() && { passive: !0 });
|
|
42
42
|
}
|
|
43
43
|
export function topIsInView(t) {
|
|
44
|
-
return DOMUtils.
|
|
44
|
+
return DOMUtils.co(t, !0, !1, !1);
|
|
45
45
|
}
|
|
46
46
|
export function bottomIsInView(t) {
|
|
47
|
-
return DOMUtils.
|
|
47
|
+
return DOMUtils.co(t, !1, !0, !1);
|
|
48
48
|
}
|
|
49
49
|
export function clickElement(t) {
|
|
50
50
|
if (t.onclick) {
|
|
@@ -61,17 +61,17 @@ export function detectSwipe(t, n, e) {
|
|
|
61
61
|
addPassiveEventListener(t, "touchmove", (o) => {
|
|
62
62
|
if (null == s || null == i) return;
|
|
63
63
|
const l = s - o.touches[0].clientX,
|
|
64
|
-
|
|
65
|
-
Math.abs(l) > Math.abs(
|
|
66
|
-
? (((l > 0 && n === DIRECTIONS.
|
|
64
|
+
u = i - o.touches[0].clientY;
|
|
65
|
+
Math.abs(l) > Math.abs(u) && Math.abs(l) >= 25
|
|
66
|
+
? (((l > 0 && n === DIRECTIONS.U) || (l < 0 && n === DIRECTIONS.V)) &&
|
|
67
67
|
e(o),
|
|
68
68
|
(s = null),
|
|
69
69
|
(i = null))
|
|
70
|
-
: Math.abs(
|
|
71
|
-
(((
|
|
72
|
-
n === DIRECTIONS.
|
|
70
|
+
: Math.abs(u) >= 25 &&
|
|
71
|
+
(((u > 0 &&
|
|
72
|
+
n === DIRECTIONS.De &&
|
|
73
73
|
t.scrollTop === t.scrollHeight - t.offsetHeight) ||
|
|
74
|
-
(
|
|
74
|
+
(u < 0 && n === DIRECTIONS.Ee && 0 === t.scrollTop)) &&
|
|
75
75
|
e(o),
|
|
76
76
|
(s = null),
|
|
77
77
|
(i = null));
|
package/src/util/key-codes.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const KeyCodes = {
|
|
1
|
+
export const KeyCodes = { To: 32, lo: 9, Eo: 13, _h: 27 };
|
package/src/util/net.js
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
import r from "../../shared-lib/
|
|
1
|
+
import { logger as r } from "../../shared-lib/index.js";
|
|
2
2
|
import qt from "../models/backend-errors.js";
|
|
3
|
-
import { getErrorMessage as
|
|
3
|
+
import { getErrorMessage as si } from "./error-utils.js";
|
|
4
4
|
const C = {
|
|
5
|
-
|
|
5
|
+
Qs: (t) => {
|
|
6
6
|
let e, o;
|
|
7
7
|
try {
|
|
8
|
-
const
|
|
9
|
-
r.
|
|
8
|
+
const n = () => {
|
|
9
|
+
r.error("This browser does not have any supported ajax options!");
|
|
10
10
|
};
|
|
11
|
-
let
|
|
12
|
-
if ((window.XMLHttpRequest && (
|
|
11
|
+
let s = !1;
|
|
12
|
+
if ((window.XMLHttpRequest && (s = !0), !s)) return void n();
|
|
13
13
|
e = new XMLHttpRequest();
|
|
14
14
|
const i = () => {
|
|
15
15
|
"function" == typeof t.error && t.error(e.status),
|
|
16
|
-
"function" == typeof t.
|
|
16
|
+
"function" == typeof t.ti && t.ti(!1);
|
|
17
17
|
};
|
|
18
18
|
(e.onload = () => {
|
|
19
19
|
let o = !1;
|
|
@@ -21,21 +21,21 @@ const C = {
|
|
|
21
21
|
if (
|
|
22
22
|
((o = (e.status >= 200 && e.status < 300) || 304 === e.status), o)
|
|
23
23
|
) {
|
|
24
|
-
if ("function" == typeof t.
|
|
24
|
+
if ("function" == typeof t.L) {
|
|
25
25
|
let o, r;
|
|
26
26
|
try {
|
|
27
27
|
(o = JSON.parse(e.responseText)),
|
|
28
28
|
(r = e.getAllResponseHeaders());
|
|
29
29
|
} catch (o) {
|
|
30
|
-
const
|
|
31
|
-
error: "" === e.responseText ? qt.
|
|
30
|
+
const n = {
|
|
31
|
+
error: "" === e.responseText ? qt.Ka : qt.La,
|
|
32
32
|
response: e.responseText,
|
|
33
33
|
};
|
|
34
|
-
(0, t.
|
|
34
|
+
(0, t.L)(n, r);
|
|
35
35
|
}
|
|
36
|
-
o && t.
|
|
36
|
+
o && t.L(o, r);
|
|
37
37
|
}
|
|
38
|
-
"function" == typeof t.
|
|
38
|
+
"function" == typeof t.ti && t.ti(!0);
|
|
39
39
|
} else i();
|
|
40
40
|
}),
|
|
41
41
|
(e.onerror = () => {
|
|
@@ -52,7 +52,7 @@ const C = {
|
|
|
52
52
|
for (const t of f) e.setRequestHeader(t[0], t[1]);
|
|
53
53
|
e.send(o);
|
|
54
54
|
} catch (t) {
|
|
55
|
-
r.
|
|
55
|
+
r.error(`Network request error: ${si(t)}`);
|
|
56
56
|
}
|
|
57
57
|
},
|
|
58
58
|
};
|
|
@@ -60,12 +60,12 @@ export const readResponseHeaders = (t) => {
|
|
|
60
60
|
const e = {},
|
|
61
61
|
o = t.toString().split("\r\n");
|
|
62
62
|
if (!o) return e;
|
|
63
|
-
let r,
|
|
63
|
+
let r, n;
|
|
64
64
|
for (const t of o)
|
|
65
65
|
t &&
|
|
66
66
|
((r = t.slice(0, t.indexOf(":")).toLowerCase().trim()),
|
|
67
|
-
(
|
|
68
|
-
(e[r] =
|
|
67
|
+
(n = t.slice(t.indexOf(":") + 1).trim()),
|
|
68
|
+
(e[r] = n));
|
|
69
69
|
return e;
|
|
70
70
|
};
|
|
71
71
|
export default C;
|
|
@@ -1,46 +1,48 @@
|
|
|
1
1
|
import { REQUEST_ATTEMPT_DEFAULT as Ae } from "../common/constants.js";
|
|
2
|
-
import { STORAGE_KEYS as
|
|
3
|
-
const
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
},
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
2
|
+
import { STORAGE_KEYS as o } from "../managers/storage-manager.js";
|
|
3
|
+
const S = {
|
|
4
|
+
Gs: { Qa: "d", Bs: "cc", qi: "ff", Cr: "t" },
|
|
5
|
+
ii: {
|
|
6
|
+
Qa: "/data",
|
|
7
|
+
Bs: "/content_cards/sync",
|
|
8
|
+
qi: "/feature_flags/sync",
|
|
9
|
+
Cr: "/template",
|
|
10
|
+
},
|
|
11
|
+
mc: (e) => (null == e ? void 0 : e.j(o.C.EE)),
|
|
12
|
+
Ac: (e) => (null == e ? void 0 : e.j(o.C.lE)),
|
|
13
|
+
Tc: (e, t) => {
|
|
14
|
+
null == e || e.k(o.C.EE, t);
|
|
15
|
+
},
|
|
16
|
+
Rc: (e, t) => {
|
|
17
|
+
null == e || e.k(o.C.lE, t);
|
|
18
|
+
},
|
|
19
|
+
Yh: (e, t) => {
|
|
18
20
|
if (!e || !t) return -1;
|
|
19
|
-
const
|
|
20
|
-
if (null ==
|
|
21
|
-
const
|
|
22
|
-
return null ==
|
|
23
|
-
},
|
|
24
|
-
|
|
25
|
-
let
|
|
26
|
-
if (!e || !t) return
|
|
27
|
-
const
|
|
28
|
-
return null ==
|
|
29
|
-
},
|
|
30
|
-
|
|
21
|
+
const s = S.mc(e);
|
|
22
|
+
if (null == s) return -1;
|
|
23
|
+
const n = s[t];
|
|
24
|
+
return null == n || isNaN(n) ? -1 : n;
|
|
25
|
+
},
|
|
26
|
+
Jh: (e, t) => {
|
|
27
|
+
let s = Ae;
|
|
28
|
+
if (!e || !t) return s;
|
|
29
|
+
const n = S.Ac(e);
|
|
30
|
+
return null == n ? s : ((s = n[t]), null == s || isNaN(s) ? Ae : s);
|
|
31
|
+
},
|
|
32
|
+
Os: (e, t, s) => {
|
|
31
33
|
if (!e || !t) return;
|
|
32
|
-
let
|
|
33
|
-
null ==
|
|
34
|
+
let n = S.mc(e);
|
|
35
|
+
null == n && (n = {}), (n[t] = s), S.Tc(e, n);
|
|
34
36
|
},
|
|
35
|
-
|
|
37
|
+
Ys: (e, t, s) => {
|
|
36
38
|
if (!e || !t) return;
|
|
37
|
-
let
|
|
38
|
-
null ==
|
|
39
|
+
let n = S.Ac(e);
|
|
40
|
+
null == n && (n = {}), (n[t] = s), S.Rc(e, n);
|
|
39
41
|
},
|
|
40
|
-
|
|
42
|
+
si: (e, t) => {
|
|
41
43
|
if (!e || !t) return;
|
|
42
|
-
const
|
|
43
|
-
|
|
44
|
+
const s = S.Jh(e, t);
|
|
45
|
+
S.Ys(e, t, s + 1);
|
|
44
46
|
},
|
|
45
47
|
};
|
|
46
|
-
export default
|
|
48
|
+
export default S;
|
package/src/util/string-utils.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import r from "../../shared-lib/
|
|
1
|
+
import { logger as r } from "../../shared-lib/index.js";
|
|
2
2
|
export function getByteLength(t) {
|
|
3
3
|
let e = t.length;
|
|
4
|
-
for (let
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
|
|
4
|
+
for (let n = t.length - 1; n >= 0; n--) {
|
|
5
|
+
const r = t.charCodeAt(n);
|
|
6
|
+
r > 127 && r <= 2047 ? e++ : r > 2047 && r <= 65535 && (e += 2),
|
|
7
|
+
r >= 56320 && r <= 57343 && n--;
|
|
8
8
|
}
|
|
9
9
|
return e;
|
|
10
10
|
}
|
|
@@ -12,11 +12,11 @@ export function decodeBrazeActions(t) {
|
|
|
12
12
|
try {
|
|
13
13
|
t = t.replace(/-/g, "+").replace(/_/g, "/");
|
|
14
14
|
const e = window.atob(t),
|
|
15
|
-
|
|
16
|
-
for (let t = 0; t < e.length; t++)
|
|
17
|
-
const
|
|
18
|
-
return String.fromCharCode(...
|
|
15
|
+
n = new Uint8Array(e.length);
|
|
16
|
+
for (let t = 0; t < e.length; t++) n[t] = e.charCodeAt(t);
|
|
17
|
+
const r = new Uint16Array(n.buffer);
|
|
18
|
+
return String.fromCharCode(...r);
|
|
19
19
|
} catch (t) {
|
|
20
|
-
return r.
|
|
20
|
+
return r.error("Unable to decode Base64: " + t), null;
|
|
21
21
|
}
|
|
22
22
|
}
|