ngx-statewise
Version:
A lightweight and intuitive state management for Angular. Simpler than NgRx, more structured than DIY.
1 lines • 63.6 kB
Source Map (JSON)
{"version":3,"file":"ngx-statewise.mjs","sources":["../../../projects/ngx-statewise/src/lib/action/utils/action.utils.ts","../../../projects/ngx-statewise/src/lib/action/services/factories/action.factory.ts","../../../projects/ngx-statewise/src/lib/action/services/handlers/action-group.handler.ts","../../../projects/ngx-statewise/src/lib/action/services/handlers/single-action.handler.ts","../../../projects/ngx-statewise/src/lib/action/services/action.service.ts","../../../projects/ngx-statewise/src/lib/registries/effect-relation.registery.ts","../../../projects/ngx-statewise/src/lib/registries/pending-effect.registery.ts","../../../projects/ngx-statewise/src/lib/effect/services/resolvers/effect-result.resolver.ts","../../../projects/ngx-statewise/src/lib/registries/global-updators.registery.ts","../../../projects/ngx-statewise/src/lib/registries/action-context.registery.ts","../../../projects/ngx-statewise/src/lib/registries/local-updators.registery.ts","../../../projects/ngx-statewise/src/lib/updator/utils/updator.utils.ts","../../../projects/ngx-statewise/src/lib/registries/global-effect.registery.ts","../../../projects/ngx-statewise/src/lib/action/services/action-history.service.ts","../../../projects/ngx-statewise/src/lib/action/services/handlers/action-effect.handler.ts","../../../projects/ngx-statewise/src/lib/action/services/action-dispatcher.service.ts","../../../projects/ngx-statewise/src/lib/manager/services/coordinator.service.ts","../../../projects/ngx-statewise/src/lib/manager/services/resolvers/updator.resolver.ts","../../../projects/ngx-statewise/src/lib/manager/services/handlers/dispatch.handler.ts","../../../projects/ngx-statewise/src/lib/effect/services/handlers/effect-result.handler.ts","../../../projects/ngx-statewise/src/lib/effect/services/effect-promise.service.ts","../../../projects/ngx-statewise/src/lib/effect/services/effect-registration.service.ts","../../../projects/ngx-statewise/src/lib/injector/root-injector.ts","../../../projects/ngx-statewise/src/lib/injector/injection-utils.ts","../../../projects/ngx-statewise/src/lib/effect/utils/create-effect.utils.ts","../../../projects/ngx-statewise/src/lib/effect/utils/pending-effect.utils.ts","../../../projects/ngx-statewise/src/lib/manager/services/dispatch.service.ts","../../../projects/ngx-statewise/src/lib/manager/services/handlers/dispatchAsync.handler.ts","../../../projects/ngx-statewise/src/lib/manager/services/dispatchAsync.service.ts","../../../projects/ngx-statewise/src/lib/updator/services/updator-registration.service.ts","../../../projects/ngx-statewise/src/lib/providers/provide-statewise.ts","../../../projects/ngx-statewise/src/lib/providers/provide-effects.ts","../../../projects/ngx-statewise/src/lib/providers/provide-updator.ts","../../../projects/ngx-statewise/src/public-api.ts","../../../projects/ngx-statewise/src/ngx-statewise.ts"],"sourcesContent":["import {\n Action,\n EmptyPayloadFn,\n ValuePayloadFn,\n} from '../interfaces/action-type';\n\n/**\n * Represents an empty payload for actions without data.\n *\n * @returns `undefined`\n */\nexport const emptyPayload: EmptyPayloadFn = () => undefined;\n\n/**\n * Creates a typed identity function for payloads.\n *\n * Useful to define payload handlers with a specific type.\n *\n * @template T - The expected payload type.\n * @returns A function that returns the same payload it receives.\n */\nexport function payload<T>(): ValuePayloadFn<T> {\n return (p: T) => p;\n}\n\n/**\n * Converts a camelCase or PascalCase string to SCREAMING_SNAKE_CASE.\n *\n * @param str - The input string.\n * @returns The same string converted to SCREAMING_SNAKE_CASE.\n *\n * @example\n * toScreamingSnakeCase('loadFailure') // 'LOAD_FAILURE'\n * toScreamingSnakeCase('UserLogin') // 'USER_LOGIN'\n */\nexport function toScreamingSnakeCase(str: string): string {\n return str.replace(/([a-z])([A-Z])/g, '$1_$2').toUpperCase();\n}\n\n/**\n * Extracts the action type string from an action creator or object.\n *\n * @param action - Either an action creator (function with `.type`) or an action object.\n * @returns The `type` string.\n *\n * @example\n * ofType(someActionCreator) // 'SOME_ACTION'\n * ofType({ type: 'MY_ACTION' }) // 'MY_ACTION'\n */\nexport function ofType<T extends (...args: any[]) => Action>(action: T): string;\nexport function ofType(action: { type: string }): string;\nexport function ofType(action: any): string {\n if (typeof action === 'function') {\n return action.type;\n }\n return action.type;\n}\n","import { SingleAction, ValuePayloadFn } from \"../../interfaces/action-type\";\nimport { emptyPayload } from \"../../utils/action.utils\";\n\nexport class ActionCreatorFactory {\n public static defineActionCreator<T extends string, P>(\n type: T,\n payloadFn: SingleAction<P>\n ): any {\n let fn: any;\n if (payloadFn === emptyPayload) {\n fn = () => this.createAction(type);\n } else {\n fn = (payload: P) =>\n this.createAction(type, (payloadFn as ValuePayloadFn<P>)(payload));\n }\n fn.type = type;\n return fn;\n }\n\n private static createAction<T extends string>(type: T): { type: T };\n private static createAction<T extends string, P>(\n type: T,\n payload: P\n ): { type: T; payload: P };\n private static createAction<T extends string, P>(\n type: T,\n payload?: P\n ): { type: T; payload?: P } {\n return payload === undefined ? { type } : { type, payload };\n }\n}\n","import {\n SingleAction,\n EmptyPayloadFn,\n CamelToSnakeCase,\n} from '../../interfaces/action-type';\nimport { toScreamingSnakeCase } from '../../utils/action.utils';\nimport { ActionCreatorFactory } from '../factories/action.factory';\n\nexport class ActionGroupHandler {\n\n public static handle<\n Source extends string,\n Events extends Record<string, SingleAction<any>>\n >(config: {\n source: Source;\n events: Events;\n }): {\n [K in keyof Events]: Events[K] extends EmptyPayloadFn\n ? () => {\n type: `${Uppercase<Source>}_${Uppercase<\n CamelToSnakeCase<string & K>\n >}`;\n }\n : (payload: Parameters<Events[K]>[0]) => {\n type: `${Uppercase<Source>}_${Uppercase<\n CamelToSnakeCase<string & K>\n >}`;\n payload: Parameters<Events[K]>[0];\n };\n } {\n const { source, events } = config;\n const result = {} as any;\n for (const key in events) {\n const type = `${source.toUpperCase()}_${toScreamingSnakeCase(key)}`;\n result[key] = ActionCreatorFactory.defineActionCreator(type, events[key]);\n }\n return result;\n }\n}\n","import { Injectable } from '@angular/core';\nimport { SingleAction } from '../../interfaces/action-type';\nimport { ActionCreatorFactory } from '../factories/action.factory';\n\n@Injectable({ providedIn: 'root' })\nexport class SingleActionHandler {\n\n public static handle<Source extends string, ActionPayload>(\n source: Source,\n payload: SingleAction<ActionPayload>\n ): {\n action: ActionPayload extends undefined\n ? () => { type: `${Source}_ACTION` }\n : (payload: ActionPayload) => {\n type: `${Source}_ACTION`;\n payload: ActionPayload;\n };\n } {\n return {\n action: ActionCreatorFactory.defineActionCreator(\n `${source}_ACTION`,\n payload\n ),\n } as any;\n }\n}\n","import { SingleAction } from '../interfaces/action-type';\nimport { ActionGroupHandler } from './handlers/action-group.handler';\nimport { SingleActionHandler } from './handlers/single-action.handler';\n\n\nexport class ActionService {\n\n public static defineActionsGroup<\n Source extends string,\n Events extends Record<string, SingleAction<any>>\n >(config: { source: Source; events: Events }) {\n return ActionGroupHandler.handle(config);\n }\n\n public static defineSingleAction<Source extends string, ActionPayload>(\n source: Source,\n payload: SingleAction<ActionPayload>\n ) {\n return SingleActionHandler.handle(source, payload);\n }\n}\n\n/**\n * Defines a group of related actions with a common source\n *\n * This function provides a convenient way to define action groups without\n * directly injecting the ActionService\n *\n * @param config - Object containing source prefix and events map\n * @returns An object with action creators for each event\n */\nexport function defineActionsGroup<\n Source extends string,\n Events extends Record<string, SingleAction<any>>\n>(config: { source: Source; events: Events }) {\n return ActionService.defineActionsGroup(config);\n}\n\n/**\n * Defines a single action with a source prefix\n *\n * This function provides a convenient way to define a single action without\n * directly injecting the ActionService\n *\n * @param source - Source prefix for the action type\n * @param payload - Payload handler function\n * @returns An object with an action creator\n */\nexport function defineSingleAction<Source extends string, ActionPayload>(\n source: Source,\n payload: SingleAction<ActionPayload>\n) {\n return ActionService.defineSingleAction(source, payload);\n}\n","import { Injectable } from '@angular/core';\n\n@Injectable({ providedIn: 'root' })\nexport class EffectRelationRegistery {\n private readonly actionRelations: Map<string, Set<string>> = new Map();\n\n public register(parent: string, child: string): void {\n if (!this.actionRelations.has(parent)) {\n this.actionRelations.set(parent, new Set());\n }\n this.actionRelations.get(parent)?.add(child);\n }\n\n public getAllRelated(\n action: string,\n visited = new Set<string>()\n ): Set<string> {\n if (visited.has(action)) return visited;\n visited.add(action);\n\n const children = this.actionRelations.get(action) || new Set();\n for (const child of children) {\n this.getAllRelated(child, visited);\n }\n return visited;\n }\n}\n","import { inject, Injectable } from '@angular/core';\nimport { EffectRelationRegistery } from './effect-relation.registery';\n\n@Injectable({ providedIn: 'root' })\nexport class PendingEffectRegistry {\n private readonly pending: Map<string, Promise<void>[]> = new Map();\n private readonly effectRelationRegistery = inject(EffectRelationRegistery);\n\n public register(actionType: string, promise: Promise<void>): Promise<void> {\n const list = this.pending.get(actionType) || [];\n this.pending.set(actionType, [...list, promise]);\n\n promise.finally(() => {\n const current = this.pending.get(actionType) || [];\n this.pending.set(\n actionType,\n current.filter((p) => p !== promise)\n );\n });\n\n return promise;\n }\n\n public get(actionType: string): Promise<void>[] {\n return this.pending.get(actionType) || [];\n }\n\n public async waitFor(actionType: string): Promise<void> {\n const allRelatedTypes =\n this.effectRelationRegistery.getAllRelated(actionType);\n const allPromisesToWait: Promise<void>[] = [];\n for (const type of allRelatedTypes) {\n const promises = this.pending.get(type) || [];\n allPromisesToWait.push(...promises);\n }\n await Promise.all(allPromisesToWait);\n }\n\n public async waitForAll(): Promise<void> {\n const all = Array.from(this.pending.values()).flat();\n await Promise.all(all);\n }\n}\n","import { Injectable } from '@angular/core';\nimport { isObservable, firstValueFrom } from 'rxjs';\nimport { Action } from '../../../action/interfaces/action-type';\nimport { SWEffects } from '../../interfaces/SWEffects.types';\n\n@Injectable({ providedIn: 'root' })\nexport class EffectResultResolver {\n public async resolve(result: SWEffects): Promise<(Action | void)[]> {\n if (result === undefined || result === null) {\n return [undefined];\n }\n\n if (result instanceof Promise) {\n const awaited = await result;\n\n if (isObservable(awaited)) {\n const resolvedObs = await firstValueFrom(awaited);\n return Array.isArray(resolvedObs) ? resolvedObs : [resolvedObs];\n }\n\n return Array.isArray(awaited) ? awaited.flat() : [awaited];\n }\n\n if (isObservable(result)) {\n const resolved = await firstValueFrom(result);\n return Array.isArray(resolved) ? resolved : [resolved];\n }\n\n if (Array.isArray(result)) {\n return result;\n }\n\n return [result];\n }\n}\n","import { Injectable } from '@angular/core';\nimport { IUpdator } from '../updator/interfaces/updator.interfaces';\n\n@Injectable({ providedIn: 'root' })\nexport class GlobalUpdatorsRegistry {\n private readonly _updatorRegistry: Map<string, IUpdator<any>> = new Map();\n\n private constructor() {}\n\n public registerUpdator<S>(actionType: string, updator: IUpdator<S>): void {\n if (this._updatorRegistry.has(actionType)) {\n return;\n }\n this._updatorRegistry.set(actionType, updator);\n }\n\n public registerFullUpdator<S>(updator: IUpdator<S>): void {\n Object.keys(updator.updators).forEach((actionType) => {\n this.registerUpdator(actionType, updator);\n });\n }\n\n public getUpdator<S>(actionType: string): IUpdator<S> | undefined {\n return this._updatorRegistry.get(actionType);\n }\n\n public getRegisteredActionTypes(): string[] {\n return Array.from(this._updatorRegistry.keys());\n }\n\n public hasUpdator(actionType: string): boolean {\n return this._updatorRegistry.has(actionType);\n }\n\n public unregisterUpdator(actionType: string): boolean {\n return this._updatorRegistry.delete(actionType);\n }\n\n public clearUpdators(): void {\n this._updatorRegistry.clear();\n }\n}\n","import { Injectable } from '@angular/core';\n\n@Injectable({ providedIn: 'root' })\nexport class ActionContextRegistery{\n private readonly contextMap = new Map<string, object>();\n\n public set(actionType: string, context: object): void {\n this.contextMap.set(actionType, context);\n }\n\n public get(actionType: string): object | undefined {\n return this.contextMap.get(actionType);\n }\n\n public clear(actionType: string): void {\n this.contextMap.delete(actionType);\n }\n}\n","import { Injectable } from \"@angular/core\";\nimport { IUpdator } from \"../updator\";\n\n\n@Injectable({ providedIn: 'root' })\nexport class LocalUpdatorRegistry {\n private readonly localRegistries = new WeakMap<object, Set<IUpdator<any>>>();\n\n public register<S>(manager: object, updator: IUpdator<S>): void {\n if (!this.localRegistries.has(manager)) {\n this.localRegistries.set(manager, new Set());\n }\n\n const localRegistry = this.localRegistries.get(manager)!;\n localRegistry.add(updator);\n }\n\n public get<S>(manager: object, actionType: string): IUpdator<S> | undefined {\n const localRegistry = this.localRegistries.get(manager);\n if (!localRegistry) return undefined;\n\n for (const updator of localRegistry) {\n if (updator.updators[actionType]) {\n return updator as IUpdator<S>;\n }\n }\n\n return undefined;\n }\n}\n","import { Action } from '../../action/interfaces/action-type';\nimport { UpdatorGlobalRegistry } from '../interfaces/updator.interfaces';\n\n/**\n * Updates the given state based on the action and the corresponding `updator`.\n *\n * This function looks up the `Updator` function associated with the action type\n * from the provided `updators` registry and applies it to update the state.\n * If no handler is found for the action type, a warning is logged.\n *\n * @template S - The type of the state to be updated.\n * @param state - The current state to be updated.\n * @param action - The action that triggered the state update.\n * @param updators - A registry of action types to their respective `Updator` functions.\n */\nexport function update<S>(\n state: S,\n action: Action,\n updators: UpdatorGlobalRegistry<S>\n): void {\n const handler = updators[action.type];\n\n if (handler) {\n handler(state, action.payload);\n } else {\n console.warn(`No handler for action type: ${action.type}`);\n }\n}\n","import { Injectable } from \"@angular/core\";\nimport { Action } from \"../action/interfaces/action-type\";\n\n@Injectable({ providedIn: 'root' })\nexport class ActionEffectRegistry {\n private readonly _effects = new Map<string, ((action: Action) => void)[]>();\n\n public register(actionType: string, effect: (action: Action) => void): void {\n const list = this._effects.get(actionType) || [];\n this._effects.set(actionType, [...list, effect]);\n }\n\n public get(actionType: string): ((action: Action) => void)[] {\n return this._effects.get(actionType) || [];\n }\n\n public has(actionType: string): boolean {\n return !!this._effects.get(actionType)?.length;\n }\n}\n","import { Injectable, signal, Signal } from '@angular/core';\nimport { Action } from '../interfaces/action-type';\n\n@Injectable({ providedIn: 'root' })\nexport class ActionHistoryService {\n private readonly _latest = signal<Action | null>(null);\n private readonly _history = signal<Action[]>([]);\n\n public latest(): Signal<Action | null> {\n return this._latest.asReadonly();\n }\n\n public history(): Signal<Action[]> {\n return this._history.asReadonly();\n }\n\n public record(action: Action): void {\n this._latest.set(action);\n this._history.update((list) => [...list, action]);\n }\n}\n","import { inject, Injectable } from '@angular/core';\nimport { ActionEffectRegistry } from '../../../registries/global-effect.registery';\nimport { Action } from '../../interfaces/action-type';\n\n@Injectable({ providedIn: 'root' })\nexport class ActionEffectHandlerr {\n private readonly registry = inject(ActionEffectRegistry);\n\n public handle(action: Action): void {\n const effects = this.registry.get(action.type);\n for (const effect of effects) {\n effect(action);\n }\n }\n}\n","import { Injectable, inject } from '@angular/core';\nimport { ActionEffectRegistry } from '../../registries/global-effect.registery';\nimport { PendingEffectRegistry } from '../../registries/pending-effect.registery';\nimport { Action } from '../interfaces/action-type';\nimport { ActionHistoryService } from './action-history.service';\nimport { ActionEffectHandlerr } from './handlers/action-effect.handler';\n\n@Injectable({ providedIn: 'root' })\nexport class ActionDispatcherService {\n private readonly actionHistory = inject(ActionHistoryService);\n private readonly actionEffectHandler = inject(ActionEffectHandlerr);\n private readonly globalEffectRegistery = inject(ActionEffectRegistry);\n private readonly pendingEffectRegistry = inject(PendingEffectRegistry);\n\n public emit(action: Action): void {\n if (!this.globalEffectRegistery.has(action.type)) {\n this.pendingEffectRegistry.register(action.type, Promise.resolve());\n }\n\n this.actionHistory.record(action);\n this.actionEffectHandler.handle(action);\n }\n}\n","import { IUpdator } from '../../updator/interfaces/updator.interfaces';\nimport { Action } from '../../action/interfaces/action-type';\nimport { update } from '../../updator/utils/updator.utils';\nimport { inject, Injectable } from '@angular/core';\nimport { PendingEffectRegistry } from '../../registries/pending-effect.registery';\nimport { ActionDispatcherService } from '../../action/services/action-dispatcher.service';\n\n@Injectable({ providedIn: 'root' })\nexport class CoordinatorService {\n private readonly pendingEffectRegistry = inject(PendingEffectRegistry);\n private readonly actionDispatcher = inject(ActionDispatcherService);\n\n public dispatch<S>(action: Action, updator: IUpdator<S>): void {\n update(updator.state, action, updator.updators);\n this.actionDispatcher.emit(action);\n }\n\n public dispatchAsync<S>(action: Action, updator: IUpdator<S>): Promise<void> {\n this.dispatch<S>(action, updator);\n return this.pendingEffectRegistry.waitFor(action.type);\n }\n}\n","import { inject, Injectable } from '@angular/core';\nimport { ActionContextRegistery } from '../../../registries/action-context.registery';\nimport { GlobalUpdatorsRegistry } from '../../../registries/global-updators.registery';\nimport { LocalUpdatorRegistry } from '../../../registries/local-updators.registery';\nimport { IUpdator } from '../../../updator';\n\n@Injectable({ providedIn: 'root' })\nexport class UpdatorResolver {\n private readonly globalUpdatorsRegistry = inject(GlobalUpdatorsRegistry);\n private readonly localUpdatorsRegistry = inject(LocalUpdatorRegistry);\n private readonly actionContext = inject(ActionContextRegistery);\n\n resolveUpdator<S>(\n actionType: string,\n contextOrUpdator?: object | IUpdator<S>\n ): IUpdator<S> | undefined {\n this.setContext(actionType, contextOrUpdator);\n\n const explicit = this.asUpdator(contextOrUpdator);\n if (explicit) {\n this.localUpdatorsRegistry.register(explicit, explicit);\n return explicit;\n }\n\n const local = this.asLocal(contextOrUpdator, actionType);\n if (local) {\n return local;\n }\n\n return this.globalUpdatorsRegistry.getUpdator<S>(actionType);\n }\n\n private setContext(type: string, context?: object | IUpdator<any>) {\n if (context) this.actionContext.set(type, context);\n }\n\n private asUpdator<S>(updator?: object | IUpdator<S>): IUpdator<S> | null {\n return updator && 'state' in updator && 'updators' in updator\n ? updator\n : null;\n }\n\n private asLocal<S>(\n context: object | IUpdator<S> | undefined,\n type: string\n ): IUpdator<S> | null {\n return context && !this.asUpdator(context)\n ? this.localUpdatorsRegistry.get(context as object, type) ?? null\n : null;\n }\n}\n","import { inject, Injectable } from '@angular/core';\n\nimport { CoordinatorService } from '../coordinator.service';\nimport { UpdatorResolver } from '../resolvers/updator.resolver';\nimport { IUpdator } from '../../../updator';\nimport { Action } from '../../../action/interfaces/action-type';\nimport { ActionDispatcherService } from '../../../action/services/action-dispatcher.service';\n\n@Injectable({ providedIn: 'root' })\nexport class DispatchHandler {\n private readonly coordinator = inject(CoordinatorService);\n private readonly actionDispatcher = inject(ActionDispatcherService);\n private readonly updatorResolver = inject(UpdatorResolver);\n\n public handle<T extends Action, S>(\n action: T,\n contextOrUpdator?: object | IUpdator<S>\n ): void {\n const updator = this.updatorResolver.resolveUpdator(\n action.type,\n contextOrUpdator\n );\n if (updator) {\n this.coordinator.dispatch(action, updator);\n } else {\n this.actionDispatcher.emit(action);\n }\n }\n}\n","import { Injectable, inject } from '@angular/core';\n\nimport { Action } from '../../../action/interfaces/action-type';\nimport { GlobalUpdatorsRegistry } from '../../../registries/global-updators.registery';\nimport { ActionContextRegistery } from '../../../registries/action-context.registery';\nimport { EffectRelationRegistery } from '../../../registries/effect-relation.registery';\nimport { PendingEffectRegistry } from '../../../registries/pending-effect.registery';\nimport { LocalUpdatorRegistry } from '../../../registries/local-updators.registery';\nimport { DispatchHandler } from '../../../manager/services/handlers/dispatch.handler';\nimport { ActionDispatcherService } from '../../../action/services/action-dispatcher.service';\n\n@Injectable({ providedIn: 'root' })\nexport class EffectResultHandler {\n private readonly actionDispatcher = inject(ActionDispatcherService);\n private readonly pendingEffectRegistry = inject(PendingEffectRegistry);\n private readonly actionContextRegistry = inject(ActionContextRegistery);\n private readonly effectRelationRegistry = inject(EffectRelationRegistery);\n private readonly globalUpdatorsRegistry = inject(GlobalUpdatorsRegistry);\n private readonly localUpdatorRegistry = inject(LocalUpdatorRegistry);\n private readonly dispatch = inject(DispatchHandler);\n\n public async handle(\n results: (Action | void)[],\n parentActionType: string\n ): Promise<Promise<void>[]> {\n const subActionPromises: Promise<void>[] = [];\n const context = this.actionContextRegistry.get(parentActionType);\n\n for (const result of results.flat().filter((a): a is Action => !!a)) {\n this.effectRelationRegistry.register(parentActionType, result.type);\n\n let used = this.tryUseLocalUpdator(result, context);\n\n if (!used) {\n used = this.tryUseGlobalUpdator(result);\n }\n\n if (!used) {\n this.actionDispatcher.emit(result);\n }\n\n this.collectPendingPromises(result, subActionPromises);\n }\n\n this.actionContextRegistry.clear(parentActionType);\n return subActionPromises;\n }\n\n private tryUseLocalUpdator(action: Action, context?: object): boolean {\n if (!context) return false;\n\n const local = this.localUpdatorRegistry.get(context, action.type);\n if (local) {\n this.dispatch.handle(action, context);\n return true;\n }\n\n return false;\n }\n\n private tryUseGlobalUpdator(action: Action): boolean {\n const globalUpdator = this.globalUpdatorsRegistry.getUpdator(action.type);\n if (globalUpdator) {\n this.dispatch.handle(action, globalUpdator);\n return true;\n }\n\n return false;\n }\n\n private collectPendingPromises(\n action: Action,\n subActionPromises: Promise<void>[]\n ): void {\n const pending = this.pendingEffectRegistry.get(action.type);\n if (pending.length) {\n subActionPromises.push(pending[0]);\n }\n }\n}\n","import { Injectable, inject } from '@angular/core';\nimport { Observable } from 'rxjs';\nimport { Action } from '../../action/interfaces/action-type';\nimport { SWEffects } from '../interfaces/SWEffects.types';\nimport { EffectResultResolver } from './resolvers/effect-result.resolver';\nimport { EffectResultHandler } from './handlers/effect-result.handler';\n\n@Injectable({ providedIn: 'root' })\nexport class EffectPromiseService {\n private readonly effectResultResolver = inject(EffectResultResolver);\n private readonly effectResultHandler = inject(EffectResultHandler);\n\n public createPromise(\n handler: (payload?: any) => SWEffects | Observable<any>,\n action: Action,\n actionType: string\n ): Promise<void> {\n return (async () => {\n try {\n const rawResult = handler(action.payload);\n const results = await this.effectResultResolver.resolve(rawResult);\n const subActionPromises = await this.effectResultHandler.handle(\n results,\n actionType\n );\n\n if (subActionPromises.length > 0) {\n await Promise.all(subActionPromises);\n }\n } catch (error) {\n console.error(`Effect for ${actionType} failed:`, error);\n }\n })();\n }\n}\n\n","import { Injectable, inject } from '@angular/core';\nimport { Action } from '../../action/interfaces/action-type';\nimport { PendingEffectRegistry } from '../../registries/pending-effect.registery';\nimport { SWEffects } from '../interfaces/SWEffects.types';\nimport { ofType } from '../../action';\nimport { EffectPromiseService } from './effect-promise.service';\nimport { ActionEffectRegistry } from '../../registries/global-effect.registery';\n\n@Injectable({ providedIn: 'root' })\nexport class EffectRegistrationService {\n private readonly globalEffectRegistry = inject(ActionEffectRegistry);\n private readonly pendingEffectRegistry = inject(PendingEffectRegistry);\n private readonly effectPromiseService = inject(EffectPromiseService);\n\n public registerEffect<T extends (...args: any[]) => Action>(\n actionCreator: T,\n handler: (payload?: any) => SWEffects\n ): void {\n const actionType = ofType(actionCreator);\n\n this.globalEffectRegistry.register(actionType, async (action: Action) => {\n const effectPromise = this.effectPromiseService.createPromise(\n handler,\n action,\n actionType\n );\n this.pendingEffectRegistry.register(actionType, effectPromise);\n return effectPromise;\n });\n }\n}\n","import { EnvironmentInjector } from '@angular/core';\n\nlet rootInjector: EnvironmentInjector | null = null;\n\nexport function setRootInjector(injector: EnvironmentInjector): void {\n rootInjector = injector;\n}\n\nexport function getRootInjector(): EnvironmentInjector {\n if (!rootInjector) {\n throw new Error(\n '[StateManager] EnvironmentInjector not initialized. Ensure that provideStateManager() is included in the providers of bootstrapApplication.'\n );\n }\n return rootInjector;\n}\n","import { runInInjectionContext } from \"@angular/core\";\nimport { getRootInjector } from \"./root-injector\";\n\nexport async function withInjectionContext<T>(\n fn: () => Promise<T> | T\n): Promise<T> {\n return runInInjectionContext(getRootInjector(), fn);\n}\n","import { inject } from '@angular/core';\nimport { Action } from '../../action/interfaces/action-type';\nimport { EffectRegistrationService } from '../services/effect-registration.service';\nimport { SWEffects } from '../interfaces/SWEffects.types';\nimport { withInjectionContext } from '../../injector/injection-utils';\n\n/**\n * Registers an effect that listens to a specific action and executes a handler.\n *\n * @param action - The action creator function.\n * @param handler - A function called when the action is dispatched.\n * - Receives the payload if the action defines one.\n * - Can return an action, array of actions, observable, or promise.\n */\nexport function createEffect<T extends (payload: any) => Action>(\n action: T,\n handler: (payload: Parameters<T>[0]) => SWEffects\n): void;\n/**\n * Registers an effect for an action without payload.\n *\n * @param action - Action creator with no payload.\n * @param handler - Function executed when the action is dispatched.\n */\nexport function createEffect(\n action: () => Action,\n handler: () => SWEffects\n): void;\n/**\n * Internal implementation of createEffect, handling both payload and no-payload cases.\n */\nexport function createEffect(\n action: (...args: any[]) => Action,\n handler: (payload?: any) => SWEffects\n): void {\n withInjectionContext(() => {\n const effectRegistrationService = inject(EffectRegistrationService);\n effectRegistrationService.registerEffect(action, handler);\n });\n}\n","import { inject } from '@angular/core';\nimport { withInjectionContext } from '../../injector/injection-utils';\nimport { PendingEffectRegistry } from '../../registries/pending-effect.registery';\n\n/**\n * Waits for all currently pending effects to resolve.\n *\n * This function ensures that all side effects triggered by actions are completed\n * before continuing with the execution flow.\n *\n * @returns A promise that resolves when all pending effects are completed.\n */\nexport function waitForAllEffects(): Promise<void> {\n return withInjectionContext(() => {\n const pendingEffect = inject(PendingEffectRegistry);\n return pendingEffect.waitForAll();\n });\n}\n\n/**\n * Waits for pending effects associated with a specific action type to resolve.\n *\n * Useful for scenarios where you need to wait for effects triggered by a particular\n * action before proceeding.\n *\n * @param actionType - The action type whose effects should be waited for.\n * @returns A promise that resolves when all pending effects for the specified action type are completed.\n */\nexport function waitForEffect(actionType: string): Promise<void> {\n return withInjectionContext(() => {\n const pendingEffect = inject(PendingEffectRegistry);\n return pendingEffect.waitFor(actionType);\n });\n}\n","import { inject, Injectable } from '@angular/core';\nimport { withInjectionContext } from '../../injector/injection-utils';\nimport { Action } from '../../action/interfaces/action-type';\nimport { IUpdator } from '../../updator';\nimport { DispatchHandler } from './handlers/dispatch.handler';\n\n@Injectable({ providedIn: 'root' })\nexport class DispatchService {\n private readonly dispatchHandler = inject(DispatchHandler);\n\n public dispatch<T extends Action, S>(\n action: T,\n contextOrUpdator?: object | IUpdator<S>\n ): void {\n this.dispatchHandler.handle(action, contextOrUpdator);\n }\n}\n\n/**\n * Dispatches an action with optional updator registration.\n *\n * This function provides a flexible way to dispatch actions:\n * - If only an action is provided, it will be dispatched through the ActionDispatcher\n * - If an updator is also provided, it will be registered (if needed) and used to update state\n *\n * @template T - The action type.\n * @template S - The state type (inferred from updator if provided).\n * @param action - The action to dispatch.\n * @param updator - Optional updator to handle state updates for this action.\n */\nexport function dispatch<T extends Action>(action: T, context?: object): void;\nexport function dispatch<T extends Action, S>(\n action: T,\n updator: IUpdator<S>\n): void;\nexport function dispatch<T extends Action, S>(\n action: T,\n contextOrUpdator?: object | IUpdator<S>\n): void {\n withInjectionContext(() => {\n const dispatchService = inject(DispatchService);\n dispatchService.dispatch(action, contextOrUpdator);\n });\n}\n","import { inject, Injectable } from '@angular/core';\n\nimport { ActionContextRegistery } from '../../../registries/action-context.registery';\nimport { PendingEffectRegistry } from '../../../registries/pending-effect.registery';\nimport { CoordinatorService } from '../coordinator.service';\nimport { UpdatorResolver } from '../resolvers/updator.resolver';\nimport { Action } from '../../../action/interfaces/action-type';\nimport { IUpdator } from '../../../updator';\nimport { ActionDispatcherService } from '../../../action/services/action-dispatcher.service';\n\n@Injectable({ providedIn: 'root' })\nexport class DispatchAsyncHandler {\n private readonly coordinator = inject(CoordinatorService);\n private readonly actionDispatcher = inject(ActionDispatcherService);\n private readonly pendingEffect = inject(PendingEffectRegistry);\n private readonly actionContext = inject(ActionContextRegistery);\n private readonly updatorResolver = inject(UpdatorResolver);\n\n public handle<T extends Action, S>(\n action: T,\n contextOrUpdator?: object | IUpdator<S>\n ): Promise<void> {\n const updator = this.updatorResolver.resolveUpdator(\n action.type,\n contextOrUpdator\n );\n\n if (updator) {\n return this.execWithCleanup(\n this.coordinator.dispatchAsync(action, updator),\n action.type\n );\n }\n\n this.actionDispatcher.emit(action);\n return this.execWithCleanup(\n this.pendingEffect.waitFor(action.type),\n action.type\n );\n }\n\n private async execWithCleanup(\n promise: Promise<void>,\n type: string\n ): Promise<void> {\n try {\n return await promise;\n } finally {\n this.actionContext.clear(type);\n }\n }\n}\n","import { inject, Injectable } from '@angular/core';\nimport { withInjectionContext } from '../../injector/injection-utils';\nimport { Action } from '../../action/interfaces/action-type';\nimport { IUpdator } from '../../updator';\nimport { DispatchAsyncHandler } from './handlers/dispatchAsync.handler';\n\n@Injectable({ providedIn: 'root' })\nexport class DispatchAsyncService {\n private readonly dispatchAsynHandler = inject(DispatchAsyncHandler);\n\n public dispatchAsync<T extends Action, S>(\n action: T,\n contextOrUpdator?: object | IUpdator<S>\n ): Promise<void> {\n return this.dispatchAsynHandler.handle(action, contextOrUpdator);\n }\n}\n\n/**\n * Asynchronously dispatches an action and waits for effects to complete.\n *\n * Similar to `dispatch`, but returns a Promise that resolves when all associated\n * effects are completed. Supports both global and local updators.\n *\n * @template T - The action type.\n * @template S - The state type (inferred from updator if provided).\n * @param action - The action to dispatch.\n * @param updator - Optional updator to handle state updates for this action.\n * @returns A Promise that resolves when all effects for this action are completed.\n */\nexport async function dispatchAsync<T extends Action>(\n action: T,\n context?: object\n): Promise<void>;\nexport async function dispatchAsync<T extends Action, S>(\n action: T,\n updator: IUpdator<S>\n): Promise<void>;\nexport function dispatchAsync<T extends Action, S>(\n action: T,\n contextOrUpdator?: object | IUpdator<S>\n): Promise<void> {\n return withInjectionContext(() => {\n const dispatchAsyncService = inject(DispatchAsyncService);\n return dispatchAsyncService.dispatchAsync(action, contextOrUpdator);\n });\n}\n","import { Injectable, inject } from '@angular/core';\nimport { withInjectionContext } from '../../injector/injection-utils';\nimport { LocalUpdatorRegistry } from '../../registries/local-updators.registery';\nimport { IUpdator } from '../interfaces/updator.interfaces';\n\n@Injectable({ providedIn: 'root' })\nexport class UpdatorRegistrationService {\n private readonly localRegistry = inject(LocalUpdatorRegistry);\n\n public registerLocalUpdator<S>(manager: object, updator: IUpdator<S>): void {\n this.localRegistry.register(manager, updator);\n }\n}\n\n/**\n * Registers a local updater for a given manager context.\n *\n * This function should be used within an Angular injection context (e.g. during component initialization).\n *\n * @template S - The state type handled by the updater.\n * @param {object} manager - The local context object (e.g., a component or a service) to associate the updater with.\n * @param {IUpdator<S>} updator - The updater instance defining actions and their update logic for the given state.\n */\nexport function registerLocalUpdator<S>(manager: object, updator: IUpdator<S>) {\n withInjectionContext(() => {\n const updatorRegistrationService = inject(UpdatorRegistrationService);\n updatorRegistrationService.registerLocalUpdator(manager, updator);\n });\n}\n","import {\n EnvironmentInjector,\n inject,\n provideEnvironmentInitializer,\n} from '@angular/core';\nimport { setRootInjector } from '../injector/root-injector';\n\nexport function provideStatewise() {\n return provideEnvironmentInitializer(() => {\n const injector = inject(EnvironmentInjector);\n setRootInjector(injector);\n });\n}\n","import {\n EnvironmentProviders,\n inject,\n makeEnvironmentProviders,\n provideEnvironmentInitializer,\n Type,\n} from '@angular/core';\n\n/**\n * Registers and instantiates a list of effect classes at application startup.\n *\n * @param effectClasses - Array of effect class types to initialize.\n * @returns EnvironmentProviders to include in your application bootstrap.\n */\nexport function provideEffects(\n effectClasses: Type<any>[]\n): EnvironmentProviders {\n return makeEnvironmentProviders([\n ...effectClasses.map((effectClass) => ({\n provide: effectClass,\n useClass: effectClass,\n })),\n provideEnvironmentInitializer(() => {\n effectClasses.forEach((effectClass) => inject(effectClass));\n }),\n ]);\n}\n","import {\n EnvironmentProviders,\n inject,\n makeEnvironmentProviders,\n provideAppInitializer,\n Type,\n} from '@angular/core';\nimport { IUpdator } from '../updator/interfaces/updator.interfaces';\nimport { GlobalUpdatorsRegistry } from '../registries/global-updators.registery';\n\n/**\n * Registers an array of updators globally at application startup.\n *\n * This function provides a way to register state updators during the Angular\n * application initialization phase, making them available throughout the application\n * without needing to register them with each dispatch call.\n *\n * @param updators - An array of Updator class to be registered globally.\n * @returns Angular EnvironmentProviders to be included in your application bootstrap.\n *\n */\nexport function provideUpdators(\n updatorClasses: Type<IUpdator<any>>[]\n): EnvironmentProviders {\n return makeEnvironmentProviders([\n ...updatorClasses, // ensure classes are registered as providers\n provideAppInitializer(() => {\n const registry = inject(GlobalUpdatorsRegistry);\n updatorClasses.forEach((cls) => {\n const instance = inject(cls);\n registry.registerFullUpdator(instance);\n });\n }),\n ]);\n}\n","/*\n * Public API Surface of ngx-statewise\n */\n\nexport * from './lib/index';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;AAMA;;;;AAIG;MACU,YAAY,GAAmB,MAAM;AAElD;;;;;;;AAOG;SACa,OAAO,GAAA;AACrB,IAAA,OAAO,CAAC,CAAI,KAAK,CAAC;AACpB;AAEA;;;;;;;;;AASG;AACG,SAAU,oBAAoB,CAAC,GAAW,EAAA;IAC9C,OAAO,GAAG,CAAC,OAAO,CAAC,iBAAiB,EAAE,OAAO,CAAC,CAAC,WAAW,EAAE;AAC9D;AAcM,SAAU,MAAM,CAAC,MAAW,EAAA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