@ngxs/store 3.7.6-dev.master-1bdb8c0 → 3.7.6-dev.master-dcdd391

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