@chzky/reqwest 0.0.1 → 0.1.1
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/core/class.d.ts +122 -0
- package/esm/lib/core/class.d.ts.map +1 -0
- package/esm/lib/core/class.js +173 -0
- package/esm/lib/core/core.d.ts +11 -0
- package/esm/lib/core/core.d.ts.map +1 -0
- package/esm/lib/core/core.js +157 -0
- package/esm/lib/{reqwest → core}/factor.d.ts +57 -9
- package/esm/lib/core/factor.d.ts.map +1 -0
- package/esm/lib/core/factor.js +48 -0
- package/esm/lib/core/interface.d.ts +172 -0
- package/esm/lib/core/interface.d.ts.map +1 -0
- package/esm/lib/core/interface.js +1 -0
- package/esm/lib/core/mod.d.ts +5 -0
- package/esm/lib/core/mod.d.ts.map +1 -0
- package/esm/lib/core/mod.js +3 -0
- package/esm/lib/helper/mod.d.ts +2 -0
- package/esm/lib/helper/mod.d.ts.map +1 -1
- package/esm/lib/helper/mod.js +2 -0
- package/esm/lib/helper/other/mod.d.ts +2 -0
- package/esm/lib/helper/other/mod.d.ts.map +1 -0
- package/esm/lib/helper/other/mod.js +1 -0
- package/esm/lib/helper/other/sseParse.d.ts +34 -0
- package/esm/lib/helper/other/sseParse.d.ts.map +1 -0
- package/esm/lib/helper/other/sseParse.js +42 -0
- package/esm/lib/helper/request/RESTful.d.ts +43 -11
- package/esm/lib/helper/request/RESTful.d.ts.map +1 -1
- package/esm/lib/helper/request/RESTful.js +129 -1
- package/esm/lib/helper/request/baseConf.d.ts +11 -4
- package/esm/lib/helper/request/baseConf.d.ts.map +1 -1
- package/esm/lib/helper/request/baseConf.js +37 -1
- package/esm/lib/helper/request/factors.d.ts +31 -0
- package/esm/lib/helper/request/factors.d.ts.map +1 -0
- package/esm/lib/helper/request/factors.js +40 -0
- package/esm/lib/helper/request/input.d.ts +5 -4
- package/esm/lib/helper/request/input.d.ts.map +1 -1
- package/esm/lib/helper/request/input.js +24 -1
- package/esm/lib/helper/request/mod.d.ts +4 -1
- package/esm/lib/helper/request/mod.d.ts.map +1 -1
- package/esm/lib/helper/request/mod.js +6 -3
- package/esm/lib/helper/request/process.d.ts +16 -0
- package/esm/lib/helper/request/process.d.ts.map +1 -0
- package/esm/lib/helper/request/process.js +37 -0
- package/esm/lib/helper/request/wait.d.ts +9 -0
- package/esm/lib/helper/request/wait.d.ts.map +1 -0
- package/esm/lib/helper/request/wait.js +13 -0
- package/esm/lib/helper/response/blobToUrl.d.ts +11 -0
- package/esm/lib/helper/response/blobToUrl.d.ts.map +1 -0
- package/esm/lib/helper/response/blobToUrl.js +22 -0
- package/esm/lib/helper/response/mod.d.ts +3 -1
- package/esm/lib/helper/response/mod.d.ts.map +1 -1
- package/esm/lib/helper/response/mod.js +4 -2
- package/esm/lib/helper/response/openLink.d.ts +8 -0
- package/esm/lib/helper/response/openLink.d.ts.map +1 -0
- package/esm/lib/helper/response/openLink.js +21 -0
- package/esm/lib/helper/response/output.d.ts +14 -3
- package/esm/lib/helper/response/output.d.ts.map +1 -1
- package/esm/lib/helper/response/output.js +24 -1
- package/esm/lib/helper/response/pick.d.ts +19 -2
- package/esm/lib/helper/response/pick.d.ts.map +1 -1
- package/esm/lib/helper/response/pick.js +26 -1
- package/esm/lib/helper/use/mod.js +2 -2
- package/esm/lib/helper/use/useCancel.d.ts +32 -2
- package/esm/lib/helper/use/useCancel.d.ts.map +1 -1
- package/esm/lib/helper/use/useCancel.js +42 -1
- package/esm/lib/helper/use/useLoading.d.ts +27 -7
- package/esm/lib/helper/use/useLoading.d.ts.map +1 -1
- package/esm/lib/helper/use/useLoading.js +58 -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/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/core/class.d.ts +122 -0
- package/script/lib/core/class.d.ts.map +1 -0
- package/script/lib/core/class.js +180 -0
- package/script/lib/core/core.d.ts +11 -0
- package/script/lib/core/core.d.ts.map +1 -0
- package/script/lib/core/core.js +165 -0
- package/script/lib/{reqwest → core}/factor.d.ts +57 -9
- package/script/lib/core/factor.d.ts.map +1 -0
- package/script/lib/{reqwest → core}/factor.js +24 -8
- package/script/lib/core/interface.d.ts +172 -0
- package/script/lib/core/interface.d.ts.map +1 -0
- package/script/lib/core/mod.d.ts +5 -0
- package/script/lib/core/mod.d.ts.map +1 -0
- package/script/lib/{reqwest → core}/mod.js +1 -0
- package/script/lib/helper/mod.d.ts +2 -0
- package/script/lib/helper/mod.d.ts.map +1 -1
- package/script/lib/helper/mod.js +2 -0
- package/script/lib/helper/other/mod.d.ts +2 -0
- package/script/lib/helper/other/mod.d.ts.map +1 -0
- package/script/lib/helper/other/mod.js +17 -0
- package/script/lib/helper/other/sseParse.d.ts +34 -0
- package/script/lib/helper/other/sseParse.d.ts.map +1 -0
- package/script/lib/helper/other/sseParse.js +45 -0
- package/script/lib/helper/request/RESTful.d.ts +43 -11
- package/script/lib/helper/request/RESTful.d.ts.map +1 -1
- package/script/lib/helper/request/RESTful.js +75 -21
- package/script/lib/helper/request/baseConf.d.ts +11 -4
- package/script/lib/helper/request/baseConf.d.ts.map +1 -1
- package/script/lib/helper/request/baseConf.js +25 -10
- package/script/lib/helper/request/factors.d.ts +31 -0
- package/script/lib/helper/request/factors.d.ts.map +1 -0
- package/script/lib/helper/request/factors.js +43 -0
- package/script/lib/helper/request/input.d.ts +5 -4
- package/script/lib/helper/request/input.d.ts.map +1 -1
- package/script/lib/helper/request/input.js +11 -11
- package/script/lib/helper/request/mod.d.ts +4 -1
- package/script/lib/helper/request/mod.d.ts.map +1 -1
- package/script/lib/helper/request/mod.js +6 -3
- package/script/lib/helper/request/process.d.ts +16 -0
- package/script/lib/helper/request/process.d.ts.map +1 -0
- package/script/lib/helper/request/process.js +41 -0
- package/script/lib/helper/request/wait.d.ts +9 -0
- package/script/lib/helper/request/wait.d.ts.map +1 -0
- package/script/lib/helper/request/wait.js +16 -0
- package/script/lib/helper/response/blobToUrl.d.ts +11 -0
- package/script/lib/helper/response/blobToUrl.d.ts.map +1 -0
- package/script/lib/helper/response/blobToUrl.js +25 -0
- package/script/lib/helper/response/mod.d.ts +3 -1
- package/script/lib/helper/response/mod.d.ts.map +1 -1
- package/script/lib/helper/response/mod.js +4 -2
- package/script/lib/helper/response/openLink.d.ts +8 -0
- package/script/lib/helper/response/openLink.d.ts.map +1 -0
- package/script/lib/helper/response/openLink.js +47 -0
- package/script/lib/helper/response/output.d.ts +14 -3
- package/script/lib/helper/response/output.d.ts.map +1 -1
- package/script/lib/helper/response/output.js +20 -7
- package/script/lib/helper/response/pick.d.ts +19 -2
- package/script/lib/helper/response/pick.d.ts.map +1 -1
- package/script/lib/helper/response/pick.js +22 -5
- package/script/lib/helper/use/mod.js +2 -2
- package/script/lib/helper/use/useCancel.d.ts +32 -2
- package/script/lib/helper/use/useCancel.d.ts.map +1 -1
- package/script/lib/helper/use/useCancel.js +37 -7
- package/script/lib/helper/use/useLoading.d.ts +27 -7
- package/script/lib/helper/use/useLoading.d.ts.map +1 -1
- package/script/lib/helper/use/useLoading.js +56 -46
- 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/esm/lib/reqwest/class.d.ts +0 -84
- package/esm/lib/reqwest/class.d.ts.map +0 -1
- package/esm/lib/reqwest/class.js +0 -1
- package/esm/lib/reqwest/core.d.ts +0 -6
- package/esm/lib/reqwest/core.d.ts.map +0 -1
- package/esm/lib/reqwest/core.js +0 -250
- package/esm/lib/reqwest/factor.d.ts.map +0 -1
- package/esm/lib/reqwest/factor.js +0 -1
- package/esm/lib/reqwest/interface.d.ts +0 -48
- package/esm/lib/reqwest/interface.d.ts.map +0 -1
- package/esm/lib/reqwest/interface.js +0 -1
- package/esm/lib/reqwest/mod.d.ts +0 -4
- package/esm/lib/reqwest/mod.d.ts.map +0 -1
- package/esm/lib/reqwest/mod.js +0 -2
- package/script/lib/reqwest/class.d.ts +0 -84
- package/script/lib/reqwest/class.d.ts.map +0 -1
- package/script/lib/reqwest/class.js +0 -72
- package/script/lib/reqwest/core.d.ts +0 -6
- package/script/lib/reqwest/core.d.ts.map +0 -1
- package/script/lib/reqwest/core.js +0 -72
- package/script/lib/reqwest/factor.d.ts.map +0 -1
- package/script/lib/reqwest/interface.d.ts +0 -23
- package/script/lib/reqwest/interface.d.ts.map +0 -1
- package/script/lib/reqwest/mod.d.ts +0 -4
- package/script/lib/reqwest/mod.d.ts.map +0 -1
- /package/script/lib/{reqwest → core}/interface.js +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"process.d.ts","sourceRoot":"","sources":["../../../../src/lib/helper/request/process.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAA;AAEpD;;;;;EAKE;AACF,MAAM,CAAC,OAAO,UAAU,cAAc,CACrC,QAAQ,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,GACjC,kBAAkB,CAAC,KAAK,CAAC,CAS3B;AAED;;;;;EAKE;AACF,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,GAAG,kBAAkB,CAAC,KAAK,CAAC,CAU/F"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { Ok } from '@chzky/core';
|
|
2
|
+
/** ## `upload_process` : 上传进度查询(浏览器专属)
|
|
3
|
+
+ 进度只保留两位小数,即`xx.yy%`
|
|
4
|
+
+ 存在两种情况,进度不可计算时,返回`-1%`
|
|
5
|
+
+ `event.lengthComputable`为`false` (长度不可计算)
|
|
6
|
+
+ `event.total`为`0`(数据的总大小不可知)
|
|
7
|
+
*/
|
|
8
|
+
export default function upload_process(progress) {
|
|
9
|
+
return conf => {
|
|
10
|
+
conf.onUploadProgress = event => {
|
|
11
|
+
if (event.lengthComputable && event.total) {
|
|
12
|
+
progress(Number.parseFloat(((event.loaded * 100) / event.total).toFixed(2)));
|
|
13
|
+
}
|
|
14
|
+
else
|
|
15
|
+
progress(-1);
|
|
16
|
+
};
|
|
17
|
+
return Ok();
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
/** ## `download_process` : 下载进度查询(浏览器专属)
|
|
21
|
+
+ 进度只保留两位小数,即`xx.yy%`
|
|
22
|
+
+ 存在两种情况,进度不可计算时,返回`-1%`
|
|
23
|
+
+ `event.lengthComputable`为`false` (长度不可计算)
|
|
24
|
+
+ `event.total`为`0`(数据的总大小不可知)
|
|
25
|
+
*/
|
|
26
|
+
export function download_process(progress) {
|
|
27
|
+
return conf => {
|
|
28
|
+
conf.onDownloadProgress = event => {
|
|
29
|
+
if (event.lengthComputable && event.total) {
|
|
30
|
+
progress(Number.parseFloat(((event.loaded * 100) / event.total).toFixed(2)));
|
|
31
|
+
}
|
|
32
|
+
else
|
|
33
|
+
progress(-1);
|
|
34
|
+
};
|
|
35
|
+
return Ok();
|
|
36
|
+
};
|
|
37
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { PositiveInteger } from '@chzky/core';
|
|
2
|
+
import type { RequestInterceptor } from '../../../mod.js';
|
|
3
|
+
/** ## `wait` : 等待指定时间后继续执行请求
|
|
4
|
+
@param time `PositiveInteger<N>` - The time to wait in milliseconds (must be a positive integer)@type `Interceptor` - `Request`
|
|
5
|
+
@returns A Promise that resolves after the specified time delay
|
|
6
|
+
@category Helper
|
|
7
|
+
*/
|
|
8
|
+
export declare function wait<N extends number>(time: PositiveInteger<N>): RequestInterceptor<never>;
|
|
9
|
+
//# sourceMappingURL=wait.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wait.d.ts","sourceRoot":"","sources":["../../../../src/lib/helper/request/wait.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAClD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAA;AAIzD;;;;GAIG;AACH,wBAAgB,IAAI,CAAC,CAAC,SAAS,MAAM,EAAE,IAAI,EAAE,eAAe,CAAC,CAAC,CAAC,GAAG,kBAAkB,CAAC,KAAK,CAAC,CAO1F"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Ok } from '@chzky/core';
|
|
2
|
+
/** ## `wait` : 等待指定时间后继续执行请求
|
|
3
|
+
@param time `PositiveInteger<N>` - The time to wait in milliseconds (must be a positive integer)@type `Interceptor` - `Request`
|
|
4
|
+
@returns A Promise that resolves after the specified time delay
|
|
5
|
+
@category Helper
|
|
6
|
+
*/
|
|
7
|
+
export function wait(time) {
|
|
8
|
+
return () => new Promise(res => {
|
|
9
|
+
setTimeout(() => {
|
|
10
|
+
res(Ok());
|
|
11
|
+
}, time);
|
|
12
|
+
});
|
|
13
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { ResponseInterceptor } from '../../../mod.js';
|
|
2
|
+
/** ## blob2url : `blob`转化成`url`,赋值在`src`字段上
|
|
3
|
+
+ 一般用于
|
|
4
|
+
1. 图片显示
|
|
5
|
+
2. 显示PDF
|
|
6
|
+
@returns [`revoke`:用于取消对`ObjectURL`对象的引用, `interceptor`:拦截器]
|
|
7
|
+
@type `Interceptor` - `Response`
|
|
8
|
+
@category Helper
|
|
9
|
+
*/
|
|
10
|
+
export declare function blob2url(): [() => void, ResponseInterceptor<Blob, string, never>];
|
|
11
|
+
//# sourceMappingURL=blobToUrl.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"blobToUrl.d.ts","sourceRoot":"","sources":["../../../../src/lib/helper/response/blobToUrl.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAA;AAI1D;;;;;;;EAOE;AACF,wBAAgB,QAAQ,IAAI,CAAC,MAAM,IAAI,EAAE,mBAAmB,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,CAAC,CAAC,CAWjF"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { Ok } from '@chzky/core';
|
|
2
|
+
/** ## blob2url : `blob`转化成`url`,赋值在`src`字段上
|
|
3
|
+
+ 一般用于
|
|
4
|
+
1. 图片显示
|
|
5
|
+
2. 显示PDF
|
|
6
|
+
@returns [`revoke`:用于取消对`ObjectURL`对象的引用, `interceptor`:拦截器]
|
|
7
|
+
@type `Interceptor` - `Response`
|
|
8
|
+
@category Helper
|
|
9
|
+
*/
|
|
10
|
+
export function blob2url() {
|
|
11
|
+
let object_url;
|
|
12
|
+
return [
|
|
13
|
+
() => {
|
|
14
|
+
if (object_url)
|
|
15
|
+
URL.revokeObjectURL(object_url);
|
|
16
|
+
},
|
|
17
|
+
blob => {
|
|
18
|
+
object_url = URL.createObjectURL(blob);
|
|
19
|
+
return Ok(object_url);
|
|
20
|
+
},
|
|
21
|
+
];
|
|
22
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../../../../src/lib/helper/response/mod.ts"],"names":[],"mappings":"AAAA,cAAc,
|
|
1
|
+
{"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../../../../src/lib/helper/response/mod.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAA;AAC9B,cAAc,eAAe,CAAA;AAC7B,cAAc,aAAa,CAAA;AAC3B,cAAc,WAAW,CAAA"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { ResponseInterceptor } from '../../../mod.js';
|
|
2
|
+
/** ### `open_link` : 将获取到的blob文件直接进行下载
|
|
3
|
+
@tips : 只能在浏览器环境下使用,在非浏览器环境下会直接返回blob
|
|
4
|
+
@type `Interceptor` - `Response`
|
|
5
|
+
@category Helper
|
|
6
|
+
*/
|
|
7
|
+
export declare function open_link(name: string): ResponseInterceptor<Blob, Blob, never>;
|
|
8
|
+
//# sourceMappingURL=openLink.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"openLink.d.ts","sourceRoot":"","sources":["../../../../src/lib/helper/response/openLink.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAA;AAI1D;;;;EAIE;AACF,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,mBAAmB,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,CAAC,CAY9E"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import * as dntShim from "../../../_dnt.shims.js";
|
|
2
|
+
import { Ok } from '@chzky/core';
|
|
3
|
+
/** ### `open_link` : 将获取到的blob文件直接进行下载
|
|
4
|
+
@tips : 只能在浏览器环境下使用,在非浏览器环境下会直接返回blob
|
|
5
|
+
@type `Interceptor` - `Response`
|
|
6
|
+
@category Helper
|
|
7
|
+
*/
|
|
8
|
+
export function open_link(name) {
|
|
9
|
+
return blob => {
|
|
10
|
+
var _a;
|
|
11
|
+
if (typeof dntShim.dntGlobalThis === 'undefined' || !((_a = dntShim.dntGlobalThis) === null || _a === void 0 ? void 0 : _a.document))
|
|
12
|
+
return Ok(blob);
|
|
13
|
+
// biome-ignore lint/suspicious/noExplicitAny: <>
|
|
14
|
+
const a = dntShim.dntGlobalThis.document.createElement('a');
|
|
15
|
+
a.href = URL.createObjectURL(blob);
|
|
16
|
+
a.download = name;
|
|
17
|
+
a.click();
|
|
18
|
+
a.remove();
|
|
19
|
+
return Ok(blob);
|
|
20
|
+
};
|
|
21
|
+
}
|
|
@@ -1,5 +1,16 @@
|
|
|
1
|
+
import type { Fn, Result, zod } from '@chzky/core';
|
|
1
2
|
import type { ResponseInterceptor } from '../../../mod.js';
|
|
2
|
-
import {
|
|
3
|
-
/** ### `
|
|
4
|
-
|
|
3
|
+
import { CheckingError } from '@chzky/core';
|
|
4
|
+
/** ### `output_validate` : 对输出类型进行类型校验
|
|
5
|
+
+ 会自动将放回类型进行校验(使用`zod.parse`),如果校验失败,则返回 `CheckingError`
|
|
6
|
+
@type `Interceptor` - `Response`
|
|
7
|
+
@category Helper
|
|
8
|
+
*/
|
|
9
|
+
export declare function output_validate<T>(schema: zod.Schema<T>): ResponseInterceptor<unknown, zod.infer<typeof schema>, CheckingError>;
|
|
10
|
+
/** ## `response_map` : 对返回类型进行`map`操作
|
|
11
|
+
+ 用于`AxiosResponse`的业务场景映射
|
|
12
|
+
+ 用于返回数据映射
|
|
13
|
+
@category ResponseInterceptor
|
|
14
|
+
*/
|
|
15
|
+
export declare function response_map<T, R, E>(fn: Fn<T, Result<R, E>>): ResponseInterceptor<T, R, E>;
|
|
5
16
|
//# sourceMappingURL=output.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"output.d.ts","sourceRoot":"","sources":["../../../../src/lib/helper/response/output.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"output.d.ts","sourceRoot":"","sources":["../../../../src/lib/helper/response/output.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,aAAa,CAAA;AAClD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAA;AAE1D,OAAO,EAAE,aAAa,EAAM,MAAM,aAAa,CAAA;AAE/C;;;;EAIE;AACF,wBAAgB,eAAe,CAAC,CAAC,EAChC,MAAM,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,GACnB,mBAAmB,CAAC,OAAO,EAAE,GAAG,CAAC,KAAK,CAAC,OAAO,MAAM,CAAC,EAAE,aAAa,CAAC,CAQvE;AAED;;;;EAIE;AACF,wBAAgB,YAAY,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,mBAAmB,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAE3F"}
|
|
@@ -1 +1,24 @@
|
|
|
1
|
-
|
|
1
|
+
import { CheckingError, Ok } from '@chzky/core';
|
|
2
|
+
/** ### `output_validate` : 对输出类型进行类型校验
|
|
3
|
+
+ 会自动将放回类型进行校验(使用`zod.parse`),如果校验失败,则返回 `CheckingError`
|
|
4
|
+
@type `Interceptor` - `Response`
|
|
5
|
+
@category Helper
|
|
6
|
+
*/
|
|
7
|
+
export function output_validate(schema) {
|
|
8
|
+
return response => {
|
|
9
|
+
try {
|
|
10
|
+
return Ok(schema.parse(response));
|
|
11
|
+
}
|
|
12
|
+
catch (e) {
|
|
13
|
+
return CheckingError.err(e);
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
/** ## `response_map` : 对返回类型进行`map`操作
|
|
18
|
+
+ 用于`AxiosResponse`的业务场景映射
|
|
19
|
+
+ 用于返回数据映射
|
|
20
|
+
@category ResponseInterceptor
|
|
21
|
+
*/
|
|
22
|
+
export function response_map(fn) {
|
|
23
|
+
return response => fn(response);
|
|
24
|
+
}
|
|
@@ -1,7 +1,24 @@
|
|
|
1
1
|
import type { ResponseInterceptor } from '../../../mod.js';
|
|
2
2
|
import type { AxiosResponse } from 'axios';
|
|
3
|
-
|
|
3
|
+
type AxiosResponseKey = 'data' | 'status' | 'statusText' | 'headers' | 'config' | 'request';
|
|
4
|
+
/** ### `pick` : 提取`Axios`请求返回字段
|
|
5
|
+
+ 默认返回`data`字段
|
|
4
6
|
一般来说axios返回的数据是一个AxiosResponse对象,而我们只需要其中的data字段作为业务数据需要的字段
|
|
7
|
+
@example Usage
|
|
8
|
+
```ts
|
|
9
|
+
const mock_reqwest = Reqwest.new().conf({ baseURL: 'https://jsonplaceholder.typicode.com/todos/' })
|
|
10
|
+
|
|
11
|
+
const result = await mock_reqwest
|
|
12
|
+
.request(get('/1'))
|
|
13
|
+
.response(pick<{ userId: number; id: number; title: string; completed: boolean }>('data'))
|
|
14
|
+
.dispatch()
|
|
15
|
+
|
|
16
|
+
assert.not(result.unwrap().completed)
|
|
17
|
+
|
|
18
|
+
```
|
|
19
|
+
@type `Interceptor` - `Response`
|
|
20
|
+
@category Helper
|
|
5
21
|
*/
|
|
6
|
-
export declare function pick<T = never>(key
|
|
22
|
+
export declare function pick<T = never>(key: AxiosResponseKey): ResponseInterceptor<AxiosResponse, T extends never ? AxiosResponse[typeof key] : T, never>;
|
|
23
|
+
export {};
|
|
7
24
|
//# sourceMappingURL=pick.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pick.d.ts","sourceRoot":"","sources":["../../../../src/lib/helper/response/pick.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAA;AAC1D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,OAAO,CAAA;
|
|
1
|
+
{"version":3,"file":"pick.d.ts","sourceRoot":"","sources":["../../../../src/lib/helper/response/pick.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAA;AAC1D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,OAAO,CAAA;AAI1C,KAAK,gBAAgB,GAAG,MAAM,GAAG,QAAQ,GAAG,YAAY,GAAG,SAAS,GAAG,QAAQ,GAAG,SAAS,CAAA;AAE3F;;;;;;;;;;;;;;;;;EAiBE;AACF,wBAAgB,IAAI,CAAC,CAAC,GAAG,KAAK,EAC7B,GAAG,EAAE,gBAAgB,GACnB,mBAAmB,CAAC,aAAa,EAAE,CAAC,SAAS,KAAK,GAAG,aAAa,CAAC,OAAO,GAAG,CAAC,GAAG,CAAC,EAAE,KAAK,CAAC,CAK5F"}
|
|
@@ -1 +1,26 @@
|
|
|
1
|
-
|
|
1
|
+
import { Ok } from '@chzky/core';
|
|
2
|
+
/** ### `pick` : 提取`Axios`请求返回字段
|
|
3
|
+
+ 默认返回`data`字段
|
|
4
|
+
一般来说axios返回的数据是一个AxiosResponse对象,而我们只需要其中的data字段作为业务数据需要的字段
|
|
5
|
+
@example Usage
|
|
6
|
+
```ts
|
|
7
|
+
const mock_reqwest = Reqwest.new().conf({ baseURL: 'https://jsonplaceholder.typicode.com/todos/' })
|
|
8
|
+
|
|
9
|
+
const result = await mock_reqwest
|
|
10
|
+
.request(get('/1'))
|
|
11
|
+
.response(pick<{ userId: number; id: number; title: string; completed: boolean }>('data'))
|
|
12
|
+
.dispatch()
|
|
13
|
+
|
|
14
|
+
assert.not(result.unwrap().completed)
|
|
15
|
+
|
|
16
|
+
```
|
|
17
|
+
@type `Interceptor` - `Response`
|
|
18
|
+
@category Helper
|
|
19
|
+
*/
|
|
20
|
+
export function pick(key) {
|
|
21
|
+
return response => {
|
|
22
|
+
if (key in response && Object.hasOwn(response, key))
|
|
23
|
+
return Ok(response[key]);
|
|
24
|
+
throw new Error(`Key '${key}' does not exist on AxiosResponse`);
|
|
25
|
+
};
|
|
26
|
+
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from './useCancel.js';
|
|
2
|
-
export * from './useLoading.js';
|
|
1
|
+
export * from './useCancel.js'; /* 取消控制 */
|
|
2
|
+
export * from './useLoading.js'; /* loading控制 */
|
|
@@ -1,4 +1,34 @@
|
|
|
1
1
|
import type { RequestInterceptor } from '../../../mod.js';
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
import { AbortedError, PromiseOr, Result } from '@chzky/core';
|
|
3
|
+
type CancelInterceptor = [
|
|
4
|
+
AbortController,
|
|
5
|
+
{
|
|
6
|
+
request: RequestInterceptor<AbortedError>;
|
|
7
|
+
response: <O>(response: O) => PromiseOr<Result<O, AbortedError>>;
|
|
8
|
+
}
|
|
9
|
+
];
|
|
10
|
+
/** ### `cancel` : 允许取消操作
|
|
11
|
+
+ 在请求时取消,会直接取消请求
|
|
12
|
+
+ 在响应时取消,会直接丢弃响应值
|
|
13
|
+
@example Usage
|
|
14
|
+
```ts
|
|
15
|
+
const [abort_controler, interceptor] = cancel()
|
|
16
|
+
|
|
17
|
+
const reqwest = mock_reqwest.clone().request(wait(2000), get('/1')).use(interceptor)
|
|
18
|
+
|
|
19
|
+
const mock_cause = 'mock abort'
|
|
20
|
+
abort_controler.abort(mock_cause)
|
|
21
|
+
|
|
22
|
+
const result = await reqwest.dispatch()
|
|
23
|
+
|
|
24
|
+
const error = result.unwrap_err()
|
|
25
|
+
assert(error.instance_of(AbortedError))
|
|
26
|
+
assert.equal(error.cause, mock_cause)
|
|
27
|
+
```
|
|
28
|
+
@returns [ `abort_controler` - 控制取消的`AbortController` , `interceptor` - 拦截器 ]
|
|
29
|
+
@type `Interceptor`
|
|
30
|
+
@category Helper
|
|
31
|
+
*/
|
|
32
|
+
export declare function cancel(control?: AbortController): CancelInterceptor;
|
|
33
|
+
export {};
|
|
4
34
|
//# sourceMappingURL=useCancel.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useCancel.d.ts","sourceRoot":"","sources":["../../../../src/lib/helper/use/useCancel.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAA;
|
|
1
|
+
{"version":3,"file":"useCancel.d.ts","sourceRoot":"","sources":["../../../../src/lib/helper/use/useCancel.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAA;AAEzD,OAAO,EAAE,YAAY,EAAM,SAAS,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AAEjE,KAAK,iBAAiB,GAAG;IACxB,eAAe;IACf;QACC,OAAO,EAAE,kBAAkB,CAAC,YAAY,CAAC,CAAA;QACzC,QAAQ,EAAE,CAAC,CAAC,EAAE,QAAQ,EAAE,CAAC,KAAK,SAAS,CAAC,MAAM,CAAC,CAAC,EAAE,YAAY,CAAC,CAAC,CAAA;KAChE;CACD,CAAA;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,MAAM,CAAC,OAAO,CAAC,EAAE,eAAe,GAAG,iBAAiB,CAgBnE"}
|
|
@@ -1 +1,42 @@
|
|
|
1
|
-
|
|
1
|
+
import { AbortedError, Ok } from '@chzky/core';
|
|
2
|
+
/** ### `cancel` : 允许取消操作
|
|
3
|
+
+ 在请求时取消,会直接取消请求
|
|
4
|
+
+ 在响应时取消,会直接丢弃响应值
|
|
5
|
+
@example Usage
|
|
6
|
+
```ts
|
|
7
|
+
const [abort_controler, interceptor] = cancel()
|
|
8
|
+
|
|
9
|
+
const reqwest = mock_reqwest.clone().request(wait(2000), get('/1')).use(interceptor)
|
|
10
|
+
|
|
11
|
+
const mock_cause = 'mock abort'
|
|
12
|
+
abort_controler.abort(mock_cause)
|
|
13
|
+
|
|
14
|
+
const result = await reqwest.dispatch()
|
|
15
|
+
|
|
16
|
+
const error = result.unwrap_err()
|
|
17
|
+
assert(error.instance_of(AbortedError))
|
|
18
|
+
assert.equal(error.cause, mock_cause)
|
|
19
|
+
```
|
|
20
|
+
@returns [ `abort_controler` - 控制取消的`AbortController` , `interceptor` - 拦截器 ]
|
|
21
|
+
@type `Interceptor`
|
|
22
|
+
@category Helper
|
|
23
|
+
*/
|
|
24
|
+
export function cancel(control) {
|
|
25
|
+
const abort_control = control || new AbortController();
|
|
26
|
+
const signal = abort_control.signal;
|
|
27
|
+
return [
|
|
28
|
+
abort_control,
|
|
29
|
+
{
|
|
30
|
+
request: () => {
|
|
31
|
+
if (signal.aborted)
|
|
32
|
+
return AbortedError.err(signal.reason);
|
|
33
|
+
return Ok();
|
|
34
|
+
},
|
|
35
|
+
response: (response) => {
|
|
36
|
+
if (signal.aborted)
|
|
37
|
+
return AbortedError.err(signal.reason);
|
|
38
|
+
return Ok(response);
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
];
|
|
42
|
+
}
|
|
@@ -1,15 +1,35 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
1
|
+
import { ReqwestInterceptor } from '../../../mod.js';
|
|
2
|
+
import { Ref } from 'vue-demi';
|
|
3
3
|
type LoadingConfig = {
|
|
4
|
-
/** 最大等待时间,超时之后loding状态会变为false,默认值是`Axios.timeout`
|
|
4
|
+
/** 最大等待时间,超时之后loding状态会变为false,默认值是`Axios.timeout`
|
|
5
|
+
如果设置为`0`,即永不超时,需要手动取消或等待请求完成
|
|
6
|
+
*/
|
|
5
7
|
maximum?: number;
|
|
6
8
|
/** 超时回调 */
|
|
7
9
|
maximun_handler?: () => void;
|
|
8
10
|
};
|
|
9
|
-
|
|
11
|
+
type LoadingControlReturn = [AbortController, ReqwestInterceptor<unknown, never>];
|
|
12
|
+
/** ## `loading_control` : loading控制器
|
|
13
|
+
使用` Ref<boolean, boolean>` 来控制loading状态 ,当reqwest开始执行的时候启动loading.当reqwest结束的时候关闭loading
|
|
14
|
+
+ 如果请求时间超过`maximum`时间,loading状态会变为false,并执行`maximun_handler`回调
|
|
15
|
+
@example Usage
|
|
16
|
+
```ts
|
|
17
|
+
const loading = ref(false)
|
|
18
|
+
const [_cnacel_controler, interceptor] = loading_control(loading, { maximum: 2000 })
|
|
19
|
+
|
|
20
|
+
let change_count = 0
|
|
21
|
+
watch(loading, nval => {
|
|
22
|
+
if (change_count === 0) assert(nval) //先变true(开始执行)
|
|
23
|
+
if (change_count === 1) assert(!nval) //后变false(执行结束)
|
|
24
|
+
change_count++
|
|
25
|
+
})
|
|
26
|
+
|
|
27
|
+
await mock_reqwest.clone().use(interceptor).dispatch()
|
|
28
|
+
```
|
|
29
|
+
@returns [ `controller` - 控制取消的`AbortController` , `interceptor` - 拦截器 ]
|
|
10
30
|
@type `Interceptor`
|
|
11
|
-
@category
|
|
12
|
-
*/
|
|
13
|
-
export declare function loading_control
|
|
31
|
+
@category Helper
|
|
32
|
+
*/
|
|
33
|
+
export declare function loading_control(ref: Ref<boolean, boolean>, conf?: LoadingConfig): LoadingControlReturn;
|
|
14
34
|
export {};
|
|
15
35
|
//# sourceMappingURL=useLoading.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useLoading.d.ts","sourceRoot":"","sources":["../../../../src/lib/helper/use/useLoading.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useLoading.d.ts","sourceRoot":"","sources":["../../../../src/lib/helper/use/useLoading.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAA;AAEpD,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAA;AAE9B,KAAK,aAAa,GAAG;IACpB;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,WAAW;IACX,eAAe,CAAC,EAAE,MAAM,IAAI,CAAA;CAC5B,CAAA;AAED,KAAK,oBAAoB,GAAG,CAAC,eAAe,EAAE,kBAAkB,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC,CAAA;AAEjF;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,eAAe,CAC9B,GAAG,EAAE,GAAG,CAAC,OAAO,EAAE,OAAO,CAAC,EAC1B,IAAI,CAAC,EAAE,aAAa,GAClB,oBAAoB,CAqCtB"}
|
|
@@ -1 +1,58 @@
|
|
|
1
|
-
|
|
1
|
+
import { Ok } from '@chzky/core';
|
|
2
|
+
/** ## `loading_control` : loading控制器
|
|
3
|
+
使用` Ref<boolean, boolean>` 来控制loading状态 ,当reqwest开始执行的时候启动loading.当reqwest结束的时候关闭loading
|
|
4
|
+
+ 如果请求时间超过`maximum`时间,loading状态会变为false,并执行`maximun_handler`回调
|
|
5
|
+
@example Usage
|
|
6
|
+
```ts
|
|
7
|
+
const loading = ref(false)
|
|
8
|
+
const [_cnacel_controler, interceptor] = loading_control(loading, { maximum: 2000 })
|
|
9
|
+
|
|
10
|
+
let change_count = 0
|
|
11
|
+
watch(loading, nval => {
|
|
12
|
+
if (change_count === 0) assert(nval) //先变true(开始执行)
|
|
13
|
+
if (change_count === 1) assert(!nval) //后变false(执行结束)
|
|
14
|
+
change_count++
|
|
15
|
+
})
|
|
16
|
+
|
|
17
|
+
await mock_reqwest.clone().use(interceptor).dispatch()
|
|
18
|
+
```
|
|
19
|
+
@returns [ `controller` - 控制取消的`AbortController` , `interceptor` - 拦截器 ]
|
|
20
|
+
@type `Interceptor`
|
|
21
|
+
@category Helper
|
|
22
|
+
*/
|
|
23
|
+
export function loading_control(ref, conf) {
|
|
24
|
+
let { maximum, maximun_handler = () => {
|
|
25
|
+
/* 默认空回调 */
|
|
26
|
+
}, } = conf !== null && conf !== void 0 ? conf : {};
|
|
27
|
+
const controller = new AbortController();
|
|
28
|
+
let timer;
|
|
29
|
+
controller.signal.addEventListener('abort', () => {
|
|
30
|
+
clearTimeout(timer);
|
|
31
|
+
if (ref.value)
|
|
32
|
+
ref.value = false;
|
|
33
|
+
});
|
|
34
|
+
return [
|
|
35
|
+
controller,
|
|
36
|
+
{
|
|
37
|
+
request: config => {
|
|
38
|
+
if (maximum === void 0)
|
|
39
|
+
maximum = config.timeout || 0;
|
|
40
|
+
ref.value = true;
|
|
41
|
+
if (maximum <= 0)
|
|
42
|
+
return Ok();
|
|
43
|
+
timer = setTimeout(() => {
|
|
44
|
+
clearTimeout(timer);
|
|
45
|
+
maximun_handler();
|
|
46
|
+
ref.value = false;
|
|
47
|
+
}, maximum);
|
|
48
|
+
return Ok();
|
|
49
|
+
},
|
|
50
|
+
response: response => {
|
|
51
|
+
clearTimeout(timer);
|
|
52
|
+
if (ref.value)
|
|
53
|
+
ref.value = false;
|
|
54
|
+
return Ok(response);
|
|
55
|
+
},
|
|
56
|
+
},
|
|
57
|
+
];
|
|
58
|
+
}
|
package/esm/lib/mod.d.ts
CHANGED
package/esm/lib/mod.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../../src/lib/mod.ts"],"names":[],"mappings":"AAAA,cAAc,
|
|
1
|
+
{"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../../src/lib/mod.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAA;AAC7B,cAAc,iBAAiB,CAAA"}
|
package/esm/lib/mod.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from './
|
|
1
|
+
export * from './core/mod.js';
|
|
2
2
|
export * from './helper/mod.js';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@chzky/reqwest",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"author": "https://github.com/HYliangkai",
|
|
5
5
|
"main": "./esm/mod.js",
|
|
6
6
|
"module": "./esm/mod.js",
|
|
@@ -12,16 +12,9 @@
|
|
|
12
12
|
},
|
|
13
13
|
"access": "public",
|
|
14
14
|
"dependencies": {
|
|
15
|
-
"@chzky/
|
|
16
|
-
"
|
|
17
|
-
"
|
|
18
|
-
"vue-demi": "0.14.10",
|
|
19
|
-
"@deno/shim-deno": "~0.18.0",
|
|
20
|
-
"@deno/shim-prompts": "~0.1.0",
|
|
21
|
-
"@deno/shim-timers": "~0.1.0"
|
|
22
|
-
},
|
|
23
|
-
"devDependencies": {
|
|
24
|
-
"@types/node": "^20.9.0"
|
|
15
|
+
"@chzky/core": "*",
|
|
16
|
+
"axios": "^1.12.2",
|
|
17
|
+
"vue-demi": "0.14.10"
|
|
25
18
|
},
|
|
26
19
|
"_generatedBy": "dnt@dev"
|
|
27
20
|
}
|
|
@@ -1,3 +1,14 @@
|
|
|
1
|
+
declare global {
|
|
2
|
+
interface Object {
|
|
3
|
+
/**
|
|
4
|
+
* Determines whether an object has a property with the specified name.
|
|
5
|
+
* @param o An object.
|
|
6
|
+
* @param v A property name.
|
|
7
|
+
*/
|
|
8
|
+
hasOwn(o: object, v: PropertyKey): boolean;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
export {};
|
|
1
12
|
declare global {
|
|
2
13
|
interface PromiseConstructor {
|
|
3
14
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"_dnt.polyfills.d.ts","sourceRoot":"","sources":["../src/_dnt.polyfills.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"_dnt.polyfills.d.ts","sourceRoot":"","sources":["../src/_dnt.polyfills.ts"],"names":[],"mappings":"AAeA,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,MAAM;QACd;;;;WAIG;QACH,MAAM,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC;KAC5C;CACF;AAED,OAAO,EAAE,CAAC;AACV,OAAO,CAAC,MAAM,CAAC;IAEb,UAAU,kBAAkB;QAC1B;;;WAGG;QACH,aAAa,CAAC,CAAC,KAAK;YAAE,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC;YAAC,OAAO,EAAE,CAAC,KAAK,EAAE,CAAC,GAAG,WAAW,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC;YAAC,MAAM,EAAE,CAAC,MAAM,CAAC,EAAE,GAAG,KAAK,IAAI,CAAA;SAAE,CAAC;KAC3H;CACF"}
|
package/script/_dnt.polyfills.js
CHANGED
|
@@ -1,4 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
// https://github.com/tc39/proposal-accessible-object-hasownproperty/blob/main/polyfill.js
|
|
4
|
+
if (!Object.hasOwn) {
|
|
5
|
+
Object.defineProperty(Object, "hasOwn", {
|
|
6
|
+
value: function (object, property) {
|
|
7
|
+
if (object == null) {
|
|
8
|
+
throw new TypeError("Cannot convert undefined or null to object");
|
|
9
|
+
}
|
|
10
|
+
return Object.prototype.hasOwnProperty.call(Object(object), property);
|
|
11
|
+
},
|
|
12
|
+
configurable: true,
|
|
13
|
+
enumerable: false,
|
|
14
|
+
writable: true,
|
|
15
|
+
});
|
|
16
|
+
}
|
|
2
17
|
// https://github.com/tc39/proposal-promise-with-resolvers/blob/3a78801e073e99217dbeb2c43ba7212f3bdc8b83/polyfills.js#L1C1-L9C2
|
|
3
18
|
if (Promise.withResolvers === undefined) {
|
|
4
19
|
Promise.withResolvers = () => {
|
package/script/_dnt.shims.d.ts
CHANGED
|
@@ -1,14 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
export { Deno } from "@deno/shim-deno";
|
|
3
|
-
export { alert, confirm, prompt } from "@deno/shim-prompts";
|
|
4
|
-
import { setInterval, setTimeout } from "@deno/shim-timers";
|
|
5
|
-
export { setInterval, setTimeout } from "@deno/shim-timers";
|
|
6
|
-
export declare const dntGlobalThis: Omit<typeof globalThis, "alert" | "confirm" | "prompt" | "setInterval" | "setTimeout" | "Deno"> & {
|
|
7
|
-
Deno: typeof Deno;
|
|
8
|
-
alert: typeof globalThis.alert;
|
|
9
|
-
confirm: typeof globalThis.confirm;
|
|
10
|
-
prompt: typeof globalThis.prompt;
|
|
11
|
-
setInterval: typeof setInterval;
|
|
12
|
-
setTimeout: typeof setTimeout;
|
|
13
|
-
};
|
|
1
|
+
export declare const dntGlobalThis: Omit<typeof globalThis, never>;
|
|
14
2
|
//# sourceMappingURL=_dnt.shims.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"_dnt.shims.d.ts","sourceRoot":"","sources":["../src/_dnt.shims.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"_dnt.shims.d.ts","sourceRoot":"","sources":["../src/_dnt.shims.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,aAAa,gCAA2C,CAAC"}
|