@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 CHANGED
@@ -226,13 +226,13 @@ defaultMessage: string
226
226
 
227
227
  ### retryResolve
228
228
 
229
- 类型:"network" | "status" | number[] | ((result: IRequestBaseResponse, count: number) => boolean)
229
+ 类型:"default" | "network" | number[] | ((result: IRequestBaseResponse, count: number) => boolean)
230
230
 
231
- 说明:重试判断方法,默认是 network
231
+ 说明:重试判断方法,默认是 default
232
232
 
233
- network 表示仅仅当网络错误时才重试,如果请求被取消(aborted)则不重试;
233
+ default 在 network 基础之上,如果是 Tencent EO 响应的 552/522 错误码,则重试;
234
234
 
235
- status 表示网络错误或者http 状态码错误时(<200 || >=400)重试;
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, Q as R, a as w, _ as H, l as C, N as E, Z as L } from "./retry-BjOxSyvC.js";
2
- import { g as z } from "./retry-BjOxSyvC.js";
3
- import { f as j } from "./request.fetch-6HUu6_l5.js";
4
- const k = async function(t, s, e) {
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 S(t, s, e, n) {
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: U(o),
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 U(t) {
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
- }, H(l).catch(function() {
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 H(R(t, e, !0)).then(() => {
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 S(t, s, e, {
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 v(t) {
140
+ function U(t) {
141
141
  if (!C())
142
142
  throw new Error("Default Module Only Support In Browser");
143
- return L() ? new E(j, t) : new E(k, t);
143
+ return L() ? new H(v, t) : new H(j, t);
144
144
  }
145
- const c = /* @__PURE__ */ v(), N = c.setConfig, B = c.request, X = c.head, F = c.get, G = c.post, I = c.del, Q = c.put, Z = c.patch;
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
- v as NetRequest,
147
+ U as NetRequest,
148
148
  w as RequestInternalError,
149
149
  I as del,
150
150
  F as get,
151
- z as getResponseRulesDescription,
152
- X as head,
151
+ Q as getResponseRulesDescription,
152
+ B as head,
153
153
  P as jsonp,
154
154
  A as jsonx,
155
- Z as patch,
155
+ z as patch,
156
156
  G as post,
157
- Q as put,
158
- B as request,
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 y, r as q, c as w, b as g, a as d, f as E, N as f, Z as x } from "./retry-BjOxSyvC.js";
2
- import { g as z } from "./retry-BjOxSyvC.js";
3
- import { f as C } from "./request.fetch-6HUu6_l5.js";
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 y(await q(L, o, a, u), o, a, u);
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(([b, h]) => [b.toLowerCase(), Array.isArray(h) ? h.join(",") : h])
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, Z = s.del, F = s.put, G = s.patch;
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
- Z as del,
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, u as T, f as R, a as c } from "./retry-BjOxSyvC.js";
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) {