export interface UseTabVisibilityOptions { /** * Callback fired once for each inactive -> active transition * after the initial mount baseline synchronization. */ onActivate?: () => void; /** * Callback fired once for each active -> inactive transition * after the initial mount baseline synchronization. */ onDeactivate?: () => void; /** * Require the browser document to be focused in addition * to being visible for the tab to be considered active. * * When false, document visibility alone determines activity. * * Changing this option after mount can produce an active/inactive * transition and invoke the corresponding callback. * * @default true */ requireWindowFocus?: boolean; /** * SSR-safe initial value before the first client-side measurement. * * @default true */ initialActive?: boolean; } export interface UseTabVisibilityResult { /** * True when the document is considered active. * When `requireWindowFocus` is true, the document must be both visible and focused. */ isActive: boolean; /** * The previously confirmed active state. * Remains `undefined` until the first real transition occurs, * avoiding false-positive triggers during initial hydration. */ wasActive: boolean | undefined; /** * Direct visibility state (`document.visibilityState === "visible"`). */ isVisible: boolean; /** * Direct document/window focus state. */ isFocused: boolean; /** * Timestamp (ms) when this hook most recently confirmed the document * as active, or null if it has never been confirmed active. */ lastActiveAt: number | null; /** * Timestamp (ms) when this hook most recently confirmed the document * as inactive, or null if it has never been confirmed inactive. */ lastInactiveAt: number | null; } /** * Tracks whether the browser document is currently active with zero-tearing SSR safety. * * Activity is derived from document visibility and (optionally) window focus. * Accurately handles multi-monitor focus, mobile browser freeze/resume (BFCache), * and avoids false-positive transitions during initial hydration. * * @param options - Configuration options and transition callbacks. * @returns {UseTabVisibilityResult} State booleans, confirmed previous state, and transition timestamps. * * @example * ```tsx * const { isActive, isVisible, isFocused } = useTabVisibility({ * onActivate: () => playVideo(), * onDeactivate: () => pauseVideo(), * }); * ``` */ export declare function useTabVisibility(options?: UseTabVisibilityOptions): UseTabVisibilityResult; export default useTabVisibility;