@ngxs/store 19.0.0-dev.master-0d2e6d0 → 19.0.0-dev.master-56b9e7d
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.
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
|
-
import { InjectionToken,
|
|
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,
|
|
@@ -145,13 +145,17 @@ const ɵINITIAL_STATE_TOKEN = new InjectionToken(typeof ngDevMode !== 'undefined
|
|
|
145
145
|
factory: () => ɵInitialState.pop()
|
|
146
146
|
});
|
|
147
147
|
|
|
148
|
-
class ɵNgxsAppBootstrappedState extends
|
|
148
|
+
class ɵNgxsAppBootstrappedState extends BehaviorSubject {
|
|
149
149
|
constructor() {
|
|
150
|
-
super(
|
|
150
|
+
super(false);
|
|
151
|
+
const destroyRef = inject(DestroyRef);
|
|
152
|
+
// Complete the subject once the root injector is destroyed to ensure
|
|
153
|
+
// there are no active subscribers that would receive events or perform
|
|
154
|
+
// any actions after the application is destroyed.
|
|
155
|
+
destroyRef.onDestroy(() => this.complete());
|
|
151
156
|
}
|
|
152
157
|
bootstrap() {
|
|
153
158
|
this.next(true);
|
|
154
|
-
this.complete();
|
|
155
159
|
}
|
|
156
160
|
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.0", ngImport: i0, type: ɵNgxsAppBootstrappedState, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
157
161
|
/** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.0.0", ngImport: i0, type: ɵNgxsAppBootstrappedState, providedIn: 'root' }); }
|
|
@@ -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 { 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","/**\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;AAC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KAAK,EAAA;oBACT,QAAQ,CAAC,MAAM,UAAU,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;iBACxC;gBACD,QAAQ,GAAA;oBACN,QAAQ,CAAC,MAAM,UAAU,CAAC,QAAQ,EAAE,CAAC;;AAExC,aAAA,CAAC;AACJ,SAAC,CAAC;AACJ,KAAC;AACH;;ACbA;;;AAGG;AAEG,MAAO,YAAa,SAAQ,uBAAqC,CAAA;AAMrE,IAAA,WAAA,GAAA;QACE,KAAK,CAAC,EAAE,CAAC;AANF,QAAA,IAAA,CAAA,KAAK,GAAyB,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,kBAAkB,CAAC,SAAS,CAAC,CAAC,EAAE;AACxF,YAAA,aAAa,EAAE,IAAI;AACnB,YAAA,WAAW,EAAE;AACd,SAAA,CAAC;;;;;;;;;AAaA,QAAA,MAAM,CAAC,UAAU,CAAC,CAAC,SAAS,CAAC,MAAM,IAAI,CAAC,QAAQ,EAAE,CAAC;;iIAjB1C,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/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 { 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 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 { 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","/**\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,MAAM,CAAC,cAAc,CAAC,kBAAkB,CAAC,EAAE;AAC9C,QAAA,M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ACT,QAAQ,CAAC,MAAM,UAAU,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;iBACxC;gBACD,QAAQ,GAAA;oBACN,QAAQ,CAAC,MAAM,UAAU,CAAC,QAAQ,EAAE,CAAC;;AAExC,aAAA,CAAC;AACJ,SAAC,CAAC;AACJ,KAAC;AACH;;ACbA;;;AAGG;AAEG,MAAO,YAAa,SAAQ,uBAAqC,CAAA;AAMrE,IAAA,WAAA,GAAA;QACE,KAAK,CAAC,EAAE,CAAC;AANF,QAAA,IAAA,CAAA,KAAK,GAAyB,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,kBAAkB,CAAC,SAAS,CAAC,CAAC,EAAE;AACxF,YAAA,aAAa,EAAE,IAAI;AACnB,YAAA,WAAW,EAAE;AACd,SAAA,CAAC;;;;;;;;;AAaA,QAAA,MAAM,CAAC,UAAU,CAAC,CAAC,SAAS,CAAC,MAAM,IAAI,CAAC,QAAQ,EAAE,CAAC;;iIAjB1C,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;;;;"}
|
package/fesm2022/ngxs-store.mjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
2
|
import { Injectable, inject, NgZone, InjectionToken, INJECTOR, DestroyRef, Injector, runInInjectionContext, ErrorHandler, ɵisPromise as _isPromise, computed, makeEnvironmentProviders, ENVIRONMENT_INITIALIZER, NgModule, APP_BOOTSTRAP_LISTENER, PendingTasks } from '@angular/core';
|
|
3
|
-
import { config, Observable, Subject, filter, share, of, forkJoin, throwError, mergeMap as mergeMap$1, map as map$1, defaultIfEmpty, catchError, from, isObservable, takeUntil, finalize, shareReplay as shareReplay$1, distinctUntilChanged, take as take$1,
|
|
3
|
+
import { config, Observable, Subject, filter, share, of, forkJoin, throwError, mergeMap as mergeMap$1, map as map$1, defaultIfEmpty, catchError, from, isObservable, takeUntil, finalize, shareReplay as shareReplay$1, distinctUntilChanged, take as take$1, EMPTY, startWith, pairwise, buffer, debounceTime } from 'rxjs';
|
|
4
4
|
import { ɵwrapObserverCalls as _wrapObserverCalls, ɵOrderedSubject as _OrderedSubject, ɵStateStream as _StateStream, ɵ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';
|
|
6
|
-
import { map, shareReplay, filter as filter$1, take, mergeMap
|
|
6
|
+
import { map, shareReplay, filter as filter$1, take, mergeMap } from 'rxjs/operators';
|
|
7
7
|
import { NGXS_PLUGINS, getActionTypeFromInstance, InitState, UpdateState, setValue, getValue, ɵisPluginClass as _isPluginClass } from '@ngxs/store/plugins';
|
|
8
8
|
export { InitState, NGXS_PLUGINS, UpdateState, actionMatcher, getActionTypeFromInstance, getValue, setValue } from '@ngxs/store/plugins';
|
|
9
9
|
import { isStateOperator } from '@ngxs/store/operators';
|
|
@@ -1710,8 +1710,6 @@ class LifecycleStateManager {
|
|
|
1710
1710
|
this._internalStateOperations = inject(InternalStateOperations);
|
|
1711
1711
|
this._stateContextFactory = inject(StateContextFactory);
|
|
1712
1712
|
this._appBootstrappedState = inject(_NgxsAppBootstrappedState);
|
|
1713
|
-
this._destroy$ = new ReplaySubject(1);
|
|
1714
|
-
inject(DestroyRef).onDestroy(() => this._destroy$.next());
|
|
1715
1713
|
}
|
|
1716
1714
|
ngxsBootstrap(action, results) {
|
|
1717
1715
|
if (typeof ngDevMode !== 'undefined' && ngDevMode) {
|
|
@@ -1729,19 +1727,35 @@ class LifecycleStateManager {
|
|
|
1729
1727
|
console.error(getInvalidInitializationOrderMessage(action.addedStates));
|
|
1730
1728
|
}
|
|
1731
1729
|
}
|
|
1730
|
+
// It does not need to unsubscribe because it is completed when the
|
|
1731
|
+
// root injector is destroyed.
|
|
1732
1732
|
this._internalStateOperations
|
|
1733
1733
|
.getRootStateOperations()
|
|
1734
1734
|
.dispatch(action)
|
|
1735
|
-
.pipe(
|
|
1736
|
-
|
|
1735
|
+
.pipe(mergeMap$1(() => {
|
|
1736
|
+
// If no states are provided, we safely complete the stream
|
|
1737
|
+
// and do not proceed further.
|
|
1738
|
+
if (!results) {
|
|
1739
|
+
return EMPTY;
|
|
1740
|
+
}
|
|
1741
|
+
this._invokeInitOnStates(results.states);
|
|
1742
|
+
return this._appBootstrappedState;
|
|
1743
|
+
}))
|
|
1744
|
+
.subscribe(appBootstrapped => {
|
|
1745
|
+
if (appBootstrapped) {
|
|
1746
|
+
this._invokeBootstrapOnStates(results.states);
|
|
1747
|
+
}
|
|
1748
|
+
});
|
|
1737
1749
|
}
|
|
1738
1750
|
_invokeInitOnStates(mappedStores) {
|
|
1739
1751
|
for (const mappedStore of mappedStores) {
|
|
1740
1752
|
const instance = mappedStore.instance;
|
|
1741
1753
|
if (instance.ngxsOnChanges) {
|
|
1754
|
+
// It does not need to unsubscribe because it is completed when the
|
|
1755
|
+
// root injector is destroyed.
|
|
1742
1756
|
this._store
|
|
1743
1757
|
.select(state => getValue(state, mappedStore.path))
|
|
1744
|
-
.pipe(startWith(undefined), pairwise()
|
|
1758
|
+
.pipe(startWith(undefined), pairwise())
|
|
1745
1759
|
.subscribe(([previousValue, currentValue]) => {
|
|
1746
1760
|
const change = new NgxsSimpleChange(previousValue, currentValue, !mappedStore.isInitialised);
|
|
1747
1761
|
instance.ngxsOnChanges(change);
|
|
@@ -1770,7 +1784,7 @@ class LifecycleStateManager {
|
|
|
1770
1784
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.0", ngImport: i0, type: LifecycleStateManager, decorators: [{
|
|
1771
1785
|
type: Injectable,
|
|
1772
1786
|
args: [{ providedIn: 'root' }]
|
|
1773
|
-
}]
|
|
1787
|
+
}] });
|
|
1774
1788
|
|
|
1775
1789
|
/**
|
|
1776
1790
|
* This function is shared by both NgModule and standalone features.
|