@zyzgroup/core-web 0.0.83 → 0.0.84
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/zyzgroup_core_web.iife.js +12 -12
- package/dist/zyzgroup_core_web.iife.js.map +1 -1
- package/dist/zyzgroup_core_web.js +40 -47
- package/dist/zyzgroup_core_web.js.map +1 -1
- package/dist/zyzgroup_core_web.umd.cjs +12 -12
- package/dist/zyzgroup_core_web.umd.cjs.map +1 -1
- package/package.json +1 -1
- package/types/axios.d.ts +11 -18
- package/types/axios.d.ts.map +1 -1
|
@@ -11175,65 +11175,57 @@ async function Qh(n, t = "SHA-256") {
|
|
|
11175
11175
|
}
|
|
11176
11176
|
class Tl {
|
|
11177
11177
|
instance;
|
|
11178
|
-
|
|
11179
|
-
|
|
11178
|
+
// Alter defaults after instance has been created
|
|
11179
|
+
// axios.defaults.baseURL = "";
|
|
11180
|
+
// axios.defaults.timeout = 30000;
|
|
11181
|
+
// axios.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded;charset=UTF-8';
|
|
11182
|
+
// axios.defaults.headers.post.Accept = 'application/json';
|
|
11183
|
+
// axios.defaults.responseType = 'json'; // json | stream
|
|
11184
|
+
// .then(function (response) {response.data.pipe(fs.createWriteStream('xxx.jpg'))});
|
|
11180
11185
|
constructor(t) {
|
|
11181
|
-
this.instance = Zh.create(t)
|
|
11182
|
-
|
|
11183
|
-
|
|
11184
|
-
|
|
11185
|
-
|
|
11186
|
-
|
|
11186
|
+
this.instance = Zh.create(t);
|
|
11187
|
+
const e = new tc();
|
|
11188
|
+
this.instance.interceptors.request.use(
|
|
11189
|
+
(s) => (e.pendingRequest(s), s),
|
|
11190
|
+
(s) => (e.cancelRequest(s.config), s)
|
|
11191
|
+
), t?.interceptor && (this.instance.interceptors.request.use(
|
|
11192
|
+
t.interceptor.request,
|
|
11193
|
+
t.interceptor.requestError
|
|
11187
11194
|
), this.instance.interceptors.response.use(
|
|
11188
|
-
|
|
11189
|
-
|
|
11190
|
-
), this.instance.interceptors.response.use(
|
|
11191
|
-
(
|
|
11192
|
-
|
|
11193
|
-
|
|
11194
|
-
|
|
11195
|
-
|
|
11196
|
-
|
|
11197
|
-
setTimeout(() => {
|
|
11198
|
-
r(void 0);
|
|
11199
|
-
}, i.retryDelay);
|
|
11200
|
-
}), await this.request(i));
|
|
11195
|
+
t.interceptor.response,
|
|
11196
|
+
t.interceptor.responseError
|
|
11197
|
+
)), this.instance.interceptors.response.use(
|
|
11198
|
+
async (s) => (await e.confirmRequest(s.config), s.data),
|
|
11199
|
+
async (s) => {
|
|
11200
|
+
const { code: i = "", config: r } = s;
|
|
11201
|
+
return !r || !r.retry || (r.retryCounted = r.retryCounted || 0, r.retryCounted >= r.retry) ? Promise.reject(s) : (r.retryCounted++, await new Promise((a) => {
|
|
11202
|
+
setTimeout(a, r.retryDelay);
|
|
11203
|
+
}), await this.request(r));
|
|
11201
11204
|
}
|
|
11202
11205
|
);
|
|
11203
11206
|
}
|
|
11204
|
-
|
|
11205
|
-
|
|
11206
|
-
return new Promise((e, s) => {
|
|
11207
|
-
try {
|
|
11208
|
-
t.interceptors?.requestInterceptor && (t = t.interceptors?.requestInterceptor(t)), this.instance.request(t).then((i) => {
|
|
11209
|
-
t.interceptors?.responseInterceptor && (i = t.interceptors.responseInterceptor(i)), e(i);
|
|
11210
|
-
}).catch((i) => {
|
|
11211
|
-
t.interceptors?.responseInterceptorCatch && (i = t.interceptors?.responseInterceptorCatch(i)), s(i);
|
|
11212
|
-
});
|
|
11213
|
-
} catch (i) {
|
|
11214
|
-
t.interceptors?.requestInterceptorCatch && t.interceptors.requestInterceptorCatch(i);
|
|
11215
|
-
}
|
|
11216
|
-
});
|
|
11207
|
+
async request(t) {
|
|
11208
|
+
return await this.instance.request(t);
|
|
11217
11209
|
}
|
|
11218
|
-
get(t, e) {
|
|
11210
|
+
async get(t, e) {
|
|
11219
11211
|
return this.request({ ...e, method: "get", url: t });
|
|
11220
11212
|
}
|
|
11221
|
-
delete(t, e) {
|
|
11213
|
+
async delete(t, e) {
|
|
11222
11214
|
return this.request({ ...e, method: "delete", url: t });
|
|
11223
11215
|
}
|
|
11224
|
-
head(t, e) {
|
|
11216
|
+
async head(t, e) {
|
|
11225
11217
|
return this.request({ ...e, method: "head", url: t });
|
|
11226
11218
|
}
|
|
11227
|
-
options(t, e) {
|
|
11219
|
+
async options(t, e) {
|
|
11228
11220
|
return this.request({ ...e, method: "options", url: t });
|
|
11229
11221
|
}
|
|
11230
|
-
post(t, e, s) {
|
|
11222
|
+
async post(t, e, s) {
|
|
11231
11223
|
return this.request({ ...s, method: "post", url: t, data: e });
|
|
11232
11224
|
}
|
|
11233
|
-
put(t, e, s) {
|
|
11225
|
+
async put(t, e, s) {
|
|
11234
11226
|
return this.request({ ...s, method: "put", url: t, data: e });
|
|
11235
11227
|
}
|
|
11236
|
-
patch(t, e, s) {
|
|
11228
|
+
async patch(t, e, s) {
|
|
11237
11229
|
return this.request({ ...s, method: "patch", url: t, data: e });
|
|
11238
11230
|
}
|
|
11239
11231
|
getUri(t) {
|
|
@@ -11245,6 +11237,10 @@ class tc {
|
|
|
11245
11237
|
constructor() {
|
|
11246
11238
|
this.pendingRequestMap = /* @__PURE__ */ new Map();
|
|
11247
11239
|
}
|
|
11240
|
+
async getRequestId(t) {
|
|
11241
|
+
const { url: e, method: s, params: i, data: r } = t;
|
|
11242
|
+
return await Qh({ url: e, method: s, params: i, data: r });
|
|
11243
|
+
}
|
|
11248
11244
|
async pendingRequest(t) {
|
|
11249
11245
|
const e = await this.getRequestId(t);
|
|
11250
11246
|
if (this.pendingRequestMap.has(e))
|
|
@@ -11267,14 +11263,11 @@ class tc {
|
|
|
11267
11263
|
this.pendingRequestMap.has(e) && (this.pendingRequestMap.get(e)?.abort(), this.pendingRequestMap.delete(e));
|
|
11268
11264
|
}
|
|
11269
11265
|
async cancelAllRequest() {
|
|
11270
|
-
|
|
11271
|
-
|
|
11266
|
+
const t = this.pendingRequestMap.values();
|
|
11267
|
+
for (const e of t)
|
|
11268
|
+
e.abort();
|
|
11272
11269
|
this.pendingRequestMap.clear();
|
|
11273
11270
|
}
|
|
11274
|
-
async getRequestId(t) {
|
|
11275
|
-
const { url: e, method: s, params: i, data: r } = t;
|
|
11276
|
-
return await Qh({ url: e, method: s, params: i, data: r });
|
|
11277
|
-
}
|
|
11278
11271
|
}
|
|
11279
11272
|
function Pl(n, t, e, s, i) {
|
|
11280
11273
|
const r = t / e;
|