@ngxs/store 19.0.0 → 20.0.0-dev.master-5e7c96c
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/fesm2022/ngxs-store-internals-testing.mjs +108 -12
- package/fesm2022/ngxs-store-internals-testing.mjs.map +1 -1
- package/fesm2022/ngxs-store-internals.mjs +72 -32
- package/fesm2022/ngxs-store-internals.mjs.map +1 -1
- package/fesm2022/ngxs-store-operators.mjs +11 -23
- package/fesm2022/ngxs-store-operators.mjs.map +1 -1
- package/fesm2022/ngxs-store-plugins.mjs +5 -4
- package/fesm2022/ngxs-store-plugins.mjs.map +1 -1
- package/fesm2022/ngxs-store.mjs +743 -815
- package/fesm2022/ngxs-store.mjs.map +1 -1
- package/index.d.ts +47 -34
- package/internals/index.d.ts +19 -6
- package/internals/testing/index.d.ts +46 -3
- package/operators/index.d.ts +4 -3
- package/package.json +7 -7
- package/plugins/index.d.ts +2 -1
- package/schematics/src/utils/versions.json +1 -1
- package/experimental/package.json +0 -3
- package/internals/package.json +0 -3
- package/internals/testing/package.json +0 -3
- package/operators/package.json +0 -3
- package/plugins/package.json +0 -3
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { TestBed } from '@angular/core/testing';
|
|
2
|
-
import { DOCUMENT } from '@angular/common';
|
|
3
2
|
import { ɵgetDOM as _getDOM, BrowserModule, ɵBrowserDomAdapter as _BrowserDomAdapter } from '@angular/platform-browser';
|
|
4
3
|
import * as i0 from '@angular/core';
|
|
5
|
-
import { destroyPlatform, VERSION, createPlatform, Component, NgModule, ApplicationRef } from '@angular/core';
|
|
4
|
+
import { DOCUMENT, destroyPlatform, VERSION, createPlatform, Injector, Component, NgModule, ApplicationRef, provideEnvironmentInitializer, inject, DestroyRef, Injectable } from '@angular/core';
|
|
6
5
|
import { BrowserDynamicTestingModule, platformBrowserDynamicTesting } from '@angular/platform-browser-dynamic/testing';
|
|
7
|
-
import { NgxsModule, Store } from '@ngxs/store';
|
|
6
|
+
import { NgxsModule, Store, Actions, ActionStatus } from '@ngxs/store';
|
|
7
|
+
import { ReplaySubject, Subject, takeUntil } from 'rxjs';
|
|
8
8
|
|
|
9
9
|
function createRootElement() {
|
|
10
10
|
const document = TestBed.inject(DOCUMENT);
|
|
@@ -32,7 +32,7 @@ function resetPlatformAfterBootstrapping() {
|
|
|
32
32
|
const version = +VERSION.major;
|
|
33
33
|
// https://github.com/angular/angular/commit/e250db4f261741b04ee4cbad4dec41a8908a12aa
|
|
34
34
|
if (version < 14) {
|
|
35
|
-
createPlatform(TestBed);
|
|
35
|
+
createPlatform(TestBed.inject(Injector));
|
|
36
36
|
}
|
|
37
37
|
}
|
|
38
38
|
function resetLocationToUrl(freshUrl) {
|
|
@@ -77,10 +77,10 @@ function freshPlatform(fn) {
|
|
|
77
77
|
class NgxsTestComponent {
|
|
78
78
|
ngOnInit() { }
|
|
79
79
|
ngAfterViewInit() { }
|
|
80
|
-
/** @nocollapse */ static
|
|
81
|
-
/** @nocollapse */ static
|
|
80
|
+
/** @nocollapse */ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.0.3", ngImport: i0, type: NgxsTestComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
81
|
+
/** @nocollapse */ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "20.0.3", 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: "20.0.3", ngImport: i0, type: NgxsTestComponent, decorators: [{
|
|
84
84
|
type: Component,
|
|
85
85
|
args: [{
|
|
86
86
|
selector: 'app-root',
|
|
@@ -92,11 +92,11 @@ class NgxsTestModule {
|
|
|
92
92
|
static ngDoBootstrap(app) {
|
|
93
93
|
app.bootstrap(NgxsTestComponent);
|
|
94
94
|
}
|
|
95
|
-
/** @nocollapse */ static
|
|
96
|
-
/** @nocollapse */ static
|
|
97
|
-
/** @nocollapse */ static
|
|
95
|
+
/** @nocollapse */ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.0.3", ngImport: i0, type: NgxsTestModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
96
|
+
/** @nocollapse */ static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "20.0.3", ngImport: i0, type: NgxsTestModule, imports: [BrowserModule, NgxsTestComponent] });
|
|
97
|
+
/** @nocollapse */ static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "20.0.3", ngImport: i0, type: NgxsTestModule, imports: [BrowserModule] });
|
|
98
98
|
}
|
|
99
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
99
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.0.3", ngImport: i0, type: NgxsTestModule, decorators: [{
|
|
100
100
|
type: NgModule,
|
|
101
101
|
args: [{
|
|
102
102
|
imports: [BrowserModule, NgxsTestComponent]
|
|
@@ -181,9 +181,105 @@ class NgxsTestBed {
|
|
|
181
181
|
}
|
|
182
182
|
}
|
|
183
183
|
|
|
184
|
+
class NgxsActionCollector {
|
|
185
|
+
/**
|
|
186
|
+
* Including this in your providers will
|
|
187
|
+
* set up the the action collector to start collecting actions
|
|
188
|
+
* from before NGXS initializes
|
|
189
|
+
* @example
|
|
190
|
+
* // In your providers declaration for your tests:
|
|
191
|
+
* {
|
|
192
|
+
* providers: [
|
|
193
|
+
* NgxsActionCollector.collectActions(),
|
|
194
|
+
* provideStore([MyState]),
|
|
195
|
+
* ],
|
|
196
|
+
* // ...
|
|
197
|
+
* }
|
|
198
|
+
* // and then in your test:
|
|
199
|
+
* const actionCollector = TestBed.inject(NgxsActionCollector);
|
|
200
|
+
* const actionsDispatched = actionCollector.dispatched;
|
|
201
|
+
* const action = actionsDispatched.find(
|
|
202
|
+
* (item) => item instanceof MyAction
|
|
203
|
+
* );
|
|
204
|
+
* expect(action).toBeDefined();
|
|
205
|
+
* @returns An environment initializer that starts the collector immediately
|
|
206
|
+
*/
|
|
207
|
+
static collectActions() {
|
|
208
|
+
return provideEnvironmentInitializer(() => {
|
|
209
|
+
inject(NgxsActionCollector).start();
|
|
210
|
+
});
|
|
211
|
+
}
|
|
212
|
+
_destroyed$ = new ReplaySubject(1);
|
|
213
|
+
_stopped$ = new Subject();
|
|
214
|
+
_started = false;
|
|
215
|
+
dispatched = [];
|
|
216
|
+
completed = [];
|
|
217
|
+
successful = [];
|
|
218
|
+
errored = [];
|
|
219
|
+
cancelled = [];
|
|
220
|
+
_actions$ = inject(Actions);
|
|
221
|
+
constructor() {
|
|
222
|
+
inject(DestroyRef).onDestroy(() => this._destroyed$.next());
|
|
223
|
+
}
|
|
224
|
+
start() {
|
|
225
|
+
if (this._started) {
|
|
226
|
+
return;
|
|
227
|
+
}
|
|
228
|
+
this._started = true;
|
|
229
|
+
this._actions$.pipe(takeUntil(this._destroyed$), takeUntil(this._stopped$)).subscribe({
|
|
230
|
+
next: (ctx) => {
|
|
231
|
+
switch (ctx?.status) {
|
|
232
|
+
case ActionStatus.Dispatched:
|
|
233
|
+
this.dispatched.push(ctx.action);
|
|
234
|
+
break;
|
|
235
|
+
case ActionStatus.Successful:
|
|
236
|
+
this.successful.push(ctx.action);
|
|
237
|
+
this.completed.push(ctx.action);
|
|
238
|
+
break;
|
|
239
|
+
case ActionStatus.Errored:
|
|
240
|
+
this.errored.push(ctx.action);
|
|
241
|
+
this.completed.push(ctx.action);
|
|
242
|
+
break;
|
|
243
|
+
case ActionStatus.Canceled:
|
|
244
|
+
this.cancelled.push(ctx.action);
|
|
245
|
+
this.completed.push(ctx.action);
|
|
246
|
+
break;
|
|
247
|
+
default:
|
|
248
|
+
break;
|
|
249
|
+
}
|
|
250
|
+
},
|
|
251
|
+
complete: () => {
|
|
252
|
+
this._started = false;
|
|
253
|
+
},
|
|
254
|
+
error: () => {
|
|
255
|
+
this._started = false;
|
|
256
|
+
}
|
|
257
|
+
});
|
|
258
|
+
}
|
|
259
|
+
reset() {
|
|
260
|
+
function clearArray(array) {
|
|
261
|
+
array.splice(0, array.length);
|
|
262
|
+
}
|
|
263
|
+
clearArray(this.dispatched);
|
|
264
|
+
clearArray(this.completed);
|
|
265
|
+
clearArray(this.successful);
|
|
266
|
+
clearArray(this.errored);
|
|
267
|
+
clearArray(this.cancelled);
|
|
268
|
+
}
|
|
269
|
+
stop() {
|
|
270
|
+
this._stopped$.next();
|
|
271
|
+
}
|
|
272
|
+
/** @nocollapse */ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.0.3", ngImport: i0, type: NgxsActionCollector, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
273
|
+
/** @nocollapse */ static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.0.3", ngImport: i0, type: NgxsActionCollector, providedIn: 'root' });
|
|
274
|
+
}
|
|
275
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.0.3", ngImport: i0, type: NgxsActionCollector, decorators: [{
|
|
276
|
+
type: Injectable,
|
|
277
|
+
args: [{ providedIn: 'root' }]
|
|
278
|
+
}], ctorParameters: () => [] });
|
|
279
|
+
|
|
184
280
|
/**
|
|
185
281
|
* Generated bundle index. Do not edit.
|
|
186
282
|
*/
|
|
187
283
|
|
|
188
|
-
export { NgxsTestBed, freshPlatform, loggedError, skipConsoleLogging };
|
|
284
|
+
export { NgxsActionCollector, NgxsTestBed, freshPlatform, loggedError, skipConsoleLogging };
|
|
189
285
|
//# sourceMappingURL=ngxs-store-internals-testing.mjs.map
|
|
@@ -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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AAA,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;;;;"}
|
|
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/action-collector.ts","../../../packages/store/internals/testing/src/ngxs-store-internals-testing.ts"],"sourcesContent":["import { TestBed } from '@angular/core/testing';\n\nimport { ɵgetDOM as getDOM } from '@angular/platform-browser';\nimport { VERSION, destroyPlatform, createPlatform, DOCUMENT, Injector } 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.inject(Injector));\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, DOCUMENT } from '@angular/core';\nimport { TestBed, TestBedStatic } from '@angular/core/testing';\n\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","import {\n DestroyRef,\n EnvironmentProviders,\n inject,\n Injectable,\n provideEnvironmentInitializer\n} from '@angular/core';\nimport { Actions, ActionStatus, type ActionContext } from '@ngxs/store';\nimport { ReplaySubject, Subject, takeUntil } from 'rxjs';\n\n@Injectable({ providedIn: 'root' })\nexport class NgxsActionCollector {\n /**\n * Including this in your providers will\n * set up the the action collector to start collecting actions\n * from before NGXS initializes\n * @example\n * // In your providers declaration for your tests:\n * {\n * providers: [\n * NgxsActionCollector.collectActions(),\n * provideStore([MyState]),\n * ],\n * // ...\n * }\n * // and then in your test:\n * const actionCollector = TestBed.inject(NgxsActionCollector);\n * const actionsDispatched = actionCollector.dispatched;\n * const action = actionsDispatched.find(\n * (item) => item instanceof MyAction\n * );\n * expect(action).toBeDefined();\n * @returns An environment initializer that starts the collector immediately\n */\n static collectActions(): EnvironmentProviders {\n return provideEnvironmentInitializer(() => {\n inject(NgxsActionCollector).start();\n });\n }\n\n private _destroyed$ = new ReplaySubject<void>(1);\n private _stopped$ = new Subject<void>();\n private _started = false;\n\n readonly dispatched: any[] = [];\n readonly completed: any[] = [];\n readonly successful: any[] = [];\n readonly errored: any[] = [];\n readonly cancelled: any[] = [];\n\n private _actions$ = inject(Actions);\n\n constructor() {\n inject(DestroyRef).onDestroy(() => this._destroyed$.next());\n }\n\n start() {\n if (this._started) {\n return;\n }\n this._started = true;\n this._actions$.pipe(takeUntil(this._destroyed$), takeUntil(this._stopped$)).subscribe({\n next: (ctx: ActionContext) => {\n switch (ctx?.status) {\n case ActionStatus.Dispatched:\n this.dispatched.push(ctx.action);\n break;\n case ActionStatus.Successful:\n this.successful.push(ctx.action);\n this.completed.push(ctx.action);\n break;\n case ActionStatus.Errored:\n this.errored.push(ctx.action);\n this.completed.push(ctx.action);\n break;\n case ActionStatus.Canceled:\n this.cancelled.push(ctx.action);\n this.completed.push(ctx.action);\n break;\n default:\n break;\n }\n },\n complete: () => {\n this._started = false;\n },\n error: () => {\n this._started = false;\n }\n });\n }\n\n reset() {\n function clearArray(array: any[]) {\n array.splice(0, array.length);\n }\n clearArray(this.dispatched);\n clearArray(this.completed);\n clearArray(this.successful);\n clearArray(this.errored);\n clearArray(this.cancelled);\n }\n\n stop() {\n this._stopped$.next();\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;;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AU;mBAAC,EAAE,UAAU,EAAE,MAAM,EAAE;;;ACVlC;;AAEG;;;;"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
|
-
import { InjectionToken, Injectable, untracked } from '@angular/core';
|
|
3
|
-
import {
|
|
2
|
+
import { InjectionToken, inject, DestroyRef, Injectable, untracked } from '@angular/core';
|
|
3
|
+
import { BehaviorSubject, Subject, Observable } from 'rxjs';
|
|
4
4
|
import { toSignal } from '@angular/core/rxjs-interop';
|
|
5
5
|
|
|
6
6
|
// This key is used to store metadata on state classes,
|
|
@@ -14,13 +14,19 @@ const ɵMETA_OPTIONS_KEY = 'NGXS_OPTIONS_META';
|
|
|
14
14
|
// `createSelector` function.
|
|
15
15
|
const ɵSELECTOR_META_KEY = 'NGXS_SELECTOR_META';
|
|
16
16
|
|
|
17
|
+
// Property reads are not minified.
|
|
18
|
+
// It's smaller to read it once and use a function.
|
|
19
|
+
const _hasOwnProperty = Object.prototype.hasOwnProperty;
|
|
20
|
+
const ɵhasOwnProperty = (target, key) => _hasOwnProperty.call(target, key);
|
|
21
|
+
const ɵdefineProperty = Object.defineProperty;
|
|
22
|
+
|
|
17
23
|
/**
|
|
18
24
|
* Ensures metadata is attached to the class and returns it.
|
|
19
25
|
*
|
|
20
26
|
* @ignore
|
|
21
27
|
*/
|
|
22
28
|
function ɵensureStoreMetadata(target) {
|
|
23
|
-
if (
|
|
29
|
+
if (!ɵhasOwnProperty(target, ɵMETA_KEY)) {
|
|
24
30
|
const defaultMetadata = {
|
|
25
31
|
name: null,
|
|
26
32
|
actions: {},
|
|
@@ -31,7 +37,7 @@ function ɵensureStoreMetadata(target) {
|
|
|
31
37
|
},
|
|
32
38
|
children: []
|
|
33
39
|
};
|
|
34
|
-
|
|
40
|
+
ɵdefineProperty(target, ɵMETA_KEY, { value: defaultMetadata });
|
|
35
41
|
}
|
|
36
42
|
return ɵgetStoreMetadata(target);
|
|
37
43
|
}
|
|
@@ -49,7 +55,7 @@ function ɵgetStoreMetadata(target) {
|
|
|
49
55
|
* @ignore
|
|
50
56
|
*/
|
|
51
57
|
function ɵensureSelectorMetadata(target) {
|
|
52
|
-
if (
|
|
58
|
+
if (!ɵhasOwnProperty(target, ɵSELECTOR_META_KEY)) {
|
|
53
59
|
const defaultMetadata = {
|
|
54
60
|
makeRootSelector: null,
|
|
55
61
|
originalFn: null,
|
|
@@ -57,7 +63,7 @@ function ɵensureSelectorMetadata(target) {
|
|
|
57
63
|
selectorName: null,
|
|
58
64
|
getSelectorOptions: () => ({})
|
|
59
65
|
};
|
|
60
|
-
|
|
66
|
+
ɵdefineProperty(target, ɵSELECTOR_META_KEY, { value: defaultMetadata });
|
|
61
67
|
}
|
|
62
68
|
return ɵgetSelectorMetadata(target);
|
|
63
69
|
}
|
|
@@ -114,6 +120,7 @@ function ɵmemoize(func, equalityCheck = Object.is) {
|
|
|
114
120
|
}
|
|
115
121
|
|
|
116
122
|
class StateToken {
|
|
123
|
+
_name;
|
|
117
124
|
constructor(_name) {
|
|
118
125
|
this._name = _name;
|
|
119
126
|
const selectorMetadata = ɵensureSelectorMetadata(this);
|
|
@@ -130,7 +137,7 @@ class StateToken {
|
|
|
130
137
|
}
|
|
131
138
|
|
|
132
139
|
class ɵInitialState {
|
|
133
|
-
static
|
|
140
|
+
static _value = {};
|
|
134
141
|
static set(state) {
|
|
135
142
|
this._value = state;
|
|
136
143
|
}
|
|
@@ -145,18 +152,22 @@ const ɵINITIAL_STATE_TOKEN = new InjectionToken(typeof ngDevMode !== 'undefined
|
|
|
145
152
|
factory: () => ɵInitialState.pop()
|
|
146
153
|
});
|
|
147
154
|
|
|
148
|
-
class ɵNgxsAppBootstrappedState extends
|
|
155
|
+
class ɵNgxsAppBootstrappedState extends BehaviorSubject {
|
|
149
156
|
constructor() {
|
|
150
|
-
super(
|
|
157
|
+
super(false);
|
|
158
|
+
const destroyRef = inject(DestroyRef);
|
|
159
|
+
// Complete the subject once the root injector is destroyed to ensure
|
|
160
|
+
// there are no active subscribers that would receive events or perform
|
|
161
|
+
// any actions after the application is destroyed.
|
|
162
|
+
destroyRef.onDestroy(() => this.complete());
|
|
151
163
|
}
|
|
152
164
|
bootstrap() {
|
|
153
165
|
this.next(true);
|
|
154
|
-
this.complete();
|
|
155
166
|
}
|
|
156
|
-
/** @nocollapse */ static
|
|
157
|
-
/** @nocollapse */ static
|
|
167
|
+
/** @nocollapse */ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.0.3", ngImport: i0, type: ɵNgxsAppBootstrappedState, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
168
|
+
/** @nocollapse */ static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.0.3", ngImport: i0, type: ɵNgxsAppBootstrappedState, providedIn: 'root' });
|
|
158
169
|
}
|
|
159
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
170
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.0.3", ngImport: i0, type: ɵNgxsAppBootstrappedState, decorators: [{
|
|
160
171
|
type: Injectable,
|
|
161
172
|
args: [{ providedIn: 'root' }]
|
|
162
173
|
}], ctorParameters: () => [] });
|
|
@@ -218,10 +229,7 @@ function orderedQueueOperation(operation) {
|
|
|
218
229
|
* When `subject` is a `OrderedSubject<T>` the second subscriber would recieve `start` and then `end`.
|
|
219
230
|
*/
|
|
220
231
|
class ɵOrderedSubject extends Subject {
|
|
221
|
-
|
|
222
|
-
super(...arguments);
|
|
223
|
-
this._orderedNext = orderedQueueOperation((value) => super.next(value));
|
|
224
|
-
}
|
|
232
|
+
_orderedNext = orderedQueueOperation((value) => super.next(value));
|
|
225
233
|
next(value) {
|
|
226
234
|
this._orderedNext(value);
|
|
227
235
|
}
|
|
@@ -242,9 +250,10 @@ class ɵOrderedSubject extends Subject {
|
|
|
242
250
|
* When `subject` is a `OrderedBehaviorSubject<T>` the second subscriber would recieve `start` and then `end`.
|
|
243
251
|
*/
|
|
244
252
|
class ɵOrderedBehaviorSubject extends BehaviorSubject {
|
|
253
|
+
_orderedNext = orderedQueueOperation((value) => super.next(value));
|
|
254
|
+
_currentValue;
|
|
245
255
|
constructor(value) {
|
|
246
256
|
super(value);
|
|
247
|
-
this._orderedNext = orderedQueueOperation((value) => super.next(value));
|
|
248
257
|
this._currentValue = value;
|
|
249
258
|
}
|
|
250
259
|
getValue() {
|
|
@@ -279,25 +288,56 @@ function ɵwrapObserverCalls(invokeFn) {
|
|
|
279
288
|
* @ignore
|
|
280
289
|
*/
|
|
281
290
|
class ɵStateStream extends ɵOrderedBehaviorSubject {
|
|
291
|
+
state = toSignal(this.pipe(ɵwrapObserverCalls(untracked)), {
|
|
292
|
+
manualCleanup: true,
|
|
293
|
+
requireSync: true
|
|
294
|
+
});
|
|
282
295
|
constructor() {
|
|
283
296
|
super({});
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
// The StateStream should never emit values once the root view is removed,
|
|
291
|
-
// such as when the `NgModuleRef.destroy()` method is called. This is crucial
|
|
292
|
-
// for preventing memory leaks in server-side rendered apps, where a new StateStream
|
|
297
|
+
// Complete the subject once the root injector is destroyed to ensure
|
|
298
|
+
// there are no active subscribers that would receive events or perform
|
|
299
|
+
// any actions after the application is destroyed.
|
|
300
|
+
// The `StateStream` should never emit values once the root view is removed,
|
|
301
|
+
// such as when the `ApplicationRef.destroy()` method is called. This is crucial
|
|
302
|
+
// for preventing memory leaks in server-side rendered apps, where a new `StateStream`
|
|
293
303
|
// is created for each HTTP request. If users forget to unsubscribe from `store.select`
|
|
294
304
|
// or `store.subscribe`, it can result in significant memory leaks in SSR apps.
|
|
295
|
-
this.complete();
|
|
305
|
+
inject(DestroyRef).onDestroy(() => this.complete());
|
|
306
|
+
}
|
|
307
|
+
/** @nocollapse */ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.0.3", ngImport: i0, type: ɵStateStream, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
308
|
+
/** @nocollapse */ static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.0.3", ngImport: i0, type: ɵStateStream, providedIn: 'root' });
|
|
309
|
+
}
|
|
310
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.0.3", ngImport: i0, type: ɵStateStream, decorators: [{
|
|
311
|
+
type: Injectable,
|
|
312
|
+
args: [{ providedIn: 'root' }]
|
|
313
|
+
}], ctorParameters: () => [] });
|
|
314
|
+
|
|
315
|
+
class ɵNgxsActionRegistry {
|
|
316
|
+
// Instead of going over the states list every time an action is dispatched,
|
|
317
|
+
// we are constructing a map of action types to lists of action metadata.
|
|
318
|
+
// If the `@@Init` action is handled in two different states, the action
|
|
319
|
+
// metadata list will contain two objects that have the state `instance` and
|
|
320
|
+
// method names to be used as action handlers (decorated with `@Action(InitState)`).
|
|
321
|
+
_actionTypeToHandlersMap = new Map();
|
|
322
|
+
constructor() {
|
|
323
|
+
inject(DestroyRef).onDestroy(() => this._actionTypeToHandlersMap.clear());
|
|
324
|
+
}
|
|
325
|
+
get(type) {
|
|
326
|
+
return this._actionTypeToHandlersMap.get(type);
|
|
327
|
+
}
|
|
328
|
+
register(type, handler) {
|
|
329
|
+
const handlers = this._actionTypeToHandlersMap.get(type) ?? new Set();
|
|
330
|
+
handlers.add(handler);
|
|
331
|
+
this._actionTypeToHandlersMap.set(type, handlers);
|
|
332
|
+
return () => {
|
|
333
|
+
const handlers = this._actionTypeToHandlersMap.get(type);
|
|
334
|
+
handlers.delete(handler);
|
|
335
|
+
};
|
|
296
336
|
}
|
|
297
|
-
/** @nocollapse */ static
|
|
298
|
-
/** @nocollapse */ static
|
|
337
|
+
/** @nocollapse */ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.0.3", ngImport: i0, type: ɵNgxsActionRegistry, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
338
|
+
/** @nocollapse */ static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.0.3", ngImport: i0, type: ɵNgxsActionRegistry, providedIn: 'root' });
|
|
299
339
|
}
|
|
300
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
340
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.0.3", ngImport: i0, type: ɵNgxsActionRegistry, decorators: [{
|
|
301
341
|
type: Injectable,
|
|
302
342
|
args: [{ providedIn: 'root' }]
|
|
303
343
|
}], ctorParameters: () => [] });
|
|
@@ -306,5 +346,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.0", ngImpor
|
|
|
306
346
|
* Generated bundle index. Do not edit.
|
|
307
347
|
*/
|
|
308
348
|
|
|
309
|
-
export { StateToken, ɵINITIAL_STATE_TOKEN, ɵInitialState, ɵMETA_KEY, ɵMETA_OPTIONS_KEY, ɵNGXS_STATE_CONTEXT_FACTORY, ɵNGXS_STATE_FACTORY, ɵNgxsAppBootstrappedState, ɵOrderedBehaviorSubject, ɵOrderedSubject, ɵSELECTOR_META_KEY, ɵStateStream, ɵensureSelectorMetadata, ɵensureStoreMetadata, ɵgetSelectorMetadata, ɵgetStoreMetadata, ɵmemoize, ɵwrapObserverCalls };
|
|
349
|
+
export { StateToken, ɵINITIAL_STATE_TOKEN, ɵInitialState, ɵMETA_KEY, ɵMETA_OPTIONS_KEY, ɵNGXS_STATE_CONTEXT_FACTORY, ɵNGXS_STATE_FACTORY, ɵNgxsActionRegistry, ɵNgxsAppBootstrappedState, ɵOrderedBehaviorSubject, ɵOrderedSubject, ɵSELECTOR_META_KEY, ɵStateStream, ɵdefineProperty, ɵensureSelectorMetadata, ɵensureStoreMetadata, ɵgetSelectorMetadata, ɵgetStoreMetadata, ɵhasOwnProperty, ɵmemoize, ɵwrapObserverCalls };
|
|
310
350
|
//# sourceMappingURL=ngxs-store-internals.mjs.map
|
|
@@ -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;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;AAEA;;;;AAIG;AACG,SAAU,iBAAiB,CAAC,MAA2B,EAAA;AAC3D,IAAA,OAAO,MAAM,CAAC,SAAS,CAAE;AAC3B;AAEA;;;;AAIG;AACG,SAAU,uBAAuB,CAAC,MAAgB,EAAA;IACtD,IAAI,CAAC,M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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
|
+
{"version":3,"file":"ngxs-store-internals.mjs","sources":["../../../packages/store/internals/src/symbols.ts","../../../packages/store/internals/src/object-utils.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/action-registry.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","// Property reads are not minified.\n// It's smaller to read it once and use a function.\nconst _hasOwnProperty = Object.prototype.hasOwnProperty;\nexport const ɵhasOwnProperty = (target: any, key: PropertyKey) =>\n _hasOwnProperty.call(target, key);\n\nexport const ɵdefineProperty = Object.defineProperty;\n","import { ɵdefineProperty, ɵhasOwnProperty } from './object-utils';\nimport {\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 (!ɵhasOwnProperty(target, ɵ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 ɵ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 (!ɵhasOwnProperty(target, ɵSELECTOR_META_KEY)) {\n const defaultMetadata: ɵSelectorMetaDataModel = {\n makeRootSelector: null,\n originalFn: null,\n containerClass: null,\n selectorName: null,\n getSelectorOptions: () => ({})\n };\n\n ɵ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 { DestroyRef, inject, Injectable } from '@angular/core';\nimport { BehaviorSubject } from 'rxjs';\n\n@Injectable({ providedIn: 'root' })\nexport class ɵNgxsAppBootstrappedState extends BehaviorSubject<boolean> {\n constructor() {\n super(false);\n\n const destroyRef = inject(DestroyRef);\n // Complete the subject once the root injector is destroyed to ensure\n // there are no active subscribers that would receive events or perform\n // any actions after the application is destroyed.\n destroyRef.onDestroy(() => this.complete());\n }\n\n bootstrap(): void {\n this.next(true);\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 override 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 override getValue(): T {\n return this._currentValue;\n }\n\n override next(value: T): void {\n this._currentValue = value;\n this._orderedNext(value);\n }\n}\n","import { type 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 { DestroyRef, inject, Injectable, 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> {\n readonly state: Signal<ɵPlainObject> = toSignal(this.pipe(ɵwrapObserverCalls(untracked)), {\n manualCleanup: true,\n requireSync: true\n });\n\n constructor() {\n super({});\n\n // Complete the subject once the root injector is destroyed to ensure\n // there are no active subscribers that would receive events or perform\n // any actions after the application is destroyed.\n // The `StateStream` should never emit values once the root view is removed,\n // such as when the `ApplicationRef.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 inject(DestroyRef).onDestroy(() => this.complete());\n }\n}\n","import { DestroyRef, inject, Injectable } from '@angular/core';\nimport type { Observable } from 'rxjs';\n\nexport type ActionHandlerFn = (action: any) => Observable<unknown>;\n\n@Injectable({ providedIn: 'root' })\nexport class ɵNgxsActionRegistry {\n // Instead of going over the states list every time an action is dispatched,\n // we are constructing a map of action types to lists of action metadata.\n // If the `@@Init` action is handled in two different states, the action\n // metadata list will contain two objects that have the state `instance` and\n // method names to be used as action handlers (decorated with `@Action(InitState)`).\n private readonly _actionTypeToHandlersMap = new Map<string, Set<ActionHandlerFn>>();\n\n constructor() {\n inject(DestroyRef).onDestroy(() => this._actionTypeToHandlersMap.clear());\n }\n\n get(type: string) {\n return this._actionTypeToHandlersMap.get(type);\n }\n\n register(type: string, handler: ActionHandlerFn) {\n const handlers = this._actionTypeToHandlersMap.get(type) ?? new Set();\n handlers.add(handler);\n this._actionTypeToHandlersMap.set(type, handlers);\n\n return () => {\n const handlers = this._actionTypeToHandlersMap.get(type)!;\n handlers.delete(handler);\n };\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;;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MAAM,QAAQ,GAAG,IAAI,CAAC,wBAAwB,CAAC,GAAG,CAAC,IAAI,CAAE;AACzD,YAAA,QAAQ,CAAC,MAAM,CAAC,OAAO,CAAC;AAC1B,SAAC;;0HAxBQ,mBAAmB,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,UAAA,EAAA,CAAA;AAAnB,uBAAA,OAAA,KAAA,GAAA,EAAA,CAAA,qBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,QAAA,EAAA,QAAA,EAAA,EAAA,EAAA,IAAA,EAAA,mBAAmB,cADN,MAAM,EAAA,CAAA;;2FACnB,mBAAmB,EAAA,UAAA,EAAA,CAAA;kBAD/B,UAAU;mBAAC,EAAE,UAAU,EAAE,MAAM,EAAE;;;ACLlC;;AAEG;;;;"}
|
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
const isArray = Array.isArray;
|
|
2
|
+
const isFunction = (value) => typeof value == 'function';
|
|
3
|
+
const isStateOperator = isFunction;
|
|
4
|
+
const isPredicate = isFunction;
|
|
5
|
+
const isNumber = (value) => typeof value === 'number';
|
|
6
|
+
const invalidIndex = (index) => Number.isNaN(index) || index === -1;
|
|
7
|
+
|
|
1
8
|
/**
|
|
2
9
|
* @param items - Specific items to append to the end of an array
|
|
3
10
|
*/
|
|
@@ -9,7 +16,7 @@ function append(items) {
|
|
|
9
16
|
if (itemsNotProvidedButExistingIs) {
|
|
10
17
|
return existing;
|
|
11
18
|
}
|
|
12
|
-
if (
|
|
19
|
+
if (isArray(existing)) {
|
|
13
20
|
return existing.concat(items);
|
|
14
21
|
}
|
|
15
22
|
// For example if some property is added dynamically
|
|
@@ -24,25 +31,6 @@ function compose(...operators) {
|
|
|
24
31
|
};
|
|
25
32
|
}
|
|
26
33
|
|
|
27
|
-
function isStateOperator(value) {
|
|
28
|
-
return typeof value === 'function';
|
|
29
|
-
}
|
|
30
|
-
function isUndefined(value) {
|
|
31
|
-
return typeof value === 'undefined';
|
|
32
|
-
}
|
|
33
|
-
function isPredicate(value) {
|
|
34
|
-
return typeof value === 'function';
|
|
35
|
-
}
|
|
36
|
-
function isNumber(value) {
|
|
37
|
-
return typeof value === 'number';
|
|
38
|
-
}
|
|
39
|
-
function invalidIndex(index) {
|
|
40
|
-
return Number.isNaN(index) || index === -1;
|
|
41
|
-
}
|
|
42
|
-
function isNil(value) {
|
|
43
|
-
return value === null || isUndefined(value);
|
|
44
|
-
}
|
|
45
|
-
|
|
46
34
|
function retrieveValue(operatorOrValue, existing) {
|
|
47
35
|
// If state operator is a function
|
|
48
36
|
// then call it with an original value
|
|
@@ -53,7 +41,7 @@ function retrieveValue(operatorOrValue, existing) {
|
|
|
53
41
|
// If operator or value was not provided
|
|
54
42
|
// e.g. `elseOperatorOrValue` is `undefined`
|
|
55
43
|
// then we just return an original value
|
|
56
|
-
if (
|
|
44
|
+
if (operatorOrValue === undefined) {
|
|
57
45
|
return existing;
|
|
58
46
|
}
|
|
59
47
|
return operatorOrValue;
|
|
@@ -88,11 +76,11 @@ function insertItem(value, beforePosition) {
|
|
|
88
76
|
return function insertItemOperator(existing) {
|
|
89
77
|
// Have to check explicitly for `null` and `undefined`
|
|
90
78
|
// because `value` can be `0`, thus `!value` will return `true`
|
|
91
|
-
if (
|
|
79
|
+
if (value == null && existing) {
|
|
92
80
|
return existing;
|
|
93
81
|
}
|
|
94
82
|
// Property may be dynamic and might not existed before
|
|
95
|
-
if (!
|
|
83
|
+
if (!isArray(existing)) {
|
|
96
84
|
return [value];
|
|
97
85
|
}
|
|
98
86
|
const clone = existing.slice();
|