@ngxs/store 19.0.0-dev.master-b836d8e → 19.0.0-dev.master-5bb8fb6
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.
|
@@ -4,7 +4,7 @@ import { ɵgetDOM as _getDOM, BrowserModule, ɵBrowserDomAdapter as _BrowserDomA
|
|
|
4
4
|
import * as i0 from '@angular/core';
|
|
5
5
|
import { destroyPlatform, VERSION, createPlatform, Component, NgModule, ApplicationRef } from '@angular/core';
|
|
6
6
|
import { BrowserDynamicTestingModule, platformBrowserDynamicTesting } from '@angular/platform-browser-dynamic/testing';
|
|
7
|
-
import { NgxsModule, Store } from '@ngxs/store';
|
|
7
|
+
import { NgxsModule, DispatchOutsideZoneNgxsExecutionStrategy, Store } from '@ngxs/store';
|
|
8
8
|
|
|
9
9
|
function createRootElement() {
|
|
10
10
|
const document = TestBed.inject(DOCUMENT);
|
|
@@ -149,7 +149,9 @@ class NgxsTestBed {
|
|
|
149
149
|
skipConsoleLogging(() => TestBed.configureTestingModule({
|
|
150
150
|
imports: [
|
|
151
151
|
NgxsTestModule,
|
|
152
|
-
NgxsModule.forRoot(options.states || [], options.ngxsOptions || {
|
|
152
|
+
NgxsModule.forRoot(options.states || [], options.ngxsOptions || {
|
|
153
|
+
executionStrategy: DispatchOutsideZoneNgxsExecutionStrategy
|
|
154
|
+
}),
|
|
153
155
|
...(options.imports || [])
|
|
154
156
|
]
|
|
155
157
|
}).compileComponents());
|
|
@@ -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, 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,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AAA;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;;;;"}
|
|
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 { DispatchOutsideZoneNgxsExecutionStrategy, 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(\n options.states || [],\n options.ngxsOptions || {\n executionStrategy: DispatchOutsideZoneNgxsExecutionStrategy\n }\n ),\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;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OAAO,CAAC,OAAO,IAAI,EAAE;AAC1B;AACF,SAAA,CAAC,CAAC,iBAAiB,EAAE,CACvB;QAED,WAAW,CAAC,aAAa,EAAE;QAE3B,OAAO;AACL,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;;ACnED;;AAEG;;;;"}
|
package/fesm2022/ngxs-store.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
|
-
import {
|
|
2
|
+
import { inject, Injectable, InjectionToken, DestroyRef, NgZone, Injector, runInInjectionContext, ErrorHandler, ɵisPromise as _isPromise, computed, makeEnvironmentProviders, provideEnvironmentInitializer, NgModule, APP_BOOTSTRAP_LISTENER, ApplicationRef, PendingTasks } from '@angular/core';
|
|
3
3
|
import { config, Observable, Subject, share, forkJoin, map, throwError, shareReplay, filter, take, mergeMap, EMPTY, defaultIfEmpty, catchError, from, isObservable, takeUntil, finalize, distinctUntilChanged, startWith, skip, buffer, debounceTime } from 'rxjs';
|
|
4
4
|
import { ɵwrapObserverCalls as _wrapObserverCalls, ɵOrderedSubject as _OrderedSubject, ɵStateStream as _StateStream, ɵof as _of, ɵmemoize as _memoize, ɵgetStoreMetadata as _getStoreMetadata, ɵgetSelectorMetadata as _getSelectorMetadata, ɵMETA_KEY as _META_KEY, ɵINITIAL_STATE_TOKEN as _INITIAL_STATE_TOKEN, ɵNgxsAppBootstrappedState as _NgxsAppBootstrappedState, ɵensureStoreMetadata as _ensureStoreMetadata, ɵMETA_OPTIONS_KEY as _META_OPTIONS_KEY, ɵensureSelectorMetadata as _ensureSelectorMetadata, ɵNGXS_STATE_CONTEXT_FACTORY as _NGXS_STATE_CONTEXT_FACTORY, ɵNGXS_STATE_FACTORY as _NGXS_STATE_FACTORY } from '@ngxs/store/internals';
|
|
5
5
|
export { StateToken } from '@ngxs/store/internals';
|
|
@@ -7,159 +7,6 @@ import { NGXS_PLUGINS, getActionTypeFromInstance, InitState, UpdateState, setVal
|
|
|
7
7
|
export { InitState, NGXS_PLUGINS, UpdateState, actionMatcher, getActionTypeFromInstance, getValue, setValue } from '@ngxs/store/plugins';
|
|
8
8
|
import { isStateOperator } from '@ngxs/store/operators';
|
|
9
9
|
|
|
10
|
-
class NoopNgxsExecutionStrategy {
|
|
11
|
-
enter(func) {
|
|
12
|
-
return func();
|
|
13
|
-
}
|
|
14
|
-
leave(func) {
|
|
15
|
-
return func();
|
|
16
|
-
}
|
|
17
|
-
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.0", ngImport: i0, type: NoopNgxsExecutionStrategy, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
18
|
-
/** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.0.0", ngImport: i0, type: NoopNgxsExecutionStrategy, providedIn: 'root' }); }
|
|
19
|
-
}
|
|
20
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.0", ngImport: i0, type: NoopNgxsExecutionStrategy, decorators: [{
|
|
21
|
-
type: Injectable,
|
|
22
|
-
args: [{ providedIn: 'root' }]
|
|
23
|
-
}] });
|
|
24
|
-
|
|
25
|
-
function throwStateNameError(name) {
|
|
26
|
-
throw new Error(`${name} is not a valid state name. It needs to be a valid object property name.`);
|
|
27
|
-
}
|
|
28
|
-
function throwStateNamePropertyError() {
|
|
29
|
-
throw new Error(`States must register a 'name' property.`);
|
|
30
|
-
}
|
|
31
|
-
function throwStateUniqueError(current, newName, oldName) {
|
|
32
|
-
throw new Error(`State name '${current}' from ${newName} already exists in ${oldName}.`);
|
|
33
|
-
}
|
|
34
|
-
function throwStateDecoratorError(name) {
|
|
35
|
-
throw new Error(`States must be decorated with @State() decorator, but "${name}" isn't.`);
|
|
36
|
-
}
|
|
37
|
-
function throwActionDecoratorError() {
|
|
38
|
-
throw new Error('@Action() decorator cannot be used with static methods.');
|
|
39
|
-
}
|
|
40
|
-
function throwSelectorDecoratorError() {
|
|
41
|
-
throw new Error('Selectors only work on methods.');
|
|
42
|
-
}
|
|
43
|
-
function getZoneWarningMessage() {
|
|
44
|
-
return ('Your application was bootstrapped with nooped zone and your execution strategy requires an actual NgZone!\n' +
|
|
45
|
-
'Please set the value of the executionStrategy property to NoopNgxsExecutionStrategy.\n' +
|
|
46
|
-
'NgxsModule.forRoot(states, { executionStrategy: NoopNgxsExecutionStrategy })');
|
|
47
|
-
}
|
|
48
|
-
function getUndecoratedStateWithInjectableWarningMessage(name) {
|
|
49
|
-
return `'${name}' class should be decorated with @Injectable() right after the @State() decorator`;
|
|
50
|
-
}
|
|
51
|
-
function getInvalidInitializationOrderMessage(addedStates) {
|
|
52
|
-
let message = 'You have an invalid state initialization order. This typically occurs when `NgxsModule.forFeature`\n' +
|
|
53
|
-
'or `provideStates` is called before `NgxsModule.forRoot` or `provideStore`.\n' +
|
|
54
|
-
'One example is when `NgxsRouterPluginModule.forRoot` is called before `NgxsModule.forRoot`.';
|
|
55
|
-
if (addedStates) {
|
|
56
|
-
const stateNames = Object.keys(addedStates).map(stateName => `"${stateName}"`);
|
|
57
|
-
message +=
|
|
58
|
-
'\nFeature states added before the store initialization is complete: ' +
|
|
59
|
-
`${stateNames.join(', ')}.`;
|
|
60
|
-
}
|
|
61
|
-
return message;
|
|
62
|
-
}
|
|
63
|
-
function throwSelectFactoryNotConnectedError() {
|
|
64
|
-
throw new Error('You have forgotten to import the NGXS module!');
|
|
65
|
-
}
|
|
66
|
-
function throwPatchingArrayError() {
|
|
67
|
-
throw new Error('Patching arrays is not supported.');
|
|
68
|
-
}
|
|
69
|
-
function throwPatchingPrimitiveError() {
|
|
70
|
-
throw new Error('Patching primitives is not supported.');
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
class DispatchOutsideZoneNgxsExecutionStrategy {
|
|
74
|
-
constructor() {
|
|
75
|
-
this._ngZone = inject(NgZone);
|
|
76
|
-
if (typeof ngDevMode !== 'undefined' && ngDevMode) {
|
|
77
|
-
verifyZoneIsNotNooped(this._ngZone);
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
enter(func) {
|
|
81
|
-
if (typeof ngServerMode !== 'undefined' && ngServerMode) {
|
|
82
|
-
return this.runInsideAngular(func);
|
|
83
|
-
}
|
|
84
|
-
return this.runOutsideAngular(func);
|
|
85
|
-
}
|
|
86
|
-
leave(func) {
|
|
87
|
-
return this.runInsideAngular(func);
|
|
88
|
-
}
|
|
89
|
-
runInsideAngular(func) {
|
|
90
|
-
if (NgZone.isInAngularZone()) {
|
|
91
|
-
return func();
|
|
92
|
-
}
|
|
93
|
-
return this._ngZone.run(func);
|
|
94
|
-
}
|
|
95
|
-
runOutsideAngular(func) {
|
|
96
|
-
if (NgZone.isInAngularZone()) {
|
|
97
|
-
return this._ngZone.runOutsideAngular(func);
|
|
98
|
-
}
|
|
99
|
-
return func();
|
|
100
|
-
}
|
|
101
|
-
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.0", ngImport: i0, type: DispatchOutsideZoneNgxsExecutionStrategy, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
102
|
-
/** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.0.0", ngImport: i0, type: DispatchOutsideZoneNgxsExecutionStrategy, providedIn: 'root' }); }
|
|
103
|
-
}
|
|
104
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.0", ngImport: i0, type: DispatchOutsideZoneNgxsExecutionStrategy, decorators: [{
|
|
105
|
-
type: Injectable,
|
|
106
|
-
args: [{ providedIn: 'root' }]
|
|
107
|
-
}], ctorParameters: () => [] });
|
|
108
|
-
// Caretaker note: this should exist as a separate function and not a class method,
|
|
109
|
-
// since class methods are not tree-shakable.
|
|
110
|
-
function verifyZoneIsNotNooped(ngZone) {
|
|
111
|
-
// `NoopNgZone` is not exposed publicly as it doesn't expect
|
|
112
|
-
// to be used outside of the core Angular code, thus we just have
|
|
113
|
-
// to check if the zone doesn't extend or instanceof `NgZone`.
|
|
114
|
-
if (ngZone instanceof NgZone) {
|
|
115
|
-
return;
|
|
116
|
-
}
|
|
117
|
-
console.warn(getZoneWarningMessage());
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
/**
|
|
121
|
-
* Consumers have the option to utilize the execution strategy provided by
|
|
122
|
-
* `NgxsModule.forRoot({executionStrategy})` or `provideStore([], {executionStrategy})`.
|
|
123
|
-
*/
|
|
124
|
-
const CUSTOM_NGXS_EXECUTION_STRATEGY = new InjectionToken(typeof ngDevMode !== 'undefined' && ngDevMode ? 'CUSTOM_NGXS_EXECUTION_STRATEGY' : '');
|
|
125
|
-
/**
|
|
126
|
-
* The injection token is used internally to resolve an instance of the execution
|
|
127
|
-
* strategy. It checks whether consumers have provided their own `executionStrategy`
|
|
128
|
-
* and also verifies if we are operating in a zone-aware environment.
|
|
129
|
-
*/
|
|
130
|
-
const NGXS_EXECUTION_STRATEGY = new InjectionToken(typeof ngDevMode !== 'undefined' && ngDevMode ? 'NGXS_EXECUTION_STRATEGY' : '', {
|
|
131
|
-
providedIn: 'root',
|
|
132
|
-
factory: () => {
|
|
133
|
-
const ngZone = inject(NgZone);
|
|
134
|
-
const injector = inject(INJECTOR);
|
|
135
|
-
const executionStrategy = injector.get(CUSTOM_NGXS_EXECUTION_STRATEGY);
|
|
136
|
-
const isNgZoneEnabled = ngZone instanceof NgZone;
|
|
137
|
-
return executionStrategy
|
|
138
|
-
? injector.get(executionStrategy)
|
|
139
|
-
: injector.get(isNgZoneEnabled
|
|
140
|
-
? DispatchOutsideZoneNgxsExecutionStrategy
|
|
141
|
-
: NoopNgxsExecutionStrategy);
|
|
142
|
-
}
|
|
143
|
-
});
|
|
144
|
-
|
|
145
|
-
class InternalNgxsExecutionStrategy {
|
|
146
|
-
constructor() {
|
|
147
|
-
this._executionStrategy = inject(NGXS_EXECUTION_STRATEGY);
|
|
148
|
-
}
|
|
149
|
-
enter(func) {
|
|
150
|
-
return this._executionStrategy.enter(func);
|
|
151
|
-
}
|
|
152
|
-
leave(func) {
|
|
153
|
-
return this._executionStrategy.leave(func);
|
|
154
|
-
}
|
|
155
|
-
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.0", ngImport: i0, type: InternalNgxsExecutionStrategy, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
156
|
-
/** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.0.0", ngImport: i0, type: InternalNgxsExecutionStrategy, providedIn: 'root' }); }
|
|
157
|
-
}
|
|
158
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.0", ngImport: i0, type: InternalNgxsExecutionStrategy, decorators: [{
|
|
159
|
-
type: Injectable,
|
|
160
|
-
args: [{ providedIn: 'root' }]
|
|
161
|
-
}] });
|
|
162
|
-
|
|
163
10
|
class PluginManager {
|
|
164
11
|
constructor() {
|
|
165
12
|
this.plugins = [];
|
|
@@ -271,6 +118,88 @@ function fallbackSubscriber(ngZone) {
|
|
|
271
118
|
};
|
|
272
119
|
}
|
|
273
120
|
|
|
121
|
+
// The injection token is used to resolve a list of states provided at
|
|
122
|
+
// the root level through either `NgxsModule.forRoot` or `provideStore`.
|
|
123
|
+
const ROOT_STATE_TOKEN = new InjectionToken(typeof ngDevMode !== 'undefined' && ngDevMode ? 'ROOT_STATE_TOKEN' : '');
|
|
124
|
+
// The injection token is used to resolve a list of states provided at
|
|
125
|
+
// the feature level through either `NgxsModule.forFeature` or `provideStates`.
|
|
126
|
+
// The Array<Array> is used to overload the resolved value of the token because
|
|
127
|
+
// it is a multi-provider token.
|
|
128
|
+
const FEATURE_STATE_TOKEN = new InjectionToken(typeof ngDevMode !== 'undefined' && ngDevMode ? 'FEATURE_STATE_TOKEN' : '');
|
|
129
|
+
// The injection token is used to resolve to options provided at the root
|
|
130
|
+
// level through either `NgxsModule.forRoot` or `provideStore`.
|
|
131
|
+
const NGXS_OPTIONS = new InjectionToken(typeof ngDevMode !== 'undefined' && ngDevMode ? 'NGXS_OPTIONS' : '');
|
|
132
|
+
/**
|
|
133
|
+
* The NGXS config settings.
|
|
134
|
+
*/
|
|
135
|
+
class NgxsConfig {
|
|
136
|
+
constructor() {
|
|
137
|
+
this.compatibility = {
|
|
138
|
+
strictContentSecurityPolicy: false
|
|
139
|
+
};
|
|
140
|
+
/**
|
|
141
|
+
* Defining shared selector options
|
|
142
|
+
*/
|
|
143
|
+
this.selectorOptions = {
|
|
144
|
+
injectContainerState: false,
|
|
145
|
+
suppressErrors: false
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.0", ngImport: i0, type: NgxsConfig, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
149
|
+
/** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.0.0", ngImport: i0, type: NgxsConfig, providedIn: 'root', useFactory: () => {
|
|
150
|
+
const defaultConfig = new NgxsConfig();
|
|
151
|
+
const config = inject(NGXS_OPTIONS);
|
|
152
|
+
return {
|
|
153
|
+
...defaultConfig,
|
|
154
|
+
...config,
|
|
155
|
+
selectorOptions: {
|
|
156
|
+
...defaultConfig.selectorOptions,
|
|
157
|
+
...config.selectorOptions
|
|
158
|
+
}
|
|
159
|
+
};
|
|
160
|
+
} }); }
|
|
161
|
+
}
|
|
162
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.0", ngImport: i0, type: NgxsConfig, decorators: [{
|
|
163
|
+
type: Injectable,
|
|
164
|
+
args: [{
|
|
165
|
+
providedIn: 'root',
|
|
166
|
+
useFactory: () => {
|
|
167
|
+
const defaultConfig = new NgxsConfig();
|
|
168
|
+
const config = inject(NGXS_OPTIONS);
|
|
169
|
+
return {
|
|
170
|
+
...defaultConfig,
|
|
171
|
+
...config,
|
|
172
|
+
selectorOptions: {
|
|
173
|
+
...defaultConfig.selectorOptions,
|
|
174
|
+
...config.selectorOptions
|
|
175
|
+
}
|
|
176
|
+
};
|
|
177
|
+
}
|
|
178
|
+
}]
|
|
179
|
+
}] });
|
|
180
|
+
/**
|
|
181
|
+
* Represents a basic change from a previous to a new value for a single state instance.
|
|
182
|
+
* Passed as a value in a NgxsSimpleChanges object to the ngxsOnChanges hook.
|
|
183
|
+
*/
|
|
184
|
+
class NgxsSimpleChange {
|
|
185
|
+
constructor(previousValue, currentValue, firstChange) {
|
|
186
|
+
this.previousValue = previousValue;
|
|
187
|
+
this.currentValue = currentValue;
|
|
188
|
+
this.firstChange = firstChange;
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
/**
|
|
193
|
+
* The injection token is used internally to resolve an instance of the execution strategy.
|
|
194
|
+
*/
|
|
195
|
+
const NGXS_EXECUTION_STRATEGY = new InjectionToken(typeof ngDevMode !== 'undefined' && ngDevMode ? 'NGXS_EXECUTION_STRATEGY' : '', {
|
|
196
|
+
providedIn: 'root',
|
|
197
|
+
// Since `executionStrategy` is a `Type<...>`, we should inject it to retrieve an
|
|
198
|
+
// instance. This injection token essentially holds an instance of the
|
|
199
|
+
// execution strategy class.
|
|
200
|
+
factory: () => inject(inject(NGXS_OPTIONS).executionStrategy)
|
|
201
|
+
});
|
|
202
|
+
|
|
274
203
|
/**
|
|
275
204
|
* Internal Action result stream that is emitted when an action is completed.
|
|
276
205
|
* This is used as a method of returning the action result to the dispatcher
|
|
@@ -331,7 +260,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.0", ngImpor
|
|
|
331
260
|
class Actions extends Observable {
|
|
332
261
|
constructor() {
|
|
333
262
|
const internalActions$ = inject(InternalActions);
|
|
334
|
-
const internalExecutionStrategy = inject(
|
|
263
|
+
const internalExecutionStrategy = inject(NGXS_EXECUTION_STRATEGY);
|
|
335
264
|
const sharedInternalActions$ = internalActions$.pipe(leaveNgxs(internalExecutionStrategy),
|
|
336
265
|
// The `InternalActions` subject emits outside of the Angular zone.
|
|
337
266
|
// We have to re-enter the Angular zone for any incoming consumer.
|
|
@@ -362,7 +291,7 @@ class InternalDispatcher {
|
|
|
362
291
|
this._actionResults = inject(InternalDispatchedActionResults);
|
|
363
292
|
this._pluginManager = inject(PluginManager);
|
|
364
293
|
this._stateStream = inject(_StateStream);
|
|
365
|
-
this._ngxsExecutionStrategy = inject(
|
|
294
|
+
this._ngxsExecutionStrategy = inject(NGXS_EXECUTION_STRATEGY);
|
|
366
295
|
this._injector = inject(Injector);
|
|
367
296
|
}
|
|
368
297
|
/**
|
|
@@ -455,89 +384,6 @@ const compose = (injector, funcs) => (...args) => {
|
|
|
455
384
|
return runInInjectionContext(injector, () => curr(...args, (...nextArgs) => compose(injector, funcs)(...nextArgs)));
|
|
456
385
|
};
|
|
457
386
|
|
|
458
|
-
// The injection token is used to resolve a list of states provided at
|
|
459
|
-
// the root level through either `NgxsModule.forRoot` or `provideStore`.
|
|
460
|
-
const ROOT_STATE_TOKEN = new InjectionToken(typeof ngDevMode !== 'undefined' && ngDevMode ? 'ROOT_STATE_TOKEN' : '');
|
|
461
|
-
// The injection token is used to resolve a list of states provided at
|
|
462
|
-
// the feature level through either `NgxsModule.forFeature` or `provideStates`.
|
|
463
|
-
// The Array<Array> is used to overload the resolved value of the token because
|
|
464
|
-
// it is a multi-provider token.
|
|
465
|
-
const FEATURE_STATE_TOKEN = new InjectionToken(typeof ngDevMode !== 'undefined' && ngDevMode ? 'FEATURE_STATE_TOKEN' : '');
|
|
466
|
-
// The injection token is used to resolve to options provided at the root
|
|
467
|
-
// level through either `NgxsModule.forRoot` or `provideStore`.
|
|
468
|
-
const NGXS_OPTIONS = new InjectionToken(typeof ngDevMode !== 'undefined' && ngDevMode ? 'NGXS_OPTIONS' : '');
|
|
469
|
-
/**
|
|
470
|
-
* The NGXS config settings.
|
|
471
|
-
*/
|
|
472
|
-
class NgxsConfig {
|
|
473
|
-
constructor() {
|
|
474
|
-
this.compatibility = {
|
|
475
|
-
strictContentSecurityPolicy: false
|
|
476
|
-
};
|
|
477
|
-
/**
|
|
478
|
-
* Determines the execution context to perform async operations inside. An implementation can be
|
|
479
|
-
* provided to override the default behaviour where the async operations are run
|
|
480
|
-
* outside Angular's zone but all observable behaviours of NGXS are run back inside Angular's zone.
|
|
481
|
-
* These observable behaviours are from:
|
|
482
|
-
* `store.selectSignal(...)`, `store.select(...)`, `actions.subscribe(...)` or `store.dispatch(...).subscribe(...)`
|
|
483
|
-
* Every `zone.run` causes Angular to run change detection on the whole tree (`app.tick()`) so of your
|
|
484
|
-
* application doesn't rely on zone.js running change detection then you can switch to the
|
|
485
|
-
* `NoopNgxsExecutionStrategy` that doesn't interact with zones.
|
|
486
|
-
* (default: null)
|
|
487
|
-
*/
|
|
488
|
-
this.executionStrategy = DispatchOutsideZoneNgxsExecutionStrategy;
|
|
489
|
-
/**
|
|
490
|
-
* Defining shared selector options
|
|
491
|
-
*/
|
|
492
|
-
this.selectorOptions = {
|
|
493
|
-
injectContainerState: false,
|
|
494
|
-
suppressErrors: false
|
|
495
|
-
};
|
|
496
|
-
}
|
|
497
|
-
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.0", ngImport: i0, type: NgxsConfig, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
498
|
-
/** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.0.0", ngImport: i0, type: NgxsConfig, providedIn: 'root', useFactory: () => {
|
|
499
|
-
const defaultConfig = new NgxsConfig();
|
|
500
|
-
const config = inject(NGXS_OPTIONS);
|
|
501
|
-
return {
|
|
502
|
-
...defaultConfig,
|
|
503
|
-
...config,
|
|
504
|
-
selectorOptions: {
|
|
505
|
-
...defaultConfig.selectorOptions,
|
|
506
|
-
...config.selectorOptions
|
|
507
|
-
}
|
|
508
|
-
};
|
|
509
|
-
} }); }
|
|
510
|
-
}
|
|
511
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.0", ngImport: i0, type: NgxsConfig, decorators: [{
|
|
512
|
-
type: Injectable,
|
|
513
|
-
args: [{
|
|
514
|
-
providedIn: 'root',
|
|
515
|
-
useFactory: () => {
|
|
516
|
-
const defaultConfig = new NgxsConfig();
|
|
517
|
-
const config = inject(NGXS_OPTIONS);
|
|
518
|
-
return {
|
|
519
|
-
...defaultConfig,
|
|
520
|
-
...config,
|
|
521
|
-
selectorOptions: {
|
|
522
|
-
...defaultConfig.selectorOptions,
|
|
523
|
-
...config.selectorOptions
|
|
524
|
-
}
|
|
525
|
-
};
|
|
526
|
-
}
|
|
527
|
-
}]
|
|
528
|
-
}] });
|
|
529
|
-
/**
|
|
530
|
-
* Represents a basic change from a previous to a new value for a single state instance.
|
|
531
|
-
* Passed as a value in a NgxsSimpleChanges object to the ngxsOnChanges hook.
|
|
532
|
-
*/
|
|
533
|
-
class NgxsSimpleChange {
|
|
534
|
-
constructor(previousValue, currentValue, firstChange) {
|
|
535
|
-
this.previousValue = previousValue;
|
|
536
|
-
this.currentValue = currentValue;
|
|
537
|
-
this.firstChange = firstChange;
|
|
538
|
-
}
|
|
539
|
-
}
|
|
540
|
-
|
|
541
387
|
/**
|
|
542
388
|
* Object freeze code
|
|
543
389
|
* https://github.com/jsdf/deep-freeze
|
|
@@ -938,6 +784,54 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.0", ngImpor
|
|
|
938
784
|
args: [{ providedIn: 'root' }]
|
|
939
785
|
}], ctorParameters: () => [] });
|
|
940
786
|
|
|
787
|
+
function throwStateNameError(name) {
|
|
788
|
+
throw new Error(`${name} is not a valid state name. It needs to be a valid object property name.`);
|
|
789
|
+
}
|
|
790
|
+
function throwStateNamePropertyError() {
|
|
791
|
+
throw new Error(`States must register a 'name' property.`);
|
|
792
|
+
}
|
|
793
|
+
function throwStateUniqueError(current, newName, oldName) {
|
|
794
|
+
throw new Error(`State name '${current}' from ${newName} already exists in ${oldName}.`);
|
|
795
|
+
}
|
|
796
|
+
function throwStateDecoratorError(name) {
|
|
797
|
+
throw new Error(`States must be decorated with @State() decorator, but "${name}" isn't.`);
|
|
798
|
+
}
|
|
799
|
+
function throwActionDecoratorError() {
|
|
800
|
+
throw new Error('@Action() decorator cannot be used with static methods.');
|
|
801
|
+
}
|
|
802
|
+
function throwSelectorDecoratorError() {
|
|
803
|
+
throw new Error('Selectors only work on methods.');
|
|
804
|
+
}
|
|
805
|
+
function getZoneWarningMessage() {
|
|
806
|
+
return ('Your application was bootstrapped with nooped zone and your execution strategy requires an actual NgZone!\n' +
|
|
807
|
+
'Please set the value of the executionStrategy property to NoopNgxsExecutionStrategy.\n' +
|
|
808
|
+
'NgxsModule.forRoot(states, { executionStrategy: NoopNgxsExecutionStrategy })');
|
|
809
|
+
}
|
|
810
|
+
function getUndecoratedStateWithInjectableWarningMessage(name) {
|
|
811
|
+
return `'${name}' class should be decorated with @Injectable() right after the @State() decorator`;
|
|
812
|
+
}
|
|
813
|
+
function getInvalidInitializationOrderMessage(addedStates) {
|
|
814
|
+
let message = 'You have an invalid state initialization order. This typically occurs when `NgxsModule.forFeature`\n' +
|
|
815
|
+
'or `provideStates` is called before `NgxsModule.forRoot` or `provideStore`.\n' +
|
|
816
|
+
'One example is when `NgxsRouterPluginModule.forRoot` is called before `NgxsModule.forRoot`.';
|
|
817
|
+
if (addedStates) {
|
|
818
|
+
const stateNames = Object.keys(addedStates).map(stateName => `"${stateName}"`);
|
|
819
|
+
message +=
|
|
820
|
+
'\nFeature states added before the store initialization is complete: ' +
|
|
821
|
+
`${stateNames.join(', ')}.`;
|
|
822
|
+
}
|
|
823
|
+
return message;
|
|
824
|
+
}
|
|
825
|
+
function throwSelectFactoryNotConnectedError() {
|
|
826
|
+
throw new Error('You have forgotten to import the NGXS module!');
|
|
827
|
+
}
|
|
828
|
+
function throwPatchingArrayError() {
|
|
829
|
+
throw new Error('Patching arrays is not supported.');
|
|
830
|
+
}
|
|
831
|
+
function throwPatchingPrimitiveError() {
|
|
832
|
+
throw new Error('Patching primitives is not supported.');
|
|
833
|
+
}
|
|
834
|
+
|
|
941
835
|
const stateNameRegex = /* @__PURE__ */ new RegExp('^[a-zA-Z0-9_]+$');
|
|
942
836
|
function ensureStateNameIsValid(name) {
|
|
943
837
|
if (!name) {
|
|
@@ -1535,7 +1429,7 @@ class Store {
|
|
|
1535
1429
|
this._stateStream = inject(_StateStream);
|
|
1536
1430
|
this._internalStateOperations = inject(InternalStateOperations);
|
|
1537
1431
|
this._config = inject(NgxsConfig);
|
|
1538
|
-
this._internalExecutionStrategy = inject(
|
|
1432
|
+
this._internalExecutionStrategy = inject(NGXS_EXECUTION_STRATEGY);
|
|
1539
1433
|
this._stateFactory = inject(StateFactory);
|
|
1540
1434
|
/**
|
|
1541
1435
|
* This is a derived state stream that leaves NGXS execution strategy to emit state changes within the Angular zone,
|
|
@@ -1919,10 +1813,6 @@ function getRootProviders(states, options) {
|
|
|
1919
1813
|
{
|
|
1920
1814
|
provide: NGXS_OPTIONS,
|
|
1921
1815
|
useValue: options
|
|
1922
|
-
},
|
|
1923
|
-
{
|
|
1924
|
-
provide: CUSTOM_NGXS_EXECUTION_STRATEGY,
|
|
1925
|
-
useValue: options.executionStrategy
|
|
1926
1816
|
}
|
|
1927
1817
|
];
|
|
1928
1818
|
}
|
|
@@ -1944,7 +1834,7 @@ function getFeatureProviders(states) {
|
|
|
1944
1834
|
}
|
|
1945
1835
|
|
|
1946
1836
|
class NgxsModule {
|
|
1947
|
-
static forRoot(states = [], options
|
|
1837
|
+
static forRoot(states = [], options) {
|
|
1948
1838
|
return {
|
|
1949
1839
|
ngModule: NgxsRootModule,
|
|
1950
1840
|
providers: getRootProviders(states, options)
|
|
@@ -2168,6 +2058,68 @@ function Selector(selectors) {
|
|
|
2168
2058
|
};
|
|
2169
2059
|
}
|
|
2170
2060
|
|
|
2061
|
+
class DispatchOutsideZoneNgxsExecutionStrategy {
|
|
2062
|
+
constructor() {
|
|
2063
|
+
this._ngZone = inject(NgZone);
|
|
2064
|
+
if (typeof ngDevMode !== 'undefined' && ngDevMode) {
|
|
2065
|
+
verifyZoneIsNotNooped(this._ngZone);
|
|
2066
|
+
}
|
|
2067
|
+
}
|
|
2068
|
+
enter(func) {
|
|
2069
|
+
if (typeof ngServerMode !== 'undefined' && ngServerMode) {
|
|
2070
|
+
return this.runInsideAngular(func);
|
|
2071
|
+
}
|
|
2072
|
+
return this.runOutsideAngular(func);
|
|
2073
|
+
}
|
|
2074
|
+
leave(func) {
|
|
2075
|
+
return this.runInsideAngular(func);
|
|
2076
|
+
}
|
|
2077
|
+
runInsideAngular(func) {
|
|
2078
|
+
if (NgZone.isInAngularZone()) {
|
|
2079
|
+
return func();
|
|
2080
|
+
}
|
|
2081
|
+
return this._ngZone.run(func);
|
|
2082
|
+
}
|
|
2083
|
+
runOutsideAngular(func) {
|
|
2084
|
+
if (NgZone.isInAngularZone()) {
|
|
2085
|
+
return this._ngZone.runOutsideAngular(func);
|
|
2086
|
+
}
|
|
2087
|
+
return func();
|
|
2088
|
+
}
|
|
2089
|
+
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.0", ngImport: i0, type: DispatchOutsideZoneNgxsExecutionStrategy, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
2090
|
+
/** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.0.0", ngImport: i0, type: DispatchOutsideZoneNgxsExecutionStrategy, providedIn: 'root' }); }
|
|
2091
|
+
}
|
|
2092
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.0", ngImport: i0, type: DispatchOutsideZoneNgxsExecutionStrategy, decorators: [{
|
|
2093
|
+
type: Injectable,
|
|
2094
|
+
args: [{ providedIn: 'root' }]
|
|
2095
|
+
}], ctorParameters: () => [] });
|
|
2096
|
+
// Caretaker note: this should exist as a separate function and not a class method,
|
|
2097
|
+
// since class methods are not tree-shakable.
|
|
2098
|
+
function verifyZoneIsNotNooped(ngZone) {
|
|
2099
|
+
// `NoopNgZone` is not exposed publicly as it doesn't expect
|
|
2100
|
+
// to be used outside of the core Angular code, thus we just have
|
|
2101
|
+
// to check if the zone doesn't extend or instanceof `NgZone`.
|
|
2102
|
+
if (ngZone instanceof NgZone) {
|
|
2103
|
+
return;
|
|
2104
|
+
}
|
|
2105
|
+
console.warn(getZoneWarningMessage());
|
|
2106
|
+
}
|
|
2107
|
+
|
|
2108
|
+
class NoopNgxsExecutionStrategy {
|
|
2109
|
+
enter(func) {
|
|
2110
|
+
return func();
|
|
2111
|
+
}
|
|
2112
|
+
leave(func) {
|
|
2113
|
+
return func();
|
|
2114
|
+
}
|
|
2115
|
+
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.0", ngImport: i0, type: NoopNgxsExecutionStrategy, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
2116
|
+
/** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.0.0", ngImport: i0, type: NoopNgxsExecutionStrategy, providedIn: 'root' }); }
|
|
2117
|
+
}
|
|
2118
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.0", ngImport: i0, type: NoopNgxsExecutionStrategy, decorators: [{
|
|
2119
|
+
type: Injectable,
|
|
2120
|
+
args: [{ providedIn: 'root' }]
|
|
2121
|
+
}] });
|
|
2122
|
+
|
|
2171
2123
|
class NgxsDevelopmentModule {
|
|
2172
2124
|
static forRoot(options) {
|
|
2173
2125
|
return {
|
|
@@ -2363,28 +2315,30 @@ function withNgxsPendingTasks() {
|
|
|
2363
2315
|
});
|
|
2364
2316
|
}
|
|
2365
2317
|
|
|
2366
|
-
|
|
2367
|
-
|
|
2368
|
-
|
|
2369
|
-
|
|
2370
|
-
|
|
2371
|
-
|
|
2372
|
-
|
|
2373
|
-
|
|
2374
|
-
|
|
2375
|
-
|
|
2376
|
-
|
|
2377
|
-
|
|
2378
|
-
|
|
2318
|
+
/**
|
|
2319
|
+
* This function provides global store providers and initializes the store.
|
|
2320
|
+
*
|
|
2321
|
+
* ```ts
|
|
2322
|
+
* bootstrapApplication(AppComponent, {
|
|
2323
|
+
* providers: [provideStore([CountriesState])]
|
|
2324
|
+
* });
|
|
2325
|
+
* ```
|
|
2326
|
+
*
|
|
2327
|
+
* The `provideStore` may be optionally called with a config before the list of features:
|
|
2328
|
+
*
|
|
2329
|
+
* ```ts
|
|
2330
|
+
* provideStore([CountriesState], {
|
|
2331
|
+
* developmentMode: !environment.production
|
|
2332
|
+
* });
|
|
2333
|
+
* ```
|
|
2334
|
+
*/
|
|
2335
|
+
function provideStore(states = [], options, ...features) {
|
|
2379
2336
|
return makeEnvironmentProviders([
|
|
2380
2337
|
...getRootProviders(states, options),
|
|
2381
2338
|
NGXS_ROOT_ENVIRONMENT_INITIALIZER,
|
|
2382
2339
|
features
|
|
2383
2340
|
]);
|
|
2384
2341
|
}
|
|
2385
|
-
function isEnvironmentProvider(target) {
|
|
2386
|
-
return !!target.ɵproviders;
|
|
2387
|
-
}
|
|
2388
2342
|
|
|
2389
2343
|
/**
|
|
2390
2344
|
* This version serves as a standalone alternative to `NgxsModule.forFeature`.
|
|
@@ -2502,5 +2456,5 @@ function ɵprovideNgxsInternalStateTokens() {
|
|
|
2502
2456
|
* Generated bundle index. Do not edit.
|
|
2503
2457
|
*/
|
|
2504
2458
|
|
|
2505
|
-
export { Action, Actions, NgxsConfig, NgxsDevelopmentModule, NgxsModule, NgxsSimpleChange, NgxsUnhandledActionsLogger, NgxsUnhandledErrorHandler, NoopNgxsExecutionStrategy, Select, Selector, SelectorOptions, State, Store, createDispatchMap, createModelSelector, createPickSelector, createPropertySelectors, createSelectMap, createSelector, dispatch, ofAction, ofActionCanceled, ofActionCompleted, ofActionDispatched, ofActionErrored, ofActionSuccessful, provideStates, provideStore, select, withNgxsDevelopmentOptions, withNgxsPendingTasks, withNgxsPlugin, withNgxsPreboot, NgxsFeatureModule as ɵNgxsFeatureModule, NgxsRootModule as ɵNgxsRootModule, ɵprovideNgxsInternalStateTokens };
|
|
2459
|
+
export { Action, Actions, DispatchOutsideZoneNgxsExecutionStrategy, NgxsConfig, NgxsDevelopmentModule, NgxsModule, NgxsSimpleChange, NgxsUnhandledActionsLogger, NgxsUnhandledErrorHandler, NoopNgxsExecutionStrategy, Select, Selector, SelectorOptions, State, Store, createDispatchMap, createModelSelector, createPickSelector, createPropertySelectors, createSelectMap, createSelector, dispatch, ofAction, ofActionCanceled, ofActionCompleted, ofActionDispatched, ofActionErrored, ofActionSuccessful, provideStates, provideStore, select, withNgxsDevelopmentOptions, withNgxsPendingTasks, withNgxsPlugin, withNgxsPreboot, NgxsFeatureModule as ɵNgxsFeatureModule, NgxsRootModule as ɵNgxsRootModule, ɵprovideNgxsInternalStateTokens };
|
|
2506
2460
|
//# sourceMappingURL=ngxs-store.mjs.map
|