@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,180 +0,0 @@
|
|
|
1
|
-
import * as i0 from '@angular/core';
|
|
2
|
-
import { Component, NgModule, ApplicationRef, destroyPlatform, VERSION, createPlatform } from '@angular/core';
|
|
3
|
-
import { TestBed } from '@angular/core/testing';
|
|
4
|
-
import { DOCUMENT } from '@angular/common';
|
|
5
|
-
import { BrowserModule, ɵBrowserDomAdapter, ɵgetDOM } from '@angular/platform-browser';
|
|
6
|
-
import { BrowserDynamicTestingModule, platformBrowserDynamicTesting } from '@angular/platform-browser-dynamic/testing';
|
|
7
|
-
import { NgxsModule, Store } from '@ngxs/store';
|
|
8
|
-
|
|
9
|
-
class NgxsTestComponent {
|
|
10
|
-
ngOnInit() { }
|
|
11
|
-
ngAfterViewInit() { }
|
|
12
|
-
}
|
|
13
|
-
/** @nocollapse */ NgxsTestComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.4", ngImport: i0, type: NgxsTestComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
14
|
-
/** @nocollapse */ NgxsTestComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.2.4", type: NgxsTestComponent, selector: "app-root", ngImport: i0, template: '', isInline: true });
|
|
15
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.4", ngImport: i0, type: NgxsTestComponent, decorators: [{
|
|
16
|
-
type: Component,
|
|
17
|
-
args: [{
|
|
18
|
-
selector: 'app-root',
|
|
19
|
-
template: ''
|
|
20
|
-
}]
|
|
21
|
-
}] });
|
|
22
|
-
|
|
23
|
-
class NgxsTestModule {
|
|
24
|
-
static ngDoBootstrap(app) {
|
|
25
|
-
app.bootstrap(NgxsTestComponent);
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
/** @nocollapse */ NgxsTestModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.4", ngImport: i0, type: NgxsTestModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
29
|
-
/** @nocollapse */ NgxsTestModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.2.4", ngImport: i0, type: NgxsTestModule, declarations: [NgxsTestComponent], imports: [BrowserModule] });
|
|
30
|
-
/** @nocollapse */ NgxsTestModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.2.4", ngImport: i0, type: NgxsTestModule, imports: [BrowserModule] });
|
|
31
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.4", ngImport: i0, type: NgxsTestModule, decorators: [{
|
|
32
|
-
type: NgModule,
|
|
33
|
-
args: [{
|
|
34
|
-
imports: [BrowserModule],
|
|
35
|
-
declarations: [NgxsTestComponent]
|
|
36
|
-
}]
|
|
37
|
-
}] });
|
|
38
|
-
|
|
39
|
-
class NgxsTestBed {
|
|
40
|
-
static configureTestingStates(options) {
|
|
41
|
-
this.resetTestBed();
|
|
42
|
-
if (options.before) {
|
|
43
|
-
options.before();
|
|
44
|
-
}
|
|
45
|
-
TestBed.configureTestingModule({
|
|
46
|
-
imports: [
|
|
47
|
-
NgxsTestModule,
|
|
48
|
-
NgxsModule.forRoot(options.states || [], options.ngxsOptions || {}),
|
|
49
|
-
...(options.imports || [])
|
|
50
|
-
]
|
|
51
|
-
}).compileComponents();
|
|
52
|
-
NgxsTestBed.ngxsBootstrap();
|
|
53
|
-
return {
|
|
54
|
-
get store() {
|
|
55
|
-
return TestBed.inject(Store);
|
|
56
|
-
},
|
|
57
|
-
get getTestBed() {
|
|
58
|
-
return TestBed;
|
|
59
|
-
}
|
|
60
|
-
};
|
|
61
|
-
}
|
|
62
|
-
static ngxsBootstrap() {
|
|
63
|
-
NgxsTestBed.createRootNode();
|
|
64
|
-
NgxsTestModule.ngDoBootstrap(TestBed.inject(ApplicationRef));
|
|
65
|
-
}
|
|
66
|
-
static resetTestBed() {
|
|
67
|
-
TestBed.resetTestEnvironment();
|
|
68
|
-
TestBed.initTestEnvironment(BrowserDynamicTestingModule, platformBrowserDynamicTesting(), {
|
|
69
|
-
teardown: { destroyAfterEach: true }
|
|
70
|
-
});
|
|
71
|
-
}
|
|
72
|
-
static createRootNode(selector = 'app-root') {
|
|
73
|
-
const document = TestBed.inject(DOCUMENT);
|
|
74
|
-
const adapter = new ɵBrowserDomAdapter();
|
|
75
|
-
const root = adapter.createElement(selector);
|
|
76
|
-
document.body.appendChild(root);
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
function createRootElement() {
|
|
81
|
-
const document = TestBed.inject(DOCUMENT);
|
|
82
|
-
const root = ɵgetDOM().createElement('app-root', document);
|
|
83
|
-
document.body.appendChild(root);
|
|
84
|
-
}
|
|
85
|
-
function removeRootElement() {
|
|
86
|
-
const root = document.getElementsByTagName('app-root').item(0);
|
|
87
|
-
try {
|
|
88
|
-
document.body.removeChild(root);
|
|
89
|
-
}
|
|
90
|
-
catch { }
|
|
91
|
-
}
|
|
92
|
-
function destroyPlatformBeforeBootstrappingTheNewOne(freshUrl) {
|
|
93
|
-
destroyPlatform();
|
|
94
|
-
resetLocationToUrl(freshUrl);
|
|
95
|
-
createRootElement();
|
|
96
|
-
}
|
|
97
|
-
// As we create our custom platform via `bootstrapModule`
|
|
98
|
-
// we have to destroy it after assetions and revert
|
|
99
|
-
// the previous one
|
|
100
|
-
function resetPlatformAfterBootstrapping() {
|
|
101
|
-
removeRootElement();
|
|
102
|
-
destroyPlatform();
|
|
103
|
-
const version = +VERSION.major;
|
|
104
|
-
// https://github.com/angular/angular/commit/e250db4f261741b04ee4cbad4dec41a8908a12aa
|
|
105
|
-
if (version < 14) {
|
|
106
|
-
createPlatform(TestBed);
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
function resetLocationToUrl(freshUrl) {
|
|
110
|
-
window.history.replaceState({}, 'Test', freshUrl);
|
|
111
|
-
}
|
|
112
|
-
function freshPlatform(fn) {
|
|
113
|
-
let resolve = null;
|
|
114
|
-
let reject = null;
|
|
115
|
-
let whenDoneIsCalledPromise = null;
|
|
116
|
-
const hasDoneArgument = fn.length === 1;
|
|
117
|
-
if (hasDoneArgument) {
|
|
118
|
-
whenDoneIsCalledPromise = new Promise((_resolve, _reject) => {
|
|
119
|
-
resolve = _resolve;
|
|
120
|
-
reject = _reject;
|
|
121
|
-
});
|
|
122
|
-
}
|
|
123
|
-
return async function testWithAFreshPlatform() {
|
|
124
|
-
try {
|
|
125
|
-
const freshUrl = '/';
|
|
126
|
-
destroyPlatformBeforeBootstrappingTheNewOne(freshUrl);
|
|
127
|
-
if (hasDoneArgument) {
|
|
128
|
-
await fn((error) => {
|
|
129
|
-
if (error) {
|
|
130
|
-
reject(error);
|
|
131
|
-
}
|
|
132
|
-
else {
|
|
133
|
-
resolve();
|
|
134
|
-
}
|
|
135
|
-
});
|
|
136
|
-
await whenDoneIsCalledPromise;
|
|
137
|
-
}
|
|
138
|
-
else {
|
|
139
|
-
await fn();
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
finally {
|
|
143
|
-
resetPlatformAfterBootstrapping();
|
|
144
|
-
}
|
|
145
|
-
};
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
/// <reference types="jest" />
|
|
149
|
-
function skipConsoleLogging(fn) {
|
|
150
|
-
const consoleSpies = [
|
|
151
|
-
jest.spyOn(console, 'log').mockImplementation(() => { }),
|
|
152
|
-
jest.spyOn(console, 'warn').mockImplementation(() => { }),
|
|
153
|
-
jest.spyOn(console, 'error').mockImplementation(() => { }),
|
|
154
|
-
jest.spyOn(console, 'info').mockImplementation(() => { })
|
|
155
|
-
];
|
|
156
|
-
function restoreSpies() {
|
|
157
|
-
consoleSpies.forEach(spy => spy.mockRestore());
|
|
158
|
-
}
|
|
159
|
-
let restoreSpyAsync = false;
|
|
160
|
-
try {
|
|
161
|
-
const returnValue = fn();
|
|
162
|
-
if (returnValue instanceof Promise) {
|
|
163
|
-
restoreSpyAsync = true;
|
|
164
|
-
return returnValue.finally(() => restoreSpies());
|
|
165
|
-
}
|
|
166
|
-
return returnValue;
|
|
167
|
-
}
|
|
168
|
-
finally {
|
|
169
|
-
if (!restoreSpyAsync) {
|
|
170
|
-
restoreSpies();
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
/**
|
|
176
|
-
* Generated bundle index. Do not edit.
|
|
177
|
-
*/
|
|
178
|
-
|
|
179
|
-
export { NgxsTestBed, freshPlatform, skipConsoleLogging };
|
|
180
|
-
//# sourceMappingURL=ngxs-store-internals-testing.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ngxs-store-internals-testing.mjs","sources":["../../../packages/store/internals/testing/src/helpers/ngxs-test.component.ts","../../../packages/store/internals/testing/src/helpers/ngxs-test.module.ts","../../../packages/store/internals/testing/src/ngxs.setup.ts","../../../packages/store/internals/testing/src/fresh-platform.ts","../../../packages/store/internals/testing/src/skip-console-logging.ts","../../../packages/store/internals/testing/src/ngxs-store-internals-testing.ts"],"sourcesContent":["import { AfterViewInit, Component, OnInit } from '@angular/core';\n\n@Component({\n selector: 'app-root',\n template: ''\n})\nexport class NgxsTestComponent implements OnInit, AfterViewInit {\n public ngOnInit(): void {}\n public ngAfterViewInit(): void {}\n}\n","import { ApplicationRef, NgModule } from '@angular/core';\nimport { BrowserModule } from '@angular/platform-browser';\n\nimport { NgxsTestComponent } from './ngxs-test.component';\n\n@NgModule({\n imports: [BrowserModule],\n declarations: [NgxsTestComponent]\n})\nexport class NgxsTestModule {\n public static ngDoBootstrap(app: ApplicationRef): void {\n app.bootstrap(NgxsTestComponent);\n }\n}\n","import { ApplicationRef } from '@angular/core';\nimport { TestBed, TestBedStatic } from '@angular/core/testing';\nimport { DOCUMENT } from '@angular/common';\nimport { ɵBrowserDomAdapter as BrowserDomAdapter } from '@angular/platform-browser';\nimport {\n BrowserDynamicTestingModule,\n platformBrowserDynamicTesting\n} from '@angular/platform-browser-dynamic/testing';\nimport { NgxsModule, Store } from '@ngxs/store';\n\nimport { NgxsTestModule } from './helpers/ngxs-test.module';\nimport { NgxsOptionsTesting, NgxsTesting } from './symbol';\n\nexport class NgxsTestBed {\n public static configureTestingStates(options: NgxsOptionsTesting): NgxsTesting {\n this.resetTestBed();\n\n if (options.before) {\n options.before();\n }\n\n TestBed.configureTestingModule({\n imports: [\n NgxsTestModule,\n NgxsModule.forRoot(options.states || [], options.ngxsOptions || {}),\n ...(options.imports || [])\n ]\n }).compileComponents();\n\n NgxsTestBed.ngxsBootstrap();\n\n return {\n get store(): Store {\n return TestBed.inject(Store);\n },\n get getTestBed(): TestBedStatic {\n return TestBed;\n }\n };\n }\n\n private static ngxsBootstrap(): void {\n NgxsTestBed.createRootNode();\n NgxsTestModule.ngDoBootstrap(TestBed.inject(ApplicationRef));\n }\n\n private static resetTestBed(): void {\n TestBed.resetTestEnvironment();\n TestBed.initTestEnvironment(BrowserDynamicTestingModule, platformBrowserDynamicTesting(), {\n teardown: { destroyAfterEach: true }\n });\n }\n\n private static createRootNode(selector = 'app-root'): void {\n const document = TestBed.inject(DOCUMENT);\n const adapter = new BrowserDomAdapter();\n const root = adapter.createElement(selector);\n document.body.appendChild(root);\n }\n}\n","import { TestBed } from '@angular/core/testing';\nimport { DOCUMENT } from '@angular/common';\nimport { ɵgetDOM as getDOM } from '@angular/platform-browser';\nimport { VERSION, destroyPlatform, createPlatform } from '@angular/core';\n\nfunction createRootElement() {\n const document = TestBed.inject(DOCUMENT);\n const root = getDOM().createElement('app-root', document);\n document.body.appendChild(root);\n}\n\nfunction removeRootElement() {\n const root: Element = document.getElementsByTagName('app-root').item(0)!;\n try {\n document.body.removeChild(root);\n } catch {}\n}\n\nfunction destroyPlatformBeforeBootstrappingTheNewOne(freshUrl: string) {\n destroyPlatform();\n resetLocationToUrl(freshUrl);\n createRootElement();\n}\n\n// As we create our custom platform via `bootstrapModule`\n// we have to destroy it after assetions and revert\n// the previous one\nfunction resetPlatformAfterBootstrapping() {\n removeRootElement();\n destroyPlatform();\n const version = +VERSION.major;\n // https://github.com/angular/angular/commit/e250db4f261741b04ee4cbad4dec41a8908a12aa\n if (version < 14) {\n createPlatform(TestBed);\n }\n}\n\nfunction resetLocationToUrl(freshUrl: string) {\n window.history.replaceState({}, 'Test', freshUrl);\n}\n\nexport function freshPlatform(fn: (done?: VoidFunction) => Promise<void>) {\n let resolve: VoidFunction | null = null;\n let reject: ((error: Error) => void) | null = null;\n let whenDoneIsCalledPromise: Promise<void> | null = null;\n\n const hasDoneArgument = fn.length === 1;\n\n if (hasDoneArgument) {\n whenDoneIsCalledPromise = new Promise<void>((_resolve, _reject) => {\n resolve = _resolve;\n reject = _reject;\n });\n }\n\n return async function testWithAFreshPlatform() {\n try {\n const freshUrl = '/';\n destroyPlatformBeforeBootstrappingTheNewOne(freshUrl);\n\n if (hasDoneArgument) {\n await fn((error?: Error) => {\n if (error) {\n reject!(error);\n } else {\n resolve!();\n }\n });\n await whenDoneIsCalledPromise!;\n } else {\n await fn();\n }\n } finally {\n resetPlatformAfterBootstrapping();\n }\n };\n}\n","/// <reference types=\"jest\" />\n\nexport function skipConsoleLogging<T extends (...args: any[]) => any>(fn: T): ReturnType<T> {\n const consoleSpies = [\n jest.spyOn(console, 'log').mockImplementation(() => {}),\n jest.spyOn(console, 'warn').mockImplementation(() => {}),\n jest.spyOn(console, 'error').mockImplementation(() => {}),\n jest.spyOn(console, 'info').mockImplementation(() => {})\n ];\n function restoreSpies() {\n consoleSpies.forEach(spy => spy.mockRestore());\n }\n let restoreSpyAsync = false;\n try {\n const returnValue = fn();\n if (returnValue instanceof Promise) {\n restoreSpyAsync = true;\n return returnValue.finally(() => restoreSpies()) as ReturnType<T>;\n }\n return returnValue;\n } finally {\n if (!restoreSpyAsync) {\n restoreSpies();\n }\n }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":["BrowserDomAdapter","getDOM"],"mappings":";;;;;;;;MAMa,iBAAiB,CAAA;AACrB,IAAA,QAAQ,MAAW;AACnB,IAAA,eAAe,MAAW;;iIAFtB,iBAAiB,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,SAAA,EAAA,CAAA,CAA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,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC,kBAAkB,CAAC,MAAK,GAAG,CAAC;KACzD,CAAC;AACF,IAAA,SAAS,YAAY,GAAA;AACnB,QAAA,YAAY,CAAC,OAAO,CAAC,GAAG,IAAI,GAAG,CAAC,WAAW,EAAE,CAAC,CAAC;KAChD;IACD,IAAI,eAAe,GAAG,KAAK,CAAC;IAC5B,IAAI;AACF,QAAA,MAAM,WAAW,GAAG,EAAE,EAAE,CAAC;QACzB,IAAI,WAAW,YAAY,OAAO,EAAE;YAClC,eAAe,GAAG,IAAI,CAAC;YACvB,OAAO,WAAW,CAAC,OAAO,CAAC,MAAM,YAAY,EAAE,CAAkB,CAAC;AACnE,SAAA;AACD,QAAA,OAAO,WAAW,CAAC;AACpB,KAAA;AAAS,YAAA;QACR,IAAI,CAAC,eAAe,EAAE;AACpB,YAAA,YAAY,EAAE,CAAC;AAChB,SAAA;AACF,KAAA;AACH;;ACzBA;;AAEG;;;;"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ngxs-store-internals.mjs","sources":["../../../packages/store/internals/src/ngxs-bootstrapper.ts","../../../packages/store/internals/src/memoize.ts","../../../packages/store/internals/src/initial-state.ts","../../../packages/store/internals/src/symbols.ts","../../../packages/store/internals/src/internal-tokens.ts","../../../packages/store/internals/src/ngxs-store-internals.ts"],"sourcesContent":["import { Injectable } from '@angular/core';\nimport { Observable, ReplaySubject } from 'rxjs';\n\n@Injectable({ providedIn: 'root' })\nexport class NgxsBootstrapper {\n /**\n * Use `ReplaySubject`, thus we can get cached value even if the stream is completed\n */\n private bootstrap$ = new ReplaySubject<boolean>(1);\n\n get appBootstrapped$(): Observable<boolean> {\n return this.bootstrap$.asObservable();\n }\n\n /**\n * This event will be emitted after attaching `ComponentRef` of the root component\n * to the tree of views, that's a signal that application has been fully rendered\n */\n bootstrap(): void {\n this.bootstrap$.next(true);\n this.bootstrap$.complete();\n }\n}\n","function defaultEqualityCheck(a: any, b: any) {\n return a === b;\n}\n\nfunction areArgumentsShallowlyEqual(\n equalityCheck: (a: any, b: any) => boolean,\n prev: IArguments | null,\n next: IArguments | null\n) {\n if (prev === null || next === null || prev.length !== next.length) {\n return false;\n }\n\n // Do this in a for loop (and not a `forEach` or an `every`) so we can determine equality as fast as possible.\n const length = prev.length;\n for (let i = 0; i < length; i++) {\n if (!equalityCheck(prev[i], next[i])) {\n return false;\n }\n }\n\n return true;\n}\n\n/**\n * Memoize a function on its last inputs only.\n * Originally from: https://github.com/reduxjs/reselect/blob/master/src/index.js\n *\n * @ignore\n */\nexport function memoize<T extends (...args: any[]) => any>(\n func: T,\n equalityCheck = defaultEqualityCheck\n): T {\n let lastArgs: IArguments | null = null;\n let lastResult: any = null;\n // we reference arguments instead of spreading them for performance reasons\n function memoized() {\n // eslint-disable-next-line prefer-rest-params\n if (!areArgumentsShallowlyEqual(equalityCheck, lastArgs, arguments)) {\n // apply arguments instead of spreading for performance.\n // eslint-disable-next-line prefer-rest-params, prefer-spread\n lastResult = (<Function>func).apply(null, arguments);\n }\n // eslint-disable-next-line prefer-rest-params\n lastArgs = arguments;\n return lastResult;\n }\n (<any>memoized).reset = function() {\n // The hidden (for now) ability to reset the memoization\n lastArgs = null;\n lastResult = null;\n };\n return memoized as T;\n}\n","import { InjectionToken } from '@angular/core';\n\nimport { PlainObject } from './symbols';\n\ndeclare const ngDevMode: boolean;\n\nconst NG_DEV_MODE = typeof ngDevMode === 'undefined' || ngDevMode;\n\nexport class InitialState {\n private static _value: PlainObject = {};\n\n static set(state: PlainObject) {\n this._value = state;\n }\n\n static pop(): PlainObject {\n const state = this._value;\n this._value = {};\n return state;\n }\n}\n\nexport const INITIAL_STATE_TOKEN = new InjectionToken<PlainObject>(\n NG_DEV_MODE ? 'INITIAL_STATE_TOKEN' : '',\n {\n providedIn: 'root',\n factory: () => InitialState.pop()\n }\n);\n","export interface PlainObject {\n [key: string]: any;\n}\n\nexport interface PlainObjectOf<T> {\n [key: string]: T;\n}\n\nexport type ɵStateClass<T = any> = new (...args: any[]) => T;\n\n// This key is used to store metadata on state classes,\n// such as actions and other related information.\nexport const ɵMETA_KEY = 'NGXS_META';\n// This key is used to store options on state classes\n// provided through the `@State` decorator.\nexport const ɵMETA_OPTIONS_KEY = 'NGXS_OPTIONS_META';\n// This key is used to store selector metadata on selector functions,\n// such as decorated with the `@Selector` or provided through the\n// `createSelector` function.\nexport const ɵSELECTOR_META_KEY = 'NGXS_SELECTOR_META';\n","import { InjectionToken } from '@angular/core';\n\ndeclare const ngDevMode: boolean;\n\nconst NG_DEV_MODE = typeof ngDevMode === 'undefined' || ngDevMode;\n\n// These tokens are internal and can change at any point.\n\nexport const ɵNGXS_STATE_FACTORY = new InjectionToken<any>(\n NG_DEV_MODE ? 'ɵNGXS_STATE_FACTORY' : ''\n);\n\nexport const ɵNGXS_STATE_CONTEXT_FACTORY = new InjectionToken<any>(\n NG_DEV_MODE ? 'ɵNGXS_STATE_CONTEXT_FACTORY' : ''\n);\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":["NG_DEV_MODE"],"mappings":";;;;MAIa,gBAAgB,CAAA;AAD7B,IAAA,WAAA,GAAA;AAEE;;AAEG;AACK,QAAA,IAAA,CAAA,UAAU,GAAG,IAAI,aAAa,CAAU,CAAC,CAAC,CAAC;AAcpD,KAAA;AAZC,IAAA,IAAI,gBAAgB,GAAA;AAClB,QAAA,OAAO,IAAI,CAAC,UAAU,CAAC,YAAY,EAAE,CAAC;KACvC;AAED;;;AAGG;IACH,SAAS,GAAA;AACP,QAAA,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC3B,QAAA,IAAI,CAAC,UAAU,CAAC,QAAQ,EAAE,CAAC;KAC5B;;gIAjBU,gBAAgB,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,UAAA,EAAA,CAAA,CAAA;AAAhB,mBAAA,gBAAA,CAAA,KAAA,GA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|
1
|
-
/**
|
|
2
|
-
* @param items - Specific items to append to the end of an array
|
|
3
|
-
*/
|
|
4
|
-
function append(items) {
|
|
5
|
-
return function appendOperator(existing) {
|
|
6
|
-
// If `items` is `undefined` or `null` or `[]` but `existing` is provided
|
|
7
|
-
// just return `existing`
|
|
8
|
-
const itemsNotProvidedButExistingIs = (!items || !items.length) && existing;
|
|
9
|
-
if (itemsNotProvidedButExistingIs) {
|
|
10
|
-
return existing;
|
|
11
|
-
}
|
|
12
|
-
if (Array.isArray(existing)) {
|
|
13
|
-
return existing.concat(items);
|
|
14
|
-
}
|
|
15
|
-
// For example if some property is added dynamically
|
|
16
|
-
// and didn't exist before thus it's not `ArrayLike`
|
|
17
|
-
return items;
|
|
18
|
-
};
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
function compose(...operators) {
|
|
22
|
-
return function composeOperator(existing) {
|
|
23
|
-
return operators.reduce((accumulator, operator) => operator(accumulator), existing);
|
|
24
|
-
};
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
function isStateOperator(value) {
|
|
28
|
-
return typeof value === 'function';
|
|
29
|
-
}
|
|
30
|
-
function isUndefined(value) {
|
|
31
|
-
return typeof value === 'undefined';
|
|
32
|
-
}
|
|
33
|
-
function isPredicate(value) {
|
|
34
|
-
return typeof value === 'function';
|
|
35
|
-
}
|
|
36
|
-
function isNumber(value) {
|
|
37
|
-
return typeof value === 'number';
|
|
38
|
-
}
|
|
39
|
-
function invalidIndex(index) {
|
|
40
|
-
return Number.isNaN(index) || index === -1;
|
|
41
|
-
}
|
|
42
|
-
function isNil(value) {
|
|
43
|
-
return value === null || isUndefined(value);
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
function retrieveValue(operatorOrValue, existing) {
|
|
47
|
-
// If state operator is a function
|
|
48
|
-
// then call it with an original value
|
|
49
|
-
if (isStateOperator(operatorOrValue)) {
|
|
50
|
-
const value = operatorOrValue(existing);
|
|
51
|
-
return value;
|
|
52
|
-
}
|
|
53
|
-
// If operator or value was not provided
|
|
54
|
-
// e.g. `elseOperatorOrValue` is `undefined`
|
|
55
|
-
// then we just return an original value
|
|
56
|
-
if (isUndefined(operatorOrValue)) {
|
|
57
|
-
return existing;
|
|
58
|
-
}
|
|
59
|
-
return operatorOrValue;
|
|
60
|
-
}
|
|
61
|
-
/**
|
|
62
|
-
* @param condition - Condition can be a plain boolean value or a function,
|
|
63
|
-
* that returns boolean, also this function can take a value as an argument
|
|
64
|
-
* to which this state operator applies
|
|
65
|
-
* @param trueOperatorOrValue - Any value or a state operator
|
|
66
|
-
* @param elseOperatorOrValue - Any value or a state operator
|
|
67
|
-
*/
|
|
68
|
-
function iif(condition, trueOperatorOrValue, elseOperatorOrValue) {
|
|
69
|
-
return function iifOperator(existing) {
|
|
70
|
-
// Convert the value to a boolean
|
|
71
|
-
let result = !!condition;
|
|
72
|
-
// but if it is a function then run it to get the result
|
|
73
|
-
if (isPredicate(condition)) {
|
|
74
|
-
result = condition(existing);
|
|
75
|
-
}
|
|
76
|
-
if (result) {
|
|
77
|
-
return retrieveValue(trueOperatorOrValue, existing);
|
|
78
|
-
}
|
|
79
|
-
return retrieveValue(elseOperatorOrValue, existing);
|
|
80
|
-
};
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
/**
|
|
84
|
-
* @param value - Value to insert
|
|
85
|
-
* @param [beforePosition] - Specified index to insert value before, optional
|
|
86
|
-
*/
|
|
87
|
-
function insertItem(value, beforePosition) {
|
|
88
|
-
return function insertItemOperator(existing) {
|
|
89
|
-
// Have to check explicitly for `null` and `undefined`
|
|
90
|
-
// because `value` can be `0`, thus `!value` will return `true`
|
|
91
|
-
if (isNil(value) && existing) {
|
|
92
|
-
return existing;
|
|
93
|
-
}
|
|
94
|
-
// Property may be dynamic and might not existed before
|
|
95
|
-
if (!Array.isArray(existing)) {
|
|
96
|
-
return [value];
|
|
97
|
-
}
|
|
98
|
-
const clone = existing.slice();
|
|
99
|
-
let index = 0;
|
|
100
|
-
// No need to call `isNumber`
|
|
101
|
-
// as we are checking `> 0` not `>= 0`
|
|
102
|
-
// everything except number will return false here
|
|
103
|
-
if (beforePosition > 0) {
|
|
104
|
-
index = beforePosition;
|
|
105
|
-
}
|
|
106
|
-
clone.splice(index, 0, value);
|
|
107
|
-
return clone;
|
|
108
|
-
};
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
function patch(patchObject) {
|
|
112
|
-
return function patchStateOperator(existing) {
|
|
113
|
-
let clone = null;
|
|
114
|
-
for (const k in patchObject) {
|
|
115
|
-
const newValue = patchObject[k];
|
|
116
|
-
const existingPropValue = existing?.[k];
|
|
117
|
-
const newPropValue = isStateOperator(newValue)
|
|
118
|
-
? newValue(existingPropValue)
|
|
119
|
-
: newValue;
|
|
120
|
-
if (newPropValue !== existingPropValue) {
|
|
121
|
-
if (!clone) {
|
|
122
|
-
clone = { ...existing };
|
|
123
|
-
}
|
|
124
|
-
clone[k] = newPropValue;
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
return clone || existing;
|
|
128
|
-
};
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
/**
|
|
132
|
-
* @param selector - Index of item in the array or a predicate function
|
|
133
|
-
* that can be provided in `Array.prototype.findIndex`
|
|
134
|
-
* @param operatorOrValue - New value under the `selector` index or a
|
|
135
|
-
* function that can be applied to an existing value
|
|
136
|
-
*/
|
|
137
|
-
function updateItem(selector, operatorOrValue) {
|
|
138
|
-
return function updateItemOperator(existing) {
|
|
139
|
-
let index = -1;
|
|
140
|
-
if (isPredicate(selector)) {
|
|
141
|
-
index = existing.findIndex(selector);
|
|
142
|
-
}
|
|
143
|
-
else if (isNumber(selector)) {
|
|
144
|
-
index = selector;
|
|
145
|
-
}
|
|
146
|
-
if (invalidIndex(index)) {
|
|
147
|
-
return existing;
|
|
148
|
-
}
|
|
149
|
-
let value = null;
|
|
150
|
-
// Need to check if the new item value will change the existing item value
|
|
151
|
-
// then, only if it will change it then clone the array and set the item
|
|
152
|
-
const theOperatorOrValue = operatorOrValue;
|
|
153
|
-
if (isStateOperator(theOperatorOrValue)) {
|
|
154
|
-
value = theOperatorOrValue(existing[index]);
|
|
155
|
-
}
|
|
156
|
-
else {
|
|
157
|
-
value = theOperatorOrValue;
|
|
158
|
-
}
|
|
159
|
-
// If the value hasn't been mutated
|
|
160
|
-
// then we just return `existing` array
|
|
161
|
-
if (value === existing[index]) {
|
|
162
|
-
return existing;
|
|
163
|
-
}
|
|
164
|
-
const clone = existing.slice();
|
|
165
|
-
clone[index] = value;
|
|
166
|
-
return clone;
|
|
167
|
-
};
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
/**
|
|
171
|
-
* @param selector - index or predicate to remove an item from an array by
|
|
172
|
-
*/
|
|
173
|
-
function removeItem(selector) {
|
|
174
|
-
return function removeItemOperator(existing) {
|
|
175
|
-
let index = -1;
|
|
176
|
-
if (isPredicate(selector)) {
|
|
177
|
-
index = existing.findIndex(selector);
|
|
178
|
-
}
|
|
179
|
-
else if (isNumber(selector)) {
|
|
180
|
-
index = selector;
|
|
181
|
-
}
|
|
182
|
-
if (invalidIndex(index)) {
|
|
183
|
-
return existing;
|
|
184
|
-
}
|
|
185
|
-
const clone = existing.slice();
|
|
186
|
-
clone.splice(index, 1);
|
|
187
|
-
return clone;
|
|
188
|
-
};
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
/**
|
|
192
|
-
* @module
|
|
193
|
-
* @description
|
|
194
|
-
* Entry point for all public APIs of this package.
|
|
195
|
-
*/
|
|
196
|
-
|
|
197
|
-
/**
|
|
198
|
-
* Generated bundle index. Do not edit.
|
|
199
|
-
*/
|
|
200
|
-
|
|
201
|
-
export { append, compose, iif, insertItem, isPredicate, isStateOperator, patch, removeItem, updateItem };
|
|
202
|
-
//# sourceMappingURL=ngxs-store-operators.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ngxs-store-operators.mjs","sources":["../../../packages/store/operators/src/append.ts","../../../packages/store/operators/src/compose.ts","../../../packages/store/operators/src/utils.ts","../../../packages/store/operators/src/iif.ts","../../../packages/store/operators/src/insert-item.ts","../../../packages/store/operators/src/patch.ts","../../../packages/store/operators/src/update-item.ts","../../../packages/store/operators/src/remove-item.ts","../../../packages/store/operators/src/index.ts","../../../packages/store/operators/src/ngxs-store-operators.ts"],"sourcesContent":["import { ExistingState, NoInfer, StateOperator } from './types';\n\n/**\n * @param items - Specific items to append to the end of an array\n */\nexport function append<T>(items: NoInfer<T[]>): StateOperator<T[]> {\n return function appendOperator(existing: ExistingState<T[]>): T[] {\n // If `items` is `undefined` or `null` or `[]` but `existing` is provided\n // just return `existing`\n const itemsNotProvidedButExistingIs = (!items || !items.length) && existing;\n if (itemsNotProvidedButExistingIs) {\n return (existing as unknown) as T[];\n }\n\n if (Array.isArray(existing)) {\n return existing.concat((items as unknown) as ExistingState<T[]>);\n }\n\n // For example if some property is added dynamically\n // and didn't exist before thus it's not `ArrayLike`\n return (items as unknown) as T[];\n };\n}\n","import { ExistingState, NoInfer, StateOperator } from './types';\n\nexport function compose<T>(...operators: NoInfer<StateOperator<T>[]>): StateOperator<T> {\n return function composeOperator(existing: ExistingState<T>): T {\n return operators.reduce(\n (accumulator, operator) => operator(accumulator as ExistingState<T>),\n existing as T\n );\n };\n}\n","import { StateOperator } from './types';\n\nexport type Predicate<T = any> = (value: T | Readonly<T>) => boolean;\n\nexport function isStateOperator<T>(value: T | StateOperator<T>): value is StateOperator<T> {\n return typeof value === 'function';\n}\n\nexport function isUndefined(value: any): value is undefined {\n return typeof value === 'undefined';\n}\n\nexport function isPredicate<T>(value: Predicate<T> | boolean | number): value is Predicate<T> {\n return typeof value === 'function';\n}\n\nexport function isNumber(value: any): value is number {\n return typeof value === 'number';\n}\n\nexport function invalidIndex(index: number): boolean {\n return Number.isNaN(index) || index === -1;\n}\n\nexport function isNil<T>(value: T | null | undefined): value is null | undefined {\n return value === null || isUndefined(value);\n}\n","import { ExistingState, NoInfer, StateOperator } from './types';\n\nimport { isStateOperator, isUndefined, isPredicate, Predicate } from './utils';\n\nfunction retrieveValue<T>(\n operatorOrValue: StateOperator<T> | T,\n existing: ExistingState<T>\n): T {\n // If state operator is a function\n // then call it with an original value\n if (isStateOperator(operatorOrValue)) {\n const value = operatorOrValue(existing);\n return value as T;\n }\n\n // If operator or value was not provided\n // e.g. `elseOperatorOrValue` is `undefined`\n // then we just return an original value\n if (isUndefined(operatorOrValue)) {\n return existing as T;\n }\n\n return operatorOrValue as T;\n}\n\n/**\n * @param condition - Condition can be a plain boolean value or a function,\n * that returns boolean, also this function can take a value as an argument\n * to which this state operator applies\n * @param trueOperatorOrValue - Any value or a state operator\n * @param elseOperatorOrValue - Any value or a state operator\n */\nexport function iif<T>(\n condition: NoInfer<Predicate<T>> | boolean,\n trueOperatorOrValue: NoInfer<StateOperator<T> | T>,\n elseOperatorOrValue?: NoInfer<StateOperator<T> | T>\n): StateOperator<T> {\n return function iifOperator(existing: ExistingState<T>): T {\n // Convert the value to a boolean\n let result = !!condition;\n // but if it is a function then run it to get the result\n if (isPredicate(condition)) {\n result = condition(existing as T);\n }\n\n if (result) {\n return retrieveValue<T>(trueOperatorOrValue as StateOperator<T> | T, existing);\n }\n\n return retrieveValue<T>(elseOperatorOrValue! as StateOperator<T> | T, existing);\n };\n}\n","import { ExistingState, NoInfer, StateOperator } from './types';\nimport { isNil } from './utils';\n\n/**\n * @param value - Value to insert\n * @param [beforePosition] - Specified index to insert value before, optional\n */\nexport function insertItem<T>(value: NoInfer<T>, beforePosition?: number): StateOperator<T[]> {\n return function insertItemOperator(existing: ExistingState<T[]>): T[] {\n // Have to check explicitly for `null` and `undefined`\n // because `value` can be `0`, thus `!value` will return `true`\n if (isNil(value) && existing) {\n return existing as T[];\n }\n\n // Property may be dynamic and might not existed before\n if (!Array.isArray(existing)) {\n return [(value as unknown) as T];\n }\n\n const clone = existing.slice();\n\n let index = 0;\n\n // No need to call `isNumber`\n // as we are checking `> 0` not `>= 0`\n // everything except number will return false here\n if (beforePosition! > 0) {\n index = beforePosition!;\n }\n\n clone.splice(index, 0, (value as unknown) as T);\n return clone;\n };\n}\n","import { ExistingState, NoInfer, StateOperator } from './types';\nimport { isStateOperator } from './utils';\n\ntype NotUndefined<T> = T extends undefined ? never : T;\n\nexport type ɵPatchSpec<T> = { [P in keyof T]?: T[P] | StateOperator<NotUndefined<T[P]>> };\n\nexport function patch<T extends Record<string, any>>(\n patchObject: NoInfer<ɵPatchSpec<T>>\n): StateOperator<T> {\n return function patchStateOperator(existing: ExistingState<T>): T {\n let clone = null;\n for (const k in patchObject) {\n const newValue = patchObject[k];\n const existingPropValue = existing?.[k];\n const newPropValue = isStateOperator(newValue)\n ? newValue(<any>existingPropValue)\n : newValue;\n if (newPropValue !== existingPropValue) {\n if (!clone) {\n clone = { ...(<any>existing) };\n }\n clone[k] = newPropValue;\n }\n }\n return clone || existing;\n };\n}\n","import { ExistingState, NoInfer, StateOperator } from './types';\n\nimport { isStateOperator, isPredicate, isNumber, invalidIndex, Predicate } from './utils';\n\n/**\n * @param selector - Index of item in the array or a predicate function\n * that can be provided in `Array.prototype.findIndex`\n * @param operatorOrValue - New value under the `selector` index or a\n * function that can be applied to an existing value\n */\nexport function updateItem<T>(\n selector: number | NoInfer<Predicate<T>>,\n operatorOrValue: NoInfer<T> | NoInfer<StateOperator<T>>\n): StateOperator<T[]> {\n return function updateItemOperator(existing: ExistingState<T[]>): T[] {\n let index = -1;\n\n if (isPredicate(selector)) {\n index = existing.findIndex(selector as Predicate<T>);\n } else if (isNumber(selector)) {\n index = selector;\n }\n\n if (invalidIndex(index)) {\n return existing as T[];\n }\n\n let value: T = null!;\n // Need to check if the new item value will change the existing item value\n // then, only if it will change it then clone the array and set the item\n const theOperatorOrValue = operatorOrValue as T | StateOperator<T>;\n if (isStateOperator(theOperatorOrValue)) {\n value = theOperatorOrValue(existing[index] as ExistingState<T>);\n } else {\n value = theOperatorOrValue;\n }\n\n // If the value hasn't been mutated\n // then we just return `existing` array\n if (value === existing[index]) {\n return existing as T[];\n }\n\n const clone = existing.slice();\n clone[index] = value as T;\n return clone;\n };\n}\n","import { ExistingState, NoInfer, StateOperator } from './types';\nimport { isPredicate, isNumber, invalidIndex, Predicate } from './utils';\n\n/**\n * @param selector - index or predicate to remove an item from an array by\n */\nexport function removeItem<T>(selector: number | NoInfer<Predicate<T>>): StateOperator<T[]> {\n return function removeItemOperator(existing: ExistingState<T[]>): T[] {\n let index = -1;\n\n if (isPredicate(selector)) {\n index = existing.findIndex(selector);\n } else if (isNumber(selector)) {\n index = selector;\n }\n\n if (invalidIndex(index)) {\n return existing as T[];\n }\n\n const clone = existing.slice();\n clone.splice(index, 1);\n return clone;\n };\n}\n","/**\n * @module\n * @description\n * Entry point for all public APIs of this package.\n */\nexport { append } from './append';\nexport { compose } from './compose';\nexport { iif } from './iif';\nexport { insertItem } from './insert-item';\nexport { patch, ɵPatchSpec } from './patch';\nexport { isStateOperator, isPredicate, Predicate } from './utils';\nexport { updateItem } from './update-item';\nexport { removeItem } from './remove-item';\nexport { ExistingState, NoInfer, StateOperator } from './types';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":"AAEA;;AAEG;AACG,SAAU,MAAM,CAAI,KAAmB,EAAA;IAC3C,OAAO,SAAS,cAAc,CAAC,QAA4B,EAAA;;;AAGzD,QAAA,MAAM,6BAA6B,GAAG,CAAC,CAAC,KAAK,IAAI,CAAC,KAAK,CAAC,MAAM,KAAK,QAAQ,CAAC;AAC5E,QAAA,IAAI,6BAA6B,EAAE;AACjC,YAAA,OAAQ,QAA2B,CAAC;AACrC,SAAA;AAED,QAAA,IAAI,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE;AAC3B,YAAA,OAAO,QAAQ,CAAC,MAAM,CAAE,KAAuC,CAAC,CAAC;AAClE,SAAA;;;AAID,QAAA,OAAQ,KAAwB,CAAC;AACnC,KAAC,CAAC;AACJ;;ACpBgB,SAAA,OAAO,CAAI,GAAG,SAA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