import type { Nullable } from './types'; type TargetKey = string; /** * API for managing pending targets keyed by a string identifier. * * Targets are stored temporarily and can be "consumed" once, * making this hook useful for deferred attachment scenarios * (e.g. IntersectionObserver, ResizeObserver, etc.). * * @template Target - The type of stored target (e.g. HTMLElement) * @template Key - A string union representing allowed keys */ export interface HoneyPendingTargetsApi { /** * Stores a target for the given key. * * @param key - Identifier for the target * @param target - Target to store (or `null` to clear) */ set: (key: Key, target: Nullable) => void; /** * Checks whether a non-null target exists for the given key. * * @param key - Identifier for the target * * @returns `true` if a target is present, otherwise `false` */ has: (key: Key) => boolean; /** * Retrieves the current target for the given key without removing it. * * @param key - Identifier for the target * * @returns The stored target or `null` if none exists */ get: (key: Key) => Nullable; /** * Retrieves and removes the target for the given key. * * After calling this, the stored value becomes `null`. * * @param key - Identifier for the target * * @returns The previously stored target or `null` */ consume: (key: Key) => Nullable; /** * Clears all stored targets. */ clear: () => void; } /** * Hook for managing pending (deferred) targets keyed by identifiers. * * Useful when targets may be assigned before a consumer is ready * (e.g. before an observer is initialized). Targets can later be * consumed and attached when needed. * * This hook does not trigger re-renders and is fully ref-based. * * @template Target - The type of stored target (e.g. HTMLElement) * @template Key - A string union representing allowed keys * * @returns API for managing pending targets * * @example * ```tsx * const pendingTargets = useHoneyPendingTargets(); * * // store target before observer is ready * pendingTargets.set('top', el); * * // later * const target = pendingTargets.consume('top'); * if (target) { * observer.observe(target); * } * ``` */ export declare const useHoneyPendingTargets: () => HoneyPendingTargetsApi; export {};