import { StateSliceId, StateSubscriber, StateSliceRegistration, StateSyncRule, StateCoordinator, StateCoordinatorConfig, createStateSliceId } from './types'; /** * Implementation of the state coordinator. * * @example * ```typescript * const coordinator = new StateCoordinatorImpl(); * * // Register a state slice * coordinator.registerSlice({ * id: createStateSliceId('settings'), * library: createLibraryId('state'), * initialValue: { theme: 'light' }, * getState: () => store.getState().settings, * setState: (value) => store.setState({ settings: value }), * subscribe: (callback) => store.subscribe( * (state) => state.settings, * callback * ), * }); * * // Add a sync rule * coordinator.addSyncRule({ * id: 'theme-sync', * sourceSlice: createStateSliceId('settings'), * sourcePath: ['theme'], * targetSlice: createStateSliceId('ui-prefs'), * targetPath: ['colorMode'], * direction: 'one-way', * }); * ``` */ export declare class StateCoordinatorImpl implements StateCoordinator { /** Configuration */ private readonly config; /** Registered slices */ private readonly slices; /** Sync rules */ private readonly syncRules; /** Global subscribers (receive all changes) */ private readonly globalSubscribers; /** Pending batched updates */ private pendingUpdates; /** Batch timer */ private batchTimer; /** Whether currently syncing (to prevent loops) */ private isSyncing; /** * Creates a new state coordinator. * @param config - Configuration options */ constructor(config?: Partial); /** * Registers a state slice. * @template T - State type * @param registration - Slice registration */ registerSlice(registration: StateSliceRegistration): void; /** * Unregisters a state slice. * @param id - Slice ID */ unregisterSlice(id: StateSliceId): void; /** * Adds a synchronization rule. * @template TSource - Source state type * @template TTarget - Target state type * @param rule - Sync rule */ addSyncRule(rule: StateSyncRule): void; /** * Removes a synchronization rule. * @param id - Rule ID */ removeSyncRule(id: string): void; /** * Gets state from a slice. * @template T - State type * @param sliceId - Slice ID * @returns State value or undefined */ getState(sliceId: StateSliceId): T | undefined; /** * Sets state in a slice. * @template T - State type * @param sliceId - Slice ID * @param value - New value or updater function */ setState(sliceId: StateSliceId, value: T | ((prev: T) => T)): void; /** * Subscribes to state changes for a slice. * @template T - State type * @param sliceId - Slice ID * @param subscriber - Change callback * @returns Unsubscribe function */ subscribe(sliceId: StateSliceId, subscriber: StateSubscriber): () => void; /** * Subscribes to all state changes. * @param subscriber - Change callback * @returns Unsubscribe function */ subscribeAll(subscriber: StateSubscriber): () => void; /** * Forces synchronization of all rules. */ forceSync(): void; /** * Gets all registered slice IDs. * @returns Array of slice IDs */ getSliceIds(): StateSliceId[]; /** * Gets all sync rule IDs. * @returns Array of rule IDs */ getSyncRuleIds(): string[]; /** * Disposes the coordinator. */ dispose(): void; /** * Handles a slice change. */ private handleSliceChange; /** * Schedules batch processing. */ private scheduleBatch; /** * Processes batched updates. */ private processBatch; /** * Processes a single change. */ private processChange; /** * Executes sync rules for a slice. */ private executeSyncRulesForSlice; /** * Executes a single sync rule. */ private executeSyncRule; } /** * Gets the global state coordinator. * @param config - Optional configuration * @returns Global state coordinator instance */ export declare function getStateCoordinator(config?: Partial): StateCoordinatorImpl; /** * Sets the global state coordinator. * @param coordinator - State coordinator instance */ export declare function setStateCoordinator(coordinator: StateCoordinatorImpl): void; /** * Resets the global state coordinator. */ export declare function resetStateCoordinator(): void; /** * Registers a state slice with the global coordinator. */ export declare function registerStateSlice(registration: StateSliceRegistration): void; /** * Creates a state slice ID. */ export { createStateSliceId }; export declare const SLICE_IDS: { readonly session: StateSliceId; readonly settings: StateSliceId; readonly ui: StateSliceId; readonly auth: StateSliceId; readonly theme: StateSliceId; readonly featureFlags: StateSliceId; readonly network: StateSliceId; readonly hydration: StateSliceId; };