@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.
Files changed (153) hide show
  1. package/index.d.ts +258 -5
  2. package/package.json +1 -1
  3. package/shared-lib/event-types.js +21 -20
  4. package/shared-lib/guid.js +3 -3
  5. package/shared-lib/indexed-db-adapter.js +70 -70
  6. package/shared-lib/logger.js +7 -7
  7. package/shared-lib/supported-options.js +26 -25
  8. package/src/Banner/banner-factory.js +11 -1
  9. package/src/Banner/banner-provider.js +244 -120
  10. package/src/Banner/banner.js +14 -12
  11. package/src/Banner/display/banner-to-html.js +23 -16
  12. package/src/Banner/display/detect-banner-impressions.js +13 -13
  13. package/src/Banner/get-all-banners.js +5 -5
  14. package/src/Banner/get-banner.js +4 -4
  15. package/src/Banner/log-banner-click.js +4 -4
  16. package/src/Banner/log-banner-dismissal.js +23 -0
  17. package/src/Banner/log-banner-impressions.js +7 -7
  18. package/src/Banner/request-banners-refresh.js +12 -16
  19. package/src/Banner/subscribe-to-banners-updates.js +6 -6
  20. package/src/Banner/ui/insert-banner.js +12 -12
  21. package/src/Card/card-manager-factory.js +5 -5
  22. package/src/Card/card-manager.js +33 -33
  23. package/src/Card/constants.js +1 -1
  24. package/src/Card/display/card-display.js +11 -11
  25. package/src/Card/log-card-dismissal.js +3 -3
  26. package/src/Card/log-content-card-click.js +3 -3
  27. package/src/Card/log-content-card-impressions.js +6 -6
  28. package/src/Card/models/captioned-image.js +21 -21
  29. package/src/Card/models/card.js +73 -73
  30. package/src/Card/models/classic-card.js +21 -21
  31. package/src/Card/models/control-card.js +11 -11
  32. package/src/Card/models/image-only.js +18 -18
  33. package/src/Card/util/card-factory.js +41 -41
  34. package/src/ContentCards/content-cards-provider-factory.js +12 -12
  35. package/src/ContentCards/content-cards-provider.js +151 -151
  36. package/src/ContentCards/content-cards.js +5 -5
  37. package/src/ContentCards/get-cached-content-cards.js +2 -2
  38. package/src/ContentCards/request-content-cards-refresh.js +2 -2
  39. package/src/ContentCards/subscribe-to-content-cards-updates.js +6 -6
  40. package/src/ContentCards/ui/show-content-cards.js +10 -10
  41. package/src/Core/add-sdk-metadata.js +2 -2
  42. package/src/Core/change-user.js +6 -6
  43. package/src/Core/disable-sdk.js +9 -8
  44. package/src/Core/enable-sdk.js +5 -5
  45. package/src/Core/get-user.js +1 -1
  46. package/src/Core/handle-braze-action.js +3 -3
  47. package/src/Core/is-disabled.js +2 -2
  48. package/src/Core/log-custom-event.js +8 -8
  49. package/src/Core/log-purchase.js +5 -5
  50. package/src/Core/open-session.js +7 -7
  51. package/src/Core/set-sdk-authentication-signature.js +3 -3
  52. package/src/Core/subscribe-to-sdk-authentication-failures.js +1 -1
  53. package/src/Core/wipe-data.js +6 -6
  54. package/src/DUST/dust-provider-factory.js +11 -11
  55. package/src/DUST/dust-provider.js +255 -255
  56. package/src/DUST/dust-shared-worker-impl.js +100 -100
  57. package/src/DUST/dust-worker-bridge.js +27 -27
  58. package/src/DUST/subscribe-to-dust.js +9 -9
  59. package/src/FeatureFlags/feature-flag-factory.js +8 -8
  60. package/src/FeatureFlags/feature-flag.js +9 -9
  61. package/src/FeatureFlags/feature-flags-provider.js +86 -86
  62. package/src/FeatureFlags/get-all-feature-flags.js +2 -2
  63. package/src/FeatureFlags/get-feature-flag.js +2 -2
  64. package/src/FeatureFlags/log-feature-flag-impression.js +5 -5
  65. package/src/FeatureFlags/subscribe-to-feature-flags-updates.js +2 -2
  66. package/src/InAppMessage/constants.js +83 -2
  67. package/src/InAppMessage/defer-in-app-message.js +1 -1
  68. package/src/InAppMessage/display/html-message-display-utils.js +15 -15
  69. package/src/InAppMessage/display/html-message-to-html.js +36 -37
  70. package/src/InAppMessage/display/in-app-message-to-html.js +44 -44
  71. package/src/InAppMessage/display/modal-utils.js +10 -14
  72. package/src/InAppMessage/in-app-message-factory.js +16 -20
  73. package/src/InAppMessage/in-app-message-manager.js +116 -117
  74. package/src/InAppMessage/log-in-app-message-button-click.js +8 -8
  75. package/src/InAppMessage/log-in-app-message-click.js +7 -7
  76. package/src/InAppMessage/log-in-app-message-html-click.js +8 -8
  77. package/src/InAppMessage/log-in-app-message-impression.js +5 -5
  78. package/src/InAppMessage/models/control-message.js +4 -4
  79. package/src/InAppMessage/models/full-screen-message.js +56 -49
  80. package/src/InAppMessage/models/html-message.js +31 -27
  81. package/src/InAppMessage/models/in-app-message-button.js +12 -12
  82. package/src/InAppMessage/models/in-app-message.js +202 -256
  83. package/src/InAppMessage/models/modal-message.js +55 -49
  84. package/src/InAppMessage/models/slide-up-message.js +57 -51
  85. package/src/InAppMessage/models/templated-in-app-message.js +10 -10
  86. package/src/InAppMessage/shared-types.js +1 -0
  87. package/src/InAppMessage/subscribe-to-in-app-message.js +1 -1
  88. package/src/InAppMessage/ui/automatically-show-in-app-messages.js +5 -5
  89. package/src/InAppMessage/ui/remove-all-visible-in-app-messages.js +3 -3
  90. package/src/InAppMessage/ui/show-in-app-message.js +43 -41
  91. package/src/Push/is-push-blocked.js +2 -2
  92. package/src/Push/is-push-permission-granted.js +2 -2
  93. package/src/Push/is-push-supported.js +2 -2
  94. package/src/Push/push-manager-factory.js +9 -9
  95. package/src/Push/push-manager.js +15 -15
  96. package/src/Push/utils/push-utils.js +15 -15
  97. package/src/User/user-manager.js +14 -14
  98. package/src/User/user.js +60 -59
  99. package/src/common/base-provider.js +1 -1
  100. package/src/common/constants.js +2 -1
  101. package/src/common/content-cards-display.js +38 -38
  102. package/src/common/event-logger.js +8 -8
  103. package/src/l10n/l10n-manager-factory.js +9 -9
  104. package/src/l10n/l10n-manager.js +2 -2
  105. package/src/managers/auth-manager.js +31 -31
  106. package/src/managers/braze-instance.js +197 -182
  107. package/src/managers/constants.js +1 -0
  108. package/src/managers/device-manager.js +25 -25
  109. package/src/managers/network-manager.js +155 -155
  110. package/src/managers/server-config-manager.js +106 -93
  111. package/src/managers/session-manager.js +37 -33
  112. package/src/managers/storage-manager-factory.js +33 -28
  113. package/src/managers/storage-manager.js +194 -175
  114. package/src/managers/subscription-manager.js +13 -13
  115. package/src/managers/utils.js +1 -1
  116. package/src/models/backend-errors.js +5 -5
  117. package/src/models/braze-event.js +13 -13
  118. package/src/models/device.js +3 -3
  119. package/src/models/identifier.js +12 -12
  120. package/src/models/push-token.js +9 -9
  121. package/src/models/request-result.js +4 -4
  122. package/src/models/server-config.js +29 -38
  123. package/src/request-controller.js +159 -163
  124. package/src/triggers/models/custom-event-data.js +7 -7
  125. package/src/triggers/models/custom-event-property-data.js +10 -10
  126. package/src/triggers/models/filter-set.js +12 -12
  127. package/src/triggers/models/filter.js +66 -66
  128. package/src/triggers/models/in-app-message-click-data.js +13 -13
  129. package/src/triggers/models/purchase-data.js +4 -4
  130. package/src/triggers/models/purchase-property-data.js +10 -10
  131. package/src/triggers/models/push-click-data.js +8 -8
  132. package/src/triggers/models/trigger-condition.js +58 -58
  133. package/src/triggers/models/trigger-events.js +3 -3
  134. package/src/triggers/models/trigger.js +44 -44
  135. package/src/triggers/triggers-provider-factory.js +5 -5
  136. package/src/triggers/triggers-provider.js +70 -70
  137. package/src/ui/js/attach-css.js +3 -3
  138. package/src/ui/js/feed-css.js +2 -2
  139. package/src/ui/js/iam-css.js +2 -2
  140. package/src/ui/js/load-font-awesome.js +2 -2
  141. package/src/util/base-device-parser.js +9 -9
  142. package/src/util/braze-actions.js +3 -3
  143. package/src/util/browser-detector.js +37 -37
  144. package/src/util/client-hints-parser.js +9 -9
  145. package/src/util/component-utils.js +3 -3
  146. package/src/util/dom-utils.js +2 -2
  147. package/src/util/html-display-utils.js +11 -11
  148. package/src/util/key-codes.js +1 -1
  149. package/src/util/net.js +8 -8
  150. package/src/util/request-header-utils.js +25 -25
  151. package/src/util/user-agent-parser.js +20 -20
  152. package/src/util/validation-utils.js +21 -21
  153. 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 m from "../managers/subscription-manager.js";
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 u,
10
- REQUEST_BACKOFF_MIN_SLEEP_MS_DEFAULT as c,
11
- REQUEST_BACKOFF_SCALE_FACTOR_DEFAULT as d,
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 tr extends t {
22
+ export default class nr extends t {
23
23
  constructor(i, t, s, e, n = !0) {
24
24
  super(),
25
- (this.j = i),
26
- (this.B = t),
25
+ (this.B = i),
26
+ (this.C = t),
27
27
  (this.h = s),
28
- (this.j = i),
29
- (this.B = t),
28
+ (this.B = i),
29
+ (this.C = t),
30
30
  (this.h = s),
31
31
  (this.mite = null),
32
- (this.ki = null),
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.Pi = null),
47
- (this.qi = null),
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 = this.Vi(n)),
54
- (this.Xi = !1),
55
- (this.Yi = 0),
56
- this.Zi();
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
- Vi(i) {
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
- _i() {
70
- this.Ki = new si({
71
- we: (i) => {
72
- this.Se(i);
69
+ Ae() {
70
+ this.We = new si({
71
+ Be: (i) => {
72
+ this.Ge(i);
73
73
  },
74
- ke: () => {
75
- this.ye();
74
+ Pe: () => {
75
+ this.qe();
76
76
  },
77
- Re: () => {},
78
- Me: (i) => {
77
+ He: () => {},
78
+ Je: (i) => {
79
79
  E.error(`Real-time messaging SharedWorker error: ${i}`);
80
80
  },
81
81
  });
82
- this.Ki.initialize() ||
82
+ this.We.initialize() ||
83
83
  (E.info(
84
84
  "SharedWorker initialization failed, falling back to direct EventSource",
85
85
  ),
86
- (this.Qi = "direct"),
87
- (this.Ki = null));
86
+ (this.Fe = "direct"),
87
+ (this.We = null));
88
88
  }
89
- ye() {
90
- (this.ji = 0),
91
- (this.Bi = null),
92
- (this.zi = !0),
93
- (this.Xi = !1),
94
- (this.Yi = 0);
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
- Se(i) {
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.Qi ? "SharedWorker" : "Direct";
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.Ji.get(i.type);
104
- if (s && s.De() > 0)
103
+ const s = this.Me.get(i.type);
104
+ if (s && s.Le() > 0)
105
105
  try {
106
- s.L(i);
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
- We() {
115
- return "sharedworker" === this.Qi;
114
+ Oe() {
115
+ return "sharedworker" === this.Fe;
116
116
  }
117
- Fe() {
118
- return this.Qi;
117
+ Ie() {
118
+ return this.Fe;
119
119
  }
120
- Zi() {
121
- if (this.B) {
122
- const i = this.B.dt(s.ft.Ue),
123
- t = this.B.dt(s.ft.Ne),
124
- e = this.B.dt(s.ft.Te),
125
- n = this.B.dt(s.ft.ze);
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.ki = t),
129
- (this.yi = e),
130
- (this.$i = n),
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.Ae());
136
+ this.Ye());
137
137
  }
138
138
  }
139
139
  Hr() {
140
- this.Li ||
141
- this.Oi ||
142
- ((this.Li = this.Be("ddr", (i) => {
143
- if (!i.body || "number" != typeof i.body.Ge) return;
144
- const t = Math.random() * i.body.Ge * 0.3,
145
- s = Math.round(i.body.Ge + t),
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.Pe(),
149
- setTimeout(() => this.qe(), s);
148
+ this.sn(),
149
+ setTimeout(() => this.en(), s);
150
150
  })),
151
- (this.Oi = this.Be("ttl", (i) => {
152
- if (!i.body || "number" != typeof i.body.He) return;
153
- const t = i.body.He;
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.Qi &&
156
- ("string" == typeof i.body.Je && (this.Mi = i.body.Je),
157
- null !== this.Ui && window.clearTimeout(this.Ui),
158
- (this.Ui = window.setTimeout(() => {
159
- (this.Ui = null),
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.Le();
161
+ this.an();
162
162
  }, t)));
163
163
  })));
164
164
  }
165
- Oe() {
166
- this.Gi ||
167
- this.Pi ||
168
- ((this.qi = () => {
169
- (this.Hi = !0), (this.zi = !1);
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.qi),
172
- (this.Gi = () => {
171
+ window.addEventListener("beforeunload", this.ye),
172
+ (this.Se = () => {
173
173
  var i;
174
- this.Hi = !0;
175
- (this.xi ||
176
- (null === (i = this.Ki) || void 0 === i ? void 0 : i.Ie())) &&
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.zi = !1),
179
- this.Pe());
178
+ (this._i = !1),
179
+ this.sn());
180
180
  }),
181
- window.addEventListener("pagehide", this.Gi),
182
- (this.Pi = (i) => {
181
+ window.addEventListener("pagehide", this.Se),
182
+ (this.ke = (i) => {
183
183
  var t;
184
184
  const s =
185
- this.xi || (null === (t = this.Ki) || void 0 === t ? void 0 : t.Ie());
185
+ this.Qi || (null === (t = this.We) || void 0 === t ? void 0 : t.cn());
186
186
  i.persisted &&
187
- this.Ke() &&
187
+ this.un() &&
188
188
  !s &&
189
189
  (E.info("Page restored from bfcache, reconnecting"),
190
- (this.Hi = !1),
191
- this.ye(),
192
- this.qe());
190
+ (this.Re = !1),
191
+ this.qe(),
192
+ this.en());
193
193
  }),
194
- window.addEventListener("pageshow", this.Pi));
194
+ window.addEventListener("pageshow", this.ke));
195
195
  }
196
- St() {
197
- return this.D;
196
+ Lt() {
197
+ return this.T;
198
198
  }
199
- wt(i) {
200
- this.D = i;
199
+ $t(i) {
200
+ this.T = i;
201
201
  }
202
- Be(i, t) {
202
+ Ze(i, t) {
203
203
  if ("function" != typeof t) return null;
204
- let s = this.Ji.get(i);
205
- return s || ((s = new m()), this.Ji.set(i, s), r.q(s)), s.Rt(t);
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
- Qe(i, t) {
208
- const s = this.Ji.get(i);
207
+ dn(i, t) {
208
+ const s = this.Me.get(i);
209
209
  s && s.removeSubscription(t);
210
210
  }
211
- Ke() {
212
- return Boolean(this.mite && this.ki);
211
+ un() {
212
+ return Boolean(this.mite && this.Wi);
213
213
  }
214
- Ve() {
215
- if (!this.$i) return !1;
216
- return Math.floor(new Date().valueOf() / 1e3) >= this.$i;
214
+ gn() {
215
+ if (!this.Hi) return !1;
216
+ return Math.floor(new Date().valueOf() / 1e3) >= this.Hi;
217
217
  }
218
- Ae() {
218
+ Ye() {
219
219
  (this.mite = null),
220
- (this.ki = null),
221
- (this.yi = null),
222
- (this.$i = null),
223
- (this.Mi = null),
224
- this.B &&
225
- (this.B.zt(s.ft.Ue),
226
- this.B.zt(s.ft.Ne),
227
- this.B.zt(s.ft.Te),
228
- this.B.zt(s.ft.ze));
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
- Xe(i, t) {
230
+ mn(i, t) {
231
231
  const e = () => {
232
232
  "function" == typeof t && t();
233
233
  },
234
- n = this.j,
235
- r = this.B;
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.Ye())
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.Ke()
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.$({}, !0),
248
- a = n.A(o, h.H.Ze, !1),
247
+ const o = n.Z({}, !0),
248
+ a = n.tt(o, h.it.pn, !1),
249
249
  c = new Date().valueOf();
250
- h.K(r, h.H.Ze, c),
251
- l.O({
252
- url: `${n.V()}/dust/config`,
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
- W: (t) => {
256
- if (!n.Y(o, t, a))
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.Z(),
263
+ n.ct(),
264
264
  t.mite && t.host
265
265
  ? ((this.mite = t.mite),
266
- (this.ki = t.host),
267
- (this.yi = t.auth || null),
268
- (this.$i = t.expiration || null),
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.bt(s.ft.Ue, t.mite),
273
- r.bt(s.ft.Ne, t.host),
274
- t.auth ? r.bt(s.ft.Te, t.auth) : r.zt(s.ft.Te),
275
- t.expiration ? r.bt(s.ft.ze, t.expiration) : r.zt(s.ft.ze),
276
- this.qe(),
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.Ae(),
281
+ this.Ye(),
282
282
  e());
283
283
  },
284
284
  error: (i) => {
285
- n._(i, "retrieving DUST config"), e();
285
+ n.dt(i, "retrieving DUST config"), e();
286
286
  },
287
287
  });
288
288
  }
289
- qe() {
290
- if (!this.h || !this.h.Ye()) return;
291
- if (!this.Ke())
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.Ve())
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.Xe(
300
+ void this.mn(
301
301
  () => {
302
- this.qe();
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.Ri || this.ki;
312
+ t = this.Oi || this.Wi;
313
313
  if (i && t)
314
- switch (this.Qi) {
314
+ switch (this.Fe) {
315
315
  case "sharedworker":
316
- this._e(i, t);
316
+ this.vn(i, t);
317
317
  break;
318
318
  case "direct":
319
- this.xi &&
319
+ this.Qi &&
320
320
  (E.info(
321
321
  "Real-time connection already exists, closing before starting new subscription",
322
322
  ),
323
- this.Pe()),
324
- this.sn();
323
+ this.sn()),
324
+ this.wn();
325
325
  }
326
326
  }
327
- en() {
327
+ bn() {
328
328
  const i = this.mite,
329
- t = this.Ri || this.ki;
329
+ t = this.Oi || this.Wi;
330
330
  return i && t
331
- ? ti(t, i, this.ji, this.yi || void 0, this.Mi || void 0)
331
+ ? ti(t, i, this.Vi, this.Gi || void 0, this.Ki || void 0)
332
332
  : null;
333
333
  }
334
- _e(i, t) {
334
+ vn(i, t) {
335
335
  var s, e, n;
336
- if ((this.Ki || this._i(), !this.Ki))
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.Qi = "direct"),
342
- void this.on()
341
+ (this.Fe = "direct"),
342
+ void this.Sn()
343
343
  );
344
- this.Ri && E.info(`Using custom real-time messaging host: ${this.Ri}`),
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.st()) || c,
347
- o = (null === (e = this.h) || void 0 === e ? void 0 : e.nt()) || u,
348
- h = (null === (n = this.h) || void 0 === n ? void 0 : n.it()) || d;
349
- this.Ki.connect({
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
- ki: t,
352
- auth: this.yi || void 0,
353
- hn: { an: r, ln: o, cn: h },
351
+ Wi: t,
352
+ auth: this.Gi || void 0,
353
+ kn: { yn: r, $n: o, Rn: h },
354
354
  });
355
355
  }
356
- on() {
357
- this.xi &&
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.un()),
362
- this.sn();
361
+ this.Cn()),
362
+ this.wn();
363
363
  }
364
- sn(i) {
365
- const t = this.en();
364
+ wn(i) {
365
+ const t = this.bn();
366
366
  if (t) {
367
- this.Ri && E.info(`Using custom real-time messaging host: ${this.Ri}`);
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.xi = s),
378
- (this.ji = 0),
379
- (this.Bi = null),
380
- (this.zi = !0),
381
- (this.Xi = !0);
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.dn(i.data);
384
+ this.Mn(i.data);
385
385
  }),
386
386
  (s.onerror = () => {
387
387
  const t = s.readyState;
388
388
  return (
389
- this.Hi ||
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.xi !== s
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.zi && this.ji < this.Wi && this.gn()))
399
- : (this.un(),
400
- this.Xi && (this.Yi++, this.Yi > 1)
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.zi = !1))
405
- : void (this.zi && this.ji < this.Wi
406
- ? this.gn()
407
- : (this.ji >= this.Wi &&
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.Wi}) reached for real-time messaging, giving up for current session`,
409
+ `Max retry attempts (${this.Xi}) reached for real-time messaging, giving up for current session`,
410
410
  ),
411
- (this.zi = !1))))
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
- gn() {
423
+ xn() {
424
424
  var i, t, s;
425
- this.ji++;
426
- const e = (null === (i = this.h) || void 0 === i ? void 0 : i.st()) || c,
427
- n = (null === (t = this.h) || void 0 === t ? void 0 : t.it()) || d,
428
- r = (null === (s = this.h) || void 0 === s ? void 0 : s.nt()) || u;
429
- let o = this.Bi;
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.Bi = h),
432
+ (this.we = h),
433
433
  E.info(
434
- `Retrying real-time messaging connection in ${h}ms (attempt ${this.ji}/${this.Wi})`,
434
+ `Retrying real-time messaging connection in ${h}ms (attempt ${this.Vi}/${this.Xi})`,
435
435
  ),
436
- (this.Fi = window.setTimeout(() => {
437
- (this.Fi = null), this.qe();
436
+ (this.Yi = window.setTimeout(() => {
437
+ (this.Yi = null), this.en();
438
438
  }, h));
439
439
  }
440
- Le() {
441
- if (this.Ke()) {
442
- if (this.Ve())
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.Pe(),
448
- void this.qe()
447
+ this.sn(),
448
+ void this.en()
449
449
  );
450
- null !== this.Ui && (window.clearTimeout(this.Ui), (this.Ui = null)),
451
- this.sn(this.xi || void 0);
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
- Pe() {
454
+ sn() {
455
455
  var i;
456
- switch (this.Qi) {
456
+ switch (this.Fe) {
457
457
  case "sharedworker":
458
- null === (i = this.Ki) || void 0 === i || i.disconnect();
458
+ null === (i = this.We) || void 0 === i || i.disconnect();
459
459
  break;
460
460
  case "direct":
461
- this.un();
461
+ this.Cn();
462
462
  }
463
463
  }
464
- un() {
465
- null !== this.Fi && (window.clearTimeout(this.Fi), (this.Fi = null)),
466
- null !== this.Ui && (window.clearTimeout(this.Ui), (this.Ui = null)),
467
- this.xi &&
468
- (this.xi.close(),
469
- (this.xi = null),
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
- dn(i) {
472
+ Mn(i) {
473
473
  try {
474
474
  const t = JSON.parse(i);
475
- this.Se(t);
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.Pe(),
485
+ this.sn(),
486
486
  i ||
487
- (this.Ke() &&
487
+ (this.un() &&
488
488
  E.info(
489
489
  "Clearing cached real-time messaging configuration for user change",
490
490
  ),
491
- this.Ae()),
492
- this.ye();
491
+ this.Ye()),
492
+ this.qe();
493
493
  }
494
494
  clearData(i = !1) {
495
- (this.zi = !1),
496
- this.Pe(),
495
+ (this._i = !1),
496
+ this.sn(),
497
497
  i &&
498
- (this.Ke() &&
498
+ (this.un() &&
499
499
  E.info(
500
500
  "Clearing cached real-time messaging configuration (wipeData)",
501
501
  ),
502
- this.Ae()),
503
- this.ye();
502
+ this.Ye()),
503
+ this.qe();
504
504
  }
505
505
  destroy() {
506
- (this.zi = !1),
507
- this.Pe(),
508
- this.Ae(),
509
- this.Ki && (this.Ki.destroy(), (this.Ki = null)),
510
- this.Li && (this.Qe("ddr", this.Li), (this.Li = null)),
511
- this.Oi && (this.Qe("ttl", this.Oi), (this.Oi = null)),
512
- this.qi &&
513
- (window.removeEventListener("beforeunload", this.qi), (this.qi = null)),
514
- this.Gi &&
515
- (window.removeEventListener("pagehide", this.Gi), (this.Gi = null)),
516
- this.Pi &&
517
- (window.removeEventListener("pageshow", this.Pi), (this.Pi = null)),
518
- this.D && (r.removeSubscription(this.D), (this.D = null));
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
  }