import { LongTaskEntry } from '../performance-monitor'; /** * Long task summary statistics */ export interface LongTaskStats { /** Total number of long tasks */ readonly count: number; /** Number of critical long tasks (>100ms) */ readonly criticalCount: number; /** Total blocking time (ms) */ readonly totalBlockingTime: number; /** Average long task duration (ms) */ readonly averageDuration: number; /** Maximum long task duration (ms) */ readonly maxDuration: number; /** Recent long task rate (tasks per minute) */ readonly ratePerMinute: number; /** Time since last long task (ms) */ readonly timeSinceLastTask: number | null; } /** * Hook options */ export interface UseLongTaskDetectorOptions { /** Long task threshold (ms) - default 50ms */ readonly threshold?: number; /** Critical threshold (ms) - default 100ms */ readonly criticalThreshold?: number; /** Maximum tasks to keep in history */ readonly maxHistory?: number; /** Callback when long task is detected */ readonly onLongTask?: (task: LongTaskEntry) => void; /** Callback when critical long task is detected */ readonly onCriticalTask?: (task: LongTaskEntry) => void; /** Time window for "isBlocked" detection (ms) */ readonly blockDetectionWindow?: number; /** Enable debug logging */ readonly debug?: boolean; } /** * Hook return value */ export interface UseLongTaskDetectorReturn { /** Recent long tasks */ readonly longTasks: LongTaskEntry[]; /** Long task statistics */ readonly stats: LongTaskStats; /** Whether main thread is currently blocked */ readonly isBlocked: boolean; /** Whether we're in a high-blocking period */ readonly isHighBlocking: boolean; /** Total blocking time */ readonly totalBlockingTime: number; /** Most recent long task */ readonly lastTask: LongTaskEntry | null; /** Register callback for long tasks */ readonly onLongTask: (callback: (task: LongTaskEntry) => void) => () => void; /** Clear long task history */ readonly clearHistory: () => void; /** Check if component should defer rendering */ readonly shouldDefer: () => boolean; /** Get attribution for last task */ readonly getLastTaskAttribution: () => string | null; } /** * Hook for long task detection */ export declare function useLongTaskDetector(options?: UseLongTaskDetectorOptions): UseLongTaskDetectorReturn; /** * Hook to defer rendering during long tasks */ export declare function useDeferredRender(value: T, options?: UseLongTaskDetectorOptions): T; /** * Hook to track blocking time for a specific operation */ export declare function useBlockingTimeTracker(): { startTracking: () => void; stopTracking: () => number; blockingTime: number; }; export declare function useYieldToMain(): { yieldToMain: () => Promise; yieldIfNeeded: (elapsedMs: number) => Promise; };