@seayoo-web/request 3.4.4 → 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"),
@@ -136,25 +136,26 @@ const M = async function(t, s, e) {
136
136
  responseHandler: c.getConfig("responseHandler")
137
137
  });
138
138
  };
139
- function v(t) {
139
+ // @__NO_SIDE_EFFECTS__
140
+ function U(t) {
140
141
  if (!C())
141
142
  throw new Error("Default Module Only Support In Browser");
142
- return L() ? new E(j, t) : new E(k, t);
143
+ return L() ? new H(v, t) : new H(j, t);
143
144
  }
144
- const c = 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;
145
146
  export {
146
- v as NetRequest,
147
+ U as NetRequest,
147
148
  w as RequestInternalError,
148
149
  I as del,
149
150
  F as get,
150
- z as getResponseRulesDescription,
151
- X as head,
151
+ Q as getResponseRulesDescription,
152
+ B as head,
152
153
  P as jsonp,
153
154
  A as jsonx,
154
- Z as patch,
155
+ z as patch,
155
156
  G as post,
156
- Q as put,
157
- B as request,
157
+ $ as put,
158
+ X as request,
158
159
  N as setGlobalConfig,
159
160
  M as upload
160
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(),
@@ -64,14 +64,15 @@ const j = async function(o, a, u) {
64
64
  }), t.body && c.write(t.body), c.end();
65
65
  });
66
66
  };
67
+ // @__NO_SIDE_EFFECTS__
67
68
  function O(o) {
68
69
  return x() ? new f(C, o) : new f(j, o);
69
70
  }
70
- const s = 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;
71
72
  export {
72
73
  O as NetRequest,
73
74
  d as RequestInternalError,
74
- Z as del,
75
+ X as del,
75
76
  D as get,
76
77
  z as getResponseRulesDescription,
77
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) {