ngssm-store 22.2.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","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 = (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';\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(store.state()));\n};\n"],"mappings":";;;;AAUA,MAAa,gBAAgB,IAAI,eAAwB,eAAe;AAExE,MAAa,kBAAkB,YAAgD;CAC7E,OAAO,yBAAyB,CAAC;EAAE,SAAS;EAAe,UAAU;EAAS,OAAO;CAAI,CAAE,CAAC;AAC9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,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"}
|
|
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(store.state()));\n};\n"],"mappings":";;;;AAUA,MAAa,gBAAgB,IAAI,eAAwB,eAAe;AAExE,MAAa,kBAAkB,YAAgD;CAC7E,OAAO,yBAAyB,CAAC;EAAE,SAAS;EAAe,UAAU;EAAS,OAAO;CAAI,CAAE,CAAC;AAC9F;AAEA,MAAa,mBAAmB,GAAG,aAAmD;CACpF,OAAO,yBAAyB,SAAS,KAAK,aAAa;EAAE,SAAS;EAAe,UAAU;EAAS,OAAO;CAAI,EAAG,CAAC;AACzH;ACJA,MAAa,eAAe,IAAI,eAAuB,cAAc;AAErE,MAAa,iBAAiB,WAA+C;CAC3E,OAAO,yBAAyB,CAAC;EAAE,SAAS;EAAc,UAAU;EAAQ,OAAO;CAAI,CAAE,CAAC;AAC5F;AAEA,MAAa,kBAAkB,GAAG,YAAkD;CAClF,OAAO,yBAAyB,QAAQ,KAAK,YAAY;EAAE,SAAS;EAAc,UAAU;EAAQ,OAAO;CAAI,EAAG,CAAC;AACrH;AAEA,MAAa,qBACX,YACA,eACwB;CACxB,OAAO,yBAAyB,CAC9B;EACE,SAAS;EACT,kBAAiB;GAMf,OAAO;IAJL,kBAAkB,CAAC,UAAU;IAC7B,gBAAgB,GAAG,OAAO,WAAW,WAAW,OAAO,MAAqB;IAC5E,QAAQ;GAEH;EACT;EACA,OAAO;CACR,CACF,CAAA;AACH;ACnCA,MAAa,0BAA0B,IAAI,eAAiC,yBAAyB;ACP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
140
140
|
export declare const NGSSM_EFFECT: InjectionToken<Effect>;
|
|
141
141
|
export declare const provideEffect: (effect: Type<unknown>) => EnvironmentProviders;
|
|
142
142
|
export declare const provideEffects: (...effects: Type<unknown>[]) => EnvironmentProviders;
|
|
143
|
-
export declare const provideEffectFunc: (actionType: string, effectFunc: EffectFunc) => EnvironmentProviders;
|
|
143
|
+
export declare const provideEffectFunc: <TActionType extends Action = Action>(actionType: string, effectFunc: EffectFunc<TActionType>) => EnvironmentProviders;
|
|
144
144
|
export interface StateInitializer {
|
|
145
145
|
initializeState(state: State): State;
|
|
146
146
|
}
|