//#region src/hooks/usePageVisibility/usePageVisibility.d.ts /** * Page visibility state derived from browser's DocumentVisibilityState. * Excludes 'prerender' as it is deprecated and not used in modern browsers. */ type VisibilityState = Exclude; /** * Page visibility information */ type PageVisibility = { /** True if page is currently visible */ isVisible: boolean; /** Current visibility state: 'visible' | 'hidden' */ visibilityState: VisibilityState; }; /** * @description * `usePageVisibility` is a React hook that detects page visibility changes. * It monitors when the user switches tabs or minimizes the browser using the Page Visibility API. * Useful for pausing/resuming animations, videos, or background tasks. * * **SSR Behavior**: Returns `{ isVisible: true, visibilityState: 'visible' }` during server-side rendering. * * @returns {PageVisibility} Page visibility information * - `isVisible` - True if page is currently visible to the user * - `visibilityState` - Current visibility state: 'visible' | 'hidden' * * @example * function VideoPlayer() { * const { isVisible } = usePageVisibility(); * const videoRef = useRef(null); * * useEffect(() => { * if (!videoRef.current) return; * * // Pause video when tab is hidden * if (!isVisible) { * videoRef.current.pause(); * } * }, [isVisible]); * * return