@braze/web-sdk 5.1.0 → 5.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.d.ts +14 -8
- package/package.json +1 -1
- package/shared-lib/encoding-utils.js +1 -1
- package/shared-lib/event-types.js +18 -18
- package/shared-lib/indexed-db-adapter.js +32 -32
- package/shared-lib/logger.js +2 -2
- package/shared-lib/supported-options.js +22 -21
- package/src/InAppMessage/display/html-message-to-html.js +38 -35
- package/src/InAppMessage/display/in-app-message-to-html.js +2 -2
- package/src/InAppMessage/display/modal-utils.js +2 -2
- package/src/InAppMessage/in-app-message-factory.js +21 -19
- package/src/InAppMessage/in-app-message-manager.js +58 -78
- package/src/InAppMessage/log-in-app-message-button-click.js +2 -2
- package/src/InAppMessage/log-in-app-message-click.js +3 -3
- package/src/InAppMessage/log-in-app-message-html-click.js +3 -3
- package/src/InAppMessage/log-in-app-message-impression.js +1 -1
- package/src/InAppMessage/models/control-message.js +4 -2
- package/src/InAppMessage/models/full-screen-message.js +5 -2
- package/src/InAppMessage/models/html-message.js +6 -4
- package/src/InAppMessage/models/in-app-message-button.js +2 -2
- package/src/InAppMessage/models/in-app-message.js +51 -46
- package/src/InAppMessage/models/modal-message.js +5 -2
- package/src/InAppMessage/models/slide-up-message.js +33 -8
- package/src/InAppMessage/models/templated-in-app-message.js +8 -8
- package/src/InAppMessage/ui/show-in-app-message.js +28 -34
- package/src/InAppMessage/utils/in-app-message-utils.js +18 -1
- package/src/Push/push-manager-factory.js +3 -3
- package/src/Push/push-manager.js +118 -110
- package/src/Push/utils/push-utils.js +4 -4
- package/src/User/user-manager.js +4 -4
- package/src/User/user.js +17 -17
- package/src/common/base-feed.js +1 -1
- package/src/common/feed-display.js +12 -12
- package/src/l10n/l10n-manager-factory.js +1 -1
- package/src/l10n/l10n-manager.js +4 -4
- package/src/managers/auth-manager.js +26 -26
- package/src/managers/braze-instance.js +59 -52
- package/src/managers/device-manager.js +15 -15
- package/src/managers/network-manager.js +98 -93
- package/src/managers/server-config-manager.js +9 -9
- package/src/managers/storage-manager.js +99 -96
- package/src/managers/utils.js +6 -0
- package/src/models/backend-errors.js +5 -5
- package/src/models/braze-event.js +20 -12
- package/src/models/device.js +3 -3
- package/src/models/identifier.js +33 -19
- package/src/models/push-token.js +4 -4
- package/src/models/server-config.js +6 -6
- package/src/request-controller.js +77 -73
- package/src/triggers/models/custom-event-data.js +2 -2
- package/src/triggers/models/custom-event-property-data.js +4 -4
- package/src/triggers/models/filter-set.js +5 -5
- package/src/triggers/models/filter.js +6 -6
- package/src/triggers/models/in-app-message-click-data.js +1 -1
- package/src/triggers/models/purchase-data.js +2 -2
- package/src/triggers/models/purchase-property-data.js +4 -4
- package/src/triggers/models/push-click-data.js +1 -1
- package/src/triggers/models/trigger-condition.js +41 -41
- package/src/triggers/models/trigger-events.js +1 -1
- package/src/triggers/models/trigger.js +36 -36
- package/src/triggers/triggers-provider-factory.js +1 -1
- package/src/triggers/triggers-provider.js +71 -82
- package/src/ui/js/attach-css.js +2 -2
- package/src/ui/js/load-font-awesome.js +1 -1
- package/src/util/base-device-parser.js +1 -1
- package/src/util/braze-actions.js +4 -4
- package/src/util/browser-detector.js +9 -8
- package/src/util/client-hints-parser.js +1 -1
- package/src/util/component-utils.js +2 -2
- package/src/util/device-constants.js +2 -2
- package/src/util/key-codes.js +1 -1
- package/src/util/net.js +1 -1
- package/src/util/request-header-utils.js +6 -6
- package/src/util/user-agent-parser.js +5 -5
- package/src/util/validation-utils.js +2 -0
- package/src/util/window-utils.js +3 -3
|
@@ -10,67 +10,72 @@ import { logger as r, EventTypes as i } from "../../shared-lib/index.js";
|
|
|
10
10
|
import { STORAGE_KEYS as o } from "./storage-manager.js";
|
|
11
11
|
import S from "../util/request-header-utils.js";
|
|
12
12
|
import { LAST_REQUEST_TO_ENDPOINT_MS_AGO_DEFAULT as Kt } from "../common/constants.js";
|
|
13
|
+
import { getAlias as Ht } from "./utils.js";
|
|
13
14
|
export default class Rt {
|
|
14
|
-
constructor(t, e, s, i, r, n, o,
|
|
15
|
-
(this.
|
|
15
|
+
constructor(t, e, s, i, r, n, o, h, a, u, l, c) {
|
|
16
|
+
(this.on = t),
|
|
16
17
|
(this.u = e),
|
|
17
18
|
(this.Go = s),
|
|
18
19
|
(this.wt = i),
|
|
19
20
|
(this.di = r),
|
|
20
21
|
(this.yt = n),
|
|
21
|
-
(this.
|
|
22
|
-
(this.Ko =
|
|
23
|
-
(this.Wo =
|
|
22
|
+
(this.rn = o),
|
|
23
|
+
(this.Ko = h),
|
|
24
|
+
(this.Wo = a),
|
|
24
25
|
(this.Vo = u),
|
|
25
26
|
(this.appVersion = l),
|
|
26
|
-
(this.
|
|
27
|
-
(this.
|
|
28
|
-
(this.
|
|
27
|
+
(this.Xh = c),
|
|
28
|
+
(this.Hh = (t) => (null == t ? "" : `${t} `)),
|
|
29
|
+
(this.on = t),
|
|
29
30
|
(this.u = e),
|
|
30
31
|
(this.Go = s),
|
|
31
32
|
(this.wt = i),
|
|
32
33
|
(this.di = r),
|
|
33
34
|
(this.yt = n),
|
|
34
|
-
(this.
|
|
35
|
-
(this.Ko =
|
|
36
|
-
(this.Wo =
|
|
35
|
+
(this.rn = o),
|
|
36
|
+
(this.Ko = h),
|
|
37
|
+
(this.Wo = a),
|
|
37
38
|
(this.Vo = u),
|
|
38
39
|
(this.appVersion = l),
|
|
39
|
-
(this.
|
|
40
|
-
(this.
|
|
40
|
+
(this.Xh = c),
|
|
41
|
+
(this.Yh = ["npm"]);
|
|
41
42
|
}
|
|
42
43
|
Ps(t, e = !1, s = !1) {
|
|
43
|
-
const i = this.
|
|
44
|
-
r = i.
|
|
45
|
-
n = this.u.j(o.C.
|
|
44
|
+
const i = this.on.ce(!s),
|
|
45
|
+
r = i.Mr(),
|
|
46
|
+
n = this.u.j(o.C.Ga);
|
|
46
47
|
ii(n, r) || (t.device = r),
|
|
47
|
-
(t.api_key = this.
|
|
48
|
+
(t.api_key = this.rn),
|
|
48
49
|
(t.time = h(new Date().valueOf(), !0));
|
|
49
|
-
const a = this.u.j(o.C.
|
|
50
|
-
u = this.u.j(o.C
|
|
50
|
+
const a = this.u.j(o.C.Jh) || [],
|
|
51
|
+
u = this.u.j(o.C.Qh) || "";
|
|
51
52
|
if (
|
|
52
|
-
(this.
|
|
53
|
-
(!ii(a, this.
|
|
54
|
-
(t.sdk_metadata = this.
|
|
53
|
+
(this.Yh.length > 0 &&
|
|
54
|
+
(!ii(a, this.Yh) || u !== this.di.ki()) &&
|
|
55
|
+
(t.sdk_metadata = this.Yh),
|
|
55
56
|
(t.sdk_version = this.Wo),
|
|
56
57
|
this.Vo && (t.sdk_flavor = this.Vo),
|
|
57
58
|
(t.app_version = this.appVersion),
|
|
58
|
-
(t.app_version_code = this.
|
|
59
|
+
(t.app_version_code = this.Xh),
|
|
59
60
|
(t.device_id = i.id),
|
|
60
61
|
e)
|
|
61
62
|
) {
|
|
62
63
|
const e = this.wt.getUserId();
|
|
63
64
|
null != e && (t.user_id = e);
|
|
64
65
|
}
|
|
66
|
+
if (!t.user_id && !this.Go.Fh()) {
|
|
67
|
+
const e = Ht(this.u);
|
|
68
|
+
e && (t.alias = e);
|
|
69
|
+
}
|
|
65
70
|
return t;
|
|
66
71
|
}
|
|
67
72
|
Ws(t, e, n) {
|
|
68
73
|
const o = e.auth_error,
|
|
69
|
-
|
|
70
|
-
if (!o && !
|
|
74
|
+
h = e.error;
|
|
75
|
+
if (!o && !h) return !0;
|
|
71
76
|
if (o) {
|
|
72
77
|
let e;
|
|
73
|
-
this.Go.
|
|
78
|
+
this.Go.Bh();
|
|
74
79
|
const s = { errorCode: o.error_code };
|
|
75
80
|
for (const t of n)
|
|
76
81
|
j(t) && "X-Braze-Auth-Signature" === t[0] && (s.signature = t[1]);
|
|
@@ -82,55 +87,55 @@ export default class Rt {
|
|
|
82
87
|
i
|
|
83
88
|
? ((s.reason = i), (e = `due to ${i}`))
|
|
84
89
|
: (e = `with error code ${o.error_code}.`),
|
|
85
|
-
this.Go.
|
|
90
|
+
this.Go.Fh() ||
|
|
86
91
|
(e +=
|
|
87
92
|
' Please use the "enableSdkAuthentication" initialization option to enable authentication.'),
|
|
88
93
|
r.error(`SDK Authentication failed ${e}`),
|
|
89
|
-
this.
|
|
90
|
-
this.Go.
|
|
94
|
+
this.Zh(t.events || [], t.attributes || []),
|
|
95
|
+
this.Go.qh(s),
|
|
91
96
|
!1
|
|
92
97
|
);
|
|
93
98
|
}
|
|
94
|
-
if (
|
|
99
|
+
if (h) {
|
|
95
100
|
let n,
|
|
96
|
-
o =
|
|
101
|
+
o = h;
|
|
97
102
|
switch (o) {
|
|
98
|
-
case qt.
|
|
103
|
+
case qt.Ra:
|
|
99
104
|
return (
|
|
100
105
|
(n = "Received successful response with empty body."),
|
|
101
106
|
s.q(i.Ms, { e: n }),
|
|
102
107
|
r.info(n),
|
|
103
108
|
!1
|
|
104
109
|
);
|
|
105
|
-
case qt.
|
|
110
|
+
case qt.Ba:
|
|
106
111
|
return (
|
|
107
112
|
(n = "Received successful response with invalid JSON"),
|
|
108
113
|
s.q(i.Ms, { e: n + ": " + e.response }),
|
|
109
114
|
r.info(n),
|
|
110
115
|
!1
|
|
111
116
|
);
|
|
112
|
-
case qt.
|
|
117
|
+
case qt.Xa:
|
|
113
118
|
o = `The API key "${t.api_key}" is invalid for the baseUrl ${this.Ko}`;
|
|
114
119
|
break;
|
|
115
|
-
case qt.
|
|
120
|
+
case qt.Na:
|
|
116
121
|
o =
|
|
117
122
|
"Sorry, we are not currently accepting your requests. If you think this is in error, please contact us.";
|
|
118
123
|
break;
|
|
119
|
-
case qt
|
|
124
|
+
case qt.$a:
|
|
120
125
|
o = "No device identifier. Please contact support@braze.com";
|
|
121
126
|
}
|
|
122
127
|
r.error("Backend error: " + o);
|
|
123
128
|
}
|
|
124
129
|
return !1;
|
|
125
130
|
}
|
|
126
|
-
|
|
131
|
+
Ea(t, e, s, i) {
|
|
127
132
|
return !!((t && 0 !== t.length) || (e && 0 !== e.length) || s || i);
|
|
128
133
|
}
|
|
129
|
-
|
|
134
|
+
Ka(t, e, s, i, r = !1) {
|
|
130
135
|
const n = [],
|
|
131
136
|
o = (t) => t || "",
|
|
132
|
-
|
|
133
|
-
let
|
|
137
|
+
h = o(this.wt.getUserId());
|
|
138
|
+
let a = this.Zi(t, e);
|
|
134
139
|
const u = [],
|
|
135
140
|
l = [];
|
|
136
141
|
let c,
|
|
@@ -138,36 +143,36 @@ export default class Rt {
|
|
|
138
143
|
if (s.length > 0) {
|
|
139
144
|
const t = [];
|
|
140
145
|
for (const e of s) {
|
|
141
|
-
if (((c = e.
|
|
142
|
-
if (
|
|
146
|
+
if (((c = e.Mr()), this.Go.Fh())) {
|
|
147
|
+
if (h && !c.user_id) {
|
|
143
148
|
d || (d = {}), d.events || (d.events = []), d.events.push(c);
|
|
144
149
|
continue;
|
|
145
150
|
}
|
|
146
|
-
if (o(c.user_id) !==
|
|
151
|
+
if (o(c.user_id) !== h) {
|
|
147
152
|
l.push(c);
|
|
148
153
|
continue;
|
|
149
154
|
}
|
|
150
155
|
}
|
|
151
156
|
t.push(c);
|
|
152
157
|
}
|
|
153
|
-
t.length > 0 && (
|
|
158
|
+
t.length > 0 && (a.events = t);
|
|
154
159
|
}
|
|
155
160
|
if (i.length > 0) {
|
|
156
161
|
const t = [];
|
|
157
162
|
for (const e of i)
|
|
158
|
-
e && (this.Go.
|
|
159
|
-
t.length > 0 && (
|
|
163
|
+
e && (this.Go.Fh() && o(e.user_id) !== h ? u.push(e) : t.push(e));
|
|
164
|
+
t.length > 0 && (a.attributes = t);
|
|
160
165
|
}
|
|
161
|
-
if ((this.
|
|
166
|
+
if ((this.Zh(l, u), (a = this.Ps(a, !0, r)), d)) {
|
|
162
167
|
d = this.Ps(d, !1, r);
|
|
163
|
-
const t = { requestData: d, headers: this._s(d, S.Gs.
|
|
168
|
+
const t = { requestData: d, headers: this._s(d, S.Gs.La) };
|
|
164
169
|
n.push(t);
|
|
165
170
|
}
|
|
166
|
-
if (
|
|
167
|
-
const f = { requestData:
|
|
171
|
+
if (a && !this.Ea(a.events, a.attributes, t, e)) return d ? n : null;
|
|
172
|
+
const f = { requestData: a, headers: this._s(a, S.Gs.La) };
|
|
168
173
|
return n.push(f), n;
|
|
169
174
|
}
|
|
170
|
-
|
|
175
|
+
Zh(t, e) {
|
|
171
176
|
if (t) {
|
|
172
177
|
const e = [];
|
|
173
178
|
for (const s of t) {
|
|
@@ -176,87 +181,87 @@ export default class Rt {
|
|
|
176
181
|
}
|
|
177
182
|
this.u.zo(e);
|
|
178
183
|
}
|
|
179
|
-
if (e) for (const t of e) this.u.
|
|
184
|
+
if (e) for (const t of e) this.u.Pa(t);
|
|
180
185
|
}
|
|
181
186
|
Zs(t, e) {
|
|
182
187
|
let s = "HTTP error ";
|
|
183
188
|
null != t && (s += t + " "), (s += e), r.error(s);
|
|
184
189
|
}
|
|
185
190
|
qr(t) {
|
|
186
|
-
return s.q(i.
|
|
191
|
+
return s.q(i.Ua, { n: t });
|
|
187
192
|
}
|
|
188
|
-
|
|
193
|
+
Zi(t, e, s) {
|
|
189
194
|
const i = {};
|
|
190
195
|
t && (i.feed = !0), e && (i.triggers = !0);
|
|
191
196
|
const r = null != s ? s : this.wt.getUserId();
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
(i.
|
|
195
|
-
|
|
196
|
-
);
|
|
197
|
+
if ((r && (i.user_id = r), !i.user_id && !this.Go.Fh())) {
|
|
198
|
+
const t = Ht(this.u);
|
|
199
|
+
t && (i.alias = t);
|
|
200
|
+
}
|
|
201
|
+
return (i.config = { config_time: this.yt.ni() }), { respond_with: i };
|
|
197
202
|
}
|
|
198
|
-
|
|
203
|
+
Ha(t) {
|
|
199
204
|
const e = new Date().valueOf();
|
|
200
205
|
let s = Kt.toString();
|
|
201
|
-
const i = S.
|
|
206
|
+
const i = S.Wa(this.u, t);
|
|
202
207
|
if (-1 !== i) {
|
|
203
208
|
s = (e - i).toString();
|
|
204
209
|
}
|
|
205
210
|
return s;
|
|
206
211
|
}
|
|
207
212
|
_s(t, e, s = !1) {
|
|
208
|
-
const i = [["X-Braze-Api-Key", this.
|
|
209
|
-
r = this.
|
|
213
|
+
const i = [["X-Braze-Api-Key", this.rn]],
|
|
214
|
+
r = this.Ha(e);
|
|
210
215
|
i.push(["X-Braze-Last-Req-Ms-Ago", r]);
|
|
211
|
-
const n = S.
|
|
216
|
+
const n = S.Ya(this.u, e).toString();
|
|
212
217
|
i.push(["X-Braze-Req-Attempt", n]);
|
|
213
|
-
let
|
|
218
|
+
let h = !1;
|
|
214
219
|
if (
|
|
215
220
|
(null != t.respond_with &&
|
|
216
221
|
t.respond_with.triggers &&
|
|
217
|
-
(i.push(["X-Braze-TriggersRequest", "true"]), (
|
|
222
|
+
(i.push(["X-Braze-TriggersRequest", "true"]), (h = !0)),
|
|
218
223
|
null != t.respond_with &&
|
|
219
224
|
t.respond_with.feed &&
|
|
220
|
-
(i.push(["X-Braze-FeedRequest", "true"]), (
|
|
225
|
+
(i.push(["X-Braze-FeedRequest", "true"]), (h = !0)),
|
|
221
226
|
e === S.Gs.Bs)
|
|
222
227
|
) {
|
|
223
228
|
i.push(["X-Braze-ContentCardsRequest", "true"]);
|
|
224
229
|
let t = this.u.j(o.C.As);
|
|
225
230
|
(t && s) || ((t = 0), this.u.k(o.C.As, t)),
|
|
226
231
|
i.push(["BRAZE-SYNC-RETRY-COUNT", t.toString()]),
|
|
227
|
-
(
|
|
232
|
+
(h = !0);
|
|
228
233
|
}
|
|
229
234
|
if (
|
|
230
235
|
(e === S.Gs.qi &&
|
|
231
|
-
(i.push(["X-Braze-FeatureFlagsRequest", "true"]), (
|
|
232
|
-
|
|
233
|
-
this.Go.
|
|
236
|
+
(i.push(["X-Braze-FeatureFlagsRequest", "true"]), (h = !0)),
|
|
237
|
+
h && i.push(["X-Braze-DataRequest", "true"]),
|
|
238
|
+
this.Go.Fh())
|
|
234
239
|
) {
|
|
235
|
-
const t = this.Go.
|
|
240
|
+
const t = this.Go.kh();
|
|
236
241
|
null != t && i.push(["X-Braze-Auth-Signature", t]);
|
|
237
242
|
}
|
|
238
243
|
return i;
|
|
239
244
|
}
|
|
240
|
-
|
|
245
|
+
Qa(t, e, s, i) {
|
|
241
246
|
window.setTimeout(() => {
|
|
242
|
-
r.info(`Retrying rate limited ${this.
|
|
247
|
+
r.info(`Retrying rate limited ${this.Hh(i)}SDK request.`),
|
|
243
248
|
this.Hs(e, s, i);
|
|
244
249
|
}, t);
|
|
245
250
|
}
|
|
246
251
|
Hs(t, e, s) {
|
|
247
|
-
const i = this.
|
|
248
|
-
if (!i.
|
|
252
|
+
const i = this.Va();
|
|
253
|
+
if (!i.Za)
|
|
249
254
|
return (
|
|
250
255
|
r.info(
|
|
251
|
-
`${this.
|
|
256
|
+
`${this.Hh(
|
|
252
257
|
s,
|
|
253
258
|
)}SDK request being rate limited. Request will be retried in ${Math.trunc(
|
|
254
|
-
i.
|
|
259
|
+
i.au / 1e3,
|
|
255
260
|
)} seconds.`,
|
|
256
261
|
),
|
|
257
|
-
void this.
|
|
262
|
+
void this.Qa(i.au, t, e, s)
|
|
258
263
|
);
|
|
259
|
-
this.u.k(o.C.
|
|
264
|
+
this.u.k(o.C.du, new Date().valueOf());
|
|
260
265
|
const n = t.device;
|
|
261
266
|
n && n.os_version instanceof Promise
|
|
262
267
|
? n.os_version.then((s) => {
|
|
@@ -266,33 +271,33 @@ export default class Rt {
|
|
|
266
271
|
}
|
|
267
272
|
li(t) {
|
|
268
273
|
var e;
|
|
269
|
-
null === (e = this.u) || void 0 === e || e.k(o.C.
|
|
274
|
+
null === (e = this.u) || void 0 === e || e.k(o.C.fu, t);
|
|
270
275
|
}
|
|
271
276
|
ui() {
|
|
272
277
|
var t;
|
|
273
|
-
return null === (t = this.u) || void 0 === t ? void 0 : t.j(o.C.
|
|
278
|
+
return null === (t = this.u) || void 0 === t ? void 0 : t.j(o.C.fu);
|
|
274
279
|
}
|
|
275
|
-
|
|
280
|
+
Ru(t, e, s, i) {
|
|
276
281
|
let r = this.ui();
|
|
277
282
|
(null == r || isNaN(r)) && (r = e);
|
|
278
283
|
const n = (t - i) / 1e3;
|
|
279
284
|
return (r = Math.min(r + n / s, e)), r;
|
|
280
285
|
}
|
|
281
|
-
|
|
286
|
+
vu(t, e) {
|
|
282
287
|
return Math.max(0, (1 - t) * e * 1e3);
|
|
283
288
|
}
|
|
284
|
-
|
|
289
|
+
Va() {
|
|
285
290
|
var t, e, s;
|
|
286
|
-
const i = {
|
|
287
|
-
r = null === (t = this.u) || void 0 === t ? void 0 : t.j(o.C.
|
|
291
|
+
const i = { Za: !0, au: 0 },
|
|
292
|
+
r = null === (t = this.u) || void 0 === t ? void 0 : t.j(o.C.du);
|
|
288
293
|
if (null == r || isNaN(r)) return i;
|
|
289
294
|
const n = (null === (e = this.yt) || void 0 === e ? void 0 : e.pu()) || -1,
|
|
290
|
-
|
|
291
|
-
if (-1 === n || -1 ===
|
|
292
|
-
const
|
|
293
|
-
let u = this.
|
|
295
|
+
h = (null === (s = this.yt) || void 0 === s ? void 0 : s.gu()) || -1;
|
|
296
|
+
if (-1 === n || -1 === h) return i;
|
|
297
|
+
const a = new Date().valueOf();
|
|
298
|
+
let u = this.Ru(a, n, h, r);
|
|
294
299
|
return u < 1
|
|
295
|
-
? ((i.
|
|
300
|
+
? ((i.Za = !1), (i.au = this.vu(u, h)), i)
|
|
296
301
|
: ((u = Math.trunc(u) - 1), this.li(u), i);
|
|
297
302
|
}
|
|
298
303
|
Xs() {
|
|
@@ -302,6 +307,6 @@ export default class Rt {
|
|
|
302
307
|
return this.Ko;
|
|
303
308
|
}
|
|
304
309
|
addSdkMetadata(t) {
|
|
305
|
-
for (const e of t) -1 === this.
|
|
310
|
+
for (const e of t) -1 === this.Yh.indexOf(e) && this.Yh.push(e);
|
|
306
311
|
}
|
|
307
312
|
}
|
|
@@ -4,8 +4,8 @@ import Gt from "../models/server-config.js";
|
|
|
4
4
|
import s from "../common/event-logger.js";
|
|
5
5
|
import { EventTypes as i } from "../../shared-lib/index.js";
|
|
6
6
|
import {
|
|
7
|
-
CONTENT_CARDS_RATE_LIMIT_CAPACITY_DEFAULT as
|
|
8
|
-
CONTENT_CARDS_RATE_LIMIT_REFILL_RATE_DEFAULT as
|
|
7
|
+
CONTENT_CARDS_RATE_LIMIT_CAPACITY_DEFAULT as Jt,
|
|
8
|
+
CONTENT_CARDS_RATE_LIMIT_REFILL_RATE_DEFAULT as Qt,
|
|
9
9
|
} from "../common/constants.js";
|
|
10
10
|
export default class Dt {
|
|
11
11
|
constructor(t) {
|
|
@@ -20,7 +20,7 @@ export default class Dt {
|
|
|
20
20
|
ll() {
|
|
21
21
|
if (null == this.rl) {
|
|
22
22
|
const t = this.u.j(o.C.hl);
|
|
23
|
-
this.rl = null != t ? Gt.
|
|
23
|
+
this.rl = null != t ? Gt.qn(t) : new Gt();
|
|
24
24
|
}
|
|
25
25
|
return this.rl;
|
|
26
26
|
}
|
|
@@ -44,7 +44,7 @@ export default class Dt {
|
|
|
44
44
|
t(e.global_request_rate_limit),
|
|
45
45
|
);
|
|
46
46
|
let s = !1;
|
|
47
|
-
null != i.cl && this.
|
|
47
|
+
null != i.cl && this.Wn() !== i.cl && (s = !0);
|
|
48
48
|
let r = !1;
|
|
49
49
|
null != i.ml.enabled && this.ri() !== i.ml.enabled && (r = !0);
|
|
50
50
|
let n = !1;
|
|
@@ -57,7 +57,7 @@ export default class Dt {
|
|
|
57
57
|
}
|
|
58
58
|
}
|
|
59
59
|
}
|
|
60
|
-
|
|
60
|
+
_n(t) {
|
|
61
61
|
const e = this.tl.It(t);
|
|
62
62
|
return this.sl && this.tl.removeSubscription(this.sl), (this.sl = e), e;
|
|
63
63
|
}
|
|
@@ -79,7 +79,7 @@ export default class Dt {
|
|
|
79
79
|
dl() {
|
|
80
80
|
return this.ll().Cl;
|
|
81
81
|
}
|
|
82
|
-
|
|
82
|
+
Wn() {
|
|
83
83
|
return this.ll().cl;
|
|
84
84
|
}
|
|
85
85
|
ri() {
|
|
@@ -92,12 +92,12 @@ export default class Dt {
|
|
|
92
92
|
ci() {
|
|
93
93
|
if (!this.Is()) return -1;
|
|
94
94
|
const t = this.ll().ml.rate_limit;
|
|
95
|
-
return null == t.capacity ?
|
|
95
|
+
return null == t.capacity ? Jt : t.capacity <= 0 ? -1 : t.capacity;
|
|
96
96
|
}
|
|
97
97
|
fi() {
|
|
98
98
|
if (!this.Is()) return -1;
|
|
99
99
|
const t = this.ll().ml.rate_limit;
|
|
100
|
-
return null == t.refill_rate ?
|
|
100
|
+
return null == t.refill_rate ? Qt : t.refill_rate <= 0 ? -1 : t.refill_rate;
|
|
101
101
|
}
|
|
102
102
|
Rl() {
|
|
103
103
|
const t = this.ll().al;
|
|
@@ -108,7 +108,7 @@ export default class Dt {
|
|
|
108
108
|
const t = this.ll().al;
|
|
109
109
|
return null == t.capacity || t.capacity < 10 ? -1 : t.capacity;
|
|
110
110
|
}
|
|
111
|
-
|
|
111
|
+
gu() {
|
|
112
112
|
if (!this.Rl()) return -1;
|
|
113
113
|
const t = this.ll().al;
|
|
114
114
|
return null == t.refill_rate || t.refill_rate <= 0 ? -1 : t.refill_rate;
|