/** * Enum for broadcast strategies. */ declare enum BroadcastStrategy { None = "none", Local = "local", CrossTab = "cross-tab", All = "all" } /** * Enum for storage types. */ declare enum StorageType { Local = "local", Session = "session" } /** * Listener function type for store state changes. * @template T - The type of the store state. * @param {T} state - The new state after an update. */ type Listener = (state: T) => void; /** * Middleware function type for intercepting state changes. * @template T - The type of the store state. * @param {{ name: string; state: T }} payload - Store name and current state. */ type Middleware = (payload: { name: string; state: T; }) => void; /** * Interface representing a generic store. * @template T - The type of the store state. */ interface Store { /** * Get the current state. * @returns {T} The current state. */ get(): T; /** * Update the state with a partial update. * @param {Partial} update - The partial state to merge. */ set(update: Partial): void; /** * Subscribe to state changes. * @param {Listener} listener - The listener function. * @returns {() => void} Unsubscribe function. */ on(listener: Listener): () => void; } /** * Options for store creation. */ interface StoreOptions { broadcast?: BroadcastStrategy; persist?: boolean; storageType?: StorageType; enableEncryption?: boolean; encryptionKey?: string; } /** * Defines a new global store. * @template T * @param {string} name - Unique store name. * @param {T} initialState - Initial state. * @param {StoreOptions} [options={}] - Store options. * @returns {Store} The created store instance. * @throws If the store name is already registered. */ declare function defineGlobalStore(name: string, initialState: T, options?: StoreOptions): Store; /** * Retrieves a global store by name. * @template T * @param {string} name - Store name. * @returns {Store} The store instance. * @throws If the store is not found. */ declare function useGlobalStore(name: string): Store; /** * Emits a global store event to listeners or other tabs. * @template T * @param {string} name - Store name. * @param {T} data - Data to emit. * @param {BroadcastStrategy} [target=BroadcastStrategy.CrossTab] - Broadcast target. */ declare function emitGlobalStoreEvent(name: string, data: T, target?: BroadcastStrategy): void; export { BroadcastStrategy, type Listener, type Middleware, StorageType, type Store, type StoreOptions, defineGlobalStore, emitGlobalStoreEvent, useGlobalStore };