@seayoo-web/request 3.4.5 → 3.5.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/README.md +4 -4
- package/dist/index.js +19 -19
- package/dist/node.js +7 -7
- package/dist/{request.fetch-6HUu6_l5.js → request.fetch-U_igg1Ax.js} +1 -1
- package/dist/retry-DodVI8cA.js +627 -0
- package/dist/wx.js +7 -7
- package/package.json +2 -2
- package/types/inc/type.d.ts +16 -4
- package/types/inc/utils.d.ts +5 -2
- package/dist/retry-BjOxSyvC.js +0 -614
package/README.md
CHANGED
|
@@ -226,13 +226,13 @@ defaultMessage: string
|
|
|
226
226
|
|
|
227
227
|
### retryResolve
|
|
228
228
|
|
|
229
|
-
类型:"
|
|
229
|
+
类型:"default" | "network" | number[] | ((result: IRequestBaseResponse, count: number) => boolean)
|
|
230
230
|
|
|
231
|
-
说明:重试判断方法,默认是
|
|
231
|
+
说明:重试判断方法,默认是 default
|
|
232
232
|
|
|
233
|
-
network
|
|
233
|
+
default 在 network 基础之上,如果是 Tencent EO 响应的 552/522 错误码,则重试;
|
|
234
234
|
|
|
235
|
-
|
|
235
|
+
network 表示仅仅当网络错误时才重试,如果请求被取消或超时(aborted/timeout)则不重试;
|
|
236
236
|
|
|
237
237
|
当设置为 number[] 时,将检查 http 状态码,匹配则重试;
|
|
238
238
|
|
package/dist/index.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { h as m, r as q, R as T, c as x,
|
|
2
|
-
import { g as
|
|
3
|
-
import { f as
|
|
4
|
-
const
|
|
1
|
+
import { h as m, r as q, R as T, c as x, H as R, a as w, v as E, b as C, N as H, X as L } from "./retry-DodVI8cA.js";
|
|
2
|
+
import { g as Q } from "./retry-DodVI8cA.js";
|
|
3
|
+
import { f as v } from "./request.fetch-U_igg1Ax.js";
|
|
4
|
+
const j = async function(t, s, e) {
|
|
5
5
|
return m(await q(y, t, s, e), t, s, e);
|
|
6
6
|
};
|
|
7
|
-
async function
|
|
7
|
+
async function k(t, s, e, n) {
|
|
8
8
|
const r = e?.body, l = e?.method === "PUT" ? "PUT" : "POST";
|
|
9
9
|
if (s instanceof Blob) {
|
|
10
10
|
const i = new T(n), u = await y(t, i, {
|
|
@@ -56,7 +56,7 @@ const y = async function(t, s, e) {
|
|
|
56
56
|
method: r,
|
|
57
57
|
status: f,
|
|
58
58
|
statusText: o.statusText,
|
|
59
|
-
headers:
|
|
59
|
+
headers: S(o),
|
|
60
60
|
body: r === "HEAD" || f === 204 ? "" : p === "" || p === "text" || p === "json" || p === "document" ? o.responseText : ""
|
|
61
61
|
});
|
|
62
62
|
}), o.addEventListener(
|
|
@@ -88,7 +88,7 @@ const y = async function(t, s, e) {
|
|
|
88
88
|
}, n.timeout));
|
|
89
89
|
});
|
|
90
90
|
};
|
|
91
|
-
function
|
|
91
|
+
function S(t) {
|
|
92
92
|
const s = {};
|
|
93
93
|
if (!t)
|
|
94
94
|
return s;
|
|
@@ -114,20 +114,20 @@ async function P(t, s, e = {}) {
|
|
|
114
114
|
if (r in window && delete n[r], s(d))
|
|
115
115
|
return d;
|
|
116
116
|
console.warn("response type check failed", t, d), a(null);
|
|
117
|
-
},
|
|
117
|
+
}, E(l).catch(function() {
|
|
118
118
|
a(null), delete n[r];
|
|
119
119
|
});
|
|
120
120
|
});
|
|
121
121
|
}
|
|
122
122
|
async function A(t, s, e = {}) {
|
|
123
123
|
const n = window;
|
|
124
|
-
return "var" in e || (e.var = "jsonxData" + Math.random().toString(16).slice(2)), t ? await
|
|
124
|
+
return "var" in e || (e.var = "jsonxData" + Math.random().toString(16).slice(2)), t ? await E(R(t, e, !0)).then(() => {
|
|
125
125
|
const r = n[e.var + ""];
|
|
126
126
|
return s(r) ? r : (console.warn("response type check failed", t, r), null);
|
|
127
127
|
}).catch(() => null) : null;
|
|
128
128
|
}
|
|
129
129
|
const M = async function(t, s, e) {
|
|
130
|
-
return await
|
|
130
|
+
return await k(t, s, e, {
|
|
131
131
|
baseURL: c.getConfig("baseURL"),
|
|
132
132
|
logHandler: c.getConfig("logHandler"),
|
|
133
133
|
errorHandler: c.getConfig("errorHandler"),
|
|
@@ -137,25 +137,25 @@ const M = async function(t, s, e) {
|
|
|
137
137
|
});
|
|
138
138
|
};
|
|
139
139
|
// @__NO_SIDE_EFFECTS__
|
|
140
|
-
function
|
|
140
|
+
function U(t) {
|
|
141
141
|
if (!C())
|
|
142
142
|
throw new Error("Default Module Only Support In Browser");
|
|
143
|
-
return L() ? new
|
|
143
|
+
return L() ? new H(v, t) : new H(j, t);
|
|
144
144
|
}
|
|
145
|
-
const c = /* @__PURE__ */
|
|
145
|
+
const c = /* @__PURE__ */ U(), N = c.setConfig, X = c.request, B = c.head, F = c.get, G = c.post, I = c.del, $ = c.put, z = c.patch;
|
|
146
146
|
export {
|
|
147
|
-
|
|
147
|
+
U as NetRequest,
|
|
148
148
|
w as RequestInternalError,
|
|
149
149
|
I as del,
|
|
150
150
|
F as get,
|
|
151
|
-
|
|
152
|
-
|
|
151
|
+
Q as getResponseRulesDescription,
|
|
152
|
+
B as head,
|
|
153
153
|
P as jsonp,
|
|
154
154
|
A as jsonx,
|
|
155
|
-
|
|
155
|
+
z as patch,
|
|
156
156
|
G as post,
|
|
157
|
-
|
|
158
|
-
|
|
157
|
+
$ as put,
|
|
158
|
+
X as request,
|
|
159
159
|
N as setGlobalConfig,
|
|
160
160
|
M as upload
|
|
161
161
|
};
|
package/dist/node.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { h as
|
|
2
|
-
import { g as z } from "./retry-
|
|
3
|
-
import { f as C } from "./request.fetch-
|
|
1
|
+
import { h as b, r as q, c as w, n as g, a as d, f as E, N as f, X as x } from "./retry-DodVI8cA.js";
|
|
2
|
+
import { g as z } from "./retry-DodVI8cA.js";
|
|
3
|
+
import { f as C } from "./request.fetch-U_igg1Ax.js";
|
|
4
4
|
import N from "node:http";
|
|
5
5
|
import T from "node:https";
|
|
6
6
|
const j = async function(o, a, u) {
|
|
7
|
-
return
|
|
7
|
+
return b(await q(L, o, a, u), o, a, u);
|
|
8
8
|
}, L = async function(o, a, u) {
|
|
9
9
|
const t = await w(o, a, u);
|
|
10
10
|
if (!g(t.url))
|
|
@@ -31,7 +31,7 @@ const j = async function(o, a, u) {
|
|
|
31
31
|
const p = [];
|
|
32
32
|
e.on("data", (m) => p.push(m)), e.on("end", () => {
|
|
33
33
|
const m = E(
|
|
34
|
-
Object.entries(e.headers).map(([
|
|
34
|
+
Object.entries(e.headers).map(([y, h]) => [y.toLowerCase(), Array.isArray(h) ? h.join(",") : h])
|
|
35
35
|
);
|
|
36
36
|
r({
|
|
37
37
|
url: n.toString(),
|
|
@@ -68,11 +68,11 @@ const j = async function(o, a, u) {
|
|
|
68
68
|
function O(o) {
|
|
69
69
|
return x() ? new f(C, o) : new f(j, o);
|
|
70
70
|
}
|
|
71
|
-
const s = /* @__PURE__ */ O(), k = s.setConfig, B = s.head, D = s.get, P = s.post,
|
|
71
|
+
const s = /* @__PURE__ */ O(), k = s.setConfig, B = s.head, D = s.get, P = s.post, X = s.del, F = s.put, G = s.patch;
|
|
72
72
|
export {
|
|
73
73
|
O as NetRequest,
|
|
74
74
|
d as RequestInternalError,
|
|
75
|
-
|
|
75
|
+
X as del,
|
|
76
76
|
D as get,
|
|
77
77
|
z as getResponseRulesDescription,
|
|
78
78
|
B as head,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { h as w, r as y, c as E,
|
|
1
|
+
import { h as w, r as y, c as E, d as T, f as R, a as c } from "./retry-DodVI8cA.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) {
|