@seayoo-web/request 1.6.3 → 1.6.4

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("./version-Dd1gKjL_.cjs"),E=async function(n,a,t){const e=await s.convertOptions(n,a,t),r=new URL(e.url),l=e.params;l instanceof Object&&Object.keys(l).forEach(c=>r.searchParams.set(c,l[c]));const o=s.Support.AbortController?new AbortController:null;function i(){o&&!o.signal.aborted&&o.abort()}e.abort&&e.abort.addEventListener("abort",i);const b=e.timeout>0?setTimeout(i,e.timeout):null,p=new Request(r,{method:e.method,headers:new Headers(e.headers),body:e.body,credentials:e.credentials,signal:o==null?void 0:o.signal,redirect:"follow"});return await fetch(p).then(async c=>{const f=s.fromEntries(Object.entries(c.headers).map(([g,h])=>[g.toLowerCase(),Array.isArray(h)?h.join(","):h]));return{url:r.toString(),method:e.method,status:c.status,statusText:c.statusText,headers:f,body:e.method==="HEAD"?"":await c.text()}}).catch(c=>({url:r.toString(),method:e.method,status:-1,statusText:o!=null&&o.signal.aborted?"Aborted":"NetworkError",body:String(c)})).finally(()=>{b!==null&&clearTimeout(b),e.abort&&e.abort.removeEventListener("abort",i)})},m=async function(n,a,t){const e={...await s.convertOptions(n,a,t),onUploadProgress:t==null?void 0:t.onUploadProgress},r=e.method,l=e.onUploadProgress||s.Wt,o=s.Et(e.url,e.params);return await new Promise(i=>{let b=1;function p(w){b=w.total,l({total:w.total,loaded:w.loaded})}let c=null,f=!1;const g=function(){f||(d.abort(),f=!0)};function h(){c!==null&&clearTimeout(c),e.abort&&e.abort.removeEventListener("abort",g)}const d=new XMLHttpRequest;d.open(r,o,!0),d.upload.addEventListener("progress",p),d.addEventListener("load",()=>{h(),l({loaded:b,total:b}),i({url:o,method:r,status:d.status,statusText:d.statusText,headers:T(d),body:r==="HEAD"?"":d.responseText})}),d.addEventListener("error",()=>{h(),i({url:o,method:r,status:-1,statusText:"Failed",body:""})}),d.addEventListener("abort",()=>{h(),i({url:o,method:r,status:-1,statusText:"Aborted",body:""})}),Object.entries(e.headers).forEach(([w,R])=>{d.setRequestHeader(w,R)}),e.credentials==="include"&&(d.withCredentials=!0),d.send(e.body||void 0),e.abort&&e.abort.addEventListener("abort",g),e.timeout>0&&(c=setTimeout(g,e.timeout))})};function T(n){const a={};if(!n)return a;const t=n.getAllResponseHeaders();return t&&t!=="null"&&t.replace(/\r/g,"").split(`
2
- `).forEach(e=>{const r=e.trim();if(!r)return;const l=r.split(":"),o=l[0].trim();o&&(a[o]=(l[1]||"").trim())}),a}const q=async function(n,a,t){return s.handleResponse(await s.retryRequest(E,n,a,t),n,a,t)},H=async function(n,a,t){return s.handleResponse(await s.retryRequest(m,n,a,t),n,a,t)};async function S(n,a,t,e){const r=t==null?void 0:t.body,l=(t==null?void 0:t.method)==="PUT"?"PUT":"POST";if(a instanceof Blob){const c=new s.RequestGlobalConfig(e),f=await m(n,c,{...t,method:l,body:a});return s.handleResponse(f,n,c,t)}const o=new FormData,i={...a};r instanceof Object&&Object.entries(r).forEach(([c,f])=>{f instanceof Blob?i[c]=f:Array.isArray(f)?f.forEach((g,h)=>{o.append(`${c}[${h}]`,String(g))}):o.append(c,String(f))});for(const c in i)o.append(c,i[c]);const b=new s.RequestGlobalConfig(e),p=await m(n,b,{...t,method:l,body:o});return s.handleResponse(p,n,b,t)}async function x(n,a,t={}){const e=window;"callback"in t||(t.callback="jsonxData"+Math.random().toString(16).slice(2));const r=t.callback+"";if(!n)return null;const l=s.Et(n,t,!0);return new Promise(o=>{e[r]=function(i){if(r in window&&delete e[r],a(i))return i;console.warn("response type check faild",n,i),o(null)},s.he(l).catch(function(){o(null),delete e[r]})})}async function C(n,a,t={}){const e=window;return"var"in t||(t.var="jsonxData"+Math.random().toString(16).slice(2)),n?await s.he(s.Et(n,t,!0)).then(()=>{const r=e[t.var+""];return a(r)?r:(console.warn("response type check faild",n,r),null)}).catch(()=>null):null}const j=async function(n,a,t){return await S(n,a,t,{baseURL:u.getConfig("baseURL"),logHandler:u.getConfig("logHandler"),errorHandler:u.getConfig("errorHandler"),requestTransformer:u.getConfig("requestTransformer"),messageHandler:u.getConfig("messageHandler"),responseHandler:u.getConfig("responseHandler")})};function y(n){if(!s.Support.window)throw new Error("Default Module Only Support In Browser");return s.Support.fetch?new s.NetRequestHandler(q,n):new s.NetRequestHandler(H,n)}const u=y(),L=u.setConfig,v=u.head,U=u.get,A=u.post,O=u.del,P=u.put,D=u.patch;exports.getResponseRulesDescription=s.getResponseRulesDescription;exports.version=s.version;exports.NetRequest=y;exports.del=O;exports.get=U;exports.head=v;exports.jsonp=x;exports.jsonx=C;exports.patch=D;exports.post=A;exports.put=P;exports.setGlobalConfig=L;exports.upload=j;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("./version-DUfwEwFz.cjs"),E=async function(n,a,t){const e=await s.convertOptions(n,a,t),r=new URL(e.url),i=e.params;i instanceof Object&&Object.keys(i).forEach(c=>r.searchParams.set(c,i[c]));const o=s.Support.AbortController?new AbortController:null;function l(){o&&!o.signal.aborted&&o.abort()}e.abort&&e.abort.addEventListener("abort",l);const b=e.timeout>0?setTimeout(l,e.timeout):null,h=new Request(r,{method:e.method,headers:new Headers(e.headers),body:e.body,credentials:e.credentials,signal:o==null?void 0:o.signal,redirect:"follow"});return await fetch(h).then(async c=>({url:r.toString(),method:e.method,status:c.status,statusText:c.statusText,headers:s.fromEntries([...c.headers.entries()]),body:e.method==="HEAD"?"":await c.text()})).catch(c=>({url:r.toString(),method:e.method,status:-1,statusText:o!=null&&o.signal.aborted?"Aborted":"NetworkError",body:String(c)})).finally(()=>{b!==null&&clearTimeout(b),e.abort&&e.abort.removeEventListener("abort",l)})},m=async function(n,a,t){const e={...await s.convertOptions(n,a,t),onUploadProgress:t==null?void 0:t.onUploadProgress},r=e.method,i=e.onUploadProgress||s.Wt,o=s.Et(e.url,e.params);return await new Promise(l=>{let b=1;function h(w){b=w.total,i({total:w.total,loaded:w.loaded})}let c=null,f=!1;const g=function(){f||(d.abort(),f=!0)};function p(){c!==null&&clearTimeout(c),e.abort&&e.abort.removeEventListener("abort",g)}const d=new XMLHttpRequest;d.open(r,o,!0),d.upload.addEventListener("progress",h),d.addEventListener("load",()=>{p(),i({loaded:b,total:b}),l({url:o,method:r,status:d.status,statusText:d.statusText,headers:T(d),body:r==="HEAD"?"":d.responseText})}),d.addEventListener("error",()=>{p(),l({url:o,method:r,status:-1,statusText:"Failed",body:""})}),d.addEventListener("abort",()=>{p(),l({url:o,method:r,status:-1,statusText:"Aborted",body:""})}),Object.entries(e.headers).forEach(([w,R])=>{d.setRequestHeader(w,R)}),e.credentials==="include"&&(d.withCredentials=!0),d.send(e.body||void 0),e.abort&&e.abort.addEventListener("abort",g),e.timeout>0&&(c=setTimeout(g,e.timeout))})};function T(n){const a={};if(!n)return a;const t=n.getAllResponseHeaders();return t&&t!=="null"&&t.replace(/\r/g,"").split(`
2
+ `).forEach(e=>{const r=e.trim();if(!r)return;const i=r.split(":"),o=i[0].trim();o&&(a[o]=(i[1]||"").trim())}),a}const q=async function(n,a,t){return s.handleResponse(await s.retryRequest(E,n,a,t),n,a,t)},H=async function(n,a,t){return s.handleResponse(await s.retryRequest(m,n,a,t),n,a,t)};async function S(n,a,t,e){const r=t==null?void 0:t.body,i=(t==null?void 0:t.method)==="PUT"?"PUT":"POST";if(a instanceof Blob){const c=new s.RequestGlobalConfig(e),f=await m(n,c,{...t,method:i,body:a});return s.handleResponse(f,n,c,t)}const o=new FormData,l={...a};r instanceof Object&&Object.entries(r).forEach(([c,f])=>{f instanceof Blob?l[c]=f:Array.isArray(f)?f.forEach((g,p)=>{o.append(`${c}[${p}]`,String(g))}):o.append(c,String(f))});for(const c in l)o.append(c,l[c]);const b=new s.RequestGlobalConfig(e),h=await m(n,b,{...t,method:i,body:o});return s.handleResponse(h,n,b,t)}async function x(n,a,t={}){const e=window;"callback"in t||(t.callback="jsonxData"+Math.random().toString(16).slice(2));const r=t.callback+"";if(!n)return null;const i=s.Et(n,t,!0);return new Promise(o=>{e[r]=function(l){if(r in window&&delete e[r],a(l))return l;console.warn("response type check faild",n,l),o(null)},s.he(i).catch(function(){o(null),delete e[r]})})}async function v(n,a,t={}){const e=window;return"var"in t||(t.var="jsonxData"+Math.random().toString(16).slice(2)),n?await s.he(s.Et(n,t,!0)).then(()=>{const r=e[t.var+""];return a(r)?r:(console.warn("response type check faild",n,r),null)}).catch(()=>null):null}const C=async function(n,a,t){return await S(n,a,t,{baseURL:u.getConfig("baseURL"),logHandler:u.getConfig("logHandler"),errorHandler:u.getConfig("errorHandler"),requestTransformer:u.getConfig("requestTransformer"),messageHandler:u.getConfig("messageHandler"),responseHandler:u.getConfig("responseHandler")})};function y(n){if(!s.Support.window)throw new Error("Default Module Only Support In Browser");return s.Support.fetch?new s.NetRequestHandler(q,n):new s.NetRequestHandler(H,n)}const u=y(),L=u.setConfig,j=u.head,U=u.get,O=u.post,P=u.del,A=u.put,D=u.patch;exports.getResponseRulesDescription=s.getResponseRulesDescription;exports.version=s.version;exports.NetRequest=y;exports.del=P;exports.get=U;exports.head=j;exports.jsonp=x;exports.jsonx=v;exports.patch=D;exports.post=O;exports.put=A;exports.setGlobalConfig=L;exports.upload=C;
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
- import { c as H, S as y, f as C, E as R, W as S, h as w, r as x, R as E, a as q, N as T } from "./version-imlkbI1X.js";
2
- import { g as K, v as Q } from "./version-imlkbI1X.js";
1
+ import { c as H, S as y, f as S, E as R, W as C, h as w, r as x, R as E, a as q, N as T } from "./version-BYvDLPww.js";
2
+ import { g as K, v as Q } from "./version-BYvDLPww.js";
3
3
  const U = async function(n, o, e) {
4
4
  const t = await H(n, o, e), r = new URL(t.url), i = t.params;
5
5
  i instanceof Object && Object.keys(i).forEach((s) => r.searchParams.set(s, i[s]));
@@ -8,7 +8,7 @@ const U = async function(n, o, e) {
8
8
  a && !a.signal.aborted && a.abort();
9
9
  }
10
10
  t.abort && t.abort.addEventListener("abort", c);
11
- const f = t.timeout > 0 ? setTimeout(c, t.timeout) : null, g = new Request(r, {
11
+ const f = t.timeout > 0 ? setTimeout(c, t.timeout) : null, b = new Request(r, {
12
12
  method: t.method,
13
13
  headers: new Headers(t.headers),
14
14
  body: t.body,
@@ -16,19 +16,14 @@ const U = async function(n, o, e) {
16
16
  signal: a == null ? void 0 : a.signal,
17
17
  redirect: "follow"
18
18
  });
19
- return await fetch(g).then(async (s) => {
20
- const u = C(
21
- Object.entries(s.headers).map(([h, b]) => [h.toLowerCase(), Array.isArray(b) ? b.join(",") : b])
22
- );
23
- return {
24
- url: r.toString(),
25
- method: t.method,
26
- status: s.status,
27
- statusText: s.statusText,
28
- headers: u,
29
- body: t.method === "HEAD" ? "" : await s.text()
30
- };
31
- }).catch((s) => ({
19
+ return await fetch(b).then(async (s) => ({
20
+ url: r.toString(),
21
+ method: t.method,
22
+ status: s.status,
23
+ statusText: s.statusText,
24
+ headers: S([...s.headers.entries()]),
25
+ body: t.method === "HEAD" ? "" : await s.text()
26
+ })).catch((s) => ({
32
27
  url: r.toString(),
33
28
  method: t.method,
34
29
  status: -1,
@@ -41,31 +36,31 @@ const U = async function(n, o, e) {
41
36
  const t = {
42
37
  ...await H(n, o, e),
43
38
  onUploadProgress: e == null ? void 0 : e.onUploadProgress
44
- }, r = t.method, i = t.onUploadProgress || S, a = R(t.url, t.params);
39
+ }, r = t.method, i = t.onUploadProgress || C, a = R(t.url, t.params);
45
40
  return await new Promise((c) => {
46
41
  let f = 1;
47
- function g(m) {
42
+ function b(m) {
48
43
  f = m.total, i({ total: m.total, loaded: m.loaded });
49
44
  }
50
45
  let s = null, u = !1;
51
46
  const h = function() {
52
47
  u || (d.abort(), u = !0);
53
48
  };
54
- function b() {
49
+ function g() {
55
50
  s !== null && clearTimeout(s), t.abort && t.abort.removeEventListener("abort", h);
56
51
  }
57
52
  const d = new XMLHttpRequest();
58
- d.open(r, a, !0), d.upload.addEventListener("progress", g), d.addEventListener("load", () => {
59
- b(), i({ loaded: f, total: f }), c({
53
+ d.open(r, a, !0), d.upload.addEventListener("progress", b), d.addEventListener("load", () => {
54
+ g(), i({ loaded: f, total: f }), c({
60
55
  url: a,
61
56
  method: r,
62
57
  status: d.status,
63
58
  statusText: d.statusText,
64
- headers: j(d),
59
+ headers: v(d),
65
60
  body: r === "HEAD" ? "" : d.responseText
66
61
  });
67
62
  }), d.addEventListener("error", () => {
68
- b(), c({
63
+ g(), c({
69
64
  url: a,
70
65
  method: r,
71
66
  status: -1,
@@ -73,7 +68,7 @@ const U = async function(n, o, e) {
73
68
  body: ""
74
69
  });
75
70
  }), d.addEventListener("abort", () => {
76
- b(), c({
71
+ g(), c({
77
72
  url: a,
78
73
  method: r,
79
74
  status: -1,
@@ -85,7 +80,7 @@ const U = async function(n, o, e) {
85
80
  }), t.credentials === "include" && (d.withCredentials = !0), d.send(t.body || void 0), t.abort && t.abort.addEventListener("abort", h), t.timeout > 0 && (s = setTimeout(h, t.timeout));
86
81
  });
87
82
  };
88
- function j(n) {
83
+ function v(n) {
89
84
  const o = {};
90
85
  if (!n)
91
86
  return o;
@@ -99,12 +94,12 @@ function j(n) {
99
94
  a && (o[a] = (i[1] || "").trim());
100
95
  }), o;
101
96
  }
102
- const A = async function(n, o, e) {
97
+ const j = async function(n, o, e) {
103
98
  return w(await x(U, n, o, e), n, o, e);
104
- }, v = async function(n, o, e) {
99
+ }, A = async function(n, o, e) {
105
100
  return w(await x(p, n, o, e), n, o, e);
106
101
  };
107
- async function O(n, o, e, t) {
102
+ async function P(n, o, e, t) {
108
103
  const r = e == null ? void 0 : e.body, i = (e == null ? void 0 : e.method) === "PUT" ? "PUT" : "POST";
109
104
  if (o instanceof Blob) {
110
105
  const s = new E(t), u = await p(n, s, {
@@ -116,20 +111,20 @@ async function O(n, o, e, t) {
116
111
  }
117
112
  const a = new FormData(), c = { ...o };
118
113
  r instanceof Object && Object.entries(r).forEach(([s, u]) => {
119
- u instanceof Blob ? c[s] = u : Array.isArray(u) ? u.forEach((h, b) => {
120
- a.append(`${s}[${b}]`, String(h));
114
+ u instanceof Blob ? c[s] = u : Array.isArray(u) ? u.forEach((h, g) => {
115
+ a.append(`${s}[${g}]`, String(h));
121
116
  }) : a.append(s, String(u));
122
117
  });
123
118
  for (const s in c)
124
119
  a.append(s, c[s]);
125
- const f = new E(t), g = await p(n, f, {
120
+ const f = new E(t), b = await p(n, f, {
126
121
  ...e,
127
122
  method: i,
128
123
  body: a
129
124
  });
130
- return w(g, n, f, e);
125
+ return w(b, n, f, e);
131
126
  }
132
- async function D(n, o, e = {}) {
127
+ async function O(n, o, e = {}) {
133
128
  const t = window;
134
129
  "callback" in e || (e.callback = "jsonxData" + Math.random().toString(16).slice(2));
135
130
  const r = e.callback + "";
@@ -154,7 +149,7 @@ async function M(n, o, e = {}) {
154
149
  }).catch(() => null) : null;
155
150
  }
156
151
  const N = async function(n, o, e) {
157
- return await O(n, o, e, {
152
+ return await P(n, o, e, {
158
153
  baseURL: l.getConfig("baseURL"),
159
154
  logHandler: l.getConfig("logHandler"),
160
155
  errorHandler: l.getConfig("errorHandler"),
@@ -163,19 +158,19 @@ const N = async function(n, o, e) {
163
158
  responseHandler: l.getConfig("responseHandler")
164
159
  });
165
160
  };
166
- function P(n) {
161
+ function k(n) {
167
162
  if (!y.window)
168
163
  throw new Error("Default Module Only Support In Browser");
169
- return y.fetch ? new T(A, n) : new T(v, n);
164
+ return y.fetch ? new T(j, n) : new T(A, n);
170
165
  }
171
- const l = P(), F = l.setConfig, B = l.head, X = l.get, G = l.post, I = l.del, W = l.put, $ = l.patch;
166
+ const l = k(), F = l.setConfig, B = l.head, X = l.get, G = l.post, I = l.del, W = l.put, $ = l.patch;
172
167
  export {
173
- P as NetRequest,
168
+ k as NetRequest,
174
169
  I as del,
175
170
  X as get,
176
171
  K as getResponseRulesDescription,
177
172
  B as head,
178
- D as jsonp,
173
+ O as jsonp,
179
174
  M as jsonx,
180
175
  $ as patch,
181
176
  G as post,
package/dist/node.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const y=require("node:http"),q=require("node:https"),o=require("./version-Dd1gKjL_.cjs"),R=async function(n,u,c){return o.handleResponse(await o.retryRequest(w,n,u,c),n,u,c)},w=async function(n,u,c){const t=await o.convertOptions(n,u,c);if(!o.U(t.url))return{url:t.url,method:t.method,status:-1,statusText:"URLFormatError",headers:{},body:""};const f=/^https:\/\//i.test(t.url)?q:y,a=new URL(t.url),i=t.params;i instanceof Object&&Object.keys(i).forEach(r=>a.searchParams.set(r,i[r]));const b=t.method==="HEAD";return new Promise(r=>{const d=f.request(a,{headers:t.headers,method:t.method,timeout:t.timeout>0?t.timeout:void 0},function(e){const p=[];e.on("data",h=>p.push(h)),e.on("end",()=>{const h=o.fromEntries(Object.entries(e.headers).map(([g,m])=>[g.toLowerCase(),Array.isArray(m)?m.join(","):m]));r({url:a.toString(),method:t.method,status:e.statusCode||-1,statusText:e.statusMessage||"Unknown",headers:h,body:b?"":Buffer.concat(p).toString("utf-8")})})});d.on("error",e=>{r({url:a.toString(),method:t.method,status:-1,statusText:e.name||"Unknown",body:e.message})}),d.on("timeout",()=>{r({url:a.toString(),method:t.method,status:-1,statusText:"Timeout",body:""})}),t.body&&d.write(t.body),d.end()})};function l(n){return new o.NetRequestHandler(R,n)}const s=l(),S=s.setConfig,T=s.head,U=s.get,j=s.post,C=s.del,O=s.put,x=s.patch;exports.version=o.version;exports.NetRequest=l;exports.del=C;exports.get=U;exports.head=T;exports.patch=x;exports.post=j;exports.put=O;exports.setGlobalConfig=S;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const y=require("node:http"),q=require("node:https"),o=require("./version-DUfwEwFz.cjs"),R=async function(n,u,c){return o.handleResponse(await o.retryRequest(w,n,u,c),n,u,c)},w=async function(n,u,c){const t=await o.convertOptions(n,u,c);if(!o.U(t.url))return{url:t.url,method:t.method,status:-1,statusText:"URLFormatError",headers:{},body:""};const f=/^https:\/\//i.test(t.url)?q:y,a=new URL(t.url),i=t.params;i instanceof Object&&Object.keys(i).forEach(r=>a.searchParams.set(r,i[r]));const b=t.method==="HEAD";return new Promise(r=>{const d=f.request(a,{headers:t.headers,method:t.method,timeout:t.timeout>0?t.timeout:void 0},function(e){const p=[];e.on("data",h=>p.push(h)),e.on("end",()=>{const h=o.fromEntries(Object.entries(e.headers).map(([g,m])=>[g.toLowerCase(),Array.isArray(m)?m.join(","):m]));r({url:a.toString(),method:t.method,status:e.statusCode||-1,statusText:e.statusMessage||"Unknown",headers:h,body:b?"":Buffer.concat(p).toString("utf-8")})})});d.on("error",e=>{r({url:a.toString(),method:t.method,status:-1,statusText:e.name||"Unknown",body:e.message})}),d.on("timeout",()=>{r({url:a.toString(),method:t.method,status:-1,statusText:"Timeout",body:""})}),t.body&&d.write(t.body),d.end()})};function l(n){return new o.NetRequestHandler(R,n)}const s=l(),S=s.setConfig,T=s.head,U=s.get,j=s.post,C=s.del,O=s.put,x=s.patch;exports.version=o.version;exports.NetRequest=l;exports.del=C;exports.get=U;exports.head=T;exports.patch=x;exports.post=j;exports.put=O;exports.setGlobalConfig=S;
package/dist/node.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import l from "node:http";
2
2
  import y from "node:https";
3
- import { h as R, r as g, c as q, U as w, f as x, N as U } from "./version-imlkbI1X.js";
4
- import { v as G } from "./version-imlkbI1X.js";
3
+ import { h as R, r as g, c as q, U as w, f as x, N as U } from "./version-BYvDLPww.js";
4
+ import { v as G } from "./version-BYvDLPww.js";
5
5
  const T = async function(s, a, u) {
6
6
  return R(await g(j, s, a, u), s, a, u);
7
7
  }, j = async function(s, a, u) {
@@ -426,7 +426,7 @@ class ue {
426
426
  return a.method = "PATCH", a.body = n, this.guard(e, await this.exec(e, a), s || null);
427
427
  }
428
428
  }
429
- const le = "1.6.3";
429
+ const le = "1.6.4";
430
430
  export {
431
431
  oe as E,
432
432
  ue as N,
@@ -1,2 +1,2 @@
1
1
  "use strict";var B=Object.defineProperty;var H=(t,e,n)=>e in t?B(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var f=(t,e,n)=>(H(t,typeof e!="symbol"?e+"":e,n),n);const m=typeof globalThis<"u"?globalThis:typeof global<"u"?global:typeof window<"u"?window:{},b={fetch:"fetch"in m,window:"window"in m,FormData:"FormData"in m,Blob:"Blob"in m,wx:"wx"in m,TextDecoder:"TextDecoder"in m,AbortController:"AbortController"in m};function M(t){return t.reduce((e,[n,s])=>(n&&(e[n]=s||""),e),{})}async function P(t,e,n){var w;const s=Object.assign({method:"GET"},n),r=b.FormData?s.body instanceof FormData:!1,a=r&&s.method!=="POST"&&s.method!=="PUT"?"POST":s.method;(a==="GET"||a==="HEAD"||a==="DELETE")&&s.body!==void 0&&(console.warn("request body is invalid with method get, head, delete"),delete s.body);const o=Object.assign(r?{}:{"Content-Type":b.Blob&&s.body instanceof Blob?s.body.type||"application/octet-stream":"application/json;charset=utf-8"},s.headers),i=s.params||{},c={};Object.keys(i).forEach(h=>{i[h]!==void 0&&(c[h]=S(i[h]))});const d=e.getFullUrl(t),l=q(s.body),u=s.timeout||e.get("timeout"),g=await async function(){var F;const h=e.get("requestTransformer");return h?await h({headers:o,params:c,method:a,url:d,body:l}):await((F=e.get("requestHandler"))==null?void 0:F(o,c,a,t))}(),y=typeof g=="string"&&g?g:d;return(w=e.get("logHandler"))==null||w({type:"ready",url:y,method:a,headers:o,timeout:u,body:l}),{url:y,method:a,body:l,params:c,headers:o,timeout:u,abort:s.abort,credentials:s.credentials||e.get("credentials")}}function S(t){return typeof t=="string"?t:Array.isArray(t)?t.join(","):t+""}function q(t){if(t)return typeof t=="string"||t instanceof URLSearchParams||t instanceof ArrayBuffer||b.Blob&&t instanceof Blob||b.FormData&&t instanceof FormData?t:JSON.stringify(t)}function K(t){return new Promise(e=>setTimeout(e,Math.max(0,t)))}function D(){}function j(t,e){try{const n=JSON.parse(t);return e?e(n)?n:null:n}catch{return null}}""+Math.random().toString(32).slice(2);const I=/^(?:https?:)?\/\/.+$/i,N=/^https?:\/\/.+$/i,G=/^\{[\d\D]*\}$/,W=/^\[[\d\D]*\]$/;function R(t,e=!1){return e?I.test(t):N.test(t)}function J(t){return t==null}function C(t,...e){if(!t||typeof t!="object")return!1;const n=Object.getPrototypeOf(t);return n!==Object.prototype&&n!==null?!1:e.every(s=>s in t)}function A(t){return G.test(t)||W.test(t)}async function _(t){return await new Promise(function(e){const n=document.getElementsByTagName("head")[0],s=document.createElement("script");s.setAttribute("type","text/javascript"),s.setAttribute("charset","utf-8"),s.onload=function(){n.removeChild(s),e(!0)},s.onerror=function(){n.removeChild(s),e(!1)},s.setAttribute("src",t),n.appendChild(s)})}function V(t,e="数据未能正确识别"){return typeof t=="function"?{guard:t,message:e}:{guard:t.guard,message:t.message||e}}function O(t,e=""){return!e||R(t,!0)?T(t):(T(e)+"/"+t).replace(/\/{2,}/g,"/").replace(/:\//,"://")}function T(t){return R(t,!0)?t.startsWith("http")?t:("location"in globalThis?location.protocol:"https:")+t:("location"in globalThis?location.origin:"http://127.0.0.1")+"/"+t.replace(/^\/+/,"")}function z(t,e){if(e){if(e===!0)return t.replace(/\?[^#]*/,"")}else return t;const n=t.split("#"),s=n[0].split("?"),r=s[0],a=s.length>1?s[1]:"",o=n.length>1?"#"+n[1]:"",i=typeof e=="string"?[e]:Array.isArray(e)?e:[];return!i.length||!a?n[0]+o:(i.map(c=>c.replace(/([\\(){}[\]^$+\-*?|])/g,"\\$1")),(r+"?"+a.replace(new RegExp("(?:^|&)(?:"+i.join("|")+")=[^&$]+","g"),"").replace(/^&/,"")).replace(/\?$/,"")+o)}function Q(t,e,n=!1){const s=typeof e=="string"?e:Object.keys(e).map(o=>`${o}=${encodeURIComponent(e[o])}`).join("&");if(!s)return t;const r=t.split("#");n&&(r[0]=z(r[0],(s.match(/([^=&#?]+)=[^&#]+/g)||[]).map(o=>o.replace(/=.+$/,""))));const a=r[0].indexOf("?")+1?"&":"?";return(r[0]+a+s+(r.length>1?"#"+r[1]:"")).replace(/\?&/,"?")}const x="data",p="message";function X(t,e,n,s,r){const a=r||s;return v(t)?ae(a.ok||s.ok,t,e,n):Z(a.failed||s.failed,e,n)}const Y=function(t){const e=[],n=t.failed||{resolve:"json"};switch(e.push("- 当http状态码 <200 或者 >=400 时"),n.resolve){case"body":e.push(" 将响应内容格式化为字符串并作为错误消息");break;case"json":e.push(" 将响应解析为json,并读取 "+(n.messageField||p)+" 作为错误消息");break}const s=t.ok||{resolve:"body"};switch(e.push("- 当http状态码 >=200 并且 <400 时"),s.resolve){case"body":e.push(" 将响应尝试解析为 json,并作为数据内容返回");break;case"json":e.push(" 将响应解析为 json,读取 "+(s.dataField||x)+" 作为响应数据,读取 "+(s.messageField||p)+" 作为提示消息"),s.statusField&&e.push(" 当 "+s.statusField+" 为 "+(s.statusOKValue||"空值")+" 时是成功提示,否则是错误消息"),s.ignoreMessage&&e.push(" 并忽略以下消息:"+s.ignoreMessage);break}return e.join(`
2
- `)};function Z(t,e,n){const s=t||{resolve:"json",messageField:p},r={ok:!1,code:e,message:n,data:null};switch(s.resolve){case"body":r.message=E(n)||n;break;case"json":const{code:a,message:o}=ee(n,s.statusField,s.messageField);r.code=a||e,r.message=E(n)||o;break}return r}function ee(t,e,n=p){if(!A(t))return{message:""};const s=j(t);return!s||!C(s)?{message:t}:{code:e?$(s,e):"",message:$(s,n)||t}}function $(t,e){const n=Array.isArray(e)?e:[e];for(const s of n)if(s in t)return te(t[s]);return""}function te(t){return t?typeof t=="string"?t:JSON.stringify(t):""}const se=/<title>([^<]+)<\/title>/i,ne=/<message>([^<]+)<\/message>/i;function E(t){const e=t.match(se);if(e)return e[1];const n=t.match(ne);return n?n[1]:""}function ae(t,e,n,s){const r=t||{resolve:"body"},a={ok:!0,code:n,message:"",data:null};if(e===202||e===204||!s)return a;if(r.resolve==="body")return a.data=A(s)?j(s):s,a;const o=j(s);if(!o||!C(o))return a.ok=!1,a.code="ResponseFormatError",a.message="响应内容无法格式化为 Object",a;const i=r.statusField,c=r.statusOKValue||"",d=r.dataField||x,l=r.messageField||p,u=r.ignoreMessage||"";if(i&&!(i in o))return a.ok=!1,a.code="ResponseFieldMissing",a.message="响应内容找不到状态字段 "+i,a;const g=i?o[i]+"":"";return a.ok=i?g===c:!0,a.code=g||n,a.data=d===!0?o:d in o?o[d]:null,a.message=$(o,l),u&&a.message&&(Array.isArray(u)&&u.includes(a.message)||typeof u=="string"&&a.message===u)&&(a.message=""),a}function v(t){return t>=200&&t<400}async function U(t,e,n,s,r){const a=r||0,o=Math.max(0,Math.min(10,(s==null?void 0:s.maxRetry)??n.get("maxRetry")??0)),i=(s==null?void 0:s.retryResolve)??n.get("retryResolve"),c=n.get("logHandler")||D;c({type:"prepear",url:e,method:(s==null?void 0:s.method)||"GET",retry:a,maxRetry:o,message:a===0?"start":`retry ${a}/${o} start`,headers:s==null?void 0:s.headers,options:s});const d=Date.now(),l=await t(e,n,s),u=l.status,g=Date.now()-d,y=`[cost ${g}][${u}] ${u<0?l.body:""}`;c({type:"finished",url:e,method:l.method,retry:a,maxRetry:o,message:a===0?`finish ${y}`:`retry ${a}/${o} finish ${y}`,response:l,headers:l.headers,cost:g});const w=v(u);if(!o||i==="network"&&u>0||i==="status"&&w||Array.isArray(i)&&!i.includes(u)||typeof i=="function"&&i(l,a)!==!0||a>=o)return l;const h=(s==null?void 0:s.retryInterval)??n.get("retryInterval")??1e3;return await K(Math.max(100,h==="2EB"?Math.pow(2,a)*1e3:typeof h=="function"?h(a+1)||0:h)),await U(t,e,n,s,a+1)}function re(t,e,n,s){var o,i;if(t.status<0)return k({ok:!1,status:t.status,code:t.statusText,headers:{},message:"",data:null},`${t.method} ${e} ${t.statusText}`,t.method,e,n,s);v(t.status)||(o=n.get("errorHandler"))==null||o(t.status,t.method,e);const r={...X(t.status,t.statusText,t.body,n.get("responseRule"),s==null?void 0:s.responseRule),status:t.status,headers:M(Object.entries(t.headers||{}).map(([c,d])=>[c.toLowerCase(),d]))};(i=n.get("responseHandler"))==null||i({...r},t.method,e);const a=r.ok?r.message:`${t.method} ${e} [${r.code||t.statusText}] ${r.message||t.statusText}`;return k(r,a,t.method,e,n,s)}function k(t,e,n,s,r,a){const o=r.get("message"),i=o===!1||(a==null?void 0:a.message)===!1?!1:(a==null?void 0:a.message)||o;if(i!==!1){const c=typeof i=="function"?i(t,n,s,e):e;c instanceof Error?r.showMessage(!0,c.message):c&&typeof c=="object"&&"message"in c?r.showMessage(!1,c.message):r.showMessage(!t.ok,c)}return t}class L{constructor(e){f(this,"config",{baseURL:"",maxRetry:0,retryInterval:1e3,retryResolve:"network",timeout:5e3,cacheTTL:500,credentials:"same-origin",responseRule:{ok:{resolve:"body"},failed:{resolve:"json",messageField:"message"}}});e&&this.set(e)}set(e){if(e.baseURL&&!/^\/.+/.test(e.baseURL)&&!R(e.baseURL))throw console.warn("baseURL 需要以 / 开头,或者是完整的 url 地址"),new Error("BaseURLError");Object.assign(this.config,e)}get(e){return this.config[e]}getFullUrl(e){return e.startsWith("/")?O(e):O(e,this.config.baseURL)}showMessage(e,n){this.config.messageHandler&&n&&this.config.messageHandler(e,n)}}class oe{constructor(e=500){f(this,"ttl");f(this,"cache");this.cache={},this.ttl=Math.max(e,0)}getKey(e,n){const s=Object.keys(n||{}).sort().map(r=>`${r}#${n==null?void 0:n[r]}`);return e+s.join(",")}updateTTL(e){this.ttl=Math.max(e,0)}get(e){if(this.ttl===0)return null;const n=this.cache[e];return n?n.ttl<Date.now()?(delete this.cache[e],null):n.res:null}set(e,n){this.ttl!==0&&(this.cache[e]={ttl:Date.now()+this.ttl,res:n})}}function ie(t,e,n,s){if(e.ok&&!J(e.data)&&s){const r=V(s,"响应数据未能正确识别");return r.guard(e.data)||(console.error("ResponseCheckFaild",t,e.data),n.showMessage(!0,`${t} ${r.message}`),e.data=null),e}return e}class ce{constructor(e,n){f(this,"agent");f(this,"config");f(this,"cache");this.config=new L(n),this.agent=e,this.cache=new oe(this.config.get("cacheTTL")),this.setConfig=this.setConfig.bind(this),this.getConfig=this.getConfig.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)}async exec(e,n){return await this.agent(e,this.config,n)}async guard(e,n,s){return ie(e,n,this.config,s)}setConfig(e){this.config.set(e),this.cache.updateTTL(this.config.get("cacheTTL"))}getConfig(e){return this.config.get(e)}async head(e,n){const s=Object.assign({},n||null);return s.method="HEAD",this.guard(e,await this.exec(e,s),null)}async get(e,n,s){const r=Object.assign({},s||null);r.method="GET";const a=this.cache.getKey(e,r.params),o=this.cache.get(a);if(o)return this.guard(e,await o,n||null);const i=this.exec(e,r);return this.cache.set(a,i),this.guard(e,await i,n||null)}async post(e,n,s,r){const a=Object.assign({},r||null);return a.method="POST",a.body=n,this.guard(e,await this.exec(e,a),s||null)}async del(e,n,s){const r=Object.assign({},s||null);return r.method="DELETE",this.guard(e,await this.exec(e,r),n||null)}async put(e,n,s,r){const a=Object.assign({},r||null);return a.method="PUT",a.body=n,this.guard(e,await this.exec(e,a),s||null)}async patch(e,n,s,r){const a=Object.assign({},r||null);return a.method="PATCH",a.body=n,this.guard(e,await this.exec(e,a),s||null)}}const ue="1.6.3";exports.Et=Q;exports.NetRequestHandler=ce;exports.RequestGlobalConfig=L;exports.Support=b;exports.U=R;exports.Wt=D;exports.convertOptions=P;exports.fromEntries=M;exports.getResponseRulesDescription=Y;exports.handleResponse=re;exports.he=_;exports.retryRequest=U;exports.version=ue;
2
+ `)};function Z(t,e,n){const s=t||{resolve:"json",messageField:p},r={ok:!1,code:e,message:n,data:null};switch(s.resolve){case"body":r.message=E(n)||n;break;case"json":const{code:a,message:o}=ee(n,s.statusField,s.messageField);r.code=a||e,r.message=E(n)||o;break}return r}function ee(t,e,n=p){if(!A(t))return{message:""};const s=j(t);return!s||!C(s)?{message:t}:{code:e?$(s,e):"",message:$(s,n)||t}}function $(t,e){const n=Array.isArray(e)?e:[e];for(const s of n)if(s in t)return te(t[s]);return""}function te(t){return t?typeof t=="string"?t:JSON.stringify(t):""}const se=/<title>([^<]+)<\/title>/i,ne=/<message>([^<]+)<\/message>/i;function E(t){const e=t.match(se);if(e)return e[1];const n=t.match(ne);return n?n[1]:""}function ae(t,e,n,s){const r=t||{resolve:"body"},a={ok:!0,code:n,message:"",data:null};if(e===202||e===204||!s)return a;if(r.resolve==="body")return a.data=A(s)?j(s):s,a;const o=j(s);if(!o||!C(o))return a.ok=!1,a.code="ResponseFormatError",a.message="响应内容无法格式化为 Object",a;const i=r.statusField,c=r.statusOKValue||"",d=r.dataField||x,l=r.messageField||p,u=r.ignoreMessage||"";if(i&&!(i in o))return a.ok=!1,a.code="ResponseFieldMissing",a.message="响应内容找不到状态字段 "+i,a;const g=i?o[i]+"":"";return a.ok=i?g===c:!0,a.code=g||n,a.data=d===!0?o:d in o?o[d]:null,a.message=$(o,l),u&&a.message&&(Array.isArray(u)&&u.includes(a.message)||typeof u=="string"&&a.message===u)&&(a.message=""),a}function v(t){return t>=200&&t<400}async function U(t,e,n,s,r){const a=r||0,o=Math.max(0,Math.min(10,(s==null?void 0:s.maxRetry)??n.get("maxRetry")??0)),i=(s==null?void 0:s.retryResolve)??n.get("retryResolve"),c=n.get("logHandler")||D;c({type:"prepear",url:e,method:(s==null?void 0:s.method)||"GET",retry:a,maxRetry:o,message:a===0?"start":`retry ${a}/${o} start`,headers:s==null?void 0:s.headers,options:s});const d=Date.now(),l=await t(e,n,s),u=l.status,g=Date.now()-d,y=`[cost ${g}][${u}] ${u<0?l.body:""}`;c({type:"finished",url:e,method:l.method,retry:a,maxRetry:o,message:a===0?`finish ${y}`:`retry ${a}/${o} finish ${y}`,response:l,headers:l.headers,cost:g});const w=v(u);if(!o||i==="network"&&u>0||i==="status"&&w||Array.isArray(i)&&!i.includes(u)||typeof i=="function"&&i(l,a)!==!0||a>=o)return l;const h=(s==null?void 0:s.retryInterval)??n.get("retryInterval")??1e3;return await K(Math.max(100,h==="2EB"?Math.pow(2,a)*1e3:typeof h=="function"?h(a+1)||0:h)),await U(t,e,n,s,a+1)}function re(t,e,n,s){var o,i;if(t.status<0)return k({ok:!1,status:t.status,code:t.statusText,headers:{},message:"",data:null},`${t.method} ${e} ${t.statusText}`,t.method,e,n,s);v(t.status)||(o=n.get("errorHandler"))==null||o(t.status,t.method,e);const r={...X(t.status,t.statusText,t.body,n.get("responseRule"),s==null?void 0:s.responseRule),status:t.status,headers:M(Object.entries(t.headers||{}).map(([c,d])=>[c.toLowerCase(),d]))};(i=n.get("responseHandler"))==null||i({...r},t.method,e);const a=r.ok?r.message:`${t.method} ${e} [${r.code||t.statusText}] ${r.message||t.statusText}`;return k(r,a,t.method,e,n,s)}function k(t,e,n,s,r,a){const o=r.get("message"),i=o===!1||(a==null?void 0:a.message)===!1?!1:(a==null?void 0:a.message)||o;if(i!==!1){const c=typeof i=="function"?i(t,n,s,e):e;c instanceof Error?r.showMessage(!0,c.message):c&&typeof c=="object"&&"message"in c?r.showMessage(!1,c.message):r.showMessage(!t.ok,c)}return t}class L{constructor(e){f(this,"config",{baseURL:"",maxRetry:0,retryInterval:1e3,retryResolve:"network",timeout:5e3,cacheTTL:500,credentials:"same-origin",responseRule:{ok:{resolve:"body"},failed:{resolve:"json",messageField:"message"}}});e&&this.set(e)}set(e){if(e.baseURL&&!/^\/.+/.test(e.baseURL)&&!R(e.baseURL))throw console.warn("baseURL 需要以 / 开头,或者是完整的 url 地址"),new Error("BaseURLError");Object.assign(this.config,e)}get(e){return this.config[e]}getFullUrl(e){return e.startsWith("/")?O(e):O(e,this.config.baseURL)}showMessage(e,n){this.config.messageHandler&&n&&this.config.messageHandler(e,n)}}class oe{constructor(e=500){f(this,"ttl");f(this,"cache");this.cache={},this.ttl=Math.max(e,0)}getKey(e,n){const s=Object.keys(n||{}).sort().map(r=>`${r}#${n==null?void 0:n[r]}`);return e+s.join(",")}updateTTL(e){this.ttl=Math.max(e,0)}get(e){if(this.ttl===0)return null;const n=this.cache[e];return n?n.ttl<Date.now()?(delete this.cache[e],null):n.res:null}set(e,n){this.ttl!==0&&(this.cache[e]={ttl:Date.now()+this.ttl,res:n})}}function ie(t,e,n,s){if(e.ok&&!J(e.data)&&s){const r=V(s,"响应数据未能正确识别");return r.guard(e.data)||(console.error("ResponseCheckFaild",t,e.data),n.showMessage(!0,`${t} ${r.message}`),e.data=null),e}return e}class ce{constructor(e,n){f(this,"agent");f(this,"config");f(this,"cache");this.config=new L(n),this.agent=e,this.cache=new oe(this.config.get("cacheTTL")),this.setConfig=this.setConfig.bind(this),this.getConfig=this.getConfig.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)}async exec(e,n){return await this.agent(e,this.config,n)}async guard(e,n,s){return ie(e,n,this.config,s)}setConfig(e){this.config.set(e),this.cache.updateTTL(this.config.get("cacheTTL"))}getConfig(e){return this.config.get(e)}async head(e,n){const s=Object.assign({},n||null);return s.method="HEAD",this.guard(e,await this.exec(e,s),null)}async get(e,n,s){const r=Object.assign({},s||null);r.method="GET";const a=this.cache.getKey(e,r.params),o=this.cache.get(a);if(o)return this.guard(e,await o,n||null);const i=this.exec(e,r);return this.cache.set(a,i),this.guard(e,await i,n||null)}async post(e,n,s,r){const a=Object.assign({},r||null);return a.method="POST",a.body=n,this.guard(e,await this.exec(e,a),s||null)}async del(e,n,s){const r=Object.assign({},s||null);return r.method="DELETE",this.guard(e,await this.exec(e,r),n||null)}async put(e,n,s,r){const a=Object.assign({},r||null);return a.method="PUT",a.body=n,this.guard(e,await this.exec(e,a),s||null)}async patch(e,n,s,r){const a=Object.assign({},r||null);return a.method="PATCH",a.body=n,this.guard(e,await this.exec(e,a),s||null)}}const ue="1.6.4";exports.Et=Q;exports.NetRequestHandler=ce;exports.RequestGlobalConfig=L;exports.Support=b;exports.U=R;exports.Wt=D;exports.convertOptions=P;exports.fromEntries=M;exports.getResponseRulesDescription=Y;exports.handleResponse=re;exports.he=_;exports.retryRequest=U;exports.version=ue;
package/dist/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const version = "1.6.3";
1
+ export declare const version = "1.6.4";
package/dist/wx.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./version-Dd1gKjL_.cjs"),p=async function(t,r,n){return e.handleResponse(await e.retryRequest(l,t,r,n),t,r,n)},l=async function(t,r,n){const o=await e.convertOptions(t,r,n),u=o.method==="PATCH"?"POST":o.method,a=e.Et(o.url,o.params);return e.Support.wx?new Promise(d=>{wx.request({url:a,data:o.body,header:o.headers,method:u,dataType:"string",responseType:"text",fail(){d({url:a,method:u,status:-1,statusText:"NetworkError",body:""})},success(c){d({url:a,method:u,status:c.statusCode,statusText:c.statusCode+"",headers:{...c.header},body:o.method==="HEAD"?"":f(c.data)})}})}):{url:a,method:u,status:-1,statusText:"NotSupport",body:"NotFound namespace of wx"}};function f(t){return typeof t=="string"?t:t instanceof ArrayBuffer&&e.Support.TextDecoder?new TextDecoder().decode(t):JSON.stringify(t)}function i(t){return new e.NetRequestHandler(p,t)}const s=i(),y=s.setConfig,g=s.head,h=s.get,x=s.post,w=s.del,T=s.put;exports.version=e.version;exports.NetRequest=i;exports.del=w;exports.get=h;exports.head=g;exports.post=x;exports.put=T;exports.setGlobalConfig=y;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./version-DUfwEwFz.cjs"),p=async function(t,r,n){return e.handleResponse(await e.retryRequest(l,t,r,n),t,r,n)},l=async function(t,r,n){const o=await e.convertOptions(t,r,n),u=o.method==="PATCH"?"POST":o.method,a=e.Et(o.url,o.params);return e.Support.wx?new Promise(d=>{wx.request({url:a,data:o.body,header:o.headers,method:u,dataType:"string",responseType:"text",fail(){d({url:a,method:u,status:-1,statusText:"NetworkError",body:""})},success(c){d({url:a,method:u,status:c.statusCode,statusText:c.statusCode+"",headers:{...c.header},body:o.method==="HEAD"?"":f(c.data)})}})}):{url:a,method:u,status:-1,statusText:"NotSupport",body:"NotFound namespace of wx"}};function f(t){return typeof t=="string"?t:t instanceof ArrayBuffer&&e.Support.TextDecoder?new TextDecoder().decode(t):JSON.stringify(t)}function i(t){return new e.NetRequestHandler(p,t)}const s=i(),y=s.setConfig,g=s.head,h=s.get,x=s.post,w=s.del,T=s.put;exports.version=e.version;exports.NetRequest=i;exports.del=w;exports.get=h;exports.head=g;exports.post=x;exports.put=T;exports.setGlobalConfig=y;
package/dist/wx.js CHANGED
@@ -1,5 +1,5 @@
1
- import { h as i, r as p, c as f, E as l, S as d, N as x } from "./version-imlkbI1X.js";
2
- import { v as A } from "./version-imlkbI1X.js";
1
+ import { h as i, r as p, c as f, E as l, S as d, N as x } from "./version-BYvDLPww.js";
2
+ import { v as A } from "./version-BYvDLPww.js";
3
3
  const h = async function(t, o, r) {
4
4
  return i(await p(y, t, o, r), t, o, r);
5
5
  }, y = async function(t, o, r) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@seayoo-web/request",
3
- "version": "1.6.3",
3
+ "version": "1.6.4",
4
4
  "description": "requst tools for seayoo web",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",