@acorex/core 18.5.13 → 18.5.15

Sign up to get free protection for your applications and to get access to all the features.
@@ -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,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZG93bmxvYWQtdGFzay5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uLy4uLy4uL2xpYnMvY29yZS9uZXR3b3JrL3NyYy9saWIvZG93bmxvYWQtdGFzay50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEVBQWMsT0FBTyxFQUFFLE1BQU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8/IDAsXG4gICAgICAgICAgICAgICAgICAgICAgICBzdGF0dXM6IEFYRG93bmxvYWRTdGF0dXMuRG93bmxvYWRpbmdcbiAgICAgICAgICAgICAgICAgICAgfTtcbiAgICAgICAgICAgICAgICB9XG5cbiAgICAgICAgICAgIGNhc2UgSHR0cEV2ZW50VHlwZS5SZXNwb25zZTpcbiAgICAgICAgICAgICAgICByZXR1cm4ge1xuICAgICAgICAgICAgICAgICAgICBwcm9ncmVzczogMTAwLFxuICAgICAgICAgICAgICAgICAgICBieXRlc1JlY2VpdmVkOiBldmVudC5ib2R5LnNpemUsXG4gICAgICAgICAgICAgICAgICAgIHRvdGFsQnl0ZXM6IGV2ZW50LmJvZHkuc2l6ZSxcbiAgICAgICAgICAgICAgICAgICAgc3RhdHVzOiBBWERvd25sb2FkU3RhdHVzLkRvd25sb2FkQ29tcGxldGUsXG4gICAgICAgICAgICAgICAgICAgIGRhdGE6IGV2ZW50LmJvZHlcbiAgICAgICAgICAgICAgICB9O1xuXG4gICAgICAgICAgICBkZWZhdWx0OlxuICAgICAgICAgICAgICAgIHJldHVybiB7XG4gICAgICAgICAgICAgICAgICAgIHByb2dyZXNzOiAwLFxuICAgICAgICAgICAgICAgICAgICBieXRlc1JlY2VpdmVkOiAwLFxuICAgICAgICAgICAgICAgICAgICB0b3RhbEJ5dGVzOiAwLFxuICAgICAgICAgICAgICAgICAgICBzdGF0dXM6IEFYRG93bmxvYWRTdGF0dXMuU3RhcnRpbmdEb3dubG9hZFxuICAgICAgICAgICAgICAgIH07XG4gICAgICAgIH1cbiAgICB9XG5cbiAgICBjYW5jZWwoKSB7XG4gICAgICAgIHRoaXMuY2FuY2VsU2lnbmFsLm5leHQoKTtcbiAgICAgICAgdGhpcy5jYW5jZWxTaWduYWwuY29tcGxldGUoKTtcbiAgICB9XG59XG4iXX0=
@@ -0,0 +1,84 @@
1
+ import { HttpRequest, HttpClient } from '@angular/common/http';
2
+ import { inject, Injectable, signal } from '@angular/core';
3
+ import { AXDownloadTask } from './download-task';
4
+ import { AXUploadTask } from './upload-task';
5
+ import { fromEvent, map, merge, startWith } from 'rxjs';
6
+ import { isBrowser } from '@acorex/core/platform';
7
+ import * as i0 from "@angular/core";
8
+ export class AXNetworkService {
9
+ constructor() {
10
+ this.http = inject(HttpClient);
11
+ this._status = signal(true);
12
+ this.status = this._status.asReadonly();
13
+ if (isBrowser()) {
14
+ // Only subscribe to these events if on the browser platform
15
+ const onlineEvent = fromEvent(window, 'online').pipe(map(() => true));
16
+ const offlineEvent = fromEvent(window, 'offline').pipe(map(() => false));
17
+ merge(onlineEvent, offlineEvent).pipe(startWith(navigator.onLine)).subscribe(c => {
18
+ this._status.set(c);
19
+ });
20
+ }
21
+ }
22
+ // Unified method handling both types of inputs
23
+ upload(arg1, arg2) {
24
+ let request;
25
+ let totalFilesSize = 0;
26
+ if (typeof arg1 === 'string' && arg2 instanceof FormData) {
27
+ // Calculate total file size
28
+ arg2.forEach((value) => {
29
+ if (value instanceof File) {
30
+ totalFilesSize += value.size;
31
+ }
32
+ });
33
+ request = new HttpRequest('POST', arg1, arg2, {
34
+ reportProgress: true,
35
+ responseType: 'json'
36
+ });
37
+ }
38
+ else if (arg1 instanceof HttpRequest) {
39
+ if (arg1.body instanceof FormData) {
40
+ // Calculate total file size
41
+ arg1.body.forEach((value) => {
42
+ if (value instanceof File) {
43
+ totalFilesSize += value.size;
44
+ }
45
+ });
46
+ }
47
+ request = arg1.clone({
48
+ reportProgress: true,
49
+ responseType: arg1.responseType || 'json'
50
+ });
51
+ }
52
+ else {
53
+ throw new Error("Invalid arguments for upload method.");
54
+ }
55
+ const events = this.http.request(request);
56
+ return new AXUploadTask(events, totalFilesSize);
57
+ }
58
+ // Unified method handling both types of inputs
59
+ download(arg) {
60
+ let request;
61
+ if (typeof arg === 'string') {
62
+ request = new HttpRequest('GET', arg, {
63
+ reportProgress: true,
64
+ responseType: 'blob',
65
+ });
66
+ }
67
+ else {
68
+ request = new HttpRequest(arg.method, arg.url, arg.body, {
69
+ ...arg,
70
+ reportProgress: true,
71
+ responseType: 'blob',
72
+ });
73
+ }
74
+ const events = this.http.request(request);
75
+ return new AXDownloadTask(events);
76
+ }
77
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.0.2", ngImport: i0, type: AXNetworkService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
78
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.0.2", ngImport: i0, type: AXNetworkService, providedIn: 'root' }); }
79
+ }
80
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.0.2", ngImport: i0, type: AXNetworkService, decorators: [{
81
+ type: Injectable,
82
+ args: [{ providedIn: 'root' }]
83
+ }], ctorParameters: () => [] });
84
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibmV0d29yay5zZXJ2aWNlLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vLi4vLi4vLi4vbGlicy9jb3JlL25ldHdvcmsvc3JjL2xpYi9uZXR3b3JrLnNlcnZpY2UudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxFQUFFLFdBQVcsRUFBRSxVQUFVLEVBQUUsTUFBTSxzQkFBc0IsQ0FBQztBQUMvRCxPQUFPLEVBQUUsTUFBTSxFQUFFLFVBQVUsRUFBRSxNQUFNLEVBQUUsTUFBTSxlQUFlLENBQUM7QUFDM0QsT0FBTyxFQUFFLGNBQWMsRUFBRSxNQUFNLGlCQUFpQixDQUFDO0FBQ2pELE9BQU8sRUFBRSxZQUFZLEVBQUUsTUFBTSxlQUFlLENBQUM7QUFDN0MsT0FBTyxFQUFFLFNBQVMsRUFBRSxHQUFHLEVBQUUsS0FBSyxFQUFFLFNBQVMsRUFBRSxNQUFNLE1BQU0sQ0FBQztBQUN4RCxPQUFPLEVBQUUsU0FBUyxFQUFFLE1BQ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ICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH0pO1xuICAgICAgICAgICAgcmVxdWVzdCA9IG5ldyBIdHRwUmVxdWVzdCgnUE9TVCcsIGFyZzEsIGFyZzIsIHtcbiAgICAgICAgICAgICAgICByZXBvcnRQcm9ncmVzczogdHJ1ZSxcbiAgICAgICAgICAgICAgICByZXNwb25zZVR5cGU6ICdqc29uJ1xuICAgICAgICAgICAgfSk7XG4gICAgICAgIH0gZWxzZSBpZiAoYXJnMSBpbnN0YW5jZW9mIEh0dHBSZXF1ZXN0KSB7XG4gICAgICAgICAgICBpZiAoYXJnMS5ib2R5IGluc3RhbmNlb2YgRm9ybURhdGEpIHtcbiAgICAgICAgICAgICAgICAvLyBDYWxjdWxhdGUgdG90YWwgZmlsZSBzaXplXG4gICAgICAgICAgICAgICAgYXJnMS5ib2R5LmZvckVhY2goKHZhbHVlKSA9PiB7XG4gICAgICAgICAgICAgICAgICAgIGlmICh2YWx1ZSBpbnN0YW5jZW9mIEZpbGUpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIHRvdGFsRmlsZXNTaXplICs9IHZhbHVlLnNpemU7XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICB9KTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIHJlcXVlc3QgPSBhcmcxLmNsb25lKHtcbiAgICAgICAgICAgICAgICByZXBvcnRQcm9ncmVzczogdHJ1ZSxcbiAgICAgICAgICAgICAgICByZXNwb25zZVR5cGU6IGFyZzEucmVzcG9uc2VUeXBlIHx8ICdqc29uJ1xuICAgICAgICAgICAgfSk7XG4gICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICB0aHJvdyBuZXcgRXJyb3IoXCJJbnZhbGlkIGFyZ3VtZW50cyBmb3IgdXBsb2FkIG1ldGhvZC5cIik7XG4gICAgICAgIH1cblxuICAgICAgICBjb25zdCBldmVudHMgPSB0aGlzLmh0dHAucmVxdWVzdDxUPihyZXF1ZXN0KTt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ZXN0KTtcbiAgICAgICAgcmV0dXJuIG5ldyBBWERvd25sb2FkVGFzayhldmVudHMpO1xuICAgIH1cblxufSJdfQ==
@@ -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,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibmV0d29yay50eXBlcy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uLy4uLy4uL2xpYnMvY29yZS9uZXR3b3JrL3NyYy9saWIvbmV0d29yay50eXBlcy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxNQUFNLENBQU4sSUFBWSxjQUtYO0FBTEQsV0FBWSxjQUFjO0lBQ3RCLDRDQUEwQixDQUFBO0lBQzFCLG9EQUFrQyxDQUFBO0lBQ2xDLG9EQUFrQyxDQUFBO0lBQ2xDLGdEQUE4QixDQUFBO0FBQ2xDLENBQUMsRUFMVyxjQUFjLEtBQWQsY0FBYyxRQUt6QjtBQVVELE1BQU0sQ0FBTixJQUFZLGdCQUtYO0FBTEQsV0FBWSxnQkFBZ0I7SUFDeEIsa0RBQThCLENBQUE7SUFDOUIsMERBQXNDLENBQUE7SUFDdEMsMERBQXNDLENBQUE7SUFDdEMsc0RBQWtDLENBQ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Byb3ByaWF0ZSB0eXBlIGJhc2VkIG9uIHlvdXIgc3BlY2lmaWMgdXNlIGNhc2Vcbn07XG4iXX0=
@@ -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.cancelSignal.complete();
46
+ }
47
+ }
48
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidXBsb2FkLXRhc2suanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi8uLi8uLi9saWJzL2NvcmUvbmV0d29yay9zcmMvbGliL3VwbG9hZC10YXNrLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sRUFBYyx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hZGVkLFxuICAgICAgICAgICAgICAgICAgICAgICAgdG90YWxCeXRlczogdGhpcy50b3RhbEZpbGVTaXplLFxuICAgICAgICAgICAgICAgICAgICAgICAgc3RhdHVzOiBBWFVwbG9hZFN0YXR1cy5VcGxvYWRpbmdcbiAgICAgICAgICAgICAgICAgICAgfTtcbiAgICAgICAgICAgICAgICB9XG5cbiAgICAgICAgICAgIGNhc2UgSHR0cEV2ZW50VHlwZS5SZXNwb25zZTpcbiAgICAgICAgICAgICAgICByZXR1cm4ge1xuICAgICAgICAgICAgICAgICAgICBwcm9ncmVzczogMTAwLFxuICAgICAgICAgICAgICAgICAgICBieXRlc1RyYW5zZmVycmVkOiB0aGlzLnRvdGFsRmlsZVNpemUsXG4gICAgICAgICAgICAgICAgICAgIHRvdGFsQnl0ZXM6IHRoaXMudG90YWxGaWxlU2l6ZSxcbiAgICAgICAgICAgICAgICAgICAgc3RhdHVzOiBBWFVwbG9hZFN0YXR1cy5VcGxvYWRDb21wbGV0ZSxcbiAgICAgICAgICAgICAgICAgICAgcmVzdWx0OiBldmVudC5ib2R5XG4gICAgICAgICAgICAgICAgfTtcblxuICAgICAgICAgICAgZGVmYXVsdDpcbiAgICAgICAgICAgICAgICByZXR1cm4ge1xuICAgICAgICAgICAgICAgICAgICBwcm9ncmVzczogMCxcbiAgICAgICAgICAgICAgICAgICAgYnl0ZXNUcmFuc2ZlcnJlZDogMCxcbiAgICAgICAgICAgICAgICAgICAgdG90YWxCeXRlczogMCxcbiAgICAgICAgICAgICAgICAgICAgc3RhdHVzOiBBWFVwbG9hZFN0YXR1cy5TdGFydGluZ1VwbG9hZFxuICAgICAgICAgICAgICAgIH07XG4gICAgICAgIH1cbiAgICB9XG5cbiAgICBjYW5jZWwoKSB7XG4gICAgICAgIHRoaXMuY2FuY2VsU2lnbmFsLm5leHQoKTtcbiAgICAgICAgdGhpcy5jYW5jZWxTaWduYWwuY29tcGxldGUoKTtcbiAgICB9XG59XG4iXX0=
@@ -0,0 +1,192 @@
1
+ import { Subject, fromEvent, map as map$1, merge, startWith } 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, signal, Injectable } from '@angular/core';
6
+ import { isBrowser } from '@acorex/core/platform';
7
+
8
+ var AXUploadStatus;
9
+ (function (AXUploadStatus) {
10
+ AXUploadStatus["Uploading"] = "Uploading...";
11
+ AXUploadStatus["UploadComplete"] = "Upload complete";
12
+ AXUploadStatus["StartingUpload"] = "Starting upload";
13
+ AXUploadStatus["UploadFailed"] = "Upload failed";
14
+ })(AXUploadStatus || (AXUploadStatus = {}));
15
+ var AXDownloadStatus;
16
+ (function (AXDownloadStatus) {
17
+ AXDownloadStatus["Downloading"] = "Downloading...";
18
+ AXDownloadStatus["DownloadComplete"] = "Download complete";
19
+ AXDownloadStatus["StartingDownload"] = "Starting download";
20
+ AXDownloadStatus["DownloadFailed"] = "Download failed";
21
+ })(AXDownloadStatus || (AXDownloadStatus = {}));
22
+
23
+ class AXUploadTask {
24
+ constructor(observable, totalFileSize) {
25
+ this.observable = observable;
26
+ this.totalFileSize = totalFileSize;
27
+ this.cancelSignal = new Subject();
28
+ }
29
+ get events() {
30
+ return this.observable.pipe(takeUntil(this.cancelSignal), map(event => this.handleEvent(event)));
31
+ }
32
+ handleEvent(event) {
33
+ switch (event.type) {
34
+ case HttpEventType.UploadProgress:
35
+ {
36
+ const percentDone = Math.round(100 * event.loaded / (this.totalFileSize || event.total));
37
+ return {
38
+ progress: percentDone,
39
+ bytesTransferred: event.loaded,
40
+ totalBytes: this.totalFileSize,
41
+ status: AXUploadStatus.Uploading
42
+ };
43
+ }
44
+ case HttpEventType.Response:
45
+ return {
46
+ progress: 100,
47
+ bytesTransferred: this.totalFileSize,
48
+ totalBytes: this.totalFileSize,
49
+ status: AXUploadStatus.UploadComplete,
50
+ result: event.body
51
+ };
52
+ default:
53
+ return {
54
+ progress: 0,
55
+ bytesTransferred: 0,
56
+ totalBytes: 0,
57
+ status: AXUploadStatus.StartingUpload
58
+ };
59
+ }
60
+ }
61
+ cancel() {
62
+ this.cancelSignal.next();
63
+ this.cancelSignal.complete();
64
+ }
65
+ }
66
+
67
+ class AXDownloadTask {
68
+ constructor(observable) {
69
+ this.observable = observable;
70
+ this.cancelSignal = new Subject();
71
+ }
72
+ get events() {
73
+ return this.observable.pipe(takeUntil(this.cancelSignal), map(event => this.handleEvent(event)));
74
+ }
75
+ handleEvent(event) {
76
+ switch (event.type) {
77
+ case HttpEventType.DownloadProgress:
78
+ {
79
+ const percentDone = Math.round(100 * event.loaded / (event.total ?? event.loaded));
80
+ return {
81
+ progress: percentDone,
82
+ bytesReceived: event.loaded,
83
+ totalBytes: event.total ?? 0,
84
+ status: AXDownloadStatus.Downloading
85
+ };
86
+ }
87
+ case HttpEventType.Response:
88
+ return {
89
+ progress: 100,
90
+ bytesReceived: event.body.size,
91
+ totalBytes: event.body.size,
92
+ status: AXDownloadStatus.DownloadComplete,
93
+ data: event.body
94
+ };
95
+ default:
96
+ return {
97
+ progress: 0,
98
+ bytesReceived: 0,
99
+ totalBytes: 0,
100
+ status: AXDownloadStatus.StartingDownload
101
+ };
102
+ }
103
+ }
104
+ cancel() {
105
+ this.cancelSignal.next();
106
+ this.cancelSignal.complete();
107
+ }
108
+ }
109
+
110
+ class AXNetworkService {
111
+ constructor() {
112
+ this.http = inject(HttpClient);
113
+ this._status = signal(true);
114
+ this.status = this._status.asReadonly();
115
+ if (isBrowser()) {
116
+ // Only subscribe to these events if on the browser platform
117
+ const onlineEvent = fromEvent(window, 'online').pipe(map$1(() => true));
118
+ const offlineEvent = fromEvent(window, 'offline').pipe(map$1(() => false));
119
+ merge(onlineEvent, offlineEvent).pipe(startWith(navigator.onLine)).subscribe(c => {
120
+ this._status.set(c);
121
+ });
122
+ }
123
+ }
124
+ // Unified method handling both types of inputs
125
+ upload(arg1, arg2) {
126
+ let request;
127
+ let totalFilesSize = 0;
128
+ if (typeof arg1 === 'string' && arg2 instanceof FormData) {
129
+ // Calculate total file size
130
+ arg2.forEach((value) => {
131
+ if (value instanceof File) {
132
+ totalFilesSize += value.size;
133
+ }
134
+ });
135
+ request = new HttpRequest('POST', arg1, arg2, {
136
+ reportProgress: true,
137
+ responseType: 'json'
138
+ });
139
+ }
140
+ else if (arg1 instanceof HttpRequest) {
141
+ if (arg1.body instanceof FormData) {
142
+ // Calculate total file size
143
+ arg1.body.forEach((value) => {
144
+ if (value instanceof File) {
145
+ totalFilesSize += value.size;
146
+ }
147
+ });
148
+ }
149
+ request = arg1.clone({
150
+ reportProgress: true,
151
+ responseType: arg1.responseType || 'json'
152
+ });
153
+ }
154
+ else {
155
+ throw new Error("Invalid arguments for upload method.");
156
+ }
157
+ const events = this.http.request(request);
158
+ return new AXUploadTask(events, totalFilesSize);
159
+ }
160
+ // Unified method handling both types of inputs
161
+ download(arg) {
162
+ let request;
163
+ if (typeof arg === 'string') {
164
+ request = new HttpRequest('GET', arg, {
165
+ reportProgress: true,
166
+ responseType: 'blob',
167
+ });
168
+ }
169
+ else {
170
+ request = new HttpRequest(arg.method, arg.url, arg.body, {
171
+ ...arg,
172
+ reportProgress: true,
173
+ responseType: 'blob',
174
+ });
175
+ }
176
+ const events = this.http.request(request);
177
+ return new AXDownloadTask(events);
178
+ }
179
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.0.2", ngImport: i0, type: AXNetworkService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
180
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.0.2", ngImport: i0, type: AXNetworkService, providedIn: 'root' }); }
181
+ }
182
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.0.2", ngImport: i0, type: AXNetworkService, decorators: [{
183
+ type: Injectable,
184
+ args: [{ providedIn: 'root' }]
185
+ }], ctorParameters: () => [] });
186
+
187
+ /**
188
+ * Generated bundle index. Do not edit.
189
+ */
190
+
191
+ export { AXDownloadStatus, AXDownloadTask, AXNetworkService, AXUploadStatus, AXUploadTask };
192
+ //# 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};\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, signal } from '@angular/core';\nimport { AXDownloadTask } from './download-task';\nimport { AXUploadTask } from './upload-task';\nimport { fromEvent, map, merge, startWith } from 'rxjs';\nimport { isBrowser } from '@acorex/core/platform';\n\n\n\n@Injectable({ providedIn: 'root' })\nexport class AXNetworkService {\n\n private http = inject(HttpClient);\n\n private _status = signal<boolean>(true);\n\n public readonly status = this._status.asReadonly();\n\n constructor() {\n if (isBrowser()) {\n // Only subscribe to these events if on the browser platform\n const onlineEvent = fromEvent(window, 'online').pipe(map(() => true));\n const offlineEvent = fromEvent(window, 'offline').pipe(map(() => false));\n\n merge(onlineEvent, offlineEvent).pipe(\n startWith(navigator.onLine)\n ).subscribe(c => {\n this._status.set(c);\n });\n }\n }\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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AAI,CAAC,OAAO,CAAO,OAAO,CAAC,CAAC;AAChD,QAAA,OAAO,IAAI,cAAc,CAAC,MAAM,CAAC,CAAC;KACrC;8GAxFQ,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;;;ACTlC;;AAEG;;;;"}
@@ -0,0 +1,3 @@
1
+ # @acorex/core/network
2
+
3
+ Secondary entry point of `@acorex/core`. It can be used by importing from `@acorex/core/network`.
@@ -0,0 +1,4 @@
1
+ export * from './lib/upload-task';
2
+ export * from './lib/download-task';
3
+ export * from './lib/network.types';
4
+ export * from './lib/network.service';
@@ -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,16 @@
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
+ private _status;
8
+ readonly status: import("@angular/core").Signal<boolean>;
9
+ constructor();
10
+ upload<T>(url: string, formData: FormData): AXUploadTask<T>;
11
+ upload<T>(request: HttpRequest<any>): AXUploadTask<T>;
12
+ download(url: string): AXDownloadTask;
13
+ download(request: HttpRequest<Blob>): AXDownloadTask;
14
+ static ɵfac: i0.ɵɵFactoryDeclaration<AXNetworkService, never>;
15
+ static ɵprov: i0.ɵɵInjectableDeclaration<AXNetworkService>;
16
+ }
@@ -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.13",
3
+ "version": "18.5.15",
4
4
  "peerDependencies": {
5
5
  "@angular/common": ">=18.0.0",
6
6
  "@angular/core": ">=18.0.0",
@@ -38,30 +38,30 @@
38
38
  "esm": "./esm2022/file/acorex-core-file.mjs",
39
39
  "default": "./fesm2022/acorex-core-file.mjs"
40
40
  },
41
- "./format": {
42
- "types": "./format/index.d.ts",
43
- "esm2022": "./esm2022/format/acorex-core-format.mjs",
44
- "esm": "./esm2022/format/acorex-core-format.mjs",
45
- "default": "./fesm2022/acorex-core-format.mjs"
46
- },
47
41
  "./events": {
48
42
  "types": "./events/index.d.ts",
49
43
  "esm2022": "./esm2022/events/acorex-core-events.mjs",
50
44
  "esm": "./esm2022/events/acorex-core-events.mjs",
51
45
  "default": "./fesm2022/acorex-core-events.mjs"
52
46
  },
53
- "./date-time": {
54
- "types": "./date-time/index.d.ts",
55
- "esm2022": "./esm2022/date-time/acorex-core-date-time.mjs",
56
- "esm": "./esm2022/date-time/acorex-core-date-time.mjs",
57
- "default": "./fesm2022/acorex-core-date-time.mjs"
58
- },
59
47
  "./config": {
60
48
  "types": "./config/index.d.ts",
61
49
  "esm2022": "./esm2022/config/acorex-core-config.mjs",
62
50
  "esm": "./esm2022/config/acorex-core-config.mjs",
63
51
  "default": "./fesm2022/acorex-core-config.mjs"
64
52
  },
53
+ "./format": {
54
+ "types": "./format/index.d.ts",
55
+ "esm2022": "./esm2022/format/acorex-core-format.mjs",
56
+ "esm": "./esm2022/format/acorex-core-format.mjs",
57
+ "default": "./fesm2022/acorex-core-format.mjs"
58
+ },
59
+ "./date-time": {
60
+ "types": "./date-time/index.d.ts",
61
+ "esm2022": "./esm2022/date-time/acorex-core-date-time.mjs",
62
+ "esm": "./esm2022/date-time/acorex-core-date-time.mjs",
63
+ "default": "./fesm2022/acorex-core-date-time.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",