@acorex/core 18.5.12 → 18.5.14
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +29 -4
- package/esm2022/file/index.mjs +1 -4
- package/esm2022/file/lib/file.service.mjs +4 -72
- package/esm2022/network/acorex-core-network.mjs +5 -0
- package/esm2022/network/index.mjs +5 -0
- package/esm2022/network/lib/download-task.mjs +47 -0
- package/esm2022/network/lib/network.service.mjs +72 -0
- package/esm2022/network/lib/network.types.mjs +15 -0
- package/esm2022/network/lib/upload-task.mjs +48 -0
- package/fesm2022/acorex-core-file.mjs +4 -138
- package/fesm2022/acorex-core-file.mjs.map +1 -1
- package/fesm2022/acorex-core-network.mjs +181 -0
- package/fesm2022/acorex-core-network.mjs.map +1 -0
- package/file/index.d.ts +0 -3
- package/file/lib/file.service.d.ts +0 -7
- package/network/README.md +3 -0
- package/network/index.d.ts +4 -0
- package/network/lib/download-task.d.ts +11 -0
- package/network/lib/network.service.d.ts +13 -0
- package/network/lib/network.types.d.ts +26 -0
- package/network/lib/upload-task.d.ts +12 -0
- package/package.json +18 -12
- package/esm2022/file/lib/file-download-ref.class.mjs +0 -12
- package/esm2022/file/lib/file-download-result.class.mjs +0 -45
- package/esm2022/file/lib/file-upload-ref.class.mjs +0 -12
- package/file/lib/file-download-ref.class.d.ts +0 -6
- package/file/lib/file-download-result.class.d.ts +0 -8
- package/file/lib/file-upload-ref.class.d.ts +0 -5
package/README.md
CHANGED
@@ -1,7 +1,32 @@
|
|
1
|
-
|
1
|
+
<p style="text-align: center;">
|
2
|
+
<picture>
|
3
|
+
<source media="(prefers-color-scheme: dark)" srcset="https://acorexui.com/acorex-slang-dark.svg">
|
4
|
+
<img alt="Acorex - Design System, UI Framework, App Builder" src="https://acorexui.com/acorex-slang.svg" width="100%">
|
5
|
+
</picture>
|
6
|
+
</p>
|
2
7
|
|
3
|
-
|
8
|
+
<div style="text-align: center;">
|
4
9
|
|
5
|
-
|
10
|
+
[![License](https://img.shields.io/npm/l/nx.svg?style=flat-square)]()
|
6
11
|
|
7
|
-
|
12
|
+
</div>
|
13
|
+
|
14
|
+
# ACoreX Core
|
15
|
+
|
16
|
+
ACoreX is an UI framework based on angular. With over 50+ beautiful fully responsive and accessible components for everyone.
|
17
|
+
|
18
|
+
A few links to help you get started:
|
19
|
+
|
20
|
+
- [ACoreX: Documentation, Guides](https://acorexui.com)
|
21
|
+
|
22
|
+
## Core Team
|
23
|
+
|
24
|
+
| Arash Oshnoudi | Ali Safari | Matin Givi | Reza Safari |
|
25
|
+
| ------------------------------------------------------------------------------------------------------------------------ | -------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------- |
|
26
|
+
| ![Arash Oshnoudi](https://gravatar.com/avatar/df151090660e3842ec1ff788bb5a650e939e45784f01513a9b9f8107311e4e78?size=180) | ![Ali Safari](https://gravatar.com/avatar/555280ee36f23bedcfcfec6e068d1a85d7e1fd14676ca07e05958fc762199def?size=180) | ![Matin Givi](https://gravatar.com/avatar/9a477829fc2ecdbce20a26af33d24baf63d24f042a551af8147eef1c99d2315a?size=180) | ![Reza Safari](https://gravatar.com/avatar/0d419926e9e86bbb4b47ca6ae3ca6a2cde30fb01a6ddedefb97d043a350d11f0?size=180) |
|
27
|
+
|
28
|
+
<br/>
|
29
|
+
|
30
|
+
| Shahin Kahrizi | Mohamad Parsaeifard | Mohamad Hasanzade | Meysa Aghili |
|
31
|
+
| ------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------ | -------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------ |
|
32
|
+
| ![Shahin Kahrizi](https://gravatar.com/avatar/e699eeae86920ea44f9dd18f8bb01b5f0d28cdbd816032c4387f1f036c5977c0?size=180) | ![Mohammad Parsaeifard](https://gravatar.com/avatar/c0d9a0143f2dbbcea46e037d12ccad8f0fdaaeeaeb5089c1ae4a0c4ad131df88?size=180) | ![Mohammad Hasanzade](https://gravatar.com/avatar/ca346e55701bbf079140cb04edea9e3c?size=180) | ![Meysa Aghili](https://0.gravatar.com/avatar/bf607792c9fac9e5f4e53d141d331abd11fa56e56f42da8b69cf9ede2ffff289?size=180) |
|
package/esm2022/file/index.mjs
CHANGED
@@ -1,7 +1,4 @@
|
|
1
|
-
export * from './lib/file-download-ref.class';
|
2
|
-
export * from './lib/file-download-result.class';
|
3
1
|
export * from './lib/file-size-formatter';
|
4
|
-
export * from './lib/file-upload-ref.class';
|
5
2
|
export * from './lib/file.module';
|
6
3
|
export * from './lib/file.service';
|
7
|
-
//# sourceMappingURL=data:application/json;base64,
|
4
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi8uLi9saWJzL2NvcmUvZmlsZS9zcmMvaW5kZXgudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsY0FBYywyQkFBMkIsQ0FBQztBQUMxQyxjQUFjLG1CQUFtQixDQUFDO0FBQ2xDLGNBQWMsb0JBQW9CLENBQUMiLCJzb3VyY2VzQ29udGVudCI6WyJleHBvcnQgKiBmcm9tICcuL2xpYi9maWxlLXNpemUtZm9ybWF0dGVyJztcbmV4cG9ydCAqIGZyb20gJy4vbGliL2ZpbGUubW9kdWxlJztcbmV4cG9ydCAqIGZyb20gJy4vbGliL2ZpbGUuc2VydmljZSc7XG4iXX0=
|
@@ -1,13 +1,7 @@
|
|
1
|
-
import { HttpClient, HttpRequest } from '@angular/common/http';
|
2
1
|
import { Injectable } from '@angular/core';
|
3
|
-
import { AXFileDownloadRef } from './file-download-ref.class';
|
4
|
-
import { AXFileDownloadResult } from './file-download-result.class';
|
5
|
-
import { AXFileUploadRef } from './file-upload-ref.class';
|
6
2
|
import * as i0 from "@angular/core";
|
7
|
-
import * as i1 from "@angular/common/http";
|
8
3
|
export class AXFileService {
|
9
|
-
constructor(
|
10
|
-
this._httpClient = _httpClient;
|
4
|
+
constructor() {
|
11
5
|
this.blobToBase64 = (blob) => {
|
12
6
|
if (blob instanceof Blob) {
|
13
7
|
return new Promise((resolve, reject) => {
|
@@ -24,68 +18,6 @@ export class AXFileService {
|
|
24
18
|
}
|
25
19
|
};
|
26
20
|
}
|
27
|
-
download(request) {
|
28
|
-
let s;
|
29
|
-
const promiseFunc = (resolve, reject) => {
|
30
|
-
if (typeof request == 'string') {
|
31
|
-
//
|
32
|
-
}
|
33
|
-
if (request instanceof Blob) {
|
34
|
-
//
|
35
|
-
}
|
36
|
-
if (request instanceof HttpRequest) {
|
37
|
-
const b = this._httpClient.request(request);
|
38
|
-
b.subscribe({
|
39
|
-
next: (v) => resolve(new AXFileDownloadResult(v)),
|
40
|
-
error: (e) => reject(e),
|
41
|
-
});
|
42
|
-
}
|
43
|
-
};
|
44
|
-
const a = new AXFileDownloadRef(promiseFunc);
|
45
|
-
a.abort = () => {
|
46
|
-
s?.unsubscribe();
|
47
|
-
};
|
48
|
-
return a;
|
49
|
-
// let s: Subscription;
|
50
|
-
// const promiseFunc = (resolve, reject) => {
|
51
|
-
// //TODO: add custome http request
|
52
|
-
// //const headers = new HttpHeaders().set('authorization','Bearer '+token);
|
53
|
-
// let b!: Observable<Blob>;
|
54
|
-
// if (typeof request === 'string') {
|
55
|
-
// b = this._httpClient.get(request, { responseType: 'blob' });
|
56
|
-
// } else if (isObservable(b)) {
|
57
|
-
// b = request;
|
58
|
-
// }
|
59
|
-
// s = b?.subscribe({
|
60
|
-
// next: (v) => resolve(new AXFileDownloadResult(v)),
|
61
|
-
// error: (e) => reject(e),
|
62
|
-
// });
|
63
|
-
// };
|
64
|
-
// const a = new AXFileDownloadRef(promiseFunc);
|
65
|
-
// a.abort = () => {
|
66
|
-
// s?.unsubscribe();
|
67
|
-
// };
|
68
|
-
// return a;
|
69
|
-
}
|
70
|
-
upload(url, files) {
|
71
|
-
let s;
|
72
|
-
const formData = new FormData();
|
73
|
-
files.forEach((f) => {
|
74
|
-
formData.append('files', f);
|
75
|
-
});
|
76
|
-
const promiseFunc = (resolve, reject) => {
|
77
|
-
const b = this._httpClient.post(url, formData);
|
78
|
-
s = b?.subscribe({
|
79
|
-
next: (v) => resolve(v),
|
80
|
-
error: (e) => reject(e),
|
81
|
-
});
|
82
|
-
};
|
83
|
-
const a = new AXFileUploadRef(promiseFunc);
|
84
|
-
a.abort = () => {
|
85
|
-
s?.unsubscribe();
|
86
|
-
};
|
87
|
-
return a;
|
88
|
-
}
|
89
21
|
choose(options) {
|
90
22
|
return new Promise((resolve, reject) => {
|
91
23
|
options = Object.assign({ multiple: false }, options);
|
@@ -130,7 +62,7 @@ export class AXFileService {
|
|
130
62
|
getBase64Size(base64) {
|
131
63
|
return atob(base64.substring(base64.indexOf(',') + 1)).length;
|
132
64
|
}
|
133
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.0.2", ngImport: i0, type: AXFileService, deps: [
|
65
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.0.2", ngImport: i0, type: AXFileService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
134
66
|
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.0.2", ngImport: i0, type: AXFileService, providedIn: 'root' }); }
|
135
67
|
}
|
136
68
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.0.2", ngImport: i0, type: AXFileService, decorators: [{
|
@@ -138,5 +70,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.0.2", ngImpor
|
|
138
70
|
args: [{
|
139
71
|
providedIn: 'root',
|
140
72
|
}]
|
141
|
-
}]
|
142
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZmlsZS5zZXJ2aWNlLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vLi4vLi4vLi4vbGl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IGJsb2InKTtcbiAgICB9XG4gIH07XG5cbiAgcHVibGljIGdldFNpemUoZmlsZTogRmlsZSB8IEJsb2IgfCBzdHJpbmcpIHtcbiAgICBpZiAodGhpcy5pc0Jhc2U2NChmaWxlIGFzIHN0cmluZykpIHtcbiAgICAgIHJldHVybiB0aGlzLmdldEJhc2U2NFNpemUoZmlsZSBhcyBzdHJpbmcpO1xuICAgIH1cbiAgICByZXR1cm4gZmFsc2U7XG4gIH1cblxuICBwdWJsaWMgaXNCYXNlNjQoYmFzZTY0OiBzdHJpbmcpIHtcbiAgICBjb25zdCByZWd4ID0gL1teOl1cXHcrXFwvW1xcdy0rXFxkLl0rKD89O3wsKS87XG4gICAgcmV0dXJuIHJlZ3gudGVzdChiYXNlNjQpO1xuICB9XG5cbiAgcHVibGljIGdldEJhc2U2NFNpemUoYmFzZTY0OiBzdHJpbmcpIHtcbiAgICByZXR1cm4gYXRvYihiYXNlNjQuc3Vic3RyaW5nKGJhc2U2NC5pbmRleE9mKCcsJykgKyAxKSkubGVuZ3RoO1xuICB9XG59XG4iXX0=
|
@@ -0,0 +1,5 @@
|
|
1
|
+
/**
|
2
|
+
* Generated bundle index. Do not edit.
|
3
|
+
*/
|
4
|
+
export * from './index';
|
5
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYWNvcmV4LWNvcmUtbmV0d29yay5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uLy4uL2xpYnMvY29yZS9uZXR3b3JrL3NyYy9hY29yZXgtY29yZS1uZXR3b3JrLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBOztHQUVHO0FBRUgsY0FBYyxTQUFTLENBQUMiLCJzb3VyY2VzQ29udGVudCI6WyIvKipcbiAqIEdlbmVyYXRlZCBidW5kbGUgaW5kZXguIERvIG5vdCBlZGl0LlxuICovXG5cbmV4cG9ydCAqIGZyb20gJy4vaW5kZXgnO1xuIl19
|
@@ -0,0 +1,5 @@
|
|
1
|
+
export * from './lib/upload-task';
|
2
|
+
export * from './lib/download-task';
|
3
|
+
export * from './lib/network.types';
|
4
|
+
export * from './lib/network.service';
|
5
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi8uLi9saWJzL2NvcmUvbmV0d29yay9zcmMvaW5kZXgudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsY0FBYyxtQkFBbUIsQ0FBQztBQUNsQyxjQUFjLHFCQUFxQixDQUFDO0FBQ3BDLGNBQWMscUJBQXFCLENBQUM7QUFDcEMsY0FBYyx1QkFBdUIsQ0FBQyIsInNvdXJjZXNDb250ZW50IjpbImV4cG9ydCAqIGZyb20gJy4vbGliL3VwbG9hZC10YXNrJztcbmV4cG9ydCAqIGZyb20gJy4vbGliL2Rvd25sb2FkLXRhc2snO1xuZXhwb3J0ICogZnJvbSAnLi9saWIvbmV0d29yay50eXBlcyc7XG5leHBvcnQgKiBmcm9tICcuL2xpYi9uZXR3b3JrLnNlcnZpY2UnOyJdfQ==
|
@@ -0,0 +1,47 @@
|
|
1
|
+
import { Subject } from 'rxjs';
|
2
|
+
import { takeUntil, map } from 'rxjs/operators';
|
3
|
+
import { HttpEventType } from '@angular/common/http';
|
4
|
+
import { AXDownloadStatus } from './network.types'; // Ensure correct import path
|
5
|
+
export class AXDownloadTask {
|
6
|
+
constructor(observable) {
|
7
|
+
this.observable = observable;
|
8
|
+
this.cancelSignal = new Subject();
|
9
|
+
}
|
10
|
+
get events() {
|
11
|
+
return this.observable.pipe(takeUntil(this.cancelSignal), map(event => this.handleEvent(event)));
|
12
|
+
}
|
13
|
+
handleEvent(event) {
|
14
|
+
switch (event.type) {
|
15
|
+
case HttpEventType.DownloadProgress:
|
16
|
+
{
|
17
|
+
const percentDone = Math.round(100 * event.loaded / (event.total ?? event.loaded));
|
18
|
+
return {
|
19
|
+
progress: percentDone,
|
20
|
+
bytesReceived: event.loaded,
|
21
|
+
totalBytes: event.total ?? 0,
|
22
|
+
status: AXDownloadStatus.Downloading
|
23
|
+
};
|
24
|
+
}
|
25
|
+
case HttpEventType.Response:
|
26
|
+
return {
|
27
|
+
progress: 100,
|
28
|
+
bytesReceived: event.body.size,
|
29
|
+
totalBytes: event.body.size,
|
30
|
+
status: AXDownloadStatus.DownloadComplete,
|
31
|
+
data: event.body
|
32
|
+
};
|
33
|
+
default:
|
34
|
+
return {
|
35
|
+
progress: 0,
|
36
|
+
bytesReceived: 0,
|
37
|
+
totalBytes: 0,
|
38
|
+
status: AXDownloadStatus.StartingDownload
|
39
|
+
};
|
40
|
+
}
|
41
|
+
}
|
42
|
+
cancel() {
|
43
|
+
this.cancelSignal.next();
|
44
|
+
this.cancelSignal.complete();
|
45
|
+
}
|
46
|
+
}
|
47
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZG93bmxvYWQtdGFzay5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uLy4uLy4uL2xpYnMvY29yZS9uZXR3b3JrL3NyYy9saWIvZG93bmxvYWQtdGFzay50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEVBQWMsT0FBTyxFQUFFLE1BQU0sTUFBTSxDQUFDO0FBQzNDLE9BQU8sRUFBRSxTQUFTLEVBQUUsR0FBRyxFQUFFLE1BQU0sZ0JBQWdCLENBQUM7QUFDaEQsT0FBTyxFQUFhLGFBQWEsRUFBRSxNQUFNLHNCQUFzQixDQUFDO0FBQ2hFLE9BQU8sRUFBc0IsZ0JBQWdCLEVBQUUsTUFBTSxpQkFBaUIsQ0FBQyxDQUFDLDZCQUE2QjtBQUVyRyxNQUFNLE9BQU8sY0FBYztJQUd2QixZQUFvQixVQUFzQztR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kUmVzcG9uc2U+IHtcbiAgICAgICAgcmV0dXJuIHRoaXMub2JzZXJ2YWJsZS5waXBlKFxuICAgICAgICAgICAgdGFrZVVudGlsKHRoaXMuY2FuY2VsU2lnbmFsKSxcbiAgICAgICAgICAgIG1hcChldmVudCA9PiB0aGlzLmhhbmRsZUV2ZW50KGV2ZW50KSksXG4gICAgICAgICk7XG4gICAgfVxuXG4gICAgcHJpdmF0ZSBoYW5kbGVFdmVudChldmVudDogSHR0cEV2ZW50PGFueT4pOiBBWERvd25sb2FkUmVzcG9uc2Uge1xuICAgICAgICBzd2l0Y2ggKGV2ZW50LnR5cGUpIHtcbiAgICAgICAgICAgIGNhc2UgSHR0cEV2ZW50VHlwZS5Eb3dubG9hZFByb2dyZXNzOlxuICAgICAgICAgICAgICAgIHtcbiAgICAgICAgICAgICAgICAgICAgY29uc3QgcGVyY2VudERvbmUgPSBNYXRoLnJvdW5kKDEwMCAqIGV2ZW50LmxvYWRlZCAvIChldmVudC50b3RhbCA/PyBldmVudC5sb2FkZWQpKTtcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIHByb2dyZXNzOiBwZXJjZW50RG9uZSxcbiAgICAgICAgICAgICAgICAgICAgICAgIGJ5dGVzUmVjZWl2ZWQ6IGV2ZW50LmxvYWRlZCxcbiAgICAgICAgICAgICAgICAgICAgICAgIHRvdGFsQnl0ZXM6IGV2ZW50LnRvdGFsID8/IDAsXG4gICAgICAgICAgICAgICAgICAgICAgICBzdGF0dXM6IEFYRG93bmxvYWRTdGF0dXMuRG93bmxvYWRpbmdcbiAgICAgICAgICAgICAgICAgICAgfTtcbiAgICAgICAgICAgICAgICB9XG5cbiAgICAgICAgICAgIGNhc2UgSHR0cEV2ZW50VHlwZS5SZXNwb25zZTpcbiAgICAgICAgICAgICAgICByZXR1cm4ge1xuICAgICAgICAgICAgICAgICAgICBwcm9ncmVzczogMTAwLFxuICAgICAgICAgICAgICAgICAgICBieXRlc1JlY2VpdmVkOiBldmVudC5ib2R5LnNpemUsXG4gICAgICAgICAgICAgICAgICAgIHRvdGFsQnl0ZXM6IGV2ZW50LmJvZHkuc2l6ZSxcbiAgICAgICAgICAgICAgICAgICAgc3RhdHVzOiBBWERvd25sb2FkU3RhdHVzLkRvd25sb2FkQ29tcGxldGUsXG4gICAgICAgICAgICAgICAgICAgIGRhdGE6IGV2ZW50LmJvZHlcbiAgICAgICAgICAgICAgICB9O1xuXG4gICAgICAgICAgICBkZWZhdWx0OlxuICAgICAgICAgICAgICAgIHJldHVybiB7XG4gICAgICAgICAgICAgICAgICAgIHByb2dyZXNzOiAwLFxuICAgICAgICAgICAgICAgICAgICBieXRlc1JlY2VpdmVkOiAwLFxuICAgICAgICAgICAgICAgICAgICB0b3RhbEJ5dGVzOiAwLFxuICAgICAgICAgICAgICAgICAgICBzdGF0dXM6IEFYRG93bmxvYWRTdGF0dXMuU3RhcnRpbmdEb3dubG9hZFxuICAgICAgICAgICAgICAgIH07XG4gICAgICAgIH1cbiAgICB9XG5cbiAgICBjYW5jZWwoKSB7XG4gICAgICAgIHRoaXMuY2FuY2VsU2lnbmFsLm5leHQoKTtcbiAgICAgICAgdGhpcy5jYW5jZWxTaWduYWwuY29tcGxldGUoKTtcbiAgICB9XG59XG4iXX0=
|
@@ -0,0 +1,72 @@
|
|
1
|
+
import { HttpRequest, HttpClient } from '@angular/common/http';
|
2
|
+
import { inject, Injectable } from '@angular/core';
|
3
|
+
import { AXDownloadTask } from './download-task';
|
4
|
+
import { AXUploadTask } from './upload-task';
|
5
|
+
import * as i0 from "@angular/core";
|
6
|
+
export class AXNetworkService {
|
7
|
+
constructor() {
|
8
|
+
this.http = inject(HttpClient);
|
9
|
+
}
|
10
|
+
// Unified method handling both types of inputs
|
11
|
+
upload(arg1, arg2) {
|
12
|
+
let request;
|
13
|
+
let totalFilesSize = 0;
|
14
|
+
if (typeof arg1 === 'string' && arg2 instanceof FormData) {
|
15
|
+
// Calculate total file size
|
16
|
+
arg2.forEach((value) => {
|
17
|
+
if (value instanceof File) {
|
18
|
+
totalFilesSize += value.size;
|
19
|
+
}
|
20
|
+
});
|
21
|
+
request = new HttpRequest('POST', arg1, arg2, {
|
22
|
+
reportProgress: true,
|
23
|
+
responseType: 'json'
|
24
|
+
});
|
25
|
+
}
|
26
|
+
else if (arg1 instanceof HttpRequest) {
|
27
|
+
if (arg1.body instanceof FormData) {
|
28
|
+
// Calculate total file size
|
29
|
+
arg1.body.forEach((value) => {
|
30
|
+
if (value instanceof File) {
|
31
|
+
totalFilesSize += value.size;
|
32
|
+
}
|
33
|
+
});
|
34
|
+
}
|
35
|
+
request = arg1.clone({
|
36
|
+
reportProgress: true,
|
37
|
+
responseType: arg1.responseType || 'json'
|
38
|
+
});
|
39
|
+
}
|
40
|
+
else {
|
41
|
+
throw new Error("Invalid arguments for upload method.");
|
42
|
+
}
|
43
|
+
const events = this.http.request(request);
|
44
|
+
return new AXUploadTask(events, totalFilesSize);
|
45
|
+
}
|
46
|
+
// Unified method handling both types of inputs
|
47
|
+
download(arg) {
|
48
|
+
let request;
|
49
|
+
if (typeof arg === 'string') {
|
50
|
+
request = new HttpRequest('GET', arg, {
|
51
|
+
reportProgress: true,
|
52
|
+
responseType: 'blob',
|
53
|
+
});
|
54
|
+
}
|
55
|
+
else {
|
56
|
+
request = new HttpRequest(arg.method, arg.url, arg.body, {
|
57
|
+
...arg,
|
58
|
+
reportProgress: true,
|
59
|
+
responseType: 'blob',
|
60
|
+
});
|
61
|
+
}
|
62
|
+
const events = this.http.request(request);
|
63
|
+
return new AXDownloadTask(events);
|
64
|
+
}
|
65
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.0.2", ngImport: i0, type: AXNetworkService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
66
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.0.2", ngImport: i0, type: AXNetworkService, providedIn: 'root' }); }
|
67
|
+
}
|
68
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.0.2", ngImport: i0, type: AXNetworkService, decorators: [{
|
69
|
+
type: Injectable,
|
70
|
+
args: [{ providedIn: 'root' }]
|
71
|
+
}] });
|
72
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibmV0d29yay5zZXJ2aWNlLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vLi4vLi4vLi4vbGlicy9jb3JlL25ldHdvcmsvc3JjL2xpYi9uZXR3b3JrLnNlcnZpY2UudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxFQUFFLFdBQVcsRUFBRSxVQUFVLEVBQUUsTUFBTSxzQkFBc0IsQ0FBQztBQUMvRCxPQUFPLEVBQUUsTUFBTSxFQUFFLFVBQVUsRUFBRSxNQUFNLGVBQWUsQ0FBQztBQUNuRCxPQUFPLEVBQUUsY0FBYyxFQUFFLE1BQU0saUJBQWlCLENBQUM7QUFDakQsT0FBTyxFQUFFLFlBQVksRUFBRSxNQUFNLGVBQWUsQ0FBQzs7QUFLN0MsTUFBTSxPQUFPLGdCQUFnQjtJQUQ3QjtRQUdZLFNBQUksR0FBRyxNQUFNLENBQUMsVUFBVSxDQUFDLENBQUM7S0FzRXJDO0lBaEVHLCtDQUErQztJQUMvQyxNQUFNLENBQUksSUFBK0IsRUFBRSxJQUFlO1FBQ3RELElBQUksT0FBeUIsQ0FBQztRQUM5QixJQUFJLGNBQWMsR0FBRyxDQUFDLENBQUM7UUFFdkIsSUFBSSxPQUFPLElBQUksS0FBSyxRQUFRLElBQUksSUFBSSxZQUFZLFFBQVEsRUFBRSxDQUFDO1lBQ3ZELDRCQUE0QjtZQUM1QixJQUFJLENBQUMsT0FBTyxDQUFDLENBQUMsS0FBSyxFQUFFLEVBQUU7Z0JBQ25CLElBQUksS0FBSyxZQUFZLElBQU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pemU7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfSk7XG4gICAgICAgICAgICByZXF1ZXN0ID0gbmV3IEh0dHBSZXF1ZXN0KCdQT1NUJywgYXJnMSwgYXJnMiwge1xuICAgICAgICAgICAgICAgIHJlcG9ydFByb2dyZXNzOiB0cnVlLFxuICAgICAgICAgICAgICAgIHJlc3BvbnNlVHlwZTogJ2pzb24nXG4gICAgICAgICAgICB9KTtcbiAgICAgICAgfSBlbHNlIGlmIChhcmcxIGluc3RhbmNlb2YgSHR0cFJlcXVlc3QpIHtcbiAgICAgICAgICAgIGlmIChhcmcxLmJvZHkgaW5zdGFuY2VvZiBGb3JtRGF0YSkge1xuICAgICAgICAgICAgICAgIC8vIENhbGN1bGF0ZSB0b3RhbCBmaWxlIHNpemVcbiAgICAgICAgICAgICAgICBhcmcxLmJvZHkuZm9yRWFjaCgodmFsdWUpID0+IHtcbiAgICAgICAgICAgICAgICAgICAgaWYgKHZhbHVlIGluc3RhbmNlb2YgRmlsZSkge1xuICAgICAgICAgICAgICAgICAgICAgICAgdG90YWxGaWxlc1NpemUgKz0gdmFsdWUuc2l6ZTtcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIH0pO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgcmVxdWVzdCA9IGFyZzEuY2xvbmUoe1xuICAgICAgICAgICAgICAgIHJlcG9ydFByb2dyZXNzOiB0cnVlLFxuICAgICAgICAgICAgICAgIHJlc3BvbnNlVHlwZTogYXJnMS5yZXNwb25zZVR5cGUgfHwgJ2pzb24nXG4gICAgICAgICAgICB9KTtcbiAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgIHRocm93IG5ldyBFcnJvcihcIkludmFsaWQgYXJndW1lbnRzIGZvciB1cGxvYWQgbWV0aG9kLlwiKTtcbiAgICAgICAgfVxuXG4gICAgICAgIGNvbnN0IGV2ZW50cyA9IHRoaXMuaHR0cC5yZXF1ZXN0PFQ+KHJlcXV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KHJlcXVlc3QpO1xuICAgICAgICByZXR1cm4gbmV3IEFYRG93bmxvYWRUYXNrKGV2ZW50cyk7XG4gICAgfVxuXG59Il19
|
@@ -0,0 +1,15 @@
|
|
1
|
+
export var AXUploadStatus;
|
2
|
+
(function (AXUploadStatus) {
|
3
|
+
AXUploadStatus["Uploading"] = "Uploading...";
|
4
|
+
AXUploadStatus["UploadComplete"] = "Upload complete";
|
5
|
+
AXUploadStatus["StartingUpload"] = "Starting upload";
|
6
|
+
AXUploadStatus["UploadFailed"] = "Upload failed";
|
7
|
+
})(AXUploadStatus || (AXUploadStatus = {}));
|
8
|
+
export var AXDownloadStatus;
|
9
|
+
(function (AXDownloadStatus) {
|
10
|
+
AXDownloadStatus["Downloading"] = "Downloading...";
|
11
|
+
AXDownloadStatus["DownloadComplete"] = "Download complete";
|
12
|
+
AXDownloadStatus["StartingDownload"] = "Starting download";
|
13
|
+
AXDownloadStatus["DownloadFailed"] = "Download failed";
|
14
|
+
})(AXDownloadStatus || (AXDownloadStatus = {}));
|
15
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibmV0d29yay50eXBlcy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uLy4uLy4uL2xpYnMvY29yZS9uZXR3b3JrL3NyYy9saWIvbmV0d29yay50eXBlcy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxNQUFNLENBQU4sSUFBWSxjQUtYO0FBTEQsV0FBWSxjQUFjO0lBQ3RCLDRDQUEwQixDQUFBO0lBQzFCLG9EQUFrQyxDQUFBO0lBQ2xDLG9EQUFrQyxDQUFBO0lBQ2xDLGdEQUE4QixDQUFBO0FBQ2xDLENBQUMsRUFMVyxjQUFjLEtBQWQsY0FBYyxRQUt6QjtBQVVELE1BQU0sQ0FBTixJQUFZLGdCQUtYO0FBTEQsV0FBWSxnQkFBZ0I7SUFDeEIsa0RBQThCLEN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GF0dXM6IEFYRG93bmxvYWRTdGF0dXM7XG4gICAgZGF0YT86IEJsb2I7IC8vIG9yIGFueSBhcHByb3ByaWF0ZSB0eXBlIGJhc2VkIG9uIHlvdXIgc3BlY2lmaWMgdXNlIGNhc2Vcbn07Il19
|
@@ -0,0 +1,48 @@
|
|
1
|
+
import { Subject } from 'rxjs';
|
2
|
+
import { takeUntil, map } from 'rxjs/operators';
|
3
|
+
import { HttpEventType } from '@angular/common/http';
|
4
|
+
import { AXUploadStatus } from './network.types'; // Ensure correct import path
|
5
|
+
export class AXUploadTask {
|
6
|
+
constructor(observable, totalFileSize) {
|
7
|
+
this.observable = observable;
|
8
|
+
this.totalFileSize = totalFileSize;
|
9
|
+
this.cancelSignal = new Subject();
|
10
|
+
}
|
11
|
+
get events() {
|
12
|
+
return this.observable.pipe(takeUntil(this.cancelSignal), map(event => this.handleEvent(event)));
|
13
|
+
}
|
14
|
+
handleEvent(event) {
|
15
|
+
switch (event.type) {
|
16
|
+
case HttpEventType.UploadProgress:
|
17
|
+
{
|
18
|
+
const percentDone = Math.round(100 * event.loaded / (this.totalFileSize || event.total));
|
19
|
+
return {
|
20
|
+
progress: percentDone,
|
21
|
+
bytesTransferred: event.loaded,
|
22
|
+
totalBytes: this.totalFileSize,
|
23
|
+
status: AXUploadStatus.Uploading
|
24
|
+
};
|
25
|
+
}
|
26
|
+
case HttpEventType.Response:
|
27
|
+
return {
|
28
|
+
progress: 100,
|
29
|
+
bytesTransferred: this.totalFileSize,
|
30
|
+
totalBytes: this.totalFileSize,
|
31
|
+
status: AXUploadStatus.UploadComplete,
|
32
|
+
result: event.body
|
33
|
+
};
|
34
|
+
default:
|
35
|
+
return {
|
36
|
+
progress: 0,
|
37
|
+
bytesTransferred: 0,
|
38
|
+
totalBytes: 0,
|
39
|
+
status: AXUploadStatus.StartingUpload
|
40
|
+
};
|
41
|
+
}
|
42
|
+
}
|
43
|
+
cancel() {
|
44
|
+
this.cancelSignal.next();
|
45
|
+
this.cancelSign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gICBjb25zdCBwZXJjZW50RG9uZSA9IE1hdGgucm91bmQoMTAwICogZXZlbnQubG9hZGVkIC8gKHRoaXMudG90YWxGaWxlU2l6ZSB8fCBldmVudC50b3RhbCkpO1xuICAgICAgICAgICAgICAgICAgICByZXR1cm4ge1xuICAgICAgICAgICAgICAgICAgICAgICAgcHJvZ3Jlc3M6IHBlcmNlbnREb25lLFxuICAgICAgICAgICAgICAgICAgICAgICAgYnl0ZXNUcmFuc2ZlcnJlZDogZXZlbnQubG9hZGVkLFxuICAgICAgICAgICAgICAgICAgICAgICAgdG90YWxCeXRlczogdGhpcy50b3RhbEZpbGVTaXplLFxuICAgICAgICAgICAgICAgICAgICAgICAgc3RhdHVzOiBBWFVwbG9hZFN0YXR1cy5VcGxvYWRpbmdcbiAgICAgICAgICAgICAgICAgICAgfTtcbiAgICAgICAgICAgICAgICB9XG5cbiAgICAgICAgICAgIGNhc2UgSHR0cEV2ZW50VHlwZS5SZXNwb25zZTpcbiAgICAgICAgICAgICAgICByZXR1cm4ge1xuICAgICAgICAgICAgICAgICAgICBwcm9ncmVzczogMTAwLFxuICAgICAgICAgICAgICAgICAgICBieXRlc1RyYW5zZmVycmVkOiB0aGlzLnRvdGFsRmlsZVNpemUsXG4gICAgICAgICAgICAgICAgICAgIHRvdGFsQnl0ZXM6IHRoaXMudG90YWxGaWxlU2l6ZSxcbiAgICAgICAgICAgICAgICAgICAgc3RhdHVzOiBBWFVwbG9hZFN0YXR1cy5VcGxvYWRDb21wbGV0ZSxcbiAgICAgICAgICAgICAgICAgICAgcmVzdWx0OiBldmVudC5ib2R5XG4gICAgICAgICAgICAgICAgfTtcblxuICAgICAgICAgICAgZGVmYXVsdDpcbiAgICAgICAgICAgICAgICByZXR1cm4ge1xuICAgICAgICAgICAgICAgICAgICBwcm9ncmVzczogMCxcbiAgICAgICAgICAgICAgICAgICAgYnl0ZXNUcmFuc2ZlcnJlZDogMCxcbiAgICAgICAgICAgICAgICAgICAgdG90YWxCeXRlczogMCxcbiAgICAgICAgICAgICAgICAgICAgc3RhdHVzOiBBWFVwbG9hZFN0YXR1cy5TdGFydGluZ1VwbG9hZFxuICAgICAgICAgICAgICAgIH07XG4gICAgICAgIH1cbiAgICB9XG5cbiAgICBjYW5jZWwoKSB7XG4gICAgICAgIHRoaXMuY2FuY2VsU2lnbmFsLm5leHQoKTtcbiAgICAgICAgdGhpcy5jYW5jZWxTaWduYWwuY29tcGxldGUoKTtcbiAgICB9XG59XG4iXX0=
|
@@ -2,65 +2,6 @@ import * as i0 from '@angular/core';
|
|
2
2
|
import { Injectable, NgModule } from '@angular/core';
|
3
3
|
import * as i1 from '@acorex/core/format';
|
4
4
|
import { AXFormatModule } from '@acorex/core/format';
|
5
|
-
import * as i1$1 from '@angular/common/http';
|
6
|
-
import { HttpRequest } from '@angular/common/http';
|
7
|
-
|
8
|
-
class AXFileDownloadRef extends Promise {
|
9
|
-
constructor(executor) {
|
10
|
-
super(executor);
|
11
|
-
}
|
12
|
-
//abort the operation
|
13
|
-
abort() {
|
14
|
-
if (this.abortMethod) {
|
15
|
-
this.abortMethod();
|
16
|
-
}
|
17
|
-
}
|
18
|
-
}
|
19
|
-
|
20
|
-
class AXFileDownloadResult {
|
21
|
-
constructor(response) {
|
22
|
-
this._response = response;
|
23
|
-
}
|
24
|
-
save(filename) {
|
25
|
-
this._defaultBrowserDownload(filename);
|
26
|
-
return Promise.resolve();
|
27
|
-
// else {
|
28
|
-
// return new Promise((resolve, reject) => {
|
29
|
-
// const button = document.createElement("button");
|
30
|
-
// button.addEventListener('click', async () => {
|
31
|
-
// button.remove();
|
32
|
-
// const opts = {
|
33
|
-
// types: [{
|
34
|
-
// description: 'Save File',
|
35
|
-
// suggestedName: filename
|
36
|
-
// // accept: {'text/plain': ['.txt']},
|
37
|
-
// }],
|
38
|
-
// };
|
39
|
-
// const result = await window['showSaveFilePicker'](opts);
|
40
|
-
// resolve();
|
41
|
-
// });
|
42
|
-
// button.click();
|
43
|
-
// });
|
44
|
-
// }
|
45
|
-
}
|
46
|
-
blob() {
|
47
|
-
return this._response;
|
48
|
-
}
|
49
|
-
base64() {
|
50
|
-
return new Promise((resolve, reject) => {
|
51
|
-
const reader = new window.FileReader();
|
52
|
-
reader.onloadend = () => resolve(reader.result);
|
53
|
-
reader.onerror = (e) => reject(e);
|
54
|
-
reader.readAsDataURL(this._response);
|
55
|
-
});
|
56
|
-
}
|
57
|
-
_defaultBrowserDownload(filename = 'download') {
|
58
|
-
const link = document.createElement('a');
|
59
|
-
link.href = URL.createObjectURL(this._response);
|
60
|
-
link.download = filename;
|
61
|
-
link.click();
|
62
|
-
}
|
63
|
-
}
|
64
5
|
|
65
6
|
class AXFileSizeFormatter {
|
66
7
|
get name() {
|
@@ -84,18 +25,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.0.2", ngImpor
|
|
84
25
|
type: Injectable
|
85
26
|
}] });
|
86
27
|
|
87
|
-
class AXFileUploadRef extends Promise {
|
88
|
-
constructor(executor) {
|
89
|
-
super(executor);
|
90
|
-
}
|
91
|
-
//abort the operation
|
92
|
-
abort() {
|
93
|
-
if (this.abortMethod) {
|
94
|
-
this.abortMethod();
|
95
|
-
}
|
96
|
-
}
|
97
|
-
}
|
98
|
-
|
99
28
|
class AXFileModule {
|
100
29
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.0.2", ngImport: i0, type: AXFileModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
|
101
30
|
static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "18.0.2", ngImport: i0, type: AXFileModule, imports: [i1.AXFormatModule] }); }
|
@@ -112,8 +41,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.0.2", ngImpor
|
|
112
41
|
}] });
|
113
42
|
|
114
43
|
class AXFileService {
|
115
|
-
constructor(
|
116
|
-
this._httpClient = _httpClient;
|
44
|
+
constructor() {
|
117
45
|
this.blobToBase64 = (blob) => {
|
118
46
|
if (blob instanceof Blob) {
|
119
47
|
return new Promise((resolve, reject) => {
|
@@ -130,68 +58,6 @@ class AXFileService {
|
|
130
58
|
}
|
131
59
|
};
|
132
60
|
}
|
133
|
-
download(request) {
|
134
|
-
let s;
|
135
|
-
const promiseFunc = (resolve, reject) => {
|
136
|
-
if (typeof request == 'string') {
|
137
|
-
//
|
138
|
-
}
|
139
|
-
if (request instanceof Blob) {
|
140
|
-
//
|
141
|
-
}
|
142
|
-
if (request instanceof HttpRequest) {
|
143
|
-
const b = this._httpClient.request(request);
|
144
|
-
b.subscribe({
|
145
|
-
next: (v) => resolve(new AXFileDownloadResult(v)),
|
146
|
-
error: (e) => reject(e),
|
147
|
-
});
|
148
|
-
}
|
149
|
-
};
|
150
|
-
const a = new AXFileDownloadRef(promiseFunc);
|
151
|
-
a.abort = () => {
|
152
|
-
s?.unsubscribe();
|
153
|
-
};
|
154
|
-
return a;
|
155
|
-
// let s: Subscription;
|
156
|
-
// const promiseFunc = (resolve, reject) => {
|
157
|
-
// //TODO: add custome http request
|
158
|
-
// //const headers = new HttpHeaders().set('authorization','Bearer '+token);
|
159
|
-
// let b!: Observable<Blob>;
|
160
|
-
// if (typeof request === 'string') {
|
161
|
-
// b = this._httpClient.get(request, { responseType: 'blob' });
|
162
|
-
// } else if (isObservable(b)) {
|
163
|
-
// b = request;
|
164
|
-
// }
|
165
|
-
// s = b?.subscribe({
|
166
|
-
// next: (v) => resolve(new AXFileDownloadResult(v)),
|
167
|
-
// error: (e) => reject(e),
|
168
|
-
// });
|
169
|
-
// };
|
170
|
-
// const a = new AXFileDownloadRef(promiseFunc);
|
171
|
-
// a.abort = () => {
|
172
|
-
// s?.unsubscribe();
|
173
|
-
// };
|
174
|
-
// return a;
|
175
|
-
}
|
176
|
-
upload(url, files) {
|
177
|
-
let s;
|
178
|
-
const formData = new FormData();
|
179
|
-
files.forEach((f) => {
|
180
|
-
formData.append('files', f);
|
181
|
-
});
|
182
|
-
const promiseFunc = (resolve, reject) => {
|
183
|
-
const b = this._httpClient.post(url, formData);
|
184
|
-
s = b?.subscribe({
|
185
|
-
next: (v) => resolve(v),
|
186
|
-
error: (e) => reject(e),
|
187
|
-
});
|
188
|
-
};
|
189
|
-
const a = new AXFileUploadRef(promiseFunc);
|
190
|
-
a.abort = () => {
|
191
|
-
s?.unsubscribe();
|
192
|
-
};
|
193
|
-
return a;
|
194
|
-
}
|
195
61
|
choose(options) {
|
196
62
|
return new Promise((resolve, reject) => {
|
197
63
|
options = Object.assign({ multiple: false }, options);
|
@@ -236,7 +102,7 @@ class AXFileService {
|
|
236
102
|
getBase64Size(base64) {
|
237
103
|
return atob(base64.substring(base64.indexOf(',') + 1)).length;
|
238
104
|
}
|
239
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.0.2", ngImport: i0, type: AXFileService, deps: [
|
105
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.0.2", ngImport: i0, type: AXFileService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
240
106
|
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.0.2", ngImport: i0, type: AXFileService, providedIn: 'root' }); }
|
241
107
|
}
|
242
108
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.0.2", ngImport: i0, type: AXFileService, decorators: [{
|
@@ -244,11 +110,11 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.0.2", ngImpor
|
|
244
110
|
args: [{
|
245
111
|
providedIn: 'root',
|
246
112
|
}]
|
247
|
-
}]
|
113
|
+
}] });
|
248
114
|
|
249
115
|
/**
|
250
116
|
* Generated bundle index. Do not edit.
|
251
117
|
*/
|
252
118
|
|
253
|
-
export {
|
119
|
+
export { AXFileModule, AXFileService, AXFileSizeFormatter };
|
254
120
|
//# sourceMappingURL=acorex-core-file.mjs.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"acorex-core-file.mjs","sources":["../../../../libs/core/file/src/lib/file-download-ref.class.ts","../../../../libs/core/file/src/lib/file-download-result.class.ts","../../../../libs/core/file/src/lib/file-size-formatter.ts","../../../../libs/core/file/src/lib/file-upload-ref.class.ts","../../../../libs/core/file/src/lib/file.module.ts","../../../../libs/core/file/src/lib/file.service.ts","../../../../libs/core/file/src/acorex-core-file.ts"],"sourcesContent":["import { AXFileDownloadResult } from './file-download-result.class';\n\nexport class AXFileDownloadRef extends Promise<AXFileDownloadResult> {\n public abortMethod: () => void;\n constructor(executor: (resolve: (value?: PromiseLike<AXFileDownloadResult>) => void, reject: (reason?: any) => void) => void) {\n super(executor as any);\n }\n //abort the operation\n public abort() {\n if (this.abortMethod) {\n this.abortMethod();\n }\n }\n}\n","export class AXFileDownloadResult {\n _response: Blob;\n\n constructor(response: Blob) {\n this._response = response;\n }\n\n save(filename?: string): Promise<void> {\n this._defaultBrowserDownload(filename);\n return Promise.resolve();\n // else {\n // return new Promise((resolve, reject) => {\n // const button = document.createElement(\"button\");\n // button.addEventListener('click', async () => {\n // button.remove();\n // const opts = {\n // types: [{\n // description: 'Save File',\n // suggestedName: filename\n // // accept: {'text/plain': ['.txt']},\n // }],\n // };\n // const result = await window['showSaveFilePicker'](opts);\n\n // resolve();\n // });\n // button.click();\n // });\n\n // }\n }\n\n blob() {\n return this._response;\n }\n\n base64(): Promise<string> {\n return new Promise((resolve, reject) => {\n const reader = new window.FileReader();\n reader.onloadend = () => resolve(reader.result as string);\n reader.onerror = (e) => reject(e);\n reader.readAsDataURL(this._response);\n });\n }\n\n private _defaultBrowserDownload(filename = 'download') {\n const link = document.createElement('a');\n link.href = URL.createObjectURL(this._response);\n link.download = filename;\n link.click();\n }\n}\n","import { AXFormatOptions, AXFormatter } from '@acorex/core/format';\nimport { Injectable } from '@angular/core';\n\nexport interface AXFileSizeFormatterOptions extends AXFormatOptions {\n format: string;\n}\n\ndeclare module '@acorex/core/format' {\n interface AXFormatOptionsMap {\n filesize: AXFileSizeFormatterOptions;\n }\n}\n\n@Injectable()\nexport class AXFileSizeFormatter implements AXFormatter {\n get name(): string {\n return 'filesize';\n }\n\n format(value: number): string {\n const size = Number(value);\n\n if (size === 0) return '0 Bytes';\n if (Number.isNaN(size)) return 'Unknown';\n\n const k = 1024;\n const sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];\n const i = Math.floor(Math.log(size) / Math.log(k));\n\n return parseFloat((size / Math.pow(k, i)).toFixed(2)) + ' ' + sizes[i];\n }\n}\n","export class AXFileUploadRef<T = any> extends Promise<T> {\n public abortMethod: () => void;\n constructor(executor: (resolve: (value?: PromiseLike<T>) => void, reject: (reason?: any) => void) => void) {\n super(executor as any);\n }\n //abort the operation\n public abort() {\n if (this.abortMethod) {\n this.abortMethod();\n }\n }\n}\n","import { AXFormatModule } from '@acorex/core/format';\nimport { NgModule } from '@angular/core';\nimport { AXFileSizeFormatter } from './file-size-formatter';\n\n@NgModule({\n imports: [AXFormatModule.forChild({ formatters: [AXFileSizeFormatter] })],\n exports: [],\n declarations: [],\n providers: [AXFileSizeFormatter],\n})\nexport class AXFileModule {}\n","import { HttpClient, HttpRequest } from '@angular/common/http';\nimport { Injectable } from '@angular/core';\nimport { Observable, Subscription } from 'rxjs';\nimport { AXFileDownloadRef } from './file-download-ref.class';\nimport { AXFileDownloadResult } from './file-download-result.class';\nimport { AXFileUploadRef } from './file-upload-ref.class';\n\n@Injectable({\n providedIn: 'root',\n})\nexport class AXFileService {\n constructor(private _httpClient: HttpClient) {}\n\n public download(request: string | Blob | HttpRequest<any>) {\n let s: Subscription;\n\n const promiseFunc = (resolve, reject) => {\n if (typeof request == 'string') {\n //\n }\n if (request instanceof Blob) {\n //\n }\n if (request instanceof HttpRequest) {\n const b = this._httpClient.request(request);\n b.subscribe({\n next: (v: any) => resolve(new AXFileDownloadResult(v)),\n error: (e) => reject(e),\n });\n }\n };\n\n const a = new AXFileDownloadRef(promiseFunc);\n a.abort = () => {\n s?.unsubscribe();\n };\n\n return a;\n\n // let s: Subscription;\n // const promiseFunc = (resolve, reject) => {\n // //TODO: add custome http request\n // //const headers = new HttpHeaders().set('authorization','Bearer '+token);\n // let b!: Observable<Blob>;\n // if (typeof request === 'string') {\n // b = this._httpClient.get(request, { responseType: 'blob' });\n // } else if (isObservable(b)) {\n // b = request;\n // }\n // s = b?.subscribe({\n // next: (v) => resolve(new AXFileDownloadResult(v)),\n // error: (e) => reject(e),\n // });\n // };\n\n // const a = new AXFileDownloadRef(promiseFunc);\n // a.abort = () => {\n // s?.unsubscribe();\n // };\n\n // return a;\n }\n\n public upload<T = any>(url: string, files: File[]): AXFileUploadRef<T> {\n let s: Subscription;\n const formData = new FormData();\n files.forEach((f) => {\n formData.append('files', f);\n });\n const promiseFunc = (resolve, reject) => {\n const b: Observable<T> = this._httpClient.post<T>(url, formData);\n s = b?.subscribe({\n next: (v) => resolve(v),\n error: (e) => reject(e),\n });\n };\n\n const a = new AXFileUploadRef(promiseFunc);\n a.abort = () => {\n s?.unsubscribe();\n };\n return a;\n }\n\n public choose(options?: { accept?: string; multiple?: boolean }): Promise<File[]> {\n return new Promise<File[]>((resolve, reject) => {\n options = Object.assign({ multiple: false }, options);\n const input: HTMLInputElement = document.createElement('input');\n input.style.display = 'none';\n document.body.appendChild(input);\n input.type = 'file';\n input.accept = options.accept || '';\n input.multiple = options.multiple || false;\n //\n const onError = (e) => {\n reject(e);\n document.body.removeChild(input);\n input.remove();\n input.removeEventListener('change', onChange);\n input.removeEventListener('error', onError);\n };\n //\n const onChange = () => {\n resolve(Array.from(input.files || []));\n document.body.removeChild(input);\n input.remove();\n input.removeEventListener('change', onChange);\n input.removeEventListener('error', onError);\n };\n //\n input.addEventListener('change', onChange);\n input.addEventListener('error', onError);\n input.click();\n });\n }\n\n public blobToBase64 = (blob: Blob) => {\n if (blob instanceof Blob) {\n return new Promise<string>((resolve, reject) => {\n const reader = new FileReader();\n reader.onerror = reject;\n reader.onload = () => {\n resolve(reader.result as string);\n };\n reader.readAsDataURL(blob);\n });\n } else {\n return Promise.reject('input is not blob');\n }\n };\n\n public getSize(file: File | Blob | string) {\n if (this.isBase64(file as string)) {\n return this.getBase64Size(file as string);\n }\n return false;\n }\n\n public isBase64(base64: string) {\n const regx = /[^:]\\w+\\/[\\w-+\\d.]+(?=;|,)/;\n return regx.test(base64);\n }\n\n public getBase64Size(base64: string) {\n return atob(base64.substring(base64.indexOf(',') + 1)).length;\n }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":["i1"],"mappings":";;;;;;;AAEM,MAAO,iBAAkB,SAAQ,OAA6B,CAAA;AAElE,IAAA,WAAA,CAAY,QAAgH,EAAA;QAC1H,KAAK,CAAC,QAAe,CAAC,CAAC;KACxB;;IAEM,KAAK,GAAA;AACV,QAAA,IAAI,IAAI,CAAC,WAAW,EAAE;YACpB,IAAI,CAAC,WAAW,EAAE,CAAC;SACpB;KACF;AACF;;MCbY,oBAAoB,CAAA;AAG/B,IAAA,WAAA,CAAY,QAAc,EAAA;AACxB,QAAA,IAAI,CAAC,SAAS,GAAG,QAAQ,CAAC;KAC3B;AAED,IAAA,IAAI,CAAC,QAAiB,EAAA;AACpB,QAAA,IAAI,CAAC,uBAAuB,CAAC,QAAQ,CAAC,CAAC;AACvC,QAAA,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC;;;;;;;;;;;;;;;;;;;KAqB1B;IAED,IAAI,GAAA;QACF,OAAO,IAAI,CAAC,SAAS,CAAC;KACvB;IAED,MAAM,GAAA;QACJ,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,KAAI;AACrC,YAAA,MAAM,MAAM,GAAG,IAAI,MAAM,CAAC,UAAU,EAAE,CAAC;AACvC,YAAA,MAAM,CAAC,SAAS,GAAG,MAAM,OAAO,CAAC,MAAM,CAAC,MAAgB,CAAC,CAAC;AAC1D,YAAA,MAAM,CAAC,OAAO,GAAG,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A,IAAA,EAAA,CAAA;AACV,oBAAA,UAAU,EAAE,MAAM;AACnB,iBAAA,CAAA;;;ACTD;;AAEG;;;;"}
|
1
|
+
{"version":3,"file":"acorex-core-file.mjs","sources":["../../../../libs/core/file/src/lib/file-size-formatter.ts","../../../../libs/core/file/src/lib/file.module.ts","../../../../libs/core/file/src/lib/file.service.ts","../../../../libs/core/file/src/acorex-core-file.ts"],"sourcesContent":["import { AXFormatOptions, AXFormatter } from '@acorex/core/format';\nimport { Injectable } from '@angular/core';\n\nexport interface AXFileSizeFormatterOptions extends AXFormatOptions {\n format: string;\n}\n\ndeclare module '@acorex/core/format' {\n interface AXFormatOptionsMap {\n filesize: AXFileSizeFormatterOptions;\n }\n}\n\n@Injectable()\nexport class AXFileSizeFormatter implements AXFormatter {\n get name(): string {\n return 'filesize';\n }\n\n format(value: number): string {\n const size = Number(value);\n\n if (size === 0) return '0 Bytes';\n if (Number.isNaN(size)) return 'Unknown';\n\n const k = 1024;\n const sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];\n const i = Math.floor(Math.log(size) / Math.log(k));\n\n return parseFloat((size / Math.pow(k, i)).toFixed(2)) + ' ' + sizes[i];\n }\n}\n","import { AXFormatModule } from '@acorex/core/format';\nimport { NgModule } from '@angular/core';\nimport { AXFileSizeFormatter } from './file-size-formatter';\n\n@NgModule({\n imports: [AXFormatModule.forChild({ formatters: [AXFileSizeFormatter] })],\n exports: [],\n declarations: [],\n providers: [AXFileSizeFormatter],\n})\nexport class AXFileModule {}\n","import { Injectable } from '@angular/core';\n\n\n@Injectable({\n providedIn: 'root',\n})\nexport class AXFileService {\n\n public choose(options?: { accept?: string; multiple?: boolean }): Promise<File[]> {\n return new Promise<File[]>((resolve, reject) => {\n options = Object.assign({ multiple: false }, options);\n const input: HTMLInputElement = document.createElement('input');\n input.style.display = 'none';\n document.body.appendChild(input);\n input.type = 'file';\n input.accept = options.accept || '';\n input.multiple = options.multiple || false;\n //\n const onError = (e) => {\n reject(e);\n document.body.removeChild(input);\n input.remove();\n input.removeEventListener('change', onChange);\n input.removeEventListener('error', onError);\n };\n //\n const onChange = () => {\n resolve(Array.from(input.files || []));\n document.body.removeChild(input);\n input.remove();\n input.removeEventListener('change', onChange);\n input.removeEventListener('error', onError);\n };\n //\n input.addEventListener('change', onChange);\n input.addEventListener('error', onError);\n input.click();\n });\n }\n\n public blobToBase64 = (blob: Blob) => {\n if (blob instanceof Blob) {\n return new Promise<string>((resolve, reject) => {\n const reader = new FileReader();\n reader.onerror = reject;\n reader.onload = () => {\n resolve(reader.result as string);\n };\n reader.readAsDataURL(blob);\n });\n } else {\n return Promise.reject('input is not blob');\n }\n };\n\n public getSize(file: File | Blob | string) {\n if (this.isBase64(file as string)) {\n return this.getBase64Size(file as string);\n }\n return false;\n }\n\n public isBase64(base64: string) {\n const regx = /[^:]\\w+\\/[\\w-+\\d.]+(?=;|,)/;\n return regx.test(base64);\n }\n\n public getBase64Size(base64: string) {\n return atob(base64.substring(base64.indexOf(',') + 1)).length;\n }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;MAca,mBAAmB,CAAA;AAC9B,IAAA,IAAI,IAAI,GAAA;AACN,QAAA,OAAO,UAAU,CAAC;KACnB;AAED,IAAA,MAAM,CAAC,KAAa,EAAA;AAClB,QAAA,MAAM,IAAI,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;QAE3B,IAAI,IAAI,KAAK,CAAC;AAAE,YAAA,OAAO,SAAS,CAAC;AACjC,QAAA,IAAI,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC;AAAE,YAAA,OAAO,SAAS,CAAC;QAEzC,MAAM,CAAC,GAAG,IAAI,CAAC;QACf,MAAM,KAAK,GAAG,CAAC,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;QAC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IAAc,CAAC,CAAC;SAC3C;AACD,QAAA,OAAO,KAAK,CAAC;KACd;AAEM,IAAA,QAAQ,CAAC,MAAc,EAAA;QAC5B,MAAM,IAAI,GAAG,4BAA4B,CAAC;AAC1C,QAAA,OAAO,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;KAC1B;AAEM,IAAA,aAAa,CAAC,MAAc,EAAA;AACjC,QAAA,OAAO,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC;KAC/D;8GA/DU,aAAa,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,UAAA,EAAA,CAAA,CAAA,EAAA;AAAb,IAAA,SAAA,IAAA,CAAA,KAAA,GAAA,EAAA,CAAA,qBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,QAAA,EAAA,QAAA,EAAA,EAAA,EAAA,IAAA,EAAA,aAAa,cAFZ,MAAM,EAAA,CAAA,CAAA,EAAA;;2FAEP,aAAa,EAAA,UAAA,EAAA,CAAA;kBAHzB,UAAU;AAAC,YAAA,IAAA,EAAA,CAAA;AACV,oBAAA,UAAU,EAAE,MAAM;AACnB,iBAAA,CAAA;;;ACLD;;AAEG;;;;"}
|
@@ -0,0 +1,181 @@
|
|
1
|
+
import { Subject } from 'rxjs';
|
2
|
+
import { takeUntil, map } from 'rxjs/operators';
|
3
|
+
import { HttpEventType, HttpClient, HttpRequest } from '@angular/common/http';
|
4
|
+
import * as i0 from '@angular/core';
|
5
|
+
import { inject, Injectable } from '@angular/core';
|
6
|
+
|
7
|
+
var AXUploadStatus;
|
8
|
+
(function (AXUploadStatus) {
|
9
|
+
AXUploadStatus["Uploading"] = "Uploading...";
|
10
|
+
AXUploadStatus["UploadComplete"] = "Upload complete";
|
11
|
+
AXUploadStatus["StartingUpload"] = "Starting upload";
|
12
|
+
AXUploadStatus["UploadFailed"] = "Upload failed";
|
13
|
+
})(AXUploadStatus || (AXUploadStatus = {}));
|
14
|
+
var AXDownloadStatus;
|
15
|
+
(function (AXDownloadStatus) {
|
16
|
+
AXDownloadStatus["Downloading"] = "Downloading...";
|
17
|
+
AXDownloadStatus["DownloadComplete"] = "Download complete";
|
18
|
+
AXDownloadStatus["StartingDownload"] = "Starting download";
|
19
|
+
AXDownloadStatus["DownloadFailed"] = "Download failed";
|
20
|
+
})(AXDownloadStatus || (AXDownloadStatus = {}));
|
21
|
+
|
22
|
+
class AXUploadTask {
|
23
|
+
constructor(observable, totalFileSize) {
|
24
|
+
this.observable = observable;
|
25
|
+
this.totalFileSize = totalFileSize;
|
26
|
+
this.cancelSignal = new Subject();
|
27
|
+
}
|
28
|
+
get events() {
|
29
|
+
return this.observable.pipe(takeUntil(this.cancelSignal), map(event => this.handleEvent(event)));
|
30
|
+
}
|
31
|
+
handleEvent(event) {
|
32
|
+
switch (event.type) {
|
33
|
+
case HttpEventType.UploadProgress:
|
34
|
+
{
|
35
|
+
const percentDone = Math.round(100 * event.loaded / (this.totalFileSize || event.total));
|
36
|
+
return {
|
37
|
+
progress: percentDone,
|
38
|
+
bytesTransferred: event.loaded,
|
39
|
+
totalBytes: this.totalFileSize,
|
40
|
+
status: AXUploadStatus.Uploading
|
41
|
+
};
|
42
|
+
}
|
43
|
+
case HttpEventType.Response:
|
44
|
+
return {
|
45
|
+
progress: 100,
|
46
|
+
bytesTransferred: this.totalFileSize,
|
47
|
+
totalBytes: this.totalFileSize,
|
48
|
+
status: AXUploadStatus.UploadComplete,
|
49
|
+
result: event.body
|
50
|
+
};
|
51
|
+
default:
|
52
|
+
return {
|
53
|
+
progress: 0,
|
54
|
+
bytesTransferred: 0,
|
55
|
+
totalBytes: 0,
|
56
|
+
status: AXUploadStatus.StartingUpload
|
57
|
+
};
|
58
|
+
}
|
59
|
+
}
|
60
|
+
cancel() {
|
61
|
+
this.cancelSignal.next();
|
62
|
+
this.cancelSignal.complete();
|
63
|
+
}
|
64
|
+
}
|
65
|
+
|
66
|
+
class AXDownloadTask {
|
67
|
+
constructor(observable) {
|
68
|
+
this.observable = observable;
|
69
|
+
this.cancelSignal = new Subject();
|
70
|
+
}
|
71
|
+
get events() {
|
72
|
+
return this.observable.pipe(takeUntil(this.cancelSignal), map(event => this.handleEvent(event)));
|
73
|
+
}
|
74
|
+
handleEvent(event) {
|
75
|
+
switch (event.type) {
|
76
|
+
case HttpEventType.DownloadProgress:
|
77
|
+
{
|
78
|
+
const percentDone = Math.round(100 * event.loaded / (event.total ?? event.loaded));
|
79
|
+
return {
|
80
|
+
progress: percentDone,
|
81
|
+
bytesReceived: event.loaded,
|
82
|
+
totalBytes: event.total ?? 0,
|
83
|
+
status: AXDownloadStatus.Downloading
|
84
|
+
};
|
85
|
+
}
|
86
|
+
case HttpEventType.Response:
|
87
|
+
return {
|
88
|
+
progress: 100,
|
89
|
+
bytesReceived: event.body.size,
|
90
|
+
totalBytes: event.body.size,
|
91
|
+
status: AXDownloadStatus.DownloadComplete,
|
92
|
+
data: event.body
|
93
|
+
};
|
94
|
+
default:
|
95
|
+
return {
|
96
|
+
progress: 0,
|
97
|
+
bytesReceived: 0,
|
98
|
+
totalBytes: 0,
|
99
|
+
status: AXDownloadStatus.StartingDownload
|
100
|
+
};
|
101
|
+
}
|
102
|
+
}
|
103
|
+
cancel() {
|
104
|
+
this.cancelSignal.next();
|
105
|
+
this.cancelSignal.complete();
|
106
|
+
}
|
107
|
+
}
|
108
|
+
|
109
|
+
class AXNetworkService {
|
110
|
+
constructor() {
|
111
|
+
this.http = inject(HttpClient);
|
112
|
+
}
|
113
|
+
// Unified method handling both types of inputs
|
114
|
+
upload(arg1, arg2) {
|
115
|
+
let request;
|
116
|
+
let totalFilesSize = 0;
|
117
|
+
if (typeof arg1 === 'string' && arg2 instanceof FormData) {
|
118
|
+
// Calculate total file size
|
119
|
+
arg2.forEach((value) => {
|
120
|
+
if (value instanceof File) {
|
121
|
+
totalFilesSize += value.size;
|
122
|
+
}
|
123
|
+
});
|
124
|
+
request = new HttpRequest('POST', arg1, arg2, {
|
125
|
+
reportProgress: true,
|
126
|
+
responseType: 'json'
|
127
|
+
});
|
128
|
+
}
|
129
|
+
else if (arg1 instanceof HttpRequest) {
|
130
|
+
if (arg1.body instanceof FormData) {
|
131
|
+
// Calculate total file size
|
132
|
+
arg1.body.forEach((value) => {
|
133
|
+
if (value instanceof File) {
|
134
|
+
totalFilesSize += value.size;
|
135
|
+
}
|
136
|
+
});
|
137
|
+
}
|
138
|
+
request = arg1.clone({
|
139
|
+
reportProgress: true,
|
140
|
+
responseType: arg1.responseType || 'json'
|
141
|
+
});
|
142
|
+
}
|
143
|
+
else {
|
144
|
+
throw new Error("Invalid arguments for upload method.");
|
145
|
+
}
|
146
|
+
const events = this.http.request(request);
|
147
|
+
return new AXUploadTask(events, totalFilesSize);
|
148
|
+
}
|
149
|
+
// Unified method handling both types of inputs
|
150
|
+
download(arg) {
|
151
|
+
let request;
|
152
|
+
if (typeof arg === 'string') {
|
153
|
+
request = new HttpRequest('GET', arg, {
|
154
|
+
reportProgress: true,
|
155
|
+
responseType: 'blob',
|
156
|
+
});
|
157
|
+
}
|
158
|
+
else {
|
159
|
+
request = new HttpRequest(arg.method, arg.url, arg.body, {
|
160
|
+
...arg,
|
161
|
+
reportProgress: true,
|
162
|
+
responseType: 'blob',
|
163
|
+
});
|
164
|
+
}
|
165
|
+
const events = this.http.request(request);
|
166
|
+
return new AXDownloadTask(events);
|
167
|
+
}
|
168
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.0.2", ngImport: i0, type: AXNetworkService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
169
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.0.2", ngImport: i0, type: AXNetworkService, providedIn: 'root' }); }
|
170
|
+
}
|
171
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.0.2", ngImport: i0, type: AXNetworkService, decorators: [{
|
172
|
+
type: Injectable,
|
173
|
+
args: [{ providedIn: 'root' }]
|
174
|
+
}] });
|
175
|
+
|
176
|
+
/**
|
177
|
+
* Generated bundle index. Do not edit.
|
178
|
+
*/
|
179
|
+
|
180
|
+
export { AXDownloadStatus, AXDownloadTask, AXNetworkService, AXUploadStatus, AXUploadTask };
|
181
|
+
//# sourceMappingURL=acorex-core-network.mjs.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"acorex-core-network.mjs","sources":["../../../../libs/core/network/src/lib/network.types.ts","../../../../libs/core/network/src/lib/upload-task.ts","../../../../libs/core/network/src/lib/download-task.ts","../../../../libs/core/network/src/lib/network.service.ts","../../../../libs/core/network/src/acorex-core-network.ts"],"sourcesContent":["export enum AXUploadStatus {\n Uploading = \"Uploading...\",\n UploadComplete = \"Upload complete\",\n StartingUpload = \"Starting upload\",\n UploadFailed = \"Upload failed\"\n}\n\nexport type AXUploadResponse<T> = {\n progress: number;\n bytesTransferred: number;\n totalBytes: number;\n status: AXUploadStatus;\n result?: T;\n};\n\nexport enum AXDownloadStatus {\n Downloading = \"Downloading...\",\n DownloadComplete = \"Download complete\",\n StartingDownload = \"Starting download\",\n DownloadFailed = \"Download failed\"\n}\n\nexport type AXDownloadResponse = {\n progress: number;\n bytesReceived: number;\n totalBytes: number;\n status: AXDownloadStatus;\n data?: Blob; // or any appropriate type based on your specific use case\n};","import { Observable, Subject } from 'rxjs';\nimport { takeUntil, map } from 'rxjs/operators';\nimport { HttpEvent, HttpEventType } from '@angular/common/http';\nimport { AXUploadResponse, AXUploadStatus } from './network.types'; // Ensure correct import path\n\nexport class AXUploadTask<T> {\n private cancelSignal = new Subject<void>();\n\n constructor(private observable: Observable<HttpEvent<T>>, private totalFileSize: number) { }\n\n get events(): Observable<AXUploadResponse<T>> {\n return this.observable.pipe(\n takeUntil(this.cancelSignal),\n map(event => this.handleEvent(event))\n );\n }\n\n private handleEvent(event: HttpEvent<any>): AXUploadResponse<T> {\n switch (event.type) {\n case HttpEventType.UploadProgress:\n {\n const percentDone = Math.round(100 * event.loaded / (this.totalFileSize || event.total));\n return {\n progress: percentDone,\n bytesTransferred: event.loaded,\n totalBytes: this.totalFileSize,\n status: AXUploadStatus.Uploading\n };\n }\n\n case HttpEventType.Response:\n return {\n progress: 100,\n bytesTransferred: this.totalFileSize,\n totalBytes: this.totalFileSize,\n status: AXUploadStatus.UploadComplete,\n result: event.body\n };\n\n default:\n return {\n progress: 0,\n bytesTransferred: 0,\n totalBytes: 0,\n status: AXUploadStatus.StartingUpload\n };\n }\n }\n\n cancel() {\n this.cancelSignal.next();\n this.cancelSignal.complete();\n }\n}\n","import { Observable, Subject } from 'rxjs';\nimport { takeUntil, map } from 'rxjs/operators';\nimport { HttpEvent, HttpEventType } from '@angular/common/http';\nimport { AXDownloadResponse, AXDownloadStatus } from './network.types'; // Ensure correct import path\n\nexport class AXDownloadTask {\n private cancelSignal = new Subject<void>();\n\n constructor(private observable: Observable<HttpEvent<any>>) { }\n\n get events(): Observable<AXDownloadResponse> {\n return this.observable.pipe(\n takeUntil(this.cancelSignal),\n map(event => this.handleEvent(event)),\n );\n }\n\n private handleEvent(event: HttpEvent<any>): AXDownloadResponse {\n switch (event.type) {\n case HttpEventType.DownloadProgress:\n {\n const percentDone = Math.round(100 * event.loaded / (event.total ?? event.loaded));\n return {\n progress: percentDone,\n bytesReceived: event.loaded,\n totalBytes: event.total ?? 0,\n status: AXDownloadStatus.Downloading\n };\n }\n\n case HttpEventType.Response:\n return {\n progress: 100,\n bytesReceived: event.body.size,\n totalBytes: event.body.size,\n status: AXDownloadStatus.DownloadComplete,\n data: event.body\n };\n\n default:\n return {\n progress: 0,\n bytesReceived: 0,\n totalBytes: 0,\n status: AXDownloadStatus.StartingDownload\n };\n }\n }\n\n cancel() {\n this.cancelSignal.next();\n this.cancelSignal.complete();\n }\n}\n","import { HttpRequest, HttpClient } from '@angular/common/http';\nimport { inject, Injectable } from '@angular/core';\nimport { AXDownloadTask } from './download-task';\nimport { AXUploadTask } from './upload-task';\n\n\n\n@Injectable({ providedIn: 'root' })\nexport class AXNetworkService {\n\n private http = inject(HttpClient);\n\n // Overload signatures\n upload<T>(url: string, formData: FormData): AXUploadTask<T>;\n upload<T>(request: HttpRequest<any>): AXUploadTask<T>;\n\n // Unified method handling both types of inputs\n upload<T>(arg1: string | HttpRequest<any>, arg2?: FormData): AXUploadTask<T> {\n let request: HttpRequest<any>;\n let totalFilesSize = 0;\n\n if (typeof arg1 === 'string' && arg2 instanceof FormData) {\n // Calculate total file size\n arg2.forEach((value) => {\n if (value instanceof File) {\n totalFilesSize += value.size;\n }\n });\n request = new HttpRequest('POST', arg1, arg2, {\n reportProgress: true,\n responseType: 'json'\n });\n } else if (arg1 instanceof HttpRequest) {\n if (arg1.body instanceof FormData) {\n // Calculate total file size\n arg1.body.forEach((value) => {\n if (value instanceof File) {\n totalFilesSize += value.size;\n }\n });\n }\n request = arg1.clone({\n reportProgress: true,\n responseType: arg1.responseType || 'json'\n });\n } else {\n throw new Error(\"Invalid arguments for upload method.\");\n }\n\n const events = this.http.request<T>(request);\n return new AXUploadTask<T>(events, totalFilesSize);\n }\n\n\n\n // Overload signatures\n download(url: string): AXDownloadTask;\n download(request: HttpRequest<Blob>): AXDownloadTask;\n\n // Unified method handling both types of inputs\n download(arg: string | HttpRequest<Blob>): AXDownloadTask {\n let request: HttpRequest<Blob>;\n\n if (typeof arg === 'string') {\n request = new HttpRequest('GET', arg, {\n reportProgress: true,\n responseType: 'blob',\n });\n } else {\n request = new HttpRequest(arg.method, arg.url, arg.body, {\n ...arg,\n reportProgress: true,\n responseType: 'blob',\n });\n }\n\n const events = this.http.request<Blob>(request);\n return new AXDownloadTask(events);\n }\n\n}","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;IAAY,eAKX;AALD,CAAA,UAAY,cAAc,EAAA;AACtB,IAA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,EAAE;AACzB,YAAA,OAAO,GAAG,IAAI,WAAW,CAAC,KAAK,EAAE,GAAG,EAAE;AAClC,gBAAA,cAAc,EAAE,IAAI;AACpB,gBAAA,YAAY,EAAE,MAAM;AACvB,aAAA,CAAC,CAAC;SACN;aAAM;AACH,YAAA,OAAO,GAAG,IAAI,WAAW,CAAC,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,EAAE,GAAG,CAAC,IAAI,EAAE;AACrD,gBAAA,GAAG,GAAG;AACN,gBAAA,cAAc,EAAE,IAAI;AACpB,gBAAA,YAAY,EAAE,MAAM;AACvB,aAAA,CAAC,CAAC;SACN;QAED,MAAM,MAAM,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,CAAO,OAAO,CAAC,CAAC;AAChD,QAAA,OAAO,IAAI,cAAc,CAAC,MAAM,CAAC,CAAC;KACrC;8GAtEQ,gBAAgB,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,UAAA,EAAA,CAAA,CAAA,EAAA;AAAhB,IAAA,SAAA,IAAA,CAAA,KAAA,GAAA,EAAA,CAAA,qBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,QAAA,EAAA,QAAA,EAAA,EAAA,EAAA,IAAA,EAAA,gBAAgB,cADH,MAAM,EAAA,CAAA,CAAA,EAAA;;2FACnB,gBAAgB,EAAA,UAAA,EAAA,CAAA;kBAD5B,UAAU;mBAAC,EAAE,UAAU,EAAE,MAAM,EAAE,CAAA;;;ACPlC;;AAEG;;;;"}
|
package/file/index.d.ts
CHANGED
@@ -1,12 +1,5 @@
|
|
1
|
-
import { HttpClient, HttpRequest } from '@angular/common/http';
|
2
|
-
import { AXFileDownloadRef } from './file-download-ref.class';
|
3
|
-
import { AXFileUploadRef } from './file-upload-ref.class';
|
4
1
|
import * as i0 from "@angular/core";
|
5
2
|
export declare class AXFileService {
|
6
|
-
private _httpClient;
|
7
|
-
constructor(_httpClient: HttpClient);
|
8
|
-
download(request: string | Blob | HttpRequest<any>): AXFileDownloadRef;
|
9
|
-
upload<T = any>(url: string, files: File[]): AXFileUploadRef<T>;
|
10
3
|
choose(options?: {
|
11
4
|
accept?: string;
|
12
5
|
multiple?: boolean;
|
@@ -0,0 +1,11 @@
|
|
1
|
+
import { Observable } from 'rxjs';
|
2
|
+
import { HttpEvent } from '@angular/common/http';
|
3
|
+
import { AXDownloadResponse } from './network.types';
|
4
|
+
export declare class AXDownloadTask {
|
5
|
+
private observable;
|
6
|
+
private cancelSignal;
|
7
|
+
constructor(observable: Observable<HttpEvent<any>>);
|
8
|
+
get events(): Observable<AXDownloadResponse>;
|
9
|
+
private handleEvent;
|
10
|
+
cancel(): void;
|
11
|
+
}
|
@@ -0,0 +1,13 @@
|
|
1
|
+
import { HttpRequest } from '@angular/common/http';
|
2
|
+
import { AXDownloadTask } from './download-task';
|
3
|
+
import { AXUploadTask } from './upload-task';
|
4
|
+
import * as i0 from "@angular/core";
|
5
|
+
export declare class AXNetworkService {
|
6
|
+
private http;
|
7
|
+
upload<T>(url: string, formData: FormData): AXUploadTask<T>;
|
8
|
+
upload<T>(request: HttpRequest<any>): AXUploadTask<T>;
|
9
|
+
download(url: string): AXDownloadTask;
|
10
|
+
download(request: HttpRequest<Blob>): AXDownloadTask;
|
11
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<AXNetworkService, never>;
|
12
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<AXNetworkService>;
|
13
|
+
}
|
@@ -0,0 +1,26 @@
|
|
1
|
+
export declare enum AXUploadStatus {
|
2
|
+
Uploading = "Uploading...",
|
3
|
+
UploadComplete = "Upload complete",
|
4
|
+
StartingUpload = "Starting upload",
|
5
|
+
UploadFailed = "Upload failed"
|
6
|
+
}
|
7
|
+
export type AXUploadResponse<T> = {
|
8
|
+
progress: number;
|
9
|
+
bytesTransferred: number;
|
10
|
+
totalBytes: number;
|
11
|
+
status: AXUploadStatus;
|
12
|
+
result?: T;
|
13
|
+
};
|
14
|
+
export declare enum AXDownloadStatus {
|
15
|
+
Downloading = "Downloading...",
|
16
|
+
DownloadComplete = "Download complete",
|
17
|
+
StartingDownload = "Starting download",
|
18
|
+
DownloadFailed = "Download failed"
|
19
|
+
}
|
20
|
+
export type AXDownloadResponse = {
|
21
|
+
progress: number;
|
22
|
+
bytesReceived: number;
|
23
|
+
totalBytes: number;
|
24
|
+
status: AXDownloadStatus;
|
25
|
+
data?: Blob;
|
26
|
+
};
|
@@ -0,0 +1,12 @@
|
|
1
|
+
import { Observable } from 'rxjs';
|
2
|
+
import { HttpEvent } from '@angular/common/http';
|
3
|
+
import { AXUploadResponse } from './network.types';
|
4
|
+
export declare class AXUploadTask<T> {
|
5
|
+
private observable;
|
6
|
+
private totalFileSize;
|
7
|
+
private cancelSignal;
|
8
|
+
constructor(observable: Observable<HttpEvent<T>>, totalFileSize: number);
|
9
|
+
get events(): Observable<AXUploadResponse<T>>;
|
10
|
+
private handleEvent;
|
11
|
+
cancel(): void;
|
12
|
+
}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@acorex/core",
|
3
|
-
"version": "18.5.
|
3
|
+
"version": "18.5.14",
|
4
4
|
"peerDependencies": {
|
5
5
|
"@angular/common": ">=18.0.0",
|
6
6
|
"@angular/core": ">=18.0.0",
|
@@ -32,11 +32,11 @@
|
|
32
32
|
"esm": "./esm2022/common/acorex-core-common.mjs",
|
33
33
|
"default": "./fesm2022/acorex-core-common.mjs"
|
34
34
|
},
|
35
|
-
"./
|
36
|
-
"types": "./
|
37
|
-
"esm2022": "./esm2022/
|
38
|
-
"esm": "./esm2022/
|
39
|
-
"default": "./fesm2022/acorex-core-
|
35
|
+
"./events": {
|
36
|
+
"types": "./events/index.d.ts",
|
37
|
+
"esm2022": "./esm2022/events/acorex-core-events.mjs",
|
38
|
+
"esm": "./esm2022/events/acorex-core-events.mjs",
|
39
|
+
"default": "./fesm2022/acorex-core-events.mjs"
|
40
40
|
},
|
41
41
|
"./config": {
|
42
42
|
"types": "./config/index.d.ts",
|
@@ -50,18 +50,18 @@
|
|
50
50
|
"esm": "./esm2022/format/acorex-core-format.mjs",
|
51
51
|
"default": "./fesm2022/acorex-core-format.mjs"
|
52
52
|
},
|
53
|
+
"./file": {
|
54
|
+
"types": "./file/index.d.ts",
|
55
|
+
"esm2022": "./esm2022/file/acorex-core-file.mjs",
|
56
|
+
"esm": "./esm2022/file/acorex-core-file.mjs",
|
57
|
+
"default": "./fesm2022/acorex-core-file.mjs"
|
58
|
+
},
|
53
59
|
"./date-time": {
|
54
60
|
"types": "./date-time/index.d.ts",
|
55
61
|
"esm2022": "./esm2022/date-time/acorex-core-date-time.mjs",
|
56
62
|
"esm": "./esm2022/date-time/acorex-core-date-time.mjs",
|
57
63
|
"default": "./fesm2022/acorex-core-date-time.mjs"
|
58
64
|
},
|
59
|
-
"./events": {
|
60
|
-
"types": "./events/index.d.ts",
|
61
|
-
"esm2022": "./esm2022/events/acorex-core-events.mjs",
|
62
|
-
"esm": "./esm2022/events/acorex-core-events.mjs",
|
63
|
-
"default": "./fesm2022/acorex-core-events.mjs"
|
64
|
-
},
|
65
65
|
"./image": {
|
66
66
|
"types": "./image/index.d.ts",
|
67
67
|
"esm2022": "./esm2022/image/acorex-core-image.mjs",
|
@@ -74,6 +74,12 @@
|
|
74
74
|
"esm": "./esm2022/memorize/acorex-core-memorize.mjs",
|
75
75
|
"default": "./fesm2022/acorex-core-memorize.mjs"
|
76
76
|
},
|
77
|
+
"./network": {
|
78
|
+
"types": "./network/index.d.ts",
|
79
|
+
"esm2022": "./esm2022/network/acorex-core-network.mjs",
|
80
|
+
"esm": "./esm2022/network/acorex-core-network.mjs",
|
81
|
+
"default": "./fesm2022/acorex-core-network.mjs"
|
82
|
+
},
|
77
83
|
"./pipes": {
|
78
84
|
"types": "./pipes/index.d.ts",
|
79
85
|
"esm2022": "./esm2022/pipes/acorex-core-pipes.mjs",
|
@@ -1,12 +0,0 @@
|
|
1
|
-
export class AXFileDownloadRef extends Promise {
|
2
|
-
constructor(executor) {
|
3
|
-
super(executor);
|
4
|
-
}
|
5
|
-
//abort the operation
|
6
|
-
abort() {
|
7
|
-
if (this.abortMethod) {
|
8
|
-
this.abortMethod();
|
9
|
-
}
|
10
|
-
}
|
11
|
-
}
|
12
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZmlsZS1kb3dubG9hZC1yZWYuY2xhc3MuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi8uLi8uLi9saWJzL2NvcmUvZmlsZS9zcmMvbGliL2ZpbGUtZG93bmxvYWQtcmVmLmNsYXNzLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUVBLE1BQU0sT0FBTyxpQkFBa0IsU0FBUSxPQUE2QjtJQUVsRSxZQUFZLFFBQWdIO1FBQzFILEtBQUssQ0FBQyxRQUFlLENBQUMsQ0FBQztJQUN6QixDQUFDO0lBQ0QscUJBQXFCO0lBQ2QsS0FBSztRQUNWLElBQUksSUFBSSxDQUFDLFdBQVcsRUFBRSxDQUFDO1lBQ3JCLElBQUksQ0FBQyxXQUFXLEVBQUUsQ0FBQztRQUNyQixDQUFDO0lBQ0gsQ0FBQztDQUNGIiwic291cmNlc0NvbnRlbnQiOlsiaW1wb3J0IHsgQVhGaWxlRG93bmxvYWRSZXN1bHQgfSBmcm9tICcuL2ZpbGUtZG93bmxvYWQtcmVzdWx0LmNsYXNzJztcblxuZXhwb3J0IGNsYXNzIEFYRmlsZURvd25sb2FkUmVmIGV4dGVuZHMgUHJvbWlzZTxBWEZpbGVEb3dubG9hZFJlc3VsdD4ge1xuICBwdWJsaWMgYWJvcnRNZXRob2Q6ICgpID0+IHZvaWQ7XG4gIGNvbnN0cnVjdG9yKGV4ZWN1dG9yOiAocmVzb2x2ZTogKHZhbHVlPzogUHJvbWlzZUxpa2U8QVhGaWxlRG93bmxvYWRSZXN1bHQ+KSA9PiB2b2lkLCByZWplY3Q6IChyZWFzb24/OiBhbnkpID0+IHZvaWQpID0+IHZvaWQpIHtcbiAgICBzdXBlcihleGVjdXRvciBhcyBhbnkpO1xuICB9XG4gIC8vYWJvcnQgdGhlIG9wZXJhdGlvblxuICBwdWJsaWMgYWJvcnQoKSB7XG4gICAgaWYgKHRoaXMuYWJvcnRNZXRob2QpIHtcbiAgICAgIHRoaXMuYWJvcnRNZXRob2QoKTtcbiAgICB9XG4gIH1cbn1cbiJdfQ==
|
@@ -1,45 +0,0 @@
|
|
1
|
-
export class AXFileDownloadResult {
|
2
|
-
constructor(response) {
|
3
|
-
this._response = response;
|
4
|
-
}
|
5
|
-
save(filename) {
|
6
|
-
this._defaultBrowserDownload(filename);
|
7
|
-
return Promise.resolve();
|
8
|
-
// else {
|
9
|
-
// return new Promise((resolve, reject) => {
|
10
|
-
// const button = document.createElement("button");
|
11
|
-
// button.addEventListener('click', async () => {
|
12
|
-
// button.remove();
|
13
|
-
// const opts = {
|
14
|
-
// types: [{
|
15
|
-
// description: 'Save File',
|
16
|
-
// suggestedName: filename
|
17
|
-
// // accept: {'text/plain': ['.txt']},
|
18
|
-
// }],
|
19
|
-
// };
|
20
|
-
// const result = await window['showSaveFilePicker'](opts);
|
21
|
-
// resolve();
|
22
|
-
// });
|
23
|
-
// button.click();
|
24
|
-
// });
|
25
|
-
// }
|
26
|
-
}
|
27
|
-
blob() {
|
28
|
-
return this._response;
|
29
|
-
}
|
30
|
-
base64() {
|
31
|
-
return new Promise((resolve, reject) => {
|
32
|
-
const reader = new window.FileReader();
|
33
|
-
reader.onloadend = () => resolve(reader.result);
|
34
|
-
reader.onerror = (e) => reject(e);
|
35
|
-
reader.readAsDataURL(this._response);
|
36
|
-
});
|
37
|
-
}
|
38
|
-
_defaultBrowserDownload(filename = 'download') {
|
39
|
-
const link = document.createElement('a');
|
40
|
-
link.href = URL.createObjectURL(this._response);
|
41
|
-
link.download = filename;
|
42
|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zZSB7XG4gICAgLy8gcmV0dXJuIG5ldyBQcm9taXNlKChyZXNvbHZlLCByZWplY3QpID0+IHtcbiAgICAvLyAgICAgY29uc3QgYnV0dG9uID0gZG9jdW1lbnQuY3JlYXRlRWxlbWVudChcImJ1dHRvblwiKTtcbiAgICAvLyAgICAgYnV0dG9uLmFkZEV2ZW50TGlzdGVuZXIoJ2NsaWNrJywgYXN5bmMgKCkgPT4ge1xuICAgIC8vICAgICAgICAgYnV0dG9uLnJlbW92ZSgpO1xuICAgIC8vICAgICAgICAgY29uc3Qgb3B0cyA9IHtcbiAgICAvLyAgICAgICAgICAgICB0eXBlczogW3tcbiAgICAvLyAgICAgICAgICAgICAgICAgZGVzY3JpcHRpb246ICdTYXZlIEZpbGUnLFxuICAgIC8vICAgICAgICAgICAgICAgICBzdWdnZXN0ZWROYW1lOiBmaWxlbmFtZVxuICAgIC8vICAgICAgICAgICAgICAgICAvLyAgIGFjY2VwdDogeyd0ZXh0L3BsYWluJzogWycudHh0J119LFxuICAgIC8vICAgICAgICAgICAgIH1dLFxuICAgIC8vICAgICAgICAgfTtcbiAgICAvLyAgICAgICAgIGNvbnN0IHJlc3VsdCA9IGF3YWl0IHdpbmRvd1snc2hvd1NhdmVGaWxlUGlja2VyJ10ob3B0cyk7XG5cbiAgICAvLyAgICAgICAgIHJlc29sdmUoKTtcbiAgICAvLyAgICAgfSk7XG4gICAgLy8gICAgIGJ1dHRvbi5jbGljaygpO1xuICAgIC8vIH0pO1xuXG4gICAgLy8gfVxuICB9XG5cbiAgYmxvYigpIHtcbiAgICByZXR1cm4gdGhpcy5fcmVzcG9uc2U7XG4gIH1cblxuICBiYXNlNjQoKTogUHJvbWlzZTxzdHJpbmc+IHtcbiAgICByZXR1cm4gbmV3IFByb21pc2UoKHJlc29sdmUsIHJlamVjdCkgPT4ge1xuICAgICAgY29uc3QgcmVhZGVyID0gbmV3IHdpbmRvdy5GaWxlUmVhZGVyKCk7XG4gICAgICByZWFkZXIub25sb2FkZW5kID0gKCkgPT4gcmVzb2x2ZShyZWFkZXIucmVzdWx0IGFzIHN0cmluZyk7XG4gICAgICByZWFkZXIub25lcnJvciA9IChlKSA9PiByZWplY3QoZSk7XG4gICAgICByZWFkZXIucmVhZEFzRGF0YVVSTCh0aGlzLl9yZXNwb25zZSk7XG4gICAgfSk7XG4gIH1cblxuICBwcml2YXRlIF9kZWZhdWx0QnJvd3NlckRvd25sb2FkKGZpbGVuYW1lID0gJ2Rvd25sb2FkJykge1xuICAgIGNvbnN0IGxpbmsgPSBkb2N1bWVudC5jcmVhdGVFbGVtZW50KCdhJyk7XG4gICAgbGluay5ocmVmID0gVVJMLmNyZWF0ZU9iamVjdFVSTCh0aGlzLl9yZXNwb25zZSk7XG4gICAgbGluay5kb3dubG9hZCA9IGZpbGVuYW1lO1xuICAgIGxpbmsuY2xpY2soKTtcbiAgfVxufVxuIl19
|
@@ -1,12 +0,0 @@
|
|
1
|
-
export class AXFileUploadRef extends Promise {
|
2
|
-
constructor(executor) {
|
3
|
-
super(executor);
|
4
|
-
}
|
5
|
-
//abort the operation
|
6
|
-
abort() {
|
7
|
-
if (this.abortMethod) {
|
8
|
-
this.abortMethod();
|
9
|
-
}
|
10
|
-
}
|
11
|
-
}
|
12
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZmlsZS11cGxvYWQtcmVmLmNsYXNzLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vLi4vLi4vLi4vbGlicy9jb3JlL2ZpbGUvc3JjL2xpYi9maWxlLXVwbG9hZC1yZWYuY2xhc3MudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsTUFBTSxPQUFPLGVBQXlCLFNBQVEsT0FBVTtJQUV0RCxZQUFZLFFBQTZGO1FBQ3ZHLEtBQUssQ0FBQyxRQUFlLENBQUMsQ0FBQztJQUN6QixDQUFDO0lBQ0QscUJBQXFCO0lBQ2QsS0FBSztRQUNWLElBQUksSUFBSSxDQUFDLFdBQVcsRUFBRSxDQUFDO1lBQ3JCLElBQUksQ0FBQyxXQUFXLEVBQUUsQ0FBQztRQUNyQixDQUFDO0lBQ0gsQ0FBQztDQUNGIiwic291cmNlc0NvbnRlbnQiOlsiZXhwb3J0IGNsYXNzIEFYRmlsZVVwbG9hZFJlZjxUID0gYW55PiBleHRlbmRzIFByb21pc2U8VD4ge1xuICBwdWJsaWMgYWJvcnRNZXRob2Q6ICgpID0+IHZvaWQ7XG4gIGNvbnN0cnVjdG9yKGV4ZWN1dG9yOiAocmVzb2x2ZTogKHZhbHVlPzogUHJvbWlzZUxpa2U8VD4pID0+IHZvaWQsIHJlamVjdDogKHJlYXNvbj86IGFueSkgPT4gdm9pZCkgPT4gdm9pZCkge1xuICAgIHN1cGVyKGV4ZWN1dG9yIGFzIGFueSk7XG4gIH1cbiAgLy9hYm9ydCB0aGUgb3BlcmF0aW9uXG4gIHB1YmxpYyBhYm9ydCgpIHtcbiAgICBpZiAodGhpcy5hYm9ydE1ldGhvZCkge1xuICAgICAgdGhpcy5hYm9ydE1ldGhvZCgpO1xuICAgIH1cbiAgfVxufVxuIl19
|
@@ -1,6 +0,0 @@
|
|
1
|
-
import { AXFileDownloadResult } from './file-download-result.class';
|
2
|
-
export declare class AXFileDownloadRef extends Promise<AXFileDownloadResult> {
|
3
|
-
abortMethod: () => void;
|
4
|
-
constructor(executor: (resolve: (value?: PromiseLike<AXFileDownloadResult>) => void, reject: (reason?: any) => void) => void);
|
5
|
-
abort(): void;
|
6
|
-
}
|