@seayoo-web/request 2.0.8 → 2.0.10

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/dist/index.cjs CHANGED
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("./retry-DrW-Az-k.cjs"),y=require("./request.fetch-Dc_ujBlU.cjs"),m=async function(t,o,e){return s.handleResponse(await s.retryRequest(p,t,o,e),t,o,e)};async function q(t,o,e,n){const r=e==null?void 0:e.body,d=(e==null?void 0:e.method)==="PUT"?"PUT":"POST";if(o instanceof Blob){const i=new s.RequestGlobalConfig(n),f=await p(t,i,{...e,method:d,body:o});return s.handleResponse(f,t,i,e)}const c=new FormData,u={...o};r instanceof Object&&Object.entries(r).forEach(([i,f])=>{f instanceof Blob?u[i]=f:Array.isArray(f)?f.forEach((a,g)=>{c.append(`${i}[${g}]`,String(a))}):c.append(i,String(f))});for(const i in u)c.append(i,u[i]);const b=new s.RequestGlobalConfig(n),w=await p(t,b,{...e,method:d,body:c});return s.handleResponse(w,t,b,e)}const p=async function(t,o,e){const n=await s.convertOptions(t,o,e),r=n.method,d=e==null?void 0:e.onUploadProgress,c=s.Bt(n.url,n.params);return await new Promise(u=>{let b=null,w=!1;const i=function(){w||(a.abort(),w=!0)};function f(){b!==null&&clearTimeout(b),n.abort&&n.abort.removeEventListener("abort",i)}const a=new XMLHttpRequest;if(a.open(r,c,!0),d){let g=1;a.upload.addEventListener("progress",h=>{g=h.total,d({total:h.total,loaded:h.loaded})}),a.addEventListener("load",()=>{d({loaded:g,total:g})})}a.addEventListener("load",()=>{f(),u({url:c,method:r,status:a.status,statusText:a.statusText,headers:H(a),body:r==="HEAD"?"":a.responseText})}),a.addEventListener("error",g=>{f(),u({url:c,method:r,status:-1,statusText:"Unknown",body:"",rawError:g})},!0),a.addEventListener("abort",()=>{f(),u({url:c,method:r,status:-1,statusText:"Aborted",body:""})}),Object.entries(n.headers).forEach(([g,h])=>{a.setRequestHeader(g,h)}),n.credentials==="include"&&(a.withCredentials=!0),a.send(n.body||void 0),n.abort&&n.abort.addEventListener("abort",i),n.timeout>0&&(b=setTimeout(i,n.timeout))})};function H(t){const o={};if(!t)return o;const e=t.getAllResponseHeaders();return e&&e!=="null"&&e.replace(/\r/g,"").split(`
2
- `).forEach(n=>{const r=n.trim();if(!r)return;const d=r.split(":"),c=d[0].trim();c&&(o[c]=(d[1]||"").trim())}),o}async function T(t,o,e={}){const n=window;"callback"in e||(e.callback="jsonxData"+Math.random().toString(16).slice(2));const r=e.callback+"";if(!t)return null;const d=s.Bt(t,e,!0);return new Promise(c=>{n[r]=function(u){if(r in window&&delete n[r],o(u))return u;console.warn("response type check faild",t,u),c(null)},s.je(d).catch(function(){c(null),delete n[r]})})}async function E(t,o,e={}){const n=window;return"var"in e||(e.var="jsonxData"+Math.random().toString(16).slice(2)),t?await s.je(s.Bt(t,e,!0)).then(()=>{const r=n[e.var+""];return o(r)?r:(console.warn("response type check faild",t,r),null)}).catch(()=>null):null}const j=async function(t,o,e){return await q(t,o,e,{baseURL:l.getConfig("baseURL"),logHandler:l.getConfig("logHandler"),errorHandler:l.getConfig("errorHandler"),requestTransformer:l.getConfig("requestTransformer"),messageHandler:l.getConfig("messageHandler"),responseHandler:l.getConfig("responseHandler")})};function R(t){if(!s.Support.window)throw new Error("Default Module Only Support In Browser");return s.Support.fetch?new s.NetRequestHandler(y.fetchRequest,t):new s.NetRequestHandler(m,t)}const l=R(),C=l.setConfig,S=l.request,x=l.head,L=l.get,U=l.post,k=l.del,v=l.put,D=l.patch;exports.getResponseRulesDescription=s.getResponseRulesDescription;exports.NetRequest=R;exports.del=k;exports.get=L;exports.head=x;exports.jsonp=T;exports.jsonx=E;exports.patch=D;exports.post=U;exports.put=v;exports.request=S;exports.setGlobalConfig=C;exports.upload=j;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("./type-CrucJEBR.cjs"),q=require("./request.fetch-K4MJcDmZ.cjs"),y=async function(t,s,e){return o.handleResponse(await o.retryRequest(R,t,s,e),t,s,e)};async function m(t,s,e,n){const r=e==null?void 0:e.body,u=(e==null?void 0:e.method)==="PUT"?"PUT":"POST";if(s instanceof Blob){const i=new o.RequestGlobalConfig(n),f=await R(t,i,{...e,method:u,body:s});return o.handleResponse(f,t,i,e)}const c=new FormData,d={...s};r instanceof Object&&Object.entries(r).forEach(([i,f])=>{f instanceof Blob?d[i]=f:Array.isArray(f)?f.forEach((a,g)=>{c.append(`${i}[${g}]`,String(a))}):c.append(i,String(f))});for(const i in d)c.append(i,d[i]);const b=new o.RequestGlobalConfig(n),w=await R(t,b,{...e,method:u,body:c});return o.handleResponse(w,t,b,e)}const R=async function(t,s,e){const n=await o.convertOptions(t,s,e),r=n.method,u=e==null?void 0:e.onUploadProgress,c=o.Dt(n.url,n.params);return await new Promise(d=>{let b=null,w=!1;const i=function(){w||(a.abort(),w=!0)};function f(){b!==null&&clearTimeout(b),n.abort&&n.abort.removeEventListener("abort",i)}const a=new XMLHttpRequest;if(a.open(r,c,!0),u){let g=1;a.upload.addEventListener("progress",h=>{g=h.total,u({total:h.total,loaded:h.loaded})}),a.addEventListener("load",()=>{u({loaded:g,total:g})})}a.addEventListener("load",()=>{f(),d({url:c,method:r,status:a.status,statusText:a.statusText,headers:E(a),body:r==="HEAD"?"":a.responseText})}),a.addEventListener("error",g=>{f(),d({url:c,method:r,status:-1,statusText:o.RequestInteralError.Unknown,body:"",rawError:g})},!0),a.addEventListener("abort",()=>{f(),d({url:c,method:r,status:-1,statusText:o.RequestInteralError.Aborted,body:""})}),Object.entries(n.headers).forEach(([g,h])=>{a.setRequestHeader(g,h)}),n.credentials==="include"&&(a.withCredentials=!0),a.send(n.body||void 0),n.abort&&n.abort.addEventListener("abort",i),n.timeout>0&&(b=setTimeout(i,n.timeout))})};function E(t){const s={};if(!t)return s;const e=t.getAllResponseHeaders();return e&&e!=="null"&&e.replace(/\r/g,"").split(`
2
+ `).forEach(n=>{const r=n.trim();if(!r)return;const u=r.split(":"),c=u[0].trim();c&&(s[c]=(u[1]||"").trim())}),s}async function H(t,s,e={}){const n=window;"callback"in e||(e.callback="jsonxData"+Math.random().toString(16).slice(2));const r=e.callback+"";if(!t)return null;const u=o.Dt(t,e,!0);return new Promise(c=>{n[r]=function(d){if(r in window&&delete n[r],s(d))return d;console.warn("response type check faild",t,d),c(null)},o.Me(u).catch(function(){c(null),delete n[r]})})}async function T(t,s,e={}){const n=window;return"var"in e||(e.var="jsonxData"+Math.random().toString(16).slice(2)),t?await o.Me(o.Dt(t,e,!0)).then(()=>{const r=n[e.var+""];return s(r)?r:(console.warn("response type check faild",t,r),null)}).catch(()=>null):null}const C=async function(t,s,e){return await m(t,s,e,{baseURL:l.getConfig("baseURL"),logHandler:l.getConfig("logHandler"),errorHandler:l.getConfig("errorHandler"),requestTransformer:l.getConfig("requestTransformer"),messageHandler:l.getConfig("messageHandler"),responseHandler:l.getConfig("responseHandler")})};function p(t){if(!o.Kt.window)throw new Error("Default Module Only Support In Browser");return o.Kt.fetch?new o.NetRequestHandler(q.fetchRequest,t):new o.NetRequestHandler(y,t)}const l=p(),x=l.setConfig,D=l.request,j=l.head,L=l.get,S=l.post,U=l.del,k=l.put,v=l.patch;exports.RequestInteralError=o.RequestInteralError;exports.getResponseRulesDescription=o.getResponseRulesDescription;exports.NetRequest=p;exports.del=U;exports.get=L;exports.head=j;exports.jsonp=H;exports.jsonx=T;exports.patch=v;exports.post=S;exports.put=k;exports.request=D;exports.setGlobalConfig=x;exports.upload=C;
package/dist/index.js CHANGED
@@ -1,23 +1,23 @@
1
- import { h as w, r as E, R as y, c as T, B as p, j as q, S as R, N as H } from "./retry-CaBI_Pfh.js";
2
- import { g as I } from "./retry-CaBI_Pfh.js";
3
- import { f as x } from "./request.fetch-DfFYJr1l.js";
4
- const C = async function(t, o, e) {
5
- return w(await E(m, t, o, e), t, o, e);
1
+ import { h as w, r as T, R as y, c as x, D as p, a as R, M as E, K as H, N as q } from "./type-CRH6iqXf.js";
2
+ import { g as z } from "./type-CRH6iqXf.js";
3
+ import { f as C } from "./request.fetch-DR4KeRZ0.js";
4
+ const L = async function(t, a, e) {
5
+ return w(await T(m, t, a, e), t, a, e);
6
6
  };
7
- async function L(t, o, e, n) {
7
+ async function D(t, a, e, n) {
8
8
  const r = e == null ? void 0 : e.body, i = (e == null ? void 0 : e.method) === "PUT" ? "PUT" : "POST";
9
- if (o instanceof Blob) {
9
+ if (a instanceof Blob) {
10
10
  const l = new y(n), u = await m(t, l, {
11
11
  ...e,
12
12
  method: i,
13
- body: o
13
+ body: a
14
14
  });
15
15
  return w(u, t, l, e);
16
16
  }
17
- const s = new FormData(), d = { ...o };
17
+ const s = new FormData(), d = { ...a };
18
18
  r instanceof Object && Object.entries(r).forEach(([l, u]) => {
19
- u instanceof Blob ? d[l] = u : Array.isArray(u) ? u.forEach((a, f) => {
20
- s.append(`${l}[${f}]`, String(a));
19
+ u instanceof Blob ? d[l] = u : Array.isArray(u) ? u.forEach((o, f) => {
20
+ s.append(`${l}[${f}]`, String(o));
21
21
  }) : s.append(l, String(u));
22
22
  });
23
23
  for (const l in d)
@@ -29,64 +29,64 @@ async function L(t, o, e, n) {
29
29
  });
30
30
  return w(h, t, b, e);
31
31
  }
32
- const m = async function(t, o, e) {
33
- const n = await T(t, o, e), r = n.method, i = e == null ? void 0 : e.onUploadProgress, s = p(n.url, n.params);
32
+ const m = async function(t, a, e) {
33
+ const n = await x(t, a, e), r = n.method, i = e == null ? void 0 : e.onUploadProgress, s = p(n.url, n.params);
34
34
  return await new Promise((d) => {
35
35
  let b = null, h = !1;
36
36
  const l = function() {
37
- h || (a.abort(), h = !0);
37
+ h || (o.abort(), h = !0);
38
38
  };
39
39
  function u() {
40
40
  b !== null && clearTimeout(b), n.abort && n.abort.removeEventListener("abort", l);
41
41
  }
42
- const a = new XMLHttpRequest();
43
- if (a.open(r, s, !0), i) {
42
+ const o = new XMLHttpRequest();
43
+ if (o.open(r, s, !0), i) {
44
44
  let f = 1;
45
- a.upload.addEventListener("progress", (g) => {
45
+ o.upload.addEventListener("progress", (g) => {
46
46
  f = g.total, i({ total: g.total, loaded: g.loaded });
47
- }), a.addEventListener("load", () => {
47
+ }), o.addEventListener("load", () => {
48
48
  i({ loaded: f, total: f });
49
49
  });
50
50
  }
51
- a.addEventListener("load", () => {
51
+ o.addEventListener("load", () => {
52
52
  u(), d({
53
53
  url: s,
54
54
  method: r,
55
- status: a.status,
56
- statusText: a.statusText,
57
- headers: S(a),
58
- body: r === "HEAD" ? "" : a.responseText
55
+ status: o.status,
56
+ statusText: o.statusText,
57
+ headers: U(o),
58
+ body: r === "HEAD" ? "" : o.responseText
59
59
  });
60
- }), a.addEventListener(
60
+ }), o.addEventListener(
61
61
  "error",
62
62
  (f) => {
63
63
  u(), d({
64
64
  url: s,
65
65
  method: r,
66
66
  status: -1,
67
- statusText: "Unknown",
67
+ statusText: R.Unknown,
68
68
  body: "",
69
69
  rawError: f
70
70
  });
71
71
  },
72
72
  !0
73
- ), a.addEventListener("abort", () => {
73
+ ), o.addEventListener("abort", () => {
74
74
  u(), d({
75
75
  url: s,
76
76
  method: r,
77
77
  status: -1,
78
- statusText: "Aborted",
78
+ statusText: R.Aborted,
79
79
  body: ""
80
80
  });
81
81
  }), Object.entries(n.headers).forEach(([f, g]) => {
82
- a.setRequestHeader(f, g);
83
- }), n.credentials === "include" && (a.withCredentials = !0), a.send(n.body || void 0), n.abort && n.abort.addEventListener("abort", l), n.timeout > 0 && (b = setTimeout(l, n.timeout));
82
+ o.setRequestHeader(f, g);
83
+ }), n.credentials === "include" && (o.withCredentials = !0), o.send(n.body || void 0), n.abort && n.abort.addEventListener("abort", l), n.timeout > 0 && (b = setTimeout(l, n.timeout));
84
84
  });
85
85
  };
86
- function S(t) {
87
- const o = {};
86
+ function U(t) {
87
+ const a = {};
88
88
  if (!t)
89
- return o;
89
+ return a;
90
90
  const e = t.getAllResponseHeaders();
91
91
  return e && e !== "null" && e.replace(/\r/g, "").split(`
92
92
  `).forEach((n) => {
@@ -94,10 +94,10 @@ function S(t) {
94
94
  if (!r)
95
95
  return;
96
96
  const i = r.split(":"), s = i[0].trim();
97
- s && (o[s] = (i[1] || "").trim());
98
- }), o;
97
+ s && (a[s] = (i[1] || "").trim());
98
+ }), a;
99
99
  }
100
- async function v(t, o, e = {}) {
100
+ async function v(t, a, e = {}) {
101
101
  const n = window;
102
102
  "callback" in e || (e.callback = "jsonxData" + Math.random().toString(16).slice(2));
103
103
  const r = e.callback + "";
@@ -106,23 +106,23 @@ async function v(t, o, e = {}) {
106
106
  const i = p(t, e, !0);
107
107
  return new Promise((s) => {
108
108
  n[r] = function(d) {
109
- if (r in window && delete n[r], o(d))
109
+ if (r in window && delete n[r], a(d))
110
110
  return d;
111
111
  console.warn("response type check faild", t, d), s(null);
112
- }, q(i).catch(function() {
112
+ }, E(i).catch(function() {
113
113
  s(null), delete n[r];
114
114
  });
115
115
  });
116
116
  }
117
- async function D(t, o, e = {}) {
117
+ async function M(t, a, e = {}) {
118
118
  const n = window;
119
- return "var" in e || (e.var = "jsonxData" + Math.random().toString(16).slice(2)), t ? await q(p(t, e, !0)).then(() => {
119
+ return "var" in e || (e.var = "jsonxData" + Math.random().toString(16).slice(2)), t ? await E(p(t, e, !0)).then(() => {
120
120
  const r = n[e.var + ""];
121
- return o(r) ? r : (console.warn("response type check faild", t, r), null);
121
+ return a(r) ? r : (console.warn("response type check faild", t, r), null);
122
122
  }).catch(() => null) : null;
123
123
  }
124
- const O = async function(t, o, e) {
125
- return await L(t, o, e, {
124
+ const O = async function(t, a, e) {
125
+ return await D(t, a, e, {
126
126
  baseURL: c.getConfig("baseURL"),
127
127
  logHandler: c.getConfig("logHandler"),
128
128
  errorHandler: c.getConfig("errorHandler"),
@@ -131,23 +131,24 @@ const O = async function(t, o, e) {
131
131
  responseHandler: c.getConfig("responseHandler")
132
132
  });
133
133
  };
134
- function j(t) {
135
- if (!R.window)
134
+ function k(t) {
135
+ if (!H.window)
136
136
  throw new Error("Default Module Only Support In Browser");
137
- return R.fetch ? new H(x, t) : new H(C, t);
137
+ return H.fetch ? new q(C, t) : new q(L, t);
138
138
  }
139
- const c = j(), P = c.setConfig, A = c.request, B = c.head, M = c.get, N = c.post, X = c.del, F = c.put, G = c.patch;
139
+ const c = k(), P = c.setConfig, A = c.request, N = c.head, B = c.get, X = c.post, F = c.del, G = c.put, I = c.patch;
140
140
  export {
141
- j as NetRequest,
142
- X as del,
143
- M as get,
144
- I as getResponseRulesDescription,
145
- B as head,
141
+ k as NetRequest,
142
+ R as RequestInteralError,
143
+ F as del,
144
+ B as get,
145
+ z as getResponseRulesDescription,
146
+ N as head,
146
147
  v as jsonp,
147
- D as jsonx,
148
- G as patch,
149
- N as post,
150
- F as put,
148
+ M as jsonx,
149
+ I as patch,
150
+ X as post,
151
+ G as put,
151
152
  A as request,
152
153
  P as setGlobalConfig,
153
154
  O as upload
package/dist/node.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./retry-DrW-Az-k.cjs"),y=require("./request.fetch-Dc_ujBlU.cjs"),R=require("node:http"),g=require("node:https"),w=async function(o,a,c){return e.handleResponse(await e.retryRequest(S,o,a,c),o,a,c)},S=async function(o,a,c){const t=await e.convertOptions(o,a,c);if(!e.X(t.url))return{url:t.url,method:t.method,status:-1,statusText:"URLFormatError",headers:{},body:""};const f=/^https:\/\//i.test(t.url)?g:R,u=new URL(t.url),i=t.params;i instanceof Object&&Object.keys(i).forEach(r=>u.searchParams.set(r,i[r]));const q=t.method==="HEAD";return new Promise(r=>{const d=f.request(u,{headers:t.headers,method:t.method,timeout:t.timeout>0?t.timeout:void 0},function(s){const p=[];s.on("data",h=>p.push(h)),s.on("end",()=>{const h=e.fromEntries(Object.entries(s.headers).map(([b,m])=>[b.toLowerCase(),Array.isArray(m)?m.join(","):m]));r({url:u.toString(),method:t.method,status:s.statusCode||-1,statusText:s.statusMessage||"Unknown",headers:h,body:q?"":Buffer.concat(p).toString("utf-8")})})});d.on("error",s=>{r({url:u.toString(),method:t.method,status:-1,statusText:"Unknown",body:"",rawError:s})}),d.on("timeout",()=>{r({url:u.toString(),method:t.method,status:-1,statusText:"Timeout",body:""})}),t.body&&d.write(t.body),d.end()})};function l(o){return e.Support.fetch?new e.NetRequestHandler(y.fetchRequest,o):new e.NetRequestHandler(w,o)}const n=l(),T=n.setConfig,j=n.head,C=n.get,E=n.post,N=n.del,O=n.put,U=n.patch;exports.NetRequest=l;exports.del=N;exports.get=C;exports.head=j;exports.patch=U;exports.post=E;exports.put=O;exports.setGlobalConfig=T;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./type-CrucJEBR.cjs"),b=require("./request.fetch-K4MJcDmZ.cjs"),y=require("node:http"),g=require("node:https"),w=async function(o,u,c){return e.handleResponse(await e.retryRequest(E,o,u,c),o,u,c)},E=async function(o,u,c){const t=await e.convertOptions(o,u,c);if(!e.Y(t.url))return{url:t.url,method:t.method,status:-1,statusText:e.RequestInteralError.URLFormatError,headers:{},body:""};const p=/^https:\/\//i.test(t.url)?g:y,a=new URL(t.url),i=t.params;i instanceof Object&&Object.keys(i).forEach(n=>a.searchParams.set(n,i[n]));const f=t.method==="HEAD";return new Promise(n=>{const d=p.request(a,{headers:t.headers,method:t.method,timeout:t.timeout>0?t.timeout:void 0},function(s){const l=[];s.on("data",h=>l.push(h)),s.on("end",()=>{const h=e.fromEntries(Object.entries(s.headers).map(([R,m])=>[R.toLowerCase(),Array.isArray(m)?m.join(","):m]));n({url:a.toString(),method:t.method,status:s.statusCode||-1,statusText:s.statusMessage||e.RequestInteralError.Unknown,headers:h,body:f?"":Buffer.concat(l).toString("utf-8")})})});d.on("error",s=>{n({url:a.toString(),method:t.method,status:-1,statusText:e.RequestInteralError.Unknown,body:"",rawError:s})}),d.on("timeout",()=>{n({url:a.toString(),method:t.method,status:-1,statusText:e.RequestInteralError.Timeout,body:""})}),t.body&&d.write(t.body),d.end()})};function q(o){return e.Kt.fetch?new e.NetRequestHandler(b.fetchRequest,o):new e.NetRequestHandler(w,o)}const r=q(),S=r.setConfig,T=r.head,j=r.get,C=r.post,N=r.del,O=r.put,U=r.patch;exports.NetRequest=q;exports.del=N;exports.get=j;exports.head=T;exports.patch=U;exports.post=C;exports.put=O;exports.setGlobalConfig=S;
package/dist/node.js CHANGED
@@ -1,25 +1,25 @@
1
- import { h as y, r as R, c as w, X as q, f as g, N as p, S } from "./retry-CaBI_Pfh.js";
2
- import { f as x } from "./request.fetch-DfFYJr1l.js";
3
- import E from "node:http";
4
- import T from "node:https";
5
- const U = async function(e, a, u) {
6
- return y(await R(j, e, a, u), e, a, u);
7
- }, j = async function(e, a, u) {
1
+ import { h as y, r as q, c as w, Y as g, a as d, f as E, N as p, K as x } from "./type-CRH6iqXf.js";
2
+ import { f as T } from "./request.fetch-DR4KeRZ0.js";
3
+ import U from "node:http";
4
+ import j from "node:https";
5
+ const C = async function(e, a, u) {
6
+ return y(await q(L, e, a, u), e, a, u);
7
+ }, L = async function(e, a, u) {
8
8
  const t = await w(e, a, u);
9
- if (!q(t.url))
9
+ if (!g(t.url))
10
10
  return {
11
11
  url: t.url,
12
12
  method: t.method,
13
13
  status: -1,
14
- statusText: "URLFormatError",
14
+ statusText: d.URLFormatError,
15
15
  headers: {},
16
16
  body: ""
17
17
  };
18
- const f = /^https:\/\//i.test(t.url) ? T : E, n = new URL(t.url), d = t.params;
19
- d instanceof Object && Object.keys(d).forEach((r) => n.searchParams.set(r, d[r]));
20
- const b = t.method === "HEAD";
18
+ const l = /^https:\/\//i.test(t.url) ? j : U, n = new URL(t.url), i = t.params;
19
+ i instanceof Object && Object.keys(i).forEach((r) => n.searchParams.set(r, i[r]));
20
+ const R = t.method === "HEAD";
21
21
  return new Promise((r) => {
22
- const c = f.request(
22
+ const c = l.request(
23
23
  n,
24
24
  {
25
25
  headers: t.headers,
@@ -27,18 +27,18 @@ const U = async function(e, a, u) {
27
27
  timeout: t.timeout > 0 ? t.timeout : void 0
28
28
  },
29
29
  function(o) {
30
- const h = [];
31
- o.on("data", (i) => h.push(i)), o.on("end", () => {
32
- const i = g(
33
- Object.entries(o.headers).map(([l, m]) => [l.toLowerCase(), Array.isArray(m) ? m.join(",") : m])
30
+ const f = [];
31
+ o.on("data", (m) => f.push(m)), o.on("end", () => {
32
+ const m = E(
33
+ Object.entries(o.headers).map(([b, h]) => [b.toLowerCase(), Array.isArray(h) ? h.join(",") : h])
34
34
  );
35
35
  r({
36
36
  url: n.toString(),
37
37
  method: t.method,
38
38
  status: o.statusCode || -1,
39
- statusText: o.statusMessage || "Unknown",
40
- headers: i,
41
- body: b ? "" : Buffer.concat(h).toString("utf-8")
39
+ statusText: o.statusMessage || d.Unknown,
40
+ headers: m,
41
+ body: R ? "" : Buffer.concat(f).toString("utf-8")
42
42
  });
43
43
  });
44
44
  }
@@ -48,7 +48,7 @@ const U = async function(e, a, u) {
48
48
  url: n.toString(),
49
49
  method: t.method,
50
50
  status: -1,
51
- statusText: "Unknown",
51
+ statusText: d.Unknown,
52
52
  body: "",
53
53
  rawError: o
54
54
  });
@@ -57,23 +57,23 @@ const U = async function(e, a, u) {
57
57
  url: n.toString(),
58
58
  method: t.method,
59
59
  status: -1,
60
- statusText: "Timeout",
60
+ statusText: d.Timeout,
61
61
  body: ""
62
62
  });
63
63
  }), t.body && c.write(t.body), c.end();
64
64
  });
65
65
  };
66
- function C(e) {
67
- return S.fetch ? new p(x, e) : new p(U, e);
66
+ function N(e) {
67
+ return x.fetch ? new p(T, e) : new p(C, e);
68
68
  }
69
- const s = C(), H = s.setConfig, k = s.head, P = s.get, B = s.post, D = s.del, F = s.put, G = s.patch;
69
+ const s = N(), k = s.setConfig, K = s.head, P = s.get, B = s.post, D = s.del, F = s.put, G = s.patch;
70
70
  export {
71
- C as NetRequest,
71
+ N as NetRequest,
72
72
  D as del,
73
73
  P as get,
74
- k as head,
74
+ K as head,
75
75
  G as patch,
76
76
  B as post,
77
77
  F as put,
78
- H as setGlobalConfig
78
+ k as setGlobalConfig
79
79
  };
@@ -1,15 +1,15 @@
1
- import { h as l, r as f, c as w, S as y, f as p } from "./retry-CaBI_Pfh.js";
2
- const x = async function(o, r, n) {
3
- return l(await f(E, o, r, n), o, r, n);
4
- }, E = async function(o, r, n) {
5
- const t = await w(o, r, n), s = new URL(t.url), i = t.params;
1
+ import { h as f, r as w, c as y, K as E, f as g, a as d } from "./type-CRH6iqXf.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
6
  i instanceof Object && Object.keys(i).forEach((e) => s.searchParams.set(e, i[e]));
7
- const a = y.AbortController ? new AbortController() : null;
7
+ const a = E.AbortController ? new AbortController() : null;
8
8
  function c() {
9
9
  a && !a.signal.aborted && a.abort();
10
10
  }
11
11
  t.abort && t.abort.addEventListener("abort", c);
12
- const d = t.timeout > 0 ? setTimeout(c, t.timeout) : null, b = t.method === "HEAD";
12
+ const h = t.timeout > 0 ? setTimeout(c, t.timeout) : null, l = t.method === "HEAD";
13
13
  return await fetch(s, {
14
14
  method: t.method,
15
15
  headers: Object.keys(t.headers).length > 0 ? new Headers(t.headers) : void 0,
@@ -18,34 +18,34 @@ const x = async function(o, r, n) {
18
18
  signal: a == null ? void 0 : a.signal,
19
19
  redirect: "follow"
20
20
  }).then(async (e) => {
21
- const u = b ? "" : await e.text().catch((m) => m), h = p([...e.headers.entries()]);
21
+ const u = l ? "" : await e.text().catch((m) => m), b = g([...e.headers.entries()]);
22
22
  return u instanceof Error ? {
23
23
  url: s.toString(),
24
24
  method: t.method,
25
25
  status: e.status,
26
- statusText: e.statusText || "Unknown",
26
+ statusText: e.statusText || d.Unknown,
27
27
  body: "",
28
- headers: h,
28
+ headers: b,
29
29
  rawError: u
30
30
  } : {
31
31
  url: s.toString(),
32
32
  method: t.method,
33
33
  status: e.status,
34
34
  statusText: e.statusText,
35
- headers: h,
35
+ headers: b,
36
36
  body: u
37
37
  };
38
38
  }).catch((e) => ({
39
39
  url: s.toString(),
40
40
  method: t.method,
41
41
  status: -1,
42
- statusText: a != null && a.signal.aborted ? "Aborted" : "Unknown",
42
+ statusText: a != null && a.signal.aborted ? d.Aborted : d.Unknown,
43
43
  body: "",
44
44
  rawError: e
45
45
  })).finally(() => {
46
- d !== null && clearTimeout(d), t.abort && t.abort.removeEventListener("abort", c);
46
+ h !== null && clearTimeout(h), t.abort && t.abort.removeEventListener("abort", c);
47
47
  });
48
48
  };
49
49
  export {
50
- x as f
50
+ T as f
51
51
  };
@@ -0,0 +1 @@
1
+ "use strict";const s=require("./type-CrucJEBR.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.Kt.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;