@stemy/ngx-utils 12.0.1 → 12.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.
@@ -792,6 +792,7 @@
792
792
  var SCRIPT_PARAMS = new core.InjectionToken("script-params");
793
793
  var ROOT_ELEMENT = new core.InjectionToken("app-root-element");
794
794
  var ERROR_HANDLER = new core.InjectionToken("error-handler-callback");
795
+ var GLOBAL_TEMPLATES = new core.InjectionToken("global-templates");
795
796
  // --- Valued promise ---
796
797
  var ValuedPromise = /** @class */ (function (_super) {
797
798
  __extends(ValuedPromise, _super);
@@ -1683,6 +1684,135 @@
1683
1684
  return MathUtils;
1684
1685
  }());
1685
1686
 
1687
+ /**
1688
+ * Use this service to determine which is the current environment
1689
+ */
1690
+ var UniversalService = /** @class */ (function () {
1691
+ function UniversalService(platformId, dds) {
1692
+ this.platformId = platformId;
1693
+ this.dds = dds;
1694
+ var info = this.dds.getDeviceInfo();
1695
+ this.crawler = /(bot|google|baidu|bing|msn|duckduckbot|teoma|slurp|yandex|lighthouse|angular-universal|PTST)/gi.test(info.userAgent);
1696
+ }
1697
+ Object.defineProperty(UniversalService.prototype, "isBrowser", {
1698
+ get: function () {
1699
+ return common.isPlatformBrowser(this.platformId);
1700
+ },
1701
+ enumerable: false,
1702
+ configurable: true
1703
+ });
1704
+ Object.defineProperty(UniversalService.prototype, "isServer", {
1705
+ get: function () {
1706
+ return common.isPlatformServer(this.platformId);
1707
+ },
1708
+ enumerable: false,
1709
+ configurable: true
1710
+ });
1711
+ Object.defineProperty(UniversalService.prototype, "deviceInfo", {
1712
+ get: function () {
1713
+ return this.isServer
1714
+ ? {
1715
+ userAgent: "angular-universal",
1716
+ os: "unknown",
1717
+ browser: "node",
1718
+ device: "node",
1719
+ os_version: "unknown",
1720
+ browser_version: "unknown",
1721
+ deviceType: "unknown",
1722
+ orientation: "landscape"
1723
+ }
1724
+ : this.dds.getDeviceInfo();
1725
+ },
1726
+ enumerable: false,
1727
+ configurable: true
1728
+ });
1729
+ Object.defineProperty(UniversalService.prototype, "browserName", {
1730
+ get: function () {
1731
+ return this.dds.browser;
1732
+ },
1733
+ enumerable: false,
1734
+ configurable: true
1735
+ });
1736
+ Object.defineProperty(UniversalService.prototype, "browserVersion", {
1737
+ get: function () {
1738
+ return this.dds.browser_version;
1739
+ },
1740
+ enumerable: false,
1741
+ configurable: true
1742
+ });
1743
+ Object.defineProperty(UniversalService.prototype, "isExplorer", {
1744
+ get: function () {
1745
+ return this.dds.browser == "ie";
1746
+ },
1747
+ enumerable: false,
1748
+ configurable: true
1749
+ });
1750
+ Object.defineProperty(UniversalService.prototype, "isEdge", {
1751
+ get: function () {
1752
+ return this.dds.browser == "ms-edge";
1753
+ },
1754
+ enumerable: false,
1755
+ configurable: true
1756
+ });
1757
+ Object.defineProperty(UniversalService.prototype, "isChrome", {
1758
+ get: function () {
1759
+ return this.dds.browser == "chrome";
1760
+ },
1761
+ enumerable: false,
1762
+ configurable: true
1763
+ });
1764
+ Object.defineProperty(UniversalService.prototype, "isFirefox", {
1765
+ get: function () {
1766
+ return this.dds.browser == "firefox";
1767
+ },
1768
+ enumerable: false,
1769
+ configurable: true
1770
+ });
1771
+ Object.defineProperty(UniversalService.prototype, "isSafari", {
1772
+ get: function () {
1773
+ return this.dds.browser == "safari";
1774
+ },
1775
+ enumerable: false,
1776
+ configurable: true
1777
+ });
1778
+ Object.defineProperty(UniversalService.prototype, "isTablet", {
1779
+ get: function () {
1780
+ return this.dds.isTablet();
1781
+ },
1782
+ enumerable: false,
1783
+ configurable: true
1784
+ });
1785
+ Object.defineProperty(UniversalService.prototype, "isMobile", {
1786
+ get: function () {
1787
+ return this.dds.isMobile();
1788
+ },
1789
+ enumerable: false,
1790
+ configurable: true
1791
+ });
1792
+ Object.defineProperty(UniversalService.prototype, "isDesktop", {
1793
+ get: function () {
1794
+ return this.dds.isDesktop();
1795
+ },
1796
+ enumerable: false,
1797
+ configurable: true
1798
+ });
1799
+ Object.defineProperty(UniversalService.prototype, "isCrawler", {
1800
+ get: function () {
1801
+ return this.crawler;
1802
+ },
1803
+ enumerable: false,
1804
+ configurable: true
1805
+ });
1806
+ return UniversalService;
1807
+ }());
1808
+ UniversalService.decorators = [
1809
+ { type: core.Injectable }
1810
+ ];
1811
+ UniversalService.ctorParameters = function () { return [
1812
+ { type: String, decorators: [{ type: core.Inject, args: [core.PLATFORM_ID,] }] },
1813
+ { type: ngxDeviceDetector.DeviceDetectorService }
1814
+ ]; };
1815
+
1686
1816
  var emptySnapshot = new router.ActivatedRouteSnapshot();
1687
1817
  var emptyData = { id: "" };
1688
1818
  var emptyParams = {};
@@ -1690,11 +1820,12 @@
1690
1820
  var emptyComponents = [];
1691
1821
  var StateService = /** @class */ (function (_super) {
1692
1822
  __extends(StateService, _super);
1693
- function StateService(injector, zone, router$1) {
1823
+ function StateService(injector, zone, universal, router$1) {
1694
1824
  if (router$1 === void 0) { router$1 = null; }
1695
1825
  var _this = _super.call(this, null) || this;
1696
1826
  _this.injector = injector;
1697
1827
  _this.zone = zone;
1828
+ _this.universal = universal;
1698
1829
  _this.router = router$1;
1699
1830
  _this.handleRouterEvent = function (event) {
1700
1831
  if (!(event instanceof router.NavigationEnd))
@@ -1865,27 +1996,75 @@
1865
1996
  });
1866
1997
  });
1867
1998
  };
1868
- StateService.prototype.navigate = function (commands, extras) {
1869
- if (!this.router)
1870
- return Promise.resolve(false);
1871
- extras = Object.assign({}, this.globalExtras, extras || {});
1872
- var tree = this.router.createUrlTree(commands, extras);
1873
- return this.navigateByUrl(tree, extras);
1999
+ StateService.prototype.navigateByUrl = function (url, navigationExtras) {
2000
+ if (navigationExtras === void 0) { navigationExtras = {}; }
2001
+ return __awaiter(this, void 0, void 0, function () {
2002
+ return __generator(this, function (_a) {
2003
+ return [2 /*return*/, this.navigate(url, navigationExtras)];
2004
+ });
2005
+ });
1874
2006
  };
1875
- StateService.prototype.navigateByUrl = function (url, extras) {
1876
- var _this = this;
1877
- if (!this.router)
1878
- return Promise.resolve(false);
1879
- extras = Object.assign({}, this.globalExtras, extras || {});
1880
- return new Promise(function (resolve) {
1881
- _this.zone.run(function () {
1882
- _this.router.navigateByUrl(url, extras).then(resolve, function () { return resolve(false); });
2007
+ StateService.prototype.navigate = function (url, navigationExtras) {
2008
+ if (navigationExtras === void 0) { navigationExtras = {}; }
2009
+ return __awaiter(this, void 0, void 0, function () {
2010
+ var _a, tree, extras;
2011
+ var _this = this;
2012
+ return __generator(this, function (_b) {
2013
+ if (!this.router)
2014
+ return [2 /*return*/, false];
2015
+ _a = __read(this.createUrlTree(url, navigationExtras), 2), tree = _a[0], extras = _a[1];
2016
+ return [2 /*return*/, this.zone.run(function () {
2017
+ return _this.router.navigateByUrl(tree, extras);
2018
+ })];
2019
+ });
2020
+ });
2021
+ };
2022
+ StateService.prototype.open = function (url, target, navigationExtras) {
2023
+ if (target === void 0) { target = "_blank"; }
2024
+ if (navigationExtras === void 0) { navigationExtras = {}; }
2025
+ return __awaiter(this, void 0, void 0, function () {
2026
+ var _a, tree, extras;
2027
+ var _this = this;
2028
+ return __generator(this, function (_b) {
2029
+ if (!this.router)
2030
+ return [2 /*return*/, false];
2031
+ _a = __read(this.createUrlTree(url, navigationExtras), 2), tree = _a[0], extras = _a[1];
2032
+ return [2 /*return*/, this.zone.run(function () {
2033
+ return _this.openInNewWindow(tree, target) || _this.router.navigateByUrl(tree, extras);
2034
+ })];
1883
2035
  });
1884
2036
  });
1885
2037
  };
1886
2038
  StateService.prototype.subscribeImmediately = function (next, error, complete) {
1887
2039
  return this.pipe(operators.skipWhile(function (v) { return v == null; })).subscribe(next, error, complete);
1888
2040
  };
2041
+ StateService.prototype.openInNewWindow = function (tree, target) {
2042
+ if (!this.universal.isBrowser)
2043
+ return false;
2044
+ var baseUrl = window.location.href.replace(this.router.url, "");
2045
+ try {
2046
+ var serialized = this.router.serializeUrl(tree);
2047
+ var separator = serialized.startsWith("/") ? "" : "/";
2048
+ window.open(baseUrl + separator + serialized, target);
2049
+ return true;
2050
+ }
2051
+ catch (e) {
2052
+ console.log("Can't open new window: " + e);
2053
+ return false;
2054
+ }
2055
+ };
2056
+ StateService.prototype.createUrlTree = function (url, extras) {
2057
+ if (!this.router)
2058
+ return null;
2059
+ extras = Object.assign(extras, this.globalExtras, extras || {});
2060
+ if (ObjectUtils.isArray(url)) {
2061
+ return [this.router.createUrlTree(url, extras), extras];
2062
+ }
2063
+ if (ObjectUtils.isString(url)) {
2064
+ return [this.router.parseUrl(url), extras];
2065
+ }
2066
+ return [url, extras];
2067
+ };
1889
2068
  return StateService;
1890
2069
  }(rxjs.BehaviorSubject));
1891
2070
  StateService.decorators = [
@@ -1894,6 +2073,7 @@
1894
2073
  StateService.ctorParameters = function () { return [
1895
2074
  { type: core.Injector },
1896
2075
  { type: core.NgZone },
2076
+ { type: UniversalService },
1897
2077
  { type: router.Router, decorators: [{ type: core.Optional }] }
1898
2078
  ]; };
1899
2079
 
@@ -2492,135 +2672,6 @@
2492
2672
  return Vector;
2493
2673
  }());
2494
2674
 
2495
- /**
2496
- * Use this service to determine which is the current environment
2497
- */
2498
- var UniversalService = /** @class */ (function () {
2499
- function UniversalService(platformId, dds) {
2500
- this.platformId = platformId;
2501
- this.dds = dds;
2502
- var info = this.dds.getDeviceInfo();
2503
- this.crawler = /(bot|google|baidu|bing|msn|duckduckbot|teoma|slurp|yandex|lighthouse|angular-universal|PTST)/gi.test(info.userAgent);
2504
- }
2505
- Object.defineProperty(UniversalService.prototype, "isBrowser", {
2506
- get: function () {
2507
- return common.isPlatformBrowser(this.platformId);
2508
- },
2509
- enumerable: false,
2510
- configurable: true
2511
- });
2512
- Object.defineProperty(UniversalService.prototype, "isServer", {
2513
- get: function () {
2514
- return common.isPlatformServer(this.platformId);
2515
- },
2516
- enumerable: false,
2517
- configurable: true
2518
- });
2519
- Object.defineProperty(UniversalService.prototype, "deviceInfo", {
2520
- get: function () {
2521
- return this.isServer
2522
- ? {
2523
- userAgent: "angular-universal",
2524
- os: "unknown",
2525
- browser: "node",
2526
- device: "node",
2527
- os_version: "unknown",
2528
- browser_version: "unknown",
2529
- deviceType: "unknown",
2530
- orientation: "landscape"
2531
- }
2532
- : this.dds.getDeviceInfo();
2533
- },
2534
- enumerable: false,
2535
- configurable: true
2536
- });
2537
- Object.defineProperty(UniversalService.prototype, "browserName", {
2538
- get: function () {
2539
- return this.dds.browser;
2540
- },
2541
- enumerable: false,
2542
- configurable: true
2543
- });
2544
- Object.defineProperty(UniversalService.prototype, "browserVersion", {
2545
- get: function () {
2546
- return this.dds.browser_version;
2547
- },
2548
- enumerable: false,
2549
- configurable: true
2550
- });
2551
- Object.defineProperty(UniversalService.prototype, "isExplorer", {
2552
- get: function () {
2553
- return this.dds.browser == "ie";
2554
- },
2555
- enumerable: false,
2556
- configurable: true
2557
- });
2558
- Object.defineProperty(UniversalService.prototype, "isEdge", {
2559
- get: function () {
2560
- return this.dds.browser == "ms-edge";
2561
- },
2562
- enumerable: false,
2563
- configurable: true
2564
- });
2565
- Object.defineProperty(UniversalService.prototype, "isChrome", {
2566
- get: function () {
2567
- return this.dds.browser == "chrome";
2568
- },
2569
- enumerable: false,
2570
- configurable: true
2571
- });
2572
- Object.defineProperty(UniversalService.prototype, "isFirefox", {
2573
- get: function () {
2574
- return this.dds.browser == "firefox";
2575
- },
2576
- enumerable: false,
2577
- configurable: true
2578
- });
2579
- Object.defineProperty(UniversalService.prototype, "isSafari", {
2580
- get: function () {
2581
- return this.dds.browser == "safari";
2582
- },
2583
- enumerable: false,
2584
- configurable: true
2585
- });
2586
- Object.defineProperty(UniversalService.prototype, "isTablet", {
2587
- get: function () {
2588
- return this.dds.isTablet();
2589
- },
2590
- enumerable: false,
2591
- configurable: true
2592
- });
2593
- Object.defineProperty(UniversalService.prototype, "isMobile", {
2594
- get: function () {
2595
- return this.dds.isMobile();
2596
- },
2597
- enumerable: false,
2598
- configurable: true
2599
- });
2600
- Object.defineProperty(UniversalService.prototype, "isDesktop", {
2601
- get: function () {
2602
- return this.dds.isDesktop();
2603
- },
2604
- enumerable: false,
2605
- configurable: true
2606
- });
2607
- Object.defineProperty(UniversalService.prototype, "isCrawler", {
2608
- get: function () {
2609
- return this.crawler;
2610
- },
2611
- enumerable: false,
2612
- configurable: true
2613
- });
2614
- return UniversalService;
2615
- }());
2616
- UniversalService.decorators = [
2617
- { type: core.Injectable }
2618
- ];
2619
- UniversalService.ctorParameters = function () { return [
2620
- { type: String, decorators: [{ type: core.Inject, args: [core.PLATFORM_ID,] }] },
2621
- { type: ngxDeviceDetector.DeviceDetectorService }
2622
- ]; };
2623
-
2624
2675
  var emptyGuards = [];
2625
2676
  var AclService = /** @class */ (function () {
2626
2677
  function AclService(injector, state, auth) {
@@ -3412,7 +3463,7 @@
3412
3463
  GlobalTemplateService.prototype.get = function (id, component) {
3413
3464
  var template = this.globalTemplates[id];
3414
3465
  if (!template)
3415
- return null;
3466
+ return undefined;
3416
3467
  var modifier = this.componentModifiers[id];
3417
3468
  if (ObjectUtils.isFunction(modifier) && component) {
3418
3469
  modifier(component);
@@ -4330,7 +4381,9 @@
4330
4381
  this.templatesUpdated.unsubscribe();
4331
4382
  };
4332
4383
  GlobalTemplatePipe.prototype.transform = function (templateId, component) {
4333
- if (this.cachedTemplate == null || this.cachedTemplateId !== templateId) {
4384
+ if (!templateId)
4385
+ return null;
4386
+ if (this.cachedTemplate === null || this.cachedTemplateId !== templateId) {
4334
4387
  this.cachedTemplateId = templateId;
4335
4388
  this.cachedTemplate = this.globalTemplates.get(templateId, component);
4336
4389
  }
@@ -4345,7 +4398,7 @@
4345
4398
  },] }
4346
4399
  ];
4347
4400
  GlobalTemplatePipe.ctorParameters = function () { return [
4348
- { type: GlobalTemplateService }
4401
+ { type: undefined, decorators: [{ type: core.Inject, args: [GLOBAL_TEMPLATES,] }] }
4349
4402
  ]; };
4350
4403
 
4351
4404
  var GroupByPipe = /** @class */ (function () {
@@ -4887,15 +4940,15 @@
4887
4940
  };
4888
4941
 
4889
4942
  var GlobalTemplateDirective = /** @class */ (function () {
4890
- function GlobalTemplateDirective(globalTemplateService, template) {
4891
- this.globalTemplateService = globalTemplateService;
4943
+ function GlobalTemplateDirective(globalTemplates, template) {
4944
+ this.globalTemplates = globalTemplates;
4892
4945
  this.template = template;
4893
4946
  }
4894
4947
  GlobalTemplateDirective.prototype.ngOnInit = function () {
4895
- this.globalTemplateService.add(this.id, this.template);
4948
+ this.globalTemplates.add(this.id, this.template);
4896
4949
  };
4897
4950
  GlobalTemplateDirective.prototype.ngOnDestroy = function () {
4898
- this.globalTemplateService.remove(this.id);
4951
+ this.globalTemplates.remove(this.id);
4899
4952
  };
4900
4953
  return GlobalTemplateDirective;
4901
4954
  }());
@@ -4905,7 +4958,7 @@
4905
4958
  },] }
4906
4959
  ];
4907
4960
  GlobalTemplateDirective.ctorParameters = function () { return [
4908
- { type: GlobalTemplateService },
4961
+ { type: undefined, decorators: [{ type: core.Inject, args: [GLOBAL_TEMPLATES,] }] },
4909
4962
  { type: core.TemplateRef }
4910
4963
  ]; };
4911
4964
  GlobalTemplateDirective.propDecorators = {
@@ -5875,6 +5928,10 @@
5875
5928
  provide: CONFIG_SERVICE,
5876
5929
  useExisting: (!config ? null : config.configService) || ConfigService
5877
5930
  },
5931
+ {
5932
+ provide: GLOBAL_TEMPLATES,
5933
+ useExisting: (!config ? null : config.globalTemplates) || GlobalTemplateService
5934
+ },
5878
5935
  {
5879
5936
  provide: ROOT_ELEMENT,
5880
5937
  useValue: null
@@ -5942,6 +5999,7 @@
5942
5999
  exports.FindPipe = FindPipe;
5943
6000
  exports.FormatNumberPipe = FormatNumberPipe;
5944
6001
  exports.FormatterService = FormatterService;
6002
+ exports.GLOBAL_TEMPLATES = GLOBAL_TEMPLATES;
5945
6003
  exports.GenericValue = GenericValue;
5946
6004
  exports.GetOffsetPipe = GetOffsetPipe;
5947
6005
  exports.GetTypePipe = GetTypePipe;