UNPKG

instantcode

Version:

AI-powered web inspection tool - Pick elements and get instant AI assistance

78 lines (77 loc) 2.45 kB
/** * Framework component detection and file location extraction */ import { ElementSelector } from '../utils/xpath'; export interface ComponentInfo { componentLocation: string; componentName?: string; elementLocation?: { file: string; line: number; column: number; endLine?: number; endColumn?: number; source?: string; }; framework?: 'vue' | 'react' | 'angular' | 'svelte' | 'vanilla'; sourceMap?: { originalLine: number; originalColumn: number; originalSource: string; originalName?: string; }; sourceHierarchy?: string; selectors?: { primary: ElementSelector; fallbacks: string[]; confidence: 'high' | 'medium' | 'low'; }; } /** * Find the nearest component in the DOM tree */ export declare function findNearestComponent(element: Element, verbose?: boolean): ComponentInfo | null; /** * Enhanced component detection with source map support */ export declare function findNearestComponentWithSourceMaps(element: Element, verbose?: boolean): Promise<ComponentInfo | null>; /** * Attempt to extract precise element location using browser DevTools APIs */ export declare function extractPreciseElementLocation(element: Element): ComponentInfo['elementLocation'] | null; /** * Enhanced element identification with comprehensive fallback strategies * This provides multiple ways to identify and re-locate an element */ export declare function generateComprehensiveElementIdentification(element: Element, verbose?: boolean): { component: ComponentInfo | null; identification: { primary: { xpath: string; cssSelector: string; confidence: 'high' | 'medium' | 'low'; }; fallbacks: { attributes: Record<string, string>; dataAttributes: Record<string, string>; textContent?: string; position: { tagName: string; siblingIndex: number; totalSiblings: number; parentPath: string; }; uniqueFeatures: string[]; }; frameworkSpecific?: { react?: { fiberKey?: string; componentStack?: string[]; }; vue?: { instancePath?: string; directiveKeys?: string[]; }; }; }; };