@ngxs/store 3.8.2-dev.master-dbed85b → 3.8.2-dev.master-81baa9d

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 (105) hide show
  1. package/esm2022/internals/custom-rxjs-subjects.mjs +92 -0
  2. package/esm2022/internals/index.mjs +9 -5
  3. package/esm2022/internals/initial-state.mjs +4 -4
  4. package/esm2022/internals/memoize.mjs +2 -2
  5. package/esm2022/internals/metadata.mjs +57 -0
  6. package/esm2022/internals/ngxs-app-bootstrapped-state.mjs +19 -0
  7. package/esm2022/internals/state-stream.mjs +32 -0
  8. package/esm2022/internals/state-token.mjs +17 -0
  9. package/esm2022/internals/symbols.mjs +1 -1
  10. package/esm2022/plugins/actions.mjs +16 -0
  11. package/esm2022/plugins/index.mjs +4 -0
  12. package/esm2022/plugins/ngxs-store-plugins.mjs +5 -0
  13. package/esm2022/plugins/symbols.mjs +6 -0
  14. package/esm2022/plugins/utils.mjs +51 -0
  15. package/esm2022/src/actions/symbols.mjs +1 -1
  16. package/esm2022/src/actions-stream.mjs +3 -3
  17. package/esm2022/src/configs/messages.config.mjs +1 -1
  18. package/esm2022/src/decorators/action.mjs +3 -3
  19. package/esm2022/src/decorators/select/symbols.mjs +1 -1
  20. package/esm2022/src/decorators/selector/symbols.mjs +1 -1
  21. package/esm2022/src/decorators/selector-options.mjs +1 -1
  22. package/esm2022/src/decorators/state.mjs +3 -4
  23. package/esm2022/src/dev-features/ngxs-development.module.mjs +8 -2
  24. package/esm2022/src/dev-features/ngxs-unhandled-actions-logger.mjs +2 -3
  25. package/esm2022/src/dev-features/symbols.mjs +3 -2
  26. package/esm2022/src/execution/dispatch-outside-zone-ngxs-execution-strategy.mjs +1 -1
  27. package/esm2022/src/internal/dispatcher.mjs +2 -2
  28. package/esm2022/src/internal/internals.mjs +3 -66
  29. package/esm2022/src/internal/lifecycle-state-manager.mjs +8 -9
  30. package/esm2022/src/internal/state-context-factory.mjs +2 -2
  31. package/esm2022/src/internal/state-factory.mjs +21 -22
  32. package/esm2022/src/internal/state-stream.mjs +6 -23
  33. package/esm2022/src/operators/of-action.mjs +2 -2
  34. package/esm2022/src/plugin-manager.mjs +2 -2
  35. package/esm2022/src/plugin_api.mjs +2 -5
  36. package/esm2022/src/public_api.mjs +3 -3
  37. package/esm2022/src/public_to_deprecate.mjs +18 -6
  38. package/esm2022/src/selectors/create-pick-selector.mjs +1 -1
  39. package/esm2022/src/selectors/selector-checks.util.mjs +3 -3
  40. package/esm2022/src/selectors/selector-metadata.mjs +3 -3
  41. package/esm2022/src/selectors/selector-models.mjs +1 -1
  42. package/esm2022/src/selectors/selector-types.util.mjs +1 -1
  43. package/esm2022/src/selectors/selector-utils.mjs +6 -7
  44. package/esm2022/src/standalone-features/initializers.mjs +1 -1
  45. package/esm2022/src/standalone-features/plugin.mjs +2 -2
  46. package/esm2022/src/standalone-features/root-providers.mjs +4 -4
  47. package/esm2022/src/store.mjs +4 -4
  48. package/esm2022/src/symbols.mjs +41 -12
  49. package/esm2022/src/utils/store-validators.mjs +3 -3
  50. package/fesm2022/ngxs-store-internals.mjs +222 -40
  51. package/fesm2022/ngxs-store-internals.mjs.map +1 -1
  52. package/fesm2022/ngxs-store-plugins.mjs +80 -0
  53. package/fesm2022/ngxs-store-plugins.mjs.map +1 -0
  54. package/fesm2022/ngxs-store.mjs +224 -468
  55. package/fesm2022/ngxs-store.mjs.map +1 -1
  56. package/{src/internal → internals}/custom-rxjs-subjects.d.ts +2 -2
  57. package/internals/index.d.ts +8 -4
  58. package/internals/initial-state.d.ts +5 -5
  59. package/internals/memoize.d.ts +1 -1
  60. package/internals/metadata.d.ts +25 -0
  61. package/internals/ngxs-app-bootstrapped-state.d.ts +8 -0
  62. package/internals/state-stream.d.ts +15 -0
  63. package/internals/state-token.d.ts +7 -0
  64. package/internals/symbols.d.ts +72 -2
  65. package/package.json +7 -1
  66. package/{src/actions → plugins}/actions.d.ts +3 -3
  67. package/plugins/index.d.ts +3 -0
  68. package/plugins/symbols.d.ts +13 -0
  69. package/{src/utils → plugins}/utils.d.ts +0 -17
  70. package/src/actions/symbols.d.ts +0 -14
  71. package/src/actions-stream.d.ts +2 -2
  72. package/src/configs/messages.config.d.ts +2 -2
  73. package/src/decorators/action.d.ts +3 -2
  74. package/src/decorators/select/symbols.d.ts +2 -3
  75. package/src/decorators/selector/symbols.d.ts +2 -3
  76. package/src/decorators/selector-options.d.ts +2 -2
  77. package/src/decorators/state.d.ts +2 -3
  78. package/src/dev-features/ngxs-development.module.d.ts +1 -0
  79. package/src/internal/internals.d.ts +8 -68
  80. package/src/internal/lifecycle-state-manager.d.ts +4 -4
  81. package/src/internal/state-factory.d.ts +5 -5
  82. package/src/internal/state-stream.d.ts +3 -9
  83. package/src/plugin-manager.d.ts +1 -1
  84. package/src/plugin_api.d.ts +1 -4
  85. package/src/public_api.d.ts +4 -3
  86. package/src/public_to_deprecate.d.ts +33 -21
  87. package/src/selectors/selector-metadata.d.ts +4 -4
  88. package/src/selectors/selector-models.d.ts +4 -4
  89. package/src/selectors/selector-types.util.d.ts +1 -2
  90. package/src/selectors/selector-utils.d.ts +3 -3
  91. package/src/standalone-features/plugin.d.ts +1 -1
  92. package/src/store.d.ts +1 -1
  93. package/src/symbols.d.ts +3 -35
  94. package/src/utils/store-validators.d.ts +4 -3
  95. package/esm2022/internals/ngxs-bootstrapper.mjs +0 -29
  96. package/esm2022/internals/src/symbols.mjs +0 -11
  97. package/esm2022/src/actions/actions.mjs +0 -16
  98. package/esm2022/src/internal/custom-rxjs-subjects.mjs +0 -92
  99. package/esm2022/src/state-token/state-token.mjs +0 -17
  100. package/esm2022/src/state-token/symbols.mjs +0 -2
  101. package/esm2022/src/utils/utils.mjs +0 -92
  102. package/internals/ngxs-bootstrapper.d.ts +0 -16
  103. package/internals/src/symbols.d.ts +0 -10
  104. package/src/state-token/state-token.d.ts +0 -7
  105. package/src/state-token/symbols.d.ts +0 -5
@@ -1,32 +1,74 @@
1
1
  import * as i0 from '@angular/core';
2
- import { Injectable, InjectionToken } from '@angular/core';
3
- import { ReplaySubject } from 'rxjs';
2
+ import { InjectionToken, Injectable } from '@angular/core';
3
+ import { ReplaySubject, Subject, BehaviorSubject } from 'rxjs';
4
+ import { toSignal } from '@angular/core/rxjs-interop';
4
5
 
5
- class NgxsBootstrapper {
6
- constructor() {
7
- /**
8
- * Use `ReplaySubject`, thus we can get cached value even if the stream is completed
9
- */
10
- this.bootstrap$ = new ReplaySubject(1);
11
- }
12
- get appBootstrapped$() {
13
- return this.bootstrap$.asObservable();
14
- }
15
- /**
16
- * This event will be emitted after attaching `ComponentRef` of the root component
17
- * to the tree of views, that's a signal that application has been fully rendered
18
- */
19
- bootstrap() {
20
- this.bootstrap$.next(true);
21
- this.bootstrap$.complete();
6
+ // This key is used to store metadata on state classes,
7
+ // such as actions and other related information.
8
+ const ɵMETA_KEY = 'NGXS_META';
9
+ // This key is used to store options on state classes
10
+ // provided through the `@State` decorator.
11
+ const ɵMETA_OPTIONS_KEY = 'NGXS_OPTIONS_META';
12
+ // This key is used to store selector metadata on selector functions,
13
+ // such as decorated with the `@Selector` or provided through the
14
+ // `createSelector` function.
15
+ const ɵSELECTOR_META_KEY = 'NGXS_SELECTOR_META';
16
+
17
+ /**
18
+ * Ensures metadata is attached to the class and returns it.
19
+ *
20
+ * @ignore
21
+ */
22
+ function ɵensureStoreMetadata(target) {
23
+ if (!target.hasOwnProperty(ɵMETA_KEY)) {
24
+ const defaultMetadata = {
25
+ name: null,
26
+ actions: {},
27
+ defaults: {},
28
+ path: null,
29
+ makeRootSelector(context) {
30
+ return context.getStateGetter(defaultMetadata.name);
31
+ },
32
+ children: []
33
+ };
34
+ Object.defineProperty(target, ɵMETA_KEY, { value: defaultMetadata });
22
35
  }
23
- /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.5", ngImport: i0, type: NgxsBootstrapper, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
24
- /** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.5", ngImport: i0, type: NgxsBootstrapper, providedIn: 'root' }); }
36
+ return ɵgetStoreMetadata(target);
37
+ }
38
+ /**
39
+ * Get the metadata attached to the state class if it exists.
40
+ *
41
+ * @ignore
42
+ */
43
+ function ɵgetStoreMetadata(target) {
44
+ return target[ɵMETA_KEY];
45
+ }
46
+ /**
47
+ * Ensures metadata is attached to the selector and returns it.
48
+ *
49
+ * @ignore
50
+ */
51
+ function ɵensureSelectorMetadata(target) {
52
+ if (!target.hasOwnProperty(ɵSELECTOR_META_KEY)) {
53
+ const defaultMetadata = {
54
+ makeRootSelector: null,
55
+ originalFn: null,
56
+ containerClass: null,
57
+ selectorName: null,
58
+ getSelectorOptions: () => ({})
59
+ };
60
+ Object.defineProperty(target, ɵSELECTOR_META_KEY, { value: defaultMetadata });
61
+ }
62
+ return ɵgetSelectorMetadata(target);
63
+ }
64
+ /**
65
+ * Get the metadata attached to the selector if it exists.
66
+ *
67
+ * @ignore
68
+ */
69
+ function ɵgetSelectorMetadata(target) {
70
+ return target[ɵSELECTOR_META_KEY];
25
71
  }
26
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.5", ngImport: i0, type: NgxsBootstrapper, decorators: [{
27
- type: Injectable,
28
- args: [{ providedIn: 'root' }]
29
- }] });
30
72
 
31
73
  function defaultEqualityCheck(a, b) {
32
74
  return a === b;
@@ -50,7 +92,7 @@ function areArgumentsShallowlyEqual(equalityCheck, prev, next) {
50
92
  *
51
93
  * @ignore
52
94
  */
53
- function memoize(func, equalityCheck = defaultEqualityCheck) {
95
+ function ɵmemoize(func, equalityCheck = defaultEqualityCheck) {
54
96
  let lastArgs = null;
55
97
  let lastResult = null;
56
98
  // we reference arguments instead of spreading them for performance reasons
@@ -73,8 +115,24 @@ function memoize(func, equalityCheck = defaultEqualityCheck) {
73
115
  return memoized;
74
116
  }
75
117
 
118
+ class StateToken {
119
+ constructor(_name) {
120
+ this._name = _name;
121
+ const selectorMetadata = ɵensureSelectorMetadata(this);
122
+ selectorMetadata.makeRootSelector = (runtimeContext) => {
123
+ return runtimeContext.getStateGetter(this._name);
124
+ };
125
+ }
126
+ getName() {
127
+ return this._name;
128
+ }
129
+ toString() {
130
+ return `StateToken[${this._name}]`;
131
+ }
132
+ }
133
+
76
134
  const NG_DEV_MODE$1 = typeof ngDevMode === 'undefined' || ngDevMode;
77
- class InitialState {
135
+ class ɵInitialState {
78
136
  static { this._value = {}; }
79
137
  static set(state) {
80
138
  this._value = state;
@@ -85,30 +143,154 @@ class InitialState {
85
143
  return state;
86
144
  }
87
145
  }
88
- const INITIAL_STATE_TOKEN = new InjectionToken(NG_DEV_MODE$1 ? 'INITIAL_STATE_TOKEN' : '', {
146
+ const ɵINITIAL_STATE_TOKEN = new InjectionToken(NG_DEV_MODE$1 ? 'INITIAL_STATE_TOKEN' : '', {
89
147
  providedIn: 'root',
90
- factory: () => InitialState.pop()
148
+ factory: () => ɵInitialState.pop()
91
149
  });
92
150
 
93
- // This key is used to store metadata on state classes,
94
- // such as actions and other related information.
95
- const ɵMETA_KEY = 'NGXS_META';
96
- // This key is used to store options on state classes
97
- // provided through the `@State` decorator.
98
- const ɵMETA_OPTIONS_KEY = 'NGXS_OPTIONS_META';
99
- // This key is used to store selector metadata on selector functions,
100
- // such as decorated with the `@Selector` or provided through the
101
- // `createSelector` function.
102
- const ɵSELECTOR_META_KEY = 'NGXS_SELECTOR_META';
151
+ class ɵNgxsAppBootstrappedState extends ReplaySubject {
152
+ constructor() {
153
+ super(1);
154
+ }
155
+ bootstrap() {
156
+ this.next(true);
157
+ this.complete();
158
+ }
159
+ /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.5", ngImport: i0, type: ɵNgxsAppBootstrappedState, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
160
+ /** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.5", ngImport: i0, type: ɵNgxsAppBootstrappedState, providedIn: 'root' }); }
161
+ }
162
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.5", ngImport: i0, type: ɵNgxsAppBootstrappedState, decorators: [{
163
+ type: Injectable,
164
+ args: [{ providedIn: 'root' }]
165
+ }], ctorParameters: () => [] });
103
166
 
104
167
  const NG_DEV_MODE = typeof ngDevMode === 'undefined' || ngDevMode;
105
168
  // These tokens are internal and can change at any point.
106
169
  const ɵNGXS_STATE_FACTORY = new InjectionToken(NG_DEV_MODE ? 'ɵNGXS_STATE_FACTORY' : '');
107
170
  const ɵNGXS_STATE_CONTEXT_FACTORY = new InjectionToken(NG_DEV_MODE ? 'ɵNGXS_STATE_CONTEXT_FACTORY' : '');
108
171
 
172
+ /**
173
+ * This wraps the provided function, and will enforce the following:
174
+ * - The calls will execute in the order that they are made
175
+ * - A call will only be initiated when the previous call has completed
176
+ * - If there is a call currently executing then the new call will be added
177
+ * to the queue and the function will return immediately
178
+ *
179
+ * NOTE: The following assumptions about the operation must hold true:
180
+ * - The operation is synchronous in nature
181
+ * - If any asynchronous side effects of the call exist, it should not
182
+ * have any bearing on the correctness of the next call in the queue
183
+ * - The operation has a void return
184
+ * - The caller should not assume that the call has completed upon
185
+ * return of the function
186
+ * - The caller can assume that all the queued calls will complete
187
+ * within the current microtask
188
+ * - The only way that a call will encounter another call in the queue
189
+ * would be if the call at the front of the queue initiated this call
190
+ * as part of its synchronous execution
191
+ */
192
+ function orderedQueueOperation(operation) {
193
+ const callsQueue = [];
194
+ let busyPushingNext = false;
195
+ return function callOperation(...args) {
196
+ if (busyPushingNext) {
197
+ callsQueue.unshift(args);
198
+ return;
199
+ }
200
+ busyPushingNext = true;
201
+ operation(...args);
202
+ while (callsQueue.length > 0) {
203
+ const nextCallArgs = callsQueue.pop();
204
+ nextCallArgs && operation(...nextCallArgs);
205
+ }
206
+ busyPushingNext = false;
207
+ };
208
+ }
209
+ /**
210
+ * Custom Subject that ensures that subscribers are notified of values in the order that they arrived.
211
+ * A standard Subject does not have this guarantee.
212
+ * For example, given the following code:
213
+ * ```typescript
214
+ * const subject = new Subject<string>();
215
+ subject.subscribe(value => {
216
+ if (value === 'start') subject.next('end');
217
+ });
218
+ subject.subscribe(value => { });
219
+ subject.next('start');
220
+ * ```
221
+ * When `subject` is a standard `Subject<T>` the second subscriber would recieve `end` and then `start`.
222
+ * When `subject` is a `OrderedSubject<T>` the second subscriber would recieve `start` and then `end`.
223
+ */
224
+ class ɵOrderedSubject extends Subject {
225
+ constructor() {
226
+ super(...arguments);
227
+ this._orderedNext = orderedQueueOperation((value) => super.next(value));
228
+ }
229
+ next(value) {
230
+ this._orderedNext(value);
231
+ }
232
+ }
233
+ /**
234
+ * Custom BehaviorSubject that ensures that subscribers are notified of values in the order that they arrived.
235
+ * A standard BehaviorSubject does not have this guarantee.
236
+ * For example, given the following code:
237
+ * ```typescript
238
+ * const subject = new BehaviorSubject<string>();
239
+ subject.subscribe(value => {
240
+ if (value === 'start') subject.next('end');
241
+ });
242
+ subject.subscribe(value => { });
243
+ subject.next('start');
244
+ * ```
245
+ * When `subject` is a standard `BehaviorSubject<T>` the second subscriber would recieve `end` and then `start`.
246
+ * When `subject` is a `OrderedBehaviorSubject<T>` the second subscriber would recieve `start` and then `end`.
247
+ */
248
+ class ɵOrderedBehaviorSubject extends BehaviorSubject {
249
+ constructor(value) {
250
+ super(value);
251
+ this._orderedNext = orderedQueueOperation((value) => super.next(value));
252
+ this._currentValue = value;
253
+ }
254
+ getValue() {
255
+ return this._currentValue;
256
+ }
257
+ next(value) {
258
+ this._currentValue = value;
259
+ this._orderedNext(value);
260
+ }
261
+ }
262
+
263
+ /**
264
+ * BehaviorSubject of the entire state.
265
+ * @ignore
266
+ */
267
+ class ɵStateStream extends ɵOrderedBehaviorSubject {
268
+ constructor() {
269
+ super({});
270
+ this.state = toSignal(this, {
271
+ manualCleanup: true,
272
+ requireSync: true
273
+ });
274
+ }
275
+ ngOnDestroy() {
276
+ // The StateStream should never emit values once the root view is removed,
277
+ // such as when the `NgModuleRef.destroy()` method is called. This is crucial
278
+ // for preventing memory leaks in server-side rendered apps, where a new StateStream
279
+ // is created for each HTTP request. If users forget to unsubscribe from `store.select`
280
+ // or `store.subscribe`, it can result in significant memory leaks in SSR apps.
281
+ this.complete();
282
+ }
283
+ /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.5", ngImport: i0, type: ɵStateStream, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
284
+ /** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.5", ngImport: i0, type: ɵStateStream, providedIn: 'root' }); }
285
+ }
286
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.5", ngImport: i0, type: ɵStateStream, decorators: [{
287
+ type: Injectable,
288
+ args: [{ providedIn: 'root' }]
289
+ }], ctorParameters: () => [] });
290
+
109
291
  /**
110
292
  * Generated bundle index. Do not edit.
111
293
  */
112
294
 
113
- export { INITIAL_STATE_TOKEN, InitialState, NgxsBootstrapper, memoize, ɵMETA_KEY, ɵMETA_OPTIONS_KEY, ɵNGXS_STATE_CONTEXT_FACTORY, ɵNGXS_STATE_FACTORY, ɵSELECTOR_META_KEY };
295
+ export { StateToken, ɵINITIAL_STATE_TOKEN, ɵInitialState, ɵMETA_KEY, ɵMETA_OPTIONS_KEY, ɵNGXS_STATE_CONTEXT_FACTORY, ɵNGXS_STATE_FACTORY, ɵNgxsAppBootstrappedState, ɵOrderedBehaviorSubject, ɵOrderedSubject, ɵSELECTOR_META_KEY, ɵStateStream, ɵensureSelectorMetadata, ɵensureStoreMetadata, ɵgetSelectorMetadata, ɵgetStoreMetadata, ɵmemoize };
114
296
  //# sourceMappingURL=ngxs-store-internals.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"ngxs-store-internals.mjs","sources":["../../../packages/store/internals/src/ngxs-bootstrapper.ts","../../../packages/store/internals/src/memoize.ts","../../../packages/store/internals/src/initial-state.ts","../../../packages/store/internals/src/symbols.ts","../../../packages/store/internals/src/internal-tokens.ts","../../../packages/store/internals/src/ngxs-store-internals.ts"],"sourcesContent":["import { Injectable } from '@angular/core';\nimport { Observable, ReplaySubject } from 'rxjs';\n\n@Injectable({ providedIn: 'root' })\nexport class NgxsBootstrapper {\n /**\n * Use `ReplaySubject`, thus we can get cached value even if the stream is completed\n */\n private bootstrap$ = new ReplaySubject<boolean>(1);\n\n get appBootstrapped$(): Observable<boolean> {\n return this.bootstrap$.asObservable();\n }\n\n /**\n * This event will be emitted after attaching `ComponentRef` of the root component\n * to the tree of views, that's a signal that application has been fully rendered\n */\n bootstrap(): void {\n this.bootstrap$.next(true);\n this.bootstrap$.complete();\n }\n}\n","function defaultEqualityCheck(a: any, b: any) {\n return a === b;\n}\n\nfunction areArgumentsShallowlyEqual(\n equalityCheck: (a: any, b: any) => boolean,\n prev: IArguments | null,\n next: IArguments | null\n) {\n if (prev === null || next === null || prev.length !== next.length) {\n return false;\n }\n\n // Do this in a for loop (and not a `forEach` or an `every`) so we can determine equality as fast as possible.\n const length = prev.length;\n for (let i = 0; i < length; i++) {\n if (!equalityCheck(prev[i], next[i])) {\n return false;\n }\n }\n\n return true;\n}\n\n/**\n * Memoize a function on its last inputs only.\n * Originally from: https://github.com/reduxjs/reselect/blob/master/src/index.js\n *\n * @ignore\n */\nexport function memoize<T extends (...args: any[]) => any>(\n func: T,\n equalityCheck = defaultEqualityCheck\n): T {\n let lastArgs: IArguments | null = null;\n let lastResult: any = null;\n // we reference arguments instead of spreading them for performance reasons\n function memoized() {\n // eslint-disable-next-line prefer-rest-params\n if (!areArgumentsShallowlyEqual(equalityCheck, lastArgs, arguments)) {\n // apply arguments instead of spreading for performance.\n // eslint-disable-next-line prefer-rest-params, prefer-spread\n lastResult = (<Function>func).apply(null, arguments);\n }\n // eslint-disable-next-line prefer-rest-params\n lastArgs = arguments;\n return lastResult;\n }\n (<any>memoized).reset = function () {\n // The hidden (for now) ability to reset the memoization\n lastArgs = null;\n lastResult = null;\n };\n return memoized as T;\n}\n","import { InjectionToken } from '@angular/core';\n\nimport { PlainObject } from './symbols';\n\ndeclare const ngDevMode: boolean;\n\nconst NG_DEV_MODE = typeof ngDevMode === 'undefined' || ngDevMode;\n\nexport class InitialState {\n private static _value: PlainObject = {};\n\n static set(state: PlainObject) {\n this._value = state;\n }\n\n static pop(): PlainObject {\n const state = this._value;\n this._value = {};\n return state;\n }\n}\n\nexport const INITIAL_STATE_TOKEN = new InjectionToken<PlainObject>(\n NG_DEV_MODE ? 'INITIAL_STATE_TOKEN' : '',\n {\n providedIn: 'root',\n factory: () => InitialState.pop()\n }\n);\n","export interface PlainObject {\n [key: string]: any;\n}\n\nexport interface PlainObjectOf<T> {\n [key: string]: T;\n}\n\nexport type ɵStateClass<T = any> = new (...args: any[]) => T;\n\n// This key is used to store metadata on state classes,\n// such as actions and other related information.\nexport const ɵMETA_KEY = 'NGXS_META';\n// This key is used to store options on state classes\n// provided through the `@State` decorator.\nexport const ɵMETA_OPTIONS_KEY = 'NGXS_OPTIONS_META';\n// This key is used to store selector metadata on selector functions,\n// such as decorated with the `@Selector` or provided through the\n// `createSelector` function.\nexport const ɵSELECTOR_META_KEY = 'NGXS_SELECTOR_META';\n","import { InjectionToken } from '@angular/core';\n\ndeclare const ngDevMode: boolean;\n\nconst NG_DEV_MODE = typeof ngDevMode === 'undefined' || ngDevMode;\n\n// These tokens are internal and can change at any point.\n\nexport const ɵNGXS_STATE_FACTORY = new InjectionToken<any>(\n NG_DEV_MODE ? 'ɵNGXS_STATE_FACTORY' : ''\n);\n\nexport const ɵNGXS_STATE_CONTEXT_FACTORY = new InjectionToken<any>(\n NG_DEV_MODE ? 'ɵNGXS_STATE_CONTEXT_FACTORY' : ''\n);\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\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KACd;;AAGU,MAAA,mBAAmB,GAAG,IAAI,cAAc,CACnDA,aAAW,GAAG,qBAAqB,GAAG,EAAE,EACxC;AACE,IAAA,UAAU,EAAE,MAAM;AAClB,IAAA,OAAO,EAAE,MAAM,YAAY,CAAC,GAAG,EAAE;AAClC,CAAA;;ACjBH;AACA;AACO,MAAM,SAAS,GAAG,YAAY;AACrC;AACA;AACO,MAAM,iBAAiB,GAAG,oBAAoB;AACrD;AACA;AACA;AACO,MAAM,kBAAkB,GAAG;;ACflC,MAAM,WAAW,GAAG,OAAO,SAAS,KAAK,WAAW,IAAI,SAAS,CAAC;AAElE;AAEa,MAAA,mBAAmB,GAAG,IAAI,cAAc,CACnD,WAAW,GAAG,qBAAqB,GAAG,EAAE,EACxC;AAEW,MAAA,2BAA2B,GAAG,IAAI,cAAc,CAC3D,WAAW,GAAG,6BAA6B,GAAG,EAAE;;ACblD;;AAEG;;;;"}
1
+ {"version":3,"file":"ngxs-store-internals.mjs","sources":["../../../packages/store/internals/src/symbols.ts","../../../packages/store/internals/src/metadata.ts","../../../packages/store/internals/src/memoize.ts","../../../packages/store/internals/src/state-token.ts","../../../packages/store/internals/src/initial-state.ts","../../../packages/store/internals/src/ngxs-app-bootstrapped-state.ts","../../../packages/store/internals/src/internal-tokens.ts","../../../packages/store/internals/src/custom-rxjs-subjects.ts","../../../packages/store/internals/src/state-stream.ts","../../../packages/store/internals/src/ngxs-store-internals.ts"],"sourcesContent":["import type { StateToken } from './state-token';\n\nexport interface ɵPlainObject {\n [key: string]: any;\n}\n\nexport interface ɵPlainObjectOf<T> {\n [key: string]: T;\n}\n\nexport type ɵStateClass<T = any> = new (...args: any[]) => T;\n\n// This key is used to store metadata on state classes,\n// such as actions and other related information.\nexport const ɵMETA_KEY = 'NGXS_META';\n// This key is used to store options on state classes\n// provided through the `@State` decorator.\nexport const ɵMETA_OPTIONS_KEY = 'NGXS_OPTIONS_META';\n// This key is used to store selector metadata on selector functions,\n// such as decorated with the `@Selector` or provided through the\n// `createSelector` function.\nexport const ɵSELECTOR_META_KEY = 'NGXS_SELECTOR_META';\n\nexport interface ɵStateToken<T, U> {\n new (name: ɵTokenName<T>): U;\n getName(): string;\n toString(): string;\n}\n\ntype RequireGeneric<T, U> = T extends void ? 'You must provide a type parameter' : U;\n\nexport type ɵTokenName<T> = string & RequireGeneric<T, string>;\n\nexport type ɵExtractTokenType<P> = P extends StateToken<infer T> ? T : never;\n\n/**\n * Options that can be provided to the store.\n */\nexport interface ɵStoreOptions<T> {\n /**\n * Name of the state. Required.\n */\n name: string | StateToken<T>;\n\n /**\n * Default values for the state. If not provided, uses empty object.\n */\n defaults?: T;\n\n /**\n * Sub states for the given state.\n */\n children?: ɵStateClass[];\n}\n\n// inspired from https://stackoverflow.com/a/43674389\nexport interface ɵStateClassInternal<T = any, U = any> extends ɵStateClass<T> {\n [ɵMETA_KEY]?: ɵMetaDataModel;\n [ɵMETA_OPTIONS_KEY]?: ɵStoreOptions<U>;\n}\n\nexport interface ɵMetaDataModel {\n name: string | null;\n actions: ɵPlainObjectOf<ɵActionHandlerMetaData[]>;\n defaults: any;\n path: string | null;\n makeRootSelector: ɵSelectorFactory | null;\n children?: ɵStateClassInternal[];\n}\n\nexport interface ɵSelectorMetaDataModel {\n makeRootSelector: ɵSelectorFactory | null;\n originalFn: Function | null;\n containerClass: any;\n selectorName: string | null;\n getSelectorOptions: () => ɵSharedSelectorOptions;\n}\n\nexport interface ɵSharedSelectorOptions {\n injectContainerState?: boolean;\n suppressErrors?: boolean;\n}\n\nexport interface ɵRuntimeSelectorContext {\n getStateGetter(key: any): (state: any) => any;\n getSelectorOptions(localOptions?: ɵSharedSelectorOptions): ɵSharedSelectorOptions;\n}\n\nexport type ɵSelectFromRootState = (rootState: any) => any;\nexport type ɵSelectorFactory = (\n runtimeContext: ɵRuntimeSelectorContext\n) => ɵSelectFromRootState;\n\n/**\n * Actions that can be provided in a action decorator.\n */\nexport interface ɵActionOptions {\n /**\n * Cancel the previous uncompleted observable(s).\n */\n cancelUncompleted?: boolean;\n}\n\nexport interface ɵActionHandlerMetaData {\n fn: string | symbol;\n options: ɵActionOptions;\n type: string;\n}\n","import {\n ɵMETA_KEY,\n ɵSELECTOR_META_KEY,\n ɵMetaDataModel,\n ɵStateClassInternal,\n ɵSelectorMetaDataModel,\n ɵRuntimeSelectorContext\n} from './symbols';\n\n/**\n * Ensures metadata is attached to the class and returns it.\n *\n * @ignore\n */\nexport function ɵensureStoreMetadata(target: ɵStateClassInternal): ɵMetaDataModel {\n if (!target.hasOwnProperty(ɵMETA_KEY)) {\n const defaultMetadata: ɵMetaDataModel = {\n name: null,\n actions: {},\n defaults: {},\n path: null,\n makeRootSelector(context: ɵRuntimeSelectorContext) {\n return context.getStateGetter(defaultMetadata.name);\n },\n children: []\n };\n\n Object.defineProperty(target, ɵMETA_KEY, { value: defaultMetadata });\n }\n return ɵgetStoreMetadata(target);\n}\n\n/**\n * Get the metadata attached to the state class if it exists.\n *\n * @ignore\n */\nexport function ɵgetStoreMetadata(target: ɵStateClassInternal): ɵMetaDataModel {\n return target[ɵMETA_KEY]!;\n}\n\n/**\n * Ensures metadata is attached to the selector and returns it.\n *\n * @ignore\n */\nexport function ɵensureSelectorMetadata(target: Function): ɵSelectorMetaDataModel {\n if (!target.hasOwnProperty(ɵSELECTOR_META_KEY)) {\n const defaultMetadata: ɵSelectorMetaDataModel = {\n makeRootSelector: null,\n originalFn: null,\n containerClass: null,\n selectorName: null,\n getSelectorOptions: () => ({})\n };\n\n Object.defineProperty(target, ɵSELECTOR_META_KEY, { value: defaultMetadata });\n }\n\n return ɵgetSelectorMetadata(target);\n}\n\n/**\n * Get the metadata attached to the selector if it exists.\n *\n * @ignore\n */\nexport function ɵgetSelectorMetadata(target: any): ɵSelectorMetaDataModel {\n return target[ɵSELECTOR_META_KEY];\n}\n","function defaultEqualityCheck(a: any, b: any) {\n return a === b;\n}\n\nfunction areArgumentsShallowlyEqual(\n equalityCheck: (a: any, b: any) => boolean,\n prev: IArguments | null,\n next: IArguments | null\n) {\n if (prev === null || next === null || prev.length !== next.length) {\n return false;\n }\n\n // Do this in a for loop (and not a `forEach` or an `every`) so we can determine equality as fast as possible.\n const length = prev.length;\n for (let i = 0; i < length; i++) {\n if (!equalityCheck(prev[i], next[i])) {\n return false;\n }\n }\n\n return true;\n}\n\n/**\n * Memoize a function on its last inputs only.\n * Originally from: https://github.com/reduxjs/reselect/blob/master/src/index.js\n *\n * @ignore\n */\nexport function ɵmemoize<T extends (...args: any[]) => any>(\n func: T,\n equalityCheck = defaultEqualityCheck\n): T {\n let lastArgs: IArguments | null = null;\n let lastResult: any = null;\n // we reference arguments instead of spreading them for performance reasons\n function memoized() {\n // eslint-disable-next-line prefer-rest-params\n if (!areArgumentsShallowlyEqual(equalityCheck, lastArgs, arguments)) {\n // apply arguments instead of spreading for performance.\n // eslint-disable-next-line prefer-rest-params, prefer-spread\n lastResult = (<Function>func).apply(null, arguments);\n }\n // eslint-disable-next-line prefer-rest-params\n lastArgs = arguments;\n return lastResult;\n }\n (<any>memoized).reset = function () {\n // The hidden (for now) ability to reset the memoization\n lastArgs = null;\n lastResult = null;\n };\n return memoized as T;\n}\n","import { ɵensureSelectorMetadata } from './metadata';\nimport type { ɵTokenName, ɵSelectFromRootState, ɵRuntimeSelectorContext } from './symbols';\n\nexport class StateToken<T = void> {\n constructor(private readonly _name: ɵTokenName<T>) {\n const selectorMetadata = ɵensureSelectorMetadata(<any>this);\n selectorMetadata.makeRootSelector = (\n runtimeContext: ɵRuntimeSelectorContext\n ): ɵSelectFromRootState => {\n return runtimeContext.getStateGetter(this._name);\n };\n }\n\n getName(): string {\n return this._name;\n }\n\n toString(): string {\n return `StateToken[${this._name}]`;\n }\n}\n","import { InjectionToken } from '@angular/core';\n\nimport { ɵPlainObject } from './symbols';\n\ndeclare const ngDevMode: boolean;\n\nconst NG_DEV_MODE = typeof ngDevMode === 'undefined' || ngDevMode;\n\nexport class ɵInitialState {\n private static _value: ɵPlainObject = {};\n\n static set(state: ɵPlainObject) {\n this._value = state;\n }\n\n static pop(): ɵPlainObject {\n const state = this._value;\n this._value = {};\n return state;\n }\n}\n\nexport const ɵINITIAL_STATE_TOKEN = new InjectionToken<ɵPlainObject>(\n NG_DEV_MODE ? 'INITIAL_STATE_TOKEN' : '',\n {\n providedIn: 'root',\n factory: () => ɵInitialState.pop()\n }\n);\n","import { Injectable } from '@angular/core';\nimport { ReplaySubject } from 'rxjs';\n\n@Injectable({ providedIn: 'root' })\nexport class ɵNgxsAppBootstrappedState extends ReplaySubject<boolean> {\n constructor() {\n super(1);\n }\n\n bootstrap(): void {\n this.next(true);\n this.complete();\n }\n}\n","import { InjectionToken } from '@angular/core';\n\ndeclare const ngDevMode: boolean;\n\nconst NG_DEV_MODE = typeof ngDevMode === 'undefined' || ngDevMode;\n\n// These tokens are internal and can change at any point.\n\nexport const ɵNGXS_STATE_FACTORY = new InjectionToken<any>(\n NG_DEV_MODE ? 'ɵNGXS_STATE_FACTORY' : ''\n);\n\nexport const ɵNGXS_STATE_CONTEXT_FACTORY = new InjectionToken<any>(\n NG_DEV_MODE ? 'ɵNGXS_STATE_CONTEXT_FACTORY' : ''\n);\n","import { BehaviorSubject, Subject } from 'rxjs';\n\n/**\n * This wraps the provided function, and will enforce the following:\n * - The calls will execute in the order that they are made\n * - A call will only be initiated when the previous call has completed\n * - If there is a call currently executing then the new call will be added\n * to the queue and the function will return immediately\n *\n * NOTE: The following assumptions about the operation must hold true:\n * - The operation is synchronous in nature\n * - If any asynchronous side effects of the call exist, it should not\n * have any bearing on the correctness of the next call in the queue\n * - The operation has a void return\n * - The caller should not assume that the call has completed upon\n * return of the function\n * - The caller can assume that all the queued calls will complete\n * within the current microtask\n * - The only way that a call will encounter another call in the queue\n * would be if the call at the front of the queue initiated this call\n * as part of its synchronous execution\n */\nfunction orderedQueueOperation<TArgs extends any[]>(operation: (...args: TArgs) => void) {\n const callsQueue: TArgs[] = [];\n let busyPushingNext = false;\n return function callOperation(...args: TArgs) {\n if (busyPushingNext) {\n callsQueue.unshift(args);\n return;\n }\n busyPushingNext = true;\n operation(...args);\n while (callsQueue.length > 0) {\n const nextCallArgs = callsQueue.pop();\n nextCallArgs && operation(...nextCallArgs);\n }\n busyPushingNext = false;\n };\n}\n\n/**\n * Custom Subject that ensures that subscribers are notified of values in the order that they arrived.\n * A standard Subject does not have this guarantee.\n * For example, given the following code:\n * ```typescript\n * const subject = new Subject<string>();\n subject.subscribe(value => {\n if (value === 'start') subject.next('end');\n });\n subject.subscribe(value => { });\n subject.next('start');\n * ```\n * When `subject` is a standard `Subject<T>` the second subscriber would recieve `end` and then `start`.\n * When `subject` is a `OrderedSubject<T>` the second subscriber would recieve `start` and then `end`.\n */\nexport class ɵOrderedSubject<T> extends Subject<T> {\n private _orderedNext = orderedQueueOperation((value?: T) => super.next(<T>value));\n\n next(value?: T): void {\n this._orderedNext(value);\n }\n}\n\n/**\n * Custom BehaviorSubject that ensures that subscribers are notified of values in the order that they arrived.\n * A standard BehaviorSubject does not have this guarantee.\n * For example, given the following code:\n * ```typescript\n * const subject = new BehaviorSubject<string>();\n subject.subscribe(value => {\n if (value === 'start') subject.next('end');\n });\n subject.subscribe(value => { });\n subject.next('start');\n * ```\n * When `subject` is a standard `BehaviorSubject<T>` the second subscriber would recieve `end` and then `start`.\n * When `subject` is a `OrderedBehaviorSubject<T>` the second subscriber would recieve `start` and then `end`.\n */\nexport class ɵOrderedBehaviorSubject<T> extends BehaviorSubject<T> {\n private _orderedNext = orderedQueueOperation((value: T) => super.next(value));\n private _currentValue: T;\n\n constructor(value: T) {\n super(value);\n this._currentValue = value;\n }\n\n getValue(): T {\n return this._currentValue;\n }\n\n next(value: T): void {\n this._currentValue = value;\n this._orderedNext(value);\n }\n}\n","import { Injectable, OnDestroy, Signal } from '@angular/core';\nimport { toSignal } from '@angular/core/rxjs-interop';\n\nimport { ɵPlainObject } from './symbols';\nimport { ɵOrderedBehaviorSubject } from './custom-rxjs-subjects';\n\n/**\n * BehaviorSubject of the entire state.\n * @ignore\n */\n@Injectable({ providedIn: 'root' })\nexport class ɵStateStream extends ɵOrderedBehaviorSubject<ɵPlainObject> implements OnDestroy {\n readonly state: Signal<ɵPlainObject> = toSignal(this, {\n manualCleanup: true,\n requireSync: true\n });\n\n constructor() {\n super({});\n }\n\n ngOnDestroy(): void {\n // The StateStream should never emit values once the root view is removed,\n // such as when the `NgModuleRef.destroy()` method is called. This is crucial\n // for preventing memory leaks in server-side rendered apps, where a new StateStream\n // is created for each HTTP request. If users forget to unsubscribe from `store.select`\n // or `store.subscribe`, it can result in significant memory leaks in SSR apps.\n this.complete();\n }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":["NG_DEV_MODE"],"mappings":";;;;;AAYA;AACA;AACO,MAAM,SAAS,GAAG,YAAY;AACrC;AACA;AACO,MAAM,iBAAiB,GAAG,oBAAoB;AACrD;AACA;AACA;AACO,MAAM,kBAAkB,GAAG;;ACZlC;;;;AAIG;AACG,SAAU,oBAAoB,CAAC,MAA2B,EAAA;AAC9D,IAAA,IAAI,CAAC,MAAM,CAAC,cAAc,CAAC,SAAS,CAAC,EAAE;AACrC,QAAA,MAAM,eAAe,GAAmB;AACtC,YAAA,IAAI,EAAE,IAAI;AACV,YAAA,OAAO,EAAE,EAAE;AACX,YAAA,QAAQ,EAAE,EAAE;AACZ,YAAA,IAAI,EAAE,IAAI;AACV,YAAA,gBAAgB,CAAC,OAAgC,EAAA;gBAC/C,OAAO,OAAO,CAAC,cAAc,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;aACrD;AACD,YAAA,QAAQ,EAAE,EAAE;SACb,CAAC;AAEF,QAAA,MAAM,CAAC,cAAc,CAAC,MAAM,EAAE,SAAS,EAAE,EAAE,KAAK,EAAE,eAAe,EAAE,CAAC,CAAC;AACtE,KAAA;AACD,IAAA,OAAO,iBAAiB,CAAC,MAAM,CAAC,CAAC;AACnC,CAAC;AAED;;;;AAIG;AACG,SAAU,iBAAiB,CAAC,MAA2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*/
6
+ class InitState {
7
+ static { this.type = '@@INIT'; }
8
+ }
9
+ /**
10
+ * Update action
11
+ */
12
+ class UpdateState {
13
+ static { this.type = '@@UPDATE_STATE'; }
14
+ constructor(addedStates) {
15
+ this.addedStates = addedStates;
16
+ }
17
+ }
18
+
19
+ const NG_DEV_MODE = typeof ngDevMode === 'undefined' || ngDevMode;
20
+ // The injection token is used to resolve to custom NGXS plugins provided
21
+ // at the root level through either `{provide}` scheme or `withNgxsPlugin`.
22
+ const NGXS_PLUGINS = new InjectionToken(NG_DEV_MODE ? 'NGXS_PLUGINS' : '');
23
+
24
+ /**
25
+ * Returns the type from an action instance/class.
26
+ * @ignore
27
+ */
28
+ function getActionTypeFromInstance(action) {
29
+ return action.constructor?.type || action.type;
30
+ }
31
+ /**
32
+ * Matches a action
33
+ * @ignore
34
+ */
35
+ function actionMatcher(action1) {
36
+ const type1 = getActionTypeFromInstance(action1);
37
+ return function (action2) {
38
+ return type1 === getActionTypeFromInstance(action2);
39
+ };
40
+ }
41
+ /**
42
+ * Set a deeply nested value. Example:
43
+ *
44
+ * setValue({ foo: { bar: { eat: false } } },
45
+ * 'foo.bar.eat', true) //=> { foo: { bar: { eat: true } } }
46
+ *
47
+ * While it traverses it also creates new objects from top down.
48
+ *
49
+ * @ignore
50
+ */
51
+ const setValue = (obj, prop, val) => {
52
+ obj = { ...obj };
53
+ const split = prop.split('.');
54
+ const lastIndex = split.length - 1;
55
+ split.reduce((acc, part, index) => {
56
+ if (index === lastIndex) {
57
+ acc[part] = val;
58
+ }
59
+ else {
60
+ acc[part] = Array.isArray(acc[part]) ? acc[part].slice() : { ...acc[part] };
61
+ }
62
+ return acc && acc[part];
63
+ }, obj);
64
+ return obj;
65
+ };
66
+ /**
67
+ * Get a deeply nested value. Example:
68
+ *
69
+ * getValue({ foo: bar: [] }, 'foo.bar') //=> []
70
+ *
71
+ * @ignore
72
+ */
73
+ const getValue = (obj, prop) => prop.split('.').reduce((acc, part) => acc && acc[part], obj);
74
+
75
+ /**
76
+ * Generated bundle index. Do not edit.
77
+ */
78
+
79
+ export { InitState, NGXS_PLUGINS, UpdateState, actionMatcher, getActionTypeFromInstance, getValue, setValue };
80
+ //# sourceMappingURL=ngxs-store-plugins.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ngxs-store-plugins.mjs","sources":["../../../packages/store/plugins/src/actions.ts","../../../packages/store/plugins/src/symbols.ts","../../../packages/store/plugins/src/utils.ts","../../../packages/store/plugins/src/ngxs-store-plugins.ts"],"sourcesContent":["import { ɵPlainObject } from '@ngxs/store/internals';\n\n/**\n * Init action\n */\nexport class InitState {\n static readonly type = '@@INIT';\n}\n\n/**\n * Update action\n */\nexport class UpdateState {\n static readonly type = '@@UPDATE_STATE';\n\n constructor(readonly addedStates?: ɵPlainObject) {}\n}\n","import { InjectionToken } from '@angular/core';\n\ndeclare const ngDevMode: boolean;\n\nconst NG_DEV_MODE = typeof ngDevMode === 'undefined' || ngDevMode;\n\n// The injection token is used to resolve to custom NGXS plugins provided\n// at the root level through either `{provide}` scheme or `withNgxsPlugin`.\nexport const NGXS_PLUGINS = new InjectionToken(NG_DEV_MODE ? 'NGXS_PLUGINS' : '');\n\nexport type NgxsPluginFn = (state: any, mutation: any, next: NgxsNextPluginFn) => any;\n\nexport type NgxsNextPluginFn = (state: any, mutation: any) => any;\n\n/**\n * Plugin interface\n */\nexport interface NgxsPlugin {\n /**\n * Handle the state/action before its submitted to the state handlers.\n */\n handle(state: any, action: any, next: NgxsNextPluginFn): any;\n}\n","/**\n * Returns the type from an action instance/class.\n * @ignore\n */\nexport function getActionTypeFromInstance(action: any): string | undefined {\n return action.constructor?.type || action.type;\n}\n\n/**\n * Matches a action\n * @ignore\n */\nexport function actionMatcher(action1: any) {\n const type1 = getActionTypeFromInstance(action1);\n\n return function (action2: any) {\n return type1 === getActionTypeFromInstance(action2);\n };\n}\n\n/**\n * Set a deeply nested value. Example:\n *\n * setValue({ foo: { bar: { eat: false } } },\n * 'foo.bar.eat', true) //=> { foo: { bar: { eat: true } } }\n *\n * While it traverses it also creates new objects from top down.\n *\n * @ignore\n */\nexport const setValue = (obj: any, prop: string, val: any) => {\n obj = { ...obj };\n\n const split = prop.split('.');\n const lastIndex = split.length - 1;\n\n split.reduce((acc, part, index) => {\n if (index === lastIndex) {\n acc[part] = val;\n } else {\n acc[part] = Array.isArray(acc[part]) ? acc[part].slice() : { ...acc[part] };\n }\n\n return acc && acc[part];\n }, obj);\n\n return obj;\n};\n\n/**\n * Get a deeply nested value. Example:\n *\n * getValue({ foo: bar: [] }, 'foo.bar') //=> []\n *\n * @ignore\n */\nexport const getValue = (obj: any, prop: string): any =>\n prop.split('.').reduce((acc: any, part: string) => acc && acc[part], obj);\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;AAEA;;AAEG;MACU,SAAS,CAAA;aACJ,IAAI,CAAA,IAAA,GAAG,QAAQ,CAAC,EAAA;;AAGlC;;AAEG;MACU,WAAW,CAAA;aACN,IAAI,CAAA,IAAA,GAAG,gBAAgB,CAAC,EAAA;AAExC,IAAA,WAAA,CAAqB,WAA0B,EAAA;QAA1B,IAAW,CAAA,WAAA,GAAX,WAAW,CAAe;KAAI;;;ACXrD,MAAM,WAAW,GAAG,OAAO,SAAS,KAAK,WAAW,IAAI,SAAS,CAAC;AAElE;AACA;AACa,MAAA,YAAY,GAAG,IAAI,cAAc,CAAC,WAAW,GAAG,cAAc,GAAG,EAAE;;ACRhF;;;AAGG;AACG,SAAU,yBAAyB,CAAC,MAAW,EAAA;IACnD,OAAO,MAAM,CAAC,WAAW,EAAE,IAAI,IAAI,MAAM,CAAC,IAAI,CAAC;AACjD,CAAC;AAED;;;AAGG;AACG,SAAU,aAAa,CAAC,OAAY,EAAA;AACxC,IAAA,MAAM,KAAK,GAAG,yBAAyB,CAAC,OAAO,CAAC,CAAC;AAEjD,IAAA,OAAO,UAAU,OAAY,EAAA;AAC3B,QAAA,OAAO,KAAK,KAAK,yBAAy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