@ngxs/store 3.8.2-dev.master-0fd1fe5 → 3.8.2
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-testing.umd.js +684 -0
- package/bundles/ngxs-store-internals-testing.umd.js.map +1 -0
- package/bundles/ngxs-store-internals.umd.js +141 -0
- package/bundles/ngxs-store-internals.umd.js.map +1 -0
- package/bundles/ngxs-store-operators.umd.js +224 -0
- package/bundles/ngxs-store-operators.umd.js.map +1 -0
- package/bundles/ngxs-store.umd.js +3076 -0
- package/bundles/ngxs-store.umd.js.map +1 -0
- package/esm2015/internals/index.js +5 -0
- package/esm2015/internals/initial-state.js +17 -0
- package/esm2015/internals/internal-tokens.js +5 -0
- package/{esm2020/internals/ngxs-bootstrapper.mjs → esm2015/internals/ngxs-bootstrapper.js} +4 -4
- package/esm2015/internals/src/symbols.js +2 -0
- package/esm2015/internals/symbols.js +2 -0
- package/esm2015/internals/testing/fresh-platform.js +70 -0
- package/{esm2020/internals/testing/helpers/ngxs-test.component.mjs → esm2015/internals/testing/helpers/ngxs-test.component.js} +4 -4
- package/esm2015/internals/testing/helpers/ngxs-test.module.js +21 -0
- package/{esm2020/internals/testing/ngxs.setup.mjs → esm2015/internals/testing/ngxs.setup.js} +2 -4
- package/esm2015/internals/testing/symbol.js +2 -0
- package/esm2015/operators/patch.js +21 -0
- package/{esm2020/src/actions-stream.mjs → esm2015/src/actions-stream.js} +7 -7
- package/esm2015/src/configs/messages.config.js +36 -0
- package/{esm2020/src/decorators/select/select-factory.mjs → esm2015/src/decorators/select/select-factory.js} +4 -4
- package/esm2015/src/decorators/selector/selector.js +32 -0
- package/esm2015/src/decorators/state.js +36 -0
- package/{esm2020/src/dev-features/ngxs-development.module.mjs → esm2015/src/dev-features/ngxs-development.module.js} +5 -5
- package/{esm2020/src/dev-features/ngxs-unhandled-actions-logger.mjs → esm2015/src/dev-features/ngxs-unhandled-actions-logger.js} +4 -4
- package/{esm2020/src/execution/dispatch-outside-zone-ngxs-execution-strategy.mjs → esm2015/src/execution/dispatch-outside-zone-ngxs-execution-strategy.js} +4 -4
- package/{esm2020/src/execution/internal-ngxs-execution-strategy.mjs → esm2015/src/execution/internal-ngxs-execution-strategy.js} +4 -4
- package/{esm2020/src/execution/noop-ngxs-execution-strategy.mjs → esm2015/src/execution/noop-ngxs-execution-strategy.js} +4 -4
- package/esm2015/src/execution/symbols.js +23 -0
- package/{esm2020/src/internal/dispatcher.mjs → esm2015/src/internal/dispatcher.js} +11 -11
- package/{esm2020/src/internal/error-handler.mjs → esm2015/src/internal/error-handler.js} +5 -5
- package/esm2015/src/internal/internals.js +248 -0
- package/esm2015/src/internal/lifecycle-state-manager.js +79 -0
- package/{esm2020/src/internal/state-context-factory.mjs → esm2015/src/internal/state-context-factory.js} +4 -4
- package/esm2015/src/internal/state-factory.js +288 -0
- package/{esm2020/src/internal/state-operations.mjs → esm2015/src/internal/state-operations.js} +5 -5
- package/esm2015/src/internal/state-operators.js +20 -0
- package/esm2015/src/internal/state-stream.js +25 -0
- package/{esm2020/src/ivy/ivy-enabled-in-dev-mode.mjs → esm2015/src/ivy/ivy-enabled-in-dev-mode.js} +2 -2
- package/esm2015/src/module.js +88 -0
- package/esm2015/src/modules/ngxs-feature.module.js +45 -0
- package/esm2015/src/modules/ngxs-root.module.js +41 -0
- package/{esm2020/src/operators/of-action.mjs → esm2015/src/operators/of-action.js} +10 -10
- package/{esm2020/src/plugin-manager.mjs → esm2015/src/plugin-manager.js} +4 -4
- package/esm2015/src/public_api.js +27 -0
- package/esm2015/src/selectors/create-property-selectors.js +20 -0
- package/esm2015/src/selectors/selector-metadata.js +30 -0
- package/esm2015/src/selectors/selector-types.util.js +2 -0
- package/{esm2020/src/store.mjs → esm2015/src/store.js} +5 -6
- package/esm2015/src/symbols.js +58 -0
- package/esm2015/src/utils/utils.js +92 -0
- package/fesm2015/{ngxs-store-internals-testing.mjs → ngxs-store-internals-testing.js} +13 -19
- package/fesm2015/ngxs-store-internals-testing.js.map +1 -0
- package/{fesm2020/ngxs-store-internals.mjs → fesm2015/ngxs-store-internals.js} +8 -21
- package/fesm2015/ngxs-store-internals.js.map +1 -0
- package/fesm2015/{ngxs-store-operators.mjs → ngxs-store-operators.js} +1 -1
- package/fesm2015/ngxs-store-operators.js.map +1 -0
- package/{fesm2020/ngxs-store.mjs → fesm2015/ngxs-store.js} +1029 -1192
- package/fesm2015/ngxs-store.js.map +1 -0
- package/internals/index.d.ts +1 -1
- package/internals/initial-state.d.ts +1 -1
- package/internals/ngxs-store-internals.d.ts +5 -0
- package/internals/package.json +10 -0
- package/internals/src/symbols.d.ts +1 -4
- package/internals/symbols.d.ts +1 -4
- package/internals/testing/helpers/ngxs-test.component.d.ts +1 -1
- package/internals/testing/ngxs-store-internals-testing.d.ts +5 -0
- package/internals/testing/package.json +10 -0
- package/internals/testing/symbol.d.ts +2 -2
- package/ngxs-store.d.ts +5 -0
- package/operators/ngxs-store-operators.d.ts +5 -0
- package/operators/package.json +10 -0
- package/package.json +11 -48
- package/src/configs/messages.config.d.ts +0 -2
- package/src/decorators/state.d.ts +2 -2
- package/src/execution/symbols.d.ts +2 -8
- package/src/internal/internals.d.ts +5 -5
- package/src/internal/lifecycle-state-manager.d.ts +1 -3
- package/src/module.d.ts +14 -3
- package/src/modules/ngxs-feature.module.d.ts +9 -2
- package/src/modules/ngxs-root.module.d.ts +9 -2
- package/src/public_api.d.ts +4 -5
- package/src/selectors/selector-types.util.d.ts +3 -3
- package/src/symbols.d.ts +8 -5
- package/esm2020/internals/index.mjs +0 -6
- package/esm2020/internals/initial-state.mjs +0 -18
- package/esm2020/internals/internal-tokens.mjs +0 -6
- package/esm2020/internals/src/symbols.mjs +0 -11
- package/esm2020/internals/symbols.mjs +0 -11
- package/esm2020/internals/testing/fresh-platform.mjs +0 -72
- package/esm2020/internals/testing/helpers/ngxs-test.module.mjs +0 -20
- package/esm2020/internals/testing/symbol.mjs +0 -2
- package/esm2020/operators/patch.mjs +0 -21
- package/esm2020/src/configs/messages.config.mjs +0 -48
- package/esm2020/src/decorators/selector/selector.mjs +0 -32
- package/esm2020/src/decorators/state.mjs +0 -36
- package/esm2020/src/execution/symbols.mjs +0 -27
- package/esm2020/src/internal/internals.mjs +0 -248
- package/esm2020/src/internal/lifecycle-state-manager.mjs +0 -97
- package/esm2020/src/internal/state-factory.mjs +0 -292
- package/esm2020/src/internal/state-operators.mjs +0 -20
- package/esm2020/src/internal/state-stream.mjs +0 -27
- package/esm2020/src/module.mjs +0 -27
- package/esm2020/src/modules/ngxs-feature.module.mjs +0 -18
- package/esm2020/src/modules/ngxs-root.module.mjs +0 -18
- package/esm2020/src/public_api.mjs +0 -28
- package/esm2020/src/selectors/create-property-selectors.mjs +0 -20
- package/esm2020/src/selectors/selector-metadata.mjs +0 -35
- package/esm2020/src/selectors/selector-types.util.mjs +0 -2
- package/esm2020/src/standalone-features/feature-providers.mjs +0 -20
- package/esm2020/src/standalone-features/index.mjs +0 -4
- package/esm2020/src/standalone-features/initializers.mjs +0 -86
- package/esm2020/src/standalone-features/plugin.mjs +0 -20
- package/esm2020/src/standalone-features/provide-states.mjs +0 -26
- package/esm2020/src/standalone-features/provide-store.mjs +0 -26
- package/esm2020/src/standalone-features/root-providers.mjs +0 -47
- package/esm2020/src/symbols.mjs +0 -65
- package/esm2020/src/utils/utils.mjs +0 -92
- package/fesm2015/ngxs-store-internals-testing.mjs.map +0 -1
- package/fesm2015/ngxs-store-internals.mjs +0 -114
- package/fesm2015/ngxs-store-internals.mjs.map +0 -1
- package/fesm2015/ngxs-store-operators.mjs.map +0 -1
- package/fesm2015/ngxs-store.mjs +0 -2454
- package/fesm2015/ngxs-store.mjs.map +0 -1
- package/fesm2020/ngxs-store-internals-testing.mjs +0 -180
- package/fesm2020/ngxs-store-internals-testing.mjs.map +0 -1
- package/fesm2020/ngxs-store-internals.mjs.map +0 -1
- package/fesm2020/ngxs-store-operators.mjs +0 -202
- package/fesm2020/ngxs-store-operators.mjs.map +0 -1
- package/fesm2020/ngxs-store.mjs.map +0 -1
- package/schematics/collection.json +0 -36
- package/schematics/src/actions/actions.factory.d.ts +0 -3
- package/schematics/src/actions/actions.factory.js +0 -22
- package/schematics/src/actions/actions.factory.js.map +0 -1
- package/schematics/src/actions/files/__name__.actions.ts__template__ +0 -4
- package/schematics/src/actions/schema.json +0 -28
- package/schematics/src/ng-add/add-declaration.d.ts +0 -4
- package/schematics/src/ng-add/add-declaration.js +0 -109
- package/schematics/src/ng-add/add-declaration.js.map +0 -1
- package/schematics/src/ng-add/ng-add.factory.d.ts +0 -9
- package/schematics/src/ng-add/ng-add.factory.js +0 -86
- package/schematics/src/ng-add/ng-add.factory.js.map +0 -1
- package/schematics/src/ng-add/schema.json +0 -72
- package/schematics/src/starter-kit/files/store/auth/auth.actions.ts__template__ +0 -7
- package/schematics/src/starter-kit/files/store/auth/auth.state.spec.ts__template__ +0 -46
- package/schematics/src/starter-kit/files/store/auth/auth.state.ts__template__ +0 -45
- package/schematics/src/starter-kit/files/store/dashboard/index.ts__template__ +0 -11
- package/schematics/src/starter-kit/files/store/dashboard/states/dictionary/dictionary.actions.ts__template__ +0 -13
- package/schematics/src/starter-kit/files/store/dashboard/states/dictionary/dictionary.state.spec.ts__template__ +0 -77
- package/schematics/src/starter-kit/files/store/dashboard/states/dictionary/dictionary.state.ts__template__ +0 -60
- package/schematics/src/starter-kit/files/store/dashboard/states/user/user.actions.ts__template__ +0 -6
- package/schematics/src/starter-kit/files/store/dashboard/states/user/user.state.spec.ts__template__ +0 -54
- package/schematics/src/starter-kit/files/store/dashboard/states/user/user.state.ts__template__ +0 -40
- package/schematics/src/starter-kit/files/store/store.config.ts__template__ +0 -38
- package/schematics/src/starter-kit/files/store/store.module.ts__template__ +0 -22
- package/schematics/src/starter-kit/schema.json +0 -18
- package/schematics/src/starter-kit/starter-kit.factory.d.ts +0 -3
- package/schematics/src/starter-kit/starter-kit.factory.js +0 -12
- package/schematics/src/starter-kit/starter-kit.factory.js.map +0 -1
- package/schematics/src/state/files/__name__.state.spec.ts__template__ +0 -22
- package/schematics/src/state/files/__name__.state.ts__template__ +0 -20
- package/schematics/src/state/schema.json +0 -33
- package/schematics/src/state/state.factory.d.ts +0 -3
- package/schematics/src/state/state.factory.js +0 -20
- package/schematics/src/state/state.factory.js.map +0 -1
- package/schematics/src/store/files/__name__.actions.ts__template__ +0 -4
- package/schematics/src/store/files/__name__.state.spec.ts__template__ +0 -24
- package/schematics/src/store/files/__name__.state.ts__template__ +0 -27
- package/schematics/src/store/schema.json +0 -33
- package/schematics/src/store/store.factory.d.ts +0 -3
- package/schematics/src/store/store.factory.js +0 -20
- package/schematics/src/store/store.factory.js.map +0 -1
- package/schematics/src/utils/common/lib.config.d.ts +0 -10
- package/schematics/src/utils/common/lib.config.js +0 -15
- package/schematics/src/utils/common/lib.config.js.map +0 -1
- package/schematics/src/utils/common/project-files.config.d.ts +0 -3
- package/schematics/src/utils/common/project-files.config.js +0 -7
- package/schematics/src/utils/common/project-files.config.js.map +0 -1
- package/schematics/src/utils/common/properties.d.ts +0 -1
- package/schematics/src/utils/common/properties.js +0 -8
- package/schematics/src/utils/common/properties.js.map +0 -1
- package/schematics/src/utils/config.d.ts +0 -119
- package/schematics/src/utils/config.js +0 -21
- package/schematics/src/utils/config.js.map +0 -1
- package/schematics/src/utils/generate-utils.d.ts +0 -4
- package/schematics/src/utils/generate-utils.js +0 -14
- package/schematics/src/utils/generate-utils.js.map +0 -1
- package/schematics/src/utils/interfaces/package.interface.d.ts +0 -7
- package/schematics/src/utils/interfaces/package.interface.js +0 -3
- package/schematics/src/utils/interfaces/package.interface.js.map +0 -1
- package/schematics/src/utils/ng-utils/README.md +0 -1
- package/schematics/src/utils/ng-utils/ast-utils.d.ts +0 -99
- package/schematics/src/utils/ng-utils/ast-utils.js +0 -517
- package/schematics/src/utils/ng-utils/ast-utils.js.map +0 -1
- package/schematics/src/utils/ng-utils/ng-ast-utils.d.ts +0 -5
- package/schematics/src/utils/ng-utils/ng-ast-utils.js +0 -67
- package/schematics/src/utils/ng-utils/ng-ast-utils.js.map +0 -1
- package/schematics/src/utils/ng-utils/project.d.ts +0 -2
- package/schematics/src/utils/ng-utils/project.js +0 -21
- package/schematics/src/utils/ng-utils/project.js.map +0 -1
- package/schematics/src/utils/ng-utils/standalone/app_config.d.ts +0 -16
- package/schematics/src/utils/ng-utils/standalone/app_config.js +0 -84
- package/schematics/src/utils/ng-utils/standalone/app_config.js.map +0 -1
- package/schematics/src/utils/ng-utils/standalone/code_block.d.ts +0 -46
- package/schematics/src/utils/ng-utils/standalone/code_block.js +0 -73
- package/schematics/src/utils/ng-utils/standalone/code_block.js.map +0 -1
- package/schematics/src/utils/ng-utils/standalone/index.d.ts +0 -1
- package/schematics/src/utils/ng-utils/standalone/index.js +0 -7
- package/schematics/src/utils/ng-utils/standalone/index.js.map +0 -1
- package/schematics/src/utils/ng-utils/standalone/rules.d.ts +0 -38
- package/schematics/src/utils/ng-utils/standalone/rules.js +0 -195
- package/schematics/src/utils/ng-utils/standalone/rules.js.map +0 -1
- package/schematics/src/utils/ng-utils/standalone/util.d.ts +0 -28
- package/schematics/src/utils/ng-utils/standalone/util.js +0 -138
- package/schematics/src/utils/ng-utils/standalone/util.js.map +0 -1
- package/schematics/src/utils/normalize-options.d.ts +0 -9
- package/schematics/src/utils/normalize-options.js +0 -24
- package/schematics/src/utils/normalize-options.js.map +0 -1
- package/schematics/src/utils/project.d.ts +0 -16
- package/schematics/src/utils/project.js +0 -40
- package/schematics/src/utils/project.js.map +0 -1
- package/schematics/src/utils/versions.json +0 -3
- package/src/standalone-features/feature-providers.d.ts +0 -7
- package/src/standalone-features/index.d.ts +0 -3
- package/src/standalone-features/initializers.d.ts +0 -29
- package/src/standalone-features/plugin.d.ts +0 -17
- package/src/standalone-features/provide-states.d.ts +0 -18
- package/src/standalone-features/provide-store.d.ts +0 -22
- package/src/standalone-features/root-providers.d.ts +0 -8
- /package/{esm2020/index.mjs → esm2015/index.js} +0 -0
- /package/{esm2020/internals/memoize.mjs → esm2015/internals/memoize.js} +0 -0
- /package/{esm2020/internals/ngxs-store-internals.mjs → esm2015/internals/ngxs-store-internals.js} +0 -0
- /package/{esm2020/internals/testing/index.mjs → esm2015/internals/testing/index.js} +0 -0
- /package/{esm2020/internals/testing/ngxs-store-internals-testing.mjs → esm2015/internals/testing/ngxs-store-internals-testing.js} +0 -0
- /package/{esm2020/internals/testing/skip-console-logging.mjs → esm2015/internals/testing/skip-console-logging.js} +0 -0
- /package/{esm2020/ngxs-store.mjs → esm2015/ngxs-store.js} +0 -0
- /package/{esm2020/operators/append.mjs → esm2015/operators/append.js} +0 -0
- /package/{esm2020/operators/compose.mjs → esm2015/operators/compose.js} +0 -0
- /package/{esm2020/operators/iif.mjs → esm2015/operators/iif.js} +0 -0
- /package/{esm2020/operators/index.mjs → esm2015/operators/index.js} +0 -0
- /package/{esm2020/operators/insert-item.mjs → esm2015/operators/insert-item.js} +0 -0
- /package/{esm2020/operators/ngxs-store-operators.mjs → esm2015/operators/ngxs-store-operators.js} +0 -0
- /package/{esm2020/operators/remove-item.mjs → esm2015/operators/remove-item.js} +0 -0
- /package/{esm2020/operators/types.mjs → esm2015/operators/types.js} +0 -0
- /package/{esm2020/operators/update-item.mjs → esm2015/operators/update-item.js} +0 -0
- /package/{esm2020/operators/utils.mjs → esm2015/operators/utils.js} +0 -0
- /package/{esm2020/src/actions/actions.mjs → esm2015/src/actions/actions.js} +0 -0
- /package/{esm2020/src/actions/symbols.mjs → esm2015/src/actions/symbols.js} +0 -0
- /package/{esm2020/src/decorators/action.mjs → esm2015/src/decorators/action.js} +0 -0
- /package/{esm2020/src/decorators/select/select.mjs → esm2015/src/decorators/select/select.js} +0 -0
- /package/{esm2020/src/decorators/select/symbols.mjs → esm2015/src/decorators/select/symbols.js} +0 -0
- /package/{esm2020/src/decorators/selector/symbols.mjs → esm2015/src/decorators/selector/symbols.js} +0 -0
- /package/{esm2020/src/decorators/selector-options.mjs → esm2015/src/decorators/selector-options.js} +0 -0
- /package/{esm2020/src/dev-features/symbols.mjs → esm2015/src/dev-features/symbols.js} +0 -0
- /package/{esm2020/src/internal/custom-rxjs-subjects.mjs → esm2015/src/internal/custom-rxjs-subjects.js} +0 -0
- /package/{esm2020/src/operators/leave-ngxs.mjs → esm2015/src/operators/leave-ngxs.js} +0 -0
- /package/{esm2020/src/plugin_api.mjs → esm2015/src/plugin_api.js} +0 -0
- /package/{esm2020/src/private_api.mjs → esm2015/src/private_api.js} +0 -0
- /package/{esm2020/src/public_to_deprecate.mjs → esm2015/src/public_to_deprecate.js} +0 -0
- /package/{esm2020/src/selectors/create-model-selector.mjs → esm2015/src/selectors/create-model-selector.js} +0 -0
- /package/{esm2020/src/selectors/create-pick-selector.mjs → esm2015/src/selectors/create-pick-selector.js} +0 -0
- /package/{esm2020/src/selectors/create-selector.mjs → esm2015/src/selectors/create-selector.js} +0 -0
- /package/{esm2020/src/selectors/index.mjs → esm2015/src/selectors/index.js} +0 -0
- /package/{esm2020/src/selectors/selector-checks.util.mjs → esm2015/src/selectors/selector-checks.util.js} +0 -0
- /package/{esm2020/src/selectors/selector-models.mjs → esm2015/src/selectors/selector-models.js} +0 -0
- /package/{esm2020/src/selectors/selector-utils.mjs → esm2015/src/selectors/selector-utils.js} +0 -0
- /package/{esm2020/src/state-token/state-token.mjs → esm2015/src/state-token/state-token.js} +0 -0
- /package/{esm2020/src/state-token/symbols.mjs → esm2015/src/state-token/symbols.js} +0 -0
- /package/{esm2020/src/utils/compose.mjs → esm2015/src/utils/compose.js} +0 -0
- /package/{esm2020/src/utils/freeze.mjs → esm2015/src/utils/freeze.js} +0 -0
- /package/{esm2020/src/utils/store-validators.mjs → esm2015/src/utils/store-validators.js} +0 -0
|
@@ -1,26 +1,103 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
|
-
import {
|
|
3
|
-
import { Observable, Subject, BehaviorSubject, of, forkJoin, throwError, EMPTY, from, isObservable, ReplaySubject } from 'rxjs';
|
|
4
|
-
import { share, shareReplay, filter, take, exhaustMap, map, mergeMap, defaultIfEmpty, catchError, takeUntil, distinctUntilChanged, tap, startWith, pairwise } from 'rxjs/operators';
|
|
2
|
+
import { NgZone, PLATFORM_ID, Injectable, Inject, InjectionToken, inject, INJECTOR, ɵglobal, ErrorHandler, Optional, SkipSelf, NgModule, APP_BOOTSTRAP_LISTENER } from '@angular/core';
|
|
5
3
|
import * as i5 from '@ngxs/store/internals';
|
|
6
|
-
import {
|
|
4
|
+
import { memoize, INITIAL_STATE_TOKEN, NgxsBootstrapper, ɵNGXS_STATE_CONTEXT_FACTORY, ɵNGXS_STATE_FACTORY } from '@ngxs/store/internals';
|
|
7
5
|
import { isPlatformServer } from '@angular/common';
|
|
6
|
+
import { Observable, Subject, BehaviorSubject, of, forkJoin, throwError, EMPTY, from, isObservable } from 'rxjs';
|
|
7
|
+
import { filter, map, share, shareReplay, take, exhaustMap, mergeMap, defaultIfEmpty, catchError, takeUntil, distinctUntilChanged, tap, startWith, pairwise } from 'rxjs/operators';
|
|
8
8
|
import { isStateOperator } from '@ngxs/store/operators';
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
/**
|
|
11
|
+
* Returns the type from an action instance/class.
|
|
12
|
+
* @ignore
|
|
13
|
+
*/
|
|
14
|
+
function getActionTypeFromInstance(action) {
|
|
15
|
+
if (action.constructor && action.constructor.type) {
|
|
16
|
+
return action.constructor.type;
|
|
13
17
|
}
|
|
14
|
-
|
|
15
|
-
return
|
|
18
|
+
else {
|
|
19
|
+
return action.type;
|
|
16
20
|
}
|
|
17
21
|
}
|
|
18
|
-
/**
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
22
|
+
/**
|
|
23
|
+
* Matches a action
|
|
24
|
+
* @ignore
|
|
25
|
+
*/
|
|
26
|
+
function actionMatcher(action1) {
|
|
27
|
+
const type1 = getActionTypeFromInstance(action1);
|
|
28
|
+
return function (action2) {
|
|
29
|
+
return type1 === getActionTypeFromInstance(action2);
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Set a deeply nested value. Example:
|
|
34
|
+
*
|
|
35
|
+
* setValue({ foo: { bar: { eat: false } } },
|
|
36
|
+
* 'foo.bar.eat', true) //=> { foo: { bar: { eat: true } } }
|
|
37
|
+
*
|
|
38
|
+
* While it traverses it also creates new objects from top down.
|
|
39
|
+
*
|
|
40
|
+
* @ignore
|
|
41
|
+
*/
|
|
42
|
+
const setValue = (obj, prop, val) => {
|
|
43
|
+
obj = Object.assign({}, obj);
|
|
44
|
+
const split = prop.split('.');
|
|
45
|
+
const lastIndex = split.length - 1;
|
|
46
|
+
split.reduce((acc, part, index) => {
|
|
47
|
+
if (index === lastIndex) {
|
|
48
|
+
acc[part] = val;
|
|
49
|
+
}
|
|
50
|
+
else {
|
|
51
|
+
acc[part] = Array.isArray(acc[part]) ? acc[part].slice() : Object.assign({}, acc[part]);
|
|
52
|
+
}
|
|
53
|
+
return acc && acc[part];
|
|
54
|
+
}, obj);
|
|
55
|
+
return obj;
|
|
56
|
+
};
|
|
57
|
+
/**
|
|
58
|
+
* Get a deeply nested value. Example:
|
|
59
|
+
*
|
|
60
|
+
* getValue({ foo: bar: [] }, 'foo.bar') //=> []
|
|
61
|
+
*
|
|
62
|
+
* @ignore
|
|
63
|
+
*/
|
|
64
|
+
const getValue = (obj, prop) => prop.split('.').reduce((acc, part) => acc && acc[part], obj);
|
|
65
|
+
/**
|
|
66
|
+
* Simple object check.
|
|
67
|
+
*
|
|
68
|
+
* isObject({a:1}) //=> true
|
|
69
|
+
* isObject(1) //=> false
|
|
70
|
+
*
|
|
71
|
+
* @ignore
|
|
72
|
+
*/
|
|
73
|
+
const isObject$1 = (item) => {
|
|
74
|
+
return item && typeof item === 'object' && !Array.isArray(item);
|
|
75
|
+
};
|
|
76
|
+
/**
|
|
77
|
+
* Deep merge two objects.
|
|
78
|
+
*
|
|
79
|
+
* mergeDeep({a:1, b:{x: 1, y:2}}, {b:{x: 3}, c:4}) //=> {a:1, b:{x:3, y:2}, c:4}
|
|
80
|
+
*
|
|
81
|
+
* @param base base object onto which `sources` will be applied
|
|
82
|
+
*/
|
|
83
|
+
const mergeDeep = (base, ...sources) => {
|
|
84
|
+
if (!sources.length)
|
|
85
|
+
return base;
|
|
86
|
+
const source = sources.shift();
|
|
87
|
+
if (isObject$1(base) && isObject$1(source)) {
|
|
88
|
+
for (const key in source) {
|
|
89
|
+
if (isObject$1(source[key])) {
|
|
90
|
+
if (!base[key])
|
|
91
|
+
Object.assign(base, { [key]: {} });
|
|
92
|
+
mergeDeep(base[key], source[key]);
|
|
93
|
+
}
|
|
94
|
+
else {
|
|
95
|
+
Object.assign(base, { [key]: source[key] });
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
return mergeDeep(base, ...sources);
|
|
100
|
+
};
|
|
24
101
|
|
|
25
102
|
function throwStateNameError(name) {
|
|
26
103
|
throw new Error(`${name} is not a valid state name. It needs to be a valid object property name.`);
|
|
@@ -48,18 +125,6 @@ function getZoneWarningMessage() {
|
|
|
48
125
|
function getUndecoratedStateInIvyWarningMessage(name) {
|
|
49
126
|
return `'${name}' class should be decorated with @Injectable() right after the @State() decorator`;
|
|
50
127
|
}
|
|
51
|
-
function getInvalidInitializationOrderMessage(addedStates) {
|
|
52
|
-
let message = 'You have an invalid state initialization order. This typically occurs when `NgxsModule.forFeature`\n' +
|
|
53
|
-
'or `provideStates` is called before `NgxsModule.forRoot` or `provideStore`.\n' +
|
|
54
|
-
'One example is when `NgxsRouterPluginModule.forRoot` is called before `NgxsModule.forRoot`.';
|
|
55
|
-
if (addedStates) {
|
|
56
|
-
const stateNames = Object.keys(addedStates).map(stateName => `"${stateName}"`);
|
|
57
|
-
message +=
|
|
58
|
-
'\nFeature states added before the store initialization is complete: ' +
|
|
59
|
-
`${stateNames.join(', ')}.`;
|
|
60
|
-
}
|
|
61
|
-
return message;
|
|
62
|
-
}
|
|
63
128
|
function throwSelectFactoryNotConnectedError() {
|
|
64
129
|
throw new Error('You have forgotten to import the NGXS module!');
|
|
65
130
|
}
|
|
@@ -102,9 +167,9 @@ class DispatchOutsideZoneNgxsExecutionStrategy {
|
|
|
102
167
|
return func();
|
|
103
168
|
}
|
|
104
169
|
}
|
|
105
|
-
/** @nocollapse */ DispatchOutsideZoneNgxsExecutionStrategy.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
106
|
-
/** @nocollapse */ DispatchOutsideZoneNgxsExecutionStrategy.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "
|
|
107
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
170
|
+
/** @nocollapse */ DispatchOutsideZoneNgxsExecutionStrategy.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: DispatchOutsideZoneNgxsExecutionStrategy, deps: [{ token: i0.NgZone }, { token: PLATFORM_ID }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
171
|
+
/** @nocollapse */ DispatchOutsideZoneNgxsExecutionStrategy.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: DispatchOutsideZoneNgxsExecutionStrategy, providedIn: 'root' });
|
|
172
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: DispatchOutsideZoneNgxsExecutionStrategy, decorators: [{
|
|
108
173
|
type: Injectable,
|
|
109
174
|
args: [{ providedIn: 'root' }]
|
|
110
175
|
}], ctorParameters: function () { return [{ type: i0.NgZone }, { type: undefined, decorators: [{
|
|
@@ -123,22 +188,87 @@ function verifyZoneIsNotNooped(ngZone) {
|
|
|
123
188
|
console.warn(getZoneWarningMessage());
|
|
124
189
|
}
|
|
125
190
|
|
|
126
|
-
const
|
|
191
|
+
const ROOT_OPTIONS = new InjectionToken('ROOT_OPTIONS');
|
|
192
|
+
const ROOT_STATE_TOKEN = new InjectionToken('ROOT_STATE_TOKEN');
|
|
193
|
+
const FEATURE_STATE_TOKEN = new InjectionToken('FEATURE_STATE_TOKEN');
|
|
194
|
+
const NGXS_PLUGINS = new InjectionToken('NGXS_PLUGINS');
|
|
195
|
+
const META_KEY = 'NGXS_META';
|
|
196
|
+
const META_OPTIONS_KEY = 'NGXS_OPTIONS_META';
|
|
197
|
+
const SELECTOR_META_KEY = 'NGXS_SELECTOR_META';
|
|
127
198
|
/**
|
|
128
|
-
*
|
|
129
|
-
|
|
199
|
+
* The NGXS config settings.
|
|
200
|
+
*/
|
|
201
|
+
class NgxsConfig {
|
|
202
|
+
constructor() {
|
|
203
|
+
/**
|
|
204
|
+
* Defining the default state before module initialization
|
|
205
|
+
* This is convenient if we need to create a define our own set of states.
|
|
206
|
+
* @deprecated will be removed after v4
|
|
207
|
+
* (default: {})
|
|
208
|
+
*/
|
|
209
|
+
this.defaultsState = {};
|
|
210
|
+
/**
|
|
211
|
+
* Defining shared selector options
|
|
212
|
+
*/
|
|
213
|
+
this.selectorOptions = {
|
|
214
|
+
injectContainerState: true,
|
|
215
|
+
suppressErrors: true // TODO: default is true in v3, will change in v4
|
|
216
|
+
};
|
|
217
|
+
this.compatibility = {
|
|
218
|
+
strictContentSecurityPolicy: false
|
|
219
|
+
};
|
|
220
|
+
this.executionStrategy = DispatchOutsideZoneNgxsExecutionStrategy;
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
/** @nocollapse */ NgxsConfig.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: NgxsConfig, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
224
|
+
/** @nocollapse */ NgxsConfig.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: NgxsConfig, providedIn: 'root', useFactory: (options) => mergeDeep(new NgxsConfig(), options), deps: [{ token: ROOT_OPTIONS }] });
|
|
225
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: NgxsConfig, decorators: [{
|
|
226
|
+
type: Injectable,
|
|
227
|
+
args: [{
|
|
228
|
+
providedIn: 'root',
|
|
229
|
+
useFactory: (options) => mergeDeep(new NgxsConfig(), options),
|
|
230
|
+
deps: [ROOT_OPTIONS]
|
|
231
|
+
}]
|
|
232
|
+
}], ctorParameters: function () { return []; } });
|
|
233
|
+
/**
|
|
234
|
+
* Represents a basic change from a previous to a new value for a single state instance.
|
|
235
|
+
* Passed as a value in a NgxsSimpleChanges object to the ngxsOnChanges hook.
|
|
130
236
|
*/
|
|
131
|
-
|
|
237
|
+
class NgxsSimpleChange {
|
|
238
|
+
constructor(previousValue, currentValue, firstChange) {
|
|
239
|
+
this.previousValue = previousValue;
|
|
240
|
+
this.currentValue = currentValue;
|
|
241
|
+
this.firstChange = firstChange;
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
class NoopNgxsExecutionStrategy {
|
|
246
|
+
enter(func) {
|
|
247
|
+
return func();
|
|
248
|
+
}
|
|
249
|
+
leave(func) {
|
|
250
|
+
return func();
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
/** @nocollapse */ NoopNgxsExecutionStrategy.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: NoopNgxsExecutionStrategy, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
254
|
+
/** @nocollapse */ NoopNgxsExecutionStrategy.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: NoopNgxsExecutionStrategy, providedIn: 'root' });
|
|
255
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: NoopNgxsExecutionStrategy, decorators: [{
|
|
256
|
+
type: Injectable,
|
|
257
|
+
args: [{ providedIn: 'root' }]
|
|
258
|
+
}] });
|
|
259
|
+
|
|
132
260
|
/**
|
|
133
|
-
* The
|
|
134
|
-
* strategy. It checks whether consumers have provided their own `executionStrategy`
|
|
135
|
-
* and also verifies if we are operating in a zone-aware environment.
|
|
261
|
+
* The strategy that might be provided by users through `options.executionStrategy`.
|
|
136
262
|
*/
|
|
137
|
-
const
|
|
263
|
+
const USER_PROVIDED_NGXS_EXECUTION_STRATEGY = new InjectionToken('USER_PROVIDED_NGXS_EXECUTION_STRATEGY');
|
|
264
|
+
/*
|
|
265
|
+
* Internal execution strategy injection token
|
|
266
|
+
*/
|
|
267
|
+
const NGXS_EXECUTION_STRATEGY = new InjectionToken('NGXS_EXECUTION_STRATEGY', {
|
|
138
268
|
providedIn: 'root',
|
|
139
269
|
factory: () => {
|
|
140
270
|
const injector = inject(INJECTOR);
|
|
141
|
-
const executionStrategy = injector.get(
|
|
271
|
+
const executionStrategy = injector.get(USER_PROVIDED_NGXS_EXECUTION_STRATEGY);
|
|
142
272
|
return executionStrategy
|
|
143
273
|
? injector.get(executionStrategy)
|
|
144
274
|
: injector.get(typeof ɵglobal.Zone !== 'undefined'
|
|
@@ -147,448 +277,640 @@ const NGXS_EXECUTION_STRATEGY = new InjectionToken(NG_DEV_MODE$4 ? 'NGXS_EXECUTI
|
|
|
147
277
|
}
|
|
148
278
|
});
|
|
149
279
|
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
280
|
+
/**
|
|
281
|
+
* Ensures metadata is attached to the class and returns it.
|
|
282
|
+
*
|
|
283
|
+
* @ignore
|
|
284
|
+
*/
|
|
285
|
+
function ensureStoreMetadata$1(target) {
|
|
286
|
+
if (!target.hasOwnProperty(META_KEY)) {
|
|
287
|
+
const defaultMetadata = {
|
|
288
|
+
name: null,
|
|
289
|
+
actions: {},
|
|
290
|
+
defaults: {},
|
|
291
|
+
path: null,
|
|
292
|
+
makeRootSelector(context) {
|
|
293
|
+
return context.getStateGetter(defaultMetadata.name);
|
|
294
|
+
},
|
|
295
|
+
children: []
|
|
296
|
+
};
|
|
297
|
+
Object.defineProperty(target, META_KEY, { value: defaultMetadata });
|
|
159
298
|
}
|
|
299
|
+
return getStoreMetadata$1(target);
|
|
160
300
|
}
|
|
161
|
-
/** @nocollapse */ InternalNgxsExecutionStrategy.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.4", ngImport: i0, type: InternalNgxsExecutionStrategy, deps: [{ token: NGXS_EXECUTION_STRATEGY }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
162
|
-
/** @nocollapse */ InternalNgxsExecutionStrategy.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.4", ngImport: i0, type: InternalNgxsExecutionStrategy, providedIn: 'root' });
|
|
163
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.4", ngImport: i0, type: InternalNgxsExecutionStrategy, decorators: [{
|
|
164
|
-
type: Injectable,
|
|
165
|
-
args: [{ providedIn: 'root' }]
|
|
166
|
-
}], ctorParameters: function () { return [{ type: undefined, decorators: [{
|
|
167
|
-
type: Inject,
|
|
168
|
-
args: [NGXS_EXECUTION_STRATEGY]
|
|
169
|
-
}] }]; } });
|
|
170
|
-
|
|
171
301
|
/**
|
|
172
|
-
*
|
|
302
|
+
* Get the metadata attached to the state class if it exists.
|
|
173
303
|
*
|
|
174
|
-
*
|
|
304
|
+
* @ignore
|
|
305
|
+
*/
|
|
306
|
+
function getStoreMetadata$1(target) {
|
|
307
|
+
return target[META_KEY];
|
|
308
|
+
}
|
|
309
|
+
/**
|
|
310
|
+
* Ensures metadata is attached to the selector and returns it.
|
|
175
311
|
*
|
|
176
|
-
*
|
|
312
|
+
* @ignore
|
|
313
|
+
*/
|
|
314
|
+
function ensureSelectorMetadata$1(target) {
|
|
315
|
+
if (!target.hasOwnProperty(SELECTOR_META_KEY)) {
|
|
316
|
+
const defaultMetadata = {
|
|
317
|
+
makeRootSelector: null,
|
|
318
|
+
originalFn: null,
|
|
319
|
+
containerClass: null,
|
|
320
|
+
selectorName: null,
|
|
321
|
+
getSelectorOptions: () => ({})
|
|
322
|
+
};
|
|
323
|
+
Object.defineProperty(target, SELECTOR_META_KEY, { value: defaultMetadata });
|
|
324
|
+
}
|
|
325
|
+
return getSelectorMetadata$1(target);
|
|
326
|
+
}
|
|
327
|
+
/**
|
|
328
|
+
* Get the metadata attached to the selector if it exists.
|
|
177
329
|
*
|
|
178
|
-
*
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
330
|
+
* @ignore
|
|
331
|
+
*/
|
|
332
|
+
function getSelectorMetadata$1(target) {
|
|
333
|
+
return target[SELECTOR_META_KEY];
|
|
334
|
+
}
|
|
335
|
+
/**
|
|
336
|
+
* Get a deeply nested value. Example:
|
|
182
337
|
*
|
|
183
|
-
*
|
|
184
|
-
* console.log('here', state, action);
|
|
185
|
-
* return state;
|
|
186
|
-
* }
|
|
338
|
+
* getValue({ foo: bar: [] }, 'foo.bar') //=> []
|
|
187
339
|
*
|
|
188
|
-
* the
|
|
340
|
+
* Note: This is not as fast as the `fastPropGetter` but is strict Content Security Policy compliant.
|
|
341
|
+
* See perf hit: https://jsperf.com/fast-value-getter-given-path/1
|
|
189
342
|
*
|
|
190
343
|
* @ignore
|
|
191
344
|
*/
|
|
192
|
-
|
|
193
|
-
const
|
|
194
|
-
return
|
|
195
|
-
};
|
|
196
|
-
|
|
197
|
-
/**
|
|
198
|
-
* Returns operator that will run
|
|
199
|
-
* `subscribe` outside of the ngxs execution context
|
|
200
|
-
*/
|
|
201
|
-
function leaveNgxs(ngxsExecutionStrategy) {
|
|
202
|
-
return (source) => {
|
|
203
|
-
return new Observable((sink) => {
|
|
204
|
-
return source.subscribe({
|
|
205
|
-
next(value) {
|
|
206
|
-
ngxsExecutionStrategy.leave(() => sink.next(value));
|
|
207
|
-
},
|
|
208
|
-
error(error) {
|
|
209
|
-
ngxsExecutionStrategy.leave(() => sink.error(error));
|
|
210
|
-
},
|
|
211
|
-
complete() {
|
|
212
|
-
ngxsExecutionStrategy.leave(() => sink.complete());
|
|
213
|
-
}
|
|
214
|
-
});
|
|
215
|
-
});
|
|
216
|
-
};
|
|
345
|
+
function compliantPropGetter(paths) {
|
|
346
|
+
const copyOfPaths = paths.slice();
|
|
347
|
+
return obj => copyOfPaths.reduce((acc, part) => acc && acc[part], obj);
|
|
217
348
|
}
|
|
218
|
-
|
|
219
349
|
/**
|
|
220
|
-
*
|
|
221
|
-
*
|
|
222
|
-
*
|
|
223
|
-
*
|
|
224
|
-
*
|
|
225
|
-
* 1) `store.dispatch()` (no subscribe) -> call `handleError()`
|
|
226
|
-
* 2) `store.dispatch().subscribe()` (no error callback) -> call `handleError()`
|
|
227
|
-
* 3) `store.dispatch().subscribe({ error: ... })` -> don't call `handleError()`
|
|
228
|
-
* 4) `toPromise()` without `catch` -> do `handleError()`
|
|
229
|
-
* 5) `toPromise()` with `catch` -> don't `handleError()`
|
|
350
|
+
* The generated function is faster than:
|
|
351
|
+
* - pluck (Observable operator)
|
|
352
|
+
* - memoize
|
|
353
|
+
*
|
|
354
|
+
* @ignore
|
|
230
355
|
*/
|
|
231
|
-
function
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
}
|
|
243
|
-
}));
|
|
244
|
-
}
|
|
245
|
-
});
|
|
246
|
-
return new Observable(subscriber => {
|
|
247
|
-
subscribed = true;
|
|
248
|
-
return source.pipe(leaveNgxs(ngxsExecutionStrategy)).subscribe(subscriber);
|
|
249
|
-
});
|
|
250
|
-
};
|
|
356
|
+
function fastPropGetter(paths) {
|
|
357
|
+
const segments = paths;
|
|
358
|
+
let seg = 'store.' + segments[0];
|
|
359
|
+
let i = 0;
|
|
360
|
+
const l = segments.length;
|
|
361
|
+
let expr = seg;
|
|
362
|
+
while (++i < l) {
|
|
363
|
+
expr = expr + ' && ' + (seg = seg + '.' + segments[i]);
|
|
364
|
+
}
|
|
365
|
+
const fn = new Function('store', 'return ' + expr + ';');
|
|
366
|
+
return fn;
|
|
251
367
|
}
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
368
|
+
/**
|
|
369
|
+
* Get a deeply nested value. Example:
|
|
370
|
+
*
|
|
371
|
+
* getValue({ foo: bar: [] }, 'foo.bar') //=> []
|
|
372
|
+
*
|
|
373
|
+
* @ignore
|
|
374
|
+
*/
|
|
375
|
+
function propGetter(paths, config) {
|
|
376
|
+
if (config && config.compatibility && config.compatibility.strictContentSecurityPolicy) {
|
|
377
|
+
return compliantPropGetter(paths);
|
|
257
378
|
}
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
this._errorHandler = this._injector.get(ErrorHandler);
|
|
261
|
-
}
|
|
262
|
-
// The `try-catch` is used to avoid handling the error twice. Suppose we call
|
|
263
|
-
// `handleError` which re-throws the error internally. The re-thrown error will
|
|
264
|
-
// be caught by zone.js which will then get to the `zone.onError.emit()` and the
|
|
265
|
-
// `onError` subscriber will call `handleError` again.
|
|
266
|
-
try {
|
|
267
|
-
this._errorHandler.handleError(error);
|
|
268
|
-
}
|
|
269
|
-
catch { }
|
|
379
|
+
else {
|
|
380
|
+
return fastPropGetter(paths);
|
|
270
381
|
}
|
|
271
382
|
}
|
|
272
|
-
/** @nocollapse */ InternalErrorReporter.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.4", ngImport: i0, type: InternalErrorReporter, deps: [{ token: i0.Injector }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
273
|
-
/** @nocollapse */ InternalErrorReporter.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.4", ngImport: i0, type: InternalErrorReporter, providedIn: 'root' });
|
|
274
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.4", ngImport: i0, type: InternalErrorReporter, decorators: [{
|
|
275
|
-
type: Injectable,
|
|
276
|
-
args: [{ providedIn: 'root' }]
|
|
277
|
-
}], ctorParameters: function () { return [{ type: i0.Injector }]; } });
|
|
278
|
-
|
|
279
383
|
/**
|
|
280
|
-
*
|
|
281
|
-
*
|
|
282
|
-
*
|
|
283
|
-
*
|
|
284
|
-
*
|
|
384
|
+
* Given an array of states, it will return a object graph. Example:
|
|
385
|
+
* const states = [
|
|
386
|
+
* Cart,
|
|
387
|
+
* CartSaved,
|
|
388
|
+
* CartSavedItems
|
|
389
|
+
* ]
|
|
285
390
|
*
|
|
286
|
-
*
|
|
287
|
-
*
|
|
288
|
-
*
|
|
289
|
-
*
|
|
290
|
-
*
|
|
291
|
-
*
|
|
292
|
-
*
|
|
293
|
-
*
|
|
294
|
-
*
|
|
295
|
-
* - The only way that a call will encounter another call in the queue
|
|
296
|
-
* would be if the call at the front of the queue initiated this call
|
|
297
|
-
* as part of its synchronous execution
|
|
391
|
+
* would return:
|
|
392
|
+
*
|
|
393
|
+
* const graph = {
|
|
394
|
+
* cart: ['saved'],
|
|
395
|
+
* saved: ['items'],
|
|
396
|
+
* items: []
|
|
397
|
+
* };
|
|
398
|
+
*
|
|
399
|
+
* @ignore
|
|
298
400
|
*/
|
|
299
|
-
function
|
|
300
|
-
const
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
}
|
|
307
|
-
busyPushingNext = true;
|
|
308
|
-
operation(...args);
|
|
309
|
-
while (callsQueue.length > 0) {
|
|
310
|
-
const nextCallArgs = callsQueue.pop();
|
|
311
|
-
nextCallArgs && operation(...nextCallArgs);
|
|
401
|
+
function buildGraph(stateClasses) {
|
|
402
|
+
const findName = (stateClass) => {
|
|
403
|
+
const meta = stateClasses.find(g => g === stateClass);
|
|
404
|
+
// Caretaker note: we have still left the `typeof` condition in order to avoid
|
|
405
|
+
// creating a breaking change for projects that still use the View Engine.
|
|
406
|
+
if ((typeof ngDevMode === 'undefined' || ngDevMode) && !meta) {
|
|
407
|
+
throw new Error(`Child state not found: ${stateClass}. \r\nYou may have forgotten to add states to module`);
|
|
312
408
|
}
|
|
313
|
-
|
|
409
|
+
return meta[META_KEY].name;
|
|
314
410
|
};
|
|
411
|
+
return stateClasses.reduce((result, stateClass) => {
|
|
412
|
+
const { name, children } = stateClass[META_KEY];
|
|
413
|
+
result[name] = (children || []).map(findName);
|
|
414
|
+
return result;
|
|
415
|
+
}, {});
|
|
315
416
|
}
|
|
316
417
|
/**
|
|
317
|
-
*
|
|
318
|
-
*
|
|
319
|
-
*
|
|
320
|
-
*
|
|
321
|
-
*
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
subject.subscribe(value => { });
|
|
326
|
-
subject.next('start');
|
|
327
|
-
* ```
|
|
328
|
-
* When `subject` is a standard `Subject<T>` the second subscriber would recieve `end` and then `start`.
|
|
329
|
-
* When `subject` is a `OrderedSubject<T>` the second subscriber would recieve `start` and then `end`.
|
|
330
|
-
*/
|
|
331
|
-
class OrderedSubject extends Subject {
|
|
332
|
-
constructor() {
|
|
333
|
-
super(...arguments);
|
|
334
|
-
this._orderedNext = orderedQueueOperation((value) => super.next(value));
|
|
335
|
-
}
|
|
336
|
-
next(value) {
|
|
337
|
-
this._orderedNext(value);
|
|
338
|
-
}
|
|
339
|
-
}
|
|
340
|
-
/**
|
|
341
|
-
* Custom BehaviorSubject that ensures that subscribers are notified of values in the order that they arrived.
|
|
342
|
-
* A standard BehaviorSubject does not have this guarantee.
|
|
343
|
-
* For example, given the following code:
|
|
344
|
-
* ```typescript
|
|
345
|
-
* const subject = new BehaviorSubject<string>();
|
|
346
|
-
subject.subscribe(value => {
|
|
347
|
-
if (value === 'start') subject.next('end');
|
|
348
|
-
});
|
|
349
|
-
subject.subscribe(value => { });
|
|
350
|
-
subject.next('start');
|
|
351
|
-
* ```
|
|
352
|
-
* When `subject` is a standard `BehaviorSubject<T>` the second subscriber would recieve `end` and then `start`.
|
|
353
|
-
* When `subject` is a `OrderedBehaviorSubject<T>` the second subscriber would recieve `start` and then `end`.
|
|
418
|
+
* Given a states array, returns object graph
|
|
419
|
+
* returning the name and state metadata. Example:
|
|
420
|
+
*
|
|
421
|
+
* const graph = {
|
|
422
|
+
* cart: { metadata }
|
|
423
|
+
* };
|
|
424
|
+
*
|
|
425
|
+
* @ignore
|
|
354
426
|
*/
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
}
|
|
361
|
-
getValue() {
|
|
362
|
-
return this._currentValue;
|
|
363
|
-
}
|
|
364
|
-
next(value) {
|
|
365
|
-
this._currentValue = value;
|
|
366
|
-
this._orderedNext(value);
|
|
367
|
-
}
|
|
427
|
+
function nameToState(states) {
|
|
428
|
+
return states.reduce((result, stateClass) => {
|
|
429
|
+
const meta = stateClass[META_KEY];
|
|
430
|
+
result[meta.name] = stateClass;
|
|
431
|
+
return result;
|
|
432
|
+
}, {});
|
|
368
433
|
}
|
|
369
|
-
|
|
370
434
|
/**
|
|
371
|
-
*
|
|
435
|
+
* Given a object relationship graph will return the full path
|
|
436
|
+
* for the child items. Example:
|
|
437
|
+
*
|
|
438
|
+
* const graph = {
|
|
439
|
+
* cart: ['saved'],
|
|
440
|
+
* saved: ['items'],
|
|
441
|
+
* items: []
|
|
442
|
+
* };
|
|
443
|
+
*
|
|
444
|
+
* would return:
|
|
445
|
+
*
|
|
446
|
+
* const r = {
|
|
447
|
+
* cart: 'cart',
|
|
448
|
+
* saved: 'cart.saved',
|
|
449
|
+
* items: 'cart.saved.items'
|
|
450
|
+
* };
|
|
451
|
+
*
|
|
452
|
+
* @ignore
|
|
372
453
|
*/
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
454
|
+
function findFullParentPath(obj, newObj = {}) {
|
|
455
|
+
const visit = (child, keyToFind) => {
|
|
456
|
+
for (const key in child) {
|
|
457
|
+
if (child.hasOwnProperty(key) && child[key].indexOf(keyToFind) >= 0) {
|
|
458
|
+
const parent = visit(child, key);
|
|
459
|
+
return parent !== null ? `${parent}.${key}` : key;
|
|
460
|
+
}
|
|
461
|
+
}
|
|
462
|
+
return null;
|
|
463
|
+
};
|
|
464
|
+
for (const key in obj) {
|
|
465
|
+
if (obj.hasOwnProperty(key)) {
|
|
466
|
+
const parent = visit(obj, key);
|
|
467
|
+
newObj[key] = parent ? `${parent}.${key}` : key;
|
|
468
|
+
}
|
|
376
469
|
}
|
|
470
|
+
return newObj;
|
|
377
471
|
}
|
|
378
|
-
/** @nocollapse */ InternalActions.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.4", ngImport: i0, type: InternalActions, deps: null, target: i0.ɵɵFactoryTarget.Injectable });
|
|
379
|
-
/** @nocollapse */ InternalActions.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.4", ngImport: i0, type: InternalActions, providedIn: 'root' });
|
|
380
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.4", ngImport: i0, type: InternalActions, decorators: [{
|
|
381
|
-
type: Injectable,
|
|
382
|
-
args: [{ providedIn: 'root' }]
|
|
383
|
-
}] });
|
|
384
472
|
/**
|
|
385
|
-
*
|
|
473
|
+
* Given a object graph, it will return the items topologically sorted Example:
|
|
386
474
|
*
|
|
387
|
-
*
|
|
475
|
+
* const graph = {
|
|
476
|
+
* cart: ['saved'],
|
|
477
|
+
* saved: ['items'],
|
|
478
|
+
* items: []
|
|
479
|
+
* };
|
|
480
|
+
*
|
|
481
|
+
* would return:
|
|
482
|
+
*
|
|
483
|
+
* const results = [
|
|
484
|
+
* 'items',
|
|
485
|
+
* 'saved',
|
|
486
|
+
* 'cart'
|
|
487
|
+
* ];
|
|
488
|
+
*
|
|
489
|
+
* @ignore
|
|
388
490
|
*/
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
491
|
+
function topologicalSort(graph) {
|
|
492
|
+
const sorted = [];
|
|
493
|
+
const visited = {};
|
|
494
|
+
const visit = (name, ancestors = []) => {
|
|
495
|
+
if (!Array.isArray(ancestors)) {
|
|
496
|
+
ancestors = [];
|
|
497
|
+
}
|
|
498
|
+
ancestors.push(name);
|
|
499
|
+
visited[name] = true;
|
|
500
|
+
graph[name].forEach((dep) => {
|
|
501
|
+
// Caretaker note: we have still left the `typeof` condition in order to avoid
|
|
502
|
+
// creating a breaking change for projects that still use the View Engine.
|
|
503
|
+
if ((typeof ngDevMode === 'undefined' || ngDevMode) && ancestors.indexOf(dep) >= 0) {
|
|
504
|
+
throw new Error(`Circular dependency '${dep}' is required by '${name}': ${ancestors.join(' -> ')}`);
|
|
505
|
+
}
|
|
506
|
+
if (visited[dep]) {
|
|
507
|
+
return;
|
|
508
|
+
}
|
|
509
|
+
visit(dep, ancestors.slice(0));
|
|
404
510
|
});
|
|
405
|
-
|
|
511
|
+
if (sorted.indexOf(name) < 0) {
|
|
512
|
+
sorted.push(name);
|
|
513
|
+
}
|
|
514
|
+
};
|
|
515
|
+
Object.keys(graph).forEach(k => visit(k));
|
|
516
|
+
return sorted.reverse();
|
|
406
517
|
}
|
|
407
|
-
/** @nocollapse */ Actions.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.4", ngImport: i0, type: Actions, deps: [{ token: InternalActions }, { token: InternalNgxsExecutionStrategy }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
408
|
-
/** @nocollapse */ Actions.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.4", ngImport: i0, type: Actions, providedIn: 'root' });
|
|
409
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.4", ngImport: i0, type: Actions, decorators: [{
|
|
410
|
-
type: Injectable,
|
|
411
|
-
args: [{ providedIn: 'root' }]
|
|
412
|
-
}], ctorParameters: function () { return [{ type: InternalActions }, { type: InternalNgxsExecutionStrategy }]; } });
|
|
413
|
-
|
|
414
518
|
/**
|
|
415
|
-
*
|
|
519
|
+
* Returns if the parameter is a object or not.
|
|
520
|
+
*
|
|
416
521
|
* @ignore
|
|
417
522
|
*/
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
super({});
|
|
421
|
-
}
|
|
422
|
-
ngOnDestroy() {
|
|
423
|
-
// The StateStream should never emit values once the root view is removed,
|
|
424
|
-
// such as when the `NgModuleRef.destroy()` method is called. This is crucial
|
|
425
|
-
// for preventing memory leaks in server-side rendered apps, where a new StateStream
|
|
426
|
-
// is created for each HTTP request. If users forget to unsubscribe from `store.select`
|
|
427
|
-
// or `store.subscribe`, it can result in significant memory leaks in SSR apps.
|
|
428
|
-
this.complete();
|
|
429
|
-
}
|
|
523
|
+
function isObject(obj) {
|
|
524
|
+
return (typeof obj === 'object' && obj !== null) || typeof obj === 'function';
|
|
430
525
|
}
|
|
431
|
-
/** @nocollapse */ StateStream.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.4", ngImport: i0, type: StateStream, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
432
|
-
/** @nocollapse */ StateStream.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.4", ngImport: i0, type: StateStream, providedIn: 'root' });
|
|
433
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.4", ngImport: i0, type: StateStream, decorators: [{
|
|
434
|
-
type: Injectable,
|
|
435
|
-
args: [{ providedIn: 'root' }]
|
|
436
|
-
}], ctorParameters: function () { return []; } });
|
|
437
526
|
|
|
438
527
|
/**
|
|
439
|
-
*
|
|
440
|
-
*
|
|
528
|
+
* RxJS operator for selecting out specific actions.
|
|
529
|
+
*
|
|
530
|
+
* This will grab actions that have just been dispatched as well as actions that have completed
|
|
441
531
|
*/
|
|
442
|
-
function
|
|
443
|
-
|
|
444
|
-
return action.constructor.type;
|
|
445
|
-
}
|
|
446
|
-
else {
|
|
447
|
-
return action.type;
|
|
448
|
-
}
|
|
532
|
+
function ofAction(...allowedTypes) {
|
|
533
|
+
return ofActionOperator(allowedTypes);
|
|
449
534
|
}
|
|
450
535
|
/**
|
|
451
|
-
*
|
|
452
|
-
*
|
|
536
|
+
* RxJS operator for selecting out specific actions.
|
|
537
|
+
*
|
|
538
|
+
* This will ONLY grab actions that have just been dispatched
|
|
453
539
|
*/
|
|
454
|
-
function
|
|
455
|
-
|
|
456
|
-
return function (action2) {
|
|
457
|
-
return type1 === getActionTypeFromInstance(action2);
|
|
458
|
-
};
|
|
540
|
+
function ofActionDispatched(...allowedTypes) {
|
|
541
|
+
return ofActionOperator(allowedTypes, ["DISPATCHED" /* Dispatched */]);
|
|
459
542
|
}
|
|
460
543
|
/**
|
|
461
|
-
*
|
|
462
|
-
*
|
|
463
|
-
* setValue({ foo: { bar: { eat: false } } },
|
|
464
|
-
* 'foo.bar.eat', true) //=> { foo: { bar: { eat: true } } }
|
|
465
|
-
*
|
|
466
|
-
* While it traverses it also creates new objects from top down.
|
|
544
|
+
* RxJS operator for selecting out specific actions.
|
|
467
545
|
*
|
|
468
|
-
*
|
|
546
|
+
* This will ONLY grab actions that have just been successfully completed
|
|
469
547
|
*/
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
const lastIndex = split.length - 1;
|
|
474
|
-
split.reduce((acc, part, index) => {
|
|
475
|
-
if (index === lastIndex) {
|
|
476
|
-
acc[part] = val;
|
|
477
|
-
}
|
|
478
|
-
else {
|
|
479
|
-
acc[part] = Array.isArray(acc[part]) ? acc[part].slice() : { ...acc[part] };
|
|
480
|
-
}
|
|
481
|
-
return acc && acc[part];
|
|
482
|
-
}, obj);
|
|
483
|
-
return obj;
|
|
484
|
-
};
|
|
548
|
+
function ofActionSuccessful(...allowedTypes) {
|
|
549
|
+
return ofActionOperator(allowedTypes, ["SUCCESSFUL" /* Successful */]);
|
|
550
|
+
}
|
|
485
551
|
/**
|
|
486
|
-
*
|
|
487
|
-
*
|
|
488
|
-
* getValue({ foo: bar: [] }, 'foo.bar') //=> []
|
|
552
|
+
* RxJS operator for selecting out specific actions.
|
|
489
553
|
*
|
|
490
|
-
*
|
|
554
|
+
* This will ONLY grab actions that have just been canceled
|
|
491
555
|
*/
|
|
492
|
-
|
|
556
|
+
function ofActionCanceled(...allowedTypes) {
|
|
557
|
+
return ofActionOperator(allowedTypes, ["CANCELED" /* Canceled */]);
|
|
558
|
+
}
|
|
493
559
|
/**
|
|
494
|
-
*
|
|
495
|
-
*
|
|
496
|
-
* isObject({a:1}) //=> true
|
|
497
|
-
* isObject(1) //=> false
|
|
560
|
+
* RxJS operator for selecting out specific actions.
|
|
498
561
|
*
|
|
499
|
-
*
|
|
562
|
+
* This will ONLY grab actions that have just been completed
|
|
500
563
|
*/
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
564
|
+
function ofActionCompleted(...allowedTypes) {
|
|
565
|
+
const allowedStatuses = [
|
|
566
|
+
"SUCCESSFUL" /* Successful */,
|
|
567
|
+
"CANCELED" /* Canceled */,
|
|
568
|
+
"ERRORED" /* Errored */
|
|
569
|
+
];
|
|
570
|
+
return ofActionOperator(allowedTypes, allowedStatuses, mapActionResult);
|
|
571
|
+
}
|
|
504
572
|
/**
|
|
505
|
-
*
|
|
506
|
-
*
|
|
507
|
-
* mergeDeep({a:1, b:{x: 1, y:2}}, {b:{x: 3}, c:4}) //=> {a:1, b:{x:3, y:2}, c:4}
|
|
573
|
+
* RxJS operator for selecting out specific actions.
|
|
508
574
|
*
|
|
509
|
-
*
|
|
575
|
+
* This will ONLY grab actions that have just thrown an error
|
|
510
576
|
*/
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
577
|
+
function ofActionErrored(...allowedTypes) {
|
|
578
|
+
return ofActionOperator(allowedTypes, ["ERRORED" /* Errored */]);
|
|
579
|
+
}
|
|
580
|
+
function ofActionOperator(allowedTypes, statuses,
|
|
581
|
+
// This actually could've been `OperatorFunction<ActionContext, ActionCompletion | any>`,
|
|
582
|
+
// since it maps either to `ctx.action` OR to `ActionCompletion`. But `ActionCompleteion | any`
|
|
583
|
+
// defaults to `any`, thus there is no sense from union type.
|
|
584
|
+
mapOperator = mapAction) {
|
|
585
|
+
const allowedMap = createAllowedActionTypesMap(allowedTypes);
|
|
586
|
+
const allowedStatusMap = statuses && createAllowedStatusesMap(statuses);
|
|
587
|
+
return function (o) {
|
|
588
|
+
return o.pipe(filterStatus(allowedMap, allowedStatusMap), mapOperator());
|
|
589
|
+
};
|
|
590
|
+
}
|
|
591
|
+
function filterStatus(allowedTypes, allowedStatuses) {
|
|
592
|
+
return filter((ctx) => {
|
|
593
|
+
const actionType = getActionTypeFromInstance(ctx.action);
|
|
594
|
+
const typeMatch = allowedTypes[actionType];
|
|
595
|
+
const statusMatch = allowedStatuses ? allowedStatuses[ctx.status] : true;
|
|
596
|
+
return typeMatch && statusMatch;
|
|
597
|
+
});
|
|
598
|
+
}
|
|
599
|
+
function mapActionResult() {
|
|
600
|
+
return map(({ action, status, error }) => {
|
|
601
|
+
return {
|
|
602
|
+
action,
|
|
603
|
+
result: {
|
|
604
|
+
successful: "SUCCESSFUL" /* Successful */ === status,
|
|
605
|
+
canceled: "CANCELED" /* Canceled */ === status,
|
|
606
|
+
error
|
|
524
607
|
}
|
|
525
|
-
}
|
|
526
|
-
}
|
|
527
|
-
return mergeDeep(base, ...sources);
|
|
528
|
-
};
|
|
529
|
-
|
|
530
|
-
const NG_DEV_MODE$3 = typeof ngDevMode === 'undefined' || ngDevMode;
|
|
531
|
-
// The injection token is used to resolve a list of states provided at
|
|
532
|
-
// the root level through either `NgxsModule.forRoot` or `provideStore`.
|
|
533
|
-
const ROOT_STATE_TOKEN = new InjectionToken(NG_DEV_MODE$3 ? 'ROOT_STATE_TOKEN' : '');
|
|
534
|
-
// The injection token is used to resolve a list of states provided at
|
|
535
|
-
// the feature level through either `NgxsModule.forFeature` or `provideStates`.
|
|
536
|
-
// The Array<Array> is used to overload the resolved value of the token because
|
|
537
|
-
// it is a multi-provider token.
|
|
538
|
-
const FEATURE_STATE_TOKEN = new InjectionToken(NG_DEV_MODE$3 ? 'FEATURE_STATE_TOKEN' : '');
|
|
539
|
-
// The injection token is used to resolve to custom NGXS plugins provided
|
|
540
|
-
// at the root level through either `{provide}` scheme or `withNgxsPlugin`.
|
|
541
|
-
const NGXS_PLUGINS = new InjectionToken(NG_DEV_MODE$3 ? 'NGXS_PLUGINS' : '');
|
|
542
|
-
// The injection token is used to resolve to options provided at the root
|
|
543
|
-
// level through either `NgxsModule.forRoot` or `provideStore`.
|
|
544
|
-
const NGXS_OPTIONS = new InjectionToken(NG_DEV_MODE$3 ? 'NGXS_OPTIONS' : '');
|
|
545
|
-
/**
|
|
546
|
-
* The NGXS config settings.
|
|
547
|
-
*/
|
|
548
|
-
class NgxsConfig {
|
|
549
|
-
constructor() {
|
|
550
|
-
/**
|
|
551
|
-
* Defining the default state before module initialization
|
|
552
|
-
* This is convenient if we need to create a define our own set of states.
|
|
553
|
-
* @deprecated will be removed after v4
|
|
554
|
-
* (default: {})
|
|
555
|
-
*/
|
|
556
|
-
this.defaultsState = {};
|
|
557
|
-
/**
|
|
558
|
-
* Defining shared selector options
|
|
559
|
-
*/
|
|
560
|
-
this.selectorOptions = {
|
|
561
|
-
injectContainerState: true,
|
|
562
|
-
suppressErrors: true // TODO: default is true in v3, will change in v4
|
|
563
|
-
};
|
|
564
|
-
this.compatibility = {
|
|
565
|
-
strictContentSecurityPolicy: false
|
|
566
608
|
};
|
|
567
|
-
|
|
568
|
-
}
|
|
609
|
+
});
|
|
569
610
|
}
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
611
|
+
function mapAction() {
|
|
612
|
+
return map((ctx) => ctx.action);
|
|
613
|
+
}
|
|
614
|
+
function createAllowedActionTypesMap(types) {
|
|
615
|
+
return types.reduce((filterMap, klass) => {
|
|
616
|
+
filterMap[getActionTypeFromInstance(klass)] = true;
|
|
617
|
+
return filterMap;
|
|
618
|
+
}, {});
|
|
619
|
+
}
|
|
620
|
+
function createAllowedStatusesMap(statuses) {
|
|
621
|
+
return statuses.reduce((filterMap, status) => {
|
|
622
|
+
filterMap[status] = true;
|
|
623
|
+
return filterMap;
|
|
624
|
+
}, {});
|
|
625
|
+
}
|
|
626
|
+
|
|
579
627
|
/**
|
|
580
|
-
*
|
|
581
|
-
*
|
|
628
|
+
* Returns operator that will run
|
|
629
|
+
* `subscribe` outside of the ngxs execution context
|
|
582
630
|
*/
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
631
|
+
function leaveNgxs(ngxsExecutionStrategy) {
|
|
632
|
+
return (source) => {
|
|
633
|
+
return new Observable((sink) => {
|
|
634
|
+
return source.subscribe({
|
|
635
|
+
next(value) {
|
|
636
|
+
ngxsExecutionStrategy.leave(() => sink.next(value));
|
|
637
|
+
},
|
|
638
|
+
error(error) {
|
|
639
|
+
ngxsExecutionStrategy.leave(() => sink.error(error));
|
|
640
|
+
},
|
|
641
|
+
complete() {
|
|
642
|
+
ngxsExecutionStrategy.leave(() => sink.complete());
|
|
643
|
+
}
|
|
644
|
+
});
|
|
645
|
+
});
|
|
646
|
+
};
|
|
589
647
|
}
|
|
590
648
|
|
|
591
|
-
class
|
|
649
|
+
class InternalNgxsExecutionStrategy {
|
|
650
|
+
constructor(_executionStrategy) {
|
|
651
|
+
this._executionStrategy = _executionStrategy;
|
|
652
|
+
}
|
|
653
|
+
enter(func) {
|
|
654
|
+
return this._executionStrategy.enter(func);
|
|
655
|
+
}
|
|
656
|
+
leave(func) {
|
|
657
|
+
return this._executionStrategy.leave(func);
|
|
658
|
+
}
|
|
659
|
+
}
|
|
660
|
+
/** @nocollapse */ InternalNgxsExecutionStrategy.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: InternalNgxsExecutionStrategy, deps: [{ token: NGXS_EXECUTION_STRATEGY }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
661
|
+
/** @nocollapse */ InternalNgxsExecutionStrategy.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: InternalNgxsExecutionStrategy, providedIn: 'root' });
|
|
662
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: InternalNgxsExecutionStrategy, decorators: [{
|
|
663
|
+
type: Injectable,
|
|
664
|
+
args: [{ providedIn: 'root' }]
|
|
665
|
+
}], ctorParameters: function () { return [{ type: undefined, decorators: [{
|
|
666
|
+
type: Inject,
|
|
667
|
+
args: [NGXS_EXECUTION_STRATEGY]
|
|
668
|
+
}] }]; } });
|
|
669
|
+
|
|
670
|
+
/**
|
|
671
|
+
* This wraps the provided function, and will enforce the following:
|
|
672
|
+
* - The calls will execute in the order that they are made
|
|
673
|
+
* - A call will only be initiated when the previous call has completed
|
|
674
|
+
* - If there is a call currently executing then the new call will be added
|
|
675
|
+
* to the queue and the function will return immediately
|
|
676
|
+
*
|
|
677
|
+
* NOTE: The following assumptions about the operation must hold true:
|
|
678
|
+
* - The operation is synchronous in nature
|
|
679
|
+
* - If any asynchronous side effects of the call exist, it should not
|
|
680
|
+
* have any bearing on the correctness of the next call in the queue
|
|
681
|
+
* - The operation has a void return
|
|
682
|
+
* - The caller should not assume that the call has completed upon
|
|
683
|
+
* return of the function
|
|
684
|
+
* - The caller can assume that all the queued calls will complete
|
|
685
|
+
* within the current microtask
|
|
686
|
+
* - The only way that a call will encounter another call in the queue
|
|
687
|
+
* would be if the call at the front of the queue initiated this call
|
|
688
|
+
* as part of its synchronous execution
|
|
689
|
+
*/
|
|
690
|
+
function orderedQueueOperation(operation) {
|
|
691
|
+
const callsQueue = [];
|
|
692
|
+
let busyPushingNext = false;
|
|
693
|
+
return function callOperation(...args) {
|
|
694
|
+
if (busyPushingNext) {
|
|
695
|
+
callsQueue.unshift(args);
|
|
696
|
+
return;
|
|
697
|
+
}
|
|
698
|
+
busyPushingNext = true;
|
|
699
|
+
operation(...args);
|
|
700
|
+
while (callsQueue.length > 0) {
|
|
701
|
+
const nextCallArgs = callsQueue.pop();
|
|
702
|
+
nextCallArgs && operation(...nextCallArgs);
|
|
703
|
+
}
|
|
704
|
+
busyPushingNext = false;
|
|
705
|
+
};
|
|
706
|
+
}
|
|
707
|
+
/**
|
|
708
|
+
* Custom Subject that ensures that subscribers are notified of values in the order that they arrived.
|
|
709
|
+
* A standard Subject does not have this guarantee.
|
|
710
|
+
* For example, given the following code:
|
|
711
|
+
* ```typescript
|
|
712
|
+
* const subject = new Subject<string>();
|
|
713
|
+
subject.subscribe(value => {
|
|
714
|
+
if (value === 'start') subject.next('end');
|
|
715
|
+
});
|
|
716
|
+
subject.subscribe(value => { });
|
|
717
|
+
subject.next('start');
|
|
718
|
+
* ```
|
|
719
|
+
* When `subject` is a standard `Subject<T>` the second subscriber would recieve `end` and then `start`.
|
|
720
|
+
* When `subject` is a `OrderedSubject<T>` the second subscriber would recieve `start` and then `end`.
|
|
721
|
+
*/
|
|
722
|
+
class OrderedSubject extends Subject {
|
|
723
|
+
constructor() {
|
|
724
|
+
super(...arguments);
|
|
725
|
+
this._orderedNext = orderedQueueOperation((value) => super.next(value));
|
|
726
|
+
}
|
|
727
|
+
next(value) {
|
|
728
|
+
this._orderedNext(value);
|
|
729
|
+
}
|
|
730
|
+
}
|
|
731
|
+
/**
|
|
732
|
+
* Custom BehaviorSubject that ensures that subscribers are notified of values in the order that they arrived.
|
|
733
|
+
* A standard BehaviorSubject does not have this guarantee.
|
|
734
|
+
* For example, given the following code:
|
|
735
|
+
* ```typescript
|
|
736
|
+
* const subject = new BehaviorSubject<string>();
|
|
737
|
+
subject.subscribe(value => {
|
|
738
|
+
if (value === 'start') subject.next('end');
|
|
739
|
+
});
|
|
740
|
+
subject.subscribe(value => { });
|
|
741
|
+
subject.next('start');
|
|
742
|
+
* ```
|
|
743
|
+
* When `subject` is a standard `BehaviorSubject<T>` the second subscriber would recieve `end` and then `start`.
|
|
744
|
+
* When `subject` is a `OrderedBehaviorSubject<T>` the second subscriber would recieve `start` and then `end`.
|
|
745
|
+
*/
|
|
746
|
+
class OrderedBehaviorSubject extends BehaviorSubject {
|
|
747
|
+
constructor(value) {
|
|
748
|
+
super(value);
|
|
749
|
+
this._orderedNext = orderedQueueOperation((value) => super.next(value));
|
|
750
|
+
this._currentValue = value;
|
|
751
|
+
}
|
|
752
|
+
getValue() {
|
|
753
|
+
return this._currentValue;
|
|
754
|
+
}
|
|
755
|
+
next(value) {
|
|
756
|
+
this._currentValue = value;
|
|
757
|
+
this._orderedNext(value);
|
|
758
|
+
}
|
|
759
|
+
}
|
|
760
|
+
|
|
761
|
+
/**
|
|
762
|
+
* Internal Action stream that is emitted anytime an action is dispatched.
|
|
763
|
+
*/
|
|
764
|
+
class InternalActions extends OrderedSubject {
|
|
765
|
+
ngOnDestroy() {
|
|
766
|
+
this.complete();
|
|
767
|
+
}
|
|
768
|
+
}
|
|
769
|
+
/** @nocollapse */ InternalActions.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: InternalActions, deps: null, target: i0.ɵɵFactoryTarget.Injectable });
|
|
770
|
+
/** @nocollapse */ InternalActions.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: InternalActions, providedIn: 'root' });
|
|
771
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: InternalActions, decorators: [{
|
|
772
|
+
type: Injectable,
|
|
773
|
+
args: [{ providedIn: 'root' }]
|
|
774
|
+
}] });
|
|
775
|
+
/**
|
|
776
|
+
* Action stream that is emitted anytime an action is dispatched.
|
|
777
|
+
*
|
|
778
|
+
* You can listen to this in services to react without stores.
|
|
779
|
+
*/
|
|
780
|
+
class Actions extends Observable {
|
|
781
|
+
constructor(internalActions$, internalExecutionStrategy) {
|
|
782
|
+
const sharedInternalActions$ = internalActions$.pipe(leaveNgxs(internalExecutionStrategy),
|
|
783
|
+
// The `InternalActions` subject emits outside of the Angular zone.
|
|
784
|
+
// We have to re-enter the Angular zone for any incoming consumer.
|
|
785
|
+
// The `share()` operator reduces the number of change detections.
|
|
786
|
+
// This would call leave only once for any stream emission across all active subscribers.
|
|
787
|
+
share());
|
|
788
|
+
super(observer => {
|
|
789
|
+
const childSubscription = sharedInternalActions$.subscribe({
|
|
790
|
+
next: ctx => observer.next(ctx),
|
|
791
|
+
error: error => observer.error(error),
|
|
792
|
+
complete: () => observer.complete()
|
|
793
|
+
});
|
|
794
|
+
observer.add(childSubscription);
|
|
795
|
+
});
|
|
796
|
+
}
|
|
797
|
+
}
|
|
798
|
+
/** @nocollapse */ Actions.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: Actions, deps: [{ token: InternalActions }, { token: InternalNgxsExecutionStrategy }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
799
|
+
/** @nocollapse */ Actions.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: Actions, providedIn: 'root' });
|
|
800
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: Actions, decorators: [{
|
|
801
|
+
type: Injectable,
|
|
802
|
+
args: [{ providedIn: 'root' }]
|
|
803
|
+
}], ctorParameters: function () { return [{ type: InternalActions }, { type: InternalNgxsExecutionStrategy }]; } });
|
|
804
|
+
|
|
805
|
+
/**
|
|
806
|
+
* Composes a array of functions from left to right. Example:
|
|
807
|
+
*
|
|
808
|
+
* compose([fn, final])(state, action);
|
|
809
|
+
*
|
|
810
|
+
* then the funcs have a signature like:
|
|
811
|
+
*
|
|
812
|
+
* function fn (state, action, next) {
|
|
813
|
+
* console.log('here', state, action, next);
|
|
814
|
+
* return next(state, action);
|
|
815
|
+
* }
|
|
816
|
+
*
|
|
817
|
+
* function final (state, action) {
|
|
818
|
+
* console.log('here', state, action);
|
|
819
|
+
* return state;
|
|
820
|
+
* }
|
|
821
|
+
*
|
|
822
|
+
* the last function should not call `next`.
|
|
823
|
+
*
|
|
824
|
+
* @ignore
|
|
825
|
+
*/
|
|
826
|
+
const compose = (funcs) => (...args) => {
|
|
827
|
+
const curr = funcs.shift();
|
|
828
|
+
return curr(...args, (...nextArgs) => compose(funcs)(...nextArgs));
|
|
829
|
+
};
|
|
830
|
+
|
|
831
|
+
/**
|
|
832
|
+
* This operator is used for piping the observable result
|
|
833
|
+
* from the `dispatch()`. It has a "smart" error handling
|
|
834
|
+
* strategy that allows us to decide whether we propagate
|
|
835
|
+
* errors to Angular's `ErrorHandler` or enable users to
|
|
836
|
+
* handle them manually. We consider following cases:
|
|
837
|
+
* 1) `store.dispatch()` (no subscribe) -> call `handleError()`
|
|
838
|
+
* 2) `store.dispatch().subscribe()` (no error callback) -> call `handleError()`
|
|
839
|
+
* 3) `store.dispatch().subscribe({ error: ... })` -> don't call `handleError()`
|
|
840
|
+
* 4) `toPromise()` without `catch` -> do `handleError()`
|
|
841
|
+
* 5) `toPromise()` with `catch` -> don't `handleError()`
|
|
842
|
+
*/
|
|
843
|
+
function ngxsErrorHandler(internalErrorReporter, ngxsExecutionStrategy) {
|
|
844
|
+
return (source) => {
|
|
845
|
+
let subscribed = false;
|
|
846
|
+
source.subscribe({
|
|
847
|
+
error: error => {
|
|
848
|
+
// Do not trigger change detection for a microtask. This depends on the execution
|
|
849
|
+
// strategy being used, but the default `DispatchOutsideZoneNgxsExecutionStrategy`
|
|
850
|
+
// leaves the Angular zone.
|
|
851
|
+
ngxsExecutionStrategy.enter(() => Promise.resolve().then(() => {
|
|
852
|
+
if (!subscribed) {
|
|
853
|
+
ngxsExecutionStrategy.leave(() => internalErrorReporter.reportErrorSafely(error));
|
|
854
|
+
}
|
|
855
|
+
}));
|
|
856
|
+
}
|
|
857
|
+
});
|
|
858
|
+
return new Observable(subscriber => {
|
|
859
|
+
subscribed = true;
|
|
860
|
+
return source.pipe(leaveNgxs(ngxsExecutionStrategy)).subscribe(subscriber);
|
|
861
|
+
});
|
|
862
|
+
};
|
|
863
|
+
}
|
|
864
|
+
class InternalErrorReporter {
|
|
865
|
+
constructor(_injector) {
|
|
866
|
+
this._injector = _injector;
|
|
867
|
+
/** Will be set lazily to be backward compatible. */
|
|
868
|
+
this._errorHandler = null;
|
|
869
|
+
}
|
|
870
|
+
reportErrorSafely(error) {
|
|
871
|
+
if (this._errorHandler === null) {
|
|
872
|
+
this._errorHandler = this._injector.get(ErrorHandler);
|
|
873
|
+
}
|
|
874
|
+
// The `try-catch` is used to avoid handling the error twice. Suppose we call
|
|
875
|
+
// `handleError` which re-throws the error internally. The re-thrown error will
|
|
876
|
+
// be caught by zone.js which will then get to the `zone.onError.emit()` and the
|
|
877
|
+
// `onError` subscriber will call `handleError` again.
|
|
878
|
+
try {
|
|
879
|
+
this._errorHandler.handleError(error);
|
|
880
|
+
}
|
|
881
|
+
catch (_a) { }
|
|
882
|
+
}
|
|
883
|
+
}
|
|
884
|
+
/** @nocollapse */ InternalErrorReporter.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: InternalErrorReporter, deps: [{ token: i0.Injector }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
885
|
+
/** @nocollapse */ InternalErrorReporter.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: InternalErrorReporter, providedIn: 'root' });
|
|
886
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: InternalErrorReporter, decorators: [{
|
|
887
|
+
type: Injectable,
|
|
888
|
+
args: [{ providedIn: 'root' }]
|
|
889
|
+
}], ctorParameters: function () { return [{ type: i0.Injector }]; } });
|
|
890
|
+
|
|
891
|
+
/**
|
|
892
|
+
* BehaviorSubject of the entire state.
|
|
893
|
+
* @ignore
|
|
894
|
+
*/
|
|
895
|
+
class StateStream extends OrderedBehaviorSubject {
|
|
896
|
+
constructor() {
|
|
897
|
+
super({});
|
|
898
|
+
}
|
|
899
|
+
ngOnDestroy() {
|
|
900
|
+
// The `StateStream` should never emit values once the root view is removed, e.g. when the `NgModuleRef.destroy()` is called.
|
|
901
|
+
// This will eliminate memory leaks in server-side rendered apps where the `StateStream` is created per each HTTP request, users
|
|
902
|
+
// might forget to unsubscribe from `store.select` or `store.subscribe`, thus this will lead to huge memory leaks in SSR apps.
|
|
903
|
+
this.complete();
|
|
904
|
+
}
|
|
905
|
+
}
|
|
906
|
+
/** @nocollapse */ StateStream.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: StateStream, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
907
|
+
/** @nocollapse */ StateStream.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: StateStream, providedIn: 'root' });
|
|
908
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: StateStream, decorators: [{
|
|
909
|
+
type: Injectable,
|
|
910
|
+
args: [{ providedIn: 'root' }]
|
|
911
|
+
}], ctorParameters: function () { return []; } });
|
|
912
|
+
|
|
913
|
+
class PluginManager {
|
|
592
914
|
constructor(_parentManager, _pluginHandlers) {
|
|
593
915
|
this._parentManager = _parentManager;
|
|
594
916
|
this._pluginHandlers = _pluginHandlers;
|
|
@@ -607,9 +929,9 @@ class PluginManager {
|
|
|
607
929
|
return handlers.map((plugin) => (plugin.handle ? plugin.handle.bind(plugin) : plugin));
|
|
608
930
|
}
|
|
609
931
|
}
|
|
610
|
-
/** @nocollapse */ PluginManager.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
611
|
-
/** @nocollapse */ PluginManager.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "
|
|
612
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
932
|
+
/** @nocollapse */ PluginManager.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: PluginManager, deps: [{ token: PluginManager, optional: true, skipSelf: true }, { token: NGXS_PLUGINS, optional: true }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
933
|
+
/** @nocollapse */ PluginManager.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: PluginManager });
|
|
934
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: PluginManager, decorators: [{
|
|
613
935
|
type: Injectable
|
|
614
936
|
}], ctorParameters: function () { return [{ type: PluginManager, decorators: [{
|
|
615
937
|
type: Optional
|
|
@@ -630,9 +952,9 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.4", ngImpor
|
|
|
630
952
|
*/
|
|
631
953
|
class InternalDispatchedActionResults extends Subject {
|
|
632
954
|
}
|
|
633
|
-
/** @nocollapse */ InternalDispatchedActionResults.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
634
|
-
/** @nocollapse */ InternalDispatchedActionResults.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "
|
|
635
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
955
|
+
/** @nocollapse */ InternalDispatchedActionResults.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: InternalDispatchedActionResults, deps: null, target: i0.ɵɵFactoryTarget.Injectable });
|
|
956
|
+
/** @nocollapse */ InternalDispatchedActionResults.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: InternalDispatchedActionResults, providedIn: 'root' });
|
|
957
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: InternalDispatchedActionResults, decorators: [{
|
|
636
958
|
type: Injectable,
|
|
637
959
|
args: [{ providedIn: 'root' }]
|
|
638
960
|
}] });
|
|
@@ -680,21 +1002,21 @@ class InternalDispatcher {
|
|
|
680
1002
|
}
|
|
681
1003
|
const actionResult$ = this.getActionResultStream(nextAction);
|
|
682
1004
|
actionResult$.subscribe(ctx => this._actions.next(ctx));
|
|
683
|
-
this._actions.next({ action: nextAction, status: "DISPATCHED" /*
|
|
1005
|
+
this._actions.next({ action: nextAction, status: "DISPATCHED" /* Dispatched */ });
|
|
684
1006
|
return this.createDispatchObservable(actionResult$);
|
|
685
1007
|
}
|
|
686
1008
|
])(prevState, action).pipe(shareReplay());
|
|
687
1009
|
}
|
|
688
1010
|
getActionResultStream(action) {
|
|
689
|
-
return this._actionResults.pipe(filter((ctx) => ctx.action === action && ctx.status !== "DISPATCHED" /*
|
|
1011
|
+
return this._actionResults.pipe(filter((ctx) => ctx.action === action && ctx.status !== "DISPATCHED" /* Dispatched */), take(1), shareReplay());
|
|
690
1012
|
}
|
|
691
1013
|
createDispatchObservable(actionResult$) {
|
|
692
1014
|
return actionResult$
|
|
693
1015
|
.pipe(exhaustMap((ctx) => {
|
|
694
1016
|
switch (ctx.status) {
|
|
695
|
-
case "SUCCESSFUL" /*
|
|
1017
|
+
case "SUCCESSFUL" /* Successful */:
|
|
696
1018
|
return of(this._stateStream.getValue());
|
|
697
|
-
case "ERRORED" /*
|
|
1019
|
+
case "ERRORED" /* Errored */:
|
|
698
1020
|
return throwError(ctx.error);
|
|
699
1021
|
default:
|
|
700
1022
|
return EMPTY;
|
|
@@ -703,9 +1025,9 @@ class InternalDispatcher {
|
|
|
703
1025
|
.pipe(shareReplay());
|
|
704
1026
|
}
|
|
705
1027
|
}
|
|
706
|
-
/** @nocollapse */ InternalDispatcher.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
707
|
-
/** @nocollapse */ InternalDispatcher.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "
|
|
708
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
1028
|
+
/** @nocollapse */ InternalDispatcher.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: InternalDispatcher, deps: [{ token: InternalActions }, { token: InternalDispatchedActionResults }, { token: PluginManager }, { token: StateStream }, { token: InternalNgxsExecutionStrategy }, { token: InternalErrorReporter }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
1029
|
+
/** @nocollapse */ InternalDispatcher.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: InternalDispatcher, providedIn: 'root' });
|
|
1030
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: InternalDispatcher, decorators: [{
|
|
709
1031
|
type: Injectable,
|
|
710
1032
|
args: [{ providedIn: 'root' }]
|
|
711
1033
|
}], ctorParameters: function () { return [{ type: InternalActions }, { type: InternalDispatchedActionResults }, { type: PluginManager }, { type: StateStream }, { type: InternalNgxsExecutionStrategy }, { type: InternalErrorReporter }]; } });
|
|
@@ -728,479 +1050,60 @@ const deepFreeze = (o) => {
|
|
|
728
1050
|
}
|
|
729
1051
|
});
|
|
730
1052
|
return o;
|
|
731
|
-
};
|
|
732
|
-
|
|
733
|
-
/**
|
|
734
|
-
* @ignore
|
|
735
|
-
*/
|
|
736
|
-
class InternalStateOperations {
|
|
737
|
-
constructor(_stateStream, _dispatcher, _config) {
|
|
738
|
-
this._stateStream = _stateStream;
|
|
739
|
-
this._dispatcher = _dispatcher;
|
|
740
|
-
this._config = _config;
|
|
741
|
-
}
|
|
742
|
-
/**
|
|
743
|
-
* Returns the root state operators.
|
|
744
|
-
*/
|
|
745
|
-
getRootStateOperations() {
|
|
746
|
-
const rootStateOperations = {
|
|
747
|
-
getState: () => this._stateStream.getValue(),
|
|
748
|
-
setState: (newState) => this._stateStream.next(newState),
|
|
749
|
-
dispatch: (actionOrActions) => this._dispatcher.dispatch(actionOrActions)
|
|
750
|
-
};
|
|
751
|
-
if (typeof ngDevMode === 'undefined' || ngDevMode) {
|
|
752
|
-
return this._config.developmentMode
|
|
753
|
-
? ensureStateAndActionsAreImmutable(rootStateOperations)
|
|
754
|
-
: rootStateOperations;
|
|
755
|
-
}
|
|
756
|
-
else {
|
|
757
|
-
return rootStateOperations;
|
|
758
|
-
}
|
|
759
|
-
}
|
|
760
|
-
setStateToTheCurrentWithNew(results) {
|
|
761
|
-
const stateOperations = this.getRootStateOperations();
|
|
762
|
-
// Get our current stream
|
|
763
|
-
const currentState = stateOperations.getState();
|
|
764
|
-
// Set the state to the current + new
|
|
765
|
-
stateOperations.setState({ ...currentState, ...results.defaults });
|
|
766
|
-
}
|
|
767
|
-
}
|
|
768
|
-
/** @nocollapse */ InternalStateOperations.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.4", ngImport: i0, type: InternalStateOperations, deps: [{ token: StateStream }, { token: InternalDispatcher }, { token: NgxsConfig }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
769
|
-
/** @nocollapse */ InternalStateOperations.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.4", ngImport: i0, type: InternalStateOperations, providedIn: 'root' });
|
|
770
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.4", ngImport: i0, type: InternalStateOperations, decorators: [{
|
|
771
|
-
type: Injectable,
|
|
772
|
-
args: [{ providedIn: 'root' }]
|
|
773
|
-
}], ctorParameters: function () { return [{ type: StateStream }, { type: InternalDispatcher }, { type: NgxsConfig }]; } });
|
|
774
|
-
function ensureStateAndActionsAreImmutable(root) {
|
|
775
|
-
return {
|
|
776
|
-
getState: () => root.getState(),
|
|
777
|
-
setState: value => {
|
|
778
|
-
const frozenValue = deepFreeze(value);
|
|
779
|
-
return root.setState(frozenValue);
|
|
780
|
-
},
|
|
781
|
-
dispatch: actions => {
|
|
782
|
-
return root.dispatch(actions);
|
|
783
|
-
}
|
|
784
|
-
};
|
|
785
|
-
}
|
|
786
|
-
|
|
787
|
-
/**
|
|
788
|
-
* Ensures metadata is attached to the class and returns it.
|
|
789
|
-
*
|
|
790
|
-
* @ignore
|
|
791
|
-
*/
|
|
792
|
-
function ensureStoreMetadata$1(target) {
|
|
793
|
-
if (!target.hasOwnProperty(ɵMETA_KEY)) {
|
|
794
|
-
const defaultMetadata = {
|
|
795
|
-
name: null,
|
|
796
|
-
actions: {},
|
|
797
|
-
defaults: {},
|
|
798
|
-
path: null,
|
|
799
|
-
makeRootSelector(context) {
|
|
800
|
-
return context.getStateGetter(defaultMetadata.name);
|
|
801
|
-
},
|
|
802
|
-
children: []
|
|
803
|
-
};
|
|
804
|
-
Object.defineProperty(target, ɵMETA_KEY, { value: defaultMetadata });
|
|
805
|
-
}
|
|
806
|
-
return getStoreMetadata$1(target);
|
|
807
|
-
}
|
|
808
|
-
/**
|
|
809
|
-
* Get the metadata attached to the state class if it exists.
|
|
810
|
-
*
|
|
811
|
-
* @ignore
|
|
812
|
-
*/
|
|
813
|
-
function getStoreMetadata$1(target) {
|
|
814
|
-
return target[ɵMETA_KEY];
|
|
815
|
-
}
|
|
816
|
-
/**
|
|
817
|
-
* Ensures metadata is attached to the selector and returns it.
|
|
818
|
-
*
|
|
819
|
-
* @ignore
|
|
820
|
-
*/
|
|
821
|
-
function ensureSelectorMetadata$1(target) {
|
|
822
|
-
if (!target.hasOwnProperty(ɵSELECTOR_META_KEY)) {
|
|
823
|
-
const defaultMetadata = {
|
|
824
|
-
makeRootSelector: null,
|
|
825
|
-
originalFn: null,
|
|
826
|
-
containerClass: null,
|
|
827
|
-
selectorName: null,
|
|
828
|
-
getSelectorOptions: () => ({})
|
|
829
|
-
};
|
|
830
|
-
Object.defineProperty(target, ɵSELECTOR_META_KEY, { value: defaultMetadata });
|
|
831
|
-
}
|
|
832
|
-
return getSelectorMetadata$1(target);
|
|
833
|
-
}
|
|
834
|
-
/**
|
|
835
|
-
* Get the metadata attached to the selector if it exists.
|
|
836
|
-
*
|
|
837
|
-
* @ignore
|
|
838
|
-
*/
|
|
839
|
-
function getSelectorMetadata$1(target) {
|
|
840
|
-
return target[ɵSELECTOR_META_KEY];
|
|
841
|
-
}
|
|
842
|
-
/**
|
|
843
|
-
* Get a deeply nested value. Example:
|
|
844
|
-
*
|
|
845
|
-
* getValue({ foo: bar: [] }, 'foo.bar') //=> []
|
|
846
|
-
*
|
|
847
|
-
* Note: This is not as fast as the `fastPropGetter` but is strict Content Security Policy compliant.
|
|
848
|
-
* See perf hit: https://jsperf.com/fast-value-getter-given-path/1
|
|
849
|
-
*
|
|
850
|
-
* @ignore
|
|
851
|
-
*/
|
|
852
|
-
function compliantPropGetter(paths) {
|
|
853
|
-
const copyOfPaths = paths.slice();
|
|
854
|
-
return obj => copyOfPaths.reduce((acc, part) => acc && acc[part], obj);
|
|
855
|
-
}
|
|
856
|
-
/**
|
|
857
|
-
* The generated function is faster than:
|
|
858
|
-
* - pluck (Observable operator)
|
|
859
|
-
* - memoize
|
|
860
|
-
*
|
|
861
|
-
* @ignore
|
|
862
|
-
*/
|
|
863
|
-
function fastPropGetter(paths) {
|
|
864
|
-
const segments = paths;
|
|
865
|
-
let seg = 'store.' + segments[0];
|
|
866
|
-
let i = 0;
|
|
867
|
-
const l = segments.length;
|
|
868
|
-
let expr = seg;
|
|
869
|
-
while (++i < l) {
|
|
870
|
-
expr = expr + ' && ' + (seg = seg + '.' + segments[i]);
|
|
871
|
-
}
|
|
872
|
-
const fn = new Function('store', 'return ' + expr + ';');
|
|
873
|
-
return fn;
|
|
874
|
-
}
|
|
875
|
-
/**
|
|
876
|
-
* Get a deeply nested value. Example:
|
|
877
|
-
*
|
|
878
|
-
* getValue({ foo: bar: [] }, 'foo.bar') //=> []
|
|
879
|
-
*
|
|
880
|
-
* @ignore
|
|
881
|
-
*/
|
|
882
|
-
function propGetter(paths, config) {
|
|
883
|
-
if (config && config.compatibility && config.compatibility.strictContentSecurityPolicy) {
|
|
884
|
-
return compliantPropGetter(paths);
|
|
885
|
-
}
|
|
886
|
-
else {
|
|
887
|
-
return fastPropGetter(paths);
|
|
888
|
-
}
|
|
889
|
-
}
|
|
890
|
-
/**
|
|
891
|
-
* Given an array of states, it will return a object graph. Example:
|
|
892
|
-
* const states = [
|
|
893
|
-
* Cart,
|
|
894
|
-
* CartSaved,
|
|
895
|
-
* CartSavedItems
|
|
896
|
-
* ]
|
|
897
|
-
*
|
|
898
|
-
* would return:
|
|
899
|
-
*
|
|
900
|
-
* const graph = {
|
|
901
|
-
* cart: ['saved'],
|
|
902
|
-
* saved: ['items'],
|
|
903
|
-
* items: []
|
|
904
|
-
* };
|
|
905
|
-
*
|
|
906
|
-
* @ignore
|
|
907
|
-
*/
|
|
908
|
-
function buildGraph(stateClasses) {
|
|
909
|
-
const findName = (stateClass) => {
|
|
910
|
-
const meta = stateClasses.find(g => g === stateClass);
|
|
911
|
-
// Caretaker note: we have still left the `typeof` condition in order to avoid
|
|
912
|
-
// creating a breaking change for projects that still use the View Engine.
|
|
913
|
-
if ((typeof ngDevMode === 'undefined' || ngDevMode) && !meta) {
|
|
914
|
-
throw new Error(`Child state not found: ${stateClass}. \r\nYou may have forgotten to add states to module`);
|
|
915
|
-
}
|
|
916
|
-
return meta[ɵMETA_KEY].name;
|
|
917
|
-
};
|
|
918
|
-
return stateClasses.reduce((result, stateClass) => {
|
|
919
|
-
const { name, children } = stateClass[ɵMETA_KEY];
|
|
920
|
-
result[name] = (children || []).map(findName);
|
|
921
|
-
return result;
|
|
922
|
-
}, {});
|
|
923
|
-
}
|
|
924
|
-
/**
|
|
925
|
-
* Given a states array, returns object graph
|
|
926
|
-
* returning the name and state metadata. Example:
|
|
927
|
-
*
|
|
928
|
-
* const graph = {
|
|
929
|
-
* cart: { metadata }
|
|
930
|
-
* };
|
|
931
|
-
*
|
|
932
|
-
* @ignore
|
|
933
|
-
*/
|
|
934
|
-
function nameToState(states) {
|
|
935
|
-
return states.reduce((result, stateClass) => {
|
|
936
|
-
const meta = stateClass[ɵMETA_KEY];
|
|
937
|
-
result[meta.name] = stateClass;
|
|
938
|
-
return result;
|
|
939
|
-
}, {});
|
|
940
|
-
}
|
|
941
|
-
/**
|
|
942
|
-
* Given a object relationship graph will return the full path
|
|
943
|
-
* for the child items. Example:
|
|
944
|
-
*
|
|
945
|
-
* const graph = {
|
|
946
|
-
* cart: ['saved'],
|
|
947
|
-
* saved: ['items'],
|
|
948
|
-
* items: []
|
|
949
|
-
* };
|
|
950
|
-
*
|
|
951
|
-
* would return:
|
|
952
|
-
*
|
|
953
|
-
* const r = {
|
|
954
|
-
* cart: 'cart',
|
|
955
|
-
* saved: 'cart.saved',
|
|
956
|
-
* items: 'cart.saved.items'
|
|
957
|
-
* };
|
|
958
|
-
*
|
|
959
|
-
* @ignore
|
|
960
|
-
*/
|
|
961
|
-
function findFullParentPath(obj, newObj = {}) {
|
|
962
|
-
const visit = (child, keyToFind) => {
|
|
963
|
-
for (const key in child) {
|
|
964
|
-
if (child.hasOwnProperty(key) && child[key].indexOf(keyToFind) >= 0) {
|
|
965
|
-
const parent = visit(child, key);
|
|
966
|
-
return parent !== null ? `${parent}.${key}` : key;
|
|
967
|
-
}
|
|
968
|
-
}
|
|
969
|
-
return null;
|
|
970
|
-
};
|
|
971
|
-
for (const key in obj) {
|
|
972
|
-
if (obj.hasOwnProperty(key)) {
|
|
973
|
-
const parent = visit(obj, key);
|
|
974
|
-
newObj[key] = parent ? `${parent}.${key}` : key;
|
|
975
|
-
}
|
|
976
|
-
}
|
|
977
|
-
return newObj;
|
|
978
|
-
}
|
|
979
|
-
/**
|
|
980
|
-
* Given a object graph, it will return the items topologically sorted Example:
|
|
981
|
-
*
|
|
982
|
-
* const graph = {
|
|
983
|
-
* cart: ['saved'],
|
|
984
|
-
* saved: ['items'],
|
|
985
|
-
* items: []
|
|
986
|
-
* };
|
|
987
|
-
*
|
|
988
|
-
* would return:
|
|
989
|
-
*
|
|
990
|
-
* const results = [
|
|
991
|
-
* 'items',
|
|
992
|
-
* 'saved',
|
|
993
|
-
* 'cart'
|
|
994
|
-
* ];
|
|
995
|
-
*
|
|
996
|
-
* @ignore
|
|
997
|
-
*/
|
|
998
|
-
function topologicalSort(graph) {
|
|
999
|
-
const sorted = [];
|
|
1000
|
-
const visited = {};
|
|
1001
|
-
const visit = (name, ancestors = []) => {
|
|
1002
|
-
if (!Array.isArray(ancestors)) {
|
|
1003
|
-
ancestors = [];
|
|
1004
|
-
}
|
|
1005
|
-
ancestors.push(name);
|
|
1006
|
-
visited[name] = true;
|
|
1007
|
-
graph[name].forEach((dep) => {
|
|
1008
|
-
// Caretaker note: we have still left the `typeof` condition in order to avoid
|
|
1009
|
-
// creating a breaking change for projects that still use the View Engine.
|
|
1010
|
-
if ((typeof ngDevMode === 'undefined' || ngDevMode) && ancestors.indexOf(dep) >= 0) {
|
|
1011
|
-
throw new Error(`Circular dependency '${dep}' is required by '${name}': ${ancestors.join(' -> ')}`);
|
|
1012
|
-
}
|
|
1013
|
-
if (visited[dep]) {
|
|
1014
|
-
return;
|
|
1015
|
-
}
|
|
1016
|
-
visit(dep, ancestors.slice(0));
|
|
1017
|
-
});
|
|
1018
|
-
if (sorted.indexOf(name) < 0) {
|
|
1019
|
-
sorted.push(name);
|
|
1020
|
-
}
|
|
1021
|
-
};
|
|
1022
|
-
Object.keys(graph).forEach(k => visit(k));
|
|
1023
|
-
return sorted.reverse();
|
|
1024
|
-
}
|
|
1025
|
-
/**
|
|
1026
|
-
* Returns if the parameter is a object or not.
|
|
1027
|
-
*
|
|
1028
|
-
* @ignore
|
|
1029
|
-
*/
|
|
1030
|
-
function isObject(obj) {
|
|
1031
|
-
return (typeof obj === 'object' && obj !== null) || typeof obj === 'function';
|
|
1032
|
-
}
|
|
1033
|
-
|
|
1034
|
-
function createRootSelectorFactory(selectorMetaData, selectors, memoizedSelectorFn) {
|
|
1035
|
-
return (context) => {
|
|
1036
|
-
const { argumentSelectorFunctions, selectorOptions } = getRuntimeSelectorInfo(context, selectorMetaData, selectors);
|
|
1037
|
-
return function selectFromRoot(rootState) {
|
|
1038
|
-
// Determine arguments from the app state using the selectors
|
|
1039
|
-
const results = argumentSelectorFunctions.map((argFn) => argFn(rootState));
|
|
1040
|
-
// if the lambda tries to access a something on the
|
|
1041
|
-
// state that doesn't exist, it will throw a TypeError.
|
|
1042
|
-
// since this is quite usual behaviour, we simply return undefined if so.
|
|
1043
|
-
try {
|
|
1044
|
-
return memoizedSelectorFn(...results);
|
|
1045
|
-
}
|
|
1046
|
-
catch (ex) {
|
|
1047
|
-
if (ex instanceof TypeError && selectorOptions.suppressErrors) {
|
|
1048
|
-
return undefined;
|
|
1049
|
-
}
|
|
1050
|
-
throw ex;
|
|
1051
|
-
}
|
|
1052
|
-
};
|
|
1053
|
-
};
|
|
1054
|
-
}
|
|
1055
|
-
function createMemoizedSelectorFn(originalFn, creationMetadata) {
|
|
1056
|
-
const containerClass = creationMetadata && creationMetadata.containerClass;
|
|
1057
|
-
const wrappedFn = function wrappedSelectorFn(...args) {
|
|
1058
|
-
const returnValue = originalFn.apply(containerClass, args);
|
|
1059
|
-
if (returnValue instanceof Function) {
|
|
1060
|
-
const innerMemoizedFn = memoize.apply(null, [returnValue]);
|
|
1061
|
-
return innerMemoizedFn;
|
|
1062
|
-
}
|
|
1063
|
-
return returnValue;
|
|
1064
|
-
};
|
|
1065
|
-
const memoizedFn = memoize(wrappedFn);
|
|
1066
|
-
Object.setPrototypeOf(memoizedFn, originalFn);
|
|
1067
|
-
return memoizedFn;
|
|
1068
|
-
}
|
|
1069
|
-
function getRuntimeSelectorInfo(context, selectorMetaData, selectors = []) {
|
|
1070
|
-
const localSelectorOptions = selectorMetaData.getSelectorOptions();
|
|
1071
|
-
const selectorOptions = context.getSelectorOptions(localSelectorOptions);
|
|
1072
|
-
const selectorsToApply = getSelectorsToApply(selectors, selectorOptions, selectorMetaData.containerClass);
|
|
1073
|
-
const argumentSelectorFunctions = selectorsToApply.map((selector) => {
|
|
1074
|
-
const factory = getRootSelectorFactory(selector);
|
|
1075
|
-
return factory(context);
|
|
1076
|
-
});
|
|
1077
|
-
return {
|
|
1078
|
-
selectorOptions,
|
|
1079
|
-
argumentSelectorFunctions,
|
|
1080
|
-
};
|
|
1081
|
-
}
|
|
1082
|
-
function getSelectorsToApply(selectors = [], selectorOptions, containerClass) {
|
|
1083
|
-
const selectorsToApply = [];
|
|
1084
|
-
const canInjectContainerState = selectors.length === 0 || selectorOptions.injectContainerState;
|
|
1085
|
-
if (containerClass && canInjectContainerState) {
|
|
1086
|
-
// If we are on a state class, add it as the first selector parameter
|
|
1087
|
-
const metadata = getStoreMetadata$1(containerClass);
|
|
1088
|
-
if (metadata) {
|
|
1089
|
-
selectorsToApply.push(containerClass);
|
|
1090
|
-
}
|
|
1091
|
-
}
|
|
1092
|
-
if (selectors) {
|
|
1093
|
-
selectorsToApply.push(...selectors);
|
|
1094
|
-
}
|
|
1095
|
-
return selectorsToApply;
|
|
1096
|
-
}
|
|
1097
|
-
/**
|
|
1098
|
-
* This function gets the factory function to create the selector to get the selected slice from the app state
|
|
1099
|
-
* @ignore
|
|
1100
|
-
*/
|
|
1101
|
-
function getRootSelectorFactory(selector) {
|
|
1102
|
-
const metadata = getSelectorMetadata$1(selector) || getStoreMetadata$1(selector);
|
|
1103
|
-
return (metadata && metadata.makeRootSelector) || (() => selector);
|
|
1104
|
-
}
|
|
1105
|
-
|
|
1106
|
-
/**
|
|
1107
|
-
* RxJS operator for selecting out specific actions.
|
|
1108
|
-
*
|
|
1109
|
-
* This will grab actions that have just been dispatched as well as actions that have completed
|
|
1110
|
-
*/
|
|
1111
|
-
function ofAction(...allowedTypes) {
|
|
1112
|
-
return ofActionOperator(allowedTypes);
|
|
1113
|
-
}
|
|
1114
|
-
/**
|
|
1115
|
-
* RxJS operator for selecting out specific actions.
|
|
1116
|
-
*
|
|
1117
|
-
* This will ONLY grab actions that have just been dispatched
|
|
1118
|
-
*/
|
|
1119
|
-
function ofActionDispatched(...allowedTypes) {
|
|
1120
|
-
return ofActionOperator(allowedTypes, ["DISPATCHED" /* ActionStatus.Dispatched */]);
|
|
1121
|
-
}
|
|
1122
|
-
/**
|
|
1123
|
-
* RxJS operator for selecting out specific actions.
|
|
1124
|
-
*
|
|
1125
|
-
* This will ONLY grab actions that have just been successfully completed
|
|
1126
|
-
*/
|
|
1127
|
-
function ofActionSuccessful(...allowedTypes) {
|
|
1128
|
-
return ofActionOperator(allowedTypes, ["SUCCESSFUL" /* ActionStatus.Successful */]);
|
|
1129
|
-
}
|
|
1130
|
-
/**
|
|
1131
|
-
* RxJS operator for selecting out specific actions.
|
|
1132
|
-
*
|
|
1133
|
-
* This will ONLY grab actions that have just been canceled
|
|
1134
|
-
*/
|
|
1135
|
-
function ofActionCanceled(...allowedTypes) {
|
|
1136
|
-
return ofActionOperator(allowedTypes, ["CANCELED" /* ActionStatus.Canceled */]);
|
|
1137
|
-
}
|
|
1138
|
-
/**
|
|
1139
|
-
* RxJS operator for selecting out specific actions.
|
|
1140
|
-
*
|
|
1141
|
-
* This will ONLY grab actions that have just been completed
|
|
1142
|
-
*/
|
|
1143
|
-
function ofActionCompleted(...allowedTypes) {
|
|
1144
|
-
const allowedStatuses = [
|
|
1145
|
-
"SUCCESSFUL" /* ActionStatus.Successful */,
|
|
1146
|
-
"CANCELED" /* ActionStatus.Canceled */,
|
|
1147
|
-
"ERRORED" /* ActionStatus.Errored */
|
|
1148
|
-
];
|
|
1149
|
-
return ofActionOperator(allowedTypes, allowedStatuses, mapActionResult);
|
|
1150
|
-
}
|
|
1053
|
+
};
|
|
1054
|
+
|
|
1151
1055
|
/**
|
|
1152
|
-
*
|
|
1153
|
-
*
|
|
1154
|
-
* This will ONLY grab actions that have just thrown an error
|
|
1056
|
+
* @ignore
|
|
1155
1057
|
*/
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
function filterStatus(allowedTypes, allowedStatuses) {
|
|
1171
|
-
return filter((ctx) => {
|
|
1172
|
-
const actionType = getActionTypeFromInstance(ctx.action);
|
|
1173
|
-
const typeMatch = allowedTypes[actionType];
|
|
1174
|
-
const statusMatch = allowedStatuses ? allowedStatuses[ctx.status] : true;
|
|
1175
|
-
return typeMatch && statusMatch;
|
|
1176
|
-
});
|
|
1177
|
-
}
|
|
1178
|
-
function mapActionResult() {
|
|
1179
|
-
return map(({ action, status, error }) => {
|
|
1180
|
-
return {
|
|
1181
|
-
action,
|
|
1182
|
-
result: {
|
|
1183
|
-
successful: "SUCCESSFUL" /* ActionStatus.Successful */ === status,
|
|
1184
|
-
canceled: "CANCELED" /* ActionStatus.Canceled */ === status,
|
|
1185
|
-
error
|
|
1186
|
-
}
|
|
1058
|
+
class InternalStateOperations {
|
|
1059
|
+
constructor(_stateStream, _dispatcher, _config) {
|
|
1060
|
+
this._stateStream = _stateStream;
|
|
1061
|
+
this._dispatcher = _dispatcher;
|
|
1062
|
+
this._config = _config;
|
|
1063
|
+
}
|
|
1064
|
+
/**
|
|
1065
|
+
* Returns the root state operators.
|
|
1066
|
+
*/
|
|
1067
|
+
getRootStateOperations() {
|
|
1068
|
+
const rootStateOperations = {
|
|
1069
|
+
getState: () => this._stateStream.getValue(),
|
|
1070
|
+
setState: (newState) => this._stateStream.next(newState),
|
|
1071
|
+
dispatch: (actionOrActions) => this._dispatcher.dispatch(actionOrActions)
|
|
1187
1072
|
};
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
}
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1073
|
+
if (typeof ngDevMode === 'undefined' || ngDevMode) {
|
|
1074
|
+
return this._config.developmentMode
|
|
1075
|
+
? ensureStateAndActionsAreImmutable(rootStateOperations)
|
|
1076
|
+
: rootStateOperations;
|
|
1077
|
+
}
|
|
1078
|
+
else {
|
|
1079
|
+
return rootStateOperations;
|
|
1080
|
+
}
|
|
1081
|
+
}
|
|
1082
|
+
setStateToTheCurrentWithNew(results) {
|
|
1083
|
+
const stateOperations = this.getRootStateOperations();
|
|
1084
|
+
// Get our current stream
|
|
1085
|
+
const currentState = stateOperations.getState();
|
|
1086
|
+
// Set the state to the current + new
|
|
1087
|
+
stateOperations.setState(Object.assign(Object.assign({}, currentState), results.defaults));
|
|
1088
|
+
}
|
|
1198
1089
|
}
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1090
|
+
/** @nocollapse */ InternalStateOperations.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: InternalStateOperations, deps: [{ token: StateStream }, { token: InternalDispatcher }, { token: NgxsConfig }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
1091
|
+
/** @nocollapse */ InternalStateOperations.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: InternalStateOperations, providedIn: 'root' });
|
|
1092
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: InternalStateOperations, decorators: [{
|
|
1093
|
+
type: Injectable,
|
|
1094
|
+
args: [{ providedIn: 'root' }]
|
|
1095
|
+
}], ctorParameters: function () { return [{ type: StateStream }, { type: InternalDispatcher }, { type: NgxsConfig }]; } });
|
|
1096
|
+
function ensureStateAndActionsAreImmutable(root) {
|
|
1097
|
+
return {
|
|
1098
|
+
getState: () => root.getState(),
|
|
1099
|
+
setState: value => {
|
|
1100
|
+
const frozenValue = deepFreeze(value);
|
|
1101
|
+
return root.setState(frozenValue);
|
|
1102
|
+
},
|
|
1103
|
+
dispatch: actions => {
|
|
1104
|
+
return root.dispatch(actions);
|
|
1105
|
+
}
|
|
1106
|
+
};
|
|
1204
1107
|
}
|
|
1205
1108
|
|
|
1206
1109
|
function simplePatch(value) {
|
|
@@ -1213,7 +1116,7 @@ function simplePatch(value) {
|
|
|
1213
1116
|
throwPatchingPrimitiveError();
|
|
1214
1117
|
}
|
|
1215
1118
|
}
|
|
1216
|
-
const newState = {
|
|
1119
|
+
const newState = Object.assign({}, existingState);
|
|
1217
1120
|
for (const key in value) {
|
|
1218
1121
|
// deep clone for patch compatibility
|
|
1219
1122
|
newState[key] = value[key];
|
|
@@ -1257,9 +1160,9 @@ class StateContextFactory {
|
|
|
1257
1160
|
};
|
|
1258
1161
|
}
|
|
1259
1162
|
}
|
|
1260
|
-
/** @nocollapse */ StateContextFactory.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
1261
|
-
/** @nocollapse */ StateContextFactory.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "
|
|
1262
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
1163
|
+
/** @nocollapse */ StateContextFactory.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: StateContextFactory, deps: [{ token: InternalStateOperations }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
1164
|
+
/** @nocollapse */ StateContextFactory.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: StateContextFactory, providedIn: 'root' });
|
|
1165
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: StateContextFactory, decorators: [{
|
|
1263
1166
|
type: Injectable,
|
|
1264
1167
|
args: [{ providedIn: 'root' }]
|
|
1265
1168
|
}], ctorParameters: function () { return [{ type: InternalStateOperations }]; } });
|
|
@@ -1327,7 +1230,7 @@ function aot_hasNgInjectableDef(stateClass) {
|
|
|
1327
1230
|
function jit_hasInjectableAnnotation(stateClass) {
|
|
1328
1231
|
// `ɵprov` doesn't exist in JIT mode (for instance when running unit tests with Jest).
|
|
1329
1232
|
const annotations = stateClass.__annotations__ || [];
|
|
1330
|
-
return annotations.some((annotation) => annotation
|
|
1233
|
+
return annotations.some((annotation) => (annotation === null || annotation === void 0 ? void 0 : annotation.ngMetadataName) === 'Injectable');
|
|
1331
1234
|
}
|
|
1332
1235
|
|
|
1333
1236
|
/**
|
|
@@ -1383,16 +1286,16 @@ class NgxsUnhandledActionsLogger {
|
|
|
1383
1286
|
console.warn(`The ${action} action has been dispatched but hasn't been handled. This may happen if the state with an action handler for this action is not registered.`);
|
|
1384
1287
|
}
|
|
1385
1288
|
}
|
|
1386
|
-
/** @nocollapse */ NgxsUnhandledActionsLogger.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
1387
|
-
/** @nocollapse */ NgxsUnhandledActionsLogger.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "
|
|
1388
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
1289
|
+
/** @nocollapse */ NgxsUnhandledActionsLogger.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: NgxsUnhandledActionsLogger, deps: [{ token: NGXS_DEVELOPMENT_OPTIONS }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
1290
|
+
/** @nocollapse */ NgxsUnhandledActionsLogger.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: NgxsUnhandledActionsLogger });
|
|
1291
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: NgxsUnhandledActionsLogger, decorators: [{
|
|
1389
1292
|
type: Injectable
|
|
1390
1293
|
}], ctorParameters: function () { return [{ type: undefined, decorators: [{
|
|
1391
1294
|
type: Inject,
|
|
1392
1295
|
args: [NGXS_DEVELOPMENT_OPTIONS]
|
|
1393
1296
|
}] }]; } });
|
|
1394
1297
|
|
|
1395
|
-
const NG_DEV_MODE
|
|
1298
|
+
const NG_DEV_MODE = typeof ngDevMode === 'undefined' || ngDevMode;
|
|
1396
1299
|
/**
|
|
1397
1300
|
* The `StateFactory` class adds root and feature states to the graph.
|
|
1398
1301
|
* This extracts state names from state classes, checks if they already
|
|
@@ -1430,26 +1333,21 @@ class StateFactory {
|
|
|
1430
1333
|
? this._parentFactory.getRuntimeSelectorContext()
|
|
1431
1334
|
: {
|
|
1432
1335
|
getStateGetter(key) {
|
|
1433
|
-
|
|
1434
|
-
// This is a Terser annotation, which will function only in the production mode.
|
|
1435
|
-
let getter = /*@__INLINE__*/ resolveGetter(key);
|
|
1336
|
+
let getter = resolveGetter(key);
|
|
1436
1337
|
if (getter) {
|
|
1437
1338
|
return getter;
|
|
1438
1339
|
}
|
|
1439
1340
|
return (...args) => {
|
|
1440
1341
|
// Late loaded getter
|
|
1441
1342
|
if (!getter) {
|
|
1442
|
-
getter =
|
|
1343
|
+
getter = resolveGetter(key);
|
|
1443
1344
|
}
|
|
1444
1345
|
return getter ? getter(...args) : undefined;
|
|
1445
1346
|
};
|
|
1446
1347
|
},
|
|
1447
1348
|
getSelectorOptions(localOptions) {
|
|
1448
1349
|
const globalSelectorOptions = stateFactory._config.selectorOptions;
|
|
1449
|
-
return {
|
|
1450
|
-
...globalSelectorOptions,
|
|
1451
|
-
...(localOptions || {})
|
|
1452
|
-
};
|
|
1350
|
+
return Object.assign(Object.assign({}, globalSelectorOptions), (localOptions || {}));
|
|
1453
1351
|
}
|
|
1454
1352
|
};
|
|
1455
1353
|
return context;
|
|
@@ -1470,7 +1368,7 @@ class StateFactory {
|
|
|
1470
1368
|
value = defaults.slice();
|
|
1471
1369
|
}
|
|
1472
1370
|
else if (isObject(defaults)) {
|
|
1473
|
-
value = {
|
|
1371
|
+
value = Object.assign({}, defaults);
|
|
1474
1372
|
}
|
|
1475
1373
|
else if (defaults === undefined) {
|
|
1476
1374
|
value = {};
|
|
@@ -1478,13 +1376,14 @@ class StateFactory {
|
|
|
1478
1376
|
return value;
|
|
1479
1377
|
}
|
|
1480
1378
|
ngOnDestroy() {
|
|
1481
|
-
|
|
1379
|
+
var _a;
|
|
1380
|
+
(_a = this._actionsSubscription) === null || _a === void 0 ? void 0 : _a.unsubscribe();
|
|
1482
1381
|
}
|
|
1483
1382
|
/**
|
|
1484
1383
|
* Add a new state to the global defs.
|
|
1485
1384
|
*/
|
|
1486
1385
|
add(stateClasses) {
|
|
1487
|
-
if (NG_DEV_MODE
|
|
1386
|
+
if (NG_DEV_MODE) {
|
|
1488
1387
|
ensureStatesAreDecorated(stateClasses);
|
|
1489
1388
|
}
|
|
1490
1389
|
const { newStates } = this.addToStatesMap(stateClasses);
|
|
@@ -1498,13 +1397,13 @@ class StateFactory {
|
|
|
1498
1397
|
for (const name of sortedStates) {
|
|
1499
1398
|
const stateClass = nameGraph[name];
|
|
1500
1399
|
const path = paths[name];
|
|
1501
|
-
const meta = stateClass[
|
|
1400
|
+
const meta = stateClass[META_KEY];
|
|
1502
1401
|
this.addRuntimeInfoToMeta(meta, path);
|
|
1503
1402
|
// Note: previously we called `ensureStateClassIsInjectable` within the
|
|
1504
1403
|
// `State` decorator. This check is moved here because the `ɵprov` property
|
|
1505
1404
|
// will not exist on the class in JIT mode (because it's set asynchronously
|
|
1506
1405
|
// during JIT compilation through `Object.defineProperty`).
|
|
1507
|
-
if (NG_DEV_MODE
|
|
1406
|
+
if (NG_DEV_MODE) {
|
|
1508
1407
|
ensureStateClassIsInjectable(stateClass);
|
|
1509
1408
|
}
|
|
1510
1409
|
const stateMap = {
|
|
@@ -1543,10 +1442,10 @@ class StateFactory {
|
|
|
1543
1442
|
}
|
|
1544
1443
|
const dispatched$ = new Subject();
|
|
1545
1444
|
this._actionsSubscription = this._actions
|
|
1546
|
-
.pipe(filter((ctx) => ctx.status === "DISPATCHED" /*
|
|
1445
|
+
.pipe(filter((ctx) => ctx.status === "DISPATCHED" /* Dispatched */), mergeMap(ctx => {
|
|
1547
1446
|
dispatched$.next(ctx);
|
|
1548
1447
|
const action = ctx.action;
|
|
1549
|
-
return this.invokeActions(dispatched$, action).pipe(map(() => ({ action, status: "SUCCESSFUL" /*
|
|
1448
|
+
return this.invokeActions(dispatched$, action).pipe(map(() => ({ action, status: "SUCCESSFUL" /* Successful */ })), defaultIfEmpty({ action, status: "CANCELED" /* Canceled */ }), catchError(error => of({ action, status: "ERRORED" /* Errored */, error })));
|
|
1550
1449
|
}))
|
|
1551
1450
|
.subscribe(ctx => this._actionResults.next(ctx));
|
|
1552
1451
|
}
|
|
@@ -1606,7 +1505,7 @@ class StateFactory {
|
|
|
1606
1505
|
}
|
|
1607
1506
|
// The `NgxsUnhandledActionsLogger` is a tree-shakable class which functions
|
|
1608
1507
|
// only during development.
|
|
1609
|
-
if (NG_DEV_MODE
|
|
1508
|
+
if (NG_DEV_MODE && !actionHasBeenHandled) {
|
|
1610
1509
|
const unhandledActionsLogger = this._injector.get(NgxsUnhandledActionsLogger, null);
|
|
1611
1510
|
// The `NgxsUnhandledActionsLogger` will not be resolved by the injector if the
|
|
1612
1511
|
// `NgxsDevelopmentModule` is not provided. It's enough to check whether the `injector.get`
|
|
@@ -1625,7 +1524,7 @@ class StateFactory {
|
|
|
1625
1524
|
const statesMap = this.statesByName;
|
|
1626
1525
|
for (const stateClass of stateClasses) {
|
|
1627
1526
|
const stateName = getStoreMetadata$1(stateClass).name;
|
|
1628
|
-
if (NG_DEV_MODE
|
|
1527
|
+
if (NG_DEV_MODE) {
|
|
1629
1528
|
ensureStateNameIsUnique(stateName, stateClass, statesMap);
|
|
1630
1529
|
}
|
|
1631
1530
|
const unmountedState = !statesMap[stateName];
|
|
@@ -1650,9 +1549,9 @@ class StateFactory {
|
|
|
1650
1549
|
return this.statesByName[name] && valueIsBootstrappedInInitialState;
|
|
1651
1550
|
}
|
|
1652
1551
|
}
|
|
1653
|
-
/** @nocollapse */ StateFactory.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
1654
|
-
/** @nocollapse */ StateFactory.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "
|
|
1655
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
1552
|
+
/** @nocollapse */ StateFactory.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: StateFactory, deps: [{ token: i0.Injector }, { token: NgxsConfig }, { token: StateFactory, optional: true, skipSelf: true }, { token: InternalActions }, { token: InternalDispatchedActionResults }, { token: StateContextFactory }, { token: INITIAL_STATE_TOKEN, optional: true }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
1553
|
+
/** @nocollapse */ StateFactory.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: StateFactory });
|
|
1554
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: StateFactory, decorators: [{
|
|
1656
1555
|
type: Injectable
|
|
1657
1556
|
}], ctorParameters: function () { return [{ type: i0.Injector }, { type: NgxsConfig }, { type: StateFactory, decorators: [{
|
|
1658
1557
|
type: Optional
|
|
@@ -1665,6 +1564,78 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.4", ngImpor
|
|
|
1665
1564
|
args: [INITIAL_STATE_TOKEN]
|
|
1666
1565
|
}] }]; } });
|
|
1667
1566
|
|
|
1567
|
+
function createRootSelectorFactory(selectorMetaData, selectors, memoizedSelectorFn) {
|
|
1568
|
+
return (context) => {
|
|
1569
|
+
const { argumentSelectorFunctions, selectorOptions } = getRuntimeSelectorInfo(context, selectorMetaData, selectors);
|
|
1570
|
+
return function selectFromRoot(rootState) {
|
|
1571
|
+
// Determine arguments from the app state using the selectors
|
|
1572
|
+
const results = argumentSelectorFunctions.map((argFn) => argFn(rootState));
|
|
1573
|
+
// if the lambda tries to access a something on the
|
|
1574
|
+
// state that doesn't exist, it will throw a TypeError.
|
|
1575
|
+
// since this is quite usual behaviour, we simply return undefined if so.
|
|
1576
|
+
try {
|
|
1577
|
+
return memoizedSelectorFn(...results);
|
|
1578
|
+
}
|
|
1579
|
+
catch (ex) {
|
|
1580
|
+
if (ex instanceof TypeError && selectorOptions.suppressErrors) {
|
|
1581
|
+
return undefined;
|
|
1582
|
+
}
|
|
1583
|
+
throw ex;
|
|
1584
|
+
}
|
|
1585
|
+
};
|
|
1586
|
+
};
|
|
1587
|
+
}
|
|
1588
|
+
function createMemoizedSelectorFn(originalFn, creationMetadata) {
|
|
1589
|
+
const containerClass = creationMetadata && creationMetadata.containerClass;
|
|
1590
|
+
const wrappedFn = function wrappedSelectorFn(...args) {
|
|
1591
|
+
const returnValue = originalFn.apply(containerClass, args);
|
|
1592
|
+
if (returnValue instanceof Function) {
|
|
1593
|
+
const innerMemoizedFn = memoize.apply(null, [returnValue]);
|
|
1594
|
+
return innerMemoizedFn;
|
|
1595
|
+
}
|
|
1596
|
+
return returnValue;
|
|
1597
|
+
};
|
|
1598
|
+
const memoizedFn = memoize(wrappedFn);
|
|
1599
|
+
Object.setPrototypeOf(memoizedFn, originalFn);
|
|
1600
|
+
return memoizedFn;
|
|
1601
|
+
}
|
|
1602
|
+
function getRuntimeSelectorInfo(context, selectorMetaData, selectors = []) {
|
|
1603
|
+
const localSelectorOptions = selectorMetaData.getSelectorOptions();
|
|
1604
|
+
const selectorOptions = context.getSelectorOptions(localSelectorOptions);
|
|
1605
|
+
const selectorsToApply = getSelectorsToApply(selectors, selectorOptions, selectorMetaData.containerClass);
|
|
1606
|
+
const argumentSelectorFunctions = selectorsToApply.map((selector) => {
|
|
1607
|
+
const factory = getRootSelectorFactory(selector);
|
|
1608
|
+
return factory(context);
|
|
1609
|
+
});
|
|
1610
|
+
return {
|
|
1611
|
+
selectorOptions,
|
|
1612
|
+
argumentSelectorFunctions,
|
|
1613
|
+
};
|
|
1614
|
+
}
|
|
1615
|
+
function getSelectorsToApply(selectors = [], selectorOptions, containerClass) {
|
|
1616
|
+
const selectorsToApply = [];
|
|
1617
|
+
const canInjectContainerState = selectors.length === 0 || selectorOptions.injectContainerState;
|
|
1618
|
+
if (containerClass && canInjectContainerState) {
|
|
1619
|
+
// If we are on a state class, add it as the first selector parameter
|
|
1620
|
+
const metadata = getStoreMetadata$1(containerClass);
|
|
1621
|
+
if (metadata) {
|
|
1622
|
+
selectorsToApply.push(containerClass);
|
|
1623
|
+
}
|
|
1624
|
+
}
|
|
1625
|
+
if (selectors) {
|
|
1626
|
+
selectorsToApply.push(...selectors);
|
|
1627
|
+
}
|
|
1628
|
+
return selectorsToApply;
|
|
1629
|
+
}
|
|
1630
|
+
/**
|
|
1631
|
+
* This function gets the factory function to create the selector to get the selected slice from the app state
|
|
1632
|
+
* @ignore
|
|
1633
|
+
*/
|
|
1634
|
+
function getRootSelectorFactory(selector) {
|
|
1635
|
+
const metadata = getSelectorMetadata$1(selector) || getStoreMetadata$1(selector);
|
|
1636
|
+
return (metadata && metadata.makeRootSelector) || (() => selector);
|
|
1637
|
+
}
|
|
1638
|
+
|
|
1668
1639
|
// tslint:disable:unified-signatures
|
|
1669
1640
|
class Store {
|
|
1670
1641
|
constructor(_stateStream, _internalStateOperations, _config, _internalExecutionStrategy, _stateFactory, initialStateValue) {
|
|
@@ -1738,15 +1709,14 @@ class Store {
|
|
|
1738
1709
|
if (storeIsEmpty) {
|
|
1739
1710
|
const defaultStateNotEmpty = Object.keys(this._config.defaultsState).length > 0;
|
|
1740
1711
|
const storeValues = defaultStateNotEmpty
|
|
1741
|
-
? {
|
|
1742
|
-
: initialStateValue;
|
|
1712
|
+
? Object.assign(Object.assign({}, this._config.defaultsState), initialStateValue) : initialStateValue;
|
|
1743
1713
|
this._stateStream.next(storeValues);
|
|
1744
1714
|
}
|
|
1745
1715
|
}
|
|
1746
1716
|
}
|
|
1747
|
-
/** @nocollapse */ Store.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
1748
|
-
/** @nocollapse */ Store.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "
|
|
1749
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
1717
|
+
/** @nocollapse */ Store.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: Store, deps: [{ token: StateStream }, { token: InternalStateOperations }, { token: NgxsConfig }, { token: InternalNgxsExecutionStrategy }, { token: StateFactory }, { token: INITIAL_STATE_TOKEN, optional: true }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
1718
|
+
/** @nocollapse */ Store.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: Store, providedIn: 'root' });
|
|
1719
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: Store, decorators: [{
|
|
1750
1720
|
type: Injectable,
|
|
1751
1721
|
args: [{ providedIn: 'root' }]
|
|
1752
1722
|
}], ctorParameters: function () { return [{ type: StateStream }, { type: InternalStateOperations }, { type: NgxsConfig }, { type: InternalNgxsExecutionStrategy }, { type: StateFactory }, { type: undefined, decorators: [{
|
|
@@ -1772,14 +1742,13 @@ class SelectFactory {
|
|
|
1772
1742
|
}
|
|
1773
1743
|
SelectFactory.store = null;
|
|
1774
1744
|
SelectFactory.config = null;
|
|
1775
|
-
/** @nocollapse */ SelectFactory.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
1776
|
-
/** @nocollapse */ SelectFactory.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "
|
|
1777
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
1745
|
+
/** @nocollapse */ SelectFactory.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: SelectFactory, deps: [{ token: Store }, { token: NgxsConfig }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
1746
|
+
/** @nocollapse */ SelectFactory.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: SelectFactory, providedIn: 'root' });
|
|
1747
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: SelectFactory, decorators: [{
|
|
1778
1748
|
type: Injectable,
|
|
1779
1749
|
args: [{ providedIn: 'root' }]
|
|
1780
1750
|
}], ctorParameters: function () { return [{ type: Store }, { type: NgxsConfig }]; } });
|
|
1781
1751
|
|
|
1782
|
-
const NG_DEV_MODE$1 = typeof ngDevMode === 'undefined' || ngDevMode;
|
|
1783
1752
|
class LifecycleStateManager {
|
|
1784
1753
|
constructor(_store, _internalErrorReporter, _internalStateOperations, _stateContextFactory, _bootstrapper) {
|
|
1785
1754
|
this._store = _store;
|
|
@@ -1787,27 +1756,12 @@ class LifecycleStateManager {
|
|
|
1787
1756
|
this._internalStateOperations = _internalStateOperations;
|
|
1788
1757
|
this._stateContextFactory = _stateContextFactory;
|
|
1789
1758
|
this._bootstrapper = _bootstrapper;
|
|
1790
|
-
this._destroy$ = new
|
|
1759
|
+
this._destroy$ = new Subject();
|
|
1791
1760
|
}
|
|
1792
1761
|
ngOnDestroy() {
|
|
1793
1762
|
this._destroy$.next();
|
|
1794
1763
|
}
|
|
1795
1764
|
ngxsBootstrap(action, results) {
|
|
1796
|
-
if (NG_DEV_MODE$1) {
|
|
1797
|
-
if (action instanceof InitState) {
|
|
1798
|
-
this._initStateHasBeenDispatched = true;
|
|
1799
|
-
}
|
|
1800
|
-
else if (
|
|
1801
|
-
// This is a dev mode-only check that ensures the correct order of
|
|
1802
|
-
// state initialization. The `NgxsModule.forRoot` or `provideStore` should
|
|
1803
|
-
// always come first, followed by `forFeature` and `provideStates`. If the
|
|
1804
|
-
// `UpdateState` is dispatched before the `InitState` is dispatched, it indicates
|
|
1805
|
-
// that modules or providers are in an invalid order.
|
|
1806
|
-
action instanceof UpdateState &&
|
|
1807
|
-
!this._initStateHasBeenDispatched) {
|
|
1808
|
-
console.error(getInvalidInitializationOrderMessage(action.addedStates));
|
|
1809
|
-
}
|
|
1810
|
-
}
|
|
1811
1765
|
this._internalStateOperations
|
|
1812
1766
|
.getRootStateOperations()
|
|
1813
1767
|
.dispatch(action)
|
|
@@ -1851,196 +1805,148 @@ class LifecycleStateManager {
|
|
|
1851
1805
|
return this._stateContextFactory.createStateContext(mappedStore);
|
|
1852
1806
|
}
|
|
1853
1807
|
}
|
|
1854
|
-
/** @nocollapse */ LifecycleStateManager.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
1855
|
-
/** @nocollapse */ LifecycleStateManager.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "
|
|
1856
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
1808
|
+
/** @nocollapse */ LifecycleStateManager.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: LifecycleStateManager, deps: [{ token: Store }, { token: InternalErrorReporter }, { token: InternalStateOperations }, { token: StateContextFactory }, { token: i5.NgxsBootstrapper }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
1809
|
+
/** @nocollapse */ LifecycleStateManager.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: LifecycleStateManager, providedIn: 'root' });
|
|
1810
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: LifecycleStateManager, decorators: [{
|
|
1857
1811
|
type: Injectable,
|
|
1858
1812
|
args: [{ providedIn: 'root' }]
|
|
1859
1813
|
}], ctorParameters: function () { return [{ type: Store }, { type: InternalErrorReporter }, { type: InternalStateOperations }, { type: StateContextFactory }, { type: i5.NgxsBootstrapper }]; } });
|
|
1860
1814
|
|
|
1861
|
-
const NG_DEV_MODE = typeof ngDevMode === 'undefined' || ngDevMode;
|
|
1862
|
-
/**
|
|
1863
|
-
* This function is shared by both NgModule and standalone features.
|
|
1864
|
-
* When using `NgxsModule.forRoot` and `provideStore`, we can depend on the
|
|
1865
|
-
* same initialization functionality.
|
|
1866
|
-
*/
|
|
1867
|
-
function rootStoreInitializer() {
|
|
1868
|
-
const factory = inject(StateFactory);
|
|
1869
|
-
const internalStateOperations = inject(InternalStateOperations);
|
|
1870
|
-
inject(Store);
|
|
1871
|
-
inject(SelectFactory);
|
|
1872
|
-
const states = inject(ROOT_STATE_TOKEN, { optional: true }) || [];
|
|
1873
|
-
const lifecycleStateManager = inject(LifecycleStateManager);
|
|
1874
|
-
// Add stores to the state graph and return their defaults.
|
|
1875
|
-
const results = factory.addAndReturnDefaults(states);
|
|
1876
|
-
internalStateOperations.setStateToTheCurrentWithNew(results);
|
|
1877
|
-
// Connect our actions stream.
|
|
1878
|
-
factory.connectActionHandlers();
|
|
1879
|
-
// Dispatch the init action and invoke init and bootstrap functions after.
|
|
1880
|
-
lifecycleStateManager.ngxsBootstrap(new InitState(), results);
|
|
1881
|
-
}
|
|
1882
|
-
/**
|
|
1883
|
-
* This function is utilized by both NgModule and standalone features.
|
|
1884
|
-
* When using `NgxsModule.forFeature` and `provideStates`, we can depend on
|
|
1885
|
-
* the same initialization functionality.
|
|
1886
|
-
*/
|
|
1887
|
-
function featureStatesInitializer() {
|
|
1888
|
-
inject(Store);
|
|
1889
|
-
const internalStateOperations = inject(InternalStateOperations);
|
|
1890
|
-
const factory = inject(StateFactory);
|
|
1891
|
-
const states = inject(FEATURE_STATE_TOKEN, { optional: true }) || [];
|
|
1892
|
-
const lifecycleStateManager = inject(LifecycleStateManager);
|
|
1893
|
-
// Since FEATURE_STATE_TOKEN is a multi token, we need to
|
|
1894
|
-
// flatten it [[Feature1State, Feature2State], [Feature3State]].
|
|
1895
|
-
const flattenedStates = states.reduce((total, values) => total.concat(values), []);
|
|
1896
|
-
// add stores to the state graph and return their defaults.
|
|
1897
|
-
const results = factory.addAndReturnDefaults(flattenedStates);
|
|
1898
|
-
if (results.states.length) {
|
|
1899
|
-
internalStateOperations.setStateToTheCurrentWithNew(results);
|
|
1900
|
-
// Dispatch the update action and invoke init and bootstrap functions after.
|
|
1901
|
-
lifecycleStateManager.ngxsBootstrap(new UpdateState(results.defaults), results);
|
|
1902
|
-
}
|
|
1903
|
-
}
|
|
1904
|
-
/**
|
|
1905
|
-
* InjectionToken that registers the global Store.
|
|
1906
|
-
*/
|
|
1907
|
-
const NGXS_ROOT_STORE_INITIALIZER = new InjectionToken(NG_DEV_MODE ? 'NGXS_ROOT_STORE_INITIALIZER' : '');
|
|
1908
|
-
/**
|
|
1909
|
-
* InjectionToken that registers feature states.
|
|
1910
|
-
*/
|
|
1911
|
-
const NGXS_FEATURE_STORE_INITIALIZER = new InjectionToken(NG_DEV_MODE ? 'NGXS_FEATURE_STORE_INITIALIZER' : '');
|
|
1912
|
-
const NGXS_ROOT_ENVIRONMENT_INITIALIZER = [
|
|
1913
|
-
{ provide: NGXS_ROOT_STORE_INITIALIZER, useFactory: rootStoreInitializer },
|
|
1914
|
-
{
|
|
1915
|
-
provide: ENVIRONMENT_INITIALIZER,
|
|
1916
|
-
multi: true,
|
|
1917
|
-
useFactory() {
|
|
1918
|
-
return () => inject(NGXS_ROOT_STORE_INITIALIZER);
|
|
1919
|
-
}
|
|
1920
|
-
}
|
|
1921
|
-
];
|
|
1922
|
-
/**
|
|
1923
|
-
* The `NGXS_FEATURE_ENVIRONMENT_INITIALIZER` functions as an environment initializer
|
|
1924
|
-
* at the `Route` level. Angular Router creates an environment route injector for each
|
|
1925
|
-
* matched route where navigation occurs. The injector is created once, ensuring that
|
|
1926
|
-
* the feature states initialization only happens once as well.
|
|
1927
|
-
*/
|
|
1928
|
-
const NGXS_FEATURE_ENVIRONMENT_INITIALIZER = [
|
|
1929
|
-
{ provide: NGXS_FEATURE_STORE_INITIALIZER, useFactory: featureStatesInitializer },
|
|
1930
|
-
{
|
|
1931
|
-
provide: ENVIRONMENT_INITIALIZER,
|
|
1932
|
-
multi: true,
|
|
1933
|
-
useFactory() {
|
|
1934
|
-
return () => inject(NGXS_FEATURE_STORE_INITIALIZER);
|
|
1935
|
-
}
|
|
1936
|
-
}
|
|
1937
|
-
];
|
|
1938
|
-
|
|
1939
1815
|
/**
|
|
1816
|
+
* Root module
|
|
1940
1817
|
* @ignore
|
|
1941
1818
|
*/
|
|
1942
1819
|
class NgxsRootModule {
|
|
1943
|
-
constructor() {
|
|
1944
|
-
|
|
1820
|
+
constructor(factory, internalStateOperations, _store, _select, states = [], lifecycleStateManager) {
|
|
1821
|
+
// Add stores to the state graph and return their defaults
|
|
1822
|
+
const results = factory.addAndReturnDefaults(states);
|
|
1823
|
+
internalStateOperations.setStateToTheCurrentWithNew(results);
|
|
1824
|
+
// Connect our actions stream
|
|
1825
|
+
factory.connectActionHandlers();
|
|
1826
|
+
// Dispatch the init action and invoke init and bootstrap functions after
|
|
1827
|
+
lifecycleStateManager.ngxsBootstrap(new InitState(), results);
|
|
1945
1828
|
}
|
|
1946
1829
|
}
|
|
1947
|
-
/** @nocollapse */ NgxsRootModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
1948
|
-
/** @nocollapse */ NgxsRootModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "
|
|
1949
|
-
/** @nocollapse */ NgxsRootModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "
|
|
1950
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
1830
|
+
/** @nocollapse */ NgxsRootModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: NgxsRootModule, deps: [{ token: StateFactory }, { token: InternalStateOperations }, { token: Store }, { token: SelectFactory }, { token: ROOT_STATE_TOKEN, optional: true }, { token: LifecycleStateManager }], target: i0.ɵɵFactoryTarget.NgModule });
|
|
1831
|
+
/** @nocollapse */ NgxsRootModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: NgxsRootModule });
|
|
1832
|
+
/** @nocollapse */ NgxsRootModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: NgxsRootModule });
|
|
1833
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: NgxsRootModule, decorators: [{
|
|
1951
1834
|
type: NgModule
|
|
1952
|
-
}], ctorParameters: function () { return [
|
|
1835
|
+
}], ctorParameters: function () { return [{ type: StateFactory }, { type: InternalStateOperations }, { type: Store }, { type: SelectFactory }, { type: undefined, decorators: [{
|
|
1836
|
+
type: Optional
|
|
1837
|
+
}, {
|
|
1838
|
+
type: Inject,
|
|
1839
|
+
args: [ROOT_STATE_TOKEN]
|
|
1840
|
+
}] }, { type: LifecycleStateManager }]; } });
|
|
1953
1841
|
|
|
1954
1842
|
/**
|
|
1843
|
+
* Feature module
|
|
1955
1844
|
* @ignore
|
|
1956
1845
|
*/
|
|
1957
1846
|
class NgxsFeatureModule {
|
|
1958
|
-
constructor() {
|
|
1959
|
-
|
|
1847
|
+
constructor(_store, internalStateOperations, factory, states = [], lifecycleStateManager) {
|
|
1848
|
+
// Since FEATURE_STATE_TOKEN is a multi token, we need to
|
|
1849
|
+
// flatten it [[Feature1State, Feature2State], [Feature3State]]
|
|
1850
|
+
const flattenedStates = NgxsFeatureModule.flattenStates(states);
|
|
1851
|
+
// add stores to the state graph and return their defaults
|
|
1852
|
+
const results = factory.addAndReturnDefaults(flattenedStates);
|
|
1853
|
+
if (results.states.length) {
|
|
1854
|
+
internalStateOperations.setStateToTheCurrentWithNew(results);
|
|
1855
|
+
// dispatch the update action and invoke init and bootstrap functions after
|
|
1856
|
+
lifecycleStateManager.ngxsBootstrap(new UpdateState(results.defaults), results);
|
|
1857
|
+
}
|
|
1858
|
+
}
|
|
1859
|
+
static flattenStates(states = []) {
|
|
1860
|
+
return states.reduce((total, values) => total.concat(values), []);
|
|
1960
1861
|
}
|
|
1961
1862
|
}
|
|
1962
|
-
/** @nocollapse */ NgxsFeatureModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
1963
|
-
/** @nocollapse */ NgxsFeatureModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "
|
|
1964
|
-
/** @nocollapse */ NgxsFeatureModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "
|
|
1965
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
1863
|
+
/** @nocollapse */ NgxsFeatureModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: NgxsFeatureModule, deps: [{ token: Store }, { token: InternalStateOperations }, { token: StateFactory }, { token: FEATURE_STATE_TOKEN, optional: true }, { token: LifecycleStateManager }], target: i0.ɵɵFactoryTarget.NgModule });
|
|
1864
|
+
/** @nocollapse */ NgxsFeatureModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: NgxsFeatureModule });
|
|
1865
|
+
/** @nocollapse */ NgxsFeatureModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: NgxsFeatureModule });
|
|
1866
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: NgxsFeatureModule, decorators: [{
|
|
1966
1867
|
type: NgModule
|
|
1967
|
-
}], ctorParameters: function () { return [
|
|
1968
|
-
|
|
1969
|
-
|
|
1970
|
-
|
|
1971
|
-
|
|
1972
|
-
|
|
1973
|
-
function getRootProviders(states, options) {
|
|
1974
|
-
return [
|
|
1975
|
-
StateFactory,
|
|
1976
|
-
PluginManager,
|
|
1977
|
-
...states,
|
|
1978
|
-
{
|
|
1979
|
-
provide: ROOT_STATE_TOKEN,
|
|
1980
|
-
useValue: states
|
|
1981
|
-
},
|
|
1982
|
-
{
|
|
1983
|
-
provide: APP_BOOTSTRAP_LISTENER,
|
|
1984
|
-
useFactory: () => {
|
|
1985
|
-
const bootstrapper = inject(NgxsBootstrapper);
|
|
1986
|
-
return () => bootstrapper.bootstrap();
|
|
1987
|
-
},
|
|
1988
|
-
multi: true
|
|
1989
|
-
},
|
|
1990
|
-
{
|
|
1991
|
-
provide: NGXS_OPTIONS,
|
|
1992
|
-
useValue: options
|
|
1993
|
-
},
|
|
1994
|
-
{
|
|
1995
|
-
provide: CUSTOM_NGXS_EXECUTION_STRATEGY,
|
|
1996
|
-
useValue: options.executionStrategy
|
|
1997
|
-
},
|
|
1998
|
-
{
|
|
1999
|
-
provide: ɵNGXS_STATE_CONTEXT_FACTORY,
|
|
2000
|
-
useExisting: StateContextFactory
|
|
2001
|
-
},
|
|
2002
|
-
{
|
|
2003
|
-
provide: ɵNGXS_STATE_FACTORY,
|
|
2004
|
-
useExisting: StateFactory
|
|
2005
|
-
}
|
|
2006
|
-
];
|
|
2007
|
-
}
|
|
1868
|
+
}], ctorParameters: function () { return [{ type: Store }, { type: InternalStateOperations }, { type: StateFactory }, { type: undefined, decorators: [{
|
|
1869
|
+
type: Optional
|
|
1870
|
+
}, {
|
|
1871
|
+
type: Inject,
|
|
1872
|
+
args: [FEATURE_STATE_TOKEN]
|
|
1873
|
+
}] }, { type: LifecycleStateManager }]; } });
|
|
2008
1874
|
|
|
2009
1875
|
/**
|
|
2010
|
-
*
|
|
2011
|
-
* or `provideStates`. It is shared between the NgModule and standalone APIs.
|
|
1876
|
+
* Ngxs Module
|
|
2012
1877
|
*/
|
|
2013
|
-
function getFeatureProviders(states) {
|
|
2014
|
-
return [
|
|
2015
|
-
StateFactory,
|
|
2016
|
-
PluginManager,
|
|
2017
|
-
...states,
|
|
2018
|
-
{
|
|
2019
|
-
provide: FEATURE_STATE_TOKEN,
|
|
2020
|
-
multi: true,
|
|
2021
|
-
useValue: states
|
|
2022
|
-
}
|
|
2023
|
-
];
|
|
2024
|
-
}
|
|
2025
|
-
|
|
2026
1878
|
class NgxsModule {
|
|
1879
|
+
/**
|
|
1880
|
+
* Root module factory
|
|
1881
|
+
*/
|
|
2027
1882
|
static forRoot(states = [], options = {}) {
|
|
2028
1883
|
return {
|
|
2029
1884
|
ngModule: NgxsRootModule,
|
|
2030
|
-
providers:
|
|
1885
|
+
providers: [
|
|
1886
|
+
StateFactory,
|
|
1887
|
+
PluginManager,
|
|
1888
|
+
...states,
|
|
1889
|
+
...NgxsModule.ngxsTokenProviders(states, options)
|
|
1890
|
+
]
|
|
2031
1891
|
};
|
|
2032
1892
|
}
|
|
1893
|
+
/**
|
|
1894
|
+
* Feature module factory
|
|
1895
|
+
*/
|
|
2033
1896
|
static forFeature(states = []) {
|
|
2034
1897
|
return {
|
|
2035
1898
|
ngModule: NgxsFeatureModule,
|
|
2036
|
-
providers:
|
|
1899
|
+
providers: [
|
|
1900
|
+
// This is required on the feature level, see comments in `state-factory.ts`.
|
|
1901
|
+
StateFactory,
|
|
1902
|
+
PluginManager,
|
|
1903
|
+
...states,
|
|
1904
|
+
{
|
|
1905
|
+
provide: FEATURE_STATE_TOKEN,
|
|
1906
|
+
multi: true,
|
|
1907
|
+
useValue: states
|
|
1908
|
+
}
|
|
1909
|
+
]
|
|
2037
1910
|
};
|
|
2038
1911
|
}
|
|
1912
|
+
static ngxsTokenProviders(states, options) {
|
|
1913
|
+
return [
|
|
1914
|
+
{
|
|
1915
|
+
provide: USER_PROVIDED_NGXS_EXECUTION_STRATEGY,
|
|
1916
|
+
useValue: options.executionStrategy
|
|
1917
|
+
},
|
|
1918
|
+
{
|
|
1919
|
+
provide: ROOT_STATE_TOKEN,
|
|
1920
|
+
useValue: states
|
|
1921
|
+
},
|
|
1922
|
+
{
|
|
1923
|
+
provide: ROOT_OPTIONS,
|
|
1924
|
+
useValue: options
|
|
1925
|
+
},
|
|
1926
|
+
{
|
|
1927
|
+
provide: APP_BOOTSTRAP_LISTENER,
|
|
1928
|
+
useFactory: NgxsModule.appBootstrapListenerFactory,
|
|
1929
|
+
multi: true,
|
|
1930
|
+
deps: [NgxsBootstrapper]
|
|
1931
|
+
},
|
|
1932
|
+
{
|
|
1933
|
+
provide: ɵNGXS_STATE_CONTEXT_FACTORY,
|
|
1934
|
+
useExisting: StateContextFactory
|
|
1935
|
+
},
|
|
1936
|
+
{
|
|
1937
|
+
provide: ɵNGXS_STATE_FACTORY,
|
|
1938
|
+
useExisting: StateFactory
|
|
1939
|
+
}
|
|
1940
|
+
];
|
|
1941
|
+
}
|
|
1942
|
+
static appBootstrapListenerFactory(bootstrapper) {
|
|
1943
|
+
return () => bootstrapper.bootstrap();
|
|
1944
|
+
}
|
|
2039
1945
|
}
|
|
2040
|
-
/** @nocollapse */ NgxsModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
2041
|
-
/** @nocollapse */ NgxsModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "
|
|
2042
|
-
/** @nocollapse */ NgxsModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "
|
|
2043
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
1946
|
+
/** @nocollapse */ NgxsModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: NgxsModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
1947
|
+
/** @nocollapse */ NgxsModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: NgxsModule });
|
|
1948
|
+
/** @nocollapse */ NgxsModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: NgxsModule });
|
|
1949
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: NgxsModule, decorators: [{
|
|
2044
1950
|
type: NgModule
|
|
2045
1951
|
}] });
|
|
2046
1952
|
|
|
@@ -2085,12 +1991,12 @@ function State(options) {
|
|
|
2085
1991
|
const inheritedStateClass = Object.getPrototypeOf(stateClass);
|
|
2086
1992
|
const optionsWithInheritance = getStateOptions(inheritedStateClass, options);
|
|
2087
1993
|
mutateMetaData({ meta, inheritedStateClass, optionsWithInheritance });
|
|
2088
|
-
stateClass[
|
|
1994
|
+
stateClass[META_OPTIONS_KEY] = optionsWithInheritance;
|
|
2089
1995
|
};
|
|
2090
1996
|
}
|
|
2091
1997
|
function getStateOptions(inheritedStateClass, options) {
|
|
2092
|
-
const inheritanceOptions = inheritedStateClass[
|
|
2093
|
-
return {
|
|
1998
|
+
const inheritanceOptions = inheritedStateClass[META_OPTIONS_KEY] || {};
|
|
1999
|
+
return Object.assign(Object.assign({}, inheritanceOptions), options);
|
|
2094
2000
|
}
|
|
2095
2001
|
function mutateMetaData(params) {
|
|
2096
2002
|
const { meta, inheritedStateClass, optionsWithInheritance } = params;
|
|
@@ -2099,9 +2005,9 @@ function mutateMetaData(params) {
|
|
|
2099
2005
|
if (typeof ngDevMode === 'undefined' || ngDevMode) {
|
|
2100
2006
|
ensureStateNameIsValid(stateName);
|
|
2101
2007
|
}
|
|
2102
|
-
if (inheritedStateClass.hasOwnProperty(
|
|
2103
|
-
const inheritedMeta = inheritedStateClass[
|
|
2104
|
-
meta.actions = {
|
|
2008
|
+
if (inheritedStateClass.hasOwnProperty(META_KEY)) {
|
|
2009
|
+
const inheritedMeta = inheritedStateClass[META_KEY] || {};
|
|
2010
|
+
meta.actions = Object.assign(Object.assign({}, meta.actions), inheritedMeta.actions);
|
|
2105
2011
|
}
|
|
2106
2012
|
meta.children = children;
|
|
2107
2013
|
meta.defaults = defaults;
|
|
@@ -2180,17 +2086,12 @@ function setupSelectorMetadata(originalFn, creationMetadata) {
|
|
|
2180
2086
|
getExplicitSelectorOptions =
|
|
2181
2087
|
creationMetadata.getSelectorOptions || getExplicitSelectorOptions;
|
|
2182
2088
|
}
|
|
2183
|
-
const selectorMetaDataClone = {
|
|
2089
|
+
const selectorMetaDataClone = Object.assign({}, selectorMetaData);
|
|
2184
2090
|
selectorMetaData.getSelectorOptions = () => getLocalSelectorOptions(selectorMetaDataClone, getExplicitSelectorOptions());
|
|
2185
2091
|
return selectorMetaData;
|
|
2186
2092
|
}
|
|
2187
2093
|
function getLocalSelectorOptions(selectorMetaData, explicitOptions) {
|
|
2188
|
-
return {
|
|
2189
|
-
...(selectorOptionsMetaAccessor.getOptions(selectorMetaData.containerClass) || {}),
|
|
2190
|
-
...(selectorOptionsMetaAccessor.getOptions(selectorMetaData.originalFn) || {}),
|
|
2191
|
-
...(selectorMetaData.getSelectorOptions() || {}),
|
|
2192
|
-
...explicitOptions,
|
|
2193
|
-
};
|
|
2094
|
+
return Object.assign(Object.assign(Object.assign(Object.assign({}, (selectorOptionsMetaAccessor.getOptions(selectorMetaData.containerClass) || {})), (selectorOptionsMetaAccessor.getOptions(selectorMetaData.originalFn) || {})), (selectorMetaData.getSelectorOptions() || {})), explicitOptions);
|
|
2194
2095
|
}
|
|
2195
2096
|
|
|
2196
2097
|
/**
|
|
@@ -2236,7 +2137,7 @@ function createSelector(selectors, projector, creationMetadata) {
|
|
|
2236
2137
|
function Selector(selectors) {
|
|
2237
2138
|
return (target, key, descriptor) => {
|
|
2238
2139
|
descriptor || (descriptor = Object.getOwnPropertyDescriptor(target, key));
|
|
2239
|
-
const originalFn = descriptor
|
|
2140
|
+
const originalFn = descriptor === null || descriptor === void 0 ? void 0 : descriptor.value;
|
|
2240
2141
|
// Caretaker note: we have still left the `typeof` condition in order to avoid
|
|
2241
2142
|
// creating a breaking change for projects that still use the View Engine.
|
|
2242
2143
|
if (typeof ngDevMode === 'undefined' || ngDevMode) {
|
|
@@ -2290,10 +2191,10 @@ class NgxsDevelopmentModule {
|
|
|
2290
2191
|
};
|
|
2291
2192
|
}
|
|
2292
2193
|
}
|
|
2293
|
-
/** @nocollapse */ NgxsDevelopmentModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
2294
|
-
/** @nocollapse */ NgxsDevelopmentModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "
|
|
2295
|
-
/** @nocollapse */ NgxsDevelopmentModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "
|
|
2296
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
2194
|
+
/** @nocollapse */ NgxsDevelopmentModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: NgxsDevelopmentModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
2195
|
+
/** @nocollapse */ NgxsDevelopmentModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: NgxsDevelopmentModule });
|
|
2196
|
+
/** @nocollapse */ NgxsDevelopmentModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: NgxsDevelopmentModule });
|
|
2197
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: NgxsDevelopmentModule, decorators: [{
|
|
2297
2198
|
type: NgModule
|
|
2298
2199
|
}] });
|
|
2299
2200
|
|
|
@@ -2367,77 +2268,13 @@ function createPropertySelectors(parentSelector) {
|
|
|
2367
2268
|
return new Proxy({}, {
|
|
2368
2269
|
get(_target, prop) {
|
|
2369
2270
|
const selector = cache[prop] ||
|
|
2370
|
-
createSelector([parentSelector], (s) => s
|
|
2271
|
+
createSelector([parentSelector], (s) => s === null || s === void 0 ? void 0 : s[prop]);
|
|
2371
2272
|
cache[prop] = selector;
|
|
2372
2273
|
return selector;
|
|
2373
2274
|
}
|
|
2374
2275
|
});
|
|
2375
2276
|
}
|
|
2376
2277
|
|
|
2377
|
-
function provideStore(states = [], ...optionsAndFeatures) {
|
|
2378
|
-
const features = [];
|
|
2379
|
-
// Options are empty by default (see `forRoot`).
|
|
2380
|
-
let options = {};
|
|
2381
|
-
if (optionsAndFeatures.length > 0) {
|
|
2382
|
-
if (isEnvironmentProvider(optionsAndFeatures[0])) {
|
|
2383
|
-
features.push(...optionsAndFeatures);
|
|
2384
|
-
}
|
|
2385
|
-
else {
|
|
2386
|
-
options = optionsAndFeatures[0];
|
|
2387
|
-
features.push(...optionsAndFeatures.slice(1));
|
|
2388
|
-
}
|
|
2389
|
-
}
|
|
2390
|
-
return makeEnvironmentProviders([
|
|
2391
|
-
...getRootProviders(states, options),
|
|
2392
|
-
features,
|
|
2393
|
-
NGXS_ROOT_ENVIRONMENT_INITIALIZER
|
|
2394
|
-
]);
|
|
2395
|
-
}
|
|
2396
|
-
function isEnvironmentProvider(target) {
|
|
2397
|
-
return !!target.ɵproviders;
|
|
2398
|
-
}
|
|
2399
|
-
|
|
2400
|
-
/**
|
|
2401
|
-
* This version serves as a standalone alternative to `NgxsModule.forFeature`.
|
|
2402
|
-
* It can be used in a similar manner to register feature states, but at the
|
|
2403
|
-
* `Route` providers level:
|
|
2404
|
-
*
|
|
2405
|
-
* ```ts
|
|
2406
|
-
* const routes: Routes = [
|
|
2407
|
-
* {
|
|
2408
|
-
* path: 'products',
|
|
2409
|
-
* loadComponent: async () => {...},
|
|
2410
|
-
* providers: [provideStates([ProductsState])]
|
|
2411
|
-
* }
|
|
2412
|
-
* ];
|
|
2413
|
-
* ```
|
|
2414
|
-
*/
|
|
2415
|
-
function provideStates(states, ...features) {
|
|
2416
|
-
return makeEnvironmentProviders([
|
|
2417
|
-
...getFeatureProviders(states),
|
|
2418
|
-
features,
|
|
2419
|
-
NGXS_FEATURE_ENVIRONMENT_INITIALIZER
|
|
2420
|
-
]);
|
|
2421
|
-
}
|
|
2422
|
-
|
|
2423
|
-
/**
|
|
2424
|
-
* This function registers a custom global plugin for the state.
|
|
2425
|
-
*
|
|
2426
|
-
* ```ts
|
|
2427
|
-
* bootstrapApplication(AppComponent, {
|
|
2428
|
-
* providers: [
|
|
2429
|
-
* provideStore(
|
|
2430
|
-
* [CountriesState],
|
|
2431
|
-
* withNgxsPlugin(logoutPlugin)
|
|
2432
|
-
* )
|
|
2433
|
-
* ]
|
|
2434
|
-
* });
|
|
2435
|
-
* ```
|
|
2436
|
-
*/
|
|
2437
|
-
function withNgxsPlugin(plugin) {
|
|
2438
|
-
return makeEnvironmentProviders([{ provide: NGXS_PLUGINS, useClass: plugin, multi: true }]);
|
|
2439
|
-
}
|
|
2440
|
-
|
|
2441
2278
|
/**
|
|
2442
2279
|
* The public api for consumers of @ngxs/store
|
|
2443
2280
|
*/
|
|
@@ -2446,5 +2283,5 @@ function withNgxsPlugin(plugin) {
|
|
|
2446
2283
|
* Generated bundle index. Do not edit.
|
|
2447
2284
|
*/
|
|
2448
2285
|
|
|
2449
|
-
export { Action, Actions, InitState, NGXS_PLUGINS, NgxsDevelopmentModule, NgxsModule, NgxsSimpleChange, NgxsUnhandledActionsLogger, NoopNgxsExecutionStrategy, Select, Selector, SelectorOptions, State, StateStream, StateToken, Store, UpdateState, actionMatcher, createModelSelector, createPickSelector, createPropertySelectors, createSelector, ensureSelectorMetadata, ensureStoreMetadata, getActionTypeFromInstance, getSelectorMetadata, getStoreMetadata, getValue, ofAction, ofActionCanceled, ofActionCompleted, ofActionDispatched, ofActionErrored, ofActionSuccessful,
|
|
2450
|
-
//# sourceMappingURL=ngxs-store.
|
|
2286
|
+
export { Action, Actions, InitState, NGXS_PLUGINS, NgxsDevelopmentModule, NgxsModule, NgxsSimpleChange, NgxsUnhandledActionsLogger, NoopNgxsExecutionStrategy, Select, Selector, SelectorOptions, State, StateStream, StateToken, Store, UpdateState, actionMatcher, createModelSelector, createPickSelector, createPropertySelectors, createSelector, ensureSelectorMetadata, ensureStoreMetadata, getActionTypeFromInstance, getSelectorMetadata, getStoreMetadata, getValue, ofAction, ofActionCanceled, ofActionCompleted, ofActionDispatched, ofActionErrored, ofActionSuccessful, setValue, NgxsFeatureModule as ɵNgxsFeatureModule, NgxsRootModule as ɵNgxsRootModule };
|
|
2287
|
+
//# sourceMappingURL=ngxs-store.js.map
|