@ngxs/store 3.7.6 → 3.8.0-dev.master-c341c15
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/bundles/ngxs-store-internals-testing.umd.js +409 -420
- package/bundles/ngxs-store-internals-testing.umd.js.map +1 -1
- package/bundles/ngxs-store-internals.umd.js +48 -117
- package/bundles/ngxs-store-internals.umd.js.map +1 -1
- package/bundles/ngxs-store-operators.umd.js +62 -402
- package/bundles/ngxs-store-operators.umd.js.map +1 -1
- package/bundles/ngxs-store.umd.js +1296 -3219
- package/bundles/ngxs-store.umd.js.map +1 -1
- package/esm2015/index.js +7 -7
- package/esm2015/internals/angular.js +1 -8
- package/esm2015/internals/index.js +2 -6
- package/esm2015/internals/initial-state.js +1 -21
- package/esm2015/internals/internal-tokens.js +4 -15
- package/esm2015/internals/memoize.js +8 -33
- package/esm2015/internals/ngxs-bootstrapper.js +7 -20
- package/esm2015/internals/ngxs-store-internals.js +2 -6
- package/esm2015/internals/src/symbols.js +2 -14
- package/esm2015/internals/symbols.js +2 -14
- package/esm2015/internals/testing/fresh-platform.js +13 -53
- package/esm2015/internals/testing/helpers/ngxs-test.component.js +11 -17
- package/esm2015/internals/testing/helpers/ngxs-test.module.js +13 -16
- package/esm2015/internals/testing/index.js +1 -5
- package/esm2015/internals/testing/ngxs-store-internals-testing.js +2 -6
- package/esm2015/internals/testing/ngxs.setup.js +1 -31
- package/esm2015/internals/testing/skip-console-logging.js +7 -42
- package/esm2015/internals/testing/symbol.js +2 -29
- package/esm2015/ngxs-store.js +2 -22
- package/esm2015/operators/append.js +7 -18
- package/esm2015/operators/compose.js +4 -22
- package/esm2015/operators/iif.js +12 -30
- package/esm2015/operators/index.js +2 -6
- package/esm2015/operators/insert-item.js +10 -22
- package/esm2015/operators/ngxs-store-operators.js +2 -6
- package/esm2015/operators/patch.js +5 -23
- package/esm2015/operators/remove-item.js +5 -17
- package/esm2015/operators/types.js +2 -0
- package/esm2015/operators/update-item.js +13 -25
- package/esm2015/operators/utils.js +1 -32
- package/esm2015/src/actions/actions.js +1 -18
- package/esm2015/src/actions/symbols.js +2 -39
- package/esm2015/src/actions-stream.js +20 -122
- package/esm2015/src/configs/messages.config.js +1 -44
- package/esm2015/src/decorators/action.js +3 -18
- package/esm2015/src/decorators/select/select-factory.js +10 -27
- package/esm2015/src/decorators/select/select.js +3 -22
- package/esm2015/src/decorators/select/symbols.js +4 -25
- package/esm2015/src/decorators/selector/selector.js +11 -38
- package/esm2015/src/decorators/selector/symbols.js +2 -5
- package/esm2015/src/decorators/selector-options.js +6 -19
- package/esm2015/src/decorators/state.js +5 -44
- package/esm2015/src/dev-features/ngxs-development.module.js +22 -0
- package/esm2015/src/dev-features/ngxs-unhandled-actions-logger.js +46 -0
- package/esm2015/src/dev-features/symbols.js +6 -0
- package/esm2015/src/execution/dispatch-outside-zone-ngxs-execution-strategy.js +10 -56
- package/esm2015/src/execution/internal-ngxs-execution-strategy.js +10 -32
- package/esm2015/src/execution/noop-ngxs-execution-strategy.js +7 -19
- package/esm2015/src/execution/symbols.js +3 -32
- package/esm2015/src/internal/custom-rxjs-subjects.js +81 -0
- package/esm2015/src/internal/dispatcher.js +26 -121
- package/esm2015/src/internal/error-handler.js +18 -72
- package/esm2015/src/internal/internals.js +24 -244
- package/esm2015/src/internal/lifecycle-state-manager.js +19 -117
- package/esm2015/src/internal/state-context-factory.js +8 -66
- package/esm2015/src/internal/state-factory.js +60 -227
- package/esm2015/src/internal/state-operations.js +19 -80
- package/esm2015/src/internal/state-operators.js +15 -28
- package/esm2015/src/internal/state-stream.js +9 -15
- package/esm2015/src/ivy/ivy-enabled-in-dev-mode.js +7 -17
- package/esm2015/src/module.js +12 -47
- package/esm2015/src/modules/ngxs-feature.module.js +18 -36
- package/esm2015/src/modules/ngxs-root.module.js +18 -26
- package/esm2015/src/operators/leave-ngxs.js +8 -43
- package/esm2015/src/operators/of-action.js +16 -105
- package/esm2015/src/plugin-manager.js +17 -50
- package/esm2015/src/plugin_api.js +1 -5
- package/esm2015/src/private_api.js +3 -0
- package/esm2015/src/public_api.js +7 -9
- package/esm2015/src/public_to_deprecate.js +1 -51
- package/esm2015/src/selectors/create-model-selector.js +28 -0
- package/esm2015/src/selectors/create-pick-selector.js +14 -0
- package/esm2015/src/selectors/create-property-selectors.js +18 -0
- package/esm2015/src/selectors/create-selector.js +9 -0
- package/esm2015/src/selectors/index.js +6 -0
- package/esm2015/src/selectors/selector-checks.util.js +18 -0
- package/esm2015/src/selectors/selector-metadata.js +30 -0
- package/esm2015/src/selectors/selector-models.js +2 -0
- package/esm2015/src/selectors/selector-types.util.js +2 -0
- package/esm2015/src/selectors/selector-utils.js +74 -0
- package/esm2015/src/state-token/state-token.js +4 -32
- package/esm2015/src/state-token/symbols.js +2 -5
- package/esm2015/src/store.js +24 -108
- package/esm2015/src/symbols.js +7 -177
- package/esm2015/src/utils/compose.js +5 -23
- package/esm2015/src/utils/freeze.js +5 -20
- package/esm2015/src/utils/store-validators.js +3 -36
- package/esm2015/src/utils/utils.js +13 -64
- package/fesm2015/ngxs-store-internals-testing.js +38 -159
- package/fesm2015/ngxs-store-internals-testing.js.map +1 -1
- package/fesm2015/ngxs-store-internals.js +18 -100
- package/fesm2015/ngxs-store-internals.js.map +1 -1
- package/fesm2015/ngxs-store-operators.js +54 -186
- package/fesm2015/ngxs-store-operators.js.map +1 -1
- package/fesm2015/ngxs-store.js +662 -2488
- package/fesm2015/ngxs-store.js.map +1 -1
- package/index.d.ts +4 -0
- package/internals/index.d.ts +1 -1
- package/internals/internal-tokens.d.ts +2 -8
- package/internals/ngxs-bootstrapper.d.ts +4 -1
- package/internals/ngxs-store-internals.d.ts +1 -0
- package/internals/package.json +2 -5
- package/internals/testing/helpers/ngxs-test.component.d.ts +3 -0
- package/internals/testing/helpers/ngxs-test.module.d.ts +6 -0
- package/internals/testing/ngxs-store-internals-testing.d.ts +1 -0
- package/internals/testing/package.json +2 -5
- package/ngxs-store.d.ts +1 -17
- package/operators/append.d.ts +2 -3
- package/operators/compose.d.ts +2 -2
- package/operators/iif.d.ts +3 -4
- package/operators/index.d.ts +3 -2
- package/operators/insert-item.d.ts +2 -3
- package/operators/ngxs-store-operators.d.ts +1 -0
- package/operators/package.json +2 -5
- package/operators/patch.d.ts +5 -8
- package/operators/remove-item.d.ts +3 -4
- package/operators/types.d.ts +56 -0
- package/operators/update-item.d.ts +3 -4
- package/operators/utils.d.ts +2 -3
- package/package.json +4 -7
- package/src/actions/actions.d.ts +2 -2
- package/src/actions-stream.d.ts +8 -22
- package/src/decorators/select/select-factory.d.ts +3 -0
- package/src/decorators/selector/selector.d.ts +7 -2
- package/src/decorators/state.d.ts +1 -1
- package/src/dev-features/ngxs-development.module.d.ts +9 -0
- package/src/dev-features/ngxs-unhandled-actions-logger.d.ts +17 -0
- package/src/dev-features/symbols.d.ts +8 -0
- package/src/execution/dispatch-outside-zone-ngxs-execution-strategy.d.ts +3 -0
- package/src/execution/internal-ngxs-execution-strategy.d.ts +3 -0
- package/src/execution/noop-ngxs-execution-strategy.d.ts +3 -0
- package/src/internal/custom-rxjs-subjects.d.ts +37 -0
- package/src/internal/dispatcher.d.ts +5 -0
- package/src/internal/error-handler.d.ts +4 -1
- package/src/internal/lifecycle-state-manager.d.ts +3 -0
- package/src/internal/state-context-factory.d.ts +3 -0
- package/src/internal/state-factory.d.ts +7 -4
- package/src/internal/state-operations.d.ts +3 -0
- package/src/internal/state-operators.d.ts +2 -2
- package/src/internal/state-stream.d.ts +5 -2
- package/src/module.d.ts +4 -0
- package/src/modules/ngxs-feature.module.d.ts +4 -0
- package/src/modules/ngxs-root.module.d.ts +4 -0
- package/src/operators/of-action.d.ts +20 -7
- package/src/plugin-manager.d.ts +4 -1
- package/src/private_api.d.ts +2 -0
- package/src/public_api.d.ts +8 -5
- package/src/selectors/create-model-selector.d.ts +10 -0
- package/src/selectors/create-pick-selector.d.ts +6 -0
- package/src/selectors/create-property-selectors.d.ts +5 -0
- package/src/selectors/create-selector.d.ts +19 -0
- package/src/selectors/index.d.ts +5 -0
- package/src/selectors/selector-checks.util.d.ts +9 -0
- package/src/selectors/selector-metadata.d.ts +7 -0
- package/src/selectors/selector-models.d.ts +10 -0
- package/src/selectors/selector-types.util.d.ts +7 -0
- package/src/selectors/selector-utils.d.ts +9 -0
- package/src/store.d.ts +3 -0
- package/src/symbols.d.ts +7 -3
- package/src/utils/utils.d.ts +1 -1
- package/bundles/ngxs-store-internals-testing.umd.min.js +0 -16
- package/bundles/ngxs-store-internals-testing.umd.min.js.map +0 -1
- package/bundles/ngxs-store-internals.umd.min.js +0 -2
- package/bundles/ngxs-store-internals.umd.min.js.map +0 -1
- package/bundles/ngxs-store-operators.umd.min.js +0 -16
- package/bundles/ngxs-store-operators.umd.min.js.map +0 -1
- package/bundles/ngxs-store.umd.min.js +0 -16
- package/bundles/ngxs-store.umd.min.js.map +0 -1
- package/esm2015/operators/internals.js +0 -5
- package/esm2015/src/utils/selector-utils.js +0 -221
- package/esm5/index.js +0 -13
- package/esm5/internals/angular.js +0 -20
- package/esm5/internals/index.js +0 -10
- package/esm5/internals/initial-state.js +0 -45
- package/esm5/internals/internal-tokens.js +0 -16
- package/esm5/internals/memoize.js +0 -71
- package/esm5/internals/ngxs-bootstrapper.js +0 -56
- package/esm5/internals/ngxs-store-internals.js +0 -9
- package/esm5/internals/src/symbols.js +0 -14
- package/esm5/internals/symbols.js +0 -14
- package/esm5/internals/testing/fresh-platform.js +0 -121
- package/esm5/internals/testing/helpers/ngxs-test.component.js +0 -32
- package/esm5/internals/testing/helpers/ngxs-test.module.js +0 -32
- package/esm5/internals/testing/index.js +0 -8
- package/esm5/internals/testing/ngxs-store-internals-testing.js +0 -9
- package/esm5/internals/testing/ngxs.setup.js +0 -98
- package/esm5/internals/testing/skip-console-logging.js +0 -62
- package/esm5/internals/testing/symbol.js +0 -29
- package/esm5/ngxs-store.js +0 -25
- package/esm5/operators/append.js +0 -31
- package/esm5/operators/compose.js +0 -28
- package/esm5/operators/iif.js +0 -56
- package/esm5/operators/index.js +0 -18
- package/esm5/operators/insert-item.js +0 -41
- package/esm5/operators/internals.js +0 -5
- package/esm5/operators/ngxs-store-operators.js +0 -9
- package/esm5/operators/patch.js +0 -40
- package/esm5/operators/remove-item.js +0 -34
- package/esm5/operators/update-item.js +0 -52
- package/esm5/operators/utils.js +0 -50
- package/esm5/src/actions/actions.js +0 -62
- package/esm5/src/actions/symbols.js +0 -39
- package/esm5/src/actions-stream.js +0 -203
- package/esm5/src/configs/messages.config.js +0 -79
- package/esm5/src/decorators/action.js +0 -60
- package/esm5/src/decorators/select/select-factory.js +0 -46
- package/esm5/src/decorators/select/select.js +0 -50
- package/esm5/src/decorators/select/symbols.js +0 -51
- package/esm5/src/decorators/selector/selector.js +0 -59
- package/esm5/src/decorators/selector/symbols.js +0 -5
- package/esm5/src/decorators/selector-options.js +0 -34
- package/esm5/src/decorators/state.js +0 -78
- package/esm5/src/execution/dispatch-outside-zone-ngxs-execution-strategy.js +0 -123
- package/esm5/src/execution/internal-ngxs-execution-strategy.js +0 -54
- package/esm5/src/execution/noop-ngxs-execution-strategy.js +0 -43
- package/esm5/src/execution/symbols.js +0 -52
- package/esm5/src/internal/dispatcher.js +0 -231
- package/esm5/src/internal/error-handler.js +0 -125
- package/esm5/src/internal/internals.js +0 -470
- package/esm5/src/internal/lifecycle-state-manager.js +0 -224
- package/esm5/src/internal/state-context-factory.js +0 -135
- package/esm5/src/internal/state-factory.js +0 -583
- package/esm5/src/internal/state-operations.js +0 -134
- package/esm5/src/internal/state-operators.js +0 -34
- package/esm5/src/internal/state-stream.js +0 -37
- package/esm5/src/ivy/ivy-enabled-in-dev-mode.js +0 -28
- package/esm5/src/module.js +0 -202
- package/esm5/src/modules/ngxs-feature.module.js +0 -65
- package/esm5/src/modules/ngxs-root.module.js +0 -44
- package/esm5/src/operators/leave-ngxs.js +0 -58
- package/esm5/src/operators/of-action.js +0 -217
- package/esm5/src/plugin-manager.js +0 -82
- package/esm5/src/plugin_api.js +0 -10
- package/esm5/src/public_api.js +0 -29
- package/esm5/src/public_to_deprecate.js +0 -64
- package/esm5/src/state-token/state-token.js +0 -57
- package/esm5/src/state-token/symbols.js +0 -5
- package/esm5/src/store.js +0 -241
- package/esm5/src/symbols.js +0 -230
- package/esm5/src/utils/compose.js +0 -55
- package/esm5/src/utils/freeze.js +0 -35
- package/esm5/src/utils/selector-utils.js +0 -230
- package/esm5/src/utils/store-validators.js +0 -78
- package/esm5/src/utils/utils.js +0 -151
- package/fesm5/ngxs-store-internals-testing.js +0 -345
- package/fesm5/ngxs-store-internals-testing.js.map +0 -1
- package/fesm5/ngxs-store-internals.js +0 -217
- package/fesm5/ngxs-store-internals.js.map +0 -1
- package/fesm5/ngxs-store-operators.js +0 -340
- package/fesm5/ngxs-store-operators.js.map +0 -1
- package/fesm5/ngxs-store.js +0 -4619
- package/fesm5/ngxs-store.js.map +0 -1
- package/internals/ngxs-store-internals.metadata.json +0 -1
- package/internals/testing/ngxs-store-internals-testing.metadata.json +0 -1
- package/ngxs-store.metadata.json +0 -1
- package/operators/internals.d.ts +0 -2
- package/operators/ngxs-store-operators.metadata.json +0 -1
- package/src/utils/selector-utils.d.ts +0 -23
- package/types/index.d.ts +0 -2
package/fesm2015/ngxs-store.js
CHANGED
|
@@ -1,97 +1,48 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
1
|
+
import * as i0 from '@angular/core';
|
|
2
|
+
import { NgZone, PLATFORM_ID, Injectable, Inject, InjectionToken, inject, INJECTOR, ɵglobal, ErrorHandler, Optional, SkipSelf, NgModule, APP_BOOTSTRAP_LISTENER } from '@angular/core';
|
|
3
|
+
import * as i5 from '@ngxs/store/internals';
|
|
4
|
+
import { memoize, INITIAL_STATE_TOKEN, NgxsBootstrapper, ɵNGXS_STATE_CONTEXT_FACTORY, ɵNGXS_STATE_FACTORY, InitialState } from '@ngxs/store/internals';
|
|
3
5
|
import { isPlatformServer } from '@angular/common';
|
|
4
|
-
import { Observable, Subject, BehaviorSubject, of, forkJoin, throwError, EMPTY, from, isObservable
|
|
5
|
-
import { filter, map, share, shareReplay, take, exhaustMap, mergeMap, defaultIfEmpty, catchError, takeUntil,
|
|
6
|
+
import { Observable, Subject, BehaviorSubject, of, forkJoin, throwError, EMPTY, from, isObservable } from 'rxjs';
|
|
7
|
+
import { filter, map, share, shareReplay, take, exhaustMap, mergeMap, defaultIfEmpty, catchError, takeUntil, distinctUntilChanged, tap, startWith, pairwise } from 'rxjs/operators';
|
|
6
8
|
|
|
7
|
-
/**
|
|
8
|
-
* @fileoverview added by tsickle
|
|
9
|
-
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
10
|
-
*/
|
|
11
|
-
/**
|
|
12
|
-
* @param {?} name
|
|
13
|
-
* @return {?}
|
|
14
|
-
*/
|
|
15
9
|
function throwStateNameError(name) {
|
|
16
10
|
throw new Error(`${name} is not a valid state name. It needs to be a valid object property name.`);
|
|
17
11
|
}
|
|
18
|
-
/**
|
|
19
|
-
* @return {?}
|
|
20
|
-
*/
|
|
21
12
|
function throwStateNamePropertyError() {
|
|
22
13
|
throw new Error(`States must register a 'name' property.`);
|
|
23
14
|
}
|
|
24
|
-
/**
|
|
25
|
-
* @param {?} current
|
|
26
|
-
* @param {?} newName
|
|
27
|
-
* @param {?} oldName
|
|
28
|
-
* @return {?}
|
|
29
|
-
*/
|
|
30
15
|
function throwStateUniqueError(current, newName, oldName) {
|
|
31
16
|
throw new Error(`State name '${current}' from ${newName} already exists in ${oldName}.`);
|
|
32
17
|
}
|
|
33
|
-
/**
|
|
34
|
-
* @param {?} name
|
|
35
|
-
* @return {?}
|
|
36
|
-
*/
|
|
37
18
|
function throwStateDecoratorError(name) {
|
|
38
19
|
throw new Error(`States must be decorated with @State() decorator, but "${name}" isn't.`);
|
|
39
20
|
}
|
|
40
|
-
/**
|
|
41
|
-
* @return {?}
|
|
42
|
-
*/
|
|
43
21
|
function throwActionDecoratorError() {
|
|
44
22
|
throw new Error('@Action() decorator cannot be used with static methods.');
|
|
45
23
|
}
|
|
46
|
-
/**
|
|
47
|
-
* @return {?}
|
|
48
|
-
*/
|
|
49
24
|
function throwSelectorDecoratorError() {
|
|
50
25
|
throw new Error('Selectors only work on methods.');
|
|
51
26
|
}
|
|
52
|
-
/**
|
|
53
|
-
* @return {?}
|
|
54
|
-
*/
|
|
55
27
|
function getZoneWarningMessage() {
|
|
56
28
|
return ('Your application was bootstrapped with nooped zone and your execution strategy requires an actual NgZone!\n' +
|
|
57
29
|
'Please set the value of the executionStrategy property to NoopNgxsExecutionStrategy.\n' +
|
|
58
30
|
'NgxsModule.forRoot(states, { executionStrategy: NoopNgxsExecutionStrategy })');
|
|
59
31
|
}
|
|
60
|
-
/**
|
|
61
|
-
* @param {?} name
|
|
62
|
-
* @return {?}
|
|
63
|
-
*/
|
|
64
32
|
function getUndecoratedStateInIvyWarningMessage(name) {
|
|
65
33
|
return `'${name}' class should be decorated with @Injectable() right after the @State() decorator`;
|
|
66
34
|
}
|
|
67
|
-
/**
|
|
68
|
-
* @return {?}
|
|
69
|
-
*/
|
|
70
35
|
function throwSelectFactoryNotConnectedError() {
|
|
71
36
|
throw new Error('You have forgotten to import the NGXS module!');
|
|
72
37
|
}
|
|
73
|
-
/**
|
|
74
|
-
* @return {?}
|
|
75
|
-
*/
|
|
76
38
|
function throwPatchingArrayError() {
|
|
77
39
|
throw new Error('Patching arrays is not supported.');
|
|
78
40
|
}
|
|
79
|
-
/**
|
|
80
|
-
* @return {?}
|
|
81
|
-
*/
|
|
82
41
|
function throwPatchingPrimitiveError() {
|
|
83
42
|
throw new Error('Patching primitives is not supported.');
|
|
84
43
|
}
|
|
85
44
|
|
|
86
|
-
/**
|
|
87
|
-
* @fileoverview added by tsickle
|
|
88
|
-
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
89
|
-
*/
|
|
90
45
|
class DispatchOutsideZoneNgxsExecutionStrategy {
|
|
91
|
-
/**
|
|
92
|
-
* @param {?} _ngZone
|
|
93
|
-
* @param {?} _platformId
|
|
94
|
-
*/
|
|
95
46
|
constructor(_ngZone, _platformId) {
|
|
96
47
|
this._ngZone = _ngZone;
|
|
97
48
|
this._platformId = _platformId;
|
|
@@ -101,43 +52,21 @@ class DispatchOutsideZoneNgxsExecutionStrategy {
|
|
|
101
52
|
verifyZoneIsNotNooped(_ngZone);
|
|
102
53
|
}
|
|
103
54
|
}
|
|
104
|
-
/**
|
|
105
|
-
* @template T
|
|
106
|
-
* @param {?} func
|
|
107
|
-
* @return {?}
|
|
108
|
-
*/
|
|
109
55
|
enter(func) {
|
|
110
56
|
if (isPlatformServer(this._platformId)) {
|
|
111
57
|
return this.runInsideAngular(func);
|
|
112
58
|
}
|
|
113
59
|
return this.runOutsideAngular(func);
|
|
114
60
|
}
|
|
115
|
-
/**
|
|
116
|
-
* @template T
|
|
117
|
-
* @param {?} func
|
|
118
|
-
* @return {?}
|
|
119
|
-
*/
|
|
120
61
|
leave(func) {
|
|
121
62
|
return this.runInsideAngular(func);
|
|
122
63
|
}
|
|
123
|
-
/**
|
|
124
|
-
* @private
|
|
125
|
-
* @template T
|
|
126
|
-
* @param {?} func
|
|
127
|
-
* @return {?}
|
|
128
|
-
*/
|
|
129
64
|
runInsideAngular(func) {
|
|
130
65
|
if (NgZone.isInAngularZone()) {
|
|
131
66
|
return func();
|
|
132
67
|
}
|
|
133
68
|
return this._ngZone.run(func);
|
|
134
69
|
}
|
|
135
|
-
/**
|
|
136
|
-
* @private
|
|
137
|
-
* @template T
|
|
138
|
-
* @param {?} func
|
|
139
|
-
* @return {?}
|
|
140
|
-
*/
|
|
141
70
|
runOutsideAngular(func) {
|
|
142
71
|
if (NgZone.isInAngularZone()) {
|
|
143
72
|
return this._ngZone.runOutsideAngular(func);
|
|
@@ -145,33 +74,17 @@ class DispatchOutsideZoneNgxsExecutionStrategy {
|
|
|
145
74
|
return func();
|
|
146
75
|
}
|
|
147
76
|
}
|
|
148
|
-
DispatchOutsideZoneNgxsExecutionStrategy
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
]
|
|
156
|
-
|
|
157
|
-
if (false) {
|
|
158
|
-
/**
|
|
159
|
-
* @type {?}
|
|
160
|
-
* @private
|
|
161
|
-
*/
|
|
162
|
-
DispatchOutsideZoneNgxsExecutionStrategy.prototype._ngZone;
|
|
163
|
-
/**
|
|
164
|
-
* @type {?}
|
|
165
|
-
* @private
|
|
166
|
-
*/
|
|
167
|
-
DispatchOutsideZoneNgxsExecutionStrategy.prototype._platformId;
|
|
168
|
-
}
|
|
77
|
+
/** @nocollapse */ DispatchOutsideZoneNgxsExecutionStrategy.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: DispatchOutsideZoneNgxsExecutionStrategy, deps: [{ token: i0.NgZone }, { token: PLATFORM_ID }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
78
|
+
/** @nocollapse */ DispatchOutsideZoneNgxsExecutionStrategy.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: DispatchOutsideZoneNgxsExecutionStrategy, providedIn: 'root' });
|
|
79
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: DispatchOutsideZoneNgxsExecutionStrategy, decorators: [{
|
|
80
|
+
type: Injectable,
|
|
81
|
+
args: [{ providedIn: 'root' }]
|
|
82
|
+
}], ctorParameters: function () { return [{ type: i0.NgZone }, { type: undefined, decorators: [{
|
|
83
|
+
type: Inject,
|
|
84
|
+
args: [PLATFORM_ID]
|
|
85
|
+
}] }]; } });
|
|
169
86
|
// Caretaker note: this should exist as a separate function and not a class method,
|
|
170
87
|
// since class methods are not tree-shakable.
|
|
171
|
-
/**
|
|
172
|
-
* @param {?} ngZone
|
|
173
|
-
* @return {?}
|
|
174
|
-
*/
|
|
175
88
|
function verifyZoneIsNotNooped(ngZone) {
|
|
176
89
|
// `NoopNgZone` is not exposed publicly as it doesn't expect
|
|
177
90
|
// to be used outside of the core Angular code, thus we just have
|
|
@@ -182,21 +95,11 @@ function verifyZoneIsNotNooped(ngZone) {
|
|
|
182
95
|
console.warn(getZoneWarningMessage());
|
|
183
96
|
}
|
|
184
97
|
|
|
185
|
-
/**
|
|
186
|
-
* @fileoverview added by tsickle
|
|
187
|
-
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
188
|
-
*/
|
|
189
|
-
/** @type {?} */
|
|
190
98
|
const ROOT_STATE_TOKEN = new InjectionToken('ROOT_STATE_TOKEN');
|
|
191
|
-
/** @type {?} */
|
|
192
99
|
const FEATURE_STATE_TOKEN = new InjectionToken('FEATURE_STATE_TOKEN');
|
|
193
|
-
/** @type {?} */
|
|
194
100
|
const NGXS_PLUGINS = new InjectionToken('NGXS_PLUGINS');
|
|
195
|
-
/** @type {?} */
|
|
196
101
|
const META_KEY = 'NGXS_META';
|
|
197
|
-
/** @type {?} */
|
|
198
102
|
const META_OPTIONS_KEY = 'NGXS_OPTIONS_META';
|
|
199
|
-
/** @type {?} */
|
|
200
103
|
const SELECTOR_META_KEY = 'NGXS_SELECTOR_META';
|
|
201
104
|
/**
|
|
202
105
|
* The NGXS config settings.
|
|
@@ -215,7 +118,6 @@ class NgxsConfig {
|
|
|
215
118
|
*/
|
|
216
119
|
this.selectorOptions = {
|
|
217
120
|
injectContainerState: true,
|
|
218
|
-
// TODO: default is true in v3, will change in v4
|
|
219
121
|
suppressErrors: true // TODO: default is true in v3, will change in v4
|
|
220
122
|
};
|
|
221
123
|
this.compatibility = {
|
|
@@ -224,402 +126,70 @@ class NgxsConfig {
|
|
|
224
126
|
this.executionStrategy = DispatchOutsideZoneNgxsExecutionStrategy;
|
|
225
127
|
}
|
|
226
128
|
}
|
|
227
|
-
NgxsConfig
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
if (false) {
|
|
233
|
-
/**
|
|
234
|
-
* Run in development mode. This will add additional debugging features:
|
|
235
|
-
* - Object.freeze on the state and actions to guarantee immutability
|
|
236
|
-
* (default: false)
|
|
237
|
-
*
|
|
238
|
-
* Note: this property will be accounted only in development mode when using the Ivy compiler.
|
|
239
|
-
* It makes sense to use it only during development to ensure there're no state mutations.
|
|
240
|
-
* When building for production, the Object.freeze will be tree-shaken away.
|
|
241
|
-
* @type {?}
|
|
242
|
-
*/
|
|
243
|
-
NgxsConfig.prototype.developmentMode;
|
|
244
|
-
/** @type {?} */
|
|
245
|
-
NgxsConfig.prototype.compatibility;
|
|
246
|
-
/**
|
|
247
|
-
* Determines the execution context to perform async operations inside. An implementation can be
|
|
248
|
-
* provided to override the default behaviour where the async operations are run
|
|
249
|
-
* outside Angular's zone but all observable behaviours of NGXS are run back inside Angular's zone.
|
|
250
|
-
* These observable behaviours are from:
|
|
251
|
-
* `\@Select(...)`, `store.select(...)`, `actions.subscribe(...)` or `store.dispatch(...).subscribe(...)`
|
|
252
|
-
* Every `zone.run` causes Angular to run change detection on the whole tree (`app.tick()`) so of your
|
|
253
|
-
* application doesn't rely on zone.js running change detection then you can switch to the
|
|
254
|
-
* `NoopNgxsExecutionStrategy` that doesn't interact with zones.
|
|
255
|
-
* (default: null)
|
|
256
|
-
* @type {?}
|
|
257
|
-
*/
|
|
258
|
-
NgxsConfig.prototype.executionStrategy;
|
|
259
|
-
/**
|
|
260
|
-
* Defining the default state before module initialization
|
|
261
|
-
* This is convenient if we need to create a define our own set of states.
|
|
262
|
-
* @deprecated will be removed after v4
|
|
263
|
-
* (default: {})
|
|
264
|
-
* @type {?}
|
|
265
|
-
*/
|
|
266
|
-
NgxsConfig.prototype.defaultsState;
|
|
267
|
-
/**
|
|
268
|
-
* Defining shared selector options
|
|
269
|
-
* @type {?}
|
|
270
|
-
*/
|
|
271
|
-
NgxsConfig.prototype.selectorOptions;
|
|
272
|
-
}
|
|
273
|
-
/**
|
|
274
|
-
* State context provided to the actions in the state.
|
|
275
|
-
* @record
|
|
276
|
-
* @template T
|
|
277
|
-
*/
|
|
278
|
-
function StateContext() { }
|
|
279
|
-
if (false) {
|
|
280
|
-
/**
|
|
281
|
-
* Get the current state.
|
|
282
|
-
* @return {?}
|
|
283
|
-
*/
|
|
284
|
-
StateContext.prototype.getState = function () { };
|
|
285
|
-
/**
|
|
286
|
-
* Reset the state to a new value.
|
|
287
|
-
* @param {?} val
|
|
288
|
-
* @return {?}
|
|
289
|
-
*/
|
|
290
|
-
StateContext.prototype.setState = function (val) { };
|
|
291
|
-
/**
|
|
292
|
-
* Patch the existing state with the provided value.
|
|
293
|
-
* @param {?} val
|
|
294
|
-
* @return {?}
|
|
295
|
-
*/
|
|
296
|
-
StateContext.prototype.patchState = function (val) { };
|
|
297
|
-
/**
|
|
298
|
-
* Dispatch a new action and return the dispatched observable.
|
|
299
|
-
* @param {?} actions
|
|
300
|
-
* @return {?}
|
|
301
|
-
*/
|
|
302
|
-
StateContext.prototype.dispatch = function (actions) { };
|
|
303
|
-
}
|
|
304
|
-
/**
|
|
305
|
-
* Plugin interface
|
|
306
|
-
* @record
|
|
307
|
-
*/
|
|
308
|
-
function NgxsPlugin() { }
|
|
309
|
-
if (false) {
|
|
310
|
-
/**
|
|
311
|
-
* Handle the state/action before its submitted to the state handlers.
|
|
312
|
-
* @param {?} state
|
|
313
|
-
* @param {?} action
|
|
314
|
-
* @param {?} next
|
|
315
|
-
* @return {?}
|
|
316
|
-
*/
|
|
317
|
-
NgxsPlugin.prototype.handle = function (state, action, next) { };
|
|
318
|
-
}
|
|
319
|
-
/**
|
|
320
|
-
* Options that can be provided to the store.
|
|
321
|
-
* @record
|
|
322
|
-
* @template T
|
|
323
|
-
*/
|
|
324
|
-
function StoreOptions() { }
|
|
325
|
-
if (false) {
|
|
326
|
-
/**
|
|
327
|
-
* Name of the state. Required.
|
|
328
|
-
* @type {?}
|
|
329
|
-
*/
|
|
330
|
-
StoreOptions.prototype.name;
|
|
331
|
-
/**
|
|
332
|
-
* Default values for the state. If not provided, uses empty object.
|
|
333
|
-
* @type {?|undefined}
|
|
334
|
-
*/
|
|
335
|
-
StoreOptions.prototype.defaults;
|
|
336
|
-
/**
|
|
337
|
-
* Sub states for the given state.
|
|
338
|
-
* @type {?|undefined}
|
|
339
|
-
*/
|
|
340
|
-
StoreOptions.prototype.children;
|
|
341
|
-
}
|
|
129
|
+
/** @nocollapse */ NgxsConfig.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: NgxsConfig, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
130
|
+
/** @nocollapse */ NgxsConfig.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: NgxsConfig });
|
|
131
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: NgxsConfig, decorators: [{
|
|
132
|
+
type: Injectable
|
|
133
|
+
}], ctorParameters: function () { return []; } });
|
|
342
134
|
/**
|
|
343
135
|
* Represents a basic change from a previous to a new value for a single state instance.
|
|
344
136
|
* Passed as a value in a NgxsSimpleChanges object to the ngxsOnChanges hook.
|
|
345
|
-
* @template T
|
|
346
137
|
*/
|
|
347
138
|
class NgxsSimpleChange {
|
|
348
|
-
/**
|
|
349
|
-
* @param {?} previousValue
|
|
350
|
-
* @param {?} currentValue
|
|
351
|
-
* @param {?} firstChange
|
|
352
|
-
*/
|
|
353
139
|
constructor(previousValue, currentValue, firstChange) {
|
|
354
140
|
this.previousValue = previousValue;
|
|
355
141
|
this.currentValue = currentValue;
|
|
356
142
|
this.firstChange = firstChange;
|
|
357
143
|
}
|
|
358
144
|
}
|
|
359
|
-
if (false) {
|
|
360
|
-
/** @type {?} */
|
|
361
|
-
NgxsSimpleChange.prototype.previousValue;
|
|
362
|
-
/** @type {?} */
|
|
363
|
-
NgxsSimpleChange.prototype.currentValue;
|
|
364
|
-
/** @type {?} */
|
|
365
|
-
NgxsSimpleChange.prototype.firstChange;
|
|
366
|
-
}
|
|
367
|
-
/**
|
|
368
|
-
* On init interface
|
|
369
|
-
* @record
|
|
370
|
-
*/
|
|
371
|
-
function NgxsOnInit() { }
|
|
372
|
-
if (false) {
|
|
373
|
-
/**
|
|
374
|
-
* @param {?} ctx
|
|
375
|
-
* @return {?}
|
|
376
|
-
*/
|
|
377
|
-
NgxsOnInit.prototype.ngxsOnInit = function (ctx) { };
|
|
378
|
-
}
|
|
379
|
-
/**
|
|
380
|
-
* On change interface
|
|
381
|
-
* @record
|
|
382
|
-
*/
|
|
383
|
-
function NgxsOnChanges() { }
|
|
384
|
-
if (false) {
|
|
385
|
-
/**
|
|
386
|
-
* @param {?} change
|
|
387
|
-
* @return {?}
|
|
388
|
-
*/
|
|
389
|
-
NgxsOnChanges.prototype.ngxsOnChanges = function (change) { };
|
|
390
|
-
}
|
|
391
|
-
/**
|
|
392
|
-
* After bootstrap interface
|
|
393
|
-
* @record
|
|
394
|
-
*/
|
|
395
|
-
function NgxsAfterBootstrap() { }
|
|
396
|
-
if (false) {
|
|
397
|
-
/**
|
|
398
|
-
* @param {?} ctx
|
|
399
|
-
* @return {?}
|
|
400
|
-
*/
|
|
401
|
-
NgxsAfterBootstrap.prototype.ngxsAfterBootstrap = function (ctx) { };
|
|
402
|
-
}
|
|
403
145
|
|
|
404
|
-
/**
|
|
405
|
-
* @fileoverview added by tsickle
|
|
406
|
-
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
407
|
-
*/
|
|
408
146
|
class NoopNgxsExecutionStrategy {
|
|
409
|
-
/**
|
|
410
|
-
* @template T
|
|
411
|
-
* @param {?} func
|
|
412
|
-
* @return {?}
|
|
413
|
-
*/
|
|
414
147
|
enter(func) {
|
|
415
148
|
return func();
|
|
416
149
|
}
|
|
417
|
-
/**
|
|
418
|
-
* @template T
|
|
419
|
-
* @param {?} func
|
|
420
|
-
* @return {?}
|
|
421
|
-
*/
|
|
422
150
|
leave(func) {
|
|
423
151
|
return func();
|
|
424
152
|
}
|
|
425
153
|
}
|
|
426
|
-
NoopNgxsExecutionStrategy
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
154
|
+
/** @nocollapse */ NoopNgxsExecutionStrategy.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: NoopNgxsExecutionStrategy, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
155
|
+
/** @nocollapse */ NoopNgxsExecutionStrategy.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: NoopNgxsExecutionStrategy, providedIn: 'root' });
|
|
156
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: NoopNgxsExecutionStrategy, decorators: [{
|
|
157
|
+
type: Injectable,
|
|
158
|
+
args: [{ providedIn: 'root' }]
|
|
159
|
+
}] });
|
|
430
160
|
|
|
431
|
-
/**
|
|
432
|
-
* @fileoverview added by tsickle
|
|
433
|
-
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
434
|
-
*/
|
|
435
161
|
/**
|
|
436
162
|
* The strategy that might be provided by users through `options.executionStrategy`.
|
|
437
|
-
* @type {?}
|
|
438
163
|
*/
|
|
439
164
|
const USER_PROVIDED_NGXS_EXECUTION_STRATEGY = new InjectionToken('USER_PROVIDED_NGXS_EXECUTION_STRATEGY');
|
|
440
165
|
/*
|
|
441
166
|
* Internal execution strategy injection token
|
|
442
167
|
*/
|
|
443
|
-
/** @type {?} */
|
|
444
168
|
const NGXS_EXECUTION_STRATEGY = new InjectionToken('NGXS_EXECUTION_STRATEGY', {
|
|
445
169
|
providedIn: 'root',
|
|
446
|
-
factory: (
|
|
447
|
-
* @return {?}
|
|
448
|
-
*/
|
|
449
|
-
() => {
|
|
450
|
-
/** @type {?} */
|
|
170
|
+
factory: () => {
|
|
451
171
|
const injector = inject(INJECTOR);
|
|
452
|
-
/** @type {?} */
|
|
453
172
|
const executionStrategy = injector.get(USER_PROVIDED_NGXS_EXECUTION_STRATEGY);
|
|
454
173
|
return executionStrategy
|
|
455
174
|
? injector.get(executionStrategy)
|
|
456
175
|
: injector.get(typeof ɵglobal.Zone !== 'undefined'
|
|
457
176
|
? DispatchOutsideZoneNgxsExecutionStrategy
|
|
458
177
|
: NoopNgxsExecutionStrategy);
|
|
459
|
-
}
|
|
178
|
+
}
|
|
460
179
|
});
|
|
461
|
-
/**
|
|
462
|
-
* @record
|
|
463
|
-
*/
|
|
464
|
-
function NgxsExecutionStrategy() { }
|
|
465
|
-
if (false) {
|
|
466
|
-
/**
|
|
467
|
-
* @template T
|
|
468
|
-
* @param {?} func
|
|
469
|
-
* @return {?}
|
|
470
|
-
*/
|
|
471
|
-
NgxsExecutionStrategy.prototype.enter = function (func) { };
|
|
472
|
-
/**
|
|
473
|
-
* @template T
|
|
474
|
-
* @param {?} func
|
|
475
|
-
* @return {?}
|
|
476
|
-
*/
|
|
477
|
-
NgxsExecutionStrategy.prototype.leave = function (func) { };
|
|
478
|
-
}
|
|
479
180
|
|
|
480
|
-
/**
|
|
481
|
-
* @fileoverview added by tsickle
|
|
482
|
-
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
483
|
-
*/
|
|
484
|
-
/**
|
|
485
|
-
* @record
|
|
486
|
-
* @template T, U
|
|
487
|
-
*/
|
|
488
|
-
function StateClassInternal() { }
|
|
489
|
-
if (false) {
|
|
490
|
-
/* Skipping unnamed member:
|
|
491
|
-
[META_KEY]?: MetaDataModel;*/
|
|
492
|
-
/* Skipping unnamed member:
|
|
493
|
-
[META_OPTIONS_KEY]?: StoreOptions<U>;*/
|
|
494
|
-
}
|
|
495
|
-
/**
|
|
496
|
-
* @record
|
|
497
|
-
* @template T
|
|
498
|
-
*/
|
|
499
|
-
function StateOperations() { }
|
|
500
|
-
if (false) {
|
|
501
|
-
/**
|
|
502
|
-
* @return {?}
|
|
503
|
-
*/
|
|
504
|
-
StateOperations.prototype.getState = function () { };
|
|
505
|
-
/**
|
|
506
|
-
* @param {?} val
|
|
507
|
-
* @return {?}
|
|
508
|
-
*/
|
|
509
|
-
StateOperations.prototype.setState = function (val) { };
|
|
510
|
-
/**
|
|
511
|
-
* @param {?} actionOrActions
|
|
512
|
-
* @return {?}
|
|
513
|
-
*/
|
|
514
|
-
StateOperations.prototype.dispatch = function (actionOrActions) { };
|
|
515
|
-
}
|
|
516
|
-
/**
|
|
517
|
-
* @record
|
|
518
|
-
*/
|
|
519
|
-
function MetaDataModel() { }
|
|
520
|
-
if (false) {
|
|
521
|
-
/** @type {?} */
|
|
522
|
-
MetaDataModel.prototype.name;
|
|
523
|
-
/** @type {?} */
|
|
524
|
-
MetaDataModel.prototype.actions;
|
|
525
|
-
/** @type {?} */
|
|
526
|
-
MetaDataModel.prototype.defaults;
|
|
527
|
-
/** @type {?} */
|
|
528
|
-
MetaDataModel.prototype.path;
|
|
529
|
-
/** @type {?} */
|
|
530
|
-
MetaDataModel.prototype.makeRootSelector;
|
|
531
|
-
/** @type {?|undefined} */
|
|
532
|
-
MetaDataModel.prototype.children;
|
|
533
|
-
}
|
|
534
|
-
/**
|
|
535
|
-
* @record
|
|
536
|
-
*/
|
|
537
|
-
function RuntimeSelectorContext() { }
|
|
538
|
-
if (false) {
|
|
539
|
-
/**
|
|
540
|
-
* @param {?} key
|
|
541
|
-
* @return {?}
|
|
542
|
-
*/
|
|
543
|
-
RuntimeSelectorContext.prototype.getStateGetter = function (key) { };
|
|
544
|
-
/**
|
|
545
|
-
* @param {?=} localOptions
|
|
546
|
-
* @return {?}
|
|
547
|
-
*/
|
|
548
|
-
RuntimeSelectorContext.prototype.getSelectorOptions = function (localOptions) { };
|
|
549
|
-
}
|
|
550
|
-
/**
|
|
551
|
-
* @record
|
|
552
|
-
*/
|
|
553
|
-
function SharedSelectorOptions() { }
|
|
554
|
-
if (false) {
|
|
555
|
-
/** @type {?|undefined} */
|
|
556
|
-
SharedSelectorOptions.prototype.injectContainerState;
|
|
557
|
-
/** @type {?|undefined} */
|
|
558
|
-
SharedSelectorOptions.prototype.suppressErrors;
|
|
559
|
-
}
|
|
560
|
-
/**
|
|
561
|
-
* @record
|
|
562
|
-
*/
|
|
563
|
-
function SelectorMetaDataModel() { }
|
|
564
|
-
if (false) {
|
|
565
|
-
/** @type {?} */
|
|
566
|
-
SelectorMetaDataModel.prototype.makeRootSelector;
|
|
567
|
-
/** @type {?} */
|
|
568
|
-
SelectorMetaDataModel.prototype.originalFn;
|
|
569
|
-
/** @type {?} */
|
|
570
|
-
SelectorMetaDataModel.prototype.containerClass;
|
|
571
|
-
/** @type {?} */
|
|
572
|
-
SelectorMetaDataModel.prototype.selectorName;
|
|
573
|
-
/** @type {?} */
|
|
574
|
-
SelectorMetaDataModel.prototype.getSelectorOptions;
|
|
575
|
-
}
|
|
576
|
-
/**
|
|
577
|
-
* @record
|
|
578
|
-
*/
|
|
579
|
-
function MappedStore() { }
|
|
580
|
-
if (false) {
|
|
581
|
-
/** @type {?} */
|
|
582
|
-
MappedStore.prototype.name;
|
|
583
|
-
/** @type {?} */
|
|
584
|
-
MappedStore.prototype.isInitialised;
|
|
585
|
-
/** @type {?} */
|
|
586
|
-
MappedStore.prototype.actions;
|
|
587
|
-
/** @type {?} */
|
|
588
|
-
MappedStore.prototype.defaults;
|
|
589
|
-
/** @type {?} */
|
|
590
|
-
MappedStore.prototype.instance;
|
|
591
|
-
/** @type {?} */
|
|
592
|
-
MappedStore.prototype.path;
|
|
593
|
-
}
|
|
594
|
-
/**
|
|
595
|
-
* @record
|
|
596
|
-
*/
|
|
597
|
-
function StatesAndDefaults() { }
|
|
598
|
-
if (false) {
|
|
599
|
-
/** @type {?} */
|
|
600
|
-
StatesAndDefaults.prototype.defaults;
|
|
601
|
-
/** @type {?} */
|
|
602
|
-
StatesAndDefaults.prototype.states;
|
|
603
|
-
}
|
|
604
181
|
/**
|
|
605
182
|
* Ensures metadata is attached to the class and returns it.
|
|
606
183
|
*
|
|
607
184
|
* @ignore
|
|
608
|
-
* @param {?} target
|
|
609
|
-
* @return {?}
|
|
610
185
|
*/
|
|
611
|
-
function ensureStoreMetadata(target) {
|
|
186
|
+
function ensureStoreMetadata$1(target) {
|
|
612
187
|
if (!target.hasOwnProperty(META_KEY)) {
|
|
613
|
-
/** @type {?} */
|
|
614
188
|
const defaultMetadata = {
|
|
615
189
|
name: null,
|
|
616
190
|
actions: {},
|
|
617
191
|
defaults: {},
|
|
618
192
|
path: null,
|
|
619
|
-
/**
|
|
620
|
-
* @param {?} context
|
|
621
|
-
* @return {?}
|
|
622
|
-
*/
|
|
623
193
|
makeRootSelector(context) {
|
|
624
194
|
return context.getStateGetter(defaultMetadata.name);
|
|
625
195
|
},
|
|
@@ -627,50 +197,40 @@ function ensureStoreMetadata(target) {
|
|
|
627
197
|
};
|
|
628
198
|
Object.defineProperty(target, META_KEY, { value: defaultMetadata });
|
|
629
199
|
}
|
|
630
|
-
return getStoreMetadata(target);
|
|
200
|
+
return getStoreMetadata$1(target);
|
|
631
201
|
}
|
|
632
202
|
/**
|
|
633
203
|
* Get the metadata attached to the state class if it exists.
|
|
634
204
|
*
|
|
635
205
|
* @ignore
|
|
636
|
-
* @param {?} target
|
|
637
|
-
* @return {?}
|
|
638
206
|
*/
|
|
639
|
-
function getStoreMetadata(target) {
|
|
640
|
-
return
|
|
207
|
+
function getStoreMetadata$1(target) {
|
|
208
|
+
return target[META_KEY];
|
|
641
209
|
}
|
|
642
210
|
/**
|
|
643
211
|
* Ensures metadata is attached to the selector and returns it.
|
|
644
212
|
*
|
|
645
213
|
* @ignore
|
|
646
|
-
* @param {?} target
|
|
647
|
-
* @return {?}
|
|
648
214
|
*/
|
|
649
|
-
function ensureSelectorMetadata(target) {
|
|
215
|
+
function ensureSelectorMetadata$1(target) {
|
|
650
216
|
if (!target.hasOwnProperty(SELECTOR_META_KEY)) {
|
|
651
|
-
/** @type {?} */
|
|
652
217
|
const defaultMetadata = {
|
|
653
218
|
makeRootSelector: null,
|
|
654
219
|
originalFn: null,
|
|
655
220
|
containerClass: null,
|
|
656
221
|
selectorName: null,
|
|
657
|
-
getSelectorOptions: (
|
|
658
|
-
* @return {?}
|
|
659
|
-
*/
|
|
660
|
-
() => ({}))
|
|
222
|
+
getSelectorOptions: () => ({})
|
|
661
223
|
};
|
|
662
224
|
Object.defineProperty(target, SELECTOR_META_KEY, { value: defaultMetadata });
|
|
663
225
|
}
|
|
664
|
-
return getSelectorMetadata(target);
|
|
226
|
+
return getSelectorMetadata$1(target);
|
|
665
227
|
}
|
|
666
228
|
/**
|
|
667
229
|
* Get the metadata attached to the selector if it exists.
|
|
668
230
|
*
|
|
669
231
|
* @ignore
|
|
670
|
-
* @param {?} target
|
|
671
|
-
* @return {?}
|
|
672
232
|
*/
|
|
673
|
-
function getSelectorMetadata(target) {
|
|
233
|
+
function getSelectorMetadata$1(target) {
|
|
674
234
|
return target[SELECTOR_META_KEY];
|
|
675
235
|
}
|
|
676
236
|
/**
|
|
@@ -682,22 +242,10 @@ function getSelectorMetadata(target) {
|
|
|
682
242
|
* See perf hit: https://jsperf.com/fast-value-getter-given-path/1
|
|
683
243
|
*
|
|
684
244
|
* @ignore
|
|
685
|
-
* @param {?} paths
|
|
686
|
-
* @return {?}
|
|
687
245
|
*/
|
|
688
246
|
function compliantPropGetter(paths) {
|
|
689
|
-
/** @type {?} */
|
|
690
247
|
const copyOfPaths = paths.slice();
|
|
691
|
-
return (
|
|
692
|
-
* @param {?} obj
|
|
693
|
-
* @return {?}
|
|
694
|
-
*/
|
|
695
|
-
obj => copyOfPaths.reduce((/**
|
|
696
|
-
* @param {?} acc
|
|
697
|
-
* @param {?} part
|
|
698
|
-
* @return {?}
|
|
699
|
-
*/
|
|
700
|
-
(acc, part) => acc && acc[part]), obj));
|
|
248
|
+
return obj => copyOfPaths.reduce((acc, part) => acc && acc[part], obj);
|
|
701
249
|
}
|
|
702
250
|
/**
|
|
703
251
|
* The generated function is faster than:
|
|
@@ -705,26 +253,18 @@ function compliantPropGetter(paths) {
|
|
|
705
253
|
* - memoize
|
|
706
254
|
*
|
|
707
255
|
* @ignore
|
|
708
|
-
* @param {?} paths
|
|
709
|
-
* @return {?}
|
|
710
256
|
*/
|
|
711
257
|
function fastPropGetter(paths) {
|
|
712
|
-
/** @type {?} */
|
|
713
258
|
const segments = paths;
|
|
714
|
-
/** @type {?} */
|
|
715
259
|
let seg = 'store.' + segments[0];
|
|
716
|
-
/** @type {?} */
|
|
717
260
|
let i = 0;
|
|
718
|
-
/** @type {?} */
|
|
719
261
|
const l = segments.length;
|
|
720
|
-
/** @type {?} */
|
|
721
262
|
let expr = seg;
|
|
722
263
|
while (++i < l) {
|
|
723
264
|
expr = expr + ' && ' + (seg = seg + '.' + segments[i]);
|
|
724
265
|
}
|
|
725
|
-
/** @type {?} */
|
|
726
266
|
const fn = new Function('store', 'return ' + expr + ';');
|
|
727
|
-
return
|
|
267
|
+
return fn;
|
|
728
268
|
}
|
|
729
269
|
/**
|
|
730
270
|
* Get a deeply nested value. Example:
|
|
@@ -732,9 +272,6 @@ function fastPropGetter(paths) {
|
|
|
732
272
|
* getValue({ foo: bar: [] }, 'foo.bar') //=> []
|
|
733
273
|
*
|
|
734
274
|
* @ignore
|
|
735
|
-
* @param {?} paths
|
|
736
|
-
* @param {?} config
|
|
737
|
-
* @return {?}
|
|
738
275
|
*/
|
|
739
276
|
function propGetter(paths, config) {
|
|
740
277
|
if (config && config.compatibility && config.compatibility.strictContentSecurityPolicy) {
|
|
@@ -761,39 +298,22 @@ function propGetter(paths, config) {
|
|
|
761
298
|
* };
|
|
762
299
|
*
|
|
763
300
|
* @ignore
|
|
764
|
-
* @param {?} stateClasses
|
|
765
|
-
* @return {?}
|
|
766
301
|
*/
|
|
767
302
|
function buildGraph(stateClasses) {
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
* @param {?} stateClass
|
|
771
|
-
* @return {?}
|
|
772
|
-
*/
|
|
773
|
-
(stateClass) => {
|
|
774
|
-
/** @type {?} */
|
|
775
|
-
const meta = stateClasses.find((/**
|
|
776
|
-
* @param {?} g
|
|
777
|
-
* @return {?}
|
|
778
|
-
*/
|
|
779
|
-
g => g === stateClass));
|
|
303
|
+
const findName = (stateClass) => {
|
|
304
|
+
const meta = stateClasses.find(g => g === stateClass);
|
|
780
305
|
// Caretaker note: we have still left the `typeof` condition in order to avoid
|
|
781
306
|
// creating a breaking change for projects that still use the View Engine.
|
|
782
307
|
if ((typeof ngDevMode === 'undefined' || ngDevMode) && !meta) {
|
|
783
308
|
throw new Error(`Child state not found: ${stateClass}. \r\nYou may have forgotten to add states to module`);
|
|
784
309
|
}
|
|
785
|
-
return
|
|
786
|
-
}
|
|
787
|
-
return stateClasses.reduce((
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
* @return {?}
|
|
791
|
-
*/
|
|
792
|
-
(result, stateClass) => {
|
|
793
|
-
const { name, children } = (/** @type {?} */ (stateClass[META_KEY]));
|
|
794
|
-
result[(/** @type {?} */ (name))] = (children || []).map(findName);
|
|
310
|
+
return meta[META_KEY].name;
|
|
311
|
+
};
|
|
312
|
+
return stateClasses.reduce((result, stateClass) => {
|
|
313
|
+
const { name, children } = stateClass[META_KEY];
|
|
314
|
+
result[name] = (children || []).map(findName);
|
|
795
315
|
return result;
|
|
796
|
-
}
|
|
316
|
+
}, {});
|
|
797
317
|
}
|
|
798
318
|
/**
|
|
799
319
|
* Given a states array, returns object graph
|
|
@@ -804,21 +324,13 @@ function buildGraph(stateClasses) {
|
|
|
804
324
|
* };
|
|
805
325
|
*
|
|
806
326
|
* @ignore
|
|
807
|
-
* @param {?} states
|
|
808
|
-
* @return {?}
|
|
809
327
|
*/
|
|
810
328
|
function nameToState(states) {
|
|
811
|
-
return states.reduce((
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
* @return {?}
|
|
815
|
-
*/
|
|
816
|
-
(result, stateClass) => {
|
|
817
|
-
/** @type {?} */
|
|
818
|
-
const meta = (/** @type {?} */ (stateClass[META_KEY]));
|
|
819
|
-
result[(/** @type {?} */ (meta.name))] = stateClass;
|
|
329
|
+
return states.reduce((result, stateClass) => {
|
|
330
|
+
const meta = stateClass[META_KEY];
|
|
331
|
+
result[meta.name] = stateClass;
|
|
820
332
|
return result;
|
|
821
|
-
}
|
|
333
|
+
}, {});
|
|
822
334
|
}
|
|
823
335
|
/**
|
|
824
336
|
* Given a object relationship graph will return the full path
|
|
@@ -839,30 +351,19 @@ function nameToState(states) {
|
|
|
839
351
|
* };
|
|
840
352
|
*
|
|
841
353
|
* @ignore
|
|
842
|
-
* @param {?} obj
|
|
843
|
-
* @param {?=} newObj
|
|
844
|
-
* @return {?}
|
|
845
354
|
*/
|
|
846
355
|
function findFullParentPath(obj, newObj = {}) {
|
|
847
|
-
|
|
848
|
-
const visit = (/**
|
|
849
|
-
* @param {?} child
|
|
850
|
-
* @param {?} keyToFind
|
|
851
|
-
* @return {?}
|
|
852
|
-
*/
|
|
853
|
-
(child, keyToFind) => {
|
|
356
|
+
const visit = (child, keyToFind) => {
|
|
854
357
|
for (const key in child) {
|
|
855
358
|
if (child.hasOwnProperty(key) && child[key].indexOf(keyToFind) >= 0) {
|
|
856
|
-
/** @type {?} */
|
|
857
359
|
const parent = visit(child, key);
|
|
858
360
|
return parent !== null ? `${parent}.${key}` : key;
|
|
859
361
|
}
|
|
860
362
|
}
|
|
861
363
|
return null;
|
|
862
|
-
}
|
|
364
|
+
};
|
|
863
365
|
for (const key in obj) {
|
|
864
366
|
if (obj.hasOwnProperty(key)) {
|
|
865
|
-
/** @type {?} */
|
|
866
367
|
const parent = visit(obj, key);
|
|
867
368
|
newObj[key] = parent ? `${parent}.${key}` : key;
|
|
868
369
|
}
|
|
@@ -887,31 +388,17 @@ function findFullParentPath(obj, newObj = {}) {
|
|
|
887
388
|
* ];
|
|
888
389
|
*
|
|
889
390
|
* @ignore
|
|
890
|
-
* @param {?} graph
|
|
891
|
-
* @return {?}
|
|
892
391
|
*/
|
|
893
392
|
function topologicalSort(graph) {
|
|
894
|
-
/** @type {?} */
|
|
895
393
|
const sorted = [];
|
|
896
|
-
/** @type {?} */
|
|
897
394
|
const visited = {};
|
|
898
|
-
|
|
899
|
-
const visit = (/**
|
|
900
|
-
* @param {?} name
|
|
901
|
-
* @param {?=} ancestors
|
|
902
|
-
* @return {?}
|
|
903
|
-
*/
|
|
904
|
-
(name, ancestors = []) => {
|
|
395
|
+
const visit = (name, ancestors = []) => {
|
|
905
396
|
if (!Array.isArray(ancestors)) {
|
|
906
397
|
ancestors = [];
|
|
907
398
|
}
|
|
908
399
|
ancestors.push(name);
|
|
909
400
|
visited[name] = true;
|
|
910
|
-
graph[name].forEach((
|
|
911
|
-
* @param {?} dep
|
|
912
|
-
* @return {?}
|
|
913
|
-
*/
|
|
914
|
-
(dep) => {
|
|
401
|
+
graph[name].forEach((dep) => {
|
|
915
402
|
// Caretaker note: we have still left the `typeof` condition in order to avoid
|
|
916
403
|
// creating a breaking change for projects that still use the View Engine.
|
|
917
404
|
if ((typeof ngDevMode === 'undefined' || ngDevMode) && ancestors.indexOf(dep) >= 0) {
|
|
@@ -921,38 +408,26 @@ function topologicalSort(graph) {
|
|
|
921
408
|
return;
|
|
922
409
|
}
|
|
923
410
|
visit(dep, ancestors.slice(0));
|
|
924
|
-
})
|
|
411
|
+
});
|
|
925
412
|
if (sorted.indexOf(name) < 0) {
|
|
926
413
|
sorted.push(name);
|
|
927
414
|
}
|
|
928
|
-
}
|
|
929
|
-
Object.keys(graph).forEach((
|
|
930
|
-
* @param {?} k
|
|
931
|
-
* @return {?}
|
|
932
|
-
*/
|
|
933
|
-
k => visit(k)));
|
|
415
|
+
};
|
|
416
|
+
Object.keys(graph).forEach(k => visit(k));
|
|
934
417
|
return sorted.reverse();
|
|
935
418
|
}
|
|
936
419
|
/**
|
|
937
420
|
* Returns if the parameter is a object or not.
|
|
938
421
|
*
|
|
939
422
|
* @ignore
|
|
940
|
-
* @param {?} obj
|
|
941
|
-
* @return {?}
|
|
942
423
|
*/
|
|
943
|
-
function isObject(obj) {
|
|
424
|
+
function isObject$1(obj) {
|
|
944
425
|
return (typeof obj === 'object' && obj !== null) || typeof obj === 'function';
|
|
945
426
|
}
|
|
946
427
|
|
|
947
|
-
/**
|
|
948
|
-
* @fileoverview added by tsickle
|
|
949
|
-
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
950
|
-
*/
|
|
951
428
|
/**
|
|
952
429
|
* Returns the type from an action instance/class.
|
|
953
430
|
* @ignore
|
|
954
|
-
* @param {?} action
|
|
955
|
-
* @return {?}
|
|
956
431
|
*/
|
|
957
432
|
function getActionTypeFromInstance(action) {
|
|
958
433
|
if (action.constructor && action.constructor.type) {
|
|
@@ -965,19 +440,12 @@ function getActionTypeFromInstance(action) {
|
|
|
965
440
|
/**
|
|
966
441
|
* Matches a action
|
|
967
442
|
* @ignore
|
|
968
|
-
* @param {?} action1
|
|
969
|
-
* @return {?}
|
|
970
443
|
*/
|
|
971
444
|
function actionMatcher(action1) {
|
|
972
|
-
/** @type {?} */
|
|
973
445
|
const type1 = getActionTypeFromInstance(action1);
|
|
974
|
-
return (
|
|
975
|
-
* @param {?} action2
|
|
976
|
-
* @return {?}
|
|
977
|
-
*/
|
|
978
|
-
function (action2) {
|
|
446
|
+
return function (action2) {
|
|
979
447
|
return type1 === getActionTypeFromInstance(action2);
|
|
980
|
-
}
|
|
448
|
+
};
|
|
981
449
|
}
|
|
982
450
|
/**
|
|
983
451
|
* Set a deeply nested value. Example:
|
|
@@ -988,27 +456,12 @@ function actionMatcher(action1) {
|
|
|
988
456
|
* While it traverses it also creates new objects from top down.
|
|
989
457
|
*
|
|
990
458
|
* @ignore
|
|
991
|
-
* @type {?}
|
|
992
459
|
*/
|
|
993
|
-
const setValue = (
|
|
994
|
-
* @param {?} obj
|
|
995
|
-
* @param {?} prop
|
|
996
|
-
* @param {?} val
|
|
997
|
-
* @return {?}
|
|
998
|
-
*/
|
|
999
|
-
(obj, prop, val) => {
|
|
460
|
+
const setValue = (obj, prop, val) => {
|
|
1000
461
|
obj = Object.assign({}, obj);
|
|
1001
|
-
/** @type {?} */
|
|
1002
462
|
const split = prop.split('.');
|
|
1003
|
-
/** @type {?} */
|
|
1004
463
|
const lastIndex = split.length - 1;
|
|
1005
|
-
split.reduce((
|
|
1006
|
-
* @param {?} acc
|
|
1007
|
-
* @param {?} part
|
|
1008
|
-
* @param {?} index
|
|
1009
|
-
* @return {?}
|
|
1010
|
-
*/
|
|
1011
|
-
(acc, part, index) => {
|
|
464
|
+
split.reduce((acc, part, index) => {
|
|
1012
465
|
if (index === lastIndex) {
|
|
1013
466
|
acc[part] = val;
|
|
1014
467
|
}
|
|
@@ -1016,28 +469,17 @@ const setValue = (/**
|
|
|
1016
469
|
acc[part] = Array.isArray(acc[part]) ? acc[part].slice() : Object.assign({}, acc[part]);
|
|
1017
470
|
}
|
|
1018
471
|
return acc && acc[part];
|
|
1019
|
-
}
|
|
472
|
+
}, obj);
|
|
1020
473
|
return obj;
|
|
1021
|
-
}
|
|
474
|
+
};
|
|
1022
475
|
/**
|
|
1023
476
|
* Get a deeply nested value. Example:
|
|
1024
477
|
*
|
|
1025
478
|
* getValue({ foo: bar: [] }, 'foo.bar') //=> []
|
|
1026
479
|
*
|
|
1027
480
|
* @ignore
|
|
1028
|
-
* @type {?}
|
|
1029
481
|
*/
|
|
1030
|
-
const getValue = (
|
|
1031
|
-
* @param {?} obj
|
|
1032
|
-
* @param {?} prop
|
|
1033
|
-
* @return {?}
|
|
1034
|
-
*/
|
|
1035
|
-
(obj, prop) => prop.split('.').reduce((/**
|
|
1036
|
-
* @param {?} acc
|
|
1037
|
-
* @param {?} part
|
|
1038
|
-
* @return {?}
|
|
1039
|
-
*/
|
|
1040
|
-
(acc, part) => acc && acc[part]), obj));
|
|
482
|
+
const getValue = (obj, prop) => prop.split('.').reduce((acc, part) => acc && acc[part], obj);
|
|
1041
483
|
/**
|
|
1042
484
|
* Simple object check.
|
|
1043
485
|
*
|
|
@@ -1045,36 +487,24 @@ const getValue = (/**
|
|
|
1045
487
|
* isObject(1) //=> false
|
|
1046
488
|
*
|
|
1047
489
|
* @ignore
|
|
1048
|
-
* @type {?}
|
|
1049
490
|
*/
|
|
1050
|
-
const isObject
|
|
1051
|
-
* @param {?} item
|
|
1052
|
-
* @return {?}
|
|
1053
|
-
*/
|
|
1054
|
-
(item) => {
|
|
491
|
+
const isObject = (item) => {
|
|
1055
492
|
return item && typeof item === 'object' && !Array.isArray(item);
|
|
1056
|
-
}
|
|
493
|
+
};
|
|
1057
494
|
/**
|
|
1058
495
|
* Deep merge two objects.
|
|
1059
496
|
*
|
|
1060
497
|
* mergeDeep({a:1, b:{x: 1, y:2}}, {b:{x: 3}, c:4}) //=> {a:1, b:{x:3, y:2}, c:4}
|
|
1061
498
|
*
|
|
1062
|
-
*
|
|
1063
|
-
* @type {?}
|
|
1064
|
-
*/
|
|
1065
|
-
const mergeDeep = (/**
|
|
1066
|
-
* @param {?} base
|
|
1067
|
-
* @param {...?} sources
|
|
1068
|
-
* @return {?}
|
|
499
|
+
* @param base base object onto which `sources` will be applied
|
|
1069
500
|
*/
|
|
1070
|
-
(base, ...sources) => {
|
|
501
|
+
const mergeDeep = (base, ...sources) => {
|
|
1071
502
|
if (!sources.length)
|
|
1072
503
|
return base;
|
|
1073
|
-
/** @type {?} */
|
|
1074
504
|
const source = sources.shift();
|
|
1075
|
-
if (isObject
|
|
505
|
+
if (isObject(base) && isObject(source)) {
|
|
1076
506
|
for (const key in source) {
|
|
1077
|
-
if (isObject
|
|
507
|
+
if (isObject(source[key])) {
|
|
1078
508
|
if (!base[key])
|
|
1079
509
|
Object.assign(base, { [key]: {} });
|
|
1080
510
|
mergeDeep(base[key], source[key]);
|
|
@@ -1085,29 +515,12 @@ const mergeDeep = (/**
|
|
|
1085
515
|
}
|
|
1086
516
|
}
|
|
1087
517
|
return mergeDeep(base, ...sources);
|
|
1088
|
-
}
|
|
518
|
+
};
|
|
1089
519
|
|
|
1090
|
-
/**
|
|
1091
|
-
* @fileoverview added by tsickle
|
|
1092
|
-
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
1093
|
-
*/
|
|
1094
|
-
/**
|
|
1095
|
-
* @record
|
|
1096
|
-
* @template T, E
|
|
1097
|
-
*/
|
|
1098
|
-
function ActionCompletion() { }
|
|
1099
|
-
if (false) {
|
|
1100
|
-
/** @type {?} */
|
|
1101
|
-
ActionCompletion.prototype.action;
|
|
1102
|
-
/** @type {?} */
|
|
1103
|
-
ActionCompletion.prototype.result;
|
|
1104
|
-
}
|
|
1105
520
|
/**
|
|
1106
521
|
* RxJS operator for selecting out specific actions.
|
|
1107
522
|
*
|
|
1108
523
|
* This will grab actions that have just been dispatched as well as actions that have completed
|
|
1109
|
-
* @param {...?} allowedTypes
|
|
1110
|
-
* @return {?}
|
|
1111
524
|
*/
|
|
1112
525
|
function ofAction(...allowedTypes) {
|
|
1113
526
|
return ofActionOperator(allowedTypes);
|
|
@@ -1116,8 +529,6 @@ function ofAction(...allowedTypes) {
|
|
|
1116
529
|
* RxJS operator for selecting out specific actions.
|
|
1117
530
|
*
|
|
1118
531
|
* This will ONLY grab actions that have just been dispatched
|
|
1119
|
-
* @param {...?} allowedTypes
|
|
1120
|
-
* @return {?}
|
|
1121
532
|
*/
|
|
1122
533
|
function ofActionDispatched(...allowedTypes) {
|
|
1123
534
|
return ofActionOperator(allowedTypes, ["DISPATCHED" /* Dispatched */]);
|
|
@@ -1126,8 +537,6 @@ function ofActionDispatched(...allowedTypes) {
|
|
|
1126
537
|
* RxJS operator for selecting out specific actions.
|
|
1127
538
|
*
|
|
1128
539
|
* This will ONLY grab actions that have just been successfully completed
|
|
1129
|
-
* @param {...?} allowedTypes
|
|
1130
|
-
* @return {?}
|
|
1131
540
|
*/
|
|
1132
541
|
function ofActionSuccessful(...allowedTypes) {
|
|
1133
542
|
return ofActionOperator(allowedTypes, ["SUCCESSFUL" /* Successful */]);
|
|
@@ -1136,8 +545,6 @@ function ofActionSuccessful(...allowedTypes) {
|
|
|
1136
545
|
* RxJS operator for selecting out specific actions.
|
|
1137
546
|
*
|
|
1138
547
|
* This will ONLY grab actions that have just been canceled
|
|
1139
|
-
* @param {...?} allowedTypes
|
|
1140
|
-
* @return {?}
|
|
1141
548
|
*/
|
|
1142
549
|
function ofActionCanceled(...allowedTypes) {
|
|
1143
550
|
return ofActionOperator(allowedTypes, ["CANCELED" /* Canceled */]);
|
|
@@ -1146,11 +553,8 @@ function ofActionCanceled(...allowedTypes) {
|
|
|
1146
553
|
* RxJS operator for selecting out specific actions.
|
|
1147
554
|
*
|
|
1148
555
|
* This will ONLY grab actions that have just been completed
|
|
1149
|
-
* @param {...?} allowedTypes
|
|
1150
|
-
* @return {?}
|
|
1151
556
|
*/
|
|
1152
557
|
function ofActionCompleted(...allowedTypes) {
|
|
1153
|
-
/** @type {?} */
|
|
1154
558
|
const allowedStatuses = [
|
|
1155
559
|
"SUCCESSFUL" /* Successful */,
|
|
1156
560
|
"CANCELED" /* Canceled */,
|
|
@@ -1162,243 +566,135 @@ function ofActionCompleted(...allowedTypes) {
|
|
|
1162
566
|
* RxJS operator for selecting out specific actions.
|
|
1163
567
|
*
|
|
1164
568
|
* This will ONLY grab actions that have just thrown an error
|
|
1165
|
-
* @param {...?} allowedTypes
|
|
1166
|
-
* @return {?}
|
|
1167
569
|
*/
|
|
1168
570
|
function ofActionErrored(...allowedTypes) {
|
|
1169
571
|
return ofActionOperator(allowedTypes, ["ERRORED" /* Errored */]);
|
|
1170
572
|
}
|
|
1171
|
-
/**
|
|
1172
|
-
* @param {?} allowedTypes
|
|
1173
|
-
* @param {?=} statuses
|
|
1174
|
-
* @param {?=} mapOperator
|
|
1175
|
-
* @return {?}
|
|
1176
|
-
*/
|
|
1177
573
|
function ofActionOperator(allowedTypes, statuses,
|
|
1178
574
|
// This actually could've been `OperatorFunction<ActionContext, ActionCompletion | any>`,
|
|
1179
575
|
// since it maps either to `ctx.action` OR to `ActionCompletion`. But `ActionCompleteion | any`
|
|
1180
576
|
// defaults to `any`, thus there is no sense from union type.
|
|
1181
577
|
mapOperator = mapAction) {
|
|
1182
|
-
/** @type {?} */
|
|
1183
578
|
const allowedMap = createAllowedActionTypesMap(allowedTypes);
|
|
1184
|
-
/** @type {?} */
|
|
1185
579
|
const allowedStatusMap = statuses && createAllowedStatusesMap(statuses);
|
|
1186
|
-
return (
|
|
1187
|
-
* @param {?} o
|
|
1188
|
-
* @return {?}
|
|
1189
|
-
*/
|
|
1190
|
-
function (o) {
|
|
580
|
+
return function (o) {
|
|
1191
581
|
return o.pipe(filterStatus(allowedMap, allowedStatusMap), mapOperator());
|
|
1192
|
-
}
|
|
582
|
+
};
|
|
1193
583
|
}
|
|
1194
|
-
/**
|
|
1195
|
-
* @param {?} allowedTypes
|
|
1196
|
-
* @param {?=} allowedStatuses
|
|
1197
|
-
* @return {?}
|
|
1198
|
-
*/
|
|
1199
584
|
function filterStatus(allowedTypes, allowedStatuses) {
|
|
1200
|
-
return filter((
|
|
1201
|
-
|
|
1202
|
-
* @return {?}
|
|
1203
|
-
*/
|
|
1204
|
-
(ctx) => {
|
|
1205
|
-
/** @type {?} */
|
|
1206
|
-
const actionType = (/** @type {?} */ (getActionTypeFromInstance(ctx.action)));
|
|
1207
|
-
/** @type {?} */
|
|
585
|
+
return filter((ctx) => {
|
|
586
|
+
const actionType = getActionTypeFromInstance(ctx.action);
|
|
1208
587
|
const typeMatch = allowedTypes[actionType];
|
|
1209
|
-
/** @type {?} */
|
|
1210
588
|
const statusMatch = allowedStatuses ? allowedStatuses[ctx.status] : true;
|
|
1211
589
|
return typeMatch && statusMatch;
|
|
1212
|
-
})
|
|
590
|
+
});
|
|
1213
591
|
}
|
|
1214
|
-
/**
|
|
1215
|
-
* @return {?}
|
|
1216
|
-
*/
|
|
1217
592
|
function mapActionResult() {
|
|
1218
|
-
return map((
|
|
1219
|
-
|
|
1220
|
-
* @return {?}
|
|
1221
|
-
*/
|
|
1222
|
-
({ action, status, error }) => {
|
|
1223
|
-
return (/** @type {?} */ ({
|
|
593
|
+
return map(({ action, status, error }) => {
|
|
594
|
+
return {
|
|
1224
595
|
action,
|
|
1225
596
|
result: {
|
|
1226
597
|
successful: "SUCCESSFUL" /* Successful */ === status,
|
|
1227
598
|
canceled: "CANCELED" /* Canceled */ === status,
|
|
1228
599
|
error
|
|
1229
600
|
}
|
|
1230
|
-
}
|
|
1231
|
-
})
|
|
601
|
+
};
|
|
602
|
+
});
|
|
1232
603
|
}
|
|
1233
|
-
/**
|
|
1234
|
-
* @template T
|
|
1235
|
-
* @return {?}
|
|
1236
|
-
*/
|
|
1237
604
|
function mapAction() {
|
|
1238
|
-
return map((
|
|
1239
|
-
* @param {?} ctx
|
|
1240
|
-
* @return {?}
|
|
1241
|
-
*/
|
|
1242
|
-
(ctx) => (/** @type {?} */ (ctx.action))));
|
|
605
|
+
return map((ctx) => ctx.action);
|
|
1243
606
|
}
|
|
1244
|
-
/**
|
|
1245
|
-
* @record
|
|
1246
|
-
*/
|
|
1247
|
-
function FilterMap() { }
|
|
1248
|
-
/**
|
|
1249
|
-
* @param {?} types
|
|
1250
|
-
* @return {?}
|
|
1251
|
-
*/
|
|
1252
607
|
function createAllowedActionTypesMap(types) {
|
|
1253
|
-
return types.reduce((
|
|
1254
|
-
|
|
1255
|
-
* @param {?} klass
|
|
1256
|
-
* @return {?}
|
|
1257
|
-
*/
|
|
1258
|
-
(filterMap, klass) => {
|
|
1259
|
-
filterMap[(/** @type {?} */ (getActionTypeFromInstance(klass)))] = true;
|
|
608
|
+
return types.reduce((filterMap, klass) => {
|
|
609
|
+
filterMap[getActionTypeFromInstance(klass)] = true;
|
|
1260
610
|
return filterMap;
|
|
1261
|
-
}
|
|
611
|
+
}, {});
|
|
1262
612
|
}
|
|
1263
|
-
/**
|
|
1264
|
-
* @param {?} statuses
|
|
1265
|
-
* @return {?}
|
|
1266
|
-
*/
|
|
1267
613
|
function createAllowedStatusesMap(statuses) {
|
|
1268
|
-
return statuses.reduce((
|
|
1269
|
-
* @param {?} filterMap
|
|
1270
|
-
* @param {?} status
|
|
1271
|
-
* @return {?}
|
|
1272
|
-
*/
|
|
1273
|
-
(filterMap, status) => {
|
|
614
|
+
return statuses.reduce((filterMap, status) => {
|
|
1274
615
|
filterMap[status] = true;
|
|
1275
616
|
return filterMap;
|
|
1276
|
-
}
|
|
617
|
+
}, {});
|
|
1277
618
|
}
|
|
1278
619
|
|
|
1279
|
-
/**
|
|
1280
|
-
* @fileoverview added by tsickle
|
|
1281
|
-
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
1282
|
-
*/
|
|
1283
620
|
/**
|
|
1284
621
|
* Returns operator that will run
|
|
1285
622
|
* `subscribe` outside of the ngxs execution context
|
|
1286
|
-
* @template T
|
|
1287
|
-
* @param {?} ngxsExecutionStrategy
|
|
1288
|
-
* @return {?}
|
|
1289
623
|
*/
|
|
1290
624
|
function leaveNgxs(ngxsExecutionStrategy) {
|
|
1291
|
-
return (
|
|
1292
|
-
|
|
1293
|
-
* @return {?}
|
|
1294
|
-
*/
|
|
1295
|
-
(source) => {
|
|
1296
|
-
return new Observable((/**
|
|
1297
|
-
* @param {?} sink
|
|
1298
|
-
* @return {?}
|
|
1299
|
-
*/
|
|
1300
|
-
(sink) => {
|
|
625
|
+
return (source) => {
|
|
626
|
+
return new Observable((sink) => {
|
|
1301
627
|
return source.subscribe({
|
|
1302
|
-
/**
|
|
1303
|
-
* @param {?} value
|
|
1304
|
-
* @return {?}
|
|
1305
|
-
*/
|
|
1306
628
|
next(value) {
|
|
1307
|
-
ngxsExecutionStrategy.leave((
|
|
1308
|
-
* @return {?}
|
|
1309
|
-
*/
|
|
1310
|
-
() => sink.next(value)));
|
|
629
|
+
ngxsExecutionStrategy.leave(() => sink.next(value));
|
|
1311
630
|
},
|
|
1312
|
-
/**
|
|
1313
|
-
* @param {?} error
|
|
1314
|
-
* @return {?}
|
|
1315
|
-
*/
|
|
1316
631
|
error(error) {
|
|
1317
|
-
ngxsExecutionStrategy.leave((
|
|
1318
|
-
* @return {?}
|
|
1319
|
-
*/
|
|
1320
|
-
() => sink.error(error)));
|
|
632
|
+
ngxsExecutionStrategy.leave(() => sink.error(error));
|
|
1321
633
|
},
|
|
1322
|
-
/**
|
|
1323
|
-
* @return {?}
|
|
1324
|
-
*/
|
|
1325
634
|
complete() {
|
|
1326
|
-
ngxsExecutionStrategy.leave((
|
|
1327
|
-
* @return {?}
|
|
1328
|
-
*/
|
|
1329
|
-
() => sink.complete()));
|
|
635
|
+
ngxsExecutionStrategy.leave(() => sink.complete());
|
|
1330
636
|
}
|
|
1331
637
|
});
|
|
1332
|
-
})
|
|
1333
|
-
}
|
|
638
|
+
});
|
|
639
|
+
};
|
|
1334
640
|
}
|
|
1335
641
|
|
|
1336
|
-
/**
|
|
1337
|
-
* @fileoverview added by tsickle
|
|
1338
|
-
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
1339
|
-
*/
|
|
1340
642
|
class InternalNgxsExecutionStrategy {
|
|
1341
|
-
/**
|
|
1342
|
-
* @param {?} _executionStrategy
|
|
1343
|
-
*/
|
|
1344
643
|
constructor(_executionStrategy) {
|
|
1345
644
|
this._executionStrategy = _executionStrategy;
|
|
1346
645
|
}
|
|
1347
|
-
/**
|
|
1348
|
-
* @template T
|
|
1349
|
-
* @param {?} func
|
|
1350
|
-
* @return {?}
|
|
1351
|
-
*/
|
|
1352
646
|
enter(func) {
|
|
1353
647
|
return this._executionStrategy.enter(func);
|
|
1354
648
|
}
|
|
1355
|
-
/**
|
|
1356
|
-
* @template T
|
|
1357
|
-
* @param {?} func
|
|
1358
|
-
* @return {?}
|
|
1359
|
-
*/
|
|
1360
649
|
leave(func) {
|
|
1361
650
|
return this._executionStrategy.leave(func);
|
|
1362
651
|
}
|
|
1363
652
|
}
|
|
1364
|
-
InternalNgxsExecutionStrategy
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
]
|
|
1371
|
-
|
|
1372
|
-
/**
|
|
1373
|
-
* @type {?}
|
|
1374
|
-
* @private
|
|
1375
|
-
*/
|
|
1376
|
-
InternalNgxsExecutionStrategy.prototype._executionStrategy;
|
|
1377
|
-
}
|
|
653
|
+
/** @nocollapse */ InternalNgxsExecutionStrategy.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: InternalNgxsExecutionStrategy, deps: [{ token: NGXS_EXECUTION_STRATEGY }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
654
|
+
/** @nocollapse */ InternalNgxsExecutionStrategy.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: InternalNgxsExecutionStrategy });
|
|
655
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: InternalNgxsExecutionStrategy, decorators: [{
|
|
656
|
+
type: Injectable
|
|
657
|
+
}], ctorParameters: function () { return [{ type: undefined, decorators: [{
|
|
658
|
+
type: Inject,
|
|
659
|
+
args: [NGXS_EXECUTION_STRATEGY]
|
|
660
|
+
}] }]; } });
|
|
1378
661
|
|
|
1379
662
|
/**
|
|
1380
|
-
*
|
|
1381
|
-
*
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
*
|
|
1392
|
-
*
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
663
|
+
* This wraps the provided function, and will enforce the following:
|
|
664
|
+
* - The calls will execute in the order that they are made
|
|
665
|
+
* - A call will only be initiated when the previous call has completed
|
|
666
|
+
* - If there is a call currently executing then the new call will be added
|
|
667
|
+
* to the queue and the function will return immediately
|
|
668
|
+
*
|
|
669
|
+
* NOTE: The following assumptions about the operation must hold true:
|
|
670
|
+
* - The operation is synchronous in nature
|
|
671
|
+
* - If any asynchronous side effects of the call exist, it should not
|
|
672
|
+
* have any bearing on the correctness of the next call in the queue
|
|
673
|
+
* - The operation has a void return
|
|
674
|
+
* - The caller should not assume that the call has completed upon
|
|
675
|
+
* return of the function
|
|
676
|
+
* - The caller can assume that all the queued calls will complete
|
|
677
|
+
* within the current microtask
|
|
678
|
+
* - The only way that a call will encounter another call in the queue
|
|
679
|
+
* would be if the call at the front of the queue initiated this call
|
|
680
|
+
* as part of its synchronous execution
|
|
681
|
+
*/
|
|
682
|
+
function orderedQueueOperation(operation) {
|
|
683
|
+
const callsQueue = [];
|
|
684
|
+
let busyPushingNext = false;
|
|
685
|
+
return function callOperation(...args) {
|
|
686
|
+
if (busyPushingNext) {
|
|
687
|
+
callsQueue.unshift(args);
|
|
688
|
+
return;
|
|
689
|
+
}
|
|
690
|
+
busyPushingNext = true;
|
|
691
|
+
operation(...args);
|
|
692
|
+
while (callsQueue.length > 0) {
|
|
693
|
+
const nextCallArgs = callsQueue.pop();
|
|
694
|
+
nextCallArgs && operation(...nextCallArgs);
|
|
695
|
+
}
|
|
696
|
+
busyPushingNext = false;
|
|
697
|
+
};
|
|
1402
698
|
}
|
|
1403
699
|
/**
|
|
1404
700
|
* Custom Subject that ensures that subscribers are notified of values in the order that they arrived.
|
|
@@ -1406,126 +702,85 @@ if (false) {
|
|
|
1406
702
|
* For example, given the following code:
|
|
1407
703
|
* ```typescript
|
|
1408
704
|
* const subject = new Subject<string>();
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
705
|
+
subject.subscribe(value => {
|
|
706
|
+
if (value === 'start') subject.next('end');
|
|
707
|
+
});
|
|
708
|
+
subject.subscribe(value => { });
|
|
709
|
+
subject.next('start');
|
|
1414
710
|
* ```
|
|
1415
711
|
* When `subject` is a standard `Subject<T>` the second subscriber would recieve `end` and then `start`.
|
|
1416
712
|
* When `subject` is a `OrderedSubject<T>` the second subscriber would recieve `start` and then `end`.
|
|
1417
|
-
* @template T
|
|
1418
713
|
*/
|
|
1419
714
|
class OrderedSubject extends Subject {
|
|
1420
715
|
constructor() {
|
|
1421
716
|
super(...arguments);
|
|
1422
|
-
this.
|
|
1423
|
-
this._busyPushingNext = false;
|
|
1424
|
-
}
|
|
1425
|
-
/**
|
|
1426
|
-
* @param {?=} value
|
|
1427
|
-
* @return {?}
|
|
1428
|
-
*/
|
|
1429
|
-
next(value) {
|
|
1430
|
-
if (this._busyPushingNext) {
|
|
1431
|
-
this._itemQueue.unshift((/** @type {?} */ (value)));
|
|
1432
|
-
return;
|
|
1433
|
-
}
|
|
1434
|
-
this._busyPushingNext = true;
|
|
1435
|
-
super.next(value);
|
|
1436
|
-
while (this._itemQueue.length > 0) {
|
|
1437
|
-
/** @type {?} */
|
|
1438
|
-
const nextValue = this._itemQueue.pop();
|
|
1439
|
-
super.next(nextValue);
|
|
1440
|
-
}
|
|
1441
|
-
this._busyPushingNext = false;
|
|
717
|
+
this.next = orderedQueueOperation((value) => super.next(value));
|
|
1442
718
|
}
|
|
1443
719
|
}
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
720
|
+
/**
|
|
721
|
+
* Custom BehaviorSubject that ensures that subscribers are notified of values in the order that they arrived.
|
|
722
|
+
* A standard BehaviorSubject does not have this guarantee.
|
|
723
|
+
* For example, given the following code:
|
|
724
|
+
* ```typescript
|
|
725
|
+
* const subject = new BehaviorSubject<string>();
|
|
726
|
+
subject.subscribe(value => {
|
|
727
|
+
if (value === 'start') subject.next('end');
|
|
728
|
+
});
|
|
729
|
+
subject.subscribe(value => { });
|
|
730
|
+
subject.next('start');
|
|
731
|
+
* ```
|
|
732
|
+
* When `subject` is a standard `BehaviorSubject<T>` the second subscriber would recieve `end` and then `start`.
|
|
733
|
+
* When `subject` is a `OrderedBehaviorSubject<T>` the second subscriber would recieve `start` and then `end`.
|
|
734
|
+
*/
|
|
735
|
+
class OrderedBehaviorSubject extends BehaviorSubject {
|
|
736
|
+
constructor() {
|
|
737
|
+
super(...arguments);
|
|
738
|
+
this.next = orderedQueueOperation((value) => super.next(value));
|
|
739
|
+
}
|
|
1455
740
|
}
|
|
741
|
+
|
|
1456
742
|
/**
|
|
1457
743
|
* Internal Action stream that is emitted anytime an action is dispatched.
|
|
1458
744
|
*/
|
|
1459
745
|
class InternalActions extends OrderedSubject {
|
|
1460
|
-
/**
|
|
1461
|
-
* @return {?}
|
|
1462
|
-
*/
|
|
1463
746
|
ngOnDestroy() {
|
|
1464
747
|
this.complete();
|
|
1465
748
|
}
|
|
1466
749
|
}
|
|
1467
|
-
InternalActions
|
|
1468
|
-
|
|
1469
|
-
|
|
750
|
+
/** @nocollapse */ InternalActions.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: InternalActions, deps: null, target: i0.ɵɵFactoryTarget.Injectable });
|
|
751
|
+
/** @nocollapse */ InternalActions.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: InternalActions });
|
|
752
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: InternalActions, decorators: [{
|
|
753
|
+
type: Injectable
|
|
754
|
+
}] });
|
|
1470
755
|
/**
|
|
1471
756
|
* Action stream that is emitted anytime an action is dispatched.
|
|
1472
757
|
*
|
|
1473
758
|
* You can listen to this in services to react without stores.
|
|
1474
759
|
*/
|
|
1475
760
|
class Actions extends Observable {
|
|
1476
|
-
// This has to be `Observable<ActionContext>` in the v4. Because `InternalActions`
|
|
1477
|
-
// is a `Subject<ActionContext>`. Leave it as `any` to avoid breaking changes
|
|
1478
|
-
/**
|
|
1479
|
-
* @param {?} internalActions$
|
|
1480
|
-
* @param {?} internalExecutionStrategy
|
|
1481
|
-
*/
|
|
1482
761
|
constructor(internalActions$, internalExecutionStrategy) {
|
|
1483
|
-
/** @type {?} */
|
|
1484
762
|
const sharedInternalActions$ = internalActions$.pipe(leaveNgxs(internalExecutionStrategy),
|
|
1485
763
|
// The `InternalActions` subject emits outside of the Angular zone.
|
|
1486
764
|
// We have to re-enter the Angular zone for any incoming consumer.
|
|
1487
765
|
// The `share()` operator reduces the number of change detections.
|
|
1488
766
|
// This would call leave only once for any stream emission across all active subscribers.
|
|
1489
767
|
share());
|
|
1490
|
-
super(
|
|
1491
|
-
* @param {?} observer
|
|
1492
|
-
* @return {?}
|
|
1493
|
-
*/
|
|
1494
|
-
observer => {
|
|
1495
|
-
/** @type {?} */
|
|
768
|
+
super(observer => {
|
|
1496
769
|
const childSubscription = sharedInternalActions$.subscribe({
|
|
1497
|
-
next: (
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
*/
|
|
1501
|
-
ctx => observer.next(ctx)),
|
|
1502
|
-
error: (/**
|
|
1503
|
-
* @param {?} error
|
|
1504
|
-
* @return {?}
|
|
1505
|
-
*/
|
|
1506
|
-
error => observer.error(error)),
|
|
1507
|
-
complete: (/**
|
|
1508
|
-
* @return {?}
|
|
1509
|
-
*/
|
|
1510
|
-
() => observer.complete())
|
|
770
|
+
next: ctx => observer.next(ctx),
|
|
771
|
+
error: error => observer.error(error),
|
|
772
|
+
complete: () => observer.complete()
|
|
1511
773
|
});
|
|
1512
774
|
observer.add(childSubscription);
|
|
1513
|
-
})
|
|
775
|
+
});
|
|
1514
776
|
}
|
|
1515
777
|
}
|
|
1516
|
-
Actions
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
{ type: InternalActions },
|
|
1522
|
-
{ type: InternalNgxsExecutionStrategy }
|
|
1523
|
-
];
|
|
778
|
+
/** @nocollapse */ Actions.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: Actions, deps: [{ token: InternalActions }, { token: InternalNgxsExecutionStrategy }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
779
|
+
/** @nocollapse */ Actions.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: Actions });
|
|
780
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: Actions, decorators: [{
|
|
781
|
+
type: Injectable
|
|
782
|
+
}], ctorParameters: function () { return [{ type: InternalActions }, { type: InternalNgxsExecutionStrategy }]; } });
|
|
1524
783
|
|
|
1525
|
-
/**
|
|
1526
|
-
* @fileoverview added by tsickle
|
|
1527
|
-
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
1528
|
-
*/
|
|
1529
784
|
/**
|
|
1530
785
|
* Composes a array of functions from left to right. Example:
|
|
1531
786
|
*
|
|
@@ -1546,30 +801,12 @@ Actions.ctorParameters = () => [
|
|
|
1546
801
|
* the last function should not call `next`.
|
|
1547
802
|
*
|
|
1548
803
|
* @ignore
|
|
1549
|
-
* @type {?}
|
|
1550
|
-
*/
|
|
1551
|
-
const compose = (/**
|
|
1552
|
-
* @param {?} funcs
|
|
1553
|
-
* @return {?}
|
|
1554
804
|
*/
|
|
1555
|
-
(funcs) => (
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
(...args) => {
|
|
1560
|
-
/** @type {?} */
|
|
1561
|
-
const curr = (/** @type {?} */ (funcs.shift()));
|
|
1562
|
-
return curr(...args, (/**
|
|
1563
|
-
* @param {...?} nextArgs
|
|
1564
|
-
* @return {?}
|
|
1565
|
-
*/
|
|
1566
|
-
(...nextArgs) => compose(funcs)(...nextArgs)));
|
|
1567
|
-
}));
|
|
805
|
+
const compose = (funcs) => (...args) => {
|
|
806
|
+
const curr = funcs.shift();
|
|
807
|
+
return curr(...args, (...nextArgs) => compose(funcs)(...nextArgs));
|
|
808
|
+
};
|
|
1568
809
|
|
|
1569
|
-
/**
|
|
1570
|
-
* @fileoverview added by tsickle
|
|
1571
|
-
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
1572
|
-
*/
|
|
1573
810
|
/**
|
|
1574
811
|
* This operator is used for piping the observable result
|
|
1575
812
|
* from the `dispatch()`. It has a "smart" error handling
|
|
@@ -1581,69 +818,34 @@ const compose = (/**
|
|
|
1581
818
|
* 3) `store.dispatch().subscribe({ error: ... })` -> don't call `handleError()`
|
|
1582
819
|
* 4) `toPromise()` without `catch` -> do `handleError()`
|
|
1583
820
|
* 5) `toPromise()` with `catch` -> don't `handleError()`
|
|
1584
|
-
* @template T
|
|
1585
|
-
* @param {?} internalErrorReporter
|
|
1586
|
-
* @param {?} ngxsExecutionStrategy
|
|
1587
|
-
* @return {?}
|
|
1588
821
|
*/
|
|
1589
822
|
function ngxsErrorHandler(internalErrorReporter, ngxsExecutionStrategy) {
|
|
1590
|
-
return (
|
|
1591
|
-
* @param {?} source
|
|
1592
|
-
* @return {?}
|
|
1593
|
-
*/
|
|
1594
|
-
(source) => {
|
|
1595
|
-
/** @type {?} */
|
|
823
|
+
return (source) => {
|
|
1596
824
|
let subscribed = false;
|
|
1597
825
|
source.subscribe({
|
|
1598
|
-
error:
|
|
1599
|
-
* @param {?} error
|
|
1600
|
-
* @return {?}
|
|
1601
|
-
*/
|
|
1602
|
-
error => {
|
|
826
|
+
error: error => {
|
|
1603
827
|
// Do not trigger change detection for a microtask. This depends on the execution
|
|
1604
828
|
// strategy being used, but the default `DispatchOutsideZoneNgxsExecutionStrategy`
|
|
1605
829
|
// leaves the Angular zone.
|
|
1606
|
-
ngxsExecutionStrategy.enter((
|
|
1607
|
-
* @return {?}
|
|
1608
|
-
*/
|
|
1609
|
-
() => Promise.resolve().then((/**
|
|
1610
|
-
* @return {?}
|
|
1611
|
-
*/
|
|
1612
|
-
() => {
|
|
830
|
+
ngxsExecutionStrategy.enter(() => Promise.resolve().then(() => {
|
|
1613
831
|
if (!subscribed) {
|
|
1614
|
-
ngxsExecutionStrategy.leave((
|
|
1615
|
-
* @return {?}
|
|
1616
|
-
*/
|
|
1617
|
-
() => internalErrorReporter.reportErrorSafely(error)));
|
|
832
|
+
ngxsExecutionStrategy.leave(() => internalErrorReporter.reportErrorSafely(error));
|
|
1618
833
|
}
|
|
1619
|
-
}))
|
|
1620
|
-
}
|
|
834
|
+
}));
|
|
835
|
+
}
|
|
1621
836
|
});
|
|
1622
|
-
return new Observable(
|
|
1623
|
-
* @param {?} subscriber
|
|
1624
|
-
* @return {?}
|
|
1625
|
-
*/
|
|
1626
|
-
subscriber => {
|
|
837
|
+
return new Observable(subscriber => {
|
|
1627
838
|
subscribed = true;
|
|
1628
839
|
return source.pipe(leaveNgxs(ngxsExecutionStrategy)).subscribe(subscriber);
|
|
1629
|
-
})
|
|
1630
|
-
}
|
|
840
|
+
});
|
|
841
|
+
};
|
|
1631
842
|
}
|
|
1632
843
|
class InternalErrorReporter {
|
|
1633
|
-
/**
|
|
1634
|
-
* @param {?} _injector
|
|
1635
|
-
*/
|
|
1636
844
|
constructor(_injector) {
|
|
1637
845
|
this._injector = _injector;
|
|
1638
|
-
/**
|
|
1639
|
-
|
|
1640
|
-
*/
|
|
1641
|
-
this._errorHandler = (/** @type {?} */ (null));
|
|
846
|
+
/** Will be set lazily to be backward compatible. */
|
|
847
|
+
this._errorHandler = null;
|
|
1642
848
|
}
|
|
1643
|
-
/**
|
|
1644
|
-
* @param {?} error
|
|
1645
|
-
* @return {?}
|
|
1646
|
-
*/
|
|
1647
849
|
reportErrorSafely(error) {
|
|
1648
850
|
if (this._errorHandler === null) {
|
|
1649
851
|
this._errorHandler = this._injector.get(ErrorHandler);
|
|
@@ -1658,43 +860,21 @@ class InternalErrorReporter {
|
|
|
1658
860
|
catch (_a) { }
|
|
1659
861
|
}
|
|
1660
862
|
}
|
|
1661
|
-
InternalErrorReporter
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
];
|
|
1668
|
-
/** @nocollapse */ InternalErrorReporter.ngInjectableDef = defineInjectable({ factory: function InternalErrorReporter_Factory() { return new InternalErrorReporter(inject(INJECTOR)); }, token: InternalErrorReporter, providedIn: "root" });
|
|
1669
|
-
if (false) {
|
|
1670
|
-
/**
|
|
1671
|
-
* Will be set lazily to be backward compatible.
|
|
1672
|
-
* @type {?}
|
|
1673
|
-
* @private
|
|
1674
|
-
*/
|
|
1675
|
-
InternalErrorReporter.prototype._errorHandler;
|
|
1676
|
-
/**
|
|
1677
|
-
* @type {?}
|
|
1678
|
-
* @private
|
|
1679
|
-
*/
|
|
1680
|
-
InternalErrorReporter.prototype._injector;
|
|
1681
|
-
}
|
|
863
|
+
/** @nocollapse */ InternalErrorReporter.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: InternalErrorReporter, deps: [{ token: i0.Injector }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
864
|
+
/** @nocollapse */ InternalErrorReporter.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: InternalErrorReporter, providedIn: 'root' });
|
|
865
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: InternalErrorReporter, decorators: [{
|
|
866
|
+
type: Injectable,
|
|
867
|
+
args: [{ providedIn: 'root' }]
|
|
868
|
+
}], ctorParameters: function () { return [{ type: i0.Injector }]; } });
|
|
1682
869
|
|
|
1683
|
-
/**
|
|
1684
|
-
* @fileoverview added by tsickle
|
|
1685
|
-
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
1686
|
-
*/
|
|
1687
870
|
/**
|
|
1688
871
|
* BehaviorSubject of the entire state.
|
|
1689
872
|
* @ignore
|
|
1690
873
|
*/
|
|
1691
|
-
class StateStream extends
|
|
874
|
+
class StateStream extends OrderedBehaviorSubject {
|
|
1692
875
|
constructor() {
|
|
1693
876
|
super({});
|
|
1694
877
|
}
|
|
1695
|
-
/**
|
|
1696
|
-
* @return {?}
|
|
1697
|
-
*/
|
|
1698
878
|
ngOnDestroy() {
|
|
1699
879
|
// The `StateStream` should never emit values once the root view is removed, e.g. when the `NgModuleRef.destroy()` is called.
|
|
1700
880
|
// This will eliminate memory leaks in server-side rendered apps where the `StateStream` is created per each HTTP request, users
|
|
@@ -1702,84 +882,46 @@ class StateStream extends BehaviorSubject {
|
|
|
1702
882
|
this.complete();
|
|
1703
883
|
}
|
|
1704
884
|
}
|
|
1705
|
-
StateStream
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
|
|
885
|
+
/** @nocollapse */ StateStream.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: StateStream, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
886
|
+
/** @nocollapse */ StateStream.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: StateStream });
|
|
887
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: StateStream, decorators: [{
|
|
888
|
+
type: Injectable
|
|
889
|
+
}], ctorParameters: function () { return []; } });
|
|
1710
890
|
|
|
1711
|
-
/**
|
|
1712
|
-
* @fileoverview added by tsickle
|
|
1713
|
-
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
1714
|
-
*/
|
|
1715
891
|
class PluginManager {
|
|
1716
|
-
/**
|
|
1717
|
-
* @param {?} _parentManager
|
|
1718
|
-
* @param {?} _pluginHandlers
|
|
1719
|
-
*/
|
|
1720
892
|
constructor(_parentManager, _pluginHandlers) {
|
|
1721
893
|
this._parentManager = _parentManager;
|
|
1722
894
|
this._pluginHandlers = _pluginHandlers;
|
|
1723
895
|
this.plugins = [];
|
|
1724
896
|
this.registerHandlers();
|
|
1725
897
|
}
|
|
1726
|
-
/**
|
|
1727
|
-
* @private
|
|
1728
|
-
* @return {?}
|
|
1729
|
-
*/
|
|
1730
898
|
get rootPlugins() {
|
|
1731
899
|
return (this._parentManager && this._parentManager.plugins) || this.plugins;
|
|
1732
900
|
}
|
|
1733
|
-
/**
|
|
1734
|
-
* @private
|
|
1735
|
-
* @return {?}
|
|
1736
|
-
*/
|
|
1737
901
|
registerHandlers() {
|
|
1738
|
-
/** @type {?} */
|
|
1739
902
|
const pluginHandlers = this.getPluginHandlers();
|
|
1740
903
|
this.rootPlugins.push(...pluginHandlers);
|
|
1741
904
|
}
|
|
1742
|
-
/**
|
|
1743
|
-
* @private
|
|
1744
|
-
* @return {?}
|
|
1745
|
-
*/
|
|
1746
905
|
getPluginHandlers() {
|
|
1747
|
-
/** @type {?} */
|
|
1748
906
|
const handlers = this._pluginHandlers || [];
|
|
1749
|
-
return handlers.map((
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
PluginManager
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
|
|
1763
|
-
|
|
1764
|
-
|
|
1765
|
-
|
|
1766
|
-
PluginManager.prototype.plugins;
|
|
1767
|
-
/**
|
|
1768
|
-
* @type {?}
|
|
1769
|
-
* @private
|
|
1770
|
-
*/
|
|
1771
|
-
PluginManager.prototype._parentManager;
|
|
1772
|
-
/**
|
|
1773
|
-
* @type {?}
|
|
1774
|
-
* @private
|
|
1775
|
-
*/
|
|
1776
|
-
PluginManager.prototype._pluginHandlers;
|
|
1777
|
-
}
|
|
907
|
+
return handlers.map((plugin) => (plugin.handle ? plugin.handle.bind(plugin) : plugin));
|
|
908
|
+
}
|
|
909
|
+
}
|
|
910
|
+
/** @nocollapse */ PluginManager.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: PluginManager, deps: [{ token: PluginManager, optional: true, skipSelf: true }, { token: NGXS_PLUGINS, optional: true }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
911
|
+
/** @nocollapse */ PluginManager.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: PluginManager });
|
|
912
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: PluginManager, decorators: [{
|
|
913
|
+
type: Injectable
|
|
914
|
+
}], ctorParameters: function () { return [{ type: PluginManager, decorators: [{
|
|
915
|
+
type: Optional
|
|
916
|
+
}, {
|
|
917
|
+
type: SkipSelf
|
|
918
|
+
}] }, { type: undefined, decorators: [{
|
|
919
|
+
type: Inject,
|
|
920
|
+
args: [NGXS_PLUGINS]
|
|
921
|
+
}, {
|
|
922
|
+
type: Optional
|
|
923
|
+
}] }]; } });
|
|
1778
924
|
|
|
1779
|
-
/**
|
|
1780
|
-
* @fileoverview added by tsickle
|
|
1781
|
-
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
1782
|
-
*/
|
|
1783
925
|
/**
|
|
1784
926
|
* Internal Action result stream that is emitted when an action is completed.
|
|
1785
927
|
* This is used as a method of returning the action result to the dispatcher
|
|
@@ -1788,18 +930,12 @@ if (false) {
|
|
|
1788
930
|
*/
|
|
1789
931
|
class InternalDispatchedActionResults extends Subject {
|
|
1790
932
|
}
|
|
1791
|
-
InternalDispatchedActionResults
|
|
1792
|
-
|
|
1793
|
-
|
|
933
|
+
/** @nocollapse */ InternalDispatchedActionResults.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: InternalDispatchedActionResults, deps: null, target: i0.ɵɵFactoryTarget.Injectable });
|
|
934
|
+
/** @nocollapse */ InternalDispatchedActionResults.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: InternalDispatchedActionResults });
|
|
935
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: InternalDispatchedActionResults, decorators: [{
|
|
936
|
+
type: Injectable
|
|
937
|
+
}] });
|
|
1794
938
|
class InternalDispatcher {
|
|
1795
|
-
/**
|
|
1796
|
-
* @param {?} _actions
|
|
1797
|
-
* @param {?} _actionResults
|
|
1798
|
-
* @param {?} _pluginManager
|
|
1799
|
-
* @param {?} _stateStream
|
|
1800
|
-
* @param {?} _ngxsExecutionStrategy
|
|
1801
|
-
* @param {?} _internalErrorReporter
|
|
1802
|
-
*/
|
|
1803
939
|
constructor(_actions, _actionResults, _pluginManager, _stateStream, _ngxsExecutionStrategy, _internalErrorReporter) {
|
|
1804
940
|
this._actions = _actions;
|
|
1805
941
|
this._actionResults = _actionResults;
|
|
@@ -1810,102 +946,50 @@ class InternalDispatcher {
|
|
|
1810
946
|
}
|
|
1811
947
|
/**
|
|
1812
948
|
* Dispatches event(s).
|
|
1813
|
-
* @param {?} actionOrActions
|
|
1814
|
-
* @return {?}
|
|
1815
949
|
*/
|
|
1816
950
|
dispatch(actionOrActions) {
|
|
1817
|
-
|
|
1818
|
-
const result = this._ngxsExecutionStrategy.enter((/**
|
|
1819
|
-
* @return {?}
|
|
1820
|
-
*/
|
|
1821
|
-
() => this.dispatchByEvents(actionOrActions)));
|
|
951
|
+
const result = this._ngxsExecutionStrategy.enter(() => this.dispatchByEvents(actionOrActions));
|
|
1822
952
|
return result.pipe(ngxsErrorHandler(this._internalErrorReporter, this._ngxsExecutionStrategy));
|
|
1823
953
|
}
|
|
1824
|
-
/**
|
|
1825
|
-
* @private
|
|
1826
|
-
* @param {?} actionOrActions
|
|
1827
|
-
* @return {?}
|
|
1828
|
-
*/
|
|
1829
954
|
dispatchByEvents(actionOrActions) {
|
|
1830
955
|
if (Array.isArray(actionOrActions)) {
|
|
1831
956
|
if (actionOrActions.length === 0)
|
|
1832
957
|
return of(this._stateStream.getValue());
|
|
1833
|
-
return forkJoin(actionOrActions.map((
|
|
1834
|
-
* @param {?} action
|
|
1835
|
-
* @return {?}
|
|
1836
|
-
*/
|
|
1837
|
-
action => this.dispatchSingle(action))));
|
|
958
|
+
return forkJoin(actionOrActions.map(action => this.dispatchSingle(action)));
|
|
1838
959
|
}
|
|
1839
960
|
else {
|
|
1840
961
|
return this.dispatchSingle(actionOrActions);
|
|
1841
962
|
}
|
|
1842
963
|
}
|
|
1843
|
-
/**
|
|
1844
|
-
* @private
|
|
1845
|
-
* @param {?} action
|
|
1846
|
-
* @return {?}
|
|
1847
|
-
*/
|
|
1848
964
|
dispatchSingle(action) {
|
|
1849
965
|
if (typeof ngDevMode === 'undefined' || ngDevMode) {
|
|
1850
|
-
/** @type {?} */
|
|
1851
966
|
const type = getActionTypeFromInstance(action);
|
|
1852
967
|
if (!type) {
|
|
1853
|
-
/** @type {?} */
|
|
1854
968
|
const error = new Error(`This action doesn't have a type property: ${action.constructor.name}`);
|
|
1855
969
|
return throwError(error);
|
|
1856
970
|
}
|
|
1857
971
|
}
|
|
1858
|
-
/** @type {?} */
|
|
1859
972
|
const prevState = this._stateStream.getValue();
|
|
1860
|
-
/** @type {?} */
|
|
1861
973
|
const plugins = this._pluginManager.plugins;
|
|
1862
|
-
return
|
|
974
|
+
return compose([
|
|
1863
975
|
...plugins,
|
|
1864
|
-
(/**
|
|
1865
|
-
* @param {?} nextState
|
|
1866
|
-
* @param {?} nextAction
|
|
1867
|
-
* @return {?}
|
|
1868
|
-
*/
|
|
1869
976
|
(nextState, nextAction) => {
|
|
1870
977
|
if (nextState !== prevState) {
|
|
1871
978
|
this._stateStream.next(nextState);
|
|
1872
979
|
}
|
|
1873
|
-
/** @type {?} */
|
|
1874
980
|
const actionResult$ = this.getActionResultStream(nextAction);
|
|
1875
|
-
actionResult$.subscribe((
|
|
1876
|
-
* @param {?} ctx
|
|
1877
|
-
* @return {?}
|
|
1878
|
-
*/
|
|
1879
|
-
ctx => this._actions.next(ctx)));
|
|
981
|
+
actionResult$.subscribe(ctx => this._actions.next(ctx));
|
|
1880
982
|
this._actions.next({ action: nextAction, status: "DISPATCHED" /* Dispatched */ });
|
|
1881
983
|
return this.createDispatchObservable(actionResult$);
|
|
1882
|
-
}
|
|
1883
|
-
])(prevState, action)
|
|
984
|
+
}
|
|
985
|
+
])(prevState, action).pipe(shareReplay());
|
|
1884
986
|
}
|
|
1885
|
-
/**
|
|
1886
|
-
* @private
|
|
1887
|
-
* @param {?} action
|
|
1888
|
-
* @return {?}
|
|
1889
|
-
*/
|
|
1890
987
|
getActionResultStream(action) {
|
|
1891
|
-
return this._actionResults.pipe(filter((
|
|
1892
|
-
* @param {?} ctx
|
|
1893
|
-
* @return {?}
|
|
1894
|
-
*/
|
|
1895
|
-
(ctx) => ctx.action === action && ctx.status !== "DISPATCHED" /* Dispatched */)), take(1), shareReplay());
|
|
988
|
+
return this._actionResults.pipe(filter((ctx) => ctx.action === action && ctx.status !== "DISPATCHED" /* Dispatched */), take(1), shareReplay());
|
|
1896
989
|
}
|
|
1897
|
-
/**
|
|
1898
|
-
* @private
|
|
1899
|
-
* @param {?} actionResult$
|
|
1900
|
-
* @return {?}
|
|
1901
|
-
*/
|
|
1902
990
|
createDispatchObservable(actionResult$) {
|
|
1903
991
|
return actionResult$
|
|
1904
|
-
.pipe(exhaustMap((
|
|
1905
|
-
* @param {?} ctx
|
|
1906
|
-
* @return {?}
|
|
1907
|
-
*/
|
|
1908
|
-
(ctx) => {
|
|
992
|
+
.pipe(exhaustMap((ctx) => {
|
|
1909
993
|
switch (ctx.status) {
|
|
1910
994
|
case "SUCCESSFUL" /* Successful */:
|
|
1911
995
|
return of(this._stateStream.getValue());
|
|
@@ -1914,79 +998,25 @@ class InternalDispatcher {
|
|
|
1914
998
|
default:
|
|
1915
999
|
return EMPTY;
|
|
1916
1000
|
}
|
|
1917
|
-
}))
|
|
1001
|
+
}))
|
|
1918
1002
|
.pipe(shareReplay());
|
|
1919
1003
|
}
|
|
1920
1004
|
}
|
|
1921
|
-
InternalDispatcher
|
|
1922
|
-
|
|
1923
|
-
|
|
1924
|
-
|
|
1925
|
-
|
|
1926
|
-
{ type: InternalActions },
|
|
1927
|
-
{ type: InternalDispatchedActionResults },
|
|
1928
|
-
{ type: PluginManager },
|
|
1929
|
-
{ type: StateStream },
|
|
1930
|
-
{ type: InternalNgxsExecutionStrategy },
|
|
1931
|
-
{ type: InternalErrorReporter }
|
|
1932
|
-
];
|
|
1933
|
-
if (false) {
|
|
1934
|
-
/**
|
|
1935
|
-
* @type {?}
|
|
1936
|
-
* @private
|
|
1937
|
-
*/
|
|
1938
|
-
InternalDispatcher.prototype._actions;
|
|
1939
|
-
/**
|
|
1940
|
-
* @type {?}
|
|
1941
|
-
* @private
|
|
1942
|
-
*/
|
|
1943
|
-
InternalDispatcher.prototype._actionResults;
|
|
1944
|
-
/**
|
|
1945
|
-
* @type {?}
|
|
1946
|
-
* @private
|
|
1947
|
-
*/
|
|
1948
|
-
InternalDispatcher.prototype._pluginManager;
|
|
1949
|
-
/**
|
|
1950
|
-
* @type {?}
|
|
1951
|
-
* @private
|
|
1952
|
-
*/
|
|
1953
|
-
InternalDispatcher.prototype._stateStream;
|
|
1954
|
-
/**
|
|
1955
|
-
* @type {?}
|
|
1956
|
-
* @private
|
|
1957
|
-
*/
|
|
1958
|
-
InternalDispatcher.prototype._ngxsExecutionStrategy;
|
|
1959
|
-
/**
|
|
1960
|
-
* @type {?}
|
|
1961
|
-
* @private
|
|
1962
|
-
*/
|
|
1963
|
-
InternalDispatcher.prototype._internalErrorReporter;
|
|
1964
|
-
}
|
|
1005
|
+
/** @nocollapse */ InternalDispatcher.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: InternalDispatcher, deps: [{ token: InternalActions }, { token: InternalDispatchedActionResults }, { token: PluginManager }, { token: StateStream }, { token: InternalNgxsExecutionStrategy }, { token: InternalErrorReporter }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
1006
|
+
/** @nocollapse */ InternalDispatcher.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: InternalDispatcher });
|
|
1007
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: InternalDispatcher, decorators: [{
|
|
1008
|
+
type: Injectable
|
|
1009
|
+
}], ctorParameters: function () { return [{ type: InternalActions }, { type: InternalDispatchedActionResults }, { type: PluginManager }, { type: StateStream }, { type: InternalNgxsExecutionStrategy }, { type: InternalErrorReporter }]; } });
|
|
1965
1010
|
|
|
1966
|
-
/**
|
|
1967
|
-
* @fileoverview added by tsickle
|
|
1968
|
-
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
1969
|
-
*/
|
|
1970
1011
|
/**
|
|
1971
1012
|
* Object freeze code
|
|
1972
1013
|
* https://github.com/jsdf/deep-freeze
|
|
1973
|
-
* @type {?}
|
|
1974
1014
|
*/
|
|
1975
|
-
const deepFreeze = (
|
|
1976
|
-
* @param {?} o
|
|
1977
|
-
* @return {?}
|
|
1978
|
-
*/
|
|
1979
|
-
(o) => {
|
|
1015
|
+
const deepFreeze = (o) => {
|
|
1980
1016
|
Object.freeze(o);
|
|
1981
|
-
/** @type {?} */
|
|
1982
1017
|
const oIsFunction = typeof o === 'function';
|
|
1983
|
-
/** @type {?} */
|
|
1984
1018
|
const hasOwnProp = Object.prototype.hasOwnProperty;
|
|
1985
|
-
Object.getOwnPropertyNames(o).forEach((
|
|
1986
|
-
* @param {?} prop
|
|
1987
|
-
* @return {?}
|
|
1988
|
-
*/
|
|
1989
|
-
function (prop) {
|
|
1019
|
+
Object.getOwnPropertyNames(o).forEach(function (prop) {
|
|
1990
1020
|
if (hasOwnProp.call(o, prop) &&
|
|
1991
1021
|
(oIsFunction ? prop !== 'caller' && prop !== 'callee' && prop !== 'arguments' : true) &&
|
|
1992
1022
|
o[prop] !== null &&
|
|
@@ -1994,24 +1024,15 @@ const deepFreeze = (/**
|
|
|
1994
1024
|
!Object.isFrozen(o[prop])) {
|
|
1995
1025
|
deepFreeze(o[prop]);
|
|
1996
1026
|
}
|
|
1997
|
-
})
|
|
1027
|
+
});
|
|
1998
1028
|
return o;
|
|
1999
|
-
}
|
|
1029
|
+
};
|
|
2000
1030
|
|
|
2001
|
-
/**
|
|
2002
|
-
* @fileoverview added by tsickle
|
|
2003
|
-
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
2004
|
-
*/
|
|
2005
1031
|
/**
|
|
2006
1032
|
* State Context factory class
|
|
2007
1033
|
* @ignore
|
|
2008
1034
|
*/
|
|
2009
1035
|
class InternalStateOperations {
|
|
2010
|
-
/**
|
|
2011
|
-
* @param {?} _stateStream
|
|
2012
|
-
* @param {?} _dispatcher
|
|
2013
|
-
* @param {?} _config
|
|
2014
|
-
*/
|
|
2015
1036
|
constructor(_stateStream, _dispatcher, _config) {
|
|
2016
1037
|
this._stateStream = _stateStream;
|
|
2017
1038
|
this._dispatcher = _dispatcher;
|
|
@@ -2019,25 +1040,12 @@ class InternalStateOperations {
|
|
|
2019
1040
|
}
|
|
2020
1041
|
/**
|
|
2021
1042
|
* Returns the root state operators.
|
|
2022
|
-
* @return {?}
|
|
2023
1043
|
*/
|
|
2024
1044
|
getRootStateOperations() {
|
|
2025
|
-
/** @type {?} */
|
|
2026
1045
|
const rootStateOperations = {
|
|
2027
|
-
getState: (
|
|
2028
|
-
|
|
2029
|
-
|
|
2030
|
-
() => this._stateStream.getValue()),
|
|
2031
|
-
setState: (/**
|
|
2032
|
-
* @param {?} newState
|
|
2033
|
-
* @return {?}
|
|
2034
|
-
*/
|
|
2035
|
-
(newState) => this._stateStream.next(newState)),
|
|
2036
|
-
dispatch: (/**
|
|
2037
|
-
* @param {?} actionOrActions
|
|
2038
|
-
* @return {?}
|
|
2039
|
-
*/
|
|
2040
|
-
(actionOrActions) => this._dispatcher.dispatch(actionOrActions))
|
|
1046
|
+
getState: () => this._stateStream.getValue(),
|
|
1047
|
+
setState: (newState) => this._stateStream.next(newState),
|
|
1048
|
+
dispatch: (actionOrActions) => this._dispatcher.dispatch(actionOrActions)
|
|
2041
1049
|
};
|
|
2042
1050
|
if (typeof ngDevMode === 'undefined' || ngDevMode) {
|
|
2043
1051
|
return this._config.developmentMode
|
|
@@ -2048,145 +1056,68 @@ class InternalStateOperations {
|
|
|
2048
1056
|
return rootStateOperations;
|
|
2049
1057
|
}
|
|
2050
1058
|
}
|
|
2051
|
-
/**
|
|
2052
|
-
* @param {?} results
|
|
2053
|
-
* @return {?}
|
|
2054
|
-
*/
|
|
2055
1059
|
setStateToTheCurrentWithNew(results) {
|
|
2056
|
-
/** @type {?} */
|
|
2057
1060
|
const stateOperations = this.getRootStateOperations();
|
|
2058
1061
|
// Get our current stream
|
|
2059
|
-
/** @type {?} */
|
|
2060
1062
|
const currentState = stateOperations.getState();
|
|
2061
1063
|
// Set the state to the current + new
|
|
2062
|
-
stateOperations.setState(Object.assign({}, currentState, results.defaults));
|
|
1064
|
+
stateOperations.setState(Object.assign(Object.assign({}, currentState), results.defaults));
|
|
2063
1065
|
}
|
|
2064
1066
|
}
|
|
2065
|
-
InternalStateOperations
|
|
2066
|
-
|
|
2067
|
-
|
|
2068
|
-
|
|
2069
|
-
|
|
2070
|
-
{ type: StateStream },
|
|
2071
|
-
{ type: InternalDispatcher },
|
|
2072
|
-
{ type: NgxsConfig }
|
|
2073
|
-
];
|
|
2074
|
-
if (false) {
|
|
2075
|
-
/**
|
|
2076
|
-
* @type {?}
|
|
2077
|
-
* @private
|
|
2078
|
-
*/
|
|
2079
|
-
InternalStateOperations.prototype._stateStream;
|
|
2080
|
-
/**
|
|
2081
|
-
* @type {?}
|
|
2082
|
-
* @private
|
|
2083
|
-
*/
|
|
2084
|
-
InternalStateOperations.prototype._dispatcher;
|
|
2085
|
-
/**
|
|
2086
|
-
* @type {?}
|
|
2087
|
-
* @private
|
|
2088
|
-
*/
|
|
2089
|
-
InternalStateOperations.prototype._config;
|
|
2090
|
-
}
|
|
2091
|
-
/**
|
|
2092
|
-
* @param {?} root
|
|
2093
|
-
* @return {?}
|
|
2094
|
-
*/
|
|
1067
|
+
/** @nocollapse */ InternalStateOperations.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: InternalStateOperations, deps: [{ token: StateStream }, { token: InternalDispatcher }, { token: NgxsConfig }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
1068
|
+
/** @nocollapse */ InternalStateOperations.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: InternalStateOperations });
|
|
1069
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: InternalStateOperations, decorators: [{
|
|
1070
|
+
type: Injectable
|
|
1071
|
+
}], ctorParameters: function () { return [{ type: StateStream }, { type: InternalDispatcher }, { type: NgxsConfig }]; } });
|
|
2095
1072
|
function ensureStateAndActionsAreImmutable(root) {
|
|
2096
1073
|
return {
|
|
2097
|
-
getState: (
|
|
2098
|
-
|
|
2099
|
-
*/
|
|
2100
|
-
() => root.getState()),
|
|
2101
|
-
setState: (/**
|
|
2102
|
-
* @param {?} value
|
|
2103
|
-
* @return {?}
|
|
2104
|
-
*/
|
|
2105
|
-
value => {
|
|
2106
|
-
/** @type {?} */
|
|
1074
|
+
getState: () => root.getState(),
|
|
1075
|
+
setState: value => {
|
|
2107
1076
|
const frozenValue = deepFreeze(value);
|
|
2108
1077
|
return root.setState(frozenValue);
|
|
2109
|
-
}
|
|
2110
|
-
dispatch:
|
|
2111
|
-
* @param {?} actions
|
|
2112
|
-
* @return {?}
|
|
2113
|
-
*/
|
|
2114
|
-
actions => {
|
|
1078
|
+
},
|
|
1079
|
+
dispatch: actions => {
|
|
2115
1080
|
return root.dispatch(actions);
|
|
2116
|
-
}
|
|
1081
|
+
}
|
|
2117
1082
|
};
|
|
2118
1083
|
}
|
|
2119
1084
|
|
|
2120
|
-
|
|
2121
|
-
|
|
2122
|
-
|
|
2123
|
-
|
|
2124
|
-
|
|
2125
|
-
|
|
2126
|
-
|
|
2127
|
-
|
|
2128
|
-
|
|
2129
|
-
function simplePatch(val) {
|
|
2130
|
-
return (/**
|
|
2131
|
-
* @param {?} existingState
|
|
2132
|
-
* @return {?}
|
|
2133
|
-
*/
|
|
2134
|
-
(existingState) => {
|
|
2135
|
-
if (Array.isArray(val)) {
|
|
2136
|
-
throwPatchingArrayError();
|
|
2137
|
-
}
|
|
2138
|
-
else if (typeof val !== 'object') {
|
|
2139
|
-
throwPatchingPrimitiveError();
|
|
1085
|
+
function simplePatch(value) {
|
|
1086
|
+
return (existingState) => {
|
|
1087
|
+
if (typeof ngDevMode === 'undefined' || ngDevMode) {
|
|
1088
|
+
if (Array.isArray(value)) {
|
|
1089
|
+
throwPatchingArrayError();
|
|
1090
|
+
}
|
|
1091
|
+
else if (typeof value !== 'object') {
|
|
1092
|
+
throwPatchingPrimitiveError();
|
|
1093
|
+
}
|
|
2140
1094
|
}
|
|
2141
|
-
|
|
2142
|
-
const
|
|
2143
|
-
for (const key in val) {
|
|
1095
|
+
const newState = Object.assign({}, existingState);
|
|
1096
|
+
for (const key in value) {
|
|
2144
1097
|
// deep clone for patch compatibility
|
|
2145
|
-
|
|
2146
|
-
newState[key] = ((/** @type {?} */ (val)))[key];
|
|
1098
|
+
newState[key] = value[key];
|
|
2147
1099
|
}
|
|
2148
|
-
return
|
|
2149
|
-
}
|
|
1100
|
+
return newState;
|
|
1101
|
+
};
|
|
2150
1102
|
}
|
|
2151
1103
|
|
|
2152
|
-
/**
|
|
2153
|
-
* @fileoverview added by tsickle
|
|
2154
|
-
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
2155
|
-
*/
|
|
2156
1104
|
/**
|
|
2157
1105
|
* State Context factory class
|
|
2158
1106
|
* @ignore
|
|
2159
1107
|
*/
|
|
2160
1108
|
class StateContextFactory {
|
|
2161
|
-
/**
|
|
2162
|
-
* @param {?} _internalStateOperations
|
|
2163
|
-
*/
|
|
2164
1109
|
constructor(_internalStateOperations) {
|
|
2165
1110
|
this._internalStateOperations = _internalStateOperations;
|
|
2166
1111
|
}
|
|
2167
1112
|
/**
|
|
2168
1113
|
* Create the state context
|
|
2169
|
-
* @template T
|
|
2170
|
-
* @param {?} mappedStore
|
|
2171
|
-
* @return {?}
|
|
2172
1114
|
*/
|
|
2173
1115
|
createStateContext(mappedStore) {
|
|
2174
|
-
/** @type {?} */
|
|
2175
1116
|
const root = this._internalStateOperations.getRootStateOperations();
|
|
2176
|
-
/**
|
|
2177
|
-
* @param {?} currentAppState
|
|
2178
|
-
* @return {?}
|
|
2179
|
-
*/
|
|
2180
1117
|
function getState(currentAppState) {
|
|
2181
1118
|
return getValue(currentAppState, mappedStore.path);
|
|
2182
1119
|
}
|
|
2183
|
-
/**
|
|
2184
|
-
* @param {?} currentAppState
|
|
2185
|
-
* @param {?} newValue
|
|
2186
|
-
* @return {?}
|
|
2187
|
-
*/
|
|
2188
1120
|
function setStateValue(currentAppState, newValue) {
|
|
2189
|
-
/** @type {?} */
|
|
2190
1121
|
const newAppState = setValue(currentAppState, mappedStore.path, newValue);
|
|
2191
1122
|
root.setState(newAppState);
|
|
2192
1123
|
return newAppState;
|
|
@@ -2197,93 +1128,43 @@ class StateContextFactory {
|
|
|
2197
1128
|
// This needs to be fixed, but is a 'breaking' change.
|
|
2198
1129
|
// I will do this fix in a subsequent PR and we can decide how to handle it.
|
|
2199
1130
|
}
|
|
2200
|
-
/**
|
|
2201
|
-
* @param {?} currentAppState
|
|
2202
|
-
* @param {?} stateOperator
|
|
2203
|
-
* @return {?}
|
|
2204
|
-
*/
|
|
2205
1131
|
function setStateFromOperator(currentAppState, stateOperator) {
|
|
2206
|
-
/** @type {?} */
|
|
2207
1132
|
const local = getState(currentAppState);
|
|
2208
|
-
/** @type {?} */
|
|
2209
1133
|
const newValue = stateOperator(local);
|
|
2210
1134
|
return setStateValue(currentAppState, newValue);
|
|
2211
1135
|
}
|
|
2212
|
-
/**
|
|
2213
|
-
* @param {?} value
|
|
2214
|
-
* @return {?}
|
|
2215
|
-
*/
|
|
2216
1136
|
function isStateOperator(value) {
|
|
2217
1137
|
return typeof value === 'function';
|
|
2218
1138
|
}
|
|
2219
1139
|
return {
|
|
2220
|
-
/**
|
|
2221
|
-
* @return {?}
|
|
2222
|
-
*/
|
|
2223
1140
|
getState() {
|
|
2224
|
-
/** @type {?} */
|
|
2225
1141
|
const currentAppState = root.getState();
|
|
2226
1142
|
return getState(currentAppState);
|
|
2227
1143
|
},
|
|
2228
|
-
/**
|
|
2229
|
-
* @param {?} val
|
|
2230
|
-
* @return {?}
|
|
2231
|
-
*/
|
|
2232
1144
|
patchState(val) {
|
|
2233
|
-
/** @type {?} */
|
|
2234
1145
|
const currentAppState = root.getState();
|
|
2235
|
-
/** @type {?} */
|
|
2236
1146
|
const patchOperator = simplePatch(val);
|
|
2237
1147
|
return setStateFromOperator(currentAppState, patchOperator);
|
|
2238
1148
|
},
|
|
2239
|
-
/**
|
|
2240
|
-
* @param {?} val
|
|
2241
|
-
* @return {?}
|
|
2242
|
-
*/
|
|
2243
1149
|
setState(val) {
|
|
2244
|
-
/** @type {?} */
|
|
2245
1150
|
const currentAppState = root.getState();
|
|
2246
1151
|
return isStateOperator(val)
|
|
2247
1152
|
? setStateFromOperator(currentAppState, val)
|
|
2248
1153
|
: setStateValue(currentAppState, val);
|
|
2249
1154
|
},
|
|
2250
|
-
/**
|
|
2251
|
-
* @param {?} actions
|
|
2252
|
-
* @return {?}
|
|
2253
|
-
*/
|
|
2254
1155
|
dispatch(actions) {
|
|
2255
1156
|
return root.dispatch(actions);
|
|
2256
1157
|
}
|
|
2257
1158
|
};
|
|
2258
1159
|
}
|
|
2259
1160
|
}
|
|
2260
|
-
StateContextFactory
|
|
2261
|
-
|
|
2262
|
-
|
|
2263
|
-
|
|
2264
|
-
|
|
2265
|
-
{ type: InternalStateOperations }
|
|
2266
|
-
];
|
|
2267
|
-
if (false) {
|
|
2268
|
-
/**
|
|
2269
|
-
* @type {?}
|
|
2270
|
-
* @private
|
|
2271
|
-
*/
|
|
2272
|
-
StateContextFactory.prototype._internalStateOperations;
|
|
2273
|
-
}
|
|
1161
|
+
/** @nocollapse */ StateContextFactory.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: StateContextFactory, deps: [{ token: InternalStateOperations }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
1162
|
+
/** @nocollapse */ StateContextFactory.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: StateContextFactory });
|
|
1163
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: StateContextFactory, decorators: [{
|
|
1164
|
+
type: Injectable
|
|
1165
|
+
}], ctorParameters: function () { return [{ type: InternalStateOperations }]; } });
|
|
2274
1166
|
|
|
2275
|
-
/**
|
|
2276
|
-
* @fileoverview added by tsickle
|
|
2277
|
-
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
2278
|
-
*/
|
|
2279
|
-
/**
|
|
2280
|
-
* @abstract
|
|
2281
|
-
*/
|
|
2282
1167
|
class StoreValidators {
|
|
2283
|
-
/**
|
|
2284
|
-
* @param {?} name
|
|
2285
|
-
* @return {?}
|
|
2286
|
-
*/
|
|
2287
1168
|
static checkThatStateIsNamedCorrectly(name) {
|
|
2288
1169
|
if (!name) {
|
|
2289
1170
|
throwStateNamePropertyError();
|
|
@@ -2292,88 +1173,112 @@ class StoreValidators {
|
|
|
2292
1173
|
throwStateNameError(name);
|
|
2293
1174
|
}
|
|
2294
1175
|
}
|
|
2295
|
-
/**
|
|
2296
|
-
* @param {?} stateName
|
|
2297
|
-
* @param {?} state
|
|
2298
|
-
* @param {?} statesByName
|
|
2299
|
-
* @return {?}
|
|
2300
|
-
*/
|
|
2301
1176
|
static checkThatStateNameIsUnique(stateName, state, statesByName) {
|
|
2302
|
-
/** @type {?} */
|
|
2303
1177
|
const existingState = statesByName[stateName];
|
|
2304
1178
|
if (existingState && existingState !== state) {
|
|
2305
1179
|
throwStateUniqueError(stateName, state.name, existingState.name);
|
|
2306
1180
|
}
|
|
2307
1181
|
}
|
|
2308
|
-
/**
|
|
2309
|
-
* @param {?} stateClasses
|
|
2310
|
-
* @return {?}
|
|
2311
|
-
*/
|
|
2312
1182
|
static checkThatStateClassesHaveBeenDecorated(stateClasses) {
|
|
2313
|
-
stateClasses.forEach((
|
|
2314
|
-
|
|
2315
|
-
* @return {?}
|
|
2316
|
-
*/
|
|
2317
|
-
(stateClass) => {
|
|
2318
|
-
if (!getStoreMetadata(stateClass)) {
|
|
1183
|
+
stateClasses.forEach((stateClass) => {
|
|
1184
|
+
if (!getStoreMetadata$1(stateClass)) {
|
|
2319
1185
|
throwStateDecoratorError(stateClass.name);
|
|
2320
1186
|
}
|
|
2321
|
-
})
|
|
1187
|
+
});
|
|
2322
1188
|
}
|
|
2323
1189
|
}
|
|
2324
1190
|
StoreValidators.stateNameRegex = new RegExp('^[a-zA-Z0-9_]+$');
|
|
2325
|
-
if (false) {
|
|
2326
|
-
/**
|
|
2327
|
-
* @type {?}
|
|
2328
|
-
* @private
|
|
2329
|
-
*/
|
|
2330
|
-
StoreValidators.stateNameRegex;
|
|
2331
|
-
}
|
|
2332
1191
|
|
|
2333
1192
|
/**
|
|
2334
|
-
*
|
|
2335
|
-
*
|
|
2336
|
-
*/
|
|
2337
|
-
/**
|
|
2338
|
-
* All provided or injected tokens must have `\@Injectable` decorator
|
|
2339
|
-
* (previously, injected tokens without `\@Injectable` were allowed
|
|
1193
|
+
* All provided or injected tokens must have `@Injectable` decorator
|
|
1194
|
+
* (previously, injected tokens without `@Injectable` were allowed
|
|
2340
1195
|
* if another decorator was used, e.g. pipes).
|
|
2341
|
-
* @param {?} stateClass
|
|
2342
|
-
* @return {?}
|
|
2343
1196
|
*/
|
|
2344
1197
|
function ensureStateClassIsInjectable(stateClass) {
|
|
2345
1198
|
// `ɵprov` is a static property added by the NGCC compiler. It always exists in
|
|
2346
1199
|
// AOT mode because this property is added before runtime. If an application is running in
|
|
2347
1200
|
// JIT mode then this property can be added by the `@Injectable()` decorator. The `@Injectable()`
|
|
2348
1201
|
// decorator has to go after the `@State()` decorator, thus we prevent users from unwanted DI errors.
|
|
2349
|
-
|
|
2350
|
-
|
|
2351
|
-
|
|
2352
|
-
|
|
2353
|
-
// Don't warn if Ivy is disabled or `ɵprov` exists on the class
|
|
2354
|
-
console.warn(getUndecoratedStateInIvyWarningMessage(stateClass.name));
|
|
2355
|
-
}
|
|
1202
|
+
const ngInjectableDef = stateClass.ɵprov;
|
|
1203
|
+
if (!ngInjectableDef) {
|
|
1204
|
+
// Don't warn if Ivy is disabled or `ɵprov` exists on the class
|
|
1205
|
+
console.warn(getUndecoratedStateInIvyWarningMessage(stateClass.name));
|
|
2356
1206
|
}
|
|
2357
1207
|
}
|
|
2358
1208
|
|
|
2359
1209
|
/**
|
|
2360
|
-
*
|
|
2361
|
-
|
|
1210
|
+
* Init action
|
|
1211
|
+
*/
|
|
1212
|
+
class InitState {
|
|
1213
|
+
static get type() {
|
|
1214
|
+
// NOTE: Not necessary to declare the type in this way in your code. See https://github.com/ngxs/store/pull/644#issuecomment-436003138
|
|
1215
|
+
return '@@INIT';
|
|
1216
|
+
}
|
|
1217
|
+
}
|
|
1218
|
+
/**
|
|
1219
|
+
* Update action
|
|
2362
1220
|
*/
|
|
1221
|
+
class UpdateState {
|
|
1222
|
+
constructor(addedStates) {
|
|
1223
|
+
this.addedStates = addedStates;
|
|
1224
|
+
}
|
|
1225
|
+
static get type() {
|
|
1226
|
+
// NOTE: Not necessary to declare the type in this way in your code. See https://github.com/ngxs/store/pull/644#issuecomment-436003138
|
|
1227
|
+
return '@@UPDATE_STATE';
|
|
1228
|
+
}
|
|
1229
|
+
}
|
|
1230
|
+
|
|
1231
|
+
const NGXS_DEVELOPMENT_OPTIONS = new InjectionToken('NGXS_DEVELOPMENT_OPTIONS', {
|
|
1232
|
+
providedIn: 'root',
|
|
1233
|
+
factory: () => ({ warnOnUnhandledActions: true })
|
|
1234
|
+
});
|
|
1235
|
+
|
|
1236
|
+
class NgxsUnhandledActionsLogger {
|
|
1237
|
+
constructor(options) {
|
|
1238
|
+
/**
|
|
1239
|
+
* These actions should be ignored by default; the user can increase this
|
|
1240
|
+
* list in the future via the `ignoreActions` method.
|
|
1241
|
+
*/
|
|
1242
|
+
this._ignoredActions = new Set([InitState.type, UpdateState.type]);
|
|
1243
|
+
if (typeof options.warnOnUnhandledActions === 'object') {
|
|
1244
|
+
this.ignoreActions(...options.warnOnUnhandledActions.ignore);
|
|
1245
|
+
}
|
|
1246
|
+
}
|
|
1247
|
+
/**
|
|
1248
|
+
* Adds actions to the internal list of actions that should be ignored.
|
|
1249
|
+
*/
|
|
1250
|
+
ignoreActions(...actions) {
|
|
1251
|
+
for (const action of actions) {
|
|
1252
|
+
this._ignoredActions.add(action.type);
|
|
1253
|
+
}
|
|
1254
|
+
}
|
|
1255
|
+
/** @internal */
|
|
1256
|
+
warn(action) {
|
|
1257
|
+
const actionShouldBeIgnored = Array.from(this._ignoredActions).some(type => type === getActionTypeFromInstance(action));
|
|
1258
|
+
if (actionShouldBeIgnored) {
|
|
1259
|
+
return;
|
|
1260
|
+
}
|
|
1261
|
+
action =
|
|
1262
|
+
action.constructor && action.constructor.name !== 'Object'
|
|
1263
|
+
? action.constructor.name
|
|
1264
|
+
: action.type;
|
|
1265
|
+
console.warn(`The ${action} action has been dispatched but hasn't been handled. This may happen if the state with an action handler for this action is not registered.`);
|
|
1266
|
+
}
|
|
1267
|
+
}
|
|
1268
|
+
/** @nocollapse */ NgxsUnhandledActionsLogger.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: NgxsUnhandledActionsLogger, deps: [{ token: NGXS_DEVELOPMENT_OPTIONS }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
1269
|
+
/** @nocollapse */ NgxsUnhandledActionsLogger.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: NgxsUnhandledActionsLogger });
|
|
1270
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: NgxsUnhandledActionsLogger, decorators: [{
|
|
1271
|
+
type: Injectable
|
|
1272
|
+
}], ctorParameters: function () { return [{ type: undefined, decorators: [{
|
|
1273
|
+
type: Inject,
|
|
1274
|
+
args: [NGXS_DEVELOPMENT_OPTIONS]
|
|
1275
|
+
}] }]; } });
|
|
1276
|
+
|
|
2363
1277
|
/**
|
|
2364
1278
|
* State factory class
|
|
2365
1279
|
* @ignore
|
|
2366
1280
|
*/
|
|
2367
1281
|
class StateFactory {
|
|
2368
|
-
/**
|
|
2369
|
-
* @param {?} _injector
|
|
2370
|
-
* @param {?} _config
|
|
2371
|
-
* @param {?} _parentFactory
|
|
2372
|
-
* @param {?} _actions
|
|
2373
|
-
* @param {?} _actionResults
|
|
2374
|
-
* @param {?} _stateContextFactory
|
|
2375
|
-
* @param {?} _initialState
|
|
2376
|
-
*/
|
|
2377
1282
|
constructor(_injector, _config, _parentFactory, _actions, _actionResults, _stateContextFactory, _initialState) {
|
|
2378
1283
|
this._injector = _injector;
|
|
2379
1284
|
this._config = _config;
|
|
@@ -2386,91 +1291,52 @@ class StateFactory {
|
|
|
2386
1291
|
this._states = [];
|
|
2387
1292
|
this._statesByName = {};
|
|
2388
1293
|
this._statePaths = {};
|
|
2389
|
-
this.getRuntimeSelectorContext = memoize((
|
|
2390
|
-
|
|
2391
|
-
*/
|
|
2392
|
-
() => {
|
|
2393
|
-
/** @type {?} */
|
|
1294
|
+
this.getRuntimeSelectorContext = memoize(() => {
|
|
1295
|
+
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
|
2394
1296
|
const stateFactory = this;
|
|
2395
|
-
/**
|
|
2396
|
-
* @param {?} key
|
|
2397
|
-
* @return {?}
|
|
2398
|
-
*/
|
|
2399
1297
|
function resolveGetter(key) {
|
|
2400
|
-
/** @type {?} */
|
|
2401
1298
|
const path = stateFactory.statePaths[key];
|
|
2402
1299
|
return path ? propGetter(path.split('.'), stateFactory._config) : null;
|
|
2403
1300
|
}
|
|
2404
|
-
/** @type {?} */
|
|
2405
1301
|
const context = this._parentFactory
|
|
2406
1302
|
? this._parentFactory.getRuntimeSelectorContext()
|
|
2407
1303
|
: {
|
|
2408
|
-
/**
|
|
2409
|
-
* @param {?} key
|
|
2410
|
-
* @return {?}
|
|
2411
|
-
*/
|
|
2412
1304
|
getStateGetter(key) {
|
|
2413
|
-
/** @type {?} */
|
|
2414
1305
|
let getter = resolveGetter(key);
|
|
2415
1306
|
if (getter) {
|
|
2416
1307
|
return getter;
|
|
2417
1308
|
}
|
|
2418
|
-
return (
|
|
2419
|
-
* @param {...?} args
|
|
2420
|
-
* @return {?}
|
|
2421
|
-
*/
|
|
2422
|
-
(...args) => {
|
|
1309
|
+
return (...args) => {
|
|
2423
1310
|
// Late loaded getter
|
|
2424
1311
|
if (!getter) {
|
|
2425
1312
|
getter = resolveGetter(key);
|
|
2426
1313
|
}
|
|
2427
1314
|
return getter ? getter(...args) : undefined;
|
|
2428
|
-
}
|
|
1315
|
+
};
|
|
2429
1316
|
},
|
|
2430
|
-
/**
|
|
2431
|
-
* @param {?=} localOptions
|
|
2432
|
-
* @return {?}
|
|
2433
|
-
*/
|
|
2434
1317
|
getSelectorOptions(localOptions) {
|
|
2435
|
-
/** @type {?} */
|
|
2436
1318
|
const globalSelectorOptions = stateFactory._config.selectorOptions;
|
|
2437
|
-
return Object.assign({}, globalSelectorOptions, (localOptions || {}));
|
|
1319
|
+
return Object.assign(Object.assign({}, globalSelectorOptions), (localOptions || {}));
|
|
2438
1320
|
}
|
|
2439
1321
|
};
|
|
2440
1322
|
return context;
|
|
2441
|
-
})
|
|
1323
|
+
});
|
|
2442
1324
|
}
|
|
2443
|
-
/**
|
|
2444
|
-
* @return {?}
|
|
2445
|
-
*/
|
|
2446
1325
|
get states() {
|
|
2447
1326
|
return this._parentFactory ? this._parentFactory.states : this._states;
|
|
2448
1327
|
}
|
|
2449
|
-
/**
|
|
2450
|
-
* @return {?}
|
|
2451
|
-
*/
|
|
2452
1328
|
get statesByName() {
|
|
2453
1329
|
return this._parentFactory ? this._parentFactory.statesByName : this._statesByName;
|
|
2454
1330
|
}
|
|
2455
|
-
/**
|
|
2456
|
-
* @private
|
|
2457
|
-
* @return {?}
|
|
2458
|
-
*/
|
|
2459
1331
|
get statePaths() {
|
|
2460
1332
|
return this._parentFactory ? this._parentFactory.statePaths : this._statePaths;
|
|
2461
1333
|
}
|
|
2462
|
-
/**
|
|
2463
|
-
* @private
|
|
2464
|
-
* @param {?} defaults
|
|
2465
|
-
* @return {?}
|
|
2466
|
-
*/
|
|
2467
1334
|
static cloneDefaults(defaults) {
|
|
2468
|
-
/** @type {?} */
|
|
2469
1335
|
let value = {};
|
|
2470
1336
|
if (Array.isArray(defaults)) {
|
|
2471
1337
|
value = defaults.slice();
|
|
2472
1338
|
}
|
|
2473
|
-
else if (isObject(defaults)) {
|
|
1339
|
+
else if (isObject$1(defaults)) {
|
|
2474
1340
|
value = Object.assign({}, defaults);
|
|
2475
1341
|
}
|
|
2476
1342
|
else if (defaults === undefined) {
|
|
@@ -2481,20 +1347,13 @@ class StateFactory {
|
|
|
2481
1347
|
}
|
|
2482
1348
|
return value;
|
|
2483
1349
|
}
|
|
2484
|
-
/**
|
|
2485
|
-
* @return {?}
|
|
2486
|
-
*/
|
|
2487
1350
|
ngOnDestroy() {
|
|
2488
|
-
//
|
|
2489
|
-
//
|
|
2490
|
-
|
|
2491
|
-
// for the first time along with the `NgxsRootModule`.
|
|
2492
|
-
(/** @type {?} */ (this._actionsSubscription)).unsubscribe();
|
|
1351
|
+
// This is being non-null asserted since `_actionsSubscrition` is
|
|
1352
|
+
// initialized within the constructor.
|
|
1353
|
+
this._actionsSubscription.unsubscribe();
|
|
2493
1354
|
}
|
|
2494
1355
|
/**
|
|
2495
1356
|
* Add a new state to the global defs.
|
|
2496
|
-
* @param {?} stateClasses
|
|
2497
|
-
* @return {?}
|
|
2498
1357
|
*/
|
|
2499
1358
|
add(stateClasses) {
|
|
2500
1359
|
// Caretaker note: we have still left the `typeof` condition in order to avoid
|
|
@@ -2505,23 +1364,15 @@ class StateFactory {
|
|
|
2505
1364
|
const { newStates } = this.addToStatesMap(stateClasses);
|
|
2506
1365
|
if (!newStates.length)
|
|
2507
1366
|
return [];
|
|
2508
|
-
/** @type {?} */
|
|
2509
1367
|
const stateGraph = buildGraph(newStates);
|
|
2510
|
-
/** @type {?} */
|
|
2511
1368
|
const sortedStates = topologicalSort(stateGraph);
|
|
2512
|
-
/** @type {?} */
|
|
2513
1369
|
const paths = findFullParentPath(stateGraph);
|
|
2514
|
-
/** @type {?} */
|
|
2515
1370
|
const nameGraph = nameToState(newStates);
|
|
2516
|
-
/** @type {?} */
|
|
2517
1371
|
const bootstrappedStores = [];
|
|
2518
1372
|
for (const name of sortedStates) {
|
|
2519
|
-
/** @type {?} */
|
|
2520
1373
|
const stateClass = nameGraph[name];
|
|
2521
|
-
/** @type {?} */
|
|
2522
1374
|
const path = paths[name];
|
|
2523
|
-
|
|
2524
|
-
const meta = (/** @type {?} */ (stateClass[META_KEY]));
|
|
1375
|
+
const meta = stateClass[META_KEY];
|
|
2525
1376
|
this.addRuntimeInfoToMeta(meta, path);
|
|
2526
1377
|
// Note: previously we called `ensureStateClassIsInjectable` within the
|
|
2527
1378
|
// `State` decorator. This check is moved here because the `ɵprov` property
|
|
@@ -2530,7 +1381,6 @@ class StateFactory {
|
|
|
2530
1381
|
if (typeof ngDevMode === 'undefined' || ngDevMode) {
|
|
2531
1382
|
ensureStateClassIsInjectable(stateClass);
|
|
2532
1383
|
}
|
|
2533
|
-
/** @type {?} */
|
|
2534
1384
|
const stateMap = {
|
|
2535
1385
|
name,
|
|
2536
1386
|
path,
|
|
@@ -2551,80 +1401,43 @@ class StateFactory {
|
|
|
2551
1401
|
}
|
|
2552
1402
|
/**
|
|
2553
1403
|
* Add a set of states to the store and return the defaults
|
|
2554
|
-
* @param {?} stateClasses
|
|
2555
|
-
* @return {?}
|
|
2556
1404
|
*/
|
|
2557
1405
|
addAndReturnDefaults(stateClasses) {
|
|
2558
|
-
/** @type {?} */
|
|
2559
1406
|
const classes = stateClasses || [];
|
|
2560
|
-
/** @type {?} */
|
|
2561
1407
|
const mappedStores = this.add(classes);
|
|
2562
|
-
|
|
2563
|
-
const defaults = mappedStores.reduce((/**
|
|
2564
|
-
* @param {?} result
|
|
2565
|
-
* @param {?} mappedStore
|
|
2566
|
-
* @return {?}
|
|
2567
|
-
*/
|
|
2568
|
-
(result, mappedStore) => setValue(result, mappedStore.path, mappedStore.defaults)), {});
|
|
1408
|
+
const defaults = mappedStores.reduce((result, mappedStore) => setValue(result, mappedStore.path, mappedStore.defaults), {});
|
|
2569
1409
|
return { defaults, states: mappedStores };
|
|
2570
1410
|
}
|
|
2571
1411
|
/**
|
|
2572
1412
|
* Bind the actions to the handlers
|
|
2573
|
-
* @return {?}
|
|
2574
1413
|
*/
|
|
2575
1414
|
connectActionHandlers() {
|
|
2576
1415
|
if (this._actionsSubscription !== null)
|
|
2577
1416
|
return;
|
|
2578
|
-
/** @type {?} */
|
|
2579
1417
|
const dispatched$ = new Subject();
|
|
2580
1418
|
this._actionsSubscription = this._actions
|
|
2581
|
-
.pipe(filter((
|
|
2582
|
-
* @param {?} ctx
|
|
2583
|
-
* @return {?}
|
|
2584
|
-
*/
|
|
2585
|
-
(ctx) => ctx.status === "DISPATCHED" /* Dispatched */)), mergeMap((/**
|
|
2586
|
-
* @param {?} ctx
|
|
2587
|
-
* @return {?}
|
|
2588
|
-
*/
|
|
2589
|
-
ctx => {
|
|
1419
|
+
.pipe(filter((ctx) => ctx.status === "DISPATCHED" /* Dispatched */), mergeMap(ctx => {
|
|
2590
1420
|
dispatched$.next(ctx);
|
|
2591
|
-
/** @type {?} */
|
|
2592
1421
|
const action = ctx.action;
|
|
2593
|
-
return this.invokeActions(dispatched$, (
|
|
2594
|
-
|
|
2595
|
-
|
|
2596
|
-
() => (/** @type {?} */ ({ action, status: "SUCCESSFUL" /* Successful */ })))), defaultIfEmpty((/** @type {?} */ ({ action, status: "CANCELED" /* Canceled */ }))), catchError((/**
|
|
2597
|
-
* @param {?} error
|
|
2598
|
-
* @return {?}
|
|
2599
|
-
*/
|
|
2600
|
-
error => of((/** @type {?} */ ({ action, status: "ERRORED" /* Errored */, error }))))));
|
|
2601
|
-
})))
|
|
2602
|
-
.subscribe((/**
|
|
2603
|
-
* @param {?} ctx
|
|
2604
|
-
* @return {?}
|
|
2605
|
-
*/
|
|
2606
|
-
ctx => this._actionResults.next(ctx)));
|
|
1422
|
+
return this.invokeActions(dispatched$, action).pipe(map(() => ({ action, status: "SUCCESSFUL" /* Successful */ })), defaultIfEmpty({ action, status: "CANCELED" /* Canceled */ }), catchError(error => of({ action, status: "ERRORED" /* Errored */, error })));
|
|
1423
|
+
}))
|
|
1424
|
+
.subscribe(ctx => this._actionResults.next(ctx));
|
|
2607
1425
|
}
|
|
2608
1426
|
/**
|
|
2609
1427
|
* Invoke actions on the states.
|
|
2610
|
-
* @param {?} dispatched$
|
|
2611
|
-
* @param {?} action
|
|
2612
|
-
* @return {?}
|
|
2613
1428
|
*/
|
|
2614
1429
|
invokeActions(dispatched$, action) {
|
|
2615
|
-
|
|
2616
|
-
const type = (/** @type {?} */ (getActionTypeFromInstance(action)));
|
|
2617
|
-
/** @type {?} */
|
|
1430
|
+
const type = getActionTypeFromInstance(action);
|
|
2618
1431
|
const results = [];
|
|
1432
|
+
// Determines whether the dispatched action has been handled, this is assigned
|
|
1433
|
+
// to `true` within the below `for` loop if any `actionMetas` has been found.
|
|
1434
|
+
let actionHasBeenHandled = false;
|
|
2619
1435
|
for (const metadata of this.states) {
|
|
2620
|
-
/** @type {?} */
|
|
2621
1436
|
const actionMetas = metadata.actions[type];
|
|
2622
1437
|
if (actionMetas) {
|
|
2623
1438
|
for (const actionMeta of actionMetas) {
|
|
2624
|
-
/** @type {?} */
|
|
2625
1439
|
const stateContext = this._stateContextFactory.createStateContext(metadata);
|
|
2626
1440
|
try {
|
|
2627
|
-
/** @type {?} */
|
|
2628
1441
|
let result = metadata.instance[actionMeta.fn](stateContext, action);
|
|
2629
1442
|
if (result instanceof Promise) {
|
|
2630
1443
|
result = from(result);
|
|
@@ -2638,11 +1451,7 @@ class StateFactory {
|
|
|
2638
1451
|
// `handler(ctx) { return EMPTY; }`
|
|
2639
1452
|
// then the action will be canceled.
|
|
2640
1453
|
// See https://github.com/ngxs/store/issues/1568
|
|
2641
|
-
result = result.pipe(mergeMap((
|
|
2642
|
-
* @param {?} value
|
|
2643
|
-
* @return {?}
|
|
2644
|
-
*/
|
|
2645
|
-
(value) => {
|
|
1454
|
+
result = result.pipe(mergeMap((value) => {
|
|
2646
1455
|
if (value instanceof Promise) {
|
|
2647
1456
|
return from(value);
|
|
2648
1457
|
}
|
|
@@ -2650,10 +1459,10 @@ class StateFactory {
|
|
|
2650
1459
|
return value;
|
|
2651
1460
|
}
|
|
2652
1461
|
return of(value);
|
|
2653
|
-
})
|
|
1462
|
+
}), defaultIfEmpty({}));
|
|
2654
1463
|
if (actionMeta.options.cancelUncompleted) {
|
|
2655
1464
|
// todo: ofActionDispatched should be used with action class
|
|
2656
|
-
result = result.pipe(takeUntil(dispatched$.pipe(ofActionDispatched(
|
|
1465
|
+
result = result.pipe(takeUntil(dispatched$.pipe(ofActionDispatched(action))));
|
|
2657
1466
|
}
|
|
2658
1467
|
}
|
|
2659
1468
|
else {
|
|
@@ -2664,33 +1473,36 @@ class StateFactory {
|
|
|
2664
1473
|
catch (e) {
|
|
2665
1474
|
results.push(throwError(e));
|
|
2666
1475
|
}
|
|
1476
|
+
actionHasBeenHandled = true;
|
|
2667
1477
|
}
|
|
2668
1478
|
}
|
|
2669
1479
|
}
|
|
1480
|
+
// The `NgxsUnhandledActionsLogger` is a tree-shakable class which functions
|
|
1481
|
+
// only during development.
|
|
1482
|
+
if ((typeof ngDevMode === 'undefined' || ngDevMode) && !actionHasBeenHandled) {
|
|
1483
|
+
const unhandledActionsLogger = this._injector.get(NgxsUnhandledActionsLogger, null);
|
|
1484
|
+
// The `NgxsUnhandledActionsLogger` will not be resolved by the injector if the
|
|
1485
|
+
// `NgxsDevelopmentModule` is not provided. It's enough to check whether the `injector.get`
|
|
1486
|
+
// didn't return `null` so we may ensure the module has been imported.
|
|
1487
|
+
if (unhandledActionsLogger) {
|
|
1488
|
+
unhandledActionsLogger.warn(action);
|
|
1489
|
+
}
|
|
1490
|
+
}
|
|
2670
1491
|
if (!results.length) {
|
|
2671
1492
|
results.push(of({}));
|
|
2672
1493
|
}
|
|
2673
1494
|
return forkJoin(results);
|
|
2674
1495
|
}
|
|
2675
|
-
/**
|
|
2676
|
-
* @private
|
|
2677
|
-
* @param {?} stateClasses
|
|
2678
|
-
* @return {?}
|
|
2679
|
-
*/
|
|
2680
1496
|
addToStatesMap(stateClasses) {
|
|
2681
|
-
/** @type {?} */
|
|
2682
1497
|
const newStates = [];
|
|
2683
|
-
/** @type {?} */
|
|
2684
1498
|
const statesMap = this.statesByName;
|
|
2685
1499
|
for (const stateClass of stateClasses) {
|
|
2686
|
-
|
|
2687
|
-
const stateName = (/** @type {?} */ (getStoreMetadata(stateClass).name));
|
|
1500
|
+
const stateName = getStoreMetadata$1(stateClass).name;
|
|
2688
1501
|
// Caretaker note: we have still left the `typeof` condition in order to avoid
|
|
2689
1502
|
// creating a breaking change for projects that still use the View Engine.
|
|
2690
1503
|
if (typeof ngDevMode === 'undefined' || ngDevMode) {
|
|
2691
1504
|
StoreValidators.checkThatStateNameIsUnique(stateName, stateClass, statesMap);
|
|
2692
1505
|
}
|
|
2693
|
-
/** @type {?} */
|
|
2694
1506
|
const unmountedState = !statesMap[stateName];
|
|
2695
1507
|
if (unmountedState) {
|
|
2696
1508
|
newStates.push(stateClass);
|
|
@@ -2699,210 +1511,51 @@ class StateFactory {
|
|
|
2699
1511
|
}
|
|
2700
1512
|
return { newStates };
|
|
2701
1513
|
}
|
|
2702
|
-
/**
|
|
2703
|
-
* @private
|
|
2704
|
-
* @param {?} meta
|
|
2705
|
-
* @param {?} path
|
|
2706
|
-
* @return {?}
|
|
2707
|
-
*/
|
|
2708
1514
|
addRuntimeInfoToMeta(meta, path) {
|
|
2709
|
-
this.statePaths[
|
|
1515
|
+
this.statePaths[meta.name] = path;
|
|
2710
1516
|
// TODO: v4 - we plan to get rid of the path property because it is non-deterministic
|
|
2711
1517
|
// we can do this when we get rid of the incorrectly exposed getStoreMetadata
|
|
2712
1518
|
// We will need to come up with an alternative in v4 because this is used by many plugins
|
|
2713
1519
|
meta.path = path;
|
|
2714
1520
|
}
|
|
2715
1521
|
/**
|
|
2716
|
-
*
|
|
1522
|
+
* @description
|
|
2717
1523
|
* the method checks if the state has already been added to the tree
|
|
2718
1524
|
* and completed the life cycle
|
|
2719
|
-
* @
|
|
2720
|
-
* @param
|
|
2721
|
-
* @param {?} path
|
|
2722
|
-
* @return {?}
|
|
1525
|
+
* @param name
|
|
1526
|
+
* @param path
|
|
2723
1527
|
*/
|
|
2724
1528
|
hasBeenMountedAndBootstrapped(name, path) {
|
|
2725
|
-
/** @type {?} */
|
|
2726
1529
|
const valueIsBootstrappedInInitialState = getValue(this._initialState, path) !== undefined;
|
|
2727
1530
|
return this.statesByName[name] && valueIsBootstrappedInInitialState;
|
|
2728
1531
|
}
|
|
2729
1532
|
}
|
|
2730
|
-
StateFactory
|
|
2731
|
-
|
|
2732
|
-
|
|
2733
|
-
|
|
2734
|
-
|
|
2735
|
-
|
|
2736
|
-
|
|
2737
|
-
|
|
2738
|
-
|
|
2739
|
-
|
|
2740
|
-
|
|
2741
|
-
|
|
2742
|
-
]
|
|
2743
|
-
|
|
2744
|
-
/**
|
|
2745
|
-
* @type {?}
|
|
2746
|
-
* @private
|
|
2747
|
-
*/
|
|
2748
|
-
StateFactory.prototype._actionsSubscription;
|
|
2749
|
-
/**
|
|
2750
|
-
* @type {?}
|
|
2751
|
-
* @private
|
|
2752
|
-
*/
|
|
2753
|
-
StateFactory.prototype._states;
|
|
2754
|
-
/**
|
|
2755
|
-
* @type {?}
|
|
2756
|
-
* @private
|
|
2757
|
-
*/
|
|
2758
|
-
StateFactory.prototype._statesByName;
|
|
2759
|
-
/**
|
|
2760
|
-
* @type {?}
|
|
2761
|
-
* @private
|
|
2762
|
-
*/
|
|
2763
|
-
StateFactory.prototype._statePaths;
|
|
2764
|
-
/** @type {?} */
|
|
2765
|
-
StateFactory.prototype.getRuntimeSelectorContext;
|
|
2766
|
-
/**
|
|
2767
|
-
* @type {?}
|
|
2768
|
-
* @private
|
|
2769
|
-
*/
|
|
2770
|
-
StateFactory.prototype._injector;
|
|
2771
|
-
/**
|
|
2772
|
-
* @type {?}
|
|
2773
|
-
* @private
|
|
2774
|
-
*/
|
|
2775
|
-
StateFactory.prototype._config;
|
|
2776
|
-
/**
|
|
2777
|
-
* @type {?}
|
|
2778
|
-
* @private
|
|
2779
|
-
*/
|
|
2780
|
-
StateFactory.prototype._parentFactory;
|
|
2781
|
-
/**
|
|
2782
|
-
* @type {?}
|
|
2783
|
-
* @private
|
|
2784
|
-
*/
|
|
2785
|
-
StateFactory.prototype._actions;
|
|
2786
|
-
/**
|
|
2787
|
-
* @type {?}
|
|
2788
|
-
* @private
|
|
2789
|
-
*/
|
|
2790
|
-
StateFactory.prototype._actionResults;
|
|
2791
|
-
/**
|
|
2792
|
-
* @type {?}
|
|
2793
|
-
* @private
|
|
2794
|
-
*/
|
|
2795
|
-
StateFactory.prototype._stateContextFactory;
|
|
2796
|
-
/**
|
|
2797
|
-
* @type {?}
|
|
2798
|
-
* @private
|
|
2799
|
-
*/
|
|
2800
|
-
StateFactory.prototype._initialState;
|
|
2801
|
-
}
|
|
1533
|
+
/** @nocollapse */ StateFactory.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: StateFactory, deps: [{ token: i0.Injector }, { token: NgxsConfig }, { token: StateFactory, optional: true, skipSelf: true }, { token: InternalActions }, { token: InternalDispatchedActionResults }, { token: StateContextFactory }, { token: INITIAL_STATE_TOKEN, optional: true }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
1534
|
+
/** @nocollapse */ StateFactory.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: StateFactory });
|
|
1535
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: StateFactory, decorators: [{
|
|
1536
|
+
type: Injectable
|
|
1537
|
+
}], ctorParameters: function () { return [{ type: i0.Injector }, { type: NgxsConfig }, { type: StateFactory, decorators: [{
|
|
1538
|
+
type: Optional
|
|
1539
|
+
}, {
|
|
1540
|
+
type: SkipSelf
|
|
1541
|
+
}] }, { type: InternalActions }, { type: InternalDispatchedActionResults }, { type: StateContextFactory }, { type: undefined, decorators: [{
|
|
1542
|
+
type: Optional
|
|
1543
|
+
}, {
|
|
1544
|
+
type: Inject,
|
|
1545
|
+
args: [INITIAL_STATE_TOKEN]
|
|
1546
|
+
}] }]; } });
|
|
2802
1547
|
|
|
2803
|
-
|
|
2804
|
-
|
|
2805
|
-
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
2806
|
-
*/
|
|
2807
|
-
/** @type {?} */
|
|
2808
|
-
const SELECTOR_OPTIONS_META_KEY = 'NGXS_SELECTOR_OPTIONS_META';
|
|
2809
|
-
/** @type {?} */
|
|
2810
|
-
const selectorOptionsMetaAccessor = {
|
|
2811
|
-
getOptions: (/**
|
|
2812
|
-
* @param {?} target
|
|
2813
|
-
* @return {?}
|
|
2814
|
-
*/
|
|
2815
|
-
(target) => {
|
|
2816
|
-
return (target && ((/** @type {?} */ (target)))[SELECTOR_OPTIONS_META_KEY]) || {};
|
|
2817
|
-
}),
|
|
2818
|
-
defineOptions: (/**
|
|
2819
|
-
* @param {?} target
|
|
2820
|
-
* @param {?} options
|
|
2821
|
-
* @return {?}
|
|
2822
|
-
*/
|
|
2823
|
-
(target, options) => {
|
|
2824
|
-
if (!target)
|
|
2825
|
-
return;
|
|
2826
|
-
((/** @type {?} */ (target)))[SELECTOR_OPTIONS_META_KEY] = options;
|
|
2827
|
-
})
|
|
2828
|
-
};
|
|
2829
|
-
/**
|
|
2830
|
-
* @record
|
|
2831
|
-
*/
|
|
2832
|
-
function CreationMetadata() { }
|
|
2833
|
-
if (false) {
|
|
2834
|
-
/** @type {?} */
|
|
2835
|
-
CreationMetadata.prototype.containerClass;
|
|
2836
|
-
/** @type {?} */
|
|
2837
|
-
CreationMetadata.prototype.selectorName;
|
|
2838
|
-
/** @type {?|undefined} */
|
|
2839
|
-
CreationMetadata.prototype.getSelectorOptions;
|
|
2840
|
-
}
|
|
2841
|
-
/**
|
|
2842
|
-
* @record
|
|
2843
|
-
*/
|
|
2844
|
-
function RuntimeSelectorInfo() { }
|
|
2845
|
-
if (false) {
|
|
2846
|
-
/** @type {?} */
|
|
2847
|
-
RuntimeSelectorInfo.prototype.selectorOptions;
|
|
2848
|
-
/** @type {?} */
|
|
2849
|
-
RuntimeSelectorInfo.prototype.argumentSelectorFunctions;
|
|
2850
|
-
}
|
|
2851
|
-
/**
|
|
2852
|
-
* Function for creating a selector
|
|
2853
|
-
* @template T
|
|
2854
|
-
* @param {?} selectors The selectors to use to create the arguments of this function
|
|
2855
|
-
* @param {?} originalFn The original function being made into a selector
|
|
2856
|
-
* @param {?=} creationMetadata
|
|
2857
|
-
* @return {?}
|
|
2858
|
-
*/
|
|
2859
|
-
function createSelector(selectors, originalFn, creationMetadata) {
|
|
2860
|
-
/** @type {?} */
|
|
2861
|
-
const containerClass = creationMetadata && creationMetadata.containerClass;
|
|
2862
|
-
/** @type {?} */
|
|
2863
|
-
const wrappedFn = (/** @type {?} */ ((/**
|
|
2864
|
-
* @param {...?} args
|
|
2865
|
-
* @return {?}
|
|
2866
|
-
*/
|
|
2867
|
-
function wrappedSelectorFn(...args) {
|
|
2868
|
-
/** @type {?} */
|
|
2869
|
-
const returnValue = originalFn.apply(containerClass, args);
|
|
2870
|
-
if (returnValue instanceof Function) {
|
|
2871
|
-
/** @type {?} */
|
|
2872
|
-
const innerMemoizedFn = memoize.apply(null, [returnValue]);
|
|
2873
|
-
return innerMemoizedFn;
|
|
2874
|
-
}
|
|
2875
|
-
return returnValue;
|
|
2876
|
-
})));
|
|
2877
|
-
/** @type {?} */
|
|
2878
|
-
const memoizedFn = memoize(wrappedFn);
|
|
2879
|
-
Object.setPrototypeOf(memoizedFn, originalFn);
|
|
2880
|
-
/** @type {?} */
|
|
2881
|
-
const selectorMetaData = setupSelectorMetadata(originalFn, creationMetadata);
|
|
2882
|
-
/** @type {?} */
|
|
2883
|
-
const makeRootSelector = (/**
|
|
2884
|
-
* @param {?} context
|
|
2885
|
-
* @return {?}
|
|
2886
|
-
*/
|
|
2887
|
-
(context) => {
|
|
1548
|
+
function createRootSelectorFactory(selectorMetaData, selectors, memoizedSelectorFn) {
|
|
1549
|
+
return (context) => {
|
|
2888
1550
|
const { argumentSelectorFunctions, selectorOptions } = getRuntimeSelectorInfo(context, selectorMetaData, selectors);
|
|
2889
|
-
return (
|
|
2890
|
-
* @param {?} rootState
|
|
2891
|
-
* @return {?}
|
|
2892
|
-
*/
|
|
2893
|
-
function selectFromRoot(rootState) {
|
|
1551
|
+
return function selectFromRoot(rootState) {
|
|
2894
1552
|
// Determine arguments from the app state using the selectors
|
|
2895
|
-
|
|
2896
|
-
const results = argumentSelectorFunctions.map((/**
|
|
2897
|
-
* @param {?} argFn
|
|
2898
|
-
* @return {?}
|
|
2899
|
-
*/
|
|
2900
|
-
argFn => argFn(rootState)));
|
|
1553
|
+
const results = argumentSelectorFunctions.map((argFn) => argFn(rootState));
|
|
2901
1554
|
// if the lambda tries to access a something on the
|
|
2902
1555
|
// state that doesn't exist, it will throw a TypeError.
|
|
2903
1556
|
// since this is quite usual behaviour, we simply return undefined if so.
|
|
2904
1557
|
try {
|
|
2905
|
-
return
|
|
1558
|
+
return memoizedSelectorFn(...results);
|
|
2906
1559
|
}
|
|
2907
1560
|
catch (ex) {
|
|
2908
1561
|
if (ex instanceof TypeError && selectorOptions.suppressErrors) {
|
|
@@ -2910,91 +1563,42 @@ function createSelector(selectors, originalFn, creationMetadata) {
|
|
|
2910
1563
|
}
|
|
2911
1564
|
throw ex;
|
|
2912
1565
|
}
|
|
2913
|
-
}
|
|
2914
|
-
}
|
|
2915
|
-
selectorMetaData.makeRootSelector = makeRootSelector;
|
|
2916
|
-
return memoizedFn;
|
|
1566
|
+
};
|
|
1567
|
+
};
|
|
2917
1568
|
}
|
|
2918
|
-
|
|
2919
|
-
|
|
2920
|
-
|
|
2921
|
-
|
|
2922
|
-
|
|
2923
|
-
|
|
2924
|
-
|
|
2925
|
-
|
|
2926
|
-
|
|
2927
|
-
|
|
2928
|
-
|
|
2929
|
-
|
|
2930
|
-
|
|
2931
|
-
*/
|
|
2932
|
-
() => ({}));
|
|
2933
|
-
if (creationMetadata) {
|
|
2934
|
-
selectorMetaData.containerClass = creationMetadata.containerClass;
|
|
2935
|
-
selectorMetaData.selectorName = creationMetadata.selectorName;
|
|
2936
|
-
getExplicitSelectorOptions =
|
|
2937
|
-
creationMetadata.getSelectorOptions || getExplicitSelectorOptions;
|
|
2938
|
-
}
|
|
2939
|
-
/** @type {?} */
|
|
2940
|
-
const selectorMetaDataClone = Object.assign({}, selectorMetaData);
|
|
2941
|
-
selectorMetaData.getSelectorOptions = (/**
|
|
2942
|
-
* @return {?}
|
|
2943
|
-
*/
|
|
2944
|
-
() => getLocalSelectorOptions(selectorMetaDataClone, getExplicitSelectorOptions()));
|
|
2945
|
-
return selectorMetaData;
|
|
1569
|
+
function createMemoizedSelectorFn(originalFn, creationMetadata) {
|
|
1570
|
+
const containerClass = creationMetadata && creationMetadata.containerClass;
|
|
1571
|
+
const wrappedFn = function wrappedSelectorFn(...args) {
|
|
1572
|
+
const returnValue = originalFn.apply(containerClass, args);
|
|
1573
|
+
if (returnValue instanceof Function) {
|
|
1574
|
+
const innerMemoizedFn = memoize.apply(null, [returnValue]);
|
|
1575
|
+
return innerMemoizedFn;
|
|
1576
|
+
}
|
|
1577
|
+
return returnValue;
|
|
1578
|
+
};
|
|
1579
|
+
const memoizedFn = memoize(wrappedFn);
|
|
1580
|
+
Object.setPrototypeOf(memoizedFn, originalFn);
|
|
1581
|
+
return memoizedFn;
|
|
2946
1582
|
}
|
|
2947
|
-
/**
|
|
2948
|
-
* @param {?} context
|
|
2949
|
-
* @param {?} selectorMetaData
|
|
2950
|
-
* @param {?=} selectors
|
|
2951
|
-
* @return {?}
|
|
2952
|
-
*/
|
|
2953
1583
|
function getRuntimeSelectorInfo(context, selectorMetaData, selectors = []) {
|
|
2954
|
-
/** @type {?} */
|
|
2955
1584
|
const localSelectorOptions = selectorMetaData.getSelectorOptions();
|
|
2956
|
-
/** @type {?} */
|
|
2957
1585
|
const selectorOptions = context.getSelectorOptions(localSelectorOptions);
|
|
2958
|
-
/** @type {?} */
|
|
2959
1586
|
const selectorsToApply = getSelectorsToApply(selectors, selectorOptions, selectorMetaData.containerClass);
|
|
2960
|
-
|
|
2961
|
-
const argumentSelectorFunctions = selectorsToApply.map((/**
|
|
2962
|
-
* @param {?} selector
|
|
2963
|
-
* @return {?}
|
|
2964
|
-
*/
|
|
2965
|
-
selector => {
|
|
2966
|
-
/** @type {?} */
|
|
1587
|
+
const argumentSelectorFunctions = selectorsToApply.map((selector) => {
|
|
2967
1588
|
const factory = getRootSelectorFactory(selector);
|
|
2968
1589
|
return factory(context);
|
|
2969
|
-
})
|
|
1590
|
+
});
|
|
2970
1591
|
return {
|
|
2971
1592
|
selectorOptions,
|
|
2972
|
-
argumentSelectorFunctions
|
|
1593
|
+
argumentSelectorFunctions,
|
|
2973
1594
|
};
|
|
2974
1595
|
}
|
|
2975
|
-
/**
|
|
2976
|
-
* @param {?} selectorMetaData
|
|
2977
|
-
* @param {?} explicitOptions
|
|
2978
|
-
* @return {?}
|
|
2979
|
-
*/
|
|
2980
|
-
function getLocalSelectorOptions(selectorMetaData, explicitOptions) {
|
|
2981
|
-
return Object.assign({}, (selectorOptionsMetaAccessor.getOptions(selectorMetaData.containerClass) || {}), (selectorOptionsMetaAccessor.getOptions(selectorMetaData.originalFn) || {}), (selectorMetaData.getSelectorOptions() || {}), explicitOptions);
|
|
2982
|
-
}
|
|
2983
|
-
/**
|
|
2984
|
-
* @param {?=} selectors
|
|
2985
|
-
* @param {?=} selectorOptions
|
|
2986
|
-
* @param {?=} containerClass
|
|
2987
|
-
* @return {?}
|
|
2988
|
-
*/
|
|
2989
1596
|
function getSelectorsToApply(selectors = [], selectorOptions, containerClass) {
|
|
2990
|
-
/** @type {?} */
|
|
2991
1597
|
const selectorsToApply = [];
|
|
2992
|
-
/** @type {?} */
|
|
2993
1598
|
const canInjectContainerState = selectors.length === 0 || selectorOptions.injectContainerState;
|
|
2994
1599
|
if (containerClass && canInjectContainerState) {
|
|
2995
1600
|
// If we are on a state class, add it as the first selector parameter
|
|
2996
|
-
|
|
2997
|
-
const metadata = getStoreMetadata(containerClass);
|
|
1601
|
+
const metadata = getStoreMetadata$1(containerClass);
|
|
2998
1602
|
if (metadata) {
|
|
2999
1603
|
selectorsToApply.push(containerClass);
|
|
3000
1604
|
}
|
|
@@ -3007,31 +1611,14 @@ function getSelectorsToApply(selectors = [], selectorOptions, containerClass) {
|
|
|
3007
1611
|
/**
|
|
3008
1612
|
* This function gets the factory function to create the selector to get the selected slice from the app state
|
|
3009
1613
|
* @ignore
|
|
3010
|
-
* @param {?} selector
|
|
3011
|
-
* @return {?}
|
|
3012
1614
|
*/
|
|
3013
1615
|
function getRootSelectorFactory(selector) {
|
|
3014
|
-
|
|
3015
|
-
|
|
3016
|
-
return (metadata && metadata.makeRootSelector) || ((/**
|
|
3017
|
-
* @return {?}
|
|
3018
|
-
*/
|
|
3019
|
-
() => selector));
|
|
1616
|
+
const metadata = getSelectorMetadata$1(selector) || getStoreMetadata$1(selector);
|
|
1617
|
+
return (metadata && metadata.makeRootSelector) || (() => selector);
|
|
3020
1618
|
}
|
|
3021
1619
|
|
|
3022
|
-
|
|
3023
|
-
* @fileoverview added by tsickle
|
|
3024
|
-
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
3025
|
-
*/
|
|
1620
|
+
// tslint:disable:unified-signatures
|
|
3026
1621
|
class Store {
|
|
3027
|
-
/**
|
|
3028
|
-
* @param {?} _stateStream
|
|
3029
|
-
* @param {?} _internalStateOperations
|
|
3030
|
-
* @param {?} _config
|
|
3031
|
-
* @param {?} _internalExecutionStrategy
|
|
3032
|
-
* @param {?} _stateFactory
|
|
3033
|
-
* @param {?} initialStateValue
|
|
3034
|
-
*/
|
|
3035
1622
|
constructor(_stateStream, _internalStateOperations, _config, _internalExecutionStrategy, _stateFactory, initialStateValue) {
|
|
3036
1623
|
this._stateStream = _stateStream;
|
|
3037
1624
|
this._internalStateOperations = _internalStateOperations;
|
|
@@ -3043,29 +1630,18 @@ class Store {
|
|
|
3043
1630
|
* because state is being changed actually within the `<root>` zone, see `InternalDispatcher#dispatchSingle`.
|
|
3044
1631
|
* All selects would use this stream, and it would call leave only once for any state change across all active selectors.
|
|
3045
1632
|
*/
|
|
3046
|
-
this._selectableStateStream = this._stateStream.pipe(
|
|
1633
|
+
this._selectableStateStream = this._stateStream.pipe(leaveNgxs(this._internalExecutionStrategy), shareReplay({ bufferSize: 1, refCount: true }));
|
|
3047
1634
|
this.initStateStream(initialStateValue);
|
|
3048
1635
|
}
|
|
3049
1636
|
/**
|
|
3050
1637
|
* Dispatches event(s).
|
|
3051
|
-
* @param {?} actionOrActions
|
|
3052
|
-
* @return {?}
|
|
3053
1638
|
*/
|
|
3054
1639
|
dispatch(actionOrActions) {
|
|
3055
1640
|
return this._internalStateOperations.getRootStateOperations().dispatch(actionOrActions);
|
|
3056
1641
|
}
|
|
3057
|
-
/**
|
|
3058
|
-
* @param {?} selector
|
|
3059
|
-
* @return {?}
|
|
3060
|
-
*/
|
|
3061
1642
|
select(selector) {
|
|
3062
|
-
/** @type {?} */
|
|
3063
1643
|
const selectorFn = this.getStoreBoundSelectorFn(selector);
|
|
3064
|
-
return this._selectableStateStream.pipe(map(selectorFn), catchError((
|
|
3065
|
-
* @param {?} err
|
|
3066
|
-
* @return {?}
|
|
3067
|
-
*/
|
|
3068
|
-
(err) => {
|
|
1644
|
+
return this._selectableStateStream.pipe(map(selectorFn), catchError((err) => {
|
|
3069
1645
|
// if error is TypeError we swallow it to prevent usual errors with property access
|
|
3070
1646
|
const { suppressErrors } = this._config.selectorOptions;
|
|
3071
1647
|
if (err instanceof TypeError && suppressErrors) {
|
|
@@ -3073,28 +1649,17 @@ class Store {
|
|
|
3073
1649
|
}
|
|
3074
1650
|
// rethrow other errors
|
|
3075
1651
|
return throwError(err);
|
|
3076
|
-
})
|
|
1652
|
+
}), distinctUntilChanged(), leaveNgxs(this._internalExecutionStrategy));
|
|
3077
1653
|
}
|
|
3078
|
-
/**
|
|
3079
|
-
* @param {?} selector
|
|
3080
|
-
* @return {?}
|
|
3081
|
-
*/
|
|
3082
1654
|
selectOnce(selector) {
|
|
3083
1655
|
return this.select(selector).pipe(take(1));
|
|
3084
1656
|
}
|
|
3085
|
-
/**
|
|
3086
|
-
* @param {?} selector
|
|
3087
|
-
* @return {?}
|
|
3088
|
-
*/
|
|
3089
1657
|
selectSnapshot(selector) {
|
|
3090
|
-
/** @type {?} */
|
|
3091
1658
|
const selectorFn = this.getStoreBoundSelectorFn(selector);
|
|
3092
1659
|
return selectorFn(this._stateStream.getValue());
|
|
3093
1660
|
}
|
|
3094
1661
|
/**
|
|
3095
1662
|
* Allow the user to subscribe to the root of the state
|
|
3096
|
-
* @param {?=} fn
|
|
3097
|
-
* @return {?}
|
|
3098
1663
|
*/
|
|
3099
1664
|
subscribe(fn) {
|
|
3100
1665
|
return this._selectableStateStream
|
|
@@ -3103,7 +1668,6 @@ class Store {
|
|
|
3103
1668
|
}
|
|
3104
1669
|
/**
|
|
3105
1670
|
* Return the raw value of the state.
|
|
3106
|
-
* @return {?}
|
|
3107
1671
|
*/
|
|
3108
1672
|
snapshot() {
|
|
3109
1673
|
return this._internalStateOperations.getRootStateOperations().getState();
|
|
@@ -3111,104 +1675,38 @@ class Store {
|
|
|
3111
1675
|
/**
|
|
3112
1676
|
* Reset the state to a specific point in time. This method is useful
|
|
3113
1677
|
* for plugin's who need to modify the state directly or unit testing.
|
|
3114
|
-
* @param {?} state
|
|
3115
|
-
* @return {?}
|
|
3116
1678
|
*/
|
|
3117
1679
|
reset(state) {
|
|
3118
1680
|
return this._internalStateOperations.getRootStateOperations().setState(state);
|
|
3119
1681
|
}
|
|
3120
|
-
/**
|
|
3121
|
-
* @private
|
|
3122
|
-
* @param {?} selector
|
|
3123
|
-
* @return {?}
|
|
3124
|
-
*/
|
|
3125
1682
|
getStoreBoundSelectorFn(selector) {
|
|
3126
|
-
/** @type {?} */
|
|
3127
1683
|
const makeSelectorFn = getRootSelectorFactory(selector);
|
|
3128
|
-
/** @type {?} */
|
|
3129
1684
|
const runtimeContext = this._stateFactory.getRuntimeSelectorContext();
|
|
3130
1685
|
return makeSelectorFn(runtimeContext);
|
|
3131
1686
|
}
|
|
3132
|
-
/**
|
|
3133
|
-
* @private
|
|
3134
|
-
* @param {?} initialStateValue
|
|
3135
|
-
* @return {?}
|
|
3136
|
-
*/
|
|
3137
1687
|
initStateStream(initialStateValue) {
|
|
3138
|
-
/** @type {?} */
|
|
3139
1688
|
const value = this._stateStream.value;
|
|
3140
|
-
/** @type {?} */
|
|
3141
1689
|
const storeIsEmpty = !value || Object.keys(value).length === 0;
|
|
3142
1690
|
if (storeIsEmpty) {
|
|
3143
|
-
/** @type {?} */
|
|
3144
1691
|
const defaultStateNotEmpty = Object.keys(this._config.defaultsState).length > 0;
|
|
3145
|
-
/** @type {?} */
|
|
3146
1692
|
const storeValues = defaultStateNotEmpty
|
|
3147
|
-
? Object.assign({}, this._config.defaultsState, initialStateValue) : initialStateValue;
|
|
1693
|
+
? Object.assign(Object.assign({}, this._config.defaultsState), initialStateValue) : initialStateValue;
|
|
3148
1694
|
this._stateStream.next(storeValues);
|
|
3149
1695
|
}
|
|
3150
1696
|
}
|
|
3151
1697
|
}
|
|
3152
|
-
Store
|
|
3153
|
-
|
|
3154
|
-
|
|
3155
|
-
|
|
3156
|
-
|
|
3157
|
-
|
|
3158
|
-
|
|
3159
|
-
|
|
3160
|
-
|
|
3161
|
-
|
|
3162
|
-
{ type: undefined, decorators: [{ type: Optional }, { type: Inject, args: [INITIAL_STATE_TOKEN,] }] }
|
|
3163
|
-
];
|
|
3164
|
-
if (false) {
|
|
3165
|
-
/**
|
|
3166
|
-
* This is a derived state stream that leaves NGXS execution strategy to emit state changes within the Angular zone,
|
|
3167
|
-
* because state is being changed actually within the `<root>` zone, see `InternalDispatcher#dispatchSingle`.
|
|
3168
|
-
* All selects would use this stream, and it would call leave only once for any state change across all active selectors.
|
|
3169
|
-
* @type {?}
|
|
3170
|
-
* @private
|
|
3171
|
-
*/
|
|
3172
|
-
Store.prototype._selectableStateStream;
|
|
3173
|
-
/**
|
|
3174
|
-
* @type {?}
|
|
3175
|
-
* @private
|
|
3176
|
-
*/
|
|
3177
|
-
Store.prototype._stateStream;
|
|
3178
|
-
/**
|
|
3179
|
-
* @type {?}
|
|
3180
|
-
* @private
|
|
3181
|
-
*/
|
|
3182
|
-
Store.prototype._internalStateOperations;
|
|
3183
|
-
/**
|
|
3184
|
-
* @type {?}
|
|
3185
|
-
* @private
|
|
3186
|
-
*/
|
|
3187
|
-
Store.prototype._config;
|
|
3188
|
-
/**
|
|
3189
|
-
* @type {?}
|
|
3190
|
-
* @private
|
|
3191
|
-
*/
|
|
3192
|
-
Store.prototype._internalExecutionStrategy;
|
|
3193
|
-
/**
|
|
3194
|
-
* @type {?}
|
|
3195
|
-
* @private
|
|
3196
|
-
*/
|
|
3197
|
-
Store.prototype._stateFactory;
|
|
3198
|
-
}
|
|
1698
|
+
/** @nocollapse */ Store.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: Store, deps: [{ token: StateStream }, { token: InternalStateOperations }, { token: NgxsConfig }, { token: InternalNgxsExecutionStrategy }, { token: StateFactory }, { token: INITIAL_STATE_TOKEN, optional: true }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
1699
|
+
/** @nocollapse */ Store.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: Store });
|
|
1700
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: Store, decorators: [{
|
|
1701
|
+
type: Injectable
|
|
1702
|
+
}], ctorParameters: function () { return [{ type: StateStream }, { type: InternalStateOperations }, { type: NgxsConfig }, { type: InternalNgxsExecutionStrategy }, { type: StateFactory }, { type: undefined, decorators: [{
|
|
1703
|
+
type: Optional
|
|
1704
|
+
}, {
|
|
1705
|
+
type: Inject,
|
|
1706
|
+
args: [INITIAL_STATE_TOKEN]
|
|
1707
|
+
}] }]; } });
|
|
3199
1708
|
|
|
3200
|
-
/**
|
|
3201
|
-
* @fileoverview added by tsickle
|
|
3202
|
-
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
3203
|
-
*/
|
|
3204
1709
|
class LifecycleStateManager {
|
|
3205
|
-
/**
|
|
3206
|
-
* @param {?} _store
|
|
3207
|
-
* @param {?} _internalErrorReporter
|
|
3208
|
-
* @param {?} _internalStateOperations
|
|
3209
|
-
* @param {?} _stateContextFactory
|
|
3210
|
-
* @param {?} _bootstrapper
|
|
3211
|
-
*/
|
|
3212
1710
|
constructor(_store, _internalErrorReporter, _internalStateOperations, _stateContextFactory, _bootstrapper) {
|
|
3213
1711
|
this._store = _store;
|
|
3214
1712
|
this._internalErrorReporter = _internalErrorReporter;
|
|
@@ -3217,78 +1715,34 @@ class LifecycleStateManager {
|
|
|
3217
1715
|
this._bootstrapper = _bootstrapper;
|
|
3218
1716
|
this._destroy$ = new Subject();
|
|
3219
1717
|
}
|
|
3220
|
-
/**
|
|
3221
|
-
* @return {?}
|
|
3222
|
-
*/
|
|
3223
1718
|
ngOnDestroy() {
|
|
3224
1719
|
this._destroy$.next();
|
|
3225
1720
|
}
|
|
3226
|
-
/**
|
|
3227
|
-
* @template T
|
|
3228
|
-
* @param {?} action
|
|
3229
|
-
* @param {?} results
|
|
3230
|
-
* @return {?}
|
|
3231
|
-
*/
|
|
3232
1721
|
ngxsBootstrap(action, results) {
|
|
3233
1722
|
this._internalStateOperations
|
|
3234
1723
|
.getRootStateOperations()
|
|
3235
1724
|
.dispatch(action)
|
|
3236
|
-
.pipe(filter((
|
|
3237
|
-
* @return {?}
|
|
3238
|
-
*/
|
|
3239
|
-
() => !!results)), tap((/**
|
|
3240
|
-
* @return {?}
|
|
3241
|
-
*/
|
|
3242
|
-
() => this._invokeInitOnStates((/** @type {?} */ (results)).states))), mergeMap((/**
|
|
3243
|
-
* @return {?}
|
|
3244
|
-
*/
|
|
3245
|
-
() => this._bootstrapper.appBootstrapped$)), filter((/**
|
|
3246
|
-
* @param {?} appBootstrapped
|
|
3247
|
-
* @return {?}
|
|
3248
|
-
*/
|
|
3249
|
-
appBootstrapped => !!appBootstrapped)), catchError((/**
|
|
3250
|
-
* @param {?} error
|
|
3251
|
-
* @return {?}
|
|
3252
|
-
*/
|
|
3253
|
-
error => {
|
|
1725
|
+
.pipe(filter(() => !!results), tap(() => this._invokeInitOnStates(results.states)), mergeMap(() => this._bootstrapper.appBootstrapped$), filter(appBootstrapped => !!appBootstrapped), catchError(error => {
|
|
3254
1726
|
// The `SafeSubscriber` (which is used by most RxJS operators) re-throws
|
|
3255
1727
|
// errors asynchronously (`setTimeout(() => { throw error })`). This might
|
|
3256
1728
|
// break existing user's code or unit tests. We catch the error manually to
|
|
3257
1729
|
// be backward compatible with the old behavior.
|
|
3258
1730
|
this._internalErrorReporter.reportErrorSafely(error);
|
|
3259
1731
|
return EMPTY;
|
|
3260
|
-
})
|
|
3261
|
-
.subscribe((
|
|
3262
|
-
* @return {?}
|
|
3263
|
-
*/
|
|
3264
|
-
() => this._invokeBootstrapOnStates((/** @type {?} */ (results)).states)));
|
|
1732
|
+
}), takeUntil(this._destroy$))
|
|
1733
|
+
.subscribe(() => this._invokeBootstrapOnStates(results.states));
|
|
3265
1734
|
}
|
|
3266
|
-
/**
|
|
3267
|
-
* @private
|
|
3268
|
-
* @param {?} mappedStores
|
|
3269
|
-
* @return {?}
|
|
3270
|
-
*/
|
|
3271
1735
|
_invokeInitOnStates(mappedStores) {
|
|
3272
1736
|
for (const mappedStore of mappedStores) {
|
|
3273
|
-
/** @type {?} */
|
|
3274
1737
|
const instance = mappedStore.instance;
|
|
3275
1738
|
if (instance.ngxsOnChanges) {
|
|
3276
1739
|
this._store
|
|
3277
|
-
.select((
|
|
3278
|
-
* @param {?} state
|
|
3279
|
-
* @return {?}
|
|
3280
|
-
*/
|
|
3281
|
-
state => getValue(state, mappedStore.path)))
|
|
1740
|
+
.select(state => getValue(state, mappedStore.path))
|
|
3282
1741
|
.pipe(startWith(undefined), pairwise(), takeUntil(this._destroy$))
|
|
3283
|
-
.subscribe((
|
|
3284
|
-
* @param {?} __0
|
|
3285
|
-
* @return {?}
|
|
3286
|
-
*/
|
|
3287
|
-
([previousValue, currentValue]) => {
|
|
3288
|
-
/** @type {?} */
|
|
1742
|
+
.subscribe(([previousValue, currentValue]) => {
|
|
3289
1743
|
const change = new NgxsSimpleChange(previousValue, currentValue, !mappedStore.isInitialised);
|
|
3290
|
-
|
|
3291
|
-
})
|
|
1744
|
+
instance.ngxsOnChanges(change);
|
|
1745
|
+
});
|
|
3292
1746
|
}
|
|
3293
1747
|
if (instance.ngxsOnInit) {
|
|
3294
1748
|
instance.ngxsOnInit(this._getStateContext(mappedStore));
|
|
@@ -3296,93 +1750,33 @@ class LifecycleStateManager {
|
|
|
3296
1750
|
mappedStore.isInitialised = true;
|
|
3297
1751
|
}
|
|
3298
1752
|
}
|
|
3299
|
-
/**
|
|
3300
|
-
* @private
|
|
3301
|
-
* @param {?} mappedStores
|
|
3302
|
-
* @return {?}
|
|
3303
|
-
*/
|
|
3304
1753
|
_invokeBootstrapOnStates(mappedStores) {
|
|
3305
1754
|
for (const mappedStore of mappedStores) {
|
|
3306
|
-
/** @type {?} */
|
|
3307
1755
|
const instance = mappedStore.instance;
|
|
3308
1756
|
if (instance.ngxsAfterBootstrap) {
|
|
3309
1757
|
instance.ngxsAfterBootstrap(this._getStateContext(mappedStore));
|
|
3310
1758
|
}
|
|
3311
1759
|
}
|
|
3312
1760
|
}
|
|
3313
|
-
/**
|
|
3314
|
-
* @private
|
|
3315
|
-
* @param {?} mappedStore
|
|
3316
|
-
* @return {?}
|
|
3317
|
-
*/
|
|
3318
1761
|
_getStateContext(mappedStore) {
|
|
3319
1762
|
return this._stateContextFactory.createStateContext(mappedStore);
|
|
3320
1763
|
}
|
|
3321
1764
|
}
|
|
3322
|
-
LifecycleStateManager
|
|
3323
|
-
|
|
3324
|
-
|
|
3325
|
-
|
|
3326
|
-
|
|
3327
|
-
{ type: Store },
|
|
3328
|
-
{ type: InternalErrorReporter },
|
|
3329
|
-
{ type: InternalStateOperations },
|
|
3330
|
-
{ type: StateContextFactory },
|
|
3331
|
-
{ type: NgxsBootstrapper }
|
|
3332
|
-
];
|
|
3333
|
-
if (false) {
|
|
3334
|
-
/**
|
|
3335
|
-
* @type {?}
|
|
3336
|
-
* @private
|
|
3337
|
-
*/
|
|
3338
|
-
LifecycleStateManager.prototype._destroy$;
|
|
3339
|
-
/**
|
|
3340
|
-
* @type {?}
|
|
3341
|
-
* @private
|
|
3342
|
-
*/
|
|
3343
|
-
LifecycleStateManager.prototype._store;
|
|
3344
|
-
/**
|
|
3345
|
-
* @type {?}
|
|
3346
|
-
* @private
|
|
3347
|
-
*/
|
|
3348
|
-
LifecycleStateManager.prototype._internalErrorReporter;
|
|
3349
|
-
/**
|
|
3350
|
-
* @type {?}
|
|
3351
|
-
* @private
|
|
3352
|
-
*/
|
|
3353
|
-
LifecycleStateManager.prototype._internalStateOperations;
|
|
3354
|
-
/**
|
|
3355
|
-
* @type {?}
|
|
3356
|
-
* @private
|
|
3357
|
-
*/
|
|
3358
|
-
LifecycleStateManager.prototype._stateContextFactory;
|
|
3359
|
-
/**
|
|
3360
|
-
* @type {?}
|
|
3361
|
-
* @private
|
|
3362
|
-
*/
|
|
3363
|
-
LifecycleStateManager.prototype._bootstrapper;
|
|
3364
|
-
}
|
|
1765
|
+
/** @nocollapse */ LifecycleStateManager.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: LifecycleStateManager, deps: [{ token: Store }, { token: InternalErrorReporter }, { token: InternalStateOperations }, { token: StateContextFactory }, { token: i5.NgxsBootstrapper }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
1766
|
+
/** @nocollapse */ LifecycleStateManager.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: LifecycleStateManager });
|
|
1767
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: LifecycleStateManager, decorators: [{
|
|
1768
|
+
type: Injectable
|
|
1769
|
+
}], ctorParameters: function () { return [{ type: Store }, { type: InternalErrorReporter }, { type: InternalStateOperations }, { type: StateContextFactory }, { type: i5.NgxsBootstrapper }]; } });
|
|
3365
1770
|
|
|
3366
|
-
/**
|
|
3367
|
-
* @fileoverview added by tsickle
|
|
3368
|
-
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
3369
|
-
*/
|
|
3370
1771
|
/**
|
|
3371
1772
|
* Allows the select decorator to get access to the DI store, this is used internally
|
|
3372
|
-
* in
|
|
1773
|
+
* in `@Select` decorator.
|
|
3373
1774
|
*/
|
|
3374
1775
|
class SelectFactory {
|
|
3375
|
-
/**
|
|
3376
|
-
* @param {?} store
|
|
3377
|
-
* @param {?} config
|
|
3378
|
-
*/
|
|
3379
1776
|
constructor(store, config) {
|
|
3380
1777
|
SelectFactory.store = store;
|
|
3381
1778
|
SelectFactory.config = config;
|
|
3382
1779
|
}
|
|
3383
|
-
/**
|
|
3384
|
-
* @return {?}
|
|
3385
|
-
*/
|
|
3386
1780
|
ngOnDestroy() {
|
|
3387
1781
|
SelectFactory.store = null;
|
|
3388
1782
|
SelectFactory.config = null;
|
|
@@ -3390,80 +1784,19 @@ class SelectFactory {
|
|
|
3390
1784
|
}
|
|
3391
1785
|
SelectFactory.store = null;
|
|
3392
1786
|
SelectFactory.config = null;
|
|
3393
|
-
SelectFactory
|
|
3394
|
-
|
|
3395
|
-
|
|
3396
|
-
|
|
3397
|
-
|
|
3398
|
-
{ type: Store },
|
|
3399
|
-
{ type: NgxsConfig }
|
|
3400
|
-
];
|
|
3401
|
-
if (false) {
|
|
3402
|
-
/** @type {?} */
|
|
3403
|
-
SelectFactory.store;
|
|
3404
|
-
/** @type {?} */
|
|
3405
|
-
SelectFactory.config;
|
|
3406
|
-
}
|
|
1787
|
+
/** @nocollapse */ SelectFactory.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: SelectFactory, deps: [{ token: Store }, { token: NgxsConfig }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
1788
|
+
/** @nocollapse */ SelectFactory.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: SelectFactory });
|
|
1789
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: SelectFactory, decorators: [{
|
|
1790
|
+
type: Injectable
|
|
1791
|
+
}], ctorParameters: function () { return [{ type: Store }, { type: NgxsConfig }]; } });
|
|
3407
1792
|
|
|
3408
|
-
/**
|
|
3409
|
-
* @fileoverview added by tsickle
|
|
3410
|
-
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
3411
|
-
*/
|
|
3412
|
-
/**
|
|
3413
|
-
* Init action
|
|
3414
|
-
*/
|
|
3415
|
-
class InitState {
|
|
3416
|
-
/**
|
|
3417
|
-
* @return {?}
|
|
3418
|
-
*/
|
|
3419
|
-
static get type() {
|
|
3420
|
-
// NOTE: Not necessary to declare the type in this way in your code. See https://github.com/ngxs/store/pull/644#issuecomment-436003138
|
|
3421
|
-
return '@@INIT';
|
|
3422
|
-
}
|
|
3423
|
-
}
|
|
3424
|
-
/**
|
|
3425
|
-
* Update action
|
|
3426
|
-
*/
|
|
3427
|
-
class UpdateState {
|
|
3428
|
-
/**
|
|
3429
|
-
* @param {?=} addedStates
|
|
3430
|
-
*/
|
|
3431
|
-
constructor(addedStates) {
|
|
3432
|
-
this.addedStates = addedStates;
|
|
3433
|
-
}
|
|
3434
|
-
/**
|
|
3435
|
-
* @return {?}
|
|
3436
|
-
*/
|
|
3437
|
-
static get type() {
|
|
3438
|
-
// NOTE: Not necessary to declare the type in this way in your code. See https://github.com/ngxs/store/pull/644#issuecomment-436003138
|
|
3439
|
-
return '@@UPDATE_STATE';
|
|
3440
|
-
}
|
|
3441
|
-
}
|
|
3442
|
-
if (false) {
|
|
3443
|
-
/** @type {?} */
|
|
3444
|
-
UpdateState.prototype.addedStates;
|
|
3445
|
-
}
|
|
3446
|
-
|
|
3447
|
-
/**
|
|
3448
|
-
* @fileoverview added by tsickle
|
|
3449
|
-
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
3450
|
-
*/
|
|
3451
1793
|
/**
|
|
3452
1794
|
* Root module
|
|
3453
1795
|
* @ignore
|
|
3454
1796
|
*/
|
|
3455
1797
|
class NgxsRootModule {
|
|
3456
|
-
/**
|
|
3457
|
-
* @param {?} factory
|
|
3458
|
-
* @param {?} internalStateOperations
|
|
3459
|
-
* @param {?} _store
|
|
3460
|
-
* @param {?} _select
|
|
3461
|
-
* @param {?=} states
|
|
3462
|
-
* @param {?=} lifecycleStateManager
|
|
3463
|
-
*/
|
|
3464
1798
|
constructor(factory, internalStateOperations, _store, _select, states = [], lifecycleStateManager) {
|
|
3465
1799
|
// Add stores to the state graph and return their defaults
|
|
3466
|
-
/** @type {?} */
|
|
3467
1800
|
const results = factory.addAndReturnDefaults(states);
|
|
3468
1801
|
internalStateOperations.setStateToTheCurrentWithNew(results);
|
|
3469
1802
|
// Connect our actions stream
|
|
@@ -3472,42 +1805,28 @@ class NgxsRootModule {
|
|
|
3472
1805
|
lifecycleStateManager.ngxsBootstrap(new InitState(), results);
|
|
3473
1806
|
}
|
|
3474
1807
|
}
|
|
3475
|
-
NgxsRootModule
|
|
3476
|
-
|
|
3477
|
-
|
|
3478
|
-
|
|
3479
|
-
|
|
3480
|
-
|
|
3481
|
-
|
|
3482
|
-
|
|
3483
|
-
|
|
3484
|
-
|
|
3485
|
-
|
|
3486
|
-
];
|
|
1808
|
+
/** @nocollapse */ NgxsRootModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: NgxsRootModule, deps: [{ token: StateFactory }, { token: InternalStateOperations }, { token: Store }, { token: SelectFactory }, { token: ROOT_STATE_TOKEN, optional: true }, { token: LifecycleStateManager }], target: i0.ɵɵFactoryTarget.NgModule });
|
|
1809
|
+
/** @nocollapse */ NgxsRootModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: NgxsRootModule });
|
|
1810
|
+
/** @nocollapse */ NgxsRootModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: NgxsRootModule });
|
|
1811
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: NgxsRootModule, decorators: [{
|
|
1812
|
+
type: NgModule
|
|
1813
|
+
}], ctorParameters: function () { return [{ type: StateFactory }, { type: InternalStateOperations }, { type: Store }, { type: SelectFactory }, { type: undefined, decorators: [{
|
|
1814
|
+
type: Optional
|
|
1815
|
+
}, {
|
|
1816
|
+
type: Inject,
|
|
1817
|
+
args: [ROOT_STATE_TOKEN]
|
|
1818
|
+
}] }, { type: LifecycleStateManager }]; } });
|
|
3487
1819
|
|
|
3488
|
-
/**
|
|
3489
|
-
* @fileoverview added by tsickle
|
|
3490
|
-
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
3491
|
-
*/
|
|
3492
1820
|
/**
|
|
3493
1821
|
* Feature module
|
|
3494
1822
|
* @ignore
|
|
3495
1823
|
*/
|
|
3496
1824
|
class NgxsFeatureModule {
|
|
3497
|
-
/**
|
|
3498
|
-
* @param {?} _store
|
|
3499
|
-
* @param {?} internalStateOperations
|
|
3500
|
-
* @param {?} factory
|
|
3501
|
-
* @param {?=} states
|
|
3502
|
-
* @param {?=} lifecycleStateManager
|
|
3503
|
-
*/
|
|
3504
1825
|
constructor(_store, internalStateOperations, factory, states = [], lifecycleStateManager) {
|
|
3505
1826
|
// Since FEATURE_STATE_TOKEN is a multi token, we need to
|
|
3506
1827
|
// flatten it [[Feature1State, Feature2State], [Feature3State]]
|
|
3507
|
-
/** @type {?} */
|
|
3508
1828
|
const flattenedStates = NgxsFeatureModule.flattenStates(states);
|
|
3509
1829
|
// add stores to the state graph and return their defaults
|
|
3510
|
-
/** @type {?} */
|
|
3511
1830
|
const results = factory.addAndReturnDefaults(flattenedStates);
|
|
3512
1831
|
if (results.states.length) {
|
|
3513
1832
|
internalStateOperations.setStateToTheCurrentWithNew(results);
|
|
@@ -3515,45 +1834,28 @@ class NgxsFeatureModule {
|
|
|
3515
1834
|
lifecycleStateManager.ngxsBootstrap(new UpdateState(results.defaults), results);
|
|
3516
1835
|
}
|
|
3517
1836
|
}
|
|
3518
|
-
/**
|
|
3519
|
-
* @private
|
|
3520
|
-
* @param {?=} states
|
|
3521
|
-
* @return {?}
|
|
3522
|
-
*/
|
|
3523
1837
|
static flattenStates(states = []) {
|
|
3524
|
-
return states.reduce((
|
|
3525
|
-
|
|
3526
|
-
|
|
3527
|
-
|
|
3528
|
-
|
|
3529
|
-
|
|
3530
|
-
|
|
3531
|
-
|
|
3532
|
-
|
|
3533
|
-
|
|
3534
|
-
|
|
3535
|
-
|
|
3536
|
-
|
|
3537
|
-
|
|
3538
|
-
{ type: InternalStateOperations },
|
|
3539
|
-
{ type: StateFactory },
|
|
3540
|
-
{ type: Array, decorators: [{ type: Optional }, { type: Inject, args: [FEATURE_STATE_TOKEN,] }] },
|
|
3541
|
-
{ type: LifecycleStateManager }
|
|
3542
|
-
];
|
|
1838
|
+
return states.reduce((total, values) => total.concat(values), []);
|
|
1839
|
+
}
|
|
1840
|
+
}
|
|
1841
|
+
/** @nocollapse */ NgxsFeatureModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: NgxsFeatureModule, deps: [{ token: Store }, { token: InternalStateOperations }, { token: StateFactory }, { token: FEATURE_STATE_TOKEN, optional: true }, { token: LifecycleStateManager }], target: i0.ɵɵFactoryTarget.NgModule });
|
|
1842
|
+
/** @nocollapse */ NgxsFeatureModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: NgxsFeatureModule });
|
|
1843
|
+
/** @nocollapse */ NgxsFeatureModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: NgxsFeatureModule });
|
|
1844
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: NgxsFeatureModule, decorators: [{
|
|
1845
|
+
type: NgModule
|
|
1846
|
+
}], ctorParameters: function () { return [{ type: Store }, { type: InternalStateOperations }, { type: StateFactory }, { type: undefined, decorators: [{
|
|
1847
|
+
type: Optional
|
|
1848
|
+
}, {
|
|
1849
|
+
type: Inject,
|
|
1850
|
+
args: [FEATURE_STATE_TOKEN]
|
|
1851
|
+
}] }, { type: LifecycleStateManager }]; } });
|
|
3543
1852
|
|
|
3544
|
-
/**
|
|
3545
|
-
* @fileoverview added by tsickle
|
|
3546
|
-
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
3547
|
-
*/
|
|
3548
1853
|
/**
|
|
3549
1854
|
* Ngxs Module
|
|
3550
1855
|
*/
|
|
3551
1856
|
class NgxsModule {
|
|
3552
1857
|
/**
|
|
3553
1858
|
* Root module factory
|
|
3554
|
-
* @param {?=} states
|
|
3555
|
-
* @param {?=} options
|
|
3556
|
-
* @return {?}
|
|
3557
1859
|
*/
|
|
3558
1860
|
static forRoot(states = [], options = {}) {
|
|
3559
1861
|
return {
|
|
@@ -3580,8 +1882,6 @@ class NgxsModule {
|
|
|
3580
1882
|
}
|
|
3581
1883
|
/**
|
|
3582
1884
|
* Feature module factory
|
|
3583
|
-
* @param {?=} states
|
|
3584
|
-
* @return {?}
|
|
3585
1885
|
*/
|
|
3586
1886
|
static forFeature(states = []) {
|
|
3587
1887
|
return {
|
|
@@ -3598,12 +1898,6 @@ class NgxsModule {
|
|
|
3598
1898
|
]
|
|
3599
1899
|
};
|
|
3600
1900
|
}
|
|
3601
|
-
/**
|
|
3602
|
-
* @private
|
|
3603
|
-
* @param {?} states
|
|
3604
|
-
* @param {?} options
|
|
3605
|
-
* @return {?}
|
|
3606
|
-
*/
|
|
3607
1901
|
static ngxsTokenProviders(states, options) {
|
|
3608
1902
|
return [
|
|
3609
1903
|
{
|
|
@@ -3634,87 +1928,51 @@ class NgxsModule {
|
|
|
3634
1928
|
useFactory: NgxsModule.getInitialState
|
|
3635
1929
|
},
|
|
3636
1930
|
{
|
|
3637
|
-
provide: NGXS_STATE_CONTEXT_FACTORY,
|
|
1931
|
+
provide: ɵNGXS_STATE_CONTEXT_FACTORY,
|
|
3638
1932
|
useExisting: StateContextFactory
|
|
3639
1933
|
},
|
|
3640
1934
|
{
|
|
3641
|
-
provide: NGXS_STATE_FACTORY,
|
|
1935
|
+
provide: ɵNGXS_STATE_FACTORY,
|
|
3642
1936
|
useExisting: StateFactory
|
|
3643
1937
|
}
|
|
3644
1938
|
];
|
|
3645
1939
|
}
|
|
3646
|
-
/**
|
|
3647
|
-
* @private
|
|
3648
|
-
* @param {?} options
|
|
3649
|
-
* @return {?}
|
|
3650
|
-
*/
|
|
3651
1940
|
static ngxsConfigFactory(options) {
|
|
3652
1941
|
return mergeDeep(new NgxsConfig(), options);
|
|
3653
1942
|
}
|
|
3654
|
-
/**
|
|
3655
|
-
* @private
|
|
3656
|
-
* @param {?} bootstrapper
|
|
3657
|
-
* @return {?}
|
|
3658
|
-
*/
|
|
3659
1943
|
static appBootstrapListenerFactory(bootstrapper) {
|
|
3660
|
-
return (
|
|
3661
|
-
* @return {?}
|
|
3662
|
-
*/
|
|
3663
|
-
() => bootstrapper.bootstrap());
|
|
1944
|
+
return () => bootstrapper.bootstrap();
|
|
3664
1945
|
}
|
|
3665
|
-
/**
|
|
3666
|
-
* @private
|
|
3667
|
-
* @return {?}
|
|
3668
|
-
*/
|
|
3669
1946
|
static getInitialState() {
|
|
3670
1947
|
return InitialState.pop();
|
|
3671
1948
|
}
|
|
3672
1949
|
}
|
|
3673
1950
|
NgxsModule.ROOT_OPTIONS = new InjectionToken('ROOT_OPTIONS');
|
|
3674
|
-
NgxsModule
|
|
3675
|
-
|
|
3676
|
-
|
|
3677
|
-
|
|
3678
|
-
|
|
3679
|
-
|
|
3680
|
-
* @private
|
|
3681
|
-
*/
|
|
3682
|
-
NgxsModule.ROOT_OPTIONS;
|
|
3683
|
-
}
|
|
1951
|
+
/** @nocollapse */ NgxsModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: NgxsModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
1952
|
+
/** @nocollapse */ NgxsModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: NgxsModule });
|
|
1953
|
+
/** @nocollapse */ NgxsModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: NgxsModule });
|
|
1954
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: NgxsModule, decorators: [{
|
|
1955
|
+
type: NgModule
|
|
1956
|
+
}] });
|
|
3684
1957
|
|
|
3685
|
-
/**
|
|
3686
|
-
* @fileoverview added by tsickle
|
|
3687
|
-
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
3688
|
-
*/
|
|
3689
1958
|
/**
|
|
3690
1959
|
* Decorates a method with a action information.
|
|
3691
|
-
* @param {?} actions
|
|
3692
|
-
* @param {?=} options
|
|
3693
|
-
* @return {?}
|
|
3694
1960
|
*/
|
|
3695
1961
|
function Action(actions, options) {
|
|
3696
|
-
return (
|
|
3697
|
-
* @param {?} target
|
|
3698
|
-
* @param {?} name
|
|
3699
|
-
* @return {?}
|
|
3700
|
-
*/
|
|
3701
|
-
(target, name) => {
|
|
1962
|
+
return (target, name) => {
|
|
3702
1963
|
// Caretaker note: we have still left the `typeof` condition in order to avoid
|
|
3703
1964
|
// creating a breaking change for projects that still use the View Engine.
|
|
3704
1965
|
if (typeof ngDevMode === 'undefined' || ngDevMode) {
|
|
3705
|
-
/** @type {?} */
|
|
3706
1966
|
const isStaticMethod = target.hasOwnProperty('prototype');
|
|
3707
1967
|
if (isStaticMethod) {
|
|
3708
1968
|
throwActionDecoratorError();
|
|
3709
1969
|
}
|
|
3710
1970
|
}
|
|
3711
|
-
|
|
3712
|
-
const meta = ensureStoreMetadata(target.constructor);
|
|
1971
|
+
const meta = ensureStoreMetadata$1(target.constructor);
|
|
3713
1972
|
if (!Array.isArray(actions)) {
|
|
3714
1973
|
actions = [actions];
|
|
3715
1974
|
}
|
|
3716
1975
|
for (const action of actions) {
|
|
3717
|
-
/** @type {?} */
|
|
3718
1976
|
const type = action.type;
|
|
3719
1977
|
if (!meta.actions[type]) {
|
|
3720
1978
|
meta.actions[type] = [];
|
|
@@ -3725,50 +1983,20 @@ function Action(actions, options) {
|
|
|
3725
1983
|
type
|
|
3726
1984
|
});
|
|
3727
1985
|
}
|
|
3728
|
-
}
|
|
1986
|
+
};
|
|
3729
1987
|
}
|
|
3730
1988
|
|
|
3731
|
-
/**
|
|
3732
|
-
* @fileoverview added by tsickle
|
|
3733
|
-
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
3734
|
-
*/
|
|
3735
|
-
/**
|
|
3736
|
-
* @record
|
|
3737
|
-
* @template T
|
|
3738
|
-
*/
|
|
3739
|
-
function MutateMetaOptions() { }
|
|
3740
|
-
if (false) {
|
|
3741
|
-
/** @type {?} */
|
|
3742
|
-
MutateMetaOptions.prototype.meta;
|
|
3743
|
-
/** @type {?} */
|
|
3744
|
-
MutateMetaOptions.prototype.inheritedStateClass;
|
|
3745
|
-
/** @type {?} */
|
|
3746
|
-
MutateMetaOptions.prototype.optionsWithInheritance;
|
|
3747
|
-
}
|
|
3748
1989
|
/**
|
|
3749
1990
|
* Decorates a class with ngxs state information.
|
|
3750
|
-
* @template T
|
|
3751
|
-
* @param {?} options
|
|
3752
|
-
* @return {?}
|
|
3753
1991
|
*/
|
|
3754
1992
|
function State(options) {
|
|
3755
|
-
/**
|
|
3756
|
-
* @param {?} inheritedStateClass
|
|
3757
|
-
* @return {?}
|
|
3758
|
-
*/
|
|
3759
1993
|
function getStateOptions(inheritedStateClass) {
|
|
3760
|
-
/** @type {?} */
|
|
3761
1994
|
const inheritanceOptions = inheritedStateClass[META_OPTIONS_KEY] || {};
|
|
3762
|
-
return (
|
|
1995
|
+
return Object.assign(Object.assign({}, inheritanceOptions), options);
|
|
3763
1996
|
}
|
|
3764
|
-
/**
|
|
3765
|
-
* @param {?} params
|
|
3766
|
-
* @return {?}
|
|
3767
|
-
*/
|
|
3768
1997
|
function mutateMetaData(params) {
|
|
3769
1998
|
const { meta, inheritedStateClass, optionsWithInheritance } = params;
|
|
3770
1999
|
const { children, defaults, name } = optionsWithInheritance;
|
|
3771
|
-
/** @type {?} */
|
|
3772
2000
|
const stateName = typeof name === 'string' ? name : (name && name.getName()) || null;
|
|
3773
2001
|
// Caretaker note: we have still left the `typeof` condition in order to avoid
|
|
3774
2002
|
// creating a breaking change for projects that still use the View Engine.
|
|
@@ -3776,102 +2004,56 @@ function State(options) {
|
|
|
3776
2004
|
StoreValidators.checkThatStateIsNamedCorrectly(stateName);
|
|
3777
2005
|
}
|
|
3778
2006
|
if (inheritedStateClass.hasOwnProperty(META_KEY)) {
|
|
3779
|
-
/** @type {?} */
|
|
3780
2007
|
const inheritedMeta = inheritedStateClass[META_KEY] || {};
|
|
3781
|
-
meta.actions = Object.assign({}, meta.actions, inheritedMeta.actions);
|
|
2008
|
+
meta.actions = Object.assign(Object.assign({}, meta.actions), inheritedMeta.actions);
|
|
3782
2009
|
}
|
|
3783
2010
|
meta.children = children;
|
|
3784
2011
|
meta.defaults = defaults;
|
|
3785
2012
|
meta.name = stateName;
|
|
3786
2013
|
}
|
|
3787
|
-
return (
|
|
3788
|
-
* @param {?} target
|
|
3789
|
-
* @return {?}
|
|
3790
|
-
*/
|
|
3791
|
-
(target) => {
|
|
3792
|
-
/** @type {?} */
|
|
2014
|
+
return (target) => {
|
|
3793
2015
|
const stateClass = target;
|
|
3794
|
-
|
|
3795
|
-
const meta = ensureStoreMetadata(stateClass);
|
|
3796
|
-
/** @type {?} */
|
|
2016
|
+
const meta = ensureStoreMetadata$1(stateClass);
|
|
3797
2017
|
const inheritedStateClass = Object.getPrototypeOf(stateClass);
|
|
3798
|
-
/** @type {?} */
|
|
3799
2018
|
const optionsWithInheritance = getStateOptions(inheritedStateClass);
|
|
3800
2019
|
mutateMetaData({ meta, inheritedStateClass, optionsWithInheritance });
|
|
3801
2020
|
stateClass[META_OPTIONS_KEY] = optionsWithInheritance;
|
|
3802
|
-
}
|
|
2021
|
+
};
|
|
3803
2022
|
}
|
|
3804
2023
|
|
|
3805
|
-
/**
|
|
3806
|
-
* @fileoverview added by tsickle
|
|
3807
|
-
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
3808
|
-
*/
|
|
3809
|
-
/** @type {?} */
|
|
3810
2024
|
const DOLLAR_CHAR_CODE = 36;
|
|
3811
|
-
/**
|
|
3812
|
-
* @template T
|
|
3813
|
-
* @param {?} selector
|
|
3814
|
-
* @return {?}
|
|
3815
|
-
*/
|
|
3816
2025
|
function createSelectObservable(selector) {
|
|
3817
2026
|
if (!SelectFactory.store) {
|
|
3818
2027
|
throwSelectFactoryNotConnectedError();
|
|
3819
2028
|
}
|
|
3820
|
-
return
|
|
2029
|
+
return SelectFactory.store.select(selector);
|
|
3821
2030
|
}
|
|
3822
|
-
/**
|
|
3823
|
-
* @param {?} name
|
|
3824
|
-
* @param {?=} rawSelector
|
|
3825
|
-
* @param {?=} paths
|
|
3826
|
-
* @return {?}
|
|
3827
|
-
*/
|
|
3828
2031
|
function createSelectorFn(name, rawSelector, paths = []) {
|
|
3829
2032
|
rawSelector = !rawSelector ? removeDollarAtTheEnd(name) : rawSelector;
|
|
3830
2033
|
if (typeof rawSelector === 'string') {
|
|
3831
|
-
/** @type {?} */
|
|
3832
2034
|
const propsArray = paths.length
|
|
3833
2035
|
? [rawSelector, ...paths]
|
|
3834
2036
|
: rawSelector.split('.');
|
|
3835
|
-
return propGetter(propsArray,
|
|
2037
|
+
return propGetter(propsArray, SelectFactory.config);
|
|
3836
2038
|
}
|
|
3837
2039
|
return rawSelector;
|
|
3838
2040
|
}
|
|
3839
2041
|
/**
|
|
3840
|
-
*
|
|
3841
|
-
* @param {?} name
|
|
3842
|
-
* @return {?}
|
|
2042
|
+
* @example If `foo$` => make it just `foo`
|
|
3843
2043
|
*/
|
|
3844
2044
|
function removeDollarAtTheEnd(name) {
|
|
3845
|
-
/** @type {?} */
|
|
3846
2045
|
const lastCharIndex = name.length - 1;
|
|
3847
|
-
/** @type {?} */
|
|
3848
2046
|
const dollarAtTheEnd = name.charCodeAt(lastCharIndex) === DOLLAR_CHAR_CODE;
|
|
3849
2047
|
return dollarAtTheEnd ? name.slice(0, lastCharIndex) : name;
|
|
3850
2048
|
}
|
|
3851
2049
|
|
|
3852
|
-
/**
|
|
3853
|
-
* @fileoverview added by tsickle
|
|
3854
|
-
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
3855
|
-
*/
|
|
3856
2050
|
/**
|
|
3857
2051
|
* Decorator for selecting a slice of state from the store.
|
|
3858
|
-
* @template T
|
|
3859
|
-
* @param {?=} rawSelector
|
|
3860
|
-
* @param {...?} paths
|
|
3861
|
-
* @return {?}
|
|
3862
2052
|
*/
|
|
3863
2053
|
function Select(rawSelector, ...paths) {
|
|
3864
|
-
return (
|
|
3865
|
-
* @param {?} target
|
|
3866
|
-
* @param {?} key
|
|
3867
|
-
* @return {?}
|
|
3868
|
-
*/
|
|
3869
|
-
function (target, key) {
|
|
3870
|
-
/** @type {?} */
|
|
2054
|
+
return function (target, key) {
|
|
3871
2055
|
const name = key.toString();
|
|
3872
|
-
/** @type {?} */
|
|
3873
2056
|
const selectorId = `__${name}__selector`;
|
|
3874
|
-
/** @type {?} */
|
|
3875
2057
|
const selector = createSelectorFn(name, rawSelector, paths);
|
|
3876
2058
|
Object.defineProperties(target, {
|
|
3877
2059
|
[selectorId]: {
|
|
@@ -3882,39 +2064,52 @@ function Select(rawSelector, ...paths) {
|
|
|
3882
2064
|
[name]: {
|
|
3883
2065
|
enumerable: true,
|
|
3884
2066
|
configurable: true,
|
|
3885
|
-
/**
|
|
3886
|
-
* @return {?}
|
|
3887
|
-
*/
|
|
3888
2067
|
get() {
|
|
3889
2068
|
return this[selectorId] || (this[selectorId] = createSelectObservable(selector));
|
|
3890
2069
|
}
|
|
3891
2070
|
}
|
|
3892
2071
|
});
|
|
3893
|
-
}
|
|
2072
|
+
};
|
|
2073
|
+
}
|
|
2074
|
+
|
|
2075
|
+
const SELECTOR_OPTIONS_META_KEY = 'NGXS_SELECTOR_OPTIONS_META';
|
|
2076
|
+
const selectorOptionsMetaAccessor = {
|
|
2077
|
+
getOptions: (target) => {
|
|
2078
|
+
return (target && target[SELECTOR_OPTIONS_META_KEY]) || {};
|
|
2079
|
+
},
|
|
2080
|
+
defineOptions: (target, options) => {
|
|
2081
|
+
if (!target)
|
|
2082
|
+
return;
|
|
2083
|
+
target[SELECTOR_OPTIONS_META_KEY] = options;
|
|
2084
|
+
},
|
|
2085
|
+
};
|
|
2086
|
+
function setupSelectorMetadata(originalFn, creationMetadata) {
|
|
2087
|
+
const selectorMetaData = ensureSelectorMetadata$1(originalFn);
|
|
2088
|
+
selectorMetaData.originalFn = originalFn;
|
|
2089
|
+
let getExplicitSelectorOptions = () => ({});
|
|
2090
|
+
if (creationMetadata) {
|
|
2091
|
+
selectorMetaData.containerClass = creationMetadata.containerClass;
|
|
2092
|
+
selectorMetaData.selectorName = creationMetadata.selectorName || null;
|
|
2093
|
+
getExplicitSelectorOptions =
|
|
2094
|
+
creationMetadata.getSelectorOptions || getExplicitSelectorOptions;
|
|
2095
|
+
}
|
|
2096
|
+
const selectorMetaDataClone = Object.assign({}, selectorMetaData);
|
|
2097
|
+
selectorMetaData.getSelectorOptions = () => getLocalSelectorOptions(selectorMetaDataClone, getExplicitSelectorOptions());
|
|
2098
|
+
return selectorMetaData;
|
|
2099
|
+
}
|
|
2100
|
+
function getLocalSelectorOptions(selectorMetaData, explicitOptions) {
|
|
2101
|
+
return Object.assign(Object.assign(Object.assign(Object.assign({}, (selectorOptionsMetaAccessor.getOptions(selectorMetaData.containerClass) || {})), (selectorOptionsMetaAccessor.getOptions(selectorMetaData.originalFn) || {})), (selectorMetaData.getSelectorOptions() || {})), explicitOptions);
|
|
3894
2102
|
}
|
|
3895
2103
|
|
|
3896
|
-
/**
|
|
3897
|
-
* @fileoverview added by tsickle
|
|
3898
|
-
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
3899
|
-
*/
|
|
3900
2104
|
/**
|
|
3901
2105
|
* Decorator for setting selector options at a method or class level.
|
|
3902
|
-
* @param {?} options
|
|
3903
|
-
* @return {?}
|
|
3904
2106
|
*/
|
|
3905
2107
|
function SelectorOptions(options) {
|
|
3906
|
-
return (
|
|
3907
|
-
* @template T
|
|
3908
|
-
* @param {?} target
|
|
3909
|
-
* @param {?} methodName
|
|
3910
|
-
* @param {?} descriptor
|
|
3911
|
-
* @return {?}
|
|
3912
|
-
*/
|
|
3913
|
-
function decorate(target, methodName, descriptor) {
|
|
2108
|
+
return (function decorate(target, methodName, descriptor) {
|
|
3914
2109
|
if (methodName) {
|
|
2110
|
+
descriptor || (descriptor = Object.getOwnPropertyDescriptor(target, methodName));
|
|
3915
2111
|
// Method Decorator
|
|
3916
|
-
|
|
3917
|
-
const originalFn = descriptor.value || ((/** @type {?} */ (descriptor))).originalFn;
|
|
2112
|
+
const originalFn = descriptor.value || descriptor.originalFn;
|
|
3918
2113
|
if (originalFn) {
|
|
3919
2114
|
selectorOptionsMetaAccessor.defineOptions(originalFn, options);
|
|
3920
2115
|
}
|
|
@@ -3923,192 +2118,171 @@ function SelectorOptions(options) {
|
|
|
3923
2118
|
// Class Decorator
|
|
3924
2119
|
selectorOptionsMetaAccessor.defineOptions(target, options);
|
|
3925
2120
|
}
|
|
3926
|
-
})
|
|
2121
|
+
});
|
|
3927
2122
|
}
|
|
3928
2123
|
|
|
3929
|
-
|
|
3930
|
-
|
|
3931
|
-
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
3932
|
-
*/
|
|
3933
|
-
/**
|
|
3934
|
-
* @record
|
|
3935
|
-
*/
|
|
3936
|
-
function MetaDataModel$1() { }
|
|
3937
|
-
if (false) {
|
|
3938
|
-
/** @type {?} */
|
|
3939
|
-
MetaDataModel$1.prototype.name;
|
|
3940
|
-
/** @type {?} */
|
|
3941
|
-
MetaDataModel$1.prototype.actions;
|
|
3942
|
-
/** @type {?} */
|
|
3943
|
-
MetaDataModel$1.prototype.defaults;
|
|
3944
|
-
/** @type {?} */
|
|
3945
|
-
MetaDataModel$1.prototype.path;
|
|
3946
|
-
/** @type {?|undefined} */
|
|
3947
|
-
MetaDataModel$1.prototype.children;
|
|
3948
|
-
}
|
|
3949
|
-
/**
|
|
3950
|
-
* @record
|
|
3951
|
-
*/
|
|
3952
|
-
function SelectorMetaDataModel$1() { }
|
|
3953
|
-
if (false) {
|
|
3954
|
-
/** @type {?} */
|
|
3955
|
-
SelectorMetaDataModel$1.prototype.originalFn;
|
|
3956
|
-
/** @type {?} */
|
|
3957
|
-
SelectorMetaDataModel$1.prototype.containerClass;
|
|
3958
|
-
/** @type {?} */
|
|
3959
|
-
SelectorMetaDataModel$1.prototype.selectorName;
|
|
3960
|
-
/** @type {?} */
|
|
3961
|
-
SelectorMetaDataModel$1.prototype.getSelectorOptions;
|
|
2124
|
+
function ensureStoreMetadata(target) {
|
|
2125
|
+
return ensureStoreMetadata$1(target);
|
|
3962
2126
|
}
|
|
3963
|
-
|
|
3964
|
-
|
|
3965
|
-
* @return {?}
|
|
3966
|
-
*/
|
|
3967
|
-
function ensureStoreMetadata$1(target) {
|
|
3968
|
-
return ensureStoreMetadata(target);
|
|
2127
|
+
function getStoreMetadata(target) {
|
|
2128
|
+
return getStoreMetadata$1(target);
|
|
3969
2129
|
}
|
|
3970
|
-
|
|
3971
|
-
|
|
3972
|
-
* @return {?}
|
|
3973
|
-
*/
|
|
3974
|
-
function getStoreMetadata$1(target) {
|
|
3975
|
-
return getStoreMetadata(target);
|
|
2130
|
+
function ensureSelectorMetadata(target) {
|
|
2131
|
+
return ensureSelectorMetadata$1(target);
|
|
3976
2132
|
}
|
|
3977
|
-
|
|
3978
|
-
|
|
3979
|
-
* @return {?}
|
|
3980
|
-
*/
|
|
3981
|
-
function ensureSelectorMetadata$1(target) {
|
|
3982
|
-
return ensureSelectorMetadata(target);
|
|
2133
|
+
function getSelectorMetadata(target) {
|
|
2134
|
+
return getSelectorMetadata$1(target);
|
|
3983
2135
|
}
|
|
3984
|
-
|
|
3985
|
-
|
|
3986
|
-
|
|
3987
|
-
|
|
3988
|
-
|
|
3989
|
-
return
|
|
2136
|
+
|
|
2137
|
+
function createSelector(selectors, projector, creationMetadata) {
|
|
2138
|
+
const memoizedFn = createMemoizedSelectorFn(projector, creationMetadata);
|
|
2139
|
+
const selectorMetaData = setupSelectorMetadata(projector, creationMetadata);
|
|
2140
|
+
selectorMetaData.makeRootSelector = createRootSelectorFactory(selectorMetaData, selectors, memoizedFn);
|
|
2141
|
+
return memoizedFn;
|
|
3990
2142
|
}
|
|
3991
2143
|
|
|
3992
|
-
/**
|
|
3993
|
-
* @fileoverview added by tsickle
|
|
3994
|
-
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
3995
|
-
*/
|
|
3996
|
-
/**
|
|
3997
|
-
* Decorator for memoizing a state selector.
|
|
3998
|
-
* @template T
|
|
3999
|
-
* @param {?=} selectors
|
|
4000
|
-
* @return {?}
|
|
4001
|
-
*/
|
|
4002
2144
|
function Selector(selectors) {
|
|
4003
|
-
return (
|
|
4004
|
-
|
|
4005
|
-
|
|
4006
|
-
* @param {?} key
|
|
4007
|
-
* @param {?} descriptor
|
|
4008
|
-
* @return {?}
|
|
4009
|
-
*/
|
|
4010
|
-
(target, key, descriptor) => {
|
|
2145
|
+
return (target, key, descriptor) => {
|
|
2146
|
+
descriptor || (descriptor = Object.getOwnPropertyDescriptor(target, key));
|
|
2147
|
+
const originalFn = descriptor === null || descriptor === void 0 ? void 0 : descriptor.value;
|
|
4011
2148
|
// Caretaker note: we have still left the `typeof` condition in order to avoid
|
|
4012
2149
|
// creating a breaking change for projects that still use the View Engine.
|
|
4013
2150
|
if (typeof ngDevMode === 'undefined' || ngDevMode) {
|
|
4014
|
-
|
|
4015
|
-
const isNotMethod = !(descriptor && descriptor.value !== null);
|
|
4016
|
-
if (isNotMethod) {
|
|
2151
|
+
if (originalFn && typeof originalFn !== 'function') {
|
|
4017
2152
|
throwSelectorDecoratorError();
|
|
4018
2153
|
}
|
|
4019
2154
|
}
|
|
4020
|
-
|
|
4021
|
-
const originalFn = descriptor.value;
|
|
4022
|
-
/** @type {?} */
|
|
4023
|
-
const memoizedFn = createSelector(selectors, (/** @type {?} */ (originalFn)), {
|
|
2155
|
+
const memoizedFn = createSelector(selectors, originalFn, {
|
|
4024
2156
|
containerClass: target,
|
|
4025
2157
|
selectorName: key.toString(),
|
|
4026
|
-
/**
|
|
4027
|
-
* @return {?}
|
|
4028
|
-
*/
|
|
4029
2158
|
getSelectorOptions() {
|
|
4030
2159
|
return {};
|
|
4031
|
-
}
|
|
2160
|
+
},
|
|
4032
2161
|
});
|
|
4033
|
-
/** @type {?} */
|
|
4034
2162
|
const newDescriptor = {
|
|
4035
2163
|
configurable: true,
|
|
4036
|
-
/**
|
|
4037
|
-
* @return {?}
|
|
4038
|
-
*/
|
|
4039
2164
|
get() {
|
|
4040
2165
|
return memoizedFn;
|
|
4041
|
-
}
|
|
2166
|
+
},
|
|
4042
2167
|
};
|
|
4043
2168
|
// Add hidden property to descriptor
|
|
4044
|
-
|
|
2169
|
+
newDescriptor['originalFn'] = originalFn;
|
|
4045
2170
|
return newDescriptor;
|
|
4046
|
-
}
|
|
2171
|
+
};
|
|
4047
2172
|
}
|
|
4048
2173
|
|
|
4049
|
-
/**
|
|
4050
|
-
* @fileoverview added by tsickle
|
|
4051
|
-
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
4052
|
-
*/
|
|
4053
|
-
/**
|
|
4054
|
-
* @template T
|
|
4055
|
-
*/
|
|
4056
2174
|
class StateToken {
|
|
4057
|
-
/**
|
|
4058
|
-
* @param {?} name
|
|
4059
|
-
*/
|
|
4060
2175
|
constructor(name) {
|
|
4061
2176
|
this.name = name;
|
|
4062
|
-
|
|
4063
|
-
|
|
4064
|
-
selectorMetadata.makeRootSelector = (/**
|
|
4065
|
-
* @param {?} runtimeContext
|
|
4066
|
-
* @return {?}
|
|
4067
|
-
*/
|
|
4068
|
-
(runtimeContext) => {
|
|
2177
|
+
const selectorMetadata = ensureSelectorMetadata$1(this);
|
|
2178
|
+
selectorMetadata.makeRootSelector = (runtimeContext) => {
|
|
4069
2179
|
return runtimeContext.getStateGetter(this.name);
|
|
4070
|
-
}
|
|
2180
|
+
};
|
|
4071
2181
|
}
|
|
4072
|
-
/**
|
|
4073
|
-
* @return {?}
|
|
4074
|
-
*/
|
|
4075
2182
|
getName() {
|
|
4076
2183
|
return this.name;
|
|
4077
2184
|
}
|
|
4078
|
-
/**
|
|
4079
|
-
* @return {?}
|
|
4080
|
-
*/
|
|
4081
2185
|
toString() {
|
|
4082
2186
|
return `StateToken[${this.name}]`;
|
|
4083
2187
|
}
|
|
4084
2188
|
}
|
|
4085
|
-
|
|
4086
|
-
|
|
4087
|
-
|
|
4088
|
-
|
|
4089
|
-
|
|
4090
|
-
|
|
2189
|
+
|
|
2190
|
+
class NgxsDevelopmentModule {
|
|
2191
|
+
static forRoot(options) {
|
|
2192
|
+
return {
|
|
2193
|
+
ngModule: NgxsDevelopmentModule,
|
|
2194
|
+
providers: [
|
|
2195
|
+
NgxsUnhandledActionsLogger,
|
|
2196
|
+
{ provide: NGXS_DEVELOPMENT_OPTIONS, useValue: options }
|
|
2197
|
+
]
|
|
2198
|
+
};
|
|
2199
|
+
}
|
|
4091
2200
|
}
|
|
2201
|
+
/** @nocollapse */ NgxsDevelopmentModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: NgxsDevelopmentModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
2202
|
+
/** @nocollapse */ NgxsDevelopmentModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: NgxsDevelopmentModule });
|
|
2203
|
+
/** @nocollapse */ NgxsDevelopmentModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: NgxsDevelopmentModule });
|
|
2204
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: NgxsDevelopmentModule, decorators: [{
|
|
2205
|
+
type: NgModule
|
|
2206
|
+
}] });
|
|
4092
2207
|
|
|
4093
|
-
|
|
4094
|
-
|
|
4095
|
-
|
|
4096
|
-
|
|
2208
|
+
function ensureValidSelector(selector, context = {}) {
|
|
2209
|
+
const noun = context.noun || 'selector';
|
|
2210
|
+
const prefix = context.prefix ? context.prefix + ': ' : '';
|
|
2211
|
+
ensureValueProvided(selector, { noun, prefix: context.prefix });
|
|
2212
|
+
const metadata = getSelectorMetadata$1(selector) || getStoreMetadata$1(selector);
|
|
2213
|
+
if (!metadata) {
|
|
2214
|
+
throw new Error(`${prefix}The value provided as the ${noun} is not a valid selector.`);
|
|
2215
|
+
}
|
|
2216
|
+
}
|
|
2217
|
+
function ensureValueProvided(value, context = {}) {
|
|
2218
|
+
const noun = context.noun || 'value';
|
|
2219
|
+
const prefix = context.prefix ? context.prefix + ': ' : '';
|
|
2220
|
+
if (!value) {
|
|
2221
|
+
throw new Error(`${prefix}A ${noun} must be provided.`);
|
|
2222
|
+
}
|
|
2223
|
+
}
|
|
4097
2224
|
|
|
4098
|
-
|
|
4099
|
-
|
|
4100
|
-
|
|
4101
|
-
|
|
2225
|
+
function createModelSelector(selectorMap) {
|
|
2226
|
+
const selectorKeys = Object.keys(selectorMap);
|
|
2227
|
+
const selectors = Object.values(selectorMap);
|
|
2228
|
+
ensureValidSelectorMap({
|
|
2229
|
+
prefix: '[createModelSelector]',
|
|
2230
|
+
selectorMap,
|
|
2231
|
+
selectorKeys,
|
|
2232
|
+
selectors,
|
|
2233
|
+
});
|
|
2234
|
+
return createSelector(selectors, (...args) => {
|
|
2235
|
+
return selectorKeys.reduce((obj, key, index) => {
|
|
2236
|
+
obj[key] = args[index];
|
|
2237
|
+
return obj;
|
|
2238
|
+
}, {});
|
|
2239
|
+
});
|
|
2240
|
+
}
|
|
2241
|
+
function ensureValidSelectorMap({ prefix, selectorMap, selectorKeys, selectors, }) {
|
|
2242
|
+
ensureValueProvided(selectorMap, { prefix, noun: 'selector map' });
|
|
2243
|
+
ensureValueProvided(typeof selectorMap === 'object', { prefix, noun: 'valid selector map' });
|
|
2244
|
+
ensureValueProvided(selectorKeys.length, { prefix, noun: 'non-empty selector map' });
|
|
2245
|
+
selectors.forEach((selector, index) => ensureValidSelector(selector, {
|
|
2246
|
+
prefix,
|
|
2247
|
+
noun: `selector for the '${selectorKeys[index]}' property`,
|
|
2248
|
+
}));
|
|
2249
|
+
}
|
|
2250
|
+
|
|
2251
|
+
function createPickSelector(selector, keys) {
|
|
2252
|
+
ensureValidSelector(selector, { prefix: '[createPickSelector]' });
|
|
2253
|
+
const validKeys = keys.filter(Boolean);
|
|
2254
|
+
const selectors = validKeys.map((key) => createSelector([selector], (s) => s[key]));
|
|
2255
|
+
return createSelector([...selectors], (...props) => {
|
|
2256
|
+
return validKeys.reduce((acc, key, index) => {
|
|
2257
|
+
acc[key] = props[index];
|
|
2258
|
+
return acc;
|
|
2259
|
+
}, {});
|
|
2260
|
+
});
|
|
2261
|
+
}
|
|
2262
|
+
|
|
2263
|
+
function createPropertySelectors(parentSelector) {
|
|
2264
|
+
ensureValidSelector(parentSelector, {
|
|
2265
|
+
prefix: '[createPropertySelectors]',
|
|
2266
|
+
noun: 'parent selector',
|
|
2267
|
+
});
|
|
2268
|
+
const cache = {};
|
|
2269
|
+
return new Proxy({}, {
|
|
2270
|
+
get(_target, prop) {
|
|
2271
|
+
const selector = cache[prop] ||
|
|
2272
|
+
createSelector([parentSelector], (s) => s === null || s === void 0 ? void 0 : s[prop]);
|
|
2273
|
+
cache[prop] = selector;
|
|
2274
|
+
return selector;
|
|
2275
|
+
},
|
|
2276
|
+
});
|
|
2277
|
+
}
|
|
4102
2278
|
|
|
4103
2279
|
/**
|
|
4104
|
-
*
|
|
4105
|
-
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
2280
|
+
* The public api for consumers of @ngxs/store
|
|
4106
2281
|
*/
|
|
4107
2282
|
|
|
4108
2283
|
/**
|
|
4109
|
-
*
|
|
4110
|
-
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
2284
|
+
* Generated bundle index. Do not edit.
|
|
4111
2285
|
*/
|
|
4112
2286
|
|
|
4113
|
-
export { Action, Actions, InitState, NGXS_PLUGINS, NgxsModule, NgxsSimpleChange, NoopNgxsExecutionStrategy, Select, Selector, SelectorOptions, State, StateStream, StateToken, Store, UpdateState, actionMatcher,
|
|
2287
|
+
export { Action, Actions, InitState, NGXS_PLUGINS, NgxsDevelopmentModule, NgxsModule, NgxsSimpleChange, NgxsUnhandledActionsLogger, NoopNgxsExecutionStrategy, Select, Selector, SelectorOptions, State, StateStream, StateToken, Store, UpdateState, actionMatcher, createModelSelector, createPickSelector, createPropertySelectors, createSelector, ensureSelectorMetadata, ensureStoreMetadata, getActionTypeFromInstance, getSelectorMetadata, getStoreMetadata, getValue, ofAction, ofActionCanceled, ofActionCompleted, ofActionDispatched, ofActionErrored, ofActionSuccessful, setValue, NgxsFeatureModule as ɵNgxsFeatureModule, NgxsRootModule as ɵNgxsRootModule };
|
|
4114
2288
|
//# sourceMappingURL=ngxs-store.js.map
|