@ngxs/store 3.7.6 → 3.8.0-dev.master-743a236

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 (267) 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 +62 -402
  6. package/bundles/ngxs-store-operators.umd.js.map +1 -1
  7. package/bundles/ngxs-store.umd.js +1296 -3219
  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 -22
  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 +2 -6
  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 -23
  35. package/esm2015/operators/remove-item.js +5 -17
  36. package/esm2015/operators/types.js +2 -0
  37. package/esm2015/operators/update-item.js +13 -25
  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 +20 -122
  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 +11 -38
  48. package/esm2015/src/decorators/selector/symbols.js +2 -5
  49. package/esm2015/src/decorators/selector-options.js +6 -19
  50. package/esm2015/src/decorators/state.js +5 -44
  51. package/esm2015/src/dev-features/ngxs-development.module.js +22 -0
  52. package/esm2015/src/dev-features/ngxs-unhandled-actions-logger.js +46 -0
  53. package/esm2015/src/dev-features/symbols.js +6 -0
  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/custom-rxjs-subjects.js +81 -0
  59. package/esm2015/src/internal/dispatcher.js +26 -121
  60. package/esm2015/src/internal/error-handler.js +18 -72
  61. package/esm2015/src/internal/internals.js +24 -244
  62. package/esm2015/src/internal/lifecycle-state-manager.js +19 -117
  63. package/esm2015/src/internal/state-context-factory.js +8 -66
  64. package/esm2015/src/internal/state-factory.js +60 -227
  65. package/esm2015/src/internal/state-operations.js +19 -80
  66. package/esm2015/src/internal/state-operators.js +15 -28
  67. package/esm2015/src/internal/state-stream.js +9 -15
  68. package/esm2015/src/ivy/ivy-enabled-in-dev-mode.js +7 -17
  69. package/esm2015/src/module.js +12 -47
  70. package/esm2015/src/modules/ngxs-feature.module.js +18 -36
  71. package/esm2015/src/modules/ngxs-root.module.js +18 -26
  72. package/esm2015/src/operators/leave-ngxs.js +8 -43
  73. package/esm2015/src/operators/of-action.js +16 -105
  74. package/esm2015/src/plugin-manager.js +17 -50
  75. package/esm2015/src/plugin_api.js +1 -5
  76. package/esm2015/src/private_api.js +3 -0
  77. package/esm2015/src/public_api.js +7 -9
  78. package/esm2015/src/public_to_deprecate.js +1 -51
  79. package/esm2015/src/selectors/create-model-selector.js +28 -0
  80. package/esm2015/src/selectors/create-pick-selector.js +14 -0
  81. package/esm2015/src/selectors/create-property-selectors.js +18 -0
  82. package/esm2015/src/selectors/create-selector.js +9 -0
  83. package/esm2015/src/selectors/index.js +6 -0
  84. package/esm2015/src/selectors/selector-checks.util.js +18 -0
  85. package/esm2015/src/selectors/selector-metadata.js +30 -0
  86. package/esm2015/src/selectors/selector-models.js +2 -0
  87. package/esm2015/src/selectors/selector-types.util.js +2 -0
  88. package/esm2015/src/selectors/selector-utils.js +74 -0
  89. package/esm2015/src/state-token/state-token.js +4 -32
  90. package/esm2015/src/state-token/symbols.js +2 -5
  91. package/esm2015/src/store.js +24 -108
  92. package/esm2015/src/symbols.js +7 -177
  93. package/esm2015/src/utils/compose.js +5 -23
  94. package/esm2015/src/utils/freeze.js +5 -20
  95. package/esm2015/src/utils/store-validators.js +3 -36
  96. package/esm2015/src/utils/utils.js +13 -64
  97. package/fesm2015/ngxs-store-internals-testing.js +38 -159
  98. package/fesm2015/ngxs-store-internals-testing.js.map +1 -1
  99. package/fesm2015/ngxs-store-internals.js +18 -100
  100. package/fesm2015/ngxs-store-internals.js.map +1 -1
  101. package/fesm2015/ngxs-store-operators.js +54 -186
  102. package/fesm2015/ngxs-store-operators.js.map +1 -1
  103. package/fesm2015/ngxs-store.js +662 -2488
  104. package/fesm2015/ngxs-store.js.map +1 -1
  105. package/index.d.ts +4 -0
  106. package/internals/index.d.ts +1 -1
  107. package/internals/internal-tokens.d.ts +2 -8
  108. package/internals/ngxs-bootstrapper.d.ts +4 -1
  109. package/internals/ngxs-store-internals.d.ts +1 -0
  110. package/internals/package.json +2 -5
  111. package/internals/testing/helpers/ngxs-test.component.d.ts +3 -0
  112. package/internals/testing/helpers/ngxs-test.module.d.ts +6 -0
  113. package/internals/testing/ngxs-store-internals-testing.d.ts +1 -0
  114. package/internals/testing/package.json +2 -5
  115. package/ngxs-store.d.ts +1 -17
  116. package/operators/append.d.ts +2 -3
  117. package/operators/compose.d.ts +2 -2
  118. package/operators/iif.d.ts +3 -4
  119. package/operators/index.d.ts +3 -2
  120. package/operators/insert-item.d.ts +2 -3
  121. package/operators/ngxs-store-operators.d.ts +1 -0
  122. package/operators/package.json +2 -5
  123. package/operators/patch.d.ts +5 -8
  124. package/operators/remove-item.d.ts +3 -4
  125. package/operators/types.d.ts +56 -0
  126. package/operators/update-item.d.ts +3 -4
  127. package/operators/utils.d.ts +2 -3
  128. package/package.json +4 -7
  129. package/src/actions/actions.d.ts +2 -2
  130. package/src/actions-stream.d.ts +8 -22
  131. package/src/decorators/select/select-factory.d.ts +3 -0
  132. package/src/decorators/selector/selector.d.ts +7 -2
  133. package/src/decorators/state.d.ts +1 -1
  134. package/src/dev-features/ngxs-development.module.d.ts +9 -0
  135. package/src/dev-features/ngxs-unhandled-actions-logger.d.ts +17 -0
  136. package/src/dev-features/symbols.d.ts +8 -0
  137. package/src/execution/dispatch-outside-zone-ngxs-execution-strategy.d.ts +3 -0
  138. package/src/execution/internal-ngxs-execution-strategy.d.ts +3 -0
  139. package/src/execution/noop-ngxs-execution-strategy.d.ts +3 -0
  140. package/src/internal/custom-rxjs-subjects.d.ts +37 -0
  141. package/src/internal/dispatcher.d.ts +5 -0
  142. package/src/internal/error-handler.d.ts +4 -1
  143. package/src/internal/lifecycle-state-manager.d.ts +3 -0
  144. package/src/internal/state-context-factory.d.ts +3 -0
  145. package/src/internal/state-factory.d.ts +7 -4
  146. package/src/internal/state-operations.d.ts +3 -0
  147. package/src/internal/state-operators.d.ts +2 -2
  148. package/src/internal/state-stream.d.ts +5 -2
  149. package/src/module.d.ts +4 -0
  150. package/src/modules/ngxs-feature.module.d.ts +4 -0
  151. package/src/modules/ngxs-root.module.d.ts +4 -0
  152. package/src/operators/of-action.d.ts +20 -7
  153. package/src/plugin-manager.d.ts +4 -1
  154. package/src/private_api.d.ts +2 -0
  155. package/src/public_api.d.ts +8 -5
  156. package/src/selectors/create-model-selector.d.ts +10 -0
  157. package/src/selectors/create-pick-selector.d.ts +6 -0
  158. package/src/selectors/create-property-selectors.d.ts +5 -0
  159. package/src/selectors/create-selector.d.ts +19 -0
  160. package/src/selectors/index.d.ts +5 -0
  161. package/src/selectors/selector-checks.util.d.ts +9 -0
  162. package/src/selectors/selector-metadata.d.ts +7 -0
  163. package/src/selectors/selector-models.d.ts +10 -0
  164. package/src/selectors/selector-types.util.d.ts +7 -0
  165. package/src/selectors/selector-utils.d.ts +9 -0
  166. package/src/store.d.ts +3 -0
  167. package/src/symbols.d.ts +7 -3
  168. package/src/utils/utils.d.ts +1 -1
  169. package/bundles/ngxs-store-internals-testing.umd.min.js +0 -16
  170. package/bundles/ngxs-store-internals-testing.umd.min.js.map +0 -1
  171. package/bundles/ngxs-store-internals.umd.min.js +0 -2
  172. package/bundles/ngxs-store-internals.umd.min.js.map +0 -1
  173. package/bundles/ngxs-store-operators.umd.min.js +0 -16
  174. package/bundles/ngxs-store-operators.umd.min.js.map +0 -1
  175. package/bundles/ngxs-store.umd.min.js +0 -16
  176. package/bundles/ngxs-store.umd.min.js.map +0 -1
  177. package/esm2015/operators/internals.js +0 -5
  178. package/esm2015/src/utils/selector-utils.js +0 -221
  179. package/esm5/index.js +0 -13
  180. package/esm5/internals/angular.js +0 -20
  181. package/esm5/internals/index.js +0 -10
  182. package/esm5/internals/initial-state.js +0 -45
  183. package/esm5/internals/internal-tokens.js +0 -16
  184. package/esm5/internals/memoize.js +0 -71
  185. package/esm5/internals/ngxs-bootstrapper.js +0 -56
  186. package/esm5/internals/ngxs-store-internals.js +0 -9
  187. package/esm5/internals/src/symbols.js +0 -14
  188. package/esm5/internals/symbols.js +0 -14
  189. package/esm5/internals/testing/fresh-platform.js +0 -121
  190. package/esm5/internals/testing/helpers/ngxs-test.component.js +0 -32
  191. package/esm5/internals/testing/helpers/ngxs-test.module.js +0 -32
  192. package/esm5/internals/testing/index.js +0 -8
  193. package/esm5/internals/testing/ngxs-store-internals-testing.js +0 -9
  194. package/esm5/internals/testing/ngxs.setup.js +0 -98
  195. package/esm5/internals/testing/skip-console-logging.js +0 -62
  196. package/esm5/internals/testing/symbol.js +0 -29
  197. package/esm5/ngxs-store.js +0 -25
  198. package/esm5/operators/append.js +0 -31
  199. package/esm5/operators/compose.js +0 -28
  200. package/esm5/operators/iif.js +0 -56
  201. package/esm5/operators/index.js +0 -18
  202. package/esm5/operators/insert-item.js +0 -41
  203. package/esm5/operators/internals.js +0 -5
  204. package/esm5/operators/ngxs-store-operators.js +0 -9
  205. package/esm5/operators/patch.js +0 -40
  206. package/esm5/operators/remove-item.js +0 -34
  207. package/esm5/operators/update-item.js +0 -52
  208. package/esm5/operators/utils.js +0 -50
  209. package/esm5/src/actions/actions.js +0 -62
  210. package/esm5/src/actions/symbols.js +0 -39
  211. package/esm5/src/actions-stream.js +0 -203
  212. package/esm5/src/configs/messages.config.js +0 -79
  213. package/esm5/src/decorators/action.js +0 -60
  214. package/esm5/src/decorators/select/select-factory.js +0 -46
  215. package/esm5/src/decorators/select/select.js +0 -50
  216. package/esm5/src/decorators/select/symbols.js +0 -51
  217. package/esm5/src/decorators/selector/selector.js +0 -59
  218. package/esm5/src/decorators/selector/symbols.js +0 -5
  219. package/esm5/src/decorators/selector-options.js +0 -34
  220. package/esm5/src/decorators/state.js +0 -78
  221. package/esm5/src/execution/dispatch-outside-zone-ngxs-execution-strategy.js +0 -123
  222. package/esm5/src/execution/internal-ngxs-execution-strategy.js +0 -54
  223. package/esm5/src/execution/noop-ngxs-execution-strategy.js +0 -43
  224. package/esm5/src/execution/symbols.js +0 -52
  225. package/esm5/src/internal/dispatcher.js +0 -231
  226. package/esm5/src/internal/error-handler.js +0 -125
  227. package/esm5/src/internal/internals.js +0 -470
  228. package/esm5/src/internal/lifecycle-state-manager.js +0 -224
  229. package/esm5/src/internal/state-context-factory.js +0 -135
  230. package/esm5/src/internal/state-factory.js +0 -583
  231. package/esm5/src/internal/state-operations.js +0 -134
  232. package/esm5/src/internal/state-operators.js +0 -34
  233. package/esm5/src/internal/state-stream.js +0 -37
  234. package/esm5/src/ivy/ivy-enabled-in-dev-mode.js +0 -28
  235. package/esm5/src/module.js +0 -202
  236. package/esm5/src/modules/ngxs-feature.module.js +0 -65
  237. package/esm5/src/modules/ngxs-root.module.js +0 -44
  238. package/esm5/src/operators/leave-ngxs.js +0 -58
  239. package/esm5/src/operators/of-action.js +0 -217
  240. package/esm5/src/plugin-manager.js +0 -82
  241. package/esm5/src/plugin_api.js +0 -10
  242. package/esm5/src/public_api.js +0 -29
  243. package/esm5/src/public_to_deprecate.js +0 -64
  244. package/esm5/src/state-token/state-token.js +0 -57
  245. package/esm5/src/state-token/symbols.js +0 -5
  246. package/esm5/src/store.js +0 -241
  247. package/esm5/src/symbols.js +0 -230
  248. package/esm5/src/utils/compose.js +0 -55
  249. package/esm5/src/utils/freeze.js +0 -35
  250. package/esm5/src/utils/selector-utils.js +0 -230
  251. package/esm5/src/utils/store-validators.js +0 -78
  252. package/esm5/src/utils/utils.js +0 -151
  253. package/fesm5/ngxs-store-internals-testing.js +0 -345
  254. package/fesm5/ngxs-store-internals-testing.js.map +0 -1
  255. package/fesm5/ngxs-store-internals.js +0 -217
  256. package/fesm5/ngxs-store-internals.js.map +0 -1
  257. package/fesm5/ngxs-store-operators.js +0 -340
  258. package/fesm5/ngxs-store-operators.js.map +0 -1
  259. package/fesm5/ngxs-store.js +0 -4619
  260. package/fesm5/ngxs-store.js.map +0 -1
  261. package/internals/ngxs-store-internals.metadata.json +0 -1
  262. package/internals/testing/ngxs-store-internals-testing.metadata.json +0 -1
  263. package/ngxs-store.metadata.json +0 -1
  264. package/operators/internals.d.ts +0 -2
  265. package/operators/ngxs-store-operators.metadata.json +0 -1
  266. package/src/utils/selector-utils.d.ts +0 -23
  267. package/types/index.d.ts +0 -2
@@ -1,4619 +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
- * @param {...?} allowedTypes
1154
- * @return {?}
1155
- */
1156
- function ofAction() {
1157
- var allowedTypes = [];
1158
- for (var _i = 0; _i < arguments.length; _i++) {
1159
- allowedTypes[_i] = arguments[_i];
1160
- }
1161
- return ofActionOperator(allowedTypes);
1162
- }
1163
- /**
1164
- * RxJS operator for selecting out specific actions.
1165
- *
1166
- * This will ONLY grab actions that have just been dispatched
1167
- * @param {...?} allowedTypes
1168
- * @return {?}
1169
- */
1170
- function ofActionDispatched() {
1171
- var allowedTypes = [];
1172
- for (var _i = 0; _i < arguments.length; _i++) {
1173
- allowedTypes[_i] = arguments[_i];
1174
- }
1175
- return ofActionOperator(allowedTypes, ["DISPATCHED" /* Dispatched */]);
1176
- }
1177
- /**
1178
- * RxJS operator for selecting out specific actions.
1179
- *
1180
- * This will ONLY grab actions that have just been successfully completed
1181
- * @param {...?} allowedTypes
1182
- * @return {?}
1183
- */
1184
- function ofActionSuccessful() {
1185
- var allowedTypes = [];
1186
- for (var _i = 0; _i < arguments.length; _i++) {
1187
- allowedTypes[_i] = arguments[_i];
1188
- }
1189
- return ofActionOperator(allowedTypes, ["SUCCESSFUL" /* Successful */]);
1190
- }
1191
- /**
1192
- * RxJS operator for selecting out specific actions.
1193
- *
1194
- * This will ONLY grab actions that have just been canceled
1195
- * @param {...?} allowedTypes
1196
- * @return {?}
1197
- */
1198
- function ofActionCanceled() {
1199
- var allowedTypes = [];
1200
- for (var _i = 0; _i < arguments.length; _i++) {
1201
- allowedTypes[_i] = arguments[_i];
1202
- }
1203
- return ofActionOperator(allowedTypes, ["CANCELED" /* Canceled */]);
1204
- }
1205
- /**
1206
- * RxJS operator for selecting out specific actions.
1207
- *
1208
- * This will ONLY grab actions that have just been completed
1209
- * @param {...?} allowedTypes
1210
- * @return {?}
1211
- */
1212
- function ofActionCompleted() {
1213
- var allowedTypes = [];
1214
- for (var _i = 0; _i < arguments.length; _i++) {
1215
- allowedTypes[_i] = arguments[_i];
1216
- }
1217
- /** @type {?} */
1218
- var allowedStatuses = [
1219
- "SUCCESSFUL" /* Successful */,
1220
- "CANCELED" /* Canceled */,
1221
- "ERRORED" /* Errored */
1222
- ];
1223
- return ofActionOperator(allowedTypes, allowedStatuses, mapActionResult);
1224
- }
1225
- /**
1226
- * RxJS operator for selecting out specific actions.
1227
- *
1228
- * This will ONLY grab actions that have just thrown an error
1229
- * @param {...?} allowedTypes
1230
- * @return {?}
1231
- */
1232
- function ofActionErrored() {
1233
- var allowedTypes = [];
1234
- for (var _i = 0; _i < arguments.length; _i++) {
1235
- allowedTypes[_i] = arguments[_i];
1236
- }
1237
- return ofActionOperator(allowedTypes, ["ERRORED" /* Errored */]);
1238
- }
1239
- /**
1240
- * @param {?} allowedTypes
1241
- * @param {?=} statuses
1242
- * @param {?=} mapOperator
1243
- * @return {?}
1244
- */
1245
- function ofActionOperator(allowedTypes, statuses,
1246
- // This actually could've been `OperatorFunction<ActionContext, ActionCompletion | any>`,
1247
- // since it maps either to `ctx.action` OR to `ActionCompletion`. But `ActionCompleteion | any`
1248
- // defaults to `any`, thus there is no sense from union type.
1249
- mapOperator) {
1250
- if (mapOperator === void 0) { mapOperator = mapAction; }
1251
- /** @type {?} */
1252
- var allowedMap = createAllowedActionTypesMap(allowedTypes);
1253
- /** @type {?} */
1254
- var allowedStatusMap = statuses && createAllowedStatusesMap(statuses);
1255
- return (/**
1256
- * @param {?} o
1257
- * @return {?}
1258
- */
1259
- function (o) {
1260
- return o.pipe(filterStatus(allowedMap, allowedStatusMap), mapOperator());
1261
- });
1262
- }
1263
- /**
1264
- * @param {?} allowedTypes
1265
- * @param {?=} allowedStatuses
1266
- * @return {?}
1267
- */
1268
- function filterStatus(allowedTypes, allowedStatuses) {
1269
- return filter((/**
1270
- * @param {?} ctx
1271
- * @return {?}
1272
- */
1273
- function (ctx) {
1274
- /** @type {?} */
1275
- var actionType = (/** @type {?} */ (getActionTypeFromInstance(ctx.action)));
1276
- /** @type {?} */
1277
- var typeMatch = allowedTypes[actionType];
1278
- /** @type {?} */
1279
- var statusMatch = allowedStatuses ? allowedStatuses[ctx.status] : true;
1280
- return typeMatch && statusMatch;
1281
- }));
1282
- }
1283
- /**
1284
- * @return {?}
1285
- */
1286
- function mapActionResult() {
1287
- return map((/**
1288
- * @param {?} __0
1289
- * @return {?}
1290
- */
1291
- function (_a) {
1292
- var action = _a.action, status = _a.status, error = _a.error;
1293
- return (/** @type {?} */ ({
1294
- action: action,
1295
- result: {
1296
- successful: "SUCCESSFUL" /* Successful */ === status,
1297
- canceled: "CANCELED" /* Canceled */ === status,
1298
- error: error
1299
- }
1300
- }));
1301
- }));
1302
- }
1303
- /**
1304
- * @template T
1305
- * @return {?}
1306
- */
1307
- function mapAction() {
1308
- return map((/**
1309
- * @param {?} ctx
1310
- * @return {?}
1311
- */
1312
- function (ctx) { return (/** @type {?} */ (ctx.action)); }));
1313
- }
1314
- /**
1315
- * @record
1316
- */
1317
- function FilterMap() { }
1318
- /**
1319
- * @param {?} types
1320
- * @return {?}
1321
- */
1322
- function createAllowedActionTypesMap(types) {
1323
- return types.reduce((/**
1324
- * @param {?} filterMap
1325
- * @param {?} klass
1326
- * @return {?}
1327
- */
1328
- function (filterMap, klass) {
1329
- filterMap[(/** @type {?} */ (getActionTypeFromInstance(klass)))] = true;
1330
- return filterMap;
1331
- }), (/** @type {?} */ ({})));
1332
- }
1333
- /**
1334
- * @param {?} statuses
1335
- * @return {?}
1336
- */
1337
- function createAllowedStatusesMap(statuses) {
1338
- return statuses.reduce((/**
1339
- * @param {?} filterMap
1340
- * @param {?} status
1341
- * @return {?}
1342
- */
1343
- function (filterMap, status) {
1344
- filterMap[status] = true;
1345
- return filterMap;
1346
- }), (/** @type {?} */ ({})));
1347
- }
1348
-
1349
- /**
1350
- * @fileoverview added by tsickle
1351
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
1352
- */
1353
- /**
1354
- * Returns operator that will run
1355
- * `subscribe` outside of the ngxs execution context
1356
- * @template T
1357
- * @param {?} ngxsExecutionStrategy
1358
- * @return {?}
1359
- */
1360
- function leaveNgxs(ngxsExecutionStrategy) {
1361
- return (/**
1362
- * @param {?} source
1363
- * @return {?}
1364
- */
1365
- function (source) {
1366
- return new Observable((/**
1367
- * @param {?} sink
1368
- * @return {?}
1369
- */
1370
- function (sink) {
1371
- return source.subscribe({
1372
- next: /**
1373
- * @param {?} value
1374
- * @return {?}
1375
- */
1376
- function (value) {
1377
- ngxsExecutionStrategy.leave((/**
1378
- * @return {?}
1379
- */
1380
- function () { return sink.next(value); }));
1381
- },
1382
- error: /**
1383
- * @param {?} error
1384
- * @return {?}
1385
- */
1386
- function (error) {
1387
- ngxsExecutionStrategy.leave((/**
1388
- * @return {?}
1389
- */
1390
- function () { return sink.error(error); }));
1391
- },
1392
- complete: /**
1393
- * @return {?}
1394
- */
1395
- function () {
1396
- ngxsExecutionStrategy.leave((/**
1397
- * @return {?}
1398
- */
1399
- function () { return sink.complete(); }));
1400
- }
1401
- });
1402
- }));
1403
- });
1404
- }
1405
-
1406
- /**
1407
- * @fileoverview added by tsickle
1408
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
1409
- */
1410
- var InternalNgxsExecutionStrategy = /** @class */ (function () {
1411
- function InternalNgxsExecutionStrategy(_executionStrategy) {
1412
- this._executionStrategy = _executionStrategy;
1413
- }
1414
- /**
1415
- * @template T
1416
- * @param {?} func
1417
- * @return {?}
1418
- */
1419
- InternalNgxsExecutionStrategy.prototype.enter = /**
1420
- * @template T
1421
- * @param {?} func
1422
- * @return {?}
1423
- */
1424
- function (func) {
1425
- return this._executionStrategy.enter(func);
1426
- };
1427
- /**
1428
- * @template T
1429
- * @param {?} func
1430
- * @return {?}
1431
- */
1432
- InternalNgxsExecutionStrategy.prototype.leave = /**
1433
- * @template T
1434
- * @param {?} func
1435
- * @return {?}
1436
- */
1437
- function (func) {
1438
- return this._executionStrategy.leave(func);
1439
- };
1440
- InternalNgxsExecutionStrategy.decorators = [
1441
- { type: Injectable }
1442
- ];
1443
- /** @nocollapse */
1444
- InternalNgxsExecutionStrategy.ctorParameters = function () { return [
1445
- { type: undefined, decorators: [{ type: Inject, args: [NGXS_EXECUTION_STRATEGY,] }] }
1446
- ]; };
1447
- return InternalNgxsExecutionStrategy;
1448
- }());
1449
- if (false) {
1450
- /**
1451
- * @type {?}
1452
- * @private
1453
- */
1454
- InternalNgxsExecutionStrategy.prototype._executionStrategy;
1455
- }
1456
-
1457
- /**
1458
- * @fileoverview added by tsickle
1459
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
1460
- */
1461
- /** @enum {string} */
1462
- var ActionStatus = {
1463
- Dispatched: 'DISPATCHED',
1464
- Successful: 'SUCCESSFUL',
1465
- Canceled: 'CANCELED',
1466
- Errored: 'ERRORED',
1467
- };
1468
- /**
1469
- * @record
1470
- * @template T
1471
- */
1472
- function ActionContext() { }
1473
- if (false) {
1474
- /** @type {?} */
1475
- ActionContext.prototype.status;
1476
- /** @type {?} */
1477
- ActionContext.prototype.action;
1478
- /** @type {?|undefined} */
1479
- ActionContext.prototype.error;
1480
- }
1481
- /**
1482
- * Custom Subject that ensures that subscribers are notified of values in the order that they arrived.
1483
- * A standard Subject does not have this guarantee.
1484
- * For example, given the following code:
1485
- * ```typescript
1486
- * const subject = new Subject<string>();
1487
- * subject.subscribe(value => {
1488
- * if (value === 'start') subject.next('end');
1489
- * });
1490
- * subject.subscribe(value => { });
1491
- * subject.next('start');
1492
- * ```
1493
- * When `subject` is a standard `Subject<T>` the second subscriber would recieve `end` and then `start`.
1494
- * When `subject` is a `OrderedSubject<T>` the second subscriber would recieve `start` and then `end`.
1495
- * @template T
1496
- */
1497
- var /**
1498
- * Custom Subject that ensures that subscribers are notified of values in the order that they arrived.
1499
- * A standard Subject does not have this guarantee.
1500
- * For example, given the following code:
1501
- * ```typescript
1502
- * const subject = new Subject<string>();
1503
- * subject.subscribe(value => {
1504
- * if (value === 'start') subject.next('end');
1505
- * });
1506
- * subject.subscribe(value => { });
1507
- * subject.next('start');
1508
- * ```
1509
- * When `subject` is a standard `Subject<T>` the second subscriber would recieve `end` and then `start`.
1510
- * When `subject` is a `OrderedSubject<T>` the second subscriber would recieve `start` and then `end`.
1511
- * @template T
1512
- */
1513
- OrderedSubject = /** @class */ (function (_super) {
1514
- __extends(OrderedSubject, _super);
1515
- function OrderedSubject() {
1516
- var _this = _super !== null && _super.apply(this, arguments) || this;
1517
- _this._itemQueue = [];
1518
- _this._busyPushingNext = false;
1519
- return _this;
1520
- }
1521
- /**
1522
- * @param {?=} value
1523
- * @return {?}
1524
- */
1525
- OrderedSubject.prototype.next = /**
1526
- * @param {?=} value
1527
- * @return {?}
1528
- */
1529
- function (value) {
1530
- if (this._busyPushingNext) {
1531
- this._itemQueue.unshift((/** @type {?} */ (value)));
1532
- return;
1533
- }
1534
- this._busyPushingNext = true;
1535
- _super.prototype.next.call(this, value);
1536
- while (this._itemQueue.length > 0) {
1537
- /** @type {?} */
1538
- var nextValue = this._itemQueue.pop();
1539
- _super.prototype.next.call(this, nextValue);
1540
- }
1541
- this._busyPushingNext = false;
1542
- };
1543
- return OrderedSubject;
1544
- }(Subject));
1545
- if (false) {
1546
- /**
1547
- * @type {?}
1548
- * @private
1549
- */
1550
- OrderedSubject.prototype._itemQueue;
1551
- /**
1552
- * @type {?}
1553
- * @private
1554
- */
1555
- OrderedSubject.prototype._busyPushingNext;
1556
- }
1557
- /**
1558
- * Internal Action stream that is emitted anytime an action is dispatched.
1559
- */
1560
- var InternalActions = /** @class */ (function (_super) {
1561
- __extends(InternalActions, _super);
1562
- function InternalActions() {
1563
- return _super !== null && _super.apply(this, arguments) || this;
1564
- }
1565
- /**
1566
- * @return {?}
1567
- */
1568
- InternalActions.prototype.ngOnDestroy = /**
1569
- * @return {?}
1570
- */
1571
- function () {
1572
- this.complete();
1573
- };
1574
- InternalActions.decorators = [
1575
- { type: Injectable }
1576
- ];
1577
- return InternalActions;
1578
- }(OrderedSubject));
1579
- /**
1580
- * Action stream that is emitted anytime an action is dispatched.
1581
- *
1582
- * You can listen to this in services to react without stores.
1583
- */
1584
- var Actions = /** @class */ (function (_super) {
1585
- __extends(Actions, _super);
1586
- // This has to be `Observable<ActionContext>` in the v4. Because `InternalActions`
1587
- // is a `Subject<ActionContext>`. Leave it as `any` to avoid breaking changes
1588
- function Actions(internalActions$, internalExecutionStrategy) {
1589
- var _this = this;
1590
- /** @type {?} */
1591
- var sharedInternalActions$ = internalActions$.pipe(leaveNgxs(internalExecutionStrategy),
1592
- // The `InternalActions` subject emits outside of the Angular zone.
1593
- // We have to re-enter the Angular zone for any incoming consumer.
1594
- // The `share()` operator reduces the number of change detections.
1595
- // This would call leave only once for any stream emission across all active subscribers.
1596
- share());
1597
- _this = _super.call(this, (/**
1598
- * @param {?} observer
1599
- * @return {?}
1600
- */
1601
- function (observer) {
1602
- /** @type {?} */
1603
- var childSubscription = sharedInternalActions$.subscribe({
1604
- next: (/**
1605
- * @param {?} ctx
1606
- * @return {?}
1607
- */
1608
- function (ctx) { return observer.next(ctx); }),
1609
- error: (/**
1610
- * @param {?} error
1611
- * @return {?}
1612
- */
1613
- function (error) { return observer.error(error); }),
1614
- complete: (/**
1615
- * @return {?}
1616
- */
1617
- function () { return observer.complete(); })
1618
- });
1619
- observer.add(childSubscription);
1620
- })) || this;
1621
- return _this;
1622
- }
1623
- Actions.decorators = [
1624
- { type: Injectable }
1625
- ];
1626
- /** @nocollapse */
1627
- Actions.ctorParameters = function () { return [
1628
- { type: InternalActions },
1629
- { type: InternalNgxsExecutionStrategy }
1630
- ]; };
1631
- return Actions;
1632
- }(Observable));
1633
-
1634
- /**
1635
- * @fileoverview added by tsickle
1636
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
1637
- */
1638
- /**
1639
- * Composes a array of functions from left to right. Example:
1640
- *
1641
- * compose([fn, final])(state, action);
1642
- *
1643
- * then the funcs have a signature like:
1644
- *
1645
- * function fn (state, action, next) {
1646
- * console.log('here', state, action, next);
1647
- * return next(state, action);
1648
- * }
1649
- *
1650
- * function final (state, action) {
1651
- * console.log('here', state, action);
1652
- * return state;
1653
- * }
1654
- *
1655
- * the last function should not call `next`.
1656
- *
1657
- * @ignore
1658
- * @type {?}
1659
- */
1660
- var compose = (/**
1661
- * @param {?} funcs
1662
- * @return {?}
1663
- */
1664
- function (funcs) { return (/**
1665
- * @param {...?} args
1666
- * @return {?}
1667
- */
1668
- function () {
1669
- var args = [];
1670
- for (var _i = 0; _i < arguments.length; _i++) {
1671
- args[_i] = arguments[_i];
1672
- }
1673
- /** @type {?} */
1674
- var curr = (/** @type {?} */ (funcs.shift()));
1675
- return curr.apply(void 0, __spread(args, [(/**
1676
- * @param {...?} nextArgs
1677
- * @return {?}
1678
- */
1679
- function () {
1680
- var nextArgs = [];
1681
- for (var _i = 0; _i < arguments.length; _i++) {
1682
- nextArgs[_i] = arguments[_i];
1683
- }
1684
- return compose(funcs).apply(void 0, __spread(nextArgs));
1685
- })]));
1686
- }); });
1687
-
1688
- /**
1689
- * @fileoverview added by tsickle
1690
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
1691
- */
1692
- /**
1693
- * This operator is used for piping the observable result
1694
- * from the `dispatch()`. It has a "smart" error handling
1695
- * strategy that allows us to decide whether we propagate
1696
- * errors to Angular's `ErrorHandler` or enable users to
1697
- * handle them manually. We consider following cases:
1698
- * 1) `store.dispatch()` (no subscribe) -> call `handleError()`
1699
- * 2) `store.dispatch().subscribe()` (no error callback) -> call `handleError()`
1700
- * 3) `store.dispatch().subscribe({ error: ... })` -> don't call `handleError()`
1701
- * 4) `toPromise()` without `catch` -> do `handleError()`
1702
- * 5) `toPromise()` with `catch` -> don't `handleError()`
1703
- * @template T
1704
- * @param {?} internalErrorReporter
1705
- * @param {?} ngxsExecutionStrategy
1706
- * @return {?}
1707
- */
1708
- function ngxsErrorHandler(internalErrorReporter, ngxsExecutionStrategy) {
1709
- return (/**
1710
- * @param {?} source
1711
- * @return {?}
1712
- */
1713
- function (source) {
1714
- /** @type {?} */
1715
- var subscribed = false;
1716
- source.subscribe({
1717
- error: (/**
1718
- * @param {?} error
1719
- * @return {?}
1720
- */
1721
- function (error) {
1722
- // Do not trigger change detection for a microtask. This depends on the execution
1723
- // strategy being used, but the default `DispatchOutsideZoneNgxsExecutionStrategy`
1724
- // leaves the Angular zone.
1725
- ngxsExecutionStrategy.enter((/**
1726
- * @return {?}
1727
- */
1728
- function () {
1729
- return Promise.resolve().then((/**
1730
- * @return {?}
1731
- */
1732
- function () {
1733
- if (!subscribed) {
1734
- ngxsExecutionStrategy.leave((/**
1735
- * @return {?}
1736
- */
1737
- function () {
1738
- return internalErrorReporter.reportErrorSafely(error);
1739
- }));
1740
- }
1741
- }));
1742
- }));
1743
- })
1744
- });
1745
- return new Observable((/**
1746
- * @param {?} subscriber
1747
- * @return {?}
1748
- */
1749
- function (subscriber) {
1750
- subscribed = true;
1751
- return source.pipe(leaveNgxs(ngxsExecutionStrategy)).subscribe(subscriber);
1752
- }));
1753
- });
1754
- }
1755
- var InternalErrorReporter = /** @class */ (function () {
1756
- function InternalErrorReporter(_injector) {
1757
- this._injector = _injector;
1758
- /**
1759
- * Will be set lazily to be backward compatible.
1760
- */
1761
- this._errorHandler = (/** @type {?} */ (null));
1762
- }
1763
- /**
1764
- * @param {?} error
1765
- * @return {?}
1766
- */
1767
- InternalErrorReporter.prototype.reportErrorSafely = /**
1768
- * @param {?} error
1769
- * @return {?}
1770
- */
1771
- function (error) {
1772
- if (this._errorHandler === null) {
1773
- this._errorHandler = this._injector.get(ErrorHandler);
1774
- }
1775
- // The `try-catch` is used to avoid handling the error twice. Suppose we call
1776
- // `handleError` which re-throws the error internally. The re-thrown error will
1777
- // be caught by zone.js which will then get to the `zone.onError.emit()` and the
1778
- // `onError` subscriber will call `handleError` again.
1779
- try {
1780
- this._errorHandler.handleError(error);
1781
- }
1782
- catch (_a) { }
1783
- };
1784
- InternalErrorReporter.decorators = [
1785
- { type: Injectable, args: [{ providedIn: 'root' },] }
1786
- ];
1787
- /** @nocollapse */
1788
- InternalErrorReporter.ctorParameters = function () { return [
1789
- { type: Injector }
1790
- ]; };
1791
- /** @nocollapse */ InternalErrorReporter.ngInjectableDef = defineInjectable({ factory: function InternalErrorReporter_Factory() { return new InternalErrorReporter(inject(INJECTOR)); }, token: InternalErrorReporter, providedIn: "root" });
1792
- return InternalErrorReporter;
1793
- }());
1794
- if (false) {
1795
- /**
1796
- * Will be set lazily to be backward compatible.
1797
- * @type {?}
1798
- * @private
1799
- */
1800
- InternalErrorReporter.prototype._errorHandler;
1801
- /**
1802
- * @type {?}
1803
- * @private
1804
- */
1805
- InternalErrorReporter.prototype._injector;
1806
- }
1807
-
1808
- /**
1809
- * @fileoverview added by tsickle
1810
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
1811
- */
1812
- /**
1813
- * BehaviorSubject of the entire state.
1814
- * @ignore
1815
- */
1816
- var StateStream = /** @class */ (function (_super) {
1817
- __extends(StateStream, _super);
1818
- function StateStream() {
1819
- return _super.call(this, {}) || this;
1820
- }
1821
- /**
1822
- * @return {?}
1823
- */
1824
- StateStream.prototype.ngOnDestroy = /**
1825
- * @return {?}
1826
- */
1827
- function () {
1828
- // The `StateStream` should never emit values once the root view is removed, e.g. when the `NgModuleRef.destroy()` is called.
1829
- // This will eliminate memory leaks in server-side rendered apps where the `StateStream` is created per each HTTP request, users
1830
- // might forget to unsubscribe from `store.select` or `store.subscribe`, thus this will lead to huge memory leaks in SSR apps.
1831
- this.complete();
1832
- };
1833
- StateStream.decorators = [
1834
- { type: Injectable }
1835
- ];
1836
- /** @nocollapse */
1837
- StateStream.ctorParameters = function () { return []; };
1838
- return StateStream;
1839
- }(BehaviorSubject));
1840
-
1841
- /**
1842
- * @fileoverview added by tsickle
1843
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
1844
- */
1845
- var PluginManager = /** @class */ (function () {
1846
- function PluginManager(_parentManager, _pluginHandlers) {
1847
- this._parentManager = _parentManager;
1848
- this._pluginHandlers = _pluginHandlers;
1849
- this.plugins = [];
1850
- this.registerHandlers();
1851
- }
1852
- Object.defineProperty(PluginManager.prototype, "rootPlugins", {
1853
- get: /**
1854
- * @private
1855
- * @return {?}
1856
- */
1857
- function () {
1858
- return (this._parentManager && this._parentManager.plugins) || this.plugins;
1859
- },
1860
- enumerable: true,
1861
- configurable: true
1862
- });
1863
- /**
1864
- * @private
1865
- * @return {?}
1866
- */
1867
- PluginManager.prototype.registerHandlers = /**
1868
- * @private
1869
- * @return {?}
1870
- */
1871
- function () {
1872
- var _a;
1873
- /** @type {?} */
1874
- var pluginHandlers = this.getPluginHandlers();
1875
- (_a = this.rootPlugins).push.apply(_a, __spread(pluginHandlers));
1876
- };
1877
- /**
1878
- * @private
1879
- * @return {?}
1880
- */
1881
- PluginManager.prototype.getPluginHandlers = /**
1882
- * @private
1883
- * @return {?}
1884
- */
1885
- function () {
1886
- /** @type {?} */
1887
- var handlers = this._pluginHandlers || [];
1888
- return handlers.map((/**
1889
- * @param {?} plugin
1890
- * @return {?}
1891
- */
1892
- function (plugin) { return (/** @type {?} */ ((plugin.handle ? plugin.handle.bind(plugin) : plugin))); }));
1893
- };
1894
- PluginManager.decorators = [
1895
- { type: Injectable }
1896
- ];
1897
- /** @nocollapse */
1898
- PluginManager.ctorParameters = function () { return [
1899
- { type: PluginManager, decorators: [{ type: Optional }, { type: SkipSelf }] },
1900
- { type: Array, decorators: [{ type: Inject, args: [NGXS_PLUGINS,] }, { type: Optional }] }
1901
- ]; };
1902
- return PluginManager;
1903
- }());
1904
- if (false) {
1905
- /** @type {?} */
1906
- PluginManager.prototype.plugins;
1907
- /**
1908
- * @type {?}
1909
- * @private
1910
- */
1911
- PluginManager.prototype._parentManager;
1912
- /**
1913
- * @type {?}
1914
- * @private
1915
- */
1916
- PluginManager.prototype._pluginHandlers;
1917
- }
1918
-
1919
- /**
1920
- * @fileoverview added by tsickle
1921
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
1922
- */
1923
- /**
1924
- * Internal Action result stream that is emitted when an action is completed.
1925
- * This is used as a method of returning the action result to the dispatcher
1926
- * for the observable returned by the dispatch(...) call.
1927
- * The dispatcher then asynchronously pushes the result from this stream onto the main action stream as a result.
1928
- */
1929
- var InternalDispatchedActionResults = /** @class */ (function (_super) {
1930
- __extends(InternalDispatchedActionResults, _super);
1931
- function InternalDispatchedActionResults() {
1932
- return _super !== null && _super.apply(this, arguments) || this;
1933
- }
1934
- InternalDispatchedActionResults.decorators = [
1935
- { type: Injectable }
1936
- ];
1937
- return InternalDispatchedActionResults;
1938
- }(Subject));
1939
- var InternalDispatcher = /** @class */ (function () {
1940
- function InternalDispatcher(_actions, _actionResults, _pluginManager, _stateStream, _ngxsExecutionStrategy, _internalErrorReporter) {
1941
- this._actions = _actions;
1942
- this._actionResults = _actionResults;
1943
- this._pluginManager = _pluginManager;
1944
- this._stateStream = _stateStream;
1945
- this._ngxsExecutionStrategy = _ngxsExecutionStrategy;
1946
- this._internalErrorReporter = _internalErrorReporter;
1947
- }
1948
- /**
1949
- * Dispatches event(s).
1950
- */
1951
- /**
1952
- * Dispatches event(s).
1953
- * @param {?} actionOrActions
1954
- * @return {?}
1955
- */
1956
- InternalDispatcher.prototype.dispatch = /**
1957
- * Dispatches event(s).
1958
- * @param {?} actionOrActions
1959
- * @return {?}
1960
- */
1961
- function (actionOrActions) {
1962
- var _this = this;
1963
- /** @type {?} */
1964
- var result = this._ngxsExecutionStrategy.enter((/**
1965
- * @return {?}
1966
- */
1967
- function () {
1968
- return _this.dispatchByEvents(actionOrActions);
1969
- }));
1970
- return result.pipe(ngxsErrorHandler(this._internalErrorReporter, this._ngxsExecutionStrategy));
1971
- };
1972
- /**
1973
- * @private
1974
- * @param {?} actionOrActions
1975
- * @return {?}
1976
- */
1977
- InternalDispatcher.prototype.dispatchByEvents = /**
1978
- * @private
1979
- * @param {?} actionOrActions
1980
- * @return {?}
1981
- */
1982
- function (actionOrActions) {
1983
- var _this = this;
1984
- if (Array.isArray(actionOrActions)) {
1985
- if (actionOrActions.length === 0)
1986
- return of(this._stateStream.getValue());
1987
- return forkJoin(actionOrActions.map((/**
1988
- * @param {?} action
1989
- * @return {?}
1990
- */
1991
- function (action) { return _this.dispatchSingle(action); })));
1992
- }
1993
- else {
1994
- return this.dispatchSingle(actionOrActions);
1995
- }
1996
- };
1997
- /**
1998
- * @private
1999
- * @param {?} action
2000
- * @return {?}
2001
- */
2002
- InternalDispatcher.prototype.dispatchSingle = /**
2003
- * @private
2004
- * @param {?} action
2005
- * @return {?}
2006
- */
2007
- function (action) {
2008
- var _this = this;
2009
- if (typeof ngDevMode === 'undefined' || ngDevMode) {
2010
- /** @type {?} */
2011
- var type = getActionTypeFromInstance(action);
2012
- if (!type) {
2013
- /** @type {?} */
2014
- var error = new Error("This action doesn't have a type property: " + action.constructor.name);
2015
- return throwError(error);
2016
- }
2017
- }
2018
- /** @type {?} */
2019
- var prevState = this._stateStream.getValue();
2020
- /** @type {?} */
2021
- var plugins = this._pluginManager.plugins;
2022
- return ((/** @type {?} */ (compose(__spread(plugins, [
2023
- (/**
2024
- * @param {?} nextState
2025
- * @param {?} nextAction
2026
- * @return {?}
2027
- */
2028
- function (nextState, nextAction) {
2029
- if (nextState !== prevState) {
2030
- _this._stateStream.next(nextState);
2031
- }
2032
- /** @type {?} */
2033
- var actionResult$ = _this.getActionResultStream(nextAction);
2034
- actionResult$.subscribe((/**
2035
- * @param {?} ctx
2036
- * @return {?}
2037
- */
2038
- function (ctx) { return _this._actions.next(ctx); }));
2039
- _this._actions.next({ action: nextAction, status: "DISPATCHED" /* Dispatched */ });
2040
- return _this.createDispatchObservable(actionResult$);
2041
- })
2042
- ]))(prevState, action)))).pipe(shareReplay());
2043
- };
2044
- /**
2045
- * @private
2046
- * @param {?} action
2047
- * @return {?}
2048
- */
2049
- InternalDispatcher.prototype.getActionResultStream = /**
2050
- * @private
2051
- * @param {?} action
2052
- * @return {?}
2053
- */
2054
- function (action) {
2055
- return this._actionResults.pipe(filter((/**
2056
- * @param {?} ctx
2057
- * @return {?}
2058
- */
2059
- function (ctx) { return ctx.action === action && ctx.status !== "DISPATCHED" /* Dispatched */; })), take(1), shareReplay());
2060
- };
2061
- /**
2062
- * @private
2063
- * @param {?} actionResult$
2064
- * @return {?}
2065
- */
2066
- InternalDispatcher.prototype.createDispatchObservable = /**
2067
- * @private
2068
- * @param {?} actionResult$
2069
- * @return {?}
2070
- */
2071
- function (actionResult$) {
2072
- var _this = this;
2073
- return actionResult$
2074
- .pipe(exhaustMap((/**
2075
- * @param {?} ctx
2076
- * @return {?}
2077
- */
2078
- function (ctx) {
2079
- switch (ctx.status) {
2080
- case "SUCCESSFUL" /* Successful */:
2081
- return of(_this._stateStream.getValue());
2082
- case "ERRORED" /* Errored */:
2083
- return throwError(ctx.error);
2084
- default:
2085
- return EMPTY;
2086
- }
2087
- })))
2088
- .pipe(shareReplay());
2089
- };
2090
- InternalDispatcher.decorators = [
2091
- { type: Injectable }
2092
- ];
2093
- /** @nocollapse */
2094
- InternalDispatcher.ctorParameters = function () { return [
2095
- { type: InternalActions },
2096
- { type: InternalDispatchedActionResults },
2097
- { type: PluginManager },
2098
- { type: StateStream },
2099
- { type: InternalNgxsExecutionStrategy },
2100
- { type: InternalErrorReporter }
2101
- ]; };
2102
- return InternalDispatcher;
2103
- }());
2104
- if (false) {
2105
- /**
2106
- * @type {?}
2107
- * @private
2108
- */
2109
- InternalDispatcher.prototype._actions;
2110
- /**
2111
- * @type {?}
2112
- * @private
2113
- */
2114
- InternalDispatcher.prototype._actionResults;
2115
- /**
2116
- * @type {?}
2117
- * @private
2118
- */
2119
- InternalDispatcher.prototype._pluginManager;
2120
- /**
2121
- * @type {?}
2122
- * @private
2123
- */
2124
- InternalDispatcher.prototype._stateStream;
2125
- /**
2126
- * @type {?}
2127
- * @private
2128
- */
2129
- InternalDispatcher.prototype._ngxsExecutionStrategy;
2130
- /**
2131
- * @type {?}
2132
- * @private
2133
- */
2134
- InternalDispatcher.prototype._internalErrorReporter;
2135
- }
2136
-
2137
- /**
2138
- * @fileoverview added by tsickle
2139
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
2140
- */
2141
- /**
2142
- * Object freeze code
2143
- * https://github.com/jsdf/deep-freeze
2144
- * @type {?}
2145
- */
2146
- var deepFreeze = (/**
2147
- * @param {?} o
2148
- * @return {?}
2149
- */
2150
- function (o) {
2151
- Object.freeze(o);
2152
- /** @type {?} */
2153
- var oIsFunction = typeof o === 'function';
2154
- /** @type {?} */
2155
- var hasOwnProp = Object.prototype.hasOwnProperty;
2156
- Object.getOwnPropertyNames(o).forEach((/**
2157
- * @param {?} prop
2158
- * @return {?}
2159
- */
2160
- function (prop) {
2161
- if (hasOwnProp.call(o, prop) &&
2162
- (oIsFunction ? prop !== 'caller' && prop !== 'callee' && prop !== 'arguments' : true) &&
2163
- o[prop] !== null &&
2164
- (typeof o[prop] === 'object' || typeof o[prop] === 'function') &&
2165
- !Object.isFrozen(o[prop])) {
2166
- deepFreeze(o[prop]);
2167
- }
2168
- }));
2169
- return o;
2170
- });
2171
-
2172
- /**
2173
- * @fileoverview added by tsickle
2174
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
2175
- */
2176
- /**
2177
- * State Context factory class
2178
- * @ignore
2179
- */
2180
- var InternalStateOperations = /** @class */ (function () {
2181
- function InternalStateOperations(_stateStream, _dispatcher, _config) {
2182
- this._stateStream = _stateStream;
2183
- this._dispatcher = _dispatcher;
2184
- this._config = _config;
2185
- }
2186
- /**
2187
- * Returns the root state operators.
2188
- */
2189
- /**
2190
- * Returns the root state operators.
2191
- * @return {?}
2192
- */
2193
- InternalStateOperations.prototype.getRootStateOperations = /**
2194
- * Returns the root state operators.
2195
- * @return {?}
2196
- */
2197
- function () {
2198
- var _this = this;
2199
- /** @type {?} */
2200
- var rootStateOperations = {
2201
- getState: (/**
2202
- * @return {?}
2203
- */
2204
- function () { return _this._stateStream.getValue(); }),
2205
- setState: (/**
2206
- * @param {?} newState
2207
- * @return {?}
2208
- */
2209
- function (newState) { return _this._stateStream.next(newState); }),
2210
- dispatch: (/**
2211
- * @param {?} actionOrActions
2212
- * @return {?}
2213
- */
2214
- function (actionOrActions) { return _this._dispatcher.dispatch(actionOrActions); })
2215
- };
2216
- if (typeof ngDevMode === 'undefined' || ngDevMode) {
2217
- return this._config.developmentMode
2218
- ? ensureStateAndActionsAreImmutable(rootStateOperations)
2219
- : rootStateOperations;
2220
- }
2221
- else {
2222
- return rootStateOperations;
2223
- }
2224
- };
2225
- /**
2226
- * @param {?} results
2227
- * @return {?}
2228
- */
2229
- InternalStateOperations.prototype.setStateToTheCurrentWithNew = /**
2230
- * @param {?} results
2231
- * @return {?}
2232
- */
2233
- function (results) {
2234
- /** @type {?} */
2235
- var stateOperations = this.getRootStateOperations();
2236
- // Get our current stream
2237
- /** @type {?} */
2238
- var currentState = stateOperations.getState();
2239
- // Set the state to the current + new
2240
- stateOperations.setState(__assign({}, currentState, results.defaults));
2241
- };
2242
- InternalStateOperations.decorators = [
2243
- { type: Injectable }
2244
- ];
2245
- /** @nocollapse */
2246
- InternalStateOperations.ctorParameters = function () { return [
2247
- { type: StateStream },
2248
- { type: InternalDispatcher },
2249
- { type: NgxsConfig }
2250
- ]; };
2251
- return InternalStateOperations;
2252
- }());
2253
- if (false) {
2254
- /**
2255
- * @type {?}
2256
- * @private
2257
- */
2258
- InternalStateOperations.prototype._stateStream;
2259
- /**
2260
- * @type {?}
2261
- * @private
2262
- */
2263
- InternalStateOperations.prototype._dispatcher;
2264
- /**
2265
- * @type {?}
2266
- * @private
2267
- */
2268
- InternalStateOperations.prototype._config;
2269
- }
2270
- /**
2271
- * @param {?} root
2272
- * @return {?}
2273
- */
2274
- function ensureStateAndActionsAreImmutable(root) {
2275
- return {
2276
- getState: (/**
2277
- * @return {?}
2278
- */
2279
- function () { return root.getState(); }),
2280
- setState: (/**
2281
- * @param {?} value
2282
- * @return {?}
2283
- */
2284
- function (value) {
2285
- /** @type {?} */
2286
- var frozenValue = deepFreeze(value);
2287
- return root.setState(frozenValue);
2288
- }),
2289
- dispatch: (/**
2290
- * @param {?} actions
2291
- * @return {?}
2292
- */
2293
- function (actions) {
2294
- return root.dispatch(actions);
2295
- })
2296
- };
2297
- }
2298
-
2299
- /**
2300
- * @fileoverview added by tsickle
2301
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
2302
- */
2303
- /**
2304
- * @template T
2305
- * @param {?} val
2306
- * @return {?}
2307
- */
2308
- function simplePatch(val) {
2309
- return (/**
2310
- * @param {?} existingState
2311
- * @return {?}
2312
- */
2313
- function (existingState) {
2314
- if (Array.isArray(val)) {
2315
- throwPatchingArrayError();
2316
- }
2317
- else if (typeof val !== 'object') {
2318
- throwPatchingPrimitiveError();
2319
- }
2320
- /** @type {?} */
2321
- var newState = __assign({}, ((/** @type {?} */ (existingState))));
2322
- for (var key in val) {
2323
- // deep clone for patch compatibility
2324
- // noinspection JSUnfilteredForInLoop (IDE)
2325
- newState[key] = ((/** @type {?} */ (val)))[key];
2326
- }
2327
- return (/** @type {?} */ (newState));
2328
- });
2329
- }
2330
-
2331
- /**
2332
- * @fileoverview added by tsickle
2333
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
2334
- */
2335
- /**
2336
- * State Context factory class
2337
- * @ignore
2338
- */
2339
- var StateContextFactory = /** @class */ (function () {
2340
- function StateContextFactory(_internalStateOperations) {
2341
- this._internalStateOperations = _internalStateOperations;
2342
- }
2343
- /**
2344
- * Create the state context
2345
- */
2346
- /**
2347
- * Create the state context
2348
- * @template T
2349
- * @param {?} mappedStore
2350
- * @return {?}
2351
- */
2352
- StateContextFactory.prototype.createStateContext = /**
2353
- * Create the state context
2354
- * @template T
2355
- * @param {?} mappedStore
2356
- * @return {?}
2357
- */
2358
- function (mappedStore) {
2359
- /** @type {?} */
2360
- var root = this._internalStateOperations.getRootStateOperations();
2361
- /**
2362
- * @param {?} currentAppState
2363
- * @return {?}
2364
- */
2365
- function getState(currentAppState) {
2366
- return getValue(currentAppState, mappedStore.path);
2367
- }
2368
- /**
2369
- * @param {?} currentAppState
2370
- * @param {?} newValue
2371
- * @return {?}
2372
- */
2373
- function setStateValue(currentAppState, newValue) {
2374
- /** @type {?} */
2375
- var newAppState = setValue(currentAppState, mappedStore.path, newValue);
2376
- root.setState(newAppState);
2377
- return newAppState;
2378
- // In doing this refactoring I noticed that there is a 'bug' where the
2379
- // application state is returned instead of this state slice.
2380
- // This has worked this way since the beginning see:
2381
- // https://github.com/ngxs/store/blame/324c667b4b7debd8eb979006c67ca0ae347d88cd/src/state-factory.ts
2382
- // This needs to be fixed, but is a 'breaking' change.
2383
- // I will do this fix in a subsequent PR and we can decide how to handle it.
2384
- }
2385
- /**
2386
- * @param {?} currentAppState
2387
- * @param {?} stateOperator
2388
- * @return {?}
2389
- */
2390
- function setStateFromOperator(currentAppState, stateOperator) {
2391
- /** @type {?} */
2392
- var local = getState(currentAppState);
2393
- /** @type {?} */
2394
- var newValue = stateOperator(local);
2395
- return setStateValue(currentAppState, newValue);
2396
- }
2397
- /**
2398
- * @param {?} value
2399
- * @return {?}
2400
- */
2401
- function isStateOperator(value) {
2402
- return typeof value === 'function';
2403
- }
2404
- return {
2405
- getState: /**
2406
- * @return {?}
2407
- */
2408
- function () {
2409
- /** @type {?} */
2410
- var currentAppState = root.getState();
2411
- return getState(currentAppState);
2412
- },
2413
- patchState: /**
2414
- * @param {?} val
2415
- * @return {?}
2416
- */
2417
- function (val) {
2418
- /** @type {?} */
2419
- var currentAppState = root.getState();
2420
- /** @type {?} */
2421
- var patchOperator = simplePatch(val);
2422
- return setStateFromOperator(currentAppState, patchOperator);
2423
- },
2424
- setState: /**
2425
- * @param {?} val
2426
- * @return {?}
2427
- */
2428
- function (val) {
2429
- /** @type {?} */
2430
- var currentAppState = root.getState();
2431
- return isStateOperator(val)
2432
- ? setStateFromOperator(currentAppState, val)
2433
- : setStateValue(currentAppState, val);
2434
- },
2435
- dispatch: /**
2436
- * @param {?} actions
2437
- * @return {?}
2438
- */
2439
- function (actions) {
2440
- return root.dispatch(actions);
2441
- }
2442
- };
2443
- };
2444
- StateContextFactory.decorators = [
2445
- { type: Injectable }
2446
- ];
2447
- /** @nocollapse */
2448
- StateContextFactory.ctorParameters = function () { return [
2449
- { type: InternalStateOperations }
2450
- ]; };
2451
- return StateContextFactory;
2452
- }());
2453
- if (false) {
2454
- /**
2455
- * @type {?}
2456
- * @private
2457
- */
2458
- StateContextFactory.prototype._internalStateOperations;
2459
- }
2460
-
2461
- /**
2462
- * @fileoverview added by tsickle
2463
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
2464
- */
2465
- /**
2466
- * @abstract
2467
- */
2468
- var StoreValidators = /** @class */ (function () {
2469
- function StoreValidators() {
2470
- }
2471
- /**
2472
- * @param {?} name
2473
- * @return {?}
2474
- */
2475
- StoreValidators.checkThatStateIsNamedCorrectly = /**
2476
- * @param {?} name
2477
- * @return {?}
2478
- */
2479
- function (name) {
2480
- if (!name) {
2481
- throwStateNamePropertyError();
2482
- }
2483
- else if (!this.stateNameRegex.test(name)) {
2484
- throwStateNameError(name);
2485
- }
2486
- };
2487
- /**
2488
- * @param {?} stateName
2489
- * @param {?} state
2490
- * @param {?} statesByName
2491
- * @return {?}
2492
- */
2493
- StoreValidators.checkThatStateNameIsUnique = /**
2494
- * @param {?} stateName
2495
- * @param {?} state
2496
- * @param {?} statesByName
2497
- * @return {?}
2498
- */
2499
- function (stateName, state, statesByName) {
2500
- /** @type {?} */
2501
- var existingState = statesByName[stateName];
2502
- if (existingState && existingState !== state) {
2503
- throwStateUniqueError(stateName, state.name, existingState.name);
2504
- }
2505
- };
2506
- /**
2507
- * @param {?} stateClasses
2508
- * @return {?}
2509
- */
2510
- StoreValidators.checkThatStateClassesHaveBeenDecorated = /**
2511
- * @param {?} stateClasses
2512
- * @return {?}
2513
- */
2514
- function (stateClasses) {
2515
- stateClasses.forEach((/**
2516
- * @param {?} stateClass
2517
- * @return {?}
2518
- */
2519
- function (stateClass) {
2520
- if (!getStoreMetadata(stateClass)) {
2521
- throwStateDecoratorError(stateClass.name);
2522
- }
2523
- }));
2524
- };
2525
- StoreValidators.stateNameRegex = new RegExp('^[a-zA-Z0-9_]+$');
2526
- return StoreValidators;
2527
- }());
2528
- if (false) {
2529
- /**
2530
- * @type {?}
2531
- * @private
2532
- */
2533
- StoreValidators.stateNameRegex;
2534
- }
2535
-
2536
- /**
2537
- * @fileoverview added by tsickle
2538
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
2539
- */
2540
- /**
2541
- * All provided or injected tokens must have `\@Injectable` decorator
2542
- * (previously, injected tokens without `\@Injectable` were allowed
2543
- * if another decorator was used, e.g. pipes).
2544
- * @param {?} stateClass
2545
- * @return {?}
2546
- */
2547
- function ensureStateClassIsInjectable(stateClass) {
2548
- // `ɵprov` is a static property added by the NGCC compiler. It always exists in
2549
- // AOT mode because this property is added before runtime. If an application is running in
2550
- // JIT mode then this property can be added by the `@Injectable()` decorator. The `@Injectable()`
2551
- // decorator has to go after the `@State()` decorator, thus we prevent users from unwanted DI errors.
2552
- if (ɵivyEnabled) {
2553
- /** @type {?} */
2554
- /** @nocollapse */ var ngInjectableDef = stateClass.ɵprov;
2555
- if (!ngInjectableDef) {
2556
- // Don't warn if Ivy is disabled or `ɵprov` exists on the class
2557
- console.warn(getUndecoratedStateInIvyWarningMessage(stateClass.name));
2558
- }
2559
- }
2560
- }
2561
-
2562
- /**
2563
- * @fileoverview added by tsickle
2564
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
2565
- */
2566
- /**
2567
- * State factory class
2568
- * @ignore
2569
- */
2570
- var StateFactory = /** @class */ (function () {
2571
- function StateFactory(_injector, _config, _parentFactory, _actions, _actionResults, _stateContextFactory, _initialState) {
2572
- var _this = this;
2573
- this._injector = _injector;
2574
- this._config = _config;
2575
- this._parentFactory = _parentFactory;
2576
- this._actions = _actions;
2577
- this._actionResults = _actionResults;
2578
- this._stateContextFactory = _stateContextFactory;
2579
- this._initialState = _initialState;
2580
- this._actionsSubscription = null;
2581
- this._states = [];
2582
- this._statesByName = {};
2583
- this._statePaths = {};
2584
- this.getRuntimeSelectorContext = memoize((/**
2585
- * @return {?}
2586
- */
2587
- function () {
2588
- /** @type {?} */
2589
- var stateFactory = _this;
2590
- /**
2591
- * @param {?} key
2592
- * @return {?}
2593
- */
2594
- function resolveGetter(key) {
2595
- /** @type {?} */
2596
- var path = stateFactory.statePaths[key];
2597
- return path ? propGetter(path.split('.'), stateFactory._config) : null;
2598
- }
2599
- /** @type {?} */
2600
- var context = _this._parentFactory
2601
- ? _this._parentFactory.getRuntimeSelectorContext()
2602
- : {
2603
- getStateGetter: /**
2604
- * @param {?} key
2605
- * @return {?}
2606
- */
2607
- function (key) {
2608
- /** @type {?} */
2609
- var getter = resolveGetter(key);
2610
- if (getter) {
2611
- return getter;
2612
- }
2613
- return (/**
2614
- * @param {...?} args
2615
- * @return {?}
2616
- */
2617
- function () {
2618
- var args = [];
2619
- for (var _i = 0; _i < arguments.length; _i++) {
2620
- args[_i] = arguments[_i];
2621
- }
2622
- // Late loaded getter
2623
- if (!getter) {
2624
- getter = resolveGetter(key);
2625
- }
2626
- return getter ? getter.apply(void 0, __spread(args)) : undefined;
2627
- });
2628
- },
2629
- getSelectorOptions: /**
2630
- * @param {?=} localOptions
2631
- * @return {?}
2632
- */
2633
- function (localOptions) {
2634
- /** @type {?} */
2635
- var globalSelectorOptions = stateFactory._config.selectorOptions;
2636
- return __assign({}, globalSelectorOptions, (localOptions || {}));
2637
- }
2638
- };
2639
- return context;
2640
- }));
2641
- }
2642
- Object.defineProperty(StateFactory.prototype, "states", {
2643
- get: /**
2644
- * @return {?}
2645
- */
2646
- function () {
2647
- return this._parentFactory ? this._parentFactory.states : this._states;
2648
- },
2649
- enumerable: true,
2650
- configurable: true
2651
- });
2652
- Object.defineProperty(StateFactory.prototype, "statesByName", {
2653
- get: /**
2654
- * @return {?}
2655
- */
2656
- function () {
2657
- return this._parentFactory ? this._parentFactory.statesByName : this._statesByName;
2658
- },
2659
- enumerable: true,
2660
- configurable: true
2661
- });
2662
- Object.defineProperty(StateFactory.prototype, "statePaths", {
2663
- get: /**
2664
- * @private
2665
- * @return {?}
2666
- */
2667
- function () {
2668
- return this._parentFactory ? this._parentFactory.statePaths : this._statePaths;
2669
- },
2670
- enumerable: true,
2671
- configurable: true
2672
- });
2673
- /**
2674
- * @private
2675
- * @param {?} defaults
2676
- * @return {?}
2677
- */
2678
- StateFactory.cloneDefaults = /**
2679
- * @private
2680
- * @param {?} defaults
2681
- * @return {?}
2682
- */
2683
- function (defaults) {
2684
- /** @type {?} */
2685
- var value = {};
2686
- if (Array.isArray(defaults)) {
2687
- value = defaults.slice();
2688
- }
2689
- else if (isObject(defaults)) {
2690
- value = __assign({}, defaults);
2691
- }
2692
- else if (defaults === undefined) {
2693
- value = {};
2694
- }
2695
- else {
2696
- value = defaults;
2697
- }
2698
- return value;
2699
- };
2700
- /**
2701
- * @return {?}
2702
- */
2703
- StateFactory.prototype.ngOnDestroy = /**
2704
- * @return {?}
2705
- */
2706
- function () {
2707
- // I'm using non-null assertion here since `_actionsSubscrition` will
2708
- // be 100% defined. This is because `ngOnDestroy()` cannot be invoked
2709
- // on the `StateFactory` until its initialized :) An it's initialized
2710
- // for the first time along with the `NgxsRootModule`.
2711
- (/** @type {?} */ (this._actionsSubscription)).unsubscribe();
2712
- };
2713
- /**
2714
- * Add a new state to the global defs.
2715
- */
2716
- /**
2717
- * Add a new state to the global defs.
2718
- * @param {?} stateClasses
2719
- * @return {?}
2720
- */
2721
- StateFactory.prototype.add = /**
2722
- * Add a new state to the global defs.
2723
- * @param {?} stateClasses
2724
- * @return {?}
2725
- */
2726
- function (stateClasses) {
2727
- var e_1, _a;
2728
- // Caretaker note: we have still left the `typeof` condition in order to avoid
2729
- // creating a breaking change for projects that still use the View Engine.
2730
- if (typeof ngDevMode === 'undefined' || ngDevMode) {
2731
- StoreValidators.checkThatStateClassesHaveBeenDecorated(stateClasses);
2732
- }
2733
- var newStates = this.addToStatesMap(stateClasses).newStates;
2734
- if (!newStates.length)
2735
- return [];
2736
- /** @type {?} */
2737
- var stateGraph = buildGraph(newStates);
2738
- /** @type {?} */
2739
- var sortedStates = topologicalSort(stateGraph);
2740
- /** @type {?} */
2741
- var paths = findFullParentPath(stateGraph);
2742
- /** @type {?} */
2743
- var nameGraph = nameToState(newStates);
2744
- /** @type {?} */
2745
- var bootstrappedStores = [];
2746
- try {
2747
- for (var sortedStates_1 = __values(sortedStates), sortedStates_1_1 = sortedStates_1.next(); !sortedStates_1_1.done; sortedStates_1_1 = sortedStates_1.next()) {
2748
- var name_1 = sortedStates_1_1.value;
2749
- /** @type {?} */
2750
- var stateClass = nameGraph[name_1];
2751
- /** @type {?} */
2752
- var path = paths[name_1];
2753
- /** @type {?} */
2754
- var meta = (/** @type {?} */ (stateClass[META_KEY]));
2755
- this.addRuntimeInfoToMeta(meta, path);
2756
- // Note: previously we called `ensureStateClassIsInjectable` within the
2757
- // `State` decorator. This check is moved here because the `ɵprov` property
2758
- // will not exist on the class in JIT mode (because it's set asynchronously
2759
- // during JIT compilation through `Object.defineProperty`).
2760
- if (typeof ngDevMode === 'undefined' || ngDevMode) {
2761
- ensureStateClassIsInjectable(stateClass);
2762
- }
2763
- /** @type {?} */
2764
- var stateMap = {
2765
- name: name_1,
2766
- path: path,
2767
- isInitialised: false,
2768
- actions: meta.actions,
2769
- instance: this._injector.get(stateClass),
2770
- defaults: StateFactory.cloneDefaults(meta.defaults)
2771
- };
2772
- // ensure our store hasn't already been added
2773
- // but don't throw since it could be lazy
2774
- // loaded from different paths
2775
- if (!this.hasBeenMountedAndBootstrapped(name_1, path)) {
2776
- bootstrappedStores.push(stateMap);
2777
- }
2778
- this.states.push(stateMap);
2779
- }
2780
- }
2781
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
2782
- finally {
2783
- try {
2784
- if (sortedStates_1_1 && !sortedStates_1_1.done && (_a = sortedStates_1.return)) _a.call(sortedStates_1);
2785
- }
2786
- finally { if (e_1) throw e_1.error; }
2787
- }
2788
- return bootstrappedStores;
2789
- };
2790
- /**
2791
- * Add a set of states to the store and return the defaults
2792
- */
2793
- /**
2794
- * Add a set of states to the store and return the defaults
2795
- * @param {?} stateClasses
2796
- * @return {?}
2797
- */
2798
- StateFactory.prototype.addAndReturnDefaults = /**
2799
- * Add a set of states to the store and return the defaults
2800
- * @param {?} stateClasses
2801
- * @return {?}
2802
- */
2803
- function (stateClasses) {
2804
- /** @type {?} */
2805
- var classes = stateClasses || [];
2806
- /** @type {?} */
2807
- var mappedStores = this.add(classes);
2808
- /** @type {?} */
2809
- var defaults = mappedStores.reduce((/**
2810
- * @param {?} result
2811
- * @param {?} mappedStore
2812
- * @return {?}
2813
- */
2814
- function (result, mappedStore) {
2815
- return setValue(result, mappedStore.path, mappedStore.defaults);
2816
- }), {});
2817
- return { defaults: defaults, states: mappedStores };
2818
- };
2819
- /**
2820
- * Bind the actions to the handlers
2821
- */
2822
- /**
2823
- * Bind the actions to the handlers
2824
- * @return {?}
2825
- */
2826
- StateFactory.prototype.connectActionHandlers = /**
2827
- * Bind the actions to the handlers
2828
- * @return {?}
2829
- */
2830
- function () {
2831
- var _this = this;
2832
- if (this._actionsSubscription !== null)
2833
- return;
2834
- /** @type {?} */
2835
- var dispatched$ = new Subject();
2836
- this._actionsSubscription = this._actions
2837
- .pipe(filter((/**
2838
- * @param {?} ctx
2839
- * @return {?}
2840
- */
2841
- function (ctx) { return ctx.status === "DISPATCHED" /* Dispatched */; })), mergeMap((/**
2842
- * @param {?} ctx
2843
- * @return {?}
2844
- */
2845
- function (ctx) {
2846
- dispatched$.next(ctx);
2847
- /** @type {?} */
2848
- var action = ctx.action;
2849
- return _this.invokeActions(dispatched$, (/** @type {?} */ (action))).pipe(map((/**
2850
- * @return {?}
2851
- */
2852
- function () { return (/** @type {?} */ ({ action: action, status: "SUCCESSFUL" /* Successful */ })); })), defaultIfEmpty((/** @type {?} */ ({ action: action, status: "CANCELED" /* Canceled */ }))), catchError((/**
2853
- * @param {?} error
2854
- * @return {?}
2855
- */
2856
- function (error) {
2857
- return of((/** @type {?} */ ({ action: action, status: "ERRORED" /* Errored */, error: error })));
2858
- })));
2859
- })))
2860
- .subscribe((/**
2861
- * @param {?} ctx
2862
- * @return {?}
2863
- */
2864
- function (ctx) { return _this._actionResults.next(ctx); }));
2865
- };
2866
- /**
2867
- * Invoke actions on the states.
2868
- */
2869
- /**
2870
- * Invoke actions on the states.
2871
- * @param {?} dispatched$
2872
- * @param {?} action
2873
- * @return {?}
2874
- */
2875
- StateFactory.prototype.invokeActions = /**
2876
- * Invoke actions on the states.
2877
- * @param {?} dispatched$
2878
- * @param {?} action
2879
- * @return {?}
2880
- */
2881
- function (dispatched$, action) {
2882
- var e_2, _a, e_3, _b;
2883
- /** @type {?} */
2884
- var type = (/** @type {?} */ (getActionTypeFromInstance(action)));
2885
- /** @type {?} */
2886
- var results = [];
2887
- try {
2888
- for (var _c = __values(this.states), _d = _c.next(); !_d.done; _d = _c.next()) {
2889
- var metadata = _d.value;
2890
- /** @type {?} */
2891
- var actionMetas = metadata.actions[type];
2892
- if (actionMetas) {
2893
- try {
2894
- for (var actionMetas_1 = __values(actionMetas), actionMetas_1_1 = actionMetas_1.next(); !actionMetas_1_1.done; actionMetas_1_1 = actionMetas_1.next()) {
2895
- var actionMeta = actionMetas_1_1.value;
2896
- /** @type {?} */
2897
- var stateContext = this._stateContextFactory.createStateContext(metadata);
2898
- try {
2899
- /** @type {?} */
2900
- var result = metadata.instance[actionMeta.fn](stateContext, action);
2901
- if (result instanceof Promise) {
2902
- result = from(result);
2903
- }
2904
- if (isObservable(result)) {
2905
- // If this observable has been completed w/o emitting
2906
- // any value then we wouldn't want to complete the whole chain
2907
- // of actions. Since if any observable completes then
2908
- // action will be canceled.
2909
- // For instance if any action handler would've had such statement:
2910
- // `handler(ctx) { return EMPTY; }`
2911
- // then the action will be canceled.
2912
- // See https://github.com/ngxs/store/issues/1568
2913
- result = result.pipe(mergeMap((/**
2914
- * @param {?} value
2915
- * @return {?}
2916
- */
2917
- function (value) {
2918
- if (value instanceof Promise) {
2919
- return from(value);
2920
- }
2921
- if (isObservable(value)) {
2922
- return value;
2923
- }
2924
- return of(value);
2925
- })), defaultIfEmpty({}));
2926
- if (actionMeta.options.cancelUncompleted) {
2927
- // todo: ofActionDispatched should be used with action class
2928
- result = result.pipe(takeUntil(dispatched$.pipe(ofActionDispatched((/** @type {?} */ (action))))));
2929
- }
2930
- }
2931
- else {
2932
- result = of({}).pipe(shareReplay());
2933
- }
2934
- results.push(result);
2935
- }
2936
- catch (e) {
2937
- results.push(throwError(e));
2938
- }
2939
- }
2940
- }
2941
- catch (e_3_1) { e_3 = { error: e_3_1 }; }
2942
- finally {
2943
- try {
2944
- if (actionMetas_1_1 && !actionMetas_1_1.done && (_b = actionMetas_1.return)) _b.call(actionMetas_1);
2945
- }
2946
- finally { if (e_3) throw e_3.error; }
2947
- }
2948
- }
2949
- }
2950
- }
2951
- catch (e_2_1) { e_2 = { error: e_2_1 }; }
2952
- finally {
2953
- try {
2954
- if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
2955
- }
2956
- finally { if (e_2) throw e_2.error; }
2957
- }
2958
- if (!results.length) {
2959
- results.push(of({}));
2960
- }
2961
- return forkJoin(results);
2962
- };
2963
- /**
2964
- * @private
2965
- * @param {?} stateClasses
2966
- * @return {?}
2967
- */
2968
- StateFactory.prototype.addToStatesMap = /**
2969
- * @private
2970
- * @param {?} stateClasses
2971
- * @return {?}
2972
- */
2973
- function (stateClasses) {
2974
- var e_4, _a;
2975
- /** @type {?} */
2976
- var newStates = [];
2977
- /** @type {?} */
2978
- var statesMap = this.statesByName;
2979
- try {
2980
- for (var stateClasses_1 = __values(stateClasses), stateClasses_1_1 = stateClasses_1.next(); !stateClasses_1_1.done; stateClasses_1_1 = stateClasses_1.next()) {
2981
- var stateClass = stateClasses_1_1.value;
2982
- /** @type {?} */
2983
- var stateName = (/** @type {?} */ (getStoreMetadata(stateClass).name));
2984
- // Caretaker note: we have still left the `typeof` condition in order to avoid
2985
- // creating a breaking change for projects that still use the View Engine.
2986
- if (typeof ngDevMode === 'undefined' || ngDevMode) {
2987
- StoreValidators.checkThatStateNameIsUnique(stateName, stateClass, statesMap);
2988
- }
2989
- /** @type {?} */
2990
- var unmountedState = !statesMap[stateName];
2991
- if (unmountedState) {
2992
- newStates.push(stateClass);
2993
- statesMap[stateName] = stateClass;
2994
- }
2995
- }
2996
- }
2997
- catch (e_4_1) { e_4 = { error: e_4_1 }; }
2998
- finally {
2999
- try {
3000
- if (stateClasses_1_1 && !stateClasses_1_1.done && (_a = stateClasses_1.return)) _a.call(stateClasses_1);
3001
- }
3002
- finally { if (e_4) throw e_4.error; }
3003
- }
3004
- return { newStates: newStates };
3005
- };
3006
- /**
3007
- * @private
3008
- * @param {?} meta
3009
- * @param {?} path
3010
- * @return {?}
3011
- */
3012
- StateFactory.prototype.addRuntimeInfoToMeta = /**
3013
- * @private
3014
- * @param {?} meta
3015
- * @param {?} path
3016
- * @return {?}
3017
- */
3018
- function (meta, path) {
3019
- this.statePaths[(/** @type {?} */ (meta.name))] = path;
3020
- // TODO: v4 - we plan to get rid of the path property because it is non-deterministic
3021
- // we can do this when we get rid of the incorrectly exposed getStoreMetadata
3022
- // We will need to come up with an alternative in v4 because this is used by many plugins
3023
- meta.path = path;
3024
- };
3025
- /**
3026
- * @description
3027
- * the method checks if the state has already been added to the tree
3028
- * and completed the life cycle
3029
- * @param name
3030
- * @param path
3031
- */
3032
- /**
3033
- * \@description
3034
- * the method checks if the state has already been added to the tree
3035
- * and completed the life cycle
3036
- * @private
3037
- * @param {?} name
3038
- * @param {?} path
3039
- * @return {?}
3040
- */
3041
- StateFactory.prototype.hasBeenMountedAndBootstrapped = /**
3042
- * \@description
3043
- * the method checks if the state has already been added to the tree
3044
- * and completed the life cycle
3045
- * @private
3046
- * @param {?} name
3047
- * @param {?} path
3048
- * @return {?}
3049
- */
3050
- function (name, path) {
3051
- /** @type {?} */
3052
- var valueIsBootstrappedInInitialState = getValue(this._initialState, path) !== undefined;
3053
- return this.statesByName[name] && valueIsBootstrappedInInitialState;
3054
- };
3055
- StateFactory.decorators = [
3056
- { type: Injectable }
3057
- ];
3058
- /** @nocollapse */
3059
- StateFactory.ctorParameters = function () { return [
3060
- { type: Injector },
3061
- { type: NgxsConfig },
3062
- { type: StateFactory, decorators: [{ type: Optional }, { type: SkipSelf }] },
3063
- { type: InternalActions },
3064
- { type: InternalDispatchedActionResults },
3065
- { type: StateContextFactory },
3066
- { type: undefined, decorators: [{ type: Optional }, { type: Inject, args: [INITIAL_STATE_TOKEN,] }] }
3067
- ]; };
3068
- return StateFactory;
3069
- }());
3070
- if (false) {
3071
- /**
3072
- * @type {?}
3073
- * @private
3074
- */
3075
- StateFactory.prototype._actionsSubscription;
3076
- /**
3077
- * @type {?}
3078
- * @private
3079
- */
3080
- StateFactory.prototype._states;
3081
- /**
3082
- * @type {?}
3083
- * @private
3084
- */
3085
- StateFactory.prototype._statesByName;
3086
- /**
3087
- * @type {?}
3088
- * @private
3089
- */
3090
- StateFactory.prototype._statePaths;
3091
- /** @type {?} */
3092
- StateFactory.prototype.getRuntimeSelectorContext;
3093
- /**
3094
- * @type {?}
3095
- * @private
3096
- */
3097
- StateFactory.prototype._injector;
3098
- /**
3099
- * @type {?}
3100
- * @private
3101
- */
3102
- StateFactory.prototype._config;
3103
- /**
3104
- * @type {?}
3105
- * @private
3106
- */
3107
- StateFactory.prototype._parentFactory;
3108
- /**
3109
- * @type {?}
3110
- * @private
3111
- */
3112
- StateFactory.prototype._actions;
3113
- /**
3114
- * @type {?}
3115
- * @private
3116
- */
3117
- StateFactory.prototype._actionResults;
3118
- /**
3119
- * @type {?}
3120
- * @private
3121
- */
3122
- StateFactory.prototype._stateContextFactory;
3123
- /**
3124
- * @type {?}
3125
- * @private
3126
- */
3127
- StateFactory.prototype._initialState;
3128
- }
3129
-
3130
- /**
3131
- * @fileoverview added by tsickle
3132
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
3133
- */
3134
- /** @type {?} */
3135
- var SELECTOR_OPTIONS_META_KEY = 'NGXS_SELECTOR_OPTIONS_META';
3136
- /** @type {?} */
3137
- var selectorOptionsMetaAccessor = {
3138
- getOptions: (/**
3139
- * @param {?} target
3140
- * @return {?}
3141
- */
3142
- function (target) {
3143
- return (target && ((/** @type {?} */ (target)))[SELECTOR_OPTIONS_META_KEY]) || {};
3144
- }),
3145
- defineOptions: (/**
3146
- * @param {?} target
3147
- * @param {?} options
3148
- * @return {?}
3149
- */
3150
- function (target, options) {
3151
- if (!target)
3152
- return;
3153
- ((/** @type {?} */ (target)))[SELECTOR_OPTIONS_META_KEY] = options;
3154
- })
3155
- };
3156
- /**
3157
- * @record
3158
- */
3159
- function CreationMetadata() { }
3160
- if (false) {
3161
- /** @type {?} */
3162
- CreationMetadata.prototype.containerClass;
3163
- /** @type {?} */
3164
- CreationMetadata.prototype.selectorName;
3165
- /** @type {?|undefined} */
3166
- CreationMetadata.prototype.getSelectorOptions;
3167
- }
3168
- /**
3169
- * @record
3170
- */
3171
- function RuntimeSelectorInfo() { }
3172
- if (false) {
3173
- /** @type {?} */
3174
- RuntimeSelectorInfo.prototype.selectorOptions;
3175
- /** @type {?} */
3176
- RuntimeSelectorInfo.prototype.argumentSelectorFunctions;
3177
- }
3178
- /**
3179
- * Function for creating a selector
3180
- * @template T
3181
- * @param {?} selectors The selectors to use to create the arguments of this function
3182
- * @param {?} originalFn The original function being made into a selector
3183
- * @param {?=} creationMetadata
3184
- * @return {?}
3185
- */
3186
- function createSelector(selectors, originalFn, creationMetadata) {
3187
- /** @type {?} */
3188
- var containerClass = creationMetadata && creationMetadata.containerClass;
3189
- /** @type {?} */
3190
- var wrappedFn = (/** @type {?} */ ((/**
3191
- * @param {...?} args
3192
- * @return {?}
3193
- */
3194
- function wrappedSelectorFn() {
3195
- var args = [];
3196
- for (var _i = 0; _i < arguments.length; _i++) {
3197
- args[_i] = arguments[_i];
3198
- }
3199
- /** @type {?} */
3200
- var returnValue = originalFn.apply(containerClass, args);
3201
- if (returnValue instanceof Function) {
3202
- /** @type {?} */
3203
- var innerMemoizedFn = memoize.apply(null, [returnValue]);
3204
- return innerMemoizedFn;
3205
- }
3206
- return returnValue;
3207
- })));
3208
- /** @type {?} */
3209
- var memoizedFn = memoize(wrappedFn);
3210
- Object.setPrototypeOf(memoizedFn, originalFn);
3211
- /** @type {?} */
3212
- var selectorMetaData = setupSelectorMetadata(originalFn, creationMetadata);
3213
- /** @type {?} */
3214
- var makeRootSelector = (/**
3215
- * @param {?} context
3216
- * @return {?}
3217
- */
3218
- function (context) {
3219
- var _a = getRuntimeSelectorInfo(context, selectorMetaData, selectors), argumentSelectorFunctions = _a.argumentSelectorFunctions, selectorOptions = _a.selectorOptions;
3220
- return (/**
3221
- * @param {?} rootState
3222
- * @return {?}
3223
- */
3224
- function selectFromRoot(rootState) {
3225
- // Determine arguments from the app state using the selectors
3226
- /** @type {?} */
3227
- var results = argumentSelectorFunctions.map((/**
3228
- * @param {?} argFn
3229
- * @return {?}
3230
- */
3231
- function (argFn) { return argFn(rootState); }));
3232
- // if the lambda tries to access a something on the
3233
- // state that doesn't exist, it will throw a TypeError.
3234
- // since this is quite usual behaviour, we simply return undefined if so.
3235
- try {
3236
- return memoizedFn.apply(void 0, __spread(results));
3237
- }
3238
- catch (ex) {
3239
- if (ex instanceof TypeError && selectorOptions.suppressErrors) {
3240
- return undefined;
3241
- }
3242
- throw ex;
3243
- }
3244
- });
3245
- });
3246
- selectorMetaData.makeRootSelector = makeRootSelector;
3247
- return memoizedFn;
3248
- }
3249
- /**
3250
- * @template T
3251
- * @param {?} originalFn
3252
- * @param {?} creationMetadata
3253
- * @return {?}
3254
- */
3255
- function setupSelectorMetadata(originalFn, creationMetadata) {
3256
- /** @type {?} */
3257
- var selectorMetaData = ensureSelectorMetadata(originalFn);
3258
- selectorMetaData.originalFn = originalFn;
3259
- /** @type {?} */
3260
- var getExplicitSelectorOptions = (/**
3261
- * @return {?}
3262
- */
3263
- function () { return ({}); });
3264
- if (creationMetadata) {
3265
- selectorMetaData.containerClass = creationMetadata.containerClass;
3266
- selectorMetaData.selectorName = creationMetadata.selectorName;
3267
- getExplicitSelectorOptions =
3268
- creationMetadata.getSelectorOptions || getExplicitSelectorOptions;
3269
- }
3270
- /** @type {?} */
3271
- var selectorMetaDataClone = __assign({}, selectorMetaData);
3272
- selectorMetaData.getSelectorOptions = (/**
3273
- * @return {?}
3274
- */
3275
- function () {
3276
- return getLocalSelectorOptions(selectorMetaDataClone, getExplicitSelectorOptions());
3277
- });
3278
- return selectorMetaData;
3279
- }
3280
- /**
3281
- * @param {?} context
3282
- * @param {?} selectorMetaData
3283
- * @param {?=} selectors
3284
- * @return {?}
3285
- */
3286
- function getRuntimeSelectorInfo(context, selectorMetaData, selectors) {
3287
- if (selectors === void 0) { selectors = []; }
3288
- /** @type {?} */
3289
- var localSelectorOptions = selectorMetaData.getSelectorOptions();
3290
- /** @type {?} */
3291
- var selectorOptions = context.getSelectorOptions(localSelectorOptions);
3292
- /** @type {?} */
3293
- var selectorsToApply = getSelectorsToApply(selectors, selectorOptions, selectorMetaData.containerClass);
3294
- /** @type {?} */
3295
- var argumentSelectorFunctions = selectorsToApply.map((/**
3296
- * @param {?} selector
3297
- * @return {?}
3298
- */
3299
- function (selector) {
3300
- /** @type {?} */
3301
- var factory = getRootSelectorFactory(selector);
3302
- return factory(context);
3303
- }));
3304
- return {
3305
- selectorOptions: selectorOptions,
3306
- argumentSelectorFunctions: argumentSelectorFunctions
3307
- };
3308
- }
3309
- /**
3310
- * @param {?} selectorMetaData
3311
- * @param {?} explicitOptions
3312
- * @return {?}
3313
- */
3314
- function getLocalSelectorOptions(selectorMetaData, explicitOptions) {
3315
- return __assign({}, (selectorOptionsMetaAccessor.getOptions(selectorMetaData.containerClass) || {}), (selectorOptionsMetaAccessor.getOptions(selectorMetaData.originalFn) || {}), (selectorMetaData.getSelectorOptions() || {}), explicitOptions);
3316
- }
3317
- /**
3318
- * @param {?=} selectors
3319
- * @param {?=} selectorOptions
3320
- * @param {?=} containerClass
3321
- * @return {?}
3322
- */
3323
- function getSelectorsToApply(selectors, selectorOptions, containerClass) {
3324
- if (selectors === void 0) { selectors = []; }
3325
- /** @type {?} */
3326
- var selectorsToApply = [];
3327
- /** @type {?} */
3328
- var canInjectContainerState = selectors.length === 0 || selectorOptions.injectContainerState;
3329
- if (containerClass && canInjectContainerState) {
3330
- // If we are on a state class, add it as the first selector parameter
3331
- /** @type {?} */
3332
- var metadata = getStoreMetadata(containerClass);
3333
- if (metadata) {
3334
- selectorsToApply.push(containerClass);
3335
- }
3336
- }
3337
- if (selectors) {
3338
- selectorsToApply.push.apply(selectorsToApply, __spread(selectors));
3339
- }
3340
- return selectorsToApply;
3341
- }
3342
- /**
3343
- * This function gets the factory function to create the selector to get the selected slice from the app state
3344
- * @ignore
3345
- * @param {?} selector
3346
- * @return {?}
3347
- */
3348
- function getRootSelectorFactory(selector) {
3349
- /** @type {?} */
3350
- var metadata = getSelectorMetadata(selector) || getStoreMetadata(selector);
3351
- return (metadata && metadata.makeRootSelector) || ((/**
3352
- * @return {?}
3353
- */
3354
- function () { return selector; }));
3355
- }
3356
-
3357
- /**
3358
- * @fileoverview added by tsickle
3359
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
3360
- */
3361
- var Store = /** @class */ (function () {
3362
- function Store(_stateStream, _internalStateOperations, _config, _internalExecutionStrategy, _stateFactory, initialStateValue) {
3363
- this._stateStream = _stateStream;
3364
- this._internalStateOperations = _internalStateOperations;
3365
- this._config = _config;
3366
- this._internalExecutionStrategy = _internalExecutionStrategy;
3367
- this._stateFactory = _stateFactory;
3368
- /**
3369
- * This is a derived state stream that leaves NGXS execution strategy to emit state changes within the Angular zone,
3370
- * because state is being changed actually within the `<root>` zone, see `InternalDispatcher#dispatchSingle`.
3371
- * All selects would use this stream, and it would call leave only once for any state change across all active selectors.
3372
- */
3373
- this._selectableStateStream = this._stateStream.pipe(observeOn(queueScheduler), leaveNgxs(this._internalExecutionStrategy), shareReplay({ bufferSize: 1, refCount: true }));
3374
- this.initStateStream(initialStateValue);
3375
- }
3376
- /**
3377
- * Dispatches event(s).
3378
- */
3379
- /**
3380
- * Dispatches event(s).
3381
- * @param {?} actionOrActions
3382
- * @return {?}
3383
- */
3384
- Store.prototype.dispatch = /**
3385
- * Dispatches event(s).
3386
- * @param {?} actionOrActions
3387
- * @return {?}
3388
- */
3389
- function (actionOrActions) {
3390
- return this._internalStateOperations.getRootStateOperations().dispatch(actionOrActions);
3391
- };
3392
- /**
3393
- * @param {?} selector
3394
- * @return {?}
3395
- */
3396
- Store.prototype.select = /**
3397
- * @param {?} selector
3398
- * @return {?}
3399
- */
3400
- function (selector) {
3401
- var _this = this;
3402
- /** @type {?} */
3403
- var selectorFn = this.getStoreBoundSelectorFn(selector);
3404
- return this._selectableStateStream.pipe(map(selectorFn), catchError((/**
3405
- * @param {?} err
3406
- * @return {?}
3407
- */
3408
- function (err) {
3409
- // if error is TypeError we swallow it to prevent usual errors with property access
3410
- var suppressErrors = _this._config.selectorOptions.suppressErrors;
3411
- if (err instanceof TypeError && suppressErrors) {
3412
- return of(undefined);
3413
- }
3414
- // rethrow other errors
3415
- return throwError(err);
3416
- })), distinctUntilChanged(), leaveNgxs(this._internalExecutionStrategy));
3417
- };
3418
- /**
3419
- * @param {?} selector
3420
- * @return {?}
3421
- */
3422
- Store.prototype.selectOnce = /**
3423
- * @param {?} selector
3424
- * @return {?}
3425
- */
3426
- function (selector) {
3427
- return this.select(selector).pipe(take(1));
3428
- };
3429
- /**
3430
- * @param {?} selector
3431
- * @return {?}
3432
- */
3433
- Store.prototype.selectSnapshot = /**
3434
- * @param {?} selector
3435
- * @return {?}
3436
- */
3437
- function (selector) {
3438
- /** @type {?} */
3439
- var selectorFn = this.getStoreBoundSelectorFn(selector);
3440
- return selectorFn(this._stateStream.getValue());
3441
- };
3442
- /**
3443
- * Allow the user to subscribe to the root of the state
3444
- */
3445
- /**
3446
- * Allow the user to subscribe to the root of the state
3447
- * @param {?=} fn
3448
- * @return {?}
3449
- */
3450
- Store.prototype.subscribe = /**
3451
- * Allow the user to subscribe to the root of the state
3452
- * @param {?=} fn
3453
- * @return {?}
3454
- */
3455
- function (fn) {
3456
- return this._selectableStateStream
3457
- .pipe(leaveNgxs(this._internalExecutionStrategy))
3458
- .subscribe(fn);
3459
- };
3460
- /**
3461
- * Return the raw value of the state.
3462
- */
3463
- /**
3464
- * Return the raw value of the state.
3465
- * @return {?}
3466
- */
3467
- Store.prototype.snapshot = /**
3468
- * Return the raw value of the state.
3469
- * @return {?}
3470
- */
3471
- function () {
3472
- return this._internalStateOperations.getRootStateOperations().getState();
3473
- };
3474
- /**
3475
- * Reset the state to a specific point in time. This method is useful
3476
- * for plugin's who need to modify the state directly or unit testing.
3477
- */
3478
- /**
3479
- * Reset the state to a specific point in time. This method is useful
3480
- * for plugin's who need to modify the state directly or unit testing.
3481
- * @param {?} state
3482
- * @return {?}
3483
- */
3484
- Store.prototype.reset = /**
3485
- * Reset the state to a specific point in time. This method is useful
3486
- * for plugin's who need to modify the state directly or unit testing.
3487
- * @param {?} state
3488
- * @return {?}
3489
- */
3490
- function (state) {
3491
- return this._internalStateOperations.getRootStateOperations().setState(state);
3492
- };
3493
- /**
3494
- * @private
3495
- * @param {?} selector
3496
- * @return {?}
3497
- */
3498
- Store.prototype.getStoreBoundSelectorFn = /**
3499
- * @private
3500
- * @param {?} selector
3501
- * @return {?}
3502
- */
3503
- function (selector) {
3504
- /** @type {?} */
3505
- var makeSelectorFn = getRootSelectorFactory(selector);
3506
- /** @type {?} */
3507
- var runtimeContext = this._stateFactory.getRuntimeSelectorContext();
3508
- return makeSelectorFn(runtimeContext);
3509
- };
3510
- /**
3511
- * @private
3512
- * @param {?} initialStateValue
3513
- * @return {?}
3514
- */
3515
- Store.prototype.initStateStream = /**
3516
- * @private
3517
- * @param {?} initialStateValue
3518
- * @return {?}
3519
- */
3520
- function (initialStateValue) {
3521
- /** @type {?} */
3522
- var value = this._stateStream.value;
3523
- /** @type {?} */
3524
- var storeIsEmpty = !value || Object.keys(value).length === 0;
3525
- if (storeIsEmpty) {
3526
- /** @type {?} */
3527
- var defaultStateNotEmpty = Object.keys(this._config.defaultsState).length > 0;
3528
- /** @type {?} */
3529
- var storeValues = defaultStateNotEmpty
3530
- ? __assign({}, this._config.defaultsState, initialStateValue) : initialStateValue;
3531
- this._stateStream.next(storeValues);
3532
- }
3533
- };
3534
- Store.decorators = [
3535
- { type: Injectable }
3536
- ];
3537
- /** @nocollapse */
3538
- Store.ctorParameters = function () { return [
3539
- { type: StateStream },
3540
- { type: InternalStateOperations },
3541
- { type: NgxsConfig },
3542
- { type: InternalNgxsExecutionStrategy },
3543
- { type: StateFactory },
3544
- { type: undefined, decorators: [{ type: Optional }, { type: Inject, args: [INITIAL_STATE_TOKEN,] }] }
3545
- ]; };
3546
- return Store;
3547
- }());
3548
- if (false) {
3549
- /**
3550
- * This is a derived state stream that leaves NGXS execution strategy to emit state changes within the Angular zone,
3551
- * because state is being changed actually within the `<root>` zone, see `InternalDispatcher#dispatchSingle`.
3552
- * All selects would use this stream, and it would call leave only once for any state change across all active selectors.
3553
- * @type {?}
3554
- * @private
3555
- */
3556
- Store.prototype._selectableStateStream;
3557
- /**
3558
- * @type {?}
3559
- * @private
3560
- */
3561
- Store.prototype._stateStream;
3562
- /**
3563
- * @type {?}
3564
- * @private
3565
- */
3566
- Store.prototype._internalStateOperations;
3567
- /**
3568
- * @type {?}
3569
- * @private
3570
- */
3571
- Store.prototype._config;
3572
- /**
3573
- * @type {?}
3574
- * @private
3575
- */
3576
- Store.prototype._internalExecutionStrategy;
3577
- /**
3578
- * @type {?}
3579
- * @private
3580
- */
3581
- Store.prototype._stateFactory;
3582
- }
3583
-
3584
- /**
3585
- * @fileoverview added by tsickle
3586
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
3587
- */
3588
- var LifecycleStateManager = /** @class */ (function () {
3589
- function LifecycleStateManager(_store, _internalErrorReporter, _internalStateOperations, _stateContextFactory, _bootstrapper) {
3590
- this._store = _store;
3591
- this._internalErrorReporter = _internalErrorReporter;
3592
- this._internalStateOperations = _internalStateOperations;
3593
- this._stateContextFactory = _stateContextFactory;
3594
- this._bootstrapper = _bootstrapper;
3595
- this._destroy$ = new Subject();
3596
- }
3597
- /**
3598
- * @return {?}
3599
- */
3600
- LifecycleStateManager.prototype.ngOnDestroy = /**
3601
- * @return {?}
3602
- */
3603
- function () {
3604
- this._destroy$.next();
3605
- };
3606
- /**
3607
- * @template T
3608
- * @param {?} action
3609
- * @param {?} results
3610
- * @return {?}
3611
- */
3612
- LifecycleStateManager.prototype.ngxsBootstrap = /**
3613
- * @template T
3614
- * @param {?} action
3615
- * @param {?} results
3616
- * @return {?}
3617
- */
3618
- function (action, results) {
3619
- var _this = this;
3620
- this._internalStateOperations
3621
- .getRootStateOperations()
3622
- .dispatch(action)
3623
- .pipe(filter((/**
3624
- * @return {?}
3625
- */
3626
- function () { return !!results; })), tap((/**
3627
- * @return {?}
3628
- */
3629
- function () { return _this._invokeInitOnStates((/** @type {?} */ (results)).states); })), mergeMap((/**
3630
- * @return {?}
3631
- */
3632
- function () { return _this._bootstrapper.appBootstrapped$; })), filter((/**
3633
- * @param {?} appBootstrapped
3634
- * @return {?}
3635
- */
3636
- function (appBootstrapped) { return !!appBootstrapped; })), catchError((/**
3637
- * @param {?} error
3638
- * @return {?}
3639
- */
3640
- function (error) {
3641
- // The `SafeSubscriber` (which is used by most RxJS operators) re-throws
3642
- // errors asynchronously (`setTimeout(() => { throw error })`). This might
3643
- // break existing user's code or unit tests. We catch the error manually to
3644
- // be backward compatible with the old behavior.
3645
- _this._internalErrorReporter.reportErrorSafely(error);
3646
- return EMPTY;
3647
- })), takeUntil(this._destroy$))
3648
- .subscribe((/**
3649
- * @return {?}
3650
- */
3651
- function () { return _this._invokeBootstrapOnStates((/** @type {?} */ (results)).states); }));
3652
- };
3653
- /**
3654
- * @private
3655
- * @param {?} mappedStores
3656
- * @return {?}
3657
- */
3658
- LifecycleStateManager.prototype._invokeInitOnStates = /**
3659
- * @private
3660
- * @param {?} mappedStores
3661
- * @return {?}
3662
- */
3663
- function (mappedStores) {
3664
- var e_1, _a;
3665
- var _loop_1 = function (mappedStore) {
3666
- /** @type {?} */
3667
- var instance = mappedStore.instance;
3668
- if (instance.ngxsOnChanges) {
3669
- this_1._store
3670
- .select((/**
3671
- * @param {?} state
3672
- * @return {?}
3673
- */
3674
- function (state) { return getValue(state, mappedStore.path); }))
3675
- .pipe(startWith(undefined), pairwise(), takeUntil(this_1._destroy$))
3676
- .subscribe((/**
3677
- * @param {?} __0
3678
- * @return {?}
3679
- */
3680
- function (_a) {
3681
- var _b = __read(_a, 2), previousValue = _b[0], currentValue = _b[1];
3682
- /** @type {?} */
3683
- var change = new NgxsSimpleChange(previousValue, currentValue, !mappedStore.isInitialised);
3684
- (/** @type {?} */ (instance.ngxsOnChanges))(change);
3685
- }));
3686
- }
3687
- if (instance.ngxsOnInit) {
3688
- instance.ngxsOnInit(this_1._getStateContext(mappedStore));
3689
- }
3690
- mappedStore.isInitialised = true;
3691
- };
3692
- var this_1 = this;
3693
- try {
3694
- for (var mappedStores_1 = __values(mappedStores), mappedStores_1_1 = mappedStores_1.next(); !mappedStores_1_1.done; mappedStores_1_1 = mappedStores_1.next()) {
3695
- var mappedStore = mappedStores_1_1.value;
3696
- _loop_1(mappedStore);
3697
- }
3698
- }
3699
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
3700
- finally {
3701
- try {
3702
- if (mappedStores_1_1 && !mappedStores_1_1.done && (_a = mappedStores_1.return)) _a.call(mappedStores_1);
3703
- }
3704
- finally { if (e_1) throw e_1.error; }
3705
- }
3706
- };
3707
- /**
3708
- * @private
3709
- * @param {?} mappedStores
3710
- * @return {?}
3711
- */
3712
- LifecycleStateManager.prototype._invokeBootstrapOnStates = /**
3713
- * @private
3714
- * @param {?} mappedStores
3715
- * @return {?}
3716
- */
3717
- function (mappedStores) {
3718
- var e_2, _a;
3719
- try {
3720
- for (var mappedStores_2 = __values(mappedStores), mappedStores_2_1 = mappedStores_2.next(); !mappedStores_2_1.done; mappedStores_2_1 = mappedStores_2.next()) {
3721
- var mappedStore = mappedStores_2_1.value;
3722
- /** @type {?} */
3723
- var instance = mappedStore.instance;
3724
- if (instance.ngxsAfterBootstrap) {
3725
- instance.ngxsAfterBootstrap(this._getStateContext(mappedStore));
3726
- }
3727
- }
3728
- }
3729
- catch (e_2_1) { e_2 = { error: e_2_1 }; }
3730
- finally {
3731
- try {
3732
- if (mappedStores_2_1 && !mappedStores_2_1.done && (_a = mappedStores_2.return)) _a.call(mappedStores_2);
3733
- }
3734
- finally { if (e_2) throw e_2.error; }
3735
- }
3736
- };
3737
- /**
3738
- * @private
3739
- * @param {?} mappedStore
3740
- * @return {?}
3741
- */
3742
- LifecycleStateManager.prototype._getStateContext = /**
3743
- * @private
3744
- * @param {?} mappedStore
3745
- * @return {?}
3746
- */
3747
- function (mappedStore) {
3748
- return this._stateContextFactory.createStateContext(mappedStore);
3749
- };
3750
- LifecycleStateManager.decorators = [
3751
- { type: Injectable }
3752
- ];
3753
- /** @nocollapse */
3754
- LifecycleStateManager.ctorParameters = function () { return [
3755
- { type: Store },
3756
- { type: InternalErrorReporter },
3757
- { type: InternalStateOperations },
3758
- { type: StateContextFactory },
3759
- { type: NgxsBootstrapper }
3760
- ]; };
3761
- return LifecycleStateManager;
3762
- }());
3763
- if (false) {
3764
- /**
3765
- * @type {?}
3766
- * @private
3767
- */
3768
- LifecycleStateManager.prototype._destroy$;
3769
- /**
3770
- * @type {?}
3771
- * @private
3772
- */
3773
- LifecycleStateManager.prototype._store;
3774
- /**
3775
- * @type {?}
3776
- * @private
3777
- */
3778
- LifecycleStateManager.prototype._internalErrorReporter;
3779
- /**
3780
- * @type {?}
3781
- * @private
3782
- */
3783
- LifecycleStateManager.prototype._internalStateOperations;
3784
- /**
3785
- * @type {?}
3786
- * @private
3787
- */
3788
- LifecycleStateManager.prototype._stateContextFactory;
3789
- /**
3790
- * @type {?}
3791
- * @private
3792
- */
3793
- LifecycleStateManager.prototype._bootstrapper;
3794
- }
3795
-
3796
- /**
3797
- * @fileoverview added by tsickle
3798
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
3799
- */
3800
- /**
3801
- * Allows the select decorator to get access to the DI store, this is used internally
3802
- * in `\@Select` decorator.
3803
- */
3804
- var SelectFactory = /** @class */ (function () {
3805
- function SelectFactory(store, config) {
3806
- SelectFactory.store = store;
3807
- SelectFactory.config = config;
3808
- }
3809
- /**
3810
- * @return {?}
3811
- */
3812
- SelectFactory.prototype.ngOnDestroy = /**
3813
- * @return {?}
3814
- */
3815
- function () {
3816
- SelectFactory.store = null;
3817
- SelectFactory.config = null;
3818
- };
3819
- SelectFactory.store = null;
3820
- SelectFactory.config = null;
3821
- SelectFactory.decorators = [
3822
- { type: Injectable }
3823
- ];
3824
- /** @nocollapse */
3825
- SelectFactory.ctorParameters = function () { return [
3826
- { type: Store },
3827
- { type: NgxsConfig }
3828
- ]; };
3829
- return SelectFactory;
3830
- }());
3831
- if (false) {
3832
- /** @type {?} */
3833
- SelectFactory.store;
3834
- /** @type {?} */
3835
- SelectFactory.config;
3836
- }
3837
-
3838
- /**
3839
- * @fileoverview added by tsickle
3840
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
3841
- */
3842
- /**
3843
- * Init action
3844
- */
3845
- var /**
3846
- * Init action
3847
- */
3848
- InitState = /** @class */ (function () {
3849
- function InitState() {
3850
- }
3851
- Object.defineProperty(InitState, "type", {
3852
- get: /**
3853
- * @return {?}
3854
- */
3855
- function () {
3856
- // NOTE: Not necessary to declare the type in this way in your code. See https://github.com/ngxs/store/pull/644#issuecomment-436003138
3857
- return '@@INIT';
3858
- },
3859
- enumerable: true,
3860
- configurable: true
3861
- });
3862
- return InitState;
3863
- }());
3864
- /**
3865
- * Update action
3866
- */
3867
- var /**
3868
- * Update action
3869
- */
3870
- UpdateState = /** @class */ (function () {
3871
- function UpdateState(addedStates) {
3872
- this.addedStates = addedStates;
3873
- }
3874
- Object.defineProperty(UpdateState, "type", {
3875
- get: /**
3876
- * @return {?}
3877
- */
3878
- function () {
3879
- // NOTE: Not necessary to declare the type in this way in your code. See https://github.com/ngxs/store/pull/644#issuecomment-436003138
3880
- return '@@UPDATE_STATE';
3881
- },
3882
- enumerable: true,
3883
- configurable: true
3884
- });
3885
- return UpdateState;
3886
- }());
3887
- if (false) {
3888
- /** @type {?} */
3889
- UpdateState.prototype.addedStates;
3890
- }
3891
-
3892
- /**
3893
- * @fileoverview added by tsickle
3894
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
3895
- */
3896
- /**
3897
- * Root module
3898
- * @ignore
3899
- */
3900
- var NgxsRootModule = /** @class */ (function () {
3901
- function NgxsRootModule(factory, internalStateOperations, _store, _select, states, lifecycleStateManager) {
3902
- if (states === void 0) { states = []; }
3903
- // Add stores to the state graph and return their defaults
3904
- /** @type {?} */
3905
- var results = factory.addAndReturnDefaults(states);
3906
- internalStateOperations.setStateToTheCurrentWithNew(results);
3907
- // Connect our actions stream
3908
- factory.connectActionHandlers();
3909
- // Dispatch the init action and invoke init and bootstrap functions after
3910
- lifecycleStateManager.ngxsBootstrap(new InitState(), results);
3911
- }
3912
- NgxsRootModule.decorators = [
3913
- { type: NgModule }
3914
- ];
3915
- /** @nocollapse */
3916
- NgxsRootModule.ctorParameters = function () { return [
3917
- { type: StateFactory },
3918
- { type: InternalStateOperations },
3919
- { type: Store },
3920
- { type: SelectFactory },
3921
- { type: Array, decorators: [{ type: Optional }, { type: Inject, args: [ROOT_STATE_TOKEN,] }] },
3922
- { type: LifecycleStateManager }
3923
- ]; };
3924
- return NgxsRootModule;
3925
- }());
3926
-
3927
- /**
3928
- * @fileoverview added by tsickle
3929
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
3930
- */
3931
- /**
3932
- * Feature module
3933
- * @ignore
3934
- */
3935
- var NgxsFeatureModule = /** @class */ (function () {
3936
- function NgxsFeatureModule(_store, internalStateOperations, factory, states, lifecycleStateManager) {
3937
- if (states === void 0) { states = []; }
3938
- // Since FEATURE_STATE_TOKEN is a multi token, we need to
3939
- // flatten it [[Feature1State, Feature2State], [Feature3State]]
3940
- /** @type {?} */
3941
- var flattenedStates = NgxsFeatureModule.flattenStates(states);
3942
- // add stores to the state graph and return their defaults
3943
- /** @type {?} */
3944
- var results = factory.addAndReturnDefaults(flattenedStates);
3945
- if (results.states.length) {
3946
- internalStateOperations.setStateToTheCurrentWithNew(results);
3947
- // dispatch the update action and invoke init and bootstrap functions after
3948
- lifecycleStateManager.ngxsBootstrap(new UpdateState(results.defaults), results);
3949
- }
3950
- }
3951
- /**
3952
- * @private
3953
- * @param {?=} states
3954
- * @return {?}
3955
- */
3956
- NgxsFeatureModule.flattenStates = /**
3957
- * @private
3958
- * @param {?=} states
3959
- * @return {?}
3960
- */
3961
- function (states) {
3962
- if (states === void 0) { states = []; }
3963
- return states.reduce((/**
3964
- * @param {?} total
3965
- * @param {?} values
3966
- * @return {?}
3967
- */
3968
- function (total, values) { return total.concat(values); }), []);
3969
- };
3970
- NgxsFeatureModule.decorators = [
3971
- { type: NgModule }
3972
- ];
3973
- /** @nocollapse */
3974
- NgxsFeatureModule.ctorParameters = function () { return [
3975
- { type: Store },
3976
- { type: InternalStateOperations },
3977
- { type: StateFactory },
3978
- { type: Array, decorators: [{ type: Optional }, { type: Inject, args: [FEATURE_STATE_TOKEN,] }] },
3979
- { type: LifecycleStateManager }
3980
- ]; };
3981
- return NgxsFeatureModule;
3982
- }());
3983
-
3984
- /**
3985
- * @fileoverview added by tsickle
3986
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
3987
- */
3988
- /**
3989
- * Ngxs Module
3990
- */
3991
- var NgxsModule = /** @class */ (function () {
3992
- function NgxsModule() {
3993
- }
3994
- /**
3995
- * Root module factory
3996
- */
3997
- /**
3998
- * Root module factory
3999
- * @param {?=} states
4000
- * @param {?=} options
4001
- * @return {?}
4002
- */
4003
- NgxsModule.forRoot = /**
4004
- * Root module factory
4005
- * @param {?=} states
4006
- * @param {?=} options
4007
- * @return {?}
4008
- */
4009
- function (states, options) {
4010
- if (states === void 0) { states = []; }
4011
- if (options === void 0) { options = {}; }
4012
- return {
4013
- ngModule: NgxsRootModule,
4014
- providers: __spread([
4015
- StateFactory,
4016
- StateContextFactory,
4017
- Actions,
4018
- InternalActions,
4019
- NgxsBootstrapper,
4020
- LifecycleStateManager,
4021
- InternalDispatcher,
4022
- InternalDispatchedActionResults,
4023
- InternalStateOperations,
4024
- InternalNgxsExecutionStrategy,
4025
- Store,
4026
- StateStream,
4027
- SelectFactory,
4028
- PluginManager
4029
- ], states, NgxsModule.ngxsTokenProviders(states, options))
4030
- };
4031
- };
4032
- /**
4033
- * Feature module factory
4034
- */
4035
- /**
4036
- * Feature module factory
4037
- * @param {?=} states
4038
- * @return {?}
4039
- */
4040
- NgxsModule.forFeature = /**
4041
- * Feature module factory
4042
- * @param {?=} states
4043
- * @return {?}
4044
- */
4045
- function (states) {
4046
- if (states === void 0) { states = []; }
4047
- return {
4048
- ngModule: NgxsFeatureModule,
4049
- providers: __spread([
4050
- StateFactory,
4051
- PluginManager
4052
- ], states, [
4053
- {
4054
- provide: FEATURE_STATE_TOKEN,
4055
- multi: true,
4056
- useValue: states
4057
- }
4058
- ])
4059
- };
4060
- };
4061
- /**
4062
- * @private
4063
- * @param {?} states
4064
- * @param {?} options
4065
- * @return {?}
4066
- */
4067
- NgxsModule.ngxsTokenProviders = /**
4068
- * @private
4069
- * @param {?} states
4070
- * @param {?} options
4071
- * @return {?}
4072
- */
4073
- function (states, options) {
4074
- return [
4075
- {
4076
- provide: USER_PROVIDED_NGXS_EXECUTION_STRATEGY,
4077
- useValue: options.executionStrategy
4078
- },
4079
- {
4080
- provide: ROOT_STATE_TOKEN,
4081
- useValue: states
4082
- },
4083
- {
4084
- provide: NgxsModule.ROOT_OPTIONS,
4085
- useValue: options
4086
- },
4087
- {
4088
- provide: NgxsConfig,
4089
- useFactory: NgxsModule.ngxsConfigFactory,
4090
- deps: [NgxsModule.ROOT_OPTIONS]
4091
- },
4092
- {
4093
- provide: APP_BOOTSTRAP_LISTENER,
4094
- useFactory: NgxsModule.appBootstrapListenerFactory,
4095
- multi: true,
4096
- deps: [NgxsBootstrapper]
4097
- },
4098
- {
4099
- provide: INITIAL_STATE_TOKEN,
4100
- useFactory: NgxsModule.getInitialState
4101
- },
4102
- {
4103
- provide: NGXS_STATE_CONTEXT_FACTORY,
4104
- useExisting: StateContextFactory
4105
- },
4106
- {
4107
- provide: NGXS_STATE_FACTORY,
4108
- useExisting: StateFactory
4109
- }
4110
- ];
4111
- };
4112
- /**
4113
- * @private
4114
- * @param {?} options
4115
- * @return {?}
4116
- */
4117
- NgxsModule.ngxsConfigFactory = /**
4118
- * @private
4119
- * @param {?} options
4120
- * @return {?}
4121
- */
4122
- function (options) {
4123
- return mergeDeep(new NgxsConfig(), options);
4124
- };
4125
- /**
4126
- * @private
4127
- * @param {?} bootstrapper
4128
- * @return {?}
4129
- */
4130
- NgxsModule.appBootstrapListenerFactory = /**
4131
- * @private
4132
- * @param {?} bootstrapper
4133
- * @return {?}
4134
- */
4135
- function (bootstrapper) {
4136
- return (/**
4137
- * @return {?}
4138
- */
4139
- function () { return bootstrapper.bootstrap(); });
4140
- };
4141
- /**
4142
- * @private
4143
- * @return {?}
4144
- */
4145
- NgxsModule.getInitialState = /**
4146
- * @private
4147
- * @return {?}
4148
- */
4149
- function () {
4150
- return InitialState.pop();
4151
- };
4152
- NgxsModule.ROOT_OPTIONS = new InjectionToken('ROOT_OPTIONS');
4153
- NgxsModule.decorators = [
4154
- { type: NgModule }
4155
- ];
4156
- return NgxsModule;
4157
- }());
4158
- if (false) {
4159
- /**
4160
- * @type {?}
4161
- * @private
4162
- */
4163
- NgxsModule.ROOT_OPTIONS;
4164
- }
4165
-
4166
- /**
4167
- * @fileoverview added by tsickle
4168
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
4169
- */
4170
- /**
4171
- * Decorates a method with a action information.
4172
- * @param {?} actions
4173
- * @param {?=} options
4174
- * @return {?}
4175
- */
4176
- function Action(actions, options) {
4177
- return (/**
4178
- * @param {?} target
4179
- * @param {?} name
4180
- * @return {?}
4181
- */
4182
- function (target, name) {
4183
- var e_1, _a;
4184
- // Caretaker note: we have still left the `typeof` condition in order to avoid
4185
- // creating a breaking change for projects that still use the View Engine.
4186
- if (typeof ngDevMode === 'undefined' || ngDevMode) {
4187
- /** @type {?} */
4188
- var isStaticMethod = target.hasOwnProperty('prototype');
4189
- if (isStaticMethod) {
4190
- throwActionDecoratorError();
4191
- }
4192
- }
4193
- /** @type {?} */
4194
- var meta = ensureStoreMetadata(target.constructor);
4195
- if (!Array.isArray(actions)) {
4196
- actions = [actions];
4197
- }
4198
- try {
4199
- for (var actions_1 = __values(actions), actions_1_1 = actions_1.next(); !actions_1_1.done; actions_1_1 = actions_1.next()) {
4200
- var action = actions_1_1.value;
4201
- /** @type {?} */
4202
- var type = action.type;
4203
- if (!meta.actions[type]) {
4204
- meta.actions[type] = [];
4205
- }
4206
- meta.actions[type].push({
4207
- fn: name,
4208
- options: options || {},
4209
- type: type
4210
- });
4211
- }
4212
- }
4213
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
4214
- finally {
4215
- try {
4216
- if (actions_1_1 && !actions_1_1.done && (_a = actions_1.return)) _a.call(actions_1);
4217
- }
4218
- finally { if (e_1) throw e_1.error; }
4219
- }
4220
- });
4221
- }
4222
-
4223
- /**
4224
- * @fileoverview added by tsickle
4225
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
4226
- */
4227
- /**
4228
- * @record
4229
- * @template T
4230
- */
4231
- function MutateMetaOptions() { }
4232
- if (false) {
4233
- /** @type {?} */
4234
- MutateMetaOptions.prototype.meta;
4235
- /** @type {?} */
4236
- MutateMetaOptions.prototype.inheritedStateClass;
4237
- /** @type {?} */
4238
- MutateMetaOptions.prototype.optionsWithInheritance;
4239
- }
4240
- /**
4241
- * Decorates a class with ngxs state information.
4242
- * @template T
4243
- * @param {?} options
4244
- * @return {?}
4245
- */
4246
- function State(options) {
4247
- /**
4248
- * @param {?} inheritedStateClass
4249
- * @return {?}
4250
- */
4251
- function getStateOptions(inheritedStateClass) {
4252
- /** @type {?} */
4253
- var inheritanceOptions = inheritedStateClass[META_OPTIONS_KEY] || {};
4254
- return (/** @type {?} */ (__assign({}, inheritanceOptions, options)));
4255
- }
4256
- /**
4257
- * @param {?} params
4258
- * @return {?}
4259
- */
4260
- function mutateMetaData(params) {
4261
- var meta = params.meta, inheritedStateClass = params.inheritedStateClass, optionsWithInheritance = params.optionsWithInheritance;
4262
- var children = optionsWithInheritance.children, defaults = optionsWithInheritance.defaults, name = optionsWithInheritance.name;
4263
- /** @type {?} */
4264
- var stateName = typeof name === 'string' ? name : (name && name.getName()) || null;
4265
- // Caretaker note: we have still left the `typeof` condition in order to avoid
4266
- // creating a breaking change for projects that still use the View Engine.
4267
- if (typeof ngDevMode === 'undefined' || ngDevMode) {
4268
- StoreValidators.checkThatStateIsNamedCorrectly(stateName);
4269
- }
4270
- if (inheritedStateClass.hasOwnProperty(META_KEY)) {
4271
- /** @type {?} */
4272
- var inheritedMeta = inheritedStateClass[META_KEY] || {};
4273
- meta.actions = __assign({}, meta.actions, inheritedMeta.actions);
4274
- }
4275
- meta.children = children;
4276
- meta.defaults = defaults;
4277
- meta.name = stateName;
4278
- }
4279
- return (/**
4280
- * @param {?} target
4281
- * @return {?}
4282
- */
4283
- function (target) {
4284
- /** @type {?} */
4285
- var stateClass = target;
4286
- /** @type {?} */
4287
- var meta = ensureStoreMetadata(stateClass);
4288
- /** @type {?} */
4289
- var inheritedStateClass = Object.getPrototypeOf(stateClass);
4290
- /** @type {?} */
4291
- var optionsWithInheritance = getStateOptions(inheritedStateClass);
4292
- mutateMetaData({ meta: meta, inheritedStateClass: inheritedStateClass, optionsWithInheritance: optionsWithInheritance });
4293
- stateClass[META_OPTIONS_KEY] = optionsWithInheritance;
4294
- });
4295
- }
4296
-
4297
- /**
4298
- * @fileoverview added by tsickle
4299
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
4300
- */
4301
- /** @type {?} */
4302
- var DOLLAR_CHAR_CODE = 36;
4303
- /**
4304
- * @template T
4305
- * @param {?} selector
4306
- * @return {?}
4307
- */
4308
- function createSelectObservable(selector) {
4309
- if (!SelectFactory.store) {
4310
- throwSelectFactoryNotConnectedError();
4311
- }
4312
- return (/** @type {?} */ (SelectFactory.store)).select(selector);
4313
- }
4314
- /**
4315
- * @param {?} name
4316
- * @param {?=} rawSelector
4317
- * @param {?=} paths
4318
- * @return {?}
4319
- */
4320
- function createSelectorFn(name, rawSelector, paths) {
4321
- if (paths === void 0) { paths = []; }
4322
- rawSelector = !rawSelector ? removeDollarAtTheEnd(name) : rawSelector;
4323
- if (typeof rawSelector === 'string') {
4324
- /** @type {?} */
4325
- var propsArray = paths.length
4326
- ? __spread([rawSelector], paths) : rawSelector.split('.');
4327
- return propGetter(propsArray, (/** @type {?} */ (SelectFactory.config)));
4328
- }
4329
- return rawSelector;
4330
- }
4331
- /**
4332
- * \@example If `foo$` => make it just `foo`
4333
- * @param {?} name
4334
- * @return {?}
4335
- */
4336
- function removeDollarAtTheEnd(name) {
4337
- /** @type {?} */
4338
- var lastCharIndex = name.length - 1;
4339
- /** @type {?} */
4340
- var dollarAtTheEnd = name.charCodeAt(lastCharIndex) === DOLLAR_CHAR_CODE;
4341
- return dollarAtTheEnd ? name.slice(0, lastCharIndex) : name;
4342
- }
4343
-
4344
- /**
4345
- * @fileoverview added by tsickle
4346
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
4347
- */
4348
- /**
4349
- * Decorator for selecting a slice of state from the store.
4350
- * @template T
4351
- * @param {?=} rawSelector
4352
- * @param {...?} paths
4353
- * @return {?}
4354
- */
4355
- function Select(rawSelector) {
4356
- var paths = [];
4357
- for (var _i = 1; _i < arguments.length; _i++) {
4358
- paths[_i - 1] = arguments[_i];
4359
- }
4360
- return (/**
4361
- * @param {?} target
4362
- * @param {?} key
4363
- * @return {?}
4364
- */
4365
- function (target, key) {
4366
- var _a;
4367
- /** @type {?} */
4368
- var name = key.toString();
4369
- /** @type {?} */
4370
- var selectorId = "__" + name + "__selector";
4371
- /** @type {?} */
4372
- var selector = createSelectorFn(name, rawSelector, paths);
4373
- Object.defineProperties(target, (_a = {},
4374
- _a[selectorId] = {
4375
- writable: true,
4376
- enumerable: false,
4377
- configurable: true
4378
- },
4379
- _a[name] = {
4380
- enumerable: true,
4381
- configurable: true,
4382
- get: /**
4383
- * @return {?}
4384
- */
4385
- function () {
4386
- return this[selectorId] || (this[selectorId] = createSelectObservable(selector));
4387
- }
4388
- },
4389
- _a));
4390
- });
4391
- }
4392
-
4393
- /**
4394
- * @fileoverview added by tsickle
4395
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
4396
- */
4397
- /**
4398
- * Decorator for setting selector options at a method or class level.
4399
- * @param {?} options
4400
- * @return {?}
4401
- */
4402
- function SelectorOptions(options) {
4403
- return (/** @type {?} */ (((/**
4404
- * @template T
4405
- * @param {?} target
4406
- * @param {?} methodName
4407
- * @param {?} descriptor
4408
- * @return {?}
4409
- */
4410
- function decorate(target, methodName, descriptor) {
4411
- if (methodName) {
4412
- // Method Decorator
4413
- /** @type {?} */
4414
- var originalFn = descriptor.value || ((/** @type {?} */ (descriptor))).originalFn;
4415
- if (originalFn) {
4416
- selectorOptionsMetaAccessor.defineOptions(originalFn, options);
4417
- }
4418
- }
4419
- else {
4420
- // Class Decorator
4421
- selectorOptionsMetaAccessor.defineOptions(target, options);
4422
- }
4423
- }))));
4424
- }
4425
-
4426
- /**
4427
- * @fileoverview added by tsickle
4428
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
4429
- */
4430
- /**
4431
- * @record
4432
- */
4433
- function MetaDataModel$1() { }
4434
- if (false) {
4435
- /** @type {?} */
4436
- MetaDataModel$1.prototype.name;
4437
- /** @type {?} */
4438
- MetaDataModel$1.prototype.actions;
4439
- /** @type {?} */
4440
- MetaDataModel$1.prototype.defaults;
4441
- /** @type {?} */
4442
- MetaDataModel$1.prototype.path;
4443
- /** @type {?|undefined} */
4444
- MetaDataModel$1.prototype.children;
4445
- }
4446
- /**
4447
- * @record
4448
- */
4449
- function SelectorMetaDataModel$1() { }
4450
- if (false) {
4451
- /** @type {?} */
4452
- SelectorMetaDataModel$1.prototype.originalFn;
4453
- /** @type {?} */
4454
- SelectorMetaDataModel$1.prototype.containerClass;
4455
- /** @type {?} */
4456
- SelectorMetaDataModel$1.prototype.selectorName;
4457
- /** @type {?} */
4458
- SelectorMetaDataModel$1.prototype.getSelectorOptions;
4459
- }
4460
- /**
4461
- * @param {?} target
4462
- * @return {?}
4463
- */
4464
- function ensureStoreMetadata$1(target) {
4465
- return ensureStoreMetadata(target);
4466
- }
4467
- /**
4468
- * @param {?} target
4469
- * @return {?}
4470
- */
4471
- function getStoreMetadata$1(target) {
4472
- return getStoreMetadata(target);
4473
- }
4474
- /**
4475
- * @param {?} target
4476
- * @return {?}
4477
- */
4478
- function ensureSelectorMetadata$1(target) {
4479
- return ensureSelectorMetadata(target);
4480
- }
4481
- /**
4482
- * @param {?} target
4483
- * @return {?}
4484
- */
4485
- function getSelectorMetadata$1(target) {
4486
- return getSelectorMetadata(target);
4487
- }
4488
-
4489
- /**
4490
- * @fileoverview added by tsickle
4491
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
4492
- */
4493
- /**
4494
- * Decorator for memoizing a state selector.
4495
- * @template T
4496
- * @param {?=} selectors
4497
- * @return {?}
4498
- */
4499
- function Selector(selectors) {
4500
- return (/**
4501
- * @template U
4502
- * @param {?} target
4503
- * @param {?} key
4504
- * @param {?} descriptor
4505
- * @return {?}
4506
- */
4507
- function (target, key, descriptor) {
4508
- // Caretaker note: we have still left the `typeof` condition in order to avoid
4509
- // creating a breaking change for projects that still use the View Engine.
4510
- if (typeof ngDevMode === 'undefined' || ngDevMode) {
4511
- /** @type {?} */
4512
- var isNotMethod = !(descriptor && descriptor.value !== null);
4513
- if (isNotMethod) {
4514
- throwSelectorDecoratorError();
4515
- }
4516
- }
4517
- /** @type {?} */
4518
- var originalFn = descriptor.value;
4519
- /** @type {?} */
4520
- var memoizedFn = createSelector(selectors, (/** @type {?} */ (originalFn)), {
4521
- containerClass: target,
4522
- selectorName: key.toString(),
4523
- getSelectorOptions: /**
4524
- * @return {?}
4525
- */
4526
- function () {
4527
- return {};
4528
- }
4529
- });
4530
- /** @type {?} */
4531
- var newDescriptor = {
4532
- configurable: true,
4533
- get: /**
4534
- * @return {?}
4535
- */
4536
- function () {
4537
- return memoizedFn;
4538
- }
4539
- };
4540
- // Add hidden property to descriptor
4541
- ((/** @type {?} */ (newDescriptor)))['originalFn'] = originalFn;
4542
- return newDescriptor;
4543
- });
4544
- }
4545
-
4546
- /**
4547
- * @fileoverview added by tsickle
4548
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
4549
- */
4550
- /**
4551
- * @template T
4552
- */
4553
- var /**
4554
- * @template T
4555
- */
4556
- StateToken = /** @class */ (function () {
4557
- function StateToken(name) {
4558
- var _this = this;
4559
- this.name = name;
4560
- /** @type {?} */
4561
- var selectorMetadata = ensureSelectorMetadata((/** @type {?} */ (this)));
4562
- selectorMetadata.makeRootSelector = (/**
4563
- * @param {?} runtimeContext
4564
- * @return {?}
4565
- */
4566
- function (runtimeContext) {
4567
- return runtimeContext.getStateGetter(_this.name);
4568
- });
4569
- }
4570
- /**
4571
- * @return {?}
4572
- */
4573
- StateToken.prototype.getName = /**
4574
- * @return {?}
4575
- */
4576
- function () {
4577
- return this.name;
4578
- };
4579
- /**
4580
- * @return {?}
4581
- */
4582
- StateToken.prototype.toString = /**
4583
- * @return {?}
4584
- */
4585
- function () {
4586
- return "StateToken[" + this.name + "]";
4587
- };
4588
- return StateToken;
4589
- }());
4590
- if (false) {
4591
- /**
4592
- * @type {?}
4593
- * @private
4594
- */
4595
- StateToken.prototype.name;
4596
- }
4597
-
4598
- /**
4599
- * @fileoverview added by tsickle
4600
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
4601
- */
4602
-
4603
- /**
4604
- * @fileoverview added by tsickle
4605
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
4606
- */
4607
-
4608
- /**
4609
- * @fileoverview added by tsickle
4610
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
4611
- */
4612
-
4613
- /**
4614
- * @fileoverview added by tsickle
4615
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
4616
- */
4617
-
4618
- export { Action, Actions, InitState, NGXS_PLUGINS, NgxsModule, NgxsSimpleChange, 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, 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, NgxsRootModule as ɵj, StateFactory as ɵk, InternalDispatchedActionResults as ɵl, InternalDispatcher as ɵm, StateContextFactory as ɵn, InternalStateOperations as ɵo, PluginManager as ɵp, InternalNgxsExecutionStrategy as ɵq, InternalErrorReporter as ɵr, SelectFactory as ɵs, ensureStoreMetadata as ɵu, getStoreMetadata as ɵv, ensureSelectorMetadata as ɵw, getSelectorMetadata as ɵx, LifecycleStateManager as ɵy, NgxsFeatureModule as ɵz };
4619
- //# sourceMappingURL=ngxs-store.js.map