@acorex/core 7.0.20 → 7.0.21

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 (205) hide show
  1. package/config/index.d.ts +5 -0
  2. package/config/public-api.d.ts +1 -0
  3. package/config/src/configs.d.ts +9 -0
  4. package/dateTime/index.d.ts +5 -0
  5. package/dateTime/{public-api.ts → public-api.d.ts} +1 -1
  6. package/dateTime/src/datetime.class.d.ts +100 -0
  7. package/dateTime/src/datetime.module.d.ts +8 -0
  8. package/dateTime/src/datetime.pipe.d.ts +8 -0
  9. package/dateTime/src/georgian.calendar.d.ts +20 -0
  10. package/dateTime/src/jalali.calendar.d.ts +35 -0
  11. package/esm2020/acorex-core.mjs +5 -0
  12. package/esm2020/config/acorex-core-config.mjs +5 -0
  13. package/esm2020/config/public-api.mjs +2 -0
  14. package/esm2020/config/src/configs.mjs +32 -0
  15. package/esm2020/dateTime/acorex-core-dateTime.mjs +5 -0
  16. package/esm2020/dateTime/public-api.mjs +6 -0
  17. package/esm2020/dateTime/src/datetime.class.mjs +288 -0
  18. package/esm2020/dateTime/src/datetime.module.mjs +39 -0
  19. package/esm2020/dateTime/src/datetime.pipe.mjs +26 -0
  20. package/esm2020/dateTime/src/georgian.calendar.mjs +189 -0
  21. package/esm2020/dateTime/src/jalali.calendar.mjs +359 -0
  22. package/esm2020/events/acorex-core-events.mjs +5 -0
  23. package/esm2020/events/public-api.mjs +2 -0
  24. package/esm2020/events/src/event.service.mjs +36 -0
  25. package/esm2020/file/acorex-core-file.mjs +5 -0
  26. package/esm2020/file/public-api.mjs +5 -0
  27. package/esm2020/file/src/file-download-ref.class.mjs +12 -0
  28. package/esm2020/file/src/file-download-result.class.mjs +47 -0
  29. package/esm2020/file/src/file-upload-ref.class.mjs +12 -0
  30. package/esm2020/file/src/file.service.mjs +101 -0
  31. package/esm2020/http/acorex-core-http.mjs +5 -0
  32. package/esm2020/http/public-api.mjs +6 -0
  33. package/esm2020/http/src/http-error.class.mjs +2 -0
  34. package/esm2020/http/src/http-events.interceptor.mjs +3 -0
  35. package/esm2020/http/src/http-request.class.mjs +2 -0
  36. package/esm2020/http/src/http-result.class.mjs +21 -0
  37. package/esm2020/http/src/http.module.mjs +29 -0
  38. package/esm2020/http/src/http.service.mjs +148 -0
  39. package/esm2020/image/acorex-core-image.mjs +5 -0
  40. package/esm2020/image/public-api.mjs +2 -0
  41. package/esm2020/image/src/image.service.mjs +43 -0
  42. package/esm2020/pipes/acorex-core-pipes.mjs +5 -0
  43. package/esm2020/pipes/public-api.mjs +3 -0
  44. package/esm2020/pipes/src/pipes.module.mjs +19 -0
  45. package/esm2020/pipes/src/safe.pipe.mjs +30 -0
  46. package/esm2020/platform/acorex-core-platform.mjs +5 -0
  47. package/esm2020/platform/public-api.mjs +2 -0
  48. package/esm2020/platform/src/platform.service.mjs +153 -0
  49. package/esm2020/public-api.mjs +5 -0
  50. package/esm2020/translation/acorex-core-translation.mjs +5 -0
  51. package/esm2020/translation/public-api.mjs +4 -0
  52. package/esm2020/translation/src/translation.module.mjs +18 -0
  53. package/esm2020/translation/src/translator.mjs +43 -0
  54. package/esm2020/translation/src/translator.pipe.mjs +15 -0
  55. package/esm2020/utils/acorex-core-utils.mjs +5 -0
  56. package/esm2020/utils/public-api.mjs +5 -0
  57. package/esm2020/utils/src/color-util.mjs +71 -0
  58. package/esm2020/utils/src/drawing-util.mjs +27 -0
  59. package/esm2020/utils/src/object-util.mjs +39 -0
  60. package/esm2020/utils/src/string-util.mjs +19 -0
  61. package/events/index.d.ts +5 -0
  62. package/events/public-api.d.ts +1 -0
  63. package/events/src/event.service.d.ts +9 -0
  64. package/fesm2015/acorex-core-config.mjs +40 -0
  65. package/fesm2015/acorex-core-config.mjs.map +1 -0
  66. package/fesm2015/acorex-core-dateTime.mjs +899 -0
  67. package/fesm2015/acorex-core-dateTime.mjs.map +1 -0
  68. package/fesm2015/acorex-core-events.mjs +44 -0
  69. package/fesm2015/acorex-core-events.mjs.map +1 -0
  70. package/fesm2015/acorex-core-file.mjs +177 -0
  71. package/fesm2015/acorex-core-file.mjs.map +1 -0
  72. package/fesm2015/acorex-core-http.mjs +203 -0
  73. package/fesm2015/acorex-core-http.mjs.map +1 -0
  74. package/fesm2015/acorex-core-image.mjs +54 -0
  75. package/fesm2015/acorex-core-image.mjs.map +1 -0
  76. package/fesm2015/acorex-core-pipes.mjs +54 -0
  77. package/fesm2015/acorex-core-pipes.mjs.map +1 -0
  78. package/fesm2015/acorex-core-platform.mjs +161 -0
  79. package/fesm2015/acorex-core-platform.mjs.map +1 -0
  80. package/fesm2015/acorex-core-translation.mjs +81 -0
  81. package/fesm2015/acorex-core-translation.mjs.map +1 -0
  82. package/fesm2015/acorex-core-utils.mjs +164 -0
  83. package/fesm2015/acorex-core-utils.mjs.map +1 -0
  84. package/fesm2015/acorex-core.mjs +12 -0
  85. package/fesm2015/acorex-core.mjs.map +1 -0
  86. package/fesm2020/acorex-core-config.mjs +40 -0
  87. package/fesm2020/acorex-core-config.mjs.map +1 -0
  88. package/fesm2020/acorex-core-dateTime.mjs +899 -0
  89. package/fesm2020/acorex-core-dateTime.mjs.map +1 -0
  90. package/fesm2020/acorex-core-events.mjs +44 -0
  91. package/fesm2020/acorex-core-events.mjs.map +1 -0
  92. package/fesm2020/acorex-core-file.mjs +177 -0
  93. package/fesm2020/acorex-core-file.mjs.map +1 -0
  94. package/fesm2020/acorex-core-http.mjs +202 -0
  95. package/fesm2020/acorex-core-http.mjs.map +1 -0
  96. package/fesm2020/acorex-core-image.mjs +51 -0
  97. package/fesm2020/acorex-core-image.mjs.map +1 -0
  98. package/fesm2020/acorex-core-pipes.mjs +54 -0
  99. package/fesm2020/acorex-core-pipes.mjs.map +1 -0
  100. package/fesm2020/acorex-core-platform.mjs +161 -0
  101. package/fesm2020/acorex-core-platform.mjs.map +1 -0
  102. package/fesm2020/acorex-core-translation.mjs +80 -0
  103. package/fesm2020/acorex-core-translation.mjs.map +1 -0
  104. package/fesm2020/acorex-core-utils.mjs +164 -0
  105. package/fesm2020/acorex-core-utils.mjs.map +1 -0
  106. package/fesm2020/acorex-core.mjs +12 -0
  107. package/fesm2020/acorex-core.mjs.map +1 -0
  108. package/file/index.d.ts +5 -0
  109. package/file/public-api.d.ts +4 -0
  110. package/file/src/file-download-ref.class.d.ts +6 -0
  111. package/file/src/file-download-result.class.d.ts +8 -0
  112. package/file/src/file-upload-ref.class.d.ts +5 -0
  113. package/file/src/file.service.d.ts +18 -0
  114. package/http/index.d.ts +5 -0
  115. package/http/{public-api.ts → public-api.d.ts} +1 -1
  116. package/http/src/{http-error.class.ts → http-error.class.d.ts} +2 -2
  117. package/http/src/{http-events.interceptor.ts → http-events.interceptor.d.ts} +3 -7
  118. package/http/src/{http-request.class.ts → http-request.class.d.ts} +5 -5
  119. package/http/src/http-result.class.d.ts +11 -0
  120. package/http/src/http.module.d.ts +8 -0
  121. package/http/src/http.service.d.ts +23 -0
  122. package/image/index.d.ts +5 -0
  123. package/image/public-api.d.ts +1 -0
  124. package/image/src/image.service.d.ts +12 -0
  125. package/index.d.ts +5 -0
  126. package/package.json +115 -16
  127. package/pipes/index.d.ts +5 -0
  128. package/pipes/public-api.d.ts +2 -0
  129. package/pipes/src/pipes.module.d.ts +8 -0
  130. package/pipes/src/safe.pipe.d.ts +10 -0
  131. package/platform/index.d.ts +5 -0
  132. package/platform/public-api.d.ts +1 -0
  133. package/platform/src/platform.service.d.ts +26 -0
  134. package/public-api.d.ts +1 -0
  135. package/translation/index.d.ts +5 -0
  136. package/translation/{public-api.ts → public-api.d.ts} +1 -1
  137. package/translation/src/translation.module.d.ts +7 -0
  138. package/translation/src/translator.d.ts +11 -0
  139. package/translation/src/translator.pipe.d.ts +7 -0
  140. package/utils/index.d.ts +5 -0
  141. package/utils/{public-api.ts → public-api.d.ts} +1 -1
  142. package/utils/src/color-util.d.ts +20 -0
  143. package/utils/src/drawing-util.d.ts +17 -0
  144. package/utils/src/object-util.d.ts +4 -0
  145. package/utils/src/string-util.d.ts +6 -0
  146. package/config/ax-preset.js +0 -186
  147. package/config/index.ts +0 -1
  148. package/config/ng-package.json +0 -6
  149. package/config/public-api.ts +0 -1
  150. package/config/src/configs.ts +0 -37
  151. package/dateTime/index.ts +0 -1
  152. package/dateTime/ng-package.json +0 -6
  153. package/dateTime/src/datetime.class.ts +0 -449
  154. package/dateTime/src/datetime.module.ts +0 -35
  155. package/dateTime/src/datetime.pipe.ts +0 -21
  156. package/dateTime/src/georgian.calendar.ts +0 -205
  157. package/dateTime/src/jalali.calendar.ts +0 -416
  158. package/events/index.ts +0 -1
  159. package/events/ng-package.json +0 -6
  160. package/events/public-api.ts +0 -1
  161. package/events/src/event.service.ts +0 -31
  162. package/file/index.ts +0 -1
  163. package/file/ng-package.json +0 -7
  164. package/file/public-api.ts +0 -4
  165. package/file/src/file-download-ref.class.ts +0 -16
  166. package/file/src/file-download-result.class.ts +0 -56
  167. package/file/src/file-upload-ref.class.ts +0 -14
  168. package/file/src/file.service.ts +0 -104
  169. package/http/index.ts +0 -1
  170. package/http/ng-package.json +0 -6
  171. package/http/src/http-result.class.ts +0 -34
  172. package/http/src/http.module.ts +0 -25
  173. package/http/src/http.service.ts +0 -161
  174. package/image/index.ts +0 -1
  175. package/image/ng-package.json +0 -7
  176. package/image/public-api.ts +0 -1
  177. package/image/src/image.service.ts +0 -42
  178. package/index.ts +0 -1
  179. package/karma.conf.js +0 -44
  180. package/ng-package.json +0 -7
  181. package/pipes/index.ts +0 -1
  182. package/pipes/ng-package.json +0 -6
  183. package/pipes/public-api.ts +0 -2
  184. package/pipes/src/pipes.module.ts +0 -11
  185. package/pipes/src/safe.pipe.ts +0 -24
  186. package/platform/index.ts +0 -1
  187. package/platform/ng-package.json +0 -6
  188. package/platform/public-api.ts +0 -1
  189. package/platform/src/platform.service.ts +0 -223
  190. package/public-api.ts +0 -4
  191. package/test.ts +0 -27
  192. package/translation/index.ts +0 -1
  193. package/translation/ng-package.json +0 -6
  194. package/translation/src/translation.module.ts +0 -12
  195. package/translation/src/translator.pipe.ts +0 -9
  196. package/translation/src/translator.ts +0 -49
  197. package/tsconfig.lib.json +0 -15
  198. package/tsconfig.lib.prod.json +0 -10
  199. package/tsconfig.spec.json +0 -17
  200. package/utils/index.ts +0 -1
  201. package/utils/ng-package.json +0 -6
  202. package/utils/src/color-util.ts +0 -83
  203. package/utils/src/drawing-util.ts +0 -43
  204. package/utils/src/object-util.ts +0 -82
  205. package/utils/src/string-util.ts +0 -25
@@ -1,31 +0,0 @@
1
- import { Injectable } from '@angular/core';
2
-
3
- @Injectable({ providedIn: 'root' })
4
- export class AXEventService {
5
- private list: any[] = [];
6
-
7
- public broadcast(key: string, options?: any): void {
8
- const d = this.list.find(c => c.key === key);
9
- if (d) {
10
- d.events.forEach((c:any) => {
11
- c(options);
12
- });
13
- }
14
- }
15
-
16
- public on(key: string, callback: (options?: any) => void) {
17
- let d = this.list.find(c => c.key === key);
18
- if (!d) {
19
- d = { key, events: [] };
20
- this.list.push(d);
21
- }
22
- d.events.push(callback);
23
- }
24
-
25
- public destroy(key: string, callback: (options?: any) => void): void {
26
- const d = this.list.find(c => c.key === key);
27
- if (d) {
28
- d.events = [];
29
- }
30
- }
31
- }
package/file/index.ts DELETED
@@ -1 +0,0 @@
1
- export * from './public-api';
@@ -1,7 +0,0 @@
1
-
2
- {
3
- "$schema": "../../../../node_modules/ng-packagr/ng-package.schema.json",
4
- "lib": {
5
- "entryFile": "public-api.ts"
6
- }
7
- }
@@ -1,4 +0,0 @@
1
- export * from './src/file-download-ref.class';
2
- export * from './src/file-download-result.class';
3
- export * from './src/file-upload-ref.class';
4
- export * from './src/file.service';
@@ -1,16 +0,0 @@
1
- import { AXFileDownloadResult } from "./file-download-result.class";
2
-
3
- export class AXFileDownloadRef extends Promise<AXFileDownloadResult>
4
- {
5
- public abortMethod: () => void;
6
- constructor(executor: (resolve: (value?: PromiseLike<AXFileDownloadResult>) => void, reject: (reason?: any) => void) => void) {
7
- super(executor);
8
-
9
- }
10
- //abort the operation
11
- public abort() {
12
- if (this.abortMethod) {
13
- this.abortMethod();
14
- }
15
- }
16
- }
@@ -1,56 +0,0 @@
1
- export class AXFileDownloadResult {
2
-
3
- _response: Blob;
4
-
5
- constructor(response: Blob) {
6
- this._response = response;
7
- }
8
-
9
- save(filename?: string): Promise<void> {
10
- this._defaultBrowserDownload(filename);
11
- return Promise.resolve();
12
- // else {
13
- // return new Promise((resolve, reject) => {
14
- // const button = document.createElement("button");
15
- // button.addEventListener('click', async () => {
16
- // debugger
17
- // button.remove();
18
- // const opts = {
19
- // types: [{
20
- // description: 'Save File',
21
- // suggestedName: filename
22
- // // accept: {'text/plain': ['.txt']},
23
- // }],
24
- // };
25
- // const result = await window['showSaveFilePicker'](opts);
26
- // console.log(result);
27
-
28
- // resolve();
29
- // });
30
- // button.click();
31
- // });
32
-
33
- // }
34
- }
35
-
36
-
37
- blob() {
38
- return this._response;
39
- }
40
-
41
- base64(): Promise<string> {
42
- return new Promise((resolve, reject) => {
43
- var reader = new window.FileReader();
44
- reader.onloadend = () => resolve(reader.result as string);
45
- reader.onerror = (e) => reject(e);
46
- reader.readAsDataURL(this._response);
47
- })
48
- }
49
-
50
- private _defaultBrowserDownload(filename: string = 'download') {
51
- const link = document.createElement("a");
52
- link.href = URL.createObjectURL(this._response);
53
- link.download = filename;
54
- link.click();
55
- }
56
- }
@@ -1,14 +0,0 @@
1
- export class AXFileUploadRef<T = any> extends Promise<T>
2
- {
3
- public abortMethod: () => void;
4
- constructor(executor: (resolve: (value?: PromiseLike<T>) => void, reject: (reason?: any) => void) => void) {
5
- super(executor);
6
-
7
- }
8
- //abort the operation
9
- public abort() {
10
- if (this.abortMethod) {
11
- this.abortMethod();
12
- }
13
- }
14
- }
@@ -1,104 +0,0 @@
1
- import { HttpClient, HttpContext, HttpHeaders, HttpParams } from '@angular/common/http';
2
- import { Injectable } from '@angular/core';
3
- import { Observable, Subscription } from 'rxjs';
4
- import { AXFileDownloadRef } from './file-download-ref.class';
5
- import { AXFileDownloadResult } from './file-download-result.class';
6
- import { AXFileUploadRef } from './file-upload-ref.class';
7
-
8
-
9
- @Injectable({ providedIn: 'root' })
10
- export class AXFileService {
11
- constructor(private _httpClient: HttpClient) { }
12
-
13
- public download(request: string | Observable<Blob>): AXFileDownloadRef {
14
- let s: Subscription;
15
- const promiseFunc = (resolve, reject) => {
16
- //TODO: add custome http request
17
- //const headers = new HttpHeaders().set('authorization','Bearer '+token);
18
- let b: Observable<Blob>;
19
- if (typeof request === 'string') {
20
- b = this._httpClient.get(request, { responseType: 'blob' });
21
- }
22
- else if (b instanceof Observable<Blob>) {
23
- b = request;
24
- }
25
- s = b?.subscribe({
26
- next: (v) => resolve(new AXFileDownloadResult(v)),
27
- error: (e) => reject(e)
28
- })
29
- };
30
-
31
- const a = new AXFileDownloadRef(promiseFunc);
32
- a.abort = () => {
33
- s?.unsubscribe();
34
- };
35
-
36
- return a;
37
- }
38
-
39
- public upload<T = any>(url: string, files: File[]): AXFileUploadRef<T> {
40
- let s: Subscription;
41
- let formData = new FormData();
42
- files.forEach(f => {
43
- formData.append("files", f);
44
- })
45
- const promiseFunc = (resolve, reject) => {
46
- let b: Observable<T>;
47
- b = this._httpClient.post<T>(url, formData);
48
-
49
- s = b?.subscribe({
50
- next: (v) => resolve(v),
51
- error: (e) => reject(e)
52
- })
53
- };
54
-
55
- const a = new AXFileUploadRef(promiseFunc);
56
- a.abort = () => {
57
- s?.unsubscribe();
58
- };
59
- return a;
60
- }
61
-
62
- public choose(options?: { accept?: string, multiple?: boolean }): Promise<File[]> {
63
- return new Promise<File[]>((resolve, reject) => {
64
- options = Object.assign({ multiple: false }, options);
65
- const input = document.createElement("input");
66
- input.style.display = 'none';
67
- document.body.appendChild(input);
68
- input.type = 'file';
69
- input.accept = options.accept;
70
- input.multiple = options.multiple;
71
- //
72
- const onError = (e) => {
73
- reject(e);
74
- document.body.removeChild(input)
75
- input.remove();
76
- input.removeEventListener('change', onChange);
77
- input.removeEventListener('error', onError);
78
- }
79
- //
80
- const onChange = () => {
81
- resolve(Array.from(input.files));
82
- document.body.removeChild(input)
83
- input.remove();
84
- input.removeEventListener('change', onChange);
85
- input.removeEventListener('error', onError);
86
- }
87
- //
88
- input.addEventListener('change', onChange);
89
- input.addEventListener('error', onError);
90
- input.click();
91
- });
92
- }
93
-
94
- blobToBase64 = (blob: Blob) => new Promise<string>((resolve, reject) => {
95
- const reader = new FileReader;
96
- reader.onerror = reject;
97
- reader.onload = () => {
98
- resolve(reader.result as string);
99
- };
100
- reader.readAsDataURL(blob);
101
- });
102
- }
103
-
104
-
package/http/index.ts DELETED
@@ -1 +0,0 @@
1
- export * from './public-api'
@@ -1,6 +0,0 @@
1
- {
2
- "$schema": "../../../../node_modules/ng-packagr/ng-package.schema.json",
3
- "lib": {
4
- "entryFile": "public-api.ts"
5
- }
6
- }
@@ -1,34 +0,0 @@
1
- import { IHttpError } from './http-error.class';
2
-
3
- export class HttpResult<T> {
4
- private _executor: (result: (e?: T) => void, error: (e?: IHttpError) => void, complete: () => void) => void;
5
- constructor(
6
- executor: (
7
- result: (e?: T) => void,
8
- error: (e?: IHttpError) => void,
9
- complete: () => void
10
- ) => void
11
- ) {
12
- this._executor = executor;
13
- setTimeout(() => {
14
- this._executor(this.resultAction, this.errorAction, this.completeAction);
15
- }, 50);
16
- }
17
-
18
- private resultAction: (e?: T) => void;
19
- private errorAction: (e?: IHttpError) => void;
20
- private completeAction: () => void;
21
-
22
- result(action: (e?: T) => void): HttpResult<T> {
23
- this.resultAction = action;
24
- return this;
25
- }
26
- error(action: (e?: IHttpError) => void): HttpResult<T> {
27
- this.errorAction = action;
28
- return this;
29
- }
30
- complete(action: () => void): HttpResult<T> {
31
- this.completeAction = action;
32
- return this;
33
- }
34
- }
@@ -1,25 +0,0 @@
1
- import { NgModule, ModuleWithProviders } from '@angular/core';
2
- import { CommonModule } from '@angular/common';
3
- import { HttpClientModule } from '@angular/common/http';
4
- import { AXHttpService } from './http.service';
5
-
6
-
7
- @NgModule({
8
- declarations: [],
9
- imports: [
10
- CommonModule,
11
- HttpClientModule
12
- ],
13
- exports: [HttpClientModule],
14
- providers: [
15
- AXHttpService
16
- ]
17
- })
18
- export class AXHttpModule {
19
- // static forRoot(): ModuleWithProviders {
20
- // return {
21
- // ngModule: AXHttpModule,
22
- // providers: [AXHttpService]
23
- // };
24
- // }
25
- }
@@ -1,161 +0,0 @@
1
- import { Injectable, Injector, InjectFlags } from '@angular/core';
2
- import { HttpClient, HttpHeaders, HttpParams, HttpErrorResponse } from '@angular/common/http';
3
- import { HttpResult } from './http-result.class';
4
- import { IHttpError } from './http-error.class';
5
- import { AXHttpRequestOptions } from './http-request.class';
6
- import {
7
- AX_HTTP_EVENT_INTERCEPTOR, AXHttpEventInterceptor
8
- } from './http-events.interceptor';
9
- // import { catchError, retry, retryWhen, mergeMap, delay, switchMap, scan, takeWhile, flatMap } from 'rxjs/operators';
10
- // import { of, concat, throwError } from 'rxjs';
11
-
12
-
13
- @Injectable({ providedIn: 'root' })
14
- export class AXHttpService {
15
-
16
- private interceptor: AXHttpEventInterceptor;
17
- constructor(private http: HttpClient, private injector: Injector) {
18
- this.interceptor = this.injector.get(AX_HTTP_EVENT_INTERCEPTOR);
19
- }
20
-
21
-
22
- get<T>(url: string, config: AXHttpRequestOptions = {}): HttpResult<T> {
23
- config.url = url;
24
- config.method = "get";
25
- return this.request(config);
26
- }
27
-
28
- post<T>(url: string, config: AXHttpRequestOptions = {}): HttpResult<T> {
29
- config.url = url;
30
- config.method = "post";
31
- return this.request(config);
32
- }
33
-
34
- delete<T>(url: string, config: AXHttpRequestOptions = {}): HttpResult<T> {
35
- config.url = url;
36
- config.method = "delete";
37
- return this.request(config);
38
- }
39
-
40
- put<T>(url: string, config: AXHttpRequestOptions = {}): HttpResult<T> {
41
- config.url = url;
42
- config.method = "put";
43
- return this.request(config);
44
- }
45
-
46
-
47
- request<T>(config: AXHttpRequestOptions): HttpResult<T> {
48
- return new HttpResult<T>((result?, error?, complete?) => {
49
- this.handleBegin(config).then(c => {
50
- this.http
51
- //TODO: check ts error
52
- //@ts-ignore
53
- .request<T>(config.method, config.url, this.mapOptions(config))
54
- //.pipe(this.retry)
55
- .subscribe(data => {
56
- this.handleResult(data, result, complete, config);
57
- }, c => {
58
- this.handleError(c, error, complete, config);
59
- });
60
- });
61
- })
62
- }
63
-
64
-
65
- private handleResult(data, result, complete, config: AXHttpRequestOptions) {
66
- if (this.interceptor) {
67
- this.interceptor.success(config, data).then(c => {
68
- if (result)
69
- result(c);
70
- this.handleComplete(complete, config);
71
- });
72
- }
73
- else {
74
- //
75
- if (result)
76
- result(data);
77
- this.handleComplete(complete, config);
78
- }
79
- }
80
-
81
- private handleBegin(config: AXHttpRequestOptions): Promise<AXHttpRequestOptions> {
82
- return new Promise((resolve) => {
83
- if (!config.headers)
84
- config.headers = {};
85
- if (!config.params)
86
- config.params = {};
87
- //
88
- if (this.interceptor) {
89
- this.interceptor.begin(config).then(c => {
90
- resolve(c);
91
- });
92
- }
93
- else {
94
- resolve(config)
95
- }
96
- })
97
- }
98
-
99
- private handleComplete(complete: Function, config: AXHttpRequestOptions) {
100
- if (complete)
101
- complete();
102
- if (this.interceptor)
103
- this.interceptor.complete(config);
104
- }
105
-
106
- private handleError(c: HttpErrorResponse, error: Function, complete: Function, config: AXHttpRequestOptions) {
107
- let r: IHttpError = {
108
- message: c.message,
109
- status: c.status,
110
- code: c.status?.toString(),
111
- handled: false,
112
- error: c.error
113
- }
114
- if (error) {
115
- error(r);
116
- }
117
- if (!r.handled) {
118
- if (this.interceptor)
119
- this.interceptor.error(config, r);
120
- }
121
- this.handleComplete(complete, config);
122
- }
123
-
124
- private mapOptions(options: AXHttpRequestOptions) {
125
- let headers = new HttpHeaders();
126
-
127
- for (const key in options.headers) {
128
- if (options.headers.hasOwnProperty(key)) {
129
- const value = options.headers[key];
130
- headers = headers.set(key, value)
131
- }
132
- }
133
- let params = new HttpParams();
134
- for (const key in options.params) {
135
- if (options.params.hasOwnProperty(key)) {
136
- const value = options.params[key];
137
- params = params.set(key, value);
138
- }
139
- }
140
- return {
141
- headers: headers,
142
- params: params,
143
- body: options.body,
144
- responseType: options.responseType || 'json'
145
- };
146
- // if (options.method == "get") {
147
- // return {
148
- // headers: headers,
149
- // params: params
150
- // };
151
- // }
152
- // else {
153
- // return {
154
- // headers: headers,
155
- // params: params,
156
- // body: options.body
157
- // };
158
- // }
159
- }
160
-
161
- }
package/image/index.ts DELETED
@@ -1 +0,0 @@
1
- export * from './public-api';
@@ -1,7 +0,0 @@
1
-
2
- {
3
- "$schema": "../../../../node_modules/ng-packagr/ng-package.schema.json",
4
- "lib": {
5
- "entryFile": "public-api.ts"
6
- }
7
- }
@@ -1 +0,0 @@
1
- export * from './src/image.service';
@@ -1,42 +0,0 @@
1
- import { Injectable } from '@angular/core';
2
-
3
- @Injectable({ providedIn: 'root' })
4
- export class AXImageService {
5
- constructor() { }
6
-
7
-
8
- async resize(options: { maxSize: number, source: HTMLImageElement | File, type?: 'image/png' | 'image/jpeg' | 'image/webp', quality?: number }): Promise<Blob> {
9
- options = Object.assign({ type: 'image/png', quality: 1 }, options);
10
-
11
- let image: HTMLImageElement;
12
- if (options.source instanceof File) {
13
- var a = new Image()
14
- a.src = URL.createObjectURL(options.source);
15
- await new Promise<Event>((res) => a.onload = res);
16
- image = a;
17
- }
18
- else {
19
- image = options.source;
20
- }
21
-
22
- // Resize the image
23
- var canvas = document.createElement('canvas'),
24
- width = image.width,
25
- height = image.height;
26
- if (width > height) {
27
- if (width > options.maxSize) {
28
- height *= options.maxSize / width;
29
- width = options.maxSize;
30
- }
31
- } else {
32
- if (height > options.maxSize) {
33
- width *= options.maxSize / height;
34
- height = options.maxSize;
35
- }
36
- }
37
- canvas.width = width;
38
- canvas.height = height;
39
- canvas.getContext('2d').drawImage(image, 0, 0, width, height);
40
- return new Promise((resolve) => canvas.toBlob(resolve, options.type, options.quality));
41
- }
42
- }
package/index.ts DELETED
@@ -1 +0,0 @@
1
- export * from './public-api'
package/karma.conf.js DELETED
@@ -1,44 +0,0 @@
1
- // Karma configuration file, see link for more information
2
- // https://karma-runner.github.io/1.0/config/configuration-file.html
3
-
4
- module.exports = function (config) {
5
- config.set({
6
- basePath: '',
7
- frameworks: ['jasmine', '@angular-devkit/build-angular'],
8
- plugins: [
9
- require('karma-jasmine'),
10
- require('karma-chrome-launcher'),
11
- require('karma-jasmine-html-reporter'),
12
- require('karma-coverage'),
13
- require('@angular-devkit/build-angular/plugins/karma')
14
- ],
15
- client: {
16
- jasmine: {
17
- // you can add configuration options for Jasmine here
18
- // the possible options are listed at https://jasmine.github.io/api/edge/Configuration.html
19
- // for example, you can disable the random execution with `random: false`
20
- // or set a specific seed with `seed: 4321`
21
- },
22
- clearContext: false // leave Jasmine Spec Runner output visible in browser
23
- },
24
- jasmineHtmlReporter: {
25
- suppressAll: true // removes the duplicated traces
26
- },
27
- coverageReporter: {
28
- dir: require('path').join(__dirname, '../../../coverage/acorex/core'),
29
- subdir: '.',
30
- reporters: [
31
- { type: 'html' },
32
- { type: 'text-summary' }
33
- ]
34
- },
35
- reporters: ['progress', 'kjhtml'],
36
- port: 9876,
37
- colors: true,
38
- logLevel: config.LOG_INFO,
39
- autoWatch: true,
40
- browsers: ['Chrome'],
41
- singleRun: false,
42
- restartOnFileChange: true
43
- });
44
- };
package/ng-package.json DELETED
@@ -1,7 +0,0 @@
1
- {
2
- "$schema": "../../../node_modules/ng-packagr/ng-package.schema.json",
3
- "dest": "../../../dist/acorex/core",
4
- "lib": {
5
- "entryFile": "public-api.ts"
6
- }
7
- }
package/pipes/index.ts DELETED
@@ -1 +0,0 @@
1
- export * from './public-api'
@@ -1,6 +0,0 @@
1
- {
2
- "$schema": "../../../../node_modules/ng-packagr/ng-package.schema.json",
3
- "lib": {
4
- "entryFile": "public-api.ts"
5
- }
6
- }
@@ -1,2 +0,0 @@
1
- export * from './src/safe.pipe'
2
- export * from './src/pipes.module'
@@ -1,11 +0,0 @@
1
- import { NgModule } from '@angular/core';
2
- import { CommonModule } from '@angular/common';
3
- import { AXSafePipe } from './safe.pipe';
4
-
5
- @NgModule({
6
- declarations: [AXSafePipe],
7
- imports: [CommonModule],
8
- exports: [AXSafePipe],
9
- providers: [],
10
- })
11
- export class AXPipesModule {}
@@ -1,24 +0,0 @@
1
- import { Pipe, PipeTransform } from '@angular/core';
2
- import { DomSanitizer, SafeHtml, SafeStyle, SafeScript, SafeUrl, SafeResourceUrl } from '@angular/platform-browser';
3
-
4
- @Pipe({
5
- name: 'safe',
6
- pure: true
7
- })
8
- export class AXSafePipe implements PipeTransform {
9
-
10
- constructor(protected sanitizer: DomSanitizer) { }
11
-
12
- public transform(value: any, type: string): SafeHtml | SafeStyle | SafeScript | SafeUrl | SafeResourceUrl {
13
- if (value == null || value == undefined || value == '')
14
- return '';
15
- switch (type) {
16
- case 'html': return this.sanitizer.bypassSecurityTrustHtml(value);
17
- case 'style': return this.sanitizer.bypassSecurityTrustStyle(value);
18
- case 'script': return this.sanitizer.bypassSecurityTrustScript(value);
19
- case 'url': return this.sanitizer.bypassSecurityTrustUrl(value);
20
- case 'resourceUrl': return this.sanitizer.bypassSecurityTrustResourceUrl(value);
21
- default: throw new Error(`Invalid safe type specified: ${type}`);
22
- }
23
- }
24
- }
package/platform/index.ts DELETED
@@ -1 +0,0 @@
1
- export * from './public-api'
@@ -1,6 +0,0 @@
1
- {
2
- "$schema": "../../../../node_modules/ng-packagr/ng-package.schema.json",
3
- "lib": {
4
- "entryFile": "public-api.ts"
5
- }
6
- }
@@ -1 +0,0 @@
1
- export * from './src/platform.service';