@acorex/core 7.1.0 → 7.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/config/index.d.ts +5 -5
- package/config/public-api.d.ts +1 -1
- package/config/src/configs.d.ts +9 -9
- package/dateTime/index.d.ts +5 -5
- package/dateTime/public-api.d.ts +5 -5
- package/dateTime/src/datetime.class.d.ts +100 -100
- package/dateTime/src/datetime.module.d.ts +8 -8
- package/dateTime/src/datetime.pipe.d.ts +8 -8
- package/dateTime/src/georgian.calendar.d.ts +20 -20
- package/dateTime/src/jalali.calendar.d.ts +35 -35
- package/esm2022/acorex-core.mjs +4 -4
- package/esm2022/config/acorex-core-config.mjs +4 -4
- package/esm2022/config/public-api.mjs +1 -1
- package/esm2022/config/src/configs.mjs +25 -24
- package/esm2022/dateTime/acorex-core-dateTime.mjs +4 -4
- package/esm2022/dateTime/public-api.mjs +5 -5
- package/esm2022/dateTime/src/datetime.class.mjs +294 -294
- package/esm2022/dateTime/src/datetime.module.mjs +40 -39
- package/esm2022/dateTime/src/datetime.pipe.mjs +27 -26
- package/esm2022/dateTime/src/georgian.calendar.mjs +186 -186
- package/esm2022/dateTime/src/jalali.calendar.mjs +356 -356
- package/esm2022/events/acorex-core-events.mjs +4 -4
- package/esm2022/events/public-api.mjs +1 -1
- package/esm2022/events/src/event.service.mjs +35 -34
- package/esm2022/file/acorex-core-file.mjs +4 -4
- package/esm2022/file/public-api.mjs +4 -4
- package/esm2022/file/src/file-download-ref.class.mjs +12 -12
- package/esm2022/file/src/file-download-result.class.mjs +46 -46
- package/esm2022/file/src/file-upload-ref.class.mjs +12 -12
- package/esm2022/file/src/file.service.mjs +103 -102
- package/esm2022/http/acorex-core-http.mjs +4 -4
- package/esm2022/http/public-api.mjs +5 -5
- package/esm2022/http/src/http-error.class.mjs +1 -1
- package/esm2022/http/src/http-events.interceptor.mjs +2 -2
- package/esm2022/http/src/http-request.class.mjs +1 -1
- package/esm2022/http/src/http-result.class.mjs +24 -24
- package/esm2022/http/src/http.module.mjs +30 -29
- package/esm2022/http/src/http.service.mjs +152 -151
- package/esm2022/image/acorex-core-image.mjs +4 -4
- package/esm2022/image/public-api.mjs +1 -1
- package/esm2022/image/src/image.service.mjs +44 -43
- package/esm2022/pipes/acorex-core-pipes.mjs +4 -4
- package/esm2022/pipes/public-api.mjs +2 -2
- package/esm2022/pipes/src/pipes.module.mjs +20 -19
- package/esm2022/pipes/src/safe.pipe.mjs +32 -31
- package/esm2022/platform/acorex-core-platform.mjs +4 -4
- package/esm2022/platform/public-api.mjs +1 -1
- package/esm2022/platform/src/platform.service.mjs +152 -159
- package/esm2022/public-api.mjs +4 -4
- package/esm2022/translation/acorex-core-translation.mjs +4 -4
- package/esm2022/translation/public-api.mjs +3 -3
- package/esm2022/translation/src/translation.module.mjs +19 -18
- package/esm2022/translation/src/translator.mjs +44 -43
- package/esm2022/translation/src/translator.pipe.mjs +16 -15
- package/esm2022/utils/acorex-core-utils.mjs +4 -4
- package/esm2022/utils/public-api.mjs +5 -5
- package/esm2022/utils/src/color-util.mjs +114 -114
- package/esm2022/utils/src/drawing-util.mjs +29 -29
- package/esm2022/utils/src/html-util.mjs +15 -15
- package/esm2022/utils/src/object-util.mjs +38 -38
- package/esm2022/utils/src/string-util.mjs +18 -18
- package/events/index.d.ts +5 -5
- package/events/public-api.d.ts +1 -1
- package/events/src/event.service.d.ts +9 -9
- package/fesm2022/acorex-core-config.mjs +22 -22
- package/fesm2022/acorex-core-config.mjs.map +1 -1
- package/fesm2022/acorex-core-dateTime.mjs +882 -882
- package/fesm2022/acorex-core-dateTime.mjs.map +1 -1
- package/fesm2022/acorex-core-events.mjs +32 -32
- package/fesm2022/acorex-core-events.mjs.map +1 -1
- package/fesm2022/acorex-core-file.mjs +162 -162
- package/fesm2022/acorex-core-file.mjs.map +1 -1
- package/fesm2022/acorex-core-http.mjs +190 -190
- package/fesm2022/acorex-core-http.mjs.map +1 -1
- package/fesm2022/acorex-core-image.mjs +41 -41
- package/fesm2022/acorex-core-image.mjs.map +1 -1
- package/fesm2022/acorex-core-pipes.mjs +41 -41
- package/fesm2022/acorex-core-pipes.mjs.map +1 -1
- package/fesm2022/acorex-core-platform.mjs +147 -155
- package/fesm2022/acorex-core-platform.mjs.map +1 -1
- package/fesm2022/acorex-core-translation.mjs +63 -63
- package/fesm2022/acorex-core-translation.mjs.map +1 -1
- package/fesm2022/acorex-core-utils.mjs +209 -209
- package/fesm2022/acorex-core.mjs +5 -5
- package/file/index.d.ts +5 -5
- package/file/public-api.d.ts +4 -4
- package/file/src/file-download-ref.class.d.ts +6 -6
- package/file/src/file-download-result.class.d.ts +8 -8
- package/file/src/file-upload-ref.class.d.ts +5 -5
- package/file/src/file.service.d.ts +18 -18
- package/http/index.d.ts +5 -5
- package/http/public-api.d.ts +5 -5
- package/http/src/http-error.class.d.ts +7 -7
- package/http/src/http-events.interceptor.d.ts +10 -10
- package/http/src/http-request.class.d.ts +14 -14
- package/http/src/http-result.class.d.ts +11 -11
- package/http/src/http.module.d.ts +8 -8
- package/http/src/http.service.d.ts +23 -23
- package/image/index.d.ts +5 -5
- package/image/public-api.d.ts +1 -1
- package/image/src/image.service.d.ts +12 -12
- package/index.d.ts +5 -5
- package/package.json +7 -7
- package/pipes/index.d.ts +5 -5
- package/pipes/public-api.d.ts +2 -2
- package/pipes/src/pipes.module.d.ts +8 -8
- package/pipes/src/safe.pipe.d.ts +10 -10
- package/platform/index.d.ts +5 -5
- package/platform/public-api.d.ts +1 -1
- package/platform/src/platform.service.d.ts +26 -26
- package/public-api.d.ts +1 -1
- package/translation/index.d.ts +5 -5
- package/translation/public-api.d.ts +3 -3
- package/translation/src/translation.module.d.ts +7 -7
- package/translation/src/translator.d.ts +11 -11
- package/translation/src/translator.pipe.d.ts +7 -7
- package/utils/index.d.ts +5 -5
- package/utils/public-api.d.ts +5 -5
- package/utils/src/color-util.d.ts +23 -23
- package/utils/src/drawing-util.d.ts +18 -18
- package/utils/src/html-util.d.ts +4 -4
- package/utils/src/object-util.d.ts +4 -4
- package/utils/src/string-util.d.ts +6 -6
@@ -6,202 +6,202 @@ import { HttpHeaders, HttpParams, HttpClientModule } from '@angular/common/http'
|
|
6
6
|
|
7
7
|
const AX_HTTP_EVENT_INTERCEPTOR = new InjectionToken('ax.http.events');
|
8
8
|
|
9
|
-
class HttpResult {
|
10
|
-
_executor;
|
11
|
-
constructor(executor) {
|
12
|
-
this._executor = executor;
|
13
|
-
setTimeout(() => {
|
14
|
-
this._executor(this.resultAction, this.errorAction, this.completeAction);
|
15
|
-
}, 50);
|
16
|
-
}
|
17
|
-
resultAction;
|
18
|
-
errorAction;
|
19
|
-
completeAction;
|
20
|
-
result(action) {
|
21
|
-
this.resultAction = action;
|
22
|
-
return this;
|
23
|
-
}
|
24
|
-
error(action) {
|
25
|
-
this.errorAction = action;
|
26
|
-
return this;
|
27
|
-
}
|
28
|
-
complete(action) {
|
29
|
-
this.completeAction = action;
|
30
|
-
return this;
|
31
|
-
}
|
9
|
+
class HttpResult {
|
10
|
+
_executor;
|
11
|
+
constructor(executor) {
|
12
|
+
this._executor = executor;
|
13
|
+
setTimeout(() => {
|
14
|
+
this._executor(this.resultAction, this.errorAction, this.completeAction);
|
15
|
+
}, 50);
|
16
|
+
}
|
17
|
+
resultAction;
|
18
|
+
errorAction;
|
19
|
+
completeAction;
|
20
|
+
result(action) {
|
21
|
+
this.resultAction = action;
|
22
|
+
return this;
|
23
|
+
}
|
24
|
+
error(action) {
|
25
|
+
this.errorAction = action;
|
26
|
+
return this;
|
27
|
+
}
|
28
|
+
complete(action) {
|
29
|
+
this.completeAction = action;
|
30
|
+
return this;
|
31
|
+
}
|
32
32
|
}
|
33
33
|
|
34
|
-
// import { catchError, retry, retryWhen, mergeMap, delay, switchMap, scan, takeWhile, flatMap } from 'rxjs/operators';
|
35
|
-
// import { of, concat, throwError } from 'rxjs';
|
36
|
-
class AXHttpService {
|
37
|
-
http;
|
38
|
-
injector;
|
39
|
-
interceptor;
|
40
|
-
constructor(http, injector) {
|
41
|
-
this.http = http;
|
42
|
-
this.injector = injector;
|
43
|
-
this.interceptor = this.injector.get(AX_HTTP_EVENT_INTERCEPTOR);
|
44
|
-
}
|
45
|
-
get(url, config = {}) {
|
46
|
-
config.url = url;
|
47
|
-
config.method = "get";
|
48
|
-
return this.request(config);
|
49
|
-
}
|
50
|
-
post(url, config = {}) {
|
51
|
-
config.url = url;
|
52
|
-
config.method = "post";
|
53
|
-
return this.request(config);
|
54
|
-
}
|
55
|
-
delete(url, config = {}) {
|
56
|
-
config.url = url;
|
57
|
-
config.method = "delete";
|
58
|
-
return this.request(config);
|
59
|
-
}
|
60
|
-
put(url, config = {}) {
|
61
|
-
config.url = url;
|
62
|
-
config.method = "put";
|
63
|
-
return this.request(config);
|
64
|
-
}
|
65
|
-
request(config) {
|
66
|
-
return new HttpResult((result, error, complete) => {
|
67
|
-
this.handleBegin(config).then(c => {
|
68
|
-
this.http
|
69
|
-
//TODO: check ts error
|
70
|
-
//@ts-ignore
|
71
|
-
.request(config.method, config.url, this.mapOptions(config))
|
72
|
-
//.pipe(this.retry)
|
73
|
-
.subscribe(data => {
|
74
|
-
this.handleResult(data, result, complete, config);
|
75
|
-
}, c => {
|
76
|
-
this.handleError(c, error, complete, config);
|
77
|
-
});
|
78
|
-
});
|
79
|
-
});
|
80
|
-
}
|
81
|
-
handleResult(data, result, complete, config) {
|
82
|
-
if (this.interceptor) {
|
83
|
-
this.interceptor.success(config, data).then(c => {
|
84
|
-
if (result)
|
85
|
-
result(c);
|
86
|
-
this.handleComplete(complete, config);
|
87
|
-
});
|
88
|
-
}
|
89
|
-
else {
|
90
|
-
//
|
91
|
-
if (result)
|
92
|
-
result(data);
|
93
|
-
this.handleComplete(complete, config);
|
94
|
-
}
|
95
|
-
}
|
96
|
-
handleBegin(config) {
|
97
|
-
return new Promise((resolve) => {
|
98
|
-
if (!config.headers)
|
99
|
-
config.headers = {};
|
100
|
-
if (!config.params)
|
101
|
-
config.params = {};
|
102
|
-
//
|
103
|
-
if (this.interceptor) {
|
104
|
-
this.interceptor.begin(config).then(c => {
|
105
|
-
resolve(c);
|
106
|
-
});
|
107
|
-
}
|
108
|
-
else {
|
109
|
-
resolve(config);
|
110
|
-
}
|
111
|
-
});
|
112
|
-
}
|
113
|
-
handleComplete(complete, config) {
|
114
|
-
if (complete)
|
115
|
-
complete();
|
116
|
-
if (this.interceptor)
|
117
|
-
this.interceptor.complete(config);
|
118
|
-
}
|
119
|
-
handleError(c, error, complete, config) {
|
120
|
-
let r = {
|
121
|
-
message: c.message,
|
122
|
-
status: c.status,
|
123
|
-
code: c.status?.toString(),
|
124
|
-
handled: false,
|
125
|
-
error: c.error
|
126
|
-
};
|
127
|
-
if (error) {
|
128
|
-
error(r);
|
129
|
-
}
|
130
|
-
if (!r.handled) {
|
131
|
-
if (this.interceptor)
|
132
|
-
this.interceptor.error(config, r);
|
133
|
-
}
|
134
|
-
this.handleComplete(complete, config);
|
135
|
-
}
|
136
|
-
mapOptions(options) {
|
137
|
-
let headers = new HttpHeaders();
|
138
|
-
for (const key in options.headers) {
|
139
|
-
if (options.headers.hasOwnProperty(key)) {
|
140
|
-
const value = options.headers[key];
|
141
|
-
headers = headers.set(key, value);
|
142
|
-
}
|
143
|
-
}
|
144
|
-
let params = new HttpParams();
|
145
|
-
for (const key in options.params) {
|
146
|
-
if (options.params.hasOwnProperty(key)) {
|
147
|
-
const value = options.params[key];
|
148
|
-
params = params.set(key, value);
|
149
|
-
}
|
150
|
-
}
|
151
|
-
return {
|
152
|
-
headers: headers,
|
153
|
-
params: params,
|
154
|
-
body: options.body,
|
155
|
-
responseType: options.responseType || 'json'
|
156
|
-
};
|
157
|
-
// if (options.method == "get") {
|
158
|
-
// return {
|
159
|
-
// headers: headers,
|
160
|
-
// params: params
|
161
|
-
// };
|
162
|
-
// }
|
163
|
-
// else {
|
164
|
-
// return {
|
165
|
-
// headers: headers,
|
166
|
-
// params: params,
|
167
|
-
// body: options.body
|
168
|
-
// };
|
169
|
-
// }
|
170
|
-
}
|
171
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.0.0", ngImport: i0, type: AXHttpService, deps: [{ token: i1.HttpClient }, { token: i0.Injector }], target: i0.ɵɵFactoryTarget.Injectable });
|
172
|
-
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.0.0", ngImport: i0, type: AXHttpService, providedIn: 'root' });
|
173
|
-
}
|
174
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.0", ngImport: i0, type: AXHttpService, decorators: [{
|
175
|
-
type: Injectable,
|
176
|
-
args: [{ providedIn: 'root' }]
|
34
|
+
// import { catchError, retry, retryWhen, mergeMap, delay, switchMap, scan, takeWhile, flatMap } from 'rxjs/operators';
|
35
|
+
// import { of, concat, throwError } from 'rxjs';
|
36
|
+
class AXHttpService {
|
37
|
+
http;
|
38
|
+
injector;
|
39
|
+
interceptor;
|
40
|
+
constructor(http, injector) {
|
41
|
+
this.http = http;
|
42
|
+
this.injector = injector;
|
43
|
+
this.interceptor = this.injector.get(AX_HTTP_EVENT_INTERCEPTOR);
|
44
|
+
}
|
45
|
+
get(url, config = {}) {
|
46
|
+
config.url = url;
|
47
|
+
config.method = "get";
|
48
|
+
return this.request(config);
|
49
|
+
}
|
50
|
+
post(url, config = {}) {
|
51
|
+
config.url = url;
|
52
|
+
config.method = "post";
|
53
|
+
return this.request(config);
|
54
|
+
}
|
55
|
+
delete(url, config = {}) {
|
56
|
+
config.url = url;
|
57
|
+
config.method = "delete";
|
58
|
+
return this.request(config);
|
59
|
+
}
|
60
|
+
put(url, config = {}) {
|
61
|
+
config.url = url;
|
62
|
+
config.method = "put";
|
63
|
+
return this.request(config);
|
64
|
+
}
|
65
|
+
request(config) {
|
66
|
+
return new HttpResult((result, error, complete) => {
|
67
|
+
this.handleBegin(config).then(c => {
|
68
|
+
this.http
|
69
|
+
//TODO: check ts error
|
70
|
+
//@ts-ignore
|
71
|
+
.request(config.method, config.url, this.mapOptions(config))
|
72
|
+
//.pipe(this.retry)
|
73
|
+
.subscribe(data => {
|
74
|
+
this.handleResult(data, result, complete, config);
|
75
|
+
}, c => {
|
76
|
+
this.handleError(c, error, complete, config);
|
77
|
+
});
|
78
|
+
});
|
79
|
+
});
|
80
|
+
}
|
81
|
+
handleResult(data, result, complete, config) {
|
82
|
+
if (this.interceptor) {
|
83
|
+
this.interceptor.success(config, data).then(c => {
|
84
|
+
if (result)
|
85
|
+
result(c);
|
86
|
+
this.handleComplete(complete, config);
|
87
|
+
});
|
88
|
+
}
|
89
|
+
else {
|
90
|
+
//
|
91
|
+
if (result)
|
92
|
+
result(data);
|
93
|
+
this.handleComplete(complete, config);
|
94
|
+
}
|
95
|
+
}
|
96
|
+
handleBegin(config) {
|
97
|
+
return new Promise((resolve) => {
|
98
|
+
if (!config.headers)
|
99
|
+
config.headers = {};
|
100
|
+
if (!config.params)
|
101
|
+
config.params = {};
|
102
|
+
//
|
103
|
+
if (this.interceptor) {
|
104
|
+
this.interceptor.begin(config).then(c => {
|
105
|
+
resolve(c);
|
106
|
+
});
|
107
|
+
}
|
108
|
+
else {
|
109
|
+
resolve(config);
|
110
|
+
}
|
111
|
+
});
|
112
|
+
}
|
113
|
+
handleComplete(complete, config) {
|
114
|
+
if (complete)
|
115
|
+
complete();
|
116
|
+
if (this.interceptor)
|
117
|
+
this.interceptor.complete(config);
|
118
|
+
}
|
119
|
+
handleError(c, error, complete, config) {
|
120
|
+
let r = {
|
121
|
+
message: c.message,
|
122
|
+
status: c.status,
|
123
|
+
code: c.status?.toString(),
|
124
|
+
handled: false,
|
125
|
+
error: c.error
|
126
|
+
};
|
127
|
+
if (error) {
|
128
|
+
error(r);
|
129
|
+
}
|
130
|
+
if (!r.handled) {
|
131
|
+
if (this.interceptor)
|
132
|
+
this.interceptor.error(config, r);
|
133
|
+
}
|
134
|
+
this.handleComplete(complete, config);
|
135
|
+
}
|
136
|
+
mapOptions(options) {
|
137
|
+
let headers = new HttpHeaders();
|
138
|
+
for (const key in options.headers) {
|
139
|
+
if (options.headers.hasOwnProperty(key)) {
|
140
|
+
const value = options.headers[key];
|
141
|
+
headers = headers.set(key, value);
|
142
|
+
}
|
143
|
+
}
|
144
|
+
let params = new HttpParams();
|
145
|
+
for (const key in options.params) {
|
146
|
+
if (options.params.hasOwnProperty(key)) {
|
147
|
+
const value = options.params[key];
|
148
|
+
params = params.set(key, value);
|
149
|
+
}
|
150
|
+
}
|
151
|
+
return {
|
152
|
+
headers: headers,
|
153
|
+
params: params,
|
154
|
+
body: options.body,
|
155
|
+
responseType: options.responseType || 'json'
|
156
|
+
};
|
157
|
+
// if (options.method == "get") {
|
158
|
+
// return {
|
159
|
+
// headers: headers,
|
160
|
+
// params: params
|
161
|
+
// };
|
162
|
+
// }
|
163
|
+
// else {
|
164
|
+
// return {
|
165
|
+
// headers: headers,
|
166
|
+
// params: params,
|
167
|
+
// body: options.body
|
168
|
+
// };
|
169
|
+
// }
|
170
|
+
}
|
171
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.0.0", ngImport: i0, type: AXHttpService, deps: [{ token: i1.HttpClient }, { token: i0.Injector }], target: i0.ɵɵFactoryTarget.Injectable });
|
172
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.0.0", ngImport: i0, type: AXHttpService, providedIn: 'root' });
|
173
|
+
}
|
174
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.0", ngImport: i0, type: AXHttpService, decorators: [{
|
175
|
+
type: Injectable,
|
176
|
+
args: [{ providedIn: 'root' }]
|
177
177
|
}], ctorParameters: function () { return [{ type: i1.HttpClient }, { type: i0.Injector }]; } });
|
178
178
|
|
179
|
-
class AXHttpModule {
|
180
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.0.0", ngImport: i0, type: AXHttpModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
181
|
-
static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "16.0.0", ngImport: i0, type: AXHttpModule, imports: [CommonModule,
|
182
|
-
HttpClientModule], exports: [HttpClientModule] });
|
183
|
-
static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "16.0.0", ngImport: i0, type: AXHttpModule, providers: [
|
184
|
-
AXHttpService
|
185
|
-
], imports: [CommonModule,
|
186
|
-
HttpClientModule, HttpClientModule] });
|
187
|
-
}
|
188
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.0", ngImport: i0, type: AXHttpModule, decorators: [{
|
189
|
-
type: NgModule,
|
190
|
-
args: [{
|
191
|
-
declarations: [],
|
192
|
-
imports: [
|
193
|
-
CommonModule,
|
194
|
-
HttpClientModule
|
195
|
-
],
|
196
|
-
exports: [HttpClientModule],
|
197
|
-
providers: [
|
198
|
-
AXHttpService
|
199
|
-
]
|
200
|
-
}]
|
179
|
+
class AXHttpModule {
|
180
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.0.0", ngImport: i0, type: AXHttpModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
181
|
+
static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "16.0.0", ngImport: i0, type: AXHttpModule, imports: [CommonModule,
|
182
|
+
HttpClientModule], exports: [HttpClientModule] });
|
183
|
+
static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "16.0.0", ngImport: i0, type: AXHttpModule, providers: [
|
184
|
+
AXHttpService
|
185
|
+
], imports: [CommonModule,
|
186
|
+
HttpClientModule, HttpClientModule] });
|
187
|
+
}
|
188
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.0", ngImport: i0, type: AXHttpModule, decorators: [{
|
189
|
+
type: NgModule,
|
190
|
+
args: [{
|
191
|
+
declarations: [],
|
192
|
+
imports: [
|
193
|
+
CommonModule,
|
194
|
+
HttpClientModule
|
195
|
+
],
|
196
|
+
exports: [HttpClientModule],
|
197
|
+
providers: [
|
198
|
+
AXHttpService
|
199
|
+
]
|
200
|
+
}]
|
201
201
|
}] });
|
202
202
|
|
203
|
-
/**
|
204
|
-
* Generated bundle index. Do not edit.
|
203
|
+
/**
|
204
|
+
* Generated bundle index. Do not edit.
|
205
205
|
*/
|
206
206
|
|
207
207
|
export { AXHttpModule, AX_HTTP_EVENT_INTERCEPTOR, HttpResult };
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"acorex-core-http.mjs","sources":["../../../../projects/acorex/core/http/src/http-events.interceptor.ts","../../../../projects/acorex/core/http/src/http-result.class.ts","../../../../projects/acorex/core/http/src/http.service.ts","../../../../projects/acorex/core/http/src/http.module.ts","../../../../projects/acorex/core/http/acorex-core-http.ts"],"sourcesContent":["import { IHttpError } from './http-error.class';\r\nimport { InjectionToken } from '@angular/core';\r\nimport { AXHttpRequestOptions } from './http-request.class';\r\n\r\nexport const AX_HTTP_EVENT_INTERCEPTOR = new InjectionToken<AXHttpEventInterceptor>('ax.http.events');\r\n\r\nexport interface AXHttpEventInterceptor {\r\n begin(request: AXHttpRequestOptions): Promise<AXHttpRequestOptions>;\r\n success(request: AXHttpRequestOptions, result: any): Promise<any>;\r\n complete(request: AXHttpRequestOptions);\r\n error(request: AXHttpRequestOptions, error: IHttpError);\r\n}\r\n\r\n\r\n","import { IHttpError } from './http-error.class';\r\n\r\nexport class HttpResult<T> {\r\n private _executor: (result: (e?: T) => void, error: (e?: IHttpError) => void, complete: () => void) => void;\r\n constructor(\r\n executor: (\r\n result: (e?: T) => void,\r\n error: (e?: IHttpError) => void,\r\n complete: () => void\r\n ) => void\r\n ) {\r\n this._executor = executor;\r\n setTimeout(() => {\r\n this._executor(this.resultAction, this.errorAction, this.completeAction);\r\n }, 50);\r\n }\r\n\r\n private resultAction: (e?: T) => void;\r\n private errorAction: (e?: IHttpError) => void;\r\n private completeAction: () => void;\r\n\r\n result(action: (e?: T) => void): HttpResult<T> { \r\n this.resultAction = action;\r\n return this;\r\n }\r\n error(action: (e?: IHttpError) => void): HttpResult<T> {\r\n this.errorAction = action;\r\n return this;\r\n }\r\n complete(action: () => void): HttpResult<T> {\r\n this.completeAction = action;\r\n return this;\r\n }\r\n}","import { Injectable, Injector, InjectFlags } from '@angular/core';\r\nimport { HttpClient, HttpHeaders, HttpParams, HttpErrorResponse } from '@angular/common/http';\r\nimport { HttpResult } from './http-result.class';\r\nimport { IHttpError } from './http-error.class';\r\nimport { AXHttpRequestOptions } from './http-request.class';\r\nimport {\r\n AX_HTTP_EVENT_INTERCEPTOR, AXHttpEventInterceptor\r\n} from './http-events.interceptor';\r\n// import { catchError, retry, retryWhen, mergeMap, delay, switchMap, scan, takeWhile, flatMap } from 'rxjs/operators';\r\n// import { of, concat, throwError } from 'rxjs';\r\n\r\n\r\n@Injectable({ providedIn: 'root' })\r\nexport class AXHttpService {\r\n\r\n private interceptor: AXHttpEventInterceptor;\r\n constructor(private http: HttpClient, private injector: Injector) {\r\n this.interceptor = this.injector.get(AX_HTTP_EVENT_INTERCEPTOR);\r\n }\r\n\r\n\r\n get<T>(url: string, config: AXHttpRequestOptions = {}): HttpResult<T> {\r\n config.url = url;\r\n config.method = \"get\";\r\n return this.request(config);\r\n }\r\n\r\n post<T>(url: string, config: AXHttpRequestOptions = {}): HttpResult<T> {\r\n config.url = url;\r\n config.method = \"post\";\r\n return this.request(config);\r\n }\r\n\r\n delete<T>(url: string, config: AXHttpRequestOptions = {}): HttpResult<T> {\r\n config.url = url;\r\n config.method = \"delete\";\r\n return this.request(config);\r\n }\r\n\r\n put<T>(url: string, config: AXHttpRequestOptions = {}): HttpResult<T> {\r\n config.url = url;\r\n config.method = \"put\";\r\n return this.request(config);\r\n }\r\n\r\n\r\n request<T>(config: AXHttpRequestOptions): HttpResult<T> {\r\n return new HttpResult<T>((result?, error?, complete?) => {\r\n this.handleBegin(config).then(c => {\r\n this.http\r\n //TODO: check ts error\r\n //@ts-ignore\r\n .request<T>(config.method, config.url, this.mapOptions(config))\r\n //.pipe(this.retry)\r\n .subscribe(data => {\r\n this.handleResult(data, result, complete, config);\r\n }, c => {\r\n this.handleError(c, error, complete, config);\r\n });\r\n });\r\n })\r\n }\r\n\r\n\r\n private handleResult(data, result, complete, config: AXHttpRequestOptions) {\r\n if (this.interceptor) {\r\n this.interceptor.success(config, data).then(c => {\r\n if (result)\r\n result(c);\r\n this.handleComplete(complete, config);\r\n });\r\n }\r\n else {\r\n //\r\n if (result)\r\n result(data);\r\n this.handleComplete(complete, config);\r\n }\r\n }\r\n\r\n private handleBegin(config: AXHttpRequestOptions): Promise<AXHttpRequestOptions> {\r\n return new Promise((resolve) => {\r\n if (!config.headers)\r\n config.headers = {};\r\n if (!config.params)\r\n config.params = {};\r\n //\r\n if (this.interceptor) {\r\n this.interceptor.begin(config).then(c => {\r\n resolve(c);\r\n });\r\n }\r\n else {\r\n resolve(config)\r\n }\r\n })\r\n }\r\n\r\n private handleComplete(complete: Function, config: AXHttpRequestOptions) {\r\n if (complete)\r\n complete();\r\n if (this.interceptor)\r\n this.interceptor.complete(config);\r\n }\r\n\r\n private handleError(c: HttpErrorResponse, error: Function, complete: Function, config: AXHttpRequestOptions) {\r\n let r: IHttpError = {\r\n message: c.message,\r\n status: c.status,\r\n code: c.status?.toString(),\r\n handled: false,\r\n error: c.error\r\n }\r\n if (error) {\r\n error(r);\r\n }\r\n if (!r.handled) {\r\n if (this.interceptor)\r\n this.interceptor.error(config, r);\r\n }\r\n this.handleComplete(complete, config);\r\n }\r\n\r\n private mapOptions(options: AXHttpRequestOptions) {\r\n let headers = new HttpHeaders();\r\n\r\n for (const key in options.headers) {\r\n if (options.headers.hasOwnProperty(key)) {\r\n const value = options.headers[key];\r\n headers = headers.set(key, value)\r\n }\r\n }\r\n let params = new HttpParams();\r\n for (const key in options.params) {\r\n if (options.params.hasOwnProperty(key)) {\r\n const value = options.params[key];\r\n params = params.set(key, value);\r\n }\r\n }\r\n return {\r\n headers: headers,\r\n params: params,\r\n body: options.body,\r\n responseType: options.responseType || 'json'\r\n };\r\n // if (options.method == \"get\") {\r\n // return {\r\n // headers: headers,\r\n // params: params\r\n // };\r\n // }\r\n // else {\r\n // return {\r\n // headers: headers,\r\n // params: params,\r\n // body: options.body\r\n // };\r\n // }\r\n }\r\n\r\n}","import { NgModule, ModuleWithProviders } from '@angular/core';\r\nimport { CommonModule } from '@angular/common';\r\nimport { HttpClientModule } from '@angular/common/http';\r\nimport { AXHttpService } from './http.service';\r\n\r\n\r\n@NgModule({\r\n declarations: [],\r\n imports: [\r\n CommonModule,\r\n HttpClientModule\r\n ],\r\n exports: [HttpClientModule],\r\n providers: [\r\n AXHttpService\r\n ]\r\n})\r\nexport class AXHttpModule {\r\n // static forRoot(): ModuleWithProviders {\r\n // return {\r\n // ngModule: AXHttpModule,\r\n // providers: [AXHttpService]\r\n // };\r\n // }\r\n}","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;;MAIa,yBAAyB,GAAG,IAAI,cAAc,CAAyB,gBAAgB;;MCFvF,UAAU,CAAA;AACX,IAAA,SAAS,CAA2F;AAC5G,IAAA,WAAA,CACI,QAIS,EAAA;AAET,QAAA,IAAI,CAAC,SAAS,GAAG,QAAQ,CAAC;QAC1B,UAAU,CAAC,MAAK;AACZ,YAAA,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,YAAY,EAAE,IAAI,CAAC,WAAW,EAAE,IAAI,CAAC,cAAc,CAAC,CAAC;SAC5E,EAAE,EAAE,CAAC,CAAC;KACV;AAEO,IAAA,YAAY,CAAkB;AAC9B,IAAA,WAAW,CAA2B;AACtC,IAAA,cAAc,CAAa;AAEnC,IAAA,MAAM,CAAC,MAAuB,EAAA;AAC1B,QAAA,IAAI,CAAC,YAAY,GAAG,MAAM,CAAC;AAC3B,QAAA,OAAO,IAAI,CAAC;KACf;AACD,IAAA,KA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EAAE,EAAE;AAChB,oBAAA,OAAO,EAAE;wBACP,YAAY;wBACZ,gBAAgB;AACjB,qBAAA;oBACD,OAAO,EAAE,CAAC,gBAAgB,CAAC;AAC3B,oBAAA,SAAS,EAAE;wBACT,aAAa;AACd,qBAAA;AACF,iBAAA,CAAA;;;AChBD;;AAEG;;;;"}
|
1
|
+
{"version":3,"file":"acorex-core-http.mjs","sources":["../../../../projects/acorex/core/http/src/http-events.interceptor.ts","../../../../projects/acorex/core/http/src/http-result.class.ts","../../../../projects/acorex/core/http/src/http.service.ts","../../../../projects/acorex/core/http/src/http.module.ts","../../../../projects/acorex/core/http/acorex-core-http.ts"],"sourcesContent":["import { IHttpError } from './http-error.class';\r\nimport { InjectionToken } from '@angular/core';\r\nimport { AXHttpRequestOptions } from './http-request.class';\r\n\r\nexport const AX_HTTP_EVENT_INTERCEPTOR = new InjectionToken<AXHttpEventInterceptor>('ax.http.events');\r\n\r\nexport interface AXHttpEventInterceptor {\r\n begin(request: AXHttpRequestOptions): Promise<AXHttpRequestOptions>;\r\n success(request: AXHttpRequestOptions, result: any): Promise<any>;\r\n complete(request: AXHttpRequestOptions);\r\n error(request: AXHttpRequestOptions, error: IHttpError);\r\n}\r\n\r\n\r\n","import { IHttpError } from './http-error.class';\r\n\r\nexport class HttpResult<T> {\r\n private _executor: (result: (e?: T) => void, error: (e?: IHttpError) => void, complete: () => void) => void;\r\n constructor(\r\n executor: (\r\n result: (e?: T) => void,\r\n error: (e?: IHttpError) => void,\r\n complete: () => void\r\n ) => void\r\n ) {\r\n this._executor = executor;\r\n setTimeout(() => {\r\n this._executor(this.resultAction, this.errorAction, this.completeAction);\r\n }, 50);\r\n }\r\n\r\n private resultAction: (e?: T) => void;\r\n private errorAction: (e?: IHttpError) => void;\r\n private completeAction: () => void;\r\n\r\n result(action: (e?: T) => void): HttpResult<T> { \r\n this.resultAction = action;\r\n return this;\r\n }\r\n error(action: (e?: IHttpError) => void): HttpResult<T> {\r\n this.errorAction = action;\r\n return this;\r\n }\r\n complete(action: () => void): HttpResult<T> {\r\n this.completeAction = action;\r\n return this;\r\n }\r\n}","import { Injectable, Injector, InjectFlags } from '@angular/core';\r\nimport { HttpClient, HttpHeaders, HttpParams, HttpErrorResponse } from '@angular/common/http';\r\nimport { HttpResult } from './http-result.class';\r\nimport { IHttpError } from './http-error.class';\r\nimport { AXHttpRequestOptions } from './http-request.class';\r\nimport {\r\n AX_HTTP_EVENT_INTERCEPTOR, AXHttpEventInterceptor\r\n} from './http-events.interceptor';\r\n// import { catchError, retry, retryWhen, mergeMap, delay, switchMap, scan, takeWhile, flatMap } from 'rxjs/operators';\r\n// import { of, concat, throwError } from 'rxjs';\r\n\r\n\r\n@Injectable({ providedIn: 'root' })\r\nexport class AXHttpService {\r\n\r\n private interceptor: AXHttpEventInterceptor;\r\n constructor(private http: HttpClient, private injector: Injector) {\r\n this.interceptor = this.injector.get(AX_HTTP_EVENT_INTERCEPTOR);\r\n }\r\n\r\n\r\n get<T>(url: string, config: AXHttpRequestOptions = {}): HttpResult<T> {\r\n config.url = url;\r\n config.method = \"get\";\r\n return this.request(config);\r\n }\r\n\r\n post<T>(url: string, config: AXHttpRequestOptions = {}): HttpResult<T> {\r\n config.url = url;\r\n config.method = \"post\";\r\n return this.request(config);\r\n }\r\n\r\n delete<T>(url: string, config: AXHttpRequestOptions = {}): HttpResult<T> {\r\n config.url = url;\r\n config.method = \"delete\";\r\n return this.request(config);\r\n }\r\n\r\n put<T>(url: string, config: AXHttpRequestOptions = {}): HttpResult<T> {\r\n config.url = url;\r\n config.method = \"put\";\r\n return this.request(config);\r\n }\r\n\r\n\r\n request<T>(config: AXHttpRequestOptions): HttpResult<T> {\r\n return new HttpResult<T>((result?, error?, complete?) => {\r\n this.handleBegin(config).then(c => {\r\n this.http\r\n //TODO: check ts error\r\n //@ts-ignore\r\n .request<T>(config.method, config.url, this.mapOptions(config))\r\n //.pipe(this.retry)\r\n .subscribe(data => {\r\n this.handleResult(data, result, complete, config);\r\n }, c => {\r\n this.handleError(c, error, complete, config);\r\n });\r\n });\r\n })\r\n }\r\n\r\n\r\n private handleResult(data, result, complete, config: AXHttpRequestOptions) {\r\n if (this.interceptor) {\r\n this.interceptor.success(config, data).then(c => {\r\n if (result)\r\n result(c);\r\n this.handleComplete(complete, config);\r\n });\r\n }\r\n else {\r\n //\r\n if (result)\r\n result(data);\r\n this.handleComplete(complete, config);\r\n }\r\n }\r\n\r\n private handleBegin(config: AXHttpRequestOptions): Promise<AXHttpRequestOptions> {\r\n return new Promise((resolve) => {\r\n if (!config.headers)\r\n config.headers = {};\r\n if (!config.params)\r\n config.params = {};\r\n //\r\n if (this.interceptor) {\r\n this.interceptor.begin(config).then(c => {\r\n resolve(c);\r\n });\r\n }\r\n else {\r\n resolve(config)\r\n }\r\n })\r\n }\r\n\r\n private handleComplete(complete: Function, config: AXHttpRequestOptions) {\r\n if (complete)\r\n complete();\r\n if (this.interceptor)\r\n this.interceptor.complete(config);\r\n }\r\n\r\n private handleError(c: HttpErrorResponse, error: Function, complete: Function, config: AXHttpRequestOptions) {\r\n let r: IHttpError = {\r\n message: c.message,\r\n status: c.status,\r\n code: c.status?.toString(),\r\n handled: false,\r\n error: c.error\r\n }\r\n if (error) {\r\n error(r);\r\n }\r\n if (!r.handled) {\r\n if (this.interceptor)\r\n this.interceptor.error(config, r);\r\n }\r\n this.handleComplete(complete, config);\r\n }\r\n\r\n private mapOptions(options: AXHttpRequestOptions) {\r\n let headers = new HttpHeaders();\r\n\r\n for (const key in options.headers) {\r\n if (options.headers.hasOwnProperty(key)) {\r\n const value = options.headers[key];\r\n headers = headers.set(key, value)\r\n }\r\n }\r\n let params = new HttpParams();\r\n for (const key in options.params) {\r\n if (options.params.hasOwnProperty(key)) {\r\n const value = options.params[key];\r\n params = params.set(key, value);\r\n }\r\n }\r\n return {\r\n headers: headers,\r\n params: params,\r\n body: options.body,\r\n responseType: options.responseType || 'json'\r\n };\r\n // if (options.method == \"get\") {\r\n // return {\r\n // headers: headers,\r\n // params: params\r\n // };\r\n // }\r\n // else {\r\n // return {\r\n // headers: headers,\r\n // params: params,\r\n // body: options.body\r\n // };\r\n // }\r\n }\r\n\r\n}","import { NgModule, ModuleWithProviders } from '@angular/core';\r\nimport { CommonModule } from '@angular/common';\r\nimport { HttpClientModule } from '@angular/common/http';\r\nimport { AXHttpService } from './http.service';\r\n\r\n\r\n@NgModule({\r\n declarations: [],\r\n imports: [\r\n CommonModule,\r\n HttpClientModule\r\n ],\r\n exports: [HttpClientModule],\r\n providers: [\r\n AXHttpService\r\n ]\r\n})\r\nexport class AXHttpModule {\r\n // static forRoot(): ModuleWithProviders {\r\n // return {\r\n // ngModule: AXHttpModule,\r\n // providers: [AXHttpService]\r\n // };\r\n // }\r\n}","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;;MAIa,yBAAyB,GAAG,IAAI,cAAc,CAAyB,gBAAgB;;MCFvF,UAAU,CAAA;AACX,IAAA,SAAS,CAA2F;AAC5G,IAAA,WAAA,CACI,QAIS,EAAA;AAET,QAAA,IAAI,CAAC,SAAS,GAAG,QAAQ,CAAC;QAC1B,UAAU,CAAC,MAAK;AACZ,YAAA,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,YAAY,EAAE,IAAI,CAAC,WAAW,EAAE,IAAI,CAAC,cAAc,CAAC,CAAC;SAC5E,EAAE,EAAE,CAAC,CAAC;KACV;AAEO,IAAA,YAAY,CAAkB;AAC9B,IAAA,WAAW,CAA2B;AACtC,IAAA,cAAc,CAAa;AAEnC,IAAA,MAAM,CAAC,MAAuB,EAAA;AAC1B,QAAA,IAAI,CAAC,YAAY,GAAG,MAAM,CAAC;AAC3B,QAAA,OAAO,IAAI,CAAC;KACf;AACD,IAAA,KAAK,CAAC,MAAgC,EAAA;AAClC,QAAA,IAAI,CAAC,WAAW,GAAG,MAAM,CAAC;AAC1B,QAAA,OAAO,IAAI,CAAC;KACf;AACD,IAAA,QAAQ,CAAC,MAAkB,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AA,SAAS,EAAE;wBACT,aAAa;AACd,qBAAA;AACF,iBAAA,CAAA;;;AChBD;;AAEG;;;;"}
|
@@ -1,49 +1,49 @@
|
|
1
1
|
import * as i0 from '@angular/core';
|
2
2
|
import { Injectable } from '@angular/core';
|
3
3
|
|
4
|
-
class AXImageService {
|
5
|
-
constructor() { }
|
6
|
-
async resize(options) {
|
7
|
-
options = Object.assign({ type: 'image/png', quality: 1 }, options);
|
8
|
-
let image;
|
9
|
-
if (options.source instanceof File) {
|
10
|
-
var a = new Image();
|
11
|
-
a.src = URL.createObjectURL(options.source);
|
12
|
-
await new Promise((res) => a.onload = res);
|
13
|
-
image = a;
|
14
|
-
}
|
15
|
-
else {
|
16
|
-
image = options.source;
|
17
|
-
}
|
18
|
-
// Resize the image
|
19
|
-
var canvas = document.createElement('canvas'), width = image.width, height = image.height;
|
20
|
-
if (width > height) {
|
21
|
-
if (width > options.maxSize) {
|
22
|
-
height *= options.maxSize / width;
|
23
|
-
width = options.maxSize;
|
24
|
-
}
|
25
|
-
}
|
26
|
-
else {
|
27
|
-
if (height > options.maxSize) {
|
28
|
-
width *= options.maxSize / height;
|
29
|
-
height = options.maxSize;
|
30
|
-
}
|
31
|
-
}
|
32
|
-
canvas.width = width;
|
33
|
-
canvas.height = height;
|
34
|
-
canvas.getContext('2d').drawImage(image, 0, 0, width, height);
|
35
|
-
return new Promise((resolve) => canvas.toBlob(resolve, options.type, options.quality));
|
36
|
-
}
|
37
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.0.0", ngImport: i0, type: AXImageService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
38
|
-
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.0.0", ngImport: i0, type: AXImageService, providedIn: 'root' });
|
39
|
-
}
|
40
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.0", ngImport: i0, type: AXImageService, decorators: [{
|
41
|
-
type: Injectable,
|
42
|
-
args: [{ providedIn: 'root' }]
|
4
|
+
class AXImageService {
|
5
|
+
constructor() { }
|
6
|
+
async resize(options) {
|
7
|
+
options = Object.assign({ type: 'image/png', quality: 1 }, options);
|
8
|
+
let image;
|
9
|
+
if (options.source instanceof File) {
|
10
|
+
var a = new Image();
|
11
|
+
a.src = URL.createObjectURL(options.source);
|
12
|
+
await new Promise((res) => a.onload = res);
|
13
|
+
image = a;
|
14
|
+
}
|
15
|
+
else {
|
16
|
+
image = options.source;
|
17
|
+
}
|
18
|
+
// Resize the image
|
19
|
+
var canvas = document.createElement('canvas'), width = image.width, height = image.height;
|
20
|
+
if (width > height) {
|
21
|
+
if (width > options.maxSize) {
|
22
|
+
height *= options.maxSize / width;
|
23
|
+
width = options.maxSize;
|
24
|
+
}
|
25
|
+
}
|
26
|
+
else {
|
27
|
+
if (height > options.maxSize) {
|
28
|
+
width *= options.maxSize / height;
|
29
|
+
height = options.maxSize;
|
30
|
+
}
|
31
|
+
}
|
32
|
+
canvas.width = width;
|
33
|
+
canvas.height = height;
|
34
|
+
canvas.getContext('2d').drawImage(image, 0, 0, width, height);
|
35
|
+
return new Promise((resolve) => canvas.toBlob(resolve, options.type, options.quality));
|
36
|
+
}
|
37
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.0.0", ngImport: i0, type: AXImageService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
38
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.0.0", ngImport: i0, type: AXImageService, providedIn: 'root' });
|
39
|
+
}
|
40
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.0", ngImport: i0, type: AXImageService, decorators: [{
|
41
|
+
type: Injectable,
|
42
|
+
args: [{ providedIn: 'root' }]
|
43
43
|
}], ctorParameters: function () { return []; } });
|
44
44
|
|
45
|
-
/**
|
46
|
-
* Generated bundle index. Do not edit.
|
45
|
+
/**
|
46
|
+
* Generated bundle index. Do not edit.
|
47
47
|
*/
|
48
48
|
|
49
49
|
export { AXImageService };
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"acorex-core-image.mjs","sources":["../../../../projects/acorex/core/image/src/image.service.ts","../../../../projects/acorex/core/image/acorex-core-image.ts"],"sourcesContent":["import { Injectable } from '@angular/core';\r\n\r\n@Injectable({ providedIn: 'root' })\r\nexport class AXImageService {\r\n constructor() { }\r\n\r\n\r\n async resize(options: { maxSize: number, source: HTMLImageElement | File, type?: 'image/png' | 'image/jpeg' | 'image/webp', quality?: number }): Promise<Blob> {\r\n options = Object.assign({ type: 'image/png', quality: 1 }, options);\r\n\r\n let image: HTMLImageElement;\r\n if (options.source instanceof File) {\r\n var a = new Image()\r\n a.src = URL.createObjectURL(options.source);\r\n await new Promise<Event>((res) => a.onload = res);\r\n image = a;\r\n }\r\n else {\r\n image = options.source;\r\n }\r\n\r\n // Resize the image\r\n var canvas = document.createElement('canvas'),\r\n width = image.width,\r\n height = image.height;\r\n if (width > height) {\r\n if (width > options.maxSize) {\r\n height *= options.maxSize / width;\r\n width = options.maxSize;\r\n }\r\n } else {\r\n if (height > options.maxSize) {\r\n width *= options.maxSize / height;\r\n height = options.maxSize;\r\n }\r\n }\r\n canvas.width = width;\r\n canvas.height = height;\r\n canvas.getContext('2d').drawImage(image, 0, 0, width, height);\r\n return new Promise((resolve) => canvas.toBlob(resolve, options.type, options.quality));\r\n }\r\n}","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;
|
1
|
+
{"version":3,"file":"acorex-core-image.mjs","sources":["../../../../projects/acorex/core/image/src/image.service.ts","../../../../projects/acorex/core/image/acorex-core-image.ts"],"sourcesContent":["import { Injectable } from '@angular/core';\r\n\r\n@Injectable({ providedIn: 'root' })\r\nexport class AXImageService {\r\n constructor() { }\r\n\r\n\r\n async resize(options: { maxSize: number, source: HTMLImageElement | File, type?: 'image/png' | 'image/jpeg' | 'image/webp', quality?: number }): Promise<Blob> {\r\n options = Object.assign({ type: 'image/png', quality: 1 }, options);\r\n\r\n let image: HTMLImageElement;\r\n if (options.source instanceof File) {\r\n var a = new Image()\r\n a.src = URL.createObjectURL(options.source);\r\n await new Promise<Event>((res) => a.onload = res);\r\n image = a;\r\n }\r\n else {\r\n image = options.source;\r\n }\r\n\r\n // Resize the image\r\n var canvas = document.createElement('canvas'),\r\n width = image.width,\r\n height = image.height;\r\n if (width > height) {\r\n if (width > options.maxSize) {\r\n height *= options.maxSize / width;\r\n width = options.maxSize;\r\n }\r\n } else {\r\n if (height > options.maxSize) {\r\n width *= options.maxSize / height;\r\n height = options.maxSize;\r\n }\r\n }\r\n canvas.width = width;\r\n canvas.height = height;\r\n canvas.getContext('2d').drawImage(image, 0, 0, width, height);\r\n return new Promise((resolve) => canvas.toBlob(resolve, options.type, options.quality));\r\n }\r\n}","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;AAEA,MACa,cAAc,CAAA;AACvB,IAAA,WAAA,GAAA,GAAiB;IAGjB,MAAM,MAAM,CAAC,OAAiI,EAAA;AAC1I,QAAA,OAAO,GAAG,MAAM,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,WAAW,EAAE,OAAO,EAAE,CAAC,EAAE,EAAE,OAAO,CAAC,CAAC;AAEpE,QAAA,IAAI,KAAuB,CAAC;AAC5B,QAAA,IAAI,OAAO,CAAC,MAAM,YAAY,IAAI,EAAE;AAChC,YAAA,IAAI,CAAC,GAAG,IAAI,KAAK,EAAE,CAAA;YACnB,CAAC,CAAC,GAAG,GAAG,GAAG,CAAC,eAAe,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;AAC5C,YAAA,MAAM,IAAI,OAAO,CAAQ,CAAC,GAAG,KAAK,CAAC,CAAC,MAAM,GAAG,GAAG,CAAC,CAAC;YAClD,KAAK,GAAG,CAAC,CAAC;AACb,SAAA;AACI,aAAA;AACD,YAAA,KAAK,GAAG,OA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