signalstory
Version:
Signal-based state management for Angular that grows with your project. Explore a versatile toolbox with enriching plugins for developers at all levels.
1 lines • 137 kB
Source Map (JSON)
{"version":3,"file":"signalstory.mjs","sources":["../../../packages/signalstory/src/lib/store-immutability/immutable-utility.ts","../../../packages/signalstory/src/lib/store-mediator.ts","../../../packages/signalstory/src/lib/store-registry.ts","../../../packages/signalstory/src/lib/utility/injector-helper.ts","../../../packages/signalstory/src/lib/utility/sideeffect.ts","../../../packages/signalstory/src/lib/store.ts","../../../packages/signalstory/src/lib/store-effect.ts","../../../packages/signalstory/src/lib/store-event.ts","../../../packages/signalstory/src/lib/store-immutability/immutable-store.ts","../../../packages/signalstory/src/lib/utility/memoize.ts","../../../packages/signalstory/src/lib/utility/feature-detection.ts","../../../packages/signalstory/src/lib/store-history.ts","../../../packages/signalstory/src/lib/store-plugin-deep-freeze/deep-freeze.ts","../../../packages/signalstory/src/lib/store-plugin-deep-freeze/plugin-deep-freeze.ts","../../../packages/signalstory/src/lib/store-plugin-devtools/plugin-devtools.ts","../../../packages/signalstory/src/lib/store-plugin-logger/plugin-logger.ts","../../../packages/signalstory/src/lib/store-plugin-performance-counter/performance-counter.ts","../../../packages/signalstory/src/lib/store-plugin-performance-counter/plugin-performance-counter.ts","../../../packages/signalstory/src/lib/store-plugin-persistence/idb/idb-migration.ts","../../../packages/signalstory/src/lib/store-plugin-persistence/idb/idb-pool.ts","../../../packages/signalstory/src/lib/store-plugin-persistence/idb/idb-adapter.ts","../../../packages/signalstory/src/lib/store-plugin-persistence/persistence-async-storage.ts","../../../packages/signalstory/src/lib/store-plugin-persistence/persistence-sync-storage.ts","../../../packages/signalstory/src/lib/store-plugin-persistence/plugin-persistence.ts","../../../packages/signalstory/src/lib/store-plugin-status/plugin-status.ts","../../../packages/signalstory/src/lib/store-query.ts","../../../packages/signalstory/src/lib/store-snapshot.ts","../../../packages/signalstory/src/public-api.ts","../../../packages/signalstory/src/signalstory.ts"],"sourcesContent":["/**\n * Naively creates a deep clone of a given state object using JSON.parse and JSON.stringify.\n * This approach is simple but not optimal for performance.\n *\n * @template TState - The type of the state object.\n * @param state - The state object to be cloned.\n * @returns A deep clone of the provided state object.\n */\nexport function naiveDeepClone<TState>(state: TState): TState {\n return JSON.parse(JSON.stringify(state)) as TState;\n}\n\n/**\n * Creates a deep clone of a given value object using either the `structuredClone` method if available,\n * or a naive approach using JSON.parse and JSON.stringify if `structuredClone` is not supported.\n * The naive approach is simple but may have shortcomings and is not optimal for performance.\n *\n * @template T - The type of the value object.\n * @param {T} value - The value object to be cloned.\n * @returns {T} A deep clone of the provided value object.\n */\nexport function deepClone<TState>(state: TState): TState {\n return window && 'structuredClone' in window\n ? structuredClone(state)\n : naiveDeepClone(state);\n}\n\n/**\n * Creates a shallow clone of a given value object\n * @param state - The state to be cloned.\n * @returns Shallow cloned state.\n */\nexport function shallowClone<TState>(state: TState): TState {\n if (!state || typeof state !== 'object') {\n return state;\n }\n\n if (Array.isArray(state)) return [...state] as TState;\n if (state instanceof Date) return new Date(state) as TState;\n if (state instanceof RegExp) return new RegExp(state) as TState;\n if (state instanceof Set) return new Set(state) as TState;\n if (state instanceof Map) return new Map(state) as TState;\n\n return Object.assign({}, state) as TState;\n}\n\n/**\n * Naive implementation of an immutable update function using a clone-and-mutate approach.\n * This function serves as a placeholder that you can swap with a more optimized\n * solution like the one provided by the 'immer.js' library (https://immerjs.github.io/immer/).\n * Using 'immer.js' will result in more efficient and concise code for managing\n * immutable updates to your state.\n *\n * @template TState - The type of the state object.\n * @param currentState - The current state object to be updated.\n * @param mutation - A function that modifies a draft copy of the state.\n * @returns The new state object after applying the mutation.\n */\nexport function naiveCloneAndMutateFunc<TState>(\n currentState: TState,\n mutation: (draftState: TState) => void\n): TState {\n const clone = deepClone(currentState) as TState;\n mutation(clone);\n return clone;\n}\n","/* eslint-disable @typescript-eslint/no-explicit-any */\nimport { Store } from './store';\nimport { StoreEvent } from './store-event';\n\ntype EventHandler<TStore extends Store<unknown>, TPayload> = {\n store: WeakRef<TStore>;\n handler: (store: TStore, event: StoreEvent<TPayload>) => void;\n};\n\ntype MediatorRegistry = WeakMap<\n StoreEvent<unknown>,\n Set<EventHandler<Store<unknown>, unknown>>\n>;\n\n/**\n * Creates an empty Mediator registry.\n */\nexport function createRegistry(): MediatorRegistry {\n return new WeakMap<\n StoreEvent<unknown>,\n Set<EventHandler<Store<unknown>, unknown>>\n >();\n}\n\n/**\n * Root mediator registry instance.\n */\nexport const rootRegistry: MediatorRegistry = /*@__PURE__*/ createRegistry();\n\n/**\n * Register an event handler for a specific event.\n *\n * @param {MediatorRegistry} registry - The mediator registry to register the handler in.\n * @param {TStore} store - The store instance associated with the event handler.\n * @param {StoreEvent<TPayload>} event - The event to register.\n * @param {(store: TStore, event: StoreEvent<TPayload>) => void} handler - The handler function to be executed when the event occurs.\n * @throws {Error} if the event name is invalid.\n */\nexport function register<TStore extends Store<any>, TPayload>(\n registry: MediatorRegistry,\n store: TStore,\n event: StoreEvent<TPayload>,\n handler: (store: TStore, event: StoreEvent<TPayload>) => void\n) {\n const existingHandlers =\n registry.get(event) || new Set<EventHandler<Store<unknown>, unknown>>();\n existingHandlers.add({\n store: new WeakRef(store),\n handler,\n } as unknown as EventHandler<Store<unknown>, unknown>);\n registry.set(event, existingHandlers);\n}\n\n/**\n * Unregister event handlers for a specific store and events.\n *\n * @param {MediatorRegistry} registry - The mediator registry to unregister the handlers from.\n * @param {TStore} store - The store instance to remove event handlers from.\n * @param {...StoreEvent<any>[]} events - The events to remove handlers for.\n */\nexport function unregister<TStore extends Store<any>>(\n registry: MediatorRegistry,\n store: TStore,\n ...events: StoreEvent<unknown>[]\n) {\n for (const event of events) {\n const handlers = registry.get(event);\n if (handlers) {\n handlers.forEach(handler => {\n const handlingStore = handler.store.deref();\n if (!handlingStore || handlingStore === store) {\n handlers.delete(handler);\n }\n });\n if (handlers.size === 0) {\n registry.delete(event);\n }\n }\n }\n}\n\n/**\n * Publishes an event, executing all associated event handlers.\n *\n * @param {MediatorRegistry} registry - The mediator registry containing the event handlers.\n * @param {StoreEvent<never>} event - The event to publish.\n * @param {undefined} payload - The payload to pass to the event handlers.\n * @throws {Error} if the event name is invalid.\n * @throws {AggregateError} if there are errors in any event handler.\n */\nexport function publish(\n registry: MediatorRegistry,\n event: StoreEvent<never>,\n payload?: undefined\n): void;\nexport function publish<T>(\n registry: MediatorRegistry,\n event: StoreEvent<T>,\n payload: T\n): void;\nexport function publish<T>(\n registry: MediatorRegistry,\n event: StoreEvent<T>,\n payload?: T\n): void {\n const handlers = registry.get(event);\n\n const eventWithPayload = {\n name: event.name,\n payload: payload,\n };\n\n if (handlers) {\n const errors: Error[] = [];\n for (const handler of handlers) {\n const store = handler.store.deref();\n if (store) {\n try {\n handler.handler(store, eventWithPayload);\n } catch (error) {\n errors.push(error as Error);\n }\n } else {\n handlers.delete(handler);\n }\n }\n if (errors.length > 0) {\n throw new AggregateError(\n errors,\n `Errors in Handler for event ${eventWithPayload.name}`\n );\n }\n }\n}\n\n/**\n * Publishes a store event, executing all associated event handlers.\n *\n * @param {StoreEvent<never>} event - The event to publish.\n * @param {undefined} payload - The payload to pass to the event handlers.\n * @throws {Error} if the event name is invalid.\n * @throws {AggregateError} if there are errors in any event handler.\n */\nexport function publishStoreEvent(\n event: StoreEvent<never>,\n payload?: undefined\n): void;\nexport function publishStoreEvent<T>(event: StoreEvent<T>, payload: T): void;\nexport function publishStoreEvent<T>(event: StoreEvent<T>, payload?: T): void {\n publish(rootRegistry, event, payload);\n}\n","/* eslint-disable @typescript-eslint/no-explicit-any */\nimport { Store } from './store';\n\n/**\n * Store registry of stores currently in scope\n */\nexport const storeRegistry = new Set<WeakRef<Store<unknown>>>();\n\n/**\n * Iterates over each store in the registry and executes the specified callback function.\n *\n * @param callbackFn - The callback function to be executed for each store in the registry.\n */\nexport function forEachStoreInScope(\n callbackFn: (store: Store<unknown>) => void\n) {\n storeRegistry.forEach(registration => {\n const store = registration.deref();\n if (store) {\n callbackFn(store);\n } else {\n storeRegistry.delete(registration);\n }\n });\n}\n\n/**\n * Adds a store to the registry.\n *\n * @param store - The store to be added to the registry.\n */\nexport function addToRegistry(store: Store<any>) {\n storeRegistry.add(new WeakRef(store));\n}\n\n/**\n * Cleare Store registry.\n * Only used for tests\n *\n */\nexport function clearRegistry() {\n storeRegistry.clear();\n}\n","import { Injector, inject } from '@angular/core';\n\n/**\n * Attempts to retrieve the Angular injector or returns null if not available.\n *\n * This function utilizes the `inject` function from Angular's dependency injection system\n * to obtain an instance of the Angular `Injector`. If the injector is not available, it\n * gracefully returns null.\n *\n * @returns The Angular injector if available, otherwise null.\n */\nexport function getInjectorOrNull(): Injector | null {\n try {\n return inject(Injector);\n } catch (_) {\n return null;\n }\n}\n","import { finalize, isObservable } from 'rxjs';\n\n/**\n * Type to indicate that a given object is a Promise\n * @template T - The type of the resolved value of the promise.\n */\ntype PromiseLike<T> = {\n then(\n onfulfilled?: (value: T) => unknown | PromiseLike<unknown>\n ): PromiseLike<unknown>;\n finally(onfinally?: () => void): PromiseLike<unknown>;\n};\n\n/**\n * Checks if the provided object is a promise\n * @param obj - The object to be checked.\n * @returns True if the object is a promise, false otherwise.\n * @template T - The type of the resolved value of the promise.\n */\nfunction isPromise<T>(obj: T | PromiseLike<T>): obj is PromiseLike<T> {\n return (\n obj &&\n typeof (obj as PromiseLike<T>).then === 'function' &&\n typeof (obj as PromiseLike<T>).finally === 'function'\n );\n}\n\n/**\n * Executes a side effect based on the nature of the source object\n * @param source - The source object\n * @param sideEffect - The side effect function to be executed.\n * @returns The source object with the side effect applied.\n * @template T - The type of the source object.\n */\nexport function withSideEffect<T>(source: T, sideEffect: () => void): T {\n if (isObservable(source)) {\n return source.pipe(finalize(sideEffect)) as T;\n } else if (isPromise(source)) {\n return source.finally(sideEffect) as T;\n }\n\n sideEffect();\n return source;\n}\n","/* eslint-disable @typescript-eslint/no-explicit-any */\nimport {\n Injector,\n ProviderToken,\n Signal,\n WritableSignal,\n assertInInjectionContext,\n computed,\n inject,\n runInInjectionContext,\n signal,\n} from '@angular/core';\nimport { StoreConfig } from './store-config';\nimport { StoreEffect } from './store-effect';\nimport { StoreEvent } from './store-event';\nimport { shallowClone } from './store-immutability/immutable-utility';\nimport { register, rootRegistry, unregister } from './store-mediator';\nimport {\n CommandPostprocessor,\n CommandPreprocessor,\n EffectPostprocessor,\n EffectPreprocessor,\n InitPostprocessor,\n} from './store-plugin';\nimport { StoreQuery } from './store-query';\nimport { addToRegistry } from './store-registry';\nimport { getInjectorOrNull } from './utility/injector-helper';\nimport { withSideEffect } from './utility/sideeffect';\n\n/**\n * Represents a signal store that manages a state and provides methods for state mutation, event handling, and more.\n * @typeparam TState The type of the store's state.\n */\nexport class Store<TState> {\n private readonly _state: WritableSignal<TState>;\n private readonly initPostprocessor?: InitPostprocessor[];\n private readonly commandPreprocessor?: CommandPreprocessor[];\n private readonly commandPostprocessor?: CommandPostprocessor[];\n private readonly effectPreprocessor?: EffectPreprocessor[];\n private readonly effectPostprocessor?: EffectPostprocessor<unknown>[];\n /**\n * The config of the store as readonly\n */\n public readonly config: Readonly<Required<StoreConfig<TState>>>;\n\n /**\n * Creates a new instance of the store class.\n * @param config The configuration options for the store.\n */\n public constructor(config: StoreConfig<TState>) {\n this.config = {\n name: config.name ?? this.constructor.name,\n initialState: config.initialState,\n injector: config.injector ?? getInjectorOrNull(),\n stateEqualityFn: config.stateEqualityFn ?? null,\n plugins: config.plugins ?? [],\n };\n\n this._state = signal(this.config.initialState, {\n equal: this.config.stateEqualityFn ?? undefined,\n });\n\n addToRegistry(this);\n\n this.config.plugins\n .sort((a, b) => (b.precedence ?? 0) - (a.precedence ?? 0))\n .forEach(plugin => {\n if (plugin.init) {\n (this.initPostprocessor as any) ??= [];\n this.initPostprocessor!.push(plugin.init);\n }\n if (plugin.preprocessCommand) {\n (this.commandPreprocessor as any) ??= [];\n this.commandPreprocessor!.push(plugin.preprocessCommand);\n }\n if (plugin.postprocessCommand) {\n (this.commandPostprocessor as any) ??= [];\n this.commandPostprocessor!.unshift(plugin.postprocessCommand);\n }\n if (plugin.preprocessEffect) {\n (this.effectPreprocessor as any) ??= [];\n this.effectPreprocessor!.push(plugin.preprocessEffect);\n }\n if (plugin.postprocessEffect) {\n (this.effectPostprocessor as any) ??= [];\n this.effectPostprocessor!.unshift(plugin.postprocessEffect);\n }\n });\n\n this.initPostprocessor?.forEach(p => p(this));\n }\n\n /**\n * Gets the name of the store\n */\n public get name(): string {\n return this.config.name;\n }\n\n /**\n * Gets the signal representing the store's current state.\n */\n public get state(): Signal<TState> {\n return this._state.asReadonly();\n }\n\n /**\n * Sets the store's state to the provided state, with an optional command name.\n * @param newState The new state of the store.\n * @param commandName The name of the command associated with the state change.\n */\n public set(newState: TState, commandName?: string): void {\n this.commandPreprocessor?.forEach(p => p(this, commandName));\n\n this._state.set(newState);\n\n this.commandPostprocessor?.forEach(p => p(this, commandName));\n }\n\n /**\n * Updates the store's state based on the current state, with an optional command name.\n * @param updateFn A function that updates the current state.\n * @param commandName The name of the command associated with the state change.\n */\n public update(\n updateFn: (currentState: TState) => TState,\n commandName?: string\n ): void {\n this.commandPreprocessor?.forEach(p => p(this, commandName));\n\n this._state.update(state => updateFn(state));\n\n this.commandPostprocessor?.forEach(p => p(this, commandName));\n }\n\n /**\n * Mutates the store's state using the provided mutator function, with an optional command name.\n * @param mutator A function that mutates the current state.\n * @param commandName The name of the command associated with the state mutation.\n */\n public mutate(\n mutator: (currentState: TState) => void,\n commandName?: string\n ): void {\n this.commandPreprocessor?.forEach(p => p(this, commandName));\n\n this._state.update(state => {\n const cloned = shallowClone(state);\n mutator(cloned);\n return cloned;\n });\n\n this.commandPostprocessor?.forEach(p => p(this, commandName));\n }\n\n /**\n * Registers a handler for the specified event in the store's mediator.\n * @param event The event to register the handler for.\n * @param handler The handler function to be executed when the event is published.\n */\n public registerHandler<TPayload>(\n event: StoreEvent<TPayload>,\n handler: (store: this, event: StoreEvent<TPayload>) => void\n ) {\n register(rootRegistry, this, event, handler);\n }\n\n /**\n * Unregister a handler for the specified event(s) in the store's mediator.\n * @param event The event to remove the handler for.\n * @param events Additional events to remove the handlers for.\n */\n public unregisterHandler(\n event: StoreEvent<any>,\n ...events: StoreEvent<any>[]\n ): void;\n public unregisterHandler(...events: StoreEvent<any>[]): void {\n unregister(rootRegistry, this, ...events);\n }\n\n /**\n * Runs an effect with the provided arguments and returns the result.\n * The effect may be associated with the store itself but it may also be unrelated\n * @typeparam TStore The types of the effect's target store.\n * @typeparam TArgs The types of the effect's arguments.\n * @typeparam TResult The type of the effect's result.\n * @param effect The store effect to run.\n * @param args The arguments to pass to the effect.\n * @returns The result of the effect.\n */\n public runEffect<TArgs extends any[], TResult>(\n effect: StoreEffect<this, TArgs, TResult>,\n ...args: TArgs\n ): TResult {\n const invocationId = performance.now() + Math.random();\n this.effectPreprocessor?.forEach(p => p(this, effect, invocationId));\n\n const effectResult =\n effect.config.withInjectionContext && this.config.injector\n ? runInInjectionContext(this.config.injector, () =>\n effect.func(this, ...args)\n )\n : effect.func(this, ...args);\n\n return !this.effectPostprocessor\n ? effectResult\n : withSideEffect(effectResult, () => {\n this.effectPostprocessor?.forEach(action =>\n action(this, effect, effectResult, invocationId)\n );\n });\n }\n\n /**\n * Runs a store query potentially targeting many differnt stores with the provided arguments and returns the result.\n * @typeparam TResult The type of the query's result.\n * @typeparam TStores The types of the stores used in the query.\n * @typeparam TArgs The type of the query's arguments.\n * @param storeQuery The store query to run.\n * @param args The arguments to pass to the query.\n * @returns The result of the query as computed signal.\n */\n public runQuery<\n TResult,\n TStores extends ProviderToken<any>[],\n TArgs = undefined,\n >(\n storeQuery: StoreQuery<TResult, TStores, TArgs>,\n ...args: TArgs extends undefined ? [] : [TArgs]\n ): Signal<TResult> {\n if (!this.config.injector) {\n assertInInjectionContext(this.runQuery);\n }\n\n return runInInjectionContext(\n this.config.injector ?? inject(Injector),\n () => {\n const queryArgs = [\n ...(storeQuery.stores.map(x =>\n x === this.constructor ? this : inject(x)\n ) as {\n [K in keyof TStores]: TStores[K] extends ProviderToken<infer U>\n ? U\n : never;\n }),\n ...(args as any[]),\n ];\n\n return computed(() => storeQuery.query(...(queryArgs as any)));\n }\n );\n }\n}\n","/* eslint-disable @typescript-eslint/no-explicit-any */\nimport { Store } from './store';\n\n/**\n * Configuration for a store effect.\n */\nexport interface StoreEffectConfig {\n /**\n * Indicates whether the effect requires an injection context. Defaults to true.\n */\n withInjectionContext?: boolean;\n\n /**\n * Indicates whether the effect sets loading status.\n * Only applicable if the `StoreStatus` plugin is used.\n * Defaults to false.\n */\n setLoadingStatus?: boolean;\n\n /**\n * Indicates whether the effect sets initialized status.\n * Only applicable if the `StoreStatus` plugin is used.\n * Defaults to false.\n */\n setInitializedStatus?: boolean;\n}\n\n/**\n * Represents an effect that can be executed on a store.\n */\nexport interface StoreEffect<\n TStore extends Store<any>,\n TArgs extends unknown[],\n TResult,\n> {\n name: string; // The name of the effect.\n func: (store: TStore, ...args: TArgs) => TResult; // The function representing the effect.\n config: Readonly<Required<StoreEffectConfig>>; // effect configuration\n}\n\n/**\n * Creates a new store effect with the provided name, function, and configuration.\n * @param name The name of the effect.\n * @param func The function representing the effect.\n * @param config Configuration options for the effect.\n * @returns A store effect object.\n */\nexport function createEffect<\n TStore extends Store<any>,\n TArgs extends any[],\n TResult,\n>(\n name: string,\n func: (store: TStore, ...args: TArgs) => TResult,\n config?: StoreEffectConfig\n): StoreEffect<TStore, TArgs, TResult>;\n\n/**\n * Implementation of the createEffect function.\n */\nexport function createEffect<\n TStore extends Store<any>,\n TArgs extends any[],\n TResult,\n>(\n name: string,\n func: (store: TStore, ...args: TArgs) => TResult,\n arg?: boolean | StoreEffectConfig\n): StoreEffect<TStore, TArgs, TResult> {\n return {\n name,\n func,\n config: {\n withInjectionContext:\n !arg || arg === true || (arg.withInjectionContext ?? true),\n setLoadingStatus: (arg as StoreEffectConfig)?.setLoadingStatus ?? false,\n setInitializedStatus:\n (arg as StoreEffectConfig)?.setInitializedStatus ?? false,\n },\n };\n}\n","/**\n * Represents an event which may affect a store.\n */\nexport interface StoreEvent<TPayload> {\n name: string; // The name of the event.\n payload?: TPayload; // The payload associated with the event.\n}\n\n/**\n * Creates a store event blueprint with the provided name.\n * @param name The name of the event.\n * @returns A store event blueprint object.\n */\nexport function createEvent<TPayload = never>(\n name: string\n): StoreEvent<TPayload> {\n return { name };\n}\n","import { Store } from '../store';\nimport { ImmutableStoreConfig } from './immutable-store-config';\nimport { Immutable } from './immutable-type';\nimport { naiveCloneAndMutateFunc } from './immutable-utility';\n\n/**\n * Represents a store that holds an immutable state, allowing mutation through controlled operations.\n *\n * @typeparam TState The type of the immutable state held by the store.\n */\nexport class ImmutableStore<TState> extends Store<Immutable<TState>> {\n private readonly cloneAndMutateFunc: (\n currentState: TState,\n mutation: (draftState: TState) => void\n ) => TState;\n\n public constructor(config: ImmutableStoreConfig<TState>) {\n super(config);\n\n this.cloneAndMutateFunc =\n config.mutationProducerFn ?? naiveCloneAndMutateFunc;\n }\n\n /**\n * Clones and mutates the store's state using the provided mutator function, with an optional command name.\n * @param mutator A function that mutates the current state.\n * @param commandName The name of the command associated with the state mutation.\n */\n public override mutate(\n mutator: (currentState: TState) => void,\n commandName?: string\n ): void;\n public override mutate(\n mutator: (currentState: Immutable<TState>) => void,\n commandName?: string\n ): void;\n public override mutate(\n mutator:\n | ((currentState: TState) => void)\n | ((currentState: Immutable<TState>) => void),\n commandName?: string\n ): void {\n this.update(\n state =>\n this.cloneAndMutateFunc(\n state as TState,\n mutator as (currentState: TState) => void\n ) as Immutable<TState>,\n commandName\n );\n }\n}\n","/**\n * Memoizes a function by caching its result and returning the cached result on subsequent calls.\n * @param fn - The function to be memoized.\n * @returns A memoized version of the input function.\n */\nexport function memoize<T>(fn: () => T): () => T {\n let cachedResult: T | undefined;\n\n return () => {\n if (cachedResult === undefined) {\n cachedResult = fn();\n }\n return cachedResult;\n };\n}\n","import { memoize } from './memoize';\n\n/**\n * Creates a memoized function for feature detection.\n *\n * @param detectionFn - Function that performs the feature detection.\n * @returns Memoized function for feature detection.\n */\nfunction makeFeatureDetector(detectionFn: () => boolean) {\n return memoize(() => {\n try {\n return detectionFn();\n } catch {\n return false;\n }\n });\n}\n\n/**\n * Feature detection for IndexedDB availability.\n */\nexport const isIndexedDbAvailable = /*@__PURE__*/ makeFeatureDetector(\n () => !!indexedDB\n);\n\n/**\n * Feature detection for Local Storage availability.\n */\nexport const isLocalStorageAvailable = /*@__PURE__*/ makeFeatureDetector(\n () => !!localStorage\n);\n\n/**\n * Feature detection for Session Storage availability.\n */\nexport const isSessionStorageAvailable = /*@__PURE__*/ makeFeatureDetector(\n () => !!sessionStorage\n);\n\n/**\n * Feature detection for Redux DevTools availability.\n */\nexport const isDevtoolsAvailable = /*@__PURE__*/ makeFeatureDetector(\n () => window && '__REDUX_DEVTOOLS_EXTENSION__' in window\n);\n\n/**\n * Feature detection for setTimeout availability.\n */\nexport const isSetTimeoutAvailable = /*@__PURE__*/ makeFeatureDetector(\n () => !!setTimeout\n);\n","/* eslint-disable @typescript-eslint/no-explicit-any */\nimport { Signal, WritableSignal, computed, signal } from '@angular/core';\nimport { Store } from './store';\nimport { ImmutableStore } from './store-immutability/immutable-store';\nimport { isSetTimeoutAvailable } from './utility/feature-detection';\n\ntype HistorySingleItem = {\n command: string;\n store: WeakRef<Store<any>>;\n before: any;\n};\n\ntype HistoryItemGroup = {\n command: string;\n before: WeakMap<Store<any>, any>;\n};\n\ntype HistoryUndoItem = (HistorySingleItem | HistoryItemGroup) & {\n undoneCommandIndex: number;\n};\n\ntype HistoryRedoItem = (HistorySingleItem | HistoryItemGroup) & {\n redoneCommandIndex: number;\n};\n\ntype HistoryItem =\n | HistorySingleItem\n | HistoryItemGroup\n | HistoryUndoItem\n | HistoryRedoItem;\n\ntype History = HistoryItem[];\n\n/**\n * Type guard to check if an item is a undo item.\n * @param item The item to be checked.\n */\nfunction isHistoryUndoItem(\n item: HistoryItem | undefined\n): item is HistoryUndoItem {\n return !!item && 'undoneCommandIndex' in item;\n}\n\n/**\n * Type guard to check if an item is a redo item.\n * @param item The item to be checked.\n */\nfunction isHistoryRedoItem(\n item: HistoryItem | undefined\n): item is HistoryRedoItem {\n return !!item && 'redoneCommandIndex' in item;\n}\n\n/**\n * Creates a tracker which immediately tracks the history of the specifiedd stores.\n * @param maxLength Maximum number of commands to retain in the history.\n * @param store Initial store to be tracked in the history.\n * @param stores Additional stores to be tracked in the history.\n * @returns An instance of `HistoryTracker`.\n *\n * @remark At least one store has to be specifieid\n */\nexport function trackHistory(\n maxLength: number,\n store: ImmutableStore<any>,\n ...stores: ImmutableStore<any>[]\n): HistoryTracker {\n stores ??= [];\n stores.push(store);\n return new HistoryTrackerBase(\n new Set(stores.map(x => new WeakRef(x))),\n maxLength\n );\n}\n\n/**\n * Hhistory tracker for tracking history of a finite set of stores enabling undo and redo functionality.\n */\nexport interface HistoryTracker {\n /**\n * Signal indicating whether undo operation is available.\n */\n canUndo: Signal<boolean>;\n\n /**\n * Signal indicating whether redo operation is available.\n */\n canRedo: Signal<boolean>;\n\n /**\n * History of commands performed.\n */\n getHistory: () => {\n /**\n * Name of the executed command or transaction tag.\n */\n command: string;\n /**\n * Array containing stores and their corresponding state values before the command was executed.\n * Each element is a tuple [store, storeState].\n */\n before: [Store<any> | undefined, any][];\n }[];\n\n /**\n * Destroys the history tracker, cleaning up any resources.\n */\n destroy: () => void;\n\n /**\n * Begins a new transaction in the history tracker.\n * @param tag Optional tag to identify the transaction (only used for pretty printing).\n */\n beginTransaction: (tag?: string) => void;\n\n /**\n * Ends the current transaction in the history tracker.\n */\n endTransaction: () => void;\n\n /**\n * Undoes the last command or a group of commands if in a transaction.\n * @returns True if the undo operation was successful, false otherwise.\n */\n undo: () => boolean;\n\n /**\n * Redoes the last undone command or a group of commands (if last undone action was a transaction).\n * @returns True if the redo operation was successful, false otherwise.\n */\n redo: () => boolean;\n}\n\nconst PRUNE_FRACTION = 0.25;\nconst UNDO_COMMAND = '_UNDO_';\nconst REDO_COMMAND = '_REDO_';\nconst UNSPECIFIED_COMMAND = 'Unspecified';\n\nclass HistoryTrackerBase implements HistoryTracker {\n private readonly stores: Set<WeakRef<Store<any>>>;\n private readonly pool: WeakMap<Store<any>, WeakRef<Store<any>>>;\n private readonly lastCommand: WritableSignal<HistoryItem | undefined>;\n private readonly maxLength: number;\n private readonly _history: History;\n private readonly addToHistoryRef = this.addToHistory.bind(this);\n\n private activeTransactions: number;\n\n constructor(stores: Set<WeakRef<Store<any>>>, maxLength: number) {\n this.stores = stores;\n this.maxLength = Math.floor(maxLength * (1 + PRUNE_FRACTION));\n this.pool = new WeakMap<Store<any>, WeakRef<Store<any>>>();\n this._history = [];\n this.activeTransactions = 0;\n this.lastCommand = signal(undefined);\n\n this.foreachStore(store => {\n if (store instanceof ImmutableStore) {\n (store['commandPreprocessor'] as any) ??= [];\n store['commandPreprocessor']!.push(this.addToHistoryRef);\n this.pool.set(store, new WeakRef(store));\n } else {\n throw new Error(\n `${store.name} is not immutable: HistoryTracker does only support ImmutableStores`\n );\n }\n });\n }\n\n private foreachStore(callbackFn: (store: Store<unknown>) => void) {\n this.stores.forEach(storeRef => {\n const store = storeRef.deref();\n if (store) {\n callbackFn(store);\n } else {\n this.stores.delete(storeRef);\n }\n });\n }\n\n private pushToHistory(historyItem: HistoryItem) {\n this._history.push(historyItem);\n this.lastCommand.set(historyItem);\n\n if (this._history.length > this.maxLength) {\n if (isSetTimeoutAvailable()) {\n setTimeout(this.prune.bind(this), 0);\n } else {\n this.prune();\n }\n }\n }\n\n private popFromHistory() {\n const poped = this._history.pop();\n this.lastCommand.set(this._history[this._history.length - 1]);\n return poped;\n }\n\n private addToHistory<TState>(\n store: Store<TState>,\n command: string | undefined\n ) {\n if (\n this.activeTransactions === 0 &&\n command !== UNDO_COMMAND &&\n command !== REDO_COMMAND\n ) {\n this.pushToHistory({\n command: command ?? UNSPECIFIED_COMMAND,\n before: store.state(),\n store: this.pool.get(store) ?? new WeakRef(store),\n });\n }\n }\n\n private collectCurrentStates() {\n const values = new WeakMap<Store<any>, any>();\n this.foreachStore(store => values.set(store, store.state()));\n return values;\n }\n\n private getCommandToUndo(): [number, HistoryItem | undefined] {\n let toBeUndoneCommandIndex = this._history.length - 1;\n let toBeUndoneCommand = this.lastCommand();\n\n while (\n toBeUndoneCommandIndex >= 0 &&\n isHistoryUndoItem(toBeUndoneCommand)\n ) {\n toBeUndoneCommandIndex = toBeUndoneCommand.undoneCommandIndex - 1;\n toBeUndoneCommand =\n toBeUndoneCommandIndex >= 0\n ? this._history[toBeUndoneCommandIndex]\n : undefined;\n }\n\n return toBeUndoneCommandIndex >= 0\n ? [toBeUndoneCommandIndex, toBeUndoneCommand]\n : [-1, undefined];\n }\n\n private getCommandToRedo(): [number, HistoryItem | undefined] {\n let toBeRedoneCommandIndex = this._history.length - 1;\n let toBeRedoneCommand = this.lastCommand();\n\n while (\n toBeRedoneCommandIndex >= 0 &&\n isHistoryRedoItem(toBeRedoneCommand)\n ) {\n toBeRedoneCommandIndex = toBeRedoneCommand.redoneCommandIndex - 1;\n toBeRedoneCommand =\n toBeRedoneCommandIndex >= 0\n ? this._history[toBeRedoneCommandIndex]\n : undefined;\n }\n\n return toBeRedoneCommandIndex >= 0 && isHistoryUndoItem(toBeRedoneCommand)\n ? [toBeRedoneCommandIndex, toBeRedoneCommand]\n : [-1, undefined];\n }\n\n private prune(): void {\n const deleteCount = Math.floor(this._history.length * PRUNE_FRACTION);\n\n if (deleteCount > 0) {\n this._history.splice(0, deleteCount);\n\n this._history.forEach(command => {\n if (isHistoryRedoItem(command)) {\n command.redoneCommandIndex -= deleteCount;\n } else if (isHistoryUndoItem(command)) {\n command.undoneCommandIndex -= deleteCount;\n }\n });\n }\n }\n\n get canUndo() {\n return computed(\n () => !!this.lastCommand() && this.getCommandToUndo()[0] >= 0\n );\n }\n\n get canRedo() {\n return computed(\n () =>\n !!this.lastCommand() &&\n this.activeTransactions === 0 &&\n this.getCommandToRedo()[0] >= 0\n );\n }\n\n getHistory() {\n const scopedStores = Array.from(this.stores);\n return this._history.map(x => {\n const stores = 'store' in x ? [x.store] : scopedStores;\n\n const before = stores.map(storeRef => {\n const store = storeRef.deref();\n return [\n store,\n x.before instanceof WeakMap\n ? store\n ? x.before.get(store)\n : undefined\n : x.before,\n ] as [Store<any> | undefined, any];\n });\n\n return {\n command: x.command,\n before,\n };\n });\n }\n\n destroy() {\n this.foreachStore(store => {\n if (store instanceof ImmutableStore) {\n const trackerRefIndex = store['commandPreprocessor']?.indexOf(\n this.addToHistoryRef\n );\n if (trackerRefIndex !== undefined && trackerRefIndex > -1) {\n store['commandPreprocessor']!.splice(trackerRefIndex, 1);\n }\n }\n });\n }\n\n beginTransaction(tag?: string) {\n if (this.activeTransactions === 0) {\n this.pushToHistory({\n command: tag ?? UNSPECIFIED_COMMAND,\n before: this.collectCurrentStates(),\n });\n }\n\n this.activeTransactions++;\n }\n\n endTransaction() {\n if (this.activeTransactions > 0) {\n this.activeTransactions--;\n }\n }\n\n undo(): boolean {\n if (this.activeTransactions > 0) {\n const toBeUndone = this.popFromHistory();\n if (toBeUndone && toBeUndone.before instanceof WeakMap) {\n this.foreachStore(store =>\n store.set(toBeUndone.before.get(store), UNDO_COMMAND)\n );\n }\n\n this.activeTransactions = 0;\n return true;\n }\n\n const [toBeUndoneCommandIndex, toBeUndoneCommand] = this.getCommandToUndo();\n\n if (toBeUndoneCommand) {\n const newState = toBeUndoneCommand.before;\n\n if (newState instanceof WeakMap) {\n this.pushToHistory({\n command: UNDO_COMMAND,\n before: this.collectCurrentStates(),\n undoneCommandIndex: toBeUndoneCommandIndex,\n });\n this.foreachStore(store =>\n store.set(newState.get(store), UNDO_COMMAND)\n );\n } else if ('store' in toBeUndoneCommand) {\n const store = toBeUndoneCommand.store.deref();\n if (store) {\n this.pushToHistory({\n command: UNDO_COMMAND,\n store: toBeUndoneCommand.store,\n before: store.state(),\n undoneCommandIndex: toBeUndoneCommandIndex,\n });\n store.set(newState, UNDO_COMMAND);\n }\n }\n\n return true;\n }\n\n return false;\n }\n\n redo(): boolean {\n if (this.activeTransactions > 0) {\n return false;\n }\n\n const [toBeRedoneCommandIndex, toBeRedoneCommand] = this.getCommandToRedo();\n\n if (toBeRedoneCommand) {\n const newState = toBeRedoneCommand.before;\n if (newState instanceof WeakMap) {\n this.pushToHistory({\n command: REDO_COMMAND,\n before: this.collectCurrentStates(),\n redoneCommandIndex: toBeRedoneCommandIndex,\n });\n this.foreachStore(store =>\n store.set(newState.get(store), REDO_COMMAND)\n );\n } else if ('store' in toBeRedoneCommand) {\n const store = toBeRedoneCommand.store.deref();\n if (store) {\n this.pushToHistory({\n command: REDO_COMMAND,\n store: toBeRedoneCommand.store,\n before: store.state(),\n redoneCommandIndex: toBeRedoneCommandIndex,\n });\n store.set(newState, REDO_COMMAND);\n }\n }\n\n return true;\n }\n\n return false;\n }\n}\n","/**\n * Deeply freezes an object and its properties, making it immutable at runtime.\n * @template T - The type of the object.\n * @param {T} obj - The object to be deeply frozen.\n * @returns {T} The deeply frozen object.\n */\nexport function deepFreeze<T>(obj: T): T {\n if (obj) {\n Object.freeze(obj);\n\n const oIsFunction = typeof obj === 'function';\n const hasOwnProp = Object.prototype.hasOwnProperty;\n\n Object.getOwnPropertyNames(obj).forEach(function (prop: string) {\n if (\n hasOwnProp.call(obj, prop) &&\n (oIsFunction\n ? prop !== 'caller' && prop !== 'callee' && prop !== 'arguments'\n : true)\n ) {\n const propValue = obj[prop as keyof T];\n if (\n propValue !== null &&\n (typeof propValue === 'object' || typeof propValue === 'function') &&\n !Object.isFrozen(propValue)\n ) {\n deepFreeze(propValue);\n }\n }\n });\n }\n\n return obj;\n}\n","import { StorePlugin } from '../store-plugin';\nimport { deepFreeze } from './deep-freeze';\n\n/**\n * Enables Storeplugin that deep freezes the state after each command\n * This middleware introduces some overhead\n *\n * @returns DeepFreeze Storeplugin.\n */\nexport function useDeepFreeze(): StorePlugin {\n return {\n postprocessCommand(store) {\n deepFreeze(store.state());\n },\n };\n}\n","import { Store } from '../store';\nimport { StorePlugin } from '../store-plugin';\nimport { isDevtoolsAvailable } from '../utility/feature-detection';\n\n/**\n * Represents a Redux action.\n */\ntype Action = { type: string };\n\n/**\n * Options for configuring the Redux DevTools extension.\n */\n// eslint-disable-next-line @typescript-eslint/no-empty-interface\ninterface DevtoolsOptions {\n // At the moment, no support for custom Enhancer options for Redux DevTools\n}\n\n/**\n * Represents a message sent to the Redux DevTools extension.\n */\ninterface DevtoolsMessage {\n type: string;\n payload: { type: string };\n state: string;\n}\n\n/**\n * Represents the Redux DevTools extension interface.\n */\ninterface Devtools {\n send(\n data: { type: string } & Record<string, unknown>,\n state: Record<string, never>\n ): void;\n init(state: Record<string, never>): void;\n unsubscribe(): void;\n subscribe(cb: (message: DevtoolsMessage) => void): () => void;\n}\n\n/**\n * Augments the global Window interface to include Redux DevTools extension functionality.\n */\ndeclare global {\n interface Window {\n __REDUX_DEVTOOLS_EXTENSION__: {\n connect(options: DevtoolsOptions): Devtools;\n };\n }\n}\n\n/**\n * Registry for store with attached redux devtools monitoring\n * It maps the store name to a Weak reference of the store\n */\nexport const registry = new Map<string, WeakRef<Store<unknown>>>();\n\n/**\n * Retrieves a store from the registry by name.\n * @param name Name of the store.\n * @returns The store, if found.\n */\nfunction getStore(name: string): Store<unknown> | undefined {\n return registry.get(name)?.deref();\n}\n\n/**\n * The DevTools extension instance.\n */\nlet devtools: Devtools | undefined;\n\n/**\n * Initializes the Redux DevTools extension.\n * @param options DevTools options.\n */\nfunction initDevtools(options: DevtoolsOptions = {}): void {\n devtools = window.__REDUX_DEVTOOLS_EXTENSION__.connect(options);\n devtools.subscribe(handleDevtoolsMessage);\n}\n\n/**\n * Scavenges and retrieves a snapshot of registered stores.\n * @returns Snapshot of registered stores.\n * @modifies registry - Deletes references to garbage collected stores\n */\nfunction scavengeAndGetStoresSnapshot<T extends Record<string, unknown>>(): T {\n const stores: T = {} as T;\n\n registry.forEach((storeRef, name) => {\n const store = storeRef.deref();\n if (store) {\n stores[store.name as keyof T] = store.state() as T[keyof T];\n } else {\n registry.delete(name);\n sendToDevtools({ type: `[${name}] - @Removal` });\n }\n });\n\n return stores;\n}\n\n/**\n * Sends an action to the Redux DevTools extension.\n * @param action Action to send.\n */\nexport function sendToDevtools(action: Action): void {\n devtools?.send(action, scavengeAndGetStoresSnapshot());\n}\n\n/**\n * Handles messages received from the Redux DevTools extension.\n * @param message DevTools message.\n */\nfunction handleDevtoolsMessage(message: DevtoolsMessage): void {\n if (devtools) {\n if (message.type === 'DISPATCH') {\n const payloadType = message.payload.type;\n\n if (payloadType === 'COMMIT') {\n devtools.init(scavengeAndGetStoresSnapshot());\n return;\n }\n\n if (payloadType === 'JUMP_TO_STATE' || payloadType === 'JUMP_TO_ACTION') {\n const state = JSON.parse(message.state);\n\n for (const [name, value] of Object.entries(state)) {\n const store = getStore(name);\n if (store) {\n store['_state'].set(value);\n }\n }\n }\n }\n }\n}\n\n/**\n * Registers a store for Devtools monitoring.\n *\n * @param store - Store to be registered.\n */\nexport function registerForDevtools<TStore extends Store<unknown>>(\n store: TStore\n) {\n if (!devtools) {\n initDevtools({});\n }\n registry.set(store.name, new WeakRef(store));\n sendToDevtools({ type: `[${store.name}] - @Init` });\n}\n\n/**\n * Removes a store from Devtools monitoring.\n *\n * @param store - Store to be removed.\n */\nexport function removeFromDevtools<TStore extends Store<unknown>>(\n store: TStore\n) {\n registry.delete(store.name);\n sendToDevtools({ type: `[${store.name}] - @Removal` });\n}\n\n/**\n * Enables Storeplugin that links the store activity with the Redux DevTools extension.\n * @returns Devtools Storeplugin\n */\nexport function useDevtools(): StorePlugin {\n if (!isDevtoolsAvailable()) {\n return {};\n }\n\n return {\n init(store) {\n registerForDevtools(store);\n },\n postprocessCommand(store, command) {\n sendToDevtools({\n type: `[${store.name}] - ${command ?? 'Command'}`,\n });\n },\n };\n}\n","import { StorePlugin } from '../store-plugin';\n\n/**\n * Represents a logger function that can be used for logging messages.\n * @param message - The message to be logged.\n * @param optionalParams - Optional parameters to include in the log.\n */\nexport type Logger = (message?: unknown, ...optionalParams: unknown[]) => void;\n\n/**\n * Options for configuring the Store Logger Plugin.\n */\nexport interface StoreLoggerPluginOptions {\n /**\n * Log Function for logging commands and effects. Defaults to `console.log`\n */\n logFunction?: Logger;\n}\n\n/**\n * Enables StorePlugin that logs command and effect execution\n * @returns A StorePlugin instance for logging.\n */\nexport function useLogger(\n options: StoreLoggerPluginOptions = {}\n): StorePlugin & { log: Logger; name: string } {\n const plugin: StorePlugin & { log: Logger; name: string } = {\n name: 'StoreLogger',\n log: options.logFunction ?? console.log,\n };\n\n plugin.init = store => plugin.log(`[${store.name}->Init]`, store.state());\n plugin.postprocessCommand = (store, command) =>\n plugin.log(\n `[${store.name}->Command] ${command ?? 'Unspecified'}`,\n store.state()\n );\n plugin.preprocessEffect = (store, effect) =>\n plugin.log(\n `[${store.name}->Effect STARTED] ${effect.name ?? 'Unspecified'}`,\n store.state()\n );\n plugin.postprocessEffect = (store, effect, _, invocationId) =>\n plugin.log(\n `[${store.name}->Effect FINNISHED in ${Math.floor(\n performance.now() - invocationId\n )} ms] ${effect.name ?? 'Unspecified'}`,\n store.state()\n );\n\n return plugin;\n}\n","/**\n * PerformanceCounter class is used to measure and analyze the performance of a process.\n */\nexport class PerformanceCounter {\n private count = 0;\n private totalDurationMs = 0;\n private maxDurationMs = 0;\n private sumSquares = 0;\n\n private currentTimer: number | null = null;\n\n /**\n * Indicates whether the timer is currently running.\n */\n public get isRunning() {\n return !!this.currentTimer;\n }\n\n /**\n * Adds the specified duration to the counter, updating relevant statistics.\n * @param duration - The duration to be added in milliseconds.\n */\n public addDuration(duration: number): void {\n this.count++;\n this.totalDurationMs += duration;\n this.maxDurationMs = Math.max(this.maxDurationMs, duration);\n this.sumSquares += duration * duration;\n }\n\n /**\n * Starts the timer, recording the current timestamp.\n */\n public startTimer(): void {\n this.currentTimer = performance.now();\n }\n\n /**\n * Stops the timer, calculates the duration, and adds it to the counter.\n */\n public stopTimer(): void {\n const duration = performance.now() - this.currentTimer!;\n this.addDuration(duration);\n this.currentTimer = null;\n }\n\n /**\n * Toggles the timer between start and stop states.\n */\n public toggleTimer(): void {\n if (this.isRunning) {\n this.stopTimer();\n } else {\n this.startTimer();\n }\n }\n\n /**\n * Calculates and returns the average duration based on the recorded intervals.\n * @returns The average duration in milliseconds.\n */\n private getAverageDuration(): number {\n return this.count === 0 ? 0 : this.totalDurationMs / this.count;\n }\n\n /**\n * Calculates and returns the standard deviation of durations.\n * @returns The standard deviation\n */\n private getStandardDeviation(): number {\n if (this.count === 0) {\n return 0;\n }\n\n const count = this.count;\n const meanSquared = (this.totalDurationMs / count) ** 2;\n const variance = (this.sumSquares - meanSquared * count) / count;\n\n return Math.sqrt(variance);\n }\n\n /**\n * Generates and returns a performance report with various statistics.\n * @returns An object containing performance statistics.\n */\n public getReport() {\n return {\n count: this.count,\n maxDurationMs: this.maxDurationMs,\n averageDurationMs: this.getAverageDuration(),\n standardDeviation: this.getStandardDeviation(),\n };\n }\n}\n","/* eslint-disable @typescript-eslint/no-explicit-any */\nimport { StorePlugin } from '../store-plugin';\nimport { registry } from '../store-plugin-devtools/plugin-devtools';\nimport { isDevtoolsAvailable } from '../utility/feature-detection';\nimport { PerformanceCounter } from './performance-counter';\n\n/**\n * Represents a counter associated with a specific store, tracking command execution metrics.\n */\ntype StoreCounter = {\n name: string;\n store: string;\n counter: PerformanceCounter;\n};\n\n// Counters\nconst globalCommandCounter: PerformanceCounter =\n /*@__PURE__*/ new PerformanceCounter();\nconst globalEffectCounter: PerformanceCounter =\n /*@__PURE__*/ new PerformanceCounter();\nconst commandCounters: StoreCounter[] = [];\nconst effectCounters: StoreCounter[] = [];\n\n/**\n * Toggles the timer for a specific command, updating the associated counter.\n * @param store - The name of the store.\n * @param command - The name of the command.\n */\nfunction toggleCommandTimer(store: string, command?: string) {\n const commandName = command ?? 'Unspecified';\n const counterRegistration = commandCounters.find(\n c => c.store === store && c.name === commandName\n );\n const counter = counterRegistration?.counter ?? new PerformanceCounter();\n\n if (!counterRegistration) {\n commandCounters.push({\n name: commandName,\n store,\n counter,\n });\n }\n\n counter.toggleTimer();\n}\n\n/**\n * Adds the duration of an effect to the associated counter.\n * @param store - The name of the store.\n * @param effect - The name of the effect.\n * @param duration - The duration of the effect execution.\n */\nfunction addEffectDuration(\n store: string,\n effect: string | undefined,\n duration: number\n) {\n const effectName = effect ?? 'Unspecified';\n const counterRegistration = effectCounters.find(\n e => e.store === store && e.name === effectName\n );\n const counter = counterRegistration?.counter ?? new PerformanceCounter();\n\n if (!counterRegistration) {\n effectCounters.push({\n name: effectName,\n store,\n counter,\n });\n }\n\n counter.addDuration(duration);\n}\n\n/**\n * Generates and returns a performance report with various metrics.\n * @returns An object containing performance statistics.\n */\nexport function getReport() {\n const globalCommandReport = globalCommandCounter.getReport();\n const globalEffectReport = globalEffectCounter.getReport();\n return {\n totalCommandCount: globalCommandReport.count,\n averageCommandDurationMs: globalCommandReport.averageDurationMs,\n commandDurationStandartDeviation: globalCommandReport.standardDeviation,\n totalEffectCount: globalEffectReport.count,\n averageEffectDurationMs: globalEffectReport.averageDurationMs,\n effectDurationStandartDeviation: globalEffectReport.standardDeviation,\n commands: commandCounters\n .map(c => ({\n name: c.name,\n store: c.store,\n ...c.counter.getReport(),\n }))\n .sort((a, b) => b.averageDurationMs - a.averageDurationMs),\n effects: effectCounters\n .map(e => ({\n name: e.name,\n store: e.store,\n ...e.counter.getReport(),\n }))\n .sort((a, b) => b.averageDurationMs - a.averageDurationMs),\n };\n}\n\n/**\n * Store-Like object for registering the performance counters in redux devtools\n */\nconst counterStore = {\n name: '@signalstory/performance-counter',\n state() {\n return getReport();\n },\n};\n\n/**\n * Returns a StorePlugin that includes initialization and hooks for tracking command and effect performance.\n * @returns The StorePlugin for performance tracking.\n */\nexport function usePerformanceCounter(): StorePlugin {\n return {\n precedence: 11, // should come early in initialization\n init() {\n if (isDevtoolsAvailable() && !registry.has(counterStore.name)) {\n registry.set(counterStore.name, new WeakRef(counterStore) as any);\n }\n },\n preprocessCommand(store, command) {\n globalCommandCounter.toggleTimer();\n toggleCommandTimer(store.name, command);\n },\n postprocessCommand(store, command) {\n globalCommandCounter.toggleTimer();\n toggleCommandTimer(store.name, command);\n },\n postprocessEffect(store, effect, _, invocationId) {\n const duration = Math.floor(performance.now() - invocationId);\n globalEffectCounter.addDuration(duration);\n addEffectDuration(store.name, effect.name, duration);\n },\n };\n}\n","/* eslint-disable @typescript-eslint/no-explicit-any */\nimport { Immutable } from '../../store-immutability/immutable-type';\n\ntype ObjectStoreMigration = (oldVersion: number, oldState: unknown) => unknown;\ntype DbUpdateOperation = ObjectStoreMigration | 'CLEAR' | 'DROP' | undefined;\ntype DbMigration = [string, DbUpdateOperation | IndexedDbStoreMigrator][];\ntype DbMigrationRegistration = {\n dbVersion: number;\n migrations: DbMigration;\n};\n\n/**\n * Class for configuring indexedb object stores and their corresponding miggrations\n */\nclass IndexedDbStoreMigrator {\n private readonly migrations: DbMigration = [];\n\n /**\n * Creates an object store if it does not exist\n * @param objectStoreName - The name of the object store\n * @returns The IndexedDbStoreRegistrator instance for chaining\n */\n createStore(objectStoreName: string) {\n this.migrations.push([objectStoreName, undefined]);\n return this;\n }\n\n /**\n * Creates an object store if it does not exist.\n * If it does exists, the current object store value is cleared\n * @param objectStoreName - The name of the object store\n * @returns The IndexedDbStoreRegistrator instance for chaining\n */\n createStoreOrClearState(objectStoreName: string) {\n this.migrations.push([objectStoreName, 'CLEAR']);\n return this;\n }\n\n /**\n * Creates an object store if it does not exist.\n * If it does exists, the current object store value can be transformed using the passed transformation function\n * @param objectStoreName - The name of the object store\n * @param transformation - Custom transformation function for update\n * @returns The IndexedDbStoreRegistrator instance for chaining\n */\n createStoreOrTransform(\n objectStoreName: string,\n transformation: (oldVersion: number, oldState: unknown) => any\n ) {\n this.migrations.push([objectStoreName, transformation]);\n return this;\n }\n\n /**\n * Creates an object store if it does not exist.\n * If it does exists, the current object store value can be transformed using the passed transformation function\n * @param objectStoreName - The name of the object store\n * @param transformation - Custom transformation function for update\n * @returns The IndexedDbStoreRegistrator instance for chaining\n */\n createStoreOrMigrateRecords(\n objectStoreName: string,\n migration: (records: IndexedDbStoreMigrator) => IndexedDbStoreMigrator\n ) {\n const recordMigration = migration(new IndexedDbStoreMigrator());\n this.migrations.push([objectStoreName, recordMigration]);\n return this;\n }\n\n /**\n * Deletes the object store if it does exist.\n * @param objectStoreName - The name of the object store\n * @returns The IndexedDbStoreRegistrator instance for chaining\n */\n dropStore(objectStoreName: string) {\n this.migrations.push([objectStoreName, 'DROP']);\n return this;\n }\n\n /**\n * Get all registrations\n */\n getMigrations(): Immutable<DbMigration> {\n return this.migrations;\n }\n}\n\n/**\n * Registered indexedDB migrations per databasename\n */\nconst idbMigrations = new Map<string, Immutable<DbMigrationRegistration>>();\n\n/**\n * Retrieves the registered migration for a specific IndexedDB database.\n * @param dbName - The name of the IndexedDB database.\n * @returns The registered migration or undefined if not found.\n */\nexport function getRegisteredMigration(dbName: string) {\n return idbMigrations.get(dbName);\n}\n\n/**\n * Redeems the migration for a specific IndexedDB database.\n * @param dbName - The name of the IndexedDB database.\n * @param dbVersion - Optional parameter specifying the database version.\n * @returns A function to handle the IDBVersionChangeEvent or undefined if the migration is not found.\n * @throws Error if attempting to open a connection with a version different from the registered migration.\n */\nexport function redeemMigration(dbName: string, dbVersion?: number) {\n const migration = idbMigrations.get(dbName);\n if (!migration) {\n return undefined;\n }\n\n if (dbVersion && dbVersion !== migration.dbVersion) {\n throw new Error(\n `getMigrationForDb: Attempted to open a connection to IndexedDb ${dbName} with the version ${dbVersion}, but a migration for the version ${migration.dbVersion} has been specified. Please use only one version for a specific db.`\n );\n }\n\n idbMigrations.delete(dbName);\n\n return (event: IDBVersionChangeEvent) => {\n const target = event.target as IDBRequest;\n const db = target.result;\n const transaction = target.transaction!;\n const oldVersion = event.oldVersion;\n\n migration.migrations.forEach(([store, op]) => {\n if (!db.objectStoreNames.contains(store)) {\n if (op !== 'DROP') {\n db.createObjectStore(store);\n }\n } else if (op) {\n if (op === 'DROP') {\n db.deleteObjectStore(store);\n } else {\n const objectStore = transaction.objectStore(store);\n if (op === 'CLEAR') {\n objectStore.clear();\n } else {\n if (op instanceof IndexedDbStoreMigrator) {\n // Migrate records of objectStore (one-objectstore-for-mulitple-stores approach)\n op.getMigrations().forEach(([recordName, recordOp]) => {\n objectStore.get(recordName).onsuccess = (event: any) => {\n if (recordOp === 'DROP') {\n objectStore.delete(recordName);\n } else if (recordOp === 'CLEAR') {\n objectStore.put(undefined, recordName);\n } else if (typeof recordOp === 'function') {\n const existingData = event.target.result;\n if (existingData) {\n const newData = recordOp(oldVersion, existingData);\n objectStore.put(newData, recordName);\n }\n }\n };\n });\n } else if (typeof op === 'function') {\n // Migrate objectStore\n objectStore.openCursor().onsuccess = (event: any) => {\n const cursor = event.target.result;\n if (cursor) {\n const existingData = cursor.value;\n const newData = op(oldVersion, existingData);\n objectStore.put(newData, cursor.primaryKey);\n }\n };\n }\n }\n }\n }\n });\n };\n}\n\n/**\n * Configures the IndexedDB with specified store registrations and database migration.\n * @param dbName - The name of the IndexedDB database.\n * @param dbVersion - The version of the IndexedDB database.\n * @param migration - A function defining store registrations and migration operations.\n * @remarks Migrations are registered lazily and applied upon the first use of the database.\n * @throws Throws an error if no stores are registered for migration.\n * @throws Throws an error if a migration for the specified database already exists.\n */\nexport function migrateIndexedDb(\n dbName: string,\n dbVersion: number,\n migration: (model: IndexedDbStoreMigrator) => IndexedDbStoreMigrator\n) {\n const migrations = migration(new IndexedDbStoreMigrator()).getMigrations();\n\n if (!migrations || migrations.length === 0) {\n throw new Error('migrateIndexedDb: Please register at least one Store');\n }\n\n if (idbMigrations.has(dbName)) {\n throw new Error(\n `migrateIndexedDb: A migration for ${dbName} has already been specified`\n );\n }\n\n idbMigrations.set(dbName, {\n dbVersion,\n migrations,\n });\n}\n","import { BehaviorSubject, Observable } from 'rxjs';\nimport { getRegisteredMigration, redeemMigration } from './idb-migration';\n\n/**\n * Represents possible states of an IndexedDB pool entry.\n */\ntype IndexedDbPoolEntryState =\n | undefined\n | 'InitError'\n | 'Blocked'\n | IDBDatabase;\n\n/**\n * Type guard for IDBDatabase based on IndexedDbPoolEntryState.\n * @param entry The IndexedDB pool entry to be checked.\n * @returns True if the entry is an IDBDatabase, false otherwise.\n */\nexport function isIDBDatabase(\n entry: IndexedDbPoolEntryState\n): entry is IDBDatabase {\n return typeof entry === 'object' && 'name' in IDBDatabase;\n}\n\n/**\n * Represents a mapping of database names to their corresponding cached IndexedDB pool entries.\n */\nconst dbPool = new Map<string, IndexedDbPoolEntry>();\n\n/**\n * Represents an entry in the IndexedDB pool.\n */\nclass IndexedDbPoolEntry {\n private readonly _db = new BehaviorSubject<IndexedDbPoolEntryState>(\n undefined\n );\n\n public constructor(\n public readonly dbName: string,\n public readonly dbVersion: number\n ) {}\n\n get db() {\n return this._db.asObservable();\n }\n\n updateEntryState(dbState: IndexedDbPoolEntryState) {\n this._db.next(dbState);\n }\n}\n\n/**\n * Retrieves an existing or opens a new connection to an IndexedDB.\n * @param dbName - The name of the database.\n * @param dbVersion - The version of the database.\n * @param migration - A callback function to perform database migration during upgrade.\n * @returns An observable stream representing the state of the IndexedDB entry.\n * @throws Throws an error if attempting to open a connection to a database with conflicting versions.\n */\nexport function getOrOpenDb(\n dbName: string,\n dbVersion?: number,\n migration?: (event: IDBVersionChangeEvent) => void\n): Observable<IndexedDbPoolEntryState> {\n const cachedDbEntry = dbPool.get(dbName);\n\n if (cachedDbEntry) {\n if (dbVersion && cachedDbEntry.dbVersion !== dbVersion) {\n throw new Error(\n `getOrOpenDb: Attempted to open a connection to IndexedDb ${dbName} with the version ${dbVersion}, but another connection to the same db with the version ${cachedDbEntry.dbVersion} is already open. Please use only one version for a specific db.`\n );\n }\n\n return cachedDbEntry.db;\n } else {\n dbVersion ??= getRegisteredMigration(dbName)?.dbVersion;\n if (!dbVersion) {\n throw new Error(\n `getOrOpenDb: No db version specified. If you want to let the db pool infer the version, you have to setup db migration first using a specific version`\n );\n }\n\n const dbPoolEntry = new IndexedDbPoolEntry(dbName, dbVersion);\n dbPool.set(dbName, dbPoolEntry);\n\n const request = indexedDB.open(dbName, dbVersion);\n\n request.onupgradeneeded = event => {\n const db = (event.target as IDBRequest)?.result as IDBDatabase;\n\n if (db) {\n const registeredMigration = redeemMigration(db.name, db.version);\n\n registeredMigration?.(event);\n migration?.(event);\n }\n };\n\n request.onsuccess = event => {\n dbPoolEntry.updateEntryState((event.target as IDBRequest)?.result);\n };\n\n request.onblocked = () => {\n dbPoolEntry.updateEntryState('Blocked');\n };\n\n request.onerror = () => {\n dbPoolEntry.updateEntryState('InitError');\n };\n\n return dbPoolEntry.db;\n }\n}\n","import { filter, first } from 'rxjs';\nimport { AsyncStorage } from '../persistence-async-storage';\nimport {\n PersistenceProjection,\n StorePersistencePluginOptions,\n} from '../plugin-persistence';\nimport { getOrOpenDb, isIDBDatabase } from './idb-pool';\n\n/**\n * Represents the configuration options for IndexedDB setup handlers.\n */\nexport interface IndexedDbSetupHandlers {\n /**\n * Callback for handling the 'success' event after successfully connecting to the database.\n */\n onSuccess?: () => void;\n\n /**\n * Callback for handling the 'blocked' event when a connection request is blocked.\n */\n onBlocked?: () => void;\n\n /**\n * Callback for handling errors during database initialization.\n */\n onInitializationError?: () => void;\n}\n\n/**\n * Represents the options for connecting to an IndexedDB.\n */\nexport interface IndexedDbOptions<TState = never, TProjection = never> {\n /**\n * The name of the IndexedDB database.\n */\n dbName: string;\n\n /**\n * The version of the IndexedDB database. If not provided,\n * the adapter will attempt to infer the version by inspecting the pool.\n * This inference relies on prior configuration through the `migrateIndexedDb` function or previous usage of the same database.\n */\n dbVersion?: number;\n\n /**\n * The name of the object store to connect to within the database.\n * If not provided, it will use the stores name.\n */\n objectStoreName?: string;\n\n /**\n * The key to use when connecting to a specific record within the object store. Default is store name.\n */\n key?: string;\n\n /**\n * Configuration options for IndexedDB setup handlers.\n */\n handlers?: IndexedDbSetupHandlers;\n\n /**\n * Projection functions which are applied before storing and after loading from storage\n * This can be useful for obfuscating sensitive data prior to storing or for saving space.\n * Optional, default nothing.\n */\n projection?: PersistenceProjection<TState, TProjection>;\n}\n\n/**\n * configures connection to an IndexedDb\n * @param options - The configuration options for IndexedDB.\n * @returns Store persistence plugin options.\n */\nexport function configureIndexedDb<TState = never, TProjection = never>(\n options: IndexedDbOptions<TState, TProjection>\n): StorePersistencePluginOptions<TState, TProjection> {\n return {\n persistenceStorage: new IndexedDbAdapter(\n options.dbName,\n options.dbVersion,\n options.objectStoreName,\n options.key,\n options.handlers\n ),\n projection: options.projection,\n };\n}\n\n/**\n * Represents an adapter for interacting with IndexedDB, implementing AsyncStorage.\n */\nexport class IndexedDbAdapter implements AsyncStorage {\n private db: IDBDatabase | undefined;\n\n constructor(\n private dbName: string,\n private dbVersion?: number,\n private _objectStoreName?: string,\n private _key?: string,\n private handlers?: IndexedDbSetupHandlers\n ) {}\n\n private get objectStoreName() {\n return this._objectStoreName!;\n }\n\n private get key() {\n return this._key!;\n }\n\n initAsync(storeName: string, callback?: () => void) {\n this._objectStoreName ??= storeName;\n this._key ??= storeName;\n\n const db = getOrOpenDb(this.dbName, this.dbVersion, event => {\n const db = (event.target as IDBRequest)?.result;\n\n if (db) {\n if (!db.objectStoreNames.contains(this._objectStoreName)) {\n db.createObjectStore(this._objectStoreName);\n }\n }\n });\n\n db.pipe(\n filter(entry => !!entry),\n first()\n ).subscribe(entry => {\n if (isIDBDatabase(entry)) {\n this.db = entry;\n this.dbVersion = entry.version;\n this.handlers?.onSuccess?.();\n callback?.();\n } else if (entry === 'Blocked') {\n this.handlers?.onBlocked?.();\n } else if (entry === 'InitError') {\n this.handlers?.onInitializationError?.();\n }\n });\n }\n\n getItemAsync(\n _: string,\n callback: (value: unknown | null | undefined) => void\n ): void {\n const request = this.db\n ?.transaction([this.objectStoreName])\n ?.objectStore(this.objectStoreName)\n ?.get(this.key);\n\n if (request) {\n request.onsuccess = (event: Event) => {\n callback((event.target as IDBRequest).result);\n };\n }\n }\n\n setItemAsync(_: string, value: unknown, callback?: () => void): void {\n const request = this.db\n ?.transaction([this.objectStoreName], 'readwrite')\n ?.objectStore(this.objectStoreName)\n ?.put(value, this.key);\n\n if (request && callback) {\n request.onsuccess = callback;\n }\n }\n\n removeItemAsync(_: string, callback?: () => void): void {\n const request = this.db\n ?.transaction([this.objectStoreName], 'readwrite')\n ?.objectStore(this.objectStoreName)\n ?.clear();\n\n if (request && callback) {\n request.onsuccess = callback;\n }\n }\n}\n","/* eslint-disable @typescript-eslint/no-explicit-any */\n\nexport interface AsyncStorage<TValue = unknown> {\n initAsync(storeName: string, callback?: () => void): void;\n getItemAsync(key: string, callback: (value: TValue | null) => void): void;\n setItemAsync(key: string, value: TValue, callback?: () => void): void;\n removeItemAsync(key: string, callback?: () => void): void;\n}\n\n/**\n * Type guard to check if an object implements the `PersistenceStorageAsynchronous` interface.\n * @param obj - The object to check.\n * @returns True if the object implements the `PersistenceStorageAsynchronous` interface, false otherwise.\n */\nexport function isAsyncStorage(obj: any): obj is AsyncStorage {\n return (\n typeof obj === 'object' &&\n typeof obj.initAsync === 'function' &&\n typeof obj.getItemAsync === 'function' &&\n typeof obj.setItemAsync === 'function' &&\n typeof obj.removeItemAsync === 'function'\n );\n}\n","/* eslint-disable @typescript-eslint/no-explicit-any */\n/**\n * Represents the interface for store persistence methods with synchronous operations.\n */\nexport interface SyncStorage {\n getItem(key: string): string | null;\n setItem(key: string, value: string): void;\n removeItem(key: string): void;\n}\n\n/**\n * Type guard to check if an object implements the `PersistenceStorageSynchronous` interface.\n * @param obj - The object to check.\n * @returns True if the object implements the `PersistenceStorageSynchronous` interface, false otherwise.\n */\nexport function isSyncStorage(obj: any): obj is SyncStorage {\n return (\n typeof obj === 'object' &&\n typeof obj.getItem === 'function' &&\n typeof obj.setItem === 'function' &&\n typeof obj.removeItem === 'function'\n );\n}\n\n/**\n * Loads a value from storage.\n *\n * @template TState - The type of state to load.\n * @param store - The store instance.\n * @returns The loaded value if available and successfully parsed, otherwise undefined.\n */\nexport function loadFromStorage<TState>(\n persistenceStorage: SyncStorage,\n persistenceKey: string\n): TState | undefined {\n const value = persistenceStorage.getItem(persistenceKey);\n\n try {\n return value ? (JSON.parse(value) as TState) : undefined;\n } catch {\n return undefined;\n }\n}\n\n/**\n * Saves a value to local storage.\n *\n * @template TState - The type of state to save.\n * @param store - The store instance.\n * @param value - The store value to store.\n */\nexport function saveToStorage<TState>(\n persistenceStorage: SyncStorage,\n persistenceKey: string,\n value: TState\n): void {\n persistenceStorage.setItem(persistenceKey, JSON.stringify(value));\n}\n","/* eslint-disable @typescript-eslint/no-explicit-any */\nimport { Store } from '../store';\nimport { StorePlugin } from '../store-plugin';\nimport {\n isIndexedDbAvailable,\n isLocalStorageAvailable,\n isSessionStorageAvailable,\n} from '../utility/feature-detection';\nimport { IndexedDbAdapter } from './idb/idb-adapter';\nimport { AsyncStorage, isAsyncStorage } from './persistence-async-storage';\nimport {\n SyncStorage,\n isSyncStorage,\n loadFromStorage,\n saveToStorage,\n} from './persistence-sync-storage';\n\n/**\n * Projection functions which are applied before storing and after loading from storage\n * This can be useful for obfuscating sensitive data prior to storing or for saving space\n */\nexport interface PersistenceProjection<TState = never, TProjection = never> {\n /**\n * Function to transform the state before saving it to storage.\n * @param state - The current state of the store.\n * @returns The transformed state to be stored.\n */\n onWrite: (state: TState) => TProjection;\n\n /**\n * Function to transform the loaded projection from storage before applying it to the store.\n * @param projection - The loaded projection from storage.\n * @returns The transformed state to be applied to the store.\n */\n onLoad: (projection: TProjection) => TState;\n}\n\n/**\n * Options for configuring the Store Persistence Plugin.\n */\nexport interface StorePersistencePluginOptions<\n TState = never,\n TProjection = never,\n> {\n /**\n * The key used for storing the state in the persistence storage (Optional, default _persisted_state_of_[storename]).\n */\n persistenceKey?: string;\n\n /**\n * The storage medium used for persistence (Optional, default localStorage).\n */\n persistenceStorage?:\n | SyncStorage\n | AsyncStorage\n | 'LOCAL_STORAGE'\n | 'SESSION_STORAGE';\n\n /**\n * Projection functions which are applied before storing and after loading from storage\n * This can be useful for obfuscating sensitive data prior to storing or for saving space.\n * Optional, default nothing.\n */\n projection?: PersistenceProjection<TState, TProjection>;\n}\n\n/**\n * Represents the Store Persistence Plugin, enhancing a store with state persistence functionality.\n */\ntype StorePersistencePlugin<TStorage extends SyncStorage | AsyncStorage> =\n StorePlugin & {\n storage: TStorage;\n persistenceKey: string;\n };\n\n/**\n * typeguard for StorePersistencePlugin.\n * @param obj - The object to check.\n * @returns True if the object is a StorePersistencePlugin, otherwise false.\n */\nfunction isStorePersistencePlugin(\n obj: StorePlugin\n): obj is StorePersistencePlugin<any> {\n return (\n obj &&\n typeof obj === 'object' &&\n 'name' in obj &&\n obj['name'] === 'StorePersistence'\n );\n}\n\n/**\n * Clears the value associated with the provided key from local storage.\n *\n * @template TState - The type of state to clear from local storage.\n * @param store - The store instance.\n *\n */\nexport function clearStoreStorage(store: Store<any>): void {\n const plugin = store.config.plugins.find(isStorePersistencePlugin);\n if (plugin) {\n if (isSyncStorage(plugin.storage)) {\n plugin.storage.removeItem(plugin.persistenceKey);\n } else if (isAsyncStorage(plugin.storage)) {\n plugin.storage.removeItemAsync(plugin.persistenceKey);\n }\n } else {\n throw new Error(\n `Store persistence plugin is not enabled for store ${store.config.name}`\n );\n }\n}\n\nfunction configureSyncStorage<TState = never, TProjection = never>(\n plugin: StorePersistencePlugin<SyncStorage>,\n projection?: PersistenceProjection<TState, TProjection>\n) {\n plugin.init = store => {\n if (!plugin.persistenceKey) {\n plugin.persistenceKey = `_persisted_state_of_${store.config.name}`;\n }\n\n const persistedState = loadFromStorage(\n plugin.storage,\n plugin.persistenceKey\n );\n if (persistedState) {\n store.set(\n projection\n ? projection.onLoad(persistedState as TProjection)\n : persistedState,\n 'Load state from storage'\n );\n }\n };\n\n plugin.postprocessCommand = projection\n ? store =>\n saveToStorage(\n plugin.storage,\n plugin.persistenceKey,\n projection.onWrite(store.state())\n )\n : store =>\n saveToStorage(plugin.storage, plugin.persistenceKey, store.state());\n\n return plugin;\n}\n\nfunction configureAsyncStorage<TState = never, TProjection = never>(\n plugin: StorePersistencePlugin<AsyncStorage>,\n projection?: PersistenceProjection<TState, TProjection>\n) {\n plugin.init = store => {\n if (!plugin.persistenceKey) {\n plugin.persistenceKey = `_persisted_state_of_${store.config.name}`;\n }\n\n plugin.storage.initAsync(store.name, () => {\n plugin.storage.getItemAsync(plugin.persistenceKey, persistedState => {\n if (persistedState) {\n store.set(\n projection\n ? projection.onLoad(persistedState as TProjection)\n : persistedState,\n 'Load state from storage'\n );\n }\n });\n });\n };\n\n plugin.postprocessCommand = projection\n ? store =>\n plugin.storage.setItemAsync(\n plugin.persistenceKey,\n projection.onWrite(store.state())\n )\n : store =>\n plugin.storage.setItemAsync(plugin.persistenceKey, store.state());\n\n return plugin;\n}\n\n/**\n * Enables Storeplugin that persists the store state to a storage (e.g. local storage).\n * State changes are automatically synced with the storage.\n * @param options - Options for configuring the StorePersistencePlugin.\n * @returns A StorePersistencePlugin instance.\n */\nexport function useStorePersistence<TState = never, TProjection = never>(\n options: StorePersistencePluginOptions<TState, TProjection> = {}\n): StorePersistencePlugin<any> {\n const storageProvider = options.persistenceStorage ?? 'LOCAL_STORAGE';\n if (\n (storageProvider === 'LOCAL_STORAGE' && !isLocalStorageAvailable()) ||\n (storageProvider === 'SESSION_STORAGE' && !isSessionStorageAvailable()) ||\n (storageProvider instanceof IndexedDbAdapter && !isIndexedDbAvailable())\n ) {\n return {} as StorePersistencePlugin<any>;\n }\n\n const storage =\n storageProvider === 'LOCAL_STORAGE'\n ? localStorage\n : storageProvider === 'SESSION_STORAGE'\n ? sessionStorage\n : storageProvider;\n\n const plugin = <StorePersistencePlugin<any>>{\n name: 'StorePersistence',\n storage,\n persistenceKey: options.persistenceKey ?? '',\n };\n\n return isAsyncStorage(storage)\n ? configureAsyncStorage(plugin, options.projection)\n : configureSyncStorage(plugin, options.projection);\n}\n","/* eslint-disable @typescript-eslint/no-explicit-any */\r\nimport { Signal, WritableSignal, computed, signal } from '@angular/core';\r\nimport { Store } from '../store';\r\nimport { StoreEffect } from '../store-effect';\r\nimport { StorePlugin } from '../store-plugin';\r\n\r\nconst storeStatusMap = new WeakMap<\r\n Store<unknown>,\r\n WritableSignal<{\r\n hasBeenModified: boolean;\r\n hasBeenInitialized: boolean;\r\n }>\r\n>();\r\n\r\nlet _runningEffects: WritableSignal<\r\n [WeakRef<Store<any>>, StoreEffect<any, any, any>, number][]\r\n> | undefined;\r\n\r\nexport function getRunningEffects(): WritableSignal<\r\n [WeakRef<Store<any>>, StoreEffect<any, any, any>, number][]\r\n> {\r\n if (!_runningEffects) {\r\n _runningEffects = signal([]);\r\n }\r\n return _runningEffects;\r\n}\r\n\r\n/**\r\n * Returns a Signal indicating whether the provided store has been modified.\r\n *\r\n * @note A store is initially considered unmodified. Any command (`set`, `update`, `mutate`) applied to the store\r\n * will mark it as modified. Additionally, an effect created with the `setInitializedStatus` flag will reset the store's\r\n * modification status to unmodified.\r\n *\r\n * @param store - The store to check for modification status.\r\n * @returns Signal<boolean> - A signal indicating whether the store has been modified.\r\n */\r\nexport function modified(store: Store<any>): Signal<boolean> {\r\n const status = storeStatusMap.get(store);\r\n if (!status) {\r\n throw new Error(\r\n `StatusPlugin has not been activated for store ${store.name}`\r\n );\r\n }\r\n\r\n return computed(() => status().hasBeenModified);\r\n}\r\n\r\n/**\r\n * Returns a Signal indicating whether the provided store has been initialized by an initializing effect.\r\n *\r\n * @note A store is initially considered as deinitialized. An effect created with the `setInitializedStatus` flag will set the store's\r\n * initialization status to `true`.\r\n *\r\n * @param store - The store to check for initialization status.\r\n * @returns Signal<boolean> - A signal indicating whether the store has been initialized.\r\n */\r\nexport function initialized(store: Store<any>): Signal<boolean> {\r\n const status = storeStatusMap.get(store);\r\n if (!status) {\r\n throw new Error(\r\n `StatusPlugin has not been activated for store ${store.name}`\r\n );\r\n }\r\n\r\n return computed(() => status().hasBeenInitialized);\r\n}\r\n\r\n/**\r\n * Manually resets the status indicators for the provided store, marking it as deinitialized and unmodified.\r\n * This means that both `unmodified()` and `initialized()` will return false. For manual reset of the loading status,\r\n * use `markAsHavingNoRunningEffects`.\r\n *\r\n * @note This method is intended for exceptional cases.\r\n *\r\n * @param store - The store to manually reset the status.\r\n * @returns void\r\n */\r\nexport function resetStoreStatus(store: Store<any>): void {\r\n storeStatusMap.get(store)?.set({\r\n hasBeenInitialized: false,\r\n hasBeenModified: false,\r\n });\r\n}\r\n\r\n/**\r\n * Returns a Signal indicating whether any of the provided stores is in a loading state.\r\n * If no stores are provided, the returned signal indicates if any store is in a loading state.\r\n *\r\n * @note An effect created with `setLoadingStatus` will mark the associated store as loading while the effect is running.\r\n *\r\n * @param stores - Stores to check for loading status. If no stores are provided, the signal checks all stores.\r\n * @returns Signal<boolean> - A signal indicating whether any store is loading.\r\n */\r\nexport function isLoading(...stores: Store<any>[]): Signal<boolean> {\r\n if (!stores || stores.length === 0) {\r\n return computed(() =>\r\n getRunningEffects()().some(effect => effect[1].config.setLoadingStatus)\r\n );\r\n } else {\r\n return computed(() =>\r\n getRunningEffects()().some(runningEffect => {\r\n const affectedStore = runningEffect[0].deref();\r\n return (\r\n affectedStore &&\r\n runningEffect[1].config.setLoadingStatus &&\r\n stores.some(store => store === affectedStore)\r\n );\r\n })\r\n );\r\n }\r\n}\r\n\r\n/**\r\n * Manually marks the provided store as not having any running effects.\r\n *\r\n * @note This method is intended for exceptional cases, specifically when you observe\r\n * that an effect is not removed from the running state by signalstory automatically.\r\n * If you encounter such a situation, use this method as a temporary workaround and\r\n * be sure to file an issue on GitHub for further investigation and resolution.\r\n *\r\n * @param store - The store to manually mark as not having running effects.\r\n * @returns void\r\n */\r\nexport function markAsHavingNoRunningEffects(store: Store<any>): void {\r\n getRunningEffects().update(state =>\r\n state.filter(runningEffect => runningEffect[0].deref() !== store)\r\n );\r\n}\r\n\r\n/**\r\n * Returns a Signal indicating whether any effect is currently running for any of the provided stores.\r\n * If no Store is provided the returned signal indicates if any store has an effect running\r\n * @param stores - Stores to check for running effects.\r\n * @returns Signal<boolean> - A signal indicating whether any effect is running for any store.\r\n */\r\nexport function isAnyEffectRunning(...stores: Store<any>[]): Signal<boolean> {\r\n if (!stores || stores.length === 0) {\r\n return computed(() =>getRunningEffects()().length > 0);\r\n } else {\r\n return computed(() =>\r\n getRunningEffects()().some(runningEffect => {\r\n const affectedStore = runningEffect[0].deref();\r\n return affectedStore && stores.some(store => store === affectedStore);\r\n })\r\n );\r\n }\r\n}\r\n\r\n/**\r\n * Returns a Signal indicating whether the specified effect is currently running for any of the provided stores.\r\n * If no Store is provided the returned signal indicates if any store has the given effect running\r\n * @param effect - The effect to check for.\r\n * @param stores - Stores to check for the specified effect.\r\n * @returns Signal<boolean> - A signal indicating whether the specified effect is running for any store.\r\n */\r\nexport function isEffectRunning(\r\n effect: StoreEffect<any, any, any>,\r\n ...stores: Store<any>[]\r\n): Signal<boolean> {\r\n if (!stores || stores.length === 0) {\r\n return computed(() =>getRunningEffects()().some(x => x[1] === effect));\r\n } else {\r\n return computed(() =>\r\n getRunningEffects()()\r\n .filter(runningEffect => runningEffect[1] === effect)\r\n .some(runningEffect => {\r\n const affectedStore = runningEffect[0].deref();\r\n return affectedStore && stores.some(store => store === affectedStore);\r\n })\r\n );\r\n }\r\n}\r\n\r\n/**\r\n * Enables StorePlugin that tracks the loading and modification status of a store.\r\n * @returns A StorePlugin instance for loading and modification status tracking.\r\n */\r\nexport function useStoreStatus(): StorePlugin {\r\n return {\r\n init(store) {\r\n storeStatusMap.set(\r\n store,\r\n signal({\r\n hasBeenInitialized: false,\r\n hasBeenModified: false,\r\n })\r\n );\r\n },\r\n postprocessCommand(store) {\r\n const status = storeStatusMap.get(store);\r\n if (status && !status().hasBeenModified) {\r\n storeStatusMap.get(store)?.update(state => ({\r\n ...state,\r\n hasBeenModified: true,\r\n }));\r\n }\r\n },\r\n preprocessEffect(store, effect, invocationId) {\r\n getRunningEffects().update(effects => [\r\n ...effects,\r\n [new WeakRef(store), effect, invocationId],\r\n ]);\r\n },\r\n postprocessEffect(store, effect, _, invocationId) {\r\n getRunningEffects().update(effects =>\r\n effects.filter(x => x[2] !== invocationId)\r\n );\r\n if (effect.config.setInitializedStatus) {\r\n storeStatusMap.get(store)?.set({\r\n hasBeenInitialized: true,\r\n hasBeenModified: false,\r\n });\r\n }\r\n },\r\n };\r\n}\r\n","/* eslint-disable @typescript-eslint/no-explicit-any */\nimport { ProviderToken } from '@angular/core';\nimport { Store } from './store';\n\n/**\n * Represents a store query with the specified result type, store dependencies, and optional argument.\n */\nexport type StoreQuery<\n TResult,\n TStores extends ProviderToken<any>[],\n TArg = undefined,\n> = {\n stores: TStores;\n query: TArg extends undefined\n ? (\n ...stores: {\n [K in keyof TStores]: TStores[K] extends ProviderToken<infer U>\n ? U\n : never;\n }\n ) => TResult\n : (\n ...storesAndArg: {\n [K in keyof TStores]: TStores[K] extends ProviderToken<infer U>\n ? U\n : never;\n } & { arg: TArg }\n ) => TResult;\n};\n\n/**\n * Creates a store query with the specified result type and store dependencies.\n * @param stores The store dependencies for the query.\n * @param query The query function that operates on the stores.\n * @returns The created store query.\n */\nexport function createQuery<\n TResult,\n TStore1 extends Store<any>,\n TStore2 extends Store<any>,\n TStore3 extends Store<any>,\n TStore4 extends Store<any>,\n TArg = undefined,\n>(\n stores: [\n ProviderToken<TStore1>,\n ProviderToken<TStore2>,\n ProviderToken<TStore3>,\n ProviderToken<TStore4>,\n ],\n query: (\n store1: TStore1,\n store2: TStore2,\n store3: TStore3,\n store4: TStore4,\n arg: TArg\n ) => TResult\n): StoreQuery<\n TResult,\n [\n ProviderToken<TStore1>,\n ProviderToken<TStore2>,\n ProviderToken<TStore3>,\n ProviderToken<TStore4>,\n ],\n TArg\n>;\n\nexport function createQuery<\n TResult,\n TStore1 extends Store<any>,\n TStore2 extends Store<any>,\n TStore3 extends Store<any>,\n TArg = undefined,\n>(\n stores: [\n ProviderToken<TStore1>,\n ProviderToken<TStore2>,\n ProviderToken<TStore3>,\n ],\n query: (\n store1: TStore1,\n store2: TStore2,\n store3: TStore3,\n arg: TArg\n ) => TResult\n): StoreQuery<\n TResult,\n [ProviderToken<TStore1>, ProviderToken<TStore2>, ProviderToken<TStore3>],\n TArg\n>;\n\nexport function createQuery<\n TResult,\n TStore1 extends Store<any>,\n TStore2 extends Store<any>,\n TArg = undefined,\n>(\n stores: [ProviderToken<TStore1>, ProviderToken<TStore2>],\n query: (store1: TStore1, store2: TStore2, arg: TArg) => TResult\n): StoreQuery<TResult, [ProviderToken<TStore1>, ProviderToken<TStore2>], TArg>;\n\nexport function createQuery<\n TResult,\n TStore1 extends Store<any>,\n TArg = undefined,\n>(\n stores: [ProviderToken<TStore1>],\n query: (store1: TStore1, arg: TArg) => TResult\n): StoreQuery<TResult, [ProviderToken<TStore1>], TArg>;\n\nexport function createQuery<TResult>(\n stores: ProviderToken<any>[],\n query: (...stores: any[]) => TResult\n): StoreQuery<TResult, ProviderToken<any>[]> {\n return {\n stores: stores,\n query: query,\n };\n}\n","/* eslint-disable @typescript-eslint/no-explicit-any */\nimport { ProviderToken } from '@angular/core';\nimport { Store } from './store';\nimport { ImmutableStore } from './store-immutability/immutable-store';\nimport { deepClone } from './store-immutability/immutable-utility';\nimport { forEachStoreInScope } from './store-registry';\n\n/**\n * Represents the snapshot restore command.\n */\nexport const RestoreCommand = '_SNAPSHOT_RESTORE_';\n\n/**\n * Represents a snapshot of the application state.\n */\nexport interface StateSnapshot {\n /**\n * The timestamp when the snapshot was created.\n */\n readonly timestamp: number;\n\n /**\n * Restores the application state to the captured snapshot.\n */\n restore: () => void;\n}\n\n/**\n * Base implementation of the StateSnapshot interface.\n */\nclass StateSnapshotBase implements StateSnapshot {\n readonly timestamp = performance.now();\n\n constructor(\n private readonly storesWithState: WeakMap<Store<unknown>, unknown>\n ) {}\n\n restore(): void {\n forEachStoreInScope(store => {\n if (this.storesWithState.has(store)) {\n const snapshotValue = this.storesWithState.get(store);\n if (snapshotValue !== store.state()) {\n store.set(snapshotValue, RestoreCommand);\n }\n }\n });\n }\n}\n\n/**\n * Creates a state snapshot either for specified stores or all stores in scope.\n *\n * If no stores are provided, the snapshot will include all stores currently in scope.\n * Stores can be specified either as instances of Store or as ProviderTokens representing\n * Store classes.\n *\n * @param stores - The stores for which to create a snapshot. Can be either instances\n * of Store or ProviderTokens representing Store classes.\n * @returns A StateSnapshot instance representing the application state snapshot.\n */\nexport function createSnapshot(\n ...stores: (Store<any> | ProviderToken<Store<any>>)[]\n): StateSnapshot {\n const storesWithState = new WeakMap<Store<unknown>, unknown>();\n\n stores ??= [];\n\n forEachStoreInScope(store => {\n if (\n stores.length === 0 ||\n stores.some(x => x === store || store.constructor === x)\n ) {\n const stateSnapshot =\n store instanceof ImmutableStore\n ? store.state()\n : deepClone(store.state());\n storesWithState.set(store, stateSnapshot);\n }\n });\n\n return new StateSnapshotBase(storesWithState);\n}\n","/*\n * Public API Surface of signalstory\n */\n\nexport { Store } from './lib/store';\nexport { StoreConfig } from './lib/store-config';\nexport { StoreEffect, createEffect } from './lib/store-effect';\nexport { StoreEvent, createEvent } from './lib/store-event';\nexport { HistoryTracker, trackHistory } from './lib/store-history';\nexport { ImmutableStore } from './lib/store-immutability/immutable-store';\nexport { ImmutableStoreConfig } from './lib/store-immutability/immutable-store-config';\nexport { Immutable } from './lib/store-immutability/immutable-type';\nexport { publishStoreEvent } from './lib/store-mediator';\nexport { StorePlugin } from './lib/store-plugin';\nexport { useDeepFreeze } from './lib/store-plugin-deep-freeze/plugin-deep-freeze';\nexport { useDevtools } from './lib/store-plugin-devtools/plugin-devtools';\nexport { useLogger } from './lib/store-plugin-logger/plugin-logger';\nexport {\n getReport,\n usePerformanceCounter,\n} from './lib/store-plugin-performance-counter/plugin-performance-counter';\nexport { configureIndexedDb } from './lib/store-plugin-persistence/idb/idb-adapter';\nexport { migrateIndexedDb } from './lib/store-plugin-persistence/idb/idb-migration';\nexport {\n StorePersistencePluginOptions,\n clearStoreStorage,\n useStorePersistence,\n} from './lib/store-plugin-persistence/plugin-persistence';\nexport {\n initialized,\n isAnyEffectRunning,\n isEffectRunning,\n isLoading,\n markAsHavingNoRunningEffects,\n modified,\n resetStoreStatus,\n useStoreStatus,\n} from './lib/store-plugin-status/plugin-status';\nexport { StoreQuery, createQuery } from './lib/store-query';\nexport { createSnapshot } from './lib/store-snapshot';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;AAAA;;;;;;;AAOG;AACG,SAAU,cAAc,CAAS,KAAa,EAAA;IAClD,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAW;AACpD;AAEA;;;;;;;;AAQG;AACG,SAAU,SAAS,CAAS,KAAa,EAAA;AAC7C,IAAA,OAAO,MAAM,IAAI,iBAAiB,IAAI;AACpC,UAAE,eAAe,CAAC,KAAK;AACvB,UAAE,cAAc,CAAC,KAAK,CAAC;AAC3B;AAEA;;;;AAIG;AACG,SAAU,YAAY,CAAS,KAAa,EAAA;IAChD,IAAI,CAAC,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE;AACvC,QAAA,OAAO,KAAK;IACd;AAEA,IAAA,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;AAAE,QAAA,OAAO,CAAC,GAAG,KAAK,CAAW;IACrD,IAAI,KAAK,YAAY,IAAI;AAAE,QAAA,OAAO,IAAI,IAAI,CAAC,KAAK,CAAW;IAC3D,IAAI,KAAK,YAAY,MAAM;AAAE,QAAA,OAAO,IAAI,MAAM,CAAC,KAAK,CAAW;IAC/D,IAAI,KAAK,YAAY,GAAG;AAAE,QAAA,OAAO,IAAI,GAAG,CAAC,KAAK,CAAW;IACzD,IAAI,KAAK,YAAY,GAAG;AAAE,QAAA,OAAO,IAAI,GAAG,CAAC,KAAK,CAAW;IAEzD,OAAO,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,KAAK,CAAW;AAC3C;AAEA;;;;;;;;;;;AAWG;AACG,SAAU,uBAAuB,CACrC,YAAoB,EACpB,QAAsC,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