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