@snail-js/api 0.1.4 → 0.1.5
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 +7 -3
- package/dist/decorators/progress.d.ts +3 -1
- package/dist/snail-api.js +8 -1
- package/dist/snail-api.umd.cjs +8 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -335,7 +335,11 @@ class Test {
|
|
|
335
335
|
|
|
336
336
|
### 上传进度装饰器`@UploadProgress`
|
|
337
337
|
|
|
338
|
-
- `@UploadProgress((
|
|
338
|
+
- `@UploadProgress((progressEvent: AxiosProgressEvent) => void)`
|
|
339
|
+
|
|
340
|
+
### 下载进度装饰器`@DownloadProgress`
|
|
341
|
+
|
|
342
|
+
- `@DownloadProgress((progressEvent: AxiosProgressEvent) => void)`
|
|
339
343
|
|
|
340
344
|
## Server Send Event 服务端推送
|
|
341
345
|
|
|
@@ -395,12 +399,12 @@ export const Sse = Service.createSse(ServerSend);
|
|
|
395
399
|
### 代码仓库
|
|
396
400
|
|
|
397
401
|
<p>
|
|
398
|
-
<a
|
|
402
|
+
<a href="https://gitee.com/limich/snail">
|
|
399
403
|
<img src="https://img.shields.io/badge/snail-js?style=flat&label=gitee&labelColor=F56C6C&link=https%3A%2F%2Fgitee.com%2Flimich%2Fsnail"></img>
|
|
400
404
|
</a>
|
|
401
405
|
</p>
|
|
402
406
|
<p>
|
|
403
|
-
<a
|
|
407
|
+
<a href="https://github.com/limingchang/snail">
|
|
404
408
|
<img src="https://img.shields.io/badge/snail-js?style=flat&label=github&labelColor=F56C6C&link=https%3A%2F%2Fgihub.com%2Flimingchang%2Fsnail"></img>
|
|
405
409
|
</a>
|
|
406
410
|
</p>
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import "reflect-metadata";
|
|
2
2
|
import { AxiosProgressEvent } from "axios";
|
|
3
3
|
export declare const UPLOAD_PROGRESS_KEY: unique symbol;
|
|
4
|
-
export declare const UploadProgress: (handler: (
|
|
4
|
+
export declare const UploadProgress: (handler: (progressEvent: AxiosProgressEvent) => void) => (target: any, propertyKey: string) => void;
|
|
5
|
+
export declare const DOWNLOAD_PROGRESS_KEY: unique symbol;
|
|
6
|
+
export declare const DownloadProgress: (handler: (progressEvent: AxiosProgressEvent) => void) => (target: any, propertyKey: string) => void;
|
package/dist/snail-api.js
CHANGED
|
@@ -3816,6 +3816,7 @@ const Cache = (hitSource) => {
|
|
|
3816
3816
|
};
|
|
3817
3817
|
};
|
|
3818
3818
|
const UPLOAD_PROGRESS_KEY = Symbol("SNAIL_UPLOAD_PROGRESS_KEY");
|
|
3819
|
+
const DOWNLOAD_PROGRESS_KEY = Symbol("SNAIL_DOWNLOAD_PROGRESS_KEY");
|
|
3819
3820
|
const EVENT_SOURCE_OPTION_KEY = Symbol("SNAIL_EVENT_SOURCE_OPTION_KEY");
|
|
3820
3821
|
const Sse = (path, options) => {
|
|
3821
3822
|
return (target, propertyKey) => {
|
|
@@ -3931,11 +3932,17 @@ class Snail {
|
|
|
3931
3932
|
target,
|
|
3932
3933
|
propertyKey
|
|
3933
3934
|
);
|
|
3935
|
+
const onDownloadProgress = Reflect.getMetadata(
|
|
3936
|
+
DOWNLOAD_PROGRESS_KEY,
|
|
3937
|
+
target,
|
|
3938
|
+
propertyKey
|
|
3939
|
+
);
|
|
3934
3940
|
try {
|
|
3935
3941
|
enableLog && console.log("send request:", request);
|
|
3936
3942
|
const response = await this.axiosInstance({
|
|
3937
3943
|
...request,
|
|
3938
|
-
onUploadProgress
|
|
3944
|
+
onUploadProgress,
|
|
3945
|
+
onDownloadProgress
|
|
3939
3946
|
});
|
|
3940
3947
|
hitSource !== null && this.setCache(request, response);
|
|
3941
3948
|
this.expireCache(propertyKey);
|
package/dist/snail-api.umd.cjs
CHANGED
|
@@ -3820,6 +3820,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
3820
3820
|
};
|
|
3821
3821
|
};
|
|
3822
3822
|
const UPLOAD_PROGRESS_KEY = Symbol("SNAIL_UPLOAD_PROGRESS_KEY");
|
|
3823
|
+
const DOWNLOAD_PROGRESS_KEY = Symbol("SNAIL_DOWNLOAD_PROGRESS_KEY");
|
|
3823
3824
|
const EVENT_SOURCE_OPTION_KEY = Symbol("SNAIL_EVENT_SOURCE_OPTION_KEY");
|
|
3824
3825
|
const Sse = (path, options) => {
|
|
3825
3826
|
return (target, propertyKey) => {
|
|
@@ -3935,11 +3936,17 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
3935
3936
|
target,
|
|
3936
3937
|
propertyKey
|
|
3937
3938
|
);
|
|
3939
|
+
const onDownloadProgress = Reflect.getMetadata(
|
|
3940
|
+
DOWNLOAD_PROGRESS_KEY,
|
|
3941
|
+
target,
|
|
3942
|
+
propertyKey
|
|
3943
|
+
);
|
|
3938
3944
|
try {
|
|
3939
3945
|
enableLog && console.log("send request:", request);
|
|
3940
3946
|
const response = await this.axiosInstance({
|
|
3941
3947
|
...request,
|
|
3942
|
-
onUploadProgress
|
|
3948
|
+
onUploadProgress,
|
|
3949
|
+
onDownloadProgress
|
|
3943
3950
|
});
|
|
3944
3951
|
hitSource !== null && this.setCache(request, response);
|
|
3945
3952
|
this.expireCache(propertyKey);
|