@braze/web-sdk 6.7.1 → 6.8.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/index.d.ts +74 -27
- package/package.json +1 -1
- package/shared-lib/encoding-utils.js +2 -2
- package/shared-lib/event-types.js +13 -13
- package/shared-lib/indexed-db-adapter.js +3 -3
- package/shared-lib/logger.js +2 -2
- package/shared-lib/supported-options.js +8 -8
- package/src/Banner/log-banner-impressions.js +20 -11
- package/src/ContentCards/content-cards-provider-factory.js +13 -11
- package/src/ContentCards/content-cards-provider.js +4 -4
- package/src/ContentCards/get-cached-content-cards.js +2 -2
- package/src/ContentCards/request-content-cards-refresh.js +2 -2
- package/src/ContentCards/subscribe-to-content-cards-updates.js +10 -10
- package/src/ContentCards/ui/show-content-cards.js +3 -3
- package/src/Core/change-user.js +2 -2
- package/src/Core/index.js +1 -0
- package/src/Core/log-ecommerce-event.js +29 -0
- package/src/Core/log-purchase.js +17 -192
- package/src/Core/open-session.js +6 -6
- package/src/Core/set-sdk-authentication-signature.js +1 -1
- package/src/Core/subscribe-to-sdk-authentication-failures.js +1 -1
- package/src/DUST/dust-connection-core.js +1 -0
- package/src/DUST/dust-provider-factory.js +10 -10
- package/src/DUST/dust-provider.js +181 -158
- package/src/DUST/dust-shared-worker-code.js +1 -1
- package/src/DUST/dust-shared-worker-impl.js +93 -100
- package/src/DUST/dust-worker-bridge.js +27 -27
- package/src/DUST/subscribe-to-dust.js +7 -7
- package/src/InAppMessage/defer-in-app-message.js +1 -1
- package/src/InAppMessage/display/in-app-message-to-html.js +16 -16
- package/src/InAppMessage/display/modal-utils.js +2 -2
- package/src/InAppMessage/in-app-message-manager.js +64 -64
- package/src/InAppMessage/log-in-app-message-button-click.js +1 -1
- package/src/InAppMessage/log-in-app-message-click.js +1 -1
- package/src/InAppMessage/log-in-app-message-html-click.js +2 -2
- package/src/InAppMessage/log-in-app-message-impression.js +1 -1
- package/src/InAppMessage/models/full-screen-message.js +7 -7
- package/src/InAppMessage/models/html-message.js +1 -1
- package/src/InAppMessage/models/in-app-message-button.js +4 -4
- package/src/InAppMessage/models/in-app-message.js +22 -22
- package/src/InAppMessage/models/modal-message.js +5 -5
- package/src/InAppMessage/models/slide-up-message.js +6 -6
- package/src/InAppMessage/models/templated-in-app-message.js +8 -8
- package/src/InAppMessage/subscribe-to-in-app-message.js +1 -1
- package/src/InAppMessage/ui/automatically-show-in-app-messages.js +3 -3
- package/src/InAppMessage/ui/show-in-app-message.js +20 -20
- package/src/Push/push-manager-factory.js +2 -2
- package/src/Push/push-manager.js +8 -8
- package/src/Push/utils/push-utils.js +6 -6
- package/src/User/user-manager.js +5 -5
- package/src/User/user.js +8 -8
- package/src/common/constants.js +1 -0
- package/src/common/content-cards-display.js +2 -2
- package/src/l10n/l10n-manager-factory.js +1 -1
- package/src/l10n/l10n-manager.js +1 -1
- package/src/managers/braze-instance.js +21 -21
- package/src/managers/device-manager.js +6 -6
- package/src/managers/network-manager.js +93 -92
- package/src/managers/server-config-manager.js +68 -68
- package/src/managers/session-manager.js +2 -2
- package/src/managers/storage-manager-factory.js +4 -4
- package/src/managers/storage-manager.js +120 -120
- package/src/managers/subscription-manager.js +1 -1
- package/src/managers/utils.js +1 -1
- package/src/models/backend-errors.js +5 -5
- package/src/models/braze-event.js +3 -3
- package/src/models/device.js +1 -1
- package/src/models/identifier.js +3 -3
- package/src/models/push-token.js +5 -5
- package/src/models/server-config.js +27 -27
- package/src/request-controller.js +99 -99
- package/src/triggers/models/custom-event-data.js +4 -4
- package/src/triggers/models/custom-event-property-data.js +5 -5
- package/src/triggers/models/filter-set.js +2 -2
- package/src/triggers/models/filter.js +1 -1
- package/src/triggers/models/in-app-message-click-data.js +5 -5
- package/src/triggers/models/purchase-data.js +1 -1
- package/src/triggers/models/purchase-property-data.js +2 -2
- package/src/triggers/models/push-click-data.js +5 -5
- package/src/triggers/models/trigger-condition.js +42 -42
- package/src/triggers/models/trigger-events.js +2 -2
- package/src/triggers/models/trigger.js +10 -10
- package/src/triggers/triggers-provider-factory.js +1 -1
- package/src/triggers/triggers-provider.js +30 -30
- package/src/types.js +5 -1
- package/src/ui/js/attach-css.js +1 -1
- package/src/util/braze-actions.js +5 -5
- package/src/util/browser-detector.js +13 -13
- package/src/util/client-hints-parser.js +2 -2
- package/src/util/dom-utils.js +2 -2
- package/src/util/ecommerce-event-validation.js +326 -0
- package/src/util/iso-4217-currency-codes.js +176 -0
- package/src/util/net.js +3 -3
- package/src/util/request-header-utils.js +18 -18
- package/src/util/user-agent-parser.js +14 -14
- package/src/util/validation-utils.js +2 -2
- package/src/util/window-utils.js +2 -2
|
@@ -3,81 +3,78 @@ let te = null,
|
|
|
3
3
|
le = null,
|
|
4
4
|
ce = 0,
|
|
5
5
|
ae = null,
|
|
6
|
-
|
|
7
|
-
const
|
|
8
|
-
let
|
|
9
|
-
ue = null,
|
|
6
|
+
ie = !1;
|
|
7
|
+
const se = new Map();
|
|
8
|
+
let ue = null,
|
|
10
9
|
me = null,
|
|
11
10
|
de = null,
|
|
11
|
+
fe = null,
|
|
12
12
|
pe = null;
|
|
13
|
-
const
|
|
14
|
-
function
|
|
15
|
-
|
|
13
|
+
const Te = { Tn: null, Pe: null };
|
|
14
|
+
function Re(e) {
|
|
15
|
+
se.forEach((n, o) => {
|
|
16
16
|
try {
|
|
17
17
|
n.port.postMessage(e);
|
|
18
18
|
} catch (e) {
|
|
19
|
-
|
|
19
|
+
se.delete(o);
|
|
20
20
|
}
|
|
21
21
|
});
|
|
22
22
|
}
|
|
23
|
-
function
|
|
24
|
-
|
|
25
|
-
const e = ie.keys().next().value;
|
|
26
|
-
(de = e || null),
|
|
27
|
-
de && console.log("[Braze Real-Time] Elected leader port:", de);
|
|
23
|
+
function a(e, n) {
|
|
24
|
+
return Math.floor(Math.random() * (n - e + 1)) + e;
|
|
28
25
|
}
|
|
29
|
-
function ge(
|
|
30
|
-
if ((
|
|
26
|
+
function ge() {
|
|
27
|
+
if (fe && se.has(fe)) return;
|
|
28
|
+
const e = se.keys().next().value;
|
|
29
|
+
(fe = e || null),
|
|
30
|
+
fe && console.log("[Braze Real-Time] Elected leader port:", fe);
|
|
31
|
+
}
|
|
32
|
+
function he(e) {
|
|
33
|
+
if ((ge(), !fe))
|
|
31
34
|
return void console.warn("[Braze Real-Time] No leader to send message to");
|
|
32
|
-
const n =
|
|
35
|
+
const n = se.get(fe);
|
|
33
36
|
if (n)
|
|
34
37
|
try {
|
|
35
38
|
n.port.postMessage(e);
|
|
36
39
|
} catch (n) {
|
|
37
|
-
|
|
40
|
+
se.delete(fe), (fe = null), he(e);
|
|
38
41
|
}
|
|
39
42
|
}
|
|
40
|
-
function
|
|
41
|
-
(
|
|
43
|
+
function ze() {
|
|
44
|
+
(ie = !1),
|
|
42
45
|
null !== ae && (clearTimeout(ae), (ae = null)),
|
|
43
|
-
null !==
|
|
46
|
+
null !== de && (clearTimeout(de), (de = null)),
|
|
44
47
|
null !== pe && (clearTimeout(pe), (pe = null)),
|
|
45
|
-
te && (te.close(), (te = null),
|
|
48
|
+
te && (te.close(), (te = null), Re({ type: "disconnected" }));
|
|
46
49
|
}
|
|
47
|
-
function
|
|
50
|
+
function Be() {
|
|
48
51
|
if (!le) return;
|
|
49
52
|
ce++;
|
|
50
|
-
const {
|
|
51
|
-
let t =
|
|
53
|
+
const { Rn: e, Cn: n, Dn: o } = le.$n;
|
|
54
|
+
let t = ue;
|
|
52
55
|
(null == t || t < e) && (t = e);
|
|
53
|
-
const l = Math.min(
|
|
54
|
-
|
|
55
|
-
(
|
|
56
|
-
);
|
|
57
|
-
var c, a;
|
|
58
|
-
(se = l),
|
|
59
|
-
console.log(
|
|
60
|
-
"[Braze Real-Time] Retrying in " + l + "ms (attempt " + ce + "/5)",
|
|
61
|
-
),
|
|
56
|
+
const l = Math.min(n, a(e, t * o));
|
|
57
|
+
(ue = l),
|
|
58
|
+
console.log(`[Braze Real-Time] Retrying in ${l}ms (attempt ${ce}/5)`),
|
|
62
59
|
(ae = setTimeout(function () {
|
|
63
|
-
(ae = null),
|
|
60
|
+
(ae = null), Te.Tn();
|
|
64
61
|
}, l));
|
|
65
62
|
}
|
|
66
|
-
function
|
|
63
|
+
function ye(e) {
|
|
67
64
|
if (!le) return;
|
|
68
65
|
if (te && !e)
|
|
69
66
|
return void console.warn("[Braze Real-Time] Connection already exists");
|
|
70
|
-
if (
|
|
67
|
+
if (ie && !e)
|
|
71
68
|
return void console.warn(
|
|
72
69
|
"[Braze Real-Time] Connection attempt already in progress",
|
|
73
70
|
);
|
|
74
|
-
|
|
71
|
+
ie = !0;
|
|
75
72
|
const { Wi: n, mite: o, auth: t } = le,
|
|
76
|
-
l = /^https?:\/\//i.test(n) ? n :
|
|
77
|
-
let c =
|
|
78
|
-
t && (c +=
|
|
79
|
-
|
|
80
|
-
const a = l
|
|
73
|
+
l = /^https?:\/\//i.test(n) ? n : `https://${n}`;
|
|
74
|
+
let c = `mite=${encodeURIComponent(o)}&attempts=${ce}`;
|
|
75
|
+
t && (c += `&auth=${encodeURIComponent(t)}`),
|
|
76
|
+
me && (c += `&rcs=${encodeURIComponent(me)}`);
|
|
77
|
+
const a = `${l}/sse?${c}`;
|
|
81
78
|
try {
|
|
82
79
|
const n = new EventSource(a);
|
|
83
80
|
(n.onopen = function () {
|
|
@@ -88,13 +85,13 @@ function Be(e) {
|
|
|
88
85
|
e.close())
|
|
89
86
|
: console.log("[Braze Real-Time] Connection established"),
|
|
90
87
|
(te = n),
|
|
91
|
-
(
|
|
88
|
+
(ie = !1),
|
|
92
89
|
(ce = 0),
|
|
93
|
-
(
|
|
94
|
-
|
|
90
|
+
(ue = null),
|
|
91
|
+
Re({ type: "connected" });
|
|
95
92
|
}),
|
|
96
93
|
n.addEventListener("msg", function (e) {
|
|
97
|
-
|
|
94
|
+
Te.Pe(e.data);
|
|
98
95
|
}),
|
|
99
96
|
(n.onerror = function () {
|
|
100
97
|
if (
|
|
@@ -108,50 +105,50 @@ function Be(e) {
|
|
|
108
105
|
"[Braze Real-Time] Gapless reconnection failed, keeping old connection",
|
|
109
106
|
),
|
|
110
107
|
n.close(),
|
|
111
|
-
(
|
|
112
|
-
void (ce < 5 &&
|
|
108
|
+
(ie = !1),
|
|
109
|
+
void (ce < 5 && Be())
|
|
113
110
|
);
|
|
114
|
-
|
|
111
|
+
ze(),
|
|
115
112
|
ce < 5
|
|
116
|
-
?
|
|
113
|
+
? Be()
|
|
117
114
|
: (console.error("[Braze Real-Time] Max retries reached"),
|
|
118
|
-
|
|
115
|
+
Re({ type: "error", error: "Max retry attempts reached" }));
|
|
119
116
|
});
|
|
120
117
|
} catch (e) {
|
|
121
|
-
(
|
|
118
|
+
(ie = !1),
|
|
122
119
|
console.error("[Braze Real-Time] Failed to create EventSource:", e),
|
|
123
|
-
|
|
120
|
+
Re({ type: "error", error: String(e) });
|
|
124
121
|
}
|
|
125
122
|
}
|
|
126
|
-
function
|
|
123
|
+
function $e(e, n, o) {
|
|
127
124
|
switch (o.type) {
|
|
128
125
|
case "connect":
|
|
129
126
|
!le ||
|
|
130
127
|
(le.mite === o.zn.mite && le.Wi === o.zn.Wi) ||
|
|
131
128
|
(console.log("[Braze Real-Time] Config changed, reconnecting"),
|
|
132
|
-
|
|
129
|
+
ze(),
|
|
133
130
|
(ce = 0),
|
|
134
|
-
(
|
|
135
|
-
(
|
|
131
|
+
(ue = null),
|
|
132
|
+
(me = null)),
|
|
136
133
|
(le = o.zn),
|
|
137
|
-
|
|
138
|
-
te ||
|
|
134
|
+
ge(),
|
|
135
|
+
te || ie ? te && e.postMessage({ type: "connected" }) : ye();
|
|
139
136
|
break;
|
|
140
137
|
case "disconnect":
|
|
141
|
-
|
|
142
|
-
n ===
|
|
143
|
-
0 ===
|
|
138
|
+
se.delete(n),
|
|
139
|
+
n === fe && ((fe = null), ge()),
|
|
140
|
+
0 === se.size &&
|
|
144
141
|
(console.log("[Braze Real-Time] No more ports, closing connection"),
|
|
145
|
-
|
|
142
|
+
ze(),
|
|
146
143
|
(le = null),
|
|
147
|
-
(
|
|
148
|
-
(
|
|
144
|
+
(me = null),
|
|
145
|
+
(fe = null));
|
|
149
146
|
break;
|
|
150
147
|
case "tab_active":
|
|
151
148
|
!(function (e) {
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
((
|
|
149
|
+
se.has(e) &&
|
|
150
|
+
fe !== e &&
|
|
151
|
+
((fe = e),
|
|
155
152
|
console.log(
|
|
156
153
|
"[Braze Real-Time] Promoted to leader (tab became active):",
|
|
157
154
|
e,
|
|
@@ -165,57 +162,53 @@ function ye(e, n, o) {
|
|
|
165
162
|
console.warn("[Braze Real-Time] Unknown message type:", o.type);
|
|
166
163
|
}
|
|
167
164
|
}
|
|
168
|
-
(
|
|
169
|
-
(
|
|
165
|
+
(Te.Tn = ye),
|
|
166
|
+
(Te.Pe = function (e) {
|
|
170
167
|
try {
|
|
171
168
|
const t = JSON.parse(e);
|
|
172
169
|
if (!t.type)
|
|
173
170
|
return void console.warn("[Braze Real-Time] Message without type:", t);
|
|
174
171
|
if ("ttl" === t.type && t.body)
|
|
175
172
|
return (
|
|
176
|
-
(n = t.body.
|
|
177
|
-
(o = t.body.
|
|
173
|
+
(n = t.body.ln),
|
|
174
|
+
(o = t.body.cn),
|
|
178
175
|
void (
|
|
179
176
|
"number" == typeof n &&
|
|
180
|
-
("string" == typeof o && (
|
|
177
|
+
("string" == typeof o && (me = o),
|
|
181
178
|
console.log(
|
|
182
|
-
|
|
183
|
-
n +
|
|
184
|
-
"ms, will perform gapless reconnection when expired",
|
|
179
|
+
`[Braze Real-Time] TTL set to ${n}ms, will perform gapless reconnection when expired`,
|
|
185
180
|
),
|
|
186
|
-
null !==
|
|
187
|
-
(
|
|
188
|
-
(
|
|
181
|
+
null !== de && clearTimeout(de),
|
|
182
|
+
(de = setTimeout(function () {
|
|
183
|
+
(de = null),
|
|
189
184
|
console.log(
|
|
190
185
|
"[Braze Real-Time] TTL expired, performing gapless reconnection",
|
|
191
186
|
),
|
|
192
|
-
|
|
187
|
+
ye(te || void 0);
|
|
193
188
|
}, n)))
|
|
194
189
|
)
|
|
195
190
|
);
|
|
196
191
|
if ("ddr" === t.type && t.body)
|
|
197
192
|
return void (function (e, n) {
|
|
198
193
|
if ("number" != typeof e) return;
|
|
199
|
-
const o =
|
|
200
|
-
t =
|
|
201
|
-
l =
|
|
194
|
+
const o = null == le ? void 0 : le.$n,
|
|
195
|
+
t = (null == o ? void 0 : o.Rn) || 1e4,
|
|
196
|
+
l = (null == o ? void 0 : o.Dn) || 3,
|
|
197
|
+
c = (null == o ? void 0 : o.Cn) || 3e5,
|
|
198
|
+
r = Math.min(c, a(t, t * l)),
|
|
199
|
+
i = Math.round(e + r),
|
|
200
|
+
s = n ? ` (${n})` : "";
|
|
202
201
|
console.log(
|
|
203
|
-
|
|
204
|
-
l +
|
|
205
|
-
", reconnecting in " +
|
|
206
|
-
t +
|
|
207
|
-
"ms",
|
|
202
|
+
`[Braze Real-Time] Admin requested disconnect${s}, reconnecting in ${i}ms (r_ms=${e} + backoff=${r})`,
|
|
208
203
|
),
|
|
209
204
|
null !== pe && clearTimeout(pe),
|
|
210
|
-
|
|
205
|
+
ze(),
|
|
211
206
|
(pe = setTimeout(function () {
|
|
212
|
-
(pe = null),
|
|
213
|
-
},
|
|
214
|
-
})(t.body.
|
|
215
|
-
console.log(
|
|
216
|
-
|
|
217
|
-
),
|
|
218
|
-
ge({ type: "message", data: t });
|
|
207
|
+
(pe = null), Te.Tn();
|
|
208
|
+
}, i));
|
|
209
|
+
})(t.body.on, t.body.e);
|
|
210
|
+
console.log(`[Braze Real-Time] Routing '${t.type}' message to leader`),
|
|
211
|
+
he({ type: "message", data: t });
|
|
219
212
|
} catch (e) {
|
|
220
213
|
console.warn("[Braze Real-Time] Failed to parse message:", e);
|
|
221
214
|
}
|
|
@@ -223,18 +216,18 @@ function ye(e, n, o) {
|
|
|
223
216
|
}),
|
|
224
217
|
(oe.onconnect = function (e) {
|
|
225
218
|
const n = e.ports[0],
|
|
226
|
-
o =
|
|
227
|
-
|
|
219
|
+
o = `port-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
|
|
220
|
+
se.set(o, { port: n }),
|
|
228
221
|
(n.onmessage = function (e) {
|
|
229
222
|
try {
|
|
230
|
-
|
|
223
|
+
$e(n, o, e.data);
|
|
231
224
|
} catch (e) {
|
|
232
225
|
console.error("[Braze Real-Time] Error handling message:", e);
|
|
233
226
|
}
|
|
234
227
|
}),
|
|
235
228
|
(n.onmessageerror = function () {
|
|
236
229
|
console.warn("[Braze Real-Time] Message error from port:", o),
|
|
237
|
-
|
|
230
|
+
se.delete(o);
|
|
238
231
|
}),
|
|
239
232
|
n.start();
|
|
240
233
|
});
|
|
@@ -6,14 +6,14 @@ export function isSharedWorkerSupported() {
|
|
|
6
6
|
export class DustWorkerBridge {
|
|
7
7
|
constructor(i) {
|
|
8
8
|
(this.Wr = null),
|
|
9
|
-
(this.
|
|
9
|
+
(this.Rr = null),
|
|
10
10
|
(this.isConnected = !1),
|
|
11
|
+
(this.Lr = null),
|
|
11
12
|
(this.Ir = null),
|
|
12
|
-
(this.
|
|
13
|
-
(this.
|
|
14
|
-
(this.
|
|
15
|
-
(this.
|
|
16
|
-
(this.Je = i.Je);
|
|
13
|
+
(this.Ge = i.Ge),
|
|
14
|
+
(this.qe = i.qe),
|
|
15
|
+
(this.Je = i.Je),
|
|
16
|
+
(this.Le = i.Le);
|
|
17
17
|
}
|
|
18
18
|
initialize() {
|
|
19
19
|
if (!isSharedWorkerSupported())
|
|
@@ -23,10 +23,10 @@ export class DustWorkerBridge {
|
|
|
23
23
|
try {
|
|
24
24
|
const i = new Blob([ri], { type: "application/javascript" });
|
|
25
25
|
return (
|
|
26
|
-
(this.
|
|
27
|
-
(this.Wr = new SharedWorker(this.
|
|
26
|
+
(this.Rr = URL.createObjectURL(i)),
|
|
27
|
+
(this.Wr = new SharedWorker(this.Rr, { name: "braze-dust-worker" })),
|
|
28
28
|
(this.Wr.port.onmessage = (i) => {
|
|
29
|
-
this.
|
|
29
|
+
this.Mr(i.data);
|
|
30
30
|
}),
|
|
31
31
|
(this.Wr.port.onmessageerror = () => {
|
|
32
32
|
E.warn("Message error from real-time messaging worker");
|
|
@@ -36,13 +36,13 @@ export class DustWorkerBridge {
|
|
|
36
36
|
E.error(
|
|
37
37
|
`Real-time messaging worker error: ${i.message || "unknown error"}`,
|
|
38
38
|
),
|
|
39
|
-
null === (e = this.
|
|
39
|
+
null === (e = this.Le) ||
|
|
40
40
|
void 0 === e ||
|
|
41
41
|
e.call(this, "SharedWorker error");
|
|
42
42
|
}),
|
|
43
43
|
this.Wr.port.start(),
|
|
44
|
+
this.Ur(),
|
|
44
45
|
this.Vr(),
|
|
45
|
-
this.Er(),
|
|
46
46
|
E.info("Real-time messaging worker initialized"),
|
|
47
47
|
!0
|
|
48
48
|
);
|
|
@@ -58,47 +58,47 @@ export class DustWorkerBridge {
|
|
|
58
58
|
);
|
|
59
59
|
}
|
|
60
60
|
}
|
|
61
|
-
|
|
61
|
+
Mr(i) {
|
|
62
62
|
var e, t, s;
|
|
63
63
|
switch (i.type) {
|
|
64
64
|
case "connected":
|
|
65
65
|
E.info("Real-time messaging connection established via SharedWorker"),
|
|
66
66
|
(this.isConnected = !0),
|
|
67
|
-
null === (e = this.
|
|
67
|
+
null === (e = this.qe) || void 0 === e || e.call(this);
|
|
68
68
|
break;
|
|
69
69
|
case "disconnected":
|
|
70
70
|
E.info("Real-time messaging connection closed via SharedWorker"),
|
|
71
71
|
(this.isConnected = !1),
|
|
72
|
-
null === (t = this.
|
|
72
|
+
null === (t = this.Je) || void 0 === t || t.call(this);
|
|
73
73
|
break;
|
|
74
74
|
case "message":
|
|
75
|
-
this.
|
|
75
|
+
this.Ge(i.data);
|
|
76
76
|
break;
|
|
77
77
|
case "error":
|
|
78
78
|
E.error(`Real-time messaging error: ${i.error}`),
|
|
79
|
-
null === (s = this.
|
|
79
|
+
null === (s = this.Le) || void 0 === s || s.call(this, i.error);
|
|
80
80
|
}
|
|
81
81
|
}
|
|
82
|
-
|
|
83
|
-
this.
|
|
82
|
+
Ur() {
|
|
83
|
+
this.Lr = window.setInterval(() => {
|
|
84
84
|
this.Wr && this.Gr({ type: "ping" });
|
|
85
85
|
}, 3e4);
|
|
86
86
|
}
|
|
87
87
|
Jr() {
|
|
88
|
-
null !== this.
|
|
88
|
+
null !== this.Lr && (window.clearInterval(this.Lr), (this.Lr = null));
|
|
89
89
|
}
|
|
90
|
-
|
|
91
|
-
(this.
|
|
90
|
+
Vr() {
|
|
91
|
+
(this.Ir = () => {
|
|
92
92
|
"visible" === document.visibilityState &&
|
|
93
93
|
this.Wr &&
|
|
94
94
|
this.Gr({ type: "tab_active" });
|
|
95
95
|
}),
|
|
96
|
-
document.addEventListener("visibilitychange", this.
|
|
96
|
+
document.addEventListener("visibilitychange", this.Ir);
|
|
97
97
|
}
|
|
98
98
|
Kr() {
|
|
99
|
-
this.
|
|
100
|
-
(document.removeEventListener("visibilitychange", this.
|
|
101
|
-
(this.
|
|
99
|
+
this.Ir &&
|
|
100
|
+
(document.removeEventListener("visibilitychange", this.Ir),
|
|
101
|
+
(this.Ir = null));
|
|
102
102
|
}
|
|
103
103
|
Gr(i) {
|
|
104
104
|
this.Wr && this.Wr.port.postMessage(i);
|
|
@@ -115,7 +115,7 @@ export class DustWorkerBridge {
|
|
|
115
115
|
(this.isConnected = !1),
|
|
116
116
|
E.info("Disconnecting from real-time messaging"));
|
|
117
117
|
}
|
|
118
|
-
|
|
118
|
+
Ie() {
|
|
119
119
|
return this.isConnected;
|
|
120
120
|
}
|
|
121
121
|
isInitialized() {
|
|
@@ -125,7 +125,7 @@ export class DustWorkerBridge {
|
|
|
125
125
|
this.Jr(),
|
|
126
126
|
this.Kr(),
|
|
127
127
|
this.Wr && (this.Wr.port.close(), (this.Wr = null)),
|
|
128
|
-
this.
|
|
128
|
+
this.Rr && (URL.revokeObjectURL(this.Rr), (this.Rr = null)),
|
|
129
129
|
(this.isConnected = !1);
|
|
130
130
|
}
|
|
131
131
|
destroy() {
|
|
@@ -1,24 +1,24 @@
|
|
|
1
1
|
import r from "../managers/braze-instance.js";
|
|
2
|
-
import
|
|
2
|
+
import dr from "./dust-provider-factory.js";
|
|
3
3
|
export function subscribeToDust() {
|
|
4
4
|
const t = r.l(),
|
|
5
5
|
n = r.nn();
|
|
6
6
|
if (!t || !n) return null;
|
|
7
|
-
const o =
|
|
7
|
+
const o = dr.o(),
|
|
8
8
|
s = () => {
|
|
9
9
|
if (!o.Lt()) {
|
|
10
|
-
o.
|
|
10
|
+
o.dn();
|
|
11
11
|
const r = n.rn(() => {
|
|
12
|
-
t.
|
|
12
|
+
t.vn() && o.pn();
|
|
13
13
|
});
|
|
14
|
-
return r && o.$t(r), o.
|
|
14
|
+
return r && o.$t(r), o.gn() && o.an(), r;
|
|
15
15
|
}
|
|
16
16
|
return o.Lt();
|
|
17
17
|
};
|
|
18
18
|
return (
|
|
19
19
|
t.Tr(() => {
|
|
20
|
-
r.ao() && (t.
|
|
20
|
+
r.ao() && (t.vn() ? (o.pn(), s()) : (o.hn(), o.gn() && o.sn()));
|
|
21
21
|
}),
|
|
22
|
-
t.
|
|
22
|
+
t.vn() ? s() : null
|
|
23
23
|
);
|
|
24
24
|
}
|
|
@@ -8,6 +8,6 @@ export function deferInAppMessage(e) {
|
|
|
8
8
|
return e instanceof ControlMessage
|
|
9
9
|
? (E.info("Not deferring since this is a ControlMessage."), !1)
|
|
10
10
|
: e instanceof InAppMessage
|
|
11
|
-
? je.ra().
|
|
11
|
+
? je.ra().An(e)
|
|
12
12
|
: (E.info("Not an instance of InAppMessage, ignoring."), !1);
|
|
13
13
|
}
|
|
@@ -17,16 +17,16 @@ import xe from "./modal-utils.js";
|
|
|
17
17
|
import { logger as E, Guid as V } from "../../../shared-lib/index.js";
|
|
18
18
|
import { KeyCodes as Ce } from "../../util/key-codes.js";
|
|
19
19
|
import {
|
|
20
|
-
IamClickAction as
|
|
21
|
-
IamCropType as
|
|
22
|
-
IamDisplayFailures as
|
|
23
|
-
IamImageStyle as
|
|
20
|
+
IamClickAction as Le,
|
|
21
|
+
IamCropType as Me,
|
|
22
|
+
IamDisplayFailures as qe,
|
|
23
|
+
IamImageStyle as Ae,
|
|
24
24
|
IamOpenTarget as ut,
|
|
25
|
-
IamOrientation as
|
|
26
|
-
IamSlideFrom as
|
|
27
|
-
IamTextAlignment as
|
|
25
|
+
IamOrientation as De,
|
|
26
|
+
IamSlideFrom as Ee,
|
|
27
|
+
IamTextAlignment as Fe,
|
|
28
28
|
} from "../constants.js";
|
|
29
|
-
export default function
|
|
29
|
+
export default function Ge(e, o, t, a, n, i, s = document.body, m = "ltr") {
|
|
30
30
|
if (((e.$o = document.activeElement), e instanceof HtmlMessage))
|
|
31
31
|
return ft(e, o, a, n, i);
|
|
32
32
|
const l = (function (e, o, t, a, n, i = document.body, s = "ltr") {
|
|
@@ -48,7 +48,7 @@ export default function Fe(e, o, t, a, n, i, s = document.body, m = "ltr") {
|
|
|
48
48
|
document.querySelectorAll(".ab-iam-img-loading").length > 0
|
|
49
49
|
? t(
|
|
50
50
|
`Cannot show in-app message ${e.message} because another message is being shown.`,
|
|
51
|
-
|
|
51
|
+
qe.tE,
|
|
52
52
|
)
|
|
53
53
|
: o(l));
|
|
54
54
|
},
|
|
@@ -66,15 +66,15 @@ export default function Fe(e, o, t, a, n, i, s = document.body, m = "ltr") {
|
|
|
66
66
|
));
|
|
67
67
|
};
|
|
68
68
|
if (
|
|
69
|
-
(e.imageStyle ===
|
|
70
|
-
e.orientation ===
|
|
69
|
+
(e.imageStyle === Ae.GRAPHIC && (l.className += " graphic"),
|
|
70
|
+
e.orientation === De.LANDSCAPE && (l.className += " landscape"),
|
|
71
71
|
null != e.buttons && 0 === e.buttons.length)
|
|
72
72
|
) {
|
|
73
|
-
e.clickAction !==
|
|
73
|
+
e.clickAction !== Le.NONE && (l.className += " ab-clickable");
|
|
74
74
|
const o = (o) => (
|
|
75
75
|
e.tl(l, () => {
|
|
76
76
|
logInAppMessageClick(e),
|
|
77
|
-
e.clickAction ===
|
|
77
|
+
e.clickAction === Le.URI &&
|
|
78
78
|
Q(e.uri || "", a || e.openTarget === ut.BLANK, o);
|
|
79
79
|
}),
|
|
80
80
|
o.stopPropagation(),
|
|
@@ -122,7 +122,7 @@ export default function Fe(e, o, t, a, n, i, s = document.body, m = "ltr") {
|
|
|
122
122
|
r(!1);
|
|
123
123
|
});
|
|
124
124
|
}
|
|
125
|
-
if (e.cropType ===
|
|
125
|
+
if (e.cropType === Me.CENTER_CROP) {
|
|
126
126
|
const e = document.createElement("div");
|
|
127
127
|
(e.className = "ab-center-cropped-img"),
|
|
128
128
|
e.appendChild(o),
|
|
@@ -148,7 +148,7 @@ export default function Fe(e, o, t, a, n, i, s = document.body, m = "ltr") {
|
|
|
148
148
|
if ((F(u, "touchstart"), e.header && e.header.length > 0)) {
|
|
149
149
|
const o = document.createElement("h1");
|
|
150
150
|
(o.className = "ab-message-header"), (e.Jo = V.de()), (o.id = e.Jo);
|
|
151
|
-
const t = (e.headerAlignment ||
|
|
151
|
+
const t = (e.headerAlignment || Fe.CENTER).toLowerCase();
|
|
152
152
|
(o.className += " " + t + "-aligned"),
|
|
153
153
|
e.Mo() || (o.style.color = ke(e.headerTextColor)),
|
|
154
154
|
o.appendChild(document.createTextNode(e.header)),
|
|
@@ -185,7 +185,7 @@ export default function Fe(e, o, t, a, n, i, s = document.body, m = "ltr") {
|
|
|
185
185
|
(l.className += " ab-swiped-right"),
|
|
186
186
|
null != o && null != o.onclick && o.onclick(e);
|
|
187
187
|
}),
|
|
188
|
-
e.slideFrom ===
|
|
188
|
+
e.slideFrom === Ee.TOP
|
|
189
189
|
? ((t = P.Uo), (a = " ab-swiped-up"))
|
|
190
190
|
: ((t = P.Vo), (a = " ab-swiped-down")),
|
|
191
191
|
O(l, t, (e) => {
|
|
@@ -3,7 +3,7 @@ import { logInAppMessageButtonClick } from "../log-in-app-message-button-click.j
|
|
|
3
3
|
import { toRgba as ke } from "../../util/color-utils.js";
|
|
4
4
|
import { addPassiveEventListener as F } from "../../util/dom-utils.js";
|
|
5
5
|
import { KeyCodes as Ce } from "../../util/key-codes.js";
|
|
6
|
-
import { IamClickAction as
|
|
6
|
+
import { IamClickAction as Le, IamOpenTarget as ut } from "../constants.js";
|
|
7
7
|
const xe = {
|
|
8
8
|
Po: (t) => {
|
|
9
9
|
const o = t.querySelectorAll(".ab-close-button, .ab-message-button");
|
|
@@ -39,7 +39,7 @@ const xe = {
|
|
|
39
39
|
const l = (s) => (a) => (
|
|
40
40
|
t.tl(o, () => {
|
|
41
41
|
logInAppMessageButtonClick(s, t),
|
|
42
|
-
s.clickAction ===
|
|
42
|
+
s.clickAction === Le.URI &&
|
|
43
43
|
Q(s.uri || "", e || t.openTarget === ut.BLANK, a);
|
|
44
44
|
}),
|
|
45
45
|
a.stopPropagation(),
|