@ngxs/store 3.8.0-dev.master-c31ed89 → 3.8.0-dev.master-7ba9a5a
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/bundles/ngxs-store-internals.umd.js +8 -5
- package/bundles/ngxs-store-internals.umd.js.map +1 -1
- package/bundles/ngxs-store.umd.js +108 -119
- package/bundles/ngxs-store.umd.js.map +1 -1
- package/esm2015/internals/initial-state.js +9 -6
- package/esm2015/src/internal/state-operations.js +1 -2
- package/esm2015/src/module.js +5 -22
- package/esm2015/src/symbols.js +10 -3
- package/fesm2015/ngxs-store-internals.js +8 -5
- package/fesm2015/ngxs-store-internals.js.map +1 -1
- package/fesm2015/ngxs-store.js +104 -115
- package/fesm2015/ngxs-store.js.map +1 -1
- package/internals/initial-state.d.ts +2 -2
- package/package.json +2 -2
- package/src/internal/state-operations.d.ts +0 -1
- package/src/module.d.ts +0 -3
- package/src/symbols.d.ts +1 -0
|
@@ -114,21 +114,24 @@
|
|
|
114
114
|
return memoized;
|
|
115
115
|
}
|
|
116
116
|
|
|
117
|
-
var INITIAL_STATE_TOKEN = new i0.InjectionToken('INITIAL_STATE_TOKEN');
|
|
118
117
|
var InitialState = /** @class */ (function () {
|
|
119
118
|
function InitialState() {
|
|
120
119
|
}
|
|
121
120
|
InitialState.set = function (state) {
|
|
122
|
-
this.
|
|
121
|
+
this._value = state;
|
|
123
122
|
};
|
|
124
123
|
InitialState.pop = function () {
|
|
125
|
-
var state = this.
|
|
126
|
-
this.
|
|
124
|
+
var state = this._value;
|
|
125
|
+
this._value = {};
|
|
127
126
|
return state;
|
|
128
127
|
};
|
|
129
128
|
return InitialState;
|
|
130
129
|
}());
|
|
131
|
-
InitialState.
|
|
130
|
+
InitialState._value = {};
|
|
131
|
+
var INITIAL_STATE_TOKEN = new i0.InjectionToken('INITIAL_STATE_TOKEN', {
|
|
132
|
+
providedIn: 'root',
|
|
133
|
+
factory: function () { return InitialState.pop(); }
|
|
134
|
+
});
|
|
132
135
|
|
|
133
136
|
// These tokens are internal and can change at any point.
|
|
134
137
|
var ɵNGXS_STATE_FACTORY = new i0.InjectionToken('ɵNGXS_STATE_FACTORY');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ngxs-store-internals.umd.js","sources":["../../../packages/store/internals/src/angular.ts","../../../packages/store/internals/src/ngxs-bootstrapper.ts","../../../packages/store/internals/src/memoize.ts","../../../packages/store/internals/src/initial-state.ts","../../../packages/store/internals/src/internal-tokens.ts","../../../packages/store/internals/src/ngxs-store-internals.ts"],"sourcesContent":["declare const __karma__: unknown;\ndeclare const jasmine: unknown;\ndeclare const jest: unknown;\ndeclare const Mocha: unknown;\n\nexport function isAngularInTestMode(): boolean {\n // This is safe to check for these properties in the following way since `typeof` does not\n // throw an exception if the value does not exist in the scope.\n // We should not try to read these values from the global scope (e.g. `ɵglobal` from the `@angular/core`).\n // This is related to how these frameworks compile and execute modules. E.g. Jest wraps the module into\n // its internal code where `jest` variable exists in the scope. It cannot be read from the global scope, e.g.\n // this will return undefined `global.jest`, but `jest` will not equal undefined.\n return (\n typeof __karma__ !== 'undefined' ||\n typeof jasmine !== 'undefined' ||\n typeof jest !== 'undefined' ||\n typeof Mocha !== 'undefined'\n );\n}\n","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';\nimport { PlainObject } from './symbols';\n\nexport
|
|
1
|
+
{"version":3,"file":"ngxs-store-internals.umd.js","sources":["../../../packages/store/internals/src/angular.ts","../../../packages/store/internals/src/ngxs-bootstrapper.ts","../../../packages/store/internals/src/memoize.ts","../../../packages/store/internals/src/initial-state.ts","../../../packages/store/internals/src/internal-tokens.ts","../../../packages/store/internals/src/ngxs-store-internals.ts"],"sourcesContent":["declare const __karma__: unknown;\ndeclare const jasmine: unknown;\ndeclare const jest: unknown;\ndeclare const Mocha: unknown;\n\nexport function isAngularInTestMode(): boolean {\n // This is safe to check for these properties in the following way since `typeof` does not\n // throw an exception if the value does not exist in the scope.\n // We should not try to read these values from the global scope (e.g. `ɵglobal` from the `@angular/core`).\n // This is related to how these frameworks compile and execute modules. E.g. Jest wraps the module into\n // its internal code where `jest` variable exists in the scope. It cannot be read from the global scope, e.g.\n // this will return undefined `global.jest`, but `jest` will not equal undefined.\n return (\n typeof __karma__ !== 'undefined' ||\n typeof jasmine !== 'undefined' ||\n typeof jest !== 'undefined' ||\n typeof Mocha !== 'undefined'\n );\n}\n","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';\nimport { PlainObject } from './symbols';\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<any>('INITIAL_STATE_TOKEN', {\n providedIn: 'root',\n factory: () => InitialState.pop()\n});\n","import { InjectionToken } from '@angular/core';\n\n// These tokens are internal and can change at any point.\n\nexport const ɵNGXS_STATE_FACTORY = new InjectionToken<any>('ɵNGXS_STATE_FACTORY');\n\nexport const ɵNGXS_STATE_CONTEXT_FACTORY = new InjectionToken<any>(\n 'ɵNGXS_STATE_CONTEXT_FACTORY'\n);\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":["ReplaySubject","i0","Injectable","InjectionToken"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;aAKgB,mBAAmB,GAAA;;;;;;;IAOjC,IAAA,QACE,OAAO,SAAS,KAAK,WAAW;YAChC,OAAO,OAAO,KAAK,WAAW;YAC9B,OAAO,IAAI,KAAK,WAAW;IAC3B,QAAA,OAAO,KAAK,KAAK,WAAW,EAC5B;IACJ;;ACdA,QAAA,gBAAA,kBAAA,YAAA;IADA,IAAA,SAAA,gBAAA,GAAA;IAEE;;IAEG;YACK,IAAA,CAAA,UAAU,GAAG,IAAIA,kBAAa,CAAU,CAAC,CAAC,CAAC;SAcpD;IAZC,IAAA,MAAA,CAAA,cAAA,CAAI,gBAAgB,CAAA,SAAA,EAAA,kBAAA,EAAA;IAApB,QAAA,GAAA,EAAA,YAAA;IACE,YAAA,OAAO,IAAI,CAAC,UAAU,CAAC,YAAY,EAAE,CAAC;aACvC;;;IAAA,KAAA,CA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EAAE,GAAA;IAClC,CAAA;;IClBD;QAEa,mBAAmB,GAAG,IAAIA,iBAAc,CAAM,qBAAqB,EAAE;QAErE,2BAA2B,GAAG,IAAIA,iBAAc,CAC3D,6BAA6B;;ICP/B;;IAEG;;;;;;;;;;;;;;;;"}
|
|
@@ -352,6 +352,103 @@
|
|
|
352
352
|
return typeof state === "function" ? receiver === state : state.has(receiver);
|
|
353
353
|
}
|
|
354
354
|
|
|
355
|
+
/**
|
|
356
|
+
* Returns the type from an action instance/class.
|
|
357
|
+
* @ignore
|
|
358
|
+
*/
|
|
359
|
+
function getActionTypeFromInstance(action) {
|
|
360
|
+
if (action.constructor && action.constructor.type) {
|
|
361
|
+
return action.constructor.type;
|
|
362
|
+
}
|
|
363
|
+
else {
|
|
364
|
+
return action.type;
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
/**
|
|
368
|
+
* Matches a action
|
|
369
|
+
* @ignore
|
|
370
|
+
*/
|
|
371
|
+
function actionMatcher(action1) {
|
|
372
|
+
var type1 = getActionTypeFromInstance(action1);
|
|
373
|
+
return function (action2) {
|
|
374
|
+
return type1 === getActionTypeFromInstance(action2);
|
|
375
|
+
};
|
|
376
|
+
}
|
|
377
|
+
/**
|
|
378
|
+
* Set a deeply nested value. Example:
|
|
379
|
+
*
|
|
380
|
+
* setValue({ foo: { bar: { eat: false } } },
|
|
381
|
+
* 'foo.bar.eat', true) //=> { foo: { bar: { eat: true } } }
|
|
382
|
+
*
|
|
383
|
+
* While it traverses it also creates new objects from top down.
|
|
384
|
+
*
|
|
385
|
+
* @ignore
|
|
386
|
+
*/
|
|
387
|
+
var setValue = function (obj, prop, val) {
|
|
388
|
+
obj = Object.assign({}, obj);
|
|
389
|
+
var split = prop.split('.');
|
|
390
|
+
var lastIndex = split.length - 1;
|
|
391
|
+
split.reduce(function (acc, part, index) {
|
|
392
|
+
if (index === lastIndex) {
|
|
393
|
+
acc[part] = val;
|
|
394
|
+
}
|
|
395
|
+
else {
|
|
396
|
+
acc[part] = Array.isArray(acc[part]) ? acc[part].slice() : Object.assign({}, acc[part]);
|
|
397
|
+
}
|
|
398
|
+
return acc && acc[part];
|
|
399
|
+
}, obj);
|
|
400
|
+
return obj;
|
|
401
|
+
};
|
|
402
|
+
/**
|
|
403
|
+
* Get a deeply nested value. Example:
|
|
404
|
+
*
|
|
405
|
+
* getValue({ foo: bar: [] }, 'foo.bar') //=> []
|
|
406
|
+
*
|
|
407
|
+
* @ignore
|
|
408
|
+
*/
|
|
409
|
+
var getValue = function (obj, prop) { return prop.split('.').reduce(function (acc, part) { return acc && acc[part]; }, obj); };
|
|
410
|
+
/**
|
|
411
|
+
* Simple object check.
|
|
412
|
+
*
|
|
413
|
+
* isObject({a:1}) //=> true
|
|
414
|
+
* isObject(1) //=> false
|
|
415
|
+
*
|
|
416
|
+
* @ignore
|
|
417
|
+
*/
|
|
418
|
+
var isObject$1 = function (item) {
|
|
419
|
+
return item && typeof item === 'object' && !Array.isArray(item);
|
|
420
|
+
};
|
|
421
|
+
/**
|
|
422
|
+
* Deep merge two objects.
|
|
423
|
+
*
|
|
424
|
+
* mergeDeep({a:1, b:{x: 1, y:2}}, {b:{x: 3}, c:4}) //=> {a:1, b:{x:3, y:2}, c:4}
|
|
425
|
+
*
|
|
426
|
+
* @param base base object onto which `sources` will be applied
|
|
427
|
+
*/
|
|
428
|
+
var mergeDeep = function (base) {
|
|
429
|
+
var _a, _b;
|
|
430
|
+
var sources = [];
|
|
431
|
+
for (var _i = 1; _i < arguments.length; _i++) {
|
|
432
|
+
sources[_i - 1] = arguments[_i];
|
|
433
|
+
}
|
|
434
|
+
if (!sources.length)
|
|
435
|
+
return base;
|
|
436
|
+
var source = sources.shift();
|
|
437
|
+
if (isObject$1(base) && isObject$1(source)) {
|
|
438
|
+
for (var key in source) {
|
|
439
|
+
if (isObject$1(source[key])) {
|
|
440
|
+
if (!base[key])
|
|
441
|
+
Object.assign(base, (_a = {}, _a[key] = {}, _a));
|
|
442
|
+
mergeDeep(base[key], source[key]);
|
|
443
|
+
}
|
|
444
|
+
else {
|
|
445
|
+
Object.assign(base, (_b = {}, _b[key] = source[key], _b));
|
|
446
|
+
}
|
|
447
|
+
}
|
|
448
|
+
}
|
|
449
|
+
return mergeDeep.apply(void 0, __spreadArray([base], __read(sources)));
|
|
450
|
+
};
|
|
451
|
+
|
|
355
452
|
function throwStateNameError(name) {
|
|
356
453
|
throw new Error(name + " is not a valid state name. It needs to be a valid object property name.");
|
|
357
454
|
}
|
|
@@ -444,6 +541,7 @@
|
|
|
444
541
|
console.warn(getZoneWarningMessage());
|
|
445
542
|
}
|
|
446
543
|
|
|
544
|
+
var ROOT_OPTIONS = new i0.InjectionToken('ROOT_OPTIONS');
|
|
447
545
|
var ROOT_STATE_TOKEN = new i0.InjectionToken('ROOT_STATE_TOKEN');
|
|
448
546
|
var FEATURE_STATE_TOKEN = new i0.InjectionToken('FEATURE_STATE_TOKEN');
|
|
449
547
|
var NGXS_PLUGINS = new i0.InjectionToken('NGXS_PLUGINS');
|
|
@@ -477,9 +575,14 @@
|
|
|
477
575
|
return NgxsConfig;
|
|
478
576
|
}());
|
|
479
577
|
/** @nocollapse */ NgxsConfig.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: NgxsConfig, deps: [], target: i0__namespace.ɵɵFactoryTarget.Injectable });
|
|
480
|
-
/** @nocollapse */ NgxsConfig.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: NgxsConfig });
|
|
578
|
+
/** @nocollapse */ NgxsConfig.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: NgxsConfig, providedIn: 'root', useFactory: function (options) { return mergeDeep(new NgxsConfig(), options); }, deps: [{ token: ROOT_OPTIONS }] });
|
|
481
579
|
i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: NgxsConfig, decorators: [{
|
|
482
|
-
type: i0.Injectable
|
|
580
|
+
type: i0.Injectable,
|
|
581
|
+
args: [{
|
|
582
|
+
providedIn: 'root',
|
|
583
|
+
useFactory: function (options) { return mergeDeep(new NgxsConfig(), options); },
|
|
584
|
+
deps: [ROOT_OPTIONS]
|
|
585
|
+
}]
|
|
483
586
|
}], ctorParameters: function () { return []; } });
|
|
484
587
|
/**
|
|
485
588
|
* Represents a basic change from a previous to a new value for a single state instance.
|
|
@@ -777,107 +880,10 @@
|
|
|
777
880
|
*
|
|
778
881
|
* @ignore
|
|
779
882
|
*/
|
|
780
|
-
function isObject
|
|
883
|
+
function isObject(obj) {
|
|
781
884
|
return (typeof obj === 'object' && obj !== null) || typeof obj === 'function';
|
|
782
885
|
}
|
|
783
886
|
|
|
784
|
-
/**
|
|
785
|
-
* Returns the type from an action instance/class.
|
|
786
|
-
* @ignore
|
|
787
|
-
*/
|
|
788
|
-
function getActionTypeFromInstance(action) {
|
|
789
|
-
if (action.constructor && action.constructor.type) {
|
|
790
|
-
return action.constructor.type;
|
|
791
|
-
}
|
|
792
|
-
else {
|
|
793
|
-
return action.type;
|
|
794
|
-
}
|
|
795
|
-
}
|
|
796
|
-
/**
|
|
797
|
-
* Matches a action
|
|
798
|
-
* @ignore
|
|
799
|
-
*/
|
|
800
|
-
function actionMatcher(action1) {
|
|
801
|
-
var type1 = getActionTypeFromInstance(action1);
|
|
802
|
-
return function (action2) {
|
|
803
|
-
return type1 === getActionTypeFromInstance(action2);
|
|
804
|
-
};
|
|
805
|
-
}
|
|
806
|
-
/**
|
|
807
|
-
* Set a deeply nested value. Example:
|
|
808
|
-
*
|
|
809
|
-
* setValue({ foo: { bar: { eat: false } } },
|
|
810
|
-
* 'foo.bar.eat', true) //=> { foo: { bar: { eat: true } } }
|
|
811
|
-
*
|
|
812
|
-
* While it traverses it also creates new objects from top down.
|
|
813
|
-
*
|
|
814
|
-
* @ignore
|
|
815
|
-
*/
|
|
816
|
-
var setValue = function (obj, prop, val) {
|
|
817
|
-
obj = Object.assign({}, obj);
|
|
818
|
-
var split = prop.split('.');
|
|
819
|
-
var lastIndex = split.length - 1;
|
|
820
|
-
split.reduce(function (acc, part, index) {
|
|
821
|
-
if (index === lastIndex) {
|
|
822
|
-
acc[part] = val;
|
|
823
|
-
}
|
|
824
|
-
else {
|
|
825
|
-
acc[part] = Array.isArray(acc[part]) ? acc[part].slice() : Object.assign({}, acc[part]);
|
|
826
|
-
}
|
|
827
|
-
return acc && acc[part];
|
|
828
|
-
}, obj);
|
|
829
|
-
return obj;
|
|
830
|
-
};
|
|
831
|
-
/**
|
|
832
|
-
* Get a deeply nested value. Example:
|
|
833
|
-
*
|
|
834
|
-
* getValue({ foo: bar: [] }, 'foo.bar') //=> []
|
|
835
|
-
*
|
|
836
|
-
* @ignore
|
|
837
|
-
*/
|
|
838
|
-
var getValue = function (obj, prop) { return prop.split('.').reduce(function (acc, part) { return acc && acc[part]; }, obj); };
|
|
839
|
-
/**
|
|
840
|
-
* Simple object check.
|
|
841
|
-
*
|
|
842
|
-
* isObject({a:1}) //=> true
|
|
843
|
-
* isObject(1) //=> false
|
|
844
|
-
*
|
|
845
|
-
* @ignore
|
|
846
|
-
*/
|
|
847
|
-
var isObject = function (item) {
|
|
848
|
-
return item && typeof item === 'object' && !Array.isArray(item);
|
|
849
|
-
};
|
|
850
|
-
/**
|
|
851
|
-
* Deep merge two objects.
|
|
852
|
-
*
|
|
853
|
-
* mergeDeep({a:1, b:{x: 1, y:2}}, {b:{x: 3}, c:4}) //=> {a:1, b:{x:3, y:2}, c:4}
|
|
854
|
-
*
|
|
855
|
-
* @param base base object onto which `sources` will be applied
|
|
856
|
-
*/
|
|
857
|
-
var mergeDeep = function (base) {
|
|
858
|
-
var _a, _b;
|
|
859
|
-
var sources = [];
|
|
860
|
-
for (var _i = 1; _i < arguments.length; _i++) {
|
|
861
|
-
sources[_i - 1] = arguments[_i];
|
|
862
|
-
}
|
|
863
|
-
if (!sources.length)
|
|
864
|
-
return base;
|
|
865
|
-
var source = sources.shift();
|
|
866
|
-
if (isObject(base) && isObject(source)) {
|
|
867
|
-
for (var key in source) {
|
|
868
|
-
if (isObject(source[key])) {
|
|
869
|
-
if (!base[key])
|
|
870
|
-
Object.assign(base, (_a = {}, _a[key] = {}, _a));
|
|
871
|
-
mergeDeep(base[key], source[key]);
|
|
872
|
-
}
|
|
873
|
-
else {
|
|
874
|
-
Object.assign(base, (_b = {}, _b[key] = source[key], _b));
|
|
875
|
-
}
|
|
876
|
-
}
|
|
877
|
-
}
|
|
878
|
-
return mergeDeep.apply(void 0, __spreadArray([base], __read(sources)));
|
|
879
|
-
};
|
|
880
|
-
|
|
881
887
|
/**
|
|
882
888
|
* RxJS operator for selecting out specific actions.
|
|
883
889
|
*
|
|
@@ -1654,7 +1660,6 @@
|
|
|
1654
1660
|
};
|
|
1655
1661
|
|
|
1656
1662
|
/**
|
|
1657
|
-
* State Context factory class
|
|
1658
1663
|
* @ignore
|
|
1659
1664
|
*/
|
|
1660
1665
|
var InternalStateOperations = /** @class */ (function () {
|
|
@@ -1864,7 +1869,7 @@
|
|
|
1864
1869
|
if (Array.isArray(defaults)) {
|
|
1865
1870
|
value = defaults.slice();
|
|
1866
1871
|
}
|
|
1867
|
-
else if (isObject
|
|
1872
|
+
else if (isObject(defaults)) {
|
|
1868
1873
|
value = Object.assign({}, defaults);
|
|
1869
1874
|
}
|
|
1870
1875
|
else if (defaults === undefined) {
|
|
@@ -2519,24 +2524,15 @@
|
|
|
2519
2524
|
useValue: states
|
|
2520
2525
|
},
|
|
2521
2526
|
{
|
|
2522
|
-
provide:
|
|
2527
|
+
provide: ROOT_OPTIONS,
|
|
2523
2528
|
useValue: options
|
|
2524
2529
|
},
|
|
2525
|
-
{
|
|
2526
|
-
provide: NgxsConfig,
|
|
2527
|
-
useFactory: NgxsModule.ngxsConfigFactory,
|
|
2528
|
-
deps: [NgxsModule.ROOT_OPTIONS]
|
|
2529
|
-
},
|
|
2530
2530
|
{
|
|
2531
2531
|
provide: i0.APP_BOOTSTRAP_LISTENER,
|
|
2532
2532
|
useFactory: NgxsModule.appBootstrapListenerFactory,
|
|
2533
2533
|
multi: true,
|
|
2534
2534
|
deps: [i5.NgxsBootstrapper]
|
|
2535
2535
|
},
|
|
2536
|
-
{
|
|
2537
|
-
provide: i5.INITIAL_STATE_TOKEN,
|
|
2538
|
-
useFactory: NgxsModule.getInitialState
|
|
2539
|
-
},
|
|
2540
2536
|
{
|
|
2541
2537
|
provide: i5["ɵNGXS_STATE_CONTEXT_FACTORY"],
|
|
2542
2538
|
useExisting: StateContextFactory
|
|
@@ -2547,18 +2543,11 @@
|
|
|
2547
2543
|
}
|
|
2548
2544
|
];
|
|
2549
2545
|
};
|
|
2550
|
-
NgxsModule.ngxsConfigFactory = function (options) {
|
|
2551
|
-
return mergeDeep(new NgxsConfig(), options);
|
|
2552
|
-
};
|
|
2553
2546
|
NgxsModule.appBootstrapListenerFactory = function (bootstrapper) {
|
|
2554
2547
|
return function () { return bootstrapper.bootstrap(); };
|
|
2555
2548
|
};
|
|
2556
|
-
NgxsModule.getInitialState = function () {
|
|
2557
|
-
return i5.InitialState.pop();
|
|
2558
|
-
};
|
|
2559
2549
|
return NgxsModule;
|
|
2560
2550
|
}());
|
|
2561
|
-
NgxsModule.ROOT_OPTIONS = new i0.InjectionToken('ROOT_OPTIONS');
|
|
2562
2551
|
/** @nocollapse */ NgxsModule.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: NgxsModule, deps: [], target: i0__namespace.ɵɵFactoryTarget.NgModule });
|
|
2563
2552
|
/** @nocollapse */ NgxsModule.ɵmod = i0__namespace.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: NgxsModule });
|
|
2564
2553
|
/** @nocollapse */ NgxsModule.ɵinj = i0__namespace.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: NgxsModule });
|