/** * useFocusRegionReporting Hook * * Manages debounced reporting of focus regions to the backend. * Used to inform the server which components a human has selected in the editor, * enabling proactive collision detection before actual edits occur. */ /** * Options for the useFocusRegionReporting hook. */ export interface UseFocusRegionReportingOptions { /** Whether focus reporting is enabled (default: true) */ enabled?: boolean; /** Debounce delay in ms before sending to server (default: 300) */ debounceMs?: number; /** Heartbeat interval in ms to keep focus alive (default: 15000) */ heartbeatMs?: number; /** * Optional function to send focus regions via WebSocket. * When provided and returns true, HTTP fallback is skipped. * When returns false or not provided, falls back to HTTP. * @param regions - Focus regions to send * @returns true if sent successfully via WebSocket, false otherwise */ sendViaWebSocket?: (regions: string[]) => boolean; } /** * Return value for the useFocusRegionReporting hook. */ export interface UseFocusRegionReportingReturn { /** Current focus regions (local state) */ focusRegions: string[]; /** Set the focus regions - triggers debounced report to server */ setFocusRegions: (regions: string[]) => void; /** Clear all focus regions */ clearFocus: () => void; /** Whether a report is currently in flight */ isReporting: boolean; } /** * Hook for reporting focus regions to the backend. * * Manages debounced updates, heartbeat keep-alive, and cleanup on unmount. * Focus regions tell the server which components the user has selected, * allowing agents to avoid editing those regions proactively. * * @param options - Configuration options * @returns Focus state and operations * * @example * ```tsx * function SelectionReporter() { * const { setFocusRegions, clearFocus } = useFocusRegionReporting(); * * // When Puck selection changes * useEffect(() => { * if (selectedItem) { * setFocusRegions([`/content/${selectedItem.index}`]); * } else { * clearFocus(); * } * }, [selectedItem, setFocusRegions, clearFocus]); * * return null; * } * ``` */ export declare function useFocusRegionReporting(options?: UseFocusRegionReportingOptions): UseFocusRegionReportingReturn;