@acorex/core 7.0.19 → 7.0.20
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/ax-preset.js +186 -0
- package/config/index.ts +1 -0
- package/config/ng-package.json +6 -0
- package/config/public-api.ts +1 -0
- package/config/src/configs.ts +37 -0
- package/dateTime/index.ts +1 -0
- package/dateTime/ng-package.json +6 -0
- package/dateTime/{public-api.d.ts → public-api.ts} +1 -1
- package/dateTime/src/datetime.class.ts +449 -0
- package/dateTime/src/datetime.module.ts +35 -0
- package/dateTime/src/datetime.pipe.ts +21 -0
- package/dateTime/src/georgian.calendar.ts +205 -0
- package/dateTime/src/jalali.calendar.ts +416 -0
- package/events/index.ts +1 -0
- package/events/ng-package.json +6 -0
- package/events/public-api.ts +1 -0
- package/events/src/event.service.ts +31 -0
- package/file/index.ts +1 -0
- package/file/ng-package.json +7 -0
- package/file/public-api.ts +4 -0
- package/file/src/file-download-ref.class.ts +16 -0
- package/file/src/file-download-result.class.ts +56 -0
- package/file/src/file-upload-ref.class.ts +14 -0
- package/file/src/file.service.ts +104 -0
- package/http/index.ts +1 -0
- package/http/ng-package.json +6 -0
- package/http/{public-api.d.ts → public-api.ts} +1 -1
- package/http/src/{http-error.class.d.ts → http-error.class.ts} +2 -2
- package/http/src/{http-events.interceptor.d.ts → http-events.interceptor.ts} +7 -3
- package/http/src/{http-request.class.d.ts → http-request.class.ts} +5 -5
- package/http/src/http-result.class.ts +34 -0
- package/http/src/http.module.ts +25 -0
- package/http/src/http.service.ts +161 -0
- package/image/index.ts +1 -0
- package/image/ng-package.json +7 -0
- package/image/public-api.ts +1 -0
- package/image/src/image.service.ts +42 -0
- package/index.ts +1 -0
- package/karma.conf.js +44 -0
- package/ng-package.json +7 -0
- package/package.json +16 -115
- package/pipes/index.ts +1 -0
- package/pipes/ng-package.json +6 -0
- package/pipes/public-api.ts +2 -0
- package/pipes/src/pipes.module.ts +11 -0
- package/pipes/src/safe.pipe.ts +24 -0
- package/platform/index.ts +1 -0
- package/platform/ng-package.json +6 -0
- package/platform/public-api.ts +1 -0
- package/platform/src/platform.service.ts +223 -0
- package/public-api.ts +4 -0
- package/test.ts +27 -0
- package/translation/index.ts +1 -0
- package/translation/ng-package.json +6 -0
- package/translation/{public-api.d.ts → public-api.ts} +1 -1
- package/translation/src/translation.module.ts +12 -0
- package/translation/src/translator.pipe.ts +9 -0
- package/translation/src/translator.ts +49 -0
- package/tsconfig.lib.json +15 -0
- package/tsconfig.lib.prod.json +10 -0
- package/tsconfig.spec.json +17 -0
- package/utils/index.ts +1 -0
- package/utils/ng-package.json +6 -0
- package/utils/{public-api.d.ts → public-api.ts} +1 -1
- package/utils/src/color-util.ts +83 -0
- package/utils/src/drawing-util.ts +43 -0
- package/utils/src/object-util.ts +82 -0
- package/utils/src/string-util.ts +25 -0
- package/config/index.d.ts +0 -5
- package/config/public-api.d.ts +0 -1
- package/config/src/configs.d.ts +0 -9
- package/dateTime/index.d.ts +0 -5
- package/dateTime/src/datetime.class.d.ts +0 -100
- package/dateTime/src/datetime.module.d.ts +0 -8
- package/dateTime/src/datetime.pipe.d.ts +0 -8
- package/dateTime/src/georgian.calendar.d.ts +0 -20
- package/dateTime/src/jalali.calendar.d.ts +0 -35
- package/esm2020/acorex-core.mjs +0 -5
- package/esm2020/config/acorex-core-config.mjs +0 -5
- package/esm2020/config/public-api.mjs +0 -2
- package/esm2020/config/src/configs.mjs +0 -32
- package/esm2020/dateTime/acorex-core-dateTime.mjs +0 -5
- package/esm2020/dateTime/public-api.mjs +0 -6
- package/esm2020/dateTime/src/datetime.class.mjs +0 -288
- package/esm2020/dateTime/src/datetime.module.mjs +0 -39
- package/esm2020/dateTime/src/datetime.pipe.mjs +0 -26
- package/esm2020/dateTime/src/georgian.calendar.mjs +0 -189
- package/esm2020/dateTime/src/jalali.calendar.mjs +0 -359
- package/esm2020/events/acorex-core-events.mjs +0 -5
- package/esm2020/events/public-api.mjs +0 -2
- package/esm2020/events/src/event.service.mjs +0 -36
- package/esm2020/file/acorex-core-file.mjs +0 -5
- package/esm2020/file/public-api.mjs +0 -5
- package/esm2020/file/src/file-download-ref.class.mjs +0 -12
- package/esm2020/file/src/file-download-result.class.mjs +0 -47
- package/esm2020/file/src/file-upload-ref.class.mjs +0 -12
- package/esm2020/file/src/file.service.mjs +0 -101
- package/esm2020/http/acorex-core-http.mjs +0 -5
- package/esm2020/http/public-api.mjs +0 -6
- package/esm2020/http/src/http-error.class.mjs +0 -2
- package/esm2020/http/src/http-events.interceptor.mjs +0 -3
- package/esm2020/http/src/http-request.class.mjs +0 -2
- package/esm2020/http/src/http-result.class.mjs +0 -21
- package/esm2020/http/src/http.module.mjs +0 -29
- package/esm2020/http/src/http.service.mjs +0 -148
- package/esm2020/image/acorex-core-image.mjs +0 -5
- package/esm2020/image/public-api.mjs +0 -2
- package/esm2020/image/src/image.service.mjs +0 -43
- package/esm2020/pipes/acorex-core-pipes.mjs +0 -5
- package/esm2020/pipes/public-api.mjs +0 -3
- package/esm2020/pipes/src/pipes.module.mjs +0 -19
- package/esm2020/pipes/src/safe.pipe.mjs +0 -30
- package/esm2020/platform/acorex-core-platform.mjs +0 -5
- package/esm2020/platform/public-api.mjs +0 -2
- package/esm2020/platform/src/platform.service.mjs +0 -153
- package/esm2020/public-api.mjs +0 -5
- package/esm2020/translation/acorex-core-translation.mjs +0 -5
- package/esm2020/translation/public-api.mjs +0 -4
- package/esm2020/translation/src/translation.module.mjs +0 -18
- package/esm2020/translation/src/translator.mjs +0 -43
- package/esm2020/translation/src/translator.pipe.mjs +0 -15
- package/esm2020/utils/acorex-core-utils.mjs +0 -5
- package/esm2020/utils/public-api.mjs +0 -5
- package/esm2020/utils/src/color-util.mjs +0 -71
- package/esm2020/utils/src/drawing-util.mjs +0 -27
- package/esm2020/utils/src/object-util.mjs +0 -39
- package/esm2020/utils/src/string-util.mjs +0 -19
- package/events/index.d.ts +0 -5
- package/events/public-api.d.ts +0 -1
- package/events/src/event.service.d.ts +0 -9
- package/fesm2015/acorex-core-config.mjs +0 -40
- package/fesm2015/acorex-core-config.mjs.map +0 -1
- package/fesm2015/acorex-core-dateTime.mjs +0 -899
- package/fesm2015/acorex-core-dateTime.mjs.map +0 -1
- package/fesm2015/acorex-core-events.mjs +0 -44
- package/fesm2015/acorex-core-events.mjs.map +0 -1
- package/fesm2015/acorex-core-file.mjs +0 -177
- package/fesm2015/acorex-core-file.mjs.map +0 -1
- package/fesm2015/acorex-core-http.mjs +0 -203
- package/fesm2015/acorex-core-http.mjs.map +0 -1
- package/fesm2015/acorex-core-image.mjs +0 -54
- package/fesm2015/acorex-core-image.mjs.map +0 -1
- package/fesm2015/acorex-core-pipes.mjs +0 -54
- package/fesm2015/acorex-core-pipes.mjs.map +0 -1
- package/fesm2015/acorex-core-platform.mjs +0 -161
- package/fesm2015/acorex-core-platform.mjs.map +0 -1
- package/fesm2015/acorex-core-translation.mjs +0 -81
- package/fesm2015/acorex-core-translation.mjs.map +0 -1
- package/fesm2015/acorex-core-utils.mjs +0 -164
- package/fesm2015/acorex-core-utils.mjs.map +0 -1
- package/fesm2015/acorex-core.mjs +0 -12
- package/fesm2015/acorex-core.mjs.map +0 -1
- package/fesm2020/acorex-core-config.mjs +0 -40
- package/fesm2020/acorex-core-config.mjs.map +0 -1
- package/fesm2020/acorex-core-dateTime.mjs +0 -899
- package/fesm2020/acorex-core-dateTime.mjs.map +0 -1
- package/fesm2020/acorex-core-events.mjs +0 -44
- package/fesm2020/acorex-core-events.mjs.map +0 -1
- package/fesm2020/acorex-core-file.mjs +0 -177
- package/fesm2020/acorex-core-file.mjs.map +0 -1
- package/fesm2020/acorex-core-http.mjs +0 -202
- package/fesm2020/acorex-core-http.mjs.map +0 -1
- package/fesm2020/acorex-core-image.mjs +0 -51
- package/fesm2020/acorex-core-image.mjs.map +0 -1
- package/fesm2020/acorex-core-pipes.mjs +0 -54
- package/fesm2020/acorex-core-pipes.mjs.map +0 -1
- package/fesm2020/acorex-core-platform.mjs +0 -161
- package/fesm2020/acorex-core-platform.mjs.map +0 -1
- package/fesm2020/acorex-core-translation.mjs +0 -80
- package/fesm2020/acorex-core-translation.mjs.map +0 -1
- package/fesm2020/acorex-core-utils.mjs +0 -164
- package/fesm2020/acorex-core-utils.mjs.map +0 -1
- package/fesm2020/acorex-core.mjs +0 -12
- package/fesm2020/acorex-core.mjs.map +0 -1
- package/file/index.d.ts +0 -5
- package/file/public-api.d.ts +0 -4
- package/file/src/file-download-ref.class.d.ts +0 -6
- package/file/src/file-download-result.class.d.ts +0 -8
- package/file/src/file-upload-ref.class.d.ts +0 -5
- package/file/src/file.service.d.ts +0 -18
- package/http/index.d.ts +0 -5
- package/http/src/http-result.class.d.ts +0 -11
- package/http/src/http.module.d.ts +0 -8
- package/http/src/http.service.d.ts +0 -23
- package/image/index.d.ts +0 -5
- package/image/public-api.d.ts +0 -1
- package/image/src/image.service.d.ts +0 -12
- package/index.d.ts +0 -5
- package/pipes/index.d.ts +0 -5
- package/pipes/public-api.d.ts +0 -2
- package/pipes/src/pipes.module.d.ts +0 -8
- package/pipes/src/safe.pipe.d.ts +0 -10
- package/platform/index.d.ts +0 -5
- package/platform/public-api.d.ts +0 -1
- package/platform/src/platform.service.d.ts +0 -26
- package/public-api.d.ts +0 -1
- package/translation/index.d.ts +0 -5
- package/translation/src/translation.module.d.ts +0 -7
- package/translation/src/translator.d.ts +0 -11
- package/translation/src/translator.pipe.d.ts +0 -7
- package/utils/index.d.ts +0 -5
- package/utils/src/color-util.d.ts +0 -20
- package/utils/src/drawing-util.d.ts +0 -17
- package/utils/src/object-util.d.ts +0 -4
- package/utils/src/string-util.d.ts +0 -6
@@ -1,10 +1,14 @@
|
|
1
1
|
import { IHttpError } from './http-error.class';
|
2
2
|
import { InjectionToken } from '@angular/core';
|
3
3
|
import { AXHttpRequestOptions } from './http-request.class';
|
4
|
-
|
4
|
+
|
5
|
+
export const AX_HTTP_EVENT_INTERCEPTOR = new InjectionToken<AXHttpEventInterceptor>('ax.http.events');
|
6
|
+
|
5
7
|
export interface AXHttpEventInterceptor {
|
6
8
|
begin(request: AXHttpRequestOptions): Promise<AXHttpRequestOptions>;
|
7
9
|
success(request: AXHttpRequestOptions, result: any): Promise<any>;
|
8
|
-
complete(request: AXHttpRequestOptions)
|
9
|
-
error(request: AXHttpRequestOptions, error: IHttpError)
|
10
|
+
complete(request: AXHttpRequestOptions);
|
11
|
+
error(request: AXHttpRequestOptions, error: IHttpError);
|
10
12
|
}
|
13
|
+
|
14
|
+
|
@@ -1,14 +1,14 @@
|
|
1
1
|
export interface AXHttpRequestOptions {
|
2
|
-
url?: any
|
2
|
+
url?: any,
|
3
3
|
params?: {
|
4
4
|
[param: string]: any;
|
5
|
-
}
|
5
|
+
},
|
6
6
|
body?: {
|
7
7
|
[param: string]: any;
|
8
|
-
}
|
8
|
+
},
|
9
9
|
headers?: {
|
10
10
|
[header: string]: any;
|
11
|
-
}
|
11
|
+
},
|
12
12
|
method?: 'get' | 'post' | 'put' | 'delete';
|
13
13
|
responseType?: any;
|
14
|
-
}
|
14
|
+
}
|
@@ -0,0 +1,34 @@
|
|
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
|
+
}
|
@@ -0,0 +1,25 @@
|
|
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
|
+
}
|
@@ -0,0 +1,161 @@
|
|
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
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
export * from './public-api';
|
@@ -0,0 +1 @@
|
|
1
|
+
export * from './src/image.service';
|
@@ -0,0 +1,42 @@
|
|
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
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
export * from './public-api'
|
package/karma.conf.js
ADDED
@@ -0,0 +1,44 @@
|
|
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
ADDED
package/package.json
CHANGED
@@ -1,115 +1,16 @@
|
|
1
|
-
{
|
2
|
-
"name": "@acorex/core",
|
3
|
-
"version": "7.0.
|
4
|
-
"dependencies": {
|
5
|
-
"tslib": "^2.3.0"
|
6
|
-
},
|
7
|
-
"
|
8
|
-
|
9
|
-
"@angular/
|
10
|
-
"
|
11
|
-
"
|
12
|
-
"
|
13
|
-
|
14
|
-
|
15
|
-
"
|
16
|
-
|
17
|
-
"esm2020": "esm2020/acorex-core.mjs",
|
18
|
-
"fesm2020": "fesm2020/acorex-core.mjs",
|
19
|
-
"fesm2015": "fesm2015/acorex-core.mjs",
|
20
|
-
"typings": "index.d.ts",
|
21
|
-
"exports": {
|
22
|
-
"./package.json": {
|
23
|
-
"default": "./package.json"
|
24
|
-
},
|
25
|
-
".": {
|
26
|
-
"types": "./index.d.ts",
|
27
|
-
"esm2020": "./esm2020/acorex-core.mjs",
|
28
|
-
"es2020": "./fesm2020/acorex-core.mjs",
|
29
|
-
"es2015": "./fesm2015/acorex-core.mjs",
|
30
|
-
"node": "./fesm2015/acorex-core.mjs",
|
31
|
-
"default": "./fesm2020/acorex-core.mjs"
|
32
|
-
},
|
33
|
-
"./config": {
|
34
|
-
"types": "./config/index.d.ts",
|
35
|
-
"esm2020": "./esm2020/config/acorex-core-config.mjs",
|
36
|
-
"es2020": "./fesm2020/acorex-core-config.mjs",
|
37
|
-
"es2015": "./fesm2015/acorex-core-config.mjs",
|
38
|
-
"node": "./fesm2015/acorex-core-config.mjs",
|
39
|
-
"default": "./fesm2020/acorex-core-config.mjs"
|
40
|
-
},
|
41
|
-
"./dateTime": {
|
42
|
-
"types": "./dateTime/index.d.ts",
|
43
|
-
"esm2020": "./esm2020/dateTime/acorex-core-dateTime.mjs",
|
44
|
-
"es2020": "./fesm2020/acorex-core-dateTime.mjs",
|
45
|
-
"es2015": "./fesm2015/acorex-core-dateTime.mjs",
|
46
|
-
"node": "./fesm2015/acorex-core-dateTime.mjs",
|
47
|
-
"default": "./fesm2020/acorex-core-dateTime.mjs"
|
48
|
-
},
|
49
|
-
"./events": {
|
50
|
-
"types": "./events/index.d.ts",
|
51
|
-
"esm2020": "./esm2020/events/acorex-core-events.mjs",
|
52
|
-
"es2020": "./fesm2020/acorex-core-events.mjs",
|
53
|
-
"es2015": "./fesm2015/acorex-core-events.mjs",
|
54
|
-
"node": "./fesm2015/acorex-core-events.mjs",
|
55
|
-
"default": "./fesm2020/acorex-core-events.mjs"
|
56
|
-
},
|
57
|
-
"./file": {
|
58
|
-
"types": "./file/index.d.ts",
|
59
|
-
"esm2020": "./esm2020/file/acorex-core-file.mjs",
|
60
|
-
"es2020": "./fesm2020/acorex-core-file.mjs",
|
61
|
-
"es2015": "./fesm2015/acorex-core-file.mjs",
|
62
|
-
"node": "./fesm2015/acorex-core-file.mjs",
|
63
|
-
"default": "./fesm2020/acorex-core-file.mjs"
|
64
|
-
},
|
65
|
-
"./http": {
|
66
|
-
"types": "./http/index.d.ts",
|
67
|
-
"esm2020": "./esm2020/http/acorex-core-http.mjs",
|
68
|
-
"es2020": "./fesm2020/acorex-core-http.mjs",
|
69
|
-
"es2015": "./fesm2015/acorex-core-http.mjs",
|
70
|
-
"node": "./fesm2015/acorex-core-http.mjs",
|
71
|
-
"default": "./fesm2020/acorex-core-http.mjs"
|
72
|
-
},
|
73
|
-
"./image": {
|
74
|
-
"types": "./image/index.d.ts",
|
75
|
-
"esm2020": "./esm2020/image/acorex-core-image.mjs",
|
76
|
-
"es2020": "./fesm2020/acorex-core-image.mjs",
|
77
|
-
"es2015": "./fesm2015/acorex-core-image.mjs",
|
78
|
-
"node": "./fesm2015/acorex-core-image.mjs",
|
79
|
-
"default": "./fesm2020/acorex-core-image.mjs"
|
80
|
-
},
|
81
|
-
"./pipes": {
|
82
|
-
"types": "./pipes/index.d.ts",
|
83
|
-
"esm2020": "./esm2020/pipes/acorex-core-pipes.mjs",
|
84
|
-
"es2020": "./fesm2020/acorex-core-pipes.mjs",
|
85
|
-
"es2015": "./fesm2015/acorex-core-pipes.mjs",
|
86
|
-
"node": "./fesm2015/acorex-core-pipes.mjs",
|
87
|
-
"default": "./fesm2020/acorex-core-pipes.mjs"
|
88
|
-
},
|
89
|
-
"./platform": {
|
90
|
-
"types": "./platform/index.d.ts",
|
91
|
-
"esm2020": "./esm2020/platform/acorex-core-platform.mjs",
|
92
|
-
"es2020": "./fesm2020/acorex-core-platform.mjs",
|
93
|
-
"es2015": "./fesm2015/acorex-core-platform.mjs",
|
94
|
-
"node": "./fesm2015/acorex-core-platform.mjs",
|
95
|
-
"default": "./fesm2020/acorex-core-platform.mjs"
|
96
|
-
},
|
97
|
-
"./translation": {
|
98
|
-
"types": "./translation/index.d.ts",
|
99
|
-
"esm2020": "./esm2020/translation/acorex-core-translation.mjs",
|
100
|
-
"es2020": "./fesm2020/acorex-core-translation.mjs",
|
101
|
-
"es2015": "./fesm2015/acorex-core-translation.mjs",
|
102
|
-
"node": "./fesm2015/acorex-core-translation.mjs",
|
103
|
-
"default": "./fesm2020/acorex-core-translation.mjs"
|
104
|
-
},
|
105
|
-
"./utils": {
|
106
|
-
"types": "./utils/index.d.ts",
|
107
|
-
"esm2020": "./esm2020/utils/acorex-core-utils.mjs",
|
108
|
-
"es2020": "./fesm2020/acorex-core-utils.mjs",
|
109
|
-
"es2015": "./fesm2015/acorex-core-utils.mjs",
|
110
|
-
"node": "./fesm2015/acorex-core-utils.mjs",
|
111
|
-
"default": "./fesm2020/acorex-core-utils.mjs"
|
112
|
-
}
|
113
|
-
},
|
114
|
-
"sideEffects": false
|
115
|
-
}
|
1
|
+
{
|
2
|
+
"name": "@acorex/core",
|
3
|
+
"version": "7.0.20",
|
4
|
+
"dependencies": {
|
5
|
+
"tslib": "^2.3.0"
|
6
|
+
},
|
7
|
+
"ngPackage": {},
|
8
|
+
"peerDependencies": {
|
9
|
+
"@angular/common": "^15.0.4",
|
10
|
+
"@angular/core": "^15.0.4",
|
11
|
+
"lodash-es": "^4.17.21",
|
12
|
+
"tinycolor2": "^1.4.2",
|
13
|
+
"tinygradient": "^1.1.5"
|
14
|
+
},
|
15
|
+
"peerDependenciesMeta": {}
|
16
|
+
}
|
package/pipes/index.ts
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
export * from './public-api'
|
@@ -0,0 +1,11 @@
|
|
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 {}
|
@@ -0,0 +1,24 @@
|
|
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
|
+
}
|
@@ -0,0 +1 @@
|
|
1
|
+
export * from './public-api'
|
@@ -0,0 +1 @@
|
|
1
|
+
export * from './src/platform.service';
|