@braze/web-sdk 6.12.1 → 6.13.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 (149) hide show
  1. package/index.d.ts +240 -3
  2. package/package.json +1 -1
  3. package/shared-lib/event-types.js +18 -18
  4. package/shared-lib/indexed-db-adapter.js +58 -58
  5. package/shared-lib/logger.js +7 -7
  6. package/shared-lib/supported-options.js +25 -24
  7. package/src/ConversationalChat/automatically-manage-chat.js +5 -0
  8. package/src/ConversationalChat/chat-message-factory.js +25 -0
  9. package/src/ConversationalChat/chat-message.js +33 -0
  10. package/src/ConversationalChat/constants.js +1 -0
  11. package/src/ConversationalChat/conversational-chat-provider-factory.js +26 -0
  12. package/src/ConversationalChat/conversational-chat-provider.js +372 -0
  13. package/src/ConversationalChat/display/chat-widget-manager.js +113 -0
  14. package/src/ConversationalChat/display/chat-widget-to-html.js +58 -0
  15. package/src/ConversationalChat/get-chat-messages.js +7 -0
  16. package/src/ConversationalChat/index.js +12 -0
  17. package/src/ConversationalChat/is-chat-conversation-ended.js +7 -0
  18. package/src/ConversationalChat/is-chat-turn-errored.js +7 -0
  19. package/src/ConversationalChat/is-chat-turn-in-progress.js +7 -0
  20. package/src/ConversationalChat/register-chat-action-handler.js +10 -0
  21. package/src/ConversationalChat/reset-chat-conversation.js +5 -0
  22. package/src/ConversationalChat/retrieve-chat-config.js +7 -0
  23. package/src/ConversationalChat/send-chat-message.js +17 -0
  24. package/src/ConversationalChat/subscribe-to-chat-action.js +5 -0
  25. package/src/ConversationalChat/subscribe-to-chat-conversation-updated.js +5 -0
  26. package/src/ConversationalChat/subscribe-to-chat-message-received.js +5 -0
  27. package/src/ConversationalChat/trigger-chat-action.js +11 -0
  28. package/src/ConversationalChat/types.js +1 -0
  29. package/src/Core/add-sdk-metadata.js +5 -5
  30. package/src/Core/change-user.js +6 -6
  31. package/src/Core/disable-sdk.js +6 -6
  32. package/src/Core/enable-sdk.js +3 -3
  33. package/src/Core/get-device-id.js +2 -2
  34. package/src/Core/handle-braze-action.js +20 -13
  35. package/src/Core/is-disabled.js +1 -1
  36. package/src/Core/is-initialized.js +1 -1
  37. package/src/Core/log-custom-event.js +9 -9
  38. package/src/Core/log-ecommerce-event.js +4 -4
  39. package/src/Core/log-purchase.js +14 -14
  40. package/src/Core/open-session.js +8 -8
  41. package/src/Core/set-sdk-authentication-signature.js +3 -3
  42. package/src/Core/subscribe-to-sdk-authentication-failures.js +1 -1
  43. package/src/Core/wipe-data.js +1 -1
  44. package/src/DUST/dust-config-store.js +35 -35
  45. package/src/DUST/dust-message-dedup.js +3 -3
  46. package/src/DUST/dust-provider-factory.js +10 -10
  47. package/src/DUST/dust-provider.js +234 -234
  48. package/src/DUST/subscribe-to-dust.js +7 -7
  49. package/src/FeatureFlags/feature-flag-factory.js +2 -2
  50. package/src/FeatureFlags/feature-flag.js +4 -4
  51. package/src/FeatureFlags/feature-flags-provider-factory.js +11 -11
  52. package/src/FeatureFlags/feature-flags-provider.js +38 -38
  53. package/src/FeatureFlags/get-all-feature-flags.js +3 -3
  54. package/src/FeatureFlags/get-feature-flag.js +3 -3
  55. package/src/FeatureFlags/log-feature-flag-impression.js +4 -4
  56. package/src/FeatureFlags/refresh-feature-flags.js +5 -5
  57. package/src/FeatureFlags/subscribe-to-feature-flags-updates.js +3 -3
  58. package/src/InAppMessage/defer-in-app-message.js +1 -1
  59. package/src/InAppMessage/display/html-message-display-utils.js +4 -4
  60. package/src/InAppMessage/display/html-message-to-html.js +13 -13
  61. package/src/InAppMessage/display/in-app-message-to-html.js +20 -20
  62. package/src/InAppMessage/display/modal-utils.js +7 -7
  63. package/src/InAppMessage/in-app-message-factory.js +6 -6
  64. package/src/InAppMessage/in-app-message-manager.js +92 -92
  65. package/src/InAppMessage/log-in-app-message-button-click.js +9 -9
  66. package/src/InAppMessage/log-in-app-message-click.js +7 -7
  67. package/src/InAppMessage/log-in-app-message-html-click.js +6 -6
  68. package/src/InAppMessage/log-in-app-message-impression.js +3 -3
  69. package/src/InAppMessage/models/full-screen-message.js +39 -39
  70. package/src/InAppMessage/models/html-message.js +20 -20
  71. package/src/InAppMessage/models/in-app-message-button.js +2 -2
  72. package/src/InAppMessage/models/in-app-message.js +102 -102
  73. package/src/InAppMessage/models/modal-message.js +38 -38
  74. package/src/InAppMessage/models/slide-up-message.js +34 -34
  75. package/src/InAppMessage/models/templated-in-app-message.js +8 -8
  76. package/src/InAppMessage/subscribe-to-in-app-message.js +1 -1
  77. package/src/InAppMessage/ui/automatically-show-in-app-messages.js +3 -3
  78. package/src/InAppMessage/ui/remove-all-visible-in-app-messages.js +3 -3
  79. package/src/InAppMessage/ui/show-in-app-message.js +23 -23
  80. package/src/Push/is-push-blocked.js +2 -2
  81. package/src/Push/is-push-permission-granted.js +2 -2
  82. package/src/Push/is-push-supported.js +2 -2
  83. package/src/Push/push-manager-factory.js +15 -15
  84. package/src/Push/push-manager.js +13 -13
  85. package/src/Push/register-push.js +2 -2
  86. package/src/Push/request-push-permission.js +2 -2
  87. package/src/Push/unregister-push-token-on-server.js +3 -3
  88. package/src/Push/unregister-push.js +3 -3
  89. package/src/Push/utils/push-utils.js +15 -15
  90. package/src/User/user-manager.js +9 -9
  91. package/src/User/user.js +50 -50
  92. package/src/common/constants.js +1 -1
  93. package/src/common/content-cards-display.js +22 -22
  94. package/src/common/event-logger.js +3 -3
  95. package/src/index.js +2 -9
  96. package/src/l10n/l10n-manager-factory.js +4 -4
  97. package/src/l10n/l10n-manager.js +6 -6
  98. package/src/managers/auth-manager.js +28 -28
  99. package/src/managers/braze-action-manager.js +14 -0
  100. package/src/managers/braze-instance.js +159 -151
  101. package/src/managers/device-manager.js +26 -26
  102. package/src/managers/network-manager.js +120 -120
  103. package/src/managers/server-config-manager.js +95 -86
  104. package/src/managers/session-manager.js +25 -25
  105. package/src/managers/storage-manager-factory.js +12 -12
  106. package/src/managers/storage-manager.js +129 -124
  107. package/src/managers/subscription-manager.js +8 -8
  108. package/src/models/backend-errors.js +5 -5
  109. package/src/models/braze-event.js +5 -5
  110. package/src/models/device.js +2 -2
  111. package/src/models/identifier.js +8 -8
  112. package/src/models/push-token.js +6 -6
  113. package/src/models/request-result.js +2 -2
  114. package/src/models/server-config.js +27 -27
  115. package/src/request-controller.js +117 -117
  116. package/src/standard-index.js +9 -0
  117. package/src/triggers/models/custom-event-data.js +4 -4
  118. package/src/triggers/models/custom-event-property-data.js +5 -5
  119. package/src/triggers/models/filter-set.js +5 -5
  120. package/src/triggers/models/filter.js +31 -31
  121. package/src/triggers/models/in-app-message-click-data.js +9 -9
  122. package/src/triggers/models/purchase-data.js +1 -1
  123. package/src/triggers/models/purchase-property-data.js +5 -5
  124. package/src/triggers/models/push-click-data.js +4 -4
  125. package/src/triggers/models/trigger-condition.js +35 -35
  126. package/src/triggers/models/trigger-events.js +3 -3
  127. package/src/triggers/models/trigger.js +36 -36
  128. package/src/triggers/triggers-provider-factory.js +5 -5
  129. package/src/triggers/triggers-provider.js +128 -128
  130. package/src/types.js +2 -2
  131. package/src/ui/js/attach-css.js +1 -1
  132. package/src/ui/js/chat-widget-css.js +11 -0
  133. package/src/ui/js/load-font-awesome.js +1 -1
  134. package/src/util/base-device-parser.js +7 -7
  135. package/src/util/braze-actions.js +5 -5
  136. package/src/util/browser-detector.js +41 -41
  137. package/src/util/client-hints-parser.js +10 -10
  138. package/src/util/component-utils.js +1 -1
  139. package/src/util/date-utils.js +2 -2
  140. package/src/util/device-constants.js +5 -5
  141. package/src/util/dom-utils.js +8 -8
  142. package/src/util/ecommerce-event-validation.js +13 -13
  143. package/src/util/html-display-utils.js +6 -6
  144. package/src/util/key-codes.js +1 -1
  145. package/src/util/net.js +82 -44
  146. package/src/util/request-header-utils.js +26 -24
  147. package/src/util/user-agent-parser.js +21 -21
  148. package/src/util/validation-utils.js +29 -21
  149. package/src/util/window-utils.js +3 -3
@@ -14,13 +14,13 @@ import {
14
14
  MAX_RETRIES as ii,
15
15
  buildSseUrl as ti,
16
16
  } from "./dust-connection-core.js";
17
- import lt, { isConfigExpired as si } from "./dust-config-store.js";
18
- import at from "./dust-message-dedup.js";
17
+ import xt, { isConfigExpired as si } from "./dust-config-store.js";
18
+ import At from "./dust-message-dedup.js";
19
19
  import {
20
20
  buildTabMite as ei,
21
21
  generateIndividual as ni,
22
22
  } from "./dust-tab-identity.js";
23
- export default class sr extends t {
23
+ export default class dr extends t {
24
24
  constructor(i, t, s, e) {
25
25
  super(),
26
26
  (this.B = i),
@@ -30,59 +30,59 @@ export default class sr extends t {
30
30
  (this.j = t),
31
31
  (this.h = s),
32
32
  (this.mite = null),
33
- (this.ye = null),
34
- (this.Se = null),
35
- (this.Re = null),
36
- (this.ke = e || null),
37
- (this.Me = null),
38
- (this.Fe = null),
39
- (this.Ne = null),
33
+ (this.Ze = null),
34
+ (this.Fn = null),
35
+ (this.Jn = null),
36
+ (this.Ln = e || null),
37
+ (this.Pn = null),
38
+ (this.Kn = null),
39
+ (this.Vn = null),
40
40
  (this.T = null),
41
- (this.Te = 0),
42
- (this.De = ii),
43
- (this.Ue = null),
44
- (this.Ae = null),
45
- (this.Ge = null),
46
- (this.Ie = !0),
47
- (this.Je = null),
48
- (this.Oe = null),
49
- (this.Pe = null),
50
- (this.qe = null),
51
- (this.Be = !1),
52
- (this.ze = new Map()),
53
- (this.He = null),
54
- (this.Ke = null),
55
- (this.Ve = null),
56
- (this.We = null),
57
- (this._e = new lt(t)),
58
- (this.Qe = null),
59
- (this.Xe = new at(t)),
60
- (this.Ye = !1),
61
- this.Ze();
62
- }
63
- sn() {
64
- return this.We || (this.We = ni()), this.We;
65
- }
66
- en() {
67
- (this.Te = 0), (this.Je = null), (this.Ie = !0);
68
- }
69
- hn() {
70
- return null !== this.Fe && this.Fe === this.Ve;
71
- }
72
- on(i, t) {
41
+ (this.Wn = 0),
42
+ (this.Qn = ii),
43
+ (this.Yn = null),
44
+ (this.Zn = null),
45
+ (this.ih = null),
46
+ (this.th = !0),
47
+ (this.sh = null),
48
+ (this.eh = null),
49
+ (this.nh = null),
50
+ (this.hh = null),
51
+ (this.oh = !1),
52
+ (this.rh = new Map()),
53
+ (this.lh = null),
54
+ (this.ah = null),
55
+ (this.uh = null),
56
+ (this.gh = null),
57
+ (this.dh = new xt(t)),
58
+ (this.mh = null),
59
+ (this.fh = new At(t)),
60
+ (this.ph = !1),
61
+ this.wh();
62
+ }
63
+ qn() {
64
+ return this.gh || (this.gh = ni()), this.gh;
65
+ }
66
+ bh() {
67
+ (this.Wn = 0), (this.sh = null), (this.th = !0);
68
+ }
69
+ yh() {
70
+ return null !== this.Kn && this.Kn === this.uh;
71
+ }
72
+ Sh(i, t) {
73
73
  const s = i.type;
74
74
  if (!s)
75
75
  return void b.warn(
76
76
  `Received real-time message without type: ${JSON.stringify(i)}`,
77
77
  );
78
78
  if ((b.info(`Received real-time message of type '${s}'`), "cir" === s))
79
- return void this.ln(t || this.Fe);
80
- if (!this.Xe.Mr(s))
79
+ return void this.Rh(t || this.Kn);
80
+ if (!this.fh.Mr(s))
81
81
  return void b.info(
82
82
  `Another tab is handling the real-time message of type '${s}', skipping it`,
83
83
  );
84
- const e = this.ze.get(s);
85
- if (e && e.an() > 0)
84
+ const e = this.rh.get(s);
85
+ if (e && e.$h() > 0)
86
86
  try {
87
87
  e.A(i);
88
88
  } catch (i) {
@@ -90,46 +90,46 @@ export default class sr extends t {
90
90
  }
91
91
  else b.info(`No subscribers for real-time message type '${s}'`);
92
92
  }
93
- ln(i) {
93
+ Rh(i) {
94
94
  i &&
95
- this.cn(i) &&
96
- (b.info("Real-time messaging connection is ready"), (this.Ve = i));
95
+ this.Ch(i) &&
96
+ (b.info("Real-time messaging connection is ready"), (this.uh = i));
97
97
  }
98
- un(i) {
99
- this.Ve === i && (this.Ve = null);
98
+ kh(i) {
99
+ this.uh === i && (this.uh = null);
100
100
  }
101
- Ze() {
101
+ wh() {
102
102
  if (!this.j) return;
103
- const i = this._e.read();
103
+ const i = this.dh.read();
104
104
  i.mite && i.host
105
105
  ? ((this.mite = i.mite),
106
- (this.ye = i.host),
107
- (this.Se = i.auth),
108
- (this.Re = i.expiration),
106
+ (this.Ze = i.host),
107
+ (this.Fn = i.auth),
108
+ (this.Jn = i.expiration),
109
109
  b.info("Restored real-time messaging configuration from storage"))
110
110
  : (i.mite || i.host) &&
111
111
  (b.warn(
112
112
  "Incomplete real-time messaging configuration in storage, clearing",
113
113
  ),
114
- this.gn());
114
+ this.jh());
115
115
  }
116
- dn() {
117
- const i = this._e.read();
116
+ xh() {
117
+ const i = this.dh.read();
118
118
  i.mite &&
119
119
  i.host &&
120
- (i.auth !== this.Se &&
120
+ (i.auth !== this.Fn &&
121
121
  b.info(
122
122
  "Using real-time messaging configuration refreshed by another tab",
123
123
  ),
124
124
  (this.mite = i.mite),
125
- (this.ye = i.host),
126
- (this.Se = i.auth),
127
- (this.Re = i.expiration));
125
+ (this.Ze = i.host),
126
+ (this.Fn = i.auth),
127
+ (this.Jn = i.expiration));
128
128
  }
129
129
  Hr() {
130
- this.He ||
131
- this.Ke ||
132
- ((this.He = this.mn("ddr", (i) => {
130
+ this.lh ||
131
+ this.ah ||
132
+ ((this.lh = this.Mh("ddr", (i) => {
133
133
  var t, s, e;
134
134
  const n = i.body;
135
135
  if (!n) return;
@@ -145,12 +145,12 @@ export default class sr extends t {
145
145
  b.info(
146
146
  `Admin requested disconnect${p}, reconnecting in ${f}ms (r_ms=${h} + backoff=${g})`,
147
147
  ),
148
- this.fn(),
149
- (this.Ge = window.setTimeout(() => {
150
- (this.Ge = null), this.pn();
148
+ this.Fh(),
149
+ (this.ih = window.setTimeout(() => {
150
+ (this.ih = null), this.Nh();
151
151
  }, f));
152
152
  })),
153
- (this.Ke = this.mn("ttl", (i) => {
153
+ (this.ah = this.Mh("ttl", (i) => {
154
154
  const t = i.body;
155
155
  if (!t) return;
156
156
  b.info(`ttl message: ${JSON.stringify(t)}`);
@@ -159,42 +159,42 @@ export default class sr extends t {
159
159
  const e = s;
160
160
  b.info(`Time to live set to ${e}ms, will reconnect when expired`);
161
161
  const n = t.rcs;
162
- "string" == typeof n && (this.Me = n),
163
- null !== this.Ae && window.clearTimeout(this.Ae),
164
- (this.Ae = window.setTimeout(() => {
165
- (this.Ae = null),
162
+ "string" == typeof n && (this.Pn = n),
163
+ null !== this.Zn && window.clearTimeout(this.Zn),
164
+ (this.Zn = window.setTimeout(() => {
165
+ (this.Zn = null),
166
166
  b.info("Time to live expired, performing gapless reconnection"),
167
- this.vn();
167
+ this.Th();
168
168
  }, e));
169
169
  })));
170
170
  }
171
- wn() {
172
- this.Oe ||
173
- this.Pe ||
174
- ((this.qe = () => {
175
- (this.Be = !0), (this.Ie = !1);
171
+ Dh() {
172
+ this.eh ||
173
+ this.nh ||
174
+ ((this.hh = () => {
175
+ (this.oh = !0), (this.th = !1);
176
176
  }),
177
- window.addEventListener("beforeunload", this.qe),
178
- (this.Oe = () => {
179
- (this.Be = !0),
180
- this.we(),
181
- (this.Fe || this.Ne) &&
177
+ window.addEventListener("beforeunload", this.hh),
178
+ (this.eh = () => {
179
+ (this.oh = !0),
180
+ this.Je(),
181
+ (this.Kn || this.Vn) &&
182
182
  (b.info("Page unloading, closing real-time connection gracefully"),
183
- (this.Ie = !1),
184
- this.fn());
183
+ (this.th = !1),
184
+ this.Fh());
185
185
  }),
186
- window.addEventListener("pagehide", this.Oe),
187
- (this.Pe = (i) => {
186
+ window.addEventListener("pagehide", this.eh),
187
+ (this.nh = (i) => {
188
188
  i.persisted &&
189
- this.bn() &&
190
- !this.Fe &&
191
- !this.Ne &&
189
+ this.Uh() &&
190
+ !this.Kn &&
191
+ !this.Vn &&
192
192
  (b.info("Page restored from bfcache, reconnecting"),
193
- (this.Be = !1),
194
- this.en(),
195
- this.pn());
193
+ (this.oh = !1),
194
+ this.bh(),
195
+ this.Nh());
196
196
  }),
197
- window.addEventListener("pageshow", this.Pe));
197
+ window.addEventListener("pageshow", this.nh));
198
198
  }
199
199
  Et() {
200
200
  return this.T;
@@ -202,75 +202,75 @@ export default class sr extends t {
202
202
  Lt(i) {
203
203
  this.T = i;
204
204
  }
205
- mn(i, t) {
205
+ Mh(i, t) {
206
206
  if ("function" != typeof t) return null;
207
- let s = this.ze.get(i);
208
- return s || ((s = new f()), this.ze.set(i, s), r.S(s)), s.Ut(t);
207
+ let s = this.rh.get(i);
208
+ return s || ((s = new f()), this.rh.set(i, s), r.S(s)), s.Ut(t);
209
209
  }
210
- yn(i, t) {
211
- const s = this.ze.get(i);
210
+ Ah(i, t) {
211
+ const s = this.rh.get(i);
212
212
  s && s.removeSubscription(t);
213
213
  }
214
- bn() {
215
- return Boolean(this.mite && this.ye);
214
+ Uh() {
215
+ return Boolean(this.mite && this.Ze);
216
216
  }
217
- Sn() {
218
- return si(this.Re);
217
+ Eh() {
218
+ return si(this.Jn);
219
219
  }
220
- gn() {
220
+ jh() {
221
221
  (this.mite = null),
222
- (this.ye = null),
223
- (this.Se = null),
224
- (this.Re = null),
225
- (this.Me = null),
226
- this._e.clear();
222
+ (this.Ze = null),
223
+ (this.Fn = null),
224
+ (this.Jn = null),
225
+ (this.Pn = null),
226
+ this.dh.clear();
227
227
  }
228
- Rn(i, t, s = !1) {
228
+ Gh(i, t, s = !1) {
229
229
  const e = () => {
230
230
  "function" == typeof t && t();
231
231
  },
232
232
  n = () => {
233
- this.pn(), "function" == typeof i && i();
233
+ this.Nh(), "function" == typeof i && i();
234
234
  };
235
- if (this.Ye) return void e();
235
+ if (this.ph) return void e();
236
236
  const o = this.B,
237
237
  r = this.j;
238
238
  if (!o || !r)
239
239
  return (
240
240
  b.error("NetworkManager or StorageManager not available"), void e()
241
241
  );
242
- if (!this.h || !this.h.$n())
242
+ if (!this.h || !this.h.Ih())
243
243
  return (
244
244
  b.info("Real-time messaging is not enabled, skipping refresh"), void e()
245
245
  );
246
- const a = this.Qe || this._e.Yi();
246
+ const a = this.mh || this.dh.Ve();
247
247
  if (!a && !s)
248
248
  return (
249
249
  b.info(
250
250
  "Another tab is refreshing real-time messaging configuration, waiting for the result",
251
251
  ),
252
- void this._e.xe(
252
+ void this.dh.Qe(
253
253
  () => {
254
- this.dn(), n();
254
+ this.xh(), n();
255
255
  },
256
- () => this.Rn(i, t, !0),
256
+ () => this.Gh(i, t, !0),
257
257
  )
258
258
  );
259
- (this.Qe = a),
260
- this.bn()
259
+ (this.mh = a),
260
+ this.Uh()
261
261
  ? b.info("Refreshing real-time messaging configuration")
262
262
  : b.info("Fetching initial real-time messaging configuration");
263
263
  const c = o.Z({}, !0),
264
- u = o.tt(c, h.it.Cn),
264
+ u = o.tt(c, h.it.Jh),
265
265
  g = new Date().valueOf();
266
- h.nt(r, h.it.Cn, g),
266
+ h.nt(r, h.it.Jh, g),
267
267
  l.ot({
268
268
  url: `${o.ht()}/dust/config`,
269
269
  headers: u,
270
270
  data: c,
271
271
  lt: (i) => {
272
- if (!this.Ye) {
273
- if ((this.we(), !o.ut(c, i, u)))
272
+ if (!this.ph) {
273
+ if ((this.Je(), !o.ut(c, i, u)))
274
274
  return (
275
275
  b.error(
276
276
  "Failed to validate server response for real-time messaging configuration",
@@ -280,134 +280,134 @@ export default class sr extends t {
280
280
  o.ct(),
281
281
  i.mite && i.host
282
282
  ? ((this.mite = i.mite),
283
- (this.ye = i.host),
284
- (this.Se = i.auth || null),
285
- (this.Re = i.expiration || null),
283
+ (this.Ze = i.host),
284
+ (this.Fn = i.auth || null),
285
+ (this.Jn = i.expiration || null),
286
286
  b.info(
287
287
  "Received real-time messaging configuration from server",
288
288
  ),
289
- this._e.write({
289
+ this.dh.write({
290
290
  mite: this.mite,
291
- host: this.ye,
292
- auth: this.Se,
293
- expiration: this.Re,
291
+ host: this.Ze,
292
+ auth: this.Fn,
293
+ expiration: this.Jn,
294
294
  }),
295
295
  n())
296
296
  : (b.info(
297
297
  "Real-time messaging configuration not available - this SDK version may not be supported",
298
298
  ),
299
- this.gn(),
299
+ this.jh(),
300
300
  e());
301
301
  }
302
302
  },
303
303
  error: (i) => {
304
- this.Ye || (this.we(), o.dt(i, "retrieving DUST config"), e());
304
+ this.ph || (this.Je(), o.dt(i, "retrieving DUST config"), e());
305
305
  },
306
306
  });
307
307
  }
308
- we() {
309
- this.Qe && (this._e.we(this.Qe), (this.Qe = null));
308
+ Je() {
309
+ this.mh && (this.dh.Je(this.mh), (this.mh = null));
310
310
  }
311
- pn() {
312
- if (!this.Ye && this.h && this.h.$n())
313
- if (this.Ne)
311
+ Nh() {
312
+ if (!this.ph && this.h && this.h.Ih())
313
+ if (this.Vn)
314
314
  b.info("Real-time messaging connection attempt already in progress");
315
315
  else {
316
- if ((this.dn(), this.bn()))
317
- return this.Sn()
316
+ if ((this.xh(), this.Uh()))
317
+ return this.Eh()
318
318
  ? (b.info(
319
319
  "Real-time messaging auth token has expired, refreshing configuration",
320
320
  ),
321
- void this.Rn(void 0, () => {
321
+ void this.Gh(void 0, () => {
322
322
  b.error(
323
323
  "Failed to refresh expired real-time messaging configuration",
324
324
  );
325
325
  }))
326
326
  : void (
327
- this.kn() &&
328
- (this.ke || this.ye) &&
329
- (this.Fe &&
327
+ this.Lh() &&
328
+ (this.Ln || this.Ze) &&
329
+ (this.Kn &&
330
330
  (b.info(
331
331
  "Real-time connection already exists, closing before starting new subscription",
332
332
  ),
333
- this.fn()),
334
- this.jn())
333
+ this.Fh()),
334
+ this.Oh())
335
335
  );
336
336
  b.error("Cannot start real-time subscription without configuration");
337
337
  }
338
338
  }
339
- kn() {
340
- return this.mite ? ei(this.mite, this.sn()) : null;
339
+ Lh() {
340
+ return this.mite ? ei(this.mite, this.qn()) : null;
341
341
  }
342
- xn() {
343
- const i = this.kn(),
344
- t = this.ke || this.ye;
342
+ Ph() {
343
+ const i = this.Lh(),
344
+ t = this.Ln || this.Ze;
345
345
  return i && t
346
- ? ti(t, i, this.Te, this.Se || void 0, this.Me || void 0)
346
+ ? ti(t, i, this.Wn, this.Fn || void 0, this.Pn || void 0)
347
347
  : null;
348
348
  }
349
- cn(i) {
350
- return this.Fe === i || this.Ne === i;
349
+ Ch(i) {
350
+ return this.Kn === i || this.Vn === i;
351
351
  }
352
- jn(i) {
353
- if (this.Ye) return;
354
- const t = this.xn();
352
+ Oh(i) {
353
+ if (this.ph) return;
354
+ const t = this.Ph();
355
355
  if (t) {
356
- this.ke && b.info(`Using custom real-time messaging host: ${this.ke}`);
356
+ this.Ln && b.info(`Using custom real-time messaging host: ${this.Ln}`);
357
357
  try {
358
358
  const s = new EventSource(t);
359
- (this.Ne = s),
359
+ (this.Vn = s),
360
360
  b.info(`createConnection: ${t}`),
361
361
  (s.onopen = () => {
362
- this.cn(s)
363
- ? (this.Ne === s && (this.Ne = null),
362
+ this.Ch(s)
363
+ ? (this.Vn === s && (this.Vn = null),
364
364
  i
365
365
  ? (b.info(
366
366
  "Gapless reconnection: new connection established, closing old connection",
367
367
  ),
368
368
  i.close())
369
369
  : b.info("Real-time messaging connection established"),
370
- (this.Fe = s),
371
- this.Ve !== s && (this.Ve = null),
372
- (this.Te = 0),
373
- (this.Je = null),
374
- (this.Ie = !0))
370
+ (this.Kn = s),
371
+ this.uh !== s && (this.uh = null),
372
+ (this.Wn = 0),
373
+ (this.sh = null),
374
+ (this.th = !0))
375
375
  : s.close();
376
376
  }),
377
377
  s.addEventListener("msg", (i) => {
378
- if (!this.cn(s))
378
+ if (!this.Ch(s))
379
379
  return (
380
380
  b.info("Ignoring real-time message from superseded connection"),
381
381
  void s.close()
382
382
  );
383
- this.Mn(i.data, s);
383
+ this.qh(i.data, s);
384
384
  }),
385
385
  (s.onerror = () => {
386
386
  const t = s.readyState;
387
- if (this.cn(s)) {
387
+ if (this.Ch(s)) {
388
388
  if (
389
- (this.Be ||
389
+ (this.oh ||
390
390
  (0 === t
391
391
  ? b.info("Real-time messaging failed to connect")
392
392
  : b.info("Real-time messaging connection lost")),
393
- i && this.Fe !== s)
393
+ i && this.Kn !== s)
394
394
  )
395
395
  return (
396
396
  b.info("Gapless reconnection failed, keeping old connection"),
397
397
  s.close(),
398
- this.Ne === s && (this.Ne = null),
399
- void (this.Ie && this.Te < this.De && this.Fn())
398
+ this.Vn === s && (this.Vn = null),
399
+ void (this.th && this.Wn < this.Qn && this.Bh())
400
400
  );
401
- if (this.Ne && this.Fe === s)
402
- return s.close(), (this.Fe = null), void this.un(s);
403
- this.fn(),
404
- this.Ie && this.Te < this.De
405
- ? this.Fn()
406
- : (this.Te >= this.De &&
401
+ if (this.Vn && this.Kn === s)
402
+ return s.close(), (this.Kn = null), void this.kh(s);
403
+ this.Fh(),
404
+ this.th && this.Wn < this.Qn
405
+ ? this.Bh()
406
+ : (this.Wn >= this.Qn &&
407
407
  b.error(
408
- `Max retry attempts (${this.De}) reached for real-time messaging, giving up for current session`,
408
+ `Max retry attempts (${this.Qn}) reached for real-time messaging, giving up for current session`,
409
409
  ),
410
- (this.Ie = !1));
410
+ (this.th = !1));
411
411
  } else s.close();
412
412
  });
413
413
  } catch (i) {
@@ -419,59 +419,59 @@ export default class sr extends t {
419
419
  }
420
420
  }
421
421
  }
422
- Fn() {
422
+ Bh() {
423
423
  var i, t, s;
424
- this.Te++;
424
+ this.Wn++;
425
425
  const e = (null === (i = this.h) || void 0 === i ? void 0 : i.vt()) || d,
426
426
  n = (null === (t = this.h) || void 0 === t ? void 0 : t.gt()) || m,
427
427
  h = (null === (s = this.h) || void 0 === s ? void 0 : s.bt()) || c;
428
- let o = this.Je;
428
+ let o = this.sh;
429
429
  (null == o || o < e) && (o = e);
430
430
  const r = Math.min(h, a(e, o * n));
431
- (this.Je = r),
431
+ (this.sh = r),
432
432
  b.info(
433
- `Retrying real-time messaging connection in ${r}ms (attempt ${this.Te}/${this.De})`,
433
+ `Retrying real-time messaging connection in ${r}ms (attempt ${this.Wn}/${this.Qn})`,
434
434
  ),
435
- (this.Ue = window.setTimeout(() => {
436
- (this.Ue = null), this.pn();
435
+ (this.Yn = window.setTimeout(() => {
436
+ (this.Yn = null), this.Nh();
437
437
  }, r));
438
438
  }
439
- vn() {
440
- if (this.Ne)
439
+ Th() {
440
+ if (this.Vn)
441
441
  b.info("Real-time messaging connection attempt already in progress");
442
442
  else {
443
- if ((this.dn(), this.bn()))
444
- return this.Sn()
443
+ if ((this.xh(), this.Uh()))
444
+ return this.Eh()
445
445
  ? (b.info(
446
446
  "Auth token expired during gapless reconnection, falling back to regular reconnection",
447
447
  ),
448
- this.fn(),
449
- void this.pn())
450
- : void (this.Ne
448
+ this.Fh(),
449
+ void this.Nh())
450
+ : void (this.Vn
451
451
  ? b.info(
452
452
  "Real-time connection attempt already in progress, skipping gapless reconnection",
453
453
  )
454
- : (null !== this.Ae &&
455
- (window.clearTimeout(this.Ae), (this.Ae = null)),
456
- this.jn(this.Fe || void 0)));
454
+ : (null !== this.Zn &&
455
+ (window.clearTimeout(this.Zn), (this.Zn = null)),
456
+ this.Oh(this.Kn || void 0)));
457
457
  b.error("Cannot perform gapless reconnection without configuration");
458
458
  }
459
459
  }
460
- fn() {
461
- null !== this.Ue && (window.clearTimeout(this.Ue), (this.Ue = null)),
462
- null !== this.Ae && (window.clearTimeout(this.Ae), (this.Ae = null)),
463
- null !== this.Ge && (window.clearTimeout(this.Ge), (this.Ge = null)),
464
- (this.Ve = null),
465
- this.Ne && (this.Ne.close(), (this.Ne = null)),
466
- this.Fe &&
467
- (this.Fe.close(),
468
- (this.Fe = null),
460
+ Fh() {
461
+ null !== this.Yn && (window.clearTimeout(this.Yn), (this.Yn = null)),
462
+ null !== this.Zn && (window.clearTimeout(this.Zn), (this.Zn = null)),
463
+ null !== this.ih && (window.clearTimeout(this.ih), (this.ih = null)),
464
+ (this.uh = null),
465
+ this.Vn && (this.Vn.close(), (this.Vn = null)),
466
+ this.Kn &&
467
+ (this.Kn.close(),
468
+ (this.Kn = null),
469
469
  b.info("Real-time messaging connection closed"));
470
470
  }
471
- Mn(i, t) {
471
+ qh(i, t) {
472
472
  try {
473
473
  const s = JSON.parse(i);
474
- this.on(s, t);
474
+ this.Sh(s, t);
475
475
  } catch (i) {
476
476
  b.warn(
477
477
  `Failed to parse real-time message: ${
@@ -481,42 +481,42 @@ export default class sr extends t {
481
481
  }
482
482
  }
483
483
  changeUser(i = !1) {
484
- this.fn(),
484
+ this.Fh(),
485
485
  i ||
486
- (this.bn() &&
486
+ (this.Uh() &&
487
487
  b.info(
488
488
  "Clearing cached real-time messaging configuration for user change",
489
489
  ),
490
- this.gn()),
491
- this.en();
490
+ this.jh()),
491
+ this.bh();
492
492
  }
493
493
  clearData(i = !1) {
494
- (this.Ie = !1),
495
- this.fn(),
494
+ (this.th = !1),
495
+ this.Fh(),
496
496
  i &&
497
- (this.bn() &&
497
+ (this.Uh() &&
498
498
  b.info(
499
499
  "Clearing cached real-time messaging configuration (wipeData)",
500
500
  ),
501
- this.gn(),
502
- this.Xe.Wr()),
503
- this.en();
501
+ this.jh(),
502
+ this.fh.Wr()),
503
+ this.bh();
504
504
  }
505
505
  destroy() {
506
- (this.Ye = !0),
507
- (this.Ie = !1),
508
- this.fn(),
509
- this.we(),
510
- this._e.destroy(),
511
- this.gn(),
512
- this.He && (this.yn("ddr", this.He), (this.He = null)),
513
- this.Ke && (this.yn("ttl", this.Ke), (this.Ke = null)),
514
- this.qe &&
515
- (window.removeEventListener("beforeunload", this.qe), (this.qe = null)),
516
- this.Oe &&
517
- (window.removeEventListener("pagehide", this.Oe), (this.Oe = null)),
518
- this.Pe &&
519
- (window.removeEventListener("pageshow", this.Pe), (this.Pe = null)),
506
+ (this.ph = !0),
507
+ (this.th = !1),
508
+ this.Fh(),
509
+ this.Je(),
510
+ this.dh.destroy(),
511
+ this.jh(),
512
+ this.lh && (this.Ah("ddr", this.lh), (this.lh = null)),
513
+ this.ah && (this.Ah("ttl", this.ah), (this.ah = null)),
514
+ this.hh &&
515
+ (window.removeEventListener("beforeunload", this.hh), (this.hh = null)),
516
+ this.eh &&
517
+ (window.removeEventListener("pagehide", this.eh), (this.eh = null)),
518
+ this.nh &&
519
+ (window.removeEventListener("pageshow", this.nh), (this.nh = null)),
520
520
  this.T && (r.removeSubscription(this.T), (this.T = null));
521
521
  }
522
522
  }