@seayoo-web/request 2.1.1 → 3.0.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.
@@ -1,572 +0,0 @@
1
- var q = Object.defineProperty;
2
- var K = (e, t, s) => t in e ? q(e, t, { enumerable: !0, configurable: !0, writable: !0, value: s }) : e[t] = s;
3
- var y = (e, t, s) => K(e, typeof t != "symbol" ? t + "" : t, s);
4
- const h = typeof globalThis < "u" ? globalThis : typeof global < "u" ? global : typeof self < "u" ? self : typeof window < "u" ? window : {}, E = {
5
- wx: "wx" in h && U(h.wx),
6
- fetch: "fetch" in h && w(h.fetch),
7
- window: "window" in h && U(h.window),
8
- Blob: "Blob" in h && w(h.Blob),
9
- FormData: "FormData" in h && w(h.FormData),
10
- TextDecoder: "TextDecoder" in h && w(h.TextDecoder),
11
- AbortController: "AbortController" in h && w(h.AbortController)
12
- };
13
- function w(e) {
14
- return typeof e == "function";
15
- }
16
- function U(e) {
17
- return typeof e == "object" && e !== null;
18
- }
19
- function I(e) {
20
- return new Promise((t) => setTimeout(t, Math.max(0, e)));
21
- }
22
- function G() {
23
- }
24
- function J(e) {
25
- const t = e || "CustomError";
26
- return class extends Error {
27
- constructor(s) {
28
- super(s), Object.defineProperty(this, "name", {
29
- value: t,
30
- enumerable: !1,
31
- configurable: !0
32
- }), "setPrototypeOf" in Object && Object.setPrototypeOf(this, new.target.prototype), "captureStackTrace" in Error && typeof Error.captureStackTrace == "function" && Error.captureStackTrace(this, this.constructor);
33
- }
34
- };
35
- }
36
- const W = /^(?:https?:)?\/\/.+$/i, V = /^https?:\/\/.+$/i, Z = /^\{[\d\D]*\}$/, Q = /^\[[\d\D]*\]$/;
37
- function A(e, t = !1) {
38
- return t ? W.test(e) : V.test(e);
39
- }
40
- function z(e) {
41
- return e == null;
42
- }
43
- function O(e, ...t) {
44
- if (!e || typeof e != "object") return !1;
45
- const s = Object.getPrototypeOf(e);
46
- return s !== Object.prototype && s !== null ? !1 : t.every((r) => r in e);
47
- }
48
- function S(e) {
49
- return Z.test(e) || Q.test(e);
50
- }
51
- function $(e) {
52
- return e ? e[0].toLowerCase() + e.slice(1) : "";
53
- }
54
- const _ = /_\w*/, B = /-\w*/;
55
- function D(e) {
56
- const t = _.test(e) ? e.replace(/(?:^_*|_*$)/g, "").replace(/_+([^_])/g, (s, r) => r.toUpperCase()) : B.test(e) ? e.replace(/(?:^-*|-*$)/g, "").replace(/-+(\w)/g, (s, r) => r.toUpperCase()) : e;
57
- return $(t);
58
- }
59
- function M(e) {
60
- return _.test(e) ? $(e).replace(/(?:^_*|_*$)/g, "").replace(/_+([^_])/g, (t, s) => "_" + s.toLowerCase()) : B.test(e) ? $(e.replace(/(?:^-*|-*$)/g, "")).replace(/-+(\w)/g, (t, s) => "_" + s.toLowerCase()) : $(e).replace(/[A-Z]/g, (t) => `_${t.toLowerCase()}`);
61
- }
62
- function T(e, t) {
63
- try {
64
- const s = JSON.parse(e);
65
- return t ? t(s) ? s : null : s;
66
- } catch {
67
- return null;
68
- }
69
- }
70
- "" + Math.random().toString(32).slice(2);
71
- function R(e, t = !1) {
72
- return typeof e == "string" ? D(e) : Array.isArray(e) ? e.map((s) => !t || typeof s == "string" ? R(s) : typeof s == "object" && s ? R(s, !0) : s) : O(e) ? Object.keys(e).reduce(
73
- (s, r) => {
74
- const a = D(String(r)), n = a.charAt(0).toLowerCase() + a.slice(1);
75
- return s[n] = t ? e[r] : R(e[r]), s;
76
- },
77
- {}
78
- ) : e;
79
- }
80
- function k(e, t = !1) {
81
- return typeof e == "string" ? M(e) : Array.isArray(e) ? e.map((s) => !t || typeof s == "string" ? k(s) : typeof s == "object" && s ? k(s, t) : s) : O(e) ? Object.keys(e).reduce(
82
- (s, r) => {
83
- const a = M(String(r));
84
- return s[a] = t ? e[r] : k(e[r]), s;
85
- },
86
- {}
87
- ) : e;
88
- }
89
- async function $e(e) {
90
- return await new Promise(function(t) {
91
- const s = document.getElementsByTagName("head")[0], r = document.createElement("script");
92
- r.setAttribute("type", "text/javascript"), r.setAttribute("charset", "utf-8"), r.onload = function() {
93
- s.removeChild(r), t(!0);
94
- }, r.onerror = function() {
95
- s.removeChild(r), t(!1);
96
- }, r.setAttribute("src", e), s.appendChild(r);
97
- });
98
- }
99
- function Y(e, t = "数据未能正确识别") {
100
- return typeof e == "function" ? {
101
- guard: e,
102
- message: t
103
- } : {
104
- guard: e.guard,
105
- message: e.message || t
106
- };
107
- }
108
- function X(e, t = "") {
109
- return !t || A(e, !0) ? L(e) : (L(t) + "/" + e).replace(/\/{2,}/g, "/").replace(/:\//, "://");
110
- }
111
- function L(e) {
112
- return A(e, !0) ? e.startsWith("http") ? e : ("location" in globalThis ? location.protocol : "https:") + e : ("location" in globalThis ? location.origin : "http://127.0.0.1") + "/" + e.replace(/^\/+/, "");
113
- }
114
- function ee(e, t) {
115
- const s = {};
116
- return (e.match(/([^=&#?]+)=[^&#]*/g) || []).forEach(function(r) {
117
- const a = r.split("="), n = a[0], o = decodeURIComponent(a[1] || "");
118
- s[n] !== void 0 ? s[n] += "," + o : s[n] = o;
119
- }), t !== !0 ? s[t] || "" : s;
120
- }
121
- function te(e, t) {
122
- if (t) {
123
- if (t === !0)
124
- return e.replace(/\?[^#]*/, "");
125
- } else return e;
126
- const s = e.split("#"), r = s[0].split("?"), a = r[0], n = r.length > 1 ? r[1] : "", o = s.length > 1 ? "#" + s[1] : "", c = typeof t == "string" ? [t] : Array.isArray(t) ? t : [];
127
- return !c.length || !n ? s[0] + o : (c.map((i) => i.replace(/([\\(){}[\]^$+\-*?|])/g, "\\$1")), (a + "?" + n.replace(new RegExp("(?:^|&)(?:" + c.join("|") + ")=[^&$]+", "g"), "").replace(/^&/, "")).replace(/\?$/, "") + o);
128
- }
129
- function Re(e, t, s = !1) {
130
- const r = typeof t == "string" ? t : Object.keys(t).map((o) => `${o}=${encodeURIComponent(t[o])}`).join("&");
131
- if (!r)
132
- return e;
133
- const a = e.split("#");
134
- s && (a[0] = te(
135
- a[0],
136
- (r.match(/([^=&#?]+)=[^&#]+/g) || []).map((o) => o.replace(/=.+$/, ""))
137
- ));
138
- const n = a[0].indexOf("?") + 1 ? "&" : "?";
139
- return (a[0] + n + r + (a.length > 1 ? "#" + a[1] : "")).replace(/\?&/, "?");
140
- }
141
- function se(e) {
142
- const t = e.match(/(?:\?|&)([^=]+)(?:&|$)/g);
143
- return t ? t.join("").replace(/(?:\?|^&+|&+$)/g, "").replace(/&{2}/g, "&").split("&").sort() : [];
144
- }
145
- class re {
146
- constructor(t = 500) {
147
- y(this, "ttl");
148
- y(this, "cache");
149
- this.cache = {}, this.ttl = Math.max(t, 0);
150
- }
151
- getKey(t, s) {
152
- const r = t.replace(/#.+/, ""), a = r.replace(/\?.+/g, ""), n = Object.assign(ee(r, !0), s), o = se(r), c = Object.keys(n).sort().map((i) => `${i}#${n[i]}`);
153
- return `${a}_${c.join(",")}_${o.join(",")}`;
154
- }
155
- updateTTL(t) {
156
- this.ttl = Math.max(t, 0);
157
- }
158
- get(t) {
159
- if (this.ttl === 0)
160
- return null;
161
- const s = this.cache[t];
162
- return s ? s.ttl < Date.now() ? (delete this.cache[t], null) : s.res : null;
163
- }
164
- set(t, s) {
165
- this.ttl !== 0 && (this.cache[t] = {
166
- ttl: Date.now() + this.ttl,
167
- res: s
168
- });
169
- }
170
- }
171
- class ne {
172
- constructor(t) {
173
- // 保存的配置需要部分字段强制设置默认值
174
- y(this, "config", {
175
- baseURL: "",
176
- maxRetry: 0,
177
- retryInterval: 1e3,
178
- retryResolve: "network",
179
- timeout: 1e4,
180
- cacheTTL: 500,
181
- credentials: "same-origin",
182
- defaultTypeGuardMessage: "响应数据未能正确识别",
183
- responseRule: {
184
- ok: {
185
- resolve: "body"
186
- },
187
- failed: {
188
- resolve: "json",
189
- messageField: "message"
190
- }
191
- }
192
- });
193
- t && this.set(t);
194
- }
195
- set(t) {
196
- if (t.baseURL && !/^\/.+/.test(t.baseURL) && !A(t.baseURL))
197
- throw console.warn("baseURL 需要以 / 开头,或者是完整的 url 地址"), new Error("BaseURLError");
198
- Object.assign(this.config, t);
199
- }
200
- get(t) {
201
- return this.config[t];
202
- }
203
- /** 基于 baseURL 返回完整的 url 地址 */
204
- getFullUrl(t) {
205
- return X(t, this.config.baseURL);
206
- }
207
- /** 提示消息 */
208
- showMessage(t, s, r, a) {
209
- this.config.messageHandler && s && this.config.messageHandler(t, s, r, a);
210
- }
211
- }
212
- var H = /* @__PURE__ */ ((e) => (e.UnexpectResponse = "UnexpectResponse", e.Aborted = "Aborted", e.Unknown = "Unknown", e.NetworkError = "NetworkError", e.Timeout = "Timeout", e.NotSupport = "NotSupport", e.URLFormatError = "URLFormatError", e))(H || {});
213
- function ae(e, t, s, r) {
214
- if (t.ok && !z(t.data) && r) {
215
- const a = Y(r, s.get("defaultTypeGuardMessage"));
216
- return a.guard(t.data) || (t.code = H.UnexpectResponse, s.showMessage(!0, `${e} ${a.message}`, t.code, t.status), console.error(t.code, e, t.data), t.data = null, t.message = a.message), t;
217
- }
218
- return t;
219
- }
220
- class ke {
221
- constructor(t, s) {
222
- y(this, "agent");
223
- y(this, "config");
224
- y(this, "cache");
225
- this.config = new ne(s), this.agent = t, this.cache = new re(this.config.get("cacheTTL")), this.setConfig = this.setConfig.bind(this), this.getConfig = this.getConfig.bind(this), this.request = this.request.bind(this), this.get = this.get.bind(this), this.post = this.post.bind(this), this.del = this.del.bind(this), this.patch = this.patch.bind(this), this.put = this.put.bind(this), this.head = this.head.bind(this);
226
- }
227
- /**
228
- * 执行网络请求
229
- */
230
- async request(t, s) {
231
- try {
232
- return await this.agent(t, this.config, s);
233
- } catch (r) {
234
- return console.error("RequestError", r), {
235
- ok: !1,
236
- status: -9,
237
- code: "Unkonwn",
238
- message: String(r),
239
- headers: {},
240
- data: null
241
- };
242
- }
243
- }
244
- /**
245
- * 检查响应的数据类型
246
- */
247
- async guard(t, s, r) {
248
- return ae(t, s, this.config, r);
249
- }
250
- /**
251
- * 修改默认请求配置: baesURL / timeout / credentials / errorHandler / messageHandler / responseHandler / logHandler / responseRule
252
- */
253
- setConfig(t) {
254
- this.config.set(t), this.cache.updateTTL(this.config.get("cacheTTL"));
255
- }
256
- /**
257
- * 读取默认的请求配置
258
- */
259
- getConfig(t) {
260
- return this.config.get(t);
261
- }
262
- /**
263
- * 发送一个 HEAD 请求,并且不处理响应 body
264
- */
265
- async head(t, s) {
266
- const r = Object.assign({}, s || null);
267
- return r.method = "HEAD", this.guard(t, await this.request(t, r), null);
268
- }
269
- async get(t, s, r) {
270
- const a = Object.assign({}, r || null);
271
- a.method = "GET";
272
- const n = this.cache.getKey(t, a.params), o = this.cache.get(n);
273
- if (o)
274
- return this.guard(t, await o, s || null);
275
- const c = this.request(t, a);
276
- return this.cache.set(n, c), this.guard(t, await c, s || null);
277
- }
278
- async post(t, s, r, a) {
279
- const n = Object.assign({}, a || null);
280
- return n.method = "POST", n.body = s || {}, this.guard(t, await this.request(t, n), r || null);
281
- }
282
- async del(t, s, r) {
283
- const a = Object.assign({}, r || null);
284
- return a.method = "DELETE", this.guard(t, await this.request(t, a), s || null);
285
- }
286
- async put(t, s, r, a) {
287
- const n = Object.assign({}, a || null);
288
- return n.method = "PUT", n.body = s || {}, this.guard(t, await this.request(t, n), r || null);
289
- }
290
- async patch(t, s, r, a) {
291
- const n = Object.assign({}, a || null);
292
- return n.method = "PATCH", n.body = s || {}, this.guard(t, await this.request(t, n), r || null);
293
- }
294
- }
295
- async function Ee(e, t, s) {
296
- var m;
297
- const r = Object.assign({ method: "GET" }, s), a = E.FormData ? r.body instanceof FormData : !1, n = a && r.method !== "POST" && r.method !== "PUT" ? "POST" : r.method, o = n === "GET" || n === "HEAD" || n === "DELETE";
298
- o && r.body !== void 0 && (console.warn("request body is invalid with method get, head, delete"), delete r.body);
299
- const c = Object.assign(
300
- a || o ? {} : {
301
- "Content-Type": E.Blob && r.body instanceof Blob ? r.body.type || "application/octet-stream" : "application/json;charset=utf-8"
302
- },
303
- r.headers
304
- ), i = r.params || {}, d = {};
305
- Object.keys(i).forEach((b) => {
306
- i[b] !== void 0 && (d[b] = oe(i[b]));
307
- });
308
- const u = t.getFullUrl(e), l = ce(r.body), f = r.timeout || t.get("timeout"), g = await async function() {
309
- const b = t.get("requestTransformer");
310
- if (b)
311
- return await b({ headers: c, params: d, method: n, url: u, body: l });
312
- }(), p = typeof g == "string" && g ? g : u;
313
- return (m = t.get("logHandler")) == null || m({ type: "ready", url: p, method: n, headers: c, timeout: f, body: l }), {
314
- url: p,
315
- method: n,
316
- body: l,
317
- params: d,
318
- headers: c,
319
- timeout: f,
320
- abort: r.abort,
321
- credentials: r.credentials || t.get("credentials") || "same-origin"
322
- };
323
- }
324
- function oe(e) {
325
- return typeof e == "string" ? e : Array.isArray(e) ? e.join(",") : e + "";
326
- }
327
- function ce(e) {
328
- if (e)
329
- return typeof e == "string" || e instanceof URLSearchParams || e instanceof ArrayBuffer || E.Blob && e instanceof Blob || E.FormData && e instanceof FormData ? e : JSON.stringify(e);
330
- }
331
- const N = "data", j = "message";
332
- function ie(e, t, s, r, a) {
333
- const n = a || r;
334
- return C(e) ? ge(n.ok || r.ok, e, t, s) : ue(n.failed || r.failed, t, s);
335
- }
336
- const Oe = function(e) {
337
- const t = [], s = e.failed || { resolve: "json" };
338
- switch (t.push("- 当http状态码 <200 或者 >=400 时"), s.resolve) {
339
- case "body":
340
- t.push(" 将响应内容格式化为字符串并作为错误消息");
341
- break;
342
- case "json":
343
- t.push(" 将响应解析为json,并读取 " + (s.messageField || j) + " 作为错误消息");
344
- break;
345
- }
346
- const r = e.ok || { resolve: "body" };
347
- switch (t.push("- 当http状态码 >=200 并且 <400 时"), r.resolve) {
348
- case "body":
349
- t.push(" 将响应尝试解析为 json,并作为数据内容返回");
350
- break;
351
- case "json":
352
- t.push(
353
- " 将响应解析为 json,读取 " + (r.dataField || N) + " 作为响应数据,读取 " + (r.messageField || j) + " 作为提示消息"
354
- ), r.statusField && t.push(
355
- " 当 " + r.statusField + " 为 " + (r.statusOKValue || "空值") + " 时是成功提示,否则是错误消息"
356
- ), r.ignoreMessage && t.push(" 并忽略以下消息:" + r.ignoreMessage);
357
- break;
358
- }
359
- return t.join(`
360
- `);
361
- };
362
- function ue(e, t, s) {
363
- const r = e || { resolve: "json", messageField: j }, a = {
364
- ok: !1,
365
- code: t,
366
- message: s,
367
- data: null
368
- };
369
- switch (r.resolve) {
370
- case "body":
371
- a.message = x(s) || s;
372
- break;
373
- case "json":
374
- const { code: n, message: o } = le(s, r.converter, r.statusField, r.messageField);
375
- a.code = n || t, a.message = x(s) || o;
376
- break;
377
- }
378
- return a;
379
- }
380
- function le(e, t, s, r = j) {
381
- if (!S(e))
382
- return { message: "" };
383
- const a = F(T(e), t);
384
- return !a || !O(a) ? { message: e } : {
385
- code: s ? v(a, s) : "",
386
- message: v(a, r) || e
387
- };
388
- }
389
- function v(e, t) {
390
- const s = Array.isArray(t) ? t : [t];
391
- for (const r of s)
392
- if (r in e)
393
- return he(e[r]);
394
- return "";
395
- }
396
- function he(e) {
397
- return e ? typeof e == "string" ? e : JSON.stringify(e) : "";
398
- }
399
- const de = /<title>([^<]+)<\/title>/i, fe = /<message>([^<]+)<\/message>/i;
400
- function x(e) {
401
- const t = e.match(de);
402
- if (t)
403
- return t[1];
404
- const s = e.match(fe);
405
- return s ? s[1] : "";
406
- }
407
- function ge(e, t, s, r) {
408
- const a = e || { resolve: "body" }, n = {
409
- ok: !0,
410
- code: s,
411
- message: "",
412
- data: null
413
- };
414
- if (t === 204 || !r)
415
- return n;
416
- if (a.resolve === "body")
417
- return n.data = S(r) ? F(T(r), e.converter) : r, n;
418
- const o = F(T(r), e.converter);
419
- if (!o || !O(o))
420
- return n.ok = !1, n.code = "ResponseFormatError", n.message = "响应内容无法格式化为 Object", n;
421
- const c = a.statusField, i = a.statusOKValue || "", d = a.dataField || N, u = a.messageField || j, l = a.ignoreMessage || "";
422
- if (c && !(c in o))
423
- return n.ok = !1, n.code = "ResponseFieldMissing", n.message = "响应内容找不到状态字段 " + c, n;
424
- const f = c ? o[c] + "" : "";
425
- return n.ok = c ? f === i : !0, n.code = f || s, n.data = d === !0 ? o : d in o ? o[d] : null, n.message = v(o, u), l && n.message && (Array.isArray(l) && l.includes(n.message) || typeof l == "string" && n.message === l) && (n.message = ""), n;
426
- }
427
- function C(e) {
428
- return e >= 200 && e < 400;
429
- }
430
- function F(e, t) {
431
- return t === "camelize" ? R(e) : t === "snakify" ? k(e) : e;
432
- }
433
- const me = J("APIError");
434
- function pe(e) {
435
- const t = {};
436
- for (const a in e.headers)
437
- (a.startsWith("x-") || a.includes("trace") || a.includes("server") || /\b(?:id|uuid)\b/.test(a)) && (t[a] = e.headers[a]);
438
- const s = e.url.replace(/^(?:https?:)?\/*/i, "").replace(/\?.+/, ""), r = e.status < 0 ? "unknown" : e.status;
439
- return {
440
- sentryError: new me(`${s} | ${r}${e.code ? ` | ${e.code}` : ""}`),
441
- sentryTags: {
442
- ...t,
443
- status: r,
444
- method: e.method,
445
- code: e.code || "unknown",
446
- message: e.message || "empty"
447
- },
448
- sentryExtra: {
449
- url: e.url,
450
- responseBody: e.body || "empty",
451
- responseHeaders: e.headers,
452
- rawError: e.error
453
- }
454
- };
455
- }
456
- function ye(e) {
457
- return e.reduce(
458
- (t, [s, r]) => (s && (t[s] = r || ""), t),
459
- {}
460
- );
461
- }
462
- function Te(e, t, s, r) {
463
- var g;
464
- const a = e.status, n = e.method, o = ye(
465
- Object.entries(e.headers || {}).map(([p, m]) => [p.toLowerCase(), m])
466
- ), { ok: c, code: i, data: d, message: u } = ie(
467
- a,
468
- e.statusText,
469
- e.body,
470
- s.get("responseRule"),
471
- r == null ? void 0 : r.responseRule
472
- );
473
- if (!C(a)) {
474
- const p = pe({
475
- url: e.url,
476
- method: e.method,
477
- status: a,
478
- code: i,
479
- message: u,
480
- body: e.body,
481
- headers: o,
482
- error: e.rawError
483
- });
484
- (s.get("errorHandler") || be)({
485
- url: t,
486
- method: n,
487
- status: a,
488
- code: i,
489
- message: u,
490
- headers: o,
491
- rawError: e.rawError,
492
- responseBody: e.body,
493
- ...p
494
- });
495
- }
496
- if (a < 0)
497
- return P(
498
- { ok: !1, status: a, code: e.statusText, headers: {}, message: "", data: null },
499
- `${n} ${t} ${e.statusText}`,
500
- n,
501
- t,
502
- s,
503
- r
504
- );
505
- const l = { ok: c, data: d, code: i, message: u, status: a, headers: o };
506
- (g = s.get("responseHandler")) == null || g({ ...l }, n, t);
507
- const f = c ? u : u || e.statusText;
508
- return P(l, f, n, t, s, r);
509
- }
510
- function P(e, t, s, r, a, n) {
511
- const o = a.get("message"), c = o === !1 || (n == null ? void 0 : n.message) === !1 ? !1 : (n == null ? void 0 : n.message) || o;
512
- if (c !== !1) {
513
- const i = typeof c == "function" ? c(e, s, r, t) : t;
514
- i instanceof Error ? a.showMessage(!0, i.message, e.code, e.status) : i && typeof i == "object" && "message" in i ? a.showMessage(!1, i.message, e.code, e.status) : a.showMessage(!e.ok, i, e.code, e.status);
515
- }
516
- return e;
517
- }
518
- function be(e) {
519
- const t = {};
520
- for (const s in e)
521
- s.startsWith("sentry") || (t[s] = e[s]);
522
- console.error("RequestError", t);
523
- }
524
- async function we(e, t, s, r, a) {
525
- const n = a || 0, o = Math.max(0, Math.min(10, (r == null ? void 0 : r.maxRetry) ?? s.get("maxRetry") ?? 0)), c = (r == null ? void 0 : r.retryResolve) ?? s.get("retryResolve"), i = s.get("logHandler") || G;
526
- i({
527
- type: "prepear",
528
- url: t,
529
- method: (r == null ? void 0 : r.method) || "GET",
530
- retry: n,
531
- maxRetry: o,
532
- message: n === 0 ? "start" : `retry ${n}/${o} start`,
533
- headers: r == null ? void 0 : r.headers,
534
- options: r
535
- });
536
- const d = Date.now(), u = await e(t, s, r), l = u.status, f = Date.now() - d, g = `[cost ${f}][${l}] ${l < 0 ? u.body : ""}`;
537
- i({
538
- type: "finished",
539
- url: t,
540
- method: u.method,
541
- retry: n,
542
- maxRetry: o,
543
- message: n === 0 ? `finish ${g}` : `retry ${n}/${o} finish ${g}`,
544
- response: u,
545
- headers: u.headers,
546
- cost: f
547
- });
548
- const p = C(l);
549
- if (!o || c === "network" && l > 0 || c === "status" && p || Array.isArray(c) && !c.includes(l) || typeof c == "function" && c(u, n) !== !0 || n >= o)
550
- return u;
551
- const m = (r == null ? void 0 : r.retryInterval) ?? s.get("retryInterval") ?? 1e3;
552
- return await I(
553
- Math.max(
554
- 100,
555
- m === "2EB" ? Math.pow(2, n) * 1e3 : typeof m == "function" ? m(n + 1) || 0 : m
556
- )
557
- ), await we(e, t, s, r, n + 1);
558
- }
559
- export {
560
- $e as I,
561
- ke as N,
562
- ne as R,
563
- Re as Z,
564
- H as a,
565
- Ee as c,
566
- ye as f,
567
- Oe as g,
568
- Te as h,
569
- E as l,
570
- we as r,
571
- A as t
572
- };