@seayoo-web/request 3.4.0 → 3.4.2

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 CHANGED
@@ -1,10 +1,10 @@
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) {
1
+ import { h as m, r as q, R as T, c as x, B as R, a as w, N as H, f as C, b as E, X as L } from "./retry-FiwuCZIu.js";
2
+ import { g as Q } from "./retry-FiwuCZIu.js";
3
+ import { f as k } from "./request.fetch-Cbt_az4v.js";
4
+ const S = async function(e, o, t) {
5
5
  return m(await q(y, e, o, t), e, o, t);
6
6
  };
7
- async function S(e, o, t, n) {
7
+ async function U(e, o, t, n) {
8
8
  const r = t?.body, l = t?.method === "PUT" ? "PUT" : "POST";
9
9
  if (o instanceof Blob) {
10
10
  const i = new T(n), u = await y(e, i, {
@@ -56,7 +56,7 @@ const y = async function(e, o, t) {
56
56
  method: r,
57
57
  status: f,
58
58
  statusText: s.statusText,
59
- headers: U(s),
59
+ headers: j(s),
60
60
  body: r === "HEAD" || f === 204 ? "" : s.responseText
61
61
  });
62
62
  }), s.addEventListener(
@@ -88,7 +88,7 @@ const y = async function(e, o, t) {
88
88
  }, n.timeout));
89
89
  });
90
90
  };
91
- function U(e) {
91
+ function j(e) {
92
92
  const o = {};
93
93
  if (!e)
94
94
  return o;
@@ -119,15 +119,15 @@ async function O(e, o, t = {}) {
119
119
  });
120
120
  });
121
121
  }
122
- async function A(e, o, t = {}) {
122
+ async function P(e, o, t = {}) {
123
123
  const n = window;
124
124
  return "var" in t || (t.var = "jsonxData" + Math.random().toString(16).slice(2)), e ? await H(R(e, t, !0)).then(() => {
125
125
  const r = n[t.var + ""];
126
126
  return o(r) ? r : (console.warn("response type check failed", e, r), null);
127
127
  }).catch(() => null) : null;
128
128
  }
129
- const M = async function(e, o, t) {
130
- return await S(e, o, t, {
129
+ const A = async function(e, o, t) {
130
+ return await U(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 M = async function(e, o, t) {
136
136
  responseHandler: c.getConfig("responseHandler")
137
137
  });
138
138
  };
139
- function j(e) {
139
+ function v(e) {
140
140
  if (!C())
141
141
  throw new Error("Default Module Only Support In Browser");
142
- return L() ? new E(k, e) : new E(P, e);
142
+ return L() ? new E(k, e) : new E(S, e);
143
143
  }
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;
144
+ const c = v(), B = c.setConfig, M = c.request, X = c.head, F = c.get, G = c.post, I = c.del, $ = c.put, z = c.patch;
145
145
  export {
146
- j as NetRequest,
146
+ v as NetRequest,
147
147
  w as RequestInternalError,
148
148
  I as del,
149
149
  F as get,
150
- z as getResponseRulesDescription,
150
+ Q as getResponseRulesDescription,
151
151
  X as head,
152
152
  O as jsonp,
153
- A as jsonx,
154
- V as patch,
153
+ P as jsonx,
154
+ z as patch,
155
155
  G as post,
156
- Q as put,
157
- B as request,
158
- N as setGlobalConfig,
159
- M as upload
156
+ $ as put,
157
+ M as request,
158
+ B as setGlobalConfig,
159
+ A as upload
160
160
  };
package/dist/node.js CHANGED
@@ -1,26 +1,26 @@
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) {
1
+ import { h as y, r as q, c as w, e as g, a as c, d as E, b as f, X as x } from "./retry-FiwuCZIu.js";
2
+ import { g as z } from "./retry-FiwuCZIu.js";
3
+ import { f as C } from "./request.fetch-Cbt_az4v.js";
4
+ import T from "node:http";
5
+ import j from "node:https";
6
+ const L = async function(o, a, u) {
7
+ return y(await q(N, o, a, u), o, a, u);
8
+ }, N = async function(o, a, u) {
9
9
  const t = await w(o, a, u);
10
10
  if (!g(t.url))
11
11
  return {
12
12
  url: t.url,
13
13
  method: t.method,
14
14
  status: -1,
15
- statusText: d.URLFormatError,
15
+ statusText: c.URLFormatError,
16
16
  headers: {},
17
17
  body: ""
18
18
  };
19
- const R = /^https:\/\//i.test(t.url) ? T : N, n = new URL(t.url), i = t.params;
19
+ const R = /^https:\/\//i.test(t.url) ? j : T, 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) => {
23
- const c = R.request(
23
+ const d = R.request(
24
24
  n,
25
25
  {
26
26
  headers: t.headers,
@@ -31,47 +31,47 @@ 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(([y, h]) => [y.toLowerCase(), Array.isArray(h) ? h.join(",") : h])
34
+ Object.entries(e.headers).map(([b, h]) => [b.toLowerCase(), Array.isArray(h) ? h.join(",") : h])
35
35
  );
36
36
  r({
37
37
  url: n.toString(),
38
38
  method: t.method,
39
39
  status: e.statusCode || -1,
40
- statusText: e.statusMessage || d.Unknown,
40
+ statusText: e.statusMessage || c.Unknown,
41
41
  headers: m,
42
42
  body: l || e.statusCode === 204 ? "" : Buffer.concat(p).toString("utf-8")
43
43
  });
44
44
  });
45
45
  }
46
46
  );
47
- c.on("error", (e) => {
47
+ d.on("error", (e) => {
48
48
  r({
49
49
  url: n.toString(),
50
50
  method: t.method,
51
51
  status: -1,
52
- statusText: d.NetworkError,
52
+ statusText: c.NetworkError,
53
53
  body: "",
54
54
  rawError: e
55
55
  });
56
- }), c.on("timeout", () => {
56
+ }), d.on("timeout", () => {
57
57
  r({
58
58
  url: n.toString(),
59
59
  method: t.method,
60
60
  status: -1,
61
- statusText: d.Timeout,
61
+ statusText: c.Timeout,
62
62
  body: ""
63
63
  });
64
- }), t.body && c.write(t.body), c.end();
64
+ }), t.body && d.write(t.body), d.end();
65
65
  });
66
66
  };
67
67
  function O(o) {
68
- return x() ? new f(C, o) : new f(j, o);
68
+ return x() ? new f(C, o) : new f(L, o);
69
69
  }
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;
70
+ const s = O(), k = s.setConfig, B = s.head, D = s.get, P = s.post, X = s.del, F = s.put, G = s.patch;
71
71
  export {
72
72
  O as NetRequest,
73
- d as RequestInternalError,
74
- Q as del,
73
+ c as RequestInternalError,
74
+ X as del,
75
75
  D as get,
76
76
  z as getResponseRulesDescription,
77
77
  B as head,
@@ -1,8 +1,8 @@
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
- const x = async function(a, s, n) {
3
- return w(await y(g, a, s, n), a, s, n);
4
- }, g = async function(a, s, n) {
5
- const t = await E(a, s, n), i = new URL(t.url), u = t.params;
1
+ import { h as w, r as y, c as E, s as T, d as R, a as c } from "./retry-FiwuCZIu.js";
2
+ const x = async function(s, a, n) {
3
+ return w(await y(g, s, a, n), s, a, n);
4
+ }, g = async function(s, a, n) {
5
+ const t = await E(s, a, 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
7
  const r = T() ? new AbortController() : null;
8
8
  function d() {
@@ -12,7 +12,7 @@ const x = async function(a, s, n) {
12
12
  let l = !1;
13
13
  const b = t.timeout > 0 ? setTimeout(function() {
14
14
  l = !0, d();
15
- }, t.timeout) : null, f = t.method === "HEAD";
15
+ }, t.timeout) : null, m = t.method === "HEAD";
16
16
  return await fetch(i, {
17
17
  method: t.method,
18
18
  headers: Object.keys(t.headers).length > 0 ? new Headers(t.headers) : void 0,
@@ -27,7 +27,7 @@ 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
- }, h = f || e.status === 204 ? "" : await e.text().catch((m) => m);
30
+ }, h = m || e.status === 204 ? "" : await e.text().catch((f) => f);
31
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;