@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.
- package/esm2022/internals/custom-rxjs-subjects.mjs +92 -0
- package/esm2022/internals/index.mjs +9 -5
- package/esm2022/internals/initial-state.mjs +4 -4
- package/esm2022/internals/memoize.mjs +2 -2
- package/esm2022/internals/metadata.mjs +57 -0
- package/esm2022/internals/ngxs-app-bootstrapped-state.mjs +19 -0
- package/esm2022/internals/state-stream.mjs +32 -0
- package/esm2022/internals/state-token.mjs +17 -0
- package/esm2022/internals/symbols.mjs +1 -1
- package/esm2022/plugins/actions.mjs +16 -0
- package/esm2022/plugins/index.mjs +4 -0
- package/esm2022/plugins/ngxs-store-plugins.mjs +5 -0
- package/esm2022/plugins/symbols.mjs +6 -0
- package/esm2022/plugins/utils.mjs +51 -0
- package/esm2022/src/actions/symbols.mjs +1 -1
- package/esm2022/src/actions-stream.mjs +3 -3
- package/esm2022/src/configs/messages.config.mjs +1 -1
- package/esm2022/src/decorators/action.mjs +3 -3
- package/esm2022/src/decorators/select/symbols.mjs +1 -1
- package/esm2022/src/decorators/selector/symbols.mjs +1 -1
- package/esm2022/src/decorators/selector-options.mjs +1 -1
- package/esm2022/src/decorators/state.mjs +3 -4
- package/esm2022/src/dev-features/ngxs-development.module.mjs +8 -2
- package/esm2022/src/dev-features/ngxs-unhandled-actions-logger.mjs +2 -3
- package/esm2022/src/dev-features/symbols.mjs +3 -2
- package/esm2022/src/execution/dispatch-outside-zone-ngxs-execution-strategy.mjs +1 -1
- package/esm2022/src/internal/dispatcher.mjs +2 -2
- package/esm2022/src/internal/internals.mjs +3 -66
- package/esm2022/src/internal/lifecycle-state-manager.mjs +8 -9
- package/esm2022/src/internal/state-context-factory.mjs +2 -2
- package/esm2022/src/internal/state-factory.mjs +21 -22
- package/esm2022/src/internal/state-stream.mjs +6 -23
- package/esm2022/src/operators/of-action.mjs +2 -2
- package/esm2022/src/plugin-manager.mjs +2 -2
- package/esm2022/src/plugin_api.mjs +2 -5
- package/esm2022/src/public_api.mjs +3 -3
- package/esm2022/src/public_to_deprecate.mjs +18 -6
- package/esm2022/src/selectors/create-pick-selector.mjs +1 -1
- package/esm2022/src/selectors/selector-checks.util.mjs +3 -3
- package/esm2022/src/selectors/selector-metadata.mjs +3 -3
- package/esm2022/src/selectors/selector-models.mjs +1 -1
- package/esm2022/src/selectors/selector-types.util.mjs +1 -1
- package/esm2022/src/selectors/selector-utils.mjs +6 -7
- package/esm2022/src/standalone-features/initializers.mjs +1 -1
- package/esm2022/src/standalone-features/plugin.mjs +2 -2
- package/esm2022/src/standalone-features/root-providers.mjs +4 -4
- package/esm2022/src/store.mjs +4 -4
- package/esm2022/src/symbols.mjs +41 -12
- package/esm2022/src/utils/store-validators.mjs +3 -3
- package/fesm2022/ngxs-store-internals.mjs +222 -40
- package/fesm2022/ngxs-store-internals.mjs.map +1 -1
- package/fesm2022/ngxs-store-plugins.mjs +80 -0
- package/fesm2022/ngxs-store-plugins.mjs.map +1 -0
- package/fesm2022/ngxs-store.mjs +224 -468
- package/fesm2022/ngxs-store.mjs.map +1 -1
- package/{src/internal → internals}/custom-rxjs-subjects.d.ts +2 -2
- package/internals/index.d.ts +8 -4
- package/internals/initial-state.d.ts +5 -5
- package/internals/memoize.d.ts +1 -1
- package/internals/metadata.d.ts +25 -0
- package/internals/ngxs-app-bootstrapped-state.d.ts +8 -0
- package/internals/state-stream.d.ts +15 -0
- package/internals/state-token.d.ts +7 -0
- package/internals/symbols.d.ts +72 -2
- package/package.json +7 -1
- package/{src/actions → plugins}/actions.d.ts +3 -3
- package/plugins/index.d.ts +3 -0
- package/plugins/symbols.d.ts +13 -0
- package/{src/utils → plugins}/utils.d.ts +0 -17
- package/src/actions/symbols.d.ts +0 -14
- package/src/actions-stream.d.ts +2 -2
- package/src/configs/messages.config.d.ts +2 -2
- package/src/decorators/action.d.ts +3 -2
- package/src/decorators/select/symbols.d.ts +2 -3
- package/src/decorators/selector/symbols.d.ts +2 -3
- package/src/decorators/selector-options.d.ts +2 -2
- package/src/decorators/state.d.ts +2 -3
- package/src/dev-features/ngxs-development.module.d.ts +1 -0
- package/src/internal/internals.d.ts +8 -68
- package/src/internal/lifecycle-state-manager.d.ts +4 -4
- package/src/internal/state-factory.d.ts +5 -5
- package/src/internal/state-stream.d.ts +3 -9
- package/src/plugin-manager.d.ts +1 -1
- package/src/plugin_api.d.ts +1 -4
- package/src/public_api.d.ts +4 -3
- package/src/public_to_deprecate.d.ts +33 -21
- package/src/selectors/selector-metadata.d.ts +4 -4
- package/src/selectors/selector-models.d.ts +4 -4
- package/src/selectors/selector-types.util.d.ts +1 -2
- package/src/selectors/selector-utils.d.ts +3 -3
- package/src/standalone-features/plugin.d.ts +1 -1
- package/src/store.d.ts +1 -1
- package/src/symbols.d.ts +3 -35
- package/src/utils/store-validators.d.ts +4 -3
- package/esm2022/internals/ngxs-bootstrapper.mjs +0 -29
- package/esm2022/internals/src/symbols.mjs +0 -11
- package/esm2022/src/actions/actions.mjs +0 -16
- package/esm2022/src/internal/custom-rxjs-subjects.mjs +0 -92
- package/esm2022/src/state-token/state-token.mjs +0 -17
- package/esm2022/src/state-token/symbols.mjs +0 -2
- package/esm2022/src/utils/utils.mjs +0 -92
- package/internals/ngxs-bootstrapper.d.ts +0 -16
- package/internals/src/symbols.d.ts +0 -10
- package/src/state-token/state-token.d.ts +0 -7
- package/src/state-token/symbols.d.ts +0 -5
package/fesm2022/ngxs-store.mjs
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
2
|
import { Injectable, NgZone, PLATFORM_ID, Inject, InjectionToken, inject, INJECTOR, ɵglobal as _global, ErrorHandler, Optional, SkipSelf, ɵisPromise as _isPromise, computed, ENVIRONMENT_INITIALIZER, NgModule, APP_BOOTSTRAP_LISTENER, makeEnvironmentProviders } from '@angular/core';
|
|
3
|
-
import { Observable, Subject,
|
|
3
|
+
import { Observable, Subject, of, forkJoin, throwError, EMPTY, from, isObservable, ReplaySubject } from 'rxjs';
|
|
4
4
|
import { share, shareReplay, filter, take, exhaustMap, map, mergeMap, defaultIfEmpty, catchError, takeUntil, distinctUntilChanged, tap, startWith, pairwise } from 'rxjs/operators';
|
|
5
5
|
import * as i5 from '@ngxs/store/internals';
|
|
6
|
-
import { ɵMETA_KEY as _META_KEY, ɵ
|
|
6
|
+
import { ɵ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, ɵNGXS_STATE_CONTEXT_FACTORY as _NGXS_STATE_CONTEXT_FACTORY, ɵNGXS_STATE_FACTORY as _NGXS_STATE_FACTORY, ɵensureStoreMetadata as _ensureStoreMetadata, ɵMETA_OPTIONS_KEY as _META_OPTIONS_KEY, ɵensureSelectorMetadata as _ensureSelectorMetadata } from '@ngxs/store/internals';
|
|
7
|
+
export { StateToken } from '@ngxs/store/internals';
|
|
7
8
|
import { isPlatformServer } from '@angular/common';
|
|
8
|
-
import {
|
|
9
|
+
import { NGXS_PLUGINS, getActionTypeFromInstance, setValue, getValue, InitState, UpdateState } from '@ngxs/store/plugins';
|
|
10
|
+
export { InitState, NGXS_PLUGINS, UpdateState, actionMatcher, getActionTypeFromInstance, getValue, setValue } from '@ngxs/store/plugins';
|
|
9
11
|
import { isStateOperator } from '@ngxs/store/operators';
|
|
10
12
|
|
|
11
13
|
class NoopNgxsExecutionStrategy {
|
|
@@ -124,18 +126,18 @@ function verifyZoneIsNotNooped(ngZone) {
|
|
|
124
126
|
console.warn(getZoneWarningMessage());
|
|
125
127
|
}
|
|
126
128
|
|
|
127
|
-
const NG_DEV_MODE$
|
|
129
|
+
const NG_DEV_MODE$5 = typeof ngDevMode === 'undefined' || ngDevMode;
|
|
128
130
|
/**
|
|
129
131
|
* Consumers have the option to utilize the execution strategy provided by
|
|
130
132
|
* `NgxsModule.forRoot({executionStrategy})` or `provideStore([], {executionStrategy})`.
|
|
131
133
|
*/
|
|
132
|
-
const CUSTOM_NGXS_EXECUTION_STRATEGY = new InjectionToken(NG_DEV_MODE$
|
|
134
|
+
const CUSTOM_NGXS_EXECUTION_STRATEGY = new InjectionToken(NG_DEV_MODE$5 ? 'CUSTOM_NGXS_EXECUTION_STRATEGY' : '');
|
|
133
135
|
/**
|
|
134
136
|
* The injection token is used internally to resolve an instance of the execution
|
|
135
137
|
* strategy. It checks whether consumers have provided their own `executionStrategy`
|
|
136
138
|
* and also verifies if we are operating in a zone-aware environment.
|
|
137
139
|
*/
|
|
138
|
-
const NGXS_EXECUTION_STRATEGY = new InjectionToken(NG_DEV_MODE$
|
|
140
|
+
const NGXS_EXECUTION_STRATEGY = new InjectionToken(NG_DEV_MODE$5 ? 'NGXS_EXECUTION_STRATEGY' : '', {
|
|
139
141
|
providedIn: 'root',
|
|
140
142
|
factory: () => {
|
|
141
143
|
const injector = inject(INJECTOR);
|
|
@@ -277,101 +279,10 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.5", ngImpor
|
|
|
277
279
|
args: [{ providedIn: 'root' }]
|
|
278
280
|
}], ctorParameters: () => [{ type: i0.Injector }] });
|
|
279
281
|
|
|
280
|
-
/**
|
|
281
|
-
* This wraps the provided function, and will enforce the following:
|
|
282
|
-
* - The calls will execute in the order that they are made
|
|
283
|
-
* - A call will only be initiated when the previous call has completed
|
|
284
|
-
* - If there is a call currently executing then the new call will be added
|
|
285
|
-
* to the queue and the function will return immediately
|
|
286
|
-
*
|
|
287
|
-
* NOTE: The following assumptions about the operation must hold true:
|
|
288
|
-
* - The operation is synchronous in nature
|
|
289
|
-
* - If any asynchronous side effects of the call exist, it should not
|
|
290
|
-
* have any bearing on the correctness of the next call in the queue
|
|
291
|
-
* - The operation has a void return
|
|
292
|
-
* - The caller should not assume that the call has completed upon
|
|
293
|
-
* return of the function
|
|
294
|
-
* - The caller can assume that all the queued calls will complete
|
|
295
|
-
* within the current microtask
|
|
296
|
-
* - The only way that a call will encounter another call in the queue
|
|
297
|
-
* would be if the call at the front of the queue initiated this call
|
|
298
|
-
* as part of its synchronous execution
|
|
299
|
-
*/
|
|
300
|
-
function orderedQueueOperation(operation) {
|
|
301
|
-
const callsQueue = [];
|
|
302
|
-
let busyPushingNext = false;
|
|
303
|
-
return function callOperation(...args) {
|
|
304
|
-
if (busyPushingNext) {
|
|
305
|
-
callsQueue.unshift(args);
|
|
306
|
-
return;
|
|
307
|
-
}
|
|
308
|
-
busyPushingNext = true;
|
|
309
|
-
operation(...args);
|
|
310
|
-
while (callsQueue.length > 0) {
|
|
311
|
-
const nextCallArgs = callsQueue.pop();
|
|
312
|
-
nextCallArgs && operation(...nextCallArgs);
|
|
313
|
-
}
|
|
314
|
-
busyPushingNext = false;
|
|
315
|
-
};
|
|
316
|
-
}
|
|
317
|
-
/**
|
|
318
|
-
* Custom Subject that ensures that subscribers are notified of values in the order that they arrived.
|
|
319
|
-
* A standard Subject does not have this guarantee.
|
|
320
|
-
* For example, given the following code:
|
|
321
|
-
* ```typescript
|
|
322
|
-
* const subject = new Subject<string>();
|
|
323
|
-
subject.subscribe(value => {
|
|
324
|
-
if (value === 'start') subject.next('end');
|
|
325
|
-
});
|
|
326
|
-
subject.subscribe(value => { });
|
|
327
|
-
subject.next('start');
|
|
328
|
-
* ```
|
|
329
|
-
* When `subject` is a standard `Subject<T>` the second subscriber would recieve `end` and then `start`.
|
|
330
|
-
* When `subject` is a `OrderedSubject<T>` the second subscriber would recieve `start` and then `end`.
|
|
331
|
-
*/
|
|
332
|
-
class OrderedSubject extends Subject {
|
|
333
|
-
constructor() {
|
|
334
|
-
super(...arguments);
|
|
335
|
-
this._orderedNext = orderedQueueOperation((value) => super.next(value));
|
|
336
|
-
}
|
|
337
|
-
next(value) {
|
|
338
|
-
this._orderedNext(value);
|
|
339
|
-
}
|
|
340
|
-
}
|
|
341
|
-
/**
|
|
342
|
-
* Custom BehaviorSubject that ensures that subscribers are notified of values in the order that they arrived.
|
|
343
|
-
* A standard BehaviorSubject does not have this guarantee.
|
|
344
|
-
* For example, given the following code:
|
|
345
|
-
* ```typescript
|
|
346
|
-
* const subject = new BehaviorSubject<string>();
|
|
347
|
-
subject.subscribe(value => {
|
|
348
|
-
if (value === 'start') subject.next('end');
|
|
349
|
-
});
|
|
350
|
-
subject.subscribe(value => { });
|
|
351
|
-
subject.next('start');
|
|
352
|
-
* ```
|
|
353
|
-
* When `subject` is a standard `BehaviorSubject<T>` the second subscriber would recieve `end` and then `start`.
|
|
354
|
-
* When `subject` is a `OrderedBehaviorSubject<T>` the second subscriber would recieve `start` and then `end`.
|
|
355
|
-
*/
|
|
356
|
-
class OrderedBehaviorSubject extends BehaviorSubject {
|
|
357
|
-
constructor(value) {
|
|
358
|
-
super(value);
|
|
359
|
-
this._orderedNext = orderedQueueOperation((value) => super.next(value));
|
|
360
|
-
this._currentValue = value;
|
|
361
|
-
}
|
|
362
|
-
getValue() {
|
|
363
|
-
return this._currentValue;
|
|
364
|
-
}
|
|
365
|
-
next(value) {
|
|
366
|
-
this._currentValue = value;
|
|
367
|
-
this._orderedNext(value);
|
|
368
|
-
}
|
|
369
|
-
}
|
|
370
|
-
|
|
371
282
|
/**
|
|
372
283
|
* Internal Action stream that is emitted anytime an action is dispatched.
|
|
373
284
|
*/
|
|
374
|
-
class InternalActions extends
|
|
285
|
+
class InternalActions extends _OrderedSubject {
|
|
375
286
|
ngOnDestroy() {
|
|
376
287
|
this.complete();
|
|
377
288
|
}
|
|
@@ -413,185 +324,16 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.5", ngImpor
|
|
|
413
324
|
}], ctorParameters: () => [{ type: InternalActions }, { type: InternalNgxsExecutionStrategy }] });
|
|
414
325
|
|
|
415
326
|
/**
|
|
416
|
-
*
|
|
417
|
-
* @ignore
|
|
327
|
+
* @deprecated use `ɵStateStream` from `@ngxs/store/internals`.
|
|
418
328
|
*/
|
|
419
|
-
class StateStream extends
|
|
420
|
-
|
|
421
|
-
super({});
|
|
422
|
-
this.state = toSignal(this, {
|
|
423
|
-
manualCleanup: true,
|
|
424
|
-
requireSync: true
|
|
425
|
-
});
|
|
426
|
-
}
|
|
427
|
-
ngOnDestroy() {
|
|
428
|
-
// The StateStream should never emit values once the root view is removed,
|
|
429
|
-
// such as when the `NgModuleRef.destroy()` method is called. This is crucial
|
|
430
|
-
// for preventing memory leaks in server-side rendered apps, where a new StateStream
|
|
431
|
-
// is created for each HTTP request. If users forget to unsubscribe from `store.select`
|
|
432
|
-
// or `store.subscribe`, it can result in significant memory leaks in SSR apps.
|
|
433
|
-
this.complete();
|
|
434
|
-
}
|
|
435
|
-
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.5", ngImport: i0, type: StateStream, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
329
|
+
class StateStream extends _StateStream {
|
|
330
|
+
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.5", ngImport: i0, type: StateStream, deps: null, target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
436
331
|
/** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.5", ngImport: i0, type: StateStream, providedIn: 'root' }); }
|
|
437
332
|
}
|
|
438
333
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.5", ngImport: i0, type: StateStream, decorators: [{
|
|
439
334
|
type: Injectable,
|
|
440
335
|
args: [{ providedIn: 'root' }]
|
|
441
|
-
}]
|
|
442
|
-
|
|
443
|
-
/**
|
|
444
|
-
* Returns the type from an action instance/class.
|
|
445
|
-
* @ignore
|
|
446
|
-
*/
|
|
447
|
-
function getActionTypeFromInstance(action) {
|
|
448
|
-
if (action.constructor && action.constructor.type) {
|
|
449
|
-
return action.constructor.type;
|
|
450
|
-
}
|
|
451
|
-
else {
|
|
452
|
-
return action.type;
|
|
453
|
-
}
|
|
454
|
-
}
|
|
455
|
-
/**
|
|
456
|
-
* Matches a action
|
|
457
|
-
* @ignore
|
|
458
|
-
*/
|
|
459
|
-
function actionMatcher(action1) {
|
|
460
|
-
const type1 = getActionTypeFromInstance(action1);
|
|
461
|
-
return function (action2) {
|
|
462
|
-
return type1 === getActionTypeFromInstance(action2);
|
|
463
|
-
};
|
|
464
|
-
}
|
|
465
|
-
/**
|
|
466
|
-
* Set a deeply nested value. Example:
|
|
467
|
-
*
|
|
468
|
-
* setValue({ foo: { bar: { eat: false } } },
|
|
469
|
-
* 'foo.bar.eat', true) //=> { foo: { bar: { eat: true } } }
|
|
470
|
-
*
|
|
471
|
-
* While it traverses it also creates new objects from top down.
|
|
472
|
-
*
|
|
473
|
-
* @ignore
|
|
474
|
-
*/
|
|
475
|
-
const setValue = (obj, prop, val) => {
|
|
476
|
-
obj = { ...obj };
|
|
477
|
-
const split = prop.split('.');
|
|
478
|
-
const lastIndex = split.length - 1;
|
|
479
|
-
split.reduce((acc, part, index) => {
|
|
480
|
-
if (index === lastIndex) {
|
|
481
|
-
acc[part] = val;
|
|
482
|
-
}
|
|
483
|
-
else {
|
|
484
|
-
acc[part] = Array.isArray(acc[part]) ? acc[part].slice() : { ...acc[part] };
|
|
485
|
-
}
|
|
486
|
-
return acc && acc[part];
|
|
487
|
-
}, obj);
|
|
488
|
-
return obj;
|
|
489
|
-
};
|
|
490
|
-
/**
|
|
491
|
-
* Get a deeply nested value. Example:
|
|
492
|
-
*
|
|
493
|
-
* getValue({ foo: bar: [] }, 'foo.bar') //=> []
|
|
494
|
-
*
|
|
495
|
-
* @ignore
|
|
496
|
-
*/
|
|
497
|
-
const getValue = (obj, prop) => prop.split('.').reduce((acc, part) => acc && acc[part], obj);
|
|
498
|
-
/**
|
|
499
|
-
* Simple object check.
|
|
500
|
-
*
|
|
501
|
-
* isObject({a:1}) //=> true
|
|
502
|
-
* isObject(1) //=> false
|
|
503
|
-
*
|
|
504
|
-
* @ignore
|
|
505
|
-
*/
|
|
506
|
-
const isObject$1 = (item) => {
|
|
507
|
-
return item && typeof item === 'object' && !Array.isArray(item);
|
|
508
|
-
};
|
|
509
|
-
/**
|
|
510
|
-
* Deep merge two objects.
|
|
511
|
-
*
|
|
512
|
-
* mergeDeep({a:1, b:{x: 1, y:2}}, {b:{x: 3}, c:4}) //=> {a:1, b:{x:3, y:2}, c:4}
|
|
513
|
-
*
|
|
514
|
-
* @param base base object onto which `sources` will be applied
|
|
515
|
-
*/
|
|
516
|
-
const mergeDeep = (base, ...sources) => {
|
|
517
|
-
if (!sources.length)
|
|
518
|
-
return base;
|
|
519
|
-
const source = sources.shift();
|
|
520
|
-
if (isObject$1(base) && isObject$1(source)) {
|
|
521
|
-
for (const key in source) {
|
|
522
|
-
if (isObject$1(source[key])) {
|
|
523
|
-
if (!base[key])
|
|
524
|
-
Object.assign(base, { [key]: {} });
|
|
525
|
-
mergeDeep(base[key], source[key]);
|
|
526
|
-
}
|
|
527
|
-
else {
|
|
528
|
-
Object.assign(base, { [key]: source[key] });
|
|
529
|
-
}
|
|
530
|
-
}
|
|
531
|
-
}
|
|
532
|
-
return mergeDeep(base, ...sources);
|
|
533
|
-
};
|
|
534
|
-
|
|
535
|
-
const NG_DEV_MODE$3 = typeof ngDevMode === 'undefined' || ngDevMode;
|
|
536
|
-
// The injection token is used to resolve a list of states provided at
|
|
537
|
-
// the root level through either `NgxsModule.forRoot` or `provideStore`.
|
|
538
|
-
const ROOT_STATE_TOKEN = new InjectionToken(NG_DEV_MODE$3 ? 'ROOT_STATE_TOKEN' : '');
|
|
539
|
-
// The injection token is used to resolve a list of states provided at
|
|
540
|
-
// the feature level through either `NgxsModule.forFeature` or `provideStates`.
|
|
541
|
-
// The Array<Array> is used to overload the resolved value of the token because
|
|
542
|
-
// it is a multi-provider token.
|
|
543
|
-
const FEATURE_STATE_TOKEN = new InjectionToken(NG_DEV_MODE$3 ? 'FEATURE_STATE_TOKEN' : '');
|
|
544
|
-
// The injection token is used to resolve to custom NGXS plugins provided
|
|
545
|
-
// at the root level through either `{provide}` scheme or `withNgxsPlugin`.
|
|
546
|
-
const NGXS_PLUGINS = new InjectionToken(NG_DEV_MODE$3 ? 'NGXS_PLUGINS' : '');
|
|
547
|
-
// The injection token is used to resolve to options provided at the root
|
|
548
|
-
// level through either `NgxsModule.forRoot` or `provideStore`.
|
|
549
|
-
const NGXS_OPTIONS = new InjectionToken(NG_DEV_MODE$3 ? 'NGXS_OPTIONS' : '');
|
|
550
|
-
/**
|
|
551
|
-
* The NGXS config settings.
|
|
552
|
-
*/
|
|
553
|
-
class NgxsConfig {
|
|
554
|
-
constructor() {
|
|
555
|
-
/**
|
|
556
|
-
* Defining the default state before module initialization
|
|
557
|
-
* This is convenient if we need to create a define our own set of states.
|
|
558
|
-
* @deprecated will be removed after v4
|
|
559
|
-
* (default: {})
|
|
560
|
-
*/
|
|
561
|
-
this.defaultsState = {};
|
|
562
|
-
/**
|
|
563
|
-
* Defining shared selector options
|
|
564
|
-
*/
|
|
565
|
-
this.selectorOptions = {
|
|
566
|
-
injectContainerState: true,
|
|
567
|
-
suppressErrors: true // TODO: default is true in v3, will change in v4
|
|
568
|
-
};
|
|
569
|
-
this.compatibility = {
|
|
570
|
-
strictContentSecurityPolicy: false
|
|
571
|
-
};
|
|
572
|
-
this.executionStrategy = DispatchOutsideZoneNgxsExecutionStrategy;
|
|
573
|
-
}
|
|
574
|
-
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.5", ngImport: i0, type: NgxsConfig, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
575
|
-
/** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.5", ngImport: i0, type: NgxsConfig, providedIn: 'root', useFactory: () => mergeDeep(new NgxsConfig(), inject(NGXS_OPTIONS)) }); }
|
|
576
|
-
}
|
|
577
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.5", ngImport: i0, type: NgxsConfig, decorators: [{
|
|
578
|
-
type: Injectable,
|
|
579
|
-
args: [{
|
|
580
|
-
providedIn: 'root',
|
|
581
|
-
useFactory: () => mergeDeep(new NgxsConfig(), inject(NGXS_OPTIONS))
|
|
582
|
-
}]
|
|
583
|
-
}], ctorParameters: () => [] });
|
|
584
|
-
/**
|
|
585
|
-
* Represents a basic change from a previous to a new value for a single state instance.
|
|
586
|
-
* Passed as a value in a NgxsSimpleChanges object to the ngxsOnChanges hook.
|
|
587
|
-
*/
|
|
588
|
-
class NgxsSimpleChange {
|
|
589
|
-
constructor(previousValue, currentValue, firstChange) {
|
|
590
|
-
this.previousValue = previousValue;
|
|
591
|
-
this.currentValue = currentValue;
|
|
592
|
-
this.firstChange = firstChange;
|
|
593
|
-
}
|
|
594
|
-
}
|
|
336
|
+
}] });
|
|
595
337
|
|
|
596
338
|
class PluginManager {
|
|
597
339
|
constructor(_parentManager, _pluginHandlers) {
|
|
@@ -715,6 +457,97 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.5", ngImpor
|
|
|
715
457
|
args: [{ providedIn: 'root' }]
|
|
716
458
|
}], ctorParameters: () => [{ type: InternalActions }, { type: InternalDispatchedActionResults }, { type: PluginManager }, { type: StateStream }, { type: InternalNgxsExecutionStrategy }, { type: InternalErrorReporter }] });
|
|
717
459
|
|
|
460
|
+
const NG_DEV_MODE$4 = typeof ngDevMode === 'undefined' || ngDevMode;
|
|
461
|
+
// The injection token is used to resolve a list of states provided at
|
|
462
|
+
// the root level through either `NgxsModule.forRoot` or `provideStore`.
|
|
463
|
+
const ROOT_STATE_TOKEN = new InjectionToken(NG_DEV_MODE$4 ? 'ROOT_STATE_TOKEN' : '');
|
|
464
|
+
// The injection token is used to resolve a list of states provided at
|
|
465
|
+
// the feature level through either `NgxsModule.forFeature` or `provideStates`.
|
|
466
|
+
// The Array<Array> is used to overload the resolved value of the token because
|
|
467
|
+
// it is a multi-provider token.
|
|
468
|
+
const FEATURE_STATE_TOKEN = new InjectionToken(NG_DEV_MODE$4 ? 'FEATURE_STATE_TOKEN' : '');
|
|
469
|
+
// The injection token is used to resolve to options provided at the root
|
|
470
|
+
// level through either `NgxsModule.forRoot` or `provideStore`.
|
|
471
|
+
const NGXS_OPTIONS = new InjectionToken(NG_DEV_MODE$4 ? 'NGXS_OPTIONS' : '');
|
|
472
|
+
/**
|
|
473
|
+
* The NGXS config settings.
|
|
474
|
+
*/
|
|
475
|
+
class NgxsConfig {
|
|
476
|
+
constructor() {
|
|
477
|
+
this.compatibility = {
|
|
478
|
+
strictContentSecurityPolicy: false
|
|
479
|
+
};
|
|
480
|
+
/**
|
|
481
|
+
* Determines the execution context to perform async operations inside. An implementation can be
|
|
482
|
+
* provided to override the default behaviour where the async operations are run
|
|
483
|
+
* outside Angular's zone but all observable behaviours of NGXS are run back inside Angular's zone.
|
|
484
|
+
* These observable behaviours are from:
|
|
485
|
+
* `@Select(...)`, `store.select(...)`, `actions.subscribe(...)` or `store.dispatch(...).subscribe(...)`
|
|
486
|
+
* Every `zone.run` causes Angular to run change detection on the whole tree (`app.tick()`) so of your
|
|
487
|
+
* application doesn't rely on zone.js running change detection then you can switch to the
|
|
488
|
+
* `NoopNgxsExecutionStrategy` that doesn't interact with zones.
|
|
489
|
+
* (default: null)
|
|
490
|
+
*/
|
|
491
|
+
this.executionStrategy = DispatchOutsideZoneNgxsExecutionStrategy;
|
|
492
|
+
/**
|
|
493
|
+
* Defining the default state before module initialization
|
|
494
|
+
* This is convenient if we need to create a define our own set of states.
|
|
495
|
+
* @deprecated will be removed after v4
|
|
496
|
+
* (default: {})
|
|
497
|
+
*/
|
|
498
|
+
this.defaultsState = {};
|
|
499
|
+
/**
|
|
500
|
+
* Defining shared selector options
|
|
501
|
+
*/
|
|
502
|
+
this.selectorOptions = {
|
|
503
|
+
injectContainerState: true,
|
|
504
|
+
suppressErrors: true // TODO: default is true in v3, will change in v4
|
|
505
|
+
};
|
|
506
|
+
}
|
|
507
|
+
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.5", ngImport: i0, type: NgxsConfig, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
508
|
+
/** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.5", ngImport: i0, type: NgxsConfig, providedIn: 'root', useFactory: () => {
|
|
509
|
+
const defaultConfig = new NgxsConfig();
|
|
510
|
+
const config = inject(NGXS_OPTIONS);
|
|
511
|
+
return {
|
|
512
|
+
...defaultConfig,
|
|
513
|
+
...config,
|
|
514
|
+
selectorOptions: {
|
|
515
|
+
...defaultConfig.selectorOptions,
|
|
516
|
+
...config.selectorOptions
|
|
517
|
+
}
|
|
518
|
+
};
|
|
519
|
+
} }); }
|
|
520
|
+
}
|
|
521
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.5", ngImport: i0, type: NgxsConfig, decorators: [{
|
|
522
|
+
type: Injectable,
|
|
523
|
+
args: [{
|
|
524
|
+
providedIn: 'root',
|
|
525
|
+
useFactory: () => {
|
|
526
|
+
const defaultConfig = new NgxsConfig();
|
|
527
|
+
const config = inject(NGXS_OPTIONS);
|
|
528
|
+
return {
|
|
529
|
+
...defaultConfig,
|
|
530
|
+
...config,
|
|
531
|
+
selectorOptions: {
|
|
532
|
+
...defaultConfig.selectorOptions,
|
|
533
|
+
...config.selectorOptions
|
|
534
|
+
}
|
|
535
|
+
};
|
|
536
|
+
}
|
|
537
|
+
}]
|
|
538
|
+
}] });
|
|
539
|
+
/**
|
|
540
|
+
* Represents a basic change from a previous to a new value for a single state instance.
|
|
541
|
+
* Passed as a value in a NgxsSimpleChanges object to the ngxsOnChanges hook.
|
|
542
|
+
*/
|
|
543
|
+
class NgxsSimpleChange {
|
|
544
|
+
constructor(previousValue, currentValue, firstChange) {
|
|
545
|
+
this.previousValue = previousValue;
|
|
546
|
+
this.currentValue = currentValue;
|
|
547
|
+
this.firstChange = firstChange;
|
|
548
|
+
}
|
|
549
|
+
}
|
|
550
|
+
|
|
718
551
|
/**
|
|
719
552
|
* Object freeze code
|
|
720
553
|
* https://github.com/jsdf/deep-freeze
|
|
@@ -789,61 +622,78 @@ function ensureStateAndActionsAreImmutable(root) {
|
|
|
789
622
|
};
|
|
790
623
|
}
|
|
791
624
|
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
625
|
+
function createRootSelectorFactory(selectorMetaData, selectors, memoizedSelectorFn) {
|
|
626
|
+
return (context) => {
|
|
627
|
+
const { argumentSelectorFunctions, selectorOptions } = getRuntimeSelectorInfo(context, selectorMetaData, selectors);
|
|
628
|
+
return function selectFromRoot(rootState) {
|
|
629
|
+
// Determine arguments from the app state using the selectors
|
|
630
|
+
const results = argumentSelectorFunctions.map(argFn => argFn(rootState));
|
|
631
|
+
// if the lambda tries to access a something on the
|
|
632
|
+
// state that doesn't exist, it will throw a TypeError.
|
|
633
|
+
// since this is quite usual behaviour, we simply return undefined if so.
|
|
634
|
+
try {
|
|
635
|
+
return memoizedSelectorFn(...results);
|
|
636
|
+
}
|
|
637
|
+
catch (ex) {
|
|
638
|
+
if (ex instanceof TypeError && selectorOptions.suppressErrors) {
|
|
639
|
+
return undefined;
|
|
640
|
+
}
|
|
641
|
+
throw ex;
|
|
642
|
+
}
|
|
808
643
|
};
|
|
809
|
-
|
|
810
|
-
}
|
|
811
|
-
return getStoreMetadata$1(target);
|
|
644
|
+
};
|
|
812
645
|
}
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
646
|
+
function createMemoizedSelectorFn(originalFn, creationMetadata) {
|
|
647
|
+
const containerClass = creationMetadata && creationMetadata.containerClass;
|
|
648
|
+
const wrappedFn = function wrappedSelectorFn(...args) {
|
|
649
|
+
const returnValue = originalFn.apply(containerClass, args);
|
|
650
|
+
if (returnValue instanceof Function) {
|
|
651
|
+
const innerMemoizedFn = _memoize.apply(null, [returnValue]);
|
|
652
|
+
return innerMemoizedFn;
|
|
653
|
+
}
|
|
654
|
+
return returnValue;
|
|
655
|
+
};
|
|
656
|
+
const memoizedFn = _memoize(wrappedFn);
|
|
657
|
+
Object.setPrototypeOf(memoizedFn, originalFn);
|
|
658
|
+
return memoizedFn;
|
|
820
659
|
}
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
660
|
+
function getRuntimeSelectorInfo(context, selectorMetaData, selectors = []) {
|
|
661
|
+
const localSelectorOptions = selectorMetaData.getSelectorOptions();
|
|
662
|
+
const selectorOptions = context.getSelectorOptions(localSelectorOptions);
|
|
663
|
+
const selectorsToApply = getSelectorsToApply(selectors, selectorOptions, selectorMetaData.containerClass);
|
|
664
|
+
const argumentSelectorFunctions = selectorsToApply.map(selector => {
|
|
665
|
+
const factory = getRootSelectorFactory(selector);
|
|
666
|
+
return factory(context);
|
|
667
|
+
});
|
|
668
|
+
return {
|
|
669
|
+
selectorOptions,
|
|
670
|
+
argumentSelectorFunctions
|
|
671
|
+
};
|
|
672
|
+
}
|
|
673
|
+
function getSelectorsToApply(selectors = [], selectorOptions, containerClass) {
|
|
674
|
+
const selectorsToApply = [];
|
|
675
|
+
const canInjectContainerState = selectors.length === 0 || selectorOptions.injectContainerState;
|
|
676
|
+
if (containerClass && canInjectContainerState) {
|
|
677
|
+
// If we are on a state class, add it as the first selector parameter
|
|
678
|
+
const metadata = _getStoreMetadata(containerClass);
|
|
679
|
+
if (metadata) {
|
|
680
|
+
selectorsToApply.push(containerClass);
|
|
681
|
+
}
|
|
682
|
+
}
|
|
683
|
+
if (selectors) {
|
|
684
|
+
selectorsToApply.push(...selectors);
|
|
836
685
|
}
|
|
837
|
-
return
|
|
686
|
+
return selectorsToApply;
|
|
838
687
|
}
|
|
839
688
|
/**
|
|
840
|
-
*
|
|
841
|
-
*
|
|
689
|
+
* This function gets the factory function to create the selector to get the selected slice from the app state
|
|
842
690
|
* @ignore
|
|
843
691
|
*/
|
|
844
|
-
function
|
|
845
|
-
|
|
692
|
+
function getRootSelectorFactory(selector) {
|
|
693
|
+
const metadata = _getSelectorMetadata(selector) || _getStoreMetadata(selector);
|
|
694
|
+
return (metadata && metadata.makeRootSelector) || (() => selector);
|
|
846
695
|
}
|
|
696
|
+
|
|
847
697
|
/**
|
|
848
698
|
* Get a deeply nested value. Example:
|
|
849
699
|
*
|
|
@@ -885,7 +735,7 @@ function fastPropGetter(paths) {
|
|
|
885
735
|
* @ignore
|
|
886
736
|
*/
|
|
887
737
|
function propGetter(paths, config) {
|
|
888
|
-
if (config
|
|
738
|
+
if (config?.compatibility?.strictContentSecurityPolicy) {
|
|
889
739
|
return compliantPropGetter(paths);
|
|
890
740
|
}
|
|
891
741
|
else {
|
|
@@ -1027,86 +877,6 @@ function topologicalSort(graph) {
|
|
|
1027
877
|
Object.keys(graph).forEach(k => visit(k));
|
|
1028
878
|
return sorted.reverse();
|
|
1029
879
|
}
|
|
1030
|
-
/**
|
|
1031
|
-
* Returns if the parameter is a object or not.
|
|
1032
|
-
*
|
|
1033
|
-
* @ignore
|
|
1034
|
-
*/
|
|
1035
|
-
function isObject(obj) {
|
|
1036
|
-
return (typeof obj === 'object' && obj !== null) || typeof obj === 'function';
|
|
1037
|
-
}
|
|
1038
|
-
|
|
1039
|
-
function createRootSelectorFactory(selectorMetaData, selectors, memoizedSelectorFn) {
|
|
1040
|
-
return (context) => {
|
|
1041
|
-
const { argumentSelectorFunctions, selectorOptions } = getRuntimeSelectorInfo(context, selectorMetaData, selectors);
|
|
1042
|
-
return function selectFromRoot(rootState) {
|
|
1043
|
-
// Determine arguments from the app state using the selectors
|
|
1044
|
-
const results = argumentSelectorFunctions.map(argFn => argFn(rootState));
|
|
1045
|
-
// if the lambda tries to access a something on the
|
|
1046
|
-
// state that doesn't exist, it will throw a TypeError.
|
|
1047
|
-
// since this is quite usual behaviour, we simply return undefined if so.
|
|
1048
|
-
try {
|
|
1049
|
-
return memoizedSelectorFn(...results);
|
|
1050
|
-
}
|
|
1051
|
-
catch (ex) {
|
|
1052
|
-
if (ex instanceof TypeError && selectorOptions.suppressErrors) {
|
|
1053
|
-
return undefined;
|
|
1054
|
-
}
|
|
1055
|
-
throw ex;
|
|
1056
|
-
}
|
|
1057
|
-
};
|
|
1058
|
-
};
|
|
1059
|
-
}
|
|
1060
|
-
function createMemoizedSelectorFn(originalFn, creationMetadata) {
|
|
1061
|
-
const containerClass = creationMetadata && creationMetadata.containerClass;
|
|
1062
|
-
const wrappedFn = function wrappedSelectorFn(...args) {
|
|
1063
|
-
const returnValue = originalFn.apply(containerClass, args);
|
|
1064
|
-
if (returnValue instanceof Function) {
|
|
1065
|
-
const innerMemoizedFn = memoize.apply(null, [returnValue]);
|
|
1066
|
-
return innerMemoizedFn;
|
|
1067
|
-
}
|
|
1068
|
-
return returnValue;
|
|
1069
|
-
};
|
|
1070
|
-
const memoizedFn = memoize(wrappedFn);
|
|
1071
|
-
Object.setPrototypeOf(memoizedFn, originalFn);
|
|
1072
|
-
return memoizedFn;
|
|
1073
|
-
}
|
|
1074
|
-
function getRuntimeSelectorInfo(context, selectorMetaData, selectors = []) {
|
|
1075
|
-
const localSelectorOptions = selectorMetaData.getSelectorOptions();
|
|
1076
|
-
const selectorOptions = context.getSelectorOptions(localSelectorOptions);
|
|
1077
|
-
const selectorsToApply = getSelectorsToApply(selectors, selectorOptions, selectorMetaData.containerClass);
|
|
1078
|
-
const argumentSelectorFunctions = selectorsToApply.map(selector => {
|
|
1079
|
-
const factory = getRootSelectorFactory(selector);
|
|
1080
|
-
return factory(context);
|
|
1081
|
-
});
|
|
1082
|
-
return {
|
|
1083
|
-
selectorOptions,
|
|
1084
|
-
argumentSelectorFunctions
|
|
1085
|
-
};
|
|
1086
|
-
}
|
|
1087
|
-
function getSelectorsToApply(selectors = [], selectorOptions, containerClass) {
|
|
1088
|
-
const selectorsToApply = [];
|
|
1089
|
-
const canInjectContainerState = selectors.length === 0 || selectorOptions.injectContainerState;
|
|
1090
|
-
if (containerClass && canInjectContainerState) {
|
|
1091
|
-
// If we are on a state class, add it as the first selector parameter
|
|
1092
|
-
const metadata = getStoreMetadata$1(containerClass);
|
|
1093
|
-
if (metadata) {
|
|
1094
|
-
selectorsToApply.push(containerClass);
|
|
1095
|
-
}
|
|
1096
|
-
}
|
|
1097
|
-
if (selectors) {
|
|
1098
|
-
selectorsToApply.push(...selectors);
|
|
1099
|
-
}
|
|
1100
|
-
return selectorsToApply;
|
|
1101
|
-
}
|
|
1102
|
-
/**
|
|
1103
|
-
* This function gets the factory function to create the selector to get the selected slice from the app state
|
|
1104
|
-
* @ignore
|
|
1105
|
-
*/
|
|
1106
|
-
function getRootSelectorFactory(selector) {
|
|
1107
|
-
const metadata = getSelectorMetadata$1(selector) || getStoreMetadata$1(selector);
|
|
1108
|
-
return (metadata && metadata.makeRootSelector) || (() => selector);
|
|
1109
|
-
}
|
|
1110
880
|
|
|
1111
881
|
/**
|
|
1112
882
|
* RxJS operator for selecting out specific actions.
|
|
@@ -1305,7 +1075,7 @@ function ensureStateNameIsUnique(stateName, state, statesByName) {
|
|
|
1305
1075
|
}
|
|
1306
1076
|
function ensureStatesAreDecorated(stateClasses) {
|
|
1307
1077
|
stateClasses.forEach((stateClass) => {
|
|
1308
|
-
if (!
|
|
1078
|
+
if (!_getStoreMetadata(stateClass)) {
|
|
1309
1079
|
throwStateDecoratorError(stateClass.name);
|
|
1310
1080
|
}
|
|
1311
1081
|
});
|
|
@@ -1335,23 +1105,8 @@ function jit_hasInjectableAnnotation(stateClass) {
|
|
|
1335
1105
|
return annotations.some((annotation) => annotation?.ngMetadataName === 'Injectable');
|
|
1336
1106
|
}
|
|
1337
1107
|
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
*/
|
|
1341
|
-
class InitState {
|
|
1342
|
-
static { this.type = '@@INIT'; }
|
|
1343
|
-
}
|
|
1344
|
-
/**
|
|
1345
|
-
* Update action
|
|
1346
|
-
*/
|
|
1347
|
-
class UpdateState {
|
|
1348
|
-
static { this.type = '@@UPDATE_STATE'; }
|
|
1349
|
-
constructor(addedStates) {
|
|
1350
|
-
this.addedStates = addedStates;
|
|
1351
|
-
}
|
|
1352
|
-
}
|
|
1353
|
-
|
|
1354
|
-
const NGXS_DEVELOPMENT_OPTIONS = new InjectionToken('NGXS_DEVELOPMENT_OPTIONS', {
|
|
1108
|
+
const NG_DEV_MODE$3 = typeof ngDevMode === 'undefined' || ngDevMode;
|
|
1109
|
+
const NGXS_DEVELOPMENT_OPTIONS = new InjectionToken(NG_DEV_MODE$3 ? 'NGXS_DEVELOPMENT_OPTIONS' : '', {
|
|
1355
1110
|
providedIn: 'root',
|
|
1356
1111
|
factory: () => ({ warnOnUnhandledActions: true })
|
|
1357
1112
|
});
|
|
@@ -1398,6 +1153,18 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.5", ngImpor
|
|
|
1398
1153
|
}] }] });
|
|
1399
1154
|
|
|
1400
1155
|
const NG_DEV_MODE$2 = typeof ngDevMode === 'undefined' || ngDevMode;
|
|
1156
|
+
function cloneDefaults(defaults) {
|
|
1157
|
+
let value = defaults === undefined ? {} : defaults;
|
|
1158
|
+
if (defaults) {
|
|
1159
|
+
if (Array.isArray(defaults)) {
|
|
1160
|
+
value = defaults.slice();
|
|
1161
|
+
}
|
|
1162
|
+
else if (typeof defaults === 'object') {
|
|
1163
|
+
value = { ...defaults };
|
|
1164
|
+
}
|
|
1165
|
+
}
|
|
1166
|
+
return value;
|
|
1167
|
+
}
|
|
1401
1168
|
/**
|
|
1402
1169
|
* The `StateFactory` class adds root and feature states to the graph.
|
|
1403
1170
|
* This extracts state names from state classes, checks if they already
|
|
@@ -1424,7 +1191,7 @@ class StateFactory {
|
|
|
1424
1191
|
this._states = [];
|
|
1425
1192
|
this._statesByName = {};
|
|
1426
1193
|
this._statePaths = {};
|
|
1427
|
-
this.getRuntimeSelectorContext =
|
|
1194
|
+
this.getRuntimeSelectorContext = _memoize(() => {
|
|
1428
1195
|
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
|
1429
1196
|
const stateFactory = this;
|
|
1430
1197
|
function resolveGetter(key) {
|
|
@@ -1469,19 +1236,6 @@ class StateFactory {
|
|
|
1469
1236
|
get statePaths() {
|
|
1470
1237
|
return this._parentFactory ? this._parentFactory.statePaths : this._statePaths;
|
|
1471
1238
|
}
|
|
1472
|
-
static _cloneDefaults(defaults) {
|
|
1473
|
-
let value = defaults;
|
|
1474
|
-
if (Array.isArray(defaults)) {
|
|
1475
|
-
value = defaults.slice();
|
|
1476
|
-
}
|
|
1477
|
-
else if (isObject(defaults)) {
|
|
1478
|
-
value = { ...defaults };
|
|
1479
|
-
}
|
|
1480
|
-
else if (defaults === undefined) {
|
|
1481
|
-
value = {};
|
|
1482
|
-
}
|
|
1483
|
-
return value;
|
|
1484
|
-
}
|
|
1485
1239
|
ngOnDestroy() {
|
|
1486
1240
|
this._actionsSubscription?.unsubscribe();
|
|
1487
1241
|
}
|
|
@@ -1518,7 +1272,7 @@ class StateFactory {
|
|
|
1518
1272
|
isInitialised: false,
|
|
1519
1273
|
actions: meta.actions,
|
|
1520
1274
|
instance: this._injector.get(stateClass),
|
|
1521
|
-
defaults:
|
|
1275
|
+
defaults: cloneDefaults(meta.defaults)
|
|
1522
1276
|
};
|
|
1523
1277
|
// ensure our store hasn't already been added
|
|
1524
1278
|
// but don't throw since it could be lazy
|
|
@@ -1635,7 +1389,7 @@ class StateFactory {
|
|
|
1635
1389
|
const newStates = [];
|
|
1636
1390
|
const statesMap = this.statesByName;
|
|
1637
1391
|
for (const stateClass of stateClasses) {
|
|
1638
|
-
const stateName =
|
|
1392
|
+
const stateName = _getStoreMetadata(stateClass).name;
|
|
1639
1393
|
if (NG_DEV_MODE$2) {
|
|
1640
1394
|
ensureStateNameIsUnique(stateName, stateClass, statesMap);
|
|
1641
1395
|
}
|
|
@@ -1660,7 +1414,7 @@ class StateFactory {
|
|
|
1660
1414
|
// its lifecycle is in 'bootstrapped' state.
|
|
1661
1415
|
return this.statesByName[name] && valueIsBootstrappedInInitialState;
|
|
1662
1416
|
}
|
|
1663
|
-
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.5", ngImport: i0, type: StateFactory, deps: [{ token: i0.Injector }, { token: NgxsConfig }, { token: StateFactory, optional: true, skipSelf: true }, { token: InternalActions }, { token: InternalDispatchedActionResults }, { token: StateContextFactory }, { token:
|
|
1417
|
+
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.5", ngImport: i0, type: StateFactory, deps: [{ token: i0.Injector }, { token: NgxsConfig }, { token: StateFactory, optional: true, skipSelf: true }, { token: InternalActions }, { token: InternalDispatchedActionResults }, { token: StateContextFactory }, { token: _INITIAL_STATE_TOKEN, optional: true }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
1664
1418
|
/** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.5", ngImport: i0, type: StateFactory }); }
|
|
1665
1419
|
}
|
|
1666
1420
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.5", ngImport: i0, type: StateFactory, decorators: [{
|
|
@@ -1673,7 +1427,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.5", ngImpor
|
|
|
1673
1427
|
type: Optional
|
|
1674
1428
|
}, {
|
|
1675
1429
|
type: Inject,
|
|
1676
|
-
args: [
|
|
1430
|
+
args: [_INITIAL_STATE_TOKEN]
|
|
1677
1431
|
}] }] });
|
|
1678
1432
|
|
|
1679
1433
|
// tslint:disable:unified-signatures
|
|
@@ -1761,7 +1515,7 @@ class Store {
|
|
|
1761
1515
|
this._stateStream.next(storeValues);
|
|
1762
1516
|
}
|
|
1763
1517
|
}
|
|
1764
|
-
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.5", ngImport: i0, type: Store, deps: [{ token: StateStream }, { token: InternalStateOperations }, { token: NgxsConfig }, { token: InternalNgxsExecutionStrategy }, { token: StateFactory }, { token:
|
|
1518
|
+
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.5", ngImport: i0, type: Store, deps: [{ token: StateStream }, { token: InternalStateOperations }, { token: NgxsConfig }, { token: InternalNgxsExecutionStrategy }, { token: StateFactory }, { token: _INITIAL_STATE_TOKEN, optional: true }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
1765
1519
|
/** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.5", ngImport: i0, type: Store, providedIn: 'root' }); }
|
|
1766
1520
|
}
|
|
1767
1521
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.5", ngImport: i0, type: Store, decorators: [{
|
|
@@ -1771,7 +1525,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.5", ngImpor
|
|
|
1771
1525
|
type: Optional
|
|
1772
1526
|
}, {
|
|
1773
1527
|
type: Inject,
|
|
1774
|
-
args: [
|
|
1528
|
+
args: [_INITIAL_STATE_TOKEN]
|
|
1775
1529
|
}] }] });
|
|
1776
1530
|
|
|
1777
1531
|
/**
|
|
@@ -1799,12 +1553,12 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.5", ngImpor
|
|
|
1799
1553
|
|
|
1800
1554
|
const NG_DEV_MODE$1 = typeof ngDevMode === 'undefined' || ngDevMode;
|
|
1801
1555
|
class LifecycleStateManager {
|
|
1802
|
-
constructor(_store, _internalErrorReporter, _internalStateOperations, _stateContextFactory,
|
|
1556
|
+
constructor(_store, _internalErrorReporter, _internalStateOperations, _stateContextFactory, _appBootstrappedState) {
|
|
1803
1557
|
this._store = _store;
|
|
1804
1558
|
this._internalErrorReporter = _internalErrorReporter;
|
|
1805
1559
|
this._internalStateOperations = _internalStateOperations;
|
|
1806
1560
|
this._stateContextFactory = _stateContextFactory;
|
|
1807
|
-
this.
|
|
1561
|
+
this._appBootstrappedState = _appBootstrappedState;
|
|
1808
1562
|
this._destroy$ = new ReplaySubject(1);
|
|
1809
1563
|
}
|
|
1810
1564
|
ngOnDestroy() {
|
|
@@ -1829,7 +1583,7 @@ class LifecycleStateManager {
|
|
|
1829
1583
|
this._internalStateOperations
|
|
1830
1584
|
.getRootStateOperations()
|
|
1831
1585
|
.dispatch(action)
|
|
1832
|
-
.pipe(filter(() => !!results), tap(() => this._invokeInitOnStates(results.states)), mergeMap(() => this.
|
|
1586
|
+
.pipe(filter(() => !!results), tap(() => this._invokeInitOnStates(results.states)), mergeMap(() => this._appBootstrappedState), filter(appBootstrapped => !!appBootstrapped), catchError(error => {
|
|
1833
1587
|
// The `SafeSubscriber` (which is used by most RxJS operators) re-throws
|
|
1834
1588
|
// errors asynchronously (`setTimeout(() => { throw error })`). This might
|
|
1835
1589
|
// break existing user's code or unit tests. We catch the error manually to
|
|
@@ -1868,13 +1622,13 @@ class LifecycleStateManager {
|
|
|
1868
1622
|
_getStateContext(mappedStore) {
|
|
1869
1623
|
return this._stateContextFactory.createStateContext(mappedStore);
|
|
1870
1624
|
}
|
|
1871
|
-
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.5", ngImport: i0, type: LifecycleStateManager, deps: [{ token: Store }, { token: InternalErrorReporter }, { token: InternalStateOperations }, { token: StateContextFactory }, { token: i5
|
|
1625
|
+
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.5", ngImport: i0, type: LifecycleStateManager, deps: [{ token: Store }, { token: InternalErrorReporter }, { token: InternalStateOperations }, { token: StateContextFactory }, { token: i5.ɵNgxsAppBootstrappedState }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
1872
1626
|
/** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.5", ngImport: i0, type: LifecycleStateManager, providedIn: 'root' }); }
|
|
1873
1627
|
}
|
|
1874
1628
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.5", ngImport: i0, type: LifecycleStateManager, decorators: [{
|
|
1875
1629
|
type: Injectable,
|
|
1876
1630
|
args: [{ providedIn: 'root' }]
|
|
1877
|
-
}], ctorParameters: () => [{ type: Store }, { type: InternalErrorReporter }, { type: InternalStateOperations }, { type: StateContextFactory }, { type: i5
|
|
1631
|
+
}], ctorParameters: () => [{ type: Store }, { type: InternalErrorReporter }, { type: InternalStateOperations }, { type: StateContextFactory }, { type: i5.ɵNgxsAppBootstrappedState }] });
|
|
1878
1632
|
|
|
1879
1633
|
const NG_DEV_MODE = typeof ngDevMode === 'undefined' || ngDevMode;
|
|
1880
1634
|
/**
|
|
@@ -2000,8 +1754,8 @@ function getRootProviders(states, options) {
|
|
|
2000
1754
|
{
|
|
2001
1755
|
provide: APP_BOOTSTRAP_LISTENER,
|
|
2002
1756
|
useFactory: () => {
|
|
2003
|
-
const
|
|
2004
|
-
return () =>
|
|
1757
|
+
const appBootstrappedState = inject(_NgxsAppBootstrappedState);
|
|
1758
|
+
return () => appBootstrappedState.bootstrap();
|
|
2005
1759
|
},
|
|
2006
1760
|
multi: true
|
|
2007
1761
|
},
|
|
@@ -2075,7 +1829,7 @@ function Action(actions, options) {
|
|
|
2075
1829
|
throwActionDecoratorError();
|
|
2076
1830
|
}
|
|
2077
1831
|
}
|
|
2078
|
-
const meta =
|
|
1832
|
+
const meta = _ensureStoreMetadata(target.constructor);
|
|
2079
1833
|
if (!Array.isArray(actions)) {
|
|
2080
1834
|
actions = [actions];
|
|
2081
1835
|
}
|
|
@@ -2099,7 +1853,7 @@ function Action(actions, options) {
|
|
|
2099
1853
|
function State(options) {
|
|
2100
1854
|
return (target) => {
|
|
2101
1855
|
const stateClass = target;
|
|
2102
|
-
const meta =
|
|
1856
|
+
const meta = _ensureStoreMetadata(stateClass);
|
|
2103
1857
|
const inheritedStateClass = Object.getPrototypeOf(stateClass);
|
|
2104
1858
|
const optionsWithInheritance = getStateOptions(inheritedStateClass, options);
|
|
2105
1859
|
mutateMetaData({ meta, inheritedStateClass, optionsWithInheritance });
|
|
@@ -2189,7 +1943,7 @@ const selectorOptionsMetaAccessor = {
|
|
|
2189
1943
|
}
|
|
2190
1944
|
};
|
|
2191
1945
|
function setupSelectorMetadata(originalFn, creationMetadata) {
|
|
2192
|
-
const selectorMetaData =
|
|
1946
|
+
const selectorMetaData = _ensureSelectorMetadata(originalFn);
|
|
2193
1947
|
selectorMetaData.originalFn = originalFn;
|
|
2194
1948
|
let getExplicitSelectorOptions = () => ({});
|
|
2195
1949
|
if (creationMetadata) {
|
|
@@ -2231,17 +1985,29 @@ function SelectorOptions(options) {
|
|
|
2231
1985
|
});
|
|
2232
1986
|
}
|
|
2233
1987
|
|
|
1988
|
+
/**
|
|
1989
|
+
* @deprecated will be removed after v4
|
|
1990
|
+
*/
|
|
2234
1991
|
function ensureStoreMetadata(target) {
|
|
2235
|
-
return
|
|
1992
|
+
return _ensureStoreMetadata(target);
|
|
2236
1993
|
}
|
|
1994
|
+
/**
|
|
1995
|
+
* @deprecated will be removed after v4
|
|
1996
|
+
*/
|
|
2237
1997
|
function getStoreMetadata(target) {
|
|
2238
|
-
return
|
|
1998
|
+
return _getStoreMetadata(target);
|
|
2239
1999
|
}
|
|
2000
|
+
/**
|
|
2001
|
+
* @deprecated will be removed after v4
|
|
2002
|
+
*/
|
|
2240
2003
|
function ensureSelectorMetadata(target) {
|
|
2241
|
-
return
|
|
2004
|
+
return _ensureSelectorMetadata(target);
|
|
2242
2005
|
}
|
|
2006
|
+
/**
|
|
2007
|
+
* @deprecated will be removed after v4
|
|
2008
|
+
*/
|
|
2243
2009
|
function getSelectorMetadata(target) {
|
|
2244
|
-
return
|
|
2010
|
+
return _getSelectorMetadata(target);
|
|
2245
2011
|
}
|
|
2246
2012
|
|
|
2247
2013
|
function createSelector(selectors, projector, creationMetadata) {
|
|
@@ -2281,22 +2047,6 @@ function Selector(selectors) {
|
|
|
2281
2047
|
};
|
|
2282
2048
|
}
|
|
2283
2049
|
|
|
2284
|
-
class StateToken {
|
|
2285
|
-
constructor(name) {
|
|
2286
|
-
this.name = name;
|
|
2287
|
-
const selectorMetadata = ensureSelectorMetadata$1(this);
|
|
2288
|
-
selectorMetadata.makeRootSelector = (runtimeContext) => {
|
|
2289
|
-
return runtimeContext.getStateGetter(this.name);
|
|
2290
|
-
};
|
|
2291
|
-
}
|
|
2292
|
-
getName() {
|
|
2293
|
-
return this.name;
|
|
2294
|
-
}
|
|
2295
|
-
toString() {
|
|
2296
|
-
return `StateToken[${this.name}]`;
|
|
2297
|
-
}
|
|
2298
|
-
}
|
|
2299
|
-
|
|
2300
2050
|
class NgxsDevelopmentModule {
|
|
2301
2051
|
static forRoot(options) {
|
|
2302
2052
|
return {
|
|
@@ -2314,12 +2064,18 @@ class NgxsDevelopmentModule {
|
|
|
2314
2064
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.5", ngImport: i0, type: NgxsDevelopmentModule, decorators: [{
|
|
2315
2065
|
type: NgModule
|
|
2316
2066
|
}] });
|
|
2067
|
+
function provideNgxsDevelopmentOptions(options) {
|
|
2068
|
+
return makeEnvironmentProviders([
|
|
2069
|
+
NgxsUnhandledActionsLogger,
|
|
2070
|
+
{ provide: NGXS_DEVELOPMENT_OPTIONS, useValue: options }
|
|
2071
|
+
]);
|
|
2072
|
+
}
|
|
2317
2073
|
|
|
2318
2074
|
function ensureValidSelector(selector, context = {}) {
|
|
2319
2075
|
const noun = context.noun || 'selector';
|
|
2320
2076
|
const prefix = context.prefix ? context.prefix + ': ' : '';
|
|
2321
2077
|
ensureValueProvided(selector, { noun, prefix: context.prefix });
|
|
2322
|
-
const metadata =
|
|
2078
|
+
const metadata = _getSelectorMetadata(selector) || _getStoreMetadata(selector);
|
|
2323
2079
|
if (!metadata) {
|
|
2324
2080
|
throw new Error(`${prefix}The value provided as the ${noun} is not a valid selector.`);
|
|
2325
2081
|
}
|
|
@@ -2464,5 +2220,5 @@ function withNgxsPlugin(plugin) {
|
|
|
2464
2220
|
* Generated bundle index. Do not edit.
|
|
2465
2221
|
*/
|
|
2466
2222
|
|
|
2467
|
-
export { Action, Actions,
|
|
2223
|
+
export { Action, Actions, NgxsDevelopmentModule, NgxsModule, NgxsSimpleChange, NgxsUnhandledActionsLogger, NoopNgxsExecutionStrategy, Select, Selector, SelectorOptions, State, StateStream, Store, createModelSelector, createPickSelector, createPropertySelectors, createSelector, ensureSelectorMetadata, ensureStoreMetadata, getSelectorMetadata, getStoreMetadata, ofAction, ofActionCanceled, ofActionCompleted, ofActionDispatched, ofActionErrored, ofActionSuccessful, provideStates, provideStore, withNgxsPlugin, NgxsFeatureModule as ɵNgxsFeatureModule, NgxsRootModule as ɵNgxsRootModule };
|
|
2468
2224
|
//# sourceMappingURL=ngxs-store.mjs.map
|