@seayoo-web/request 1.6.0 → 1.6.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.
@@ -0,0 +1,437 @@
1
+ var A = Object.defineProperty;
2
+ var x = (t, e, n) => e in t ? A(t, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : t[e] = n;
3
+ var f = (t, e, n) => (x(t, typeof e != "symbol" ? e + "" : e, n), n);
4
+ const m = typeof globalThis < "u" ? globalThis : typeof global < "u" ? global : typeof window < "u" ? window : {}, w = {
5
+ fetch: "fetch" in m,
6
+ window: "window" in m,
7
+ FormData: "FormData" in m,
8
+ Blob: "Blob" in m,
9
+ wx: "wx" in m,
10
+ TextDecoder: "TextDecoder" in m,
11
+ AbortController: "AbortController" in m
12
+ };
13
+ async function ne(t, e, n) {
14
+ var p;
15
+ const s = Object.assign({ method: "GET" }, n), r = w.FormData ? s.body instanceof FormData : !1, a = r && s.method !== "POST" && s.method !== "PUT" ? "POST" : s.method;
16
+ (a === "GET" || a === "HEAD" || a === "DELETE") && s.body !== void 0 && (console.warn("request body is invalid with method get, head, delete"), delete s.body);
17
+ const o = Object.assign(
18
+ r ? {} : {
19
+ "Content-Type": w.Blob && s.body instanceof Blob ? s.body.type || "application/octet-stream" : "application/json;charset=utf-8"
20
+ },
21
+ s.headers
22
+ ), i = s.params || {}, c = {};
23
+ Object.keys(i).forEach((h) => {
24
+ i[h] !== void 0 && (c[h] = L(i[h]));
25
+ });
26
+ const d = e.getFullUrl(t), l = U(s.body), u = s.timeout || e.get("timeout"), g = await async function() {
27
+ var O;
28
+ const h = e.get("requestTransformer");
29
+ return h ? await h({ headers: o, params: c, method: a, url: d, body: l }) : await ((O = e.get("requestHandler")) == null ? void 0 : O(o, c, a, t));
30
+ }(), y = typeof g == "string" && g ? g : d;
31
+ return (p = e.get("logHandler")) == null || p({ type: "ready", url: y, method: a, headers: o, timeout: u, body: l }), {
32
+ url: y,
33
+ method: a,
34
+ body: l,
35
+ params: c,
36
+ headers: o,
37
+ timeout: u,
38
+ abort: s.abort,
39
+ credentials: s.credentials || e.get("credentials")
40
+ };
41
+ }
42
+ function L(t) {
43
+ return typeof t == "string" ? t : Array.isArray(t) ? t.join(",") : t + "";
44
+ }
45
+ function U(t) {
46
+ if (t)
47
+ return typeof t == "string" || t instanceof URLSearchParams || t instanceof ArrayBuffer || w.Blob && t instanceof Blob || w.FormData && t instanceof FormData ? t : JSON.stringify(t);
48
+ }
49
+ function B(t) {
50
+ return new Promise((e) => setTimeout(e, Math.max(0, t)));
51
+ }
52
+ function P() {
53
+ }
54
+ function R(t, e) {
55
+ try {
56
+ const n = JSON.parse(t);
57
+ return e ? e(n) ? n : null : n;
58
+ } catch {
59
+ return null;
60
+ }
61
+ }
62
+ "" + Math.random().toString(32).slice(2);
63
+ const H = /^(?:https?:)?\/\/.+$/i, S = /^https?:\/\/.+$/i, K = /^\{[\d\D]*\}$/, I = /^\[[\d\D]*\]$/;
64
+ function $(t, e = !1) {
65
+ return e ? H.test(t) : S.test(t);
66
+ }
67
+ function N(t) {
68
+ return t == null;
69
+ }
70
+ function M(t, ...e) {
71
+ if (!t || typeof t != "object")
72
+ return !1;
73
+ const n = Object.getPrototypeOf(t);
74
+ return n !== Object.prototype && n !== null ? !1 : e.every((s) => s in t);
75
+ }
76
+ function D(t) {
77
+ return K.test(t) || I.test(t);
78
+ }
79
+ async function ae(t) {
80
+ return await new Promise(function(e) {
81
+ const n = document.getElementsByTagName("head")[0], s = document.createElement("script");
82
+ s.setAttribute("type", "text/javascript"), s.setAttribute("charset", "utf-8"), s.onload = function() {
83
+ n.removeChild(s), e(!0);
84
+ }, s.onerror = function() {
85
+ n.removeChild(s), e(!1);
86
+ }, s.setAttribute("src", t), n.appendChild(s);
87
+ });
88
+ }
89
+ function q(t, e = "数据未能正确识别") {
90
+ return typeof t == "function" ? {
91
+ guard: t,
92
+ message: e
93
+ } : {
94
+ guard: t.guard,
95
+ message: t.message || e
96
+ };
97
+ }
98
+ function v(t, e = "") {
99
+ return !e || $(t, !0) ? T(t) : (T(e) + "/" + t).replace(/\/{2,}/g, "/").replace(/:\//, "://");
100
+ }
101
+ function T(t) {
102
+ return $(t, !0) ? t.startsWith("http") ? t : ("location" in globalThis ? location.protocol : "https:") + t : ("location" in globalThis ? location.origin : "http://127.0.0.1") + "/" + t.replace(/^\/+/, "");
103
+ }
104
+ function W(t, e) {
105
+ if (e) {
106
+ if (e === !0)
107
+ return t.replace(/\?[^#]*/, "");
108
+ } else
109
+ return t;
110
+ const n = t.split("#"), s = n[0].split("?"), r = s[0], a = s.length > 1 ? s[1] : "", o = n.length > 1 ? "#" + n[1] : "", i = typeof e == "string" ? [e] : Array.isArray(e) ? e : [];
111
+ return !i.length || !a ? n[0] + o : (i.map((c) => c.replace(/([\\(){}[\]^$+\-*?|])/g, "\\$1")), (r + "?" + a.replace(new RegExp("(?:^|&)(?:" + i.join("|") + ")=[^&$]+", "g"), "").replace(/^&/, "")).replace(/\?$/, "") + o);
112
+ }
113
+ function re(t, e, n = !1) {
114
+ const s = typeof e == "string" ? e : Object.keys(e).map((o) => `${o}=${encodeURIComponent(e[o])}`).join("&");
115
+ if (!s)
116
+ return t;
117
+ const r = t.split("#");
118
+ n && (r[0] = W(
119
+ r[0],
120
+ (s.match(/([^=&#?]+)=[^&#]+/g) || []).map((o) => o.replace(/=.+$/, ""))
121
+ ));
122
+ const a = r[0].indexOf("?") + 1 ? "&" : "?";
123
+ return (r[0] + a + s + (r.length > 1 ? "#" + r[1] : "")).replace(/\?&/, "?");
124
+ }
125
+ const C = "data", b = "message";
126
+ function G(t, e, n, s, r) {
127
+ const a = r || s;
128
+ return F(t) ? X(a.ok || s.ok, t, e, n) : J(a.failed || s.failed, e, n);
129
+ }
130
+ const oe = function(t) {
131
+ const e = [], n = t.failed || { resolve: "json" };
132
+ switch (e.push("- 当http状态码 <200 或者 >=400 时"), n.resolve) {
133
+ case "body":
134
+ e.push(" 将响应内容格式化为字符串并作为错误消息");
135
+ break;
136
+ case "json":
137
+ e.push(" 将响应解析为json,并读取 " + (n.messageField || b) + " 作为错误消息");
138
+ break;
139
+ }
140
+ const s = t.ok || { resolve: "body" };
141
+ switch (e.push("- 当http状态码 >=200 并且 <400 时"), s.resolve) {
142
+ case "body":
143
+ e.push(" 将响应尝试解析为 json,并作为数据内容返回");
144
+ break;
145
+ case "json":
146
+ e.push(
147
+ " 将响应解析为 json,读取 " + (s.dataField || C) + " 作为响应数据,读取 " + (s.messageField || b) + " 作为提示消息"
148
+ ), s.statusField && e.push(" 当 " + s.statusField + " 为 " + (s.statusOKValue || "空值") + " 时是成功提示,否则是错误消息"), s.ignoreMessage && e.push(" 并忽略以下消息:" + s.ignoreMessage);
149
+ break;
150
+ }
151
+ return e.join(`
152
+ `);
153
+ };
154
+ function J(t, e, n) {
155
+ const s = t || { resolve: "json", messageField: b }, r = {
156
+ ok: !1,
157
+ code: e,
158
+ message: n,
159
+ data: null
160
+ };
161
+ switch (s.resolve) {
162
+ case "body":
163
+ r.message = k(n) || n;
164
+ break;
165
+ case "json":
166
+ const { code: a, message: o } = _(n, s.statusField, s.messageField);
167
+ r.code = a || e, r.message = k(n) || o;
168
+ break;
169
+ }
170
+ return r;
171
+ }
172
+ function _(t, e, n = b) {
173
+ if (!D(t))
174
+ return { message: "" };
175
+ const s = R(t);
176
+ return !s || !M(s) ? { message: t } : {
177
+ code: e ? j(s, e) : "",
178
+ message: j(s, n) || t
179
+ };
180
+ }
181
+ function j(t, e) {
182
+ const n = Array.isArray(e) ? e : [e];
183
+ for (const s of n)
184
+ if (s in t)
185
+ return V(t[s]);
186
+ return "";
187
+ }
188
+ function V(t) {
189
+ return t ? typeof t == "string" ? t : JSON.stringify(t) : "";
190
+ }
191
+ const z = /<title>([^<]+)<\/title>/i, Q = /<message>([^<]+)<\/message>/i;
192
+ function k(t) {
193
+ const e = t.match(z);
194
+ if (e)
195
+ return e[1];
196
+ const n = t.match(Q);
197
+ return n ? n[1] : "";
198
+ }
199
+ function X(t, e, n, s) {
200
+ const r = t || { resolve: "body" }, a = {
201
+ ok: !0,
202
+ code: n,
203
+ message: "",
204
+ data: null
205
+ };
206
+ if (e === 202 || e === 204 || !s)
207
+ return a;
208
+ if (r.resolve === "body")
209
+ return a.data = D(s) ? R(s) : s, a;
210
+ const o = R(s);
211
+ if (!o || !M(o))
212
+ return a.ok = !1, a.code = "ResponseFormatError", a.message = "响应内容无法格式化为 Object", a;
213
+ const i = r.statusField, c = r.statusOKValue || "", d = r.dataField || C, l = r.messageField || b, u = r.ignoreMessage || "";
214
+ if (i && !(i in o))
215
+ return a.ok = !1, a.code = "ResponseFieldMissing", a.message = "响应内容找不到状态字段 " + i, a;
216
+ const g = i ? o[i] + "" : "";
217
+ return a.ok = i ? g === c : !0, a.code = g || n, a.data = d === !0 ? o : d in o ? o[d] : null, a.message = j(o, l), u && a.message && (Array.isArray(u) && u.includes(a.message) || typeof u == "string" && a.message === u) && (a.message = ""), a;
218
+ }
219
+ function F(t) {
220
+ return t >= 200 && t < 400;
221
+ }
222
+ async function Y(t, e, n, s, r) {
223
+ const a = r || 0, o = Math.max(0, Math.min(10, (s == null ? void 0 : s.maxRetry) ?? n.get("maxRetry") ?? 0)), i = (s == null ? void 0 : s.retryResolve) ?? n.get("retryResolve"), c = n.get("logHandler") || P;
224
+ c({
225
+ type: "prepear",
226
+ url: e,
227
+ method: (s == null ? void 0 : s.method) || "GET",
228
+ retry: a,
229
+ maxRetry: o,
230
+ message: a === 0 ? "start" : `retry ${a}/${o} start`,
231
+ headers: s == null ? void 0 : s.headers,
232
+ options: s
233
+ });
234
+ const d = Date.now(), l = await t(e, n, s), u = l.status, g = Date.now() - d, y = `[cost ${g}][${u}] ${u < 0 ? l.body : ""}`;
235
+ c({
236
+ type: "finished",
237
+ url: e,
238
+ method: l.method,
239
+ retry: a,
240
+ maxRetry: o,
241
+ message: a === 0 ? `finish ${y}` : `retry ${a}/${o} finish ${y}`,
242
+ response: l,
243
+ headers: l.headers,
244
+ cost: g
245
+ });
246
+ const p = F(u);
247
+ if (!o || i === "network" && u > 0 || i === "status" && p || Array.isArray(i) && !i.includes(u) || typeof i == "function" && i(l, a) !== !0 || a >= o)
248
+ return l;
249
+ const h = (s == null ? void 0 : s.retryInterval) ?? n.get("retryInterval") ?? 1e3;
250
+ return await B(
251
+ Math.max(
252
+ 100,
253
+ h === "2EB" ? Math.pow(2, a) * 1e3 : typeof h == "function" ? h(a + 1) || 0 : h
254
+ )
255
+ ), await Y(t, e, n, s, a + 1);
256
+ }
257
+ function ie(t, e, n, s) {
258
+ var o, i;
259
+ if (t.status < 0)
260
+ return E(
261
+ { ok: !1, status: t.status, code: t.statusText, headers: {}, message: "", data: null },
262
+ `${t.method} ${e} ${t.statusText}`,
263
+ t.method,
264
+ e,
265
+ n,
266
+ s
267
+ );
268
+ F(t.status) || (o = n.get("errorHandler")) == null || o(t.status, t.method, e);
269
+ const r = {
270
+ ...G(t.status, t.statusText, t.body, n.get("responseRule"), s == null ? void 0 : s.responseRule),
271
+ status: t.status,
272
+ headers: Object.fromEntries(Object.entries(t.headers || {}).map(([c, d]) => [c.toLowerCase(), d]))
273
+ };
274
+ (i = n.get("responseHandler")) == null || i({ ...r }, t.method, e);
275
+ const a = r.ok ? r.message : `${t.method} ${e} [${r.code || t.statusText}] ${r.message || t.statusText}`;
276
+ return E(r, a, t.method, e, n, s);
277
+ }
278
+ function E(t, e, n, s, r, a) {
279
+ const o = r.get("message"), i = o === !1 || (a == null ? void 0 : a.message) === !1 ? !1 : (a == null ? void 0 : a.message) || o;
280
+ if (i !== !1) {
281
+ const c = typeof i == "function" ? i(t, n, s, e) : e;
282
+ c instanceof Error ? r.showMessage(!0, c.message) : c && typeof c == "object" && "message" in c ? r.showMessage(!1, c.message) : r.showMessage(!t.ok, c);
283
+ }
284
+ return t;
285
+ }
286
+ class Z {
287
+ constructor(e) {
288
+ // 保存的配置需要部分字段强制设置默认值
289
+ f(this, "config", {
290
+ baseURL: "",
291
+ maxRetry: 0,
292
+ retryInterval: 1e3,
293
+ retryResolve: "network",
294
+ timeout: 5e3,
295
+ cacheTTL: 500,
296
+ credentials: "same-origin",
297
+ responseRule: {
298
+ ok: {
299
+ resolve: "body"
300
+ },
301
+ failed: {
302
+ resolve: "json",
303
+ messageField: "message"
304
+ }
305
+ }
306
+ });
307
+ e && this.set(e);
308
+ }
309
+ set(e) {
310
+ if (e.baseURL && !/^\/.+/.test(e.baseURL) && !$(e.baseURL))
311
+ throw console.warn("baseURL 需要以 / 开头,或者是完整的 url 地址"), new Error("BaseURLError");
312
+ Object.assign(this.config, e);
313
+ }
314
+ get(e) {
315
+ return this.config[e];
316
+ }
317
+ /** 基于 baseURL 返回完整的 url 地址, 如果 url 地址以 / 开头则表示忽略 baseURL 的值 */
318
+ getFullUrl(e) {
319
+ return e.startsWith("/") ? v(e) : v(e, this.config.baseURL);
320
+ }
321
+ /** 提示消息 */
322
+ showMessage(e, n) {
323
+ this.config.messageHandler && n && this.config.messageHandler(e, n);
324
+ }
325
+ }
326
+ class ee {
327
+ constructor(e = 500) {
328
+ f(this, "ttl");
329
+ f(this, "cache");
330
+ this.cache = {}, this.ttl = Math.max(e, 0);
331
+ }
332
+ getKey(e, n) {
333
+ const s = Object.keys(n || {}).sort().map((r) => `${r}#${n == null ? void 0 : n[r]}`);
334
+ return e + s.join(",");
335
+ }
336
+ updateTTL(e) {
337
+ this.ttl = Math.max(e, 0);
338
+ }
339
+ get(e) {
340
+ if (this.ttl === 0)
341
+ return null;
342
+ const n = this.cache[e];
343
+ return n ? n.ttl < Date.now() ? (delete this.cache[e], null) : n.res : null;
344
+ }
345
+ set(e, n) {
346
+ this.ttl !== 0 && (this.cache[e] = {
347
+ ttl: Date.now() + this.ttl,
348
+ res: n
349
+ });
350
+ }
351
+ }
352
+ function te(t, e, n, s) {
353
+ if (e.ok && !N(e.data) && s) {
354
+ const r = q(s, "响应数据未能正确识别");
355
+ return r.guard(e.data) || (console.error("ResponseCheckFaild", t, e.data), n.showMessage(!0, `${t} ${r.message}`), e.data = null), e;
356
+ }
357
+ return e;
358
+ }
359
+ class ce {
360
+ constructor(e, n) {
361
+ f(this, "agent");
362
+ f(this, "config");
363
+ f(this, "cache");
364
+ this.config = new Z(n), this.agent = e, this.cache = new ee(this.config.get("cacheTTL")), this.setConfig = this.setConfig.bind(this), this.getConfig = this.getConfig.bind(this), this.get = this.get.bind(this), this.post = this.post.bind(this), this.del = this.del.bind(this), this.patch = this.patch.bind(this), this.put = this.put.bind(this), this.head = this.head.bind(this);
365
+ }
366
+ /**
367
+ * 执行网络请求
368
+ */
369
+ async exec(e, n) {
370
+ return await this.agent(e, this.config, n);
371
+ }
372
+ /**
373
+ * 检查响应的数据类型
374
+ */
375
+ async guard(e, n, s) {
376
+ return te(e, n, this.config, s);
377
+ }
378
+ /**
379
+ * 修改默认请求配置: baesURL / timeout / credentials / errorHandler / messageHandler / responseHandler / logHandler / responseRule
380
+ */
381
+ setConfig(e) {
382
+ this.config.set(e), this.cache.updateTTL(this.config.get("cacheTTL"));
383
+ }
384
+ /**
385
+ * 读取默认的请求配置
386
+ */
387
+ getConfig(e) {
388
+ return this.config.get(e);
389
+ }
390
+ /**
391
+ * 发送一个 HEAD 请求,并且不处理响应 body
392
+ */
393
+ async head(e, n) {
394
+ const s = Object.assign({}, n || null);
395
+ return s.method = "HEAD", this.guard(e, await this.exec(e, s), null);
396
+ }
397
+ async get(e, n, s) {
398
+ const r = Object.assign({}, s || null);
399
+ r.method = "GET";
400
+ const a = this.cache.getKey(e, r.params), o = this.cache.get(a);
401
+ if (o)
402
+ return this.guard(e, await o, n || null);
403
+ const i = this.exec(e, r);
404
+ return this.cache.set(a, i), this.guard(e, await i, n || null);
405
+ }
406
+ async post(e, n, s, r) {
407
+ const a = Object.assign({}, r || null);
408
+ return a.method = "POST", a.body = n, this.guard(e, await this.exec(e, a), s || null);
409
+ }
410
+ async del(e, n, s) {
411
+ const r = Object.assign({}, s || null);
412
+ return r.method = "DELETE", this.guard(e, await this.exec(e, r), n || null);
413
+ }
414
+ async put(e, n, s, r) {
415
+ const a = Object.assign({}, r || null);
416
+ return a.method = "PUT", a.body = n, this.guard(e, await this.exec(e, a), s || null);
417
+ }
418
+ async patch(e, n, s, r) {
419
+ const a = Object.assign({}, r || null);
420
+ return a.method = "PATCH", a.body = n, this.guard(e, await this.exec(e, a), s || null);
421
+ }
422
+ }
423
+ const ue = "1.6.2";
424
+ export {
425
+ re as E,
426
+ ce as N,
427
+ Z as R,
428
+ w as S,
429
+ $ as U,
430
+ P as W,
431
+ ae as a,
432
+ ne as c,
433
+ oe as g,
434
+ ie as h,
435
+ Y as r,
436
+ ue as v
437
+ };
package/dist/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const version = "1.6.0";
1
+ export declare const version = "1.6.2";
package/dist/wx.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("./version-DJIdoURF.cjs"),l=async function(t,n,r){return s.handleResponse(await s.retryRequest(f,t,n,r),t,n,r)},f=async function(t,n,r){const e=await s.convertOptions(t,n,r),u=e.method==="PATCH"?"POST":e.method,a=s.Ct(e.url,e.params);return globalThis.wx?new Promise(i=>{wx.request({url:a,data:e.body,header:e.headers,method:u,dataType:"string",responseType:"text",fail(){i({url:a,method:u,status:-1,statusText:"NetworkError",body:""})},success(c){i({url:a,method:u,status:c.statusCode,statusText:c.statusCode+"",headers:{...c.header},body:e.method==="HEAD"?"":p(c.data)})}})}):{url:a,method:u,status:-1,statusText:"NotSupport",body:"NotFound namespace of wx"}};function p(t){return typeof t=="string"?t:t instanceof ArrayBuffer&&"TextDecoder"in globalThis?new TextDecoder().decode(t):JSON.stringify(t)}function d(t){return new s.NetRequestHandler(l,t)}const o=d(),g=o.setConfig,h=o.head,y=o.get,T=o.post,b=o.del,x=o.put;exports.version=s.version;exports.NetRequest=d;exports.del=b;exports.get=y;exports.head=h;exports.post=T;exports.put=x;exports.setGlobalConfig=g;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./version-D6D6EXmg.cjs"),p=async function(t,r,n){return e.handleResponse(await e.retryRequest(l,t,r,n),t,r,n)},l=async function(t,r,n){const o=await e.convertOptions(t,r,n),u=o.method==="PATCH"?"POST":o.method,a=e.Et(o.url,o.params);return e.Support.wx?new Promise(d=>{wx.request({url:a,data:o.body,header:o.headers,method:u,dataType:"string",responseType:"text",fail(){d({url:a,method:u,status:-1,statusText:"NetworkError",body:""})},success(c){d({url:a,method:u,status:c.statusCode,statusText:c.statusCode+"",headers:{...c.header},body:o.method==="HEAD"?"":f(c.data)})}})}):{url:a,method:u,status:-1,statusText:"NotSupport",body:"NotFound namespace of wx"}};function f(t){return typeof t=="string"?t:t instanceof ArrayBuffer&&e.Support.TextDecoder?new TextDecoder().decode(t):JSON.stringify(t)}function i(t){return new e.NetRequestHandler(p,t)}const s=i(),y=s.setConfig,g=s.head,h=s.get,x=s.post,w=s.del,T=s.put;exports.version=e.version;exports.NetRequest=i;exports.del=w;exports.get=h;exports.head=g;exports.post=x;exports.put=T;exports.setGlobalConfig=y;
package/dist/wx.js CHANGED
@@ -1,10 +1,10 @@
1
- import { h as d, r as i, c as f, C as l, N as p } from "./version-CLBYgaXw.js";
2
- import { v as A } from "./version-CLBYgaXw.js";
1
+ import { h as i, r as p, c as f, E as l, S as d, N as x } from "./version-D9usx_Q7.js";
2
+ import { v as A } from "./version-D9usx_Q7.js";
3
3
  const h = async function(t, o, r) {
4
- return d(await i(x, t, o, r), t, o, r);
5
- }, x = async function(t, o, r) {
4
+ return i(await p(y, t, o, r), t, o, r);
5
+ }, y = async function(t, o, r) {
6
6
  const e = await f(t, o, r), n = e.method === "PATCH" ? "POST" : e.method, a = l(e.url, e.params);
7
- return globalThis.wx ? new Promise((c) => {
7
+ return d.wx ? new Promise((c) => {
8
8
  wx.request({
9
9
  url: a,
10
10
  data: e.body,
@@ -28,7 +28,7 @@ const h = async function(t, o, r) {
28
28
  status: u.statusCode,
29
29
  statusText: u.statusCode + "",
30
30
  headers: { ...u.header },
31
- body: e.method === "HEAD" ? "" : y(u.data)
31
+ body: e.method === "HEAD" ? "" : m(u.data)
32
32
  });
33
33
  }
34
34
  });
@@ -40,20 +40,20 @@ const h = async function(t, o, r) {
40
40
  body: "NotFound namespace of wx"
41
41
  };
42
42
  };
43
- function y(t) {
44
- return typeof t == "string" ? t : t instanceof ArrayBuffer && "TextDecoder" in globalThis ? new TextDecoder().decode(t) : JSON.stringify(t);
45
- }
46
43
  function m(t) {
47
- return new p(h, t);
44
+ return typeof t == "string" ? t : t instanceof ArrayBuffer && d.TextDecoder ? new TextDecoder().decode(t) : JSON.stringify(t);
45
+ }
46
+ function w(t) {
47
+ return new x(h, t);
48
48
  }
49
- const s = m(), g = s.setConfig, w = s.head, b = s.get, q = s.post, C = s.del, N = s.put;
49
+ const s = w(), g = s.setConfig, q = s.head, N = s.get, R = s.post, b = s.del, S = s.put;
50
50
  export {
51
- m as NetRequest,
52
- C as del,
53
- b as get,
54
- w as head,
55
- q as post,
56
- N as put,
51
+ w as NetRequest,
52
+ b as del,
53
+ N as get,
54
+ q as head,
55
+ R as post,
56
+ S as put,
57
57
  g as setGlobalConfig,
58
58
  A as version
59
59
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@seayoo-web/request",
3
- "version": "1.6.0",
3
+ "version": "1.6.2",
4
4
  "description": "requst tools for seayoo web",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",
@@ -67,21 +67,21 @@
67
67
  "@types/node": "18.19.5",
68
68
  "@typescript-eslint/eslint-plugin": "^6.21.0",
69
69
  "@typescript-eslint/parser": "^6.21.0",
70
- "@vitest/browser": "^1.3.1",
71
- "@vitest/coverage-istanbul": "^1.3.1",
70
+ "@vitest/browser": "^1.4.0",
71
+ "@vitest/coverage-istanbul": "^1.4.0",
72
72
  "eslint": "^8.57.0",
73
73
  "eslint-config-prettier": "^9.1.0",
74
74
  "eslint-plugin-prettier": "^5.1.3",
75
75
  "happy-dom": "^12.10.3",
76
76
  "lint-staged": "^14.0.1",
77
- "msw": "^2.2.3",
77
+ "msw": "^2.2.13",
78
78
  "rimraf": "^5.0.5",
79
- "simple-git-hooks": "^2.10.0",
79
+ "simple-git-hooks": "^2.11.1",
80
80
  "typescript": "~5.2.2",
81
- "vite": "^5.1.6",
82
- "vitest": "^1.3.1"
81
+ "vite": "^5.2.8",
82
+ "vitest": "^1.4.0"
83
83
  },
84
84
  "dependencies": {
85
- "@seayoo-web/utils": "^1.16.1"
85
+ "@seayoo-web/utils": "^1.16.4"
86
86
  }
87
87
  }