ngssm-store 22.1.0 → 22.2.1

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 +1 @@
1
- {"version":3,"file":"ngssm-store.mjs","sources":["../../../projects/ngssm-store/src/lib/reducer.ts","../../../projects/ngssm-store/src/lib/effect.ts","../../../projects/ngssm-store/src/lib/state-initializer.ts","../../../projects/ngssm-store/src/lib/logging/log-level.ts","../../../projects/ngssm-store/src/lib/logging/logger.ts","../../../projects/ngssm-store/src/lib/logging/console-appender.ts","../../../projects/ngssm-store/src/lib/logging/provide-console-appender.ts","../../../projects/ngssm-store/src/lib/store.ts","../../../projects/ngssm-store/src/lib/feature-state/feature-state-specification.ts","../../../projects/ngssm-store/src/lib/actions/ngssm-store-action-type.ts","../../../projects/ngssm-store/src/lib/actions/ngssm-register-feature-state.action.ts","../../../projects/ngssm-store/src/lib/actions/ngssm-unregister-feature-state.action.ts","../../../projects/ngssm-store/src/lib/feature-state/provide-feature-state.ts","../../../projects/ngssm-store/src/lib/feature-state/provide-ngssm-feature-state.directive.ts","../../../projects/ngssm-store/src/lib/feature-state/feature-state.reducer.ts","../../../projects/ngssm-store/src/lib/ngssm-component.ts","../../../projects/ngssm-store/src/lib/provide-ngssm-store.ts","../../../projects/ngssm-store/src/lib/signal-helpers.ts","../../../projects/ngssm-store/src/public-api.ts","../../../projects/ngssm-store/src/ngssm-store.ts"],"sourcesContent":["import { EnvironmentProviders, InjectionToken, Type, makeEnvironmentProviders } from '@angular/core';\n\nimport { Action } from './action';\nimport { State } from './state';\n\nexport interface Reducer {\n processedActions: string[];\n updateState(state: State, action: Action): State;\n}\n\nexport const NGSSM_REDUCER = new InjectionToken<Reducer>('NGSSM_REDUCER');\n\nexport const provideReducer = (reducer: Type<unknown>): EnvironmentProviders => {\n return makeEnvironmentProviders([{ provide: NGSSM_REDUCER, useClass: reducer, multi: true }]);\n};\n\nexport const provideReducers = (...reducers: Type<unknown>[]): EnvironmentProviders => {\n return makeEnvironmentProviders(reducers.map((reducer) => ({ provide: NGSSM_REDUCER, useClass: reducer, multi: true })));\n};\n","import { EnvironmentProviders, InjectionToken, Type, makeEnvironmentProviders } from '@angular/core';\n\nimport { Action } from './action';\nimport { State } from './state';\nimport { ActionDispatcher } from './action-dispatcher';\n\nexport type EffectFunc = (state: State, action: Action) => void;\n\nexport interface Effect {\n isFunc?: boolean;\n processedActions: string[];\n processAction(actiondispatcher: ActionDispatcher, state: State, action: Action): void;\n}\n\nexport const NGSSM_EFFECT = new InjectionToken<Effect>('NGSSM_EFFECT');\n\nexport const provideEffect = (effect: Type<unknown>): EnvironmentProviders => {\n return makeEnvironmentProviders([{ provide: NGSSM_EFFECT, useClass: effect, multi: true }]);\n};\n\nexport const provideEffects = (...effects: Type<unknown>[]): EnvironmentProviders => {\n return makeEnvironmentProviders(effects.map((effect) => ({ provide: NGSSM_EFFECT, useClass: effect, multi: true })));\n};\n\nexport const provideEffectFunc = (actionType: string, effectFunc: EffectFunc): EnvironmentProviders => {\n return makeEnvironmentProviders([\n {\n provide: NGSSM_EFFECT,\n useFactory: () => {\n const effect: Effect = {\n processedActions: [actionType],\n processAction: (_, state, action) => effectFunc(state, action),\n isFunc: true\n };\n return effect;\n },\n multi: true\n }\n ]);\n};\n","import { InjectionToken } from '@angular/core';\nimport { State } from './state';\n\nexport interface StateInitializer {\n initializeState(state: State): State;\n}\n\nexport const NGSSM_STATE_INITIALIZER = new InjectionToken<StateInitializer>('NGSSM_STATE_INITIALIZER');\n","export enum LogLevel {\n debug = 'Debug',\n information = 'Information',\n error = 'Error'\n}\n","import { Injectable } from '@angular/core';\nimport { Observable, Subject } from 'rxjs';\n\nimport { LogEvent } from './log-event';\nimport { LogLevel } from './log-level';\n\n@Injectable({\n providedIn: 'root'\n})\nexport class Logger {\n private readonly _logEvents$ = new Subject<LogEvent>();\n\n public get logEvents$(): Observable<LogEvent> {\n return this._logEvents$.asObservable();\n }\n\n public debug(message: string, payload?: unknown): void {\n this.log(LogLevel.debug, message, payload);\n }\n\n public information(message: string, payload?: unknown): void {\n this.log(LogLevel.information, message, payload);\n }\n\n public error(message: string, payload?: unknown): void {\n this.log(LogLevel.error, message, payload);\n }\n\n public log(level: LogLevel, message: string, payload?: unknown): void {\n this._logEvents$.next({\n level,\n message,\n payload\n });\n }\n}\n","import { inject, Injectable } from '@angular/core';\nimport { Subject, takeUntil } from 'rxjs';\nimport { Logger } from './logger';\nimport { LogLevel } from './log-level';\n\n@Injectable({\n providedIn: 'root'\n})\nexport class ConsoleAppender {\n private logger = inject(Logger);\n\n private readonly stopEvent$ = new Subject<boolean>();\n\n public start(contextName?: string): void {\n this.logger.logEvents$.pipe(takeUntil(this.stopEvent$)).subscribe((logEvent) => {\n let logFunction: (...data: unknown[]) => void;\n switch (logEvent.level) {\n case LogLevel.error:\n logFunction = console.error;\n break;\n\n default:\n logFunction = console.log;\n break;\n }\n\n const now = new Date().toLocaleString();\n const prefix = contextName ? `[${contextName}] ` : '';\n\n if (logEvent.payload) {\n logFunction(`${prefix}[${now}] [${logEvent.level}] ${logEvent.message}`, logEvent.payload);\n } else {\n logFunction(`${prefix}[${now}] [${logEvent.level}] ${logEvent.message}`);\n }\n });\n }\n\n public stop(): void {\n this.stopEvent$.next(true);\n }\n}\n","import { EnvironmentProviders, InjectionToken, makeEnvironmentProviders, inject, provideAppInitializer } from '@angular/core';\nimport { ConsoleAppender } from './console-appender';\n\nexport const NGSSM_CONSOLE_APPENDER_NAME = new InjectionToken<string>('NGSSM_CONSOLE_APPENDER_NAME');\n\nexport const startConsoleAppenderFactory = (): (() => void) => {\n return () => {\n const name = inject(NGSSM_CONSOLE_APPENDER_NAME);\n const consoleAppender = inject(ConsoleAppender);\n consoleAppender.start(name);\n };\n};\n\nexport const provideConsoleAppender = (name: string): EnvironmentProviders => {\n return makeEnvironmentProviders([\n {\n provide: NGSSM_CONSOLE_APPENDER_NAME,\n useValue: name\n },\n provideAppInitializer(startConsoleAppenderFactory())\n ]);\n};\n","import { ApplicationRef, EnvironmentInjector, Injectable, Signal, inject, runInInjectionContext, signal } from '@angular/core';\nimport { BehaviorSubject, Observable } from 'rxjs';\n\nimport update from 'immutability-helper';\n\nimport { FeatureStateSpecification } from './feature-state';\nimport { State } from './state';\nimport { Action } from './action';\nimport { NGSSM_REDUCER, Reducer } from './reducer';\nimport { Effect, NGSSM_EFFECT } from './effect';\nimport { NGSSM_STATE_INITIALIZER, StateInitializer } from './state-initializer';\nimport { Logger } from './logging';\nimport { ActionDispatcher } from './action-dispatcher';\n\nconst featureStateSpecifications: FeatureStateSpecification[] = [];\nexport const NgSsmFeatureState = (specification: FeatureStateSpecification) => {\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n return (target: object) => {\n featureStateSpecifications.push(specification);\n };\n};\n\n/**\n * The `Store` class is a centralized state management system for Angular applications.\n * It manages the application state, processes actions using reducers, and handles side effects using effects.\n * The class integrates both RxJS (`BehaviorSubject`) and Angular signals for reactive state management.\n *\n * ### Features:\n * - Centralized state management with support for reducers and effects.\n * - Reactive state updates using both RxJS and Angular signals.\n * - Modular initialization of feature states, reducers, and effects.\n * - Sequential action processing with an action queue.\n * - Logging for debugging and monitoring state changes and action processing.\n *\n * ### Usage:\n * - Dispatch actions using `dispatchAction` or `dispatchActionType`.\n * - Subscribe to state updates using `state$` (RxJS) or `state` (Angular signal).\n */\n@Injectable({\n providedIn: 'root'\n})\nexport class Store implements ActionDispatcher {\n // If true, an action is processed in a macro-task by using setTimoeout. Otherwise, Promise.resolve() is used\n // When using micro task, an issue can occur with angular root effects that want to process state or action signals.\n // They can be executed after a list of actions is processed. In that case, some actions are never processed by the effects.\n public useMacroTasks = true;\n\n // If true, a call to ApplicationRef.tick is made after an action is processed and the state is updated.\n public forceChangeDetectionAfterActionProcessed = false;\n\n // Logger service for debugging and monitoring.\n private readonly logger = inject(Logger);\n // Array of reducers to process state updates.\n private readonly reducers: Reducer[] | null = inject(NGSSM_REDUCER, { optional: true }) as unknown as Reducer[];\n // Array of effects to handle side effects.\n private readonly effects: Effect[] | null = inject(NGSSM_EFFECT, { optional: true }) as unknown as Effect[];\n // Array of state initializers to set up the initial state.\n private readonly initializers: StateInitializer[] = inject(NGSSM_STATE_INITIALIZER, { optional: true }) as unknown as StateInitializer[];\n // Angular's `EnvironmentInjector` for running effects in the correct context.\n private readonly injector = inject(EnvironmentInjector);\n private readonly applicationRef = inject(ApplicationRef);\n\n // The current state of the application, managed as a BehaviorSubject for RxJS compatibility.\n private readonly _state$ = new BehaviorSubject<State>({});\n\n // A queue to ensure actions are processed sequentially.\n private readonly actionQueue: Action[] = [];\n\n // Maps action types to their corresponding reducers.\n private readonly reducersPerActionType = new Map<string, Reducer[]>();\n\n // Maps action types to their corresponding effects.\n private readonly effectsPerActionType = new Map<string, Effect[]>();\n\n // The current state of the application, managed as an Angular signal for signal-based reactivity.\n private readonly _stateSignal = signal<State>({});\n\n // The most recently action processed by reducers, managed as an Angular signal.\n private readonly _processedAction = signal<Action>({ type: '' });\n\n // The most recently action processed by reducers, managed as an observable.\n private readonly _processedAction$ = new BehaviorSubject<Action>({ type: '' });\n\n /**\n * Initializes the `Store` with reducers, effects, and state initializers.\n * Also sets up the initial state and registers reducers and effects.\n */\n constructor() {\n // Synchronize the RxJS state with the Angular signal state.\n this._state$.subscribe((value) => this._stateSignal.set(value));\n\n this.logger.information('[Store] ---> state initialization...');\n let state = this._state$.getValue();\n\n // Initialize feature states.\n state = featureStateSpecifications.reduce((p, c) => update(p, { [c.featureStateKey]: { $set: c.initialState } }), state);\n\n // Apply state initializers.\n (this.initializers ?? []).forEach((initializer) => {\n this.logger.information('[Store] ------> calling initializer', initializer);\n state = initializer.initializeState(state);\n });\n\n // Update the state with the initialized values.\n this._state$.next(state);\n\n // Register reducers and effects.\n this.logger.information(`[Store] ---> initialization of ${(this.reducers ?? []).length} reducers...`);\n this.initializeProcessors(this.reducers ?? [], this.reducersPerActionType, (r) => r.processedActions);\n this.logger.information(`[Store] ---> initialization of ${(this.effects ?? []).length} effects...`);\n this.initializeProcessors(this.effects ?? [], this.effectsPerActionType, (e) => e.processedActions);\n }\n\n /**\n * Returns the current state as an RxJS observable.\n * Useful for subscribing to state changes in a reactive manner.\n */\n public get state$(): Observable<State> {\n return this._state$.asObservable();\n }\n\n /**\n * Returns the most recently action processed by reducers as an Angular signal.\n * Useful for accessing the last processed action in a reactive manner.\n * This signal is updated before processing the effects.\n */\n public get processedAction(): Signal<Action> {\n return this._processedAction.asReadonly();\n }\n\n /**\n * Returns the most recently action processed by reducers as an observale.\n * Useful for accessing the last processed action in a reactive manner.\n * This signal is updated before processing the effects.\n */\n public get processedAction$(): Observable<Action> {\n return this._processedAction$.asObservable();\n }\n\n /**\n * Returns the current state as an Angular signal.\n * Useful for signal-based reactivity in Angular components.\n */\n public get state(): Signal<State> {\n return this._stateSignal.asReadonly();\n }\n\n /**\n * Dispatches an action to the store.\n * The action is added to the action queue and processed sequentially.\n *\n * @param action - The action to dispatch.\n */\n public dispatchAction(action: Action): void {\n this.actionQueue.push(action);\n this.logger.debug(`Action of type '${action.type}' added to the queue => ${this.actionQueue.length} pending actions`, action);\n\n this.addTaskForNextAction();\n }\n\n /**\n * Dispatches an action by its type.\n * This is a shorthand for dispatching actions without additional payload.\n *\n * @param type - The type of the action to dispatch.\n */\n public dispatchActionType(type: string): void {\n this.dispatchAction({ type });\n }\n\n /**\n * Processes the next action in the action queue.\n * Applies reducers to update the state and executes effects for side effects.\n */\n private processNextAction(): void {\n const nextAction = this.actionQueue.shift();\n if (!nextAction) {\n this.logger.debug('[processNextAction] No action to process');\n return;\n }\n\n this.logger.information(`[processNextAction] Start processing action '${nextAction.type}...`, nextAction);\n\n try {\n // Apply reducers to update the state.\n const updatedState = this.applyReducers(nextAction);\n\n if (this.forceChangeDetectionAfterActionProcessed) {\n this.applicationRef.tick();\n }\n\n // Execute effects for the action.\n const effects = this.effectsPerActionType.get(nextAction.type) ?? [];\n this.logger.debug(`[Store] ${effects.length} effects found to process the action ${nextAction.type}`, effects);\n effects.forEach((effect) => {\n if (effect.isFunc === true) {\n runInInjectionContext(this.injector, () => this.runEffect(effect, updatedState, nextAction));\n } else {\n this.runEffect(effect, updatedState, nextAction);\n }\n });\n } catch (error) {\n this.logger.error(`Error when processing action ${nextAction.type}`, {\n error,\n action: nextAction\n });\n } finally {\n this.logger.information(`[processNextAction] action '${nextAction.type} processed.`, nextAction);\n\n // Process the next action asynchronously\n this.addTaskForNextAction();\n }\n }\n\n /**\n * Applies reducers to the current state based on the dispatched action.\n * Updates the state if there are changes and sets the processed action signal.\n *\n * @param nextAction - The action being processed.\n * @returns The updated state after applying reducers.\n */\n private applyReducers(nextAction: Action): State {\n try {\n const reducers = this.reducersPerActionType.get(nextAction.type) ?? [];\n this.logger.debug(`[Store] ${reducers.length} reducers found to process the action ${nextAction.type}`, reducers);\n const currentState = this._state$.getValue();\n const updatedState = reducers.reduce((p, c) => c.updateState(p, nextAction), currentState);\n\n if (updatedState !== currentState) {\n this._state$.next(updatedState);\n }\n\n return updatedState;\n } finally {\n this.logger.debug(`[Store] Notify action ${nextAction.type} as processed`);\n this._processedAction.set(nextAction);\n this._processedAction$.next(nextAction);\n }\n }\n\n /**\n * Executes an effect for a given action.\n * Handles any errors that occur during effect execution.\n *\n * @param effect - The effect to execute.\n * @param updatedState - The updated state after reducers have been applied.\n * @param nextAction - The action being processed.\n */\n private runEffect(effect: Effect, updatedState: State, nextAction: Action): void {\n try {\n effect.processAction(this, updatedState, nextAction);\n } catch (error) {\n this.logger.error(`Unable to process action ${nextAction.type} by effect ${effect}`, {\n error,\n action: nextAction,\n processor: effect\n });\n }\n }\n\n /**\n * Initializes reducers or effects and maps them to their corresponding action types.\n *\n * @param processors - The array of reducers or effects to initialize.\n * @param processorMap - The map to store processors by action type.\n * @param getProcessedActions - A function to retrieve the action types processed by a processor.\n */\n private initializeProcessors<T>(processors: T[], processorMap: Map<string, T[]>, getProcessedActions: (processor: T) => string[]): void {\n processors.forEach((processor) => {\n this.logger.information('[Store] ------> initialization of ', processor);\n getProcessedActions(processor).forEach((actionType) => {\n const storedProcessors = processorMap.get(actionType) ?? [];\n if (storedProcessors.length === 0) {\n processorMap.set(actionType, storedProcessors);\n }\n storedProcessors.push(processor);\n });\n });\n }\n\n private addTaskForNextAction(): void {\n if (this.useMacroTasks) {\n setTimeout(() => this.processNextAction());\n } else {\n Promise.resolve().then(() => this.processNextAction());\n }\n }\n}\n","import { InjectionToken } from '@angular/core';\n\nexport interface FeatureStateSpecification {\n readonly featureStateKey: string;\n readonly initialState: object;\n}\n\nexport const NGSSM_COMPONENT_WITH_FEATURE_STATE = new InjectionToken<FeatureStateSpecification>('NGSSM_COMPONENT_WITH_FEATURE_STATE');\n","export enum NgssmStoreActionType {\n registerFeatureState = '[NgssmStoreActionType] registerFeatureState',\n unregisterFeatureState = '[NgssmStoreActionType] unregisterFeatureState'\n}\n","import { Action } from '../action';\nimport { NgssmStoreActionType } from './ngssm-store-action-type';\n\nexport class NgssmRegisterFeatureStateAction implements Action {\n public readonly type: string = NgssmStoreActionType.registerFeatureState;\n\n constructor(\n public readonly featureStateKey: string,\n public readonly initialValue: object\n ) {}\n}\n","import { Action } from '../action';\nimport { NgssmStoreActionType } from './ngssm-store-action-type';\n\nexport class NgssmUnregisterFeatureStateAction implements Action {\n public readonly type: string = NgssmStoreActionType.unregisterFeatureState;\n\n constructor(public readonly featureStateKey: string) {}\n}\n","import { EnvironmentProviders, makeEnvironmentProviders, inject, provideAppInitializer } from '@angular/core';\nimport { Store } from '../store';\nimport { NgssmRegisterFeatureStateAction } from '../actions';\n\nconst registerFeatureState = (featureStateKey: string, initialValue: object) => {\n return () => {\n inject(Store).dispatchAction(new NgssmRegisterFeatureStateAction(featureStateKey, initialValue));\n };\n};\n\nexport const provideNgssmFeatureState = (featureStateKey: string, initialValue: object): EnvironmentProviders => {\n return makeEnvironmentProviders([provideAppInitializer(registerFeatureState(featureStateKey, initialValue))]);\n};\n","import { Directive, inject, OnDestroy } from '@angular/core';\n\nimport { Store } from '../store';\nimport { NgssmRegisterFeatureStateAction, NgssmUnregisterFeatureStateAction } from '../actions';\nimport { FeatureStateSpecification, NGSSM_COMPONENT_WITH_FEATURE_STATE } from './feature-state-specification';\n\n// export interface ComponentWithFeatureState {\n// featureStateKey: string;\n// initialValue: object;\n// }\n\n// export const NGSSM_COMPONENT_WITH_FEATURE_STATE = new InjectionToken<ComponentWithFeatureState>('NGSSM_COMPONENT_WITH_FEATURE_STATE');\n\n@Directive({\n // eslint-disable-next-line @angular-eslint/directive-selector\n selector: '[provideNgssmFeatureState]'\n})\nexport class ProvideNgssmFeatureStateDirective implements OnDestroy {\n private readonly component: FeatureStateSpecification = inject(NGSSM_COMPONENT_WITH_FEATURE_STATE);\n private store = inject(Store);\n\n constructor() {\n this.store.dispatchAction(new NgssmRegisterFeatureStateAction(this.component.featureStateKey, this.component.initialState));\n }\n\n public ngOnDestroy(): void {\n this.store.dispatchAction(new NgssmUnregisterFeatureStateAction(this.component.featureStateKey));\n }\n}\n","import { Injectable } from '@angular/core';\n\nimport update from 'immutability-helper';\n\nimport { Reducer } from '../reducer';\nimport { NgssmRegisterFeatureStateAction, NgssmStoreActionType, NgssmUnregisterFeatureStateAction } from '../actions';\nimport { State } from '../state';\nimport { Action } from '../action';\n\n@Injectable()\nexport class FeatureStateReducer implements Reducer {\n public readonly processedActions: string[] = [NgssmStoreActionType.registerFeatureState, NgssmStoreActionType.unregisterFeatureState];\n\n public updateState(state: State, action: Action): State {\n switch (action.type) {\n case NgssmStoreActionType.registerFeatureState: {\n const registerFeatureStateAction = action as NgssmRegisterFeatureStateAction;\n return update(state, {\n [registerFeatureStateAction.featureStateKey]: { $set: registerFeatureStateAction.initialValue }\n });\n }\n\n case NgssmStoreActionType.unregisterFeatureState: {\n const unregisterFeatureStateAction = action as NgssmUnregisterFeatureStateAction;\n return update(state, {\n $unset: [unregisterFeatureStateAction.featureStateKey]\n });\n }\n }\n\n return state;\n }\n}\n","import { Directive, inject, OnDestroy } from '@angular/core';\nimport { map, Observable, Subject, distinctUntilChanged, takeUntil } from 'rxjs';\n\nimport { Action } from './action';\nimport { State } from './state';\nimport { Store } from './store';\n\n@Directive({})\nexport class NgSsmComponent implements OnDestroy {\n protected store = inject(Store);\n\n private readonly _unsubscribeAll$ = new Subject<void>();\n\n protected get unsubscribeAll$(): Observable<void> {\n return this._unsubscribeAll$.asObservable();\n }\n\n public ngOnDestroy(): void {\n this._unsubscribeAll$.next();\n this._unsubscribeAll$.complete();\n }\n\n public watch<T>(selector: (state: State) => T): Observable<T> {\n return this.store.state$.pipe(\n map((state) => selector(state)),\n distinctUntilChanged(),\n takeUntil(this.unsubscribeAll$)\n );\n }\n\n public dispatchAction(action: Action): void {\n this.store.dispatchAction(action);\n }\n\n public dispatchActionType(actionType: string): void {\n this.store.dispatchActionType(actionType);\n }\n}\n","import { EnvironmentProviders, InjectionToken, makeEnvironmentProviders } from '@angular/core';\n\nimport { provideReducers } from './reducer';\nimport { ActionDispatcher } from './action-dispatcher';\nimport { FeatureStateReducer } from './feature-state';\nimport { Store } from './store';\n\nexport const ACTION_DISPATCHER = new InjectionToken<ActionDispatcher>('ACTION_DISPATCHER');\n\nexport const provideNgssmStore = (): EnvironmentProviders => {\n return makeEnvironmentProviders([provideReducers(FeatureStateReducer), { provide: ACTION_DISPATCHER, useExisting: Store }]);\n};\n","import { computed, inject, Signal } from '@angular/core';\nimport { State } from './state';\nimport { Store } from './store';\n\nexport const createSignal = <T = unknown>(selector: (state: State) => T): Signal<T> => {\n const store = inject(Store);\n return computed(() => selector(store.state()));\n};\n","/*\n * Public API Surface of ngssm-store\n */\n\nexport * from './lib/store';\nexport * from './lib/state';\nexport * from './lib/action';\nexport * from './lib/reducer';\nexport * from './lib/effect';\nexport * from './lib/feature-state';\nexport * from './lib/ngssm-component';\nexport * from './lib/state-initializer';\nexport * from './lib/logging';\nexport * from './lib/actions';\nexport * from './lib/provide-ngssm-store';\nexport * from './lib/signal-helpers';\nexport * from './lib/action-dispatcher';\n","/**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EAAE,WAAW,EAAE,KAAK,EAAE,CAAC,CAAC;AAC7H;;ACPO,MAAM,YAAY,GAAG,CAAc,QAA6B,KAAe;AACpF,IAAA,MAAM,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC;AAC3B,IAAA,OAAO,QAAQ,CAAC,MAAM,QAAQ,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC,CAAC;AAChD;;ACPA;;AAEG;;ACFH;;AAEG;;;;"}
1
+ {"version":3,"file":"ngssm-store.mjs","names":[],"sources":["../../../projects/ngssm-store/src/lib/reducer.ts","../../../projects/ngssm-store/src/lib/effect.ts","../../../projects/ngssm-store/src/lib/state-initializer.ts","../../../projects/ngssm-store/src/lib/logging/log-level.ts","../../../projects/ngssm-store/src/lib/logging/logger.ts","../../../projects/ngssm-store/src/lib/logging/console-appender.ts","../../../projects/ngssm-store/src/lib/logging/provide-console-appender.ts","../../../projects/ngssm-store/src/lib/store.ts","../../../projects/ngssm-store/src/lib/feature-state/feature-state-specification.ts","../../../projects/ngssm-store/src/lib/actions/ngssm-store-action-type.ts","../../../projects/ngssm-store/src/lib/actions/ngssm-register-feature-state.action.ts","../../../projects/ngssm-store/src/lib/actions/ngssm-unregister-feature-state.action.ts","../../../projects/ngssm-store/src/lib/feature-state/provide-feature-state.ts","../../../projects/ngssm-store/src/lib/feature-state/provide-ngssm-feature-state.directive.ts","../../../projects/ngssm-store/src/lib/feature-state/feature-state.reducer.ts","../../../projects/ngssm-store/src/lib/provide-ngssm-store.ts","../../../projects/ngssm-store/src/lib/signal-helpers.ts"],"sourcesContent":["import { EnvironmentProviders, InjectionToken, Type, makeEnvironmentProviders } from '@angular/core';\n\nimport { Action } from './action';\nimport { State } from './state';\n\nexport interface Reducer {\n processedActions: string[];\n updateState(state: State, action: Action): State;\n}\n\nexport const NGSSM_REDUCER = new InjectionToken<Reducer>('NGSSM_REDUCER');\n\nexport const provideReducer = (reducer: Type<unknown>): EnvironmentProviders => {\n return makeEnvironmentProviders([{ provide: NGSSM_REDUCER, useClass: reducer, multi: true }]);\n};\n\nexport const provideReducers = (...reducers: Type<unknown>[]): EnvironmentProviders => {\n return makeEnvironmentProviders(reducers.map((reducer) => ({ provide: NGSSM_REDUCER, useClass: reducer, multi: true })));\n};\n","import { EnvironmentProviders, InjectionToken, Type, makeEnvironmentProviders } from '@angular/core';\n\nimport { Action } from './action';\nimport { State } from './state';\nimport { ActionDispatcher } from './action-dispatcher';\n\nexport type EffectFunc<TActionType extends Action = Action> = (state: State, action: TActionType) => void;\n\nexport interface Effect {\n isFunc?: boolean;\n processedActions: string[];\n processAction(actiondispatcher: ActionDispatcher, state: State, action: Action): void;\n}\n\nexport const NGSSM_EFFECT = new InjectionToken<Effect>('NGSSM_EFFECT');\n\nexport const provideEffect = (effect: Type<unknown>): EnvironmentProviders => {\n return makeEnvironmentProviders([{ provide: NGSSM_EFFECT, useClass: effect, multi: true }]);\n};\n\nexport const provideEffects = (...effects: Type<unknown>[]): EnvironmentProviders => {\n return makeEnvironmentProviders(effects.map((effect) => ({ provide: NGSSM_EFFECT, useClass: effect, multi: true })));\n};\n\nexport const provideEffectFunc = <TActionType extends Action = Action>(\n actionType: string,\n effectFunc: EffectFunc<TActionType>\n): EnvironmentProviders => {\n return makeEnvironmentProviders([\n {\n provide: NGSSM_EFFECT,\n useFactory: () => {\n const effect: Effect = {\n processedActions: [actionType],\n processAction: (_, state, action) => effectFunc(state, action as TActionType),\n isFunc: true\n };\n return effect;\n },\n multi: true\n }\n ]);\n};\n","import { InjectionToken } from '@angular/core';\nimport { State } from './state';\n\nexport interface StateInitializer {\n initializeState(state: State): State;\n}\n\nexport const NGSSM_STATE_INITIALIZER = new InjectionToken<StateInitializer>('NGSSM_STATE_INITIALIZER');\n","export enum LogLevel {\n debug = 'Debug',\n information = 'Information',\n error = 'Error'\n}\n","import { Injectable } from '@angular/core';\nimport { Observable, Subject } from 'rxjs';\n\nimport { LogEvent } from './log-event';\nimport { LogLevel } from './log-level';\n\n@Injectable({\n providedIn: 'root'\n})\nexport class Logger {\n private readonly _logEvents$ = new Subject<LogEvent>();\n\n public get logEvents$(): Observable<LogEvent> {\n return this._logEvents$.asObservable();\n }\n\n public debug(message: string, payload?: unknown): void {\n this.log(LogLevel.debug, message, payload);\n }\n\n public information(message: string, payload?: unknown): void {\n this.log(LogLevel.information, message, payload);\n }\n\n public error(message: string, payload?: unknown): void {\n this.log(LogLevel.error, message, payload);\n }\n\n public log(level: LogLevel, message: string, payload?: unknown): void {\n this._logEvents$.next({\n level,\n message,\n payload\n });\n }\n}\n","import { inject, Injectable } from '@angular/core';\nimport { Subject, takeUntil } from 'rxjs';\nimport { Logger } from './logger';\nimport { LogLevel } from './log-level';\n\n@Injectable({\n providedIn: 'root'\n})\nexport class ConsoleAppender {\n private logger = inject(Logger);\n\n private readonly stopEvent$ = new Subject<boolean>();\n\n public start(contextName?: string): void {\n this.logger.logEvents$.pipe(takeUntil(this.stopEvent$)).subscribe((logEvent) => {\n let logFunction: (...data: unknown[]) => void;\n switch (logEvent.level) {\n case LogLevel.error:\n logFunction = console.error;\n break;\n\n default:\n logFunction = console.log;\n break;\n }\n\n const now = new Date().toLocaleString();\n const prefix = contextName ? `[${contextName}] ` : '';\n\n if (logEvent.payload) {\n logFunction(`${prefix}[${now}] [${logEvent.level}] ${logEvent.message}`, logEvent.payload);\n } else {\n logFunction(`${prefix}[${now}] [${logEvent.level}] ${logEvent.message}`);\n }\n });\n }\n\n public stop(): void {\n this.stopEvent$.next(true);\n }\n}\n","import { EnvironmentProviders, InjectionToken, makeEnvironmentProviders, inject, provideAppInitializer } from '@angular/core';\nimport { ConsoleAppender } from './console-appender';\n\nexport const NGSSM_CONSOLE_APPENDER_NAME = new InjectionToken<string>('NGSSM_CONSOLE_APPENDER_NAME');\n\nexport const startConsoleAppenderFactory = (): (() => void) => {\n return () => {\n const name = inject(NGSSM_CONSOLE_APPENDER_NAME);\n const consoleAppender = inject(ConsoleAppender);\n consoleAppender.start(name);\n };\n};\n\nexport const provideConsoleAppender = (name: string): EnvironmentProviders => {\n return makeEnvironmentProviders([\n {\n provide: NGSSM_CONSOLE_APPENDER_NAME,\n useValue: name\n },\n provideAppInitializer(startConsoleAppenderFactory())\n ]);\n};\n","import { ApplicationRef, EnvironmentInjector, Injectable, Signal, inject, runInInjectionContext, signal } from '@angular/core';\n\nimport update from 'immutability-helper';\n\nimport { FeatureStateSpecification } from './feature-state';\nimport { State } from './state';\nimport { Action } from './action';\nimport { NGSSM_REDUCER, Reducer } from './reducer';\nimport { Effect, NGSSM_EFFECT } from './effect';\nimport { NGSSM_STATE_INITIALIZER, StateInitializer } from './state-initializer';\nimport { Logger } from './logging';\nimport { ActionDispatcher } from './action-dispatcher';\n\nconst featureStateSpecifications: FeatureStateSpecification[] = [];\nexport const NgSsmFeatureState = (specification: FeatureStateSpecification) => {\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n return (target: object) => {\n featureStateSpecifications.push(specification);\n };\n};\n\n/**\n * The `Store` class is a centralized state management system for Angular applications.\n * It manages the application state, processes actions using reducers, and handles side effects using effects.\n * The class exposes Angular signals for reactive state management.\n *\n * ### Features:\n * - Centralized state management with support for reducers and effects.\n * - Reactive state updates using Angular signals.\n * - Modular initialization of feature states, reducers, and effects.\n * - Sequential action processing with an action queue.\n * - Logging for debugging and monitoring state changes and action processing.\n *\n * ### Usage:\n * - Dispatch actions using `dispatchAction` or `dispatchActionType`.\n * - Read state updates using `state` (Angular signal).\n */\n@Injectable({\n providedIn: 'root'\n})\nexport class Store implements ActionDispatcher {\n // If true, an action is processed in a macro-task by using setTimoeout. Otherwise, Promise.resolve() is used\n // When using micro task, an issue can occur with angular root effects that want to process state or action signals.\n // They can be executed after a list of actions is processed. In that case, some actions are never processed by the effects.\n public useMacroTasks = true;\n\n // If true, a call to ApplicationRef.tick is made after an action is processed and the state is updated.\n public forceChangeDetectionAfterActionProcessed = false;\n\n // Logger service for debugging and monitoring.\n private readonly logger = inject(Logger);\n // Array of reducers to process state updates.\n private readonly reducers: Reducer[] | null = inject(NGSSM_REDUCER, { optional: true }) as unknown as Reducer[];\n // Array of effects to handle side effects.\n private readonly effects: Effect[] | null = inject(NGSSM_EFFECT, { optional: true }) as unknown as Effect[];\n // Array of state initializers to set up the initial state.\n private readonly initializers: StateInitializer[] = inject(NGSSM_STATE_INITIALIZER, { optional: true }) as unknown as StateInitializer[];\n // Angular's `EnvironmentInjector` for running effects in the correct context.\n private readonly injector = inject(EnvironmentInjector);\n private readonly applicationRef = inject(ApplicationRef);\n\n // A queue to ensure actions are processed sequentially.\n private readonly actionQueue: Action[] = [];\n\n // Maps action types to their corresponding reducers.\n private readonly reducersPerActionType = new Map<string, Reducer[]>();\n\n // Maps action types to their corresponding effects.\n private readonly effectsPerActionType = new Map<string, Effect[]>();\n\n // The current state of the application, managed as an Angular signal.\n private readonly _stateSignal = signal<State>({});\n\n // The most recently action processed by reducers, managed as an Angular signal.\n private readonly _processedAction = signal<Action>({ type: '' });\n\n /**\n * Initializes the `Store` with reducers, effects, and state initializers.\n * Also sets up the initial state and registers reducers and effects.\n */\n constructor() {\n this.logger.information('[Store] ---> state initialization...');\n let state = this._stateSignal();\n\n // Initialize feature states.\n state = featureStateSpecifications.reduce((p, c) => update(p, { [c.featureStateKey]: { $set: c.initialState } }), state);\n\n // Apply state initializers.\n (this.initializers ?? []).forEach((initializer) => {\n this.logger.information('[Store] ------> calling initializer', initializer);\n state = initializer.initializeState(state);\n });\n\n // Update the state with the initialized values.\n this._stateSignal.set(state);\n\n // Register reducers and effects.\n this.logger.information(`[Store] ---> initialization of ${(this.reducers ?? []).length} reducers...`);\n this.initializeProcessors(this.reducers ?? [], this.reducersPerActionType, (r) => r.processedActions);\n this.logger.information(`[Store] ---> initialization of ${(this.effects ?? []).length} effects...`);\n this.initializeProcessors(this.effects ?? [], this.effectsPerActionType, (e) => e.processedActions);\n }\n\n /**\n * Returns the most recently action processed by reducers as an Angular signal.\n * Useful for accessing the last processed action in a reactive manner.\n * This signal is updated before processing the effects.\n */\n public get processedAction(): Signal<Action> {\n return this._processedAction.asReadonly();\n }\n\n /**\n * Returns the current state as an Angular signal.\n * Useful for signal-based reactivity in Angular components.\n */\n public get state(): Signal<State> {\n return this._stateSignal.asReadonly();\n }\n\n /**\n * Dispatches an action to the store.\n * The action is added to the action queue and processed sequentially.\n *\n * @param action - The action to dispatch.\n */\n public dispatchAction(action: Action): void {\n this.actionQueue.push(action);\n this.logger.debug(`Action of type '${action.type}' added to the queue => ${this.actionQueue.length} pending actions`, action);\n\n this.addTaskForNextAction();\n }\n\n /**\n * Dispatches an action by its type.\n * This is a shorthand for dispatching actions without additional payload.\n *\n * @param type - The type of the action to dispatch.\n */\n public dispatchActionType(type: string): void {\n this.dispatchAction({ type });\n }\n\n /**\n * Processes the next action in the action queue.\n * Applies reducers to update the state and executes effects for side effects.\n */\n private processNextAction(): void {\n const nextAction = this.actionQueue.shift();\n if (!nextAction) {\n this.logger.debug('[processNextAction] No action to process');\n return;\n }\n\n this.logger.information(`[processNextAction] Start processing action '${nextAction.type}...`, nextAction);\n\n try {\n // Apply reducers to update the state.\n const updatedState = this.applyReducers(nextAction);\n\n if (this.forceChangeDetectionAfterActionProcessed) {\n this.applicationRef.tick();\n }\n\n // Execute effects for the action.\n const effects = this.effectsPerActionType.get(nextAction.type) ?? [];\n this.logger.debug(`[Store] ${effects.length} effects found to process the action ${nextAction.type}`, effects);\n effects.forEach((effect) => {\n if (effect.isFunc === true) {\n runInInjectionContext(this.injector, () => this.runEffect(effect, updatedState, nextAction));\n } else {\n this.runEffect(effect, updatedState, nextAction);\n }\n });\n } catch (error) {\n this.logger.error(`Error when processing action ${nextAction.type}`, {\n error,\n action: nextAction\n });\n } finally {\n this.logger.information(`[processNextAction] action '${nextAction.type} processed.`, nextAction);\n\n // Process the next action asynchronously\n this.addTaskForNextAction();\n }\n }\n\n /**\n * Applies reducers to the current state based on the dispatched action.\n * Updates the state if there are changes and sets the processed action signal.\n *\n * @param nextAction - The action being processed.\n * @returns The updated state after applying reducers.\n */\n private applyReducers(nextAction: Action): State {\n try {\n const reducers = this.reducersPerActionType.get(nextAction.type) ?? [];\n this.logger.debug(`[Store] ${reducers.length} reducers found to process the action ${nextAction.type}`, reducers);\n const currentState = this._stateSignal();\n const updatedState = reducers.reduce((p, c) => c.updateState(p, nextAction), currentState);\n\n if (updatedState !== currentState) {\n this._stateSignal.set(updatedState);\n }\n\n return updatedState;\n } finally {\n this.logger.debug(`[Store] Notify action ${nextAction.type} as processed`);\n this._processedAction.set(nextAction);\n }\n }\n\n /**\n * Executes an effect for a given action.\n * Handles any errors that occur during effect execution.\n *\n * @param effect - The effect to execute.\n * @param updatedState - The updated state after reducers have been applied.\n * @param nextAction - The action being processed.\n */\n private runEffect(effect: Effect, updatedState: State, nextAction: Action): void {\n try {\n effect.processAction(this, updatedState, nextAction);\n } catch (error) {\n this.logger.error(`Unable to process action ${nextAction.type} by effect ${effect}`, {\n error,\n action: nextAction,\n processor: effect\n });\n }\n }\n\n /**\n * Initializes reducers or effects and maps them to their corresponding action types.\n *\n * @param processors - The array of reducers or effects to initialize.\n * @param processorMap - The map to store processors by action type.\n * @param getProcessedActions - A function to retrieve the action types processed by a processor.\n */\n private initializeProcessors<T>(processors: T[], processorMap: Map<string, T[]>, getProcessedActions: (processor: T) => string[]): void {\n processors.forEach((processor) => {\n this.logger.information('[Store] ------> initialization of ', processor);\n getProcessedActions(processor).forEach((actionType) => {\n const storedProcessors = processorMap.get(actionType) ?? [];\n if (storedProcessors.length === 0) {\n processorMap.set(actionType, storedProcessors);\n }\n storedProcessors.push(processor);\n });\n });\n }\n\n private addTaskForNextAction(): void {\n if (this.useMacroTasks) {\n setTimeout(() => this.processNextAction());\n } else {\n Promise.resolve().then(() => this.processNextAction());\n }\n }\n}\n","import { InjectionToken } from '@angular/core';\n\nexport interface FeatureStateSpecification {\n readonly featureStateKey: string;\n readonly initialState: object;\n}\n\nexport const NGSSM_COMPONENT_WITH_FEATURE_STATE = new InjectionToken<FeatureStateSpecification>('NGSSM_COMPONENT_WITH_FEATURE_STATE');\n","export enum NgssmStoreActionType {\n registerFeatureState = '[NgssmStoreActionType] registerFeatureState',\n unregisterFeatureState = '[NgssmStoreActionType] unregisterFeatureState'\n}\n","import { Action } from '../action';\nimport { NgssmStoreActionType } from './ngssm-store-action-type';\n\nexport class NgssmRegisterFeatureStateAction implements Action {\n public readonly type: string = NgssmStoreActionType.registerFeatureState;\n\n constructor(\n public readonly featureStateKey: string,\n public readonly initialValue: object\n ) {}\n}\n","import { Action } from '../action';\nimport { NgssmStoreActionType } from './ngssm-store-action-type';\n\nexport class NgssmUnregisterFeatureStateAction implements Action {\n public readonly type: string = NgssmStoreActionType.unregisterFeatureState;\n\n constructor(public readonly featureStateKey: string) {}\n}\n","import { EnvironmentProviders, makeEnvironmentProviders, inject, provideAppInitializer } from '@angular/core';\nimport { Store } from '../store';\nimport { NgssmRegisterFeatureStateAction } from '../actions';\n\nconst registerFeatureState = (featureStateKey: string, initialValue: object) => {\n return () => {\n inject(Store).dispatchAction(new NgssmRegisterFeatureStateAction(featureStateKey, initialValue));\n };\n};\n\nexport const provideNgssmFeatureState = (featureStateKey: string, initialValue: object): EnvironmentProviders => {\n return makeEnvironmentProviders([provideAppInitializer(registerFeatureState(featureStateKey, initialValue))]);\n};\n","import { Directive, inject, OnDestroy } from '@angular/core';\n\nimport { Store } from '../store';\nimport { NgssmRegisterFeatureStateAction, NgssmUnregisterFeatureStateAction } from '../actions';\nimport { FeatureStateSpecification, NGSSM_COMPONENT_WITH_FEATURE_STATE } from './feature-state-specification';\n\n// export interface ComponentWithFeatureState {\n// featureStateKey: string;\n// initialValue: object;\n// }\n\n// export const NGSSM_COMPONENT_WITH_FEATURE_STATE = new InjectionToken<ComponentWithFeatureState>('NGSSM_COMPONENT_WITH_FEATURE_STATE');\n\n@Directive({\n // eslint-disable-next-line @angular-eslint/directive-selector\n selector: '[provideNgssmFeatureState]'\n})\nexport class ProvideNgssmFeatureStateDirective implements OnDestroy {\n private readonly component: FeatureStateSpecification = inject(NGSSM_COMPONENT_WITH_FEATURE_STATE);\n private store = inject(Store);\n\n constructor() {\n this.store.dispatchAction(new NgssmRegisterFeatureStateAction(this.component.featureStateKey, this.component.initialState));\n }\n\n public ngOnDestroy(): void {\n this.store.dispatchAction(new NgssmUnregisterFeatureStateAction(this.component.featureStateKey));\n }\n}\n","import { Injectable } from '@angular/core';\n\nimport update from 'immutability-helper';\n\nimport { Reducer } from '../reducer';\nimport { NgssmRegisterFeatureStateAction, NgssmStoreActionType, NgssmUnregisterFeatureStateAction } from '../actions';\nimport { State } from '../state';\nimport { Action } from '../action';\n\n@Injectable()\nexport class FeatureStateReducer implements Reducer {\n public readonly processedActions: string[] = [NgssmStoreActionType.registerFeatureState, NgssmStoreActionType.unregisterFeatureState];\n\n public updateState(state: State, action: Action): State {\n switch (action.type) {\n case NgssmStoreActionType.registerFeatureState: {\n const registerFeatureStateAction = action as NgssmRegisterFeatureStateAction;\n return update(state, {\n [registerFeatureStateAction.featureStateKey]: { $set: registerFeatureStateAction.initialValue }\n });\n }\n\n case NgssmStoreActionType.unregisterFeatureState: {\n const unregisterFeatureStateAction = action as NgssmUnregisterFeatureStateAction;\n return update(state, {\n $unset: [unregisterFeatureStateAction.featureStateKey]\n });\n }\n }\n\n return state;\n }\n}\n","import { EnvironmentProviders, InjectionToken, makeEnvironmentProviders } from '@angular/core';\n\nimport { provideReducers } from './reducer';\nimport { ActionDispatcher } from './action-dispatcher';\nimport { FeatureStateReducer } from './feature-state';\nimport { Store } from './store';\n\nexport const ACTION_DISPATCHER = new InjectionToken<ActionDispatcher>('ACTION_DISPATCHER');\n\nexport const provideNgssmStore = (): EnvironmentProviders => {\n return makeEnvironmentProviders([provideReducers(FeatureStateReducer), { provide: ACTION_DISPATCHER, useExisting: Store }]);\n};\n","import { computed, inject, Signal } from '@angular/core';\nimport { State } from './state';\nimport { Store } from './store';\n\nexport const createSignal = <T = unknown>(selector: (state: State) => T): Signal<T> => {\n const store = inject(Store);\n return computed(() => selector(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A2B,kBAAkB,EAAE,MAAM,2BAA2B,aAAY,EAC9F,CAAA;GACH;GAEA,KAAK,qBAAqB,wBAExB,OAAO,OAAO,OAAO,EACnB,QAAQ,CAAC,OAA6B,eAAe,EACtD,CAAA;EAEL;EAEA,OAAO;CACT;CArBW,OAAA,OAAA,GAAA,mBAAA;EAAA,YAAA;EAAA,SAAA;EAAA,UAAA;EAAA,MAAA;EAAmB,MAAA,CAAA;EAAA,QAAA,GAAA,gBAAA;CAAA,CAAA;CAAnB,OAAA,QAAA,GAAA,sBAAA;EAAA,YAAA;EAAA,SAAA;EAAA,UAAA;EAAA,MAAA;CAAmB,CAAA;;AAAnB,GAAA,yBAAA;CAAA,YAAA;CAAA,SAAA;CAAA,UAAA;CAAA,MAAA;CAAmB,YAAA,CAAA,EAD/B,MAAA,WAAA,CAAA;;ACFD,MAAa,oBAAoB,IAAI,eAAiC,mBAAmB;AAEzF,MAAa,0BAA+C;CAC1D,OAAO,yBAAyB,CAAC,gBAAgB,mBAAmB,GAAG;EAAE,SAAS;EAAmB,aAAa;CAAK,CAAE,CAAC;AAC5H;ACPA,MAAa,gBAA6B,aAA4C;CACpF,MAAM,QAAQ,OAAO,KAAK;CAC1B,OAAO,eAAe,SAAS,MAAM,MAAK,CAAE,CAAC;AAC/C"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ngssm-store",
3
- "version": "22.1.0",
3
+ "version": "22.2.1",
4
4
  "description": "NgSsm - Simple state management implementation.",
5
5
  "author": "Lion Marc",
6
6
  "license": "MIT",
@@ -1,51 +1,47 @@
1
- import * as i0 from '@angular/core';
2
- import { EnvironmentProviders } from '@angular/core';
3
- import { SetCachedItemAction, CachedItemStatus } from 'ngssm-store/caching';
4
- import { StoreMock } from 'ngssm-store/testing';
5
-
1
+ import * as i0 from "@angular/core";
2
+ import { EnvironmentProviders } from "@angular/core";
3
+ import { CachedItemStatus, SetCachedItemAction } from "ngssm-store/caching";
4
+ import { StoreMock } from "ngssm-store/testing";
6
5
  /**
7
6
  * App initializer that sets up the NgssmCaching state in the StoreMock for testing purposes.
8
7
  * Throws an error if StoreMock is not registered.
9
8
  */
10
- declare const ngssmCachingStateInitializer: () => void;
9
+ export declare const ngssmCachingStateInitializer: () => void;
11
10
  /**
12
11
  * Provides environment providers for NgssmCaching testing, including the state initializer.
13
12
  */
14
- declare const provideNgssmCachingTesting: () => EnvironmentProviders;
15
-
13
+ export declare const provideNgssmCachingTesting: () => EnvironmentProviders;
16
14
  /**
17
15
  * Utility service for setting and updating cached items in the StoreMock during tests.
18
16
  * Provides methods to apply a SetCachedItemAction, set the status, or set the value of a cached item.
19
17
  */
20
- declare class NgssmCachedItemSetter {
21
- readonly store: StoreMock;
22
- /**
23
- * Applies a SetCachedItemAction to the StoreMock, updating the cache state.
24
- * @param action The SetCachedItemAction to apply.
25
- * @returns The NgssmCachedItemSetter instance for chaining.
26
- */
27
- apply<T = unknown>(action: SetCachedItemAction<T>): NgssmCachedItemSetter;
28
- /**
29
- * Sets the status of a cached item in the StoreMock.
30
- * If the key does not exist in cache, it is created with an undefined value.
31
- *
32
- * @param cachedItemKey The key of the cached item.
33
- * @param status The new status to set.
34
- * @returns The NgssmCachedItemSetter instance for chaining.
35
- */
36
- setCachedItemStatus(cachedItemKey: string, status: CachedItemStatus): NgssmCachedItemSetter;
37
- /**
38
- * Sets the value of a cached item in the StoreMock.
39
- * If the key does not exist in cache, it is created with the status CachedItemStatus.notSet.
40
- *
41
- * @param cachedItemKey The key of the cached item.
42
- * @param value The value to set.
43
- * @returns The NgssmCachedItemSetter instance for chaining.
44
- */
45
- setCachedItemValue<T>(cachedItemKey: string, value?: T): NgssmCachedItemSetter;
46
- static ɵfac: i0.ɵɵFactoryDeclaration<NgssmCachedItemSetter, never>;
47
- static ɵprov: i0.ɵɵInjectableDeclaration<NgssmCachedItemSetter>;
18
+ export declare class NgssmCachedItemSetter {
19
+ readonly store: StoreMock;
20
+ /**
21
+ * Applies a SetCachedItemAction to the StoreMock, updating the cache state.
22
+ * @param action The SetCachedItemAction to apply.
23
+ * @returns The NgssmCachedItemSetter instance for chaining.
24
+ */
25
+ apply<T = unknown>(action: SetCachedItemAction<T>): NgssmCachedItemSetter;
26
+ /**
27
+ * Sets the status of a cached item in the StoreMock.
28
+ * If the key does not exist in cache, it is created with an undefined value.
29
+ *
30
+ * @param cachedItemKey The key of the cached item.
31
+ * @param status The new status to set.
32
+ * @returns The NgssmCachedItemSetter instance for chaining.
33
+ */
34
+ setCachedItemStatus(cachedItemKey: string, status: CachedItemStatus): NgssmCachedItemSetter;
35
+ /**
36
+ * Sets the value of a cached item in the StoreMock.
37
+ * If the key does not exist in cache, it is created with the status CachedItemStatus.notSet.
38
+ *
39
+ * @param cachedItemKey The key of the cached item.
40
+ * @param value The value to set.
41
+ * @returns The NgssmCachedItemSetter instance for chaining.
42
+ */
43
+ setCachedItemValue<T>(cachedItemKey: string, value?: T): NgssmCachedItemSetter;
44
+ static ɵfac: i0.ɵɵFactoryDeclaration<NgssmCachedItemSetter, never>;
45
+ static ɵprov: i0.ɵɵInjectableDeclaration<any>;
48
46
  }
49
- declare const ngssmCachedItemSetter: () => NgssmCachedItemSetter;
50
-
51
- export { NgssmCachedItemSetter, ngssmCachedItemSetter, ngssmCachingStateInitializer, provideNgssmCachingTesting };
47
+ export declare const ngssmCachedItemSetter: () => NgssmCachedItemSetter;
@@ -1,27 +1,22 @@
1
- import { EnvironmentProviders, Signal } from '@angular/core';
2
- import { Action, State } from 'ngssm-store';
3
- import { CustomCommands, Spec } from 'immutability-helper';
4
-
5
- declare const provideNgssmCaching: () => EnvironmentProviders;
6
-
7
- declare enum NgssmCachingActionType {
8
- setCachedItem = "[NgssmCachingActionType] setCachedItem",
9
- unsetCachedItem = "[NgssmCachingActionType] unsetCachedItem"
1
+ import { EnvironmentProviders, Signal } from "@angular/core";
2
+ import { Action, State } from "ngssm-store";
3
+ import { CustomCommands, Spec } from "immutability-helper";
4
+ export declare const provideNgssmCaching: () => EnvironmentProviders;
5
+ export declare enum NgssmCachingActionType {
6
+ setCachedItem = "[NgssmCachingActionType] setCachedItem",
7
+ unsetCachedItem = "[NgssmCachingActionType] unsetCachedItem"
10
8
  }
11
-
12
- declare enum CachedItemStatus {
13
- notSet = "Not Set",
14
- loading = "Loading",
15
- set = "Set",
16
- error = "Error"
9
+ export declare enum CachedItemStatus {
10
+ notSet = "Not Set",
11
+ loading = "Loading",
12
+ set = "Set",
13
+ error = "Error"
17
14
  }
18
-
19
- interface CachedItem<TData = unknown> {
20
- status: CachedItemStatus;
21
- item?: TData;
22
- error?: string;
15
+ export interface CachedItem<TData = unknown> {
16
+ status: CachedItemStatus;
17
+ item?: TData;
18
+ error?: string;
23
19
  }
24
-
25
20
  /**
26
21
  * Represents an action to set a cached item in the state. If key is already set in the state, the value is replaced by the new one.
27
22
  *
@@ -36,43 +31,36 @@ interface CachedItem<TData = unknown> {
36
31
  * @remarks
37
32
  * This action is dispatched to update the cache with a new or modified item, along with its status and any error information.
38
33
  */
39
- declare class SetCachedItemAction<TData = unknown> implements Action {
40
- readonly cachedItemKey: string;
41
- readonly cachedItem: TData;
42
- readonly status: CachedItemStatus;
43
- readonly error?: string | undefined;
44
- readonly type: string;
45
- constructor(cachedItemKey: string, cachedItem: TData, status?: CachedItemStatus, error?: string | undefined);
34
+ export declare class SetCachedItemAction<TData = unknown> implements Action {
35
+ readonly cachedItemKey: string;
36
+ readonly cachedItem: TData;
37
+ readonly status: CachedItemStatus;
38
+ readonly error?: string | undefined;
39
+ readonly type: string;
40
+ constructor(cachedItemKey: string, cachedItem: TData, status?: CachedItemStatus, error?: string | undefined);
46
41
  }
47
-
48
- declare class UnsetCachedItemAction implements Action {
49
- readonly cachedItemKey: string;
50
- readonly type: string;
51
- constructor(cachedItemKey: string);
42
+ export declare class UnsetCachedItemAction implements Action {
43
+ readonly cachedItemKey: string;
44
+ readonly type: string;
45
+ constructor(cachedItemKey: string);
52
46
  }
53
-
54
- declare const selectNgssmCachingState: (state: State) => NgssmCachingState;
55
- declare const updateNgssmCachingState: <T extends CustomCommands<object> = never>(state: State, command: Spec<NgssmCachingState, T>) => State;
56
- interface NgssmCachingState {
57
- caches: Record<string, CachedItem>;
47
+ export declare const selectNgssmCachingState: (state: State) => NgssmCachingState;
48
+ export declare const updateNgssmCachingState: <T extends CustomCommands<object> = never>(state: State, command: Spec<NgssmCachingState, T>) => State;
49
+ export interface NgssmCachingState {
50
+ caches: Record<string, CachedItem>;
58
51
  }
59
- declare class NgssmCachingStateSpecification {
60
- static readonly featureStateKey = "ngssm-caching-state";
61
- static readonly initialState: NgssmCachingState;
52
+ export declare class NgssmCachingStateSpecification {
53
+ static readonly featureStateKey = "ngssm-caching-state";
54
+ static readonly initialState: NgssmCachingState;
62
55
  }
63
-
64
- declare const selectNgssmCachedItem: <T = unknown>(state: State, key: string) => CachedItem<T> | undefined;
65
-
66
- interface NgssmCachedItemSignal<T = unknown> {
67
- key: string;
68
- value: Signal<T>;
56
+ export declare const selectNgssmCachedItem: <T = unknown>(state: State, key: string) => CachedItem<T> | undefined;
57
+ export interface NgssmCachedItemSignal<T = unknown> {
58
+ key: string;
59
+ value: Signal<T>;
69
60
  }
70
- type NgssmCachedItemSignalType = 'item' | 'status' | 'error';
71
- interface NgssmCachedItemSignalOptions<T = unknown> {
72
- type?: NgssmCachedItemSignalType;
73
- defaultValue?: T;
61
+ export type NgssmCachedItemSignalType = 'item' | 'status' | 'error';
62
+ export interface NgssmCachedItemSignalOptions<T = unknown> {
63
+ type?: NgssmCachedItemSignalType;
64
+ defaultValue?: T;
74
65
  }
75
- declare const cachedItemToSignal: <T = unknown>(key: string, options?: NgssmCachedItemSignalOptions<T>) => NgssmCachedItemSignal<T>;
76
-
77
- export { CachedItemStatus, NgssmCachingActionType, NgssmCachingStateSpecification, SetCachedItemAction, UnsetCachedItemAction, cachedItemToSignal, provideNgssmCaching, selectNgssmCachedItem, selectNgssmCachingState, updateNgssmCachingState };
78
- export type { CachedItem, NgssmCachedItemSignal, NgssmCachedItemSignalOptions, NgssmCachedItemSignalType, NgssmCachingState };
66
+ export declare const cachedItemToSignal: <T = unknown>(key: string, options?: NgssmCachedItemSignalOptions<T>) => NgssmCachedItemSignal<T>;
@@ -1,20 +1,16 @@
1
- import { WritableSignal, EnvironmentProviders } from '@angular/core';
2
- import { BehaviorSubject } from 'rxjs';
3
- import { ActionDispatcher, State, Action } from 'ngssm-store';
4
-
5
- declare class StoreMock implements ActionDispatcher {
6
- readonly state$: BehaviorSubject<State>;
7
- readonly state: WritableSignal<State>;
8
- logsEnabled: boolean;
9
- processedAction: WritableSignal<Action>;
10
- private _stateValue;
11
- constructor(initialState: State);
12
- get stateValue(): State;
13
- set stateValue(value: State);
14
- dispatchAction(action: Action): void;
15
- dispatchActionType(type: string): void;
1
+ import { EnvironmentProviders, WritableSignal } from "@angular/core";
2
+ import { Action, ActionDispatcher, State } from "ngssm-store";
3
+ export declare class StoreMock implements ActionDispatcher {
4
+ readonly state: WritableSignal<State>;
5
+ logsEnabled: boolean;
6
+ processedAction: WritableSignal<Action>;
7
+ private _stateValue;
8
+ constructor(initialState: State);
9
+ get stateValue(): State;
10
+ set stateValue(value: State);
11
+ dispatchAction(action: Action): void;
12
+ dispatchActionType(type: string): void;
16
13
  }
17
-
18
14
  /**
19
15
  * Provides a testing environment provider for the `Store` service using a mock implementation.
20
16
  *
@@ -28,6 +24,4 @@ declare class StoreMock implements ActionDispatcher {
28
24
  * or manipulate the mock store before it is provided to the testing environment.
29
25
  * @returns The environment providers configured with the `StoreMock`.
30
26
  */
31
- declare const provideNgssmStoreTesting: (action?: (store: StoreMock) => void) => EnvironmentProviders;
32
-
33
- export { StoreMock, provideNgssmStoreTesting };
27
+ export declare const provideNgssmStoreTesting: (action?: (store: StoreMock) => void) => EnvironmentProviders;
@@ -1,48 +1,44 @@
1
- import * as i0 from '@angular/core';
2
- import { EnvironmentProviders } from '@angular/core';
3
- import { StoreMock } from 'ngssm-store/testing';
4
-
1
+ import * as i0 from "@angular/core";
2
+ import { EnvironmentProviders } from "@angular/core";
3
+ import { StoreMock } from "ngssm-store/testing";
5
4
  /**
6
5
  * App initializer that sets up the ngssm state visibility in the StoreMock for testing purposes.
7
6
  * Throws an error if StoreMock is not registered.
8
7
  */
9
- declare const ngssmVisibilityStateInitializer: () => void;
8
+ export declare const ngssmVisibilityStateInitializer: () => void;
10
9
  /**
11
10
  * Provides environment providers for ngssm visibility testing, including the state initializer.
12
11
  */
13
- declare const provideNgssmVisibilityTesting: () => EnvironmentProviders;
14
-
12
+ export declare const provideNgssmVisibilityTesting: () => EnvironmentProviders;
15
13
  /**
16
14
  * Utility service for manipulating element visibility state in the StoreMock during tests.
17
15
  * Provides methods to show, hide, or toggle the visibility of an element.
18
16
  */
19
- declare class NgssmVisibilitySetter {
20
- readonly store: StoreMock;
21
- private readonly reducer;
22
- /**
23
- * Sets the specified element as visible in the StoreMock.
24
- * @param elementKey The key of the element to show.
25
- * @returns The NgssmVisibilitySetter instance for chaining.
26
- */
27
- showElement(elementKey: string): NgssmVisibilitySetter;
28
- /**
29
- * Sets the specified element as hidden in the StoreMock.
30
- * @param elementKey The key of the element to hide.
31
- * @returns The NgssmVisibilitySetter instance for chaining.
32
- */
33
- hideElement(elementKey: string): NgssmVisibilitySetter;
34
- /**
35
- * Toggles the visibility of the specified element in the StoreMock.
36
- * @param elementKey The key of the element to toggle.
37
- * @returns The NgssmVisibilitySetter instance for chaining.
38
- */
39
- toggleElementVisibility(elementKey: string): NgssmVisibilitySetter;
40
- static ɵfac: i0.ɵɵFactoryDeclaration<NgssmVisibilitySetter, never>;
41
- static ɵprov: i0.ɵɵInjectableDeclaration<NgssmVisibilitySetter>;
17
+ export declare class NgssmVisibilitySetter {
18
+ readonly store: StoreMock;
19
+ private readonly reducer;
20
+ /**
21
+ * Sets the specified element as visible in the StoreMock.
22
+ * @param elementKey The key of the element to show.
23
+ * @returns The NgssmVisibilitySetter instance for chaining.
24
+ */
25
+ showElement(elementKey: string): NgssmVisibilitySetter;
26
+ /**
27
+ * Sets the specified element as hidden in the StoreMock.
28
+ * @param elementKey The key of the element to hide.
29
+ * @returns The NgssmVisibilitySetter instance for chaining.
30
+ */
31
+ hideElement(elementKey: string): NgssmVisibilitySetter;
32
+ /**
33
+ * Toggles the visibility of the specified element in the StoreMock.
34
+ * @param elementKey The key of the element to toggle.
35
+ * @returns The NgssmVisibilitySetter instance for chaining.
36
+ */
37
+ toggleElementVisibility(elementKey: string): NgssmVisibilitySetter;
38
+ static ɵfac: i0.ɵɵFactoryDeclaration<NgssmVisibilitySetter, never>;
39
+ static ɵprov: i0.ɵɵInjectableDeclaration<any>;
42
40
  }
43
41
  /**
44
42
  * Helper function to retrieve the NgssmVisibilitySetter instance from the TestBed.
45
43
  */
46
- declare const ngssmVisibilitySetter: () => NgssmVisibilitySetter;
47
-
48
- export { NgssmVisibilitySetter, ngssmVisibilitySetter, ngssmVisibilityStateInitializer, provideNgssmVisibilityTesting };
44
+ export declare const ngssmVisibilitySetter: () => NgssmVisibilitySetter;