@braze/web-sdk 5.4.0 → 5.5.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 +3 -3
- package/package.json +1 -1
- package/shared-lib/event-types.js +12 -12
- package/shared-lib/indexed-db-adapter.js +14 -14
- package/shared-lib/logger.js +2 -2
- package/shared-lib/supported-options.js +5 -5
- package/src/Card/card-manager.js +46 -42
- package/src/Card/models/card.js +61 -55
- package/src/Card/models/classic-card.js +1 -1
- package/src/Card/models/control-card.js +1 -1
- package/src/Card/models/image-only.js +1 -1
- package/src/Card/util/card-factory.js +20 -20
- package/src/ContentCards/content-cards-provider.js +140 -140
- 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 +4 -4
- package/src/ContentCards/ui/show-content-cards.js +3 -3
- package/src/Core/disable-sdk.js +2 -2
- package/src/Core/enable-sdk.js +2 -2
- package/src/Core/log-custom-event.js +14 -14
- package/src/Core/log-purchase.js +8 -8
- package/src/Core/open-session.js +4 -4
- package/src/Core/wipe-data.js +2 -2
- package/src/FeatureFlags/feature-flag-factory.js +5 -5
- package/src/FeatureFlags/feature-flag.js +1 -1
- package/src/FeatureFlags/feature-flags-provider.js +74 -74
- package/src/FeatureFlags/get-all-feature-flags.js +2 -2
- package/src/FeatureFlags/get-feature-flag.js +2 -2
- package/src/FeatureFlags/log-feature-flag-impression.js +12 -12
- package/src/FeatureFlags/subscribe-to-feature-flags-updates.js +2 -2
- package/src/Feed/feed-provider.js +29 -29
- package/src/Feed/get-cached-feed.js +1 -1
- package/src/Feed/request-feed-refresh.js +1 -1
- package/src/Feed/subscribe-to-feed-updates.js +1 -1
- package/src/Feed/ui/show-feed.js +1 -1
- package/src/InAppMessage/in-app-message-manager.js +63 -63
- package/src/InAppMessage/log-in-app-message-button-click.js +2 -2
- package/src/InAppMessage/log-in-app-message-click.js +2 -2
- 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 +10 -10
- package/src/InAppMessage/models/html-message.js +13 -13
- package/src/InAppMessage/models/in-app-message-button.js +4 -4
- package/src/InAppMessage/models/in-app-message.js +59 -59
- package/src/InAppMessage/models/modal-message.js +9 -9
- package/src/InAppMessage/models/slide-up-message.js +11 -11
- package/src/InAppMessage/models/templated-in-app-message.js +8 -8
- package/src/Push/push-manager-factory.js +4 -4
- package/src/Push/push-manager.js +6 -6
- package/src/Push/utils/push-utils.js +1 -1
- package/src/User/user-manager.js +6 -6
- package/src/User/user.js +27 -27
- package/src/common/base-provider.js +1 -1
- package/src/common/event-logger.js +7 -7
- package/src/common/feed-display.js +1 -1
- package/src/managers/auth-manager.js +9 -9
- package/src/managers/braze-instance.js +44 -44
- package/src/managers/network-manager.js +100 -100
- package/src/managers/server-config-manager.js +24 -24
- package/src/managers/session-manager.js +10 -10
- package/src/managers/storage-manager.js +20 -20
- package/src/managers/subscription-manager.js +2 -2
- package/src/models/backend-errors.js +4 -4
- package/src/models/braze-event.js +1 -1
- package/src/models/device.js +1 -1
- package/src/models/request-result.js +1 -1
- package/src/models/server-config.js +5 -5
- package/src/request-controller.js +121 -121
- package/src/triggers/models/filter.js +9 -9
- package/src/triggers/models/trigger-condition.js +26 -26
- package/src/triggers/models/trigger-events.js +1 -1
- package/src/triggers/models/trigger.js +7 -7
- package/src/triggers/triggers-provider.js +27 -27
- package/src/ui/js/attach-css.js +1 -1
- package/src/util/braze-actions.js +4 -4
- package/src/util/net.js +4 -4
- package/src/util/request-header-utils.js +17 -17
package/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* Type definitions for @braze/web-sdk v5.
|
|
2
|
+
* Type definitions for @braze/web-sdk v5.5.0
|
|
3
3
|
* Project: https://github.com/braze-inc/braze-web-sdk
|
|
4
4
|
* (c) Braze, Inc. 2024 - http://braze.com
|
|
5
5
|
* License available at https://github.com/braze-inc/braze-web-sdk/blob/master/LICENSE
|
|
@@ -2138,7 +2138,7 @@ export function openSession(): void;
|
|
|
2138
2138
|
* - Create a `service-worker.js` file with the content below and place it in the root directory of your website:
|
|
2139
2139
|
*
|
|
2140
2140
|
* ```
|
|
2141
|
-
* self.importScripts('https://js.appboycdn.com/web-sdk-develop/5.
|
|
2141
|
+
* self.importScripts('https://js.appboycdn.com/web-sdk-develop/5.5/service-worker.js');
|
|
2142
2142
|
* ```
|
|
2143
2143
|
*
|
|
2144
2144
|
* For more details, see [Our Product Documentation](https://www.braze.com/docs/developer_guide/platform_integration_guides/web/push_notifications/integration).
|
|
@@ -2518,7 +2518,7 @@ export type InitializationOptions = {
|
|
|
2518
2518
|
* lifecycle of, set this option to true and the Braze SDK will not register or unregister a service worker. If you set this
|
|
2519
2519
|
* option to true, in order for push to function correctly you must register the service worker yourself BEFORE calling
|
|
2520
2520
|
* `requestPushPermission`, and ensure that it contains Braze's service worker code, either with
|
|
2521
|
-
* `self.importScripts('https://js.appboycdn.com/web-sdk-develop/5.
|
|
2521
|
+
* `self.importScripts('https://js.appboycdn.com/web-sdk-develop/5.5/service-worker.js');` or by including the content
|
|
2522
2522
|
* of that file directly. When this option is true, the `serviceWorkerLocation` option is irrelevant and is ignored.
|
|
2523
2523
|
*/
|
|
2524
2524
|
manageServiceWorkerExternally?: boolean;
|
package/package.json
CHANGED
|
@@ -1,33 +1,33 @@
|
|
|
1
1
|
const i = {
|
|
2
2
|
CustomEvent: "ce",
|
|
3
3
|
Pr: "p",
|
|
4
|
-
|
|
4
|
+
Ku: "pc",
|
|
5
5
|
vc: "ca",
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
Ua: "i",
|
|
7
|
+
Ls: "ie",
|
|
8
8
|
M: "cci",
|
|
9
9
|
R: "ccic",
|
|
10
|
-
|
|
10
|
+
k: "ccc",
|
|
11
11
|
F: "ccd",
|
|
12
12
|
ql: "ss",
|
|
13
13
|
xl: "se",
|
|
14
|
-
|
|
14
|
+
Xi: "si",
|
|
15
15
|
$i: "sc",
|
|
16
|
-
|
|
16
|
+
Oi: "sbc",
|
|
17
17
|
Cc: "sfe",
|
|
18
18
|
mo: "iec",
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
Ju: "lr",
|
|
20
|
+
Eu: "uae",
|
|
21
21
|
O: "ci",
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
22
|
+
D: "cc",
|
|
23
|
+
Xu: "lcaa",
|
|
24
|
+
Gu: "lcar",
|
|
25
25
|
On: "inc",
|
|
26
26
|
Ln: "add",
|
|
27
27
|
Rn: "rem",
|
|
28
28
|
$n: "set",
|
|
29
29
|
Bn: "ncam",
|
|
30
|
-
|
|
30
|
+
Hu: "sgu",
|
|
31
31
|
Fr: "ffi",
|
|
32
32
|
},
|
|
33
33
|
or = { Ar: "feed_displayed", Ec: "content_cards_displayed" };
|
|
@@ -64,11 +64,11 @@ export default class A {
|
|
|
64
64
|
"...",
|
|
65
65
|
);
|
|
66
66
|
const n = null === (e = t.target) || void 0 === e ? void 0 : e.result;
|
|
67
|
-
for (const t in i.database.
|
|
67
|
+
for (const t in i.database.hs) {
|
|
68
68
|
const e = t;
|
|
69
|
-
i.database.
|
|
70
|
-
!n.objectStoreNames.contains(i.database.
|
|
71
|
-
n.createObjectStore(i.database.
|
|
69
|
+
i.database.hs.hasOwnProperty(t) &&
|
|
70
|
+
!n.objectStoreNames.contains(i.database.hs[e]) &&
|
|
71
|
+
n.createObjectStore(i.database.hs[e]);
|
|
72
72
|
}
|
|
73
73
|
}),
|
|
74
74
|
(o.onsuccess = (n) => {
|
|
@@ -249,7 +249,7 @@ export default class A {
|
|
|
249
249
|
};
|
|
250
250
|
});
|
|
251
251
|
}
|
|
252
|
-
|
|
252
|
+
ss(t, e) {
|
|
253
253
|
if (!this.isSupported()) return !1;
|
|
254
254
|
const n = this;
|
|
255
255
|
return this.Bd((o) => {
|
|
@@ -304,11 +304,11 @@ export default class A {
|
|
|
304
304
|
clearData() {
|
|
305
305
|
if (!this.isSupported()) return !1;
|
|
306
306
|
const t = [];
|
|
307
|
-
for (const e in this.database.
|
|
307
|
+
for (const e in this.database.hs) {
|
|
308
308
|
const n = e;
|
|
309
|
-
this.database.
|
|
310
|
-
this.database.
|
|
311
|
-
t.push(this.database.
|
|
309
|
+
this.database.hs.hasOwnProperty(e) &&
|
|
310
|
+
this.database.hs[n] !== this.database.hs.ae &&
|
|
311
|
+
t.push(this.database.hs[n]);
|
|
312
312
|
}
|
|
313
313
|
const e = this;
|
|
314
314
|
return this.Bd(function (n) {
|
|
@@ -333,16 +333,16 @@ export default class A {
|
|
|
333
333
|
});
|
|
334
334
|
}
|
|
335
335
|
}
|
|
336
|
-
A.
|
|
337
|
-
|
|
336
|
+
A.ts = {
|
|
337
|
+
Zt: {
|
|
338
338
|
Sd: "AppboyServiceWorkerAsyncStorage",
|
|
339
339
|
VERSION: 6,
|
|
340
|
-
|
|
341
|
-
|
|
340
|
+
hs: {
|
|
341
|
+
Ka: "data",
|
|
342
342
|
hr: "pushClicks",
|
|
343
343
|
cu: "pushSubscribed",
|
|
344
344
|
Cd: "fallbackDevice",
|
|
345
|
-
|
|
345
|
+
es: "cardUpdates",
|
|
346
346
|
ae: "optOut",
|
|
347
347
|
wr: "pendingData",
|
|
348
348
|
jh: "sdkAuthenticationSignature",
|
package/shared-lib/logger.js
CHANGED
|
@@ -24,13 +24,13 @@ const r = {
|
|
|
24
24
|
},
|
|
25
25
|
warn: function (n) {
|
|
26
26
|
if (r.zg) {
|
|
27
|
-
const o = "Braze SDK Warning: " + n + " (v5.
|
|
27
|
+
const o = "Braze SDK Warning: " + n + " (v5.5.0)";
|
|
28
28
|
null != r.vd ? r.vd(o) : console.warn(o);
|
|
29
29
|
}
|
|
30
30
|
},
|
|
31
31
|
error: function (n) {
|
|
32
32
|
if (r.zg) {
|
|
33
|
-
const o = "Braze SDK Error: " + n + " (v5.
|
|
33
|
+
const o = "Braze SDK Error: " + n + " (v5.5.0)";
|
|
34
34
|
null != r.vd ? r.vd(o) : console.error(o);
|
|
35
35
|
}
|
|
36
36
|
},
|
|
@@ -3,16 +3,16 @@ export default {
|
|
|
3
3
|
_o: "baseUrl",
|
|
4
4
|
Io: "noCookies",
|
|
5
5
|
So: "devicePropertyAllowlist",
|
|
6
|
-
|
|
6
|
+
Aa: "disablePushTokenMaintenance",
|
|
7
7
|
Ao: "enableLogging",
|
|
8
8
|
No: "enableSdkAuthentication",
|
|
9
|
-
|
|
9
|
+
qa: "manageServiceWorkerExternally",
|
|
10
10
|
Oo: "minimumIntervalBetweenTriggerActionsInSeconds",
|
|
11
11
|
Ro: "sessionTimeoutInSeconds",
|
|
12
12
|
Po: "appVersion",
|
|
13
13
|
Lo: "appVersionNumber",
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
Ma: "serviceWorkerLocation",
|
|
15
|
+
ka: "safariWebsitePushId",
|
|
16
16
|
zn: "localization",
|
|
17
17
|
bo: "contentSecurityNonce",
|
|
18
18
|
Do: "allowUserSuppliedJavascript",
|
|
@@ -22,7 +22,7 @@ export default {
|
|
|
22
22
|
Lh: "requireExplicitInAppMessageDismissal",
|
|
23
23
|
Mo: "doNotLoadFontAwesome",
|
|
24
24
|
Uo: "deviceId",
|
|
25
|
-
|
|
25
|
+
_a: "serviceWorkerScope",
|
|
26
26
|
Wo: "sdkFlavor",
|
|
27
27
|
tn: "openCardsInNewTab",
|
|
28
28
|
};
|
package/src/Card/card-manager.js
CHANGED
|
@@ -1,30 +1,30 @@
|
|
|
1
1
|
import { ControlCard } from "./models/index.js";
|
|
2
|
-
import
|
|
3
|
-
import
|
|
2
|
+
import t from "../common/event-logger.js";
|
|
3
|
+
import s from "../models/request-result.js";
|
|
4
4
|
import { logger as r, EventTypes as i } from "../../shared-lib/index.js";
|
|
5
5
|
import { STORAGE_KEYS as o } from "../managers/storage-manager.js";
|
|
6
6
|
export default class a {
|
|
7
|
-
constructor(
|
|
8
|
-
(this.u =
|
|
7
|
+
constructor(t) {
|
|
8
|
+
(this.u = t), (this.u = t);
|
|
9
9
|
}
|
|
10
10
|
h(n, e) {
|
|
11
|
-
const l = new
|
|
11
|
+
const l = new s();
|
|
12
12
|
if ((n.p(), null == n.url || "" === n.url))
|
|
13
13
|
return (
|
|
14
14
|
r.info(`Card ${n.id} has no url. Not logging click to Braze servers.`),
|
|
15
15
|
l
|
|
16
16
|
);
|
|
17
17
|
if (e && n.id && this.u) {
|
|
18
|
-
const
|
|
19
|
-
(
|
|
18
|
+
const t = this.u.j(o.C.v) || {};
|
|
19
|
+
(t[n.id] = !0), this.u.I(o.C.v, t);
|
|
20
20
|
}
|
|
21
|
-
const
|
|
22
|
-
if (null ==
|
|
23
|
-
const
|
|
24
|
-
return
|
|
21
|
+
const a = this.$([n]);
|
|
22
|
+
if (null == a) return l;
|
|
23
|
+
const u = e ? i.k : i.D;
|
|
24
|
+
return t.q(u, a);
|
|
25
25
|
}
|
|
26
26
|
B(n) {
|
|
27
|
-
const e = new
|
|
27
|
+
const e = new s();
|
|
28
28
|
if (!n.N())
|
|
29
29
|
return (
|
|
30
30
|
r.info(
|
|
@@ -33,44 +33,48 @@ export default class a {
|
|
|
33
33
|
e
|
|
34
34
|
);
|
|
35
35
|
if (n.id && this.u) {
|
|
36
|
-
const
|
|
37
|
-
(
|
|
36
|
+
const t = this.u.j(o.C.A) || {};
|
|
37
|
+
(t[n.id] = !0), this.u.I(o.C.A, t);
|
|
38
38
|
}
|
|
39
|
-
const l = this
|
|
40
|
-
return null == l ? e :
|
|
39
|
+
const l = this.$([n]);
|
|
40
|
+
return null == l ? e : t.q(i.F, l);
|
|
41
41
|
}
|
|
42
|
-
G(n,
|
|
43
|
-
const
|
|
44
|
-
|
|
42
|
+
G(n, e) {
|
|
43
|
+
const l = new s(!0),
|
|
44
|
+
a = [],
|
|
45
45
|
u = [];
|
|
46
46
|
let c = {};
|
|
47
|
-
this.u && (c =
|
|
48
|
-
for (const
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
if ((this.u && (r ? this.u.k(o.C.H, c) : this.u.k(o.C.J, c)), null != h)) {
|
|
56
|
-
const t = r ? i.M : i.O,
|
|
57
|
-
n = s.q(t, h);
|
|
58
|
-
e.P(n);
|
|
47
|
+
this.u && (c = e ? this.u.j(o.C.H) || {} : this.u.j(o.C.J) || {});
|
|
48
|
+
for (const t of n) {
|
|
49
|
+
t.K()
|
|
50
|
+
? (t instanceof ControlCard ? u.push(t) : a.push(t),
|
|
51
|
+
t.id && (c[t.id] = !0))
|
|
52
|
+
: r.info(
|
|
53
|
+
`Card ${t.id} logged an impression too recently. Ignoring analytics event.`,
|
|
54
|
+
);
|
|
59
55
|
}
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
56
|
+
const h = this.$(a),
|
|
57
|
+
m = this.$(u);
|
|
58
|
+
if (null == h && null == m) return (l.L = !1), l;
|
|
59
|
+
if ((this.u && (e ? this.u.I(o.C.H, c) : this.u.I(o.C.J, c)), null != h)) {
|
|
60
|
+
const s = e ? i.M : i.O,
|
|
61
|
+
n = t.q(s, h);
|
|
62
|
+
l.P(n);
|
|
63
63
|
}
|
|
64
|
-
|
|
64
|
+
if (null != m && e) {
|
|
65
|
+
const s = t.q(i.R, m);
|
|
66
|
+
l.P(s);
|
|
67
|
+
}
|
|
68
|
+
return l;
|
|
65
69
|
}
|
|
66
|
-
|
|
67
|
-
let
|
|
70
|
+
$(t) {
|
|
71
|
+
let s,
|
|
68
72
|
n = null;
|
|
69
|
-
for (let r = 0; r <
|
|
70
|
-
(
|
|
71
|
-
null !=
|
|
72
|
-
"" !==
|
|
73
|
-
((n = n || {}), (n.ids = n.ids || []), n.ids.push(
|
|
73
|
+
for (let r = 0; r < t.length; r++)
|
|
74
|
+
(s = t[r].id),
|
|
75
|
+
null != s &&
|
|
76
|
+
"" !== s &&
|
|
77
|
+
((n = n || {}), (n.ids = n.ids || []), n.ids.push(s));
|
|
74
78
|
return n;
|
|
75
79
|
}
|
|
76
80
|
}
|
package/src/Card/models/card.js
CHANGED
|
@@ -6,13 +6,13 @@ import { FEED_ANIMATION_DURATION as E } from "../../common/constants.js";
|
|
|
6
6
|
import T from "../../managers/subscription-manager.js";
|
|
7
7
|
import r from "../../../shared-lib/logger.js";
|
|
8
8
|
export default class Card {
|
|
9
|
-
constructor(t, i, s, h,
|
|
9
|
+
constructor(t, i, s, h, n, l, e, r, u, E, o, T, I, a, c, N) {
|
|
10
10
|
(this.id = t),
|
|
11
11
|
(this.viewed = i),
|
|
12
12
|
(this.title = s),
|
|
13
13
|
(this.imageUrl = h),
|
|
14
|
-
(this.description =
|
|
15
|
-
(this.created =
|
|
14
|
+
(this.description = n),
|
|
15
|
+
(this.created = l),
|
|
16
16
|
(this.updated = e),
|
|
17
17
|
(this.categories = r),
|
|
18
18
|
(this.expiresAt = u),
|
|
@@ -21,14 +21,14 @@ export default class Card {
|
|
|
21
21
|
(this.aspectRatio = T),
|
|
22
22
|
(this.extras = I),
|
|
23
23
|
(this.pinned = a),
|
|
24
|
-
(this.dismissible =
|
|
25
|
-
(this.clicked =
|
|
24
|
+
(this.dismissible = c),
|
|
25
|
+
(this.clicked = N),
|
|
26
26
|
(this.id = t),
|
|
27
27
|
(this.viewed = i || !1),
|
|
28
28
|
(this.title = s || ""),
|
|
29
29
|
(this.imageUrl = h),
|
|
30
|
-
(this.description =
|
|
31
|
-
(this.created =
|
|
30
|
+
(this.description = n || ""),
|
|
31
|
+
(this.created = l || null),
|
|
32
32
|
(this.updated = e || null),
|
|
33
33
|
(this.categories = r || []),
|
|
34
34
|
(this.expiresAt = u || null),
|
|
@@ -40,25 +40,26 @@ export default class Card {
|
|
|
40
40
|
(this.aspectRatio = isNaN(T) ? null : T)),
|
|
41
41
|
(this.extras = I || {}),
|
|
42
42
|
(this.pinned = a || !1),
|
|
43
|
-
(this.dismissible =
|
|
43
|
+
(this.dismissible = c || !1),
|
|
44
44
|
(this.dismissed = !1),
|
|
45
|
-
(this.clicked =
|
|
45
|
+
(this.clicked = N || !1),
|
|
46
46
|
(this.isControl = !1),
|
|
47
47
|
(this.test = !1),
|
|
48
48
|
(this.Et = null),
|
|
49
|
-
(this.Tt = null)
|
|
49
|
+
(this.Tt = null),
|
|
50
|
+
(this.It = null);
|
|
50
51
|
}
|
|
51
52
|
subscribeToClickedEvent(t) {
|
|
52
|
-
return this.
|
|
53
|
+
return this.St().Nt(t);
|
|
53
54
|
}
|
|
54
55
|
subscribeToDismissedEvent(t) {
|
|
55
|
-
return this.
|
|
56
|
+
return this.At().Nt(t);
|
|
56
57
|
}
|
|
57
58
|
removeSubscription(t) {
|
|
58
|
-
this.
|
|
59
|
+
this.St().removeSubscription(t), this.At().removeSubscription(t);
|
|
59
60
|
}
|
|
60
61
|
removeAllSubscriptions() {
|
|
61
|
-
this.
|
|
62
|
+
this.St().removeAllSubscriptions(), this.At().removeAllSubscriptions();
|
|
62
63
|
}
|
|
63
64
|
dismissCard() {
|
|
64
65
|
if (!this.dismissible || this.dismissed) return;
|
|
@@ -75,65 +76,69 @@ export default class Card {
|
|
|
75
76
|
(t.style.margin = "0"),
|
|
76
77
|
setTimeout(function () {
|
|
77
78
|
t && t.parentNode && t.parentNode.removeChild(t);
|
|
78
|
-
}, Card.
|
|
79
|
+
}, Card.Dt));
|
|
79
80
|
}, E));
|
|
80
81
|
}
|
|
81
|
-
|
|
82
|
+
St() {
|
|
82
83
|
return null == this.Et && (this.Et = new T()), this.Et;
|
|
83
84
|
}
|
|
84
|
-
|
|
85
|
+
At() {
|
|
85
86
|
return null == this.Tt && (this.Tt = new T()), this.Tt;
|
|
86
87
|
}
|
|
87
88
|
K() {
|
|
88
|
-
|
|
89
|
+
const t = new Date().valueOf();
|
|
90
|
+
return (
|
|
91
|
+
!(null != this.It && t - this.It < Card.Ct) &&
|
|
92
|
+
((this.It = t), (this.viewed = !0), !0)
|
|
93
|
+
);
|
|
89
94
|
}
|
|
90
95
|
p() {
|
|
91
|
-
(this.viewed = !0), (this.clicked = !0), this.
|
|
96
|
+
(this.viewed = !0), (this.clicked = !0), this.St().Rt();
|
|
92
97
|
}
|
|
93
98
|
N() {
|
|
94
99
|
return (
|
|
95
100
|
!(!this.dismissible || this.dismissed) &&
|
|
96
|
-
((this.dismissed = !0), this.
|
|
101
|
+
((this.dismissed = !0), this.At().Rt(), !0)
|
|
97
102
|
);
|
|
98
103
|
}
|
|
99
|
-
|
|
100
|
-
if (null == t || t[Card.
|
|
101
|
-
if (t[Card.
|
|
104
|
+
Lt(t) {
|
|
105
|
+
if (null == t || t[Card._t.ht] !== this.id) return !0;
|
|
106
|
+
if (t[Card._t.Ot]) return !1;
|
|
102
107
|
if (
|
|
103
|
-
null != t[Card.
|
|
108
|
+
null != t[Card._t.nt] &&
|
|
104
109
|
null != this.updated &&
|
|
105
|
-
parseInt(t[Card.
|
|
110
|
+
parseInt(t[Card._t.nt]) < h(this.updated.valueOf())
|
|
106
111
|
)
|
|
107
112
|
return !0;
|
|
108
113
|
if (
|
|
109
|
-
(t[Card.
|
|
110
|
-
t[Card.
|
|
111
|
-
null != t[Card.
|
|
112
|
-
null != t[Card.
|
|
113
|
-
null != t[Card.
|
|
114
|
-
null != t[Card.
|
|
114
|
+
(t[Card._t.et] && !this.viewed && (this.viewed = !0),
|
|
115
|
+
t[Card._t.zt] && !this.clicked && (this.clicked = t[Card._t.zt]),
|
|
116
|
+
null != t[Card._t.rt] && (this.title = t[Card._t.rt]),
|
|
117
|
+
null != t[Card._t.ot] && (this.imageUrl = t[Card._t.ot]),
|
|
118
|
+
null != t[Card._t.ct] && (this.description = t[Card._t.ct]),
|
|
119
|
+
null != t[Card._t.nt])
|
|
115
120
|
) {
|
|
116
|
-
const i = l(t[Card.
|
|
121
|
+
const i = l(t[Card._t.nt]);
|
|
117
122
|
null != i && (this.updated = i);
|
|
118
123
|
}
|
|
119
|
-
if (null != t[Card.
|
|
124
|
+
if (null != t[Card._t.lt]) {
|
|
120
125
|
let i;
|
|
121
|
-
(i = t[Card.
|
|
126
|
+
(i = t[Card._t.lt] === Card.Mt ? null : l(t[Card._t.lt])),
|
|
122
127
|
(this.expiresAt = i);
|
|
123
128
|
}
|
|
124
129
|
if (
|
|
125
|
-
(null != t[Card.
|
|
126
|
-
null != t[Card.
|
|
127
|
-
null != t[Card.
|
|
130
|
+
(null != t[Card._t.URL] && (this.url = t[Card._t.URL]),
|
|
131
|
+
null != t[Card._t.ft] && (this.linkText = t[Card._t.ft]),
|
|
132
|
+
null != t[Card._t.xt])
|
|
128
133
|
) {
|
|
129
|
-
const i = parseFloat(t[Card.
|
|
134
|
+
const i = parseFloat(t[Card._t.xt].toString());
|
|
130
135
|
this.aspectRatio = isNaN(i) ? null : i;
|
|
131
136
|
}
|
|
132
137
|
return (
|
|
133
|
-
null != t[Card.
|
|
134
|
-
null != t[Card.
|
|
135
|
-
null != t[Card.
|
|
136
|
-
null != t[Card.
|
|
138
|
+
null != t[Card._t.bt] && (this.extras = t[Card._t.bt]),
|
|
139
|
+
null != t[Card._t.gt] && (this.pinned = t[Card._t.gt]),
|
|
140
|
+
null != t[Card._t.jt] && (this.dismissible = t[Card._t.jt]),
|
|
141
|
+
null != t[Card._t.kt] && (this.test = t[Card._t.kt]),
|
|
137
142
|
!0
|
|
138
143
|
);
|
|
139
144
|
}
|
|
@@ -141,12 +146,12 @@ export default class Card {
|
|
|
141
146
|
r.error("Must be implemented in a subclass");
|
|
142
147
|
}
|
|
143
148
|
}
|
|
144
|
-
(Card.
|
|
145
|
-
(Card.
|
|
149
|
+
(Card.Mt = -1),
|
|
150
|
+
(Card._t = {
|
|
146
151
|
ht: "id",
|
|
147
152
|
et: "v",
|
|
148
153
|
jt: "db",
|
|
149
|
-
|
|
154
|
+
Ot: "r",
|
|
150
155
|
nt: "ca",
|
|
151
156
|
gt: "p",
|
|
152
157
|
lt: "ea",
|
|
@@ -163,10 +168,10 @@ export default class Card {
|
|
|
163
168
|
}),
|
|
164
169
|
(Card.it = {
|
|
165
170
|
st: "captioned_image",
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
171
|
+
Pt: "text_announcement",
|
|
172
|
+
Ut: "short_news",
|
|
173
|
+
Gt: "banner_image",
|
|
174
|
+
Xt: "control",
|
|
170
175
|
}),
|
|
171
176
|
(Card.tt = {
|
|
172
177
|
ht: "id",
|
|
@@ -188,10 +193,11 @@ export default class Card {
|
|
|
188
193
|
zt: "cl",
|
|
189
194
|
kt: "s",
|
|
190
195
|
}),
|
|
191
|
-
(Card.
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
+
(Card.vt = {
|
|
197
|
+
Vt: "ADVERTISING",
|
|
198
|
+
Wt: "ANNOUNCEMENTS",
|
|
199
|
+
wt: "NEWS",
|
|
200
|
+
Ft: "SOCIAL",
|
|
196
201
|
}),
|
|
197
|
-
(Card.
|
|
202
|
+
(Card.Dt = 400),
|
|
203
|
+
(Card.Ct = 1e4);
|
|
@@ -12,31 +12,31 @@ import {
|
|
|
12
12
|
import { logger as r } from "../../../shared-lib/index.js";
|
|
13
13
|
export function newCard(n, e, t, o, i, l, u, d, a, w, f, s, m, C, p, c, x, F) {
|
|
14
14
|
let j;
|
|
15
|
-
if (e === Card.it.
|
|
15
|
+
if (e === Card.it.Pt || e === Card.it.Ut)
|
|
16
16
|
j = new ClassicCard(n, t, o, i, l, u, d, a, w, f, s, m, C, p, c, x);
|
|
17
17
|
else if (e === Card.it.st)
|
|
18
18
|
j = new CaptionedImage(n, t, o, i, l, u, d, a, w, f, s, m, C, p, c, x);
|
|
19
|
-
else if (e === Card.it.
|
|
19
|
+
else if (e === Card.it.Gt)
|
|
20
20
|
j = new ImageOnly(n, t, i, u, d, a, w, f, s, m, C, p, c, x);
|
|
21
21
|
else {
|
|
22
|
-
if (e !== Card.it.
|
|
22
|
+
if (e !== Card.it.Xt)
|
|
23
23
|
return r.error("Ignoring card with unknown type " + e), null;
|
|
24
24
|
j = new ControlCard(n, t, d, w, C, p);
|
|
25
25
|
}
|
|
26
26
|
return F && (j.test = F), j;
|
|
27
27
|
}
|
|
28
28
|
export function newCardFromContentCardsJson(n) {
|
|
29
|
-
if (n[Card.
|
|
30
|
-
const e = n[Card.
|
|
31
|
-
r = n[Card.
|
|
32
|
-
t = n[Card.
|
|
33
|
-
o = n[Card.
|
|
34
|
-
i = n[Card.
|
|
35
|
-
u = n[Card.
|
|
36
|
-
d = l(n[Card.
|
|
29
|
+
if (n[Card._t.Ot]) return null;
|
|
30
|
+
const e = n[Card._t.ht],
|
|
31
|
+
r = n[Card._t.Z],
|
|
32
|
+
t = n[Card._t.et],
|
|
33
|
+
o = n[Card._t.rt],
|
|
34
|
+
i = n[Card._t.ot],
|
|
35
|
+
u = n[Card._t.ct],
|
|
36
|
+
d = l(n[Card._t.nt]),
|
|
37
37
|
a = d;
|
|
38
38
|
let w;
|
|
39
|
-
w = n[Card.
|
|
39
|
+
w = n[Card._t.lt] === Card.Mt ? null : l(n[Card._t.lt]);
|
|
40
40
|
return newCard(
|
|
41
41
|
e,
|
|
42
42
|
r,
|
|
@@ -48,14 +48,14 @@ export function newCardFromContentCardsJson(n) {
|
|
|
48
48
|
d,
|
|
49
49
|
null,
|
|
50
50
|
w,
|
|
51
|
-
n[Card.
|
|
52
|
-
n[Card.
|
|
53
|
-
n[Card.
|
|
54
|
-
n[Card.
|
|
55
|
-
n[Card.
|
|
56
|
-
n[Card.
|
|
57
|
-
n[Card.
|
|
58
|
-
n[Card.
|
|
51
|
+
n[Card._t.URL],
|
|
52
|
+
n[Card._t.ft],
|
|
53
|
+
n[Card._t.xt],
|
|
54
|
+
n[Card._t.bt],
|
|
55
|
+
n[Card._t.gt],
|
|
56
|
+
n[Card._t.jt],
|
|
57
|
+
n[Card._t.zt],
|
|
58
|
+
n[Card._t.kt] || !1,
|
|
59
59
|
);
|
|
60
60
|
}
|
|
61
61
|
export function newCardFromFeedJson(n) {
|