@ngxs/store 18.1.5 → 18.1.6-dev.master-a9e7ff3

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 (153) hide show
  1. package/experimental/index.d.ts +6 -5
  2. package/fesm2022/ngxs-store-experimental.mjs +8 -25
  3. package/fesm2022/ngxs-store-experimental.mjs.map +1 -1
  4. package/fesm2022/ngxs-store-internals-testing.mjs +8 -9
  5. package/fesm2022/ngxs-store-internals-testing.mjs.map +1 -1
  6. package/fesm2022/ngxs-store-internals.mjs +9 -11
  7. package/fesm2022/ngxs-store-internals.mjs.map +1 -1
  8. package/fesm2022/ngxs-store-operators.mjs.map +1 -1
  9. package/fesm2022/ngxs-store-plugins.mjs +14 -5
  10. package/fesm2022/ngxs-store-plugins.mjs.map +1 -1
  11. package/fesm2022/ngxs-store.mjs +276 -272
  12. package/fesm2022/ngxs-store.mjs.map +1 -1
  13. package/index.d.ts +44 -185
  14. package/package.json +7 -19
  15. package/plugins/index.d.ts +12 -5
  16. package/schematics/src/actions/actions.factory.js +1 -2
  17. package/schematics/src/actions/actions.factory.js.map +1 -1
  18. package/schematics/src/ng-add/add-declaration.js +2 -3
  19. package/schematics/src/ng-add/add-declaration.js.map +1 -1
  20. package/schematics/src/ng-add/ng-add.factory.js +1 -2
  21. package/schematics/src/ng-add/ng-add.factory.js.map +1 -1
  22. package/schematics/src/starter-kit/starter-kit.factory.js +1 -2
  23. package/schematics/src/starter-kit/starter-kit.factory.js.map +1 -1
  24. package/schematics/src/state/state.factory.js +1 -2
  25. package/schematics/src/state/state.factory.js.map +1 -1
  26. package/schematics/src/store/store.factory.js +1 -2
  27. package/schematics/src/store/store.factory.js.map +1 -1
  28. package/schematics/src/utils/common/properties.js +1 -2
  29. package/schematics/src/utils/common/properties.js.map +1 -1
  30. package/schematics/src/utils/config.js +2 -3
  31. package/schematics/src/utils/config.js.map +1 -1
  32. package/schematics/src/utils/generate-utils.js +1 -2
  33. package/schematics/src/utils/generate-utils.js.map +1 -1
  34. package/schematics/src/utils/normalize-options.js +3 -4
  35. package/schematics/src/utils/normalize-options.js.map +1 -1
  36. package/schematics/src/utils/project.js +4 -5
  37. package/schematics/src/utils/project.js.map +1 -1
  38. package/schematics/src/utils/versions.json +1 -1
  39. package/esm2022/experimental/index.mjs +0 -2
  40. package/esm2022/experimental/ngxs-store-experimental.mjs +0 -5
  41. package/esm2022/experimental/pending-tasks.mjs +0 -30
  42. package/esm2022/index.mjs +0 -13
  43. package/esm2022/internals/custom-rxjs-operators.mjs +0 -19
  44. package/esm2022/internals/custom-rxjs-subjects.mjs +0 -92
  45. package/esm2022/internals/index.mjs +0 -11
  46. package/esm2022/internals/initial-state.mjs +0 -18
  47. package/esm2022/internals/internal-tokens.mjs +0 -6
  48. package/esm2022/internals/memoize.mjs +0 -43
  49. package/esm2022/internals/metadata.mjs +0 -57
  50. package/esm2022/internals/ngxs-app-bootstrapped-state.mjs +0 -19
  51. package/esm2022/internals/ngxs-store-internals.mjs +0 -5
  52. package/esm2022/internals/state-stream.mjs +0 -33
  53. package/esm2022/internals/state-token.mjs +0 -17
  54. package/esm2022/internals/symbols.mjs +0 -11
  55. package/esm2022/internals/testing/fresh-platform.mjs +0 -72
  56. package/esm2022/internals/testing/helpers/ngxs-test.component.mjs +0 -16
  57. package/esm2022/internals/testing/helpers/ngxs-test.module.mjs +0 -20
  58. package/esm2022/internals/testing/index.mjs +0 -4
  59. package/esm2022/internals/testing/ngxs-store-internals-testing.mjs +0 -5
  60. package/esm2022/internals/testing/ngxs.setup.mjs +0 -49
  61. package/esm2022/internals/testing/skip-console-logging.mjs +0 -37
  62. package/esm2022/internals/testing/symbol.mjs +0 -2
  63. package/esm2022/ngxs-store.mjs +0 -5
  64. package/esm2022/operators/append.mjs +0 -20
  65. package/esm2022/operators/compose.mjs +0 -6
  66. package/esm2022/operators/iif.mjs +0 -38
  67. package/esm2022/operators/index.mjs +0 -14
  68. package/esm2022/operators/insert-item.mjs +0 -29
  69. package/esm2022/operators/ngxs-store-operators.mjs +0 -5
  70. package/esm2022/operators/patch.mjs +0 -21
  71. package/esm2022/operators/remove-item.mjs +0 -22
  72. package/esm2022/operators/types.mjs +0 -2
  73. package/esm2022/operators/update-item.mjs +0 -40
  74. package/esm2022/operators/utils.mjs +0 -19
  75. package/esm2022/plugins/actions.mjs +0 -16
  76. package/esm2022/plugins/index.mjs +0 -4
  77. package/esm2022/plugins/ngxs-store-plugins.mjs +0 -5
  78. package/esm2022/plugins/symbols.mjs +0 -6
  79. package/esm2022/plugins/utils.mjs +0 -51
  80. package/esm2022/src/actions/action-registry.mjs +0 -34
  81. package/esm2022/src/actions/symbols.mjs +0 -2
  82. package/esm2022/src/actions-stream.mjs +0 -60
  83. package/esm2022/src/configs/messages.config.mjs +0 -48
  84. package/esm2022/src/decorators/action.mjs +0 -31
  85. package/esm2022/src/decorators/select/select-factory.mjs +0 -29
  86. package/esm2022/src/decorators/select/select.mjs +0 -29
  87. package/esm2022/src/decorators/select/symbols.mjs +0 -29
  88. package/esm2022/src/decorators/selector/selector.mjs +0 -29
  89. package/esm2022/src/decorators/selector/symbols.mjs +0 -2
  90. package/esm2022/src/decorators/selector-options.mjs +0 -21
  91. package/esm2022/src/decorators/state.mjs +0 -35
  92. package/esm2022/src/dev-features/ngxs-development.module.mjs +0 -28
  93. package/esm2022/src/dev-features/ngxs-unhandled-actions-logger.mjs +0 -45
  94. package/esm2022/src/dev-features/symbols.mjs +0 -7
  95. package/esm2022/src/execution/dispatch-outside-zone-ngxs-execution-strategy.mjs +0 -55
  96. package/esm2022/src/execution/internal-ngxs-execution-strategy.mjs +0 -24
  97. package/esm2022/src/execution/noop-ngxs-execution-strategy.mjs +0 -17
  98. package/esm2022/src/execution/symbols.mjs +0 -29
  99. package/esm2022/src/internal/dispatcher.mjs +0 -106
  100. package/esm2022/src/internal/fallback-subscriber.mjs +0 -29
  101. package/esm2022/src/internal/internals.mjs +0 -206
  102. package/esm2022/src/internal/lifecycle-state-manager.mjs +0 -86
  103. package/esm2022/src/internal/provide-internal-tokens.mjs +0 -20
  104. package/esm2022/src/internal/state-context-factory.mjs +0 -71
  105. package/esm2022/src/internal/state-factory.mjs +0 -331
  106. package/esm2022/src/internal/state-operations.mjs +0 -63
  107. package/esm2022/src/internal/state-operators.mjs +0 -20
  108. package/esm2022/src/internal/unhandled-rxjs-error-callback.mjs +0 -39
  109. package/esm2022/src/ivy/ivy-enabled-in-dev-mode.mjs +0 -25
  110. package/esm2022/src/module.mjs +0 -27
  111. package/esm2022/src/modules/ngxs-feature.module.mjs +0 -18
  112. package/esm2022/src/modules/ngxs-root.module.mjs +0 -18
  113. package/esm2022/src/ngxs-unhandled-error-handler.mjs +0 -29
  114. package/esm2022/src/operators/leave-ngxs.mjs +0 -9
  115. package/esm2022/src/operators/of-action.mjs +0 -104
  116. package/esm2022/src/plugin-manager.mjs +0 -33
  117. package/esm2022/src/plugin_api.mjs +0 -2
  118. package/esm2022/src/private_api.mjs +0 -5
  119. package/esm2022/src/public_api.mjs +0 -20
  120. package/esm2022/src/selectors/create-model-selector.mjs +0 -30
  121. package/esm2022/src/selectors/create-pick-selector.mjs +0 -16
  122. package/esm2022/src/selectors/create-property-selectors.mjs +0 -20
  123. package/esm2022/src/selectors/create-selector.mjs +0 -9
  124. package/esm2022/src/selectors/index.mjs +0 -6
  125. package/esm2022/src/selectors/private_api.mjs +0 -2
  126. package/esm2022/src/selectors/selector-checks.util.mjs +0 -43
  127. package/esm2022/src/selectors/selector-metadata.mjs +0 -35
  128. package/esm2022/src/selectors/selector-models.mjs +0 -2
  129. package/esm2022/src/selectors/selector-types.util.mjs +0 -2
  130. package/esm2022/src/selectors/selector-utils.mjs +0 -96
  131. package/esm2022/src/standalone-features/feature-providers.mjs +0 -20
  132. package/esm2022/src/standalone-features/index.mjs +0 -5
  133. package/esm2022/src/standalone-features/initializers.mjs +0 -89
  134. package/esm2022/src/standalone-features/plugin.mjs +0 -27
  135. package/esm2022/src/standalone-features/preboot.mjs +0 -32
  136. package/esm2022/src/standalone-features/provide-states.mjs +0 -26
  137. package/esm2022/src/standalone-features/provide-store.mjs +0 -26
  138. package/esm2022/src/standalone-features/root-providers.mjs +0 -38
  139. package/esm2022/src/store.mjs +0 -127
  140. package/esm2022/src/symbols.mjs +0 -87
  141. package/esm2022/src/utils/compose.mjs +0 -26
  142. package/esm2022/src/utils/create-dispatch-map.mjs +0 -11
  143. package/esm2022/src/utils/create-select-map.mjs +0 -13
  144. package/esm2022/src/utils/dispatch.mjs +0 -7
  145. package/esm2022/src/utils/freeze.mjs +0 -20
  146. package/esm2022/src/utils/public_api.mjs +0 -5
  147. package/esm2022/src/utils/select.mjs +0 -19
  148. package/esm2022/src/utils/store-validators.mjs +0 -25
  149. package/experimental/package.json +0 -3
  150. package/internals/package.json +0 -3
  151. package/internals/testing/package.json +0 -3
  152. package/operators/package.json +0 -3
  153. package/plugins/package.json +0 -3
@@ -1,12 +1,11 @@
1
1
  import * as i0 from '@angular/core';
2
- import { Injectable, NgZone, PLATFORM_ID, Inject, InjectionToken, inject, INJECTOR, ErrorHandler, Injector, ɵisPromise as _isPromise, computed, Optional, makeEnvironmentProviders, ENVIRONMENT_INITIALIZER, NgModule, APP_BOOTSTRAP_LISTENER } from '@angular/core';
3
- import { Subject, filter, Observable, share, config, of, forkJoin, throwError, EMPTY, mergeMap, map as map$1, defaultIfEmpty, catchError, from, isObservable, takeUntil, finalize, shareReplay as shareReplay$1, distinctUntilChanged, take as take$1, ReplaySubject } from 'rxjs';
4
- import * as i1 from '@ngxs/store/internals';
5
- import { ɵwrapObserverCalls as _wrapObserverCalls, ɵ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, ɵensureStoreMetadata as _ensureStoreMetadata, ɵMETA_OPTIONS_KEY as _META_OPTIONS_KEY, ɵensureSelectorMetadata as _ensureSelectorMetadata, ɵNGXS_STATE_CONTEXT_FACTORY as _NGXS_STATE_CONTEXT_FACTORY, ɵNGXS_STATE_FACTORY as _NGXS_STATE_FACTORY } from '@ngxs/store/internals';
2
+ import { Injectable, inject, NgZone, PLATFORM_ID, InjectionToken, INJECTOR, Injector, runInInjectionContext, ErrorHandler, ɵisPromise as _isPromise, computed, makeEnvironmentProviders, ENVIRONMENT_INITIALIZER, NgModule, APP_BOOTSTRAP_LISTENER, PendingTasks } from '@angular/core';
3
+ import { Subject, filter, Observable, share, config, of, forkJoin, throwError, mergeMap as mergeMap$1, map as map$1, defaultIfEmpty, catchError, from, isObservable, takeUntil, finalize, shareReplay as shareReplay$1, distinctUntilChanged, take as take$1, ReplaySubject } from 'rxjs';
4
+ import { ɵwrapObserverCalls as _wrapObserverCalls, ɵOrderedSubject as _OrderedSubject, ɵStateStream as _StateStream, ɵmemoize as _memoize, ɵgetStoreMetadata as _getStoreMetadata, ɵgetSelectorMetadata as _getSelectorMetadata, ɵMETA_KEY as _META_KEY, ɵINITIAL_STATE_TOKEN as _INITIAL_STATE_TOKEN, ɵNgxsAppBootstrappedState as _NgxsAppBootstrappedState, ɵensureStoreMetadata as _ensureStoreMetadata, ɵMETA_OPTIONS_KEY as _META_OPTIONS_KEY, ɵensureSelectorMetadata as _ensureSelectorMetadata, ɵNGXS_STATE_CONTEXT_FACTORY as _NGXS_STATE_CONTEXT_FACTORY, ɵNGXS_STATE_FACTORY as _NGXS_STATE_FACTORY } from '@ngxs/store/internals';
6
5
  export { StateToken } from '@ngxs/store/internals';
7
6
  import { isPlatformServer } from '@angular/common';
8
- import { map, shareReplay, filter as filter$1, take, exhaustMap, tap, mergeMap as mergeMap$1, takeUntil as takeUntil$1, startWith, pairwise } from 'rxjs/operators';
9
- import { NGXS_PLUGINS, getActionTypeFromInstance, InitState, UpdateState, setValue, getValue } from '@ngxs/store/plugins';
7
+ import { map, shareReplay, filter as filter$1, take, mergeMap, tap, takeUntil as takeUntil$1, startWith, pairwise } from 'rxjs/operators';
8
+ import { NGXS_PLUGINS, getActionTypeFromInstance, InitState, UpdateState, setValue, getValue, ɵisPluginClass as _isPluginClass } from '@ngxs/store/plugins';
10
9
  export { InitState, NGXS_PLUGINS, UpdateState, actionMatcher, getActionTypeFromInstance, getValue, setValue } from '@ngxs/store/plugins';
11
10
  import { isStateOperator } from '@ngxs/store/operators';
12
11
 
@@ -17,10 +16,10 @@ class NoopNgxsExecutionStrategy {
17
16
  leave(func) {
18
17
  return func();
19
18
  }
20
- /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.0.6", ngImport: i0, type: NoopNgxsExecutionStrategy, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
21
- /** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.0.6", ngImport: i0, type: NoopNgxsExecutionStrategy, providedIn: 'root' }); }
19
+ /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.0", ngImport: i0, type: NoopNgxsExecutionStrategy, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
20
+ /** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.0.0", ngImport: i0, type: NoopNgxsExecutionStrategy, providedIn: 'root' }); }
22
21
  }
23
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.0.6", ngImport: i0, type: NoopNgxsExecutionStrategy, decorators: [{
22
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.0", ngImport: i0, type: NoopNgxsExecutionStrategy, decorators: [{
24
23
  type: Injectable,
25
24
  args: [{ providedIn: 'root' }]
26
25
  }] });
@@ -74,15 +73,15 @@ function throwPatchingPrimitiveError() {
74
73
  }
75
74
 
76
75
  class DispatchOutsideZoneNgxsExecutionStrategy {
77
- constructor(_ngZone, _platformId) {
78
- this._ngZone = _ngZone;
79
- this._platformId = _platformId;
76
+ constructor() {
77
+ this._ngZone = inject(NgZone);
78
+ this._isServer = isPlatformServer(inject(PLATFORM_ID));
80
79
  if (typeof ngDevMode !== 'undefined' && ngDevMode) {
81
- verifyZoneIsNotNooped(_ngZone);
80
+ verifyZoneIsNotNooped(this._ngZone);
82
81
  }
83
82
  }
84
83
  enter(func) {
85
- if (isPlatformServer(this._platformId)) {
84
+ if (this._isServer) {
86
85
  return this.runInsideAngular(func);
87
86
  }
88
87
  return this.runOutsideAngular(func);
@@ -102,16 +101,13 @@ class DispatchOutsideZoneNgxsExecutionStrategy {
102
101
  }
103
102
  return func();
104
103
  }
105
- /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.0.6", 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: "18.0.6", ngImport: i0, type: DispatchOutsideZoneNgxsExecutionStrategy, providedIn: 'root' }); }
104
+ /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.0", ngImport: i0, type: DispatchOutsideZoneNgxsExecutionStrategy, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
105
+ /** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.0.0", ngImport: i0, type: DispatchOutsideZoneNgxsExecutionStrategy, providedIn: 'root' }); }
107
106
  }
108
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.0.6", ngImport: i0, type: DispatchOutsideZoneNgxsExecutionStrategy, decorators: [{
107
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.0", ngImport: i0, type: DispatchOutsideZoneNgxsExecutionStrategy, decorators: [{
109
108
  type: Injectable,
110
109
  args: [{ providedIn: 'root' }]
111
- }], ctorParameters: () => [{ type: i0.NgZone }, { type: undefined, decorators: [{
112
- type: Inject,
113
- args: [PLATFORM_ID]
114
- }] }] });
110
+ }], ctorParameters: () => [] });
115
111
  // Caretaker note: this should exist as a separate function and not a class method,
116
112
  // since class methods are not tree-shakable.
117
113
  function verifyZoneIsNotNooped(ngZone) {
@@ -124,18 +120,17 @@ function verifyZoneIsNotNooped(ngZone) {
124
120
  console.warn(getZoneWarningMessage());
125
121
  }
126
122
 
127
- const NG_DEV_MODE$9 = typeof ngDevMode !== 'undefined' && ngDevMode;
128
123
  /**
129
124
  * Consumers have the option to utilize the execution strategy provided by
130
125
  * `NgxsModule.forRoot({executionStrategy})` or `provideStore([], {executionStrategy})`.
131
126
  */
132
- const CUSTOM_NGXS_EXECUTION_STRATEGY = new InjectionToken(NG_DEV_MODE$9 ? 'CUSTOM_NGXS_EXECUTION_STRATEGY' : '');
127
+ const CUSTOM_NGXS_EXECUTION_STRATEGY = new InjectionToken(typeof ngDevMode !== 'undefined' && ngDevMode ? 'CUSTOM_NGXS_EXECUTION_STRATEGY' : '');
133
128
  /**
134
129
  * The injection token is used internally to resolve an instance of the execution
135
130
  * strategy. It checks whether consumers have provided their own `executionStrategy`
136
131
  * and also verifies if we are operating in a zone-aware environment.
137
132
  */
138
- const NGXS_EXECUTION_STRATEGY = new InjectionToken(NG_DEV_MODE$9 ? 'NGXS_EXECUTION_STRATEGY' : '', {
133
+ const NGXS_EXECUTION_STRATEGY = new InjectionToken(typeof ngDevMode !== 'undefined' && ngDevMode ? 'NGXS_EXECUTION_STRATEGY' : '', {
139
134
  providedIn: 'root',
140
135
  factory: () => {
141
136
  const ngZone = inject(NgZone);
@@ -151,8 +146,8 @@ const NGXS_EXECUTION_STRATEGY = new InjectionToken(NG_DEV_MODE$9 ? 'NGXS_EXECUTI
151
146
  });
152
147
 
153
148
  class InternalNgxsExecutionStrategy {
154
- constructor(_executionStrategy) {
155
- this._executionStrategy = _executionStrategy;
149
+ constructor() {
150
+ this._executionStrategy = inject(NGXS_EXECUTION_STRATEGY);
156
151
  }
157
152
  enter(func) {
158
153
  return this._executionStrategy.enter(func);
@@ -160,42 +155,13 @@ class InternalNgxsExecutionStrategy {
160
155
  leave(func) {
161
156
  return this._executionStrategy.leave(func);
162
157
  }
163
- /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.0.6", 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: "18.0.6", ngImport: i0, type: InternalNgxsExecutionStrategy, providedIn: 'root' }); }
158
+ /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.0", ngImport: i0, type: InternalNgxsExecutionStrategy, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
159
+ /** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.0.0", ngImport: i0, type: InternalNgxsExecutionStrategy, providedIn: 'root' }); }
165
160
  }
166
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.0.6", ngImport: i0, type: InternalNgxsExecutionStrategy, decorators: [{
161
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.0", ngImport: i0, type: InternalNgxsExecutionStrategy, decorators: [{
167
162
  type: Injectable,
168
163
  args: [{ providedIn: 'root' }]
169
- }], ctorParameters: () => [{ type: undefined, decorators: [{
170
- type: Inject,
171
- args: [NGXS_EXECUTION_STRATEGY]
172
- }] }] });
173
-
174
- /**
175
- * Composes a array of functions from left to right. Example:
176
- *
177
- * compose([fn, final])(state, action);
178
- *
179
- * then the funcs have a signature like:
180
- *
181
- * function fn (state, action, next) {
182
- * console.log('here', state, action, next);
183
- * return next(state, action);
184
- * }
185
- *
186
- * function final (state, action) {
187
- * console.log('here', state, action);
188
- * return state;
189
- * }
190
- *
191
- * the last function should not call `next`.
192
- *
193
- * @ignore
194
- */
195
- const compose = (funcs) => (...args) => {
196
- const curr = funcs.shift();
197
- return curr(...args, (...nextArgs) => compose(funcs)(...nextArgs));
198
- };
164
+ }] });
199
165
 
200
166
  /**
201
167
  * Returns operator that will run
@@ -221,10 +187,10 @@ class InternalActions extends _OrderedSubject {
221
187
  ngOnDestroy() {
222
188
  this.complete();
223
189
  }
224
- /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.0.6", ngImport: i0, type: InternalActions, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
225
- /** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.0.6", ngImport: i0, type: InternalActions, providedIn: 'root' }); }
190
+ /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.0", ngImport: i0, type: InternalActions, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
191
+ /** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.0.0", ngImport: i0, type: InternalActions, providedIn: 'root' }); }
226
192
  }
227
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.0.6", ngImport: i0, type: InternalActions, decorators: [{
193
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.0", ngImport: i0, type: InternalActions, decorators: [{
228
194
  type: Injectable,
229
195
  args: [{ providedIn: 'root' }]
230
196
  }], ctorParameters: () => [] });
@@ -234,7 +200,9 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.0.6", ngImpor
234
200
  * You can listen to this in services to react without stores.
235
201
  */
236
202
  class Actions extends Observable {
237
- constructor(internalActions$, internalExecutionStrategy) {
203
+ constructor() {
204
+ const internalActions$ = inject(InternalActions);
205
+ const internalExecutionStrategy = inject(InternalNgxsExecutionStrategy);
238
206
  const sharedInternalActions$ = internalActions$.pipe(leaveNgxs(internalExecutionStrategy),
239
207
  // The `InternalActions` subject emits outside of the Angular zone.
240
208
  // We have to re-enter the Angular zone for any incoming consumer.
@@ -250,13 +218,13 @@ class Actions extends Observable {
250
218
  observer.add(childSubscription);
251
219
  });
252
220
  }
253
- /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.0.6", ngImport: i0, type: Actions, deps: [{ token: InternalActions }, { token: InternalNgxsExecutionStrategy }], target: i0.ɵɵFactoryTarget.Injectable }); }
254
- /** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.0.6", ngImport: i0, type: Actions, providedIn: 'root' }); }
221
+ /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.0", ngImport: i0, type: Actions, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
222
+ /** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.0.0", ngImport: i0, type: Actions, providedIn: 'root' }); }
255
223
  }
256
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.0.6", ngImport: i0, type: Actions, decorators: [{
224
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.0", ngImport: i0, type: Actions, decorators: [{
257
225
  type: Injectable,
258
226
  args: [{ providedIn: 'root' }]
259
- }], ctorParameters: () => [{ type: InternalActions }, { type: InternalNgxsExecutionStrategy }] });
227
+ }], ctorParameters: () => [] });
260
228
 
261
229
  class PluginManager {
262
230
  constructor() {
@@ -281,27 +249,35 @@ class PluginManager {
281
249
  const handlers = this._pluginHandlers || [];
282
250
  return handlers.map((plugin) => (plugin.handle ? plugin.handle.bind(plugin) : plugin));
283
251
  }
284
- /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.0.6", ngImport: i0, type: PluginManager, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
285
- /** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.0.6", ngImport: i0, type: PluginManager }); }
252
+ /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.0", ngImport: i0, type: PluginManager, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
253
+ /** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.0.0", ngImport: i0, type: PluginManager, providedIn: 'root' }); }
286
254
  }
287
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.0.6", ngImport: i0, type: PluginManager, decorators: [{
288
- type: Injectable
255
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.0", ngImport: i0, type: PluginManager, decorators: [{
256
+ type: Injectable,
257
+ args: [{ providedIn: 'root' }]
289
258
  }], ctorParameters: () => [] });
290
259
 
291
260
  const ɵɵunhandledRxjsErrorCallbacks = new WeakMap();
292
- const existingHandler = config.onUnhandledError;
293
- config.onUnhandledError = function (error) {
294
- const unhandledErrorCallback = ɵɵunhandledRxjsErrorCallbacks.get(error);
295
- if (unhandledErrorCallback) {
296
- unhandledErrorCallback();
297
- }
298
- else if (existingHandler) {
299
- existingHandler.call(this, error);
300
- }
301
- else {
302
- throw error;
261
+ let installed = false;
262
+ function installOnUnhandhedErrorHandler() {
263
+ if (installed) {
264
+ return;
303
265
  }
304
- };
266
+ const existingHandler = config.onUnhandledError;
267
+ config.onUnhandledError = function (error) {
268
+ const unhandledErrorCallback = ɵɵunhandledRxjsErrorCallbacks.get(error);
269
+ if (unhandledErrorCallback) {
270
+ unhandledErrorCallback();
271
+ }
272
+ else if (existingHandler) {
273
+ existingHandler.call(this, error);
274
+ }
275
+ else {
276
+ throw error;
277
+ }
278
+ };
279
+ installed = true;
280
+ }
305
281
  function executeUnhandledCallback(error) {
306
282
  const unhandledErrorCallback = ɵɵunhandledRxjsErrorCallbacks.get(error);
307
283
  if (unhandledErrorCallback) {
@@ -360,21 +336,22 @@ function fallbackSubscriber(ngZone) {
360
336
  * The dispatcher then asynchronously pushes the result from this stream onto the main action stream as a result.
361
337
  */
362
338
  class InternalDispatchedActionResults extends Subject {
363
- /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.0.6", ngImport: i0, type: InternalDispatchedActionResults, deps: null, target: i0.ɵɵFactoryTarget.Injectable }); }
364
- /** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.0.6", ngImport: i0, type: InternalDispatchedActionResults, providedIn: 'root' }); }
339
+ /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.0", ngImport: i0, type: InternalDispatchedActionResults, deps: null, target: i0.ɵɵFactoryTarget.Injectable }); }
340
+ /** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.0.0", ngImport: i0, type: InternalDispatchedActionResults, providedIn: 'root' }); }
365
341
  }
366
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.0.6", ngImport: i0, type: InternalDispatchedActionResults, decorators: [{
342
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.0", ngImport: i0, type: InternalDispatchedActionResults, decorators: [{
367
343
  type: Injectable,
368
344
  args: [{ providedIn: 'root' }]
369
345
  }] });
370
346
  class InternalDispatcher {
371
- constructor(_ngZone, _actions, _actionResults, _pluginManager, _stateStream, _ngxsExecutionStrategy) {
372
- this._ngZone = _ngZone;
373
- this._actions = _actions;
374
- this._actionResults = _actionResults;
375
- this._pluginManager = _pluginManager;
376
- this._stateStream = _stateStream;
377
- this._ngxsExecutionStrategy = _ngxsExecutionStrategy;
347
+ constructor() {
348
+ this._ngZone = inject(NgZone);
349
+ this._actions = inject(InternalActions);
350
+ this._actionResults = inject(InternalDispatchedActionResults);
351
+ this._pluginManager = inject(PluginManager);
352
+ this._stateStream = inject(_StateStream);
353
+ this._ngxsExecutionStrategy = inject(InternalNgxsExecutionStrategy);
354
+ this._injector = inject(Injector);
378
355
  }
379
356
  /**
380
357
  * Dispatches event(s).
@@ -403,7 +380,7 @@ class InternalDispatcher {
403
380
  }
404
381
  const prevState = this._stateStream.getValue();
405
382
  const plugins = this._pluginManager.plugins;
406
- return compose([
383
+ return compose(this._injector, [
407
384
  ...plugins,
408
385
  (nextState, nextAction) => {
409
386
  if (nextState !== prevState) {
@@ -420,41 +397,63 @@ class InternalDispatcher {
420
397
  return this._actionResults.pipe(filter$1((ctx) => ctx.action === action && ctx.status !== "DISPATCHED" /* ActionStatus.Dispatched */), take(1), shareReplay());
421
398
  }
422
399
  createDispatchObservable(actionResult$) {
423
- return actionResult$
424
- .pipe(exhaustMap((ctx) => {
400
+ return actionResult$.pipe(mergeMap((ctx) => {
425
401
  switch (ctx.status) {
426
402
  case "SUCCESSFUL" /* ActionStatus.Successful */:
427
403
  // The `createDispatchObservable` function should return the
428
- // state, as its result is utilized by plugins.
404
+ // state, as its result is used by plugins.
429
405
  return of(this._stateStream.getValue());
430
406
  case "ERRORED" /* ActionStatus.Errored */:
431
407
  return throwError(() => ctx.error);
432
408
  default:
433
- return EMPTY;
409
+ // Once dispatched or canceled, we complete it immediately because
410
+ // `dispatch()` should emit (or error, or complete) as soon as it succeeds or fails.
411
+ return of();
434
412
  }
435
- }))
436
- .pipe(shareReplay());
413
+ }), shareReplay());
437
414
  }
438
- /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.0.6", ngImport: i0, type: InternalDispatcher, deps: [{ token: i0.NgZone }, { token: InternalActions }, { token: InternalDispatchedActionResults }, { token: PluginManager }, { token: i1.ɵStateStream }, { token: InternalNgxsExecutionStrategy }], target: i0.ɵɵFactoryTarget.Injectable }); }
439
- /** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.0.6", ngImport: i0, type: InternalDispatcher, providedIn: 'root' }); }
415
+ /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.0", ngImport: i0, type: InternalDispatcher, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
416
+ /** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.0.0", ngImport: i0, type: InternalDispatcher, providedIn: 'root' }); }
440
417
  }
441
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.0.6", ngImport: i0, type: InternalDispatcher, decorators: [{
418
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.0", ngImport: i0, type: InternalDispatcher, decorators: [{
442
419
  type: Injectable,
443
420
  args: [{ providedIn: 'root' }]
444
- }], ctorParameters: () => [{ type: i0.NgZone }, { type: InternalActions }, { type: InternalDispatchedActionResults }, { type: PluginManager }, { type: i1.ɵStateStream }, { type: InternalNgxsExecutionStrategy }] });
421
+ }] });
422
+ /**
423
+ * Composes a array of functions from left to right. Example:
424
+ *
425
+ * compose([fn, final])(state, action);
426
+ *
427
+ * then the funcs have a signature like:
428
+ *
429
+ * function fn (state, action, next) {
430
+ * console.log('here', state, action, next);
431
+ * return next(state, action);
432
+ * }
433
+ *
434
+ * function final (state, action) {
435
+ * console.log('here', state, action);
436
+ * return state;
437
+ * }
438
+ *
439
+ * the last function should not call `next`.
440
+ */
441
+ const compose = (injector, funcs) => (...args) => {
442
+ const curr = funcs.shift();
443
+ return runInInjectionContext(injector, () => curr(...args, (...nextArgs) => compose(injector, funcs)(...nextArgs)));
444
+ };
445
445
 
446
- const NG_DEV_MODE$8 = typeof ngDevMode !== 'undefined' && ngDevMode;
447
446
  // The injection token is used to resolve a list of states provided at
448
447
  // the root level through either `NgxsModule.forRoot` or `provideStore`.
449
- const ROOT_STATE_TOKEN = new InjectionToken(NG_DEV_MODE$8 ? 'ROOT_STATE_TOKEN' : '');
448
+ const ROOT_STATE_TOKEN = new InjectionToken(typeof ngDevMode !== 'undefined' && ngDevMode ? 'ROOT_STATE_TOKEN' : '');
450
449
  // The injection token is used to resolve a list of states provided at
451
450
  // the feature level through either `NgxsModule.forFeature` or `provideStates`.
452
451
  // The Array<Array> is used to overload the resolved value of the token because
453
452
  // it is a multi-provider token.
454
- const FEATURE_STATE_TOKEN = new InjectionToken(NG_DEV_MODE$8 ? 'FEATURE_STATE_TOKEN' : '');
453
+ const FEATURE_STATE_TOKEN = new InjectionToken(typeof ngDevMode !== 'undefined' && ngDevMode ? 'FEATURE_STATE_TOKEN' : '');
455
454
  // The injection token is used to resolve to options provided at the root
456
455
  // level through either `NgxsModule.forRoot` or `provideStore`.
457
- const NGXS_OPTIONS = new InjectionToken(NG_DEV_MODE$8 ? 'NGXS_OPTIONS' : '');
456
+ const NGXS_OPTIONS = new InjectionToken(typeof ngDevMode !== 'undefined' && ngDevMode ? 'NGXS_OPTIONS' : '');
458
457
  /**
459
458
  * The NGXS config settings.
460
459
  */
@@ -483,8 +482,8 @@ class NgxsConfig {
483
482
  suppressErrors: false
484
483
  };
485
484
  }
486
- /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.0.6", ngImport: i0, type: NgxsConfig, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
487
- /** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.0.6", ngImport: i0, type: NgxsConfig, providedIn: 'root', useFactory: () => {
485
+ /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.0", ngImport: i0, type: NgxsConfig, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
486
+ /** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.0.0", ngImport: i0, type: NgxsConfig, providedIn: 'root', useFactory: () => {
488
487
  const defaultConfig = new NgxsConfig();
489
488
  const config = inject(NGXS_OPTIONS);
490
489
  return {
@@ -497,7 +496,7 @@ class NgxsConfig {
497
496
  };
498
497
  } }); }
499
498
  }
500
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.0.6", ngImport: i0, type: NgxsConfig, decorators: [{
499
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.0", ngImport: i0, type: NgxsConfig, decorators: [{
501
500
  type: Injectable,
502
501
  args: [{
503
502
  providedIn: 'root',
@@ -551,10 +550,10 @@ const deepFreeze = (o) => {
551
550
  * @ignore
552
551
  */
553
552
  class InternalStateOperations {
554
- constructor(_stateStream, _dispatcher, _config) {
555
- this._stateStream = _stateStream;
556
- this._dispatcher = _dispatcher;
557
- this._config = _config;
553
+ constructor() {
554
+ this._stateStream = inject(_StateStream);
555
+ this._dispatcher = inject(InternalDispatcher);
556
+ this._config = inject(NgxsConfig);
558
557
  }
559
558
  /**
560
559
  * Returns the root state operators.
@@ -581,13 +580,13 @@ class InternalStateOperations {
581
580
  // Set the state to the current + new
582
581
  stateOperations.setState({ ...currentState, ...results.defaults });
583
582
  }
584
- /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.0.6", ngImport: i0, type: InternalStateOperations, deps: [{ token: i1.ɵStateStream }, { token: InternalDispatcher }, { token: NgxsConfig }], target: i0.ɵɵFactoryTarget.Injectable }); }
585
- /** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.0.6", ngImport: i0, type: InternalStateOperations, providedIn: 'root' }); }
583
+ /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.0", ngImport: i0, type: InternalStateOperations, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
584
+ /** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.0.0", ngImport: i0, type: InternalStateOperations, providedIn: 'root' }); }
586
585
  }
587
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.0.6", ngImport: i0, type: InternalStateOperations, decorators: [{
586
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.0", ngImport: i0, type: InternalStateOperations, decorators: [{
588
587
  type: Injectable,
589
588
  args: [{ providedIn: 'root' }]
590
- }], ctorParameters: () => [{ type: i1.ɵStateStream }, { type: InternalDispatcher }, { type: NgxsConfig }] });
589
+ }] });
591
590
  function ensureStateAndActionsAreImmutable(root) {
592
591
  return {
593
592
  getState: () => root.getState(),
@@ -601,7 +600,6 @@ function ensureStateAndActionsAreImmutable(root) {
601
600
  };
602
601
  }
603
602
 
604
- const NG_DEV_MODE$7 = typeof ngDevMode !== 'undefined' && ngDevMode;
605
603
  function createRootSelectorFactory(selectorMetaData, selectors, memoizedSelectorFn) {
606
604
  return (context) => {
607
605
  const { argumentSelectorFunctions, selectorOptions } = getRuntimeSelectorInfo(context, selectorMetaData, selectors);
@@ -622,7 +620,7 @@ function createRootSelectorFactory(selectorMetaData, selectors, memoizedSelector
622
620
  // We're logging an error in this function because it may be used by `select`,
623
621
  // `selectSignal`, and `selectSnapshot`. Therefore, there's no need to catch
624
622
  // exceptions there to log errors.
625
- if (NG_DEV_MODE$7) {
623
+ if (typeof ngDevMode !== 'undefined' && ngDevMode) {
626
624
  const message = 'The selector below has thrown an error upon invocation. ' +
627
625
  'Please check for any unsafe property access that may result in null ' +
628
626
  'or undefined values.';
@@ -696,7 +694,6 @@ function getRootSelectorFactory(selector) {
696
694
  return (metadata && metadata.makeRootSelector) || (() => selector);
697
695
  }
698
696
 
699
- const NG_DEV_MODE$6 = typeof ngDevMode !== 'undefined' && ngDevMode;
700
697
  /**
701
698
  * Get a deeply nested value. Example:
702
699
  *
@@ -761,7 +758,7 @@ function propGetter(paths, config) {
761
758
  // `createSelectorFn`, which, in turn, is solely used by the `Select` decorator.
762
759
  // We've been trying to deprecate the `Select` decorator because it's unstable with
763
760
  // server-side rendering and micro-frontend applications.
764
- const ɵPROP_GETTER = new InjectionToken(NG_DEV_MODE$6 ? 'PROP_GETTER' : '', {
761
+ const ɵPROP_GETTER = new InjectionToken(typeof ngDevMode !== 'undefined' && ngDevMode ? 'PROP_GETTER' : '', {
765
762
  providedIn: 'root',
766
763
  factory: () => inject(NgxsConfig).compatibility?.strictContentSecurityPolicy
767
764
  ? compliantPropGetter
@@ -788,7 +785,7 @@ const ɵPROP_GETTER = new InjectionToken(NG_DEV_MODE$6 ? 'PROP_GETTER' : '', {
788
785
  function buildGraph(stateClasses) {
789
786
  const findName = (stateClass) => {
790
787
  const meta = stateClasses.find(g => g === stateClass);
791
- if (NG_DEV_MODE$6 && !meta) {
788
+ if (typeof ngDevMode !== 'undefined' && ngDevMode && !meta) {
792
789
  throw new Error(`Child state not found: ${stateClass}. \r\nYou may have forgotten to add states to module`);
793
790
  }
794
791
  return meta[_META_KEY].name;
@@ -883,7 +880,7 @@ function topologicalSort(graph) {
883
880
  ancestors.push(name);
884
881
  visited[name] = true;
885
882
  graph[name].forEach((dep) => {
886
- if (NG_DEV_MODE$6 && ancestors.indexOf(dep) >= 0) {
883
+ if (typeof ngDevMode !== 'undefined' && ngDevMode && ancestors.indexOf(dep) >= 0) {
887
884
  throw new Error(`Circular dependency '${dep}' is required by '${name}': ${ancestors.join(' -> ')}`);
888
885
  }
889
886
  if (visited[dep]) {
@@ -923,10 +920,10 @@ class NgxsActionRegistry {
923
920
  handlers.delete(handler);
924
921
  };
925
922
  }
926
- /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.0.6", ngImport: i0, type: NgxsActionRegistry, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
927
- /** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.0.6", ngImport: i0, type: NgxsActionRegistry, providedIn: 'root' }); }
923
+ /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.0", ngImport: i0, type: NgxsActionRegistry, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
924
+ /** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.0.0", ngImport: i0, type: NgxsActionRegistry, providedIn: 'root' }); }
928
925
  }
929
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.0.6", ngImport: i0, type: NgxsActionRegistry, decorators: [{
926
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.0", ngImport: i0, type: NgxsActionRegistry, decorators: [{
930
927
  type: Injectable,
931
928
  args: [{ providedIn: 'root' }]
932
929
  }] });
@@ -978,19 +975,20 @@ function jit_hasInjectableAnnotation(stateClass) {
978
975
  return annotations.some((annotation) => annotation?.ngMetadataName === 'Injectable');
979
976
  }
980
977
 
981
- const NG_DEV_MODE$5 = typeof ngDevMode !== 'undefined' && ngDevMode;
982
- const NGXS_DEVELOPMENT_OPTIONS = new InjectionToken(NG_DEV_MODE$5 ? 'NGXS_DEVELOPMENT_OPTIONS' : '', {
978
+ const NGXS_DEVELOPMENT_OPTIONS =
979
+ /* @__PURE__ */ new InjectionToken(typeof ngDevMode !== 'undefined' && ngDevMode ? 'NGXS_DEVELOPMENT_OPTIONS' : '', {
983
980
  providedIn: 'root',
984
981
  factory: () => ({ warnOnUnhandledActions: true })
985
982
  });
986
983
 
987
984
  class NgxsUnhandledActionsLogger {
988
- constructor(options) {
985
+ constructor() {
989
986
  /**
990
987
  * These actions should be ignored by default; the user can increase this
991
988
  * list in the future via the `ignoreActions` method.
992
989
  */
993
990
  this._ignoredActions = new Set([InitState.type, UpdateState.type]);
991
+ const options = inject(NGXS_DEVELOPMENT_OPTIONS);
994
992
  if (typeof options.warnOnUnhandledActions === 'object') {
995
993
  this.ignoreActions(...options.warnOnUnhandledActions.ignore);
996
994
  }
@@ -1015,15 +1013,12 @@ class NgxsUnhandledActionsLogger {
1015
1013
  : action.type;
1016
1014
  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.`);
1017
1015
  }
1018
- /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.0.6", ngImport: i0, type: NgxsUnhandledActionsLogger, deps: [{ token: NGXS_DEVELOPMENT_OPTIONS }], target: i0.ɵɵFactoryTarget.Injectable }); }
1019
- /** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.0.6", ngImport: i0, type: NgxsUnhandledActionsLogger }); }
1016
+ /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.0", ngImport: i0, type: NgxsUnhandledActionsLogger, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
1017
+ /** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.0.0", ngImport: i0, type: NgxsUnhandledActionsLogger }); }
1020
1018
  }
1021
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.0.6", ngImport: i0, type: NgxsUnhandledActionsLogger, decorators: [{
1019
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.0", ngImport: i0, type: NgxsUnhandledActionsLogger, decorators: [{
1022
1020
  type: Injectable
1023
- }], ctorParameters: () => [{ type: undefined, decorators: [{
1024
- type: Inject,
1025
- args: [NGXS_DEVELOPMENT_OPTIONS]
1026
- }] }] });
1021
+ }], ctorParameters: () => [] });
1027
1022
 
1028
1023
  class NgxsUnhandledErrorHandler {
1029
1024
  constructor() {
@@ -1044,10 +1039,10 @@ class NgxsUnhandledErrorHandler {
1044
1039
  // `handleError` (see `_callAndReportToErrorHandler`).
1045
1040
  this._ngZone.runOutsideAngular(() => this._errorHandler.handleError(error));
1046
1041
  }
1047
- /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.0.6", ngImport: i0, type: NgxsUnhandledErrorHandler, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
1048
- /** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.0.6", ngImport: i0, type: NgxsUnhandledErrorHandler, providedIn: 'root' }); }
1042
+ /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.0", ngImport: i0, type: NgxsUnhandledErrorHandler, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
1043
+ /** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.0.0", ngImport: i0, type: NgxsUnhandledErrorHandler, providedIn: 'root' }); }
1049
1044
  }
1050
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.0.6", ngImport: i0, type: NgxsUnhandledErrorHandler, decorators: [{
1045
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.0", ngImport: i0, type: NgxsUnhandledErrorHandler, decorators: [{
1051
1046
  type: Injectable,
1052
1047
  args: [{ providedIn: 'root' }]
1053
1048
  }] });
@@ -1076,8 +1071,8 @@ function simplePatch(value) {
1076
1071
  * @ignore
1077
1072
  */
1078
1073
  class StateContextFactory {
1079
- constructor(_internalStateOperations) {
1080
- this._internalStateOperations = _internalStateOperations;
1074
+ constructor() {
1075
+ this._internalStateOperations = inject(InternalStateOperations);
1081
1076
  }
1082
1077
  /**
1083
1078
  * Create the state context
@@ -1108,13 +1103,13 @@ class StateContextFactory {
1108
1103
  }
1109
1104
  };
1110
1105
  }
1111
- /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.0.6", ngImport: i0, type: StateContextFactory, deps: [{ token: InternalStateOperations }], target: i0.ɵɵFactoryTarget.Injectable }); }
1112
- /** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.0.6", ngImport: i0, type: StateContextFactory, providedIn: 'root' }); }
1106
+ /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.0", ngImport: i0, type: StateContextFactory, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
1107
+ /** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.0.0", ngImport: i0, type: StateContextFactory, providedIn: 'root' }); }
1113
1108
  }
1114
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.0.6", ngImport: i0, type: StateContextFactory, decorators: [{
1109
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.0", ngImport: i0, type: StateContextFactory, decorators: [{
1115
1110
  type: Injectable,
1116
1111
  args: [{ providedIn: 'root' }]
1117
- }], ctorParameters: () => [{ type: InternalStateOperations }] });
1112
+ }] });
1118
1113
  function setStateValue(root, currentAppState, newValue, path) {
1119
1114
  const newAppState = setValue(currentAppState, path, newValue);
1120
1115
  root.setState(newAppState);
@@ -1237,7 +1232,6 @@ function createAllowedStatusesMap(statuses) {
1237
1232
  }, {});
1238
1233
  }
1239
1234
 
1240
- const NG_DEV_MODE$4 = typeof ngDevMode !== 'undefined' && ngDevMode;
1241
1235
  function cloneDefaults(defaults) {
1242
1236
  let value = defaults === undefined ? {} : defaults;
1243
1237
  if (defaults) {
@@ -1254,20 +1248,17 @@ function cloneDefaults(defaults) {
1254
1248
  * The `StateFactory` class adds root and feature states to the graph.
1255
1249
  * This extracts state names from state classes, checks if they already
1256
1250
  * exist in the global graph, throws errors if their names are invalid, etc.
1257
- * See its constructor, state factories inject state factories that are
1258
- * parent-level providers. This is required to get feature states from the
1259
- * injector on the same level.
1260
1251
  *
1261
- * The `NgxsModule.forFeature(...)` returns `providers: [StateFactory, ...states]`.
1262
- * The `StateFactory` is initialized on the feature level and goes through `...states`
1263
- * to get them from the injector through `injector.get(state)`.
1252
+ * Root and feature initializers call `addAndReturnDefaults()` to add those states
1253
+ * to the global graph. Since `addAndReturnDefaults` runs within the injection
1254
+ * context (which might be the root injector or a feature injector), we can
1255
+ * retrieve an instance of the state class using `inject(StateClass)`.
1264
1256
  * @ignore
1265
1257
  */
1266
1258
  class StateFactory {
1267
1259
  constructor() {
1268
1260
  this._injector = inject(Injector);
1269
1261
  this._config = inject(NgxsConfig);
1270
- this._parentFactory = inject(StateFactory, { optional: true, skipSelf: true });
1271
1262
  this._stateContextFactory = inject(StateContextFactory);
1272
1263
  this._actions = inject(InternalActions);
1273
1264
  this._actionResults = inject(InternalDispatchedActionResults);
@@ -1284,47 +1275,36 @@ class StateFactory {
1284
1275
  const stateFactory = this;
1285
1276
  const propGetter = stateFactory._propGetter;
1286
1277
  function resolveGetter(key) {
1287
- const path = stateFactory.statePaths[key];
1278
+ const path = stateFactory._statePaths[key];
1288
1279
  return path ? propGetter(path.split('.')) : null;
1289
1280
  }
1290
- const context = this._parentFactory
1291
- ? this._parentFactory.getRuntimeSelectorContext()
1292
- : {
1293
- getStateGetter(key) {
1294
- // Use `@__INLINE__` annotation to forcely inline `resolveGetter`.
1295
- // This is a Terser annotation, which will function only in the production mode.
1296
- let getter = /*@__INLINE__*/ resolveGetter(key);
1297
- if (getter) {
1298
- return getter;
1299
- }
1300
- return (...args) => {
1301
- // Late loaded getter
1302
- if (!getter) {
1303
- getter = /*@__INLINE__*/ resolveGetter(key);
1304
- }
1305
- return getter ? getter(...args) : undefined;
1306
- };
1307
- },
1308
- getSelectorOptions(localOptions) {
1309
- const globalSelectorOptions = stateFactory._config.selectorOptions;
1310
- return {
1311
- ...globalSelectorOptions,
1312
- ...(localOptions || {})
1313
- };
1281
+ const context = {
1282
+ getStateGetter(key) {
1283
+ // Use `@__INLINE__` annotation to forcely inline `resolveGetter`.
1284
+ // This is a Terser annotation, which will function only in the production mode.
1285
+ let getter = /*@__INLINE__*/ resolveGetter(key);
1286
+ if (getter) {
1287
+ return getter;
1314
1288
  }
1315
- };
1289
+ return (...args) => {
1290
+ // Late loaded getter
1291
+ if (!getter) {
1292
+ getter = /*@__INLINE__*/ resolveGetter(key);
1293
+ }
1294
+ return getter ? getter(...args) : undefined;
1295
+ };
1296
+ },
1297
+ getSelectorOptions(localOptions) {
1298
+ const globalSelectorOptions = stateFactory._config.selectorOptions;
1299
+ return {
1300
+ ...globalSelectorOptions,
1301
+ ...(localOptions || {})
1302
+ };
1303
+ }
1304
+ };
1316
1305
  return context;
1317
1306
  });
1318
1307
  }
1319
- get states() {
1320
- return this._parentFactory ? this._parentFactory.states : this._states;
1321
- }
1322
- get statesByName() {
1323
- return this._parentFactory ? this._parentFactory.statesByName : this._statesByName;
1324
- }
1325
- get statePaths() {
1326
- return this._parentFactory ? this._parentFactory.statePaths : this._statePaths;
1327
- }
1328
1308
  ngOnDestroy() {
1329
1309
  this._actionsSubscription?.unsubscribe();
1330
1310
  }
@@ -1332,7 +1312,7 @@ class StateFactory {
1332
1312
  * Add a new state to the global defs.
1333
1313
  */
1334
1314
  add(stateClasses) {
1335
- if (NG_DEV_MODE$4) {
1315
+ if (typeof ngDevMode !== 'undefined' && ngDevMode) {
1336
1316
  ensureStatesAreDecorated(stateClasses);
1337
1317
  }
1338
1318
  const { newStates } = this.addToStatesMap(stateClasses);
@@ -1352,7 +1332,7 @@ class StateFactory {
1352
1332
  // `State` decorator. This check is moved here because the `ɵprov` property
1353
1333
  // will not exist on the class in JIT mode (because it's set asynchronously
1354
1334
  // during JIT compilation through `Object.defineProperty`).
1355
- if (NG_DEV_MODE$4) {
1335
+ if (typeof ngDevMode !== 'undefined' && ngDevMode) {
1356
1336
  ensureStateClassIsInjectable(stateClass);
1357
1337
  }
1358
1338
  const stateMap = {
@@ -1360,7 +1340,7 @@ class StateFactory {
1360
1340
  path,
1361
1341
  isInitialised: false,
1362
1342
  actions: meta.actions,
1363
- instance: this._injector.get(stateClass),
1343
+ instance: inject(stateClass),
1364
1344
  defaults: cloneDefaults(meta.defaults)
1365
1345
  };
1366
1346
  // ensure our store hasn't already been added
@@ -1369,7 +1349,7 @@ class StateFactory {
1369
1349
  if (!this.hasBeenMountedAndBootstrapped(name, path)) {
1370
1350
  bootstrappedStores.push(stateMap);
1371
1351
  }
1372
- this.states.push(stateMap);
1352
+ this._states.push(stateMap);
1373
1353
  this.hydrateActionMetasMap(stateMap);
1374
1354
  }
1375
1355
  return bootstrappedStores;
@@ -1384,14 +1364,8 @@ class StateFactory {
1384
1364
  return { defaults, states: mappedStores };
1385
1365
  }
1386
1366
  connectActionHandlers() {
1387
- // Note: We have to connect actions only once when the `StateFactory`
1388
- // is being created for the first time. This checks if we're in
1389
- // a child state factory and the parent state factory already exists.
1390
- if (this._parentFactory || this._actionsSubscription !== null) {
1391
- return;
1392
- }
1393
1367
  this._actionsSubscription = this._actions
1394
- .pipe(filter((ctx) => ctx.status === "DISPATCHED" /* ActionStatus.Dispatched */), mergeMap(ctx => {
1368
+ .pipe(filter((ctx) => ctx.status === "DISPATCHED" /* ActionStatus.Dispatched */), mergeMap$1(ctx => {
1395
1369
  const action = ctx.action;
1396
1370
  return this.invokeActions(action).pipe(map$1(() => ({ action, status: "SUCCESSFUL" /* ActionStatus.Successful */ })), defaultIfEmpty({ action, status: "CANCELED" /* ActionStatus.Canceled */ }), catchError(error => {
1397
1371
  const ngxsUnhandledErrorHandler = (this._ngxsUnhandledErrorHandler ||=
@@ -1431,7 +1405,7 @@ class StateFactory {
1431
1405
  }
1432
1406
  // The `NgxsUnhandledActionsLogger` is a tree-shakable class which functions
1433
1407
  // only during development.
1434
- if (NG_DEV_MODE$4 && !actionHasBeenHandled) {
1408
+ if (typeof ngDevMode !== 'undefined' && ngDevMode && !actionHasBeenHandled) {
1435
1409
  const unhandledActionsLogger = this._injector.get(NgxsUnhandledActionsLogger, null);
1436
1410
  // The `NgxsUnhandledActionsLogger` will not be resolved by the injector if the
1437
1411
  // `NgxsDevelopmentModule` is not provided. It's enough to check whether the `injector.get`
@@ -1445,10 +1419,10 @@ class StateFactory {
1445
1419
  }
1446
1420
  addToStatesMap(stateClasses) {
1447
1421
  const newStates = [];
1448
- const statesMap = this.statesByName;
1422
+ const statesMap = this._statesByName;
1449
1423
  for (const stateClass of stateClasses) {
1450
1424
  const stateName = _getStoreMetadata(stateClass).name;
1451
- if (NG_DEV_MODE$4) {
1425
+ if (typeof ngDevMode !== 'undefined' && ngDevMode) {
1452
1426
  ensureStateNameIsUnique(stateName, stateClass, statesMap);
1453
1427
  }
1454
1428
  const unmountedState = !statesMap[stateName];
@@ -1460,7 +1434,7 @@ class StateFactory {
1460
1434
  return { newStates };
1461
1435
  }
1462
1436
  addRuntimeInfoToMeta(meta, path) {
1463
- this.statePaths[meta.name] = path;
1437
+ this._statePaths[meta.name] = path;
1464
1438
  // TODO: versions after v3 - we plan to get rid of the `path` property because it is non-deterministic
1465
1439
  // we can do this when we get rid of the incorrectly exposed getStoreMetadata
1466
1440
  // We will need to come up with an alternative to what was exposed in v3 because this is used by many plugins
@@ -1470,7 +1444,7 @@ class StateFactory {
1470
1444
  const valueIsBootstrappedInInitialState = getValue(this._initialState, path) !== undefined;
1471
1445
  // This checks whether a state has been already added to the global graph and
1472
1446
  // its lifecycle is in 'bootstrapped' state.
1473
- return this.statesByName[name] && valueIsBootstrappedInInitialState;
1447
+ return this._statesByName[name] && valueIsBootstrappedInInitialState;
1474
1448
  }
1475
1449
  hydrateActionMetasMap({ path, actions, instance }) {
1476
1450
  const { dispatched$ } = this._actions;
@@ -1490,7 +1464,7 @@ class StateFactory {
1490
1464
  result = from(result);
1491
1465
  }
1492
1466
  if (isObservable(result)) {
1493
- result = result.pipe(mergeMap((value) => {
1467
+ result = result.pipe(mergeMap$1((value) => {
1494
1468
  if (_isPromise(value)) {
1495
1469
  return from(value);
1496
1470
  }
@@ -1540,38 +1514,38 @@ class StateFactory {
1540
1514
  }
1541
1515
  }
1542
1516
  }
1543
- /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.0.6", ngImport: i0, type: StateFactory, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
1544
- /** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.0.6", ngImport: i0, type: StateFactory }); }
1517
+ /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.0", ngImport: i0, type: StateFactory, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
1518
+ /** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.0.0", ngImport: i0, type: StateFactory, providedIn: 'root' }); }
1545
1519
  }
1546
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.0.6", ngImport: i0, type: StateFactory, decorators: [{
1547
- type: Injectable
1520
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.0", ngImport: i0, type: StateFactory, decorators: [{
1521
+ type: Injectable,
1522
+ args: [{ providedIn: 'root' }]
1548
1523
  }] });
1549
1524
  // This is used to replace `setState` and `patchState` once the action
1550
1525
  // handler has been unsubscribed or completed, to prevent writing
1551
1526
  // to the state context.
1552
1527
  function noop() { }
1553
1528
 
1554
- const NG_DEV_MODE$3 = typeof ngDevMode !== 'undefined' && ngDevMode;
1555
1529
  class Store {
1556
- constructor(_stateStream, _internalStateOperations, _config, _internalExecutionStrategy, _stateFactory, initialStateValue) {
1557
- this._stateStream = _stateStream;
1558
- this._internalStateOperations = _internalStateOperations;
1559
- this._config = _config;
1560
- this._internalExecutionStrategy = _internalExecutionStrategy;
1561
- this._stateFactory = _stateFactory;
1530
+ constructor() {
1531
+ this._stateStream = inject(_StateStream);
1532
+ this._internalStateOperations = inject(InternalStateOperations);
1533
+ this._config = inject(NgxsConfig);
1534
+ this._internalExecutionStrategy = inject(InternalNgxsExecutionStrategy);
1535
+ this._stateFactory = inject(StateFactory);
1562
1536
  /**
1563
1537
  * This is a derived state stream that leaves NGXS execution strategy to emit state changes within the Angular zone,
1564
1538
  * because state is being changed actually within the `<root>` zone, see `InternalDispatcher#dispatchSingle`.
1565
1539
  * All selects would use this stream, and it would call leave only once for any state change across all active selectors.
1566
1540
  */
1567
1541
  this._selectableStateStream = this._stateStream.pipe(leaveNgxs(this._internalExecutionStrategy), shareReplay$1({ bufferSize: 1, refCount: true }));
1568
- this.initStateStream(initialStateValue);
1542
+ this.initStateStream();
1569
1543
  }
1570
1544
  /**
1571
1545
  * Dispatches action(s).
1572
1546
  */
1573
1547
  dispatch(actionOrActions) {
1574
- if (NG_DEV_MODE$3) {
1548
+ if (typeof ngDevMode !== 'undefined' && ngDevMode) {
1575
1549
  if (
1576
1550
  // If a single action is dispatched and it's nullable.
1577
1551
  actionOrActions == null ||
@@ -1643,31 +1617,26 @@ class Store {
1643
1617
  const runtimeContext = this._stateFactory.getRuntimeSelectorContext();
1644
1618
  return makeSelectorFn(runtimeContext);
1645
1619
  }
1646
- initStateStream(initialStateValue) {
1620
+ initStateStream() {
1621
+ const initialStateValue = inject(_INITIAL_STATE_TOKEN);
1647
1622
  const value = this._stateStream.value;
1648
1623
  const storeIsEmpty = !value || Object.keys(value).length === 0;
1649
1624
  if (storeIsEmpty) {
1650
1625
  this._stateStream.next(initialStateValue);
1651
1626
  }
1652
1627
  }
1653
- /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.0.6", 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 }); }
1654
- /** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.0.6", ngImport: i0, type: Store, providedIn: 'root' }); }
1628
+ /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.0", ngImport: i0, type: Store, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
1629
+ /** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.0.0", ngImport: i0, type: Store, providedIn: 'root' }); }
1655
1630
  }
1656
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.0.6", ngImport: i0, type: Store, decorators: [{
1631
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.0", ngImport: i0, type: Store, decorators: [{
1657
1632
  type: Injectable,
1658
1633
  args: [{ providedIn: 'root' }]
1659
- }], ctorParameters: () => [{ type: i1.ɵStateStream }, { type: InternalStateOperations }, { type: NgxsConfig }, { type: InternalNgxsExecutionStrategy }, { type: StateFactory }, { type: undefined, decorators: [{
1660
- type: Optional
1661
- }, {
1662
- type: Inject,
1663
- args: [_INITIAL_STATE_TOKEN]
1664
- }] }] });
1634
+ }], ctorParameters: () => [] });
1665
1635
 
1666
- const NG_DEV_MODE$2 = typeof ngDevMode !== 'undefined' && ngDevMode;
1667
1636
  /**
1668
1637
  * InjectionToken that registers preboot functions (called before the root initializer).
1669
1638
  */
1670
- const NGXS_PREBOOT_FNS = new InjectionToken(NG_DEV_MODE$2 ? 'NGXS_PREBOOT_FNS' : '');
1639
+ const NGXS_PREBOOT_FNS = new InjectionToken(typeof ngDevMode !== 'undefined' && ngDevMode ? 'NGXS_PREBOOT_FNS' : '');
1671
1640
  /**
1672
1641
  * This function registers a preboot function which will be called before the root
1673
1642
  * store initializer is run, but after all of the NGXS features are provided and
@@ -1709,28 +1678,27 @@ class SelectFactory {
1709
1678
  SelectFactory.store = null;
1710
1679
  SelectFactory.config = null;
1711
1680
  }
1712
- /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.0.6", ngImport: i0, type: SelectFactory, deps: [{ token: Store }, { token: NgxsConfig }], target: i0.ɵɵFactoryTarget.Injectable }); }
1713
- /** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.0.6", ngImport: i0, type: SelectFactory, providedIn: 'root' }); }
1681
+ /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.0", ngImport: i0, type: SelectFactory, deps: [{ token: Store }, { token: NgxsConfig }], target: i0.ɵɵFactoryTarget.Injectable }); }
1682
+ /** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.0.0", ngImport: i0, type: SelectFactory, providedIn: 'root' }); }
1714
1683
  }
1715
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.0.6", ngImport: i0, type: SelectFactory, decorators: [{
1684
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.0", ngImport: i0, type: SelectFactory, decorators: [{
1716
1685
  type: Injectable,
1717
1686
  args: [{ providedIn: 'root' }]
1718
1687
  }], ctorParameters: () => [{ type: Store }, { type: NgxsConfig }] });
1719
1688
 
1720
- const NG_DEV_MODE$1 = typeof ngDevMode !== 'undefined' && ngDevMode;
1721
1689
  class LifecycleStateManager {
1722
- constructor(_store, _internalStateOperations, _stateContextFactory, _appBootstrappedState) {
1723
- this._store = _store;
1724
- this._internalStateOperations = _internalStateOperations;
1725
- this._stateContextFactory = _stateContextFactory;
1726
- this._appBootstrappedState = _appBootstrappedState;
1690
+ constructor() {
1691
+ this._store = inject(Store);
1692
+ this._internalStateOperations = inject(InternalStateOperations);
1693
+ this._stateContextFactory = inject(StateContextFactory);
1694
+ this._appBootstrappedState = inject(_NgxsAppBootstrappedState);
1727
1695
  this._destroy$ = new ReplaySubject(1);
1728
1696
  }
1729
1697
  ngOnDestroy() {
1730
1698
  this._destroy$.next();
1731
1699
  }
1732
1700
  ngxsBootstrap(action, results) {
1733
- if (NG_DEV_MODE$1) {
1701
+ if (typeof ngDevMode !== 'undefined' && ngDevMode) {
1734
1702
  if (action instanceof InitState) {
1735
1703
  this._initStateHasBeenDispatched = true;
1736
1704
  }
@@ -1748,7 +1716,7 @@ class LifecycleStateManager {
1748
1716
  this._internalStateOperations
1749
1717
  .getRootStateOperations()
1750
1718
  .dispatch(action)
1751
- .pipe(filter$1(() => !!results), tap(() => this._invokeInitOnStates(results.states)), mergeMap$1(() => this._appBootstrappedState), filter$1(appBootstrapped => !!appBootstrapped), takeUntil$1(this._destroy$))
1719
+ .pipe(filter$1(() => !!results), tap(() => this._invokeInitOnStates(results.states)), mergeMap(() => this._appBootstrappedState), filter$1(appBootstrapped => !!appBootstrapped), takeUntil$1(this._destroy$))
1752
1720
  .subscribe(() => this._invokeBootstrapOnStates(results.states));
1753
1721
  }
1754
1722
  _invokeInitOnStates(mappedStores) {
@@ -1780,21 +1748,25 @@ class LifecycleStateManager {
1780
1748
  _getStateContext(mappedStore) {
1781
1749
  return this._stateContextFactory.createStateContext(mappedStore.path);
1782
1750
  }
1783
- /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.0.6", ngImport: i0, type: LifecycleStateManager, deps: [{ token: Store }, { token: InternalStateOperations }, { token: StateContextFactory }, { token: i1.ɵNgxsAppBootstrappedState }], target: i0.ɵɵFactoryTarget.Injectable }); }
1784
- /** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.0.6", ngImport: i0, type: LifecycleStateManager, providedIn: 'root' }); }
1751
+ /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.0", ngImport: i0, type: LifecycleStateManager, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
1752
+ /** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.0.0", ngImport: i0, type: LifecycleStateManager, providedIn: 'root' }); }
1785
1753
  }
1786
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.0.6", ngImport: i0, type: LifecycleStateManager, decorators: [{
1754
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.0", ngImport: i0, type: LifecycleStateManager, decorators: [{
1787
1755
  type: Injectable,
1788
1756
  args: [{ providedIn: 'root' }]
1789
- }], ctorParameters: () => [{ type: Store }, { type: InternalStateOperations }, { type: StateContextFactory }, { type: i1.ɵNgxsAppBootstrappedState }] });
1757
+ }] });
1790
1758
 
1791
- const NG_DEV_MODE = typeof ngDevMode !== 'undefined' && ngDevMode;
1792
1759
  /**
1793
1760
  * This function is shared by both NgModule and standalone features.
1794
1761
  * When using `NgxsModule.forRoot` and `provideStore`, we can depend on the
1795
1762
  * same initialization functionality.
1796
1763
  */
1797
1764
  function rootStoreInitializer() {
1765
+ // Override the RxJS `config.onUnhandledError` within the root store initializer,
1766
+ // but only after other code has already executed.
1767
+ // If users have a custom `config.onUnhandledError`, we might overwrite it too
1768
+ // early and capture the original `config.onUnhandledError` before it is properly set.
1769
+ installOnUnhandhedErrorHandler();
1798
1770
  const prebootFns = inject(NGXS_PREBOOT_FNS, { optional: true }) || [];
1799
1771
  prebootFns.forEach(prebootFn => prebootFn());
1800
1772
  const factory = inject(StateFactory);
@@ -1836,11 +1808,11 @@ function featureStatesInitializer() {
1836
1808
  /**
1837
1809
  * InjectionToken that registers the global Store.
1838
1810
  */
1839
- const NGXS_ROOT_STORE_INITIALIZER = new InjectionToken(NG_DEV_MODE ? 'NGXS_ROOT_STORE_INITIALIZER' : '');
1811
+ const NGXS_ROOT_STORE_INITIALIZER = new InjectionToken(typeof ngDevMode !== 'undefined' && ngDevMode ? 'NGXS_ROOT_STORE_INITIALIZER' : '');
1840
1812
  /**
1841
1813
  * InjectionToken that registers feature states.
1842
1814
  */
1843
- const NGXS_FEATURE_STORE_INITIALIZER = new InjectionToken(NG_DEV_MODE ? 'NGXS_FEATURE_STORE_INITIALIZER' : '');
1815
+ const NGXS_FEATURE_STORE_INITIALIZER = new InjectionToken(typeof ngDevMode !== 'undefined' && ngDevMode ? 'NGXS_FEATURE_STORE_INITIALIZER' : '');
1844
1816
  const NGXS_ROOT_ENVIRONMENT_INITIALIZER = [
1845
1817
  { provide: NGXS_ROOT_STORE_INITIALIZER, useFactory: rootStoreInitializer },
1846
1818
  {
@@ -1875,11 +1847,11 @@ class NgxsRootModule {
1875
1847
  constructor() {
1876
1848
  rootStoreInitializer();
1877
1849
  }
1878
- /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.0.6", ngImport: i0, type: NgxsRootModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
1879
- /** @nocollapse */ static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "18.0.6", ngImport: i0, type: NgxsRootModule }); }
1880
- /** @nocollapse */ static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "18.0.6", ngImport: i0, type: NgxsRootModule }); }
1850
+ /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.0", ngImport: i0, type: NgxsRootModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
1851
+ /** @nocollapse */ static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "19.0.0", ngImport: i0, type: NgxsRootModule }); }
1852
+ /** @nocollapse */ static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "19.0.0", ngImport: i0, type: NgxsRootModule }); }
1881
1853
  }
1882
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.0.6", ngImport: i0, type: NgxsRootModule, decorators: [{
1854
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.0", ngImport: i0, type: NgxsRootModule, decorators: [{
1883
1855
  type: NgModule
1884
1856
  }], ctorParameters: () => [] });
1885
1857
 
@@ -1890,11 +1862,11 @@ class NgxsFeatureModule {
1890
1862
  constructor() {
1891
1863
  featureStatesInitializer();
1892
1864
  }
1893
- /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.0.6", ngImport: i0, type: NgxsFeatureModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
1894
- /** @nocollapse */ static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "18.0.6", ngImport: i0, type: NgxsFeatureModule }); }
1895
- /** @nocollapse */ static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "18.0.6", ngImport: i0, type: NgxsFeatureModule }); }
1865
+ /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.0", ngImport: i0, type: NgxsFeatureModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
1866
+ /** @nocollapse */ static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "19.0.0", ngImport: i0, type: NgxsFeatureModule }); }
1867
+ /** @nocollapse */ static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "19.0.0", ngImport: i0, type: NgxsFeatureModule }); }
1896
1868
  }
1897
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.0.6", ngImport: i0, type: NgxsFeatureModule, decorators: [{
1869
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.0", ngImport: i0, type: NgxsFeatureModule, decorators: [{
1898
1870
  type: NgModule
1899
1871
  }], ctorParameters: () => [] });
1900
1872
 
@@ -1904,8 +1876,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.0.6", ngImpor
1904
1876
  */
1905
1877
  function getRootProviders(states, options) {
1906
1878
  return [
1907
- StateFactory,
1908
- PluginManager,
1909
1879
  ...states,
1910
1880
  {
1911
1881
  provide: ROOT_STATE_TOKEN,
@@ -1936,7 +1906,6 @@ function getRootProviders(states, options) {
1936
1906
  */
1937
1907
  function getFeatureProviders(states) {
1938
1908
  return [
1939
- StateFactory,
1940
1909
  PluginManager,
1941
1910
  ...states,
1942
1911
  {
@@ -1960,11 +1929,11 @@ class NgxsModule {
1960
1929
  providers: getFeatureProviders(states)
1961
1930
  };
1962
1931
  }
1963
- /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.0.6", ngImport: i0, type: NgxsModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
1964
- /** @nocollapse */ static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "18.0.6", ngImport: i0, type: NgxsModule }); }
1965
- /** @nocollapse */ static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "18.0.6", ngImport: i0, type: NgxsModule }); }
1932
+ /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.0", ngImport: i0, type: NgxsModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
1933
+ /** @nocollapse */ static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "19.0.0", ngImport: i0, type: NgxsModule }); }
1934
+ /** @nocollapse */ static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "19.0.0", ngImport: i0, type: NgxsModule }); }
1966
1935
  }
1967
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.0.6", ngImport: i0, type: NgxsModule, decorators: [{
1936
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.0", ngImport: i0, type: NgxsModule, decorators: [{
1968
1937
  type: NgModule
1969
1938
  }] });
1970
1939
 
@@ -2182,11 +2151,11 @@ class NgxsDevelopmentModule {
2182
2151
  ]
2183
2152
  };
2184
2153
  }
2185
- /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.0.6", ngImport: i0, type: NgxsDevelopmentModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
2186
- /** @nocollapse */ static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "18.0.6", ngImport: i0, type: NgxsDevelopmentModule }); }
2187
- /** @nocollapse */ static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "18.0.6", ngImport: i0, type: NgxsDevelopmentModule }); }
2154
+ /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.0", ngImport: i0, type: NgxsDevelopmentModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
2155
+ /** @nocollapse */ static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "19.0.0", ngImport: i0, type: NgxsDevelopmentModule }); }
2156
+ /** @nocollapse */ static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "19.0.0", ngImport: i0, type: NgxsDevelopmentModule }); }
2188
2157
  }
2189
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.0.6", ngImport: i0, type: NgxsDevelopmentModule, decorators: [{
2158
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.0", ngImport: i0, type: NgxsDevelopmentModule, decorators: [{
2190
2159
  type: NgModule
2191
2160
  }] });
2192
2161
  function withNgxsDevelopmentOptions(options) {
@@ -2297,6 +2266,35 @@ function createPropertySelectors(parentSelector) {
2297
2266
  });
2298
2267
  }
2299
2268
 
2269
+ /**
2270
+ * This feature that contributes to app stability, which is required during
2271
+ * server-side rendering. With asynchronous actions being dispatched and handled,
2272
+ * Angular is unaware of them in zoneless mode and doesn't know whether the app is
2273
+ * still unstable. This may prematurely serialize the final HTML that is sent to the client.
2274
+ * Including `withNgxsPendingTasks` in your `provideStore` for your SSR
2275
+ * app will resolve the above issue.
2276
+ */
2277
+ function withNgxsPendingTasks() {
2278
+ return withNgxsPreboot(() => {
2279
+ const pendingTasks = inject(PendingTasks);
2280
+ const actions$ = inject(Actions);
2281
+ const actionToRemoveTaskFnMap = new Map();
2282
+ actions$.subscribe(ctx => {
2283
+ if (ctx.status === "DISPATCHED" /* ActionStatus.Dispatched */) {
2284
+ const removeTaskFn = pendingTasks.add();
2285
+ actionToRemoveTaskFnMap.set(ctx.action, removeTaskFn);
2286
+ }
2287
+ else {
2288
+ const removeTaskFn = actionToRemoveTaskFnMap.get(ctx.action);
2289
+ if (typeof removeTaskFn === 'function') {
2290
+ actionToRemoveTaskFnMap.delete(ctx.action);
2291
+ removeTaskFn();
2292
+ }
2293
+ }
2294
+ });
2295
+ });
2296
+ }
2297
+
2300
2298
  function provideStore(states = [], ...optionsAndFeatures) {
2301
2299
  const features = [];
2302
2300
  // Options are empty by default (see `forRoot`).
@@ -2359,11 +2357,17 @@ function provideStates(states, ...features) {
2359
2357
  */
2360
2358
  function withNgxsPlugin(plugin) {
2361
2359
  return makeEnvironmentProviders([
2362
- { provide: NGXS_PLUGINS, useClass: plugin, multi: true },
2360
+ _isPluginClass(plugin)
2361
+ ? { provide: NGXS_PLUGINS, useClass: plugin, multi: true }
2362
+ : { provide: NGXS_PLUGINS, useValue: plugin, multi: true },
2363
2363
  // We should inject the `PluginManager` to retrieve `NGXS_PLUGINS` and
2364
2364
  // register those plugins. The plugin can be added from inside the child
2365
2365
  // route, so the plugin manager should be re-injected.
2366
- { provide: ENVIRONMENT_INITIALIZER, useValue: () => inject(PluginManager), multi: true }
2366
+ {
2367
+ provide: ENVIRONMENT_INITIALIZER,
2368
+ useValue: () => inject(PluginManager),
2369
+ multi: true
2370
+ }
2367
2371
  ]);
2368
2372
  }
2369
2373
 
@@ -2434,5 +2438,5 @@ function ɵprovideNgxsInternalStateTokens() {
2434
2438
  * Generated bundle index. Do not edit.
2435
2439
  */
2436
2440
 
2437
- 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, ɵprovideNgxsInternalStateTokens };
2441
+ 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, withNgxsPendingTasks, withNgxsPlugin, withNgxsPreboot, NgxsFeatureModule as ɵNgxsFeatureModule, NgxsRootModule as ɵNgxsRootModule, ɵprovideNgxsInternalStateTokens };
2438
2442
  //# sourceMappingURL=ngxs-store.mjs.map