@seayoo-web/request 2.1.0 → 2.1.2

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,7 +1,7 @@
1
- var N = Object.defineProperty;
2
- var K = (e, t, s) => t in e ? N(e, t, { enumerable: !0, configurable: !0, writable: !0, value: s }) : e[t] = s;
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
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 : {}, k = {
4
+ const h = typeof globalThis < "u" ? globalThis : typeof global < "u" ? global : typeof self < "u" ? self : typeof window < "u" ? window : {}, E = {
5
5
  wx: "wx" in h && U(h.wx),
6
6
  fetch: "fetch" in h && w(h.fetch),
7
7
  window: "window" in h && U(h.window),
@@ -16,10 +16,10 @@ function w(e) {
16
16
  function U(e) {
17
17
  return typeof e == "object" && e !== null;
18
18
  }
19
- function G(e) {
19
+ function I(e) {
20
20
  return new Promise((t) => setTimeout(t, Math.max(0, e)));
21
21
  }
22
- function I() {
22
+ function G() {
23
23
  }
24
24
  function J(e) {
25
25
  const t = e || "CustomError";
@@ -33,20 +33,20 @@ function J(e) {
33
33
  }
34
34
  };
35
35
  }
36
- const V = /^(?:https?:)?\/\/.+$/i, W = /^https?:\/\/.+$/i, z = /^\{[\d\D]*\}$/, Y = /^\[[\d\D]*\]$/;
36
+ const W = /^(?:https?:)?\/\/.+$/i, V = /^https?:\/\/.+$/i, Z = /^\{[\d\D]*\}$/, Q = /^\[[\d\D]*\]$/;
37
37
  function A(e, t = !1) {
38
- return t ? V.test(e) : W.test(e);
38
+ return t ? W.test(e) : V.test(e);
39
39
  }
40
- function Z(e) {
40
+ function z(e) {
41
41
  return e == null;
42
42
  }
43
- function E(e, ...t) {
43
+ function O(e, ...t) {
44
44
  if (!e || typeof e != "object") return !1;
45
45
  const s = Object.getPrototypeOf(e);
46
46
  return s !== Object.prototype && s !== null ? !1 : t.every((r) => r in e);
47
47
  }
48
48
  function S(e) {
49
- return z.test(e) || Y.test(e);
49
+ return Z.test(e) || Q.test(e);
50
50
  }
51
51
  function $(e) {
52
52
  return e ? e[0].toLowerCase() + e.slice(1) : "";
@@ -59,7 +59,7 @@ function D(e) {
59
59
  function M(e) {
60
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
61
  }
62
- function v(e, t) {
62
+ function T(e, t) {
63
63
  try {
64
64
  const s = JSON.parse(e);
65
65
  return t ? t(s) ? s : null : s;
@@ -69,7 +69,7 @@ function v(e, t) {
69
69
  }
70
70
  "" + Math.random().toString(32).slice(2);
71
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) : E(e) ? Object.keys(e).reduce(
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
73
  (s, r) => {
74
74
  const a = D(String(r)), n = a.charAt(0).toLowerCase() + a.slice(1);
75
75
  return s[n] = t ? e[r] : R(e[r]), s;
@@ -77,11 +77,11 @@ function R(e, t = !1) {
77
77
  {}
78
78
  ) : e;
79
79
  }
80
- function O(e, t = !1) {
81
- return typeof e == "string" ? M(e) : Array.isArray(e) ? e.map((s) => !t || typeof s == "string" ? O(s) : typeof s == "object" && s ? O(s, t) : s) : E(e) ? Object.keys(e).reduce(
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
82
  (s, r) => {
83
83
  const a = M(String(r));
84
- return s[a] = t ? e[r] : O(e[r]), s;
84
+ return s[a] = t ? e[r] : k(e[r]), s;
85
85
  },
86
86
  {}
87
87
  ) : e;
@@ -96,7 +96,7 @@ async function $e(e) {
96
96
  }, r.setAttribute("src", e), s.appendChild(r);
97
97
  });
98
98
  }
99
- function Q(e, t = "数据未能正确识别") {
99
+ function Y(e, t = "数据未能正确识别") {
100
100
  return typeof e == "function" ? {
101
101
  guard: e,
102
102
  message: t
@@ -172,9 +172,9 @@ class ne {
172
172
  constructor(t) {
173
173
  // 保存的配置需要部分字段强制设置默认值
174
174
  y(this, "config", {
175
- baseURL: "",
175
+ baseURL: "/",
176
176
  maxRetry: 0,
177
- retryInterval: 1e3,
177
+ retryInterval: 100,
178
178
  retryResolve: "network",
179
179
  timeout: 1e4,
180
180
  cacheTTL: 500,
@@ -209,15 +209,15 @@ class ne {
209
209
  this.config.messageHandler && s && this.config.messageHandler(t, s, r, a);
210
210
  }
211
211
  }
212
- var H = /* @__PURE__ */ ((e) => (e.UnexpectResponse = "UnexpectResponse", e.Aborted = "Aborted", e.Unknown = "Unknown", e.Timeout = "Timeout", e.NotSupport = "NotSupport", e.URLFormatError = "URLFormatError", e))(H || {});
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
213
  function ae(e, t, s, r) {
214
- if (t.ok && !Z(t.data) && r) {
215
- const a = Q(r, s.get("defaultTypeGuardMessage"));
214
+ if (t.ok && !z(t.data) && r) {
215
+ const a = Y(r, s.get("defaultTypeGuardMessage"));
216
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
217
  }
218
218
  return t;
219
219
  }
220
- class Oe {
220
+ class ke {
221
221
  constructor(t, s) {
222
222
  y(this, "agent");
223
223
  y(this, "config");
@@ -292,13 +292,13 @@ class Oe {
292
292
  return n.method = "PATCH", n.body = s || {}, this.guard(t, await this.request(t, n), r || null);
293
293
  }
294
294
  }
295
- async function ke(e, t, s) {
295
+ async function Ee(e, t, s) {
296
296
  var m;
297
- const r = Object.assign({ method: "GET" }, s), a = k.FormData ? r.body instanceof FormData : !1, n = a && r.method !== "POST" && r.method !== "PUT" ? "POST" : r.method, o = n === "GET" || n === "HEAD" || n === "DELETE";
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
298
  o && r.body !== void 0 && (console.warn("request body is invalid with method get, head, delete"), delete r.body);
299
299
  const c = Object.assign(
300
300
  a || o ? {} : {
301
- "Content-Type": k.Blob && r.body instanceof Blob ? r.body.type || "application/octet-stream" : "application/json;charset=utf-8"
301
+ "Content-Type": E.Blob && r.body instanceof Blob ? r.body.type || "application/octet-stream" : "application/json;charset=utf-8"
302
302
  },
303
303
  r.headers
304
304
  ), i = r.params || {}, d = {};
@@ -326,14 +326,14 @@ function oe(e) {
326
326
  }
327
327
  function ce(e) {
328
328
  if (e)
329
- return typeof e == "string" || e instanceof URLSearchParams || e instanceof ArrayBuffer || k.Blob && e instanceof Blob || k.FormData && e instanceof FormData ? e : JSON.stringify(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
330
  }
331
- const q = "data", j = "message";
331
+ const N = "data", j = "message";
332
332
  function ie(e, t, s, r, a) {
333
333
  const n = a || r;
334
334
  return C(e) ? ge(n.ok || r.ok, e, t, s) : ue(n.failed || r.failed, t, s);
335
335
  }
336
- const Ee = function(e) {
336
+ const Oe = function(e) {
337
337
  const t = [], s = e.failed || { resolve: "json" };
338
338
  switch (t.push("- 当http状态码 <200 或者 >=400 时"), s.resolve) {
339
339
  case "body":
@@ -350,7 +350,7 @@ const Ee = function(e) {
350
350
  break;
351
351
  case "json":
352
352
  t.push(
353
- " 将响应解析为 json,读取 " + (r.dataField || q) + " 作为响应数据,读取 " + (r.messageField || j) + " 作为提示消息"
353
+ " 将响应解析为 json,读取 " + (r.dataField || N) + " 作为响应数据,读取 " + (r.messageField || j) + " 作为提示消息"
354
354
  ), r.statusField && t.push(
355
355
  " 当 " + r.statusField + " 为 " + (r.statusOKValue || "空值") + " 时是成功提示,否则是错误消息"
356
356
  ), r.ignoreMessage && t.push(" 并忽略以下消息:" + r.ignoreMessage);
@@ -380,13 +380,13 @@ function ue(e, t, s) {
380
380
  function le(e, t, s, r = j) {
381
381
  if (!S(e))
382
382
  return { message: "" };
383
- const a = F(v(e), t);
384
- return !a || !E(a) ? { message: e } : {
385
- code: s ? T(a, s) : "",
386
- message: T(a, r) || e
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
387
  };
388
388
  }
389
- function T(e, t) {
389
+ function v(e, t) {
390
390
  const s = Array.isArray(t) ? t : [t];
391
391
  for (const r of s)
392
392
  if (r in e)
@@ -414,21 +414,21 @@ function ge(e, t, s, r) {
414
414
  if (t === 204 || !r)
415
415
  return n;
416
416
  if (a.resolve === "body")
417
- return n.data = S(r) ? F(v(r), e.converter) : r, n;
418
- const o = F(v(r), e.converter);
419
- if (!o || !E(o))
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
420
  return n.ok = !1, n.code = "ResponseFormatError", n.message = "响应内容无法格式化为 Object", n;
421
- const c = a.statusField, i = a.statusOKValue || "", d = a.dataField || q, u = a.messageField || j, l = a.ignoreMessage || "";
421
+ const c = a.statusField, i = a.statusOKValue || "", d = a.dataField || N, u = a.messageField || j, l = a.ignoreMessage || "";
422
422
  if (c && !(c in o))
423
423
  return n.ok = !1, n.code = "ResponseFieldMissing", n.message = "响应内容找不到状态字段 " + c, n;
424
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 = T(o, u), l && n.message && (Array.isArray(l) && l.includes(n.message) || typeof l == "string" && n.message === l) && (n.message = ""), n;
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
426
  }
427
427
  function C(e) {
428
428
  return e >= 200 && e < 400;
429
429
  }
430
430
  function F(e, t) {
431
- return t === "camelize" ? R(e) : t === "snakify" ? O(e) : e;
431
+ return t === "camelize" ? R(e) : t === "snakify" ? k(e) : e;
432
432
  }
433
433
  const me = J("APIError");
434
434
  function pe(e) {
@@ -459,7 +459,7 @@ function ye(e) {
459
459
  {}
460
460
  );
461
461
  }
462
- function ve(e, t, s, r) {
462
+ function Te(e, t, s, r) {
463
463
  var g;
464
464
  const a = e.status, n = e.method, o = ye(
465
465
  Object.entries(e.headers || {}).map(([p, m]) => [p.toLowerCase(), m])
@@ -522,7 +522,7 @@ function be(e) {
522
522
  console.error("RequestError", t);
523
523
  }
524
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") || I;
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
526
  i({
527
527
  type: "prepear",
528
528
  url: t,
@@ -548,25 +548,25 @@ async function we(e, t, s, r, a) {
548
548
  const p = C(l);
549
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
550
  return u;
551
- const m = (r == null ? void 0 : r.retryInterval) ?? s.get("retryInterval") ?? 1e3;
552
- return await G(
551
+ const m = (r == null ? void 0 : r.retryInterval) ?? s.get("retryInterval") ?? 100;
552
+ return await I(
553
553
  Math.max(
554
554
  100,
555
- m === "2EB" ? Math.pow(2, n) * 1e3 : typeof m == "function" ? m(n + 1) || 0 : m
555
+ m === "2EB" ? Math.pow(2, n) * 100 : typeof m == "function" ? m(n + 1) || 0 : m
556
556
  )
557
557
  ), await we(e, t, s, r, n + 1);
558
558
  }
559
559
  export {
560
- Re as H,
561
- Oe as N,
562
- $e as O,
560
+ $e as I,
561
+ ke as N,
563
562
  ne as R,
564
- A as Y,
563
+ Re as Z,
565
564
  H as a,
566
- ke as c,
567
- k as e,
565
+ Ee as c,
568
566
  ye as f,
569
- Ee as g,
570
- ve as h,
571
- we as r
567
+ Oe as g,
568
+ Te as h,
569
+ E as l,
570
+ we as r,
571
+ A as t
572
572
  };
package/dist/wx.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./retry-CRrgnQtP.cjs"),l=async function(e,r,n){return t.handleResponse(await t.retryRequest(f,e,r,n),e,r,n)},f=async function(e,r,n){const s=await t.convertOptions(e,r,n),u=s.method==="PATCH"?"POST":s.method,a=t.Ht(s.url,s.params);return t.ee.wx?new Promise(d=>{wx.request({url:a,data:s.body,header:s.headers,method:u,dataType:"string",responseType:"text",fail(){d({url:a,method:u,status:-1,statusText:t.RequestInteralError.Unknown,body:""})},success(c){d({url:a,method:u,status:c.statusCode,statusText:c.statusCode+"",headers:{...c.header},body:s.method==="HEAD"?"":p(c.data)})}})}):{url:a,method:u,status:-1,statusText:t.RequestInteralError.NotSupport,body:""}};function p(e){return typeof e=="string"?e:e instanceof ArrayBuffer&&t.ee.TextDecoder?new TextDecoder().decode(e):JSON.stringify(e)}function i(e){return new t.NetRequestHandler(l,e)}const o=i(),y=o.setConfig,g=o.head,h=o.get,q=o.post,x=o.del,R=o.put;exports.NetRequest=i;exports.del=x;exports.get=h;exports.head=g;exports.post=q;exports.put=R;exports.setGlobalConfig=y;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./retry-B9vBp2mw.cjs"),l=async function(t,n,u){return e.handleResponse(await e.retryRequest(f,t,n,u),t,n,u)},f=async function(t,n,u){const s=await e.convertOptions(t,n,u),a=s.method==="PATCH"?"POST":s.method,c=e.Zt(s.url,s.params);return e.lt.wx?new Promise(d=>{wx.request({url:c,data:s.body,header:s.headers,method:a,dataType:"string",responseType:"text",fail(){d({url:c,method:a,status:-1,statusText:e.RequestInteralError.Unknown,body:""})},success(r){d({url:c,method:a,status:r.statusCode,statusText:r.statusCode+"",headers:{...r.header},body:s.method==="HEAD"||r.statusCode===204?"":p(r.data)})}})}):{url:c,method:a,status:-1,statusText:e.RequestInteralError.NotSupport,body:""}};function p(t){return typeof t=="string"?t:t instanceof ArrayBuffer&&e.lt.TextDecoder?new TextDecoder().decode(t):JSON.stringify(t)}function i(t){return new e.NetRequestHandler(l,t)}const o=i(),y=o.setConfig,g=o.head,h=o.get,q=o.post,x=o.del,R=o.put;exports.NetRequest=i;exports.del=x;exports.get=h;exports.head=g;exports.post=q;exports.put=R;exports.setGlobalConfig=y;
package/dist/wx.js CHANGED
@@ -1,39 +1,39 @@
1
- import { h as f, r as p, c as l, H as h, e as i, a as d, N as y } from "./retry-8Z8eLh90.js";
2
- const x = async function(t, o, n) {
3
- return f(await p(m, t, o, n), t, o, n);
4
- }, m = async function(t, o, n) {
5
- const e = await l(t, o, n), r = e.method === "PATCH" ? "POST" : e.method, a = h(e.url, e.params);
1
+ import { h as l, r as f, c as p, Z as h, l as i, a as d, N as y } from "./retry-Ch1GFMrA.js";
2
+ const x = async function(t, n, r) {
3
+ return l(await f(m, t, n, r), t, n, r);
4
+ }, m = async function(t, n, r) {
5
+ const e = await p(t, n, r), a = e.method === "PATCH" ? "POST" : e.method, u = h(e.url, e.params);
6
6
  return i.wx ? new Promise((c) => {
7
7
  wx.request({
8
- url: a,
8
+ url: u,
9
9
  data: e.body,
10
10
  header: e.headers,
11
- method: r,
11
+ method: a,
12
12
  dataType: "string",
13
13
  responseType: "text",
14
14
  fail() {
15
15
  c({
16
- url: a,
17
- method: r,
16
+ url: u,
17
+ method: a,
18
18
  status: -1,
19
19
  statusText: d.Unknown,
20
20
  body: ""
21
21
  });
22
22
  },
23
- success(u) {
23
+ success(o) {
24
24
  c({
25
- url: a,
26
- method: r,
27
- status: u.statusCode,
28
- statusText: u.statusCode + "",
29
- headers: { ...u.header },
30
- body: e.method === "HEAD" ? "" : w(u.data)
25
+ url: u,
26
+ method: a,
27
+ status: o.statusCode,
28
+ statusText: o.statusCode + "",
29
+ headers: { ...o.header },
30
+ body: e.method === "HEAD" || o.statusCode === 204 ? "" : w(o.data)
31
31
  });
32
32
  }
33
33
  });
34
34
  }) : {
35
- url: a,
36
- method: r,
35
+ url: u,
36
+ method: a,
37
37
  status: -1,
38
38
  statusText: d.NotSupport,
39
39
  body: ""
@@ -45,13 +45,13 @@ function w(t) {
45
45
  function T(t) {
46
46
  return new y(x, t);
47
47
  }
48
- const s = T(), q = s.setConfig, R = s.head, b = s.get, C = s.post, H = s.del, N = s.put;
48
+ const s = T(), q = s.setConfig, R = s.head, b = s.get, C = s.post, N = s.del, S = s.put;
49
49
  export {
50
50
  T as NetRequest,
51
- H as del,
51
+ N as del,
52
52
  b as get,
53
53
  R as head,
54
54
  C as post,
55
- N as put,
55
+ S as put,
56
56
  q as setGlobalConfig
57
57
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@seayoo-web/request",
3
- "version": "2.1.0",
3
+ "version": "2.1.2",
4
4
  "description": "requst tools for seayoo web",
5
5
  "type": "module",
6
6
  "source": "./src/index.ts",
@@ -59,7 +59,7 @@
59
59
  "happy-dom": "^12.10.3",
60
60
  "msw": "^2.7.0",
61
61
  "vitest": "^3.0.5",
62
- "@seayoo-web/utils": "^3.0.4"
62
+ "@seayoo-web/utils": "^3.0.8"
63
63
  },
64
64
  "scripts": {
65
65
  "build": "vite build && tsc --emitDeclarationOnly",
@@ -6,8 +6,10 @@ export declare const enum RequestInteralError {
6
6
  UnexpectResponse = "UnexpectResponse",
7
7
  /** 请求被取消 */
8
8
  Aborted = "Aborted",
9
- /** 未知错误,通常是网络错误 */
9
+ /** 未知错误 */
10
10
  Unknown = "Unknown",
11
+ /** 网络错误 */
12
+ NetworkError = "NetworkError",
11
13
  /** 超时 */
12
14
  Timeout = "Timeout",
13
15
  /** 请求方法不被支持,在微信小程序环境下有效 */
@@ -47,9 +49,9 @@ export interface IRetryRequestOptions {
47
49
  /** 重试策略:默认 network,可选 status 或者指定特殊的 status 或自定义检查 */
48
50
  retryResolve?: IRetryResolve;
49
51
  /**
50
- * 两次重试的间隔,如果设置时间,则单位 ms,或者设置函数返回等待的时间(单位ms),默认 1000,最小 100,函数参数 retryIndex 从 1 开始
52
+ * 两次重试的间隔,如果设置时间,则单位 ms,或者设置函数返回等待的时间(单位ms),默认 100,最小 100,函数参数 retryIndex 从 1 开始
51
53
  *
52
- * 特殊值 2EB 表示以 2 为底的指数退避,首次延迟为 1 秒,第二次为 2 秒,第三次为 4 秒,第四次为 8 秒...
54
+ * 特殊值 2EB 表示以 2 为底的指数退避,首次延迟为 100ms,第二次为 200ms,第三次为 400ms,第四次为 800ms...
53
55
  *
54
56
  * 扩展阅读 https://en.wikipedia.org/wiki/Exponential_backoff
55
57
  */
@@ -1 +0,0 @@
1
- "use strict";const s=require("./retry-CRrgnQtP.cjs"),f=async function(o,n,i){return s.handleResponse(await s.retryRequest(w,o,n,i),o,n,i)},w=async function(o,n,i){const t=await s.convertOptions(o,n,i),a=new URL(t.url),u=t.params;u instanceof Object&&Object.keys(u).forEach(e=>a.searchParams.set(e,u[e]));const r=s.ee.AbortController?new AbortController:null;function c(){r&&!r.signal.aborted&&r.abort()}t.abort&&t.abort.addEventListener("abort",c);const h=t.timeout>0?setTimeout(c,t.timeout):null,b=t.method==="HEAD";return await fetch(a,{method:t.method,headers:Object.keys(t.headers).length>0?new Headers(t.headers):void 0,body:t.body,credentials:t.credentials,signal:r==null?void 0:r.signal,redirect:"follow"}).then(async e=>{const d=b?"":await e.text().catch(m=>m),l=s.fromEntries([...e.headers.entries()]);return d instanceof Error?{url:a.toString(),method:t.method,status:e.status,statusText:e.statusText||s.RequestInteralError.Unknown,body:"",headers:l,rawError:d}:{url:a.toString(),method:t.method,status:e.status,statusText:e.statusText,headers:l,body:d}}).catch(e=>({url:a.toString(),method:t.method,status:-1,statusText:r!=null&&r.signal.aborted?s.RequestInteralError.Aborted:s.RequestInteralError.Unknown,body:"",rawError:e})).finally(()=>{h!==null&&clearTimeout(h),t.abort&&t.abort.removeEventListener("abort",c)})};exports.fetchRequest=f;
@@ -1,51 +0,0 @@
1
- import { h as f, r as w, c as y, e as E, f as g, a as d } from "./retry-8Z8eLh90.js";
2
- const T = async function(r, o, n) {
3
- return f(await w(x, r, o, n), r, o, n);
4
- }, x = async function(r, o, n) {
5
- const t = await y(r, o, n), s = new URL(t.url), i = t.params;
6
- i instanceof Object && Object.keys(i).forEach((e) => s.searchParams.set(e, i[e]));
7
- const a = E.AbortController ? new AbortController() : null;
8
- function c() {
9
- a && !a.signal.aborted && a.abort();
10
- }
11
- t.abort && t.abort.addEventListener("abort", c);
12
- const h = t.timeout > 0 ? setTimeout(c, t.timeout) : null, l = t.method === "HEAD";
13
- return await fetch(s, {
14
- method: t.method,
15
- headers: Object.keys(t.headers).length > 0 ? new Headers(t.headers) : void 0,
16
- body: t.body,
17
- credentials: t.credentials,
18
- signal: a == null ? void 0 : a.signal,
19
- redirect: "follow"
20
- }).then(async (e) => {
21
- const u = l ? "" : await e.text().catch((m) => m), b = g([...e.headers.entries()]);
22
- return u instanceof Error ? {
23
- url: s.toString(),
24
- method: t.method,
25
- status: e.status,
26
- statusText: e.statusText || d.Unknown,
27
- body: "",
28
- headers: b,
29
- rawError: u
30
- } : {
31
- url: s.toString(),
32
- method: t.method,
33
- status: e.status,
34
- statusText: e.statusText,
35
- headers: b,
36
- body: u
37
- };
38
- }).catch((e) => ({
39
- url: s.toString(),
40
- method: t.method,
41
- status: -1,
42
- statusText: a != null && a.signal.aborted ? d.Aborted : d.Unknown,
43
- body: "",
44
- rawError: e
45
- })).finally(() => {
46
- h !== null && clearTimeout(h), t.abort && t.abort.removeEventListener("abort", c);
47
- });
48
- };
49
- export {
50
- T as f
51
- };