@stemy/ngx-utils 13.0.3 → 13.0.4

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.
@@ -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, DOCUMENT, CommonModule } from '@angular/common';
11
+ import { isPlatformBrowser, isPlatformServer, APP_BASE_HREF, DOCUMENT, 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';
@@ -2468,26 +2468,18 @@ class StaticAuthService {
2468
2468
  }
2469
2469
 
2470
2470
  class ConfigService {
2471
- constructor(http, universal, rootElement, baseConfig = null, scriptParams = null) {
2471
+ constructor(http, universal, rootElement, baseHref, baseConfig = null, scriptParams = null) {
2472
2472
  this.http = http;
2473
2473
  this.universal = universal;
2474
2474
  this.rootElement = rootElement;
2475
+ this.baseHref = baseHref;
2475
2476
  for (const key in []) {
2476
2477
  Object.defineProperty(Array.prototype, key, {
2477
2478
  enumerable: false
2478
2479
  });
2479
2480
  }
2480
- let baseUrl = "";
2481
- if (this.universal.isBrowser) {
2482
- const currentScript = document.currentScript;
2483
- if (!!currentScript) {
2484
- const scriptSrc = currentScript.src;
2485
- const srcParts = scriptSrc.split(".js");
2486
- baseUrl = scriptSrc.substr(0, srcParts[0].lastIndexOf("/") + 1);
2487
- }
2488
- }
2489
2481
  this.baseConfig = baseConfig || {};
2490
- this.loadedConfig = Object.assign(!baseUrl ? {} : { baseUrl, baseDomain: this.parseDomain(baseUrl) }, this.baseConfig);
2482
+ this.loadedConfig = Object.assign(!this.baseHref ? {} : { baseUrl: this.baseHref, baseDomain: this.parseDomain(this.baseHref) }, this.baseConfig);
2491
2483
  this.scriptParameters = scriptParams || {};
2492
2484
  this.loaderFunc = () => {
2493
2485
  this.loader = this.loader || new Promise((resolve, reject) => {
@@ -2569,13 +2561,16 @@ class ConfigService {
2569
2561
  return decodeURIComponent(results[2].replace(/\+/g, " "));
2570
2562
  }
2571
2563
  }
2572
- 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: BASE_CONFIG, optional: true }, { token: SCRIPT_PARAMS, optional: true }], target: i0.ɵɵFactoryTarget.Injectable });
2564
+ 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_HREF }, { token: BASE_CONFIG, optional: true }, { token: SCRIPT_PARAMS, optional: true }], target: i0.ɵɵFactoryTarget.Injectable });
2573
2565
  ConfigService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.3.8", ngImport: i0, type: ConfigService });
2574
2566
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.8", ngImport: i0, type: ConfigService, decorators: [{
2575
2567
  type: Injectable
2576
2568
  }], ctorParameters: function () { return [{ type: i1$1.HttpClient }, { type: UniversalService }, { type: undefined, decorators: [{
2577
2569
  type: Inject,
2578
2570
  args: [ROOT_ELEMENT]
2571
+ }] }, { type: undefined, decorators: [{
2572
+ type: Inject,
2573
+ args: [APP_BASE_HREF]
2579
2574
  }] }, { type: IConfiguration, decorators: [{
2580
2575
  type: Optional
2581
2576
  }, {
@@ -4964,6 +4959,26 @@ function loadConfig(config) {
4964
4959
  return config.load;
4965
4960
  }
4966
4961
 
4962
+ function loadBaseHref() {
4963
+ if (typeof (document) === "undefined" || typeof (location) === "undefined")
4964
+ return "/";
4965
+ const currentScript = document.currentScript;
4966
+ if (!currentScript) {
4967
+ try {
4968
+ // noinspection ExceptionCaughtLocallyJS
4969
+ throw new Error();
4970
+ }
4971
+ catch (e) {
4972
+ const qualifiedUrl = location.protocol + "//" + location.host;
4973
+ const srcUrl = (e.stack || "").match(new RegExp(qualifiedUrl + ".*?\\.js", "g")) || e.stack.match(/http([A-Z:\/\-\.]+)\.js/gi).shift();
4974
+ const lastIndex = srcUrl.lastIndexOf("/");
4975
+ return lastIndex < 0 ? "/" : srcUrl.substring(0, lastIndex + 1);
4976
+ }
4977
+ }
4978
+ const scriptSrc = currentScript.src;
4979
+ const lastIndex = scriptSrc.lastIndexOf("/");
4980
+ return lastIndex < 0 ? "/" : scriptSrc.substring(0, lastIndex + 1);
4981
+ }
4967
4982
  class NgxUtilsModule {
4968
4983
  constructor() {
4969
4984
  }
@@ -5013,6 +5028,11 @@ class NgxUtilsModule {
5013
5028
  useFactory: (!config ? null : config.initializeApp) || loadConfig,
5014
5029
  multi: true,
5015
5030
  deps: [(!config ? null : config.initializeApp) ? Injector : CONFIG_SERVICE]
5031
+ },
5032
+ {
5033
+ provide: APP_BASE_HREF,
5034
+ useFactory: (!config ? null : config.baseHref) || loadBaseHref,
5035
+ deps: [Injector]
5016
5036
  }
5017
5037
  ]
5018
5038
  };