@stemy/ngx-utils 13.1.0 → 13.1.3
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/esm2020/ngx-utils/common-types.mjs +2 -1
- package/esm2020/ngx-utils/ngx-utils.module.mjs +21 -6
- package/esm2020/ngx-utils/services/config.service.mjs +8 -18
- package/esm2020/ngx-utils/utils/string.utils.mjs +14 -1
- package/esm2020/public_api.mjs +2 -2
- package/fesm2015/stemy-ngx-utils.mjs +40 -21
- package/fesm2015/stemy-ngx-utils.mjs.map +1 -1
- package/fesm2020/stemy-ngx-utils.mjs +40 -21
- package/fesm2020/stemy-ngx-utils.mjs.map +1 -1
- package/ngx-utils/common-types.d.ts +2 -1
- package/ngx-utils/ngx-utils.module.d.ts +2 -1
- package/ngx-utils/services/config.service.d.ts +2 -3
- package/ngx-utils/utils/string.utils.d.ts +2 -0
- package/package.json +1 -1
- package/public_api.d.ts +1 -1
|
@@ -9,7 +9,7 @@ import { __awaiter } from 'tslib';
|
|
|
9
9
|
import * as i2 from '@angular/router';
|
|
10
10
|
import { ActivatedRouteSnapshot, NavigationEnd, DefaultUrlSerializer, UrlTree, UrlSegmentGroup, UrlSegment, UrlSerializer } from '@angular/router';
|
|
11
11
|
import * as i1$3 from '@angular/common';
|
|
12
|
-
import { isPlatformBrowser, isPlatformServer,
|
|
12
|
+
import { isPlatformBrowser, isPlatformServer, DOCUMENT, APP_BASE_HREF, CommonModule } from '@angular/common';
|
|
13
13
|
import * as i1 from 'ngx-device-detector';
|
|
14
14
|
import { DeviceDetectorService } from 'ngx-device-detector';
|
|
15
15
|
import * as i1$1 from '@angular/common/http';
|
|
@@ -414,6 +414,7 @@ const API_SERVICE = new InjectionToken("api-service");
|
|
|
414
414
|
class ResourceIfContext {
|
|
415
415
|
}
|
|
416
416
|
// --- ConfigService ---
|
|
417
|
+
const APP_BASE_URL = new InjectionToken("app-base-url");
|
|
417
418
|
class IConfiguration {
|
|
418
419
|
}
|
|
419
420
|
const CONFIG_SERVICE = new InjectionToken("config-service");
|
|
@@ -1773,6 +1774,19 @@ class StringUtils {
|
|
|
1773
1774
|
static ucFirst(str) {
|
|
1774
1775
|
return str ? str.charAt(0).toUpperCase() + str.substring(1) : "";
|
|
1775
1776
|
}
|
|
1777
|
+
static isObjectId(id) {
|
|
1778
|
+
return typeof id === "string" && id.length == 24 && !isNaN(Number("0x" + id));
|
|
1779
|
+
}
|
|
1780
|
+
static parseDomain(baseUrl) {
|
|
1781
|
+
try {
|
|
1782
|
+
const url = new URL(baseUrl);
|
|
1783
|
+
const port = url.port && url.port !== "443" && url.port !== "80" ? `:${url.port}` : ``;
|
|
1784
|
+
return `${url.protocol}//${url.hostname}${port}/`;
|
|
1785
|
+
}
|
|
1786
|
+
catch (_a) {
|
|
1787
|
+
return "/";
|
|
1788
|
+
}
|
|
1789
|
+
}
|
|
1776
1790
|
}
|
|
1777
1791
|
|
|
1778
1792
|
class ArrayUtils {
|
|
@@ -2496,18 +2510,18 @@ class StaticAuthService {
|
|
|
2496
2510
|
}
|
|
2497
2511
|
|
|
2498
2512
|
class ConfigService {
|
|
2499
|
-
constructor(http, universal, rootElement,
|
|
2513
|
+
constructor(http, universal, rootElement, baseUrl, baseConfig = null, scriptParams = null) {
|
|
2500
2514
|
this.http = http;
|
|
2501
2515
|
this.universal = universal;
|
|
2502
2516
|
this.rootElement = rootElement;
|
|
2503
|
-
this.
|
|
2517
|
+
this.baseUrl = baseUrl;
|
|
2504
2518
|
for (const key in []) {
|
|
2505
2519
|
Object.defineProperty(Array.prototype, key, {
|
|
2506
2520
|
enumerable: false
|
|
2507
2521
|
});
|
|
2508
2522
|
}
|
|
2509
2523
|
this.baseConfig = baseConfig || {};
|
|
2510
|
-
this.loadedConfig = Object.assign(!this.
|
|
2524
|
+
this.loadedConfig = Object.assign(!this.baseUrl ? {} : { baseUrl: this.baseUrl, baseDomain: StringUtils.parseDomain(this.baseUrl) }, this.baseConfig);
|
|
2511
2525
|
this.scriptParameters = scriptParams || {};
|
|
2512
2526
|
this.loaderFunc = () => {
|
|
2513
2527
|
this.loader = this.loader || new Promise((resolve, reject) => {
|
|
@@ -2533,16 +2547,6 @@ class ConfigService {
|
|
|
2533
2547
|
get configUrl() {
|
|
2534
2548
|
return `${this.loadedConfig.baseUrl}config/config.json`;
|
|
2535
2549
|
}
|
|
2536
|
-
parseDomain(baseUrl) {
|
|
2537
|
-
try {
|
|
2538
|
-
const url = new URL(baseUrl);
|
|
2539
|
-
const port = url.port && url.port !== "443" && url.port !== "80" ? `:${url.port}` : ``;
|
|
2540
|
-
return `${url.protocol}//${url.hostname}${port}/`;
|
|
2541
|
-
}
|
|
2542
|
-
catch (_a) {
|
|
2543
|
-
return "/";
|
|
2544
|
-
}
|
|
2545
|
-
}
|
|
2546
2550
|
initService() {
|
|
2547
2551
|
}
|
|
2548
2552
|
loadJson() {
|
|
@@ -2592,7 +2596,7 @@ class ConfigService {
|
|
|
2592
2596
|
return decodeURIComponent(results[2].replace(/\+/g, " "));
|
|
2593
2597
|
}
|
|
2594
2598
|
}
|
|
2595
|
-
ConfigService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.8", ngImport: i0, type: ConfigService, deps: [{ token: i1$1.HttpClient }, { token: UniversalService }, { token: ROOT_ELEMENT }, { token:
|
|
2599
|
+
ConfigService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.8", ngImport: i0, type: ConfigService, deps: [{ token: i1$1.HttpClient }, { token: UniversalService }, { token: ROOT_ELEMENT }, { token: APP_BASE_URL }, { token: BASE_CONFIG, optional: true }, { token: SCRIPT_PARAMS, optional: true }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
2596
2600
|
ConfigService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.3.8", ngImport: i0, type: ConfigService });
|
|
2597
2601
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.8", ngImport: i0, type: ConfigService, decorators: [{
|
|
2598
2602
|
type: Injectable
|
|
@@ -2602,7 +2606,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.8", ngImpor
|
|
|
2602
2606
|
args: [ROOT_ELEMENT]
|
|
2603
2607
|
}] }, { type: undefined, decorators: [{
|
|
2604
2608
|
type: Inject,
|
|
2605
|
-
args: [
|
|
2609
|
+
args: [APP_BASE_URL]
|
|
2606
2610
|
}] }, { type: IConfiguration, decorators: [{
|
|
2607
2611
|
type: Optional
|
|
2608
2612
|
}, {
|
|
@@ -5033,7 +5037,7 @@ function loadConfig(config) {
|
|
|
5033
5037
|
return config.load;
|
|
5034
5038
|
}
|
|
5035
5039
|
|
|
5036
|
-
function
|
|
5040
|
+
function loadBaseUrl() {
|
|
5037
5041
|
if (typeof (document) === "undefined" || typeof (location) === "undefined")
|
|
5038
5042
|
return "/";
|
|
5039
5043
|
const currentScript = document.currentScript;
|
|
@@ -5044,7 +5048,8 @@ function loadBaseHref() {
|
|
|
5044
5048
|
}
|
|
5045
5049
|
catch (e) {
|
|
5046
5050
|
const qualifiedUrl = location.protocol + "//" + location.host;
|
|
5047
|
-
const
|
|
5051
|
+
const stack = (e.stack || "");
|
|
5052
|
+
const srcUrl = (stack.match(new RegExp(qualifiedUrl + ".*?\\.js", "g")) || stack.match(/http([A-Z:\/\-.]+)\.js/gi)).shift();
|
|
5048
5053
|
const lastIndex = srcUrl.lastIndexOf("/");
|
|
5049
5054
|
return lastIndex < 0 ? "/" : srcUrl.substring(0, lastIndex + 1);
|
|
5050
5055
|
}
|
|
@@ -5053,6 +5058,15 @@ function loadBaseHref() {
|
|
|
5053
5058
|
const lastIndex = scriptSrc.lastIndexOf("/");
|
|
5054
5059
|
return lastIndex < 0 ? "/" : scriptSrc.substring(0, lastIndex + 1);
|
|
5055
5060
|
}
|
|
5061
|
+
function loadBaseHref(baseUrl) {
|
|
5062
|
+
try {
|
|
5063
|
+
return new URL(baseUrl).pathname;
|
|
5064
|
+
}
|
|
5065
|
+
catch (e) {
|
|
5066
|
+
console.log(e);
|
|
5067
|
+
return "/";
|
|
5068
|
+
}
|
|
5069
|
+
}
|
|
5056
5070
|
class NgxUtilsModule {
|
|
5057
5071
|
constructor() {
|
|
5058
5072
|
}
|
|
@@ -5093,6 +5107,11 @@ class NgxUtilsModule {
|
|
|
5093
5107
|
provide: GLOBAL_TEMPLATES,
|
|
5094
5108
|
useExisting: (!config ? null : config.globalTemplates) || GlobalTemplateService
|
|
5095
5109
|
},
|
|
5110
|
+
{
|
|
5111
|
+
provide: APP_BASE_URL,
|
|
5112
|
+
useFactory: (!config ? null : config.baseUrl) || loadBaseUrl,
|
|
5113
|
+
deps: [Injector]
|
|
5114
|
+
},
|
|
5096
5115
|
{
|
|
5097
5116
|
provide: ROOT_ELEMENT,
|
|
5098
5117
|
useValue: null
|
|
@@ -5105,8 +5124,8 @@ class NgxUtilsModule {
|
|
|
5105
5124
|
},
|
|
5106
5125
|
{
|
|
5107
5126
|
provide: APP_BASE_HREF,
|
|
5108
|
-
useFactory:
|
|
5109
|
-
deps: [
|
|
5127
|
+
useFactory: loadBaseHref,
|
|
5128
|
+
deps: [APP_BASE_URL]
|
|
5110
5129
|
}
|
|
5111
5130
|
]
|
|
5112
5131
|
};
|
|
@@ -5145,5 +5164,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.8", ngImpor
|
|
|
5145
5164
|
* Generated bundle index. Do not edit.
|
|
5146
5165
|
*/
|
|
5147
5166
|
|
|
5148
|
-
export { API_SERVICE, AUTH_SERVICE, AclService, AjaxRequestHandler, ApiService, ArrayUtils, AsyncMethodBase, AsyncMethodDirective, AuthGuard, BASE_CONFIG, BackgroundDirective, BaseHttpClient, BaseHttpService, CONFIG_SERVICE, CanvasColor, CanvasUtils, ChunkPipe, Circle, ConfigService, ConsoleToasterService, DateUtils, DynamicTableComponent, DynamicTableTemplateDirective, ERROR_HANDLER, EXPRESS_REQUEST, EntriesPipe, ErrorHandlerService, EventsService, ExtraItemPropertiesPipe, FactoryDependencies, FileUtils, FilterPipe, FindPipe, FormatNumberPipe, FormatterService, GLOBAL_TEMPLATES, GenericValue, GetOffsetPipe, GetTypePipe, GlobalTemplateDirective, GlobalTemplatePipe, GlobalTemplateService, GroupByPipe, HttpPromise, ICON_SERVICE, IConfiguration, IconDirective, IconService, Initializer, IsTypePipe, JoinPipe, KeysPipe, LANGUAGE_SERVICE, LanguageService, LoaderUtils, MapPipe, MathUtils, MaxPipe, MinPipe, NgxTemplateOutletDirective, NgxUtilsModule, ObjectUtils, ObservableUtils, OpenApiService, PROMISE_SERVICE, PaginationDirective, PaginationItemContext, PaginationItemDirective, PaginationMenuComponent, Point, PromiseService, ROOT_ELEMENT, Rect, ReducePipe, ReflectUtils, RemapPipe, ReplacePipe, ResizeEventPlugin, ResourceIfContext, ResourceIfDirective, ReversePipe, RoundPipe, SCRIPT_PARAMS, SafeHtmlPipe, ScrollEventPlugin, SetUtils, StateService, StaticAuthService, StaticLanguageService, StickyClassDirective, StickyDirective, StorageMode, StorageService, StringUtils, TOASTER_SERVICE, TimerUtils, TranslatePipe, TranslatedUrlSerializer, UniqueUtils, UniversalService, UnorderedListComponent, UnorderedListItemDirective, UnorderedListTemplateDirective, UnorederedListTemplate, ValuedPromise, ValuesPipe, Vector };
|
|
5167
|
+
export { API_SERVICE, APP_BASE_URL, AUTH_SERVICE, AclService, AjaxRequestHandler, ApiService, ArrayUtils, AsyncMethodBase, AsyncMethodDirective, AuthGuard, BASE_CONFIG, BackgroundDirective, BaseHttpClient, BaseHttpService, CONFIG_SERVICE, CanvasColor, CanvasUtils, ChunkPipe, Circle, ConfigService, ConsoleToasterService, DateUtils, DynamicTableComponent, DynamicTableTemplateDirective, ERROR_HANDLER, EXPRESS_REQUEST, EntriesPipe, ErrorHandlerService, EventsService, ExtraItemPropertiesPipe, FactoryDependencies, FileUtils, FilterPipe, FindPipe, FormatNumberPipe, FormatterService, GLOBAL_TEMPLATES, GenericValue, GetOffsetPipe, GetTypePipe, GlobalTemplateDirective, GlobalTemplatePipe, GlobalTemplateService, GroupByPipe, HttpPromise, ICON_SERVICE, IConfiguration, IconDirective, IconService, Initializer, IsTypePipe, JoinPipe, KeysPipe, LANGUAGE_SERVICE, LanguageService, LoaderUtils, MapPipe, MathUtils, MaxPipe, MinPipe, NgxTemplateOutletDirective, NgxUtilsModule, ObjectUtils, ObservableUtils, OpenApiService, PROMISE_SERVICE, PaginationDirective, PaginationItemContext, PaginationItemDirective, PaginationMenuComponent, Point, PromiseService, ROOT_ELEMENT, Rect, ReducePipe, ReflectUtils, RemapPipe, ReplacePipe, ResizeEventPlugin, ResourceIfContext, ResourceIfDirective, ReversePipe, RoundPipe, SCRIPT_PARAMS, SafeHtmlPipe, ScrollEventPlugin, SetUtils, StateService, StaticAuthService, StaticLanguageService, StickyClassDirective, StickyDirective, StorageMode, StorageService, StringUtils, TOASTER_SERVICE, TimerUtils, TranslatePipe, TranslatedUrlSerializer, UniqueUtils, UniversalService, UnorderedListComponent, UnorderedListItemDirective, UnorderedListTemplateDirective, UnorederedListTemplate, ValuedPromise, ValuesPipe, Vector };
|
|
5149
5168
|
//# sourceMappingURL=stemy-ngx-utils.mjs.map
|