@ngxs/store 3.8.1-dev.master-3e21e23 → 3.8.1-dev.master-c0944d0

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.
@@ -1010,33 +1010,28 @@
1010
1010
  }, {});
1011
1011
  }
1012
1012
 
1013
- var StoreValidators = /** @class */ (function () {
1014
- function StoreValidators() {
1013
+ var stateNameRegex = new RegExp('^[a-zA-Z0-9_]+$');
1014
+ function ensureStateNameIsValid(name) {
1015
+ if (!name) {
1016
+ throwStateNamePropertyError();
1015
1017
  }
1016
- StoreValidators.checkThatStateIsNamedCorrectly = function (name) {
1017
- if (!name) {
1018
- throwStateNamePropertyError();
1019
- }
1020
- else if (!this.stateNameRegex.test(name)) {
1021
- throwStateNameError(name);
1022
- }
1023
- };
1024
- StoreValidators.checkThatStateNameIsUnique = function (stateName, state, statesByName) {
1025
- var existingState = statesByName[stateName];
1026
- if (existingState && existingState !== state) {
1027
- throwStateUniqueError(stateName, state.name, existingState.name);
1018
+ else if (!stateNameRegex.test(name)) {
1019
+ throwStateNameError(name);
1020
+ }
1021
+ }
1022
+ function ensureStateNameIsUnique(stateName, state, statesByName) {
1023
+ var existingState = statesByName[stateName];
1024
+ if (existingState && existingState !== state) {
1025
+ throwStateUniqueError(stateName, state.name, existingState.name);
1026
+ }
1027
+ }
1028
+ function ensureStatesAreDecorated(stateClasses) {
1029
+ stateClasses.forEach(function (stateClass) {
1030
+ if (!getStoreMetadata$1(stateClass)) {
1031
+ throwStateDecoratorError(stateClass.name);
1028
1032
  }
1029
- };
1030
- StoreValidators.checkThatStateClassesHaveBeenDecorated = function (stateClasses) {
1031
- stateClasses.forEach(function (stateClass) {
1032
- if (!getStoreMetadata$1(stateClass)) {
1033
- throwStateDecoratorError(stateClass.name);
1034
- }
1035
- });
1036
- };
1037
- return StoreValidators;
1038
- }());
1039
- StoreValidators.stateNameRegex = new RegExp('^[a-zA-Z0-9_]+$');
1033
+ });
1034
+ }
1040
1035
 
1041
1036
  /**
1042
1037
  * All provided or injected tokens must have `@Injectable` decorator
@@ -1864,8 +1859,8 @@
1864
1859
  enumerable: false,
1865
1860
  configurable: true
1866
1861
  });
1867
- StateFactory.cloneDefaults = function (defaults) {
1868
- var value = {};
1862
+ StateFactory._cloneDefaults = function (defaults) {
1863
+ var value = defaults;
1869
1864
  if (Array.isArray(defaults)) {
1870
1865
  value = defaults.slice();
1871
1866
  }
@@ -1875,9 +1870,6 @@
1875
1870
  else if (defaults === undefined) {
1876
1871
  value = {};
1877
1872
  }
1878
- else {
1879
- value = defaults;
1880
- }
1881
1873
  return value;
1882
1874
  };
1883
1875
  StateFactory.prototype.ngOnDestroy = function () {
@@ -1890,7 +1882,7 @@
1890
1882
  StateFactory.prototype.add = function (stateClasses) {
1891
1883
  var e_1, _b;
1892
1884
  if (NG_DEV_MODE) {
1893
- StoreValidators.checkThatStateClassesHaveBeenDecorated(stateClasses);
1885
+ ensureStatesAreDecorated(stateClasses);
1894
1886
  }
1895
1887
  var newStates = this.addToStatesMap(stateClasses).newStates;
1896
1888
  if (!newStates.length)
@@ -1911,7 +1903,7 @@
1911
1903
  // `State` decorator. This check is moved here because the `ɵprov` property
1912
1904
  // will not exist on the class in JIT mode (because it's set asynchronously
1913
1905
  // during JIT compilation through `Object.defineProperty`).
1914
- if (typeof ngDevMode === 'undefined' || ngDevMode) {
1906
+ if (NG_DEV_MODE) {
1915
1907
  ensureStateClassIsInjectable(stateClass);
1916
1908
  }
1917
1909
  var stateMap = {
@@ -1920,7 +1912,7 @@
1920
1912
  isInitialised: false,
1921
1913
  actions: meta.actions,
1922
1914
  instance: this._injector.get(stateClass),
1923
- defaults: StateFactory.cloneDefaults(meta.defaults)
1915
+ defaults: StateFactory._cloneDefaults(meta.defaults)
1924
1916
  };
1925
1917
  // ensure our store hasn't already been added
1926
1918
  // but don't throw since it could be lazy
@@ -2066,7 +2058,7 @@
2066
2058
  var stateClass = stateClasses_1_1.value;
2067
2059
  var stateName = getStoreMetadata$1(stateClass).name;
2068
2060
  if (NG_DEV_MODE) {
2069
- StoreValidators.checkThatStateNameIsUnique(stateName, stateClass, statesMap);
2061
+ ensureStateNameIsUnique(stateName, stateClass, statesMap);
2070
2062
  }
2071
2063
  var unmountedState = !statesMap[stateName];
2072
2064
  if (unmountedState) {
@@ -2601,36 +2593,34 @@
2601
2593
  * Decorates a class with ngxs state information.
2602
2594
  */
2603
2595
  function State(options) {
2604
- function getStateOptions(inheritedStateClass) {
2605
- var inheritanceOptions = inheritedStateClass[META_OPTIONS_KEY] || {};
2606
- return Object.assign(Object.assign({}, inheritanceOptions), options);
2607
- }
2608
- function mutateMetaData(params) {
2609
- var meta = params.meta, inheritedStateClass = params.inheritedStateClass, optionsWithInheritance = params.optionsWithInheritance;
2610
- var children = optionsWithInheritance.children, defaults = optionsWithInheritance.defaults, name = optionsWithInheritance.name;
2611
- var stateName = typeof name === 'string' ? name : (name && name.getName()) || null;
2612
- // Caretaker note: we have still left the `typeof` condition in order to avoid
2613
- // creating a breaking change for projects that still use the View Engine.
2614
- if (typeof ngDevMode === 'undefined' || ngDevMode) {
2615
- StoreValidators.checkThatStateIsNamedCorrectly(stateName);
2616
- }
2617
- if (inheritedStateClass.hasOwnProperty(META_KEY)) {
2618
- var inheritedMeta = inheritedStateClass[META_KEY] || {};
2619
- meta.actions = Object.assign(Object.assign({}, meta.actions), inheritedMeta.actions);
2620
- }
2621
- meta.children = children;
2622
- meta.defaults = defaults;
2623
- meta.name = stateName;
2624
- }
2625
2596
  return function (target) {
2626
2597
  var stateClass = target;
2627
2598
  var meta = ensureStoreMetadata$1(stateClass);
2628
2599
  var inheritedStateClass = Object.getPrototypeOf(stateClass);
2629
- var optionsWithInheritance = getStateOptions(inheritedStateClass);
2600
+ var optionsWithInheritance = getStateOptions(inheritedStateClass, options);
2630
2601
  mutateMetaData({ meta: meta, inheritedStateClass: inheritedStateClass, optionsWithInheritance: optionsWithInheritance });
2631
2602
  stateClass[META_OPTIONS_KEY] = optionsWithInheritance;
2632
2603
  };
2633
2604
  }
2605
+ function getStateOptions(inheritedStateClass, options) {
2606
+ var inheritanceOptions = inheritedStateClass[META_OPTIONS_KEY] || {};
2607
+ return Object.assign(Object.assign({}, inheritanceOptions), options);
2608
+ }
2609
+ function mutateMetaData(params) {
2610
+ var meta = params.meta, inheritedStateClass = params.inheritedStateClass, optionsWithInheritance = params.optionsWithInheritance;
2611
+ var children = optionsWithInheritance.children, defaults = optionsWithInheritance.defaults, name = optionsWithInheritance.name;
2612
+ var stateName = typeof name === 'string' ? name : (name && name.getName()) || null;
2613
+ if (typeof ngDevMode === 'undefined' || ngDevMode) {
2614
+ ensureStateNameIsValid(stateName);
2615
+ }
2616
+ if (inheritedStateClass.hasOwnProperty(META_KEY)) {
2617
+ var inheritedMeta = inheritedStateClass[META_KEY] || {};
2618
+ meta.actions = Object.assign(Object.assign({}, meta.actions), inheritedMeta.actions);
2619
+ }
2620
+ meta.children = children;
2621
+ meta.defaults = defaults;
2622
+ meta.name = stateName;
2623
+ }
2634
2624
 
2635
2625
  var DOLLAR_CHAR_CODE = 36;
2636
2626
  function createSelectObservable(selector) {