@chzky/reqwest 0.0.1 → 0.1.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 +314 -0
- package/esm/_dnt.polyfills.d.ts +11 -0
- package/esm/_dnt.polyfills.d.ts.map +1 -10
- package/esm/_dnt.polyfills.js +24 -66
- package/esm/_dnt.shims.d.ts +1 -13
- package/esm/_dnt.shims.d.ts.map +1 -1
- package/esm/_dnt.shims.js +57 -1
- package/esm/lib/mod.d.ts +1 -1
- package/esm/lib/mod.d.ts.map +1 -1
- package/esm/lib/mod.js +1 -1
- package/esm/lib/reqwest/class.d.ts +116 -78
- package/esm/lib/reqwest/class.d.ts.map +1 -1
- package/esm/lib/reqwest/class.js +175 -1
- package/esm/lib/reqwest/core.d.ts +5 -0
- package/esm/lib/reqwest/core.d.ts.map +1 -1
- package/esm/lib/reqwest/core.js +154 -244
- package/esm/lib/reqwest/factor.d.ts +2 -2
- package/esm/lib/reqwest/factor.d.ts.map +1 -1
- package/esm/lib/reqwest/factor.js +32 -1
- package/esm/lib/reqwest/interface.d.ts +166 -42
- package/esm/lib/reqwest/interface.d.ts.map +1 -1
- package/esm/lib/reqwest/interface.js +1 -1
- package/esm/lib/reqwest/mod.d.ts +1 -1
- package/esm/lib/reqwest/mod.d.ts.map +1 -1
- package/esm/lib/reqwest/mod.js +2 -2
- package/esm/lib/{helper → utils}/mod.d.ts +1 -0
- package/esm/lib/utils/mod.d.ts.map +1 -0
- package/esm/lib/{helper → utils}/mod.js +1 -0
- package/esm/lib/utils/other/mod.d.ts +2 -0
- package/esm/lib/utils/other/mod.d.ts.map +1 -0
- package/esm/lib/utils/other/mod.js +1 -0
- package/esm/lib/utils/other/sseParse.d.ts +34 -0
- package/esm/lib/utils/other/sseParse.d.ts.map +1 -0
- package/esm/lib/utils/other/sseParse.js +42 -0
- package/{script/lib/helper → esm/lib/utils}/request/RESTful.d.ts +43 -11
- package/esm/lib/utils/request/RESTful.d.ts.map +1 -0
- package/esm/lib/utils/request/RESTful.js +129 -0
- package/esm/lib/utils/request/baseConf.d.ts +22 -0
- package/esm/lib/utils/request/baseConf.d.ts.map +1 -0
- package/esm/lib/utils/request/baseConf.js +37 -0
- package/esm/lib/utils/request/factors.d.ts +30 -0
- package/esm/lib/utils/request/factors.d.ts.map +1 -0
- package/esm/lib/utils/request/factors.js +39 -0
- package/esm/lib/{helper → utils}/request/input.d.ts +4 -3
- package/esm/lib/utils/request/input.d.ts.map +1 -0
- package/esm/lib/utils/request/input.js +24 -0
- package/esm/lib/utils/request/mod.d.ts +7 -0
- package/esm/lib/utils/request/mod.d.ts.map +1 -0
- package/esm/lib/utils/request/mod.js +6 -0
- package/esm/lib/utils/request/process.d.ts +16 -0
- package/esm/lib/utils/request/process.d.ts.map +1 -0
- package/esm/lib/utils/request/process.js +37 -0
- package/esm/lib/utils/request/wait.d.ts +10 -0
- package/esm/lib/utils/request/wait.d.ts.map +1 -0
- package/esm/lib/utils/request/wait.js +14 -0
- package/esm/lib/utils/response/blobToUrl.d.ts +10 -0
- package/esm/lib/utils/response/blobToUrl.d.ts.map +1 -0
- package/esm/lib/utils/response/blobToUrl.js +21 -0
- package/esm/lib/utils/response/mod.d.ts +5 -0
- package/esm/lib/utils/response/mod.d.ts.map +1 -0
- package/esm/lib/utils/response/mod.js +4 -0
- package/esm/lib/utils/response/openLink.d.ts +7 -0
- package/esm/lib/utils/response/openLink.d.ts.map +1 -0
- package/esm/lib/utils/response/openLink.js +20 -0
- package/esm/lib/utils/response/output.d.ts +16 -0
- package/esm/lib/utils/response/output.d.ts.map +1 -0
- package/esm/lib/utils/response/output.js +24 -0
- package/esm/lib/utils/response/pick.d.ts +23 -0
- package/esm/lib/utils/response/pick.d.ts.map +1 -0
- package/esm/lib/utils/response/pick.js +25 -0
- package/esm/lib/utils/use/mod.d.ts.map +1 -0
- package/esm/lib/utils/use/mod.js +2 -0
- package/esm/lib/utils/use/useCancel.d.ts +33 -0
- package/esm/lib/utils/use/useCancel.d.ts.map +1 -0
- package/esm/lib/utils/use/useCancel.js +41 -0
- package/esm/lib/utils/use/useLoading.d.ts +34 -0
- package/esm/lib/utils/use/useLoading.d.ts.map +1 -0
- package/esm/lib/utils/use/useLoading.js +57 -0
- package/package.json +4 -11
- package/script/_dnt.polyfills.d.ts +11 -0
- package/script/_dnt.polyfills.d.ts.map +1 -1
- package/script/_dnt.polyfills.js +15 -0
- package/script/_dnt.shims.d.ts +1 -13
- package/script/_dnt.shims.d.ts.map +1 -1
- package/script/_dnt.shims.js +2 -21
- package/script/lib/mod.d.ts +1 -1
- package/script/lib/mod.d.ts.map +1 -1
- package/script/lib/mod.js +1 -1
- package/script/lib/reqwest/class.d.ts +116 -78
- package/script/lib/reqwest/class.d.ts.map +1 -1
- package/script/lib/reqwest/class.js +135 -25
- package/script/lib/reqwest/core.d.ts +5 -0
- package/script/lib/reqwest/core.d.ts.map +1 -1
- package/script/lib/reqwest/core.js +119 -23
- package/script/lib/reqwest/factor.d.ts +2 -2
- package/script/lib/reqwest/factor.d.ts.map +1 -1
- package/script/lib/reqwest/factor.js +2 -2
- package/script/lib/reqwest/interface.d.ts +160 -11
- package/script/lib/reqwest/interface.d.ts.map +1 -1
- package/script/lib/reqwest/mod.d.ts +1 -1
- package/script/lib/reqwest/mod.d.ts.map +1 -1
- package/script/lib/{helper → utils}/mod.d.ts +1 -0
- package/script/lib/utils/mod.d.ts.map +1 -0
- package/script/lib/{helper → utils}/mod.js +1 -0
- package/script/lib/utils/other/mod.d.ts +2 -0
- package/script/lib/utils/other/mod.d.ts.map +1 -0
- package/script/lib/{helper/response → utils/other}/mod.js +1 -2
- package/script/lib/utils/other/sseParse.d.ts +34 -0
- package/script/lib/utils/other/sseParse.d.ts.map +1 -0
- package/script/lib/utils/other/sseParse.js +45 -0
- package/{esm/lib/helper → script/lib/utils}/request/RESTful.d.ts +43 -11
- package/script/lib/utils/request/RESTful.d.ts.map +1 -0
- package/script/lib/utils/request/RESTful.js +140 -0
- package/script/lib/utils/request/baseConf.d.ts +22 -0
- package/script/lib/utils/request/baseConf.d.ts.map +1 -0
- package/script/lib/utils/request/baseConf.js +42 -0
- package/script/lib/utils/request/factors.d.ts +30 -0
- package/script/lib/utils/request/factors.d.ts.map +1 -0
- package/script/lib/utils/request/factors.js +42 -0
- package/script/lib/{helper → utils}/request/input.d.ts +4 -3
- package/script/lib/utils/request/input.d.ts.map +1 -0
- package/script/lib/{helper → utils}/request/input.js +10 -10
- package/script/lib/utils/request/mod.d.ts +7 -0
- package/script/lib/utils/request/mod.d.ts.map +1 -0
- package/script/lib/utils/request/mod.js +22 -0
- package/script/lib/utils/request/process.d.ts +16 -0
- package/script/lib/utils/request/process.d.ts.map +1 -0
- package/script/lib/utils/request/process.js +41 -0
- package/script/lib/utils/request/wait.d.ts +10 -0
- package/script/lib/utils/request/wait.d.ts.map +1 -0
- package/script/lib/utils/request/wait.js +17 -0
- package/script/lib/utils/response/blobToUrl.d.ts +10 -0
- package/script/lib/utils/response/blobToUrl.d.ts.map +1 -0
- package/script/lib/utils/response/blobToUrl.js +24 -0
- package/script/lib/utils/response/mod.d.ts +5 -0
- package/script/lib/utils/response/mod.d.ts.map +1 -0
- package/script/lib/{helper/request → utils/response}/mod.js +4 -3
- package/script/lib/utils/response/openLink.d.ts +7 -0
- package/script/lib/utils/response/openLink.d.ts.map +1 -0
- package/script/lib/{helper/use/useLoading.js → utils/response/openLink.js} +17 -22
- package/script/lib/utils/response/output.d.ts +16 -0
- package/script/lib/utils/response/output.d.ts.map +1 -0
- package/script/lib/utils/response/output.js +28 -0
- package/script/lib/utils/response/pick.d.ts +23 -0
- package/script/lib/utils/response/pick.d.ts.map +1 -0
- package/script/lib/utils/response/pick.js +28 -0
- package/script/lib/utils/use/mod.d.ts.map +1 -0
- package/script/lib/{helper → utils}/use/mod.js +2 -2
- package/script/lib/utils/use/useCancel.d.ts +33 -0
- package/script/lib/utils/use/useCancel.d.ts.map +1 -0
- package/script/lib/utils/use/useCancel.js +44 -0
- package/script/lib/utils/use/useLoading.d.ts +34 -0
- package/script/lib/utils/use/useLoading.d.ts.map +1 -0
- package/script/lib/utils/use/useLoading.js +60 -0
- package/esm/lib/helper/mod.d.ts.map +0 -1
- package/esm/lib/helper/request/RESTful.d.ts.map +0 -1
- package/esm/lib/helper/request/RESTful.js +0 -1
- package/esm/lib/helper/request/baseConf.d.ts +0 -15
- package/esm/lib/helper/request/baseConf.d.ts.map +0 -1
- package/esm/lib/helper/request/baseConf.js +0 -1
- package/esm/lib/helper/request/input.d.ts.map +0 -1
- package/esm/lib/helper/request/input.js +0 -1
- package/esm/lib/helper/request/mod.d.ts +0 -4
- package/esm/lib/helper/request/mod.d.ts.map +0 -1
- package/esm/lib/helper/request/mod.js +0 -3
- package/esm/lib/helper/response/mod.d.ts +0 -3
- package/esm/lib/helper/response/mod.d.ts.map +0 -1
- package/esm/lib/helper/response/mod.js +0 -2
- package/esm/lib/helper/response/output.d.ts +0 -5
- package/esm/lib/helper/response/output.d.ts.map +0 -1
- package/esm/lib/helper/response/output.js +0 -1
- package/esm/lib/helper/response/pick.d.ts +0 -7
- package/esm/lib/helper/response/pick.d.ts.map +0 -1
- package/esm/lib/helper/response/pick.js +0 -1
- package/esm/lib/helper/use/mod.d.ts.map +0 -1
- package/esm/lib/helper/use/mod.js +0 -2
- package/esm/lib/helper/use/useCancel.d.ts +0 -4
- package/esm/lib/helper/use/useCancel.d.ts.map +0 -1
- package/esm/lib/helper/use/useCancel.js +0 -1
- package/esm/lib/helper/use/useLoading.d.ts +0 -15
- package/esm/lib/helper/use/useLoading.d.ts.map +0 -1
- package/esm/lib/helper/use/useLoading.js +0 -1
- package/script/lib/helper/mod.d.ts.map +0 -1
- package/script/lib/helper/request/RESTful.d.ts.map +0 -1
- package/script/lib/helper/request/RESTful.js +0 -86
- package/script/lib/helper/request/baseConf.d.ts +0 -15
- package/script/lib/helper/request/baseConf.d.ts.map +0 -1
- package/script/lib/helper/request/baseConf.js +0 -27
- package/script/lib/helper/request/input.d.ts.map +0 -1
- package/script/lib/helper/request/mod.d.ts +0 -4
- package/script/lib/helper/request/mod.d.ts.map +0 -1
- package/script/lib/helper/response/mod.d.ts +0 -3
- package/script/lib/helper/response/mod.d.ts.map +0 -1
- package/script/lib/helper/response/output.d.ts +0 -5
- package/script/lib/helper/response/output.d.ts.map +0 -1
- package/script/lib/helper/response/output.js +0 -15
- package/script/lib/helper/response/pick.d.ts +0 -7
- package/script/lib/helper/response/pick.d.ts.map +0 -1
- package/script/lib/helper/response/pick.js +0 -12
- package/script/lib/helper/use/mod.d.ts.map +0 -1
- package/script/lib/helper/use/useCancel.d.ts +0 -4
- package/script/lib/helper/use/useCancel.d.ts.map +0 -1
- package/script/lib/helper/use/useCancel.js +0 -15
- package/script/lib/helper/use/useLoading.d.ts +0 -15
- package/script/lib/helper/use/useLoading.d.ts.map +0 -1
- /package/esm/lib/{helper → utils}/use/mod.d.ts +0 -0
- /package/script/lib/{helper → utils}/use/mod.d.ts +0 -0
package/esm/lib/reqwest/core.js
CHANGED
|
@@ -1,250 +1,160 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
(_0x48dd = function () {
|
|
58
|
-
return _0x590c3d
|
|
59
|
-
}),
|
|
60
|
-
_0x48dd()
|
|
61
|
-
)
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
var __await = (this && this.__await) || function (v) { return this instanceof __await ? (this.v = v, this) : new __await(v); }
|
|
11
|
+
var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) {
|
|
12
|
+
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
13
|
+
var g = generator.apply(thisArg, _arguments || []), i, q = [];
|
|
14
|
+
return i = {}, verb("next"), verb("throw"), verb("return", awaitReturn), i[Symbol.asyncIterator] = function () { return this; }, i;
|
|
15
|
+
function awaitReturn(f) { return function (v) { return Promise.resolve(v).then(f, reject); }; }
|
|
16
|
+
function verb(n, f) { if (g[n]) { i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; if (f) i[n] = f(i[n]); } }
|
|
17
|
+
function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
|
|
18
|
+
function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
|
|
19
|
+
function fulfill(value) { resume("next", value); }
|
|
20
|
+
function reject(value) { resume("throw", value); }
|
|
21
|
+
function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
|
|
22
|
+
};
|
|
23
|
+
/** biome-ignore-all lint/suspicious/noExplicitAny: < core file should ignore any type > */
|
|
24
|
+
import { AbortedError, AnyError, AnyHowError, CheckingError, Err, is_err, is_ok, None, Ok, rjx_ws, throwing, UnexpectedError, } from '@chzky/core';
|
|
25
|
+
import { AxiosError, CanceledError } from 'axios';
|
|
26
|
+
/** 正常的dispatch */
|
|
27
|
+
export function normal_dispatch() {
|
|
28
|
+
const { resolve, promise } = Promise.withResolvers();
|
|
29
|
+
/** request_interceptor */
|
|
30
|
+
this.internal_axios.interceptors.request.use((conf) => __awaiter(this, void 0, void 0, function* () {
|
|
31
|
+
yield request_interceptor_run(conf, this.interceptors_req);
|
|
32
|
+
return conf;
|
|
33
|
+
}));
|
|
34
|
+
/** response_interceptor */
|
|
35
|
+
this.internal_axios.interceptors.response.use((r) => r /* 2xx 范围内的状态码都会触发该函数。 */, throwing /* 超出 2xx 范围的状态码都会触发该函数。 */);
|
|
36
|
+
this.internal_axios({})
|
|
37
|
+
.then((res) => __awaiter(this, void 0, void 0, function* () {
|
|
38
|
+
const result = yield response_interceptor_run(res, this.interceptors_res);
|
|
39
|
+
return Ok(result);
|
|
40
|
+
}))
|
|
41
|
+
.then(resolve, (e) => {
|
|
42
|
+
/* 异常的可能情况
|
|
43
|
+
1. interceptors.request的异常
|
|
44
|
+
1.1 CanceledError - 请求终止错误
|
|
45
|
+
2. interceptors.response超出200~300的code
|
|
46
|
+
3. interceptors.response执行过程中的异常:<返回Err类型,或是执行过程中直接throw>
|
|
47
|
+
*/
|
|
48
|
+
resolve(e instanceof AnyError
|
|
49
|
+
? Err(e)
|
|
50
|
+
: e instanceof CanceledError
|
|
51
|
+
? AbortedError.err(e.message || 'Request has been canceled')
|
|
52
|
+
: e instanceof AxiosError
|
|
53
|
+
? AnyHowError.err(e.message)
|
|
54
|
+
: UnexpectedError.err(e));
|
|
55
|
+
});
|
|
56
|
+
return promise;
|
|
62
57
|
}
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
parseInt(_0x256f3f(0x12b)) / 0x5 +
|
|
73
|
-
-parseInt(_0x256f3f(0x134)) / 0x6 +
|
|
74
|
-
parseInt(_0x256f3f(0x147)) / 0x7 +
|
|
75
|
-
parseInt(_0x256f3f(0x139)) / 0x8 +
|
|
76
|
-
(parseInt(_0x256f3f(0x146)) / 0x9) * (parseInt(_0x256f3f(0x136)) / 0xa)
|
|
77
|
-
if (_0x27d687 === _0x370f46) break
|
|
78
|
-
else _0x1aece0[_0x2f0328(0x15b)](_0x1aece0['shift']())
|
|
79
|
-
} catch (_0x19e562) {
|
|
80
|
-
_0x1aece0[_0x2f0328(0x15b)](_0x1aece0[_0x2f0328(0x157)]())
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
})(_0x48dd, 0xa040e)
|
|
84
|
-
var __awaiter =
|
|
85
|
-
(this && this[_0x331489(0x13f)]) ||
|
|
86
|
-
function (_0x306983, _0x27bc44, _0x32b9f9, _0x18c108) {
|
|
87
|
-
function _0x40fb84(_0x4c88ca) {
|
|
88
|
-
return _0x4c88ca instanceof _0x32b9f9
|
|
89
|
-
? _0x4c88ca
|
|
90
|
-
: new _0x32b9f9(function (_0x372950) {
|
|
91
|
-
_0x372950(_0x4c88ca)
|
|
92
|
-
})
|
|
93
|
-
}
|
|
94
|
-
return new (_0x32b9f9 || (_0x32b9f9 = Promise))(function (_0x8736fa, _0x3942fe) {
|
|
95
|
-
const _0x2b1951 = _0x46bd,
|
|
96
|
-
_0x4a2995 = _0x2059
|
|
97
|
-
function _0x510224(_0x52c938) {
|
|
98
|
-
const _0x5d71d1 = _0x2059
|
|
99
|
-
try {
|
|
100
|
-
_0xee9f05(_0x18c108[_0x5d71d1(0x140)](_0x52c938))
|
|
101
|
-
} catch (_0x525723) {
|
|
102
|
-
_0x3942fe(_0x525723)
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
function _0x44f118(_0x2120f3) {
|
|
106
|
-
const _0x2b937f = _0x2059
|
|
107
|
-
try {
|
|
108
|
-
_0xee9f05(_0x18c108[_0x2b937f(0x13e)](_0x2120f3))
|
|
109
|
-
} catch (_0x2bf162) {
|
|
110
|
-
_0x3942fe(_0x2bf162)
|
|
58
|
+
/** 请求拦截器运行核心 */
|
|
59
|
+
export function request_interceptor_run(conf, arrs) {
|
|
60
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
61
|
+
for (const fn of arrs) {
|
|
62
|
+
const res = yield Promise.resolve(fn(conf));
|
|
63
|
+
if (is_err(res) || is_ok(res))
|
|
64
|
+
res.unwrap(); /* 解包 */
|
|
65
|
+
else
|
|
66
|
+
throw CheckingError.new('RequestInterceptor must return Err<E> or Ok<void>');
|
|
111
67
|
}
|
|
112
|
-
|
|
113
|
-
function _0xee9f05(_0x23b9cb) {
|
|
114
|
-
const _0x40c348 = _0x2059
|
|
115
|
-
_0x23b9cb[_0x40c348(0x12c)]
|
|
116
|
-
? _0x8736fa(_0x23b9cb[_0x40c348(0x12a)])
|
|
117
|
-
: _0x40fb84(_0x23b9cb[_0x40c348(0x12a)])[_0x40c348(0x130)](_0x510224, _0x44f118)
|
|
118
|
-
}
|
|
119
|
-
_0xee9f05(
|
|
120
|
-
(_0x18c108 = _0x18c108[_0x2b1951(0x162)](_0x306983, _0x27bc44 || []))[_0x4a2995(0x140)]()
|
|
121
|
-
)
|
|
122
|
-
})
|
|
123
|
-
}
|
|
124
|
-
import { is_ok, is_err, throwing, AnyError, UnexpectedError, CheckingError, Ok } from '@chzky/fp'
|
|
125
|
-
import { AbortError } from '@chzky/std'
|
|
126
|
-
function _0x5f14() {
|
|
127
|
-
const _0x1c7ea4 = [
|
|
128
|
-
'ResponseInterceptor\x20must\x20return\x20Err<E>\x20or\x20Ok<O>',
|
|
129
|
-
'_interceptors_res',
|
|
130
|
-
'push',
|
|
131
|
-
'_axios',
|
|
132
|
-
'24cUGpup',
|
|
133
|
-
'throw',
|
|
134
|
-
'3vHmLqX',
|
|
135
|
-
'unwrap',
|
|
136
|
-
'done',
|
|
137
|
-
'apply',
|
|
138
|
-
'new',
|
|
139
|
-
'interceptors',
|
|
140
|
-
'30TDKdqb',
|
|
141
|
-
'2809302QzYYWq',
|
|
142
|
-
'_interceptors_req',
|
|
143
|
-
'response',
|
|
144
|
-
'1422769NsDOjj',
|
|
145
|
-
'2284175guJLXQ',
|
|
146
|
-
'4920660QsgvGE',
|
|
147
|
-
'194534pMcrEI',
|
|
148
|
-
'656808kygNYy',
|
|
149
|
-
'4025392hBKjsI',
|
|
150
|
-
'Request\x20has\x20been\x20canceled',
|
|
151
|
-
'next',
|
|
152
|
-
'119hqDCLd',
|
|
153
|
-
'resolve',
|
|
154
|
-
'85996sIPTZH',
|
|
155
|
-
'36786924uNGuGB',
|
|
156
|
-
'445294DBEDoO',
|
|
157
|
-
'err',
|
|
158
|
-
'1003761PQwMMB',
|
|
159
|
-
'3giFlxH',
|
|
160
|
-
'2421850nFOODb',
|
|
161
|
-
'shift',
|
|
162
|
-
'use',
|
|
163
|
-
]
|
|
164
|
-
_0x5f14 = function () {
|
|
165
|
-
return _0x1c7ea4
|
|
166
|
-
}
|
|
167
|
-
return _0x5f14()
|
|
68
|
+
});
|
|
168
69
|
}
|
|
169
|
-
|
|
170
|
-
export function
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
(_0x1a90bb) => _0x1a90bb,
|
|
183
|
-
throwing
|
|
184
|
-
),
|
|
185
|
-
this[_0x163234(0x145)]({})
|
|
186
|
-
[_0x163234(0x130)]((_0x1c7116) =>
|
|
187
|
-
__awaiter(this, void 0x0, void 0x0, function* () {
|
|
188
|
-
const _0x102966 = _0x163234,
|
|
189
|
-
_0x1e024e = yield response_interceptor_run(_0x1c7116, this[_0x102966(0x13d)])
|
|
190
|
-
return Ok(_0x1e024e)
|
|
191
|
-
})
|
|
192
|
-
)
|
|
193
|
-
['then'](_0x32a4c1, (_0x2cab37) => {
|
|
194
|
-
const _0x16568a = _0x163234
|
|
195
|
-
_0x32a4c1(
|
|
196
|
-
_0x2cab37 instanceof AnyError
|
|
197
|
-
? _0x2cab37
|
|
198
|
-
: _0x2cab37 instanceof CanceledError
|
|
199
|
-
? AbortError[_0x16568a(0x137)](_0x16568a(0x132))
|
|
200
|
-
: UnexpectedError[_0x16568a(0x137)](_0x2cab37)
|
|
201
|
-
)
|
|
202
|
-
}),
|
|
203
|
-
_0x425065
|
|
204
|
-
)
|
|
70
|
+
/** 响应拦截器运行核心 */
|
|
71
|
+
export function response_interceptor_run(res, arrs) {
|
|
72
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
73
|
+
let result = res;
|
|
74
|
+
for (const fn of arrs) {
|
|
75
|
+
result = yield Promise.resolve(fn(result));
|
|
76
|
+
if (is_err(result) || is_ok(result))
|
|
77
|
+
result = result.unwrap(); /* 解包 */
|
|
78
|
+
else
|
|
79
|
+
throw CheckingError.new('ResponseInterceptor must return Err<E> or Ok<O>');
|
|
80
|
+
}
|
|
81
|
+
return result;
|
|
82
|
+
});
|
|
205
83
|
}
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
84
|
+
const is_aborteder = (err) => err instanceof DOMException && err.name === 'AbortError';
|
|
85
|
+
const cleanup_reader = (readerr) => __awaiter(void 0, void 0, void 0, function* () {
|
|
86
|
+
/**
|
|
87
|
+
1. 数据读取完毕
|
|
88
|
+
2. gen被关闭读取
|
|
89
|
+
3. aborted
|
|
90
|
+
*/
|
|
91
|
+
try {
|
|
92
|
+
yield (readerr === null || readerr === void 0 ? void 0 : readerr.cancel());
|
|
213
93
|
}
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
function _0x2059(_0x146acf, _0x37bf35) {
|
|
217
|
-
const _0x24d0bb = _0x48dd()
|
|
218
|
-
return (
|
|
219
|
-
(_0x2059 = function (_0x2feba2, _0x539a61) {
|
|
220
|
-
_0x2feba2 = _0x2feba2 - 0x12a
|
|
221
|
-
let _0x44ddef = _0x24d0bb[_0x2feba2]
|
|
222
|
-
return _0x44ddef
|
|
223
|
-
}),
|
|
224
|
-
_0x2059(_0x146acf, _0x37bf35)
|
|
225
|
-
)
|
|
226
|
-
}
|
|
227
|
-
function _0x46bd(_0xc756f8, _0x142471) {
|
|
228
|
-
const _0x5f14b9 = _0x5f14()
|
|
229
|
-
return (
|
|
230
|
-
(_0x46bd = function (_0x46bd96, _0x1de341) {
|
|
231
|
-
_0x46bd96 = _0x46bd96 - 0x151
|
|
232
|
-
let _0x36625f = _0x5f14b9[_0x46bd96]
|
|
233
|
-
return _0x36625f
|
|
234
|
-
}),
|
|
235
|
-
_0x46bd(_0xc756f8, _0x142471)
|
|
236
|
-
)
|
|
237
|
-
}
|
|
238
|
-
export function response_interceptor_run(_0x5e0884, _0x13a7fe) {
|
|
239
|
-
return __awaiter(this, void 0x0, void 0x0, function* () {
|
|
240
|
-
const _0x213429 = _0x46bd,
|
|
241
|
-
_0x5d58b8 = _0x2059
|
|
242
|
-
let _0x478f66 = _0x5e0884
|
|
243
|
-
for (const _0x407d0f of _0x13a7fe) {
|
|
244
|
-
_0x478f66 = yield Promise[_0x5d58b8(0x12f)](_0x407d0f(_0x478f66))
|
|
245
|
-
if (is_err(_0x478f66) || is_ok(_0x478f66)) _0x478f66 = _0x478f66[_0x5d58b8(0x144)]()
|
|
246
|
-
else throw CheckingError[_0x213429(0x163)](_0x5d58b8(0x143))
|
|
94
|
+
catch (_) {
|
|
95
|
+
// ignore exception
|
|
247
96
|
}
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
97
|
+
});
|
|
98
|
+
/** sse请求转Generator */
|
|
99
|
+
export const see_reqwest = (conf) => {
|
|
100
|
+
const { url, abort, method = 'GET' } = conf;
|
|
101
|
+
let response;
|
|
102
|
+
let reader;
|
|
103
|
+
const init_reader = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
104
|
+
var _a;
|
|
105
|
+
if (reader !== undefined)
|
|
106
|
+
return;
|
|
107
|
+
response = yield fetch(url, {
|
|
108
|
+
method,
|
|
109
|
+
headers: {
|
|
110
|
+
Accept: 'text/event-stream',
|
|
111
|
+
'Cache-Control': 'no-cache',
|
|
112
|
+
},
|
|
113
|
+
signal: abort ? (abort instanceof AbortController ? abort.signal : abort) : undefined,
|
|
114
|
+
});
|
|
115
|
+
const lreader = (_a = response.body) === null || _a === void 0 ? void 0 : _a.getReader();
|
|
116
|
+
if (lreader === undefined)
|
|
117
|
+
throw None;
|
|
118
|
+
reader = lreader;
|
|
119
|
+
});
|
|
120
|
+
function start_sse() {
|
|
121
|
+
return __asyncGenerator(this, arguments, function* start_sse_1() {
|
|
122
|
+
try {
|
|
123
|
+
yield __await(init_reader());
|
|
124
|
+
}
|
|
125
|
+
catch (_) {
|
|
126
|
+
return yield __await(void 0);
|
|
127
|
+
}
|
|
128
|
+
try {
|
|
129
|
+
while (true) {
|
|
130
|
+
const { done, value } = yield __await(reader.read());
|
|
131
|
+
if (done)
|
|
132
|
+
break;
|
|
133
|
+
yield yield __await(value);
|
|
134
|
+
}
|
|
135
|
+
return yield __await(void 0);
|
|
136
|
+
}
|
|
137
|
+
catch (error) {
|
|
138
|
+
if (!is_aborteder(error))
|
|
139
|
+
throw error;
|
|
140
|
+
}
|
|
141
|
+
finally {
|
|
142
|
+
yield __await(cleanup_reader(reader));
|
|
143
|
+
}
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
return start_sse();
|
|
147
|
+
};
|
|
148
|
+
const default_deserialize = (data) => JSON.parse(data.data);
|
|
149
|
+
const default_serialize = (data) => JSON.stringify(data);
|
|
150
|
+
export const ws_reqwest = (conf) => {
|
|
151
|
+
const { url, abort, deserialize = default_deserialize, serialize = default_serialize } = conf;
|
|
152
|
+
const subject = rjx_ws.webSocket({ url, serializer: serialize, deserializer: deserialize });
|
|
153
|
+
if (abort instanceof AbortController) {
|
|
154
|
+
abort === null || abort === void 0 ? void 0 : abort.signal.addEventListener('abort', subject.complete.bind(subject));
|
|
155
|
+
}
|
|
156
|
+
else {
|
|
157
|
+
abort === null || abort === void 0 ? void 0 : abort.addEventListener('abort', subject.complete.bind(subject));
|
|
158
|
+
}
|
|
159
|
+
return subject;
|
|
160
|
+
};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/** 工厂函数,省去类型声明的步骤 */
|
|
2
|
-
import type { RequestInterceptor,
|
|
2
|
+
import type { MergeErrors, RequestInterceptor, ReqwestInterceptor, ResponseInterceptor } from './interface.js';
|
|
3
3
|
/** ### `merge_request` : 工厂函数 of `Reqwest-request`
|
|
4
4
|
+ 将多个request拦截器合并成一个拦截器
|
|
5
5
|
*/
|
|
6
|
-
export declare function merge_request<Interceptors extends RequestInterceptor<
|
|
6
|
+
export declare function merge_request<Interceptors extends RequestInterceptor<unknown>[]>(...interceptors: Interceptors): RequestInterceptor<MergeErrors<Interceptors>>;
|
|
7
7
|
/** ### `merge_response` : 工厂函数 of `Reqwest-response`
|
|
8
8
|
+ 将多个response拦截器合并成一个拦截器
|
|
9
9
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"factor.d.ts","sourceRoot":"","sources":["../../../src/lib/reqwest/factor.ts"],"names":[],"mappings":"AAAA,qBAAqB;
|
|
1
|
+
{"version":3,"file":"factor.d.ts","sourceRoot":"","sources":["../../../src/lib/reqwest/factor.ts"],"names":[],"mappings":"AAAA,qBAAqB;AAErB,OAAO,KAAK,EACX,WAAW,EACX,kBAAkB,EAClB,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,CAAC;IAC/B,mBAAmB,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC;IAC/B,mBAAmB,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC;IAC/B,mBAAmB,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC;IAC/B,mBAAmB,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC;IAC/B,mBAAmB,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC;IAC/B,mBAAmB,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC;CAC/B,GACC,mBAAmB,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,CAAA;AASxE;;EAEE;AACF,wBAAgB,aAAa,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,EAAE,EAAE,EACzC,OAAO,EAAE,kBAAkB,CAAC,CAAC,CAAC,EAC9B,QAAQ,EAAE,mBAAmB,CAAC,CAAC,EAAE,EAAE,EAAE,EAAE,CAAC,GACtC,kBAAkB,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,EAAE,EAAE,CAAC,CAElC"}
|
|
@@ -1 +1,32 @@
|
|
|
1
|
-
|
|
1
|
+
/** 工厂函数,省去类型声明的步骤 */
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
import { Ok } from '@chzky/core';
|
|
12
|
+
import { request_interceptor_run, response_interceptor_run } from './core.js';
|
|
13
|
+
/** ### `merge_request` : 工厂函数 of `Reqwest-request`
|
|
14
|
+
+ 将多个request拦截器合并成一个拦截器
|
|
15
|
+
*/
|
|
16
|
+
export function merge_request(...interceptors) {
|
|
17
|
+
return (conf) => __awaiter(this, void 0, void 0, function* () {
|
|
18
|
+
yield request_interceptor_run(conf, interceptors);
|
|
19
|
+
return Ok();
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
export function merge_response(...interceptor) {
|
|
23
|
+
return (res) => __awaiter(this, void 0, void 0, function* () {
|
|
24
|
+
return yield response_interceptor_run(res, interceptor);
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
/** ### `merge_response` : 工厂函数 of `Reqwest-use`
|
|
28
|
+
+ 快捷生成`ReqwestInterceptor`供`use`使用
|
|
29
|
+
*/
|
|
30
|
+
export function merge_reqwest(request, response) {
|
|
31
|
+
return { request, response };
|
|
32
|
+
}
|