@ngxs/store 3.7.6-dev.master-fb318b1 → 3.7.6-dev.master-40a2210
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 +61 -402
- package/bundles/ngxs-store-operators.umd.js.map +1 -1
- package/bundles/ngxs-store.umd.js +1041 -3269
- 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 -23
- 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 -22
- package/esm2015/operators/remove-item.js +5 -17
- package/esm2015/operators/types.js +2 -5
- package/esm2015/operators/update-item.js +12 -26
- 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 +24 -90
- 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 +5 -29
- package/esm2015/src/decorators/selector/symbols.js +2 -5
- package/esm2015/src/decorators/selector-options.js +4 -18
- package/esm2015/src/decorators/state.js +5 -44
- package/esm2015/src/dev-features/ngxs-development.module.js +8 -12
- package/esm2015/src/dev-features/ngxs-unhandled-actions-logger.js +12 -37
- package/esm2015/src/dev-features/symbols.js +2 -18
- 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/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 +9 -67
- package/esm2015/src/internal/state-factory.js +42 -225
- package/esm2015/src/internal/state-operations.js +19 -80
- package/esm2015/src/internal/state-operators.js +6 -20
- package/esm2015/src/internal/state-stream.js +7 -13
- 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 -111
- 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 +1 -5
- package/esm2015/src/public_to_deprecate.js +1 -51
- package/esm2015/src/state-token/state-token.js +4 -32
- package/esm2015/src/state-token/symbols.js +2 -5
- package/esm2015/src/store.js +20 -104
- 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/selector-utils.js +23 -136
- 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 +53 -186
- package/fesm2015/ngxs-store-operators.js.map +1 -1
- package/fesm2015/ngxs-store.js +400 -2473
- 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 -18
- package/operators/index.d.ts +2 -2
- package/operators/ngxs-store-operators.d.ts +1 -0
- package/operators/package.json +2 -5
- package/operators/patch.d.ts +2 -2
- package/operators/types.d.ts +6 -3
- package/package.json +3 -6
- package/src/actions/actions.d.ts +2 -2
- package/src/actions-stream.d.ts +5 -0
- package/src/decorators/select/select-factory.d.ts +3 -0
- package/src/decorators/state.d.ts +1 -1
- package/src/dev-features/ngxs-development.module.d.ts +4 -0
- package/src/dev-features/ngxs-unhandled-actions-logger.d.ts +3 -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/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-stream.d.ts +3 -0
- 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/plugin-manager.d.ts +4 -1
- package/src/private_api.d.ts +2 -0
- package/src/store.d.ts +3 -0
- package/src/symbols.d.ts +4 -1
- 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/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 -26
- 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/ngxs-store-operators.js +0 -9
- package/esm5/operators/patch.js +0 -39
- package/esm5/operators/remove-item.js +0 -34
- package/esm5/operators/types.js +0 -5
- package/esm5/operators/update-item.js +0 -54
- 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 -201
- 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/dev-features/ngxs-development.module.js +0 -34
- package/esm5/src/dev-features/ngxs-unhandled-actions-logger.js +0 -100
- package/esm5/src/dev-features/symbols.js +0 -22
- 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 -599
- 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 -223
- package/esm5/src/plugin-manager.js +0 -82
- package/esm5/src/plugin_api.js +0 -10
- package/esm5/src/public_api.js +0 -31
- 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 -341
- package/fesm5/ngxs-store-operators.js.map +0 -1
- package/fesm5/ngxs-store.js +0 -4783
- 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/ngxs-store-operators.metadata.json +0 -1
- 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
6
|
import { Observable, Subject, BehaviorSubject, of, forkJoin, throwError, EMPTY, from, isObservable, queueScheduler } from 'rxjs';
|
|
5
7
|
import { filter, map, share, shareReplay, take, exhaustMap, mergeMap, defaultIfEmpty, catchError, takeUntil, observeOn, 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
|
-
*/
|
|
993
|
-
const setValue = (/**
|
|
994
|
-
* @param {?} obj
|
|
995
|
-
* @param {?} prop
|
|
996
|
-
* @param {?} val
|
|
997
|
-
* @return {?}
|
|
998
459
|
*/
|
|
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
|
-
*/
|
|
1050
|
-
const isObject$1 = (/**
|
|
1051
|
-
* @param {?} item
|
|
1052
|
-
* @return {?}
|
|
1053
490
|
*/
|
|
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,30 +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
|
-
* @template T
|
|
1110
|
-
* @param {...?} allowedTypes
|
|
1111
|
-
* @return {?}
|
|
1112
524
|
*/
|
|
1113
525
|
function ofAction(...allowedTypes) {
|
|
1114
526
|
return ofActionOperator(allowedTypes);
|
|
@@ -1117,9 +529,6 @@ function ofAction(...allowedTypes) {
|
|
|
1117
529
|
* RxJS operator for selecting out specific actions.
|
|
1118
530
|
*
|
|
1119
531
|
* This will ONLY grab actions that have just been dispatched
|
|
1120
|
-
* @template T
|
|
1121
|
-
* @param {...?} allowedTypes
|
|
1122
|
-
* @return {?}
|
|
1123
532
|
*/
|
|
1124
533
|
function ofActionDispatched(...allowedTypes) {
|
|
1125
534
|
return ofActionOperator(allowedTypes, ["DISPATCHED" /* Dispatched */]);
|
|
@@ -1128,9 +537,6 @@ function ofActionDispatched(...allowedTypes) {
|
|
|
1128
537
|
* RxJS operator for selecting out specific actions.
|
|
1129
538
|
*
|
|
1130
539
|
* This will ONLY grab actions that have just been successfully completed
|
|
1131
|
-
* @template T
|
|
1132
|
-
* @param {...?} allowedTypes
|
|
1133
|
-
* @return {?}
|
|
1134
540
|
*/
|
|
1135
541
|
function ofActionSuccessful(...allowedTypes) {
|
|
1136
542
|
return ofActionOperator(allowedTypes, ["SUCCESSFUL" /* Successful */]);
|
|
@@ -1139,9 +545,6 @@ function ofActionSuccessful(...allowedTypes) {
|
|
|
1139
545
|
* RxJS operator for selecting out specific actions.
|
|
1140
546
|
*
|
|
1141
547
|
* This will ONLY grab actions that have just been canceled
|
|
1142
|
-
* @template T
|
|
1143
|
-
* @param {...?} allowedTypes
|
|
1144
|
-
* @return {?}
|
|
1145
548
|
*/
|
|
1146
549
|
function ofActionCanceled(...allowedTypes) {
|
|
1147
550
|
return ofActionOperator(allowedTypes, ["CANCELED" /* Canceled */]);
|
|
@@ -1150,12 +553,8 @@ function ofActionCanceled(...allowedTypes) {
|
|
|
1150
553
|
* RxJS operator for selecting out specific actions.
|
|
1151
554
|
*
|
|
1152
555
|
* This will ONLY grab actions that have just been completed
|
|
1153
|
-
* @template T
|
|
1154
|
-
* @param {...?} allowedTypes
|
|
1155
|
-
* @return {?}
|
|
1156
556
|
*/
|
|
1157
557
|
function ofActionCompleted(...allowedTypes) {
|
|
1158
|
-
/** @type {?} */
|
|
1159
558
|
const allowedStatuses = [
|
|
1160
559
|
"SUCCESSFUL" /* Successful */,
|
|
1161
560
|
"CANCELED" /* Canceled */,
|
|
@@ -1167,260 +566,113 @@ function ofActionCompleted(...allowedTypes) {
|
|
|
1167
566
|
* RxJS operator for selecting out specific actions.
|
|
1168
567
|
*
|
|
1169
568
|
* This will ONLY grab actions that have just thrown an error
|
|
1170
|
-
* @template T
|
|
1171
|
-
* @param {...?} allowedTypes
|
|
1172
|
-
* @return {?}
|
|
1173
569
|
*/
|
|
1174
570
|
function ofActionErrored(...allowedTypes) {
|
|
1175
571
|
return ofActionOperator(allowedTypes, ["ERRORED" /* Errored */]);
|
|
1176
572
|
}
|
|
1177
|
-
/**
|
|
1178
|
-
* @param {?} allowedTypes
|
|
1179
|
-
* @param {?=} statuses
|
|
1180
|
-
* @param {?=} mapOperator
|
|
1181
|
-
* @return {?}
|
|
1182
|
-
*/
|
|
1183
573
|
function ofActionOperator(allowedTypes, statuses,
|
|
1184
574
|
// This actually could've been `OperatorFunction<ActionContext, ActionCompletion | any>`,
|
|
1185
575
|
// since it maps either to `ctx.action` OR to `ActionCompletion`. But `ActionCompleteion | any`
|
|
1186
576
|
// defaults to `any`, thus there is no sense from union type.
|
|
1187
577
|
mapOperator = mapAction) {
|
|
1188
|
-
/** @type {?} */
|
|
1189
578
|
const allowedMap = createAllowedActionTypesMap(allowedTypes);
|
|
1190
|
-
/** @type {?} */
|
|
1191
579
|
const allowedStatusMap = statuses && createAllowedStatusesMap(statuses);
|
|
1192
|
-
return (
|
|
1193
|
-
* @param {?} o
|
|
1194
|
-
* @return {?}
|
|
1195
|
-
*/
|
|
1196
|
-
function (o) {
|
|
580
|
+
return function (o) {
|
|
1197
581
|
return o.pipe(filterStatus(allowedMap, allowedStatusMap), mapOperator());
|
|
1198
|
-
}
|
|
582
|
+
};
|
|
1199
583
|
}
|
|
1200
|
-
/**
|
|
1201
|
-
* @param {?} allowedTypes
|
|
1202
|
-
* @param {?=} allowedStatuses
|
|
1203
|
-
* @return {?}
|
|
1204
|
-
*/
|
|
1205
584
|
function filterStatus(allowedTypes, allowedStatuses) {
|
|
1206
|
-
return filter((
|
|
1207
|
-
|
|
1208
|
-
* @return {?}
|
|
1209
|
-
*/
|
|
1210
|
-
(ctx) => {
|
|
1211
|
-
/** @type {?} */
|
|
1212
|
-
const actionType = (/** @type {?} */ (getActionTypeFromInstance(ctx.action)));
|
|
1213
|
-
/** @type {?} */
|
|
585
|
+
return filter((ctx) => {
|
|
586
|
+
const actionType = getActionTypeFromInstance(ctx.action);
|
|
1214
587
|
const typeMatch = allowedTypes[actionType];
|
|
1215
|
-
/** @type {?} */
|
|
1216
588
|
const statusMatch = allowedStatuses ? allowedStatuses[ctx.status] : true;
|
|
1217
589
|
return typeMatch && statusMatch;
|
|
1218
|
-
})
|
|
590
|
+
});
|
|
1219
591
|
}
|
|
1220
|
-
/**
|
|
1221
|
-
* @return {?}
|
|
1222
|
-
*/
|
|
1223
592
|
function mapActionResult() {
|
|
1224
|
-
return map((
|
|
1225
|
-
|
|
1226
|
-
* @return {?}
|
|
1227
|
-
*/
|
|
1228
|
-
({ action, status, error }) => {
|
|
1229
|
-
return (/** @type {?} */ ({
|
|
593
|
+
return map(({ action, status, error }) => {
|
|
594
|
+
return {
|
|
1230
595
|
action,
|
|
1231
596
|
result: {
|
|
1232
597
|
successful: "SUCCESSFUL" /* Successful */ === status,
|
|
1233
598
|
canceled: "CANCELED" /* Canceled */ === status,
|
|
1234
599
|
error
|
|
1235
600
|
}
|
|
1236
|
-
}
|
|
1237
|
-
})
|
|
601
|
+
};
|
|
602
|
+
});
|
|
1238
603
|
}
|
|
1239
|
-
/**
|
|
1240
|
-
* @template T
|
|
1241
|
-
* @return {?}
|
|
1242
|
-
*/
|
|
1243
604
|
function mapAction() {
|
|
1244
|
-
return map((
|
|
1245
|
-
* @param {?} ctx
|
|
1246
|
-
* @return {?}
|
|
1247
|
-
*/
|
|
1248
|
-
(ctx) => (/** @type {?} */ (ctx.action))));
|
|
605
|
+
return map((ctx) => ctx.action);
|
|
1249
606
|
}
|
|
1250
|
-
/**
|
|
1251
|
-
* @record
|
|
1252
|
-
*/
|
|
1253
|
-
function FilterMap() { }
|
|
1254
|
-
/**
|
|
1255
|
-
* @param {?} types
|
|
1256
|
-
* @return {?}
|
|
1257
|
-
*/
|
|
1258
607
|
function createAllowedActionTypesMap(types) {
|
|
1259
|
-
return types.reduce((
|
|
1260
|
-
|
|
1261
|
-
* @param {?} klass
|
|
1262
|
-
* @return {?}
|
|
1263
|
-
*/
|
|
1264
|
-
(filterMap, klass) => {
|
|
1265
|
-
filterMap[(/** @type {?} */ (getActionTypeFromInstance(klass)))] = true;
|
|
608
|
+
return types.reduce((filterMap, klass) => {
|
|
609
|
+
filterMap[getActionTypeFromInstance(klass)] = true;
|
|
1266
610
|
return filterMap;
|
|
1267
|
-
}
|
|
611
|
+
}, {});
|
|
1268
612
|
}
|
|
1269
|
-
/**
|
|
1270
|
-
* @param {?} statuses
|
|
1271
|
-
* @return {?}
|
|
1272
|
-
*/
|
|
1273
613
|
function createAllowedStatusesMap(statuses) {
|
|
1274
|
-
return statuses.reduce((
|
|
1275
|
-
* @param {?} filterMap
|
|
1276
|
-
* @param {?} status
|
|
1277
|
-
* @return {?}
|
|
1278
|
-
*/
|
|
1279
|
-
(filterMap, status) => {
|
|
614
|
+
return statuses.reduce((filterMap, status) => {
|
|
1280
615
|
filterMap[status] = true;
|
|
1281
616
|
return filterMap;
|
|
1282
|
-
}
|
|
617
|
+
}, {});
|
|
1283
618
|
}
|
|
1284
619
|
|
|
1285
|
-
/**
|
|
1286
|
-
* @fileoverview added by tsickle
|
|
1287
|
-
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
1288
|
-
*/
|
|
1289
620
|
/**
|
|
1290
621
|
* Returns operator that will run
|
|
1291
622
|
* `subscribe` outside of the ngxs execution context
|
|
1292
|
-
* @template T
|
|
1293
|
-
* @param {?} ngxsExecutionStrategy
|
|
1294
|
-
* @return {?}
|
|
1295
623
|
*/
|
|
1296
624
|
function leaveNgxs(ngxsExecutionStrategy) {
|
|
1297
|
-
return (
|
|
1298
|
-
|
|
1299
|
-
* @return {?}
|
|
1300
|
-
*/
|
|
1301
|
-
(source) => {
|
|
1302
|
-
return new Observable((/**
|
|
1303
|
-
* @param {?} sink
|
|
1304
|
-
* @return {?}
|
|
1305
|
-
*/
|
|
1306
|
-
(sink) => {
|
|
625
|
+
return (source) => {
|
|
626
|
+
return new Observable((sink) => {
|
|
1307
627
|
return source.subscribe({
|
|
1308
|
-
/**
|
|
1309
|
-
* @param {?} value
|
|
1310
|
-
* @return {?}
|
|
1311
|
-
*/
|
|
1312
628
|
next(value) {
|
|
1313
|
-
ngxsExecutionStrategy.leave((
|
|
1314
|
-
* @return {?}
|
|
1315
|
-
*/
|
|
1316
|
-
() => sink.next(value)));
|
|
629
|
+
ngxsExecutionStrategy.leave(() => sink.next(value));
|
|
1317
630
|
},
|
|
1318
|
-
/**
|
|
1319
|
-
* @param {?} error
|
|
1320
|
-
* @return {?}
|
|
1321
|
-
*/
|
|
1322
631
|
error(error) {
|
|
1323
|
-
ngxsExecutionStrategy.leave((
|
|
1324
|
-
* @return {?}
|
|
1325
|
-
*/
|
|
1326
|
-
() => sink.error(error)));
|
|
632
|
+
ngxsExecutionStrategy.leave(() => sink.error(error));
|
|
1327
633
|
},
|
|
1328
|
-
/**
|
|
1329
|
-
* @return {?}
|
|
1330
|
-
*/
|
|
1331
634
|
complete() {
|
|
1332
|
-
ngxsExecutionStrategy.leave((
|
|
1333
|
-
* @return {?}
|
|
1334
|
-
*/
|
|
1335
|
-
() => sink.complete()));
|
|
635
|
+
ngxsExecutionStrategy.leave(() => sink.complete());
|
|
1336
636
|
}
|
|
1337
637
|
});
|
|
1338
|
-
})
|
|
1339
|
-
}
|
|
638
|
+
});
|
|
639
|
+
};
|
|
1340
640
|
}
|
|
1341
641
|
|
|
1342
|
-
/**
|
|
1343
|
-
* @fileoverview added by tsickle
|
|
1344
|
-
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
1345
|
-
*/
|
|
1346
642
|
class InternalNgxsExecutionStrategy {
|
|
1347
|
-
/**
|
|
1348
|
-
* @param {?} _executionStrategy
|
|
1349
|
-
*/
|
|
1350
643
|
constructor(_executionStrategy) {
|
|
1351
644
|
this._executionStrategy = _executionStrategy;
|
|
1352
645
|
}
|
|
1353
|
-
/**
|
|
1354
|
-
* @template T
|
|
1355
|
-
* @param {?} func
|
|
1356
|
-
* @return {?}
|
|
1357
|
-
*/
|
|
1358
646
|
enter(func) {
|
|
1359
647
|
return this._executionStrategy.enter(func);
|
|
1360
648
|
}
|
|
1361
|
-
/**
|
|
1362
|
-
* @template T
|
|
1363
|
-
* @param {?} func
|
|
1364
|
-
* @return {?}
|
|
1365
|
-
*/
|
|
1366
649
|
leave(func) {
|
|
1367
650
|
return this._executionStrategy.leave(func);
|
|
1368
651
|
}
|
|
1369
652
|
}
|
|
1370
|
-
InternalNgxsExecutionStrategy
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
]
|
|
1377
|
-
|
|
1378
|
-
/**
|
|
1379
|
-
* @type {?}
|
|
1380
|
-
* @private
|
|
1381
|
-
*/
|
|
1382
|
-
InternalNgxsExecutionStrategy.prototype._executionStrategy;
|
|
1383
|
-
}
|
|
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
|
+
}] }]; } });
|
|
1384
661
|
|
|
1385
|
-
/**
|
|
1386
|
-
* @fileoverview added by tsickle
|
|
1387
|
-
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
1388
|
-
*/
|
|
1389
|
-
/** @enum {string} */
|
|
1390
|
-
const ActionStatus = {
|
|
1391
|
-
Dispatched: 'DISPATCHED',
|
|
1392
|
-
Successful: 'SUCCESSFUL',
|
|
1393
|
-
Canceled: 'CANCELED',
|
|
1394
|
-
Errored: 'ERRORED',
|
|
1395
|
-
};
|
|
1396
|
-
/**
|
|
1397
|
-
* @record
|
|
1398
|
-
* @template T
|
|
1399
|
-
*/
|
|
1400
|
-
function ActionContext() { }
|
|
1401
|
-
if (false) {
|
|
1402
|
-
/** @type {?} */
|
|
1403
|
-
ActionContext.prototype.status;
|
|
1404
|
-
/** @type {?} */
|
|
1405
|
-
ActionContext.prototype.action;
|
|
1406
|
-
/** @type {?|undefined} */
|
|
1407
|
-
ActionContext.prototype.error;
|
|
1408
|
-
}
|
|
1409
662
|
/**
|
|
1410
663
|
* Custom Subject that ensures that subscribers are notified of values in the order that they arrived.
|
|
1411
664
|
* A standard Subject does not have this guarantee.
|
|
1412
665
|
* For example, given the following code:
|
|
1413
666
|
* ```typescript
|
|
1414
667
|
* const subject = new Subject<string>();
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
668
|
+
subject.subscribe(value => {
|
|
669
|
+
if (value === 'start') subject.next('end');
|
|
670
|
+
});
|
|
671
|
+
subject.subscribe(value => { });
|
|
672
|
+
subject.next('start');
|
|
1420
673
|
* ```
|
|
1421
674
|
* When `subject` is a standard `Subject<T>` the second subscriber would recieve `end` and then `start`.
|
|
1422
675
|
* When `subject` is a `OrderedSubject<T>` the second subscriber would recieve `start` and then `end`.
|
|
1423
|
-
* @template T
|
|
1424
676
|
*/
|
|
1425
677
|
class OrderedSubject extends Subject {
|
|
1426
678
|
constructor() {
|
|
@@ -1428,108 +680,62 @@ class OrderedSubject extends Subject {
|
|
|
1428
680
|
this._itemQueue = [];
|
|
1429
681
|
this._busyPushingNext = false;
|
|
1430
682
|
}
|
|
1431
|
-
/**
|
|
1432
|
-
* @param {?=} value
|
|
1433
|
-
* @return {?}
|
|
1434
|
-
*/
|
|
1435
683
|
next(value) {
|
|
1436
684
|
if (this._busyPushingNext) {
|
|
1437
|
-
this._itemQueue.unshift(
|
|
685
|
+
this._itemQueue.unshift(value);
|
|
1438
686
|
return;
|
|
1439
687
|
}
|
|
1440
688
|
this._busyPushingNext = true;
|
|
1441
689
|
super.next(value);
|
|
1442
690
|
while (this._itemQueue.length > 0) {
|
|
1443
|
-
/** @type {?} */
|
|
1444
691
|
const nextValue = this._itemQueue.pop();
|
|
1445
692
|
super.next(nextValue);
|
|
1446
693
|
}
|
|
1447
694
|
this._busyPushingNext = false;
|
|
1448
695
|
}
|
|
1449
696
|
}
|
|
1450
|
-
if (false) {
|
|
1451
|
-
/**
|
|
1452
|
-
* @type {?}
|
|
1453
|
-
* @private
|
|
1454
|
-
*/
|
|
1455
|
-
OrderedSubject.prototype._itemQueue;
|
|
1456
|
-
/**
|
|
1457
|
-
* @type {?}
|
|
1458
|
-
* @private
|
|
1459
|
-
*/
|
|
1460
|
-
OrderedSubject.prototype._busyPushingNext;
|
|
1461
|
-
}
|
|
1462
697
|
/**
|
|
1463
698
|
* Internal Action stream that is emitted anytime an action is dispatched.
|
|
1464
699
|
*/
|
|
1465
700
|
class InternalActions extends OrderedSubject {
|
|
1466
|
-
/**
|
|
1467
|
-
* @return {?}
|
|
1468
|
-
*/
|
|
1469
701
|
ngOnDestroy() {
|
|
1470
702
|
this.complete();
|
|
1471
703
|
}
|
|
1472
704
|
}
|
|
1473
|
-
InternalActions
|
|
1474
|
-
|
|
1475
|
-
|
|
705
|
+
/** @nocollapse */ InternalActions.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: InternalActions, deps: null, target: i0.ɵɵFactoryTarget.Injectable });
|
|
706
|
+
/** @nocollapse */ InternalActions.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: InternalActions });
|
|
707
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: InternalActions, decorators: [{
|
|
708
|
+
type: Injectable
|
|
709
|
+
}] });
|
|
1476
710
|
/**
|
|
1477
711
|
* Action stream that is emitted anytime an action is dispatched.
|
|
1478
712
|
*
|
|
1479
713
|
* You can listen to this in services to react without stores.
|
|
1480
714
|
*/
|
|
1481
715
|
class Actions extends Observable {
|
|
1482
|
-
/**
|
|
1483
|
-
* @param {?} internalActions$
|
|
1484
|
-
* @param {?} internalExecutionStrategy
|
|
1485
|
-
*/
|
|
1486
716
|
constructor(internalActions$, internalExecutionStrategy) {
|
|
1487
|
-
/** @type {?} */
|
|
1488
717
|
const sharedInternalActions$ = internalActions$.pipe(leaveNgxs(internalExecutionStrategy),
|
|
1489
718
|
// The `InternalActions` subject emits outside of the Angular zone.
|
|
1490
719
|
// We have to re-enter the Angular zone for any incoming consumer.
|
|
1491
720
|
// The `share()` operator reduces the number of change detections.
|
|
1492
721
|
// This would call leave only once for any stream emission across all active subscribers.
|
|
1493
722
|
share());
|
|
1494
|
-
super(
|
|
1495
|
-
* @param {?} observer
|
|
1496
|
-
* @return {?}
|
|
1497
|
-
*/
|
|
1498
|
-
observer => {
|
|
1499
|
-
/** @type {?} */
|
|
723
|
+
super(observer => {
|
|
1500
724
|
const childSubscription = sharedInternalActions$.subscribe({
|
|
1501
|
-
next: (
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
*/
|
|
1505
|
-
ctx => observer.next(ctx)),
|
|
1506
|
-
error: (/**
|
|
1507
|
-
* @param {?} error
|
|
1508
|
-
* @return {?}
|
|
1509
|
-
*/
|
|
1510
|
-
error => observer.error(error)),
|
|
1511
|
-
complete: (/**
|
|
1512
|
-
* @return {?}
|
|
1513
|
-
*/
|
|
1514
|
-
() => observer.complete())
|
|
725
|
+
next: ctx => observer.next(ctx),
|
|
726
|
+
error: error => observer.error(error),
|
|
727
|
+
complete: () => observer.complete()
|
|
1515
728
|
});
|
|
1516
729
|
observer.add(childSubscription);
|
|
1517
|
-
})
|
|
730
|
+
});
|
|
1518
731
|
}
|
|
1519
732
|
}
|
|
1520
|
-
Actions
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
{ type: InternalActions },
|
|
1526
|
-
{ type: InternalNgxsExecutionStrategy }
|
|
1527
|
-
];
|
|
733
|
+
/** @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 });
|
|
734
|
+
/** @nocollapse */ Actions.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: Actions });
|
|
735
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: Actions, decorators: [{
|
|
736
|
+
type: Injectable
|
|
737
|
+
}], ctorParameters: function () { return [{ type: InternalActions }, { type: InternalNgxsExecutionStrategy }]; } });
|
|
1528
738
|
|
|
1529
|
-
/**
|
|
1530
|
-
* @fileoverview added by tsickle
|
|
1531
|
-
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
1532
|
-
*/
|
|
1533
739
|
/**
|
|
1534
740
|
* Composes a array of functions from left to right. Example:
|
|
1535
741
|
*
|
|
@@ -1550,30 +756,12 @@ Actions.ctorParameters = () => [
|
|
|
1550
756
|
* the last function should not call `next`.
|
|
1551
757
|
*
|
|
1552
758
|
* @ignore
|
|
1553
|
-
* @type {?}
|
|
1554
|
-
*/
|
|
1555
|
-
const compose = (/**
|
|
1556
|
-
* @param {?} funcs
|
|
1557
|
-
* @return {?}
|
|
1558
759
|
*/
|
|
1559
|
-
(funcs) => (
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
(...args) => {
|
|
1564
|
-
/** @type {?} */
|
|
1565
|
-
const curr = (/** @type {?} */ (funcs.shift()));
|
|
1566
|
-
return curr(...args, (/**
|
|
1567
|
-
* @param {...?} nextArgs
|
|
1568
|
-
* @return {?}
|
|
1569
|
-
*/
|
|
1570
|
-
(...nextArgs) => compose(funcs)(...nextArgs)));
|
|
1571
|
-
}));
|
|
760
|
+
const compose = (funcs) => (...args) => {
|
|
761
|
+
const curr = funcs.shift();
|
|
762
|
+
return curr(...args, (...nextArgs) => compose(funcs)(...nextArgs));
|
|
763
|
+
};
|
|
1572
764
|
|
|
1573
|
-
/**
|
|
1574
|
-
* @fileoverview added by tsickle
|
|
1575
|
-
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
1576
|
-
*/
|
|
1577
765
|
/**
|
|
1578
766
|
* This operator is used for piping the observable result
|
|
1579
767
|
* from the `dispatch()`. It has a "smart" error handling
|
|
@@ -1585,69 +773,34 @@ const compose = (/**
|
|
|
1585
773
|
* 3) `store.dispatch().subscribe({ error: ... })` -> don't call `handleError()`
|
|
1586
774
|
* 4) `toPromise()` without `catch` -> do `handleError()`
|
|
1587
775
|
* 5) `toPromise()` with `catch` -> don't `handleError()`
|
|
1588
|
-
* @template T
|
|
1589
|
-
* @param {?} internalErrorReporter
|
|
1590
|
-
* @param {?} ngxsExecutionStrategy
|
|
1591
|
-
* @return {?}
|
|
1592
776
|
*/
|
|
1593
777
|
function ngxsErrorHandler(internalErrorReporter, ngxsExecutionStrategy) {
|
|
1594
|
-
return (
|
|
1595
|
-
* @param {?} source
|
|
1596
|
-
* @return {?}
|
|
1597
|
-
*/
|
|
1598
|
-
(source) => {
|
|
1599
|
-
/** @type {?} */
|
|
778
|
+
return (source) => {
|
|
1600
779
|
let subscribed = false;
|
|
1601
780
|
source.subscribe({
|
|
1602
|
-
error:
|
|
1603
|
-
* @param {?} error
|
|
1604
|
-
* @return {?}
|
|
1605
|
-
*/
|
|
1606
|
-
error => {
|
|
781
|
+
error: error => {
|
|
1607
782
|
// Do not trigger change detection for a microtask. This depends on the execution
|
|
1608
783
|
// strategy being used, but the default `DispatchOutsideZoneNgxsExecutionStrategy`
|
|
1609
784
|
// leaves the Angular zone.
|
|
1610
|
-
ngxsExecutionStrategy.enter((
|
|
1611
|
-
* @return {?}
|
|
1612
|
-
*/
|
|
1613
|
-
() => Promise.resolve().then((/**
|
|
1614
|
-
* @return {?}
|
|
1615
|
-
*/
|
|
1616
|
-
() => {
|
|
785
|
+
ngxsExecutionStrategy.enter(() => Promise.resolve().then(() => {
|
|
1617
786
|
if (!subscribed) {
|
|
1618
|
-
ngxsExecutionStrategy.leave((
|
|
1619
|
-
* @return {?}
|
|
1620
|
-
*/
|
|
1621
|
-
() => internalErrorReporter.reportErrorSafely(error)));
|
|
787
|
+
ngxsExecutionStrategy.leave(() => internalErrorReporter.reportErrorSafely(error));
|
|
1622
788
|
}
|
|
1623
|
-
}))
|
|
1624
|
-
}
|
|
789
|
+
}));
|
|
790
|
+
}
|
|
1625
791
|
});
|
|
1626
|
-
return new Observable(
|
|
1627
|
-
* @param {?} subscriber
|
|
1628
|
-
* @return {?}
|
|
1629
|
-
*/
|
|
1630
|
-
subscriber => {
|
|
792
|
+
return new Observable(subscriber => {
|
|
1631
793
|
subscribed = true;
|
|
1632
794
|
return source.pipe(leaveNgxs(ngxsExecutionStrategy)).subscribe(subscriber);
|
|
1633
|
-
})
|
|
1634
|
-
}
|
|
795
|
+
});
|
|
796
|
+
};
|
|
1635
797
|
}
|
|
1636
798
|
class InternalErrorReporter {
|
|
1637
|
-
/**
|
|
1638
|
-
* @param {?} _injector
|
|
1639
|
-
*/
|
|
1640
799
|
constructor(_injector) {
|
|
1641
800
|
this._injector = _injector;
|
|
1642
|
-
/**
|
|
1643
|
-
|
|
1644
|
-
*/
|
|
1645
|
-
this._errorHandler = (/** @type {?} */ (null));
|
|
801
|
+
/** Will be set lazily to be backward compatible. */
|
|
802
|
+
this._errorHandler = null;
|
|
1646
803
|
}
|
|
1647
|
-
/**
|
|
1648
|
-
* @param {?} error
|
|
1649
|
-
* @return {?}
|
|
1650
|
-
*/
|
|
1651
804
|
reportErrorSafely(error) {
|
|
1652
805
|
if (this._errorHandler === null) {
|
|
1653
806
|
this._errorHandler = this._injector.get(ErrorHandler);
|
|
@@ -1662,32 +815,13 @@ class InternalErrorReporter {
|
|
|
1662
815
|
catch (_a) { }
|
|
1663
816
|
}
|
|
1664
817
|
}
|
|
1665
|
-
InternalErrorReporter
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
];
|
|
1672
|
-
/** @nocollapse */ InternalErrorReporter.ngInjectableDef = defineInjectable({ factory: function InternalErrorReporter_Factory() { return new InternalErrorReporter(inject(INJECTOR)); }, token: InternalErrorReporter, providedIn: "root" });
|
|
1673
|
-
if (false) {
|
|
1674
|
-
/**
|
|
1675
|
-
* Will be set lazily to be backward compatible.
|
|
1676
|
-
* @type {?}
|
|
1677
|
-
* @private
|
|
1678
|
-
*/
|
|
1679
|
-
InternalErrorReporter.prototype._errorHandler;
|
|
1680
|
-
/**
|
|
1681
|
-
* @type {?}
|
|
1682
|
-
* @private
|
|
1683
|
-
*/
|
|
1684
|
-
InternalErrorReporter.prototype._injector;
|
|
1685
|
-
}
|
|
818
|
+
/** @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 });
|
|
819
|
+
/** @nocollapse */ InternalErrorReporter.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: InternalErrorReporter, providedIn: 'root' });
|
|
820
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: InternalErrorReporter, decorators: [{
|
|
821
|
+
type: Injectable,
|
|
822
|
+
args: [{ providedIn: 'root' }]
|
|
823
|
+
}], ctorParameters: function () { return [{ type: i0.Injector }]; } });
|
|
1686
824
|
|
|
1687
|
-
/**
|
|
1688
|
-
* @fileoverview added by tsickle
|
|
1689
|
-
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
1690
|
-
*/
|
|
1691
825
|
/**
|
|
1692
826
|
* BehaviorSubject of the entire state.
|
|
1693
827
|
* @ignore
|
|
@@ -1696,9 +830,6 @@ class StateStream extends BehaviorSubject {
|
|
|
1696
830
|
constructor() {
|
|
1697
831
|
super({});
|
|
1698
832
|
}
|
|
1699
|
-
/**
|
|
1700
|
-
* @return {?}
|
|
1701
|
-
*/
|
|
1702
833
|
ngOnDestroy() {
|
|
1703
834
|
// The `StateStream` should never emit values once the root view is removed, e.g. when the `NgModuleRef.destroy()` is called.
|
|
1704
835
|
// This will eliminate memory leaks in server-side rendered apps where the `StateStream` is created per each HTTP request, users
|
|
@@ -1706,84 +837,46 @@ class StateStream extends BehaviorSubject {
|
|
|
1706
837
|
this.complete();
|
|
1707
838
|
}
|
|
1708
839
|
}
|
|
1709
|
-
StateStream
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
|
|
840
|
+
/** @nocollapse */ StateStream.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: StateStream, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
841
|
+
/** @nocollapse */ StateStream.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: StateStream });
|
|
842
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: StateStream, decorators: [{
|
|
843
|
+
type: Injectable
|
|
844
|
+
}], ctorParameters: function () { return []; } });
|
|
1714
845
|
|
|
1715
|
-
/**
|
|
1716
|
-
* @fileoverview added by tsickle
|
|
1717
|
-
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
1718
|
-
*/
|
|
1719
846
|
class PluginManager {
|
|
1720
|
-
/**
|
|
1721
|
-
* @param {?} _parentManager
|
|
1722
|
-
* @param {?} _pluginHandlers
|
|
1723
|
-
*/
|
|
1724
847
|
constructor(_parentManager, _pluginHandlers) {
|
|
1725
848
|
this._parentManager = _parentManager;
|
|
1726
849
|
this._pluginHandlers = _pluginHandlers;
|
|
1727
850
|
this.plugins = [];
|
|
1728
851
|
this.registerHandlers();
|
|
1729
852
|
}
|
|
1730
|
-
/**
|
|
1731
|
-
* @private
|
|
1732
|
-
* @return {?}
|
|
1733
|
-
*/
|
|
1734
853
|
get rootPlugins() {
|
|
1735
854
|
return (this._parentManager && this._parentManager.plugins) || this.plugins;
|
|
1736
855
|
}
|
|
1737
|
-
/**
|
|
1738
|
-
* @private
|
|
1739
|
-
* @return {?}
|
|
1740
|
-
*/
|
|
1741
856
|
registerHandlers() {
|
|
1742
|
-
/** @type {?} */
|
|
1743
857
|
const pluginHandlers = this.getPluginHandlers();
|
|
1744
858
|
this.rootPlugins.push(...pluginHandlers);
|
|
1745
859
|
}
|
|
1746
|
-
/**
|
|
1747
|
-
* @private
|
|
1748
|
-
* @return {?}
|
|
1749
|
-
*/
|
|
1750
860
|
getPluginHandlers() {
|
|
1751
|
-
/** @type {?} */
|
|
1752
861
|
const handlers = this._pluginHandlers || [];
|
|
1753
|
-
return handlers.map((
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
PluginManager
|
|
1761
|
-
|
|
1762
|
-
|
|
1763
|
-
|
|
1764
|
-
|
|
1765
|
-
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
|
|
1769
|
-
|
|
1770
|
-
PluginManager.prototype.plugins;
|
|
1771
|
-
/**
|
|
1772
|
-
* @type {?}
|
|
1773
|
-
* @private
|
|
1774
|
-
*/
|
|
1775
|
-
PluginManager.prototype._parentManager;
|
|
1776
|
-
/**
|
|
1777
|
-
* @type {?}
|
|
1778
|
-
* @private
|
|
1779
|
-
*/
|
|
1780
|
-
PluginManager.prototype._pluginHandlers;
|
|
1781
|
-
}
|
|
862
|
+
return handlers.map((plugin) => (plugin.handle ? plugin.handle.bind(plugin) : plugin));
|
|
863
|
+
}
|
|
864
|
+
}
|
|
865
|
+
/** @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 });
|
|
866
|
+
/** @nocollapse */ PluginManager.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: PluginManager });
|
|
867
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: PluginManager, decorators: [{
|
|
868
|
+
type: Injectable
|
|
869
|
+
}], ctorParameters: function () { return [{ type: PluginManager, decorators: [{
|
|
870
|
+
type: Optional
|
|
871
|
+
}, {
|
|
872
|
+
type: SkipSelf
|
|
873
|
+
}] }, { type: undefined, decorators: [{
|
|
874
|
+
type: Inject,
|
|
875
|
+
args: [NGXS_PLUGINS]
|
|
876
|
+
}, {
|
|
877
|
+
type: Optional
|
|
878
|
+
}] }]; } });
|
|
1782
879
|
|
|
1783
|
-
/**
|
|
1784
|
-
* @fileoverview added by tsickle
|
|
1785
|
-
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
1786
|
-
*/
|
|
1787
880
|
/**
|
|
1788
881
|
* Internal Action result stream that is emitted when an action is completed.
|
|
1789
882
|
* This is used as a method of returning the action result to the dispatcher
|
|
@@ -1792,18 +885,12 @@ if (false) {
|
|
|
1792
885
|
*/
|
|
1793
886
|
class InternalDispatchedActionResults extends Subject {
|
|
1794
887
|
}
|
|
1795
|
-
InternalDispatchedActionResults
|
|
1796
|
-
|
|
1797
|
-
|
|
888
|
+
/** @nocollapse */ InternalDispatchedActionResults.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: InternalDispatchedActionResults, deps: null, target: i0.ɵɵFactoryTarget.Injectable });
|
|
889
|
+
/** @nocollapse */ InternalDispatchedActionResults.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: InternalDispatchedActionResults });
|
|
890
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: InternalDispatchedActionResults, decorators: [{
|
|
891
|
+
type: Injectable
|
|
892
|
+
}] });
|
|
1798
893
|
class InternalDispatcher {
|
|
1799
|
-
/**
|
|
1800
|
-
* @param {?} _actions
|
|
1801
|
-
* @param {?} _actionResults
|
|
1802
|
-
* @param {?} _pluginManager
|
|
1803
|
-
* @param {?} _stateStream
|
|
1804
|
-
* @param {?} _ngxsExecutionStrategy
|
|
1805
|
-
* @param {?} _internalErrorReporter
|
|
1806
|
-
*/
|
|
1807
894
|
constructor(_actions, _actionResults, _pluginManager, _stateStream, _ngxsExecutionStrategy, _internalErrorReporter) {
|
|
1808
895
|
this._actions = _actions;
|
|
1809
896
|
this._actionResults = _actionResults;
|
|
@@ -1814,102 +901,50 @@ class InternalDispatcher {
|
|
|
1814
901
|
}
|
|
1815
902
|
/**
|
|
1816
903
|
* Dispatches event(s).
|
|
1817
|
-
* @param {?} actionOrActions
|
|
1818
|
-
* @return {?}
|
|
1819
904
|
*/
|
|
1820
905
|
dispatch(actionOrActions) {
|
|
1821
|
-
|
|
1822
|
-
const result = this._ngxsExecutionStrategy.enter((/**
|
|
1823
|
-
* @return {?}
|
|
1824
|
-
*/
|
|
1825
|
-
() => this.dispatchByEvents(actionOrActions)));
|
|
906
|
+
const result = this._ngxsExecutionStrategy.enter(() => this.dispatchByEvents(actionOrActions));
|
|
1826
907
|
return result.pipe(ngxsErrorHandler(this._internalErrorReporter, this._ngxsExecutionStrategy));
|
|
1827
908
|
}
|
|
1828
|
-
/**
|
|
1829
|
-
* @private
|
|
1830
|
-
* @param {?} actionOrActions
|
|
1831
|
-
* @return {?}
|
|
1832
|
-
*/
|
|
1833
909
|
dispatchByEvents(actionOrActions) {
|
|
1834
910
|
if (Array.isArray(actionOrActions)) {
|
|
1835
911
|
if (actionOrActions.length === 0)
|
|
1836
912
|
return of(this._stateStream.getValue());
|
|
1837
|
-
return forkJoin(actionOrActions.map((
|
|
1838
|
-
* @param {?} action
|
|
1839
|
-
* @return {?}
|
|
1840
|
-
*/
|
|
1841
|
-
action => this.dispatchSingle(action))));
|
|
913
|
+
return forkJoin(actionOrActions.map(action => this.dispatchSingle(action)));
|
|
1842
914
|
}
|
|
1843
915
|
else {
|
|
1844
916
|
return this.dispatchSingle(actionOrActions);
|
|
1845
917
|
}
|
|
1846
918
|
}
|
|
1847
|
-
/**
|
|
1848
|
-
* @private
|
|
1849
|
-
* @param {?} action
|
|
1850
|
-
* @return {?}
|
|
1851
|
-
*/
|
|
1852
919
|
dispatchSingle(action) {
|
|
1853
920
|
if (typeof ngDevMode === 'undefined' || ngDevMode) {
|
|
1854
|
-
/** @type {?} */
|
|
1855
921
|
const type = getActionTypeFromInstance(action);
|
|
1856
922
|
if (!type) {
|
|
1857
|
-
/** @type {?} */
|
|
1858
923
|
const error = new Error(`This action doesn't have a type property: ${action.constructor.name}`);
|
|
1859
924
|
return throwError(error);
|
|
1860
925
|
}
|
|
1861
926
|
}
|
|
1862
|
-
/** @type {?} */
|
|
1863
927
|
const prevState = this._stateStream.getValue();
|
|
1864
|
-
/** @type {?} */
|
|
1865
928
|
const plugins = this._pluginManager.plugins;
|
|
1866
|
-
return
|
|
929
|
+
return compose([
|
|
1867
930
|
...plugins,
|
|
1868
|
-
(/**
|
|
1869
|
-
* @param {?} nextState
|
|
1870
|
-
* @param {?} nextAction
|
|
1871
|
-
* @return {?}
|
|
1872
|
-
*/
|
|
1873
931
|
(nextState, nextAction) => {
|
|
1874
932
|
if (nextState !== prevState) {
|
|
1875
933
|
this._stateStream.next(nextState);
|
|
1876
934
|
}
|
|
1877
|
-
/** @type {?} */
|
|
1878
935
|
const actionResult$ = this.getActionResultStream(nextAction);
|
|
1879
|
-
actionResult$.subscribe((
|
|
1880
|
-
* @param {?} ctx
|
|
1881
|
-
* @return {?}
|
|
1882
|
-
*/
|
|
1883
|
-
ctx => this._actions.next(ctx)));
|
|
936
|
+
actionResult$.subscribe(ctx => this._actions.next(ctx));
|
|
1884
937
|
this._actions.next({ action: nextAction, status: "DISPATCHED" /* Dispatched */ });
|
|
1885
938
|
return this.createDispatchObservable(actionResult$);
|
|
1886
|
-
}
|
|
1887
|
-
])(prevState, action)
|
|
939
|
+
}
|
|
940
|
+
])(prevState, action).pipe(shareReplay());
|
|
1888
941
|
}
|
|
1889
|
-
/**
|
|
1890
|
-
* @private
|
|
1891
|
-
* @param {?} action
|
|
1892
|
-
* @return {?}
|
|
1893
|
-
*/
|
|
1894
942
|
getActionResultStream(action) {
|
|
1895
|
-
return this._actionResults.pipe(filter((
|
|
1896
|
-
* @param {?} ctx
|
|
1897
|
-
* @return {?}
|
|
1898
|
-
*/
|
|
1899
|
-
(ctx) => ctx.action === action && ctx.status !== "DISPATCHED" /* Dispatched */)), take(1), shareReplay());
|
|
943
|
+
return this._actionResults.pipe(filter((ctx) => ctx.action === action && ctx.status !== "DISPATCHED" /* Dispatched */), take(1), shareReplay());
|
|
1900
944
|
}
|
|
1901
|
-
/**
|
|
1902
|
-
* @private
|
|
1903
|
-
* @param {?} actionResult$
|
|
1904
|
-
* @return {?}
|
|
1905
|
-
*/
|
|
1906
945
|
createDispatchObservable(actionResult$) {
|
|
1907
946
|
return actionResult$
|
|
1908
|
-
.pipe(exhaustMap((
|
|
1909
|
-
* @param {?} ctx
|
|
1910
|
-
* @return {?}
|
|
1911
|
-
*/
|
|
1912
|
-
(ctx) => {
|
|
947
|
+
.pipe(exhaustMap((ctx) => {
|
|
1913
948
|
switch (ctx.status) {
|
|
1914
949
|
case "SUCCESSFUL" /* Successful */:
|
|
1915
950
|
return of(this._stateStream.getValue());
|
|
@@ -1918,79 +953,25 @@ class InternalDispatcher {
|
|
|
1918
953
|
default:
|
|
1919
954
|
return EMPTY;
|
|
1920
955
|
}
|
|
1921
|
-
}))
|
|
956
|
+
}))
|
|
1922
957
|
.pipe(shareReplay());
|
|
1923
958
|
}
|
|
1924
959
|
}
|
|
1925
|
-
InternalDispatcher
|
|
1926
|
-
|
|
1927
|
-
|
|
1928
|
-
|
|
1929
|
-
|
|
1930
|
-
{ type: InternalActions },
|
|
1931
|
-
{ type: InternalDispatchedActionResults },
|
|
1932
|
-
{ type: PluginManager },
|
|
1933
|
-
{ type: StateStream },
|
|
1934
|
-
{ type: InternalNgxsExecutionStrategy },
|
|
1935
|
-
{ type: InternalErrorReporter }
|
|
1936
|
-
];
|
|
1937
|
-
if (false) {
|
|
1938
|
-
/**
|
|
1939
|
-
* @type {?}
|
|
1940
|
-
* @private
|
|
1941
|
-
*/
|
|
1942
|
-
InternalDispatcher.prototype._actions;
|
|
1943
|
-
/**
|
|
1944
|
-
* @type {?}
|
|
1945
|
-
* @private
|
|
1946
|
-
*/
|
|
1947
|
-
InternalDispatcher.prototype._actionResults;
|
|
1948
|
-
/**
|
|
1949
|
-
* @type {?}
|
|
1950
|
-
* @private
|
|
1951
|
-
*/
|
|
1952
|
-
InternalDispatcher.prototype._pluginManager;
|
|
1953
|
-
/**
|
|
1954
|
-
* @type {?}
|
|
1955
|
-
* @private
|
|
1956
|
-
*/
|
|
1957
|
-
InternalDispatcher.prototype._stateStream;
|
|
1958
|
-
/**
|
|
1959
|
-
* @type {?}
|
|
1960
|
-
* @private
|
|
1961
|
-
*/
|
|
1962
|
-
InternalDispatcher.prototype._ngxsExecutionStrategy;
|
|
1963
|
-
/**
|
|
1964
|
-
* @type {?}
|
|
1965
|
-
* @private
|
|
1966
|
-
*/
|
|
1967
|
-
InternalDispatcher.prototype._internalErrorReporter;
|
|
1968
|
-
}
|
|
960
|
+
/** @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 });
|
|
961
|
+
/** @nocollapse */ InternalDispatcher.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: InternalDispatcher });
|
|
962
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: InternalDispatcher, decorators: [{
|
|
963
|
+
type: Injectable
|
|
964
|
+
}], ctorParameters: function () { return [{ type: InternalActions }, { type: InternalDispatchedActionResults }, { type: PluginManager }, { type: StateStream }, { type: InternalNgxsExecutionStrategy }, { type: InternalErrorReporter }]; } });
|
|
1969
965
|
|
|
1970
|
-
/**
|
|
1971
|
-
* @fileoverview added by tsickle
|
|
1972
|
-
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
1973
|
-
*/
|
|
1974
966
|
/**
|
|
1975
967
|
* Object freeze code
|
|
1976
968
|
* https://github.com/jsdf/deep-freeze
|
|
1977
|
-
* @type {?}
|
|
1978
|
-
*/
|
|
1979
|
-
const deepFreeze = (/**
|
|
1980
|
-
* @param {?} o
|
|
1981
|
-
* @return {?}
|
|
1982
969
|
*/
|
|
1983
|
-
(o) => {
|
|
970
|
+
const deepFreeze = (o) => {
|
|
1984
971
|
Object.freeze(o);
|
|
1985
|
-
/** @type {?} */
|
|
1986
972
|
const oIsFunction = typeof o === 'function';
|
|
1987
|
-
/** @type {?} */
|
|
1988
973
|
const hasOwnProp = Object.prototype.hasOwnProperty;
|
|
1989
|
-
Object.getOwnPropertyNames(o).forEach((
|
|
1990
|
-
* @param {?} prop
|
|
1991
|
-
* @return {?}
|
|
1992
|
-
*/
|
|
1993
|
-
function (prop) {
|
|
974
|
+
Object.getOwnPropertyNames(o).forEach(function (prop) {
|
|
1994
975
|
if (hasOwnProp.call(o, prop) &&
|
|
1995
976
|
(oIsFunction ? prop !== 'caller' && prop !== 'callee' && prop !== 'arguments' : true) &&
|
|
1996
977
|
o[prop] !== null &&
|
|
@@ -1998,24 +979,15 @@ const deepFreeze = (/**
|
|
|
1998
979
|
!Object.isFrozen(o[prop])) {
|
|
1999
980
|
deepFreeze(o[prop]);
|
|
2000
981
|
}
|
|
2001
|
-
})
|
|
982
|
+
});
|
|
2002
983
|
return o;
|
|
2003
|
-
}
|
|
984
|
+
};
|
|
2004
985
|
|
|
2005
|
-
/**
|
|
2006
|
-
* @fileoverview added by tsickle
|
|
2007
|
-
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
2008
|
-
*/
|
|
2009
986
|
/**
|
|
2010
987
|
* State Context factory class
|
|
2011
988
|
* @ignore
|
|
2012
989
|
*/
|
|
2013
990
|
class InternalStateOperations {
|
|
2014
|
-
/**
|
|
2015
|
-
* @param {?} _stateStream
|
|
2016
|
-
* @param {?} _dispatcher
|
|
2017
|
-
* @param {?} _config
|
|
2018
|
-
*/
|
|
2019
991
|
constructor(_stateStream, _dispatcher, _config) {
|
|
2020
992
|
this._stateStream = _stateStream;
|
|
2021
993
|
this._dispatcher = _dispatcher;
|
|
@@ -2023,25 +995,12 @@ class InternalStateOperations {
|
|
|
2023
995
|
}
|
|
2024
996
|
/**
|
|
2025
997
|
* Returns the root state operators.
|
|
2026
|
-
* @return {?}
|
|
2027
998
|
*/
|
|
2028
999
|
getRootStateOperations() {
|
|
2029
|
-
/** @type {?} */
|
|
2030
1000
|
const rootStateOperations = {
|
|
2031
|
-
getState: (
|
|
2032
|
-
|
|
2033
|
-
|
|
2034
|
-
() => this._stateStream.getValue()),
|
|
2035
|
-
setState: (/**
|
|
2036
|
-
* @param {?} newState
|
|
2037
|
-
* @return {?}
|
|
2038
|
-
*/
|
|
2039
|
-
(newState) => this._stateStream.next(newState)),
|
|
2040
|
-
dispatch: (/**
|
|
2041
|
-
* @param {?} actionOrActions
|
|
2042
|
-
* @return {?}
|
|
2043
|
-
*/
|
|
2044
|
-
(actionOrActions) => this._dispatcher.dispatch(actionOrActions))
|
|
1001
|
+
getState: () => this._stateStream.getValue(),
|
|
1002
|
+
setState: (newState) => this._stateStream.next(newState),
|
|
1003
|
+
dispatch: (actionOrActions) => this._dispatcher.dispatch(actionOrActions)
|
|
2045
1004
|
};
|
|
2046
1005
|
if (typeof ngDevMode === 'undefined' || ngDevMode) {
|
|
2047
1006
|
return this._config.developmentMode
|
|
@@ -2052,145 +1011,67 @@ class InternalStateOperations {
|
|
|
2052
1011
|
return rootStateOperations;
|
|
2053
1012
|
}
|
|
2054
1013
|
}
|
|
2055
|
-
/**
|
|
2056
|
-
* @param {?} results
|
|
2057
|
-
* @return {?}
|
|
2058
|
-
*/
|
|
2059
1014
|
setStateToTheCurrentWithNew(results) {
|
|
2060
|
-
/** @type {?} */
|
|
2061
1015
|
const stateOperations = this.getRootStateOperations();
|
|
2062
1016
|
// Get our current stream
|
|
2063
|
-
/** @type {?} */
|
|
2064
1017
|
const currentState = stateOperations.getState();
|
|
2065
1018
|
// Set the state to the current + new
|
|
2066
|
-
stateOperations.setState(Object.assign({}, currentState, results.defaults));
|
|
1019
|
+
stateOperations.setState(Object.assign(Object.assign({}, currentState), results.defaults));
|
|
2067
1020
|
}
|
|
2068
1021
|
}
|
|
2069
|
-
InternalStateOperations
|
|
2070
|
-
|
|
2071
|
-
|
|
2072
|
-
|
|
2073
|
-
|
|
2074
|
-
{ type: StateStream },
|
|
2075
|
-
{ type: InternalDispatcher },
|
|
2076
|
-
{ type: NgxsConfig }
|
|
2077
|
-
];
|
|
2078
|
-
if (false) {
|
|
2079
|
-
/**
|
|
2080
|
-
* @type {?}
|
|
2081
|
-
* @private
|
|
2082
|
-
*/
|
|
2083
|
-
InternalStateOperations.prototype._stateStream;
|
|
2084
|
-
/**
|
|
2085
|
-
* @type {?}
|
|
2086
|
-
* @private
|
|
2087
|
-
*/
|
|
2088
|
-
InternalStateOperations.prototype._dispatcher;
|
|
2089
|
-
/**
|
|
2090
|
-
* @type {?}
|
|
2091
|
-
* @private
|
|
2092
|
-
*/
|
|
2093
|
-
InternalStateOperations.prototype._config;
|
|
2094
|
-
}
|
|
2095
|
-
/**
|
|
2096
|
-
* @param {?} root
|
|
2097
|
-
* @return {?}
|
|
2098
|
-
*/
|
|
1022
|
+
/** @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 });
|
|
1023
|
+
/** @nocollapse */ InternalStateOperations.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: InternalStateOperations });
|
|
1024
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: InternalStateOperations, decorators: [{
|
|
1025
|
+
type: Injectable
|
|
1026
|
+
}], ctorParameters: function () { return [{ type: StateStream }, { type: InternalDispatcher }, { type: NgxsConfig }]; } });
|
|
2099
1027
|
function ensureStateAndActionsAreImmutable(root) {
|
|
2100
1028
|
return {
|
|
2101
|
-
getState: (
|
|
2102
|
-
|
|
2103
|
-
*/
|
|
2104
|
-
() => root.getState()),
|
|
2105
|
-
setState: (/**
|
|
2106
|
-
* @param {?} value
|
|
2107
|
-
* @return {?}
|
|
2108
|
-
*/
|
|
2109
|
-
value => {
|
|
2110
|
-
/** @type {?} */
|
|
1029
|
+
getState: () => root.getState(),
|
|
1030
|
+
setState: value => {
|
|
2111
1031
|
const frozenValue = deepFreeze(value);
|
|
2112
1032
|
return root.setState(frozenValue);
|
|
2113
|
-
}
|
|
2114
|
-
dispatch:
|
|
2115
|
-
* @param {?} actions
|
|
2116
|
-
* @return {?}
|
|
2117
|
-
*/
|
|
2118
|
-
actions => {
|
|
1033
|
+
},
|
|
1034
|
+
dispatch: actions => {
|
|
2119
1035
|
return root.dispatch(actions);
|
|
2120
|
-
}
|
|
1036
|
+
}
|
|
2121
1037
|
};
|
|
2122
1038
|
}
|
|
2123
1039
|
|
|
2124
|
-
/**
|
|
2125
|
-
* @fileoverview added by tsickle
|
|
2126
|
-
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
2127
|
-
*/
|
|
2128
|
-
/**
|
|
2129
|
-
* @template T
|
|
2130
|
-
* @param {?} val
|
|
2131
|
-
* @return {?}
|
|
2132
|
-
*/
|
|
2133
1040
|
function simplePatch(val) {
|
|
2134
|
-
return (
|
|
2135
|
-
* @param {?} existingState
|
|
2136
|
-
* @return {?}
|
|
2137
|
-
*/
|
|
2138
|
-
(existingState) => {
|
|
1041
|
+
return (existingState) => {
|
|
2139
1042
|
if (Array.isArray(val)) {
|
|
2140
1043
|
throwPatchingArrayError();
|
|
2141
1044
|
}
|
|
2142
1045
|
else if (typeof val !== 'object') {
|
|
2143
1046
|
throwPatchingPrimitiveError();
|
|
2144
1047
|
}
|
|
2145
|
-
|
|
2146
|
-
const newState = Object.assign({}, ((/** @type {?} */ (existingState))));
|
|
1048
|
+
const newState = Object.assign({}, existingState);
|
|
2147
1049
|
for (const key in val) {
|
|
2148
1050
|
// deep clone for patch compatibility
|
|
2149
1051
|
// noinspection JSUnfilteredForInLoop (IDE)
|
|
2150
|
-
newState[key] =
|
|
1052
|
+
newState[key] = val[key];
|
|
2151
1053
|
}
|
|
2152
|
-
return
|
|
2153
|
-
}
|
|
1054
|
+
return newState;
|
|
1055
|
+
};
|
|
2154
1056
|
}
|
|
2155
1057
|
|
|
2156
|
-
/**
|
|
2157
|
-
* @fileoverview added by tsickle
|
|
2158
|
-
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
2159
|
-
*/
|
|
2160
1058
|
/**
|
|
2161
1059
|
* State Context factory class
|
|
2162
1060
|
* @ignore
|
|
2163
1061
|
*/
|
|
2164
1062
|
class StateContextFactory {
|
|
2165
|
-
/**
|
|
2166
|
-
* @param {?} _internalStateOperations
|
|
2167
|
-
*/
|
|
2168
1063
|
constructor(_internalStateOperations) {
|
|
2169
1064
|
this._internalStateOperations = _internalStateOperations;
|
|
2170
1065
|
}
|
|
2171
1066
|
/**
|
|
2172
1067
|
* Create the state context
|
|
2173
|
-
* @template T
|
|
2174
|
-
* @param {?} mappedStore
|
|
2175
|
-
* @return {?}
|
|
2176
1068
|
*/
|
|
2177
1069
|
createStateContext(mappedStore) {
|
|
2178
|
-
/** @type {?} */
|
|
2179
1070
|
const root = this._internalStateOperations.getRootStateOperations();
|
|
2180
|
-
/**
|
|
2181
|
-
* @param {?} currentAppState
|
|
2182
|
-
* @return {?}
|
|
2183
|
-
*/
|
|
2184
1071
|
function getState(currentAppState) {
|
|
2185
1072
|
return getValue(currentAppState, mappedStore.path);
|
|
2186
1073
|
}
|
|
2187
|
-
/**
|
|
2188
|
-
* @param {?} currentAppState
|
|
2189
|
-
* @param {?} newValue
|
|
2190
|
-
* @return {?}
|
|
2191
|
-
*/
|
|
2192
1074
|
function setStateValue(currentAppState, newValue) {
|
|
2193
|
-
/** @type {?} */
|
|
2194
1075
|
const newAppState = setValue(currentAppState, mappedStore.path, newValue);
|
|
2195
1076
|
root.setState(newAppState);
|
|
2196
1077
|
return newAppState;
|
|
@@ -2201,93 +1082,43 @@ class StateContextFactory {
|
|
|
2201
1082
|
// This needs to be fixed, but is a 'breaking' change.
|
|
2202
1083
|
// I will do this fix in a subsequent PR and we can decide how to handle it.
|
|
2203
1084
|
}
|
|
2204
|
-
/**
|
|
2205
|
-
* @param {?} currentAppState
|
|
2206
|
-
* @param {?} stateOperator
|
|
2207
|
-
* @return {?}
|
|
2208
|
-
*/
|
|
2209
1085
|
function setStateFromOperator(currentAppState, stateOperator) {
|
|
2210
|
-
/** @type {?} */
|
|
2211
1086
|
const local = getState(currentAppState);
|
|
2212
|
-
|
|
2213
|
-
const newValue = stateOperator((/** @type {?} */ (local)));
|
|
1087
|
+
const newValue = stateOperator(local);
|
|
2214
1088
|
return setStateValue(currentAppState, newValue);
|
|
2215
1089
|
}
|
|
2216
|
-
/**
|
|
2217
|
-
* @param {?} value
|
|
2218
|
-
* @return {?}
|
|
2219
|
-
*/
|
|
2220
1090
|
function isStateOperator(value) {
|
|
2221
1091
|
return typeof value === 'function';
|
|
2222
1092
|
}
|
|
2223
1093
|
return {
|
|
2224
|
-
/**
|
|
2225
|
-
* @return {?}
|
|
2226
|
-
*/
|
|
2227
1094
|
getState() {
|
|
2228
|
-
/** @type {?} */
|
|
2229
1095
|
const currentAppState = root.getState();
|
|
2230
1096
|
return getState(currentAppState);
|
|
2231
1097
|
},
|
|
2232
|
-
/**
|
|
2233
|
-
* @param {?} val
|
|
2234
|
-
* @return {?}
|
|
2235
|
-
*/
|
|
2236
1098
|
patchState(val) {
|
|
2237
|
-
/** @type {?} */
|
|
2238
1099
|
const currentAppState = root.getState();
|
|
2239
|
-
/** @type {?} */
|
|
2240
1100
|
const patchOperator = simplePatch(val);
|
|
2241
1101
|
return setStateFromOperator(currentAppState, patchOperator);
|
|
2242
1102
|
},
|
|
2243
|
-
/**
|
|
2244
|
-
* @param {?} val
|
|
2245
|
-
* @return {?}
|
|
2246
|
-
*/
|
|
2247
1103
|
setState(val) {
|
|
2248
|
-
/** @type {?} */
|
|
2249
1104
|
const currentAppState = root.getState();
|
|
2250
1105
|
return isStateOperator(val)
|
|
2251
1106
|
? setStateFromOperator(currentAppState, val)
|
|
2252
1107
|
: setStateValue(currentAppState, val);
|
|
2253
1108
|
},
|
|
2254
|
-
/**
|
|
2255
|
-
* @param {?} actions
|
|
2256
|
-
* @return {?}
|
|
2257
|
-
*/
|
|
2258
1109
|
dispatch(actions) {
|
|
2259
1110
|
return root.dispatch(actions);
|
|
2260
1111
|
}
|
|
2261
1112
|
};
|
|
2262
1113
|
}
|
|
2263
1114
|
}
|
|
2264
|
-
StateContextFactory
|
|
2265
|
-
|
|
2266
|
-
|
|
2267
|
-
|
|
2268
|
-
|
|
2269
|
-
{ type: InternalStateOperations }
|
|
2270
|
-
];
|
|
2271
|
-
if (false) {
|
|
2272
|
-
/**
|
|
2273
|
-
* @type {?}
|
|
2274
|
-
* @private
|
|
2275
|
-
*/
|
|
2276
|
-
StateContextFactory.prototype._internalStateOperations;
|
|
2277
|
-
}
|
|
1115
|
+
/** @nocollapse */ StateContextFactory.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: StateContextFactory, deps: [{ token: InternalStateOperations }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
1116
|
+
/** @nocollapse */ StateContextFactory.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: StateContextFactory });
|
|
1117
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: StateContextFactory, decorators: [{
|
|
1118
|
+
type: Injectable
|
|
1119
|
+
}], ctorParameters: function () { return [{ type: InternalStateOperations }]; } });
|
|
2278
1120
|
|
|
2279
|
-
/**
|
|
2280
|
-
* @fileoverview added by tsickle
|
|
2281
|
-
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
2282
|
-
*/
|
|
2283
|
-
/**
|
|
2284
|
-
* @abstract
|
|
2285
|
-
*/
|
|
2286
1121
|
class StoreValidators {
|
|
2287
|
-
/**
|
|
2288
|
-
* @param {?} name
|
|
2289
|
-
* @return {?}
|
|
2290
|
-
*/
|
|
2291
1122
|
static checkThatStateIsNamedCorrectly(name) {
|
|
2292
1123
|
if (!name) {
|
|
2293
1124
|
throwStateNamePropertyError();
|
|
@@ -2296,81 +1127,43 @@ class StoreValidators {
|
|
|
2296
1127
|
throwStateNameError(name);
|
|
2297
1128
|
}
|
|
2298
1129
|
}
|
|
2299
|
-
/**
|
|
2300
|
-
* @param {?} stateName
|
|
2301
|
-
* @param {?} state
|
|
2302
|
-
* @param {?} statesByName
|
|
2303
|
-
* @return {?}
|
|
2304
|
-
*/
|
|
2305
1130
|
static checkThatStateNameIsUnique(stateName, state, statesByName) {
|
|
2306
|
-
/** @type {?} */
|
|
2307
1131
|
const existingState = statesByName[stateName];
|
|
2308
1132
|
if (existingState && existingState !== state) {
|
|
2309
1133
|
throwStateUniqueError(stateName, state.name, existingState.name);
|
|
2310
1134
|
}
|
|
2311
1135
|
}
|
|
2312
|
-
/**
|
|
2313
|
-
* @param {?} stateClasses
|
|
2314
|
-
* @return {?}
|
|
2315
|
-
*/
|
|
2316
1136
|
static checkThatStateClassesHaveBeenDecorated(stateClasses) {
|
|
2317
|
-
stateClasses.forEach((
|
|
2318
|
-
|
|
2319
|
-
* @return {?}
|
|
2320
|
-
*/
|
|
2321
|
-
(stateClass) => {
|
|
2322
|
-
if (!getStoreMetadata(stateClass)) {
|
|
1137
|
+
stateClasses.forEach((stateClass) => {
|
|
1138
|
+
if (!getStoreMetadata$1(stateClass)) {
|
|
2323
1139
|
throwStateDecoratorError(stateClass.name);
|
|
2324
1140
|
}
|
|
2325
|
-
})
|
|
1141
|
+
});
|
|
2326
1142
|
}
|
|
2327
1143
|
}
|
|
2328
1144
|
StoreValidators.stateNameRegex = new RegExp('^[a-zA-Z0-9_]+$');
|
|
2329
|
-
if (false) {
|
|
2330
|
-
/**
|
|
2331
|
-
* @type {?}
|
|
2332
|
-
* @private
|
|
2333
|
-
*/
|
|
2334
|
-
StoreValidators.stateNameRegex;
|
|
2335
|
-
}
|
|
2336
1145
|
|
|
2337
1146
|
/**
|
|
2338
|
-
*
|
|
2339
|
-
*
|
|
2340
|
-
*/
|
|
2341
|
-
/**
|
|
2342
|
-
* All provided or injected tokens must have `\@Injectable` decorator
|
|
2343
|
-
* (previously, injected tokens without `\@Injectable` were allowed
|
|
1147
|
+
* All provided or injected tokens must have `@Injectable` decorator
|
|
1148
|
+
* (previously, injected tokens without `@Injectable` were allowed
|
|
2344
1149
|
* if another decorator was used, e.g. pipes).
|
|
2345
|
-
* @param {?} stateClass
|
|
2346
|
-
* @return {?}
|
|
2347
1150
|
*/
|
|
2348
1151
|
function ensureStateClassIsInjectable(stateClass) {
|
|
2349
1152
|
// `ɵprov` is a static property added by the NGCC compiler. It always exists in
|
|
2350
1153
|
// AOT mode because this property is added before runtime. If an application is running in
|
|
2351
1154
|
// JIT mode then this property can be added by the `@Injectable()` decorator. The `@Injectable()`
|
|
2352
1155
|
// decorator has to go after the `@State()` decorator, thus we prevent users from unwanted DI errors.
|
|
2353
|
-
|
|
2354
|
-
|
|
2355
|
-
|
|
2356
|
-
|
|
2357
|
-
// Don't warn if Ivy is disabled or `ɵprov` exists on the class
|
|
2358
|
-
console.warn(getUndecoratedStateInIvyWarningMessage(stateClass.name));
|
|
2359
|
-
}
|
|
1156
|
+
const ngInjectableDef = stateClass.ɵprov;
|
|
1157
|
+
if (!ngInjectableDef) {
|
|
1158
|
+
// Don't warn if Ivy is disabled or `ɵprov` exists on the class
|
|
1159
|
+
console.warn(getUndecoratedStateInIvyWarningMessage(stateClass.name));
|
|
2360
1160
|
}
|
|
2361
1161
|
}
|
|
2362
1162
|
|
|
2363
|
-
/**
|
|
2364
|
-
* @fileoverview added by tsickle
|
|
2365
|
-
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
2366
|
-
*/
|
|
2367
1163
|
/**
|
|
2368
1164
|
* Init action
|
|
2369
1165
|
*/
|
|
2370
1166
|
class InitState {
|
|
2371
|
-
/**
|
|
2372
|
-
* @return {?}
|
|
2373
|
-
*/
|
|
2374
1167
|
static get type() {
|
|
2375
1168
|
// NOTE: Not necessary to declare the type in this way in your code. See https://github.com/ngxs/store/pull/644#issuecomment-436003138
|
|
2376
1169
|
return '@@INIT';
|
|
@@ -2380,54 +1173,21 @@ class InitState {
|
|
|
2380
1173
|
* Update action
|
|
2381
1174
|
*/
|
|
2382
1175
|
class UpdateState {
|
|
2383
|
-
/**
|
|
2384
|
-
* @param {?=} addedStates
|
|
2385
|
-
*/
|
|
2386
1176
|
constructor(addedStates) {
|
|
2387
1177
|
this.addedStates = addedStates;
|
|
2388
1178
|
}
|
|
2389
|
-
/**
|
|
2390
|
-
* @return {?}
|
|
2391
|
-
*/
|
|
2392
1179
|
static get type() {
|
|
2393
1180
|
// NOTE: Not necessary to declare the type in this way in your code. See https://github.com/ngxs/store/pull/644#issuecomment-436003138
|
|
2394
1181
|
return '@@UPDATE_STATE';
|
|
2395
1182
|
}
|
|
2396
1183
|
}
|
|
2397
|
-
if (false) {
|
|
2398
|
-
/** @type {?} */
|
|
2399
|
-
UpdateState.prototype.addedStates;
|
|
2400
|
-
}
|
|
2401
1184
|
|
|
2402
|
-
/**
|
|
2403
|
-
* @fileoverview added by tsickle
|
|
2404
|
-
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
2405
|
-
*/
|
|
2406
|
-
/**
|
|
2407
|
-
* @record
|
|
2408
|
-
*/
|
|
2409
|
-
function NgxsDevelopmentOptions() { }
|
|
2410
|
-
if (false) {
|
|
2411
|
-
/** @type {?} */
|
|
2412
|
-
NgxsDevelopmentOptions.prototype.warnOnUnhandledActions;
|
|
2413
|
-
}
|
|
2414
|
-
/** @type {?} */
|
|
2415
1185
|
const NGXS_DEVELOPMENT_OPTIONS = new InjectionToken('NGXS_DEVELOPMENT_OPTIONS', {
|
|
2416
1186
|
providedIn: 'root',
|
|
2417
|
-
factory: (
|
|
2418
|
-
* @return {?}
|
|
2419
|
-
*/
|
|
2420
|
-
() => ({ warnOnUnhandledActions: true }))
|
|
1187
|
+
factory: () => ({ warnOnUnhandledActions: true })
|
|
2421
1188
|
});
|
|
2422
1189
|
|
|
2423
|
-
/**
|
|
2424
|
-
* @fileoverview added by tsickle
|
|
2425
|
-
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
2426
|
-
*/
|
|
2427
1190
|
class NgxsUnhandledActionsLogger {
|
|
2428
|
-
/**
|
|
2429
|
-
* @param {?} options
|
|
2430
|
-
*/
|
|
2431
1191
|
constructor(options) {
|
|
2432
1192
|
/**
|
|
2433
1193
|
* These actions should be ignored by default; the user can increase this
|
|
@@ -2440,26 +1200,15 @@ class NgxsUnhandledActionsLogger {
|
|
|
2440
1200
|
}
|
|
2441
1201
|
/**
|
|
2442
1202
|
* Adds actions to the internal list of actions that should be ignored.
|
|
2443
|
-
* @param {...?} actions
|
|
2444
|
-
* @return {?}
|
|
2445
1203
|
*/
|
|
2446
1204
|
ignoreActions(...actions) {
|
|
2447
1205
|
for (const action of actions) {
|
|
2448
1206
|
this._ignoredActions.add(action.type);
|
|
2449
1207
|
}
|
|
2450
1208
|
}
|
|
2451
|
-
/**
|
|
2452
|
-
* \@internal
|
|
2453
|
-
* @param {?} action
|
|
2454
|
-
* @return {?}
|
|
2455
|
-
*/
|
|
1209
|
+
/** @internal */
|
|
2456
1210
|
warn(action) {
|
|
2457
|
-
|
|
2458
|
-
const actionShouldBeIgnored = Array.from(this._ignoredActions).some((/**
|
|
2459
|
-
* @param {?} type
|
|
2460
|
-
* @return {?}
|
|
2461
|
-
*/
|
|
2462
|
-
type => type === getActionTypeFromInstance(action)));
|
|
1211
|
+
const actionShouldBeIgnored = Array.from(this._ignoredActions).some(type => type === getActionTypeFromInstance(action));
|
|
2463
1212
|
if (actionShouldBeIgnored) {
|
|
2464
1213
|
return;
|
|
2465
1214
|
}
|
|
@@ -2470,41 +1219,20 @@ class NgxsUnhandledActionsLogger {
|
|
|
2470
1219
|
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.`);
|
|
2471
1220
|
}
|
|
2472
1221
|
}
|
|
2473
|
-
NgxsUnhandledActionsLogger
|
|
2474
|
-
|
|
2475
|
-
|
|
2476
|
-
|
|
2477
|
-
|
|
2478
|
-
|
|
2479
|
-
]
|
|
2480
|
-
|
|
2481
|
-
/**
|
|
2482
|
-
* These actions should be ignored by default; the user can increase this
|
|
2483
|
-
* list in the future via the `ignoreActions` method.
|
|
2484
|
-
* @type {?}
|
|
2485
|
-
* @private
|
|
2486
|
-
*/
|
|
2487
|
-
NgxsUnhandledActionsLogger.prototype._ignoredActions;
|
|
2488
|
-
}
|
|
1222
|
+
/** @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 });
|
|
1223
|
+
/** @nocollapse */ NgxsUnhandledActionsLogger.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: NgxsUnhandledActionsLogger });
|
|
1224
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: NgxsUnhandledActionsLogger, decorators: [{
|
|
1225
|
+
type: Injectable
|
|
1226
|
+
}], ctorParameters: function () { return [{ type: undefined, decorators: [{
|
|
1227
|
+
type: Inject,
|
|
1228
|
+
args: [NGXS_DEVELOPMENT_OPTIONS]
|
|
1229
|
+
}] }]; } });
|
|
2489
1230
|
|
|
2490
|
-
/**
|
|
2491
|
-
* @fileoverview added by tsickle
|
|
2492
|
-
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
2493
|
-
*/
|
|
2494
1231
|
/**
|
|
2495
1232
|
* State factory class
|
|
2496
1233
|
* @ignore
|
|
2497
1234
|
*/
|
|
2498
1235
|
class StateFactory {
|
|
2499
|
-
/**
|
|
2500
|
-
* @param {?} _injector
|
|
2501
|
-
* @param {?} _config
|
|
2502
|
-
* @param {?} _parentFactory
|
|
2503
|
-
* @param {?} _actions
|
|
2504
|
-
* @param {?} _actionResults
|
|
2505
|
-
* @param {?} _stateContextFactory
|
|
2506
|
-
* @param {?} _initialState
|
|
2507
|
-
*/
|
|
2508
1236
|
constructor(_injector, _config, _parentFactory, _actions, _actionResults, _stateContextFactory, _initialState) {
|
|
2509
1237
|
this._injector = _injector;
|
|
2510
1238
|
this._config = _config;
|
|
@@ -2517,91 +1245,52 @@ class StateFactory {
|
|
|
2517
1245
|
this._states = [];
|
|
2518
1246
|
this._statesByName = {};
|
|
2519
1247
|
this._statePaths = {};
|
|
2520
|
-
this.getRuntimeSelectorContext = memoize((
|
|
2521
|
-
|
|
2522
|
-
*/
|
|
2523
|
-
() => {
|
|
2524
|
-
/** @type {?} */
|
|
1248
|
+
this.getRuntimeSelectorContext = memoize(() => {
|
|
1249
|
+
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
|
2525
1250
|
const stateFactory = this;
|
|
2526
|
-
/**
|
|
2527
|
-
* @param {?} key
|
|
2528
|
-
* @return {?}
|
|
2529
|
-
*/
|
|
2530
1251
|
function resolveGetter(key) {
|
|
2531
|
-
/** @type {?} */
|
|
2532
1252
|
const path = stateFactory.statePaths[key];
|
|
2533
1253
|
return path ? propGetter(path.split('.'), stateFactory._config) : null;
|
|
2534
1254
|
}
|
|
2535
|
-
/** @type {?} */
|
|
2536
1255
|
const context = this._parentFactory
|
|
2537
1256
|
? this._parentFactory.getRuntimeSelectorContext()
|
|
2538
1257
|
: {
|
|
2539
|
-
/**
|
|
2540
|
-
* @param {?} key
|
|
2541
|
-
* @return {?}
|
|
2542
|
-
*/
|
|
2543
1258
|
getStateGetter(key) {
|
|
2544
|
-
/** @type {?} */
|
|
2545
1259
|
let getter = resolveGetter(key);
|
|
2546
1260
|
if (getter) {
|
|
2547
1261
|
return getter;
|
|
2548
1262
|
}
|
|
2549
|
-
return (
|
|
2550
|
-
* @param {...?} args
|
|
2551
|
-
* @return {?}
|
|
2552
|
-
*/
|
|
2553
|
-
(...args) => {
|
|
1263
|
+
return (...args) => {
|
|
2554
1264
|
// Late loaded getter
|
|
2555
1265
|
if (!getter) {
|
|
2556
1266
|
getter = resolveGetter(key);
|
|
2557
1267
|
}
|
|
2558
1268
|
return getter ? getter(...args) : undefined;
|
|
2559
|
-
}
|
|
1269
|
+
};
|
|
2560
1270
|
},
|
|
2561
|
-
/**
|
|
2562
|
-
* @param {?=} localOptions
|
|
2563
|
-
* @return {?}
|
|
2564
|
-
*/
|
|
2565
1271
|
getSelectorOptions(localOptions) {
|
|
2566
|
-
/** @type {?} */
|
|
2567
1272
|
const globalSelectorOptions = stateFactory._config.selectorOptions;
|
|
2568
|
-
return Object.assign({}, globalSelectorOptions, (localOptions || {}));
|
|
1273
|
+
return Object.assign(Object.assign({}, globalSelectorOptions), (localOptions || {}));
|
|
2569
1274
|
}
|
|
2570
1275
|
};
|
|
2571
1276
|
return context;
|
|
2572
|
-
})
|
|
1277
|
+
});
|
|
2573
1278
|
}
|
|
2574
|
-
/**
|
|
2575
|
-
* @return {?}
|
|
2576
|
-
*/
|
|
2577
1279
|
get states() {
|
|
2578
1280
|
return this._parentFactory ? this._parentFactory.states : this._states;
|
|
2579
1281
|
}
|
|
2580
|
-
/**
|
|
2581
|
-
* @return {?}
|
|
2582
|
-
*/
|
|
2583
1282
|
get statesByName() {
|
|
2584
1283
|
return this._parentFactory ? this._parentFactory.statesByName : this._statesByName;
|
|
2585
1284
|
}
|
|
2586
|
-
/**
|
|
2587
|
-
* @private
|
|
2588
|
-
* @return {?}
|
|
2589
|
-
*/
|
|
2590
1285
|
get statePaths() {
|
|
2591
1286
|
return this._parentFactory ? this._parentFactory.statePaths : this._statePaths;
|
|
2592
1287
|
}
|
|
2593
|
-
/**
|
|
2594
|
-
* @private
|
|
2595
|
-
* @param {?} defaults
|
|
2596
|
-
* @return {?}
|
|
2597
|
-
*/
|
|
2598
1288
|
static cloneDefaults(defaults) {
|
|
2599
|
-
/** @type {?} */
|
|
2600
1289
|
let value = {};
|
|
2601
1290
|
if (Array.isArray(defaults)) {
|
|
2602
1291
|
value = defaults.slice();
|
|
2603
1292
|
}
|
|
2604
|
-
else if (isObject(defaults)) {
|
|
1293
|
+
else if (isObject$1(defaults)) {
|
|
2605
1294
|
value = Object.assign({}, defaults);
|
|
2606
1295
|
}
|
|
2607
1296
|
else if (defaults === undefined) {
|
|
@@ -2612,18 +1301,13 @@ class StateFactory {
|
|
|
2612
1301
|
}
|
|
2613
1302
|
return value;
|
|
2614
1303
|
}
|
|
2615
|
-
/**
|
|
2616
|
-
* @return {?}
|
|
2617
|
-
*/
|
|
2618
1304
|
ngOnDestroy() {
|
|
2619
1305
|
// This is being non-null asserted since `_actionsSubscrition` is
|
|
2620
1306
|
// initialized within the constructor.
|
|
2621
|
-
|
|
1307
|
+
this._actionsSubscription.unsubscribe();
|
|
2622
1308
|
}
|
|
2623
1309
|
/**
|
|
2624
1310
|
* Add a new state to the global defs.
|
|
2625
|
-
* @param {?} stateClasses
|
|
2626
|
-
* @return {?}
|
|
2627
1311
|
*/
|
|
2628
1312
|
add(stateClasses) {
|
|
2629
1313
|
// Caretaker note: we have still left the `typeof` condition in order to avoid
|
|
@@ -2634,23 +1318,15 @@ class StateFactory {
|
|
|
2634
1318
|
const { newStates } = this.addToStatesMap(stateClasses);
|
|
2635
1319
|
if (!newStates.length)
|
|
2636
1320
|
return [];
|
|
2637
|
-
/** @type {?} */
|
|
2638
1321
|
const stateGraph = buildGraph(newStates);
|
|
2639
|
-
/** @type {?} */
|
|
2640
1322
|
const sortedStates = topologicalSort(stateGraph);
|
|
2641
|
-
/** @type {?} */
|
|
2642
1323
|
const paths = findFullParentPath(stateGraph);
|
|
2643
|
-
/** @type {?} */
|
|
2644
1324
|
const nameGraph = nameToState(newStates);
|
|
2645
|
-
/** @type {?} */
|
|
2646
1325
|
const bootstrappedStores = [];
|
|
2647
1326
|
for (const name of sortedStates) {
|
|
2648
|
-
/** @type {?} */
|
|
2649
1327
|
const stateClass = nameGraph[name];
|
|
2650
|
-
/** @type {?} */
|
|
2651
1328
|
const path = paths[name];
|
|
2652
|
-
|
|
2653
|
-
const meta = (/** @type {?} */ (stateClass[META_KEY]));
|
|
1329
|
+
const meta = stateClass[META_KEY];
|
|
2654
1330
|
this.addRuntimeInfoToMeta(meta, path);
|
|
2655
1331
|
// Note: previously we called `ensureStateClassIsInjectable` within the
|
|
2656
1332
|
// `State` decorator. This check is moved here because the `ɵprov` property
|
|
@@ -2659,7 +1335,6 @@ class StateFactory {
|
|
|
2659
1335
|
if (typeof ngDevMode === 'undefined' || ngDevMode) {
|
|
2660
1336
|
ensureStateClassIsInjectable(stateClass);
|
|
2661
1337
|
}
|
|
2662
|
-
/** @type {?} */
|
|
2663
1338
|
const stateMap = {
|
|
2664
1339
|
name,
|
|
2665
1340
|
path,
|
|
@@ -2680,84 +1355,43 @@ class StateFactory {
|
|
|
2680
1355
|
}
|
|
2681
1356
|
/**
|
|
2682
1357
|
* Add a set of states to the store and return the defaults
|
|
2683
|
-
* @param {?} stateClasses
|
|
2684
|
-
* @return {?}
|
|
2685
1358
|
*/
|
|
2686
1359
|
addAndReturnDefaults(stateClasses) {
|
|
2687
|
-
/** @type {?} */
|
|
2688
1360
|
const classes = stateClasses || [];
|
|
2689
|
-
/** @type {?} */
|
|
2690
1361
|
const mappedStores = this.add(classes);
|
|
2691
|
-
|
|
2692
|
-
const defaults = mappedStores.reduce((/**
|
|
2693
|
-
* @param {?} result
|
|
2694
|
-
* @param {?} mappedStore
|
|
2695
|
-
* @return {?}
|
|
2696
|
-
*/
|
|
2697
|
-
(result, mappedStore) => setValue(result, mappedStore.path, mappedStore.defaults)), {});
|
|
1362
|
+
const defaults = mappedStores.reduce((result, mappedStore) => setValue(result, mappedStore.path, mappedStore.defaults), {});
|
|
2698
1363
|
return { defaults, states: mappedStores };
|
|
2699
1364
|
}
|
|
2700
1365
|
/**
|
|
2701
1366
|
* Bind the actions to the handlers
|
|
2702
|
-
* @return {?}
|
|
2703
1367
|
*/
|
|
2704
1368
|
connectActionHandlers() {
|
|
2705
1369
|
if (this._actionsSubscription !== null)
|
|
2706
1370
|
return;
|
|
2707
|
-
/** @type {?} */
|
|
2708
1371
|
const dispatched$ = new Subject();
|
|
2709
1372
|
this._actionsSubscription = this._actions
|
|
2710
|
-
.pipe(filter((
|
|
2711
|
-
* @param {?} ctx
|
|
2712
|
-
* @return {?}
|
|
2713
|
-
*/
|
|
2714
|
-
(ctx) => ctx.status === "DISPATCHED" /* Dispatched */)), mergeMap((/**
|
|
2715
|
-
* @param {?} ctx
|
|
2716
|
-
* @return {?}
|
|
2717
|
-
*/
|
|
2718
|
-
ctx => {
|
|
1373
|
+
.pipe(filter((ctx) => ctx.status === "DISPATCHED" /* Dispatched */), mergeMap(ctx => {
|
|
2719
1374
|
dispatched$.next(ctx);
|
|
2720
|
-
/** @type {?} */
|
|
2721
1375
|
const action = ctx.action;
|
|
2722
|
-
return this.invokeActions(dispatched$, (
|
|
2723
|
-
|
|
2724
|
-
|
|
2725
|
-
() => (/** @type {?} */ ({ action, status: "SUCCESSFUL" /* Successful */ })))), defaultIfEmpty((/** @type {?} */ ({ action, status: "CANCELED" /* Canceled */ }))), catchError((/**
|
|
2726
|
-
* @param {?} error
|
|
2727
|
-
* @return {?}
|
|
2728
|
-
*/
|
|
2729
|
-
error => of((/** @type {?} */ ({ action, status: "ERRORED" /* Errored */, error }))))));
|
|
2730
|
-
})))
|
|
2731
|
-
.subscribe((/**
|
|
2732
|
-
* @param {?} ctx
|
|
2733
|
-
* @return {?}
|
|
2734
|
-
*/
|
|
2735
|
-
ctx => this._actionResults.next(ctx)));
|
|
1376
|
+
return this.invokeActions(dispatched$, action).pipe(map(() => ({ action, status: "SUCCESSFUL" /* Successful */ })), defaultIfEmpty({ action, status: "CANCELED" /* Canceled */ }), catchError(error => of({ action, status: "ERRORED" /* Errored */, error })));
|
|
1377
|
+
}))
|
|
1378
|
+
.subscribe(ctx => this._actionResults.next(ctx));
|
|
2736
1379
|
}
|
|
2737
1380
|
/**
|
|
2738
1381
|
* Invoke actions on the states.
|
|
2739
|
-
* @param {?} dispatched$
|
|
2740
|
-
* @param {?} action
|
|
2741
|
-
* @return {?}
|
|
2742
1382
|
*/
|
|
2743
1383
|
invokeActions(dispatched$, action) {
|
|
2744
|
-
|
|
2745
|
-
const type = (/** @type {?} */ (getActionTypeFromInstance(action)));
|
|
2746
|
-
/** @type {?} */
|
|
1384
|
+
const type = getActionTypeFromInstance(action);
|
|
2747
1385
|
const results = [];
|
|
2748
1386
|
// Determines whether the dispatched action has been handled, this is assigned
|
|
2749
1387
|
// to `true` within the below `for` loop if any `actionMetas` has been found.
|
|
2750
|
-
/** @type {?} */
|
|
2751
1388
|
let actionHasBeenHandled = false;
|
|
2752
1389
|
for (const metadata of this.states) {
|
|
2753
|
-
/** @type {?} */
|
|
2754
1390
|
const actionMetas = metadata.actions[type];
|
|
2755
1391
|
if (actionMetas) {
|
|
2756
1392
|
for (const actionMeta of actionMetas) {
|
|
2757
|
-
/** @type {?} */
|
|
2758
1393
|
const stateContext = this._stateContextFactory.createStateContext(metadata);
|
|
2759
1394
|
try {
|
|
2760
|
-
/** @type {?} */
|
|
2761
1395
|
let result = metadata.instance[actionMeta.fn](stateContext, action);
|
|
2762
1396
|
if (result instanceof Promise) {
|
|
2763
1397
|
result = from(result);
|
|
@@ -2771,11 +1405,7 @@ class StateFactory {
|
|
|
2771
1405
|
// `handler(ctx) { return EMPTY; }`
|
|
2772
1406
|
// then the action will be canceled.
|
|
2773
1407
|
// See https://github.com/ngxs/store/issues/1568
|
|
2774
|
-
result = result.pipe(mergeMap((
|
|
2775
|
-
* @param {?} value
|
|
2776
|
-
* @return {?}
|
|
2777
|
-
*/
|
|
2778
|
-
(value) => {
|
|
1408
|
+
result = result.pipe(mergeMap((value) => {
|
|
2779
1409
|
if (value instanceof Promise) {
|
|
2780
1410
|
return from(value);
|
|
2781
1411
|
}
|
|
@@ -2783,10 +1413,10 @@ class StateFactory {
|
|
|
2783
1413
|
return value;
|
|
2784
1414
|
}
|
|
2785
1415
|
return of(value);
|
|
2786
|
-
})
|
|
1416
|
+
}), defaultIfEmpty({}));
|
|
2787
1417
|
if (actionMeta.options.cancelUncompleted) {
|
|
2788
1418
|
// todo: ofActionDispatched should be used with action class
|
|
2789
|
-
result = result.pipe(takeUntil(dispatched$.pipe(ofActionDispatched(
|
|
1419
|
+
result = result.pipe(takeUntil(dispatched$.pipe(ofActionDispatched(action))));
|
|
2790
1420
|
}
|
|
2791
1421
|
}
|
|
2792
1422
|
else {
|
|
@@ -2804,7 +1434,6 @@ class StateFactory {
|
|
|
2804
1434
|
// The `NgxsUnhandledActionsLogger` is a tree-shakable class which functions
|
|
2805
1435
|
// only during development.
|
|
2806
1436
|
if ((typeof ngDevMode === 'undefined' || ngDevMode) && !actionHasBeenHandled) {
|
|
2807
|
-
/** @type {?} */
|
|
2808
1437
|
const unhandledActionsLogger = this._injector.get(NgxsUnhandledActionsLogger, null);
|
|
2809
1438
|
// The `NgxsUnhandledActionsLogger` will not be resolved by the injector if the
|
|
2810
1439
|
// `NgxsDevelopmentModule` is not provided. It's enough to check whether the `injector.get`
|
|
@@ -2818,25 +1447,16 @@ class StateFactory {
|
|
|
2818
1447
|
}
|
|
2819
1448
|
return forkJoin(results);
|
|
2820
1449
|
}
|
|
2821
|
-
/**
|
|
2822
|
-
* @private
|
|
2823
|
-
* @param {?} stateClasses
|
|
2824
|
-
* @return {?}
|
|
2825
|
-
*/
|
|
2826
1450
|
addToStatesMap(stateClasses) {
|
|
2827
|
-
/** @type {?} */
|
|
2828
1451
|
const newStates = [];
|
|
2829
|
-
/** @type {?} */
|
|
2830
1452
|
const statesMap = this.statesByName;
|
|
2831
1453
|
for (const stateClass of stateClasses) {
|
|
2832
|
-
|
|
2833
|
-
const stateName = (/** @type {?} */ (getStoreMetadata(stateClass).name));
|
|
1454
|
+
const stateName = getStoreMetadata$1(stateClass).name;
|
|
2834
1455
|
// Caretaker note: we have still left the `typeof` condition in order to avoid
|
|
2835
1456
|
// creating a breaking change for projects that still use the View Engine.
|
|
2836
1457
|
if (typeof ngDevMode === 'undefined' || ngDevMode) {
|
|
2837
1458
|
StoreValidators.checkThatStateNameIsUnique(stateName, stateClass, statesMap);
|
|
2838
1459
|
}
|
|
2839
|
-
/** @type {?} */
|
|
2840
1460
|
const unmountedState = !statesMap[stateName];
|
|
2841
1461
|
if (unmountedState) {
|
|
2842
1462
|
newStates.push(stateClass);
|
|
@@ -2845,205 +1465,75 @@ class StateFactory {
|
|
|
2845
1465
|
}
|
|
2846
1466
|
return { newStates };
|
|
2847
1467
|
}
|
|
2848
|
-
/**
|
|
2849
|
-
* @private
|
|
2850
|
-
* @param {?} meta
|
|
2851
|
-
* @param {?} path
|
|
2852
|
-
* @return {?}
|
|
2853
|
-
*/
|
|
2854
1468
|
addRuntimeInfoToMeta(meta, path) {
|
|
2855
|
-
this.statePaths[
|
|
1469
|
+
this.statePaths[meta.name] = path;
|
|
2856
1470
|
// TODO: v4 - we plan to get rid of the path property because it is non-deterministic
|
|
2857
1471
|
// we can do this when we get rid of the incorrectly exposed getStoreMetadata
|
|
2858
1472
|
// We will need to come up with an alternative in v4 because this is used by many plugins
|
|
2859
1473
|
meta.path = path;
|
|
2860
1474
|
}
|
|
2861
1475
|
/**
|
|
2862
|
-
*
|
|
1476
|
+
* @description
|
|
2863
1477
|
* the method checks if the state has already been added to the tree
|
|
2864
1478
|
* and completed the life cycle
|
|
2865
|
-
* @
|
|
2866
|
-
* @param
|
|
2867
|
-
* @param {?} path
|
|
2868
|
-
* @return {?}
|
|
1479
|
+
* @param name
|
|
1480
|
+
* @param path
|
|
2869
1481
|
*/
|
|
2870
1482
|
hasBeenMountedAndBootstrapped(name, path) {
|
|
2871
|
-
/** @type {?} */
|
|
2872
1483
|
const valueIsBootstrappedInInitialState = getValue(this._initialState, path) !== undefined;
|
|
2873
1484
|
return this.statesByName[name] && valueIsBootstrappedInInitialState;
|
|
2874
1485
|
}
|
|
2875
1486
|
}
|
|
2876
|
-
StateFactory
|
|
2877
|
-
|
|
2878
|
-
|
|
2879
|
-
|
|
2880
|
-
|
|
2881
|
-
|
|
2882
|
-
|
|
2883
|
-
|
|
2884
|
-
|
|
2885
|
-
|
|
2886
|
-
|
|
2887
|
-
|
|
2888
|
-
]
|
|
2889
|
-
|
|
2890
|
-
/**
|
|
2891
|
-
* @type {?}
|
|
2892
|
-
* @private
|
|
2893
|
-
*/
|
|
2894
|
-
StateFactory.prototype._actionsSubscription;
|
|
2895
|
-
/**
|
|
2896
|
-
* @type {?}
|
|
2897
|
-
* @private
|
|
2898
|
-
*/
|
|
2899
|
-
StateFactory.prototype._states;
|
|
2900
|
-
/**
|
|
2901
|
-
* @type {?}
|
|
2902
|
-
* @private
|
|
2903
|
-
*/
|
|
2904
|
-
StateFactory.prototype._statesByName;
|
|
2905
|
-
/**
|
|
2906
|
-
* @type {?}
|
|
2907
|
-
* @private
|
|
2908
|
-
*/
|
|
2909
|
-
StateFactory.prototype._statePaths;
|
|
2910
|
-
/** @type {?} */
|
|
2911
|
-
StateFactory.prototype.getRuntimeSelectorContext;
|
|
2912
|
-
/**
|
|
2913
|
-
* @type {?}
|
|
2914
|
-
* @private
|
|
2915
|
-
*/
|
|
2916
|
-
StateFactory.prototype._injector;
|
|
2917
|
-
/**
|
|
2918
|
-
* @type {?}
|
|
2919
|
-
* @private
|
|
2920
|
-
*/
|
|
2921
|
-
StateFactory.prototype._config;
|
|
2922
|
-
/**
|
|
2923
|
-
* @type {?}
|
|
2924
|
-
* @private
|
|
2925
|
-
*/
|
|
2926
|
-
StateFactory.prototype._parentFactory;
|
|
2927
|
-
/**
|
|
2928
|
-
* @type {?}
|
|
2929
|
-
* @private
|
|
2930
|
-
*/
|
|
2931
|
-
StateFactory.prototype._actions;
|
|
2932
|
-
/**
|
|
2933
|
-
* @type {?}
|
|
2934
|
-
* @private
|
|
2935
|
-
*/
|
|
2936
|
-
StateFactory.prototype._actionResults;
|
|
2937
|
-
/**
|
|
2938
|
-
* @type {?}
|
|
2939
|
-
* @private
|
|
2940
|
-
*/
|
|
2941
|
-
StateFactory.prototype._stateContextFactory;
|
|
2942
|
-
/**
|
|
2943
|
-
* @type {?}
|
|
2944
|
-
* @private
|
|
2945
|
-
*/
|
|
2946
|
-
StateFactory.prototype._initialState;
|
|
2947
|
-
}
|
|
1487
|
+
/** @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 });
|
|
1488
|
+
/** @nocollapse */ StateFactory.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: StateFactory });
|
|
1489
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: StateFactory, decorators: [{
|
|
1490
|
+
type: Injectable
|
|
1491
|
+
}], ctorParameters: function () { return [{ type: i0.Injector }, { type: NgxsConfig }, { type: StateFactory, decorators: [{
|
|
1492
|
+
type: Optional
|
|
1493
|
+
}, {
|
|
1494
|
+
type: SkipSelf
|
|
1495
|
+
}] }, { type: InternalActions }, { type: InternalDispatchedActionResults }, { type: StateContextFactory }, { type: undefined, decorators: [{
|
|
1496
|
+
type: Optional
|
|
1497
|
+
}, {
|
|
1498
|
+
type: Inject,
|
|
1499
|
+
args: [INITIAL_STATE_TOKEN]
|
|
1500
|
+
}] }]; } });
|
|
2948
1501
|
|
|
2949
|
-
/**
|
|
2950
|
-
* @fileoverview added by tsickle
|
|
2951
|
-
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
2952
|
-
*/
|
|
2953
|
-
/** @type {?} */
|
|
2954
1502
|
const SELECTOR_OPTIONS_META_KEY = 'NGXS_SELECTOR_OPTIONS_META';
|
|
2955
|
-
/** @type {?} */
|
|
2956
1503
|
const selectorOptionsMetaAccessor = {
|
|
2957
|
-
getOptions: (
|
|
2958
|
-
|
|
2959
|
-
|
|
2960
|
-
|
|
2961
|
-
(target) => {
|
|
2962
|
-
return (target && ((/** @type {?} */ (target)))[SELECTOR_OPTIONS_META_KEY]) || {};
|
|
2963
|
-
}),
|
|
2964
|
-
defineOptions: (/**
|
|
2965
|
-
* @param {?} target
|
|
2966
|
-
* @param {?} options
|
|
2967
|
-
* @return {?}
|
|
2968
|
-
*/
|
|
2969
|
-
(target, options) => {
|
|
1504
|
+
getOptions: (target) => {
|
|
1505
|
+
return (target && target[SELECTOR_OPTIONS_META_KEY]) || {};
|
|
1506
|
+
},
|
|
1507
|
+
defineOptions: (target, options) => {
|
|
2970
1508
|
if (!target)
|
|
2971
1509
|
return;
|
|
2972
|
-
|
|
2973
|
-
}
|
|
1510
|
+
target[SELECTOR_OPTIONS_META_KEY] = options;
|
|
1511
|
+
}
|
|
2974
1512
|
};
|
|
2975
|
-
/**
|
|
2976
|
-
* @record
|
|
2977
|
-
*/
|
|
2978
|
-
function CreationMetadata() { }
|
|
2979
|
-
if (false) {
|
|
2980
|
-
/** @type {?} */
|
|
2981
|
-
CreationMetadata.prototype.containerClass;
|
|
2982
|
-
/** @type {?} */
|
|
2983
|
-
CreationMetadata.prototype.selectorName;
|
|
2984
|
-
/** @type {?|undefined} */
|
|
2985
|
-
CreationMetadata.prototype.getSelectorOptions;
|
|
2986
|
-
}
|
|
2987
|
-
/**
|
|
2988
|
-
* @record
|
|
2989
|
-
*/
|
|
2990
|
-
function RuntimeSelectorInfo() { }
|
|
2991
|
-
if (false) {
|
|
2992
|
-
/** @type {?} */
|
|
2993
|
-
RuntimeSelectorInfo.prototype.selectorOptions;
|
|
2994
|
-
/** @type {?} */
|
|
2995
|
-
RuntimeSelectorInfo.prototype.argumentSelectorFunctions;
|
|
2996
|
-
}
|
|
2997
1513
|
/**
|
|
2998
1514
|
* Function for creating a selector
|
|
2999
|
-
* @
|
|
3000
|
-
* @param
|
|
3001
|
-
* @param
|
|
3002
|
-
* @param {?=} creationMetadata
|
|
3003
|
-
* @return {?}
|
|
1515
|
+
* @param selectors The selectors to use to create the arguments of this function
|
|
1516
|
+
* @param originalFn The original function being made into a selector
|
|
1517
|
+
* @param creationMetadata
|
|
3004
1518
|
*/
|
|
3005
1519
|
function createSelector(selectors, originalFn, creationMetadata) {
|
|
3006
|
-
/** @type {?} */
|
|
3007
1520
|
const containerClass = creationMetadata && creationMetadata.containerClass;
|
|
3008
|
-
|
|
3009
|
-
const wrappedFn = (/** @type {?} */ ((/**
|
|
3010
|
-
* @param {...?} args
|
|
3011
|
-
* @return {?}
|
|
3012
|
-
*/
|
|
3013
|
-
function wrappedSelectorFn(...args) {
|
|
3014
|
-
/** @type {?} */
|
|
1521
|
+
const wrappedFn = function wrappedSelectorFn(...args) {
|
|
3015
1522
|
const returnValue = originalFn.apply(containerClass, args);
|
|
3016
1523
|
if (returnValue instanceof Function) {
|
|
3017
|
-
/** @type {?} */
|
|
3018
1524
|
const innerMemoizedFn = memoize.apply(null, [returnValue]);
|
|
3019
1525
|
return innerMemoizedFn;
|
|
3020
1526
|
}
|
|
3021
1527
|
return returnValue;
|
|
3022
|
-
}
|
|
3023
|
-
/** @type {?} */
|
|
1528
|
+
};
|
|
3024
1529
|
const memoizedFn = memoize(wrappedFn);
|
|
3025
1530
|
Object.setPrototypeOf(memoizedFn, originalFn);
|
|
3026
|
-
/** @type {?} */
|
|
3027
1531
|
const selectorMetaData = setupSelectorMetadata(originalFn, creationMetadata);
|
|
3028
|
-
|
|
3029
|
-
const makeRootSelector = (/**
|
|
3030
|
-
* @param {?} context
|
|
3031
|
-
* @return {?}
|
|
3032
|
-
*/
|
|
3033
|
-
(context) => {
|
|
1532
|
+
const makeRootSelector = (context) => {
|
|
3034
1533
|
const { argumentSelectorFunctions, selectorOptions } = getRuntimeSelectorInfo(context, selectorMetaData, selectors);
|
|
3035
|
-
return (
|
|
3036
|
-
* @param {?} rootState
|
|
3037
|
-
* @return {?}
|
|
3038
|
-
*/
|
|
3039
|
-
function selectFromRoot(rootState) {
|
|
1534
|
+
return function selectFromRoot(rootState) {
|
|
3040
1535
|
// Determine arguments from the app state using the selectors
|
|
3041
|
-
|
|
3042
|
-
const results = argumentSelectorFunctions.map((/**
|
|
3043
|
-
* @param {?} argFn
|
|
3044
|
-
* @return {?}
|
|
3045
|
-
*/
|
|
3046
|
-
argFn => argFn(rootState)));
|
|
1536
|
+
const results = argumentSelectorFunctions.map(argFn => argFn(rootState));
|
|
3047
1537
|
// if the lambda tries to access a something on the
|
|
3048
1538
|
// state that doesn't exist, it will throw a TypeError.
|
|
3049
1539
|
// since this is quite usual behaviour, we simply return undefined if so.
|
|
@@ -3056,91 +1546,47 @@ function createSelector(selectors, originalFn, creationMetadata) {
|
|
|
3056
1546
|
}
|
|
3057
1547
|
throw ex;
|
|
3058
1548
|
}
|
|
3059
|
-
}
|
|
3060
|
-
}
|
|
1549
|
+
};
|
|
1550
|
+
};
|
|
3061
1551
|
selectorMetaData.makeRootSelector = makeRootSelector;
|
|
3062
1552
|
return memoizedFn;
|
|
3063
1553
|
}
|
|
3064
|
-
/**
|
|
3065
|
-
* @template T
|
|
3066
|
-
* @param {?} originalFn
|
|
3067
|
-
* @param {?} creationMetadata
|
|
3068
|
-
* @return {?}
|
|
3069
|
-
*/
|
|
3070
1554
|
function setupSelectorMetadata(originalFn, creationMetadata) {
|
|
3071
|
-
|
|
3072
|
-
const selectorMetaData = ensureSelectorMetadata(originalFn);
|
|
1555
|
+
const selectorMetaData = ensureSelectorMetadata$1(originalFn);
|
|
3073
1556
|
selectorMetaData.originalFn = originalFn;
|
|
3074
|
-
|
|
3075
|
-
let getExplicitSelectorOptions = (/**
|
|
3076
|
-
* @return {?}
|
|
3077
|
-
*/
|
|
3078
|
-
() => ({}));
|
|
1557
|
+
let getExplicitSelectorOptions = () => ({});
|
|
3079
1558
|
if (creationMetadata) {
|
|
3080
1559
|
selectorMetaData.containerClass = creationMetadata.containerClass;
|
|
3081
1560
|
selectorMetaData.selectorName = creationMetadata.selectorName;
|
|
3082
1561
|
getExplicitSelectorOptions =
|
|
3083
1562
|
creationMetadata.getSelectorOptions || getExplicitSelectorOptions;
|
|
3084
1563
|
}
|
|
3085
|
-
/** @type {?} */
|
|
3086
1564
|
const selectorMetaDataClone = Object.assign({}, selectorMetaData);
|
|
3087
|
-
selectorMetaData.getSelectorOptions = (
|
|
3088
|
-
* @return {?}
|
|
3089
|
-
*/
|
|
3090
|
-
() => getLocalSelectorOptions(selectorMetaDataClone, getExplicitSelectorOptions()));
|
|
1565
|
+
selectorMetaData.getSelectorOptions = () => getLocalSelectorOptions(selectorMetaDataClone, getExplicitSelectorOptions());
|
|
3091
1566
|
return selectorMetaData;
|
|
3092
1567
|
}
|
|
3093
|
-
/**
|
|
3094
|
-
* @param {?} context
|
|
3095
|
-
* @param {?} selectorMetaData
|
|
3096
|
-
* @param {?=} selectors
|
|
3097
|
-
* @return {?}
|
|
3098
|
-
*/
|
|
3099
1568
|
function getRuntimeSelectorInfo(context, selectorMetaData, selectors = []) {
|
|
3100
|
-
/** @type {?} */
|
|
3101
1569
|
const localSelectorOptions = selectorMetaData.getSelectorOptions();
|
|
3102
|
-
/** @type {?} */
|
|
3103
1570
|
const selectorOptions = context.getSelectorOptions(localSelectorOptions);
|
|
3104
|
-
/** @type {?} */
|
|
3105
1571
|
const selectorsToApply = getSelectorsToApply(selectors, selectorOptions, selectorMetaData.containerClass);
|
|
3106
|
-
|
|
3107
|
-
const argumentSelectorFunctions = selectorsToApply.map((/**
|
|
3108
|
-
* @param {?} selector
|
|
3109
|
-
* @return {?}
|
|
3110
|
-
*/
|
|
3111
|
-
selector => {
|
|
3112
|
-
/** @type {?} */
|
|
1572
|
+
const argumentSelectorFunctions = selectorsToApply.map(selector => {
|
|
3113
1573
|
const factory = getRootSelectorFactory(selector);
|
|
3114
1574
|
return factory(context);
|
|
3115
|
-
})
|
|
1575
|
+
});
|
|
3116
1576
|
return {
|
|
3117
1577
|
selectorOptions,
|
|
3118
1578
|
argumentSelectorFunctions
|
|
3119
1579
|
};
|
|
3120
1580
|
}
|
|
3121
|
-
/**
|
|
3122
|
-
* @param {?} selectorMetaData
|
|
3123
|
-
* @param {?} explicitOptions
|
|
3124
|
-
* @return {?}
|
|
3125
|
-
*/
|
|
3126
1581
|
function getLocalSelectorOptions(selectorMetaData, explicitOptions) {
|
|
3127
|
-
return Object.assign({}, (selectorOptionsMetaAccessor.getOptions(selectorMetaData.containerClass) || {}), (selectorOptionsMetaAccessor.getOptions(selectorMetaData.originalFn) || {}), (selectorMetaData.getSelectorOptions() || {}), explicitOptions);
|
|
1582
|
+
return Object.assign(Object.assign(Object.assign(Object.assign({}, (selectorOptionsMetaAccessor.getOptions(selectorMetaData.containerClass) || {})), (selectorOptionsMetaAccessor.getOptions(selectorMetaData.originalFn) || {})), (selectorMetaData.getSelectorOptions() || {})), explicitOptions);
|
|
3128
1583
|
}
|
|
3129
|
-
/**
|
|
3130
|
-
* @param {?=} selectors
|
|
3131
|
-
* @param {?=} selectorOptions
|
|
3132
|
-
* @param {?=} containerClass
|
|
3133
|
-
* @return {?}
|
|
3134
|
-
*/
|
|
3135
1584
|
function getSelectorsToApply(selectors = [], selectorOptions, containerClass) {
|
|
3136
|
-
/** @type {?} */
|
|
3137
1585
|
const selectorsToApply = [];
|
|
3138
|
-
/** @type {?} */
|
|
3139
1586
|
const canInjectContainerState = selectors.length === 0 || selectorOptions.injectContainerState;
|
|
3140
1587
|
if (containerClass && canInjectContainerState) {
|
|
3141
1588
|
// If we are on a state class, add it as the first selector parameter
|
|
3142
|
-
|
|
3143
|
-
const metadata = getStoreMetadata(containerClass);
|
|
1589
|
+
const metadata = getStoreMetadata$1(containerClass);
|
|
3144
1590
|
if (metadata) {
|
|
3145
1591
|
selectorsToApply.push(containerClass);
|
|
3146
1592
|
}
|
|
@@ -3153,31 +1599,14 @@ function getSelectorsToApply(selectors = [], selectorOptions, containerClass) {
|
|
|
3153
1599
|
/**
|
|
3154
1600
|
* This function gets the factory function to create the selector to get the selected slice from the app state
|
|
3155
1601
|
* @ignore
|
|
3156
|
-
* @param {?} selector
|
|
3157
|
-
* @return {?}
|
|
3158
1602
|
*/
|
|
3159
1603
|
function getRootSelectorFactory(selector) {
|
|
3160
|
-
|
|
3161
|
-
|
|
3162
|
-
return (metadata && metadata.makeRootSelector) || ((/**
|
|
3163
|
-
* @return {?}
|
|
3164
|
-
*/
|
|
3165
|
-
() => selector));
|
|
1604
|
+
const metadata = getSelectorMetadata$1(selector) || getStoreMetadata$1(selector);
|
|
1605
|
+
return (metadata && metadata.makeRootSelector) || (() => selector);
|
|
3166
1606
|
}
|
|
3167
1607
|
|
|
3168
|
-
|
|
3169
|
-
* @fileoverview added by tsickle
|
|
3170
|
-
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
3171
|
-
*/
|
|
1608
|
+
// tslint:disable:unified-signatures
|
|
3172
1609
|
class Store {
|
|
3173
|
-
/**
|
|
3174
|
-
* @param {?} _stateStream
|
|
3175
|
-
* @param {?} _internalStateOperations
|
|
3176
|
-
* @param {?} _config
|
|
3177
|
-
* @param {?} _internalExecutionStrategy
|
|
3178
|
-
* @param {?} _stateFactory
|
|
3179
|
-
* @param {?} initialStateValue
|
|
3180
|
-
*/
|
|
3181
1610
|
constructor(_stateStream, _internalStateOperations, _config, _internalExecutionStrategy, _stateFactory, initialStateValue) {
|
|
3182
1611
|
this._stateStream = _stateStream;
|
|
3183
1612
|
this._internalStateOperations = _internalStateOperations;
|
|
@@ -3194,24 +1623,13 @@ class Store {
|
|
|
3194
1623
|
}
|
|
3195
1624
|
/**
|
|
3196
1625
|
* Dispatches event(s).
|
|
3197
|
-
* @param {?} actionOrActions
|
|
3198
|
-
* @return {?}
|
|
3199
1626
|
*/
|
|
3200
1627
|
dispatch(actionOrActions) {
|
|
3201
1628
|
return this._internalStateOperations.getRootStateOperations().dispatch(actionOrActions);
|
|
3202
1629
|
}
|
|
3203
|
-
/**
|
|
3204
|
-
* @param {?} selector
|
|
3205
|
-
* @return {?}
|
|
3206
|
-
*/
|
|
3207
1630
|
select(selector) {
|
|
3208
|
-
/** @type {?} */
|
|
3209
1631
|
const selectorFn = this.getStoreBoundSelectorFn(selector);
|
|
3210
|
-
return this._selectableStateStream.pipe(map(selectorFn), catchError((
|
|
3211
|
-
* @param {?} err
|
|
3212
|
-
* @return {?}
|
|
3213
|
-
*/
|
|
3214
|
-
(err) => {
|
|
1632
|
+
return this._selectableStateStream.pipe(map(selectorFn), catchError((err) => {
|
|
3215
1633
|
// if error is TypeError we swallow it to prevent usual errors with property access
|
|
3216
1634
|
const { suppressErrors } = this._config.selectorOptions;
|
|
3217
1635
|
if (err instanceof TypeError && suppressErrors) {
|
|
@@ -3219,28 +1637,17 @@ class Store {
|
|
|
3219
1637
|
}
|
|
3220
1638
|
// rethrow other errors
|
|
3221
1639
|
return throwError(err);
|
|
3222
|
-
})
|
|
1640
|
+
}), distinctUntilChanged(), leaveNgxs(this._internalExecutionStrategy));
|
|
3223
1641
|
}
|
|
3224
|
-
/**
|
|
3225
|
-
* @param {?} selector
|
|
3226
|
-
* @return {?}
|
|
3227
|
-
*/
|
|
3228
1642
|
selectOnce(selector) {
|
|
3229
1643
|
return this.select(selector).pipe(take(1));
|
|
3230
1644
|
}
|
|
3231
|
-
/**
|
|
3232
|
-
* @param {?} selector
|
|
3233
|
-
* @return {?}
|
|
3234
|
-
*/
|
|
3235
1645
|
selectSnapshot(selector) {
|
|
3236
|
-
/** @type {?} */
|
|
3237
1646
|
const selectorFn = this.getStoreBoundSelectorFn(selector);
|
|
3238
1647
|
return selectorFn(this._stateStream.getValue());
|
|
3239
1648
|
}
|
|
3240
1649
|
/**
|
|
3241
1650
|
* Allow the user to subscribe to the root of the state
|
|
3242
|
-
* @param {?=} fn
|
|
3243
|
-
* @return {?}
|
|
3244
1651
|
*/
|
|
3245
1652
|
subscribe(fn) {
|
|
3246
1653
|
return this._selectableStateStream
|
|
@@ -3249,7 +1656,6 @@ class Store {
|
|
|
3249
1656
|
}
|
|
3250
1657
|
/**
|
|
3251
1658
|
* Return the raw value of the state.
|
|
3252
|
-
* @return {?}
|
|
3253
1659
|
*/
|
|
3254
1660
|
snapshot() {
|
|
3255
1661
|
return this._internalStateOperations.getRootStateOperations().getState();
|
|
@@ -3257,104 +1663,38 @@ class Store {
|
|
|
3257
1663
|
/**
|
|
3258
1664
|
* Reset the state to a specific point in time. This method is useful
|
|
3259
1665
|
* for plugin's who need to modify the state directly or unit testing.
|
|
3260
|
-
* @param {?} state
|
|
3261
|
-
* @return {?}
|
|
3262
1666
|
*/
|
|
3263
1667
|
reset(state) {
|
|
3264
1668
|
return this._internalStateOperations.getRootStateOperations().setState(state);
|
|
3265
1669
|
}
|
|
3266
|
-
/**
|
|
3267
|
-
* @private
|
|
3268
|
-
* @param {?} selector
|
|
3269
|
-
* @return {?}
|
|
3270
|
-
*/
|
|
3271
1670
|
getStoreBoundSelectorFn(selector) {
|
|
3272
|
-
/** @type {?} */
|
|
3273
1671
|
const makeSelectorFn = getRootSelectorFactory(selector);
|
|
3274
|
-
/** @type {?} */
|
|
3275
1672
|
const runtimeContext = this._stateFactory.getRuntimeSelectorContext();
|
|
3276
1673
|
return makeSelectorFn(runtimeContext);
|
|
3277
1674
|
}
|
|
3278
|
-
/**
|
|
3279
|
-
* @private
|
|
3280
|
-
* @param {?} initialStateValue
|
|
3281
|
-
* @return {?}
|
|
3282
|
-
*/
|
|
3283
1675
|
initStateStream(initialStateValue) {
|
|
3284
|
-
/** @type {?} */
|
|
3285
1676
|
const value = this._stateStream.value;
|
|
3286
|
-
/** @type {?} */
|
|
3287
1677
|
const storeIsEmpty = !value || Object.keys(value).length === 0;
|
|
3288
1678
|
if (storeIsEmpty) {
|
|
3289
|
-
/** @type {?} */
|
|
3290
1679
|
const defaultStateNotEmpty = Object.keys(this._config.defaultsState).length > 0;
|
|
3291
|
-
/** @type {?} */
|
|
3292
1680
|
const storeValues = defaultStateNotEmpty
|
|
3293
|
-
? Object.assign({}, this._config.defaultsState, initialStateValue) : initialStateValue;
|
|
1681
|
+
? Object.assign(Object.assign({}, this._config.defaultsState), initialStateValue) : initialStateValue;
|
|
3294
1682
|
this._stateStream.next(storeValues);
|
|
3295
1683
|
}
|
|
3296
1684
|
}
|
|
3297
1685
|
}
|
|
3298
|
-
Store
|
|
3299
|
-
|
|
3300
|
-
|
|
3301
|
-
|
|
3302
|
-
|
|
3303
|
-
|
|
3304
|
-
|
|
3305
|
-
|
|
3306
|
-
|
|
3307
|
-
|
|
3308
|
-
{ type: undefined, decorators: [{ type: Optional }, { type: Inject, args: [INITIAL_STATE_TOKEN,] }] }
|
|
3309
|
-
];
|
|
3310
|
-
if (false) {
|
|
3311
|
-
/**
|
|
3312
|
-
* This is a derived state stream that leaves NGXS execution strategy to emit state changes within the Angular zone,
|
|
3313
|
-
* because state is being changed actually within the `<root>` zone, see `InternalDispatcher#dispatchSingle`.
|
|
3314
|
-
* All selects would use this stream, and it would call leave only once for any state change across all active selectors.
|
|
3315
|
-
* @type {?}
|
|
3316
|
-
* @private
|
|
3317
|
-
*/
|
|
3318
|
-
Store.prototype._selectableStateStream;
|
|
3319
|
-
/**
|
|
3320
|
-
* @type {?}
|
|
3321
|
-
* @private
|
|
3322
|
-
*/
|
|
3323
|
-
Store.prototype._stateStream;
|
|
3324
|
-
/**
|
|
3325
|
-
* @type {?}
|
|
3326
|
-
* @private
|
|
3327
|
-
*/
|
|
3328
|
-
Store.prototype._internalStateOperations;
|
|
3329
|
-
/**
|
|
3330
|
-
* @type {?}
|
|
3331
|
-
* @private
|
|
3332
|
-
*/
|
|
3333
|
-
Store.prototype._config;
|
|
3334
|
-
/**
|
|
3335
|
-
* @type {?}
|
|
3336
|
-
* @private
|
|
3337
|
-
*/
|
|
3338
|
-
Store.prototype._internalExecutionStrategy;
|
|
3339
|
-
/**
|
|
3340
|
-
* @type {?}
|
|
3341
|
-
* @private
|
|
3342
|
-
*/
|
|
3343
|
-
Store.prototype._stateFactory;
|
|
3344
|
-
}
|
|
1686
|
+
/** @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 });
|
|
1687
|
+
/** @nocollapse */ Store.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: Store });
|
|
1688
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: Store, decorators: [{
|
|
1689
|
+
type: Injectable
|
|
1690
|
+
}], ctorParameters: function () { return [{ type: StateStream }, { type: InternalStateOperations }, { type: NgxsConfig }, { type: InternalNgxsExecutionStrategy }, { type: StateFactory }, { type: undefined, decorators: [{
|
|
1691
|
+
type: Optional
|
|
1692
|
+
}, {
|
|
1693
|
+
type: Inject,
|
|
1694
|
+
args: [INITIAL_STATE_TOKEN]
|
|
1695
|
+
}] }]; } });
|
|
3345
1696
|
|
|
3346
|
-
/**
|
|
3347
|
-
* @fileoverview added by tsickle
|
|
3348
|
-
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
3349
|
-
*/
|
|
3350
1697
|
class LifecycleStateManager {
|
|
3351
|
-
/**
|
|
3352
|
-
* @param {?} _store
|
|
3353
|
-
* @param {?} _internalErrorReporter
|
|
3354
|
-
* @param {?} _internalStateOperations
|
|
3355
|
-
* @param {?} _stateContextFactory
|
|
3356
|
-
* @param {?} _bootstrapper
|
|
3357
|
-
*/
|
|
3358
1698
|
constructor(_store, _internalErrorReporter, _internalStateOperations, _stateContextFactory, _bootstrapper) {
|
|
3359
1699
|
this._store = _store;
|
|
3360
1700
|
this._internalErrorReporter = _internalErrorReporter;
|
|
@@ -3363,78 +1703,34 @@ class LifecycleStateManager {
|
|
|
3363
1703
|
this._bootstrapper = _bootstrapper;
|
|
3364
1704
|
this._destroy$ = new Subject();
|
|
3365
1705
|
}
|
|
3366
|
-
/**
|
|
3367
|
-
* @return {?}
|
|
3368
|
-
*/
|
|
3369
1706
|
ngOnDestroy() {
|
|
3370
1707
|
this._destroy$.next();
|
|
3371
1708
|
}
|
|
3372
|
-
/**
|
|
3373
|
-
* @template T
|
|
3374
|
-
* @param {?} action
|
|
3375
|
-
* @param {?} results
|
|
3376
|
-
* @return {?}
|
|
3377
|
-
*/
|
|
3378
1709
|
ngxsBootstrap(action, results) {
|
|
3379
1710
|
this._internalStateOperations
|
|
3380
1711
|
.getRootStateOperations()
|
|
3381
1712
|
.dispatch(action)
|
|
3382
|
-
.pipe(filter((
|
|
3383
|
-
* @return {?}
|
|
3384
|
-
*/
|
|
3385
|
-
() => !!results)), tap((/**
|
|
3386
|
-
* @return {?}
|
|
3387
|
-
*/
|
|
3388
|
-
() => this._invokeInitOnStates((/** @type {?} */ (results)).states))), mergeMap((/**
|
|
3389
|
-
* @return {?}
|
|
3390
|
-
*/
|
|
3391
|
-
() => this._bootstrapper.appBootstrapped$)), filter((/**
|
|
3392
|
-
* @param {?} appBootstrapped
|
|
3393
|
-
* @return {?}
|
|
3394
|
-
*/
|
|
3395
|
-
appBootstrapped => !!appBootstrapped)), catchError((/**
|
|
3396
|
-
* @param {?} error
|
|
3397
|
-
* @return {?}
|
|
3398
|
-
*/
|
|
3399
|
-
error => {
|
|
1713
|
+
.pipe(filter(() => !!results), tap(() => this._invokeInitOnStates(results.states)), mergeMap(() => this._bootstrapper.appBootstrapped$), filter(appBootstrapped => !!appBootstrapped), catchError(error => {
|
|
3400
1714
|
// The `SafeSubscriber` (which is used by most RxJS operators) re-throws
|
|
3401
1715
|
// errors asynchronously (`setTimeout(() => { throw error })`). This might
|
|
3402
1716
|
// break existing user's code or unit tests. We catch the error manually to
|
|
3403
1717
|
// be backward compatible with the old behavior.
|
|
3404
1718
|
this._internalErrorReporter.reportErrorSafely(error);
|
|
3405
1719
|
return EMPTY;
|
|
3406
|
-
})
|
|
3407
|
-
.subscribe((
|
|
3408
|
-
* @return {?}
|
|
3409
|
-
*/
|
|
3410
|
-
() => this._invokeBootstrapOnStates((/** @type {?} */ (results)).states)));
|
|
1720
|
+
}), takeUntil(this._destroy$))
|
|
1721
|
+
.subscribe(() => this._invokeBootstrapOnStates(results.states));
|
|
3411
1722
|
}
|
|
3412
|
-
/**
|
|
3413
|
-
* @private
|
|
3414
|
-
* @param {?} mappedStores
|
|
3415
|
-
* @return {?}
|
|
3416
|
-
*/
|
|
3417
1723
|
_invokeInitOnStates(mappedStores) {
|
|
3418
1724
|
for (const mappedStore of mappedStores) {
|
|
3419
|
-
/** @type {?} */
|
|
3420
1725
|
const instance = mappedStore.instance;
|
|
3421
1726
|
if (instance.ngxsOnChanges) {
|
|
3422
1727
|
this._store
|
|
3423
|
-
.select((
|
|
3424
|
-
* @param {?} state
|
|
3425
|
-
* @return {?}
|
|
3426
|
-
*/
|
|
3427
|
-
state => getValue(state, mappedStore.path)))
|
|
1728
|
+
.select(state => getValue(state, mappedStore.path))
|
|
3428
1729
|
.pipe(startWith(undefined), pairwise(), takeUntil(this._destroy$))
|
|
3429
|
-
.subscribe((
|
|
3430
|
-
* @param {?} __0
|
|
3431
|
-
* @return {?}
|
|
3432
|
-
*/
|
|
3433
|
-
([previousValue, currentValue]) => {
|
|
3434
|
-
/** @type {?} */
|
|
1730
|
+
.subscribe(([previousValue, currentValue]) => {
|
|
3435
1731
|
const change = new NgxsSimpleChange(previousValue, currentValue, !mappedStore.isInitialised);
|
|
3436
|
-
|
|
3437
|
-
})
|
|
1732
|
+
instance.ngxsOnChanges(change);
|
|
1733
|
+
});
|
|
3438
1734
|
}
|
|
3439
1735
|
if (instance.ngxsOnInit) {
|
|
3440
1736
|
instance.ngxsOnInit(this._getStateContext(mappedStore));
|
|
@@ -3442,93 +1738,33 @@ class LifecycleStateManager {
|
|
|
3442
1738
|
mappedStore.isInitialised = true;
|
|
3443
1739
|
}
|
|
3444
1740
|
}
|
|
3445
|
-
/**
|
|
3446
|
-
* @private
|
|
3447
|
-
* @param {?} mappedStores
|
|
3448
|
-
* @return {?}
|
|
3449
|
-
*/
|
|
3450
1741
|
_invokeBootstrapOnStates(mappedStores) {
|
|
3451
1742
|
for (const mappedStore of mappedStores) {
|
|
3452
|
-
/** @type {?} */
|
|
3453
1743
|
const instance = mappedStore.instance;
|
|
3454
1744
|
if (instance.ngxsAfterBootstrap) {
|
|
3455
1745
|
instance.ngxsAfterBootstrap(this._getStateContext(mappedStore));
|
|
3456
1746
|
}
|
|
3457
1747
|
}
|
|
3458
1748
|
}
|
|
3459
|
-
/**
|
|
3460
|
-
* @private
|
|
3461
|
-
* @param {?} mappedStore
|
|
3462
|
-
* @return {?}
|
|
3463
|
-
*/
|
|
3464
1749
|
_getStateContext(mappedStore) {
|
|
3465
1750
|
return this._stateContextFactory.createStateContext(mappedStore);
|
|
3466
1751
|
}
|
|
3467
1752
|
}
|
|
3468
|
-
LifecycleStateManager
|
|
3469
|
-
|
|
3470
|
-
|
|
3471
|
-
|
|
3472
|
-
|
|
3473
|
-
{ type: Store },
|
|
3474
|
-
{ type: InternalErrorReporter },
|
|
3475
|
-
{ type: InternalStateOperations },
|
|
3476
|
-
{ type: StateContextFactory },
|
|
3477
|
-
{ type: NgxsBootstrapper }
|
|
3478
|
-
];
|
|
3479
|
-
if (false) {
|
|
3480
|
-
/**
|
|
3481
|
-
* @type {?}
|
|
3482
|
-
* @private
|
|
3483
|
-
*/
|
|
3484
|
-
LifecycleStateManager.prototype._destroy$;
|
|
3485
|
-
/**
|
|
3486
|
-
* @type {?}
|
|
3487
|
-
* @private
|
|
3488
|
-
*/
|
|
3489
|
-
LifecycleStateManager.prototype._store;
|
|
3490
|
-
/**
|
|
3491
|
-
* @type {?}
|
|
3492
|
-
* @private
|
|
3493
|
-
*/
|
|
3494
|
-
LifecycleStateManager.prototype._internalErrorReporter;
|
|
3495
|
-
/**
|
|
3496
|
-
* @type {?}
|
|
3497
|
-
* @private
|
|
3498
|
-
*/
|
|
3499
|
-
LifecycleStateManager.prototype._internalStateOperations;
|
|
3500
|
-
/**
|
|
3501
|
-
* @type {?}
|
|
3502
|
-
* @private
|
|
3503
|
-
*/
|
|
3504
|
-
LifecycleStateManager.prototype._stateContextFactory;
|
|
3505
|
-
/**
|
|
3506
|
-
* @type {?}
|
|
3507
|
-
* @private
|
|
3508
|
-
*/
|
|
3509
|
-
LifecycleStateManager.prototype._bootstrapper;
|
|
3510
|
-
}
|
|
1753
|
+
/** @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 });
|
|
1754
|
+
/** @nocollapse */ LifecycleStateManager.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: LifecycleStateManager });
|
|
1755
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: LifecycleStateManager, decorators: [{
|
|
1756
|
+
type: Injectable
|
|
1757
|
+
}], ctorParameters: function () { return [{ type: Store }, { type: InternalErrorReporter }, { type: InternalStateOperations }, { type: StateContextFactory }, { type: i5.NgxsBootstrapper }]; } });
|
|
3511
1758
|
|
|
3512
|
-
/**
|
|
3513
|
-
* @fileoverview added by tsickle
|
|
3514
|
-
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
3515
|
-
*/
|
|
3516
1759
|
/**
|
|
3517
1760
|
* Allows the select decorator to get access to the DI store, this is used internally
|
|
3518
|
-
* in
|
|
1761
|
+
* in `@Select` decorator.
|
|
3519
1762
|
*/
|
|
3520
1763
|
class SelectFactory {
|
|
3521
|
-
/**
|
|
3522
|
-
* @param {?} store
|
|
3523
|
-
* @param {?} config
|
|
3524
|
-
*/
|
|
3525
1764
|
constructor(store, config) {
|
|
3526
1765
|
SelectFactory.store = store;
|
|
3527
1766
|
SelectFactory.config = config;
|
|
3528
1767
|
}
|
|
3529
|
-
/**
|
|
3530
|
-
* @return {?}
|
|
3531
|
-
*/
|
|
3532
1768
|
ngOnDestroy() {
|
|
3533
1769
|
SelectFactory.store = null;
|
|
3534
1770
|
SelectFactory.config = null;
|
|
@@ -3536,41 +1772,19 @@ class SelectFactory {
|
|
|
3536
1772
|
}
|
|
3537
1773
|
SelectFactory.store = null;
|
|
3538
1774
|
SelectFactory.config = null;
|
|
3539
|
-
SelectFactory
|
|
3540
|
-
|
|
3541
|
-
|
|
3542
|
-
|
|
3543
|
-
|
|
3544
|
-
{ type: Store },
|
|
3545
|
-
{ type: NgxsConfig }
|
|
3546
|
-
];
|
|
3547
|
-
if (false) {
|
|
3548
|
-
/** @type {?} */
|
|
3549
|
-
SelectFactory.store;
|
|
3550
|
-
/** @type {?} */
|
|
3551
|
-
SelectFactory.config;
|
|
3552
|
-
}
|
|
1775
|
+
/** @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 });
|
|
1776
|
+
/** @nocollapse */ SelectFactory.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: SelectFactory });
|
|
1777
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: SelectFactory, decorators: [{
|
|
1778
|
+
type: Injectable
|
|
1779
|
+
}], ctorParameters: function () { return [{ type: Store }, { type: NgxsConfig }]; } });
|
|
3553
1780
|
|
|
3554
|
-
/**
|
|
3555
|
-
* @fileoverview added by tsickle
|
|
3556
|
-
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
3557
|
-
*/
|
|
3558
1781
|
/**
|
|
3559
1782
|
* Root module
|
|
3560
1783
|
* @ignore
|
|
3561
1784
|
*/
|
|
3562
1785
|
class NgxsRootModule {
|
|
3563
|
-
/**
|
|
3564
|
-
* @param {?} factory
|
|
3565
|
-
* @param {?} internalStateOperations
|
|
3566
|
-
* @param {?} _store
|
|
3567
|
-
* @param {?} _select
|
|
3568
|
-
* @param {?=} states
|
|
3569
|
-
* @param {?=} lifecycleStateManager
|
|
3570
|
-
*/
|
|
3571
1786
|
constructor(factory, internalStateOperations, _store, _select, states = [], lifecycleStateManager) {
|
|
3572
1787
|
// Add stores to the state graph and return their defaults
|
|
3573
|
-
/** @type {?} */
|
|
3574
1788
|
const results = factory.addAndReturnDefaults(states);
|
|
3575
1789
|
internalStateOperations.setStateToTheCurrentWithNew(results);
|
|
3576
1790
|
// Connect our actions stream
|
|
@@ -3579,42 +1793,28 @@ class NgxsRootModule {
|
|
|
3579
1793
|
lifecycleStateManager.ngxsBootstrap(new InitState(), results);
|
|
3580
1794
|
}
|
|
3581
1795
|
}
|
|
3582
|
-
NgxsRootModule
|
|
3583
|
-
|
|
3584
|
-
|
|
3585
|
-
|
|
3586
|
-
|
|
3587
|
-
|
|
3588
|
-
|
|
3589
|
-
|
|
3590
|
-
|
|
3591
|
-
|
|
3592
|
-
|
|
3593
|
-
];
|
|
1796
|
+
/** @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 });
|
|
1797
|
+
/** @nocollapse */ NgxsRootModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: NgxsRootModule });
|
|
1798
|
+
/** @nocollapse */ NgxsRootModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: NgxsRootModule });
|
|
1799
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: NgxsRootModule, decorators: [{
|
|
1800
|
+
type: NgModule
|
|
1801
|
+
}], ctorParameters: function () { return [{ type: StateFactory }, { type: InternalStateOperations }, { type: Store }, { type: SelectFactory }, { type: undefined, decorators: [{
|
|
1802
|
+
type: Optional
|
|
1803
|
+
}, {
|
|
1804
|
+
type: Inject,
|
|
1805
|
+
args: [ROOT_STATE_TOKEN]
|
|
1806
|
+
}] }, { type: LifecycleStateManager }]; } });
|
|
3594
1807
|
|
|
3595
|
-
/**
|
|
3596
|
-
* @fileoverview added by tsickle
|
|
3597
|
-
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
3598
|
-
*/
|
|
3599
1808
|
/**
|
|
3600
1809
|
* Feature module
|
|
3601
1810
|
* @ignore
|
|
3602
1811
|
*/
|
|
3603
1812
|
class NgxsFeatureModule {
|
|
3604
|
-
/**
|
|
3605
|
-
* @param {?} _store
|
|
3606
|
-
* @param {?} internalStateOperations
|
|
3607
|
-
* @param {?} factory
|
|
3608
|
-
* @param {?=} states
|
|
3609
|
-
* @param {?=} lifecycleStateManager
|
|
3610
|
-
*/
|
|
3611
1813
|
constructor(_store, internalStateOperations, factory, states = [], lifecycleStateManager) {
|
|
3612
1814
|
// Since FEATURE_STATE_TOKEN is a multi token, we need to
|
|
3613
1815
|
// flatten it [[Feature1State, Feature2State], [Feature3State]]
|
|
3614
|
-
/** @type {?} */
|
|
3615
1816
|
const flattenedStates = NgxsFeatureModule.flattenStates(states);
|
|
3616
1817
|
// add stores to the state graph and return their defaults
|
|
3617
|
-
/** @type {?} */
|
|
3618
1818
|
const results = factory.addAndReturnDefaults(flattenedStates);
|
|
3619
1819
|
if (results.states.length) {
|
|
3620
1820
|
internalStateOperations.setStateToTheCurrentWithNew(results);
|
|
@@ -3622,45 +1822,28 @@ class NgxsFeatureModule {
|
|
|
3622
1822
|
lifecycleStateManager.ngxsBootstrap(new UpdateState(results.defaults), results);
|
|
3623
1823
|
}
|
|
3624
1824
|
}
|
|
3625
|
-
/**
|
|
3626
|
-
* @private
|
|
3627
|
-
* @param {?=} states
|
|
3628
|
-
* @return {?}
|
|
3629
|
-
*/
|
|
3630
1825
|
static flattenStates(states = []) {
|
|
3631
|
-
return states.reduce((
|
|
3632
|
-
|
|
3633
|
-
|
|
3634
|
-
|
|
3635
|
-
|
|
3636
|
-
|
|
3637
|
-
|
|
3638
|
-
|
|
3639
|
-
|
|
3640
|
-
|
|
3641
|
-
|
|
3642
|
-
|
|
3643
|
-
|
|
3644
|
-
|
|
3645
|
-
{ type: InternalStateOperations },
|
|
3646
|
-
{ type: StateFactory },
|
|
3647
|
-
{ type: Array, decorators: [{ type: Optional }, { type: Inject, args: [FEATURE_STATE_TOKEN,] }] },
|
|
3648
|
-
{ type: LifecycleStateManager }
|
|
3649
|
-
];
|
|
1826
|
+
return states.reduce((total, values) => total.concat(values), []);
|
|
1827
|
+
}
|
|
1828
|
+
}
|
|
1829
|
+
/** @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 });
|
|
1830
|
+
/** @nocollapse */ NgxsFeatureModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: NgxsFeatureModule });
|
|
1831
|
+
/** @nocollapse */ NgxsFeatureModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: NgxsFeatureModule });
|
|
1832
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: NgxsFeatureModule, decorators: [{
|
|
1833
|
+
type: NgModule
|
|
1834
|
+
}], ctorParameters: function () { return [{ type: Store }, { type: InternalStateOperations }, { type: StateFactory }, { type: undefined, decorators: [{
|
|
1835
|
+
type: Optional
|
|
1836
|
+
}, {
|
|
1837
|
+
type: Inject,
|
|
1838
|
+
args: [FEATURE_STATE_TOKEN]
|
|
1839
|
+
}] }, { type: LifecycleStateManager }]; } });
|
|
3650
1840
|
|
|
3651
|
-
/**
|
|
3652
|
-
* @fileoverview added by tsickle
|
|
3653
|
-
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
3654
|
-
*/
|
|
3655
1841
|
/**
|
|
3656
1842
|
* Ngxs Module
|
|
3657
1843
|
*/
|
|
3658
1844
|
class NgxsModule {
|
|
3659
1845
|
/**
|
|
3660
1846
|
* Root module factory
|
|
3661
|
-
* @param {?=} states
|
|
3662
|
-
* @param {?=} options
|
|
3663
|
-
* @return {?}
|
|
3664
1847
|
*/
|
|
3665
1848
|
static forRoot(states = [], options = {}) {
|
|
3666
1849
|
return {
|
|
@@ -3687,8 +1870,6 @@ class NgxsModule {
|
|
|
3687
1870
|
}
|
|
3688
1871
|
/**
|
|
3689
1872
|
* Feature module factory
|
|
3690
|
-
* @param {?=} states
|
|
3691
|
-
* @return {?}
|
|
3692
1873
|
*/
|
|
3693
1874
|
static forFeature(states = []) {
|
|
3694
1875
|
return {
|
|
@@ -3705,12 +1886,6 @@ class NgxsModule {
|
|
|
3705
1886
|
]
|
|
3706
1887
|
};
|
|
3707
1888
|
}
|
|
3708
|
-
/**
|
|
3709
|
-
* @private
|
|
3710
|
-
* @param {?} states
|
|
3711
|
-
* @param {?} options
|
|
3712
|
-
* @return {?}
|
|
3713
|
-
*/
|
|
3714
1889
|
static ngxsTokenProviders(states, options) {
|
|
3715
1890
|
return [
|
|
3716
1891
|
{
|
|
@@ -3741,87 +1916,51 @@ class NgxsModule {
|
|
|
3741
1916
|
useFactory: NgxsModule.getInitialState
|
|
3742
1917
|
},
|
|
3743
1918
|
{
|
|
3744
|
-
provide: NGXS_STATE_CONTEXT_FACTORY,
|
|
1919
|
+
provide: ɵNGXS_STATE_CONTEXT_FACTORY,
|
|
3745
1920
|
useExisting: StateContextFactory
|
|
3746
1921
|
},
|
|
3747
1922
|
{
|
|
3748
|
-
provide: NGXS_STATE_FACTORY,
|
|
1923
|
+
provide: ɵNGXS_STATE_FACTORY,
|
|
3749
1924
|
useExisting: StateFactory
|
|
3750
1925
|
}
|
|
3751
1926
|
];
|
|
3752
1927
|
}
|
|
3753
|
-
/**
|
|
3754
|
-
* @private
|
|
3755
|
-
* @param {?} options
|
|
3756
|
-
* @return {?}
|
|
3757
|
-
*/
|
|
3758
1928
|
static ngxsConfigFactory(options) {
|
|
3759
1929
|
return mergeDeep(new NgxsConfig(), options);
|
|
3760
1930
|
}
|
|
3761
|
-
/**
|
|
3762
|
-
* @private
|
|
3763
|
-
* @param {?} bootstrapper
|
|
3764
|
-
* @return {?}
|
|
3765
|
-
*/
|
|
3766
1931
|
static appBootstrapListenerFactory(bootstrapper) {
|
|
3767
|
-
return (
|
|
3768
|
-
* @return {?}
|
|
3769
|
-
*/
|
|
3770
|
-
() => bootstrapper.bootstrap());
|
|
1932
|
+
return () => bootstrapper.bootstrap();
|
|
3771
1933
|
}
|
|
3772
|
-
/**
|
|
3773
|
-
* @private
|
|
3774
|
-
* @return {?}
|
|
3775
|
-
*/
|
|
3776
1934
|
static getInitialState() {
|
|
3777
1935
|
return InitialState.pop();
|
|
3778
1936
|
}
|
|
3779
1937
|
}
|
|
3780
1938
|
NgxsModule.ROOT_OPTIONS = new InjectionToken('ROOT_OPTIONS');
|
|
3781
|
-
NgxsModule
|
|
3782
|
-
|
|
3783
|
-
|
|
3784
|
-
|
|
3785
|
-
|
|
3786
|
-
|
|
3787
|
-
* @private
|
|
3788
|
-
*/
|
|
3789
|
-
NgxsModule.ROOT_OPTIONS;
|
|
3790
|
-
}
|
|
1939
|
+
/** @nocollapse */ NgxsModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: NgxsModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
1940
|
+
/** @nocollapse */ NgxsModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: NgxsModule });
|
|
1941
|
+
/** @nocollapse */ NgxsModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: NgxsModule });
|
|
1942
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: NgxsModule, decorators: [{
|
|
1943
|
+
type: NgModule
|
|
1944
|
+
}] });
|
|
3791
1945
|
|
|
3792
|
-
/**
|
|
3793
|
-
* @fileoverview added by tsickle
|
|
3794
|
-
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
3795
|
-
*/
|
|
3796
1946
|
/**
|
|
3797
1947
|
* Decorates a method with a action information.
|
|
3798
|
-
* @param {?} actions
|
|
3799
|
-
* @param {?=} options
|
|
3800
|
-
* @return {?}
|
|
3801
1948
|
*/
|
|
3802
1949
|
function Action(actions, options) {
|
|
3803
|
-
return (
|
|
3804
|
-
* @param {?} target
|
|
3805
|
-
* @param {?} name
|
|
3806
|
-
* @return {?}
|
|
3807
|
-
*/
|
|
3808
|
-
(target, name) => {
|
|
1950
|
+
return (target, name) => {
|
|
3809
1951
|
// Caretaker note: we have still left the `typeof` condition in order to avoid
|
|
3810
1952
|
// creating a breaking change for projects that still use the View Engine.
|
|
3811
1953
|
if (typeof ngDevMode === 'undefined' || ngDevMode) {
|
|
3812
|
-
/** @type {?} */
|
|
3813
1954
|
const isStaticMethod = target.hasOwnProperty('prototype');
|
|
3814
1955
|
if (isStaticMethod) {
|
|
3815
1956
|
throwActionDecoratorError();
|
|
3816
1957
|
}
|
|
3817
1958
|
}
|
|
3818
|
-
|
|
3819
|
-
const meta = ensureStoreMetadata(target.constructor);
|
|
1959
|
+
const meta = ensureStoreMetadata$1(target.constructor);
|
|
3820
1960
|
if (!Array.isArray(actions)) {
|
|
3821
1961
|
actions = [actions];
|
|
3822
1962
|
}
|
|
3823
1963
|
for (const action of actions) {
|
|
3824
|
-
/** @type {?} */
|
|
3825
1964
|
const type = action.type;
|
|
3826
1965
|
if (!meta.actions[type]) {
|
|
3827
1966
|
meta.actions[type] = [];
|
|
@@ -3832,50 +1971,20 @@ function Action(actions, options) {
|
|
|
3832
1971
|
type
|
|
3833
1972
|
});
|
|
3834
1973
|
}
|
|
3835
|
-
}
|
|
1974
|
+
};
|
|
3836
1975
|
}
|
|
3837
1976
|
|
|
3838
|
-
/**
|
|
3839
|
-
* @fileoverview added by tsickle
|
|
3840
|
-
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
3841
|
-
*/
|
|
3842
|
-
/**
|
|
3843
|
-
* @record
|
|
3844
|
-
* @template T
|
|
3845
|
-
*/
|
|
3846
|
-
function MutateMetaOptions() { }
|
|
3847
|
-
if (false) {
|
|
3848
|
-
/** @type {?} */
|
|
3849
|
-
MutateMetaOptions.prototype.meta;
|
|
3850
|
-
/** @type {?} */
|
|
3851
|
-
MutateMetaOptions.prototype.inheritedStateClass;
|
|
3852
|
-
/** @type {?} */
|
|
3853
|
-
MutateMetaOptions.prototype.optionsWithInheritance;
|
|
3854
|
-
}
|
|
3855
1977
|
/**
|
|
3856
1978
|
* Decorates a class with ngxs state information.
|
|
3857
|
-
* @template T
|
|
3858
|
-
* @param {?} options
|
|
3859
|
-
* @return {?}
|
|
3860
1979
|
*/
|
|
3861
1980
|
function State(options) {
|
|
3862
|
-
/**
|
|
3863
|
-
* @param {?} inheritedStateClass
|
|
3864
|
-
* @return {?}
|
|
3865
|
-
*/
|
|
3866
1981
|
function getStateOptions(inheritedStateClass) {
|
|
3867
|
-
/** @type {?} */
|
|
3868
1982
|
const inheritanceOptions = inheritedStateClass[META_OPTIONS_KEY] || {};
|
|
3869
|
-
return (
|
|
1983
|
+
return Object.assign(Object.assign({}, inheritanceOptions), options);
|
|
3870
1984
|
}
|
|
3871
|
-
/**
|
|
3872
|
-
* @param {?} params
|
|
3873
|
-
* @return {?}
|
|
3874
|
-
*/
|
|
3875
1985
|
function mutateMetaData(params) {
|
|
3876
1986
|
const { meta, inheritedStateClass, optionsWithInheritance } = params;
|
|
3877
1987
|
const { children, defaults, name } = optionsWithInheritance;
|
|
3878
|
-
/** @type {?} */
|
|
3879
1988
|
const stateName = typeof name === 'string' ? name : (name && name.getName()) || null;
|
|
3880
1989
|
// Caretaker note: we have still left the `typeof` condition in order to avoid
|
|
3881
1990
|
// creating a breaking change for projects that still use the View Engine.
|
|
@@ -3883,102 +1992,56 @@ function State(options) {
|
|
|
3883
1992
|
StoreValidators.checkThatStateIsNamedCorrectly(stateName);
|
|
3884
1993
|
}
|
|
3885
1994
|
if (inheritedStateClass.hasOwnProperty(META_KEY)) {
|
|
3886
|
-
/** @type {?} */
|
|
3887
1995
|
const inheritedMeta = inheritedStateClass[META_KEY] || {};
|
|
3888
|
-
meta.actions = Object.assign({}, meta.actions, inheritedMeta.actions);
|
|
1996
|
+
meta.actions = Object.assign(Object.assign({}, meta.actions), inheritedMeta.actions);
|
|
3889
1997
|
}
|
|
3890
1998
|
meta.children = children;
|
|
3891
1999
|
meta.defaults = defaults;
|
|
3892
2000
|
meta.name = stateName;
|
|
3893
2001
|
}
|
|
3894
|
-
return (
|
|
3895
|
-
* @param {?} target
|
|
3896
|
-
* @return {?}
|
|
3897
|
-
*/
|
|
3898
|
-
(target) => {
|
|
3899
|
-
/** @type {?} */
|
|
2002
|
+
return (target) => {
|
|
3900
2003
|
const stateClass = target;
|
|
3901
|
-
|
|
3902
|
-
const meta = ensureStoreMetadata(stateClass);
|
|
3903
|
-
/** @type {?} */
|
|
2004
|
+
const meta = ensureStoreMetadata$1(stateClass);
|
|
3904
2005
|
const inheritedStateClass = Object.getPrototypeOf(stateClass);
|
|
3905
|
-
/** @type {?} */
|
|
3906
2006
|
const optionsWithInheritance = getStateOptions(inheritedStateClass);
|
|
3907
2007
|
mutateMetaData({ meta, inheritedStateClass, optionsWithInheritance });
|
|
3908
2008
|
stateClass[META_OPTIONS_KEY] = optionsWithInheritance;
|
|
3909
|
-
}
|
|
2009
|
+
};
|
|
3910
2010
|
}
|
|
3911
2011
|
|
|
3912
|
-
/**
|
|
3913
|
-
* @fileoverview added by tsickle
|
|
3914
|
-
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
3915
|
-
*/
|
|
3916
|
-
/** @type {?} */
|
|
3917
2012
|
const DOLLAR_CHAR_CODE = 36;
|
|
3918
|
-
/**
|
|
3919
|
-
* @template T
|
|
3920
|
-
* @param {?} selector
|
|
3921
|
-
* @return {?}
|
|
3922
|
-
*/
|
|
3923
2013
|
function createSelectObservable(selector) {
|
|
3924
2014
|
if (!SelectFactory.store) {
|
|
3925
2015
|
throwSelectFactoryNotConnectedError();
|
|
3926
2016
|
}
|
|
3927
|
-
return
|
|
2017
|
+
return SelectFactory.store.select(selector);
|
|
3928
2018
|
}
|
|
3929
|
-
/**
|
|
3930
|
-
* @param {?} name
|
|
3931
|
-
* @param {?=} rawSelector
|
|
3932
|
-
* @param {?=} paths
|
|
3933
|
-
* @return {?}
|
|
3934
|
-
*/
|
|
3935
2019
|
function createSelectorFn(name, rawSelector, paths = []) {
|
|
3936
2020
|
rawSelector = !rawSelector ? removeDollarAtTheEnd(name) : rawSelector;
|
|
3937
2021
|
if (typeof rawSelector === 'string') {
|
|
3938
|
-
/** @type {?} */
|
|
3939
2022
|
const propsArray = paths.length
|
|
3940
2023
|
? [rawSelector, ...paths]
|
|
3941
2024
|
: rawSelector.split('.');
|
|
3942
|
-
return propGetter(propsArray,
|
|
2025
|
+
return propGetter(propsArray, SelectFactory.config);
|
|
3943
2026
|
}
|
|
3944
2027
|
return rawSelector;
|
|
3945
2028
|
}
|
|
3946
2029
|
/**
|
|
3947
|
-
*
|
|
3948
|
-
* @param {?} name
|
|
3949
|
-
* @return {?}
|
|
2030
|
+
* @example If `foo$` => make it just `foo`
|
|
3950
2031
|
*/
|
|
3951
2032
|
function removeDollarAtTheEnd(name) {
|
|
3952
|
-
/** @type {?} */
|
|
3953
2033
|
const lastCharIndex = name.length - 1;
|
|
3954
|
-
/** @type {?} */
|
|
3955
2034
|
const dollarAtTheEnd = name.charCodeAt(lastCharIndex) === DOLLAR_CHAR_CODE;
|
|
3956
2035
|
return dollarAtTheEnd ? name.slice(0, lastCharIndex) : name;
|
|
3957
2036
|
}
|
|
3958
2037
|
|
|
3959
|
-
/**
|
|
3960
|
-
* @fileoverview added by tsickle
|
|
3961
|
-
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
3962
|
-
*/
|
|
3963
2038
|
/**
|
|
3964
2039
|
* Decorator for selecting a slice of state from the store.
|
|
3965
|
-
* @template T
|
|
3966
|
-
* @param {?=} rawSelector
|
|
3967
|
-
* @param {...?} paths
|
|
3968
|
-
* @return {?}
|
|
3969
2040
|
*/
|
|
3970
2041
|
function Select(rawSelector, ...paths) {
|
|
3971
|
-
return (
|
|
3972
|
-
* @param {?} target
|
|
3973
|
-
* @param {?} key
|
|
3974
|
-
* @return {?}
|
|
3975
|
-
*/
|
|
3976
|
-
function (target, key) {
|
|
3977
|
-
/** @type {?} */
|
|
2042
|
+
return function (target, key) {
|
|
3978
2043
|
const name = key.toString();
|
|
3979
|
-
/** @type {?} */
|
|
3980
2044
|
const selectorId = `__${name}__selector`;
|
|
3981
|
-
/** @type {?} */
|
|
3982
2045
|
const selector = createSelectorFn(name, rawSelector, paths);
|
|
3983
2046
|
Object.defineProperties(target, {
|
|
3984
2047
|
[selectorId]: {
|
|
@@ -3989,39 +2052,22 @@ function Select(rawSelector, ...paths) {
|
|
|
3989
2052
|
[name]: {
|
|
3990
2053
|
enumerable: true,
|
|
3991
2054
|
configurable: true,
|
|
3992
|
-
/**
|
|
3993
|
-
* @return {?}
|
|
3994
|
-
*/
|
|
3995
2055
|
get() {
|
|
3996
2056
|
return this[selectorId] || (this[selectorId] = createSelectObservable(selector));
|
|
3997
2057
|
}
|
|
3998
2058
|
}
|
|
3999
2059
|
});
|
|
4000
|
-
}
|
|
2060
|
+
};
|
|
4001
2061
|
}
|
|
4002
2062
|
|
|
4003
|
-
/**
|
|
4004
|
-
* @fileoverview added by tsickle
|
|
4005
|
-
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
4006
|
-
*/
|
|
4007
2063
|
/**
|
|
4008
2064
|
* Decorator for setting selector options at a method or class level.
|
|
4009
|
-
* @param {?} options
|
|
4010
|
-
* @return {?}
|
|
4011
2065
|
*/
|
|
4012
2066
|
function SelectorOptions(options) {
|
|
4013
|
-
return (
|
|
4014
|
-
* @template T
|
|
4015
|
-
* @param {?} target
|
|
4016
|
-
* @param {?} methodName
|
|
4017
|
-
* @param {?} descriptor
|
|
4018
|
-
* @return {?}
|
|
4019
|
-
*/
|
|
4020
|
-
function decorate(target, methodName, descriptor) {
|
|
2067
|
+
return (function decorate(target, methodName, descriptor) {
|
|
4021
2068
|
if (methodName) {
|
|
4022
2069
|
// Method Decorator
|
|
4023
|
-
|
|
4024
|
-
const originalFn = descriptor.value || ((/** @type {?} */ (descriptor))).originalFn;
|
|
2070
|
+
const originalFn = descriptor.value || descriptor.originalFn;
|
|
4025
2071
|
if (originalFn) {
|
|
4026
2072
|
selectorOptionsMetaAccessor.defineOptions(originalFn, options);
|
|
4027
2073
|
}
|
|
@@ -4030,182 +2076,72 @@ function SelectorOptions(options) {
|
|
|
4030
2076
|
// Class Decorator
|
|
4031
2077
|
selectorOptionsMetaAccessor.defineOptions(target, options);
|
|
4032
2078
|
}
|
|
4033
|
-
})
|
|
2079
|
+
});
|
|
4034
2080
|
}
|
|
4035
2081
|
|
|
4036
|
-
|
|
4037
|
-
|
|
4038
|
-
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
4039
|
-
*/
|
|
4040
|
-
/**
|
|
4041
|
-
* @record
|
|
4042
|
-
*/
|
|
4043
|
-
function MetaDataModel$1() { }
|
|
4044
|
-
if (false) {
|
|
4045
|
-
/** @type {?} */
|
|
4046
|
-
MetaDataModel$1.prototype.name;
|
|
4047
|
-
/** @type {?} */
|
|
4048
|
-
MetaDataModel$1.prototype.actions;
|
|
4049
|
-
/** @type {?} */
|
|
4050
|
-
MetaDataModel$1.prototype.defaults;
|
|
4051
|
-
/** @type {?} */
|
|
4052
|
-
MetaDataModel$1.prototype.path;
|
|
4053
|
-
/** @type {?|undefined} */
|
|
4054
|
-
MetaDataModel$1.prototype.children;
|
|
4055
|
-
}
|
|
4056
|
-
/**
|
|
4057
|
-
* @record
|
|
4058
|
-
*/
|
|
4059
|
-
function SelectorMetaDataModel$1() { }
|
|
4060
|
-
if (false) {
|
|
4061
|
-
/** @type {?} */
|
|
4062
|
-
SelectorMetaDataModel$1.prototype.originalFn;
|
|
4063
|
-
/** @type {?} */
|
|
4064
|
-
SelectorMetaDataModel$1.prototype.containerClass;
|
|
4065
|
-
/** @type {?} */
|
|
4066
|
-
SelectorMetaDataModel$1.prototype.selectorName;
|
|
4067
|
-
/** @type {?} */
|
|
4068
|
-
SelectorMetaDataModel$1.prototype.getSelectorOptions;
|
|
4069
|
-
}
|
|
4070
|
-
/**
|
|
4071
|
-
* @param {?} target
|
|
4072
|
-
* @return {?}
|
|
4073
|
-
*/
|
|
4074
|
-
function ensureStoreMetadata$1(target) {
|
|
4075
|
-
return ensureStoreMetadata(target);
|
|
2082
|
+
function ensureStoreMetadata(target) {
|
|
2083
|
+
return ensureStoreMetadata$1(target);
|
|
4076
2084
|
}
|
|
4077
|
-
|
|
4078
|
-
|
|
4079
|
-
* @return {?}
|
|
4080
|
-
*/
|
|
4081
|
-
function getStoreMetadata$1(target) {
|
|
4082
|
-
return getStoreMetadata(target);
|
|
2085
|
+
function getStoreMetadata(target) {
|
|
2086
|
+
return getStoreMetadata$1(target);
|
|
4083
2087
|
}
|
|
4084
|
-
|
|
4085
|
-
|
|
4086
|
-
* @return {?}
|
|
4087
|
-
*/
|
|
4088
|
-
function ensureSelectorMetadata$1(target) {
|
|
4089
|
-
return ensureSelectorMetadata(target);
|
|
2088
|
+
function ensureSelectorMetadata(target) {
|
|
2089
|
+
return ensureSelectorMetadata$1(target);
|
|
4090
2090
|
}
|
|
4091
|
-
|
|
4092
|
-
|
|
4093
|
-
* @return {?}
|
|
4094
|
-
*/
|
|
4095
|
-
function getSelectorMetadata$1(target) {
|
|
4096
|
-
return getSelectorMetadata(target);
|
|
2091
|
+
function getSelectorMetadata(target) {
|
|
2092
|
+
return getSelectorMetadata$1(target);
|
|
4097
2093
|
}
|
|
4098
2094
|
|
|
4099
|
-
/**
|
|
4100
|
-
* @fileoverview added by tsickle
|
|
4101
|
-
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
4102
|
-
*/
|
|
4103
2095
|
/**
|
|
4104
2096
|
* Decorator for memoizing a state selector.
|
|
4105
|
-
* @template T
|
|
4106
|
-
* @param {?=} selectors
|
|
4107
|
-
* @return {?}
|
|
4108
2097
|
*/
|
|
4109
2098
|
function Selector(selectors) {
|
|
4110
|
-
return (
|
|
4111
|
-
* @template U
|
|
4112
|
-
* @param {?} target
|
|
4113
|
-
* @param {?} key
|
|
4114
|
-
* @param {?} descriptor
|
|
4115
|
-
* @return {?}
|
|
4116
|
-
*/
|
|
4117
|
-
(target, key, descriptor) => {
|
|
2099
|
+
return (target, key, descriptor) => {
|
|
4118
2100
|
// Caretaker note: we have still left the `typeof` condition in order to avoid
|
|
4119
2101
|
// creating a breaking change for projects that still use the View Engine.
|
|
4120
2102
|
if (typeof ngDevMode === 'undefined' || ngDevMode) {
|
|
4121
|
-
/** @type {?} */
|
|
4122
2103
|
const isNotMethod = !(descriptor && descriptor.value !== null);
|
|
4123
2104
|
if (isNotMethod) {
|
|
4124
2105
|
throwSelectorDecoratorError();
|
|
4125
2106
|
}
|
|
4126
2107
|
}
|
|
4127
|
-
/** @type {?} */
|
|
4128
2108
|
const originalFn = descriptor.value;
|
|
4129
|
-
|
|
4130
|
-
const memoizedFn = createSelector(selectors, (/** @type {?} */ (originalFn)), {
|
|
2109
|
+
const memoizedFn = createSelector(selectors, originalFn, {
|
|
4131
2110
|
containerClass: target,
|
|
4132
2111
|
selectorName: key.toString(),
|
|
4133
|
-
/**
|
|
4134
|
-
* @return {?}
|
|
4135
|
-
*/
|
|
4136
2112
|
getSelectorOptions() {
|
|
4137
2113
|
return {};
|
|
4138
2114
|
}
|
|
4139
2115
|
});
|
|
4140
|
-
/** @type {?} */
|
|
4141
2116
|
const newDescriptor = {
|
|
4142
2117
|
configurable: true,
|
|
4143
|
-
/**
|
|
4144
|
-
* @return {?}
|
|
4145
|
-
*/
|
|
4146
2118
|
get() {
|
|
4147
2119
|
return memoizedFn;
|
|
4148
2120
|
}
|
|
4149
2121
|
};
|
|
4150
2122
|
// Add hidden property to descriptor
|
|
4151
|
-
|
|
2123
|
+
newDescriptor['originalFn'] = originalFn;
|
|
4152
2124
|
return newDescriptor;
|
|
4153
|
-
}
|
|
2125
|
+
};
|
|
4154
2126
|
}
|
|
4155
2127
|
|
|
4156
|
-
/**
|
|
4157
|
-
* @fileoverview added by tsickle
|
|
4158
|
-
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
4159
|
-
*/
|
|
4160
|
-
/**
|
|
4161
|
-
* @template T
|
|
4162
|
-
*/
|
|
4163
2128
|
class StateToken {
|
|
4164
|
-
/**
|
|
4165
|
-
* @param {?} name
|
|
4166
|
-
*/
|
|
4167
2129
|
constructor(name) {
|
|
4168
2130
|
this.name = name;
|
|
4169
|
-
|
|
4170
|
-
|
|
4171
|
-
selectorMetadata.makeRootSelector = (/**
|
|
4172
|
-
* @param {?} runtimeContext
|
|
4173
|
-
* @return {?}
|
|
4174
|
-
*/
|
|
4175
|
-
(runtimeContext) => {
|
|
2131
|
+
const selectorMetadata = ensureSelectorMetadata$1(this);
|
|
2132
|
+
selectorMetadata.makeRootSelector = (runtimeContext) => {
|
|
4176
2133
|
return runtimeContext.getStateGetter(this.name);
|
|
4177
|
-
}
|
|
2134
|
+
};
|
|
4178
2135
|
}
|
|
4179
|
-
/**
|
|
4180
|
-
* @return {?}
|
|
4181
|
-
*/
|
|
4182
2136
|
getName() {
|
|
4183
2137
|
return this.name;
|
|
4184
2138
|
}
|
|
4185
|
-
/**
|
|
4186
|
-
* @return {?}
|
|
4187
|
-
*/
|
|
4188
2139
|
toString() {
|
|
4189
2140
|
return `StateToken[${this.name}]`;
|
|
4190
2141
|
}
|
|
4191
2142
|
}
|
|
4192
|
-
if (false) {
|
|
4193
|
-
/**
|
|
4194
|
-
* @type {?}
|
|
4195
|
-
* @private
|
|
4196
|
-
*/
|
|
4197
|
-
StateToken.prototype.name;
|
|
4198
|
-
}
|
|
4199
2143
|
|
|
4200
|
-
/**
|
|
4201
|
-
* @fileoverview added by tsickle
|
|
4202
|
-
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
4203
|
-
*/
|
|
4204
2144
|
class NgxsDevelopmentModule {
|
|
4205
|
-
/**
|
|
4206
|
-
* @param {?} options
|
|
4207
|
-
* @return {?}
|
|
4208
|
-
*/
|
|
4209
2145
|
static forRoot(options) {
|
|
4210
2146
|
return {
|
|
4211
2147
|
ngModule: NgxsDevelopmentModule,
|
|
@@ -4216,29 +2152,20 @@ class NgxsDevelopmentModule {
|
|
|
4216
2152
|
};
|
|
4217
2153
|
}
|
|
4218
2154
|
}
|
|
4219
|
-
NgxsDevelopmentModule
|
|
4220
|
-
|
|
4221
|
-
|
|
4222
|
-
|
|
4223
|
-
|
|
4224
|
-
|
|
4225
|
-
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
4226
|
-
*/
|
|
4227
|
-
|
|
4228
|
-
/**
|
|
4229
|
-
* @fileoverview added by tsickle
|
|
4230
|
-
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
4231
|
-
*/
|
|
2155
|
+
/** @nocollapse */ NgxsDevelopmentModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: NgxsDevelopmentModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
2156
|
+
/** @nocollapse */ NgxsDevelopmentModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: NgxsDevelopmentModule });
|
|
2157
|
+
/** @nocollapse */ NgxsDevelopmentModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: NgxsDevelopmentModule });
|
|
2158
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: NgxsDevelopmentModule, decorators: [{
|
|
2159
|
+
type: NgModule
|
|
2160
|
+
}] });
|
|
4232
2161
|
|
|
4233
2162
|
/**
|
|
4234
|
-
*
|
|
4235
|
-
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
2163
|
+
* The public api for consumers of @ngxs/store
|
|
4236
2164
|
*/
|
|
4237
2165
|
|
|
4238
2166
|
/**
|
|
4239
|
-
*
|
|
4240
|
-
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
2167
|
+
* Generated bundle index. Do not edit.
|
|
4241
2168
|
*/
|
|
4242
2169
|
|
|
4243
|
-
export { Action, Actions, InitState, NGXS_PLUGINS, NgxsDevelopmentModule, NgxsModule, NgxsSimpleChange, NgxsUnhandledActionsLogger, NoopNgxsExecutionStrategy, Select, Selector, SelectorOptions, State, StateStream, StateToken, Store, UpdateState, actionMatcher, createSelector, ensureSelectorMetadata
|
|
2170
|
+
export { Action, Actions, InitState, NGXS_PLUGINS, NgxsDevelopmentModule, NgxsModule, NgxsSimpleChange, NgxsUnhandledActionsLogger, NoopNgxsExecutionStrategy, Select, Selector, SelectorOptions, State, StateStream, StateToken, Store, UpdateState, actionMatcher, createSelector, ensureSelectorMetadata, ensureStoreMetadata, getActionTypeFromInstance, getSelectorMetadata, getStoreMetadata, getValue, ofAction, ofActionCanceled, ofActionCompleted, ofActionDispatched, ofActionErrored, ofActionSuccessful, setValue, NgxsFeatureModule as ɵNgxsFeatureModule, NgxsRootModule as ɵNgxsRootModule };
|
|
4244
2171
|
//# sourceMappingURL=ngxs-store.js.map
|