@seayoo-web/request 3.3.3 → 3.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +53 -53
- package/dist/node.js +17 -17
- package/dist/{request.fetch-CHbeHmeX.js → request.fetch-B3ED8nRu.js} +6 -6
- package/dist/retry-CdUkYrFw.js +606 -0
- package/dist/wx.js +23 -23
- package/package.json +2 -6
- package/dist/index.cjs +0 -2
- package/dist/node.cjs +0 -1
- package/dist/request.fetch-Ce3_4Yuj.cjs +0 -1
- package/dist/retry-BXoyQlSJ.js +0 -1191
- package/dist/retry-D_7OkloZ.cjs +0 -3
- package/dist/wx.cjs +0 -1
package/dist/index.js
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import { h as m, r as
|
|
2
|
-
import { g as
|
|
3
|
-
import { f as
|
|
4
|
-
const
|
|
5
|
-
return m(await
|
|
1
|
+
import { h as m, r as q, R as T, c as x, W as R, a as w, P as H, V as C, N as E, Q as L } from "./retry-CdUkYrFw.js";
|
|
2
|
+
import { g as z } from "./retry-CdUkYrFw.js";
|
|
3
|
+
import { f as k } from "./request.fetch-B3ED8nRu.js";
|
|
4
|
+
const P = async function(e, o, t) {
|
|
5
|
+
return m(await q(y, e, o, t), e, o, t);
|
|
6
6
|
};
|
|
7
|
-
async function
|
|
8
|
-
const r =
|
|
7
|
+
async function S(e, o, t, n) {
|
|
8
|
+
const r = t?.body, l = t?.method === "PUT" ? "PUT" : "POST";
|
|
9
9
|
if (o instanceof Blob) {
|
|
10
|
-
const i = new T(n), u = await y(
|
|
11
|
-
...
|
|
10
|
+
const i = new T(n), u = await y(e, i, {
|
|
11
|
+
...t,
|
|
12
12
|
method: l,
|
|
13
13
|
body: o
|
|
14
14
|
});
|
|
15
|
-
return m(u,
|
|
15
|
+
return m(u, e, i, t);
|
|
16
16
|
}
|
|
17
17
|
const a = new FormData(), d = { ...o };
|
|
18
18
|
r instanceof Object && Object.entries(r).forEach(([i, u]) => {
|
|
@@ -22,19 +22,19 @@ async function k(t, o, e, n) {
|
|
|
22
22
|
});
|
|
23
23
|
for (const i in d)
|
|
24
24
|
a.append(i, d[i]);
|
|
25
|
-
const b = new T(n),
|
|
26
|
-
...
|
|
25
|
+
const b = new T(n), p = await y(e, b, {
|
|
26
|
+
...t,
|
|
27
27
|
method: l,
|
|
28
28
|
body: a
|
|
29
29
|
});
|
|
30
|
-
return m(
|
|
30
|
+
return m(p, e, b, t);
|
|
31
31
|
}
|
|
32
|
-
const y = async function(
|
|
33
|
-
const n = await
|
|
32
|
+
const y = async function(e, o, t) {
|
|
33
|
+
const n = await x(e, o, t), r = n.method, l = t?.onUploadProgress, a = R(n.url, n.params);
|
|
34
34
|
return await new Promise((d) => {
|
|
35
|
-
let b = null,
|
|
35
|
+
let b = null, p = !1;
|
|
36
36
|
const i = function() {
|
|
37
|
-
|
|
37
|
+
p || (s.abort(), p = !0);
|
|
38
38
|
};
|
|
39
39
|
function u() {
|
|
40
40
|
b !== null && clearTimeout(b), n.abort && n.abort.removeEventListener("abort", i);
|
|
@@ -43,8 +43,8 @@ const y = async function(t, o, e) {
|
|
|
43
43
|
let g = !1;
|
|
44
44
|
if (s.open(r, a, !0), l) {
|
|
45
45
|
let f = 1;
|
|
46
|
-
s.upload.addEventListener("progress", (
|
|
47
|
-
f =
|
|
46
|
+
s.upload.addEventListener("progress", (h) => {
|
|
47
|
+
f = h.total, l({ total: h.total, loaded: h.loaded });
|
|
48
48
|
}), s.addEventListener("load", () => {
|
|
49
49
|
l({ loaded: f, total: f });
|
|
50
50
|
});
|
|
@@ -81,19 +81,19 @@ const y = async function(t, o, e) {
|
|
|
81
81
|
statusText: g ? w.Timeout : w.Aborted,
|
|
82
82
|
body: ""
|
|
83
83
|
});
|
|
84
|
-
}), Object.entries(n.headers).forEach(([f,
|
|
85
|
-
s.setRequestHeader(f,
|
|
84
|
+
}), Object.entries(n.headers).forEach(([f, h]) => {
|
|
85
|
+
s.setRequestHeader(f, h);
|
|
86
86
|
}), n.credentials === "include" && (s.withCredentials = !0), s.send(n.body || void 0), n.abort && n.abort.addEventListener("abort", i), n.timeout > 0 && (b = setTimeout(function() {
|
|
87
87
|
g = !0, i();
|
|
88
88
|
}, n.timeout));
|
|
89
89
|
});
|
|
90
90
|
};
|
|
91
|
-
function U(
|
|
91
|
+
function U(e) {
|
|
92
92
|
const o = {};
|
|
93
|
-
if (!
|
|
93
|
+
if (!e)
|
|
94
94
|
return o;
|
|
95
|
-
const
|
|
96
|
-
return
|
|
95
|
+
const t = e.getAllResponseHeaders();
|
|
96
|
+
return t && t !== "null" && t.replace(/\r/g, "").split(`
|
|
97
97
|
`).forEach((n) => {
|
|
98
98
|
const r = n.trim();
|
|
99
99
|
if (!r)
|
|
@@ -102,32 +102,32 @@ function U(t) {
|
|
|
102
102
|
a && (o[a] = (l[1] || "").trim());
|
|
103
103
|
}), o;
|
|
104
104
|
}
|
|
105
|
-
async function O(
|
|
105
|
+
async function O(e, o, t = {}) {
|
|
106
106
|
const n = window;
|
|
107
|
-
"callback" in
|
|
108
|
-
const r =
|
|
109
|
-
if (!
|
|
107
|
+
"callback" in t || (t.callback = "jsonxData" + Math.random().toString(16).slice(2));
|
|
108
|
+
const r = t.callback + "";
|
|
109
|
+
if (!e)
|
|
110
110
|
return null;
|
|
111
|
-
const l = R(
|
|
111
|
+
const l = R(e, t, !0);
|
|
112
112
|
return new Promise((a) => {
|
|
113
113
|
n[r] = function(d) {
|
|
114
114
|
if (r in window && delete n[r], o(d))
|
|
115
115
|
return d;
|
|
116
|
-
console.warn("response type check failed",
|
|
117
|
-
},
|
|
116
|
+
console.warn("response type check failed", e, d), a(null);
|
|
117
|
+
}, H(l).catch(function() {
|
|
118
118
|
a(null), delete n[r];
|
|
119
119
|
});
|
|
120
120
|
});
|
|
121
121
|
}
|
|
122
|
-
async function
|
|
122
|
+
async function A(e, o, t = {}) {
|
|
123
123
|
const n = window;
|
|
124
|
-
return "var" in
|
|
125
|
-
const r = n[
|
|
126
|
-
return o(r) ? r : (console.warn("response type check failed",
|
|
124
|
+
return "var" in t || (t.var = "jsonxData" + Math.random().toString(16).slice(2)), e ? await H(R(e, t, !0)).then(() => {
|
|
125
|
+
const r = n[t.var + ""];
|
|
126
|
+
return o(r) ? r : (console.warn("response type check failed", e, r), null);
|
|
127
127
|
}).catch(() => null) : null;
|
|
128
128
|
}
|
|
129
|
-
const
|
|
130
|
-
return await
|
|
129
|
+
const M = async function(e, o, t) {
|
|
130
|
+
return await S(e, o, t, {
|
|
131
131
|
baseURL: c.getConfig("baseURL"),
|
|
132
132
|
logHandler: c.getConfig("logHandler"),
|
|
133
133
|
errorHandler: c.getConfig("errorHandler"),
|
|
@@ -136,25 +136,25 @@ const A = async function(t, o, e) {
|
|
|
136
136
|
responseHandler: c.getConfig("responseHandler")
|
|
137
137
|
});
|
|
138
138
|
};
|
|
139
|
-
function j(
|
|
140
|
-
if (!
|
|
139
|
+
function j(e) {
|
|
140
|
+
if (!C())
|
|
141
141
|
throw new Error("Default Module Only Support In Browser");
|
|
142
|
-
return
|
|
142
|
+
return L() ? new E(k, e) : new E(P, e);
|
|
143
143
|
}
|
|
144
|
-
const c = j(),
|
|
144
|
+
const c = j(), N = c.setConfig, B = c.request, X = c.head, F = c.get, G = c.post, I = c.del, Q = c.put, V = c.patch;
|
|
145
145
|
export {
|
|
146
146
|
j as NetRequest,
|
|
147
147
|
w as RequestInternalError,
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
148
|
+
I as del,
|
|
149
|
+
F as get,
|
|
150
|
+
z as getResponseRulesDescription,
|
|
151
|
+
X as head,
|
|
152
152
|
O as jsonp,
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
153
|
+
A as jsonx,
|
|
154
|
+
V as patch,
|
|
155
|
+
G as post,
|
|
156
|
+
Q as put,
|
|
157
|
+
B as request,
|
|
158
|
+
N as setGlobalConfig,
|
|
159
|
+
M as upload
|
|
160
160
|
};
|
package/dist/node.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { h as b, r as q, c as w,
|
|
2
|
-
import { g as
|
|
3
|
-
import { f as
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
const
|
|
7
|
-
return b(await q(
|
|
8
|
-
},
|
|
1
|
+
import { h as b, r as q, c as w, e as g, a as d, f as E, N as f, Q as x } from "./retry-CdUkYrFw.js";
|
|
2
|
+
import { g as z } from "./retry-CdUkYrFw.js";
|
|
3
|
+
import { f as C } from "./request.fetch-B3ED8nRu.js";
|
|
4
|
+
import N from "node:http";
|
|
5
|
+
import T from "node:https";
|
|
6
|
+
const j = async function(o, a, u) {
|
|
7
|
+
return b(await q(L, o, a, u), o, a, u);
|
|
8
|
+
}, L = async function(o, a, u) {
|
|
9
9
|
const t = await w(o, a, u);
|
|
10
10
|
if (!g(t.url))
|
|
11
11
|
return {
|
|
@@ -16,7 +16,7 @@ const N = async function(o, a, u) {
|
|
|
16
16
|
headers: {},
|
|
17
17
|
body: ""
|
|
18
18
|
};
|
|
19
|
-
const R = /^https:\/\//i.test(t.url) ?
|
|
19
|
+
const R = /^https:\/\//i.test(t.url) ? T : N, n = new URL(t.url), i = t.params;
|
|
20
20
|
i instanceof Object && Object.keys(i).forEach((r) => n.searchParams.set(r, i[r]));
|
|
21
21
|
const l = t.method === "HEAD";
|
|
22
22
|
return new Promise((r) => {
|
|
@@ -64,19 +64,19 @@ const N = async function(o, a, u) {
|
|
|
64
64
|
}), t.body && c.write(t.body), c.end();
|
|
65
65
|
});
|
|
66
66
|
};
|
|
67
|
-
function
|
|
68
|
-
return x
|
|
67
|
+
function O(o) {
|
|
68
|
+
return x() ? new f(C, o) : new f(j, o);
|
|
69
69
|
}
|
|
70
|
-
const s =
|
|
70
|
+
const s = O(), k = s.setConfig, B = s.head, D = s.get, P = s.post, Q = s.del, F = s.put, G = s.patch;
|
|
71
71
|
export {
|
|
72
|
-
|
|
72
|
+
O as NetRequest,
|
|
73
73
|
d as RequestInternalError,
|
|
74
|
-
|
|
74
|
+
Q as del,
|
|
75
75
|
D as get,
|
|
76
|
-
|
|
76
|
+
z as getResponseRulesDescription,
|
|
77
77
|
B as head,
|
|
78
|
-
|
|
78
|
+
G as patch,
|
|
79
79
|
P as post,
|
|
80
|
-
|
|
80
|
+
F as put,
|
|
81
81
|
k as setGlobalConfig
|
|
82
82
|
};
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import { h as w, r as y, c as E,
|
|
1
|
+
import { h as w, r as y, c as E, o as T, f as R, a as c } from "./retry-CdUkYrFw.js";
|
|
2
2
|
const x = async function(a, s, n) {
|
|
3
3
|
return w(await y(g, a, s, n), a, s, n);
|
|
4
4
|
}, g = async function(a, s, n) {
|
|
5
5
|
const t = await E(a, s, n), i = new URL(t.url), u = t.params;
|
|
6
6
|
u instanceof Object && Object.keys(u).forEach((e) => i.searchParams.set(e, u[e]));
|
|
7
|
-
const r = T
|
|
7
|
+
const r = T() ? new AbortController() : null;
|
|
8
8
|
function d() {
|
|
9
9
|
r && !r.signal.aborted && r.abort();
|
|
10
10
|
}
|
|
11
11
|
t.abort && t.abort.addEventListener("abort", d);
|
|
12
12
|
let l = !1;
|
|
13
|
-
const
|
|
13
|
+
const b = t.timeout > 0 ? setTimeout(function() {
|
|
14
14
|
l = !0, d();
|
|
15
15
|
}, t.timeout) : null, f = t.method === "HEAD";
|
|
16
16
|
return await fetch(i, {
|
|
@@ -27,8 +27,8 @@ const x = async function(a, s, n) {
|
|
|
27
27
|
status: e.status,
|
|
28
28
|
statusText: e.statusText,
|
|
29
29
|
headers: R([...e.headers.entries()])
|
|
30
|
-
},
|
|
31
|
-
return
|
|
30
|
+
}, h = f || e.status === 204 ? "" : await e.text().catch((m) => m);
|
|
31
|
+
return h instanceof Error ? { ...o, body: "", statusText: c.Unknown, rawError: h } : { ...o, body: h };
|
|
32
32
|
}).catch((e) => {
|
|
33
33
|
const o = r?.signal.aborted;
|
|
34
34
|
return {
|
|
@@ -41,7 +41,7 @@ const x = async function(a, s, n) {
|
|
|
41
41
|
rawError: e
|
|
42
42
|
};
|
|
43
43
|
}).finally(() => {
|
|
44
|
-
|
|
44
|
+
b !== null && clearTimeout(b), t.abort && t.abort.removeEventListener("abort", d);
|
|
45
45
|
});
|
|
46
46
|
};
|
|
47
47
|
export {
|