/** * The type of a hook state. */ type HookState = [T, unknown[]]; /** * The plain state object of a hook. */ export type HooksState = HookState[]; /** * The type of a cleanup function. * It is called when the effect is no longer needed. */ type Cleanup = () => void; /** * The type of an effect function. */ export type Effect = () => Cleanup | undefined | void; /** * The hooks manager. */ export declare class HooksManager { /** * The internal state of hooks. */ private state; /** * The index of current hook. */ private index; /** * The queue of effects to run. */ private effects; /** * Create a new hooks manager. * @param state The initial state of hooks. */ constructor(state?: HooksState); /** * Get the next state of a hook. * If the dependencies are changed, the value of the state will be updated. * @param factory The state value factory. * @param deps The dependencies of the state. * @returns The state value and its dependencies. */ private nextState; /** * Create a state value and its setter. * @param initialValue The initial value of the state. * @returns The state value and its setter. */ useState(initialValue: T): [T, (newValue: T) => boolean]; /** * Create a memoized value. * @param factory The state value factory. * @param deps The dependencies of the state. * @returns The memoized value. */ useMemo(factory: () => T, deps?: unknown[]): T; /** * Create an effect that runs after the render. * @param effect The effect function to run. * @param deps The dependencies of the effect. * @returns A cleanup function to run when the effect is no longer needed. */ useEffect(effect: Effect, deps?: unknown[]): void; /** * Generate a unique ID for the rendering context. * @param fn The function component requesting the ID. * @param suffix An optional suffix to append to the ID. * @returns A unique ID string. */ useId(ref: Node, suffix?: string): string; /** * Run all effects that were created since the last call. * @returns An array of effects to run. */ runEffects(): void; /** * Cleanup all effects and states. * This method should be called when the component is unmounted or no longer needed. */ cleanup(): void; } export {};