@stemy/ngx-utils 13.1.0 → 13.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.
- 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 +11 -1
- package/esm2020/public_api.mjs +2 -2
- package/fesm2015/stemy-ngx-utils.mjs +37 -21
- package/fesm2015/stemy-ngx-utils.mjs.map +1 -1
- package/fesm2020/stemy-ngx-utils.mjs +37 -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 +1 -0
- package/package.json +1 -1
- package/public_api.d.ts +1 -1
|
@@ -8,7 +8,7 @@ import { Invokable } from 'invokable';
|
|
|
8
8
|
import * as i2 from '@angular/router';
|
|
9
9
|
import { ActivatedRouteSnapshot, NavigationEnd, DefaultUrlSerializer, UrlTree, UrlSegmentGroup, UrlSegment, UrlSerializer } from '@angular/router';
|
|
10
10
|
import * as i1$3 from '@angular/common';
|
|
11
|
-
import { isPlatformBrowser, isPlatformServer,
|
|
11
|
+
import { isPlatformBrowser, isPlatformServer, DOCUMENT, APP_BASE_HREF, CommonModule } from '@angular/common';
|
|
12
12
|
import * as i1 from 'ngx-device-detector';
|
|
13
13
|
import { DeviceDetectorService } from 'ngx-device-detector';
|
|
14
14
|
import * as i1$1 from '@angular/common/http';
|
|
@@ -413,6 +413,7 @@ const API_SERVICE = new InjectionToken("api-service");
|
|
|
413
413
|
class ResourceIfContext {
|
|
414
414
|
}
|
|
415
415
|
// --- ConfigService ---
|
|
416
|
+
const APP_BASE_URL = new InjectionToken("app-base-url");
|
|
416
417
|
class IConfiguration {
|
|
417
418
|
}
|
|
418
419
|
const CONFIG_SERVICE = new InjectionToken("config-service");
|
|
@@ -1753,6 +1754,16 @@ class StringUtils {
|
|
|
1753
1754
|
static ucFirst(str) {
|
|
1754
1755
|
return str ? str.charAt(0).toUpperCase() + str.substring(1) : "";
|
|
1755
1756
|
}
|
|
1757
|
+
static parseDomain(baseUrl) {
|
|
1758
|
+
try {
|
|
1759
|
+
const url = new URL(baseUrl);
|
|
1760
|
+
const port = url.port && url.port !== "443" && url.port !== "80" ? `:${url.port}` : ``;
|
|
1761
|
+
return `${url.protocol}//${url.hostname}${port}/`;
|
|
1762
|
+
}
|
|
1763
|
+
catch {
|
|
1764
|
+
return "/";
|
|
1765
|
+
}
|
|
1766
|
+
}
|
|
1756
1767
|
}
|
|
1757
1768
|
|
|
1758
1769
|
class ArrayUtils {
|
|
@@ -2469,18 +2480,18 @@ class StaticAuthService {
|
|
|
2469
2480
|
}
|
|
2470
2481
|
|
|
2471
2482
|
class ConfigService {
|
|
2472
|
-
constructor(http, universal, rootElement,
|
|
2483
|
+
constructor(http, universal, rootElement, baseUrl, baseConfig = null, scriptParams = null) {
|
|
2473
2484
|
this.http = http;
|
|
2474
2485
|
this.universal = universal;
|
|
2475
2486
|
this.rootElement = rootElement;
|
|
2476
|
-
this.
|
|
2487
|
+
this.baseUrl = baseUrl;
|
|
2477
2488
|
for (const key in []) {
|
|
2478
2489
|
Object.defineProperty(Array.prototype, key, {
|
|
2479
2490
|
enumerable: false
|
|
2480
2491
|
});
|
|
2481
2492
|
}
|
|
2482
2493
|
this.baseConfig = baseConfig || {};
|
|
2483
|
-
this.loadedConfig = Object.assign(!this.
|
|
2494
|
+
this.loadedConfig = Object.assign(!this.baseUrl ? {} : { baseUrl: this.baseUrl, baseDomain: StringUtils.parseDomain(this.baseUrl) }, this.baseConfig);
|
|
2484
2495
|
this.scriptParameters = scriptParams || {};
|
|
2485
2496
|
this.loaderFunc = () => {
|
|
2486
2497
|
this.loader = this.loader || new Promise((resolve, reject) => {
|
|
@@ -2506,16 +2517,6 @@ class ConfigService {
|
|
|
2506
2517
|
get configUrl() {
|
|
2507
2518
|
return `${this.loadedConfig.baseUrl}config/config.json`;
|
|
2508
2519
|
}
|
|
2509
|
-
parseDomain(baseUrl) {
|
|
2510
|
-
try {
|
|
2511
|
-
const url = new URL(baseUrl);
|
|
2512
|
-
const port = url.port && url.port !== "443" && url.port !== "80" ? `:${url.port}` : ``;
|
|
2513
|
-
return `${url.protocol}//${url.hostname}${port}/`;
|
|
2514
|
-
}
|
|
2515
|
-
catch {
|
|
2516
|
-
return "/";
|
|
2517
|
-
}
|
|
2518
|
-
}
|
|
2519
2520
|
initService() {
|
|
2520
2521
|
}
|
|
2521
2522
|
async loadJson() {
|
|
@@ -2562,7 +2563,7 @@ class ConfigService {
|
|
|
2562
2563
|
return decodeURIComponent(results[2].replace(/\+/g, " "));
|
|
2563
2564
|
}
|
|
2564
2565
|
}
|
|
2565
|
-
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:
|
|
2566
|
+
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 });
|
|
2566
2567
|
ConfigService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.3.8", ngImport: i0, type: ConfigService });
|
|
2567
2568
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.8", ngImport: i0, type: ConfigService, decorators: [{
|
|
2568
2569
|
type: Injectable
|
|
@@ -2571,7 +2572,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.8", ngImpor
|
|
|
2571
2572
|
args: [ROOT_ELEMENT]
|
|
2572
2573
|
}] }, { type: undefined, decorators: [{
|
|
2573
2574
|
type: Inject,
|
|
2574
|
-
args: [
|
|
2575
|
+
args: [APP_BASE_URL]
|
|
2575
2576
|
}] }, { type: IConfiguration, decorators: [{
|
|
2576
2577
|
type: Optional
|
|
2577
2578
|
}, {
|
|
@@ -4964,7 +4965,7 @@ function loadConfig(config) {
|
|
|
4964
4965
|
return config.load;
|
|
4965
4966
|
}
|
|
4966
4967
|
|
|
4967
|
-
function
|
|
4968
|
+
function loadBaseUrl() {
|
|
4968
4969
|
if (typeof (document) === "undefined" || typeof (location) === "undefined")
|
|
4969
4970
|
return "/";
|
|
4970
4971
|
const currentScript = document.currentScript;
|
|
@@ -4975,7 +4976,8 @@ function loadBaseHref() {
|
|
|
4975
4976
|
}
|
|
4976
4977
|
catch (e) {
|
|
4977
4978
|
const qualifiedUrl = location.protocol + "//" + location.host;
|
|
4978
|
-
const
|
|
4979
|
+
const stack = (e.stack || "");
|
|
4980
|
+
const srcUrl = (stack.match(new RegExp(qualifiedUrl + ".*?\\.js", "g")) || stack.match(/http([A-Z:\/\-.]+)\.js/gi)).shift();
|
|
4979
4981
|
const lastIndex = srcUrl.lastIndexOf("/");
|
|
4980
4982
|
return lastIndex < 0 ? "/" : srcUrl.substring(0, lastIndex + 1);
|
|
4981
4983
|
}
|
|
@@ -4984,6 +4986,15 @@ function loadBaseHref() {
|
|
|
4984
4986
|
const lastIndex = scriptSrc.lastIndexOf("/");
|
|
4985
4987
|
return lastIndex < 0 ? "/" : scriptSrc.substring(0, lastIndex + 1);
|
|
4986
4988
|
}
|
|
4989
|
+
function loadBaseHref(baseUrl) {
|
|
4990
|
+
try {
|
|
4991
|
+
return new URL(baseUrl).pathname;
|
|
4992
|
+
}
|
|
4993
|
+
catch (e) {
|
|
4994
|
+
console.log(e);
|
|
4995
|
+
return "/";
|
|
4996
|
+
}
|
|
4997
|
+
}
|
|
4987
4998
|
class NgxUtilsModule {
|
|
4988
4999
|
constructor() {
|
|
4989
5000
|
}
|
|
@@ -5024,6 +5035,11 @@ class NgxUtilsModule {
|
|
|
5024
5035
|
provide: GLOBAL_TEMPLATES,
|
|
5025
5036
|
useExisting: (!config ? null : config.globalTemplates) || GlobalTemplateService
|
|
5026
5037
|
},
|
|
5038
|
+
{
|
|
5039
|
+
provide: APP_BASE_URL,
|
|
5040
|
+
useFactory: (!config ? null : config.baseUrl) || loadBaseUrl,
|
|
5041
|
+
deps: [Injector]
|
|
5042
|
+
},
|
|
5027
5043
|
{
|
|
5028
5044
|
provide: ROOT_ELEMENT,
|
|
5029
5045
|
useValue: null
|
|
@@ -5036,8 +5052,8 @@ class NgxUtilsModule {
|
|
|
5036
5052
|
},
|
|
5037
5053
|
{
|
|
5038
5054
|
provide: APP_BASE_HREF,
|
|
5039
|
-
useFactory:
|
|
5040
|
-
deps: [
|
|
5055
|
+
useFactory: loadBaseHref,
|
|
5056
|
+
deps: [APP_BASE_URL]
|
|
5041
5057
|
}
|
|
5042
5058
|
]
|
|
5043
5059
|
};
|
|
@@ -5076,5 +5092,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.8", ngImpor
|
|
|
5076
5092
|
* Generated bundle index. Do not edit.
|
|
5077
5093
|
*/
|
|
5078
5094
|
|
|
5079
|
-
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 };
|
|
5095
|
+
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 };
|
|
5080
5096
|
//# sourceMappingURL=stemy-ngx-utils.mjs.map
|