/** * Hit target interception utilities. * * These utilities help prevent race conditions in click operations by: * 1. Verifying that a click point will hit the expected element * 2. Intercepting events at dispatch time to validate the target * * Based on Playwright's hit target interception pattern. */ export interface HitTargetResult { /** Whether the hit target check succeeded */ success: boolean; /** Whether the click was blocked by another element */ blocked?: boolean; /** Description of the element that blocked the click */ hitTargetDescription?: string; } export type HitTargetAction = 'click' | 'hover' | 'drag' | 'tap'; export interface HitTargetInterceptorOptions { /** * Block all events regardless of hit target result. * Useful for strict safety scenarios. */ blockAllEvents?: boolean; } export interface HitTargetInterceptor { /** Verify the current state of hit target interception */ verify: () => HitTargetResult; /** Stop the interceptor and clean up event listeners */ stop: () => void; } /** * Get a human-readable description of an element for error messages. * * @example * describeElement(document.querySelector('button')) * // => '' */ export declare function describeElement(element: Element): string; /** * Check if the hit point lands on the target element or its descendants. * * This function performs a thorough check that: * 1. Traverses all shadow DOM boundaries correctly * 2. Handles display:contents elements * 3. Follows the composed tree (slots and shadow DOM) * * @param hitPoint - The point to check (client coordinates) * @param targetElement - The element we expect to hit * @returns HitTargetResult indicating success or failure with description */ export declare function expectHitTarget(hitPoint: { x: number; y: number; }, targetElement: Element): HitTargetResult; /** * Check if an event is a TouchEvent. * Handles both modern and legacy touch event detection. */ export declare function isTouchEvent(event: Event): event is TouchEvent; /** * Create a Touch object, handling WebKit's deprecated API. * This provides compatibility across different browser implementations. */ export declare function createTouchObject(target: EventTarget, identifier: number, x: number, y: number): Touch; /** * Set up event interceptors to validate clicks at event time. * * This prevents race conditions where overlays appear between * finding an element and dispatching the click. The interceptor * listens for mouse/pointer events at the capture phase and * validates that the event point hits the target element. * * @param element - The target element we expect to be clicking * @param hitPoint - The expected point of interaction * @param action - The type of action ('click', 'hover', 'drag', or 'tap') * @param options - Optional configuration for the interceptor * @returns HitTargetInterceptor for verifying and stopping interception * * @example * const interceptor = setupHitTargetInterceptor(button, { x: 100, y: 50 }, 'click'); * // ... perform click ... * const result = interceptor.verify(); * interceptor.stop(); * if (!result.success) { * console.error('Click was blocked by:', result.hitTargetDescription); * } * * @example * // Block all events regardless of hit target result * const interceptor = setupHitTargetInterceptor(button, { x: 100, y: 50 }, 'tap', { blockAllEvents: true }); */ export declare function setupHitTargetInterceptor(element: Element, hitPoint: { x: number; y: number; }, action: HitTargetAction, options?: HitTargetInterceptorOptions): HitTargetInterceptor; //# sourceMappingURL=hitTarget.d.ts.map