@acorex/core 7.0.41 → 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.
Files changed (170) hide show
  1. package/config/index.d.ts +5 -5
  2. package/config/public-api.d.ts +1 -1
  3. package/config/src/configs.d.ts +9 -9
  4. package/dateTime/index.d.ts +5 -5
  5. package/dateTime/public-api.d.ts +5 -5
  6. package/dateTime/src/datetime.class.d.ts +100 -100
  7. package/dateTime/src/datetime.module.d.ts +8 -8
  8. package/dateTime/src/datetime.pipe.d.ts +8 -8
  9. package/dateTime/src/georgian.calendar.d.ts +20 -20
  10. package/dateTime/src/jalali.calendar.d.ts +35 -35
  11. package/{esm2020 → esm2022}/acorex-core.mjs +4 -4
  12. package/{esm2020 → esm2022}/config/acorex-core-config.mjs +4 -4
  13. package/{esm2020 → esm2022}/config/public-api.mjs +1 -1
  14. package/esm2022/config/src/configs.mjs +25 -0
  15. package/{esm2020 → esm2022}/dateTime/acorex-core-dateTime.mjs +4 -4
  16. package/{esm2020 → esm2022}/dateTime/public-api.mjs +5 -5
  17. package/esm2022/dateTime/src/datetime.class.mjs +295 -0
  18. package/esm2022/dateTime/src/datetime.module.mjs +40 -0
  19. package/esm2022/dateTime/src/datetime.pipe.mjs +27 -0
  20. package/esm2022/dateTime/src/georgian.calendar.mjs +187 -0
  21. package/esm2022/dateTime/src/jalali.calendar.mjs +357 -0
  22. package/{esm2020 → esm2022}/events/acorex-core-events.mjs +4 -4
  23. package/{esm2020 → esm2022}/events/public-api.mjs +1 -1
  24. package/esm2022/events/src/event.service.mjs +35 -0
  25. package/{esm2020 → esm2022}/file/acorex-core-file.mjs +4 -4
  26. package/{esm2020 → esm2022}/file/public-api.mjs +4 -4
  27. package/esm2022/file/src/file-download-ref.class.mjs +13 -0
  28. package/esm2022/file/src/file-download-result.class.mjs +47 -0
  29. package/esm2022/file/src/file-upload-ref.class.mjs +13 -0
  30. package/esm2022/file/src/file.service.mjs +103 -0
  31. package/{esm2020 → esm2022}/http/acorex-core-http.mjs +4 -4
  32. package/{esm2020 → esm2022}/http/public-api.mjs +5 -5
  33. package/{esm2020 → esm2022}/http/src/http-error.class.mjs +1 -1
  34. package/{esm2020 → esm2022}/http/src/http-events.interceptor.mjs +2 -2
  35. package/{esm2020 → esm2022}/http/src/http-request.class.mjs +1 -1
  36. package/esm2022/http/src/http-result.class.mjs +25 -0
  37. package/esm2022/http/src/http.module.mjs +30 -0
  38. package/esm2022/http/src/http.service.mjs +152 -0
  39. package/{esm2020 → esm2022}/image/acorex-core-image.mjs +4 -4
  40. package/{esm2020 → esm2022}/image/public-api.mjs +1 -1
  41. package/esm2022/image/src/image.service.mjs +44 -0
  42. package/{esm2020 → esm2022}/pipes/acorex-core-pipes.mjs +4 -4
  43. package/{esm2020 → esm2022}/pipes/public-api.mjs +2 -2
  44. package/esm2022/pipes/src/pipes.module.mjs +20 -0
  45. package/{esm2020 → esm2022}/pipes/src/safe.pipe.mjs +32 -30
  46. package/{esm2020 → esm2022}/platform/acorex-core-platform.mjs +4 -4
  47. package/{esm2020 → esm2022}/platform/public-api.mjs +1 -1
  48. package/esm2022/platform/src/platform.service.mjs +152 -0
  49. package/{esm2020 → esm2022}/public-api.mjs +4 -4
  50. package/{esm2020 → esm2022}/translation/acorex-core-translation.mjs +4 -4
  51. package/{esm2020 → esm2022}/translation/public-api.mjs +3 -3
  52. package/esm2022/translation/src/translation.module.mjs +19 -0
  53. package/esm2022/translation/src/translator.mjs +44 -0
  54. package/esm2022/translation/src/translator.pipe.mjs +16 -0
  55. package/{esm2020 → esm2022}/utils/acorex-core-utils.mjs +4 -4
  56. package/{esm2020 → esm2022}/utils/public-api.mjs +5 -5
  57. package/{esm2020 → esm2022}/utils/src/color-util.mjs +114 -114
  58. package/{esm2020 → esm2022}/utils/src/drawing-util.mjs +29 -29
  59. package/{esm2020 → esm2022}/utils/src/html-util.mjs +15 -15
  60. package/{esm2020 → esm2022}/utils/src/object-util.mjs +38 -38
  61. package/{esm2020 → esm2022}/utils/src/string-util.mjs +18 -18
  62. package/events/index.d.ts +5 -5
  63. package/events/public-api.d.ts +1 -1
  64. package/events/src/event.service.d.ts +9 -9
  65. package/{fesm2015 → fesm2022}/acorex-core-config.mjs +23 -24
  66. package/{fesm2015 → fesm2022}/acorex-core-config.mjs.map +1 -1
  67. package/{fesm2015 → fesm2022}/acorex-core-dateTime.mjs +882 -880
  68. package/{fesm2020 → fesm2022}/acorex-core-dateTime.mjs.map +1 -1
  69. package/{fesm2020 → fesm2022}/acorex-core-events.mjs +32 -35
  70. package/fesm2022/acorex-core-events.mjs.map +1 -0
  71. package/{fesm2020 → fesm2022}/acorex-core-file.mjs +162 -159
  72. package/{fesm2020 → fesm2022}/acorex-core-file.mjs.map +1 -1
  73. package/{fesm2020 → fesm2022}/acorex-core-http.mjs +190 -184
  74. package/{fesm2020 → fesm2022}/acorex-core-http.mjs.map +1 -1
  75. package/{fesm2020 → fesm2022}/acorex-core-image.mjs +41 -42
  76. package/{fesm2020 → fesm2022}/acorex-core-image.mjs.map +1 -1
  77. package/{fesm2015 → fesm2022}/acorex-core-pipes.mjs +41 -41
  78. package/fesm2022/acorex-core-pipes.mjs.map +1 -0
  79. package/{fesm2020 → fesm2022}/acorex-core-platform.mjs +147 -154
  80. package/fesm2022/acorex-core-platform.mjs.map +1 -0
  81. package/{fesm2020 → fesm2022}/acorex-core-translation.mjs +64 -65
  82. package/{fesm2020 → fesm2022}/acorex-core-translation.mjs.map +1 -1
  83. package/{fesm2020 → fesm2022}/acorex-core-utils.mjs +209 -210
  84. package/{fesm2015 → fesm2022}/acorex-core.mjs +5 -6
  85. package/file/index.d.ts +5 -5
  86. package/file/public-api.d.ts +4 -4
  87. package/file/src/file-download-ref.class.d.ts +6 -6
  88. package/file/src/file-download-result.class.d.ts +8 -8
  89. package/file/src/file-upload-ref.class.d.ts +5 -5
  90. package/file/src/file.service.d.ts +18 -18
  91. package/http/index.d.ts +5 -5
  92. package/http/public-api.d.ts +5 -5
  93. package/http/src/http-error.class.d.ts +7 -7
  94. package/http/src/http-events.interceptor.d.ts +10 -10
  95. package/http/src/http-request.class.d.ts +14 -14
  96. package/http/src/http-result.class.d.ts +11 -11
  97. package/http/src/http.module.d.ts +8 -8
  98. package/http/src/http.service.d.ts +23 -23
  99. package/image/index.d.ts +5 -5
  100. package/image/public-api.d.ts +1 -1
  101. package/image/src/image.service.d.ts +12 -12
  102. package/index.d.ts +5 -5
  103. package/package.json +39 -65
  104. package/pipes/index.d.ts +5 -5
  105. package/pipes/public-api.d.ts +2 -2
  106. package/pipes/src/pipes.module.d.ts +8 -8
  107. package/pipes/src/safe.pipe.d.ts +10 -10
  108. package/platform/index.d.ts +5 -5
  109. package/platform/public-api.d.ts +1 -1
  110. package/platform/src/platform.service.d.ts +26 -26
  111. package/public-api.d.ts +1 -1
  112. package/translation/index.d.ts +5 -5
  113. package/translation/public-api.d.ts +3 -3
  114. package/translation/src/translation.module.d.ts +7 -7
  115. package/translation/src/translator.d.ts +11 -11
  116. package/translation/src/translator.pipe.d.ts +7 -7
  117. package/utils/index.d.ts +5 -5
  118. package/utils/public-api.d.ts +5 -5
  119. package/utils/src/color-util.d.ts +23 -23
  120. package/utils/src/drawing-util.d.ts +18 -18
  121. package/utils/src/html-util.d.ts +4 -4
  122. package/utils/src/object-util.d.ts +4 -4
  123. package/utils/src/string-util.d.ts +6 -6
  124. package/esm2020/config/src/configs.mjs +0 -24
  125. package/esm2020/dateTime/src/datetime.class.mjs +0 -288
  126. package/esm2020/dateTime/src/datetime.module.mjs +0 -39
  127. package/esm2020/dateTime/src/datetime.pipe.mjs +0 -26
  128. package/esm2020/dateTime/src/georgian.calendar.mjs +0 -189
  129. package/esm2020/dateTime/src/jalali.calendar.mjs +0 -359
  130. package/esm2020/events/src/event.service.mjs +0 -36
  131. package/esm2020/file/src/file-download-ref.class.mjs +0 -12
  132. package/esm2020/file/src/file-download-result.class.mjs +0 -46
  133. package/esm2020/file/src/file-upload-ref.class.mjs +0 -12
  134. package/esm2020/file/src/file.service.mjs +0 -101
  135. package/esm2020/http/src/http-result.class.mjs +0 -21
  136. package/esm2020/http/src/http.module.mjs +0 -29
  137. package/esm2020/http/src/http.service.mjs +0 -148
  138. package/esm2020/image/src/image.service.mjs +0 -43
  139. package/esm2020/pipes/src/pipes.module.mjs +0 -19
  140. package/esm2020/platform/src/platform.service.mjs +0 -157
  141. package/esm2020/translation/src/translation.module.mjs +0 -18
  142. package/esm2020/translation/src/translator.mjs +0 -43
  143. package/esm2020/translation/src/translator.pipe.mjs +0 -15
  144. package/fesm2015/acorex-core-dateTime.mjs.map +0 -1
  145. package/fesm2015/acorex-core-events.mjs +0 -44
  146. package/fesm2015/acorex-core-events.mjs.map +0 -1
  147. package/fesm2015/acorex-core-file.mjs +0 -176
  148. package/fesm2015/acorex-core-file.mjs.map +0 -1
  149. package/fesm2015/acorex-core-http.mjs +0 -203
  150. package/fesm2015/acorex-core-http.mjs.map +0 -1
  151. package/fesm2015/acorex-core-image.mjs +0 -54
  152. package/fesm2015/acorex-core-image.mjs.map +0 -1
  153. package/fesm2015/acorex-core-pipes.mjs.map +0 -1
  154. package/fesm2015/acorex-core-platform.mjs +0 -165
  155. package/fesm2015/acorex-core-platform.mjs.map +0 -1
  156. package/fesm2015/acorex-core-translation.mjs +0 -81
  157. package/fesm2015/acorex-core-translation.mjs.map +0 -1
  158. package/fesm2015/acorex-core-utils.mjs +0 -227
  159. package/fesm2020/acorex-core-config.mjs +0 -32
  160. package/fesm2020/acorex-core-config.mjs.map +0 -1
  161. package/fesm2020/acorex-core-dateTime.mjs +0 -899
  162. package/fesm2020/acorex-core-events.mjs.map +0 -1
  163. package/fesm2020/acorex-core-pipes.mjs +0 -54
  164. package/fesm2020/acorex-core-pipes.mjs.map +0 -1
  165. package/fesm2020/acorex-core-platform.mjs.map +0 -1
  166. package/fesm2020/acorex-core-utils.mjs.map +0 -1
  167. package/fesm2020/acorex-core.mjs +0 -12
  168. package/fesm2020/acorex-core.mjs.map +0 -1
  169. /package/{fesm2015 → fesm2022}/acorex-core-utils.mjs.map +0 -0
  170. /package/{fesm2015 → fesm2022}/acorex-core.mjs.map +0 -0
@@ -6,197 +6,203 @@ 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
- constructor(executor) {
11
- this._executor = executor;
12
- setTimeout(() => {
13
- this._executor(this.resultAction, this.errorAction, this.completeAction);
14
- }, 50);
15
- }
16
- result(action) {
17
- this.resultAction = action;
18
- return this;
19
- }
20
- error(action) {
21
- this.errorAction = action;
22
- return this;
23
- }
24
- complete(action) {
25
- this.completeAction = action;
26
- return this;
27
- }
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
+ }
28
32
  }
29
33
 
30
- // import { catchError, retry, retryWhen, mergeMap, delay, switchMap, scan, takeWhile, flatMap } from 'rxjs/operators';
31
- // import { of, concat, throwError } from 'rxjs';
32
- class AXHttpService {
33
- constructor(http, injector) {
34
- this.http = http;
35
- this.injector = injector;
36
- this.interceptor = this.injector.get(AX_HTTP_EVENT_INTERCEPTOR);
37
- }
38
- get(url, config = {}) {
39
- config.url = url;
40
- config.method = "get";
41
- return this.request(config);
42
- }
43
- post(url, config = {}) {
44
- config.url = url;
45
- config.method = "post";
46
- return this.request(config);
47
- }
48
- delete(url, config = {}) {
49
- config.url = url;
50
- config.method = "delete";
51
- return this.request(config);
52
- }
53
- put(url, config = {}) {
54
- config.url = url;
55
- config.method = "put";
56
- return this.request(config);
57
- }
58
- request(config) {
59
- return new HttpResult((result, error, complete) => {
60
- this.handleBegin(config).then(c => {
61
- this.http
62
- //TODO: check ts error
63
- //@ts-ignore
64
- .request(config.method, config.url, this.mapOptions(config))
65
- //.pipe(this.retry)
66
- .subscribe(data => {
67
- this.handleResult(data, result, complete, config);
68
- }, c => {
69
- this.handleError(c, error, complete, config);
70
- });
71
- });
72
- });
73
- }
74
- handleResult(data, result, complete, config) {
75
- if (this.interceptor) {
76
- this.interceptor.success(config, data).then(c => {
77
- if (result)
78
- result(c);
79
- this.handleComplete(complete, config);
80
- });
81
- }
82
- else {
83
- //
84
- if (result)
85
- result(data);
86
- this.handleComplete(complete, config);
87
- }
88
- }
89
- handleBegin(config) {
90
- return new Promise((resolve) => {
91
- if (!config.headers)
92
- config.headers = {};
93
- if (!config.params)
94
- config.params = {};
95
- //
96
- if (this.interceptor) {
97
- this.interceptor.begin(config).then(c => {
98
- resolve(c);
99
- });
100
- }
101
- else {
102
- resolve(config);
103
- }
104
- });
105
- }
106
- handleComplete(complete, config) {
107
- if (complete)
108
- complete();
109
- if (this.interceptor)
110
- this.interceptor.complete(config);
111
- }
112
- handleError(c, error, complete, config) {
113
- let r = {
114
- message: c.message,
115
- status: c.status,
116
- code: c.status?.toString(),
117
- handled: false,
118
- error: c.error
119
- };
120
- if (error) {
121
- error(r);
122
- }
123
- if (!r.handled) {
124
- if (this.interceptor)
125
- this.interceptor.error(config, r);
126
- }
127
- this.handleComplete(complete, config);
128
- }
129
- mapOptions(options) {
130
- let headers = new HttpHeaders();
131
- for (const key in options.headers) {
132
- if (options.headers.hasOwnProperty(key)) {
133
- const value = options.headers[key];
134
- headers = headers.set(key, value);
135
- }
136
- }
137
- let params = new HttpParams();
138
- for (const key in options.params) {
139
- if (options.params.hasOwnProperty(key)) {
140
- const value = options.params[key];
141
- params = params.set(key, value);
142
- }
143
- }
144
- return {
145
- headers: headers,
146
- params: params,
147
- body: options.body,
148
- responseType: options.responseType || 'json'
149
- };
150
- // if (options.method == "get") {
151
- // return {
152
- // headers: headers,
153
- // params: params
154
- // };
155
- // }
156
- // else {
157
- // return {
158
- // headers: headers,
159
- // params: params,
160
- // body: options.body
161
- // };
162
- // }
163
- }
164
- }
165
- AXHttpService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: AXHttpService, deps: [{ token: i1.HttpClient }, { token: i0.Injector }], target: i0.ɵɵFactoryTarget.Injectable });
166
- AXHttpService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: AXHttpService, providedIn: 'root' });
167
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: AXHttpService, decorators: [{
168
- type: Injectable,
169
- 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' }]
170
177
  }], ctorParameters: function () { return [{ type: i1.HttpClient }, { type: i0.Injector }]; } });
171
178
 
172
- class AXHttpModule {
173
- }
174
- AXHttpModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: AXHttpModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
175
- AXHttpModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.1.4", ngImport: i0, type: AXHttpModule, imports: [CommonModule,
176
- HttpClientModule], exports: [HttpClientModule] });
177
- AXHttpModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: AXHttpModule, providers: [
178
- AXHttpService
179
- ], imports: [CommonModule,
180
- HttpClientModule, HttpClientModule] });
181
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: AXHttpModule, decorators: [{
182
- type: NgModule,
183
- args: [{
184
- declarations: [],
185
- imports: [
186
- CommonModule,
187
- HttpClientModule
188
- ],
189
- exports: [HttpClientModule],
190
- providers: [
191
- AXHttpService
192
- ]
193
- }]
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
+ }]
194
201
  }] });
195
202
 
196
- /**
197
- * Generated bundle index. Do not edit.
203
+ /**
204
+ * Generated bundle index. Do not edit.
198
205
  */
199
206
 
200
207
  export { AXHttpModule, AX_HTTP_EVENT_INTERCEPTOR, HttpResult };
201
208
  //# sourceMappingURL=acorex-core-http.mjs.map
202
- //# sourceMappingURL=acorex-core-http.mjs.map
@@ -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;AAEnB,IAAA,WAAA,CACI,QAIS,EAAA;AAET,QAAA,IAAI,CA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,EAAA,EAAA,EAAA,IAAA,EAAA,YAAY,EAJZ,SAAA,EAAA;QACT,aAAa;AACd,KAAA,EAAA,OAAA,EAAA,CANC,YAAY;AACZ,QAAA,gBAAgB,EAER,gBAAgB,CAAA,EAAA,CAAA,CAAA;2FAKf,YAAY,EAAA,UAAA,EAAA,CAAA;kBAXxB,QAAQ;AAAC,YAAA,IAAA,EAAA,CAAA;AACR,oBAAA,YAAY,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,M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BAAgB,CAAA,EAAA,CAAA,CAAA;;2FAKf,YAAY,EAAA,UAAA,EAAA,CAAA;kBAXxB,QAAQ;AAAC,YAAA,IAAA,EAAA,CAAA;AACR,oBAAA,YAAY,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,51 +1,50 @@
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
- }
38
- AXImageService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: AXImageService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
39
- AXImageService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: AXImageService, providedIn: 'root' });
40
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.4", 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 };
50
50
  //# sourceMappingURL=acorex-core-image.mjs.map
51
- //# sourceMappingURL=acorex-core-image.mjs.map
@@ -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":";;;MAGa,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,O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AAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,UAAA,EAAA,CAAA,CAAA;AAAd,cAAA,CAAA,KAAA,GAAA,EAAA,CAAA,qBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,QAAA,EAAA,QAAA,EAAA,EAAA,EAAA,IAAA,EAAA,cAAc,cADD,MAAM,EAAA,CAAA,CAAA;2FACnB,cAAc,EAAA,UAAA,EAAA,CAAA;kBAD1B,UAAU;mBAAC,EAAE,UAAU,EAAE,MAAM,EAAE,CAAA;;;ACFlC;;AAEG;;;;"}
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":[],"mapp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