@ngxs/store 3.8.1-dev.master-5942e46 → 3.8.1-dev.master-b132a8a
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/src/configs/messages.config.mjs +6 -1
- package/esm2020/src/internal/lifecycle-state-manager.mjs +19 -1
- package/fesm2015/ngxs-store.mjs +34 -13
- package/fesm2015/ngxs-store.mjs.map +1 -1
- package/fesm2020/ngxs-store.mjs +34 -13
- package/fesm2020/ngxs-store.mjs.map +1 -1
- package/package.json +1 -1
- package/src/configs/messages.config.d.ts +1 -0
- package/src/internal/lifecycle-state-manager.d.ts +3 -1
package/fesm2020/ngxs-store.mjs
CHANGED
|
@@ -48,6 +48,11 @@ function getZoneWarningMessage() {
|
|
|
48
48
|
function getUndecoratedStateInIvyWarningMessage(name) {
|
|
49
49
|
return `'${name}' class should be decorated with @Injectable() right after the @State() decorator`;
|
|
50
50
|
}
|
|
51
|
+
function getInvalidInitializationOrderMessage() {
|
|
52
|
+
return ('You have an invalid state initialization order. This typically occurs when `NgxsModule.forFeature`\n' +
|
|
53
|
+
'or `provideStates` is called before `NgxsModule.forRoot` or `provideStore`.\n' +
|
|
54
|
+
'One example is when `NgxsRouterPluginModule.forRoot` is called before `NgxsModule.forRoot`.');
|
|
55
|
+
}
|
|
51
56
|
function throwSelectFactoryNotConnectedError() {
|
|
52
57
|
throw new Error('You have forgotten to import the NGXS module!');
|
|
53
58
|
}
|
|
@@ -111,18 +116,18 @@ function verifyZoneIsNotNooped(ngZone) {
|
|
|
111
116
|
console.warn(getZoneWarningMessage());
|
|
112
117
|
}
|
|
113
118
|
|
|
114
|
-
const NG_DEV_MODE$
|
|
119
|
+
const NG_DEV_MODE$4 = typeof ngDevMode === 'undefined' || ngDevMode;
|
|
115
120
|
/**
|
|
116
121
|
* Consumers have the option to utilize the execution strategy provided by
|
|
117
122
|
* `NgxsModule.forRoot({executionStrategy})` or `provideStore([], {executionStrategy})`.
|
|
118
123
|
*/
|
|
119
|
-
const CUSTOM_NGXS_EXECUTION_STRATEGY = new InjectionToken(NG_DEV_MODE$
|
|
124
|
+
const CUSTOM_NGXS_EXECUTION_STRATEGY = new InjectionToken(NG_DEV_MODE$4 ? 'CUSTOM_NGXS_EXECUTION_STRATEGY' : '');
|
|
120
125
|
/**
|
|
121
126
|
* The injection token is used internally to resolve an instance of the execution
|
|
122
127
|
* strategy. It checks whether consumers have provided their own `executionStrategy`
|
|
123
128
|
* and also verifies if we are operating in a zone-aware environment.
|
|
124
129
|
*/
|
|
125
|
-
const NGXS_EXECUTION_STRATEGY = new InjectionToken(NG_DEV_MODE$
|
|
130
|
+
const NGXS_EXECUTION_STRATEGY = new InjectionToken(NG_DEV_MODE$4 ? 'NGXS_EXECUTION_STRATEGY' : '', {
|
|
126
131
|
providedIn: 'root',
|
|
127
132
|
factory: () => {
|
|
128
133
|
const injector = inject(INJECTOR);
|
|
@@ -515,21 +520,21 @@ const mergeDeep = (base, ...sources) => {
|
|
|
515
520
|
return mergeDeep(base, ...sources);
|
|
516
521
|
};
|
|
517
522
|
|
|
518
|
-
const NG_DEV_MODE$
|
|
523
|
+
const NG_DEV_MODE$3 = typeof ngDevMode === 'undefined' || ngDevMode;
|
|
519
524
|
// The injection token is used to resolve a list of states provided at
|
|
520
525
|
// the root level through either `NgxsModule.forRoot` or `provideStore`.
|
|
521
|
-
const ROOT_STATE_TOKEN = new InjectionToken(NG_DEV_MODE$
|
|
526
|
+
const ROOT_STATE_TOKEN = new InjectionToken(NG_DEV_MODE$3 ? 'ROOT_STATE_TOKEN' : '');
|
|
522
527
|
// The injection token is used to resolve a list of states provided at
|
|
523
528
|
// the feature level through either `NgxsModule.forFeature` or `provideStates`.
|
|
524
529
|
// The Array<Array> is used to overload the resolved value of the token because
|
|
525
530
|
// it is a multi-provider token.
|
|
526
|
-
const FEATURE_STATE_TOKEN = new InjectionToken(NG_DEV_MODE$
|
|
531
|
+
const FEATURE_STATE_TOKEN = new InjectionToken(NG_DEV_MODE$3 ? 'FEATURE_STATE_TOKEN' : '');
|
|
527
532
|
// The injection token is used to resolve to custom NGXS plugins provided
|
|
528
533
|
// at the root level through either `{provide}` scheme or `withNgxsPlugin`.
|
|
529
|
-
const NGXS_PLUGINS = new InjectionToken(NG_DEV_MODE$
|
|
534
|
+
const NGXS_PLUGINS = new InjectionToken(NG_DEV_MODE$3 ? 'NGXS_PLUGINS' : '');
|
|
530
535
|
// The injection token is used to resolve to options provided at the root
|
|
531
536
|
// level through either `NgxsModule.forRoot` or `provideStore`.
|
|
532
|
-
const NGXS_OPTIONS = new InjectionToken(NG_DEV_MODE$
|
|
537
|
+
const NGXS_OPTIONS = new InjectionToken(NG_DEV_MODE$3 ? 'NGXS_OPTIONS' : '');
|
|
533
538
|
/**
|
|
534
539
|
* The NGXS config settings.
|
|
535
540
|
*/
|
|
@@ -1380,7 +1385,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.4", ngImpor
|
|
|
1380
1385
|
args: [NGXS_DEVELOPMENT_OPTIONS]
|
|
1381
1386
|
}] }]; } });
|
|
1382
1387
|
|
|
1383
|
-
const NG_DEV_MODE$
|
|
1388
|
+
const NG_DEV_MODE$2 = typeof ngDevMode === 'undefined' || ngDevMode;
|
|
1384
1389
|
/**
|
|
1385
1390
|
* The `StateFactory` class adds root and feature states to the graph.
|
|
1386
1391
|
* This extracts state names from state classes, checks if they already
|
|
@@ -1472,7 +1477,7 @@ class StateFactory {
|
|
|
1472
1477
|
* Add a new state to the global defs.
|
|
1473
1478
|
*/
|
|
1474
1479
|
add(stateClasses) {
|
|
1475
|
-
if (NG_DEV_MODE$
|
|
1480
|
+
if (NG_DEV_MODE$2) {
|
|
1476
1481
|
ensureStatesAreDecorated(stateClasses);
|
|
1477
1482
|
}
|
|
1478
1483
|
const { newStates } = this.addToStatesMap(stateClasses);
|
|
@@ -1492,7 +1497,7 @@ class StateFactory {
|
|
|
1492
1497
|
// `State` decorator. This check is moved here because the `ɵprov` property
|
|
1493
1498
|
// will not exist on the class in JIT mode (because it's set asynchronously
|
|
1494
1499
|
// during JIT compilation through `Object.defineProperty`).
|
|
1495
|
-
if (NG_DEV_MODE$
|
|
1500
|
+
if (NG_DEV_MODE$2) {
|
|
1496
1501
|
ensureStateClassIsInjectable(stateClass);
|
|
1497
1502
|
}
|
|
1498
1503
|
const stateMap = {
|
|
@@ -1594,7 +1599,7 @@ class StateFactory {
|
|
|
1594
1599
|
}
|
|
1595
1600
|
// The `NgxsUnhandledActionsLogger` is a tree-shakable class which functions
|
|
1596
1601
|
// only during development.
|
|
1597
|
-
if (NG_DEV_MODE$
|
|
1602
|
+
if (NG_DEV_MODE$2 && !actionHasBeenHandled) {
|
|
1598
1603
|
const unhandledActionsLogger = this._injector.get(NgxsUnhandledActionsLogger, null);
|
|
1599
1604
|
// The `NgxsUnhandledActionsLogger` will not be resolved by the injector if the
|
|
1600
1605
|
// `NgxsDevelopmentModule` is not provided. It's enough to check whether the `injector.get`
|
|
@@ -1613,7 +1618,7 @@ class StateFactory {
|
|
|
1613
1618
|
const statesMap = this.statesByName;
|
|
1614
1619
|
for (const stateClass of stateClasses) {
|
|
1615
1620
|
const stateName = getStoreMetadata$1(stateClass).name;
|
|
1616
|
-
if (NG_DEV_MODE$
|
|
1621
|
+
if (NG_DEV_MODE$2) {
|
|
1617
1622
|
ensureStateNameIsUnique(stateName, stateClass, statesMap);
|
|
1618
1623
|
}
|
|
1619
1624
|
const unmountedState = !statesMap[stateName];
|
|
@@ -1767,6 +1772,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.4", ngImpor
|
|
|
1767
1772
|
args: [{ providedIn: 'root' }]
|
|
1768
1773
|
}], ctorParameters: function () { return [{ type: Store }, { type: NgxsConfig }]; } });
|
|
1769
1774
|
|
|
1775
|
+
const NG_DEV_MODE$1 = typeof ngDevMode === 'undefined' || ngDevMode;
|
|
1770
1776
|
class LifecycleStateManager {
|
|
1771
1777
|
constructor(_store, _internalErrorReporter, _internalStateOperations, _stateContextFactory, _bootstrapper) {
|
|
1772
1778
|
this._store = _store;
|
|
@@ -1780,6 +1786,21 @@ class LifecycleStateManager {
|
|
|
1780
1786
|
this._destroy$.next();
|
|
1781
1787
|
}
|
|
1782
1788
|
ngxsBootstrap(action, results) {
|
|
1789
|
+
if (NG_DEV_MODE$1) {
|
|
1790
|
+
if (action instanceof InitState) {
|
|
1791
|
+
this._initStateHasBeenDispatched = true;
|
|
1792
|
+
}
|
|
1793
|
+
else if (
|
|
1794
|
+
// This is a dev mode-only check that ensures the correct order of
|
|
1795
|
+
// state initialization. The `NgxsModule.forRoot` or `provideStore` should
|
|
1796
|
+
// always come first, followed by `forFeature` and `provideStates`. If the
|
|
1797
|
+
// `UpdateState` is dispatched before the `InitState` is dispatched, it indicates
|
|
1798
|
+
// that modules or providers are in an invalid order.
|
|
1799
|
+
action instanceof UpdateState &&
|
|
1800
|
+
!this._initStateHasBeenDispatched) {
|
|
1801
|
+
console.error(getInvalidInitializationOrderMessage());
|
|
1802
|
+
}
|
|
1803
|
+
}
|
|
1783
1804
|
this._internalStateOperations
|
|
1784
1805
|
.getRootStateOperations()
|
|
1785
1806
|
.dispatch(action)
|