@ngxs/store 18.1.5-dev.master-c73c22f → 18.1.5-dev.master-e14b71b
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/esm2022/internals/initial-state.mjs +2 -3
- package/esm2022/internals/internal-tokens.mjs +3 -4
- package/esm2022/plugins/symbols.mjs +2 -3
- package/esm2022/src/dev-features/symbols.mjs +2 -3
- package/esm2022/src/execution/symbols.mjs +3 -4
- package/esm2022/src/internal/dispatcher.mjs +27 -4
- package/esm2022/src/internal/internals.mjs +4 -5
- package/esm2022/src/internal/lifecycle-state-manager.mjs +2 -3
- package/esm2022/src/internal/state-factory.mjs +5 -6
- package/esm2022/src/selectors/selector-utils.mjs +2 -3
- package/esm2022/src/standalone-features/initializers.mjs +3 -4
- package/esm2022/src/standalone-features/preboot.mjs +2 -3
- package/esm2022/src/store.mjs +2 -3
- package/esm2022/src/symbols.mjs +4 -5
- package/fesm2022/ngxs-store-internals.mjs +3 -5
- package/fesm2022/ngxs-store-internals.mjs.map +1 -1
- package/fesm2022/ngxs-store-plugins.mjs +1 -2
- package/fesm2022/ngxs-store-plugins.mjs.map +1 -1
- package/fesm2022/ngxs-store.mjs +45 -57
- package/fesm2022/ngxs-store.mjs.map +1 -1
- package/package.json +7 -7
- package/esm2022/src/utils/compose.mjs +0 -26
|
@@ -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\nconst NG_DEV_MODE = typeof ngDevMode !== 'undefined' && ngDevMode;\n\nexport class ɵInitialState {\n private static _value: ɵPlainObject = {};\n\n static set(state: ɵPlainObject) {\n this._value = state;\n }\n\n static pop(): ɵPlainObject {\n const state = this._value;\n this._value = {};\n return state;\n }\n}\n\nexport const ɵINITIAL_STATE_TOKEN = new InjectionToken<ɵPlainObject>(\n NG_DEV_MODE ? 'INITIAL_STATE_TOKEN' : '',\n {\n providedIn: 'root',\n factory: () => ɵInitialState.pop()\n }\n);\n","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\nconst NG_DEV_MODE = typeof ngDevMode !== 'undefined' && ngDevMode;\n\n// These tokens are internal and can change at any point.\n\nexport const ɵNGXS_STATE_FACTORY = /* @__PURE__ */ new InjectionToken<any>(\n NG_DEV_MODE ? 'ɵNGXS_STATE_FACTORY' : ''\n);\n\nexport const ɵNGXS_STATE_CONTEXT_FACTORY = /* @__PURE__ */ new InjectionToken<any>(\n NG_DEV_MODE ? 'ɵ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"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sources":["../../../packages/store/internals/src/symbols.ts","../../../packages/store/internals/src/metadata.ts","../../../packages/store/internals/src/memoize.ts","../../../packages/store/internals/src/state-token.ts","../../../packages/store/internals/src/initial-state.ts","../../../packages/store/internals/src/ngxs-app-bootstrapped-state.ts","../../../packages/store/internals/src/internal-tokens.ts","../../../packages/store/internals/src/custom-rxjs-subjects.ts","../../../packages/store/internals/src/custom-rxjs-operators.ts","../../../packages/store/internals/src/state-stream.ts","../../../packages/store/internals/src/ngxs-store-internals.ts"],"sourcesContent":["import type { StateToken } from './state-token';\n\nexport interface ɵPlainObject {\n [key: string]: any;\n}\n\nexport interface ɵPlainObjectOf<T> {\n [key: string]: T;\n}\n\nexport type ɵStateClass<T = any> = new (...args: any[]) => T;\n\n// This key is used to store metadata on state classes,\n// such as actions and other related information.\nexport const ɵMETA_KEY = 'NGXS_META';\n// This key is used to store options on state classes\n// provided through the `@State` decorator.\nexport const ɵMETA_OPTIONS_KEY = 'NGXS_OPTIONS_META';\n// This key is used to store selector metadata on selector functions,\n// such as decorated with the `@Selector` or provided through the\n// `createSelector` function.\nexport const ɵSELECTOR_META_KEY = 'NGXS_SELECTOR_META';\n\nexport interface ɵStateToken<T, U> {\n new (name: ɵTokenName<T>): U;\n getName(): string;\n toString(): string;\n}\n\ntype RequireGeneric<T, U> = T extends void ? 'You must provide a type parameter' : U;\n\nexport type ɵTokenName<T> = string & RequireGeneric<T, string>;\n\nexport type ɵExtractTokenType<P> = P extends StateToken<infer T> ? T : never;\n\n/**\n * Options that can be provided to the store.\n */\nexport interface ɵStoreOptions<T> {\n /**\n * Name of the state. Required.\n */\n name: string | StateToken<T>;\n\n /**\n * Default values for the state. If not provided, uses empty object.\n */\n defaults?: T;\n\n /**\n * Sub states for the given state.\n *\n * @deprecated\n * Read the deprecation notice at this link: https://ngxs.io/deprecations/sub-states-deprecation.\n */\n children?: ɵStateClass[];\n}\n\n// inspired from https://stackoverflow.com/a/43674389\nexport interface ɵStateClassInternal<T = any, U = any> extends ɵStateClass<T> {\n [ɵMETA_KEY]?: ɵMetaDataModel;\n [ɵMETA_OPTIONS_KEY]?: ɵStoreOptions<U>;\n}\n\nexport interface ɵMetaDataModel {\n name: string | null;\n actions: ɵPlainObjectOf<ɵActionHandlerMetaData[]>;\n defaults: any;\n path: string | null;\n makeRootSelector: ɵSelectorFactory | null;\n /** @deprecated */\n children?: ɵStateClassInternal[];\n}\n\nexport interface ɵSelectorMetaDataModel {\n makeRootSelector: ɵSelectorFactory | null;\n originalFn: Function | null;\n containerClass: any;\n selectorName: string | null;\n getSelectorOptions: () => ɵSharedSelectorOptions;\n}\n\nexport interface ɵSharedSelectorOptions {\n /**\n * @deprecated\n * Read the deprecation notice at this link: https://ngxs.io/deprecations/inject-container-state-deprecation.md.\n */\n injectContainerState?: boolean;\n suppressErrors?: boolean;\n}\n\nexport interface ɵRuntimeSelectorContext {\n getStateGetter(key: any): (state: any) => any;\n getSelectorOptions(localOptions?: ɵSharedSelectorOptions): ɵSharedSelectorOptions;\n}\n\nexport type ɵSelectFromRootState = (rootState: any) => any;\nexport type ɵSelectorFactory = (\n runtimeContext: ɵRuntimeSelectorContext\n) => ɵSelectFromRootState;\n\n/**\n * Actions that can be provided in a action decorator.\n */\nexport interface ɵActionOptions {\n /**\n * Cancel the previous uncompleted observable(s).\n */\n cancelUncompleted?: boolean;\n}\n\nexport interface ɵActionHandlerMetaData {\n fn: string | symbol;\n options: ɵActionOptions;\n type: string;\n}\n","import {\n ɵMETA_KEY,\n ɵSELECTOR_META_KEY,\n ɵMetaDataModel,\n ɵStateClassInternal,\n ɵSelectorMetaDataModel,\n ɵRuntimeSelectorContext\n} from './symbols';\n\n/**\n * Ensures metadata is attached to the class and returns it.\n *\n * @ignore\n */\nexport function ɵensureStoreMetadata(target: ɵStateClassInternal): ɵMetaDataModel {\n if (!target.hasOwnProperty(ɵMETA_KEY)) {\n const defaultMetadata: ɵMetaDataModel = {\n name: null,\n actions: {},\n defaults: {},\n path: null,\n makeRootSelector(context: ɵRuntimeSelectorContext) {\n return context.getStateGetter(defaultMetadata.name);\n },\n children: []\n };\n\n Object.defineProperty(target, ɵMETA_KEY, { value: defaultMetadata });\n }\n return ɵgetStoreMetadata(target);\n}\n\n/**\n * Get the metadata attached to the state class if it exists.\n *\n * @ignore\n */\nexport function ɵgetStoreMetadata(target: ɵStateClassInternal): ɵMetaDataModel {\n return target[ɵMETA_KEY]!;\n}\n\n/**\n * Ensures metadata is attached to the selector and returns it.\n *\n * @ignore\n */\nexport function ɵensureSelectorMetadata(target: Function): ɵSelectorMetaDataModel {\n if (!target.hasOwnProperty(ɵSELECTOR_META_KEY)) {\n const defaultMetadata: ɵSelectorMetaDataModel = {\n makeRootSelector: null,\n originalFn: null,\n containerClass: null,\n selectorName: null,\n getSelectorOptions: () => ({})\n };\n\n Object.defineProperty(target, ɵSELECTOR_META_KEY, { value: defaultMetadata });\n }\n\n return ɵgetSelectorMetadata(target);\n}\n\n/**\n * Get the metadata attached to the selector if it exists.\n *\n * @ignore\n */\nexport function ɵgetSelectorMetadata(target: any): ɵSelectorMetaDataModel {\n return target[ɵSELECTOR_META_KEY];\n}\n","function areArgumentsShallowlyEqual(\n equalityCheck: (a: any, b: any) => boolean,\n prev: IArguments | null,\n next: IArguments | null\n) {\n if (prev === null || next === null || prev.length !== next.length) {\n return false;\n }\n\n // Do this in a for loop (and not a `forEach` or an `every`) so we can\n // determine equality as fast as possible.\n const length = prev.length;\n for (let i = 0; i < length; i++) {\n if (!equalityCheck(prev[i], next[i])) {\n return false;\n }\n }\n\n return true;\n}\n\n/**\n * Memoize a function on its last inputs only.\n * Originally from: https://github.com/reduxjs/reselect/blob/master/src/index.js\n *\n * @ignore\n */\nexport function ɵmemoize<T extends (...args: any[]) => any>(\n func: T,\n equalityCheck = Object.is\n): T {\n let lastArgs: IArguments | null = null;\n let lastResult: any = null;\n // we reference arguments instead of spreading them for performance reasons\n function memoized() {\n // eslint-disable-next-line prefer-rest-params\n if (!areArgumentsShallowlyEqual(equalityCheck, lastArgs, arguments)) {\n // apply arguments instead of spreading for performance.\n // eslint-disable-next-line prefer-rest-params, prefer-spread\n lastResult = (<Function>func).apply(null, arguments);\n }\n // eslint-disable-next-line prefer-rest-params\n lastArgs = arguments;\n return lastResult;\n }\n (<any>memoized).reset = function () {\n // The hidden (for now) ability to reset the memoization\n lastArgs = null;\n lastResult = null;\n };\n return memoized as T;\n}\n","import { ɵensureSelectorMetadata } from './metadata';\nimport type { ɵTokenName, ɵSelectFromRootState, ɵRuntimeSelectorContext } from './symbols';\n\nexport class StateToken<T = void> {\n constructor(private readonly _name: ɵTokenName<T>) {\n const selectorMetadata = ɵensureSelectorMetadata(<any>this);\n selectorMetadata.makeRootSelector = (\n runtimeContext: ɵRuntimeSelectorContext\n ): ɵSelectFromRootState => {\n return runtimeContext.getStateGetter(this._name);\n };\n }\n\n getName(): string {\n return this._name;\n }\n\n toString(): string {\n return `StateToken[${this._name}]`;\n }\n}\n","import { InjectionToken } from '@angular/core';\n\nimport { ɵPlainObject } from './symbols';\n\ndeclare const ngDevMode: boolean;\n\nexport class ɵInitialState {\n private static _value: ɵPlainObject = {};\n\n static set(state: ɵPlainObject) {\n this._value = state;\n }\n\n static pop(): ɵPlainObject {\n const state = this._value;\n this._value = {};\n return state;\n }\n}\n\nexport const ɵINITIAL_STATE_TOKEN = new InjectionToken<ɵPlainObject>(\n typeof ngDevMode !== 'undefined' && ngDevMode ? 'INITIAL_STATE_TOKEN' : '',\n {\n providedIn: 'root',\n factory: () => ɵInitialState.pop()\n }\n);\n","import { Injectable } from '@angular/core';\nimport { ReplaySubject } from 'rxjs';\n\n@Injectable({ providedIn: 'root' })\nexport class ɵNgxsAppBootstrappedState extends ReplaySubject<boolean> {\n constructor() {\n super(1);\n }\n\n bootstrap(): void {\n this.next(true);\n this.complete();\n }\n}\n","import { InjectionToken } from '@angular/core';\n\ndeclare const ngDevMode: boolean;\n\n// These tokens are internal and can change at any point.\n\nexport const ɵNGXS_STATE_FACTORY = /* @__PURE__ */ new InjectionToken<any>(\n typeof ngDevMode !== 'undefined' && ngDevMode ? 'ɵNGXS_STATE_FACTORY' : ''\n);\n\nexport const ɵNGXS_STATE_CONTEXT_FACTORY = /* @__PURE__ */ new InjectionToken<any>(\n typeof ngDevMode !== 'undefined' && ngDevMode ? 'ɵNGXS_STATE_CONTEXT_FACTORY' : ''\n);\n","import { BehaviorSubject, Subject } from 'rxjs';\n\n/**\n * This wraps the provided function, and will enforce the following:\n * - The calls will execute in the order that they are made\n * - A call will only be initiated when the previous call has completed\n * - If there is a call currently executing then the new call will be added\n * to the queue and the function will return immediately\n *\n * NOTE: The following assumptions about the operation must hold true:\n * - The operation is synchronous in nature\n * - If any asynchronous side effects of the call exist, it should not\n * have any bearing on the correctness of the next call in the queue\n * - The operation has a void return\n * - The caller should not assume that the call has completed upon\n * return of the function\n * - The caller can assume that all the queued calls will complete\n * within the current microtask\n * - The only way that a call will encounter another call in the queue\n * would be if the call at the front of the queue initiated this call\n * as part of its synchronous execution\n */\nfunction orderedQueueOperation<TArgs extends any[]>(operation: (...args: TArgs) => void) {\n const callsQueue: TArgs[] = [];\n let busyPushingNext = false;\n return function callOperation(...args: TArgs) {\n if (busyPushingNext) {\n callsQueue.unshift(args);\n return;\n }\n busyPushingNext = true;\n operation(...args);\n while (callsQueue.length > 0) {\n const nextCallArgs = callsQueue.pop();\n nextCallArgs && operation(...nextCallArgs);\n }\n busyPushingNext = false;\n };\n}\n\n/**\n * Custom Subject that ensures that subscribers are notified of values in the order that they arrived.\n * A standard Subject does not have this guarantee.\n * For example, given the following code:\n * ```typescript\n * const subject = new Subject<string>();\n subject.subscribe(value => {\n if (value === 'start') subject.next('end');\n });\n subject.subscribe(value => { });\n subject.next('start');\n * ```\n * When `subject` is a standard `Subject<T>` the second subscriber would recieve `end` and then `start`.\n * When `subject` is a `OrderedSubject<T>` the second subscriber would recieve `start` and then `end`.\n */\nexport class ɵOrderedSubject<T> extends Subject<T> {\n private _orderedNext = orderedQueueOperation((value?: T) => super.next(<T>value));\n\n next(value?: T): void {\n this._orderedNext(value);\n }\n}\n\n/**\n * Custom BehaviorSubject that ensures that subscribers are notified of values in the order that they arrived.\n * A standard BehaviorSubject does not have this guarantee.\n * For example, given the following code:\n * ```typescript\n * const subject = new BehaviorSubject<string>();\n subject.subscribe(value => {\n if (value === 'start') subject.next('end');\n });\n subject.subscribe(value => { });\n subject.next('start');\n * ```\n * When `subject` is a standard `BehaviorSubject<T>` the second subscriber would recieve `end` and then `start`.\n * When `subject` is a `OrderedBehaviorSubject<T>` the second subscriber would recieve `start` and then `end`.\n */\nexport class ɵOrderedBehaviorSubject<T> extends BehaviorSubject<T> {\n private _orderedNext = orderedQueueOperation((value: T) => super.next(value));\n private _currentValue: T;\n\n constructor(value: T) {\n super(value);\n this._currentValue = value;\n }\n\n getValue(): T {\n return this._currentValue;\n }\n\n next(value: T): void {\n this._currentValue = value;\n this._orderedNext(value);\n }\n}\n","import { MonoTypeOperatorFunction, Observable } from 'rxjs';\n\nexport function ɵwrapObserverCalls<TValue>(\n invokeFn: (fn: () => void) => void\n): MonoTypeOperatorFunction<TValue> {\n return (source: Observable<TValue>) => {\n return new Observable<TValue>(subscriber => {\n return source.subscribe({\n next(value) {\n invokeFn(() => subscriber.next(value));\n },\n error(error) {\n invokeFn(() => subscriber.error(error));\n },\n complete() {\n invokeFn(() => subscriber.complete());\n }\n });\n });\n };\n}\n","import { Injectable, OnDestroy, Signal, untracked } from '@angular/core';\nimport { toSignal } from '@angular/core/rxjs-interop';\n\nimport { ɵwrapObserverCalls } from './custom-rxjs-operators';\nimport { ɵOrderedBehaviorSubject } from './custom-rxjs-subjects';\nimport { ɵPlainObject } from './symbols';\n\n/**\n * BehaviorSubject of the entire state.\n * @ignore\n */\n@Injectable({ providedIn: 'root' })\nexport class ɵStateStream extends ɵOrderedBehaviorSubject<ɵPlainObject> implements OnDestroy {\n readonly state: Signal<ɵPlainObject> = toSignal(this.pipe(ɵwrapObserverCalls(untracked)), {\n manualCleanup: true,\n requireSync: true\n });\n\n constructor() {\n super({});\n }\n\n ngOnDestroy(): void {\n // The StateStream should never emit values once the root view is removed,\n // such as when the `NgModuleRef.destroy()` method is called. This is crucial\n // for preventing memory leaks in server-side rendered apps, where a new StateStream\n // is created for each HTTP request. If users forget to unsubscribe from `store.select`\n // or `store.subscribe`, it can result in significant memory leaks in SSR apps.\n this.complete();\n }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;AAYA;AACA;AACO,MAAM,SAAS,GAAG,YAAY;AACrC;AACA;AACO,MAAM,iBAAiB,GAAG,oBAAoB;AACrD;AACA;AACA;AACO,MAAM,kBAAkB,GAAG;;ACZlC;;;;AAIG;AACG,SAAU,oBAAoB,CAAC,MAA2B,EAAA;IAC9D,IAAI,CAAC,MAAM,CAAC,cAAc,CAAC,SAAS,CAAC,EAAE;AACrC,QAAA,MAAM,eAAe,GAAmB;AACtC,YAAA,IAAI,EAAE,IAAI;AACV,YAAA,OAAO,EAAE,EAAE;AACX,YAAA,QAAQ,EAAE,EAAE;AACZ,YAAA,IAAI,EAAE,IAAI;AACV,YAAA,gBAAgB,CAAC,OAAgC,EAAA;gBAC/C,OAAO,OAAO,CAAC,cAAc,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;aACrD;AACD,YAAA,QAAQ,EAAE,EAAE;SACb,CAAC;AAEF,QAAA,MAAM,CAAC,cAAc,CAAC,MAAM,EAAE,SAAS,EAAE,EAAE,KAAK,EAAE,eAAe,EAAE,CAAC,CAAC;KACtE;AACD,IAAA,OAAO,iBAAiB,CAAC,MAAM,CAAC,CAAC;AACnC,CAAC;AAED;;;;AAIG;AACG,SAAU,iBAAiB,CAAC,MAA2B,EAAA;AAC3D,IAAA,OAAO,MAAM,CAAC,SAAS,CAAE,CAAC;AAC5B,CAAC;AAED;;;;AAIG;AACG,SAAU,uBAAuB,CAAC,MAAgB,EAAA;IACtD,IAAI,CAAC,MAAM,CAAC,cAAc,CAAC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EAAA,EAAA,IAAA,EAAA,YAAY,cADC,MAAM,EAAA,CAAA,CAAA,EAAA;;2FACnB,YAAY,EAAA,UAAA,EAAA,CAAA;kBADxB,UAAU;mBAAC,EAAE,UAAU,EAAE,MAAM,EAAE,CAAA;;;ACXlC;;AAEG;;;;"}
|
|
@@ -16,10 +16,9 @@ class UpdateState {
|
|
|
16
16
|
}
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
-
const NG_DEV_MODE = typeof ngDevMode !== 'undefined' && ngDevMode;
|
|
20
19
|
// The injection token is used to resolve to custom NGXS plugins provided
|
|
21
20
|
// at the root level through either `{provide}` scheme or `withNgxsPlugin`.
|
|
22
|
-
const NGXS_PLUGINS = new InjectionToken(
|
|
21
|
+
const NGXS_PLUGINS = new InjectionToken(typeof ngDevMode !== 'undefined' && ngDevMode ? 'NGXS_PLUGINS' : '');
|
|
23
22
|
|
|
24
23
|
/**
|
|
25
24
|
* Returns the type from an action instance/class.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ngxs-store-plugins.mjs","sources":["../../../packages/store/plugins/src/actions.ts","../../../packages/store/plugins/src/symbols.ts","../../../packages/store/plugins/src/utils.ts","../../../packages/store/plugins/src/ngxs-store-plugins.ts"],"sourcesContent":["import { ɵPlainObject } from '@ngxs/store/internals';\n\n/**\n * Init action\n */\nexport class InitState {\n static readonly type = '@@INIT';\n}\n\n/**\n * Update action\n */\nexport class UpdateState {\n static readonly type = '@@UPDATE_STATE';\n\n constructor(readonly addedStates?: ɵPlainObject) {}\n}\n","import { InjectionToken } from '@angular/core';\n\ndeclare const ngDevMode: boolean;\n\
|
|
1
|
+
{"version":3,"file":"ngxs-store-plugins.mjs","sources":["../../../packages/store/plugins/src/actions.ts","../../../packages/store/plugins/src/symbols.ts","../../../packages/store/plugins/src/utils.ts","../../../packages/store/plugins/src/ngxs-store-plugins.ts"],"sourcesContent":["import { ɵPlainObject } from '@ngxs/store/internals';\n\n/**\n * Init action\n */\nexport class InitState {\n static readonly type = '@@INIT';\n}\n\n/**\n * Update action\n */\nexport class UpdateState {\n static readonly type = '@@UPDATE_STATE';\n\n constructor(readonly addedStates?: ɵPlainObject) {}\n}\n","import { InjectionToken } from '@angular/core';\n\ndeclare const ngDevMode: boolean;\n\n// The injection token is used to resolve to custom NGXS plugins provided\n// at the root level through either `{provide}` scheme or `withNgxsPlugin`.\nexport const NGXS_PLUGINS = new InjectionToken(\n typeof ngDevMode !== 'undefined' && ngDevMode ? 'NGXS_PLUGINS' : ''\n);\n\nexport type NgxsPluginFn = (state: any, mutation: any, next: NgxsNextPluginFn) => any;\n\nexport type NgxsNextPluginFn = (state: any, mutation: any) => any;\n\n/**\n * Plugin interface\n */\nexport interface NgxsPlugin {\n /**\n * Handle the state/action before its submitted to the state handlers.\n */\n handle(state: any, action: any, next: NgxsNextPluginFn): any;\n}\n","/**\n * Returns the type from an action instance/class.\n * @ignore\n */\nexport function getActionTypeFromInstance(action: any): string | undefined {\n return action.constructor?.type || action.type;\n}\n\n/**\n * Matches a action\n * @ignore\n */\nexport function actionMatcher(action1: any) {\n const type1 = getActionTypeFromInstance(action1);\n\n return function (action2: any) {\n return type1 === getActionTypeFromInstance(action2);\n };\n}\n\n/**\n * Set a deeply nested value. Example:\n *\n * setValue({ foo: { bar: { eat: false } } },\n * 'foo.bar.eat', true) //=> { foo: { bar: { eat: true } } }\n *\n * While it traverses it also creates new objects from top down.\n *\n * @ignore\n */\nexport const setValue = (obj: any, prop: string, val: any) => {\n obj = { ...obj };\n\n const split = prop.split('.');\n const lastIndex = split.length - 1;\n\n split.reduce((acc, part, index) => {\n if (index === lastIndex) {\n acc[part] = val;\n } else {\n acc[part] = Array.isArray(acc[part]) ? acc[part].slice() : { ...acc[part] };\n }\n\n return acc && acc[part];\n }, obj);\n\n return obj;\n};\n\n/**\n * Get a deeply nested value. Example:\n *\n * getValue({ foo: bar: [] }, 'foo.bar') //=> []\n *\n * @ignore\n */\nexport const getValue = (obj: any, prop: string): any =>\n prop.split('.').reduce((acc: any, part: string) => acc && acc[part], obj);\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;AAEA;;AAEG;MACU,SAAS,CAAA;aACJ,IAAI,CAAA,IAAA,GAAG,QAAQ,CAAC,EAAA;;AAGlC;;AAEG;MACU,WAAW,CAAA;aACN,IAAI,CAAA,IAAA,GAAG,gBAAgB,CAAC,EAAA;AAExC,IAAA,WAAA,CAAqB,WAA0B,EAAA;QAA1B,IAAW,CAAA,WAAA,GAAX,WAAW,CAAe;KAAI;;;ACXrD;AACA;MACa,YAAY,GAAG,IAAI,cAAc,CAC5C,OAAO,SAAS,KAAK,WAAW,IAAI,SAAS,GAAG,cAAc,GAAG,EAAE;;ACPrE;;;AAGG;AACG,SAAU,yBAAyB,CAAC,MAAW,EAAA;IACnD,OAAO,MAAM,CAAC,WAAW,EAAE,IAAI,IAAI,MAAM,CAAC,IAAI,CAAC;AACjD,CAAC;AAED;;;AAGG;AACG,SAAU,aAAa,CAAC,OAAY,EAAA;AACxC,IAAA,MAAM,KAAK,GAAG,yBAAyB,CAAC,OAAO,CAAC,CAAC;AAEjD,IAAA,OAAO,UAAU,OAAY,EAAA;AAC3B,QAAA,OAAO,KAAK,KAAK,yBAAyB,CAAC,OAAO,CAAC,CAAC;AACtD,KAAC,CAAC;AACJ,CAAC;AAED;;;;;;;;;AASG;AACU,MAAA,QAAQ,GAAG,CAAC,GAAQ,EAAE,IAAY,EAAE,GAAQ,KAAI;AAC3D,IAAA,GAAG,GAAG,EAAE,GAAG,GAAG,EAAE,CAAC;IAEjB,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;AAC9B,IAAA,MAAM,SAAS,GAAG,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC;IAEnC,KAAK,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,IAAI,EAAE,KAAK,KAAI;AAChC,QAAA,IAAI,KAAK,KAAK,SAAS,EAAE;AACvB,YAAA,GAAG,CAAC,IAAI,CAAC,GAAG,GAAG,CAAC;SACjB;aAAM;AACL,YAAA,GAAG,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,GAAG,GAAG,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,GAAG,EAAE,GAAG,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;SAC7E;AAED,QAAA,OAAO,GAAG,IAAI,GAAG,CAAC,IAAI,CAAC,CAAC;KACzB,EAAE,GAAG,CAAC,CAAC;AAER,IAAA,OAAO,GAAG,CAAC;AACb,EAAE;AAEF;;;;;;AAMG;AACU,MAAA,QAAQ,GAAG,CAAC,GAAQ,EAAE,IAAY,KAC7C,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,GAAQ,EAAE,IAAY,KAAK,GAAG,IAAI,GAAG,CAAC,IAAI,CAAC,EAAE,GAAG;;ACzD1E;;AAEG;;;;"}
|
package/fesm2022/ngxs-store.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
|
-
import { Injectable, inject, NgZone, PLATFORM_ID, InjectionToken, INJECTOR,
|
|
2
|
+
import { Injectable, inject, NgZone, PLATFORM_ID, InjectionToken, INJECTOR, Injector, runInInjectionContext, ErrorHandler, ɵisPromise as _isPromise, computed, makeEnvironmentProviders, ENVIRONMENT_INITIALIZER, NgModule, APP_BOOTSTRAP_LISTENER } from '@angular/core';
|
|
3
3
|
import { Subject, filter, Observable, share, config, of, forkJoin, throwError, EMPTY, mergeMap, map as map$1, defaultIfEmpty, catchError, from, isObservable, takeUntil, finalize, shareReplay as shareReplay$1, distinctUntilChanged, take as take$1, ReplaySubject } 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';
|
|
@@ -120,18 +120,17 @@ function verifyZoneIsNotNooped(ngZone) {
|
|
|
120
120
|
console.warn(getZoneWarningMessage());
|
|
121
121
|
}
|
|
122
122
|
|
|
123
|
-
const NG_DEV_MODE$9 = typeof ngDevMode !== 'undefined' && ngDevMode;
|
|
124
123
|
/**
|
|
125
124
|
* Consumers have the option to utilize the execution strategy provided by
|
|
126
125
|
* `NgxsModule.forRoot({executionStrategy})` or `provideStore([], {executionStrategy})`.
|
|
127
126
|
*/
|
|
128
|
-
const CUSTOM_NGXS_EXECUTION_STRATEGY = new InjectionToken(
|
|
127
|
+
const CUSTOM_NGXS_EXECUTION_STRATEGY = new InjectionToken(typeof ngDevMode !== 'undefined' && ngDevMode ? 'CUSTOM_NGXS_EXECUTION_STRATEGY' : '');
|
|
129
128
|
/**
|
|
130
129
|
* The injection token is used internally to resolve an instance of the execution
|
|
131
130
|
* strategy. It checks whether consumers have provided their own `executionStrategy`
|
|
132
131
|
* and also verifies if we are operating in a zone-aware environment.
|
|
133
132
|
*/
|
|
134
|
-
const NGXS_EXECUTION_STRATEGY = new InjectionToken(
|
|
133
|
+
const NGXS_EXECUTION_STRATEGY = new InjectionToken(typeof ngDevMode !== 'undefined' && ngDevMode ? 'NGXS_EXECUTION_STRATEGY' : '', {
|
|
135
134
|
providedIn: 'root',
|
|
136
135
|
factory: () => {
|
|
137
136
|
const ngZone = inject(NgZone);
|
|
@@ -164,32 +163,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.0.6", ngImpor
|
|
|
164
163
|
args: [{ providedIn: 'root' }]
|
|
165
164
|
}] });
|
|
166
165
|
|
|
167
|
-
/**
|
|
168
|
-
* Composes a array of functions from left to right. Example:
|
|
169
|
-
*
|
|
170
|
-
* compose([fn, final])(state, action);
|
|
171
|
-
*
|
|
172
|
-
* then the funcs have a signature like:
|
|
173
|
-
*
|
|
174
|
-
* function fn (state, action, next) {
|
|
175
|
-
* console.log('here', state, action, next);
|
|
176
|
-
* return next(state, action);
|
|
177
|
-
* }
|
|
178
|
-
*
|
|
179
|
-
* function final (state, action) {
|
|
180
|
-
* console.log('here', state, action);
|
|
181
|
-
* return state;
|
|
182
|
-
* }
|
|
183
|
-
*
|
|
184
|
-
* the last function should not call `next`.
|
|
185
|
-
*
|
|
186
|
-
* @ignore
|
|
187
|
-
*/
|
|
188
|
-
const compose = (funcs) => (...args) => {
|
|
189
|
-
const curr = funcs.shift();
|
|
190
|
-
return curr(...args, (...nextArgs) => compose(funcs)(...nextArgs));
|
|
191
|
-
};
|
|
192
|
-
|
|
193
166
|
/**
|
|
194
167
|
* Returns operator that will run
|
|
195
168
|
* `subscribe` outside of the ngxs execution context
|
|
@@ -370,6 +343,7 @@ class InternalDispatcher {
|
|
|
370
343
|
this._pluginManager = inject(PluginManager);
|
|
371
344
|
this._stateStream = inject(_StateStream);
|
|
372
345
|
this._ngxsExecutionStrategy = inject(InternalNgxsExecutionStrategy);
|
|
346
|
+
this._injector = inject(Injector);
|
|
373
347
|
}
|
|
374
348
|
/**
|
|
375
349
|
* Dispatches event(s).
|
|
@@ -398,7 +372,7 @@ class InternalDispatcher {
|
|
|
398
372
|
}
|
|
399
373
|
const prevState = this._stateStream.getValue();
|
|
400
374
|
const plugins = this._pluginManager.plugins;
|
|
401
|
-
return compose([
|
|
375
|
+
return compose(this._injector, [
|
|
402
376
|
...plugins,
|
|
403
377
|
(nextState, nextAction) => {
|
|
404
378
|
if (nextState !== prevState) {
|
|
@@ -437,19 +411,41 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.0.6", ngImpor
|
|
|
437
411
|
type: Injectable,
|
|
438
412
|
args: [{ providedIn: 'root' }]
|
|
439
413
|
}] });
|
|
414
|
+
/**
|
|
415
|
+
* Composes a array of functions from left to right. Example:
|
|
416
|
+
*
|
|
417
|
+
* compose([fn, final])(state, action);
|
|
418
|
+
*
|
|
419
|
+
* then the funcs have a signature like:
|
|
420
|
+
*
|
|
421
|
+
* function fn (state, action, next) {
|
|
422
|
+
* console.log('here', state, action, next);
|
|
423
|
+
* return next(state, action);
|
|
424
|
+
* }
|
|
425
|
+
*
|
|
426
|
+
* function final (state, action) {
|
|
427
|
+
* console.log('here', state, action);
|
|
428
|
+
* return state;
|
|
429
|
+
* }
|
|
430
|
+
*
|
|
431
|
+
* the last function should not call `next`.
|
|
432
|
+
*/
|
|
433
|
+
const compose = (injector, funcs) => (...args) => {
|
|
434
|
+
const curr = funcs.shift();
|
|
435
|
+
return runInInjectionContext(injector, () => curr(...args, (...nextArgs) => compose(injector, funcs)(...nextArgs)));
|
|
436
|
+
};
|
|
440
437
|
|
|
441
|
-
const NG_DEV_MODE$8 = typeof ngDevMode !== 'undefined' && ngDevMode;
|
|
442
438
|
// The injection token is used to resolve a list of states provided at
|
|
443
439
|
// the root level through either `NgxsModule.forRoot` or `provideStore`.
|
|
444
|
-
const ROOT_STATE_TOKEN = new InjectionToken(
|
|
440
|
+
const ROOT_STATE_TOKEN = new InjectionToken(typeof ngDevMode !== 'undefined' && ngDevMode ? 'ROOT_STATE_TOKEN' : '');
|
|
445
441
|
// The injection token is used to resolve a list of states provided at
|
|
446
442
|
// the feature level through either `NgxsModule.forFeature` or `provideStates`.
|
|
447
443
|
// The Array<Array> is used to overload the resolved value of the token because
|
|
448
444
|
// it is a multi-provider token.
|
|
449
|
-
const FEATURE_STATE_TOKEN = new InjectionToken(
|
|
445
|
+
const FEATURE_STATE_TOKEN = new InjectionToken(typeof ngDevMode !== 'undefined' && ngDevMode ? 'FEATURE_STATE_TOKEN' : '');
|
|
450
446
|
// The injection token is used to resolve to options provided at the root
|
|
451
447
|
// level through either `NgxsModule.forRoot` or `provideStore`.
|
|
452
|
-
const NGXS_OPTIONS = new InjectionToken(
|
|
448
|
+
const NGXS_OPTIONS = new InjectionToken(typeof ngDevMode !== 'undefined' && ngDevMode ? 'NGXS_OPTIONS' : '');
|
|
453
449
|
/**
|
|
454
450
|
* The NGXS config settings.
|
|
455
451
|
*/
|
|
@@ -596,7 +592,6 @@ function ensureStateAndActionsAreImmutable(root) {
|
|
|
596
592
|
};
|
|
597
593
|
}
|
|
598
594
|
|
|
599
|
-
const NG_DEV_MODE$7 = typeof ngDevMode !== 'undefined' && ngDevMode;
|
|
600
595
|
function createRootSelectorFactory(selectorMetaData, selectors, memoizedSelectorFn) {
|
|
601
596
|
return (context) => {
|
|
602
597
|
const { argumentSelectorFunctions, selectorOptions } = getRuntimeSelectorInfo(context, selectorMetaData, selectors);
|
|
@@ -617,7 +612,7 @@ function createRootSelectorFactory(selectorMetaData, selectors, memoizedSelector
|
|
|
617
612
|
// We're logging an error in this function because it may be used by `select`,
|
|
618
613
|
// `selectSignal`, and `selectSnapshot`. Therefore, there's no need to catch
|
|
619
614
|
// exceptions there to log errors.
|
|
620
|
-
if (
|
|
615
|
+
if (typeof ngDevMode !== 'undefined' && ngDevMode) {
|
|
621
616
|
const message = 'The selector below has thrown an error upon invocation. ' +
|
|
622
617
|
'Please check for any unsafe property access that may result in null ' +
|
|
623
618
|
'or undefined values.';
|
|
@@ -691,7 +686,6 @@ function getRootSelectorFactory(selector) {
|
|
|
691
686
|
return (metadata && metadata.makeRootSelector) || (() => selector);
|
|
692
687
|
}
|
|
693
688
|
|
|
694
|
-
const NG_DEV_MODE$6 = typeof ngDevMode !== 'undefined' && ngDevMode;
|
|
695
689
|
/**
|
|
696
690
|
* Get a deeply nested value. Example:
|
|
697
691
|
*
|
|
@@ -756,7 +750,7 @@ function propGetter(paths, config) {
|
|
|
756
750
|
// `createSelectorFn`, which, in turn, is solely used by the `Select` decorator.
|
|
757
751
|
// We've been trying to deprecate the `Select` decorator because it's unstable with
|
|
758
752
|
// server-side rendering and micro-frontend applications.
|
|
759
|
-
const ɵPROP_GETTER = new InjectionToken(
|
|
753
|
+
const ɵPROP_GETTER = new InjectionToken(typeof ngDevMode !== 'undefined' && ngDevMode ? 'PROP_GETTER' : '', {
|
|
760
754
|
providedIn: 'root',
|
|
761
755
|
factory: () => inject(NgxsConfig).compatibility?.strictContentSecurityPolicy
|
|
762
756
|
? compliantPropGetter
|
|
@@ -783,7 +777,7 @@ const ɵPROP_GETTER = new InjectionToken(NG_DEV_MODE$6 ? 'PROP_GETTER' : '', {
|
|
|
783
777
|
function buildGraph(stateClasses) {
|
|
784
778
|
const findName = (stateClass) => {
|
|
785
779
|
const meta = stateClasses.find(g => g === stateClass);
|
|
786
|
-
if (
|
|
780
|
+
if (typeof ngDevMode !== 'undefined' && ngDevMode && !meta) {
|
|
787
781
|
throw new Error(`Child state not found: ${stateClass}. \r\nYou may have forgotten to add states to module`);
|
|
788
782
|
}
|
|
789
783
|
return meta[_META_KEY].name;
|
|
@@ -878,7 +872,7 @@ function topologicalSort(graph) {
|
|
|
878
872
|
ancestors.push(name);
|
|
879
873
|
visited[name] = true;
|
|
880
874
|
graph[name].forEach((dep) => {
|
|
881
|
-
if (
|
|
875
|
+
if (typeof ngDevMode !== 'undefined' && ngDevMode && ancestors.indexOf(dep) >= 0) {
|
|
882
876
|
throw new Error(`Circular dependency '${dep}' is required by '${name}': ${ancestors.join(' -> ')}`);
|
|
883
877
|
}
|
|
884
878
|
if (visited[dep]) {
|
|
@@ -973,8 +967,7 @@ function jit_hasInjectableAnnotation(stateClass) {
|
|
|
973
967
|
return annotations.some((annotation) => annotation?.ngMetadataName === 'Injectable');
|
|
974
968
|
}
|
|
975
969
|
|
|
976
|
-
const
|
|
977
|
-
const NGXS_DEVELOPMENT_OPTIONS = new InjectionToken(NG_DEV_MODE$5 ? 'NGXS_DEVELOPMENT_OPTIONS' : '', {
|
|
970
|
+
const NGXS_DEVELOPMENT_OPTIONS = new InjectionToken(typeof ngDevMode !== 'undefined' && ngDevMode ? 'NGXS_DEVELOPMENT_OPTIONS' : '', {
|
|
978
971
|
providedIn: 'root',
|
|
979
972
|
factory: () => ({ warnOnUnhandledActions: true })
|
|
980
973
|
});
|
|
@@ -1230,7 +1223,6 @@ function createAllowedStatusesMap(statuses) {
|
|
|
1230
1223
|
}, {});
|
|
1231
1224
|
}
|
|
1232
1225
|
|
|
1233
|
-
const NG_DEV_MODE$4 = typeof ngDevMode !== 'undefined' && ngDevMode;
|
|
1234
1226
|
function cloneDefaults(defaults) {
|
|
1235
1227
|
let value = defaults === undefined ? {} : defaults;
|
|
1236
1228
|
if (defaults) {
|
|
@@ -1325,7 +1317,7 @@ class StateFactory {
|
|
|
1325
1317
|
* Add a new state to the global defs.
|
|
1326
1318
|
*/
|
|
1327
1319
|
add(stateClasses) {
|
|
1328
|
-
if (
|
|
1320
|
+
if (typeof ngDevMode !== 'undefined' && ngDevMode) {
|
|
1329
1321
|
ensureStatesAreDecorated(stateClasses);
|
|
1330
1322
|
}
|
|
1331
1323
|
const { newStates } = this.addToStatesMap(stateClasses);
|
|
@@ -1345,7 +1337,7 @@ class StateFactory {
|
|
|
1345
1337
|
// `State` decorator. This check is moved here because the `ɵprov` property
|
|
1346
1338
|
// will not exist on the class in JIT mode (because it's set asynchronously
|
|
1347
1339
|
// during JIT compilation through `Object.defineProperty`).
|
|
1348
|
-
if (
|
|
1340
|
+
if (typeof ngDevMode !== 'undefined' && ngDevMode) {
|
|
1349
1341
|
ensureStateClassIsInjectable(stateClass);
|
|
1350
1342
|
}
|
|
1351
1343
|
const stateMap = {
|
|
@@ -1424,7 +1416,7 @@ class StateFactory {
|
|
|
1424
1416
|
}
|
|
1425
1417
|
// The `NgxsUnhandledActionsLogger` is a tree-shakable class which functions
|
|
1426
1418
|
// only during development.
|
|
1427
|
-
if (
|
|
1419
|
+
if (typeof ngDevMode !== 'undefined' && ngDevMode && !actionHasBeenHandled) {
|
|
1428
1420
|
const unhandledActionsLogger = this._injector.get(NgxsUnhandledActionsLogger, null);
|
|
1429
1421
|
// The `NgxsUnhandledActionsLogger` will not be resolved by the injector if the
|
|
1430
1422
|
// `NgxsDevelopmentModule` is not provided. It's enough to check whether the `injector.get`
|
|
@@ -1441,7 +1433,7 @@ class StateFactory {
|
|
|
1441
1433
|
const statesMap = this.statesByName;
|
|
1442
1434
|
for (const stateClass of stateClasses) {
|
|
1443
1435
|
const stateName = _getStoreMetadata(stateClass).name;
|
|
1444
|
-
if (
|
|
1436
|
+
if (typeof ngDevMode !== 'undefined' && ngDevMode) {
|
|
1445
1437
|
ensureStateNameIsUnique(stateName, stateClass, statesMap);
|
|
1446
1438
|
}
|
|
1447
1439
|
const unmountedState = !statesMap[stateName];
|
|
@@ -1544,7 +1536,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.0.6", ngImpor
|
|
|
1544
1536
|
// to the state context.
|
|
1545
1537
|
function noop() { }
|
|
1546
1538
|
|
|
1547
|
-
const NG_DEV_MODE$3 = typeof ngDevMode !== 'undefined' && ngDevMode;
|
|
1548
1539
|
class Store {
|
|
1549
1540
|
constructor() {
|
|
1550
1541
|
this._stateStream = inject(_StateStream);
|
|
@@ -1564,7 +1555,7 @@ class Store {
|
|
|
1564
1555
|
* Dispatches action(s).
|
|
1565
1556
|
*/
|
|
1566
1557
|
dispatch(actionOrActions) {
|
|
1567
|
-
if (
|
|
1558
|
+
if (typeof ngDevMode !== 'undefined' && ngDevMode) {
|
|
1568
1559
|
if (
|
|
1569
1560
|
// If a single action is dispatched and it's nullable.
|
|
1570
1561
|
actionOrActions == null ||
|
|
@@ -1652,11 +1643,10 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.0.6", ngImpor
|
|
|
1652
1643
|
args: [{ providedIn: 'root' }]
|
|
1653
1644
|
}], ctorParameters: () => [] });
|
|
1654
1645
|
|
|
1655
|
-
const NG_DEV_MODE$2 = typeof ngDevMode !== 'undefined' && ngDevMode;
|
|
1656
1646
|
/**
|
|
1657
1647
|
* InjectionToken that registers preboot functions (called before the root initializer).
|
|
1658
1648
|
*/
|
|
1659
|
-
const NGXS_PREBOOT_FNS = new InjectionToken(
|
|
1649
|
+
const NGXS_PREBOOT_FNS = new InjectionToken(typeof ngDevMode !== 'undefined' && ngDevMode ? 'NGXS_PREBOOT_FNS' : '');
|
|
1660
1650
|
/**
|
|
1661
1651
|
* This function registers a preboot function which will be called before the root
|
|
1662
1652
|
* store initializer is run, but after all of the NGXS features are provided and
|
|
@@ -1706,7 +1696,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.0.6", ngImpor
|
|
|
1706
1696
|
args: [{ providedIn: 'root' }]
|
|
1707
1697
|
}], ctorParameters: () => [{ type: Store }, { type: NgxsConfig }] });
|
|
1708
1698
|
|
|
1709
|
-
const NG_DEV_MODE$1 = typeof ngDevMode !== 'undefined' && ngDevMode;
|
|
1710
1699
|
class LifecycleStateManager {
|
|
1711
1700
|
constructor() {
|
|
1712
1701
|
this._store = inject(Store);
|
|
@@ -1719,7 +1708,7 @@ class LifecycleStateManager {
|
|
|
1719
1708
|
this._destroy$.next();
|
|
1720
1709
|
}
|
|
1721
1710
|
ngxsBootstrap(action, results) {
|
|
1722
|
-
if (
|
|
1711
|
+
if (typeof ngDevMode !== 'undefined' && ngDevMode) {
|
|
1723
1712
|
if (action instanceof InitState) {
|
|
1724
1713
|
this._initStateHasBeenDispatched = true;
|
|
1725
1714
|
}
|
|
@@ -1777,7 +1766,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.0.6", ngImpor
|
|
|
1777
1766
|
args: [{ providedIn: 'root' }]
|
|
1778
1767
|
}] });
|
|
1779
1768
|
|
|
1780
|
-
const NG_DEV_MODE = typeof ngDevMode !== 'undefined' && ngDevMode;
|
|
1781
1769
|
/**
|
|
1782
1770
|
* This function is shared by both NgModule and standalone features.
|
|
1783
1771
|
* When using `NgxsModule.forRoot` and `provideStore`, we can depend on the
|
|
@@ -1825,11 +1813,11 @@ function featureStatesInitializer() {
|
|
|
1825
1813
|
/**
|
|
1826
1814
|
* InjectionToken that registers the global Store.
|
|
1827
1815
|
*/
|
|
1828
|
-
const NGXS_ROOT_STORE_INITIALIZER = new InjectionToken(
|
|
1816
|
+
const NGXS_ROOT_STORE_INITIALIZER = new InjectionToken(typeof ngDevMode !== 'undefined' && ngDevMode ? 'NGXS_ROOT_STORE_INITIALIZER' : '');
|
|
1829
1817
|
/**
|
|
1830
1818
|
* InjectionToken that registers feature states.
|
|
1831
1819
|
*/
|
|
1832
|
-
const NGXS_FEATURE_STORE_INITIALIZER = new InjectionToken(
|
|
1820
|
+
const NGXS_FEATURE_STORE_INITIALIZER = new InjectionToken(typeof ngDevMode !== 'undefined' && ngDevMode ? 'NGXS_FEATURE_STORE_INITIALIZER' : '');
|
|
1833
1821
|
const NGXS_ROOT_ENVIRONMENT_INITIALIZER = [
|
|
1834
1822
|
{ provide: NGXS_ROOT_STORE_INITIALIZER, useFactory: rootStoreInitializer },
|
|
1835
1823
|
{
|