@ngxs/store 3.8.2 → 18.0.0-dev.master-f4c2c19

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 (379) hide show
  1. package/README.md +1 -1
  2. package/{esm2015/index.js → esm2022/index.mjs} +2 -2
  3. package/esm2022/internals/custom-rxjs-subjects.mjs +92 -0
  4. package/esm2022/internals/index.mjs +10 -0
  5. package/esm2022/internals/initial-state.mjs +18 -0
  6. package/esm2022/internals/internal-tokens.mjs +6 -0
  7. package/esm2022/internals/memoize.mjs +45 -0
  8. package/esm2022/internals/metadata.mjs +57 -0
  9. package/esm2022/internals/ngxs-app-bootstrapped-state.mjs +19 -0
  10. package/esm2022/internals/state-stream.mjs +32 -0
  11. package/esm2022/internals/state-token.mjs +17 -0
  12. package/esm2022/internals/symbols.mjs +11 -0
  13. package/esm2022/internals/testing/fresh-platform.mjs +72 -0
  14. package/{esm2015/internals/testing/helpers/ngxs-test.component.js → esm2022/internals/testing/helpers/ngxs-test.component.mjs} +4 -4
  15. package/esm2022/internals/testing/helpers/ngxs-test.module.mjs +20 -0
  16. package/{esm2015/internals/testing/index.js → esm2022/internals/testing/index.mjs} +2 -2
  17. package/esm2022/internals/testing/ngxs.setup.mjs +48 -0
  18. package/{esm2015/internals/testing/skip-console-logging.js → esm2022/internals/testing/skip-console-logging.mjs} +1 -1
  19. package/esm2022/internals/testing/symbol.mjs +2 -0
  20. package/esm2022/operators/append.mjs +20 -0
  21. package/esm2022/operators/iif.mjs +38 -0
  22. package/esm2022/operators/insert-item.mjs +29 -0
  23. package/esm2022/operators/patch.mjs +21 -0
  24. package/esm2022/operators/remove-item.mjs +22 -0
  25. package/esm2022/operators/update-item.mjs +40 -0
  26. package/esm2022/plugins/actions.mjs +16 -0
  27. package/esm2022/plugins/index.mjs +4 -0
  28. package/esm2022/plugins/ngxs-store-plugins.mjs +5 -0
  29. package/esm2022/plugins/symbols.mjs +6 -0
  30. package/esm2022/plugins/utils.mjs +51 -0
  31. package/esm2022/src/actions/symbols.mjs +2 -0
  32. package/esm2022/src/actions-stream.mjs +52 -0
  33. package/esm2022/src/configs/messages.config.mjs +48 -0
  34. package/esm2022/src/decorators/action.mjs +31 -0
  35. package/esm2022/src/decorators/select/select-factory.mjs +29 -0
  36. package/esm2022/src/decorators/select/select.mjs +29 -0
  37. package/esm2022/src/decorators/select/symbols.mjs +29 -0
  38. package/esm2022/src/decorators/selector/selector.mjs +29 -0
  39. package/esm2022/src/decorators/selector/symbols.mjs +2 -0
  40. package/esm2022/src/decorators/selector-options.mjs +21 -0
  41. package/esm2022/src/decorators/state.mjs +35 -0
  42. package/esm2022/src/dev-features/ngxs-development.module.mjs +28 -0
  43. package/esm2022/src/dev-features/ngxs-unhandled-actions-logger.mjs +45 -0
  44. package/esm2022/src/dev-features/symbols.mjs +7 -0
  45. package/esm2022/src/execution/dispatch-outside-zone-ngxs-execution-strategy.mjs +55 -0
  46. package/{esm2015/src/execution/internal-ngxs-execution-strategy.js → esm2022/src/execution/internal-ngxs-execution-strategy.mjs} +6 -6
  47. package/{esm2015/src/execution/noop-ngxs-execution-strategy.js → esm2022/src/execution/noop-ngxs-execution-strategy.mjs} +4 -4
  48. package/esm2022/src/execution/symbols.mjs +29 -0
  49. package/esm2022/src/internal/dispatcher.mjs +106 -0
  50. package/esm2022/src/internal/fallback-subscriber.mjs +29 -0
  51. package/esm2022/src/internal/internals.mjs +206 -0
  52. package/esm2022/src/internal/lifecycle-state-manager.mjs +86 -0
  53. package/esm2022/src/internal/state-context-factory.mjs +71 -0
  54. package/esm2022/src/internal/state-factory.mjs +311 -0
  55. package/esm2022/src/internal/state-operations.mjs +63 -0
  56. package/esm2022/src/internal/state-operators.mjs +20 -0
  57. package/esm2022/src/internal/unhandled-rxjs-error-callback.mjs +39 -0
  58. package/esm2022/src/ivy/ivy-enabled-in-dev-mode.mjs +25 -0
  59. package/esm2022/src/module.mjs +27 -0
  60. package/esm2022/src/modules/ngxs-feature.module.mjs +18 -0
  61. package/esm2022/src/modules/ngxs-root.module.mjs +18 -0
  62. package/esm2022/src/ngxs-unhandled-error-handler.mjs +29 -0
  63. package/esm2022/src/operators/of-action.mjs +104 -0
  64. package/esm2022/src/plugin-manager.mjs +37 -0
  65. package/esm2022/src/plugin_api.mjs +2 -0
  66. package/{esm2015/src/private_api.js → esm2022/src/private_api.mjs} +2 -1
  67. package/esm2022/src/public_api.mjs +20 -0
  68. package/esm2022/src/selectors/create-model-selector.mjs +30 -0
  69. package/esm2022/src/selectors/create-pick-selector.mjs +16 -0
  70. package/esm2022/src/selectors/create-property-selectors.mjs +20 -0
  71. package/esm2022/src/selectors/create-selector.mjs +9 -0
  72. package/esm2022/src/selectors/private_api.mjs +2 -0
  73. package/esm2022/src/selectors/selector-checks.util.mjs +18 -0
  74. package/esm2022/src/selectors/selector-metadata.mjs +35 -0
  75. package/esm2022/src/selectors/selector-models.mjs +2 -0
  76. package/esm2022/src/selectors/selector-types.util.mjs +2 -0
  77. package/esm2022/src/selectors/selector-utils.mjs +95 -0
  78. package/esm2022/src/standalone-features/feature-providers.mjs +20 -0
  79. package/esm2022/src/standalone-features/index.mjs +5 -0
  80. package/esm2022/src/standalone-features/initializers.mjs +89 -0
  81. package/esm2022/src/standalone-features/plugin.mjs +20 -0
  82. package/esm2022/src/standalone-features/preboot.mjs +32 -0
  83. package/esm2022/src/standalone-features/provide-states.mjs +26 -0
  84. package/esm2022/src/standalone-features/provide-store.mjs +26 -0
  85. package/esm2022/src/standalone-features/root-providers.mjs +47 -0
  86. package/esm2022/src/store.mjs +117 -0
  87. package/esm2022/src/symbols.mjs +87 -0
  88. package/esm2022/src/utils/compose.mjs +26 -0
  89. package/esm2022/src/utils/create-dispatch-map.mjs +11 -0
  90. package/esm2022/src/utils/create-select-map.mjs +13 -0
  91. package/esm2022/src/utils/dispatch.mjs +7 -0
  92. package/{esm2015/src/utils/freeze.js → esm2022/src/utils/freeze.mjs} +1 -1
  93. package/esm2022/src/utils/public_api.mjs +5 -0
  94. package/esm2022/src/utils/select.mjs +19 -0
  95. package/esm2022/src/utils/store-validators.mjs +25 -0
  96. package/{fesm2015/ngxs-store-internals-testing.js → fesm2022/ngxs-store-internals-testing.mjs} +84 -81
  97. package/fesm2022/ngxs-store-internals-testing.mjs.map +1 -0
  98. package/fesm2022/ngxs-store-internals.mjs +296 -0
  99. package/fesm2022/ngxs-store-internals.mjs.map +1 -0
  100. package/{fesm2015/ngxs-store-operators.js → fesm2022/ngxs-store-operators.mjs} +3 -3
  101. package/fesm2022/ngxs-store-operators.mjs.map +1 -0
  102. package/fesm2022/ngxs-store-plugins.mjs +80 -0
  103. package/fesm2022/ngxs-store-plugins.mjs.map +1 -0
  104. package/{fesm2015/ngxs-store.js → fesm2022/ngxs-store.mjs} +1319 -1265
  105. package/fesm2022/ngxs-store.mjs.map +1 -0
  106. package/index.d.ts +1 -1
  107. package/{src/internal → internals}/custom-rxjs-subjects.d.ts +2 -2
  108. package/internals/index.d.ts +8 -4
  109. package/internals/initial-state.d.ts +5 -5
  110. package/internals/memoize.d.ts +1 -1
  111. package/internals/metadata.d.ts +25 -0
  112. package/internals/ngxs-app-bootstrapped-state.d.ts +8 -0
  113. package/internals/state-stream.d.ts +15 -0
  114. package/internals/state-token.d.ts +7 -0
  115. package/internals/symbols.d.ts +84 -3
  116. package/internals/testing/helpers/ngxs-test.component.d.ts +1 -1
  117. package/internals/testing/index.d.ts +2 -2
  118. package/internals/testing/symbol.d.ts +2 -2
  119. package/operators/patch.d.ts +2 -2
  120. package/operators/types.d.ts +5 -5
  121. package/operators/utils.d.ts +1 -1
  122. package/package.json +44 -13
  123. package/{src/actions → plugins}/actions.d.ts +3 -3
  124. package/plugins/index.d.ts +3 -0
  125. package/plugins/symbols.d.ts +13 -0
  126. package/{src/utils → plugins}/utils.d.ts +0 -17
  127. package/schematics/collection.json +36 -0
  128. package/schematics/src/actions/actions.factory.d.ts +3 -0
  129. package/schematics/src/actions/actions.factory.js +24 -0
  130. package/schematics/src/actions/actions.factory.js.map +1 -0
  131. package/schematics/src/actions/files/__name__.actions.ts__template__ +4 -0
  132. package/schematics/src/actions/schema.json +35 -0
  133. package/schematics/src/ng-add/add-declaration.d.ts +4 -0
  134. package/schematics/src/ng-add/add-declaration.js +109 -0
  135. package/schematics/src/ng-add/add-declaration.js.map +1 -0
  136. package/schematics/src/ng-add/ng-add.factory.d.ts +9 -0
  137. package/schematics/src/ng-add/ng-add.factory.js +89 -0
  138. package/schematics/src/ng-add/ng-add.factory.js.map +1 -0
  139. package/schematics/src/ng-add/schema.json +72 -0
  140. package/schematics/src/starter-kit/files/store/auth/auth.actions.ts__template__ +6 -0
  141. package/schematics/src/starter-kit/files/store/auth/auth.state.spec.ts__template__ +55 -0
  142. package/schematics/src/starter-kit/files/store/auth/auth.state.ts__template__ +47 -0
  143. package/schematics/src/starter-kit/files/store/dashboard/index.ts__template__ +4 -0
  144. package/schematics/src/starter-kit/files/store/dashboard/states/dictionary/dictionary.actions.ts__template__ +10 -0
  145. package/schematics/src/starter-kit/files/store/dashboard/states/dictionary/dictionary.state.spec.ts__template__ +92 -0
  146. package/schematics/src/starter-kit/files/store/dashboard/states/dictionary/dictionary.state.ts__template__ +62 -0
  147. package/schematics/src/starter-kit/files/store/dashboard/states/user/user.actions.ts__template__ +6 -0
  148. package/schematics/src/starter-kit/files/store/dashboard/states/user/user.state.spec.ts__template__ +61 -0
  149. package/schematics/src/starter-kit/files/store/dashboard/states/user/user.state.ts__template__ +42 -0
  150. package/schematics/src/starter-kit/files/store/store.config.ts__template__ +39 -0
  151. package/schematics/src/starter-kit/files/store/store.module.ts__template__ +22 -0
  152. package/schematics/src/starter-kit/schema.json +22 -0
  153. package/schematics/src/starter-kit/starter-kit.factory.d.ts +3 -0
  154. package/schematics/src/starter-kit/starter-kit.factory.js +21 -0
  155. package/schematics/src/starter-kit/starter-kit.factory.js.map +1 -0
  156. package/schematics/src/state/files/__name__.state.spec.ts__template__ +25 -0
  157. package/schematics/src/state/files/__name__.state.ts__template__ +22 -0
  158. package/schematics/src/state/schema.json +44 -0
  159. package/schematics/src/state/state.factory.d.ts +3 -0
  160. package/schematics/src/state/state.factory.js +29 -0
  161. package/schematics/src/state/state.factory.js.map +1 -0
  162. package/schematics/src/store/files/__name__.actions.ts__template__ +4 -0
  163. package/schematics/src/store/files/__name__.state.spec.ts__template__ +26 -0
  164. package/schematics/src/store/files/__name__.state.ts__template__ +29 -0
  165. package/schematics/src/store/schema.json +44 -0
  166. package/schematics/src/store/store.factory.d.ts +3 -0
  167. package/schematics/src/store/store.factory.js +29 -0
  168. package/schematics/src/store/store.factory.js.map +1 -0
  169. package/schematics/src/utils/common/lib.config.d.ts +10 -0
  170. package/schematics/src/utils/common/lib.config.js +15 -0
  171. package/schematics/src/utils/common/lib.config.js.map +1 -0
  172. package/schematics/src/utils/common/project-files.config.d.ts +3 -0
  173. package/schematics/src/utils/common/project-files.config.js +7 -0
  174. package/schematics/src/utils/common/project-files.config.js.map +1 -0
  175. package/schematics/src/utils/common/properties.d.ts +1 -0
  176. package/schematics/src/utils/common/properties.js +8 -0
  177. package/schematics/src/utils/common/properties.js.map +1 -0
  178. package/schematics/src/utils/config.d.ts +119 -0
  179. package/schematics/src/utils/config.js +21 -0
  180. package/schematics/src/utils/config.js.map +1 -0
  181. package/schematics/src/utils/generate-utils.d.ts +4 -0
  182. package/schematics/src/utils/generate-utils.js +14 -0
  183. package/schematics/src/utils/generate-utils.js.map +1 -0
  184. package/schematics/src/utils/interfaces/package.interface.d.ts +7 -0
  185. package/schematics/src/utils/interfaces/package.interface.js +3 -0
  186. package/schematics/src/utils/interfaces/package.interface.js.map +1 -0
  187. package/schematics/src/utils/ng-utils/README.md +1 -0
  188. package/schematics/src/utils/ng-utils/ast-utils.d.ts +99 -0
  189. package/schematics/src/utils/ng-utils/ast-utils.js +517 -0
  190. package/schematics/src/utils/ng-utils/ast-utils.js.map +1 -0
  191. package/schematics/src/utils/ng-utils/ng-ast-utils.d.ts +5 -0
  192. package/schematics/src/utils/ng-utils/ng-ast-utils.js +67 -0
  193. package/schematics/src/utils/ng-utils/ng-ast-utils.js.map +1 -0
  194. package/schematics/src/utils/ng-utils/project.d.ts +2 -0
  195. package/schematics/src/utils/ng-utils/project.js +27 -0
  196. package/schematics/src/utils/ng-utils/project.js.map +1 -0
  197. package/schematics/src/utils/ng-utils/standalone/app_config.d.ts +16 -0
  198. package/schematics/src/utils/ng-utils/standalone/app_config.js +84 -0
  199. package/schematics/src/utils/ng-utils/standalone/app_config.js.map +1 -0
  200. package/schematics/src/utils/ng-utils/standalone/code_block.d.ts +46 -0
  201. package/schematics/src/utils/ng-utils/standalone/code_block.js +73 -0
  202. package/schematics/src/utils/ng-utils/standalone/code_block.js.map +1 -0
  203. package/schematics/src/utils/ng-utils/standalone/index.d.ts +1 -0
  204. package/schematics/src/utils/ng-utils/standalone/index.js +7 -0
  205. package/schematics/src/utils/ng-utils/standalone/index.js.map +1 -0
  206. package/schematics/src/utils/ng-utils/standalone/rules.d.ts +38 -0
  207. package/schematics/src/utils/ng-utils/standalone/rules.js +195 -0
  208. package/schematics/src/utils/ng-utils/standalone/rules.js.map +1 -0
  209. package/schematics/src/utils/ng-utils/standalone/util.d.ts +28 -0
  210. package/schematics/src/utils/ng-utils/standalone/util.js +138 -0
  211. package/schematics/src/utils/ng-utils/standalone/util.js.map +1 -0
  212. package/schematics/src/utils/normalize-options.d.ts +11 -0
  213. package/schematics/src/utils/normalize-options.js +27 -0
  214. package/schematics/src/utils/normalize-options.js.map +1 -0
  215. package/schematics/src/utils/project.d.ts +19 -0
  216. package/schematics/src/utils/project.js +46 -0
  217. package/schematics/src/utils/project.js.map +1 -0
  218. package/schematics/src/utils/versions.json +3 -0
  219. package/src/actions/symbols.d.ts +3 -17
  220. package/src/actions-stream.d.ts +2 -2
  221. package/src/configs/messages.config.d.ts +3 -1
  222. package/src/decorators/action.d.ts +28 -3
  223. package/src/decorators/select/select.d.ts +3 -0
  224. package/src/decorators/select/symbols.d.ts +2 -3
  225. package/src/decorators/selector/selector.d.ts +2 -3
  226. package/src/decorators/selector/symbols.d.ts +73 -4
  227. package/src/decorators/selector-options.d.ts +2 -2
  228. package/src/decorators/state.d.ts +2 -3
  229. package/src/dev-features/ngxs-development.module.d.ts +1 -0
  230. package/src/execution/symbols.d.ts +8 -2
  231. package/src/internal/dispatcher.d.ts +5 -5
  232. package/src/internal/fallback-subscriber.d.ts +3 -0
  233. package/src/internal/internals.d.ts +13 -69
  234. package/src/internal/lifecycle-state-manager.d.ts +6 -6
  235. package/src/internal/state-factory.d.ts +8 -6
  236. package/src/internal/state-operations.d.ts +2 -2
  237. package/src/internal/unhandled-rxjs-error-callback.d.ts +2 -0
  238. package/src/module.d.ts +3 -14
  239. package/src/modules/ngxs-feature.module.d.ts +2 -9
  240. package/src/modules/ngxs-root.module.d.ts +2 -9
  241. package/src/ngxs-unhandled-error-handler.d.ts +16 -0
  242. package/src/operators/of-action.d.ts +3 -3
  243. package/src/plugin-manager.d.ts +1 -1
  244. package/src/plugin_api.d.ts +1 -5
  245. package/src/private_api.d.ts +1 -0
  246. package/src/public_api.d.ts +11 -8
  247. package/src/selectors/create-model-selector.d.ts +2 -2
  248. package/src/selectors/create-pick-selector.d.ts +1 -1
  249. package/src/selectors/create-property-selectors.d.ts +3 -3
  250. package/src/selectors/create-selector.d.ts +10 -10
  251. package/src/selectors/private_api.d.ts +7 -0
  252. package/src/selectors/selector-checks.util.d.ts +2 -2
  253. package/src/selectors/selector-metadata.d.ts +4 -4
  254. package/src/selectors/selector-models.d.ts +4 -4
  255. package/src/selectors/selector-types.util.d.ts +6 -7
  256. package/src/selectors/selector-utils.d.ts +3 -3
  257. package/src/standalone-features/feature-providers.d.ts +7 -0
  258. package/src/standalone-features/index.d.ts +4 -0
  259. package/src/standalone-features/initializers.d.ts +29 -0
  260. package/src/standalone-features/plugin.d.ts +17 -0
  261. package/src/standalone-features/preboot.d.ts +26 -0
  262. package/src/standalone-features/provide-states.d.ts +18 -0
  263. package/src/standalone-features/provide-store.d.ts +22 -0
  264. package/src/standalone-features/root-providers.d.ts +8 -0
  265. package/src/store.d.ts +13 -15
  266. package/src/symbols.d.ts +12 -54
  267. package/src/utils/compose.d.ts +1 -1
  268. package/src/utils/create-dispatch-map.d.ts +4 -0
  269. package/src/utils/create-select-map.d.ts +4 -0
  270. package/src/utils/dispatch.d.ts +2 -0
  271. package/src/utils/public_api.d.ts +4 -0
  272. package/src/utils/select.d.ts +16 -0
  273. package/src/utils/store-validators.d.ts +4 -3
  274. package/bundles/ngxs-store-internals-testing.umd.js +0 -684
  275. package/bundles/ngxs-store-internals-testing.umd.js.map +0 -1
  276. package/bundles/ngxs-store-internals.umd.js +0 -141
  277. package/bundles/ngxs-store-internals.umd.js.map +0 -1
  278. package/bundles/ngxs-store-operators.umd.js +0 -224
  279. package/bundles/ngxs-store-operators.umd.js.map +0 -1
  280. package/bundles/ngxs-store.umd.js +0 -3076
  281. package/bundles/ngxs-store.umd.js.map +0 -1
  282. package/esm2015/internals/index.js +0 -5
  283. package/esm2015/internals/initial-state.js +0 -17
  284. package/esm2015/internals/internal-tokens.js +0 -5
  285. package/esm2015/internals/memoize.js +0 -45
  286. package/esm2015/internals/ngxs-bootstrapper.js +0 -29
  287. package/esm2015/internals/src/symbols.js +0 -2
  288. package/esm2015/internals/symbols.js +0 -2
  289. package/esm2015/internals/testing/fresh-platform.js +0 -70
  290. package/esm2015/internals/testing/helpers/ngxs-test.module.js +0 -21
  291. package/esm2015/internals/testing/ngxs.setup.js +0 -46
  292. package/esm2015/internals/testing/symbol.js +0 -2
  293. package/esm2015/operators/append.js +0 -20
  294. package/esm2015/operators/iif.js +0 -38
  295. package/esm2015/operators/insert-item.js +0 -29
  296. package/esm2015/operators/patch.js +0 -21
  297. package/esm2015/operators/remove-item.js +0 -22
  298. package/esm2015/operators/update-item.js +0 -40
  299. package/esm2015/src/actions/actions.js +0 -16
  300. package/esm2015/src/actions/symbols.js +0 -2
  301. package/esm2015/src/actions-stream.js +0 -52
  302. package/esm2015/src/configs/messages.config.js +0 -36
  303. package/esm2015/src/decorators/action.js +0 -33
  304. package/esm2015/src/decorators/select/select-factory.js +0 -29
  305. package/esm2015/src/decorators/select/select.js +0 -26
  306. package/esm2015/src/decorators/select/symbols.js +0 -29
  307. package/esm2015/src/decorators/selector/selector.js +0 -32
  308. package/esm2015/src/decorators/selector/symbols.js +0 -2
  309. package/esm2015/src/decorators/selector-options.js +0 -21
  310. package/esm2015/src/decorators/state.js +0 -36
  311. package/esm2015/src/dev-features/ngxs-development.module.js +0 -22
  312. package/esm2015/src/dev-features/ngxs-unhandled-actions-logger.js +0 -46
  313. package/esm2015/src/dev-features/symbols.js +0 -6
  314. package/esm2015/src/execution/dispatch-outside-zone-ngxs-execution-strategy.js +0 -57
  315. package/esm2015/src/execution/symbols.js +0 -23
  316. package/esm2015/src/internal/custom-rxjs-subjects.js +0 -92
  317. package/esm2015/src/internal/dispatcher.js +0 -104
  318. package/esm2015/src/internal/error-handler.js +0 -64
  319. package/esm2015/src/internal/internals.js +0 -248
  320. package/esm2015/src/internal/lifecycle-state-manager.js +0 -79
  321. package/esm2015/src/internal/state-context-factory.js +0 -68
  322. package/esm2015/src/internal/state-factory.js +0 -288
  323. package/esm2015/src/internal/state-operations.js +0 -63
  324. package/esm2015/src/internal/state-operators.js +0 -20
  325. package/esm2015/src/internal/state-stream.js +0 -25
  326. package/esm2015/src/ivy/ivy-enabled-in-dev-mode.js +0 -25
  327. package/esm2015/src/module.js +0 -88
  328. package/esm2015/src/modules/ngxs-feature.module.js +0 -45
  329. package/esm2015/src/modules/ngxs-root.module.js +0 -41
  330. package/esm2015/src/operators/of-action.js +0 -102
  331. package/esm2015/src/plugin-manager.js +0 -37
  332. package/esm2015/src/plugin_api.js +0 -6
  333. package/esm2015/src/public_api.js +0 -27
  334. package/esm2015/src/public_to_deprecate.js +0 -14
  335. package/esm2015/src/selectors/create-model-selector.js +0 -30
  336. package/esm2015/src/selectors/create-pick-selector.js +0 -16
  337. package/esm2015/src/selectors/create-property-selectors.js +0 -20
  338. package/esm2015/src/selectors/create-selector.js +0 -9
  339. package/esm2015/src/selectors/selector-checks.util.js +0 -18
  340. package/esm2015/src/selectors/selector-metadata.js +0 -30
  341. package/esm2015/src/selectors/selector-models.js +0 -2
  342. package/esm2015/src/selectors/selector-types.util.js +0 -2
  343. package/esm2015/src/selectors/selector-utils.js +0 -74
  344. package/esm2015/src/state-token/state-token.js +0 -17
  345. package/esm2015/src/state-token/symbols.js +0 -2
  346. package/esm2015/src/store.js +0 -107
  347. package/esm2015/src/symbols.js +0 -58
  348. package/esm2015/src/utils/compose.js +0 -26
  349. package/esm2015/src/utils/store-validators.js +0 -25
  350. package/esm2015/src/utils/utils.js +0 -92
  351. package/fesm2015/ngxs-store-internals-testing.js.map +0 -1
  352. package/fesm2015/ngxs-store-internals.js +0 -101
  353. package/fesm2015/ngxs-store-internals.js.map +0 -1
  354. package/fesm2015/ngxs-store-operators.js.map +0 -1
  355. package/fesm2015/ngxs-store.js.map +0 -1
  356. package/internals/ngxs-bootstrapper.d.ts +0 -16
  357. package/internals/ngxs-store-internals.d.ts +0 -5
  358. package/internals/package.json +0 -10
  359. package/internals/src/symbols.d.ts +0 -7
  360. package/internals/testing/ngxs-store-internals-testing.d.ts +0 -5
  361. package/internals/testing/package.json +0 -10
  362. package/ngxs-store.d.ts +0 -5
  363. package/operators/ngxs-store-operators.d.ts +0 -5
  364. package/operators/package.json +0 -10
  365. package/src/internal/error-handler.d.ts +0 -26
  366. package/src/internal/state-stream.d.ts +0 -14
  367. package/src/public_to_deprecate.d.ts +0 -21
  368. package/src/state-token/state-token.d.ts +0 -7
  369. package/src/state-token/symbols.d.ts +0 -5
  370. /package/{esm2015/internals/ngxs-store-internals.js → esm2022/internals/ngxs-store-internals.mjs} +0 -0
  371. /package/{esm2015/internals/testing/ngxs-store-internals-testing.js → esm2022/internals/testing/ngxs-store-internals-testing.mjs} +0 -0
  372. /package/{esm2015/ngxs-store.js → esm2022/ngxs-store.mjs} +0 -0
  373. /package/{esm2015/operators/compose.js → esm2022/operators/compose.mjs} +0 -0
  374. /package/{esm2015/operators/index.js → esm2022/operators/index.mjs} +0 -0
  375. /package/{esm2015/operators/ngxs-store-operators.js → esm2022/operators/ngxs-store-operators.mjs} +0 -0
  376. /package/{esm2015/operators/types.js → esm2022/operators/types.mjs} +0 -0
  377. /package/{esm2015/operators/utils.js → esm2022/operators/utils.mjs} +0 -0
  378. /package/{esm2015/src/operators/leave-ngxs.js → esm2022/src/operators/leave-ngxs.mjs} +0 -0
  379. /package/{esm2015/src/selectors/index.js → esm2022/src/selectors/index.mjs} +0 -0
@@ -1,103 +1,29 @@
1
1
  import * as i0 from '@angular/core';
2
- import { NgZone, PLATFORM_ID, Injectable, Inject, InjectionToken, inject, INJECTOR, ɵglobal, ErrorHandler, Optional, SkipSelf, NgModule, APP_BOOTSTRAP_LISTENER } from '@angular/core';
3
- import * as i5 from '@ngxs/store/internals';
4
- import { memoize, INITIAL_STATE_TOKEN, NgxsBootstrapper, ɵNGXS_STATE_CONTEXT_FACTORY, ɵNGXS_STATE_FACTORY } from '@ngxs/store/internals';
2
+ import { Injectable, NgZone, PLATFORM_ID, Inject, InjectionToken, inject, INJECTOR, Optional, SkipSelf, ErrorHandler, ɵisPromise as _isPromise, computed, makeEnvironmentProviders, ENVIRONMENT_INITIALIZER, NgModule, APP_BOOTSTRAP_LISTENER } from '@angular/core';
3
+ import { Observable, config, Subject, of, forkJoin, throwError, EMPTY, from, isObservable, ReplaySubject } from 'rxjs';
4
+ import { share, map, shareReplay, filter, take, exhaustMap, mergeMap, defaultIfEmpty, catchError, takeUntil, distinctUntilChanged, tap, startWith, pairwise } from 'rxjs/operators';
5
+ import * as i1 from '@ngxs/store/internals';
6
+ import { ɵOrderedSubject as _OrderedSubject, ɵmemoize as _memoize, ɵgetStoreMetadata as _getStoreMetadata, ɵgetSelectorMetadata as _getSelectorMetadata, ɵMETA_KEY as _META_KEY, ɵINITIAL_STATE_TOKEN as _INITIAL_STATE_TOKEN, ɵNgxsAppBootstrappedState as _NgxsAppBootstrappedState, ɵNGXS_STATE_CONTEXT_FACTORY as _NGXS_STATE_CONTEXT_FACTORY, ɵNGXS_STATE_FACTORY as _NGXS_STATE_FACTORY, ɵensureStoreMetadata as _ensureStoreMetadata, ɵMETA_OPTIONS_KEY as _META_OPTIONS_KEY, ɵensureSelectorMetadata as _ensureSelectorMetadata } from '@ngxs/store/internals';
7
+ export { StateToken } from '@ngxs/store/internals';
5
8
  import { isPlatformServer } from '@angular/common';
6
- import { Observable, Subject, BehaviorSubject, of, forkJoin, throwError, EMPTY, from, isObservable } from 'rxjs';
7
- import { filter, map, share, shareReplay, take, exhaustMap, mergeMap, defaultIfEmpty, catchError, takeUntil, distinctUntilChanged, tap, startWith, pairwise } from 'rxjs/operators';
9
+ import { NGXS_PLUGINS, getActionTypeFromInstance, setValue, getValue, InitState, UpdateState } from '@ngxs/store/plugins';
10
+ export { InitState, NGXS_PLUGINS, UpdateState, actionMatcher, getActionTypeFromInstance, getValue, setValue } from '@ngxs/store/plugins';
8
11
  import { isStateOperator } from '@ngxs/store/operators';
9
12
 
10
- /**
11
- * Returns the type from an action instance/class.
12
- * @ignore
13
- */
14
- function getActionTypeFromInstance(action) {
15
- if (action.constructor && action.constructor.type) {
16
- return action.constructor.type;
13
+ class NoopNgxsExecutionStrategy {
14
+ enter(func) {
15
+ return func();
17
16
  }
18
- else {
19
- return action.type;
17
+ leave(func) {
18
+ return func();
20
19
  }
20
+ /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: NoopNgxsExecutionStrategy, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
21
+ /** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: NoopNgxsExecutionStrategy, providedIn: 'root' }); }
21
22
  }
22
- /**
23
- * Matches a action
24
- * @ignore
25
- */
26
- function actionMatcher(action1) {
27
- const type1 = getActionTypeFromInstance(action1);
28
- return function (action2) {
29
- return type1 === getActionTypeFromInstance(action2);
30
- };
31
- }
32
- /**
33
- * Set a deeply nested value. Example:
34
- *
35
- * setValue({ foo: { bar: { eat: false } } },
36
- * 'foo.bar.eat', true) //=> { foo: { bar: { eat: true } } }
37
- *
38
- * While it traverses it also creates new objects from top down.
39
- *
40
- * @ignore
41
- */
42
- const setValue = (obj, prop, val) => {
43
- obj = Object.assign({}, obj);
44
- const split = prop.split('.');
45
- const lastIndex = split.length - 1;
46
- split.reduce((acc, part, index) => {
47
- if (index === lastIndex) {
48
- acc[part] = val;
49
- }
50
- else {
51
- acc[part] = Array.isArray(acc[part]) ? acc[part].slice() : Object.assign({}, acc[part]);
52
- }
53
- return acc && acc[part];
54
- }, obj);
55
- return obj;
56
- };
57
- /**
58
- * Get a deeply nested value. Example:
59
- *
60
- * getValue({ foo: bar: [] }, 'foo.bar') //=> []
61
- *
62
- * @ignore
63
- */
64
- const getValue = (obj, prop) => prop.split('.').reduce((acc, part) => acc && acc[part], obj);
65
- /**
66
- * Simple object check.
67
- *
68
- * isObject({a:1}) //=> true
69
- * isObject(1) //=> false
70
- *
71
- * @ignore
72
- */
73
- const isObject$1 = (item) => {
74
- return item && typeof item === 'object' && !Array.isArray(item);
75
- };
76
- /**
77
- * Deep merge two objects.
78
- *
79
- * mergeDeep({a:1, b:{x: 1, y:2}}, {b:{x: 3}, c:4}) //=> {a:1, b:{x:3, y:2}, c:4}
80
- *
81
- * @param base base object onto which `sources` will be applied
82
- */
83
- const mergeDeep = (base, ...sources) => {
84
- if (!sources.length)
85
- return base;
86
- const source = sources.shift();
87
- if (isObject$1(base) && isObject$1(source)) {
88
- for (const key in source) {
89
- if (isObject$1(source[key])) {
90
- if (!base[key])
91
- Object.assign(base, { [key]: {} });
92
- mergeDeep(base[key], source[key]);
93
- }
94
- else {
95
- Object.assign(base, { [key]: source[key] });
96
- }
97
- }
98
- }
99
- return mergeDeep(base, ...sources);
100
- };
23
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: NoopNgxsExecutionStrategy, decorators: [{
24
+ type: Injectable,
25
+ args: [{ providedIn: 'root' }]
26
+ }] });
101
27
 
102
28
  function throwStateNameError(name) {
103
29
  throw new Error(`${name} is not a valid state name. It needs to be a valid object property name.`);
@@ -122,9 +48,21 @@ function getZoneWarningMessage() {
122
48
  'Please set the value of the executionStrategy property to NoopNgxsExecutionStrategy.\n' +
123
49
  'NgxsModule.forRoot(states, { executionStrategy: NoopNgxsExecutionStrategy })');
124
50
  }
125
- function getUndecoratedStateInIvyWarningMessage(name) {
51
+ function getUndecoratedStateWithInjectableWarningMessage(name) {
126
52
  return `'${name}' class should be decorated with @Injectable() right after the @State() decorator`;
127
53
  }
54
+ function getInvalidInitializationOrderMessage(addedStates) {
55
+ let message = 'You have an invalid state initialization order. This typically occurs when `NgxsModule.forFeature`\n' +
56
+ 'or `provideStates` is called before `NgxsModule.forRoot` or `provideStore`.\n' +
57
+ 'One example is when `NgxsRouterPluginModule.forRoot` is called before `NgxsModule.forRoot`.';
58
+ if (addedStates) {
59
+ const stateNames = Object.keys(addedStates).map(stateName => `"${stateName}"`);
60
+ message +=
61
+ '\nFeature states added before the store initialization is complete: ' +
62
+ `${stateNames.join(', ')}.`;
63
+ }
64
+ return message;
65
+ }
128
66
  function throwSelectFactoryNotConnectedError() {
129
67
  throw new Error('You have forgotten to import the NGXS module!');
130
68
  }
@@ -139,9 +77,7 @@ class DispatchOutsideZoneNgxsExecutionStrategy {
139
77
  constructor(_ngZone, _platformId) {
140
78
  this._ngZone = _ngZone;
141
79
  this._platformId = _platformId;
142
- // Caretaker note: we have still left the `typeof` condition in order to avoid
143
- // creating a breaking change for projects that still use the View Engine.
144
- if (typeof ngDevMode === 'undefined' || ngDevMode) {
80
+ if (typeof ngDevMode !== 'undefined' && ngDevMode) {
145
81
  verifyZoneIsNotNooped(_ngZone);
146
82
  }
147
83
  }
@@ -166,16 +102,16 @@ class DispatchOutsideZoneNgxsExecutionStrategy {
166
102
  }
167
103
  return func();
168
104
  }
105
+ /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: DispatchOutsideZoneNgxsExecutionStrategy, deps: [{ token: i0.NgZone }, { token: PLATFORM_ID }], target: i0.ɵɵFactoryTarget.Injectable }); }
106
+ /** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: DispatchOutsideZoneNgxsExecutionStrategy, providedIn: 'root' }); }
169
107
  }
170
- /** @nocollapse */ DispatchOutsideZoneNgxsExecutionStrategy.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: DispatchOutsideZoneNgxsExecutionStrategy, deps: [{ token: i0.NgZone }, { token: PLATFORM_ID }], target: i0.ɵɵFactoryTarget.Injectable });
171
- /** @nocollapse */ DispatchOutsideZoneNgxsExecutionStrategy.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: DispatchOutsideZoneNgxsExecutionStrategy, providedIn: 'root' });
172
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: DispatchOutsideZoneNgxsExecutionStrategy, decorators: [{
108
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: DispatchOutsideZoneNgxsExecutionStrategy, decorators: [{
173
109
  type: Injectable,
174
110
  args: [{ providedIn: 'root' }]
175
- }], ctorParameters: function () { return [{ type: i0.NgZone }, { type: undefined, decorators: [{
111
+ }], ctorParameters: () => [{ type: i0.NgZone }, { type: undefined, decorators: [{
176
112
  type: Inject,
177
113
  args: [PLATFORM_ID]
178
- }] }]; } });
114
+ }] }] });
179
115
  // Caretaker note: this should exist as a separate function and not a class method,
180
116
  // since class methods are not tree-shakable.
181
117
  function verifyZoneIsNotNooped(ngZone) {
@@ -188,245 +124,702 @@ function verifyZoneIsNotNooped(ngZone) {
188
124
  console.warn(getZoneWarningMessage());
189
125
  }
190
126
 
191
- const ROOT_OPTIONS = new InjectionToken('ROOT_OPTIONS');
192
- const ROOT_STATE_TOKEN = new InjectionToken('ROOT_STATE_TOKEN');
193
- const FEATURE_STATE_TOKEN = new InjectionToken('FEATURE_STATE_TOKEN');
194
- const NGXS_PLUGINS = new InjectionToken('NGXS_PLUGINS');
195
- const META_KEY = 'NGXS_META';
196
- const META_OPTIONS_KEY = 'NGXS_OPTIONS_META';
197
- const SELECTOR_META_KEY = 'NGXS_SELECTOR_META';
198
- /**
199
- * The NGXS config settings.
200
- */
201
- class NgxsConfig {
202
- constructor() {
203
- /**
204
- * Defining the default state before module initialization
205
- * This is convenient if we need to create a define our own set of states.
206
- * @deprecated will be removed after v4
207
- * (default: {})
208
- */
209
- this.defaultsState = {};
210
- /**
211
- * Defining shared selector options
212
- */
213
- this.selectorOptions = {
214
- injectContainerState: true,
215
- suppressErrors: true // TODO: default is true in v3, will change in v4
216
- };
217
- this.compatibility = {
218
- strictContentSecurityPolicy: false
219
- };
220
- this.executionStrategy = DispatchOutsideZoneNgxsExecutionStrategy;
221
- }
222
- }
223
- /** @nocollapse */ NgxsConfig.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: NgxsConfig, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
224
- /** @nocollapse */ NgxsConfig.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: NgxsConfig, providedIn: 'root', useFactory: (options) => mergeDeep(new NgxsConfig(), options), deps: [{ token: ROOT_OPTIONS }] });
225
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: NgxsConfig, decorators: [{
226
- type: Injectable,
227
- args: [{
228
- providedIn: 'root',
229
- useFactory: (options) => mergeDeep(new NgxsConfig(), options),
230
- deps: [ROOT_OPTIONS]
231
- }]
232
- }], ctorParameters: function () { return []; } });
127
+ const NG_DEV_MODE$8 = typeof ngDevMode !== 'undefined' && ngDevMode;
233
128
  /**
234
- * Represents a basic change from a previous to a new value for a single state instance.
235
- * Passed as a value in a NgxsSimpleChanges object to the ngxsOnChanges hook.
129
+ * Consumers have the option to utilize the execution strategy provided by
130
+ * `NgxsModule.forRoot({executionStrategy})` or `provideStore([], {executionStrategy})`.
236
131
  */
237
- class NgxsSimpleChange {
238
- constructor(previousValue, currentValue, firstChange) {
239
- this.previousValue = previousValue;
240
- this.currentValue = currentValue;
241
- this.firstChange = firstChange;
242
- }
243
- }
244
-
245
- class NoopNgxsExecutionStrategy {
246
- enter(func) {
247
- return func();
248
- }
249
- leave(func) {
250
- return func();
251
- }
252
- }
253
- /** @nocollapse */ NoopNgxsExecutionStrategy.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: NoopNgxsExecutionStrategy, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
254
- /** @nocollapse */ NoopNgxsExecutionStrategy.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: NoopNgxsExecutionStrategy, providedIn: 'root' });
255
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: NoopNgxsExecutionStrategy, decorators: [{
256
- type: Injectable,
257
- args: [{ providedIn: 'root' }]
258
- }] });
259
-
132
+ const CUSTOM_NGXS_EXECUTION_STRATEGY = new InjectionToken(NG_DEV_MODE$8 ? 'CUSTOM_NGXS_EXECUTION_STRATEGY' : '');
260
133
  /**
261
- * The strategy that might be provided by users through `options.executionStrategy`.
262
- */
263
- const USER_PROVIDED_NGXS_EXECUTION_STRATEGY = new InjectionToken('USER_PROVIDED_NGXS_EXECUTION_STRATEGY');
264
- /*
265
- * Internal execution strategy injection token
134
+ * The injection token is used internally to resolve an instance of the execution
135
+ * strategy. It checks whether consumers have provided their own `executionStrategy`
136
+ * and also verifies if we are operating in a zone-aware environment.
266
137
  */
267
- const NGXS_EXECUTION_STRATEGY = new InjectionToken('NGXS_EXECUTION_STRATEGY', {
138
+ const NGXS_EXECUTION_STRATEGY = new InjectionToken(NG_DEV_MODE$8 ? 'NGXS_EXECUTION_STRATEGY' : '', {
268
139
  providedIn: 'root',
269
140
  factory: () => {
141
+ const ngZone = inject(NgZone);
270
142
  const injector = inject(INJECTOR);
271
- const executionStrategy = injector.get(USER_PROVIDED_NGXS_EXECUTION_STRATEGY);
143
+ const executionStrategy = injector.get(CUSTOM_NGXS_EXECUTION_STRATEGY);
144
+ const isNgZoneEnabled = ngZone instanceof NgZone;
272
145
  return executionStrategy
273
146
  ? injector.get(executionStrategy)
274
- : injector.get(typeof ɵglobal.Zone !== 'undefined'
147
+ : injector.get(isNgZoneEnabled
275
148
  ? DispatchOutsideZoneNgxsExecutionStrategy
276
149
  : NoopNgxsExecutionStrategy);
277
150
  }
278
151
  });
279
152
 
280
- /**
281
- * Ensures metadata is attached to the class and returns it.
282
- *
283
- * @ignore
284
- */
285
- function ensureStoreMetadata$1(target) {
286
- if (!target.hasOwnProperty(META_KEY)) {
287
- const defaultMetadata = {
288
- name: null,
289
- actions: {},
290
- defaults: {},
291
- path: null,
292
- makeRootSelector(context) {
293
- return context.getStateGetter(defaultMetadata.name);
294
- },
295
- children: []
296
- };
297
- Object.defineProperty(target, META_KEY, { value: defaultMetadata });
153
+ class InternalNgxsExecutionStrategy {
154
+ constructor(_executionStrategy) {
155
+ this._executionStrategy = _executionStrategy;
156
+ }
157
+ enter(func) {
158
+ return this._executionStrategy.enter(func);
298
159
  }
299
- return getStoreMetadata$1(target);
160
+ leave(func) {
161
+ return this._executionStrategy.leave(func);
162
+ }
163
+ /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: InternalNgxsExecutionStrategy, deps: [{ token: NGXS_EXECUTION_STRATEGY }], target: i0.ɵɵFactoryTarget.Injectable }); }
164
+ /** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: InternalNgxsExecutionStrategy, providedIn: 'root' }); }
300
165
  }
166
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: InternalNgxsExecutionStrategy, decorators: [{
167
+ type: Injectable,
168
+ args: [{ providedIn: 'root' }]
169
+ }], ctorParameters: () => [{ type: undefined, decorators: [{
170
+ type: Inject,
171
+ args: [NGXS_EXECUTION_STRATEGY]
172
+ }] }] });
173
+
301
174
  /**
302
- * Get the metadata attached to the state class if it exists.
175
+ * Composes a array of functions from left to right. Example:
303
176
  *
304
- * @ignore
305
- */
306
- function getStoreMetadata$1(target) {
307
- return target[META_KEY];
308
- }
309
- /**
310
- * Ensures metadata is attached to the selector and returns it.
177
+ * compose([fn, final])(state, action);
311
178
  *
312
- * @ignore
313
- */
314
- function ensureSelectorMetadata$1(target) {
315
- if (!target.hasOwnProperty(SELECTOR_META_KEY)) {
316
- const defaultMetadata = {
317
- makeRootSelector: null,
318
- originalFn: null,
319
- containerClass: null,
320
- selectorName: null,
321
- getSelectorOptions: () => ({})
322
- };
323
- Object.defineProperty(target, SELECTOR_META_KEY, { value: defaultMetadata });
324
- }
325
- return getSelectorMetadata$1(target);
326
- }
327
- /**
328
- * Get the metadata attached to the selector if it exists.
179
+ * then the funcs have a signature like:
329
180
  *
330
- * @ignore
331
- */
332
- function getSelectorMetadata$1(target) {
333
- return target[SELECTOR_META_KEY];
334
- }
335
- /**
336
- * Get a deeply nested value. Example:
181
+ * function fn (state, action, next) {
182
+ * console.log('here', state, action, next);
183
+ * return next(state, action);
184
+ * }
337
185
  *
338
- * getValue({ foo: bar: [] }, 'foo.bar') //=> []
186
+ * function final (state, action) {
187
+ * console.log('here', state, action);
188
+ * return state;
189
+ * }
339
190
  *
340
- * Note: This is not as fast as the `fastPropGetter` but is strict Content Security Policy compliant.
341
- * See perf hit: https://jsperf.com/fast-value-getter-given-path/1
191
+ * the last function should not call `next`.
342
192
  *
343
193
  * @ignore
344
194
  */
345
- function compliantPropGetter(paths) {
346
- const copyOfPaths = paths.slice();
347
- return obj => copyOfPaths.reduce((acc, part) => acc && acc[part], obj);
348
- }
195
+ const compose = (funcs) => (...args) => {
196
+ const curr = funcs.shift();
197
+ return curr(...args, (...nextArgs) => compose(funcs)(...nextArgs));
198
+ };
199
+
349
200
  /**
350
- * The generated function is faster than:
351
- * - pluck (Observable operator)
352
- * - memoize
353
- *
354
- * @ignore
201
+ * Returns operator that will run
202
+ * `subscribe` outside of the ngxs execution context
355
203
  */
356
- function fastPropGetter(paths) {
357
- const segments = paths;
358
- let seg = 'store.' + segments[0];
359
- let i = 0;
360
- const l = segments.length;
361
- let expr = seg;
362
- while (++i < l) {
363
- expr = expr + ' && ' + (seg = seg + '.' + segments[i]);
364
- }
365
- const fn = new Function('store', 'return ' + expr + ';');
366
- return fn;
204
+ function leaveNgxs(ngxsExecutionStrategy) {
205
+ return (source) => {
206
+ return new Observable((sink) => {
207
+ return source.subscribe({
208
+ next(value) {
209
+ ngxsExecutionStrategy.leave(() => sink.next(value));
210
+ },
211
+ error(error) {
212
+ ngxsExecutionStrategy.leave(() => sink.error(error));
213
+ },
214
+ complete() {
215
+ ngxsExecutionStrategy.leave(() => sink.complete());
216
+ }
217
+ });
218
+ });
219
+ };
367
220
  }
221
+
368
222
  /**
369
- * Get a deeply nested value. Example:
370
- *
371
- * getValue({ foo: bar: [] }, 'foo.bar') //=> []
372
- *
373
- * @ignore
223
+ * Internal Action stream that is emitted anytime an action is dispatched.
374
224
  */
375
- function propGetter(paths, config) {
376
- if (config && config.compatibility && config.compatibility.strictContentSecurityPolicy) {
377
- return compliantPropGetter(paths);
378
- }
379
- else {
380
- return fastPropGetter(paths);
225
+ class InternalActions extends _OrderedSubject {
226
+ ngOnDestroy() {
227
+ this.complete();
381
228
  }
229
+ /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: InternalActions, deps: null, target: i0.ɵɵFactoryTarget.Injectable }); }
230
+ /** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: InternalActions, providedIn: 'root' }); }
382
231
  }
232
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: InternalActions, decorators: [{
233
+ type: Injectable,
234
+ args: [{ providedIn: 'root' }]
235
+ }] });
383
236
  /**
384
- * Given an array of states, it will return a object graph. Example:
385
- * const states = [
386
- * Cart,
387
- * CartSaved,
388
- * CartSavedItems
389
- * ]
390
- *
391
- * would return:
392
- *
393
- * const graph = {
394
- * cart: ['saved'],
395
- * saved: ['items'],
396
- * items: []
397
- * };
237
+ * Action stream that is emitted anytime an action is dispatched.
398
238
  *
399
- * @ignore
239
+ * You can listen to this in services to react without stores.
400
240
  */
401
- function buildGraph(stateClasses) {
402
- const findName = (stateClass) => {
403
- const meta = stateClasses.find(g => g === stateClass);
404
- // Caretaker note: we have still left the `typeof` condition in order to avoid
405
- // creating a breaking change for projects that still use the View Engine.
406
- if ((typeof ngDevMode === 'undefined' || ngDevMode) && !meta) {
407
- throw new Error(`Child state not found: ${stateClass}. \r\nYou may have forgotten to add states to module`);
408
- }
409
- return meta[META_KEY].name;
410
- };
411
- return stateClasses.reduce((result, stateClass) => {
412
- const { name, children } = stateClass[META_KEY];
413
- result[name] = (children || []).map(findName);
414
- return result;
415
- }, {});
241
+ class Actions extends Observable {
242
+ constructor(internalActions$, internalExecutionStrategy) {
243
+ const sharedInternalActions$ = internalActions$.pipe(leaveNgxs(internalExecutionStrategy),
244
+ // The `InternalActions` subject emits outside of the Angular zone.
245
+ // We have to re-enter the Angular zone for any incoming consumer.
246
+ // The `share()` operator reduces the number of change detections.
247
+ // This would call leave only once for any stream emission across all active subscribers.
248
+ share());
249
+ super(observer => {
250
+ const childSubscription = sharedInternalActions$.subscribe({
251
+ next: ctx => observer.next(ctx),
252
+ error: error => observer.error(error),
253
+ complete: () => observer.complete()
254
+ });
255
+ observer.add(childSubscription);
256
+ });
257
+ }
258
+ /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: Actions, deps: [{ token: InternalActions }, { token: InternalNgxsExecutionStrategy }], target: i0.ɵɵFactoryTarget.Injectable }); }
259
+ /** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: Actions, providedIn: 'root' }); }
416
260
  }
417
- /**
418
- * Given a states array, returns object graph
419
- * returning the name and state metadata. Example:
420
- *
421
- * const graph = {
422
- * cart: { metadata }
423
- * };
424
- *
261
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: Actions, decorators: [{
262
+ type: Injectable,
263
+ args: [{ providedIn: 'root' }]
264
+ }], ctorParameters: () => [{ type: InternalActions }, { type: InternalNgxsExecutionStrategy }] });
265
+
266
+ class PluginManager {
267
+ constructor(_parentManager, _pluginHandlers) {
268
+ this._parentManager = _parentManager;
269
+ this._pluginHandlers = _pluginHandlers;
270
+ this.plugins = [];
271
+ this.registerHandlers();
272
+ }
273
+ get rootPlugins() {
274
+ return (this._parentManager && this._parentManager.plugins) || this.plugins;
275
+ }
276
+ registerHandlers() {
277
+ const pluginHandlers = this.getPluginHandlers();
278
+ this.rootPlugins.push(...pluginHandlers);
279
+ }
280
+ getPluginHandlers() {
281
+ const handlers = this._pluginHandlers || [];
282
+ return handlers.map((plugin) => (plugin.handle ? plugin.handle.bind(plugin) : plugin));
283
+ }
284
+ /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: PluginManager, deps: [{ token: PluginManager, optional: true, skipSelf: true }, { token: NGXS_PLUGINS, optional: true }], target: i0.ɵɵFactoryTarget.Injectable }); }
285
+ /** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: PluginManager }); }
286
+ }
287
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: PluginManager, decorators: [{
288
+ type: Injectable
289
+ }], ctorParameters: () => [{ type: PluginManager, decorators: [{
290
+ type: Optional
291
+ }, {
292
+ type: SkipSelf
293
+ }] }, { type: undefined, decorators: [{
294
+ type: Inject,
295
+ args: [NGXS_PLUGINS]
296
+ }, {
297
+ type: Optional
298
+ }] }] });
299
+
300
+ const ɵɵunhandledRxjsErrorCallbacks = new WeakMap();
301
+ const existingHandler = config.onUnhandledError;
302
+ config.onUnhandledError = function (error) {
303
+ const unhandledErrorCallback = ɵɵunhandledRxjsErrorCallbacks.get(error);
304
+ if (unhandledErrorCallback) {
305
+ unhandledErrorCallback();
306
+ }
307
+ else if (existingHandler) {
308
+ existingHandler.call(this, error);
309
+ }
310
+ else {
311
+ throw error;
312
+ }
313
+ };
314
+ function executeUnhandledCallback(error) {
315
+ const unhandledErrorCallback = ɵɵunhandledRxjsErrorCallbacks.get(error);
316
+ if (unhandledErrorCallback) {
317
+ unhandledErrorCallback();
318
+ return true;
319
+ }
320
+ return false;
321
+ }
322
+ function assignUnhandledCallback(error, callback) {
323
+ // Since the error can be essentially anything, we must ensure that we only
324
+ // handle objects, as weak maps do not allow any other key type besides objects.
325
+ // The error can also be a string if thrown in the following manner: `throwError('My Error')`.
326
+ if (error !== null && typeof error === 'object') {
327
+ let hasBeenCalled = false;
328
+ ɵɵunhandledRxjsErrorCallbacks.set(error, () => {
329
+ if (!hasBeenCalled) {
330
+ hasBeenCalled = true;
331
+ callback();
332
+ }
333
+ });
334
+ }
335
+ return error;
336
+ }
337
+
338
+ function fallbackSubscriber(ngZone) {
339
+ return (source) => {
340
+ let subscription = source.subscribe({
341
+ error: error => {
342
+ ngZone.runOutsideAngular(() => {
343
+ // This is necessary to schedule a microtask to ensure that synchronous
344
+ // errors are not reported before the real subscriber arrives. If an error
345
+ // is thrown synchronously in any action, it will be reported to the error
346
+ // handler regardless. Since RxJS reports unhandled errors asynchronously,
347
+ // implementing a microtask ensures that we are also safe in this scenario.
348
+ queueMicrotask(() => {
349
+ if (subscription) {
350
+ executeUnhandledCallback(error);
351
+ }
352
+ });
353
+ });
354
+ }
355
+ });
356
+ return new Observable(subscriber => {
357
+ // Now that there is a real subscriber, we can unsubscribe our pro-active subscription
358
+ subscription?.unsubscribe();
359
+ subscription = null;
360
+ return source.subscribe(subscriber);
361
+ });
362
+ };
363
+ }
364
+
365
+ /**
366
+ * Internal Action result stream that is emitted when an action is completed.
367
+ * This is used as a method of returning the action result to the dispatcher
368
+ * for the observable returned by the dispatch(...) call.
369
+ * The dispatcher then asynchronously pushes the result from this stream onto the main action stream as a result.
370
+ */
371
+ class InternalDispatchedActionResults extends Subject {
372
+ /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: InternalDispatchedActionResults, deps: null, target: i0.ɵɵFactoryTarget.Injectable }); }
373
+ /** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: InternalDispatchedActionResults, providedIn: 'root' }); }
374
+ }
375
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: InternalDispatchedActionResults, decorators: [{
376
+ type: Injectable,
377
+ args: [{ providedIn: 'root' }]
378
+ }] });
379
+ class InternalDispatcher {
380
+ constructor(_ngZone, _actions, _actionResults, _pluginManager, _stateStream, _ngxsExecutionStrategy) {
381
+ this._ngZone = _ngZone;
382
+ this._actions = _actions;
383
+ this._actionResults = _actionResults;
384
+ this._pluginManager = _pluginManager;
385
+ this._stateStream = _stateStream;
386
+ this._ngxsExecutionStrategy = _ngxsExecutionStrategy;
387
+ }
388
+ /**
389
+ * Dispatches event(s).
390
+ */
391
+ dispatch(actionOrActions) {
392
+ const result = this._ngxsExecutionStrategy.enter(() => this.dispatchByEvents(actionOrActions));
393
+ return result.pipe(fallbackSubscriber(this._ngZone), leaveNgxs(this._ngxsExecutionStrategy));
394
+ }
395
+ dispatchByEvents(actionOrActions) {
396
+ if (Array.isArray(actionOrActions)) {
397
+ if (actionOrActions.length === 0)
398
+ return of(undefined);
399
+ return forkJoin(actionOrActions.map(action => this.dispatchSingle(action))).pipe(map(() => undefined));
400
+ }
401
+ else {
402
+ return this.dispatchSingle(actionOrActions);
403
+ }
404
+ }
405
+ dispatchSingle(action) {
406
+ if (typeof ngDevMode !== 'undefined' && ngDevMode) {
407
+ const type = getActionTypeFromInstance(action);
408
+ if (!type) {
409
+ const error = new Error(`This action doesn't have a type property: ${action.constructor.name}`);
410
+ return throwError(() => error);
411
+ }
412
+ }
413
+ const prevState = this._stateStream.getValue();
414
+ const plugins = this._pluginManager.plugins;
415
+ return compose([
416
+ ...plugins,
417
+ (nextState, nextAction) => {
418
+ if (nextState !== prevState) {
419
+ this._stateStream.next(nextState);
420
+ }
421
+ const actionResult$ = this.getActionResultStream(nextAction);
422
+ actionResult$.subscribe(ctx => this._actions.next(ctx));
423
+ this._actions.next({ action: nextAction, status: "DISPATCHED" /* ActionStatus.Dispatched */ });
424
+ return this.createDispatchObservable(actionResult$);
425
+ }
426
+ ])(prevState, action).pipe(shareReplay());
427
+ }
428
+ getActionResultStream(action) {
429
+ return this._actionResults.pipe(filter((ctx) => ctx.action === action && ctx.status !== "DISPATCHED" /* ActionStatus.Dispatched */), take(1), shareReplay());
430
+ }
431
+ createDispatchObservable(actionResult$) {
432
+ return actionResult$
433
+ .pipe(exhaustMap((ctx) => {
434
+ switch (ctx.status) {
435
+ case "SUCCESSFUL" /* ActionStatus.Successful */:
436
+ // The `createDispatchObservable` function should return the
437
+ // state, as its result is utilized by plugins.
438
+ return of(this._stateStream.getValue());
439
+ case "ERRORED" /* ActionStatus.Errored */:
440
+ return throwError(() => ctx.error);
441
+ default:
442
+ return EMPTY;
443
+ }
444
+ }))
445
+ .pipe(shareReplay());
446
+ }
447
+ /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: InternalDispatcher, deps: [{ token: i0.NgZone }, { token: InternalActions }, { token: InternalDispatchedActionResults }, { token: PluginManager }, { token: i1.ɵStateStream }, { token: InternalNgxsExecutionStrategy }], target: i0.ɵɵFactoryTarget.Injectable }); }
448
+ /** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: InternalDispatcher, providedIn: 'root' }); }
449
+ }
450
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: InternalDispatcher, decorators: [{
451
+ type: Injectable,
452
+ args: [{ providedIn: 'root' }]
453
+ }], ctorParameters: () => [{ type: i0.NgZone }, { type: InternalActions }, { type: InternalDispatchedActionResults }, { type: PluginManager }, { type: i1.ɵStateStream }, { type: InternalNgxsExecutionStrategy }] });
454
+
455
+ const NG_DEV_MODE$7 = typeof ngDevMode !== 'undefined' && ngDevMode;
456
+ // The injection token is used to resolve a list of states provided at
457
+ // the root level through either `NgxsModule.forRoot` or `provideStore`.
458
+ const ROOT_STATE_TOKEN = new InjectionToken(NG_DEV_MODE$7 ? 'ROOT_STATE_TOKEN' : '');
459
+ // The injection token is used to resolve a list of states provided at
460
+ // the feature level through either `NgxsModule.forFeature` or `provideStates`.
461
+ // The Array<Array> is used to overload the resolved value of the token because
462
+ // it is a multi-provider token.
463
+ const FEATURE_STATE_TOKEN = new InjectionToken(NG_DEV_MODE$7 ? 'FEATURE_STATE_TOKEN' : '');
464
+ // The injection token is used to resolve to options provided at the root
465
+ // level through either `NgxsModule.forRoot` or `provideStore`.
466
+ const NGXS_OPTIONS = new InjectionToken(NG_DEV_MODE$7 ? 'NGXS_OPTIONS' : '');
467
+ /**
468
+ * The NGXS config settings.
469
+ */
470
+ class NgxsConfig {
471
+ constructor() {
472
+ this.compatibility = {
473
+ strictContentSecurityPolicy: false
474
+ };
475
+ /**
476
+ * Determines the execution context to perform async operations inside. An implementation can be
477
+ * provided to override the default behaviour where the async operations are run
478
+ * outside Angular's zone but all observable behaviours of NGXS are run back inside Angular's zone.
479
+ * These observable behaviours are from:
480
+ * `store.selectSignal(...)`, `store.select(...)`, `actions.subscribe(...)` or `store.dispatch(...).subscribe(...)`
481
+ * Every `zone.run` causes Angular to run change detection on the whole tree (`app.tick()`) so of your
482
+ * application doesn't rely on zone.js running change detection then you can switch to the
483
+ * `NoopNgxsExecutionStrategy` that doesn't interact with zones.
484
+ * (default: null)
485
+ */
486
+ this.executionStrategy = DispatchOutsideZoneNgxsExecutionStrategy;
487
+ /**
488
+ * Defining shared selector options
489
+ */
490
+ this.selectorOptions = {
491
+ injectContainerState: false,
492
+ suppressErrors: false
493
+ };
494
+ }
495
+ /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: NgxsConfig, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
496
+ /** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: NgxsConfig, providedIn: 'root', useFactory: () => {
497
+ const defaultConfig = new NgxsConfig();
498
+ const config = inject(NGXS_OPTIONS);
499
+ return {
500
+ ...defaultConfig,
501
+ ...config,
502
+ selectorOptions: {
503
+ ...defaultConfig.selectorOptions,
504
+ ...config.selectorOptions
505
+ }
506
+ };
507
+ } }); }
508
+ }
509
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: NgxsConfig, decorators: [{
510
+ type: Injectable,
511
+ args: [{
512
+ providedIn: 'root',
513
+ useFactory: () => {
514
+ const defaultConfig = new NgxsConfig();
515
+ const config = inject(NGXS_OPTIONS);
516
+ return {
517
+ ...defaultConfig,
518
+ ...config,
519
+ selectorOptions: {
520
+ ...defaultConfig.selectorOptions,
521
+ ...config.selectorOptions
522
+ }
523
+ };
524
+ }
525
+ }]
526
+ }] });
527
+ /**
528
+ * Represents a basic change from a previous to a new value for a single state instance.
529
+ * Passed as a value in a NgxsSimpleChanges object to the ngxsOnChanges hook.
530
+ */
531
+ class NgxsSimpleChange {
532
+ constructor(previousValue, currentValue, firstChange) {
533
+ this.previousValue = previousValue;
534
+ this.currentValue = currentValue;
535
+ this.firstChange = firstChange;
536
+ }
537
+ }
538
+
539
+ /**
540
+ * Object freeze code
541
+ * https://github.com/jsdf/deep-freeze
542
+ */
543
+ const deepFreeze = (o) => {
544
+ Object.freeze(o);
545
+ const oIsFunction = typeof o === 'function';
546
+ const hasOwnProp = Object.prototype.hasOwnProperty;
547
+ Object.getOwnPropertyNames(o).forEach(function (prop) {
548
+ if (hasOwnProp.call(o, prop) &&
549
+ (oIsFunction ? prop !== 'caller' && prop !== 'callee' && prop !== 'arguments' : true) &&
550
+ o[prop] !== null &&
551
+ (typeof o[prop] === 'object' || typeof o[prop] === 'function') &&
552
+ !Object.isFrozen(o[prop])) {
553
+ deepFreeze(o[prop]);
554
+ }
555
+ });
556
+ return o;
557
+ };
558
+
559
+ /**
560
+ * @ignore
561
+ */
562
+ class InternalStateOperations {
563
+ constructor(_stateStream, _dispatcher, _config) {
564
+ this._stateStream = _stateStream;
565
+ this._dispatcher = _dispatcher;
566
+ this._config = _config;
567
+ }
568
+ /**
569
+ * Returns the root state operators.
570
+ */
571
+ getRootStateOperations() {
572
+ const rootStateOperations = {
573
+ getState: () => this._stateStream.getValue(),
574
+ setState: (newState) => this._stateStream.next(newState),
575
+ dispatch: (actionOrActions) => this._dispatcher.dispatch(actionOrActions)
576
+ };
577
+ if (typeof ngDevMode !== 'undefined' && ngDevMode) {
578
+ return this._config.developmentMode
579
+ ? ensureStateAndActionsAreImmutable(rootStateOperations)
580
+ : rootStateOperations;
581
+ }
582
+ else {
583
+ return rootStateOperations;
584
+ }
585
+ }
586
+ setStateToTheCurrentWithNew(results) {
587
+ const stateOperations = this.getRootStateOperations();
588
+ // Get our current stream
589
+ const currentState = stateOperations.getState();
590
+ // Set the state to the current + new
591
+ stateOperations.setState({ ...currentState, ...results.defaults });
592
+ }
593
+ /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: InternalStateOperations, deps: [{ token: i1.ɵStateStream }, { token: InternalDispatcher }, { token: NgxsConfig }], target: i0.ɵɵFactoryTarget.Injectable }); }
594
+ /** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: InternalStateOperations, providedIn: 'root' }); }
595
+ }
596
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: InternalStateOperations, decorators: [{
597
+ type: Injectable,
598
+ args: [{ providedIn: 'root' }]
599
+ }], ctorParameters: () => [{ type: i1.ɵStateStream }, { type: InternalDispatcher }, { type: NgxsConfig }] });
600
+ function ensureStateAndActionsAreImmutable(root) {
601
+ return {
602
+ getState: () => root.getState(),
603
+ setState: value => {
604
+ const frozenValue = deepFreeze(value);
605
+ return root.setState(frozenValue);
606
+ },
607
+ dispatch: actions => {
608
+ return root.dispatch(actions);
609
+ }
610
+ };
611
+ }
612
+
613
+ const NG_DEV_MODE$6 = typeof ngDevMode !== 'undefined' && ngDevMode;
614
+ function createRootSelectorFactory(selectorMetaData, selectors, memoizedSelectorFn) {
615
+ return (context) => {
616
+ const { argumentSelectorFunctions, selectorOptions } = getRuntimeSelectorInfo(context, selectorMetaData, selectors);
617
+ const { suppressErrors } = selectorOptions;
618
+ return function selectFromRoot(rootState) {
619
+ // Determine arguments from the app state using the selectors
620
+ const results = argumentSelectorFunctions.map(argFn => argFn(rootState));
621
+ // If the lambda attempts to access something in the state that doesn't exist,
622
+ // it will throw a `TypeError`. Since this behavior is common, we simply return
623
+ // `undefined` in such cases.
624
+ try {
625
+ return memoizedSelectorFn(...results);
626
+ }
627
+ catch (ex) {
628
+ if (suppressErrors && ex instanceof TypeError) {
629
+ return undefined;
630
+ }
631
+ // We're logging an error in this function because it may be used by `select`,
632
+ // `selectSignal`, and `selectSnapshot`. Therefore, there's no need to catch
633
+ // exceptions there to log errors.
634
+ if (NG_DEV_MODE$6) {
635
+ const message = 'The selector below has thrown an error upon invocation. ' +
636
+ 'Please check for any unsafe property access that may result in null ' +
637
+ 'or undefined values.';
638
+ // Avoid concatenating the message with the original function, as this will
639
+ // invoke `toString()` on the function. Instead, log it as the second argument.
640
+ // This way, developers will be able to navigate to the actual code in the browser.
641
+ console.error(message, selectorMetaData.originalFn);
642
+ }
643
+ throw ex;
644
+ }
645
+ };
646
+ };
647
+ }
648
+ function createMemoizedSelectorFn(originalFn, creationMetadata) {
649
+ const containerClass = creationMetadata && creationMetadata.containerClass;
650
+ const wrappedFn = function wrappedSelectorFn(...args) {
651
+ const returnValue = originalFn.apply(containerClass, args);
652
+ if (returnValue instanceof Function) {
653
+ const innerMemoizedFn = _memoize.apply(null, [returnValue]);
654
+ return innerMemoizedFn;
655
+ }
656
+ return returnValue;
657
+ };
658
+ const memoizedFn = _memoize(wrappedFn);
659
+ Object.setPrototypeOf(memoizedFn, originalFn);
660
+ return memoizedFn;
661
+ }
662
+ function getRuntimeSelectorInfo(context, selectorMetaData, selectors = []) {
663
+ const localSelectorOptions = selectorMetaData.getSelectorOptions();
664
+ const selectorOptions = context.getSelectorOptions(localSelectorOptions);
665
+ const selectorsToApply = getSelectorsToApply(selectors, selectorOptions, selectorMetaData.containerClass);
666
+ const argumentSelectorFunctions = selectorsToApply.map(selector => {
667
+ const factory = getRootSelectorFactory(selector);
668
+ return factory(context);
669
+ });
670
+ return {
671
+ selectorOptions,
672
+ argumentSelectorFunctions
673
+ };
674
+ }
675
+ function getSelectorsToApply(selectors = [], selectorOptions, containerClass) {
676
+ const selectorsToApply = [];
677
+ // The container state refers to the state class that includes the
678
+ // definition of the selector function, for example:
679
+ // @State()
680
+ // class AnimalsState {
681
+ // @Selector()
682
+ // static getAnimals(state: AnimalsStateModel) {}
683
+ // }
684
+ // The `AnimalsState` serves as the container state. Additionally, the
685
+ // selector may reside within a namespace or another class lacking the
686
+ // `@State` decorator, thus not being treated as the container state.
687
+ const canInjectContainerState = selectorOptions.injectContainerState || selectors.length === 0;
688
+ if (containerClass && canInjectContainerState) {
689
+ // If we are on a state class, add it as the first selector parameter
690
+ const metadata = _getStoreMetadata(containerClass);
691
+ if (metadata) {
692
+ selectorsToApply.push(containerClass);
693
+ }
694
+ }
695
+ selectorsToApply.push(...selectors);
696
+ return selectorsToApply;
697
+ }
698
+ /**
699
+ * This function gets the factory function to create the selector to get the selected slice from the app state
700
+ * @ignore
701
+ */
702
+ function getRootSelectorFactory(selector) {
703
+ const metadata = _getSelectorMetadata(selector) || _getStoreMetadata(selector);
704
+ return (metadata && metadata.makeRootSelector) || (() => selector);
705
+ }
706
+
707
+ const NG_DEV_MODE$5 = typeof ngDevMode !== 'undefined' && ngDevMode;
708
+ /**
709
+ * Get a deeply nested value. Example:
710
+ *
711
+ * getValue({ foo: bar: [] }, 'foo.bar') //=> []
712
+ *
713
+ * Note: This is not as fast as the `fastPropGetter` but is strict Content Security Policy compliant.
714
+ * See perf hit: https://jsperf.com/fast-value-getter-given-path/1
715
+ *
716
+ * @ignore
717
+ */
718
+ function compliantPropGetter(paths) {
719
+ return obj => {
720
+ for (let i = 0; i < paths.length; i++) {
721
+ if (!obj)
722
+ return undefined;
723
+ obj = obj[paths[i]];
724
+ }
725
+ return obj;
726
+ };
727
+ }
728
+ /**
729
+ * The generated function is faster than:
730
+ * - pluck (Observable operator)
731
+ * - memoize
732
+ *
733
+ * @ignore
734
+ */
735
+ function fastPropGetter(paths) {
736
+ const segments = paths;
737
+ let seg = 'store.' + segments[0];
738
+ let i = 0;
739
+ const l = segments.length;
740
+ let expr = seg;
741
+ while (++i < l) {
742
+ expr = expr + ' && ' + (seg = seg + '.' + segments[i]);
743
+ }
744
+ const fn = new Function('store', 'return ' + expr + ';');
745
+ return fn;
746
+ }
747
+ /**
748
+ * Get a deeply nested value. Example:
749
+ *
750
+ * getValue({ foo: bar: [] }, 'foo.bar') //=> []
751
+ *
752
+ * @ignore
753
+ *
754
+ * Marked for removal. It's only used within `createSelectorFn`.
755
+ */
756
+ function propGetter(paths, config) {
757
+ if (config?.compatibility?.strictContentSecurityPolicy) {
758
+ return compliantPropGetter(paths);
759
+ }
760
+ else {
761
+ return fastPropGetter(paths);
762
+ }
763
+ }
764
+ // This injection token selects the prop getter implementation once the app is
765
+ // bootstrapped, as the `propGetter` function's behavior determines the implementation
766
+ // each time it's called. It accepts the config as the second argument. We no longer
767
+ // need to check for the `strictContentSecurityPolicy` every time the prop getter
768
+ // implementation is selected. Now, the `propGetter` function is only used within
769
+ // `createSelectorFn`, which, in turn, is solely used by the `Select` decorator.
770
+ // We've been trying to deprecate the `Select` decorator because it's unstable with
771
+ // server-side rendering and micro-frontend applications.
772
+ const ɵPROP_GETTER = new InjectionToken(NG_DEV_MODE$5 ? 'PROP_GETTER' : '', {
773
+ providedIn: 'root',
774
+ factory: () => inject(NgxsConfig).compatibility?.strictContentSecurityPolicy
775
+ ? compliantPropGetter
776
+ : fastPropGetter
777
+ });
778
+ /**
779
+ * Given an array of states, it will return a object graph. Example:
780
+ * const states = [
781
+ * Cart,
782
+ * CartSaved,
783
+ * CartSavedItems
784
+ * ]
785
+ *
786
+ * would return:
787
+ *
788
+ * const graph = {
789
+ * cart: ['saved'],
790
+ * saved: ['items'],
791
+ * items: []
792
+ * };
793
+ *
794
+ * @ignore
795
+ */
796
+ function buildGraph(stateClasses) {
797
+ const findName = (stateClass) => {
798
+ const meta = stateClasses.find(g => g === stateClass);
799
+ if (NG_DEV_MODE$5 && !meta) {
800
+ throw new Error(`Child state not found: ${stateClass}. \r\nYou may have forgotten to add states to module`);
801
+ }
802
+ return meta[_META_KEY].name;
803
+ };
804
+ return stateClasses.reduce((result, stateClass) => {
805
+ const { name, children } = stateClass[_META_KEY];
806
+ result[name] = (children || []).map(findName);
807
+ return result;
808
+ }, {});
809
+ }
810
+ /**
811
+ * Given a states array, returns object graph
812
+ * returning the name and state metadata. Example:
813
+ *
814
+ * const graph = {
815
+ * cart: { metadata }
816
+ * };
817
+ *
425
818
  * @ignore
426
819
  */
427
820
  function nameToState(states) {
428
821
  return states.reduce((result, stateClass) => {
429
- const meta = stateClass[META_KEY];
822
+ const meta = stateClass[_META_KEY];
430
823
  result[meta.name] = stateClass;
431
824
  return result;
432
825
  }, {});
@@ -476,639 +869,149 @@ function findFullParentPath(obj, newObj = {}) {
476
869
  * cart: ['saved'],
477
870
  * saved: ['items'],
478
871
  * items: []
479
- * };
480
- *
481
- * would return:
482
- *
483
- * const results = [
484
- * 'items',
485
- * 'saved',
486
- * 'cart'
487
- * ];
488
- *
489
- * @ignore
490
- */
491
- function topologicalSort(graph) {
492
- const sorted = [];
493
- const visited = {};
494
- const visit = (name, ancestors = []) => {
495
- if (!Array.isArray(ancestors)) {
496
- ancestors = [];
497
- }
498
- ancestors.push(name);
499
- visited[name] = true;
500
- graph[name].forEach((dep) => {
501
- // Caretaker note: we have still left the `typeof` condition in order to avoid
502
- // creating a breaking change for projects that still use the View Engine.
503
- if ((typeof ngDevMode === 'undefined' || ngDevMode) && ancestors.indexOf(dep) >= 0) {
504
- throw new Error(`Circular dependency '${dep}' is required by '${name}': ${ancestors.join(' -> ')}`);
505
- }
506
- if (visited[dep]) {
507
- return;
508
- }
509
- visit(dep, ancestors.slice(0));
510
- });
511
- if (sorted.indexOf(name) < 0) {
512
- sorted.push(name);
513
- }
514
- };
515
- Object.keys(graph).forEach(k => visit(k));
516
- return sorted.reverse();
517
- }
518
- /**
519
- * Returns if the parameter is a object or not.
520
- *
521
- * @ignore
522
- */
523
- function isObject(obj) {
524
- return (typeof obj === 'object' && obj !== null) || typeof obj === 'function';
525
- }
526
-
527
- /**
528
- * RxJS operator for selecting out specific actions.
529
- *
530
- * This will grab actions that have just been dispatched as well as actions that have completed
531
- */
532
- function ofAction(...allowedTypes) {
533
- return ofActionOperator(allowedTypes);
534
- }
535
- /**
536
- * RxJS operator for selecting out specific actions.
537
- *
538
- * This will ONLY grab actions that have just been dispatched
539
- */
540
- function ofActionDispatched(...allowedTypes) {
541
- return ofActionOperator(allowedTypes, ["DISPATCHED" /* Dispatched */]);
542
- }
543
- /**
544
- * RxJS operator for selecting out specific actions.
545
- *
546
- * This will ONLY grab actions that have just been successfully completed
547
- */
548
- function ofActionSuccessful(...allowedTypes) {
549
- return ofActionOperator(allowedTypes, ["SUCCESSFUL" /* Successful */]);
550
- }
551
- /**
552
- * RxJS operator for selecting out specific actions.
553
- *
554
- * This will ONLY grab actions that have just been canceled
555
- */
556
- function ofActionCanceled(...allowedTypes) {
557
- return ofActionOperator(allowedTypes, ["CANCELED" /* Canceled */]);
558
- }
559
- /**
560
- * RxJS operator for selecting out specific actions.
561
- *
562
- * This will ONLY grab actions that have just been completed
563
- */
564
- function ofActionCompleted(...allowedTypes) {
565
- const allowedStatuses = [
566
- "SUCCESSFUL" /* Successful */,
567
- "CANCELED" /* Canceled */,
568
- "ERRORED" /* Errored */
569
- ];
570
- return ofActionOperator(allowedTypes, allowedStatuses, mapActionResult);
571
- }
572
- /**
573
- * RxJS operator for selecting out specific actions.
574
- *
575
- * This will ONLY grab actions that have just thrown an error
576
- */
577
- function ofActionErrored(...allowedTypes) {
578
- return ofActionOperator(allowedTypes, ["ERRORED" /* Errored */]);
579
- }
580
- function ofActionOperator(allowedTypes, statuses,
581
- // This actually could've been `OperatorFunction<ActionContext, ActionCompletion | any>`,
582
- // since it maps either to `ctx.action` OR to `ActionCompletion`. But `ActionCompleteion | any`
583
- // defaults to `any`, thus there is no sense from union type.
584
- mapOperator = mapAction) {
585
- const allowedMap = createAllowedActionTypesMap(allowedTypes);
586
- const allowedStatusMap = statuses && createAllowedStatusesMap(statuses);
587
- return function (o) {
588
- return o.pipe(filterStatus(allowedMap, allowedStatusMap), mapOperator());
589
- };
590
- }
591
- function filterStatus(allowedTypes, allowedStatuses) {
592
- return filter((ctx) => {
593
- const actionType = getActionTypeFromInstance(ctx.action);
594
- const typeMatch = allowedTypes[actionType];
595
- const statusMatch = allowedStatuses ? allowedStatuses[ctx.status] : true;
596
- return typeMatch && statusMatch;
597
- });
598
- }
599
- function mapActionResult() {
600
- return map(({ action, status, error }) => {
601
- return {
602
- action,
603
- result: {
604
- successful: "SUCCESSFUL" /* Successful */ === status,
605
- canceled: "CANCELED" /* Canceled */ === status,
606
- error
607
- }
608
- };
609
- });
610
- }
611
- function mapAction() {
612
- return map((ctx) => ctx.action);
613
- }
614
- function createAllowedActionTypesMap(types) {
615
- return types.reduce((filterMap, klass) => {
616
- filterMap[getActionTypeFromInstance(klass)] = true;
617
- return filterMap;
618
- }, {});
619
- }
620
- function createAllowedStatusesMap(statuses) {
621
- return statuses.reduce((filterMap, status) => {
622
- filterMap[status] = true;
623
- return filterMap;
624
- }, {});
625
- }
626
-
627
- /**
628
- * Returns operator that will run
629
- * `subscribe` outside of the ngxs execution context
630
- */
631
- function leaveNgxs(ngxsExecutionStrategy) {
632
- return (source) => {
633
- return new Observable((sink) => {
634
- return source.subscribe({
635
- next(value) {
636
- ngxsExecutionStrategy.leave(() => sink.next(value));
637
- },
638
- error(error) {
639
- ngxsExecutionStrategy.leave(() => sink.error(error));
640
- },
641
- complete() {
642
- ngxsExecutionStrategy.leave(() => sink.complete());
643
- }
644
- });
645
- });
646
- };
647
- }
648
-
649
- class InternalNgxsExecutionStrategy {
650
- constructor(_executionStrategy) {
651
- this._executionStrategy = _executionStrategy;
652
- }
653
- enter(func) {
654
- return this._executionStrategy.enter(func);
655
- }
656
- leave(func) {
657
- return this._executionStrategy.leave(func);
658
- }
659
- }
660
- /** @nocollapse */ InternalNgxsExecutionStrategy.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: InternalNgxsExecutionStrategy, deps: [{ token: NGXS_EXECUTION_STRATEGY }], target: i0.ɵɵFactoryTarget.Injectable });
661
- /** @nocollapse */ InternalNgxsExecutionStrategy.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: InternalNgxsExecutionStrategy, providedIn: 'root' });
662
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: InternalNgxsExecutionStrategy, decorators: [{
663
- type: Injectable,
664
- args: [{ providedIn: 'root' }]
665
- }], ctorParameters: function () { return [{ type: undefined, decorators: [{
666
- type: Inject,
667
- args: [NGXS_EXECUTION_STRATEGY]
668
- }] }]; } });
669
-
670
- /**
671
- * This wraps the provided function, and will enforce the following:
672
- * - The calls will execute in the order that they are made
673
- * - A call will only be initiated when the previous call has completed
674
- * - If there is a call currently executing then the new call will be added
675
- * to the queue and the function will return immediately
676
- *
677
- * NOTE: The following assumptions about the operation must hold true:
678
- * - The operation is synchronous in nature
679
- * - If any asynchronous side effects of the call exist, it should not
680
- * have any bearing on the correctness of the next call in the queue
681
- * - The operation has a void return
682
- * - The caller should not assume that the call has completed upon
683
- * return of the function
684
- * - The caller can assume that all the queued calls will complete
685
- * within the current microtask
686
- * - The only way that a call will encounter another call in the queue
687
- * would be if the call at the front of the queue initiated this call
688
- * as part of its synchronous execution
689
- */
690
- function orderedQueueOperation(operation) {
691
- const callsQueue = [];
692
- let busyPushingNext = false;
693
- return function callOperation(...args) {
694
- if (busyPushingNext) {
695
- callsQueue.unshift(args);
696
- return;
697
- }
698
- busyPushingNext = true;
699
- operation(...args);
700
- while (callsQueue.length > 0) {
701
- const nextCallArgs = callsQueue.pop();
702
- nextCallArgs && operation(...nextCallArgs);
703
- }
704
- busyPushingNext = false;
705
- };
706
- }
707
- /**
708
- * Custom Subject that ensures that subscribers are notified of values in the order that they arrived.
709
- * A standard Subject does not have this guarantee.
710
- * For example, given the following code:
711
- * ```typescript
712
- * const subject = new Subject<string>();
713
- subject.subscribe(value => {
714
- if (value === 'start') subject.next('end');
715
- });
716
- subject.subscribe(value => { });
717
- subject.next('start');
718
- * ```
719
- * When `subject` is a standard `Subject<T>` the second subscriber would recieve `end` and then `start`.
720
- * When `subject` is a `OrderedSubject<T>` the second subscriber would recieve `start` and then `end`.
721
- */
722
- class OrderedSubject extends Subject {
723
- constructor() {
724
- super(...arguments);
725
- this._orderedNext = orderedQueueOperation((value) => super.next(value));
726
- }
727
- next(value) {
728
- this._orderedNext(value);
729
- }
730
- }
731
- /**
732
- * Custom BehaviorSubject that ensures that subscribers are notified of values in the order that they arrived.
733
- * A standard BehaviorSubject does not have this guarantee.
734
- * For example, given the following code:
735
- * ```typescript
736
- * const subject = new BehaviorSubject<string>();
737
- subject.subscribe(value => {
738
- if (value === 'start') subject.next('end');
739
- });
740
- subject.subscribe(value => { });
741
- subject.next('start');
742
- * ```
743
- * When `subject` is a standard `BehaviorSubject<T>` the second subscriber would recieve `end` and then `start`.
744
- * When `subject` is a `OrderedBehaviorSubject<T>` the second subscriber would recieve `start` and then `end`.
745
- */
746
- class OrderedBehaviorSubject extends BehaviorSubject {
747
- constructor(value) {
748
- super(value);
749
- this._orderedNext = orderedQueueOperation((value) => super.next(value));
750
- this._currentValue = value;
751
- }
752
- getValue() {
753
- return this._currentValue;
754
- }
755
- next(value) {
756
- this._currentValue = value;
757
- this._orderedNext(value);
758
- }
759
- }
760
-
761
- /**
762
- * Internal Action stream that is emitted anytime an action is dispatched.
763
- */
764
- class InternalActions extends OrderedSubject {
765
- ngOnDestroy() {
766
- this.complete();
767
- }
768
- }
769
- /** @nocollapse */ InternalActions.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: InternalActions, deps: null, target: i0.ɵɵFactoryTarget.Injectable });
770
- /** @nocollapse */ InternalActions.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: InternalActions, providedIn: 'root' });
771
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: InternalActions, decorators: [{
772
- type: Injectable,
773
- args: [{ providedIn: 'root' }]
774
- }] });
775
- /**
776
- * Action stream that is emitted anytime an action is dispatched.
777
- *
778
- * You can listen to this in services to react without stores.
779
- */
780
- class Actions extends Observable {
781
- constructor(internalActions$, internalExecutionStrategy) {
782
- const sharedInternalActions$ = internalActions$.pipe(leaveNgxs(internalExecutionStrategy),
783
- // The `InternalActions` subject emits outside of the Angular zone.
784
- // We have to re-enter the Angular zone for any incoming consumer.
785
- // The `share()` operator reduces the number of change detections.
786
- // This would call leave only once for any stream emission across all active subscribers.
787
- share());
788
- super(observer => {
789
- const childSubscription = sharedInternalActions$.subscribe({
790
- next: ctx => observer.next(ctx),
791
- error: error => observer.error(error),
792
- complete: () => observer.complete()
793
- });
794
- observer.add(childSubscription);
795
- });
796
- }
797
- }
798
- /** @nocollapse */ Actions.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: Actions, deps: [{ token: InternalActions }, { token: InternalNgxsExecutionStrategy }], target: i0.ɵɵFactoryTarget.Injectable });
799
- /** @nocollapse */ Actions.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: Actions, providedIn: 'root' });
800
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: Actions, decorators: [{
801
- type: Injectable,
802
- args: [{ providedIn: 'root' }]
803
- }], ctorParameters: function () { return [{ type: InternalActions }, { type: InternalNgxsExecutionStrategy }]; } });
804
-
805
- /**
806
- * Composes a array of functions from left to right. Example:
807
- *
808
- * compose([fn, final])(state, action);
809
- *
810
- * then the funcs have a signature like:
811
- *
812
- * function fn (state, action, next) {
813
- * console.log('here', state, action, next);
814
- * return next(state, action);
815
- * }
816
- *
817
- * function final (state, action) {
818
- * console.log('here', state, action);
819
- * return state;
820
- * }
872
+ * };
821
873
  *
822
- * the last function should not call `next`.
874
+ * would return:
875
+ *
876
+ * const results = [
877
+ * 'items',
878
+ * 'saved',
879
+ * 'cart'
880
+ * ];
823
881
  *
824
882
  * @ignore
825
883
  */
826
- const compose = (funcs) => (...args) => {
827
- const curr = funcs.shift();
828
- return curr(...args, (...nextArgs) => compose(funcs)(...nextArgs));
829
- };
830
-
831
- /**
832
- * This operator is used for piping the observable result
833
- * from the `dispatch()`. It has a "smart" error handling
834
- * strategy that allows us to decide whether we propagate
835
- * errors to Angular's `ErrorHandler` or enable users to
836
- * handle them manually. We consider following cases:
837
- * 1) `store.dispatch()` (no subscribe) -> call `handleError()`
838
- * 2) `store.dispatch().subscribe()` (no error callback) -> call `handleError()`
839
- * 3) `store.dispatch().subscribe({ error: ... })` -> don't call `handleError()`
840
- * 4) `toPromise()` without `catch` -> do `handleError()`
841
- * 5) `toPromise()` with `catch` -> don't `handleError()`
842
- */
843
- function ngxsErrorHandler(internalErrorReporter, ngxsExecutionStrategy) {
844
- return (source) => {
845
- let subscribed = false;
846
- source.subscribe({
847
- error: error => {
848
- // Do not trigger change detection for a microtask. This depends on the execution
849
- // strategy being used, but the default `DispatchOutsideZoneNgxsExecutionStrategy`
850
- // leaves the Angular zone.
851
- ngxsExecutionStrategy.enter(() => Promise.resolve().then(() => {
852
- if (!subscribed) {
853
- ngxsExecutionStrategy.leave(() => internalErrorReporter.reportErrorSafely(error));
854
- }
855
- }));
884
+ function topologicalSort(graph) {
885
+ const sorted = [];
886
+ const visited = {};
887
+ const visit = (name, ancestors = []) => {
888
+ if (!Array.isArray(ancestors)) {
889
+ ancestors = [];
890
+ }
891
+ ancestors.push(name);
892
+ visited[name] = true;
893
+ graph[name].forEach((dep) => {
894
+ if (NG_DEV_MODE$5 && ancestors.indexOf(dep) >= 0) {
895
+ throw new Error(`Circular dependency '${dep}' is required by '${name}': ${ancestors.join(' -> ')}`);
856
896
  }
897
+ if (visited[dep]) {
898
+ return;
899
+ }
900
+ visit(dep, ancestors.slice(0));
857
901
  });
858
- return new Observable(subscriber => {
859
- subscribed = true;
860
- return source.pipe(leaveNgxs(ngxsExecutionStrategy)).subscribe(subscriber);
861
- });
862
- };
863
- }
864
- class InternalErrorReporter {
865
- constructor(_injector) {
866
- this._injector = _injector;
867
- /** Will be set lazily to be backward compatible. */
868
- this._errorHandler = null;
869
- }
870
- reportErrorSafely(error) {
871
- if (this._errorHandler === null) {
872
- this._errorHandler = this._injector.get(ErrorHandler);
873
- }
874
- // The `try-catch` is used to avoid handling the error twice. Suppose we call
875
- // `handleError` which re-throws the error internally. The re-thrown error will
876
- // be caught by zone.js which will then get to the `zone.onError.emit()` and the
877
- // `onError` subscriber will call `handleError` again.
878
- try {
879
- this._errorHandler.handleError(error);
902
+ if (sorted.indexOf(name) < 0) {
903
+ sorted.push(name);
880
904
  }
881
- catch (_a) { }
882
- }
905
+ };
906
+ Object.keys(graph).forEach(k => visit(k));
907
+ return sorted.reverse();
883
908
  }
884
- /** @nocollapse */ InternalErrorReporter.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: InternalErrorReporter, deps: [{ token: i0.Injector }], target: i0.ɵɵFactoryTarget.Injectable });
885
- /** @nocollapse */ InternalErrorReporter.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: InternalErrorReporter, providedIn: 'root' });
886
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: InternalErrorReporter, decorators: [{
887
- type: Injectable,
888
- args: [{ providedIn: 'root' }]
889
- }], ctorParameters: function () { return [{ type: i0.Injector }]; } });
890
909
 
891
910
  /**
892
- * BehaviorSubject of the entire state.
893
- * @ignore
911
+ * RxJS operator for selecting out specific actions.
912
+ *
913
+ * This will grab actions that have just been dispatched as well as actions that have completed
894
914
  */
895
- class StateStream extends OrderedBehaviorSubject {
896
- constructor() {
897
- super({});
898
- }
899
- ngOnDestroy() {
900
- // The `StateStream` should never emit values once the root view is removed, e.g. when the `NgModuleRef.destroy()` is called.
901
- // This will eliminate memory leaks in server-side rendered apps where the `StateStream` is created per each HTTP request, users
902
- // might forget to unsubscribe from `store.select` or `store.subscribe`, thus this will lead to huge memory leaks in SSR apps.
903
- this.complete();
904
- }
915
+ function ofAction(...allowedTypes) {
916
+ return ofActionOperator(allowedTypes);
905
917
  }
906
- /** @nocollapse */ StateStream.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: StateStream, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
907
- /** @nocollapse */ StateStream.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: StateStream, providedIn: 'root' });
908
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: StateStream, decorators: [{
909
- type: Injectable,
910
- args: [{ providedIn: 'root' }]
911
- }], ctorParameters: function () { return []; } });
912
-
913
- class PluginManager {
914
- constructor(_parentManager, _pluginHandlers) {
915
- this._parentManager = _parentManager;
916
- this._pluginHandlers = _pluginHandlers;
917
- this.plugins = [];
918
- this.registerHandlers();
919
- }
920
- get rootPlugins() {
921
- return (this._parentManager && this._parentManager.plugins) || this.plugins;
922
- }
923
- registerHandlers() {
924
- const pluginHandlers = this.getPluginHandlers();
925
- this.rootPlugins.push(...pluginHandlers);
926
- }
927
- getPluginHandlers() {
928
- const handlers = this._pluginHandlers || [];
929
- return handlers.map((plugin) => (plugin.handle ? plugin.handle.bind(plugin) : plugin));
930
- }
918
+ /**
919
+ * RxJS operator for selecting out specific actions.
920
+ *
921
+ * This will ONLY grab actions that have just been dispatched
922
+ */
923
+ function ofActionDispatched(...allowedTypes) {
924
+ return ofActionOperator(allowedTypes, ["DISPATCHED" /* ActionStatus.Dispatched */]);
931
925
  }
932
- /** @nocollapse */ PluginManager.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: PluginManager, deps: [{ token: PluginManager, optional: true, skipSelf: true }, { token: NGXS_PLUGINS, optional: true }], target: i0.ɵɵFactoryTarget.Injectable });
933
- /** @nocollapse */ PluginManager.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: PluginManager });
934
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: PluginManager, decorators: [{
935
- type: Injectable
936
- }], ctorParameters: function () { return [{ type: PluginManager, decorators: [{
937
- type: Optional
938
- }, {
939
- type: SkipSelf
940
- }] }, { type: undefined, decorators: [{
941
- type: Inject,
942
- args: [NGXS_PLUGINS]
943
- }, {
944
- type: Optional
945
- }] }]; } });
946
-
947
926
  /**
948
- * Internal Action result stream that is emitted when an action is completed.
949
- * This is used as a method of returning the action result to the dispatcher
950
- * for the observable returned by the dispatch(...) call.
951
- * The dispatcher then asynchronously pushes the result from this stream onto the main action stream as a result.
927
+ * RxJS operator for selecting out specific actions.
928
+ *
929
+ * This will ONLY grab actions that have just been successfully completed
952
930
  */
953
- class InternalDispatchedActionResults extends Subject {
931
+ function ofActionSuccessful(...allowedTypes) {
932
+ return ofActionOperator(allowedTypes, ["SUCCESSFUL" /* ActionStatus.Successful */]);
954
933
  }
955
- /** @nocollapse */ InternalDispatchedActionResults.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: InternalDispatchedActionResults, deps: null, target: i0.ɵɵFactoryTarget.Injectable });
956
- /** @nocollapse */ InternalDispatchedActionResults.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: InternalDispatchedActionResults, providedIn: 'root' });
957
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: InternalDispatchedActionResults, decorators: [{
958
- type: Injectable,
959
- args: [{ providedIn: 'root' }]
960
- }] });
961
- class InternalDispatcher {
962
- constructor(_actions, _actionResults, _pluginManager, _stateStream, _ngxsExecutionStrategy, _internalErrorReporter) {
963
- this._actions = _actions;
964
- this._actionResults = _actionResults;
965
- this._pluginManager = _pluginManager;
966
- this._stateStream = _stateStream;
967
- this._ngxsExecutionStrategy = _ngxsExecutionStrategy;
968
- this._internalErrorReporter = _internalErrorReporter;
969
- }
970
- /**
971
- * Dispatches event(s).
972
- */
973
- dispatch(actionOrActions) {
974
- const result = this._ngxsExecutionStrategy.enter(() => this.dispatchByEvents(actionOrActions));
975
- return result.pipe(ngxsErrorHandler(this._internalErrorReporter, this._ngxsExecutionStrategy));
976
- }
977
- dispatchByEvents(actionOrActions) {
978
- if (Array.isArray(actionOrActions)) {
979
- if (actionOrActions.length === 0)
980
- return of(this._stateStream.getValue());
981
- return forkJoin(actionOrActions.map(action => this.dispatchSingle(action)));
982
- }
983
- else {
984
- return this.dispatchSingle(actionOrActions);
985
- }
986
- }
987
- dispatchSingle(action) {
988
- if (typeof ngDevMode === 'undefined' || ngDevMode) {
989
- const type = getActionTypeFromInstance(action);
990
- if (!type) {
991
- const error = new Error(`This action doesn't have a type property: ${action.constructor.name}`);
992
- return throwError(error);
993
- }
994
- }
995
- const prevState = this._stateStream.getValue();
996
- const plugins = this._pluginManager.plugins;
997
- return compose([
998
- ...plugins,
999
- (nextState, nextAction) => {
1000
- if (nextState !== prevState) {
1001
- this._stateStream.next(nextState);
1002
- }
1003
- const actionResult$ = this.getActionResultStream(nextAction);
1004
- actionResult$.subscribe(ctx => this._actions.next(ctx));
1005
- this._actions.next({ action: nextAction, status: "DISPATCHED" /* Dispatched */ });
1006
- return this.createDispatchObservable(actionResult$);
1007
- }
1008
- ])(prevState, action).pipe(shareReplay());
1009
- }
1010
- getActionResultStream(action) {
1011
- return this._actionResults.pipe(filter((ctx) => ctx.action === action && ctx.status !== "DISPATCHED" /* Dispatched */), take(1), shareReplay());
1012
- }
1013
- createDispatchObservable(actionResult$) {
1014
- return actionResult$
1015
- .pipe(exhaustMap((ctx) => {
1016
- switch (ctx.status) {
1017
- case "SUCCESSFUL" /* Successful */:
1018
- return of(this._stateStream.getValue());
1019
- case "ERRORED" /* Errored */:
1020
- return throwError(ctx.error);
1021
- default:
1022
- return EMPTY;
1023
- }
1024
- }))
1025
- .pipe(shareReplay());
1026
- }
934
+ /**
935
+ * RxJS operator for selecting out specific actions.
936
+ *
937
+ * This will ONLY grab actions that have just been canceled
938
+ */
939
+ function ofActionCanceled(...allowedTypes) {
940
+ return ofActionOperator(allowedTypes, ["CANCELED" /* ActionStatus.Canceled */]);
1027
941
  }
1028
- /** @nocollapse */ InternalDispatcher.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: InternalDispatcher, deps: [{ token: InternalActions }, { token: InternalDispatchedActionResults }, { token: PluginManager }, { token: StateStream }, { token: InternalNgxsExecutionStrategy }, { token: InternalErrorReporter }], target: i0.ɵɵFactoryTarget.Injectable });
1029
- /** @nocollapse */ InternalDispatcher.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: InternalDispatcher, providedIn: 'root' });
1030
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: InternalDispatcher, decorators: [{
1031
- type: Injectable,
1032
- args: [{ providedIn: 'root' }]
1033
- }], ctorParameters: function () { return [{ type: InternalActions }, { type: InternalDispatchedActionResults }, { type: PluginManager }, { type: StateStream }, { type: InternalNgxsExecutionStrategy }, { type: InternalErrorReporter }]; } });
1034
-
1035
942
  /**
1036
- * Object freeze code
1037
- * https://github.com/jsdf/deep-freeze
943
+ * RxJS operator for selecting out specific actions.
944
+ *
945
+ * This will ONLY grab actions that have just been completed
1038
946
  */
1039
- const deepFreeze = (o) => {
1040
- Object.freeze(o);
1041
- const oIsFunction = typeof o === 'function';
1042
- const hasOwnProp = Object.prototype.hasOwnProperty;
1043
- Object.getOwnPropertyNames(o).forEach(function (prop) {
1044
- if (hasOwnProp.call(o, prop) &&
1045
- (oIsFunction ? prop !== 'caller' && prop !== 'callee' && prop !== 'arguments' : true) &&
1046
- o[prop] !== null &&
1047
- (typeof o[prop] === 'object' || typeof o[prop] === 'function') &&
1048
- !Object.isFrozen(o[prop])) {
1049
- deepFreeze(o[prop]);
1050
- }
1051
- });
1052
- return o;
1053
- };
1054
-
947
+ function ofActionCompleted(...allowedTypes) {
948
+ const allowedStatuses = [
949
+ "SUCCESSFUL" /* ActionStatus.Successful */,
950
+ "CANCELED" /* ActionStatus.Canceled */,
951
+ "ERRORED" /* ActionStatus.Errored */
952
+ ];
953
+ return ofActionOperator(allowedTypes, allowedStatuses, mapActionResult);
954
+ }
1055
955
  /**
1056
- * @ignore
956
+ * RxJS operator for selecting out specific actions.
957
+ *
958
+ * This will ONLY grab actions that have just thrown an error
1057
959
  */
1058
- class InternalStateOperations {
1059
- constructor(_stateStream, _dispatcher, _config) {
1060
- this._stateStream = _stateStream;
1061
- this._dispatcher = _dispatcher;
1062
- this._config = _config;
1063
- }
1064
- /**
1065
- * Returns the root state operators.
1066
- */
1067
- getRootStateOperations() {
1068
- const rootStateOperations = {
1069
- getState: () => this._stateStream.getValue(),
1070
- setState: (newState) => this._stateStream.next(newState),
1071
- dispatch: (actionOrActions) => this._dispatcher.dispatch(actionOrActions)
960
+ function ofActionErrored(...allowedTypes) {
961
+ return ofActionOperator(allowedTypes, ["ERRORED" /* ActionStatus.Errored */], mapActionResult);
962
+ }
963
+ function ofActionOperator(allowedTypes, statuses,
964
+ // This could have been written as
965
+ // `OperatorFunction<ActionContext, ActionCompletion | any>`, as it maps
966
+ // either to `ctx.action` or to `ActionCompletion`. However,
967
+ // `ActionCompletion | any` defaults to `any`, rendering the union
968
+ // type meaningless.
969
+ mapOperator = mapAction) {
970
+ const allowedMap = createAllowedActionTypesMap(allowedTypes);
971
+ const allowedStatusMap = statuses && createAllowedStatusesMap(statuses);
972
+ return function (o) {
973
+ return o.pipe(filterStatus(allowedMap, allowedStatusMap), mapOperator());
974
+ };
975
+ }
976
+ function filterStatus(allowedTypes, allowedStatuses) {
977
+ return filter((ctx) => {
978
+ const actionType = getActionTypeFromInstance(ctx.action);
979
+ const typeMatch = allowedTypes[actionType];
980
+ const statusMatch = allowedStatuses ? allowedStatuses[ctx.status] : true;
981
+ return typeMatch && statusMatch;
982
+ });
983
+ }
984
+ function mapActionResult() {
985
+ return map(({ action, status, error }) => {
986
+ return {
987
+ action,
988
+ result: {
989
+ successful: "SUCCESSFUL" /* ActionStatus.Successful */ === status,
990
+ canceled: "CANCELED" /* ActionStatus.Canceled */ === status,
991
+ error
992
+ }
1072
993
  };
1073
- if (typeof ngDevMode === 'undefined' || ngDevMode) {
1074
- return this._config.developmentMode
1075
- ? ensureStateAndActionsAreImmutable(rootStateOperations)
1076
- : rootStateOperations;
1077
- }
1078
- else {
1079
- return rootStateOperations;
1080
- }
1081
- }
1082
- setStateToTheCurrentWithNew(results) {
1083
- const stateOperations = this.getRootStateOperations();
1084
- // Get our current stream
1085
- const currentState = stateOperations.getState();
1086
- // Set the state to the current + new
1087
- stateOperations.setState(Object.assign(Object.assign({}, currentState), results.defaults));
1088
- }
994
+ });
1089
995
  }
1090
- /** @nocollapse */ InternalStateOperations.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: InternalStateOperations, deps: [{ token: StateStream }, { token: InternalDispatcher }, { token: NgxsConfig }], target: i0.ɵɵFactoryTarget.Injectable });
1091
- /** @nocollapse */ InternalStateOperations.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: InternalStateOperations, providedIn: 'root' });
1092
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: InternalStateOperations, decorators: [{
1093
- type: Injectable,
1094
- args: [{ providedIn: 'root' }]
1095
- }], ctorParameters: function () { return [{ type: StateStream }, { type: InternalDispatcher }, { type: NgxsConfig }]; } });
1096
- function ensureStateAndActionsAreImmutable(root) {
1097
- return {
1098
- getState: () => root.getState(),
1099
- setState: value => {
1100
- const frozenValue = deepFreeze(value);
1101
- return root.setState(frozenValue);
1102
- },
1103
- dispatch: actions => {
1104
- return root.dispatch(actions);
1105
- }
1106
- };
996
+ function mapAction() {
997
+ return map((ctx) => ctx.action);
998
+ }
999
+ function createAllowedActionTypesMap(types) {
1000
+ return types.reduce((filterMap, klass) => {
1001
+ filterMap[getActionTypeFromInstance(klass)] = true;
1002
+ return filterMap;
1003
+ }, {});
1004
+ }
1005
+ function createAllowedStatusesMap(statuses) {
1006
+ return statuses.reduce((filterMap, status) => {
1007
+ filterMap[status] = true;
1008
+ return filterMap;
1009
+ }, {});
1107
1010
  }
1108
1011
 
1109
1012
  function simplePatch(value) {
1110
1013
  return (existingState) => {
1111
- if (typeof ngDevMode === 'undefined' || ngDevMode) {
1014
+ if (typeof ngDevMode !== 'undefined' && ngDevMode) {
1112
1015
  if (Array.isArray(value)) {
1113
1016
  throwPatchingArrayError();
1114
1017
  }
@@ -1116,7 +1019,7 @@ function simplePatch(value) {
1116
1019
  throwPatchingPrimitiveError();
1117
1020
  }
1118
1021
  }
1119
- const newState = Object.assign({}, existingState);
1022
+ const newState = { ...existingState };
1120
1023
  for (const key in value) {
1121
1024
  // deep clone for patch compatibility
1122
1025
  newState[key] = value[key];
@@ -1146,26 +1049,29 @@ class StateContextFactory {
1146
1049
  patchState(val) {
1147
1050
  const currentAppState = root.getState();
1148
1051
  const patchOperator = simplePatch(val);
1149
- return setStateFromOperator(root, currentAppState, patchOperator, mappedStore.path);
1052
+ setStateFromOperator(root, currentAppState, patchOperator, mappedStore.path);
1150
1053
  },
1151
1054
  setState(val) {
1152
1055
  const currentAppState = root.getState();
1153
- return isStateOperator(val)
1154
- ? setStateFromOperator(root, currentAppState, val, mappedStore.path)
1155
- : setStateValue(root, currentAppState, val, mappedStore.path);
1056
+ if (isStateOperator(val)) {
1057
+ setStateFromOperator(root, currentAppState, val, mappedStore.path);
1058
+ }
1059
+ else {
1060
+ setStateValue(root, currentAppState, val, mappedStore.path);
1061
+ }
1156
1062
  },
1157
1063
  dispatch(actions) {
1158
1064
  return root.dispatch(actions);
1159
1065
  }
1160
1066
  };
1161
1067
  }
1068
+ /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: StateContextFactory, deps: [{ token: InternalStateOperations }], target: i0.ɵɵFactoryTarget.Injectable }); }
1069
+ /** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: StateContextFactory, providedIn: 'root' }); }
1162
1070
  }
1163
- /** @nocollapse */ StateContextFactory.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: StateContextFactory, deps: [{ token: InternalStateOperations }], target: i0.ɵɵFactoryTarget.Injectable });
1164
- /** @nocollapse */ StateContextFactory.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: StateContextFactory, providedIn: 'root' });
1165
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: StateContextFactory, decorators: [{
1071
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: StateContextFactory, decorators: [{
1166
1072
  type: Injectable,
1167
1073
  args: [{ providedIn: 'root' }]
1168
- }], ctorParameters: function () { return [{ type: InternalStateOperations }]; } });
1074
+ }], ctorParameters: () => [{ type: InternalStateOperations }] });
1169
1075
  function setStateValue(root, currentAppState, newValue, path) {
1170
1076
  const newAppState = setValue(currentAppState, path, newValue);
1171
1077
  root.setState(newAppState);
@@ -1203,7 +1109,7 @@ function ensureStateNameIsUnique(stateName, state, statesByName) {
1203
1109
  }
1204
1110
  function ensureStatesAreDecorated(stateClasses) {
1205
1111
  stateClasses.forEach((stateClass) => {
1206
- if (!getStoreMetadata$1(stateClass)) {
1112
+ if (!_getStoreMetadata(stateClass)) {
1207
1113
  throwStateDecoratorError(stateClass.name);
1208
1114
  }
1209
1115
  });
@@ -1218,7 +1124,7 @@ function ensureStateClassIsInjectable(stateClass) {
1218
1124
  if (jit_hasInjectableAnnotation(stateClass) || aot_hasNgInjectableDef(stateClass)) {
1219
1125
  return;
1220
1126
  }
1221
- console.warn(getUndecoratedStateInIvyWarningMessage(stateClass.name));
1127
+ console.warn(getUndecoratedStateWithInjectableWarningMessage(stateClass.name));
1222
1128
  }
1223
1129
  function aot_hasNgInjectableDef(stateClass) {
1224
1130
  // `ɵprov` is a static property added by the NGCC compiler. It always exists in
@@ -1230,26 +1136,11 @@ function aot_hasNgInjectableDef(stateClass) {
1230
1136
  function jit_hasInjectableAnnotation(stateClass) {
1231
1137
  // `ɵprov` doesn't exist in JIT mode (for instance when running unit tests with Jest).
1232
1138
  const annotations = stateClass.__annotations__ || [];
1233
- return annotations.some((annotation) => (annotation === null || annotation === void 0 ? void 0 : annotation.ngMetadataName) === 'Injectable');
1234
- }
1235
-
1236
- /**
1237
- * Init action
1238
- */
1239
- class InitState {
1240
- }
1241
- InitState.type = '@@INIT';
1242
- /**
1243
- * Update action
1244
- */
1245
- class UpdateState {
1246
- constructor(addedStates) {
1247
- this.addedStates = addedStates;
1248
- }
1139
+ return annotations.some((annotation) => annotation?.ngMetadataName === 'Injectable');
1249
1140
  }
1250
- UpdateState.type = '@@UPDATE_STATE';
1251
1141
 
1252
- const NGXS_DEVELOPMENT_OPTIONS = new InjectionToken('NGXS_DEVELOPMENT_OPTIONS', {
1142
+ const NG_DEV_MODE$4 = typeof ngDevMode !== 'undefined' && ngDevMode;
1143
+ const NGXS_DEVELOPMENT_OPTIONS = new InjectionToken(NG_DEV_MODE$4 ? 'NGXS_DEVELOPMENT_OPTIONS' : '', {
1253
1144
  providedIn: 'root',
1254
1145
  factory: () => ({ warnOnUnhandledActions: true })
1255
1146
  });
@@ -1285,17 +1176,56 @@ class NgxsUnhandledActionsLogger {
1285
1176
  : action.type;
1286
1177
  console.warn(`The ${action} action has been dispatched but hasn't been handled. This may happen if the state with an action handler for this action is not registered.`);
1287
1178
  }
1179
+ /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: NgxsUnhandledActionsLogger, deps: [{ token: NGXS_DEVELOPMENT_OPTIONS }], target: i0.ɵɵFactoryTarget.Injectable }); }
1180
+ /** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: NgxsUnhandledActionsLogger }); }
1288
1181
  }
1289
- /** @nocollapse */ NgxsUnhandledActionsLogger.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: NgxsUnhandledActionsLogger, deps: [{ token: NGXS_DEVELOPMENT_OPTIONS }], target: i0.ɵɵFactoryTarget.Injectable });
1290
- /** @nocollapse */ NgxsUnhandledActionsLogger.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: NgxsUnhandledActionsLogger });
1291
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: NgxsUnhandledActionsLogger, decorators: [{
1182
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: NgxsUnhandledActionsLogger, decorators: [{
1292
1183
  type: Injectable
1293
- }], ctorParameters: function () { return [{ type: undefined, decorators: [{
1184
+ }], ctorParameters: () => [{ type: undefined, decorators: [{
1294
1185
  type: Inject,
1295
1186
  args: [NGXS_DEVELOPMENT_OPTIONS]
1296
- }] }]; } });
1187
+ }] }] });
1188
+
1189
+ class NgxsUnhandledErrorHandler {
1190
+ constructor() {
1191
+ this._ngZone = inject(NgZone);
1192
+ this._errorHandler = inject(ErrorHandler);
1193
+ }
1194
+ /**
1195
+ * The `_unhandledErrorContext` is left unused internally since we do not
1196
+ * require it for internal operations. However, developers who wish to provide
1197
+ * their own custom error handler may utilize this context information.
1198
+ */
1199
+ handleError(error, _unhandledErrorContext) {
1200
+ // In order to avoid duplicate error handling, it is necessary to leave
1201
+ // the Angular zone to ensure that errors are not caught twice. The `handleError`
1202
+ // method may contain a `throw error` statement, which is used to re-throw the error.
1203
+ // If the error is re-thrown within the Angular zone, it will be caught again by the
1204
+ // Angular zone. By default, `@angular/core` leaves the Angular zone when invoking
1205
+ // `handleError` (see `_callAndReportToErrorHandler`).
1206
+ this._ngZone.runOutsideAngular(() => this._errorHandler.handleError(error));
1207
+ }
1208
+ /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: NgxsUnhandledErrorHandler, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
1209
+ /** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: NgxsUnhandledErrorHandler, providedIn: 'root' }); }
1210
+ }
1211
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: NgxsUnhandledErrorHandler, decorators: [{
1212
+ type: Injectable,
1213
+ args: [{ providedIn: 'root' }]
1214
+ }] });
1297
1215
 
1298
- const NG_DEV_MODE = typeof ngDevMode === 'undefined' || ngDevMode;
1216
+ const NG_DEV_MODE$3 = typeof ngDevMode !== 'undefined' && ngDevMode;
1217
+ function cloneDefaults(defaults) {
1218
+ let value = defaults === undefined ? {} : defaults;
1219
+ if (defaults) {
1220
+ if (Array.isArray(defaults)) {
1221
+ value = defaults.slice();
1222
+ }
1223
+ else if (typeof defaults === 'object') {
1224
+ value = { ...defaults };
1225
+ }
1226
+ }
1227
+ return value;
1228
+ }
1299
1229
  /**
1300
1230
  * The `StateFactory` class adds root and feature states to the graph.
1301
1231
  * This extracts state names from state classes, checks if they already
@@ -1319,35 +1249,43 @@ class StateFactory {
1319
1249
  this._stateContextFactory = _stateContextFactory;
1320
1250
  this._initialState = _initialState;
1321
1251
  this._actionsSubscription = null;
1252
+ this._propGetter = inject(ɵPROP_GETTER);
1253
+ this._ngxsUnhandledErrorHandler = null;
1322
1254
  this._states = [];
1323
1255
  this._statesByName = {};
1324
1256
  this._statePaths = {};
1325
- this.getRuntimeSelectorContext = memoize(() => {
1257
+ this.getRuntimeSelectorContext = _memoize(() => {
1326
1258
  // eslint-disable-next-line @typescript-eslint/no-this-alias
1327
1259
  const stateFactory = this;
1260
+ const propGetter = stateFactory._propGetter;
1328
1261
  function resolveGetter(key) {
1329
1262
  const path = stateFactory.statePaths[key];
1330
- return path ? propGetter(path.split('.'), stateFactory._config) : null;
1263
+ return path ? propGetter(path.split('.')) : null;
1331
1264
  }
1332
1265
  const context = this._parentFactory
1333
1266
  ? this._parentFactory.getRuntimeSelectorContext()
1334
1267
  : {
1335
1268
  getStateGetter(key) {
1336
- let getter = resolveGetter(key);
1269
+ // Use `@__INLINE__` annotation to forcely inline `resolveGetter`.
1270
+ // This is a Terser annotation, which will function only in the production mode.
1271
+ let getter = /*@__INLINE__*/ resolveGetter(key);
1337
1272
  if (getter) {
1338
1273
  return getter;
1339
1274
  }
1340
1275
  return (...args) => {
1341
1276
  // Late loaded getter
1342
1277
  if (!getter) {
1343
- getter = resolveGetter(key);
1278
+ getter = /*@__INLINE__*/ resolveGetter(key);
1344
1279
  }
1345
1280
  return getter ? getter(...args) : undefined;
1346
1281
  };
1347
1282
  },
1348
1283
  getSelectorOptions(localOptions) {
1349
1284
  const globalSelectorOptions = stateFactory._config.selectorOptions;
1350
- return Object.assign(Object.assign({}, globalSelectorOptions), (localOptions || {}));
1285
+ return {
1286
+ ...globalSelectorOptions,
1287
+ ...(localOptions || {})
1288
+ };
1351
1289
  }
1352
1290
  };
1353
1291
  return context;
@@ -1362,28 +1300,14 @@ class StateFactory {
1362
1300
  get statePaths() {
1363
1301
  return this._parentFactory ? this._parentFactory.statePaths : this._statePaths;
1364
1302
  }
1365
- static _cloneDefaults(defaults) {
1366
- let value = defaults;
1367
- if (Array.isArray(defaults)) {
1368
- value = defaults.slice();
1369
- }
1370
- else if (isObject(defaults)) {
1371
- value = Object.assign({}, defaults);
1372
- }
1373
- else if (defaults === undefined) {
1374
- value = {};
1375
- }
1376
- return value;
1377
- }
1378
1303
  ngOnDestroy() {
1379
- var _a;
1380
- (_a = this._actionsSubscription) === null || _a === void 0 ? void 0 : _a.unsubscribe();
1304
+ this._actionsSubscription?.unsubscribe();
1381
1305
  }
1382
1306
  /**
1383
1307
  * Add a new state to the global defs.
1384
1308
  */
1385
1309
  add(stateClasses) {
1386
- if (NG_DEV_MODE) {
1310
+ if (NG_DEV_MODE$3) {
1387
1311
  ensureStatesAreDecorated(stateClasses);
1388
1312
  }
1389
1313
  const { newStates } = this.addToStatesMap(stateClasses);
@@ -1397,13 +1321,13 @@ class StateFactory {
1397
1321
  for (const name of sortedStates) {
1398
1322
  const stateClass = nameGraph[name];
1399
1323
  const path = paths[name];
1400
- const meta = stateClass[META_KEY];
1324
+ const meta = stateClass[_META_KEY];
1401
1325
  this.addRuntimeInfoToMeta(meta, path);
1402
1326
  // Note: previously we called `ensureStateClassIsInjectable` within the
1403
1327
  // `State` decorator. This check is moved here because the `ɵprov` property
1404
1328
  // will not exist on the class in JIT mode (because it's set asynchronously
1405
1329
  // during JIT compilation through `Object.defineProperty`).
1406
- if (NG_DEV_MODE) {
1330
+ if (NG_DEV_MODE$3) {
1407
1331
  ensureStateClassIsInjectable(stateClass);
1408
1332
  }
1409
1333
  const stateMap = {
@@ -1412,7 +1336,7 @@ class StateFactory {
1412
1336
  isInitialised: false,
1413
1337
  actions: meta.actions,
1414
1338
  instance: this._injector.get(stateClass),
1415
- defaults: StateFactory._cloneDefaults(meta.defaults)
1339
+ defaults: cloneDefaults(meta.defaults)
1416
1340
  };
1417
1341
  // ensure our store hasn't already been added
1418
1342
  // but don't throw since it could be lazy
@@ -1442,10 +1366,19 @@ class StateFactory {
1442
1366
  }
1443
1367
  const dispatched$ = new Subject();
1444
1368
  this._actionsSubscription = this._actions
1445
- .pipe(filter((ctx) => ctx.status === "DISPATCHED" /* Dispatched */), mergeMap(ctx => {
1369
+ .pipe(filter((ctx) => ctx.status === "DISPATCHED" /* ActionStatus.Dispatched */), mergeMap(ctx => {
1446
1370
  dispatched$.next(ctx);
1447
1371
  const action = ctx.action;
1448
- return this.invokeActions(dispatched$, action).pipe(map(() => ({ action, status: "SUCCESSFUL" /* Successful */ })), defaultIfEmpty({ action, status: "CANCELED" /* Canceled */ }), catchError(error => of({ action, status: "ERRORED" /* Errored */, error })));
1372
+ return this.invokeActions(dispatched$, action).pipe(map(() => ({ action, status: "SUCCESSFUL" /* ActionStatus.Successful */ })), defaultIfEmpty({ action, status: "CANCELED" /* ActionStatus.Canceled */ }), catchError(error => {
1373
+ const ngxsUnhandledErrorHandler = (this._ngxsUnhandledErrorHandler ||=
1374
+ this._injector.get(NgxsUnhandledErrorHandler));
1375
+ const handleableError = assignUnhandledCallback(error, () => ngxsUnhandledErrorHandler.handleError(error, { action }));
1376
+ return of({
1377
+ action,
1378
+ status: "ERRORED" /* ActionStatus.Errored */,
1379
+ error: handleableError
1380
+ });
1381
+ }));
1449
1382
  }))
1450
1383
  .subscribe(ctx => this._actionResults.next(ctx));
1451
1384
  }
@@ -1465,7 +1398,13 @@ class StateFactory {
1465
1398
  const stateContext = this._stateContextFactory.createStateContext(metadata);
1466
1399
  try {
1467
1400
  let result = metadata.instance[actionMeta.fn](stateContext, action);
1468
- if (result instanceof Promise) {
1401
+ // We need to use `isPromise` instead of checking whether
1402
+ // `result instanceof Promise`. In zone.js patched environments, `global.Promise`
1403
+ // is the `ZoneAwarePromise`. Some APIs, which are likely not patched by zone.js
1404
+ // for certain reasons, might not work with `instanceof`. For instance, the dynamic
1405
+ // import returns a native promise (not a `ZoneAwarePromise`), causing this check to
1406
+ // be falsy.
1407
+ if (_isPromise(result)) {
1469
1408
  result = from(result);
1470
1409
  }
1471
1410
  if (isObservable(result)) {
@@ -1478,7 +1417,7 @@ class StateFactory {
1478
1417
  // then the action will be canceled.
1479
1418
  // See https://github.com/ngxs/store/issues/1568
1480
1419
  result = result.pipe(mergeMap((value) => {
1481
- if (value instanceof Promise) {
1420
+ if (_isPromise(value)) {
1482
1421
  return from(value);
1483
1422
  }
1484
1423
  if (isObservable(value)) {
@@ -1505,7 +1444,7 @@ class StateFactory {
1505
1444
  }
1506
1445
  // The `NgxsUnhandledActionsLogger` is a tree-shakable class which functions
1507
1446
  // only during development.
1508
- if (NG_DEV_MODE && !actionHasBeenHandled) {
1447
+ if (NG_DEV_MODE$3 && !actionHasBeenHandled) {
1509
1448
  const unhandledActionsLogger = this._injector.get(NgxsUnhandledActionsLogger, null);
1510
1449
  // The `NgxsUnhandledActionsLogger` will not be resolved by the injector if the
1511
1450
  // `NgxsDevelopmentModule` is not provided. It's enough to check whether the `injector.get`
@@ -1523,8 +1462,8 @@ class StateFactory {
1523
1462
  const newStates = [];
1524
1463
  const statesMap = this.statesByName;
1525
1464
  for (const stateClass of stateClasses) {
1526
- const stateName = getStoreMetadata$1(stateClass).name;
1527
- if (NG_DEV_MODE) {
1465
+ const stateName = _getStoreMetadata(stateClass).name;
1466
+ if (NG_DEV_MODE$3) {
1528
1467
  ensureStateNameIsUnique(stateName, stateClass, statesMap);
1529
1468
  }
1530
1469
  const unmountedState = !statesMap[stateName];
@@ -1548,12 +1487,12 @@ class StateFactory {
1548
1487
  // its lifecycle is in 'bootstrapped' state.
1549
1488
  return this.statesByName[name] && valueIsBootstrappedInInitialState;
1550
1489
  }
1490
+ /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: StateFactory, deps: [{ token: i0.Injector }, { token: NgxsConfig }, { token: StateFactory, optional: true, skipSelf: true }, { token: InternalActions }, { token: InternalDispatchedActionResults }, { token: StateContextFactory }, { token: _INITIAL_STATE_TOKEN, optional: true }], target: i0.ɵɵFactoryTarget.Injectable }); }
1491
+ /** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: StateFactory }); }
1551
1492
  }
1552
- /** @nocollapse */ StateFactory.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: StateFactory, deps: [{ token: i0.Injector }, { token: NgxsConfig }, { token: StateFactory, optional: true, skipSelf: true }, { token: InternalActions }, { token: InternalDispatchedActionResults }, { token: StateContextFactory }, { token: INITIAL_STATE_TOKEN, optional: true }], target: i0.ɵɵFactoryTarget.Injectable });
1553
- /** @nocollapse */ StateFactory.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: StateFactory });
1554
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: StateFactory, decorators: [{
1493
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: StateFactory, decorators: [{
1555
1494
  type: Injectable
1556
- }], ctorParameters: function () { return [{ type: i0.Injector }, { type: NgxsConfig }, { type: StateFactory, decorators: [{
1495
+ }], ctorParameters: () => [{ type: i0.Injector }, { type: NgxsConfig }, { type: StateFactory, decorators: [{
1557
1496
  type: Optional
1558
1497
  }, {
1559
1498
  type: SkipSelf
@@ -1561,82 +1500,9 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImpo
1561
1500
  type: Optional
1562
1501
  }, {
1563
1502
  type: Inject,
1564
- args: [INITIAL_STATE_TOKEN]
1565
- }] }]; } });
1566
-
1567
- function createRootSelectorFactory(selectorMetaData, selectors, memoizedSelectorFn) {
1568
- return (context) => {
1569
- const { argumentSelectorFunctions, selectorOptions } = getRuntimeSelectorInfo(context, selectorMetaData, selectors);
1570
- return function selectFromRoot(rootState) {
1571
- // Determine arguments from the app state using the selectors
1572
- const results = argumentSelectorFunctions.map((argFn) => argFn(rootState));
1573
- // if the lambda tries to access a something on the
1574
- // state that doesn't exist, it will throw a TypeError.
1575
- // since this is quite usual behaviour, we simply return undefined if so.
1576
- try {
1577
- return memoizedSelectorFn(...results);
1578
- }
1579
- catch (ex) {
1580
- if (ex instanceof TypeError && selectorOptions.suppressErrors) {
1581
- return undefined;
1582
- }
1583
- throw ex;
1584
- }
1585
- };
1586
- };
1587
- }
1588
- function createMemoizedSelectorFn(originalFn, creationMetadata) {
1589
- const containerClass = creationMetadata && creationMetadata.containerClass;
1590
- const wrappedFn = function wrappedSelectorFn(...args) {
1591
- const returnValue = originalFn.apply(containerClass, args);
1592
- if (returnValue instanceof Function) {
1593
- const innerMemoizedFn = memoize.apply(null, [returnValue]);
1594
- return innerMemoizedFn;
1595
- }
1596
- return returnValue;
1597
- };
1598
- const memoizedFn = memoize(wrappedFn);
1599
- Object.setPrototypeOf(memoizedFn, originalFn);
1600
- return memoizedFn;
1601
- }
1602
- function getRuntimeSelectorInfo(context, selectorMetaData, selectors = []) {
1603
- const localSelectorOptions = selectorMetaData.getSelectorOptions();
1604
- const selectorOptions = context.getSelectorOptions(localSelectorOptions);
1605
- const selectorsToApply = getSelectorsToApply(selectors, selectorOptions, selectorMetaData.containerClass);
1606
- const argumentSelectorFunctions = selectorsToApply.map((selector) => {
1607
- const factory = getRootSelectorFactory(selector);
1608
- return factory(context);
1609
- });
1610
- return {
1611
- selectorOptions,
1612
- argumentSelectorFunctions,
1613
- };
1614
- }
1615
- function getSelectorsToApply(selectors = [], selectorOptions, containerClass) {
1616
- const selectorsToApply = [];
1617
- const canInjectContainerState = selectors.length === 0 || selectorOptions.injectContainerState;
1618
- if (containerClass && canInjectContainerState) {
1619
- // If we are on a state class, add it as the first selector parameter
1620
- const metadata = getStoreMetadata$1(containerClass);
1621
- if (metadata) {
1622
- selectorsToApply.push(containerClass);
1623
- }
1624
- }
1625
- if (selectors) {
1626
- selectorsToApply.push(...selectors);
1627
- }
1628
- return selectorsToApply;
1629
- }
1630
- /**
1631
- * This function gets the factory function to create the selector to get the selected slice from the app state
1632
- * @ignore
1633
- */
1634
- function getRootSelectorFactory(selector) {
1635
- const metadata = getSelectorMetadata$1(selector) || getStoreMetadata$1(selector);
1636
- return (metadata && metadata.makeRootSelector) || (() => selector);
1637
- }
1503
+ args: [_INITIAL_STATE_TOKEN]
1504
+ }] }] });
1638
1505
 
1639
- // tslint:disable:unified-signatures
1640
1506
  class Store {
1641
1507
  constructor(_stateStream, _internalStateOperations, _config, _internalExecutionStrategy, _stateFactory, initialStateValue) {
1642
1508
  this._stateStream = _stateStream;
@@ -1658,25 +1524,40 @@ class Store {
1658
1524
  dispatch(actionOrActions) {
1659
1525
  return this._internalStateOperations.getRootStateOperations().dispatch(actionOrActions);
1660
1526
  }
1527
+ /**
1528
+ * Selects a slice of data from the store.
1529
+ */
1661
1530
  select(selector) {
1662
1531
  const selectorFn = this.getStoreBoundSelectorFn(selector);
1663
- return this._selectableStateStream.pipe(map(selectorFn), catchError((err) => {
1532
+ return this._selectableStateStream.pipe(map(selectorFn), catchError((error) => {
1664
1533
  // if error is TypeError we swallow it to prevent usual errors with property access
1665
- const { suppressErrors } = this._config.selectorOptions;
1666
- if (err instanceof TypeError && suppressErrors) {
1534
+ if (this._config.selectorOptions.suppressErrors && error instanceof TypeError) {
1667
1535
  return of(undefined);
1668
1536
  }
1669
1537
  // rethrow other errors
1670
- return throwError(err);
1538
+ return throwError(error);
1671
1539
  }), distinctUntilChanged(), leaveNgxs(this._internalExecutionStrategy));
1672
1540
  }
1541
+ /**
1542
+ * Select one slice of data from the store.
1543
+ */
1673
1544
  selectOnce(selector) {
1674
1545
  return this.select(selector).pipe(take(1));
1675
1546
  }
1547
+ /**
1548
+ * Select a snapshot from the state.
1549
+ */
1676
1550
  selectSnapshot(selector) {
1677
1551
  const selectorFn = this.getStoreBoundSelectorFn(selector);
1678
1552
  return selectorFn(this._stateStream.getValue());
1679
1553
  }
1554
+ /**
1555
+ * Select a signal from the state.
1556
+ */
1557
+ selectSignal(selector) {
1558
+ const selectorFn = this.getStoreBoundSelectorFn(selector);
1559
+ return computed(() => selectorFn(this._stateStream.state()));
1560
+ }
1680
1561
  /**
1681
1562
  * Allow the user to subscribe to the root of the state
1682
1563
  */
@@ -1696,7 +1577,7 @@ class Store {
1696
1577
  * for plugin's who need to modify the state directly or unit testing.
1697
1578
  */
1698
1579
  reset(state) {
1699
- return this._internalStateOperations.getRootStateOperations().setState(state);
1580
+ this._internalStateOperations.getRootStateOperations().setState(state);
1700
1581
  }
1701
1582
  getStoreBoundSelectorFn(selector) {
1702
1583
  const makeSelectorFn = getRootSelectorFactory(selector);
@@ -1707,30 +1588,60 @@ class Store {
1707
1588
  const value = this._stateStream.value;
1708
1589
  const storeIsEmpty = !value || Object.keys(value).length === 0;
1709
1590
  if (storeIsEmpty) {
1710
- const defaultStateNotEmpty = Object.keys(this._config.defaultsState).length > 0;
1711
- const storeValues = defaultStateNotEmpty
1712
- ? Object.assign(Object.assign({}, this._config.defaultsState), initialStateValue) : initialStateValue;
1713
- this._stateStream.next(storeValues);
1591
+ this._stateStream.next(initialStateValue);
1714
1592
  }
1715
1593
  }
1594
+ /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: Store, deps: [{ token: i1.ɵStateStream }, { token: InternalStateOperations }, { token: NgxsConfig }, { token: InternalNgxsExecutionStrategy }, { token: StateFactory }, { token: _INITIAL_STATE_TOKEN, optional: true }], target: i0.ɵɵFactoryTarget.Injectable }); }
1595
+ /** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: Store, providedIn: 'root' }); }
1716
1596
  }
1717
- /** @nocollapse */ Store.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: Store, deps: [{ token: StateStream }, { token: InternalStateOperations }, { token: NgxsConfig }, { token: InternalNgxsExecutionStrategy }, { token: StateFactory }, { token: INITIAL_STATE_TOKEN, optional: true }], target: i0.ɵɵFactoryTarget.Injectable });
1718
- /** @nocollapse */ Store.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: Store, providedIn: 'root' });
1719
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: Store, decorators: [{
1597
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: Store, decorators: [{
1720
1598
  type: Injectable,
1721
1599
  args: [{ providedIn: 'root' }]
1722
- }], ctorParameters: function () { return [{ type: StateStream }, { type: InternalStateOperations }, { type: NgxsConfig }, { type: InternalNgxsExecutionStrategy }, { type: StateFactory }, { type: undefined, decorators: [{
1600
+ }], ctorParameters: () => [{ type: i1.ɵStateStream }, { type: InternalStateOperations }, { type: NgxsConfig }, { type: InternalNgxsExecutionStrategy }, { type: StateFactory }, { type: undefined, decorators: [{
1723
1601
  type: Optional
1724
1602
  }, {
1725
1603
  type: Inject,
1726
- args: [INITIAL_STATE_TOKEN]
1727
- }] }]; } });
1604
+ args: [_INITIAL_STATE_TOKEN]
1605
+ }] }] });
1606
+
1607
+ const NG_DEV_MODE$2 = typeof ngDevMode !== 'undefined' && ngDevMode;
1608
+ /**
1609
+ * InjectionToken that registers preboot functions (called before the root initializer).
1610
+ */
1611
+ const NGXS_PREBOOT_FNS = new InjectionToken(NG_DEV_MODE$2 ? 'NGXS_PREBOOT_FNS' : '');
1612
+ /**
1613
+ * This function registers a preboot function which will be called before the root
1614
+ * store initializer is run, but after all of the NGXS features are provided and
1615
+ * available for injection. This is useful for registering action stream listeners
1616
+ * before any action is dispatched.
1617
+ *
1618
+ * ```ts
1619
+ * bootstrapApplication(AppComponent, {
1620
+ * providers: [
1621
+ * provideStore(
1622
+ * [CountriesState],
1623
+ * withNgxsPreboot(() => {
1624
+ * const actions$ = inject(Actions);
1625
+ * actions$.subscribe(ctx => console.log(ctx));
1626
+ * })
1627
+ * )
1628
+ * ]
1629
+ * });
1630
+ * ```
1631
+ */
1632
+ function withNgxsPreboot(prebootFn) {
1633
+ return makeEnvironmentProviders([
1634
+ { provide: NGXS_PREBOOT_FNS, multi: true, useValue: prebootFn }
1635
+ ]);
1636
+ }
1728
1637
 
1729
1638
  /**
1730
1639
  * Allows the select decorator to get access to the DI store, this is used internally
1731
1640
  * in `@Select` decorator.
1732
1641
  */
1733
1642
  class SelectFactory {
1643
+ static { this.store = null; }
1644
+ static { this.config = null; }
1734
1645
  constructor(store, config) {
1735
1646
  SelectFactory.store = store;
1736
1647
  SelectFactory.config = config;
@@ -1739,40 +1650,46 @@ class SelectFactory {
1739
1650
  SelectFactory.store = null;
1740
1651
  SelectFactory.config = null;
1741
1652
  }
1653
+ /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: SelectFactory, deps: [{ token: Store }, { token: NgxsConfig }], target: i0.ɵɵFactoryTarget.Injectable }); }
1654
+ /** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: SelectFactory, providedIn: 'root' }); }
1742
1655
  }
1743
- SelectFactory.store = null;
1744
- SelectFactory.config = null;
1745
- /** @nocollapse */ SelectFactory.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: SelectFactory, deps: [{ token: Store }, { token: NgxsConfig }], target: i0.ɵɵFactoryTarget.Injectable });
1746
- /** @nocollapse */ SelectFactory.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: SelectFactory, providedIn: 'root' });
1747
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: SelectFactory, decorators: [{
1656
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: SelectFactory, decorators: [{
1748
1657
  type: Injectable,
1749
1658
  args: [{ providedIn: 'root' }]
1750
- }], ctorParameters: function () { return [{ type: Store }, { type: NgxsConfig }]; } });
1659
+ }], ctorParameters: () => [{ type: Store }, { type: NgxsConfig }] });
1751
1660
 
1661
+ const NG_DEV_MODE$1 = typeof ngDevMode !== 'undefined' && ngDevMode;
1752
1662
  class LifecycleStateManager {
1753
- constructor(_store, _internalErrorReporter, _internalStateOperations, _stateContextFactory, _bootstrapper) {
1663
+ constructor(_store, _internalStateOperations, _stateContextFactory, _appBootstrappedState) {
1754
1664
  this._store = _store;
1755
- this._internalErrorReporter = _internalErrorReporter;
1756
1665
  this._internalStateOperations = _internalStateOperations;
1757
1666
  this._stateContextFactory = _stateContextFactory;
1758
- this._bootstrapper = _bootstrapper;
1759
- this._destroy$ = new Subject();
1667
+ this._appBootstrappedState = _appBootstrappedState;
1668
+ this._destroy$ = new ReplaySubject(1);
1760
1669
  }
1761
1670
  ngOnDestroy() {
1762
1671
  this._destroy$.next();
1763
1672
  }
1764
1673
  ngxsBootstrap(action, results) {
1674
+ if (NG_DEV_MODE$1) {
1675
+ if (action instanceof InitState) {
1676
+ this._initStateHasBeenDispatched = true;
1677
+ }
1678
+ else if (
1679
+ // This is a dev mode-only check that ensures the correct order of
1680
+ // state initialization. The `NgxsModule.forRoot` or `provideStore` should
1681
+ // always come first, followed by `forFeature` and `provideStates`. If the
1682
+ // `UpdateState` is dispatched before the `InitState` is dispatched, it indicates
1683
+ // that modules or providers are in an invalid order.
1684
+ action instanceof UpdateState &&
1685
+ !this._initStateHasBeenDispatched) {
1686
+ console.error(getInvalidInitializationOrderMessage(action.addedStates));
1687
+ }
1688
+ }
1765
1689
  this._internalStateOperations
1766
1690
  .getRootStateOperations()
1767
1691
  .dispatch(action)
1768
- .pipe(filter(() => !!results), tap(() => this._invokeInitOnStates(results.states)), mergeMap(() => this._bootstrapper.appBootstrapped$), filter(appBootstrapped => !!appBootstrapped), catchError(error => {
1769
- // The `SafeSubscriber` (which is used by most RxJS operators) re-throws
1770
- // errors asynchronously (`setTimeout(() => { throw error })`). This might
1771
- // break existing user's code or unit tests. We catch the error manually to
1772
- // be backward compatible with the old behavior.
1773
- this._internalErrorReporter.reportErrorSafely(error);
1774
- return EMPTY;
1775
- }), takeUntil(this._destroy$))
1692
+ .pipe(filter(() => !!results), tap(() => this._invokeInitOnStates(results.states)), mergeMap(() => this._appBootstrappedState), filter(appBootstrapped => !!appBootstrapped), takeUntil(this._destroy$))
1776
1693
  .subscribe(() => this._invokeBootstrapOnStates(results.states));
1777
1694
  }
1778
1695
  _invokeInitOnStates(mappedStores) {
@@ -1804,170 +1721,218 @@ class LifecycleStateManager {
1804
1721
  _getStateContext(mappedStore) {
1805
1722
  return this._stateContextFactory.createStateContext(mappedStore);
1806
1723
  }
1724
+ /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: LifecycleStateManager, deps: [{ token: Store }, { token: InternalStateOperations }, { token: StateContextFactory }, { token: i1.ɵNgxsAppBootstrappedState }], target: i0.ɵɵFactoryTarget.Injectable }); }
1725
+ /** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: LifecycleStateManager, providedIn: 'root' }); }
1807
1726
  }
1808
- /** @nocollapse */ LifecycleStateManager.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: LifecycleStateManager, deps: [{ token: Store }, { token: InternalErrorReporter }, { token: InternalStateOperations }, { token: StateContextFactory }, { token: i5.NgxsBootstrapper }], target: i0.ɵɵFactoryTarget.Injectable });
1809
- /** @nocollapse */ LifecycleStateManager.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: LifecycleStateManager, providedIn: 'root' });
1810
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: LifecycleStateManager, decorators: [{
1727
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: LifecycleStateManager, decorators: [{
1811
1728
  type: Injectable,
1812
1729
  args: [{ providedIn: 'root' }]
1813
- }], ctorParameters: function () { return [{ type: Store }, { type: InternalErrorReporter }, { type: InternalStateOperations }, { type: StateContextFactory }, { type: i5.NgxsBootstrapper }]; } });
1730
+ }], ctorParameters: () => [{ type: Store }, { type: InternalStateOperations }, { type: StateContextFactory }, { type: i1.ɵNgxsAppBootstrappedState }] });
1731
+
1732
+ const NG_DEV_MODE = typeof ngDevMode !== 'undefined' && ngDevMode;
1733
+ /**
1734
+ * This function is shared by both NgModule and standalone features.
1735
+ * When using `NgxsModule.forRoot` and `provideStore`, we can depend on the
1736
+ * same initialization functionality.
1737
+ */
1738
+ function rootStoreInitializer() {
1739
+ const prebootFns = inject(NGXS_PREBOOT_FNS, { optional: true }) || [];
1740
+ prebootFns.forEach(prebootFn => prebootFn());
1741
+ const factory = inject(StateFactory);
1742
+ const internalStateOperations = inject(InternalStateOperations);
1743
+ inject(Store);
1744
+ inject(SelectFactory);
1745
+ const states = inject(ROOT_STATE_TOKEN, { optional: true }) || [];
1746
+ const lifecycleStateManager = inject(LifecycleStateManager);
1747
+ // Add stores to the state graph and return their defaults.
1748
+ const results = factory.addAndReturnDefaults(states);
1749
+ internalStateOperations.setStateToTheCurrentWithNew(results);
1750
+ // Connect our actions stream.
1751
+ factory.connectActionHandlers();
1752
+ // Dispatch the init action and invoke init and bootstrap functions after.
1753
+ lifecycleStateManager.ngxsBootstrap(new InitState(), results);
1754
+ }
1755
+ /**
1756
+ * This function is utilized by both NgModule and standalone features.
1757
+ * When using `NgxsModule.forFeature` and `provideStates`, we can depend on
1758
+ * the same initialization functionality.
1759
+ */
1760
+ function featureStatesInitializer() {
1761
+ inject(Store);
1762
+ const internalStateOperations = inject(InternalStateOperations);
1763
+ const factory = inject(StateFactory);
1764
+ const states = inject(FEATURE_STATE_TOKEN, { optional: true }) || [];
1765
+ const lifecycleStateManager = inject(LifecycleStateManager);
1766
+ // Since FEATURE_STATE_TOKEN is a multi token, we need to
1767
+ // flatten it [[Feature1State, Feature2State], [Feature3State]].
1768
+ const flattenedStates = states.reduce((total, values) => total.concat(values), []);
1769
+ // add stores to the state graph and return their defaults.
1770
+ const results = factory.addAndReturnDefaults(flattenedStates);
1771
+ if (results.states.length) {
1772
+ internalStateOperations.setStateToTheCurrentWithNew(results);
1773
+ // Dispatch the update action and invoke init and bootstrap functions after.
1774
+ lifecycleStateManager.ngxsBootstrap(new UpdateState(results.defaults), results);
1775
+ }
1776
+ }
1777
+ /**
1778
+ * InjectionToken that registers the global Store.
1779
+ */
1780
+ const NGXS_ROOT_STORE_INITIALIZER = new InjectionToken(NG_DEV_MODE ? 'NGXS_ROOT_STORE_INITIALIZER' : '');
1781
+ /**
1782
+ * InjectionToken that registers feature states.
1783
+ */
1784
+ const NGXS_FEATURE_STORE_INITIALIZER = new InjectionToken(NG_DEV_MODE ? 'NGXS_FEATURE_STORE_INITIALIZER' : '');
1785
+ const NGXS_ROOT_ENVIRONMENT_INITIALIZER = [
1786
+ { provide: NGXS_ROOT_STORE_INITIALIZER, useFactory: rootStoreInitializer },
1787
+ {
1788
+ provide: ENVIRONMENT_INITIALIZER,
1789
+ multi: true,
1790
+ useFactory() {
1791
+ return () => inject(NGXS_ROOT_STORE_INITIALIZER);
1792
+ }
1793
+ }
1794
+ ];
1795
+ /**
1796
+ * The `NGXS_FEATURE_ENVIRONMENT_INITIALIZER` functions as an environment initializer
1797
+ * at the `Route` level. Angular Router creates an environment route injector for each
1798
+ * matched route where navigation occurs. The injector is created once, ensuring that
1799
+ * the feature states initialization only happens once as well.
1800
+ */
1801
+ const NGXS_FEATURE_ENVIRONMENT_INITIALIZER = [
1802
+ { provide: NGXS_FEATURE_STORE_INITIALIZER, useFactory: featureStatesInitializer },
1803
+ {
1804
+ provide: ENVIRONMENT_INITIALIZER,
1805
+ multi: true,
1806
+ useFactory() {
1807
+ return () => inject(NGXS_FEATURE_STORE_INITIALIZER);
1808
+ }
1809
+ }
1810
+ ];
1814
1811
 
1815
1812
  /**
1816
- * Root module
1817
1813
  * @ignore
1818
1814
  */
1819
1815
  class NgxsRootModule {
1820
- constructor(factory, internalStateOperations, _store, _select, states = [], lifecycleStateManager) {
1821
- // Add stores to the state graph and return their defaults
1822
- const results = factory.addAndReturnDefaults(states);
1823
- internalStateOperations.setStateToTheCurrentWithNew(results);
1824
- // Connect our actions stream
1825
- factory.connectActionHandlers();
1826
- // Dispatch the init action and invoke init and bootstrap functions after
1827
- lifecycleStateManager.ngxsBootstrap(new InitState(), results);
1816
+ constructor() {
1817
+ rootStoreInitializer();
1828
1818
  }
1819
+ /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: NgxsRootModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
1820
+ /** @nocollapse */ static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "17.3.3", ngImport: i0, type: NgxsRootModule }); }
1821
+ /** @nocollapse */ static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: NgxsRootModule }); }
1829
1822
  }
1830
- /** @nocollapse */ NgxsRootModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: NgxsRootModule, deps: [{ token: StateFactory }, { token: InternalStateOperations }, { token: Store }, { token: SelectFactory }, { token: ROOT_STATE_TOKEN, optional: true }, { token: LifecycleStateManager }], target: i0.ɵɵFactoryTarget.NgModule });
1831
- /** @nocollapse */ NgxsRootModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: NgxsRootModule });
1832
- /** @nocollapse */ NgxsRootModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: NgxsRootModule });
1833
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: NgxsRootModule, decorators: [{
1823
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: NgxsRootModule, decorators: [{
1834
1824
  type: NgModule
1835
- }], ctorParameters: function () { return [{ type: StateFactory }, { type: InternalStateOperations }, { type: Store }, { type: SelectFactory }, { type: undefined, decorators: [{
1836
- type: Optional
1837
- }, {
1838
- type: Inject,
1839
- args: [ROOT_STATE_TOKEN]
1840
- }] }, { type: LifecycleStateManager }]; } });
1825
+ }], ctorParameters: () => [] });
1841
1826
 
1842
1827
  /**
1843
- * Feature module
1844
1828
  * @ignore
1845
1829
  */
1846
1830
  class NgxsFeatureModule {
1847
- constructor(_store, internalStateOperations, factory, states = [], lifecycleStateManager) {
1848
- // Since FEATURE_STATE_TOKEN is a multi token, we need to
1849
- // flatten it [[Feature1State, Feature2State], [Feature3State]]
1850
- const flattenedStates = NgxsFeatureModule.flattenStates(states);
1851
- // add stores to the state graph and return their defaults
1852
- const results = factory.addAndReturnDefaults(flattenedStates);
1853
- if (results.states.length) {
1854
- internalStateOperations.setStateToTheCurrentWithNew(results);
1855
- // dispatch the update action and invoke init and bootstrap functions after
1856
- lifecycleStateManager.ngxsBootstrap(new UpdateState(results.defaults), results);
1857
- }
1858
- }
1859
- static flattenStates(states = []) {
1860
- return states.reduce((total, values) => total.concat(values), []);
1831
+ constructor() {
1832
+ featureStatesInitializer();
1861
1833
  }
1834
+ /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: NgxsFeatureModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
1835
+ /** @nocollapse */ static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "17.3.3", ngImport: i0, type: NgxsFeatureModule }); }
1836
+ /** @nocollapse */ static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: NgxsFeatureModule }); }
1862
1837
  }
1863
- /** @nocollapse */ NgxsFeatureModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: NgxsFeatureModule, deps: [{ token: Store }, { token: InternalStateOperations }, { token: StateFactory }, { token: FEATURE_STATE_TOKEN, optional: true }, { token: LifecycleStateManager }], target: i0.ɵɵFactoryTarget.NgModule });
1864
- /** @nocollapse */ NgxsFeatureModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: NgxsFeatureModule });
1865
- /** @nocollapse */ NgxsFeatureModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: NgxsFeatureModule });
1866
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: NgxsFeatureModule, decorators: [{
1838
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: NgxsFeatureModule, decorators: [{
1867
1839
  type: NgModule
1868
- }], ctorParameters: function () { return [{ type: Store }, { type: InternalStateOperations }, { type: StateFactory }, { type: undefined, decorators: [{
1869
- type: Optional
1870
- }, {
1871
- type: Inject,
1872
- args: [FEATURE_STATE_TOKEN]
1873
- }] }, { type: LifecycleStateManager }]; } });
1840
+ }], ctorParameters: () => [] });
1841
+
1842
+ /**
1843
+ * This function provides the required providers when invoking `NgxsModule.forRoot`
1844
+ * or `provideStore`. It is shared between the NgModule and standalone APIs.
1845
+ */
1846
+ function getRootProviders(states, options) {
1847
+ return [
1848
+ StateFactory,
1849
+ PluginManager,
1850
+ ...states,
1851
+ {
1852
+ provide: ROOT_STATE_TOKEN,
1853
+ useValue: states
1854
+ },
1855
+ {
1856
+ provide: APP_BOOTSTRAP_LISTENER,
1857
+ useFactory: () => {
1858
+ const appBootstrappedState = inject(_NgxsAppBootstrappedState);
1859
+ return () => appBootstrappedState.bootstrap();
1860
+ },
1861
+ multi: true
1862
+ },
1863
+ {
1864
+ provide: NGXS_OPTIONS,
1865
+ useValue: options
1866
+ },
1867
+ {
1868
+ provide: CUSTOM_NGXS_EXECUTION_STRATEGY,
1869
+ useValue: options.executionStrategy
1870
+ },
1871
+ {
1872
+ provide: _NGXS_STATE_CONTEXT_FACTORY,
1873
+ useExisting: StateContextFactory
1874
+ },
1875
+ {
1876
+ provide: _NGXS_STATE_FACTORY,
1877
+ useExisting: StateFactory
1878
+ }
1879
+ ];
1880
+ }
1874
1881
 
1875
1882
  /**
1876
- * Ngxs Module
1883
+ * This function provides the required providers when calling `NgxsModule.forFeature`
1884
+ * or `provideStates`. It is shared between the NgModule and standalone APIs.
1877
1885
  */
1886
+ function getFeatureProviders(states) {
1887
+ return [
1888
+ StateFactory,
1889
+ PluginManager,
1890
+ ...states,
1891
+ {
1892
+ provide: FEATURE_STATE_TOKEN,
1893
+ multi: true,
1894
+ useValue: states
1895
+ }
1896
+ ];
1897
+ }
1898
+
1878
1899
  class NgxsModule {
1879
- /**
1880
- * Root module factory
1881
- */
1882
1900
  static forRoot(states = [], options = {}) {
1883
1901
  return {
1884
1902
  ngModule: NgxsRootModule,
1885
- providers: [
1886
- StateFactory,
1887
- PluginManager,
1888
- ...states,
1889
- ...NgxsModule.ngxsTokenProviders(states, options)
1890
- ]
1903
+ providers: getRootProviders(states, options)
1891
1904
  };
1892
1905
  }
1893
- /**
1894
- * Feature module factory
1895
- */
1896
1906
  static forFeature(states = []) {
1897
1907
  return {
1898
1908
  ngModule: NgxsFeatureModule,
1899
- providers: [
1900
- // This is required on the feature level, see comments in `state-factory.ts`.
1901
- StateFactory,
1902
- PluginManager,
1903
- ...states,
1904
- {
1905
- provide: FEATURE_STATE_TOKEN,
1906
- multi: true,
1907
- useValue: states
1908
- }
1909
- ]
1909
+ providers: getFeatureProviders(states)
1910
1910
  };
1911
1911
  }
1912
- static ngxsTokenProviders(states, options) {
1913
- return [
1914
- {
1915
- provide: USER_PROVIDED_NGXS_EXECUTION_STRATEGY,
1916
- useValue: options.executionStrategy
1917
- },
1918
- {
1919
- provide: ROOT_STATE_TOKEN,
1920
- useValue: states
1921
- },
1922
- {
1923
- provide: ROOT_OPTIONS,
1924
- useValue: options
1925
- },
1926
- {
1927
- provide: APP_BOOTSTRAP_LISTENER,
1928
- useFactory: NgxsModule.appBootstrapListenerFactory,
1929
- multi: true,
1930
- deps: [NgxsBootstrapper]
1931
- },
1932
- {
1933
- provide: ɵNGXS_STATE_CONTEXT_FACTORY,
1934
- useExisting: StateContextFactory
1935
- },
1936
- {
1937
- provide: ɵNGXS_STATE_FACTORY,
1938
- useExisting: StateFactory
1939
- }
1940
- ];
1941
- }
1942
- static appBootstrapListenerFactory(bootstrapper) {
1943
- return () => bootstrapper.bootstrap();
1944
- }
1912
+ /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: NgxsModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
1913
+ /** @nocollapse */ static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "17.3.3", ngImport: i0, type: NgxsModule }); }
1914
+ /** @nocollapse */ static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: NgxsModule }); }
1945
1915
  }
1946
- /** @nocollapse */ NgxsModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: NgxsModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
1947
- /** @nocollapse */ NgxsModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: NgxsModule });
1948
- /** @nocollapse */ NgxsModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: NgxsModule });
1949
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: NgxsModule, decorators: [{
1916
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: NgxsModule, decorators: [{
1950
1917
  type: NgModule
1951
1918
  }] });
1952
1919
 
1953
1920
  /**
1954
- * Decorates a method with a action information.
1921
+ * Decorates a method with action information.
1955
1922
  */
1956
1923
  function Action(actions, options) {
1957
- return (target, name) => {
1958
- // Caretaker note: we have still left the `typeof` condition in order to avoid
1959
- // creating a breaking change for projects that still use the View Engine.
1960
- if (typeof ngDevMode === 'undefined' || ngDevMode) {
1924
+ return (target, name,
1925
+ // This parameter ensures that the decorated method has a call signature that could be passed an instance of the given action(s).
1926
+ _descriptor) => {
1927
+ if (typeof ngDevMode !== 'undefined' && ngDevMode) {
1961
1928
  const isStaticMethod = target.hasOwnProperty('prototype');
1962
1929
  if (isStaticMethod) {
1963
1930
  throwActionDecoratorError();
1964
1931
  }
1965
1932
  }
1966
- const meta = ensureStoreMetadata$1(target.constructor);
1967
- if (!Array.isArray(actions)) {
1968
- actions = [actions];
1969
- }
1970
- for (const action of actions) {
1933
+ const meta = _ensureStoreMetadata(target.constructor);
1934
+ const actionArray = Array.isArray(actions) ? actions : [actions];
1935
+ for (const action of actionArray) {
1971
1936
  const type = action.type;
1972
1937
  if (!meta.actions[type]) {
1973
1938
  meta.actions[type] = [];
@@ -1987,27 +1952,27 @@ function Action(actions, options) {
1987
1952
  function State(options) {
1988
1953
  return (target) => {
1989
1954
  const stateClass = target;
1990
- const meta = ensureStoreMetadata$1(stateClass);
1955
+ const meta = _ensureStoreMetadata(stateClass);
1991
1956
  const inheritedStateClass = Object.getPrototypeOf(stateClass);
1992
1957
  const optionsWithInheritance = getStateOptions(inheritedStateClass, options);
1993
1958
  mutateMetaData({ meta, inheritedStateClass, optionsWithInheritance });
1994
- stateClass[META_OPTIONS_KEY] = optionsWithInheritance;
1959
+ stateClass[_META_OPTIONS_KEY] = optionsWithInheritance;
1995
1960
  };
1996
1961
  }
1997
1962
  function getStateOptions(inheritedStateClass, options) {
1998
- const inheritanceOptions = inheritedStateClass[META_OPTIONS_KEY] || {};
1999
- return Object.assign(Object.assign({}, inheritanceOptions), options);
1963
+ const inheritanceOptions = inheritedStateClass[_META_OPTIONS_KEY] || {};
1964
+ return { ...inheritanceOptions, ...options };
2000
1965
  }
2001
1966
  function mutateMetaData(params) {
2002
1967
  const { meta, inheritedStateClass, optionsWithInheritance } = params;
2003
1968
  const { children, defaults, name } = optionsWithInheritance;
2004
1969
  const stateName = typeof name === 'string' ? name : (name && name.getName()) || null;
2005
- if (typeof ngDevMode === 'undefined' || ngDevMode) {
1970
+ if (typeof ngDevMode !== 'undefined' && ngDevMode) {
2006
1971
  ensureStateNameIsValid(stateName);
2007
1972
  }
2008
- if (inheritedStateClass.hasOwnProperty(META_KEY)) {
2009
- const inheritedMeta = inheritedStateClass[META_KEY] || {};
2010
- meta.actions = Object.assign(Object.assign({}, meta.actions), inheritedMeta.actions);
1973
+ if (inheritedStateClass.hasOwnProperty(_META_KEY)) {
1974
+ const inheritedMeta = inheritedStateClass[_META_KEY] || {};
1975
+ meta.actions = { ...meta.actions, ...inheritedMeta.actions };
2011
1976
  }
2012
1977
  meta.children = children;
2013
1978
  meta.defaults = defaults;
@@ -2042,6 +2007,9 @@ function removeDollarAtTheEnd(name) {
2042
2007
 
2043
2008
  /**
2044
2009
  * Decorator for selecting a slice of state from the store.
2010
+ *
2011
+ * @deprecated
2012
+ * Read the deprecation notice at this link: https://ngxs.io/deprecations/select-decorator-deprecation.
2045
2013
  */
2046
2014
  function Select(rawSelector, ...paths) {
2047
2015
  return function (target, key) {
@@ -2074,10 +2042,10 @@ const selectorOptionsMetaAccessor = {
2074
2042
  if (!target)
2075
2043
  return;
2076
2044
  target[SELECTOR_OPTIONS_META_KEY] = options;
2077
- },
2045
+ }
2078
2046
  };
2079
2047
  function setupSelectorMetadata(originalFn, creationMetadata) {
2080
- const selectorMetaData = ensureSelectorMetadata$1(originalFn);
2048
+ const selectorMetaData = _ensureSelectorMetadata(originalFn);
2081
2049
  selectorMetaData.originalFn = originalFn;
2082
2050
  let getExplicitSelectorOptions = () => ({});
2083
2051
  if (creationMetadata) {
@@ -2086,12 +2054,17 @@ function setupSelectorMetadata(originalFn, creationMetadata) {
2086
2054
  getExplicitSelectorOptions =
2087
2055
  creationMetadata.getSelectorOptions || getExplicitSelectorOptions;
2088
2056
  }
2089
- const selectorMetaDataClone = Object.assign({}, selectorMetaData);
2057
+ const selectorMetaDataClone = { ...selectorMetaData };
2090
2058
  selectorMetaData.getSelectorOptions = () => getLocalSelectorOptions(selectorMetaDataClone, getExplicitSelectorOptions());
2091
2059
  return selectorMetaData;
2092
2060
  }
2093
2061
  function getLocalSelectorOptions(selectorMetaData, explicitOptions) {
2094
- return Object.assign(Object.assign(Object.assign(Object.assign({}, (selectorOptionsMetaAccessor.getOptions(selectorMetaData.containerClass) || {})), (selectorOptionsMetaAccessor.getOptions(selectorMetaData.originalFn) || {})), (selectorMetaData.getSelectorOptions() || {})), explicitOptions);
2062
+ return {
2063
+ ...(selectorOptionsMetaAccessor.getOptions(selectorMetaData.containerClass) || {}),
2064
+ ...(selectorOptionsMetaAccessor.getOptions(selectorMetaData.originalFn) || {}),
2065
+ ...(selectorMetaData.getSelectorOptions() || {}),
2066
+ ...explicitOptions
2067
+ };
2095
2068
  }
2096
2069
 
2097
2070
  /**
@@ -2100,7 +2073,7 @@ function getLocalSelectorOptions(selectorMetaData, explicitOptions) {
2100
2073
  function SelectorOptions(options) {
2101
2074
  return (function decorate(target, methodName, descriptor) {
2102
2075
  if (methodName) {
2103
- descriptor || (descriptor = Object.getOwnPropertyDescriptor(target, methodName));
2076
+ descriptor ||= Object.getOwnPropertyDescriptor(target, methodName);
2104
2077
  // Method Decorator
2105
2078
  const originalFn = descriptor.value || descriptor.originalFn;
2106
2079
  if (originalFn) {
@@ -2114,19 +2087,6 @@ function SelectorOptions(options) {
2114
2087
  });
2115
2088
  }
2116
2089
 
2117
- function ensureStoreMetadata(target) {
2118
- return ensureStoreMetadata$1(target);
2119
- }
2120
- function getStoreMetadata(target) {
2121
- return getStoreMetadata$1(target);
2122
- }
2123
- function ensureSelectorMetadata(target) {
2124
- return ensureSelectorMetadata$1(target);
2125
- }
2126
- function getSelectorMetadata(target) {
2127
- return getSelectorMetadata$1(target);
2128
- }
2129
-
2130
2090
  function createSelector(selectors, projector, creationMetadata) {
2131
2091
  const memoizedFn = createMemoizedSelectorFn(projector, creationMetadata);
2132
2092
  const selectorMetaData = setupSelectorMetadata(projector, creationMetadata);
@@ -2136,11 +2096,9 @@ function createSelector(selectors, projector, creationMetadata) {
2136
2096
 
2137
2097
  function Selector(selectors) {
2138
2098
  return (target, key, descriptor) => {
2139
- descriptor || (descriptor = Object.getOwnPropertyDescriptor(target, key));
2140
- const originalFn = descriptor === null || descriptor === void 0 ? void 0 : descriptor.value;
2141
- // Caretaker note: we have still left the `typeof` condition in order to avoid
2142
- // creating a breaking change for projects that still use the View Engine.
2143
- if (typeof ngDevMode === 'undefined' || ngDevMode) {
2099
+ descriptor ||= Object.getOwnPropertyDescriptor(target, key);
2100
+ const originalFn = descriptor?.value;
2101
+ if (typeof ngDevMode !== 'undefined' && ngDevMode) {
2144
2102
  if (originalFn && typeof originalFn !== 'function') {
2145
2103
  throwSelectorDecoratorError();
2146
2104
  }
@@ -2150,36 +2108,19 @@ function Selector(selectors) {
2150
2108
  selectorName: key.toString(),
2151
2109
  getSelectorOptions() {
2152
2110
  return {};
2153
- },
2111
+ }
2154
2112
  });
2155
2113
  const newDescriptor = {
2156
2114
  configurable: true,
2157
2115
  get() {
2158
2116
  return memoizedFn;
2159
2117
  },
2118
+ originalFn
2160
2119
  };
2161
- // Add hidden property to descriptor
2162
- newDescriptor['originalFn'] = originalFn;
2163
2120
  return newDescriptor;
2164
2121
  };
2165
2122
  }
2166
2123
 
2167
- class StateToken {
2168
- constructor(name) {
2169
- this.name = name;
2170
- const selectorMetadata = ensureSelectorMetadata$1(this);
2171
- selectorMetadata.makeRootSelector = (runtimeContext) => {
2172
- return runtimeContext.getStateGetter(this.name);
2173
- };
2174
- }
2175
- getName() {
2176
- return this.name;
2177
- }
2178
- toString() {
2179
- return `StateToken[${this.name}]`;
2180
- }
2181
- }
2182
-
2183
2124
  class NgxsDevelopmentModule {
2184
2125
  static forRoot(options) {
2185
2126
  return {
@@ -2190,19 +2131,25 @@ class NgxsDevelopmentModule {
2190
2131
  ]
2191
2132
  };
2192
2133
  }
2134
+ /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: NgxsDevelopmentModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
2135
+ /** @nocollapse */ static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "17.3.3", ngImport: i0, type: NgxsDevelopmentModule }); }
2136
+ /** @nocollapse */ static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: NgxsDevelopmentModule }); }
2193
2137
  }
2194
- /** @nocollapse */ NgxsDevelopmentModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: NgxsDevelopmentModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
2195
- /** @nocollapse */ NgxsDevelopmentModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: NgxsDevelopmentModule });
2196
- /** @nocollapse */ NgxsDevelopmentModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: NgxsDevelopmentModule });
2197
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: NgxsDevelopmentModule, decorators: [{
2138
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: NgxsDevelopmentModule, decorators: [{
2198
2139
  type: NgModule
2199
2140
  }] });
2141
+ function withNgxsDevelopmentOptions(options) {
2142
+ return makeEnvironmentProviders([
2143
+ NgxsUnhandledActionsLogger,
2144
+ { provide: NGXS_DEVELOPMENT_OPTIONS, useValue: options }
2145
+ ]);
2146
+ }
2200
2147
 
2201
2148
  function ensureValidSelector(selector, context = {}) {
2202
2149
  const noun = context.noun || 'selector';
2203
2150
  const prefix = context.prefix ? context.prefix + ': ' : '';
2204
2151
  ensureValueProvided(selector, { noun, prefix: context.prefix });
2205
- const metadata = getSelectorMetadata$1(selector) || getStoreMetadata$1(selector);
2152
+ const metadata = _getSelectorMetadata(selector) || _getStoreMetadata(selector);
2206
2153
  if (!metadata) {
2207
2154
  throw new Error(`${prefix}The value provided as the ${noun} is not a valid selector.`);
2208
2155
  }
@@ -2218,7 +2165,7 @@ function ensureValueProvided(value, context = {}) {
2218
2165
  function createModelSelector(selectorMap) {
2219
2166
  const selectorKeys = Object.keys(selectorMap);
2220
2167
  const selectors = Object.values(selectorMap);
2221
- if (typeof ngDevMode === 'undefined' || ngDevMode) {
2168
+ if (typeof ngDevMode !== 'undefined' && ngDevMode) {
2222
2169
  ensureValidSelectorMap({
2223
2170
  prefix: '[createModelSelector]',
2224
2171
  selectorMap,
@@ -2244,7 +2191,7 @@ function ensureValidSelectorMap({ prefix, selectorMap, selectorKeys, selectors }
2244
2191
  }
2245
2192
 
2246
2193
  function createPickSelector(selector, keys) {
2247
- if (typeof ngDevMode === 'undefined' || ngDevMode) {
2194
+ if (typeof ngDevMode !== 'undefined' && ngDevMode) {
2248
2195
  ensureValidSelector(selector, { prefix: '[createPickSelector]' });
2249
2196
  }
2250
2197
  const validKeys = keys.filter(Boolean);
@@ -2258,7 +2205,7 @@ function createPickSelector(selector, keys) {
2258
2205
  }
2259
2206
 
2260
2207
  function createPropertySelectors(parentSelector) {
2261
- if (typeof ngDevMode === 'undefined' || ngDevMode) {
2208
+ if (typeof ngDevMode !== 'undefined' && ngDevMode) {
2262
2209
  ensureValidSelector(parentSelector, {
2263
2210
  prefix: '[createPropertySelectors]',
2264
2211
  noun: 'parent selector'
@@ -2268,13 +2215,120 @@ function createPropertySelectors(parentSelector) {
2268
2215
  return new Proxy({}, {
2269
2216
  get(_target, prop) {
2270
2217
  const selector = cache[prop] ||
2271
- createSelector([parentSelector], (s) => s === null || s === void 0 ? void 0 : s[prop]);
2218
+ createSelector([parentSelector], (s) => s?.[prop]);
2272
2219
  cache[prop] = selector;
2273
2220
  return selector;
2274
2221
  }
2275
2222
  });
2276
2223
  }
2277
2224
 
2225
+ function provideStore(states = [], ...optionsAndFeatures) {
2226
+ const features = [];
2227
+ // Options are empty by default (see `forRoot`).
2228
+ let options = {};
2229
+ if (optionsAndFeatures.length > 0) {
2230
+ if (isEnvironmentProvider(optionsAndFeatures[0])) {
2231
+ features.push(...optionsAndFeatures);
2232
+ }
2233
+ else {
2234
+ options = optionsAndFeatures[0];
2235
+ features.push(...optionsAndFeatures.slice(1));
2236
+ }
2237
+ }
2238
+ return makeEnvironmentProviders([
2239
+ ...getRootProviders(states, options),
2240
+ NGXS_ROOT_ENVIRONMENT_INITIALIZER,
2241
+ features
2242
+ ]);
2243
+ }
2244
+ function isEnvironmentProvider(target) {
2245
+ return !!target.ɵproviders;
2246
+ }
2247
+
2248
+ /**
2249
+ * This version serves as a standalone alternative to `NgxsModule.forFeature`.
2250
+ * It can be used in a similar manner to register feature states, but at the
2251
+ * `Route` providers level:
2252
+ *
2253
+ * ```ts
2254
+ * const routes: Routes = [
2255
+ * {
2256
+ * path: 'products',
2257
+ * loadComponent: async () => {...},
2258
+ * providers: [provideStates([ProductsState])]
2259
+ * }
2260
+ * ];
2261
+ * ```
2262
+ */
2263
+ function provideStates(states, ...features) {
2264
+ return makeEnvironmentProviders([
2265
+ ...getFeatureProviders(states),
2266
+ features,
2267
+ NGXS_FEATURE_ENVIRONMENT_INITIALIZER
2268
+ ]);
2269
+ }
2270
+
2271
+ /**
2272
+ * This function registers a custom global plugin for the state.
2273
+ *
2274
+ * ```ts
2275
+ * bootstrapApplication(AppComponent, {
2276
+ * providers: [
2277
+ * provideStore(
2278
+ * [CountriesState],
2279
+ * withNgxsPlugin(LogoutPlugin)
2280
+ * )
2281
+ * ]
2282
+ * });
2283
+ * ```
2284
+ */
2285
+ function withNgxsPlugin(plugin) {
2286
+ return makeEnvironmentProviders([{ provide: NGXS_PLUGINS, useClass: plugin, multi: true }]);
2287
+ }
2288
+
2289
+ /**
2290
+ * This function serves as a utility and has multiple purposes.
2291
+ * Firstly, it allows you to select properties from the state class
2292
+ * without having to inject the store class and use `this.store.selectSignal`,
2293
+ * resulting in a more concise implementation. Secondly, it can be used with
2294
+ * other solutions such as NgRx signal store with its `signalStoreFeature` or
2295
+ * `withComputed` functionalities.
2296
+ *
2297
+ * Please note that it's named `select` instead of `selectSignal` because
2298
+ * signals are evolving into first-class primitives in Angular, displacing other
2299
+ * primitives such as observables. Observables represent a stream of events,
2300
+ * whereas signals represent a single value changing over time.
2301
+ */
2302
+ function select(selector) {
2303
+ return inject(Store).selectSignal(selector);
2304
+ }
2305
+
2306
+ function dispatch(ActionType) {
2307
+ const store = inject(Store);
2308
+ return (...args) => store.dispatch(new ActionType(...args));
2309
+ }
2310
+
2311
+ function createSelectMap(selectorMap) {
2312
+ const store = inject(Store);
2313
+ return Object.entries(selectorMap).reduce((accumulator, [key, selector]) => {
2314
+ Object.defineProperty(accumulator, key, {
2315
+ enumerable: true,
2316
+ value: store.selectSignal(selector)
2317
+ });
2318
+ return accumulator;
2319
+ }, {});
2320
+ }
2321
+
2322
+ function createDispatchMap(actionMap) {
2323
+ return Object.entries(actionMap).reduce((accumulator, [key, ActionType]) => {
2324
+ Object.defineProperty(accumulator, key, {
2325
+ enumerable: true,
2326
+ value: dispatch(ActionType)
2327
+ });
2328
+ return accumulator;
2329
+ }, {});
2330
+ }
2331
+
2278
2332
  /**
2279
2333
  * The public api for consumers of @ngxs/store
2280
2334
  */
@@ -2283,5 +2337,5 @@ function createPropertySelectors(parentSelector) {
2283
2337
  * Generated bundle index. Do not edit.
2284
2338
  */
2285
2339
 
2286
- export { Action, Actions, InitState, NGXS_PLUGINS, NgxsDevelopmentModule, NgxsModule, NgxsSimpleChange, NgxsUnhandledActionsLogger, NoopNgxsExecutionStrategy, Select, Selector, SelectorOptions, State, StateStream, StateToken, Store, UpdateState, actionMatcher, createModelSelector, createPickSelector, createPropertySelectors, createSelector, ensureSelectorMetadata, ensureStoreMetadata, getActionTypeFromInstance, getSelectorMetadata, getStoreMetadata, getValue, ofAction, ofActionCanceled, ofActionCompleted, ofActionDispatched, ofActionErrored, ofActionSuccessful, setValue, NgxsFeatureModule as ɵNgxsFeatureModule, NgxsRootModule as ɵNgxsRootModule };
2287
- //# sourceMappingURL=ngxs-store.js.map
2340
+ export { Action, Actions, NgxsConfig, NgxsDevelopmentModule, NgxsModule, NgxsSimpleChange, NgxsUnhandledActionsLogger, NgxsUnhandledErrorHandler, NoopNgxsExecutionStrategy, Select, Selector, SelectorOptions, State, Store, createDispatchMap, createModelSelector, createPickSelector, createPropertySelectors, createSelectMap, createSelector, dispatch, ofAction, ofActionCanceled, ofActionCompleted, ofActionDispatched, ofActionErrored, ofActionSuccessful, provideStates, provideStore, select, withNgxsDevelopmentOptions, withNgxsPlugin, withNgxsPreboot, NgxsFeatureModule as ɵNgxsFeatureModule, NgxsRootModule as ɵNgxsRootModule };
2341
+ //# sourceMappingURL=ngxs-store.mjs.map