@braze/web-sdk 6.5.0 → 6.7.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 +258 -5
- package/package.json +1 -1
- package/shared-lib/event-types.js +21 -20
- package/shared-lib/guid.js +3 -3
- package/shared-lib/indexed-db-adapter.js +70 -70
- package/shared-lib/logger.js +7 -7
- package/shared-lib/supported-options.js +26 -25
- package/src/Banner/banner-factory.js +11 -1
- package/src/Banner/banner-provider.js +244 -120
- package/src/Banner/banner.js +14 -12
- package/src/Banner/display/banner-to-html.js +23 -16
- package/src/Banner/display/detect-banner-impressions.js +13 -13
- package/src/Banner/get-all-banners.js +5 -5
- package/src/Banner/get-banner.js +4 -4
- package/src/Banner/log-banner-click.js +4 -4
- package/src/Banner/log-banner-dismissal.js +23 -0
- package/src/Banner/log-banner-impressions.js +7 -7
- package/src/Banner/request-banners-refresh.js +12 -16
- package/src/Banner/subscribe-to-banners-updates.js +6 -6
- package/src/Banner/ui/insert-banner.js +12 -12
- package/src/Card/card-manager-factory.js +5 -5
- package/src/Card/card-manager.js +33 -33
- package/src/Card/constants.js +1 -1
- package/src/Card/display/card-display.js +11 -11
- package/src/Card/log-card-dismissal.js +3 -3
- package/src/Card/log-content-card-click.js +3 -3
- package/src/Card/log-content-card-impressions.js +6 -6
- 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 +18 -18
- package/src/Card/util/card-factory.js +41 -41
- package/src/ContentCards/content-cards-provider-factory.js +12 -12
- package/src/ContentCards/content-cards-provider.js +151 -151
- package/src/ContentCards/content-cards.js +5 -5
- 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 +6 -6
- package/src/ContentCards/ui/show-content-cards.js +10 -10
- package/src/Core/add-sdk-metadata.js +2 -2
- package/src/Core/change-user.js +6 -6
- package/src/Core/disable-sdk.js +9 -8
- package/src/Core/enable-sdk.js +5 -5
- package/src/Core/get-user.js +1 -1
- package/src/Core/handle-braze-action.js +3 -3
- package/src/Core/is-disabled.js +2 -2
- package/src/Core/log-custom-event.js +8 -8
- package/src/Core/log-purchase.js +5 -5
- package/src/Core/open-session.js +7 -7
- package/src/Core/set-sdk-authentication-signature.js +3 -3
- package/src/Core/subscribe-to-sdk-authentication-failures.js +1 -1
- package/src/Core/wipe-data.js +6 -6
- package/src/DUST/dust-provider-factory.js +11 -11
- package/src/DUST/dust-provider.js +255 -255
- package/src/DUST/dust-shared-worker-impl.js +100 -100
- package/src/DUST/dust-worker-bridge.js +27 -27
- package/src/DUST/subscribe-to-dust.js +9 -9
- package/src/FeatureFlags/feature-flag-factory.js +8 -8
- package/src/FeatureFlags/feature-flag.js +9 -9
- package/src/FeatureFlags/feature-flags-provider.js +86 -86
- 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 +5 -5
- package/src/FeatureFlags/subscribe-to-feature-flags-updates.js +2 -2
- package/src/InAppMessage/constants.js +83 -2
- package/src/InAppMessage/defer-in-app-message.js +1 -1
- package/src/InAppMessage/display/html-message-display-utils.js +15 -15
- package/src/InAppMessage/display/html-message-to-html.js +36 -37
- package/src/InAppMessage/display/in-app-message-to-html.js +44 -44
- package/src/InAppMessage/display/modal-utils.js +10 -14
- package/src/InAppMessage/in-app-message-factory.js +16 -20
- package/src/InAppMessage/in-app-message-manager.js +116 -117
- package/src/InAppMessage/log-in-app-message-button-click.js +8 -8
- package/src/InAppMessage/log-in-app-message-click.js +7 -7
- package/src/InAppMessage/log-in-app-message-html-click.js +8 -8
- package/src/InAppMessage/log-in-app-message-impression.js +5 -5
- package/src/InAppMessage/models/control-message.js +4 -4
- package/src/InAppMessage/models/full-screen-message.js +56 -49
- package/src/InAppMessage/models/html-message.js +31 -27
- package/src/InAppMessage/models/in-app-message-button.js +12 -12
- package/src/InAppMessage/models/in-app-message.js +202 -256
- package/src/InAppMessage/models/modal-message.js +55 -49
- package/src/InAppMessage/models/slide-up-message.js +57 -51
- package/src/InAppMessage/models/templated-in-app-message.js +10 -10
- package/src/InAppMessage/shared-types.js +1 -0
- package/src/InAppMessage/subscribe-to-in-app-message.js +1 -1
- package/src/InAppMessage/ui/automatically-show-in-app-messages.js +5 -5
- package/src/InAppMessage/ui/remove-all-visible-in-app-messages.js +3 -3
- package/src/InAppMessage/ui/show-in-app-message.js +43 -41
- 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 +9 -9
- package/src/Push/push-manager.js +15 -15
- package/src/Push/utils/push-utils.js +15 -15
- package/src/User/user-manager.js +14 -14
- package/src/User/user.js +60 -59
- package/src/common/base-provider.js +1 -1
- package/src/common/constants.js +2 -1
- package/src/common/content-cards-display.js +38 -38
- package/src/common/event-logger.js +8 -8
- package/src/l10n/l10n-manager-factory.js +9 -9
- package/src/l10n/l10n-manager.js +2 -2
- package/src/managers/auth-manager.js +31 -31
- package/src/managers/braze-instance.js +197 -182
- package/src/managers/constants.js +1 -0
- package/src/managers/device-manager.js +25 -25
- package/src/managers/network-manager.js +155 -155
- package/src/managers/server-config-manager.js +106 -93
- package/src/managers/session-manager.js +37 -33
- package/src/managers/storage-manager-factory.js +33 -28
- package/src/managers/storage-manager.js +194 -175
- package/src/managers/subscription-manager.js +13 -13
- package/src/managers/utils.js +1 -1
- package/src/models/backend-errors.js +5 -5
- package/src/models/braze-event.js +13 -13
- package/src/models/device.js +3 -3
- package/src/models/identifier.js +12 -12
- package/src/models/push-token.js +9 -9
- package/src/models/request-result.js +4 -4
- package/src/models/server-config.js +29 -38
- package/src/request-controller.js +159 -163
- 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 +12 -12
- package/src/triggers/models/filter.js +66 -66
- package/src/triggers/models/in-app-message-click-data.js +13 -13
- package/src/triggers/models/purchase-data.js +4 -4
- package/src/triggers/models/purchase-property-data.js +10 -10
- package/src/triggers/models/push-click-data.js +8 -8
- package/src/triggers/models/trigger-condition.js +58 -58
- package/src/triggers/models/trigger-events.js +3 -3
- package/src/triggers/models/trigger.js +44 -44
- package/src/triggers/triggers-provider-factory.js +5 -5
- package/src/triggers/triggers-provider.js +70 -70
- package/src/ui/js/attach-css.js +3 -3
- package/src/ui/js/feed-css.js +2 -2
- package/src/ui/js/iam-css.js +2 -2
- package/src/ui/js/load-font-awesome.js +2 -2
- package/src/util/base-device-parser.js +9 -9
- package/src/util/braze-actions.js +3 -3
- package/src/util/browser-detector.js +37 -37
- package/src/util/client-hints-parser.js +9 -9
- package/src/util/component-utils.js +3 -3
- package/src/util/dom-utils.js +2 -2
- package/src/util/html-display-utils.js +11 -11
- package/src/util/key-codes.js +1 -1
- package/src/util/net.js +8 -8
- package/src/util/request-header-utils.js +25 -25
- package/src/util/user-agent-parser.js +20 -20
- package/src/util/validation-utils.js +21 -21
- package/src/util/window-utils.js +3 -3
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import t from "../common/base-provider.js";
|
|
2
2
|
import r from "../managers/braze-instance.js";
|
|
3
3
|
import { STORAGE_KEYS as s } from "../managers/storage-manager.js";
|
|
4
|
-
import
|
|
4
|
+
import f from "../managers/subscription-manager.js";
|
|
5
5
|
import l from "../util/net.js";
|
|
6
6
|
import h from "../util/request-header-utils.js";
|
|
7
7
|
import { logger as E } from "../../shared-lib/index.js";
|
|
8
8
|
import {
|
|
9
|
-
REQUEST_BACKOFF_MAX_SLEEP_MS_DEFAULT as
|
|
10
|
-
REQUEST_BACKOFF_MIN_SLEEP_MS_DEFAULT as
|
|
11
|
-
REQUEST_BACKOFF_SCALE_FACTOR_DEFAULT as
|
|
9
|
+
REQUEST_BACKOFF_MAX_SLEEP_MS_DEFAULT as c,
|
|
10
|
+
REQUEST_BACKOFF_MIN_SLEEP_MS_DEFAULT as d,
|
|
11
|
+
REQUEST_BACKOFF_SCALE_FACTOR_DEFAULT as m,
|
|
12
12
|
} from "../common/constants.js";
|
|
13
13
|
import { randomInclusive as a } from "../util/math.js";
|
|
14
14
|
import {
|
|
@@ -19,43 +19,43 @@ import {
|
|
|
19
19
|
DustWorkerBridge as si,
|
|
20
20
|
isSharedWorkerSupported as ei,
|
|
21
21
|
} from "./dust-worker-bridge.js";
|
|
22
|
-
export default class
|
|
22
|
+
export default class nr extends t {
|
|
23
23
|
constructor(i, t, s, e, n = !0) {
|
|
24
24
|
super(),
|
|
25
|
-
(this.
|
|
26
|
-
(this.
|
|
25
|
+
(this.B = i),
|
|
26
|
+
(this.C = t),
|
|
27
27
|
(this.h = s),
|
|
28
|
-
(this.
|
|
29
|
-
(this.
|
|
28
|
+
(this.B = i),
|
|
29
|
+
(this.C = t),
|
|
30
30
|
(this.h = s),
|
|
31
31
|
(this.mite = null),
|
|
32
|
-
(this.
|
|
33
|
-
(this.yi = null),
|
|
34
|
-
(this.$i = null),
|
|
35
|
-
(this.Ri = e || null),
|
|
36
|
-
(this.Mi = null),
|
|
37
|
-
(this.xi = null),
|
|
38
|
-
(this.D = null),
|
|
39
|
-
(this.ji = 0),
|
|
40
|
-
(this.Wi = ii),
|
|
41
|
-
(this.Fi = null),
|
|
42
|
-
(this.Ui = null),
|
|
43
|
-
(this.zi = !0),
|
|
44
|
-
(this.Bi = null),
|
|
32
|
+
(this.Wi = null),
|
|
45
33
|
(this.Gi = null),
|
|
46
|
-
(this.
|
|
47
|
-
(this.
|
|
48
|
-
(this.Hi = !1),
|
|
49
|
-
(this.Ji = new Map()),
|
|
50
|
-
(this.Li = null),
|
|
51
|
-
(this.Oi = null),
|
|
34
|
+
(this.Hi = null),
|
|
35
|
+
(this.Oi = e || null),
|
|
52
36
|
(this.Ki = null),
|
|
53
|
-
(this.Qi =
|
|
54
|
-
(this.
|
|
55
|
-
(this.
|
|
56
|
-
this.
|
|
37
|
+
(this.Qi = null),
|
|
38
|
+
(this.T = null),
|
|
39
|
+
(this.Vi = 0),
|
|
40
|
+
(this.Xi = ii),
|
|
41
|
+
(this.Yi = null),
|
|
42
|
+
(this.Zi = null),
|
|
43
|
+
(this._i = !0),
|
|
44
|
+
(this.we = null),
|
|
45
|
+
(this.Se = null),
|
|
46
|
+
(this.ke = null),
|
|
47
|
+
(this.ye = null),
|
|
48
|
+
(this.Re = !1),
|
|
49
|
+
(this.Me = new Map()),
|
|
50
|
+
(this.xe = null),
|
|
51
|
+
(this.De = null),
|
|
52
|
+
(this.We = null),
|
|
53
|
+
(this.Fe = this.Ue(n)),
|
|
54
|
+
(this.Ne = !1),
|
|
55
|
+
(this.Te = 0),
|
|
56
|
+
this.ze();
|
|
57
57
|
}
|
|
58
|
-
|
|
58
|
+
Ue(i) {
|
|
59
59
|
return i
|
|
60
60
|
? ei()
|
|
61
61
|
? "sharedworker"
|
|
@@ -66,44 +66,44 @@ export default class tr extends t {
|
|
|
66
66
|
: (E.info("Shared connection disabled, using direct EventSource"),
|
|
67
67
|
"direct");
|
|
68
68
|
}
|
|
69
|
-
|
|
70
|
-
this.
|
|
71
|
-
|
|
72
|
-
this.
|
|
69
|
+
Ae() {
|
|
70
|
+
this.We = new si({
|
|
71
|
+
Be: (i) => {
|
|
72
|
+
this.Ge(i);
|
|
73
73
|
},
|
|
74
|
-
|
|
75
|
-
this.
|
|
74
|
+
Pe: () => {
|
|
75
|
+
this.qe();
|
|
76
76
|
},
|
|
77
|
-
|
|
78
|
-
|
|
77
|
+
He: () => {},
|
|
78
|
+
Je: (i) => {
|
|
79
79
|
E.error(`Real-time messaging SharedWorker error: ${i}`);
|
|
80
80
|
},
|
|
81
81
|
});
|
|
82
|
-
this.
|
|
82
|
+
this.We.initialize() ||
|
|
83
83
|
(E.info(
|
|
84
84
|
"SharedWorker initialization failed, falling back to direct EventSource",
|
|
85
85
|
),
|
|
86
|
-
(this.
|
|
87
|
-
(this.
|
|
86
|
+
(this.Fe = "direct"),
|
|
87
|
+
(this.We = null));
|
|
88
88
|
}
|
|
89
|
-
|
|
90
|
-
(this.
|
|
91
|
-
(this.
|
|
92
|
-
(this.
|
|
93
|
-
(this.
|
|
94
|
-
(this.
|
|
89
|
+
qe() {
|
|
90
|
+
(this.Vi = 0),
|
|
91
|
+
(this.we = null),
|
|
92
|
+
(this._i = !0),
|
|
93
|
+
(this.Ne = !1),
|
|
94
|
+
(this.Te = 0);
|
|
95
95
|
}
|
|
96
|
-
|
|
96
|
+
Ge(i) {
|
|
97
97
|
if (!i.type)
|
|
98
98
|
return void E.warn(
|
|
99
99
|
`Received real-time message without type: ${JSON.stringify(i)}`,
|
|
100
100
|
);
|
|
101
|
-
const t = "sharedworker" === this.
|
|
101
|
+
const t = "sharedworker" === this.Fe ? "SharedWorker" : "Direct";
|
|
102
102
|
E.info(`Received real-time message of type '${i.type}' via ${t}`);
|
|
103
|
-
const s = this.
|
|
104
|
-
if (s && s.
|
|
103
|
+
const s = this.Me.get(i.type);
|
|
104
|
+
if (s && s.Le() > 0)
|
|
105
105
|
try {
|
|
106
|
-
s.
|
|
106
|
+
s.A(i);
|
|
107
107
|
} catch (t) {
|
|
108
108
|
E.error(
|
|
109
109
|
`Error invoking subscription for message type '${i.type}': ${t}`,
|
|
@@ -111,195 +111,195 @@ export default class tr extends t {
|
|
|
111
111
|
}
|
|
112
112
|
else E.info(`No subscribers for real-time message type '${i.type}'`);
|
|
113
113
|
}
|
|
114
|
-
|
|
115
|
-
return "sharedworker" === this.
|
|
114
|
+
Oe() {
|
|
115
|
+
return "sharedworker" === this.Fe;
|
|
116
116
|
}
|
|
117
|
-
|
|
118
|
-
return this.
|
|
117
|
+
Ie() {
|
|
118
|
+
return this.Fe;
|
|
119
119
|
}
|
|
120
|
-
|
|
121
|
-
if (this.
|
|
122
|
-
const i = this.
|
|
123
|
-
t = this.
|
|
124
|
-
e = this.
|
|
125
|
-
n = this.
|
|
120
|
+
ze() {
|
|
121
|
+
if (this.C) {
|
|
122
|
+
const i = this.C.Rt(s.Tt.Ke),
|
|
123
|
+
t = this.C.Rt(s.Tt.Qe),
|
|
124
|
+
e = this.C.Rt(s.Tt.Ve),
|
|
125
|
+
n = this.C.Rt(s.Tt.Xe);
|
|
126
126
|
i && t
|
|
127
127
|
? ((this.mite = i),
|
|
128
|
-
(this.
|
|
129
|
-
(this.
|
|
130
|
-
(this
|
|
128
|
+
(this.Wi = t),
|
|
129
|
+
(this.Gi = e),
|
|
130
|
+
(this.Hi = n),
|
|
131
131
|
E.info("Restored real-time messaging configuration from storage"))
|
|
132
132
|
: (i || t) &&
|
|
133
133
|
(E.warn(
|
|
134
134
|
"Incomplete real-time messaging configuration in storage, clearing",
|
|
135
135
|
),
|
|
136
|
-
this.
|
|
136
|
+
this.Ye());
|
|
137
137
|
}
|
|
138
138
|
}
|
|
139
139
|
Hr() {
|
|
140
|
-
this.
|
|
141
|
-
this.
|
|
142
|
-
((this.
|
|
143
|
-
if (!i.body || "number" != typeof i.body.
|
|
144
|
-
const t = Math.random() * i.body.
|
|
145
|
-
s = Math.round(i.body.
|
|
140
|
+
this.xe ||
|
|
141
|
+
this.De ||
|
|
142
|
+
((this.xe = this.Ze("ddr", (i) => {
|
|
143
|
+
if (!i.body || "number" != typeof i.body._e) return;
|
|
144
|
+
const t = Math.random() * i.body._e * 0.3,
|
|
145
|
+
s = Math.round(i.body._e + t),
|
|
146
146
|
e = i.body.e ? ` (${i.body.e})` : "";
|
|
147
147
|
E.info(`Admin requested disconnect${e}, reconnecting in ${s}ms`),
|
|
148
|
-
this.
|
|
149
|
-
setTimeout(() => this.
|
|
148
|
+
this.sn(),
|
|
149
|
+
setTimeout(() => this.en(), s);
|
|
150
150
|
})),
|
|
151
|
-
(this.
|
|
152
|
-
if (!i.body || "number" != typeof i.body.
|
|
153
|
-
const t = i.body.
|
|
151
|
+
(this.De = this.Ze("ttl", (i) => {
|
|
152
|
+
if (!i.body || "number" != typeof i.body.on) return;
|
|
153
|
+
const t = i.body.on;
|
|
154
154
|
E.info(`Time to live set to ${t}ms, will reconnect when expired`),
|
|
155
|
-
"sharedworker" !== this.
|
|
156
|
-
("string" == typeof i.body.
|
|
157
|
-
null !== this.
|
|
158
|
-
(this.
|
|
159
|
-
(this.
|
|
155
|
+
"sharedworker" !== this.Fe &&
|
|
156
|
+
("string" == typeof i.body.hn && (this.Ki = i.body.hn),
|
|
157
|
+
null !== this.Zi && window.clearTimeout(this.Zi),
|
|
158
|
+
(this.Zi = window.setTimeout(() => {
|
|
159
|
+
(this.Zi = null),
|
|
160
160
|
E.info("Time to live expired, performing gapless reconnection"),
|
|
161
|
-
this.
|
|
161
|
+
this.an();
|
|
162
162
|
}, t)));
|
|
163
163
|
})));
|
|
164
164
|
}
|
|
165
|
-
|
|
166
|
-
this.
|
|
167
|
-
this.
|
|
168
|
-
((this.
|
|
169
|
-
(this.
|
|
165
|
+
ln() {
|
|
166
|
+
this.Se ||
|
|
167
|
+
this.ke ||
|
|
168
|
+
((this.ye = () => {
|
|
169
|
+
(this.Re = !0), (this._i = !1);
|
|
170
170
|
}),
|
|
171
|
-
window.addEventListener("beforeunload", this.
|
|
172
|
-
(this.
|
|
171
|
+
window.addEventListener("beforeunload", this.ye),
|
|
172
|
+
(this.Se = () => {
|
|
173
173
|
var i;
|
|
174
|
-
this.
|
|
175
|
-
(this.
|
|
176
|
-
(null === (i = this.
|
|
174
|
+
this.Re = !0;
|
|
175
|
+
(this.Qi ||
|
|
176
|
+
(null === (i = this.We) || void 0 === i ? void 0 : i.cn())) &&
|
|
177
177
|
(E.info("Page unloading, closing real-time connection gracefully"),
|
|
178
|
-
(this.
|
|
179
|
-
this.
|
|
178
|
+
(this._i = !1),
|
|
179
|
+
this.sn());
|
|
180
180
|
}),
|
|
181
|
-
window.addEventListener("pagehide", this.
|
|
182
|
-
(this.
|
|
181
|
+
window.addEventListener("pagehide", this.Se),
|
|
182
|
+
(this.ke = (i) => {
|
|
183
183
|
var t;
|
|
184
184
|
const s =
|
|
185
|
-
this.
|
|
185
|
+
this.Qi || (null === (t = this.We) || void 0 === t ? void 0 : t.cn());
|
|
186
186
|
i.persisted &&
|
|
187
|
-
this.
|
|
187
|
+
this.un() &&
|
|
188
188
|
!s &&
|
|
189
189
|
(E.info("Page restored from bfcache, reconnecting"),
|
|
190
|
-
(this.
|
|
191
|
-
this.
|
|
192
|
-
this.
|
|
190
|
+
(this.Re = !1),
|
|
191
|
+
this.qe(),
|
|
192
|
+
this.en());
|
|
193
193
|
}),
|
|
194
|
-
window.addEventListener("pageshow", this.
|
|
194
|
+
window.addEventListener("pageshow", this.ke));
|
|
195
195
|
}
|
|
196
|
-
|
|
197
|
-
return this.
|
|
196
|
+
Lt() {
|
|
197
|
+
return this.T;
|
|
198
198
|
}
|
|
199
|
-
|
|
200
|
-
this.
|
|
199
|
+
$t(i) {
|
|
200
|
+
this.T = i;
|
|
201
201
|
}
|
|
202
|
-
|
|
202
|
+
Ze(i, t) {
|
|
203
203
|
if ("function" != typeof t) return null;
|
|
204
|
-
let s = this.
|
|
205
|
-
return s || ((s = new
|
|
204
|
+
let s = this.Me.get(i);
|
|
205
|
+
return s || ((s = new f()), this.Me.set(i, s), r.S(s)), s.Kt(t);
|
|
206
206
|
}
|
|
207
|
-
|
|
208
|
-
const s = this.
|
|
207
|
+
dn(i, t) {
|
|
208
|
+
const s = this.Me.get(i);
|
|
209
209
|
s && s.removeSubscription(t);
|
|
210
210
|
}
|
|
211
|
-
|
|
212
|
-
return Boolean(this.mite && this.
|
|
211
|
+
un() {
|
|
212
|
+
return Boolean(this.mite && this.Wi);
|
|
213
213
|
}
|
|
214
|
-
|
|
215
|
-
if (!this
|
|
216
|
-
return Math.floor(new Date().valueOf() / 1e3) >= this
|
|
214
|
+
gn() {
|
|
215
|
+
if (!this.Hi) return !1;
|
|
216
|
+
return Math.floor(new Date().valueOf() / 1e3) >= this.Hi;
|
|
217
217
|
}
|
|
218
|
-
|
|
218
|
+
Ye() {
|
|
219
219
|
(this.mite = null),
|
|
220
|
-
(this.
|
|
221
|
-
(this.
|
|
222
|
-
(this
|
|
223
|
-
(this.
|
|
224
|
-
this.
|
|
225
|
-
(this.
|
|
226
|
-
this.
|
|
227
|
-
this.
|
|
228
|
-
this.
|
|
220
|
+
(this.Wi = null),
|
|
221
|
+
(this.Gi = null),
|
|
222
|
+
(this.Hi = null),
|
|
223
|
+
(this.Ki = null),
|
|
224
|
+
this.C &&
|
|
225
|
+
(this.C.Qt(s.Tt.Ke),
|
|
226
|
+
this.C.Qt(s.Tt.Qe),
|
|
227
|
+
this.C.Qt(s.Tt.Ve),
|
|
228
|
+
this.C.Qt(s.Tt.Xe));
|
|
229
229
|
}
|
|
230
|
-
|
|
230
|
+
mn(i, t) {
|
|
231
231
|
const e = () => {
|
|
232
232
|
"function" == typeof t && t();
|
|
233
233
|
},
|
|
234
|
-
n = this.
|
|
235
|
-
r = this.
|
|
234
|
+
n = this.B,
|
|
235
|
+
r = this.C;
|
|
236
236
|
if (!n || !r)
|
|
237
237
|
return (
|
|
238
238
|
E.error("NetworkManager or StorageManager not available"), void e()
|
|
239
239
|
);
|
|
240
|
-
if (!this.h || !this.h.
|
|
240
|
+
if (!this.h || !this.h.fn())
|
|
241
241
|
return (
|
|
242
242
|
E.info("Real-time messaging is not enabled, skipping refresh"), void e()
|
|
243
243
|
);
|
|
244
|
-
this.
|
|
244
|
+
this.un()
|
|
245
245
|
? E.info("Refreshing real-time messaging configuration")
|
|
246
246
|
: E.info("Fetching initial real-time messaging configuration");
|
|
247
|
-
const o = n
|
|
248
|
-
a = n.
|
|
247
|
+
const o = n.Z({}, !0),
|
|
248
|
+
a = n.tt(o, h.it.pn, !1),
|
|
249
249
|
c = new Date().valueOf();
|
|
250
|
-
h.
|
|
251
|
-
l.
|
|
252
|
-
url: `${n.
|
|
250
|
+
h.nt(r, h.it.pn, c),
|
|
251
|
+
l.ot({
|
|
252
|
+
url: `${n.ht()}/dust/config`,
|
|
253
253
|
headers: a,
|
|
254
254
|
data: o,
|
|
255
|
-
|
|
256
|
-
if (!n.
|
|
255
|
+
lt: (t) => {
|
|
256
|
+
if (!n.ut(o, t, a))
|
|
257
257
|
return (
|
|
258
258
|
E.error(
|
|
259
259
|
"Failed to validate server response for real-time messaging configuration",
|
|
260
260
|
),
|
|
261
261
|
void e()
|
|
262
262
|
);
|
|
263
|
-
n.
|
|
263
|
+
n.ct(),
|
|
264
264
|
t.mite && t.host
|
|
265
265
|
? ((this.mite = t.mite),
|
|
266
|
-
(this.
|
|
267
|
-
(this.
|
|
268
|
-
(this
|
|
266
|
+
(this.Wi = t.host),
|
|
267
|
+
(this.Gi = t.auth || null),
|
|
268
|
+
(this.Hi = t.expiration || null),
|
|
269
269
|
E.info(
|
|
270
270
|
"Received real-time messaging configuration from server",
|
|
271
271
|
),
|
|
272
|
-
r.
|
|
273
|
-
r.
|
|
274
|
-
t.auth ? r.
|
|
275
|
-
t.expiration ? r.
|
|
276
|
-
this.
|
|
272
|
+
r.It(s.Tt.Ke, t.mite),
|
|
273
|
+
r.It(s.Tt.Qe, t.host),
|
|
274
|
+
t.auth ? r.It(s.Tt.Ve, t.auth) : r.Qt(s.Tt.Ve),
|
|
275
|
+
t.expiration ? r.It(s.Tt.Xe, t.expiration) : r.Qt(s.Tt.Xe),
|
|
276
|
+
this.en(),
|
|
277
277
|
"function" == typeof i && i())
|
|
278
278
|
: (E.info(
|
|
279
279
|
"Real-time messaging configuration not available - this SDK version may not be supported",
|
|
280
280
|
),
|
|
281
|
-
this.
|
|
281
|
+
this.Ye(),
|
|
282
282
|
e());
|
|
283
283
|
},
|
|
284
284
|
error: (i) => {
|
|
285
|
-
n.
|
|
285
|
+
n.dt(i, "retrieving DUST config"), e();
|
|
286
286
|
},
|
|
287
287
|
});
|
|
288
288
|
}
|
|
289
|
-
|
|
290
|
-
if (!this.h || !this.h.
|
|
291
|
-
if (!this.
|
|
289
|
+
en() {
|
|
290
|
+
if (!this.h || !this.h.fn()) return;
|
|
291
|
+
if (!this.un())
|
|
292
292
|
return void E.error(
|
|
293
293
|
"Cannot start real-time subscription without configuration",
|
|
294
294
|
);
|
|
295
|
-
if (this.
|
|
295
|
+
if (this.gn())
|
|
296
296
|
return (
|
|
297
297
|
E.info(
|
|
298
298
|
"Real-time messaging auth token has expired, refreshing configuration",
|
|
299
299
|
),
|
|
300
|
-
void this.
|
|
300
|
+
void this.mn(
|
|
301
301
|
() => {
|
|
302
|
-
this.
|
|
302
|
+
this.en();
|
|
303
303
|
},
|
|
304
304
|
() => {
|
|
305
305
|
E.error(
|
|
@@ -309,62 +309,62 @@ export default class tr extends t {
|
|
|
309
309
|
)
|
|
310
310
|
);
|
|
311
311
|
const i = this.mite,
|
|
312
|
-
t = this.
|
|
312
|
+
t = this.Oi || this.Wi;
|
|
313
313
|
if (i && t)
|
|
314
|
-
switch (this.
|
|
314
|
+
switch (this.Fe) {
|
|
315
315
|
case "sharedworker":
|
|
316
|
-
this.
|
|
316
|
+
this.vn(i, t);
|
|
317
317
|
break;
|
|
318
318
|
case "direct":
|
|
319
|
-
this.
|
|
319
|
+
this.Qi &&
|
|
320
320
|
(E.info(
|
|
321
321
|
"Real-time connection already exists, closing before starting new subscription",
|
|
322
322
|
),
|
|
323
|
-
this.
|
|
324
|
-
this.
|
|
323
|
+
this.sn()),
|
|
324
|
+
this.wn();
|
|
325
325
|
}
|
|
326
326
|
}
|
|
327
|
-
|
|
327
|
+
bn() {
|
|
328
328
|
const i = this.mite,
|
|
329
|
-
t = this.
|
|
329
|
+
t = this.Oi || this.Wi;
|
|
330
330
|
return i && t
|
|
331
|
-
? ti(t, i, this.
|
|
331
|
+
? ti(t, i, this.Vi, this.Gi || void 0, this.Ki || void 0)
|
|
332
332
|
: null;
|
|
333
333
|
}
|
|
334
|
-
|
|
334
|
+
vn(i, t) {
|
|
335
335
|
var s, e, n;
|
|
336
|
-
if ((this.
|
|
336
|
+
if ((this.We || this.Ae(), !this.We))
|
|
337
337
|
return (
|
|
338
338
|
E.info(
|
|
339
339
|
"SharedWorker initialization failed, falling back to direct EventSource",
|
|
340
340
|
),
|
|
341
|
-
(this.
|
|
342
|
-
void this.
|
|
341
|
+
(this.Fe = "direct"),
|
|
342
|
+
void this.Sn()
|
|
343
343
|
);
|
|
344
|
-
this.
|
|
344
|
+
this.Oi && E.info(`Using custom real-time messaging host: ${this.Oi}`),
|
|
345
345
|
E.info("Starting real-time subscription via SharedWorker");
|
|
346
|
-
const r = (null === (s = this.h) || void 0 === s ? void 0 : s.
|
|
347
|
-
o = (null === (e = this.h) || void 0 === e ? void 0 : e.
|
|
348
|
-
h = (null === (n = this.h) || void 0 === n ? void 0 : n.
|
|
349
|
-
this.
|
|
346
|
+
const r = (null === (s = this.h) || void 0 === s ? void 0 : s.vt()) || d,
|
|
347
|
+
o = (null === (e = this.h) || void 0 === e ? void 0 : e.bt()) || c,
|
|
348
|
+
h = (null === (n = this.h) || void 0 === n ? void 0 : n.gt()) || m;
|
|
349
|
+
this.We.connect({
|
|
350
350
|
mite: i,
|
|
351
|
-
|
|
352
|
-
auth: this.
|
|
353
|
-
|
|
351
|
+
Wi: t,
|
|
352
|
+
auth: this.Gi || void 0,
|
|
353
|
+
kn: { yn: r, $n: o, Rn: h },
|
|
354
354
|
});
|
|
355
355
|
}
|
|
356
|
-
|
|
357
|
-
this.
|
|
356
|
+
Sn() {
|
|
357
|
+
this.Qi &&
|
|
358
358
|
(E.info(
|
|
359
359
|
"Real-time connection already exists, closing before starting new subscription",
|
|
360
360
|
),
|
|
361
|
-
this.
|
|
362
|
-
this.
|
|
361
|
+
this.Cn()),
|
|
362
|
+
this.wn();
|
|
363
363
|
}
|
|
364
|
-
|
|
365
|
-
const t = this.
|
|
364
|
+
wn(i) {
|
|
365
|
+
const t = this.bn();
|
|
366
366
|
if (t) {
|
|
367
|
-
this.
|
|
367
|
+
this.Oi && E.info(`Using custom real-time messaging host: ${this.Oi}`);
|
|
368
368
|
try {
|
|
369
369
|
const s = new EventSource(t);
|
|
370
370
|
(s.onopen = () => {
|
|
@@ -374,41 +374,41 @@ export default class tr extends t {
|
|
|
374
374
|
),
|
|
375
375
|
i.close())
|
|
376
376
|
: E.info("Real-time messaging connection established"),
|
|
377
|
-
(this.
|
|
378
|
-
(this.
|
|
379
|
-
(this.
|
|
380
|
-
(this.
|
|
381
|
-
(this.
|
|
377
|
+
(this.Qi = s),
|
|
378
|
+
(this.Vi = 0),
|
|
379
|
+
(this.we = null),
|
|
380
|
+
(this._i = !0),
|
|
381
|
+
(this.Ne = !0);
|
|
382
382
|
}),
|
|
383
383
|
s.addEventListener("msg", (i) => {
|
|
384
|
-
this.
|
|
384
|
+
this.Mn(i.data);
|
|
385
385
|
}),
|
|
386
386
|
(s.onerror = () => {
|
|
387
387
|
const t = s.readyState;
|
|
388
388
|
return (
|
|
389
|
-
this.
|
|
389
|
+
this.Re ||
|
|
390
390
|
(0 === t
|
|
391
391
|
? E.info("Real-time messaging failed to connect")
|
|
392
392
|
: E.info("Real-time messaging connection lost")),
|
|
393
|
-
i && this.
|
|
393
|
+
i && this.Qi !== s
|
|
394
394
|
? (E.info(
|
|
395
395
|
"Gapless reconnection failed, keeping old connection",
|
|
396
396
|
),
|
|
397
397
|
s.close(),
|
|
398
|
-
void (this.
|
|
399
|
-
: (this.
|
|
400
|
-
this.
|
|
398
|
+
void (this._i && this.Vi < this.Xi && this.xn()))
|
|
399
|
+
: (this.Cn(),
|
|
400
|
+
this.Ne && (this.Te++, this.Te > 1)
|
|
401
401
|
? (E.info(
|
|
402
402
|
"Real-time messaging connection lost twice after successful connect (likely multi-tab conflict), yielding to other tab",
|
|
403
403
|
),
|
|
404
|
-
void (this.
|
|
405
|
-
: void (this.
|
|
406
|
-
? this.
|
|
407
|
-
: (this.
|
|
404
|
+
void (this._i = !1))
|
|
405
|
+
: void (this._i && this.Vi < this.Xi
|
|
406
|
+
? this.xn()
|
|
407
|
+
: (this.Vi >= this.Xi &&
|
|
408
408
|
E.error(
|
|
409
|
-
`Max retry attempts (${this.
|
|
409
|
+
`Max retry attempts (${this.Xi}) reached for real-time messaging, giving up for current session`,
|
|
410
410
|
),
|
|
411
|
-
(this.
|
|
411
|
+
(this._i = !1))))
|
|
412
412
|
);
|
|
413
413
|
});
|
|
414
414
|
} catch (i) {
|
|
@@ -420,59 +420,59 @@ export default class tr extends t {
|
|
|
420
420
|
}
|
|
421
421
|
}
|
|
422
422
|
}
|
|
423
|
-
|
|
423
|
+
xn() {
|
|
424
424
|
var i, t, s;
|
|
425
|
-
this.
|
|
426
|
-
const e = (null === (i = this.h) || void 0 === i ? void 0 : i.
|
|
427
|
-
n = (null === (t = this.h) || void 0 === t ? void 0 : t.
|
|
428
|
-
r = (null === (s = this.h) || void 0 === s ? void 0 : s.
|
|
429
|
-
let o = this.
|
|
425
|
+
this.Vi++;
|
|
426
|
+
const e = (null === (i = this.h) || void 0 === i ? void 0 : i.vt()) || d,
|
|
427
|
+
n = (null === (t = this.h) || void 0 === t ? void 0 : t.gt()) || m,
|
|
428
|
+
r = (null === (s = this.h) || void 0 === s ? void 0 : s.bt()) || c;
|
|
429
|
+
let o = this.we;
|
|
430
430
|
(null == o || o < e) && (o = e);
|
|
431
431
|
const h = Math.min(r, a(e, o * n));
|
|
432
|
-
(this.
|
|
432
|
+
(this.we = h),
|
|
433
433
|
E.info(
|
|
434
|
-
`Retrying real-time messaging connection in ${h}ms (attempt ${this.
|
|
434
|
+
`Retrying real-time messaging connection in ${h}ms (attempt ${this.Vi}/${this.Xi})`,
|
|
435
435
|
),
|
|
436
|
-
(this.
|
|
437
|
-
(this.
|
|
436
|
+
(this.Yi = window.setTimeout(() => {
|
|
437
|
+
(this.Yi = null), this.en();
|
|
438
438
|
}, h));
|
|
439
439
|
}
|
|
440
|
-
|
|
441
|
-
if (this.
|
|
442
|
-
if (this.
|
|
440
|
+
an() {
|
|
441
|
+
if (this.un()) {
|
|
442
|
+
if (this.gn())
|
|
443
443
|
return (
|
|
444
444
|
E.info(
|
|
445
445
|
"Auth token expired during gapless reconnection, falling back to regular reconnection",
|
|
446
446
|
),
|
|
447
|
-
this.
|
|
448
|
-
void this.
|
|
447
|
+
this.sn(),
|
|
448
|
+
void this.en()
|
|
449
449
|
);
|
|
450
|
-
null !== this.
|
|
451
|
-
this.
|
|
450
|
+
null !== this.Zi && (window.clearTimeout(this.Zi), (this.Zi = null)),
|
|
451
|
+
this.wn(this.Qi || void 0);
|
|
452
452
|
} else E.error("Cannot perform gapless reconnection without configuration");
|
|
453
453
|
}
|
|
454
|
-
|
|
454
|
+
sn() {
|
|
455
455
|
var i;
|
|
456
|
-
switch (this.
|
|
456
|
+
switch (this.Fe) {
|
|
457
457
|
case "sharedworker":
|
|
458
|
-
null === (i = this.
|
|
458
|
+
null === (i = this.We) || void 0 === i || i.disconnect();
|
|
459
459
|
break;
|
|
460
460
|
case "direct":
|
|
461
|
-
this.
|
|
461
|
+
this.Cn();
|
|
462
462
|
}
|
|
463
463
|
}
|
|
464
|
-
|
|
465
|
-
null !== this.
|
|
466
|
-
null !== this.
|
|
467
|
-
this.
|
|
468
|
-
(this.
|
|
469
|
-
(this.
|
|
464
|
+
Cn() {
|
|
465
|
+
null !== this.Yi && (window.clearTimeout(this.Yi), (this.Yi = null)),
|
|
466
|
+
null !== this.Zi && (window.clearTimeout(this.Zi), (this.Zi = null)),
|
|
467
|
+
this.Qi &&
|
|
468
|
+
(this.Qi.close(),
|
|
469
|
+
(this.Qi = null),
|
|
470
470
|
E.info("Real-time messaging connection closed"));
|
|
471
471
|
}
|
|
472
|
-
|
|
472
|
+
Mn(i) {
|
|
473
473
|
try {
|
|
474
474
|
const t = JSON.parse(i);
|
|
475
|
-
this.
|
|
475
|
+
this.Ge(t);
|
|
476
476
|
} catch (i) {
|
|
477
477
|
E.warn(
|
|
478
478
|
`Failed to parse real-time message: ${
|
|
@@ -482,39 +482,39 @@ export default class tr extends t {
|
|
|
482
482
|
}
|
|
483
483
|
}
|
|
484
484
|
changeUser(i = !1) {
|
|
485
|
-
this.
|
|
485
|
+
this.sn(),
|
|
486
486
|
i ||
|
|
487
|
-
(this.
|
|
487
|
+
(this.un() &&
|
|
488
488
|
E.info(
|
|
489
489
|
"Clearing cached real-time messaging configuration for user change",
|
|
490
490
|
),
|
|
491
|
-
this.
|
|
492
|
-
this.
|
|
491
|
+
this.Ye()),
|
|
492
|
+
this.qe();
|
|
493
493
|
}
|
|
494
494
|
clearData(i = !1) {
|
|
495
|
-
(this.
|
|
496
|
-
this.
|
|
495
|
+
(this._i = !1),
|
|
496
|
+
this.sn(),
|
|
497
497
|
i &&
|
|
498
|
-
(this.
|
|
498
|
+
(this.un() &&
|
|
499
499
|
E.info(
|
|
500
500
|
"Clearing cached real-time messaging configuration (wipeData)",
|
|
501
501
|
),
|
|
502
|
-
this.
|
|
503
|
-
this.
|
|
502
|
+
this.Ye()),
|
|
503
|
+
this.qe();
|
|
504
504
|
}
|
|
505
505
|
destroy() {
|
|
506
|
-
(this.
|
|
507
|
-
this.
|
|
508
|
-
this.
|
|
509
|
-
this.
|
|
510
|
-
this.
|
|
511
|
-
this.
|
|
512
|
-
this.
|
|
513
|
-
(window.removeEventListener("beforeunload", this.
|
|
514
|
-
this.
|
|
515
|
-
(window.removeEventListener("pagehide", this.
|
|
516
|
-
this.
|
|
517
|
-
(window.removeEventListener("pageshow", this.
|
|
518
|
-
this.
|
|
506
|
+
(this._i = !1),
|
|
507
|
+
this.sn(),
|
|
508
|
+
this.Ye(),
|
|
509
|
+
this.We && (this.We.destroy(), (this.We = null)),
|
|
510
|
+
this.xe && (this.dn("ddr", this.xe), (this.xe = null)),
|
|
511
|
+
this.De && (this.dn("ttl", this.De), (this.De = null)),
|
|
512
|
+
this.ye &&
|
|
513
|
+
(window.removeEventListener("beforeunload", this.ye), (this.ye = null)),
|
|
514
|
+
this.Se &&
|
|
515
|
+
(window.removeEventListener("pagehide", this.Se), (this.Se = null)),
|
|
516
|
+
this.ke &&
|
|
517
|
+
(window.removeEventListener("pageshow", this.ke), (this.ke = null)),
|
|
518
|
+
this.T && (r.removeSubscription(this.T), (this.T = null));
|
|
519
519
|
}
|
|
520
520
|
}
|