@ldu-anguboot/app 0.5.0

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.
@@ -0,0 +1,113 @@
1
+ import * as i0 from '@angular/core';
2
+ import { inject, Injectable } from '@angular/core';
3
+ import { DomSanitizer } from '@angular/platform-browser';
4
+ import { Router } from '@angular/router';
5
+
6
+ class LDuAnguBootAppService {
7
+ router$ = inject(Router);
8
+ sanitizer$ = inject(DomSanitizer);
9
+ console$ = console;
10
+ document$ = document;
11
+ sessionStorage$ = sessionStorage;
12
+ localStorage$ = localStorage;
13
+ location$ = location;
14
+ onInit() {
15
+ const appRoot = this.document.getElementsByTagName('app-root')[0]
16
+ || this.document.getElementById('app-root')
17
+ || this.document.getElementsByClassName('app-root')[0];
18
+ appRoot?.classList.remove('app-root');
19
+ appRoot?.removeAttribute('id');
20
+ appRoot?.removeAttribute('ng-version');
21
+ const noscriptItem = this.document.getElementsByTagName('noscript')[0];
22
+ noscriptItem?.remove();
23
+ const routerOutlets = this.document.getElementsByTagName('router-outlet');
24
+ for (const element of routerOutlets) {
25
+ element.remove();
26
+ }
27
+ const outdatedBrowserItem = this.document.getElementById('outdated');
28
+ if (outdatedBrowserItem) {
29
+ const styles = globalThis.getComputedStyle(outdatedBrowserItem);
30
+ if (styles.display === 'none') {
31
+ const outdatedBrowserElement = this.document.getElementsByTagName('outdated-browser')[0];
32
+ outdatedBrowserElement?.remove();
33
+ }
34
+ }
35
+ }
36
+ safeHtml(value) {
37
+ return this.sanitizer.bypassSecurityTrustHtml(value);
38
+ }
39
+ safeUrl(value) {
40
+ return this.sanitizer.bypassSecurityTrustUrl(value);
41
+ }
42
+ safeResourceUrl(value) {
43
+ return this.sanitizer.bypassSecurityTrustResourceUrl(value);
44
+ }
45
+ checkStorageItem(key) {
46
+ return !!this.getStorageItem(key);
47
+ }
48
+ getStorageItem(key) {
49
+ const value = this.sessionStorage.getItem(key) ?? this.localStorage.getItem(key);
50
+ if (value) {
51
+ return JSON.parse(value);
52
+ }
53
+ return null;
54
+ }
55
+ setLocalStorageItem(key, value) {
56
+ this.localStorage.setItem(key, JSON.stringify(value ?? 'N/A'));
57
+ }
58
+ setSessionStorageItem(key, value) {
59
+ this.sessionStorage.setItem(key, JSON.stringify(value ?? 'N/A'));
60
+ }
61
+ static format(date, { fDate = true, fTime = true, fTimeShort = false, fTimeMs = false, } = {}) {
62
+ const y = date.getFullYear();
63
+ const year = y < 1970 ? `1970` : y;
64
+ const m = date.getMonth() + 1;
65
+ const month = m < 10 ? `0${m}` : m;
66
+ const d = date.getDate() + 1;
67
+ const day = d < 10 ? `0${d}` : d;
68
+ const h = date.getHours() + 1;
69
+ const hours = h < 10 ? `0${h}` : h;
70
+ const min = date.getMinutes() + 1;
71
+ const minutes = min < 10 ? `0${min}` : min;
72
+ const s = date.getSeconds() + 1;
73
+ const seconds = s < 10 ? `0${s}` : s;
74
+ const ms = date.getMilliseconds() + 1;
75
+ const milliseconds = ms < 10 ? `0${ms}` : ms;
76
+ let formatted = '';
77
+ if (fDate) {
78
+ formatted += `${year}-${month}-${day}`;
79
+ }
80
+ if (fTime) {
81
+ if (fTimeShort) {
82
+ formatted += ` ${hours}:${minutes}`;
83
+ }
84
+ else if (fTimeMs) {
85
+ formatted += ` ${hours}:${minutes}:${seconds}.${milliseconds}`;
86
+ }
87
+ else {
88
+ formatted += ` ${hours}:${minutes}:${seconds}`;
89
+ }
90
+ }
91
+ return formatted;
92
+ }
93
+ get sanitizer() { return this.sanitizer$; }
94
+ get router() { return this.router$; }
95
+ get console() { return this.console$; }
96
+ get document() { return this.document$; }
97
+ get sessionStorage() { return this.sessionStorage$; }
98
+ get localStorage() { return this.localStorage$; }
99
+ get location() { return this.location$; }
100
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.5", ngImport: i0, type: LDuAnguBootAppService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
101
+ static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.1.5", ngImport: i0, type: LDuAnguBootAppService, providedIn: 'root' });
102
+ }
103
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.5", ngImport: i0, type: LDuAnguBootAppService, decorators: [{
104
+ type: Injectable,
105
+ args: [{ providedIn: 'root' }]
106
+ }] });
107
+
108
+ /**
109
+ * Generated bundle index. Do not edit.
110
+ */
111
+
112
+ export { LDuAnguBootAppService };
113
+ //# sourceMappingURL=ldu-anguboot-app.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ldu-anguboot-app.mjs","sources":["../../lib/src/services/ldu-anguboot-app.service.ts","../../lib/src/ldu-anguboot-app.ts"],"sourcesContent":["import { inject, Injectable } from '@angular/core';\nimport { DomSanitizer, SafeHtml, SafeResourceUrl, SafeUrl } from '@angular/platform-browser';\nimport { Router } from '@angular/router';\n\n@Injectable({ providedIn: 'root' })\nexport class LDuAnguBootAppService {\n\n private readonly router$ = inject(Router);\n\n private readonly sanitizer$ = inject(DomSanitizer);\n\n private readonly console$ = console;\n\n private readonly document$ = document;\n\n private readonly sessionStorage$ = sessionStorage;\n\n private readonly localStorage$ = localStorage;\n\n private readonly location$ = location;\n\n public onInit(): void {\n const appRoot = this.document.getElementsByTagName('app-root')[0]\n || this.document.getElementById('app-root')\n || this.document.getElementsByClassName('app-root')[0];\n\n appRoot?.classList.remove('app-root');\n appRoot?.removeAttribute('id');\n appRoot?.removeAttribute('ng-version');\n\n const noscriptItem = this.document.getElementsByTagName('noscript')[0];\n noscriptItem?.remove();\n\n const routerOutlets = this.document.getElementsByTagName('router-outlet');\n for (const element of routerOutlets) {\n element.remove();\n }\n\n const outdatedBrowserItem = this.document.getElementById('outdated');\n if (outdatedBrowserItem) {\n const styles = globalThis.getComputedStyle(outdatedBrowserItem);\n if (styles.display === 'none') {\n const outdatedBrowserElement = this.document.getElementsByTagName('outdated-browser')[0];\n outdatedBrowserElement?.remove();\n }\n }\n }\n\n public safeHtml(value: string): SafeHtml {\n return this.sanitizer.bypassSecurityTrustHtml(value);\n }\n\n public safeUrl(value: string): SafeUrl {\n return this.sanitizer.bypassSecurityTrustUrl(value);\n }\n\n public safeResourceUrl(value: string): SafeResourceUrl {\n return this.sanitizer.bypassSecurityTrustResourceUrl(value);\n }\n\n public checkStorageItem(key: string): boolean {\n return !!this.getStorageItem(key);\n }\n\n public getStorageItem<T>(key: string): T | null {\n const value = this.sessionStorage.getItem(key) ?? this.localStorage.getItem(key);\n if (value) {\n return JSON.parse(value) as T;\n }\n return null;\n }\n\n public setLocalStorageItem(key: string, value: any): void {\n this.localStorage.setItem(key, JSON.stringify(value ?? 'N/A'));\n }\n\n public setSessionStorageItem(key: string, value: any): void {\n this.sessionStorage.setItem(key, JSON.stringify(value ?? 'N/A'));\n }\n\n public static format(date: Date, {\n fDate = true,\n fTime = true,\n fTimeShort = false,\n fTimeMs = false,\n } = {}): string {\n const y = date.getFullYear();\n const year = y < 1970 ? `1970` : y;\n const m = date.getMonth() + 1;\n const month = m < 10 ? `0${m}` : m;\n const d = date.getDate() + 1;\n const day = d < 10 ? `0${d}` : d;\n const h = date.getHours() + 1;\n const hours = h < 10 ? `0${h}` : h;\n const min = date.getMinutes() + 1;\n const minutes = min < 10 ? `0${min}` : min;\n const s = date.getSeconds() + 1;\n const seconds = s < 10 ? `0${s}` : s;\n const ms = date.getMilliseconds() + 1;\n const milliseconds = ms < 10 ? `0${ms}` : ms;\n let formatted = '';\n if (fDate) {\n formatted += `${year}-${month}-${day}`;\n }\n if (fTime) {\n if (fTimeShort) {\n formatted += ` ${hours}:${minutes}`;\n } else if (fTimeMs) {\n formatted += ` ${hours}:${minutes}:${seconds}.${milliseconds}`;\n } else {\n formatted += ` ${hours}:${minutes}:${seconds}`;\n }\n }\n return formatted;\n }\n\n public get sanitizer(): DomSanitizer { return this.sanitizer$; }\n\n public get router(): Router { return this.router$; }\n\n public get console(): Console { return this.console$; }\n\n public get document(): Document { return this.document$; }\n\n public get sessionStorage(): Storage { return this.sessionStorage$; }\n\n public get localStorage(): Storage { return this.localStorage$; }\n\n public get location(): Location { return this.location$; }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;MAKa,qBAAqB,CAAA;AAEb,IAAA,OAAO,GAAG,MAAM,CAAC,MAAM,CAAC;AAExB,IAAA,UAAU,GAAG,MAAM,CAAC,YAAY,CAAC;IAEjC,QAAQ,GAAG,OAAO;IAElB,SAAS,GAAG,QAAQ;IAEpB,eAAe,GAAG,cAAc;IAEhC,aAAa,GAAG,YAAY;IAE5B,SAAS,GAAG,QAAQ;IAE9B,MAAM,GAAA;AACT,QAAA,MAAM,OAAO,GAAG,IAAI,CAAC,QAAQ,CAAC,oBAAoB,CAAC,UAAU,CAAC,CAAC,CAAC;AACzD,eAAA,IAAI,CAAC,QAAQ,CAAC,cAAc,CAAC,UAAU;eACvC,IAAI,CAAC,QAAQ,CAAC,sBAAsB,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;AAE1D,QAAA,OAAO,EAAE,SAAS,CAAC,MAAM,CAAC,UAAU,CAAC;AACrC,QAAA,OAAO,EAAE,eAAe,CAAC,IAAI,CAAC;AAC9B,QAAA,OAAO,EAAE,eAAe,CAAC,YAAY,CAAC;AAEtC,QAAA,MAAM,YAAY,GAAG,IAAI,CAAC,QAAQ,CAAC,oBAAoB,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;QACtE,YAAY,EAAE,MAAM,EAAE;QAEtB,MAAM,aAAa,GAAG,IAAI,CAAC,QAAQ,CAAC,oBAAoB,CAAC,eAAe,CAAC;AACzE,QAAA,KAAK,MAAM,OAAO,IAAI,aAAa,EAAE;YACjC,OAAO,CAAC,MAAM,EAAE;QACpB;QAEA,MAAM,mBAAmB,GAAG,IAAI,CAAC,QAAQ,CAAC,cAAc,CAAC,UAAU,CAAC;QACpE,IAAI,mBAAmB,EAAE;YACrB,MAAM,MAAM,GAAG,UAAU,CAAC,gBA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,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,QAAA,EAAA,QAAA,EAAA,EAAA,EAAA,IAAA,EAAA,qBAAqB,cADR,MAAM,EAAA,CAAA;;2FACnB,qBAAqB,EAAA,UAAA,EAAA,CAAA;kBADjC,UAAU;mBAAC,EAAE,UAAU,EAAE,MAAM,EAAE;;;ACJlC;;AAEG;;;;"}
package/package.json ADDED
@@ -0,0 +1,24 @@
1
+ {
2
+ "name": "@ldu-anguboot/app",
3
+ "version": "0.5.0",
4
+ "peerDependencies": {
5
+ "@angular/core": "^21.1.0",
6
+ "@angular/platform-browser": "^21.0.0",
7
+ "@angular/router": "^21.0.0"
8
+ },
9
+ "module": "fesm2022/ldu-anguboot-app.mjs",
10
+ "typings": "types/ldu-anguboot-app.d.ts",
11
+ "exports": {
12
+ "./package.json": {
13
+ "default": "./package.json"
14
+ },
15
+ ".": {
16
+ "types": "./types/ldu-anguboot-app.d.ts",
17
+ "default": "./fesm2022/ldu-anguboot-app.mjs"
18
+ }
19
+ },
20
+ "sideEffects": false,
21
+ "dependencies": {
22
+ "tslib": "^2.3.0"
23
+ }
24
+ }
@@ -0,0 +1,38 @@
1
+ import { SafeHtml, SafeUrl, SafeResourceUrl, DomSanitizer } from '@angular/platform-browser';
2
+ import { Router } from '@angular/router';
3
+ import * as i0 from '@angular/core';
4
+
5
+ declare class LDuAnguBootAppService {
6
+ private readonly router$;
7
+ private readonly sanitizer$;
8
+ private readonly console$;
9
+ private readonly document$;
10
+ private readonly sessionStorage$;
11
+ private readonly localStorage$;
12
+ private readonly location$;
13
+ onInit(): void;
14
+ safeHtml(value: string): SafeHtml;
15
+ safeUrl(value: string): SafeUrl;
16
+ safeResourceUrl(value: string): SafeResourceUrl;
17
+ checkStorageItem(key: string): boolean;
18
+ getStorageItem<T>(key: string): T | null;
19
+ setLocalStorageItem(key: string, value: any): void;
20
+ setSessionStorageItem(key: string, value: any): void;
21
+ static format(date: Date, { fDate, fTime, fTimeShort, fTimeMs, }?: {
22
+ fDate?: boolean | undefined;
23
+ fTime?: boolean | undefined;
24
+ fTimeShort?: boolean | undefined;
25
+ fTimeMs?: boolean | undefined;
26
+ }): string;
27
+ get sanitizer(): DomSanitizer;
28
+ get router(): Router;
29
+ get console(): Console;
30
+ get document(): Document;
31
+ get sessionStorage(): Storage;
32
+ get localStorage(): Storage;
33
+ get location(): Location;
34
+ static ɵfac: i0.ɵɵFactoryDeclaration<LDuAnguBootAppService, never>;
35
+ static ɵprov: i0.ɵɵInjectableDeclaration<LDuAnguBootAppService>;
36
+ }
37
+
38
+ export { LDuAnguBootAppService };