@ngxs/store 18.1.6 → 19.0.0
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/experimental/index.d.ts +6 -5
- package/fesm2022/ngxs-store-experimental.mjs +8 -25
- package/fesm2022/ngxs-store-experimental.mjs.map +1 -1
- package/fesm2022/ngxs-store-internals-testing.mjs +8 -9
- package/fesm2022/ngxs-store-internals-testing.mjs.map +1 -1
- package/fesm2022/ngxs-store-internals.mjs +6 -6
- package/fesm2022/ngxs-store-internals.mjs.map +1 -1
- package/fesm2022/ngxs-store-operators.mjs.map +1 -1
- package/fesm2022/ngxs-store-plugins.mjs.map +1 -1
- package/fesm2022/ngxs-store.mjs +101 -72
- package/fesm2022/ngxs-store.mjs.map +1 -1
- package/index.d.ts +11 -1
- package/package.json +2 -14
- package/schematics/src/actions/actions.factory.js +1 -2
- package/schematics/src/actions/actions.factory.js.map +1 -1
- package/schematics/src/ng-add/add-declaration.js +2 -3
- package/schematics/src/ng-add/add-declaration.js.map +1 -1
- package/schematics/src/ng-add/ng-add.factory.js +1 -2
- package/schematics/src/ng-add/ng-add.factory.js.map +1 -1
- package/schematics/src/starter-kit/starter-kit.factory.js +1 -2
- package/schematics/src/starter-kit/starter-kit.factory.js.map +1 -1
- package/schematics/src/state/state.factory.js +1 -2
- package/schematics/src/state/state.factory.js.map +1 -1
- package/schematics/src/store/store.factory.js +1 -2
- package/schematics/src/store/store.factory.js.map +1 -1
- package/schematics/src/utils/common/properties.js +1 -2
- package/schematics/src/utils/common/properties.js.map +1 -1
- package/schematics/src/utils/config.js +2 -3
- package/schematics/src/utils/config.js.map +1 -1
- package/schematics/src/utils/generate-utils.js +1 -2
- package/schematics/src/utils/generate-utils.js.map +1 -1
- package/schematics/src/utils/normalize-options.js +3 -4
- package/schematics/src/utils/normalize-options.js.map +1 -1
- package/schematics/src/utils/project.js +4 -5
- package/schematics/src/utils/project.js.map +1 -1
- package/schematics/src/utils/versions.json +1 -1
- package/esm2022/experimental/index.mjs +0 -2
- package/esm2022/experimental/ngxs-store-experimental.mjs +0 -5
- package/esm2022/experimental/pending-tasks.mjs +0 -30
- package/esm2022/index.mjs +0 -13
- package/esm2022/internals/custom-rxjs-operators.mjs +0 -19
- package/esm2022/internals/custom-rxjs-subjects.mjs +0 -92
- package/esm2022/internals/index.mjs +0 -11
- package/esm2022/internals/initial-state.mjs +0 -17
- package/esm2022/internals/internal-tokens.mjs +0 -5
- package/esm2022/internals/memoize.mjs +0 -43
- package/esm2022/internals/metadata.mjs +0 -57
- package/esm2022/internals/ngxs-app-bootstrapped-state.mjs +0 -19
- package/esm2022/internals/ngxs-store-internals.mjs +0 -5
- package/esm2022/internals/state-stream.mjs +0 -33
- package/esm2022/internals/state-token.mjs +0 -17
- package/esm2022/internals/symbols.mjs +0 -11
- package/esm2022/internals/testing/fresh-platform.mjs +0 -72
- package/esm2022/internals/testing/helpers/ngxs-test.component.mjs +0 -16
- package/esm2022/internals/testing/helpers/ngxs-test.module.mjs +0 -20
- package/esm2022/internals/testing/index.mjs +0 -4
- package/esm2022/internals/testing/ngxs-store-internals-testing.mjs +0 -5
- package/esm2022/internals/testing/ngxs.setup.mjs +0 -49
- package/esm2022/internals/testing/skip-console-logging.mjs +0 -37
- package/esm2022/internals/testing/symbol.mjs +0 -2
- package/esm2022/ngxs-store.mjs +0 -5
- package/esm2022/operators/append.mjs +0 -20
- package/esm2022/operators/compose.mjs +0 -6
- package/esm2022/operators/iif.mjs +0 -38
- package/esm2022/operators/index.mjs +0 -14
- package/esm2022/operators/insert-item.mjs +0 -29
- package/esm2022/operators/ngxs-store-operators.mjs +0 -5
- package/esm2022/operators/patch.mjs +0 -21
- package/esm2022/operators/remove-item.mjs +0 -22
- package/esm2022/operators/types.mjs +0 -2
- package/esm2022/operators/update-item.mjs +0 -40
- package/esm2022/operators/utils.mjs +0 -19
- package/esm2022/plugins/actions.mjs +0 -16
- package/esm2022/plugins/index.mjs +0 -4
- package/esm2022/plugins/ngxs-store-plugins.mjs +0 -5
- package/esm2022/plugins/symbols.mjs +0 -15
- package/esm2022/plugins/utils.mjs +0 -51
- package/esm2022/src/actions/action-registry.mjs +0 -34
- package/esm2022/src/actions/symbols.mjs +0 -2
- package/esm2022/src/actions-stream.mjs +0 -61
- package/esm2022/src/configs/messages.config.mjs +0 -48
- package/esm2022/src/decorators/action.mjs +0 -31
- package/esm2022/src/decorators/select/select-factory.mjs +0 -29
- package/esm2022/src/decorators/select/select.mjs +0 -29
- package/esm2022/src/decorators/select/symbols.mjs +0 -29
- package/esm2022/src/decorators/selector/selector.mjs +0 -29
- package/esm2022/src/decorators/selector/symbols.mjs +0 -2
- package/esm2022/src/decorators/selector-options.mjs +0 -21
- package/esm2022/src/decorators/state.mjs +0 -35
- package/esm2022/src/dev-features/ngxs-development.module.mjs +0 -28
- package/esm2022/src/dev-features/ngxs-unhandled-actions-logger.mjs +0 -43
- package/esm2022/src/dev-features/symbols.mjs +0 -7
- package/esm2022/src/execution/dispatch-outside-zone-ngxs-execution-strategy.mjs +0 -52
- package/esm2022/src/execution/internal-ngxs-execution-strategy.mjs +0 -21
- package/esm2022/src/execution/noop-ngxs-execution-strategy.mjs +0 -17
- package/esm2022/src/execution/symbols.mjs +0 -28
- package/esm2022/src/internal/dispatcher.mjs +0 -125
- package/esm2022/src/internal/fallback-subscriber.mjs +0 -29
- package/esm2022/src/internal/internals.mjs +0 -205
- package/esm2022/src/internal/lifecycle-state-manager.mjs +0 -81
- package/esm2022/src/internal/provide-internal-tokens.mjs +0 -20
- package/esm2022/src/internal/state-context-factory.mjs +0 -70
- package/esm2022/src/internal/state-factory.mjs +0 -311
- package/esm2022/src/internal/state-operations.mjs +0 -60
- package/esm2022/src/internal/state-operators.mjs +0 -20
- package/esm2022/src/internal/unhandled-rxjs-error-callback.mjs +0 -46
- package/esm2022/src/ivy/ivy-enabled-in-dev-mode.mjs +0 -25
- package/esm2022/src/module.mjs +0 -27
- package/esm2022/src/modules/ngxs-feature.module.mjs +0 -18
- package/esm2022/src/modules/ngxs-root.module.mjs +0 -18
- package/esm2022/src/ngxs-unhandled-error-handler.mjs +0 -29
- package/esm2022/src/operators/leave-ngxs.mjs +0 -9
- package/esm2022/src/operators/of-action.mjs +0 -104
- package/esm2022/src/plugin-manager.mjs +0 -34
- package/esm2022/src/plugin_api.mjs +0 -2
- package/esm2022/src/private_api.mjs +0 -5
- package/esm2022/src/public_api.mjs +0 -20
- package/esm2022/src/selectors/create-model-selector.mjs +0 -30
- package/esm2022/src/selectors/create-pick-selector.mjs +0 -16
- package/esm2022/src/selectors/create-property-selectors.mjs +0 -20
- package/esm2022/src/selectors/create-selector.mjs +0 -9
- package/esm2022/src/selectors/index.mjs +0 -6
- package/esm2022/src/selectors/private_api.mjs +0 -2
- package/esm2022/src/selectors/selector-checks.util.mjs +0 -43
- package/esm2022/src/selectors/selector-metadata.mjs +0 -35
- package/esm2022/src/selectors/selector-models.mjs +0 -2
- package/esm2022/src/selectors/selector-types.util.mjs +0 -2
- package/esm2022/src/selectors/selector-utils.mjs +0 -95
- package/esm2022/src/standalone-features/feature-providers.mjs +0 -18
- package/esm2022/src/standalone-features/index.mjs +0 -5
- package/esm2022/src/standalone-features/initializers.mjs +0 -94
- package/esm2022/src/standalone-features/plugin.mjs +0 -33
- package/esm2022/src/standalone-features/preboot.mjs +0 -31
- package/esm2022/src/standalone-features/provide-states.mjs +0 -26
- package/esm2022/src/standalone-features/provide-store.mjs +0 -26
- package/esm2022/src/standalone-features/root-providers.mjs +0 -34
- package/esm2022/src/store.mjs +0 -117
- package/esm2022/src/symbols.mjs +0 -86
- package/esm2022/src/utils/create-dispatch-map.mjs +0 -11
- package/esm2022/src/utils/create-select-map.mjs +0 -13
- package/esm2022/src/utils/dispatch.mjs +0 -7
- package/esm2022/src/utils/freeze.mjs +0 -20
- package/esm2022/src/utils/public_api.mjs +0 -5
- package/esm2022/src/utils/select.mjs +0 -19
- package/esm2022/src/utils/store-validators.mjs +0 -25
package/experimental/index.d.ts
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import * as _angular_core from '@angular/core';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* This
|
|
4
|
+
* Required for correct functioning of SSR apps.
|
|
5
|
+
*
|
|
6
|
+
* @deprecated
|
|
7
|
+
* This experimental export is deprecated in favour of the non-experimental export.
|
|
8
|
+
* This is no longer an experimental feature, but is now available as
|
|
9
|
+
* `withNgxsPendingTasks` in the main `@ngxs/store` package.
|
|
9
10
|
*/
|
|
10
11
|
declare function withExperimentalNgxsPendingTasks(): _angular_core.EnvironmentProviders;
|
|
11
12
|
|
|
@@ -1,32 +1,15 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { withNgxsPreboot, Actions } from '@ngxs/store';
|
|
1
|
+
import { withNgxsPendingTasks } from '@ngxs/store';
|
|
3
2
|
|
|
4
3
|
/**
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
* This
|
|
4
|
+
* Required for correct functioning of SSR apps.
|
|
5
|
+
*
|
|
6
|
+
* @deprecated
|
|
7
|
+
* This experimental export is deprecated in favour of the non-experimental export.
|
|
8
|
+
* This is no longer an experimental feature, but is now available as
|
|
9
|
+
* `withNgxsPendingTasks` in the main `@ngxs/store` package.
|
|
10
10
|
*/
|
|
11
11
|
function withExperimentalNgxsPendingTasks() {
|
|
12
|
-
return
|
|
13
|
-
const pendingTasks = inject(ExperimentalPendingTasks);
|
|
14
|
-
const actions$ = inject(Actions);
|
|
15
|
-
const actionToRemoveTaskFnMap = new Map();
|
|
16
|
-
actions$.subscribe(ctx => {
|
|
17
|
-
if (ctx.status === "DISPATCHED" /* ActionStatus.Dispatched */) {
|
|
18
|
-
const removeTaskFn = pendingTasks.add();
|
|
19
|
-
actionToRemoveTaskFnMap.set(ctx.action, removeTaskFn);
|
|
20
|
-
}
|
|
21
|
-
else {
|
|
22
|
-
const removeTaskFn = actionToRemoveTaskFnMap.get(ctx.action);
|
|
23
|
-
if (typeof removeTaskFn === 'function') {
|
|
24
|
-
removeTaskFn();
|
|
25
|
-
actionToRemoveTaskFnMap.delete(ctx.action);
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
});
|
|
29
|
-
});
|
|
12
|
+
return withNgxsPendingTasks();
|
|
30
13
|
}
|
|
31
14
|
|
|
32
15
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ngxs-store-experimental.mjs","sources":["../../../packages/store/experimental/src/
|
|
1
|
+
{"version":3,"file":"ngxs-store-experimental.mjs","sources":["../../../packages/store/experimental/src/index.ts","../../../packages/store/experimental/src/ngxs-store-experimental.ts"],"sourcesContent":["import { withNgxsPendingTasks } from '@ngxs/store';\n\n/**\n * Required for correct functioning of SSR apps.\n *\n * @deprecated\n * This experimental export is deprecated in favour of the non-experimental export.\n * This is no longer an experimental feature, but is now available as\n * `withNgxsPendingTasks` in the main `@ngxs/store` package.\n */\nexport function withExperimentalNgxsPendingTasks() {\n return withNgxsPendingTasks();\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;AAEA;;;;;;;AAOG;SACa,gCAAgC,GAAA;IAC9C,OAAO,oBAAoB,EAAE;AAC/B;;ACZA;;AAEG;;;;"}
|
|
@@ -77,10 +77,10 @@ function freshPlatform(fn) {
|
|
|
77
77
|
class NgxsTestComponent {
|
|
78
78
|
ngOnInit() { }
|
|
79
79
|
ngAfterViewInit() { }
|
|
80
|
-
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
81
|
-
/** @nocollapse */ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "
|
|
80
|
+
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.0", ngImport: i0, type: NgxsTestComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
81
|
+
/** @nocollapse */ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "19.0.0", type: NgxsTestComponent, isStandalone: true, selector: "app-root", ngImport: i0, template: '', isInline: true }); }
|
|
82
82
|
}
|
|
83
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
83
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.0", ngImport: i0, type: NgxsTestComponent, decorators: [{
|
|
84
84
|
type: Component,
|
|
85
85
|
args: [{
|
|
86
86
|
selector: 'app-root',
|
|
@@ -92,15 +92,14 @@ class NgxsTestModule {
|
|
|
92
92
|
static ngDoBootstrap(app) {
|
|
93
93
|
app.bootstrap(NgxsTestComponent);
|
|
94
94
|
}
|
|
95
|
-
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
96
|
-
/** @nocollapse */ static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "
|
|
97
|
-
/** @nocollapse */ static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "
|
|
95
|
+
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.0", ngImport: i0, type: NgxsTestModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
|
|
96
|
+
/** @nocollapse */ static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "19.0.0", ngImport: i0, type: NgxsTestModule, imports: [BrowserModule, NgxsTestComponent] }); }
|
|
97
|
+
/** @nocollapse */ static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "19.0.0", ngImport: i0, type: NgxsTestModule, imports: [BrowserModule] }); }
|
|
98
98
|
}
|
|
99
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
99
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.0", ngImport: i0, type: NgxsTestModule, decorators: [{
|
|
100
100
|
type: NgModule,
|
|
101
101
|
args: [{
|
|
102
|
-
imports: [BrowserModule]
|
|
103
|
-
declarations: [NgxsTestComponent]
|
|
102
|
+
imports: [BrowserModule, NgxsTestComponent]
|
|
104
103
|
}]
|
|
105
104
|
}] });
|
|
106
105
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ngxs-store-internals-testing.mjs","sources":["../../../packages/store/internals/testing/src/fresh-platform.ts","../../../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/skip-console-logging.ts","../../../packages/store/internals/testing/src/ngxs.setup.ts","../../../packages/store/internals/testing/src/ngxs-store-internals-testing.ts"],"sourcesContent":["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","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","export type ConsoleRecord = [string, any[]];\nexport type ConsoleRecorder = ConsoleRecord[];\n\nexport function loggedError(message: string): ConsoleRecord {\n return ['error', [expect.objectContaining({ message })]];\n}\n\nexport function skipConsoleLogging<T extends (...args: any[]) => any>(\n fn: T,\n consoleRecorder: ConsoleRecorder = []\n): ReturnType<T> {\n const consoleSpies = [\n jest.spyOn(console, 'log').mockImplementation((...args) => {\n consoleRecorder.push(['log', args]);\n }),\n jest.spyOn(console, 'warn').mockImplementation((...args) => {\n consoleRecorder.push(['warn', args]);\n }),\n jest.spyOn(console, 'error').mockImplementation((...args) => {\n consoleRecorder.push(['error', args]);\n }),\n jest.spyOn(console, 'info').mockImplementation((...args) => {\n consoleRecorder.push(['info', args]);\n })\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","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';\nimport { skipConsoleLogging } from './skip-console-logging';\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 skipConsoleLogging(() =>\n TestBed.configureTestingModule({\n imports: [\n NgxsTestModule,\n NgxsModule.forRoot(options.states || [], options.ngxsOptions || {}),\n ...(options.imports || [])\n ]\n }).compileComponents()\n );\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","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":["getDOM","BrowserDomAdapter"],"mappings":";;;;;;;;AAKA,SAAS,iBAAiB,GAAA;IACxB,MAAM,QAAQ,GAAG,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;IAC1C,MAAM,IAAI,GAAGA,OAAM,EAAE,CAAC,aAAa,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC;AAC1D,IAAA,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;AAClC,CAAC;AAED,SAAS,iBAAiB,GAAA;AACxB,IAAA,MAAM,IAAI,GAAY,QAAQ,CAAC,oBAAoB,CAAC,UAAU,CAAC,CAAC,IAAI,CAAC,CAAC,CAAE,CAAC;AACzE,IAAA,IAAI;AACF,QAAA,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;KACjC;IAAC,MAAM,GAAE;AACZ,CAAC;AAED,SAAS,2CAA2C,CAAC,QAAgB,EAAA;AACnE,IAAA,eAAe,EAAE,CAAC;IAClB,kBAAkB,CAAC,QAAQ,CAAC,CAAC;AAC7B,IAAA,iBAAiB,EAAE,CAAC;AACtB,CAAC;AAED;AACA;AACA;AACA,SAAS,+BAA+B,GAAA;AACtC,IAAA,iBAAiB,EAAE,CAAC;AACpB,IAAA,eAAe,EAAE,CAAC;AAClB,IAAA,MAAM,OAAO,GAAG,CAAC,OAAO,CAAC,KAAK,CAAC;;AAE/B,IAAA,IAAI,OAAO,GAAG,EAAE,EAAE;QAChB,cAAc,CAAC,OAAO,CAAC,CAAC;KACzB;AACH,CAAC;AAED,SAAS,kBAAkB,CAAC,QAAgB,EAAA;IAC1C,MAAM,CAAC,OAAO,CAAC,YAAY,CAAC,EAAE,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAC;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C,QAAQ,CAAC,CAAC;AAC1C,QAAA,MAAM,OAAO,GAAG,IAAIC,kBAAiB,EAAE,CAAC;QACxC,MAAM,IAAI,GAAG,OAAO,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC;AAC7C,QAAA,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;KACjC;AACF;;AC9DD;;AAEG;;;;"}
|
|
1
|
+
{"version":3,"file":"ngxs-store-internals-testing.mjs","sources":["../../../packages/store/internals/testing/src/fresh-platform.ts","../../../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/skip-console-logging.ts","../../../packages/store/internals/testing/src/ngxs.setup.ts","../../../packages/store/internals/testing/src/ngxs-store-internals-testing.ts"],"sourcesContent":["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","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, NgxsTestComponent]\n})\nexport class NgxsTestModule {\n public static ngDoBootstrap(app: ApplicationRef): void {\n app.bootstrap(NgxsTestComponent);\n }\n}\n","export type ConsoleRecord = [string, any[]];\nexport type ConsoleRecorder = ConsoleRecord[];\n\nexport function loggedError(message: string): ConsoleRecord {\n return ['error', [expect.objectContaining({ message })]];\n}\n\nexport function skipConsoleLogging<T extends (...args: any[]) => any>(\n fn: T,\n consoleRecorder: ConsoleRecorder = []\n): ReturnType<T> {\n const consoleSpies = [\n jest.spyOn(console, 'log').mockImplementation((...args) => {\n consoleRecorder.push(['log', args]);\n }),\n jest.spyOn(console, 'warn').mockImplementation((...args) => {\n consoleRecorder.push(['warn', args]);\n }),\n jest.spyOn(console, 'error').mockImplementation((...args) => {\n consoleRecorder.push(['error', args]);\n }),\n jest.spyOn(console, 'info').mockImplementation((...args) => {\n consoleRecorder.push(['info', args]);\n })\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","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';\nimport { skipConsoleLogging } from './skip-console-logging';\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 skipConsoleLogging(() =>\n TestBed.configureTestingModule({\n imports: [\n NgxsTestModule,\n NgxsModule.forRoot(options.states || [], options.ngxsOptions || {}),\n ...(options.imports || [])\n ]\n }).compileComponents()\n );\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","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":["getDOM","BrowserDomAdapter"],"mappings":";;;;;;;;AAKA,SAAS,iBAAiB,GAAA;IACxB,MAAM,QAAQ,GAAG,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC;IACzC,MAAM,IAAI,GAAGA,OAAM,EAAE,CAAC,aAAa,CAAC,UAAU,EAAE,QAAQ,CAAC;AACzD,IAAA,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC;AACjC;AAEA,SAAS,iBAAiB,GAAA;AACxB,IAAA,MAAM,IAAI,GAAY,QAAQ,CAAC,oBAAoB,CAAC,UAAU,CAAC,CAAC,IAAI,CAAC,CAAC,CAAE;AACxE,IAAA,IAAI;AACF,QAAA,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC;;IAC/B,MAAM;AACV;AAEA,SAAS,2CAA2C,CAAC,QAAgB,EAAA;AACnE,IAAA,eAAe,EAAE;IACjB,kBAAkB,CAAC,QAAQ,CAAC;AAC5B,IAAA,iBAAiB,EAAE;AACrB;AAEA;AACA;AACA;AACA,SAAS,+BAA+B,GAAA;AACtC,IAAA,iBAAiB,EAAE;AACnB,IAAA,eAAe,EAAE;AACjB,IAAA,MAAM,OAAO,GAAG,CAAC,OAAO,CAAC,KAAK;;AAE9B,IAAA,IAAI,OAAO,GAAG,EAAE,EAAE;QAChB,cAAc,CAAC,OAAO,CAAC;;AAE3B;AAEA,SAAS,kBAAkB,CAAC,QAAgB,EAAA;IAC1C,MAAM,CAAC,OAAO,CAAC,YAAY,CAAC,EAAE,EAAE,MAAM,EAAE,QAAQ,CAAC;AACnD;AAEM,SAAU,aAAa,CAAC,EAA0C,EAAA;IACtE,IAAI,OAAO,GAAwB,IAAI;IACvC,IAAI,MAAM,GAAoC,IAAI;IAClD,IAAI,uBAAuB,GAAyB,IAAI;AAExD,IAAA,MAAM,eAAe,GAAG,EAAE,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YAAA,IAAI,KAAK,GAAA;AACP,gBAAA,OAAO,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC;aAC7B;AACD,YAAA,IAAI,UAAU,GAAA;AACZ,gBAAA,OAAO,OAAO;;SAEjB;;AAGK,IAAA,OAAO,aAAa,GAAA;QAC1B,WAAW,CAAC,cAAc,EAAE;QAC5B,cAAc,CAAC,aAAa,CAAC,OAAO,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC;;AAGtD,IAAA,OAAO,YAAY,GAAA;QACzB,OAAO,CAAC,oBAAoB,EAAE;AAC9B,QAAA,OAAO,CAAC,mBAAmB,CAAC,2BAA2B,EAAE,6BAA6B,EAAE,EAAE;AACxF,YAAA,QAAQ,EAAE,EAAE,gBAAgB,EAAE,IAAI;AACnC,SAAA,CAAC;;AAGI,IAAA,OAAO,cAAc,CAAC,QAAQ,GAAG,UAAU,EAAA;QACjD,MAAM,QAAQ,GAAG,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC;AACzC,QAAA,MAAM,OAAO,GAAG,IAAIC,kBAAiB,EAAE;QACvC,MAAM,IAAI,GAAG,OAAO,CAAC,aAAa,CAAC,QAAQ,CAAC;AAC5C,QAAA,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC;;AAElC;;AC9DD;;AAEG;;;;"}
|
|
@@ -153,10 +153,10 @@ class ɵNgxsAppBootstrappedState extends ReplaySubject {
|
|
|
153
153
|
this.next(true);
|
|
154
154
|
this.complete();
|
|
155
155
|
}
|
|
156
|
-
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
157
|
-
/** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "
|
|
156
|
+
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.0", ngImport: i0, type: ɵNgxsAppBootstrappedState, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
157
|
+
/** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.0.0", ngImport: i0, type: ɵNgxsAppBootstrappedState, providedIn: 'root' }); }
|
|
158
158
|
}
|
|
159
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
159
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.0", ngImport: i0, type: ɵNgxsAppBootstrappedState, decorators: [{
|
|
160
160
|
type: Injectable,
|
|
161
161
|
args: [{ providedIn: 'root' }]
|
|
162
162
|
}], ctorParameters: () => [] });
|
|
@@ -294,10 +294,10 @@ class ɵStateStream extends ɵOrderedBehaviorSubject {
|
|
|
294
294
|
// or `store.subscribe`, it can result in significant memory leaks in SSR apps.
|
|
295
295
|
this.complete();
|
|
296
296
|
}
|
|
297
|
-
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
298
|
-
/** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "
|
|
297
|
+
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.0", ngImport: i0, type: ɵStateStream, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
298
|
+
/** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.0.0", ngImport: i0, type: ɵStateStream, providedIn: 'root' }); }
|
|
299
299
|
}
|
|
300
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
300
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.0", ngImport: i0, type: ɵStateStream, decorators: [{
|
|
301
301
|
type: Injectable,
|
|
302
302
|
args: [{ providedIn: 'root' }]
|
|
303
303
|
}], ctorParameters: () => [] });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ngxs-store-internals.mjs","sources":["../../../packages/store/internals/src/symbols.ts","../../../packages/store/internals/src/metadata.ts","../../../packages/store/internals/src/memoize.ts","../../../packages/store/internals/src/state-token.ts","../../../packages/store/internals/src/initial-state.ts","../../../packages/store/internals/src/ngxs-app-bootstrapped-state.ts","../../../packages/store/internals/src/internal-tokens.ts","../../../packages/store/internals/src/custom-rxjs-subjects.ts","../../../packages/store/internals/src/custom-rxjs-operators.ts","../../../packages/store/internals/src/state-stream.ts","../../../packages/store/internals/src/ngxs-store-internals.ts"],"sourcesContent":["import type { StateToken } from './state-token';\n\nexport interface ɵPlainObject {\n [key: string]: any;\n}\n\nexport interface ɵPlainObjectOf<T> {\n [key: string]: T;\n}\n\nexport type ɵStateClass<T = any> = new (...args: any[]) => T;\n\n// This key is used to store metadata on state classes,\n// such as actions and other related information.\nexport const ɵMETA_KEY = 'NGXS_META';\n// This key is used to store options on state classes\n// provided through the `@State` decorator.\nexport const ɵMETA_OPTIONS_KEY = 'NGXS_OPTIONS_META';\n// This key is used to store selector metadata on selector functions,\n// such as decorated with the `@Selector` or provided through the\n// `createSelector` function.\nexport const ɵSELECTOR_META_KEY = 'NGXS_SELECTOR_META';\n\nexport interface ɵStateToken<T, U> {\n new (name: ɵTokenName<T>): U;\n getName(): string;\n toString(): string;\n}\n\ntype RequireGeneric<T, U> = T extends void ? 'You must provide a type parameter' : U;\n\nexport type ɵTokenName<T> = string & RequireGeneric<T, string>;\n\nexport type ɵExtractTokenType<P> = P extends StateToken<infer T> ? T : never;\n\n/**\n * Options that can be provided to the store.\n */\nexport interface ɵStoreOptions<T> {\n /**\n * Name of the state. Required.\n */\n name: string | StateToken<T>;\n\n /**\n * Default values for the state. If not provided, uses empty object.\n */\n defaults?: T;\n\n /**\n * Sub states for the given state.\n *\n * @deprecated\n * Read the deprecation notice at this link: https://ngxs.io/deprecations/sub-states-deprecation.\n */\n children?: ɵStateClass[];\n}\n\n// inspired from https://stackoverflow.com/a/43674389\nexport interface ɵStateClassInternal<T = any, U = any> extends ɵStateClass<T> {\n [ɵMETA_KEY]?: ɵMetaDataModel;\n [ɵMETA_OPTIONS_KEY]?: ɵStoreOptions<U>;\n}\n\nexport interface ɵMetaDataModel {\n name: string | null;\n actions: ɵPlainObjectOf<ɵActionHandlerMetaData[]>;\n defaults: any;\n path: string | null;\n makeRootSelector: ɵSelectorFactory | null;\n /** @deprecated */\n children?: ɵStateClassInternal[];\n}\n\nexport interface ɵSelectorMetaDataModel {\n makeRootSelector: ɵSelectorFactory | null;\n originalFn: Function | null;\n containerClass: any;\n selectorName: string | null;\n getSelectorOptions: () => ɵSharedSelectorOptions;\n}\n\nexport interface ɵSharedSelectorOptions {\n /**\n * @deprecated\n * Read the deprecation notice at this link: https://ngxs.io/deprecations/inject-container-state-deprecation.md.\n */\n injectContainerState?: boolean;\n suppressErrors?: boolean;\n}\n\nexport interface ɵRuntimeSelectorContext {\n getStateGetter(key: any): (state: any) => any;\n getSelectorOptions(localOptions?: ɵSharedSelectorOptions): ɵSharedSelectorOptions;\n}\n\nexport type ɵSelectFromRootState = (rootState: any) => any;\nexport type ɵSelectorFactory = (\n runtimeContext: ɵRuntimeSelectorContext\n) => ɵSelectFromRootState;\n\n/**\n * Actions that can be provided in a action decorator.\n */\nexport interface ɵActionOptions {\n /**\n * Cancel the previous uncompleted observable(s).\n */\n cancelUncompleted?: boolean;\n}\n\nexport interface ɵActionHandlerMetaData {\n fn: string | symbol;\n options: ɵActionOptions;\n type: string;\n}\n","import {\n ɵMETA_KEY,\n ɵSELECTOR_META_KEY,\n ɵMetaDataModel,\n ɵStateClassInternal,\n ɵSelectorMetaDataModel,\n ɵRuntimeSelectorContext\n} from './symbols';\n\n/**\n * Ensures metadata is attached to the class and returns it.\n *\n * @ignore\n */\nexport function ɵensureStoreMetadata(target: ɵStateClassInternal): ɵMetaDataModel {\n if (!target.hasOwnProperty(ɵMETA_KEY)) {\n const defaultMetadata: ɵMetaDataModel = {\n name: null,\n actions: {},\n defaults: {},\n path: null,\n makeRootSelector(context: ɵRuntimeSelectorContext) {\n return context.getStateGetter(defaultMetadata.name);\n },\n children: []\n };\n\n Object.defineProperty(target, ɵMETA_KEY, { value: defaultMetadata });\n }\n return ɵgetStoreMetadata(target);\n}\n\n/**\n * Get the metadata attached to the state class if it exists.\n *\n * @ignore\n */\nexport function ɵgetStoreMetadata(target: ɵStateClassInternal): ɵMetaDataModel {\n return target[ɵMETA_KEY]!;\n}\n\n/**\n * Ensures metadata is attached to the selector and returns it.\n *\n * @ignore\n */\nexport function ɵensureSelectorMetadata(target: Function): ɵSelectorMetaDataModel {\n if (!target.hasOwnProperty(ɵSELECTOR_META_KEY)) {\n const defaultMetadata: ɵSelectorMetaDataModel = {\n makeRootSelector: null,\n originalFn: null,\n containerClass: null,\n selectorName: null,\n getSelectorOptions: () => ({})\n };\n\n Object.defineProperty(target, ɵSELECTOR_META_KEY, { value: defaultMetadata });\n }\n\n return ɵgetSelectorMetadata(target);\n}\n\n/**\n * Get the metadata attached to the selector if it exists.\n *\n * @ignore\n */\nexport function ɵgetSelectorMetadata(target: any): ɵSelectorMetaDataModel {\n return target[ɵSELECTOR_META_KEY];\n}\n","function 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\n // 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 = Object.is\n): T {\n let lastArgs: IArguments | null = null;\n let lastResult: any = null;\n // we reference arguments instead of spreading them for performance reasons\n function memoized() {\n // eslint-disable-next-line prefer-rest-params\n if (!areArgumentsShallowlyEqual(equalityCheck, lastArgs, arguments)) {\n // apply arguments instead of spreading for performance.\n // eslint-disable-next-line prefer-rest-params, prefer-spread\n lastResult = (<Function>func).apply(null, arguments);\n }\n // eslint-disable-next-line prefer-rest-params\n lastArgs = arguments;\n return lastResult;\n }\n (<any>memoized).reset = function () {\n // The hidden (for now) ability to reset the memoization\n lastArgs = null;\n lastResult = null;\n };\n return memoized as T;\n}\n","import { ɵensureSelectorMetadata } from './metadata';\nimport type { ɵTokenName, ɵSelectFromRootState, ɵRuntimeSelectorContext } from './symbols';\n\nexport class StateToken<T = void> {\n constructor(private readonly _name: ɵTokenName<T>) {\n const selectorMetadata = ɵensureSelectorMetadata(<any>this);\n selectorMetadata.makeRootSelector = (\n runtimeContext: ɵRuntimeSelectorContext\n ): ɵSelectFromRootState => {\n return runtimeContext.getStateGetter(this._name);\n };\n }\n\n getName(): string {\n return this._name;\n }\n\n toString(): string {\n return `StateToken[${this._name}]`;\n }\n}\n","import { InjectionToken } from '@angular/core';\n\nimport { ɵPlainObject } from './symbols';\n\ndeclare const ngDevMode: boolean;\n\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 typeof ngDevMode !== 'undefined' && ngDevMode ? 'INITIAL_STATE_TOKEN' : '',\n {\n providedIn: 'root',\n factory: () => ɵInitialState.pop()\n }\n);\n","import { Injectable } from '@angular/core';\nimport { ReplaySubject } from 'rxjs';\n\n@Injectable({ providedIn: 'root' })\nexport class ɵNgxsAppBootstrappedState extends ReplaySubject<boolean> {\n constructor() {\n super(1);\n }\n\n bootstrap(): void {\n this.next(true);\n this.complete();\n }\n}\n","import { InjectionToken } from '@angular/core';\n\ndeclare const ngDevMode: boolean;\n\n// These tokens are internal and can change at any point.\n\nexport const ɵNGXS_STATE_FACTORY = /* @__PURE__ */ new InjectionToken<any>(\n typeof ngDevMode !== 'undefined' && ngDevMode ? 'ɵNGXS_STATE_FACTORY' : ''\n);\n\nexport const ɵNGXS_STATE_CONTEXT_FACTORY = /* @__PURE__ */ new InjectionToken<any>(\n typeof ngDevMode !== 'undefined' && ngDevMode ? 'ɵNGXS_STATE_CONTEXT_FACTORY' : ''\n);\n","import { BehaviorSubject, Subject } from 'rxjs';\n\n/**\n * This wraps the provided function, and will enforce the following:\n * - The calls will execute in the order that they are made\n * - A call will only be initiated when the previous call has completed\n * - If there is a call currently executing then the new call will be added\n * to the queue and the function will return immediately\n *\n * NOTE: The following assumptions about the operation must hold true:\n * - The operation is synchronous in nature\n * - If any asynchronous side effects of the call exist, it should not\n * have any bearing on the correctness of the next call in the queue\n * - The operation has a void return\n * - The caller should not assume that the call has completed upon\n * return of the function\n * - The caller can assume that all the queued calls will complete\n * within the current microtask\n * - The only way that a call will encounter another call in the queue\n * would be if the call at the front of the queue initiated this call\n * as part of its synchronous execution\n */\nfunction orderedQueueOperation<TArgs extends any[]>(operation: (...args: TArgs) => void) {\n const callsQueue: TArgs[] = [];\n let busyPushingNext = false;\n return function callOperation(...args: TArgs) {\n if (busyPushingNext) {\n callsQueue.unshift(args);\n return;\n }\n busyPushingNext = true;\n operation(...args);\n while (callsQueue.length > 0) {\n const nextCallArgs = callsQueue.pop();\n nextCallArgs && operation(...nextCallArgs);\n }\n busyPushingNext = false;\n };\n}\n\n/**\n * Custom Subject that ensures that subscribers are notified of values in the order that they arrived.\n * A standard Subject does not have this guarantee.\n * For example, given the following code:\n * ```typescript\n * const subject = new Subject<string>();\n subject.subscribe(value => {\n if (value === 'start') subject.next('end');\n });\n subject.subscribe(value => { });\n subject.next('start');\n * ```\n * When `subject` is a standard `Subject<T>` the second subscriber would recieve `end` and then `start`.\n * When `subject` is a `OrderedSubject<T>` the second subscriber would recieve `start` and then `end`.\n */\nexport class ɵOrderedSubject<T> extends Subject<T> {\n private _orderedNext = orderedQueueOperation((value?: T) => super.next(<T>value));\n\n next(value?: T): void {\n this._orderedNext(value);\n }\n}\n\n/**\n * Custom BehaviorSubject that ensures that subscribers are notified of values in the order that they arrived.\n * A standard BehaviorSubject does not have this guarantee.\n * For example, given the following code:\n * ```typescript\n * const subject = new BehaviorSubject<string>();\n subject.subscribe(value => {\n if (value === 'start') subject.next('end');\n });\n subject.subscribe(value => { });\n subject.next('start');\n * ```\n * When `subject` is a standard `BehaviorSubject<T>` the second subscriber would recieve `end` and then `start`.\n * When `subject` is a `OrderedBehaviorSubject<T>` the second subscriber would recieve `start` and then `end`.\n */\nexport class ɵOrderedBehaviorSubject<T> extends BehaviorSubject<T> {\n private _orderedNext = orderedQueueOperation((value: T) => super.next(value));\n private _currentValue: T;\n\n constructor(value: T) {\n super(value);\n this._currentValue = value;\n }\n\n getValue(): T {\n return this._currentValue;\n }\n\n next(value: T): void {\n this._currentValue = value;\n this._orderedNext(value);\n }\n}\n","import { MonoTypeOperatorFunction, Observable } from 'rxjs';\n\nexport function ɵwrapObserverCalls<TValue>(\n invokeFn: (fn: () => void) => void\n): MonoTypeOperatorFunction<TValue> {\n return (source: Observable<TValue>) => {\n return new Observable<TValue>(subscriber => {\n return source.subscribe({\n next(value) {\n invokeFn(() => subscriber.next(value));\n },\n error(error) {\n invokeFn(() => subscriber.error(error));\n },\n complete() {\n invokeFn(() => subscriber.complete());\n }\n });\n });\n };\n}\n","import { Injectable, OnDestroy, Signal, untracked } from '@angular/core';\nimport { toSignal } from '@angular/core/rxjs-interop';\n\nimport { ɵwrapObserverCalls } from './custom-rxjs-operators';\nimport { ɵOrderedBehaviorSubject } from './custom-rxjs-subjects';\nimport { ɵPlainObject } from './symbols';\n\n/**\n * BehaviorSubject of the entire state.\n * @ignore\n */\n@Injectable({ providedIn: 'root' })\nexport class ɵStateStream extends ɵOrderedBehaviorSubject<ɵPlainObject> implements OnDestroy {\n readonly state: Signal<ɵPlainObject> = toSignal(this.pipe(ɵwrapObserverCalls(untracked)), {\n manualCleanup: true,\n requireSync: true\n });\n\n constructor() {\n super({});\n }\n\n ngOnDestroy(): void {\n // The StateStream should never emit values once the root view is removed,\n // such as when the `NgModuleRef.destroy()` method is called. This is crucial\n // for preventing memory leaks in server-side rendered apps, where a new StateStream\n // is created for each HTTP request. If users forget to unsubscribe from `store.select`\n // or `store.subscribe`, it can result in significant memory leaks in SSR apps.\n this.complete();\n }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;AAYA;AACA;AACO,MAAM,SAAS,GAAG,YAAY;AACrC;AACA;AACO,MAAM,iBAAiB,GAAG,oBAAoB;AACrD;AACA;AACA;AACO,MAAM,kBAAkB,GAAG;;ACZlC;;;;AAIG;AACG,SAAU,oBAAoB,CAAC,MAA2B,EAAA;IAC9D,IAAI,CAAC,MAAM,CAAC,cAAc,CAAC,SAAS,CAAC,EAAE;AACrC,QAAA,MAAM,eAAe,GAAmB;AACtC,YAAA,IAAI,EAAE,IAAI;AACV,YAAA,OAAO,EAAE,EAAE;AACX,YAAA,QAAQ,EAAE,EAAE;AACZ,YAAA,IAAI,EAAE,IAAI;AACV,YAAA,gBAAgB,CAAC,OAAgC,EAAA;gBAC/C,OAAO,OAAO,CAAC,cAAc,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;aACrD;AACD,YAAA,QAAQ,EAAE,EAAE;SACb,CAAC;AAEF,QAAA,MAAM,CAAC,cAAc,CAAC,MAAM,EAAE,SAAS,EAAE,EAAE,KAAK,EAAE,eAAe,EAAE,CAAC,CAAC;KACtE;AACD,IAAA,OAAO,iBAAiB,CAAC,MAAM,CAAC,CAAC;AACnC,CAAC;AAED;;;;AAIG;AACG,SAAU,iBAAiB,CAAC,MAA2B,EAAA;AAC3D,IAAA,OAAO,MAAM,CAAC,SAAS,CAAE,CAAC;AAC5B,CAAC;AAED;;;;AAIG;AACG,SAAU,uBAAuB,CAAC,MAAgB,EAAA;IACt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,OAAA,EAAA,QAAA,EAAA,QAAA,EAAA,EAAA,EAAA,IAAA,EAAA,YAAY,cADC,MAAM,EAAA,CAAA,CAAA,EAAA;;2FACnB,YAAY,EAAA,UAAA,EAAA,CAAA;kBADxB,UAAU;mBAAC,EAAE,UAAU,EAAE,MAAM,EAAE,CAAA;;;ACXlC;;AAEG;;;;"}
|
|
1
|
+
{"version":3,"file":"ngxs-store-internals.mjs","sources":["../../../packages/store/internals/src/symbols.ts","../../../packages/store/internals/src/metadata.ts","../../../packages/store/internals/src/memoize.ts","../../../packages/store/internals/src/state-token.ts","../../../packages/store/internals/src/initial-state.ts","../../../packages/store/internals/src/ngxs-app-bootstrapped-state.ts","../../../packages/store/internals/src/internal-tokens.ts","../../../packages/store/internals/src/custom-rxjs-subjects.ts","../../../packages/store/internals/src/custom-rxjs-operators.ts","../../../packages/store/internals/src/state-stream.ts","../../../packages/store/internals/src/ngxs-store-internals.ts"],"sourcesContent":["import type { StateToken } from './state-token';\n\nexport interface ɵPlainObject {\n [key: string]: any;\n}\n\nexport interface ɵPlainObjectOf<T> {\n [key: string]: T;\n}\n\nexport type ɵStateClass<T = any> = new (...args: any[]) => T;\n\n// This key is used to store metadata on state classes,\n// such as actions and other related information.\nexport const ɵMETA_KEY = 'NGXS_META';\n// This key is used to store options on state classes\n// provided through the `@State` decorator.\nexport const ɵMETA_OPTIONS_KEY = 'NGXS_OPTIONS_META';\n// This key is used to store selector metadata on selector functions,\n// such as decorated with the `@Selector` or provided through the\n// `createSelector` function.\nexport const ɵSELECTOR_META_KEY = 'NGXS_SELECTOR_META';\n\nexport interface ɵStateToken<T, U> {\n new (name: ɵTokenName<T>): U;\n getName(): string;\n toString(): string;\n}\n\ntype RequireGeneric<T, U> = T extends void ? 'You must provide a type parameter' : U;\n\nexport type ɵTokenName<T> = string & RequireGeneric<T, string>;\n\nexport type ɵExtractTokenType<P> = P extends StateToken<infer T> ? T : never;\n\n/**\n * Options that can be provided to the store.\n */\nexport interface ɵStoreOptions<T> {\n /**\n * Name of the state. Required.\n */\n name: string | StateToken<T>;\n\n /**\n * Default values for the state. If not provided, uses empty object.\n */\n defaults?: T;\n\n /**\n * Sub states for the given state.\n *\n * @deprecated\n * Read the deprecation notice at this link: https://ngxs.io/deprecations/sub-states-deprecation.\n */\n children?: ɵStateClass[];\n}\n\n// inspired from https://stackoverflow.com/a/43674389\nexport interface ɵStateClassInternal<T = any, U = any> extends ɵStateClass<T> {\n [ɵMETA_KEY]?: ɵMetaDataModel;\n [ɵMETA_OPTIONS_KEY]?: ɵStoreOptions<U>;\n}\n\nexport interface ɵMetaDataModel {\n name: string | null;\n actions: ɵPlainObjectOf<ɵActionHandlerMetaData[]>;\n defaults: any;\n path: string | null;\n makeRootSelector: ɵSelectorFactory | null;\n /** @deprecated */\n children?: ɵStateClassInternal[];\n}\n\nexport interface ɵSelectorMetaDataModel {\n makeRootSelector: ɵSelectorFactory | null;\n originalFn: Function | null;\n containerClass: any;\n selectorName: string | null;\n getSelectorOptions: () => ɵSharedSelectorOptions;\n}\n\nexport interface ɵSharedSelectorOptions {\n /**\n * @deprecated\n * Read the deprecation notice at this link: https://ngxs.io/deprecations/inject-container-state-deprecation.md.\n */\n injectContainerState?: boolean;\n suppressErrors?: boolean;\n}\n\nexport interface ɵRuntimeSelectorContext {\n getStateGetter(key: any): (state: any) => any;\n getSelectorOptions(localOptions?: ɵSharedSelectorOptions): ɵSharedSelectorOptions;\n}\n\nexport type ɵSelectFromRootState = (rootState: any) => any;\nexport type ɵSelectorFactory = (\n runtimeContext: ɵRuntimeSelectorContext\n) => ɵSelectFromRootState;\n\n/**\n * Actions that can be provided in a action decorator.\n */\nexport interface ɵActionOptions {\n /**\n * Cancel the previous uncompleted observable(s).\n */\n cancelUncompleted?: boolean;\n}\n\nexport interface ɵActionHandlerMetaData {\n fn: string | symbol;\n options: ɵActionOptions;\n type: string;\n}\n","import {\n ɵMETA_KEY,\n ɵSELECTOR_META_KEY,\n ɵMetaDataModel,\n ɵStateClassInternal,\n ɵSelectorMetaDataModel,\n ɵRuntimeSelectorContext\n} from './symbols';\n\n/**\n * Ensures metadata is attached to the class and returns it.\n *\n * @ignore\n */\nexport function ɵensureStoreMetadata(target: ɵStateClassInternal): ɵMetaDataModel {\n if (!target.hasOwnProperty(ɵMETA_KEY)) {\n const defaultMetadata: ɵMetaDataModel = {\n name: null,\n actions: {},\n defaults: {},\n path: null,\n makeRootSelector(context: ɵRuntimeSelectorContext) {\n return context.getStateGetter(defaultMetadata.name);\n },\n children: []\n };\n\n Object.defineProperty(target, ɵMETA_KEY, { value: defaultMetadata });\n }\n return ɵgetStoreMetadata(target);\n}\n\n/**\n * Get the metadata attached to the state class if it exists.\n *\n * @ignore\n */\nexport function ɵgetStoreMetadata(target: ɵStateClassInternal): ɵMetaDataModel {\n return target[ɵMETA_KEY]!;\n}\n\n/**\n * Ensures metadata is attached to the selector and returns it.\n *\n * @ignore\n */\nexport function ɵensureSelectorMetadata(target: Function): ɵSelectorMetaDataModel {\n if (!target.hasOwnProperty(ɵSELECTOR_META_KEY)) {\n const defaultMetadata: ɵSelectorMetaDataModel = {\n makeRootSelector: null,\n originalFn: null,\n containerClass: null,\n selectorName: null,\n getSelectorOptions: () => ({})\n };\n\n Object.defineProperty(target, ɵSELECTOR_META_KEY, { value: defaultMetadata });\n }\n\n return ɵgetSelectorMetadata(target);\n}\n\n/**\n * Get the metadata attached to the selector if it exists.\n *\n * @ignore\n */\nexport function ɵgetSelectorMetadata(target: any): ɵSelectorMetaDataModel {\n return target[ɵSELECTOR_META_KEY];\n}\n","function 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\n // 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 = Object.is\n): T {\n let lastArgs: IArguments | null = null;\n let lastResult: any = null;\n // we reference arguments instead of spreading them for performance reasons\n function memoized() {\n // eslint-disable-next-line prefer-rest-params\n if (!areArgumentsShallowlyEqual(equalityCheck, lastArgs, arguments)) {\n // apply arguments instead of spreading for performance.\n // eslint-disable-next-line prefer-rest-params, prefer-spread\n lastResult = (<Function>func).apply(null, arguments);\n }\n // eslint-disable-next-line prefer-rest-params\n lastArgs = arguments;\n return lastResult;\n }\n (<any>memoized).reset = function () {\n // The hidden (for now) ability to reset the memoization\n lastArgs = null;\n lastResult = null;\n };\n return memoized as T;\n}\n","import { ɵensureSelectorMetadata } from './metadata';\nimport type { ɵTokenName, ɵSelectFromRootState, ɵRuntimeSelectorContext } from './symbols';\n\nexport class StateToken<T = void> {\n constructor(private readonly _name: ɵTokenName<T>) {\n const selectorMetadata = ɵensureSelectorMetadata(<any>this);\n selectorMetadata.makeRootSelector = (\n runtimeContext: ɵRuntimeSelectorContext\n ): ɵSelectFromRootState => {\n return runtimeContext.getStateGetter(this._name);\n };\n }\n\n getName(): string {\n return this._name;\n }\n\n toString(): string {\n return `StateToken[${this._name}]`;\n }\n}\n","import { InjectionToken } from '@angular/core';\n\nimport { ɵPlainObject } from './symbols';\n\ndeclare const ngDevMode: boolean;\n\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 typeof ngDevMode !== 'undefined' && ngDevMode ? 'INITIAL_STATE_TOKEN' : '',\n {\n providedIn: 'root',\n factory: () => ɵInitialState.pop()\n }\n);\n","import { Injectable } from '@angular/core';\nimport { ReplaySubject } from 'rxjs';\n\n@Injectable({ providedIn: 'root' })\nexport class ɵNgxsAppBootstrappedState extends ReplaySubject<boolean> {\n constructor() {\n super(1);\n }\n\n bootstrap(): void {\n this.next(true);\n this.complete();\n }\n}\n","import { InjectionToken } from '@angular/core';\n\ndeclare const ngDevMode: boolean;\n\n// These tokens are internal and can change at any point.\n\nexport const ɵNGXS_STATE_FACTORY = /* @__PURE__ */ new InjectionToken<any>(\n typeof ngDevMode !== 'undefined' && ngDevMode ? 'ɵNGXS_STATE_FACTORY' : ''\n);\n\nexport const ɵNGXS_STATE_CONTEXT_FACTORY = /* @__PURE__ */ new InjectionToken<any>(\n typeof ngDevMode !== 'undefined' && ngDevMode ? 'ɵNGXS_STATE_CONTEXT_FACTORY' : ''\n);\n","import { BehaviorSubject, Subject } from 'rxjs';\n\n/**\n * This wraps the provided function, and will enforce the following:\n * - The calls will execute in the order that they are made\n * - A call will only be initiated when the previous call has completed\n * - If there is a call currently executing then the new call will be added\n * to the queue and the function will return immediately\n *\n * NOTE: The following assumptions about the operation must hold true:\n * - The operation is synchronous in nature\n * - If any asynchronous side effects of the call exist, it should not\n * have any bearing on the correctness of the next call in the queue\n * - The operation has a void return\n * - The caller should not assume that the call has completed upon\n * return of the function\n * - The caller can assume that all the queued calls will complete\n * within the current microtask\n * - The only way that a call will encounter another call in the queue\n * would be if the call at the front of the queue initiated this call\n * as part of its synchronous execution\n */\nfunction orderedQueueOperation<TArgs extends any[]>(operation: (...args: TArgs) => void) {\n const callsQueue: TArgs[] = [];\n let busyPushingNext = false;\n return function callOperation(...args: TArgs) {\n if (busyPushingNext) {\n callsQueue.unshift(args);\n return;\n }\n busyPushingNext = true;\n operation(...args);\n while (callsQueue.length > 0) {\n const nextCallArgs = callsQueue.pop();\n nextCallArgs && operation(...nextCallArgs);\n }\n busyPushingNext = false;\n };\n}\n\n/**\n * Custom Subject that ensures that subscribers are notified of values in the order that they arrived.\n * A standard Subject does not have this guarantee.\n * For example, given the following code:\n * ```typescript\n * const subject = new Subject<string>();\n subject.subscribe(value => {\n if (value === 'start') subject.next('end');\n });\n subject.subscribe(value => { });\n subject.next('start');\n * ```\n * When `subject` is a standard `Subject<T>` the second subscriber would recieve `end` and then `start`.\n * When `subject` is a `OrderedSubject<T>` the second subscriber would recieve `start` and then `end`.\n */\nexport class ɵOrderedSubject<T> extends Subject<T> {\n private _orderedNext = orderedQueueOperation((value?: T) => super.next(<T>value));\n\n next(value?: T): void {\n this._orderedNext(value);\n }\n}\n\n/**\n * Custom BehaviorSubject that ensures that subscribers are notified of values in the order that they arrived.\n * A standard BehaviorSubject does not have this guarantee.\n * For example, given the following code:\n * ```typescript\n * const subject = new BehaviorSubject<string>();\n subject.subscribe(value => {\n if (value === 'start') subject.next('end');\n });\n subject.subscribe(value => { });\n subject.next('start');\n * ```\n * When `subject` is a standard `BehaviorSubject<T>` the second subscriber would recieve `end` and then `start`.\n * When `subject` is a `OrderedBehaviorSubject<T>` the second subscriber would recieve `start` and then `end`.\n */\nexport class ɵOrderedBehaviorSubject<T> extends BehaviorSubject<T> {\n private _orderedNext = orderedQueueOperation((value: T) => super.next(value));\n private _currentValue: T;\n\n constructor(value: T) {\n super(value);\n this._currentValue = value;\n }\n\n getValue(): T {\n return this._currentValue;\n }\n\n next(value: T): void {\n this._currentValue = value;\n this._orderedNext(value);\n }\n}\n","import { MonoTypeOperatorFunction, Observable } from 'rxjs';\n\nexport function ɵwrapObserverCalls<TValue>(\n invokeFn: (fn: () => void) => void\n): MonoTypeOperatorFunction<TValue> {\n return (source: Observable<TValue>) => {\n return new Observable<TValue>(subscriber => {\n return source.subscribe({\n next(value) {\n invokeFn(() => subscriber.next(value));\n },\n error(error) {\n invokeFn(() => subscriber.error(error));\n },\n complete() {\n invokeFn(() => subscriber.complete());\n }\n });\n });\n };\n}\n","import { Injectable, OnDestroy, Signal, untracked } from '@angular/core';\nimport { toSignal } from '@angular/core/rxjs-interop';\n\nimport { ɵwrapObserverCalls } from './custom-rxjs-operators';\nimport { ɵOrderedBehaviorSubject } from './custom-rxjs-subjects';\nimport { ɵPlainObject } from './symbols';\n\n/**\n * BehaviorSubject of the entire state.\n * @ignore\n */\n@Injectable({ providedIn: 'root' })\nexport class ɵStateStream extends ɵOrderedBehaviorSubject<ɵPlainObject> implements OnDestroy {\n readonly state: Signal<ɵPlainObject> = toSignal(this.pipe(ɵwrapObserverCalls(untracked)), {\n manualCleanup: true,\n requireSync: true\n });\n\n constructor() {\n super({});\n }\n\n ngOnDestroy(): void {\n // The StateStream should never emit values once the root view is removed,\n // such as when the `NgModuleRef.destroy()` method is called. This is crucial\n // for preventing memory leaks in server-side rendered apps, where a new StateStream\n // is created for each HTTP request. If users forget to unsubscribe from `store.select`\n // or `store.subscribe`, it can result in significant memory leaks in SSR apps.\n this.complete();\n }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;AAYA;AACA;AACO,MAAM,SAAS,GAAG;AACzB;AACA;AACO,MAAM,iBAAiB,GAAG;AACjC;AACA;AACA;AACO,MAAM,kBAAkB,GAAG;;ACZlC;;;;AAIG;AACG,SAAU,oBAAoB,CAAC,MAA2B,EAAA;IAC9D,IAAI,CAAC,MAAM,CAAC,cAAc,CAAC,SAAS,CAAC,EAAE;AACrC,QAAA,MAAM,eAAe,GAAmB;AACtC,YAAA,IAAI,EAAE,IAAI;AACV,YAAA,OAAO,EAAE,EAAE;AACX,YAAA,QAAQ,EAAE,EAAE;AACZ,YAAA,IAAI,EAAE,IAAI;AACV,YAAA,gBAAgB,CAAC,OAAgC,EAAA;gBAC/C,OAAO,OAAO,CAAC,cAAc,CAAC,eAAe,CAAC,IAAI,CAAC;aACpD;AACD,YAAA,QAAQ,EAAE;SACX;AAED,QAAA,MAAM,CAAC,cAAc,CAAC,MAAM,EAAE,SAAS,EAAE,EAAE,KAAK,EAAE,eAAe,EAAE,CAAC;;AAEtE,IAAA,OAAO,iBAAiB,CAAC,MAAM,CAAC;AAClC;A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AAI,CAAC,KAAK,EAAA;oBACR,QAAQ,CAAC,MAAM,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;iBACvC;AACD,gBAAA,KAAK,CAAC,KAAK,EAAA;oBACT,QAAQ,CAAC,MAAM,UAAU,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;iBACxC;gBACD,QAAQ,GAAA;oBACN,QAAQ,CAAC,MAAM,UAAU,CAAC,QAAQ,EAAE,CAAC;;AAExC,aAAA,CAAC;AACJ,SAAC,CAAC;AACJ,KAAC;AACH;;ACbA;;;AAGG;AAEG,MAAO,YAAa,SAAQ,uBAAqC,CAAA;AAMrE,IAAA,WAAA,GAAA;QACE,KAAK,CAAC,EAAE,CAAC;AANF,QAAA,IAAA,CAAA,KAAK,GAAyB,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,kBAAkB,CAAC,SAAS,CAAC,CAAC,EAAE;AACxF,YAAA,aAAa,EAAE,IAAI;AACnB,YAAA,WAAW,EAAE;AACd,SAAA,CAAC;;IAMF,WAAW,GAAA;;;;;;QAMT,IAAI,CAAC,QAAQ,EAAE;;iIAhBN,YAAY,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,UAAA,EAAA,CAAA,CAAA;AAAZ,uBAAA,SAAA,IAAA,CAAA,KAAA,GAAA,EAAA,CAAA,qBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,QAAA,EAAA,QAAA,EAAA,EAAA,EAAA,IAAA,EAAA,YAAY,cADC,MAAM,EAAA,CAAA,CAAA;;2FACnB,YAAY,EAAA,UAAA,EAAA,CAAA;kBADxB,UAAU;mBAAC,EAAE,UAAU,EAAE,MAAM,EAAE;;;ACXlC;;AAEG;;;;"}
|
|
@@ -1 +1 @@
|
|
|
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;QAC5E,IAAI,6BAA6B,EAAE;AACjC,YAAA,OAAO,QAA0B,CAAC;SACnC;AAED,QAAA,IAAI,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE;AAC3B,YAAA,OAAO,QAAQ,CAAC,MAAM,CAAC,KAAsC,CAAC,CAAC;SAChE;;;AAID,QAAA,OAAO,KAAuB,CAAC;AACjC,KAAC,CAAC;AACJ;;ACpBgB,SAAA,OAAO,CAAI,GAAG,SAAsC,EAAA;IAClE,OAAO,SAAS,eAAe,CAAC,QAA0B,EAAA;AACxD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AED,QAAA,MAAM,KAAK,GAAG,QAAQ,CAAC,KAAK,EAAE,CAAC;AAC/B,QAAA,KAAK,CAAC,KAAK,CAAC,GAAG,KAAU,CAAC;AAC1B,QAAA,OAAO,KAAK,CAAC;AACf,KAAC,CAAC;AACJ;;AC5CA;;AAEG;AACG,SAAU,UAAU,CAAI,QAAwC,EAAA;IACpE,OAAO,SAAS,kBAAkB,CAAC,QAA4B,EAAA;AAC7D,QAAA,IAAI,KAAK,GAAG,CAAC,CAAC,CAAC;AAEf,QAAA,IAAI,WAAW,CAAC,QAAQ,CAAC,EAAE;AACzB,YAAA,KAAK,GAAG,QAAQ,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC;SACtC;AAAM,aAAA,IAAI,QAAQ,CAAC,QAAQ,CAAC,EAAE;YAC7B,KAAK,GAAG,QAAQ,CAAC;SAClB;AAED,QAAA,IAAI,YAAY,CAAC,KAAK,CAAC,EAAE;AACvB,YAAA,OAAO,QAAe,CAAC;SACxB;AAED,QAAA,MAAM,KAAK,GAAG,QAAQ,CAAC,KAAK,EAAE,CAAC;AAC/B,QAAA,KAAK,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;AACvB,QAAA,OAAO,KAAK,CAAC;AACf,KAAC,CAAC;AACJ;;ACxBA;;;;AAIG;;ACJH;;AAEG;;;;"}
|
|
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;QAC3E,IAAI,6BAA6B,EAAE;AACjC,YAAA,OAAO,QAA0B;;AAGnC,QAAA,IAAI,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE;AAC3B,YAAA,OAAO,QAAQ,CAAC,MAAM,CAAC,KAAsC,CAAC;;;;AAKhE,QAAA,OAAO,KAAuB;AAChC,KAAC;AACH;;ACpBgB,SAAA,OAAO,CAAI,GAAG,SAAsC,EAAA;IAClE,OAAO,SAAS,eAAe,CAAC,QAA0B,EAAA;AACxD,QAAA,OAAO,SAAS,CAAC,MAAM,CACrB,CAAC,WAAW,EAAE,QAAQ,KAAK,QAAQ,CAAC,WAA+B,CAAC,EACpE,QAAa,CACd;AACH,KAAC;AACH;;ACLM,SAAU,eAAe,CAAI,KAA2B,EAAA;AAC5D,IAAA,OAAO,OAAO,KAAK,KAAK,UAAU;AACpC;AAEM,SAAU,WAAW,CAAC,KAAU,EAAA;AACpC,IAAA,OAAO,OAAO,KAAK,KAAK,WAAW;AACrC;AAEM,SAAU,WAAW,CAAI,KAA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A,OAAO,KAAK;AACd,KAAC;AACH;;ACxBA;;;;AAIG;;ACJH;;AAEG;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ngxs-store-plugins.mjs","sources":["../../../packages/store/plugins/src/actions.ts","../../../packages/store/plugins/src/symbols.ts","../../../packages/store/plugins/src/utils.ts","../../../packages/store/plugins/src/ngxs-store-plugins.ts"],"sourcesContent":["import { ɵPlainObject } from '@ngxs/store/internals';\n\n/**\n * Init action\n */\nexport class InitState {\n static readonly type = '@@INIT';\n}\n\n/**\n * Update action\n */\nexport class UpdateState {\n static readonly type = '@@UPDATE_STATE';\n\n constructor(readonly addedStates?: ɵPlainObject) {}\n}\n","import { InjectionToken, Type } from '@angular/core';\n\ndeclare const ngDevMode: boolean;\n\nexport type NgxsNextPluginFn = (state: any, action: any) => any;\n\nexport type NgxsPluginFn = (state: any, action: any, next: NgxsNextPluginFn) => any;\n\n/**\n * Plugin interface\n */\nexport interface NgxsPlugin {\n /**\n * Handle the state/action before its submitted to the state handlers.\n */\n handle(state: any, action: any, next: NgxsNextPluginFn): any;\n}\n\n/**\n * A multi-provider token used to resolve to custom NGXS plugins provided\n * at the root and feature levels through the `{provide}` scheme.\n *\n * @deprecated from v18.0.0, use `withNgxsPlugin` instead.\n */\nexport const NGXS_PLUGINS = /* @__PURE__ */ new InjectionToken<NgxsPlugin[]>(\n typeof ngDevMode !== 'undefined' && ngDevMode ? 'NGXS_PLUGINS' : ''\n);\n\nexport function ɵisPluginClass(\n plugin: Type<NgxsPlugin> | NgxsPluginFn\n): plugin is Type<NgxsPlugin> {\n // Determines whether the provided value is a class rather than a function.\n // If it’s a class, its handle method should be defined on its prototype,\n // as plugins can be either classes or functions.\n return !!plugin.prototype.handle;\n}\n","/**\n * Returns the type from an action instance/class.\n * @ignore\n */\nexport function getActionTypeFromInstance(action: any): string | undefined {\n return action.constructor?.type || action.type;\n}\n\n/**\n * Matches a action\n * @ignore\n */\nexport function actionMatcher(action1: any) {\n const type1 = getActionTypeFromInstance(action1);\n\n return function (action2: any) {\n return type1 === getActionTypeFromInstance(action2);\n };\n}\n\n/**\n * Set a deeply nested value. Example:\n *\n * setValue({ foo: { bar: { eat: false } } },\n * 'foo.bar.eat', true) //=> { foo: { bar: { eat: true } } }\n *\n * While it traverses it also creates new objects from top down.\n *\n * @ignore\n */\nexport const setValue = (obj: any, prop: string, val: any) => {\n obj = { ...obj };\n\n const split = prop.split('.');\n const lastIndex = split.length - 1;\n\n split.reduce((acc, part, index) => {\n if (index === lastIndex) {\n acc[part] = val;\n } else {\n acc[part] = Array.isArray(acc[part]) ? acc[part].slice() : { ...acc[part] };\n }\n\n return acc && acc[part];\n }, obj);\n\n return obj;\n};\n\n/**\n * Get a deeply nested value. Example:\n *\n * getValue({ foo: bar: [] }, 'foo.bar') //=> []\n *\n * @ignore\n */\nexport const getValue = (obj: any, prop: string): any =>\n prop.split('.').reduce((acc: any, part: string) => acc && acc[part], obj);\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;AAEA;;AAEG;MACU,SAAS,CAAA;aACJ,IAAI,CAAA,IAAA,GAAG,QAAQ,CAAC
|
|
1
|
+
{"version":3,"file":"ngxs-store-plugins.mjs","sources":["../../../packages/store/plugins/src/actions.ts","../../../packages/store/plugins/src/symbols.ts","../../../packages/store/plugins/src/utils.ts","../../../packages/store/plugins/src/ngxs-store-plugins.ts"],"sourcesContent":["import { ɵPlainObject } from '@ngxs/store/internals';\n\n/**\n * Init action\n */\nexport class InitState {\n static readonly type = '@@INIT';\n}\n\n/**\n * Update action\n */\nexport class UpdateState {\n static readonly type = '@@UPDATE_STATE';\n\n constructor(readonly addedStates?: ɵPlainObject) {}\n}\n","import { InjectionToken, Type } from '@angular/core';\n\ndeclare const ngDevMode: boolean;\n\nexport type NgxsNextPluginFn = (state: any, action: any) => any;\n\nexport type NgxsPluginFn = (state: any, action: any, next: NgxsNextPluginFn) => any;\n\n/**\n * Plugin interface\n */\nexport interface NgxsPlugin {\n /**\n * Handle the state/action before its submitted to the state handlers.\n */\n handle(state: any, action: any, next: NgxsNextPluginFn): any;\n}\n\n/**\n * A multi-provider token used to resolve to custom NGXS plugins provided\n * at the root and feature levels through the `{provide}` scheme.\n *\n * @deprecated from v18.0.0, use `withNgxsPlugin` instead.\n */\nexport const NGXS_PLUGINS = /* @__PURE__ */ new InjectionToken<NgxsPlugin[]>(\n typeof ngDevMode !== 'undefined' && ngDevMode ? 'NGXS_PLUGINS' : ''\n);\n\nexport function ɵisPluginClass(\n plugin: Type<NgxsPlugin> | NgxsPluginFn\n): plugin is Type<NgxsPlugin> {\n // Determines whether the provided value is a class rather than a function.\n // If it’s a class, its handle method should be defined on its prototype,\n // as plugins can be either classes or functions.\n return !!plugin.prototype.handle;\n}\n","/**\n * Returns the type from an action instance/class.\n * @ignore\n */\nexport function getActionTypeFromInstance(action: any): string | undefined {\n return action.constructor?.type || action.type;\n}\n\n/**\n * Matches a action\n * @ignore\n */\nexport function actionMatcher(action1: any) {\n const type1 = getActionTypeFromInstance(action1);\n\n return function (action2: any) {\n return type1 === getActionTypeFromInstance(action2);\n };\n}\n\n/**\n * Set a deeply nested value. Example:\n *\n * setValue({ foo: { bar: { eat: false } } },\n * 'foo.bar.eat', true) //=> { foo: { bar: { eat: true } } }\n *\n * While it traverses it also creates new objects from top down.\n *\n * @ignore\n */\nexport const setValue = (obj: any, prop: string, val: any) => {\n obj = { ...obj };\n\n const split = prop.split('.');\n const lastIndex = split.length - 1;\n\n split.reduce((acc, part, index) => {\n if (index === lastIndex) {\n acc[part] = val;\n } else {\n acc[part] = Array.isArray(acc[part]) ? acc[part].slice() : { ...acc[part] };\n }\n\n return acc && acc[part];\n }, obj);\n\n return obj;\n};\n\n/**\n * Get a deeply nested value. Example:\n *\n * getValue({ foo: bar: [] }, 'foo.bar') //=> []\n *\n * @ignore\n */\nexport const getValue = (obj: any, prop: string): any =>\n prop.split('.').reduce((acc: any, part: string) => acc && acc[part], obj);\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