import type { CodeSymbol, CallNode } from "../types.js";
export { buildJsxAdjacency, buildComponentTree, extractJsxComponents, extractHookCalls, extractHookNames, findRuleOfHooksViolations, findRenderRisks, buildReverseAdjacency, computePropChainDepth };
export declare const REACT_STDLIB_HOOKS: Set<string>;
interface JsxAdjacency {
    /** component id → components it renders */
    children: Map<string, CodeSymbol[]>;
}
/**
 * Extract PascalCase JSX element names from source code.
 * Returns the set of component names used via `<ComponentName ...>` or `<ComponentName/>`.
 * HTML elements (lowercase) are skipped.
 */
declare function extractJsxComponents(source: string): Set<string>;
/**
 * Build component → rendered-components adjacency from the index.
 * Only considers symbols with kind "component" (requires Wave 1 extractor).
 */
declare function buildJsxAdjacency(symbols: CodeSymbol[]): JsxAdjacency;
/**
 * Invert JsxAdjacency to a reverse adjacency: child id → sorted list of parent ids.
 *
 * Used by computePropChainDepth to walk UP the render tree (from a leaf back toward
 * roots) and measure render-tree depth. Sorts each parent list alphabetically for
 * deterministic output on cyclic graphs.
 */
declare function buildReverseAdjacency(adjacency: JsxAdjacency): Map<string, string[]>;
/**
 * Compute the longest path (in edges) from componentId UP to the deepest root in
 * the reverse JSX adjacency. This is render-tree depth — NOT prop-flow depth.
 *
 * Iterative implementation using an explicit 2-phase ("enter"/"exit") stack to
 * avoid recursive blowup on deep linear chains (V8 stack ~10-15K frames).
 *
 * Uses shared `memo` and `inProgress` across all calls in one analyzeRenders run
 * to amortize cost to O(V+E) total.
 */
declare function computePropChainDepth(componentId: string, reverseAdjacency: Map<string, string[]>, memo: Map<string, number>, inProgress: Set<string>): number;
/**
 * Walk UP the JSX render tree from a component, looking for any ancestor whose
 * source contains a Suspense boundary. Returns the first ancestor found, or
 * null if no Suspense exists anywhere in the upward chain.
 *
 * Tier 7 — closes the cross-file FP in `react-lazy-no-suspense-same-file` regex
 * (Tier 6 limitation). Reuses `buildReverseAdjacency` infrastructure from Tier 5.
 * Cycle-safe via visited set (BFS on potentially cyclic graph).
 */
export declare function findSuspenseAncestor(componentId: string, reverseAdjacency: Map<string, string[]>, symbolsById: Map<string, CodeSymbol>): {
    name: string;
    file: string;
} | null;
/**
 * Find all React.lazy() / lazy() usages whose containing component lacks a
 * Suspense boundary anywhere in its ancestor chain. Cross-file proper detection.
 * Tier 7 — complements the single-file regex `react-lazy-no-suspense-same-file`.
 */
export interface LazyWithoutSuspense {
    name: string;
    file: string;
    start_line: number;
}
export declare function findLazyComponentsWithoutSuspense(symbols: CodeSymbol[]): LazyWithoutSuspense[];
/**
 * BFS the component composition tree from a root component.
 * Returns a CallNode tree of rendered components up to maxDepth.
 */
declare function buildComponentTree(root: CodeSymbol, adjacency: JsxAdjacency, maxDepth: number): CallNode;
export interface TraceComponentTreeOptions {
    depth?: number | undefined;
    output_format?: "json" | "mermaid" | undefined;
    include_source?: boolean | undefined;
    include_tests?: boolean | undefined;
}
/**
 * Trace the React component composition tree from a root component.
 * Returns a tree of JSX children (which components the root renders,
 * and recursively their children).
 */
export declare function traceComponentTree(repo: string, rootComponent: string, options?: TraceComponentTreeOptions): Promise<CallNode | {
    mermaid: string;
    root: string;
    depth: number;
}>;
export interface HookCall {
    name: string;
    line: number;
    is_stdlib: boolean;
    context: string;
}
export interface HookInventoryEntry {
    name: string;
    kind: "component" | "hook";
    file: string;
    start_line: number;
    hook_count: number;
    hooks: HookCall[];
    violations: string[];
}
export interface HookUsageSummary {
    name: string;
    count: number;
    is_stdlib: boolean;
}
export interface AnalyzeHooksResult {
    entries: HookInventoryEntry[];
    total_components: number;
    total_custom_hooks: number;
    hook_usage: HookUsageSummary[];
    violations_count: number;
}
/**
 * Scan a component/hook source for Rule of Hooks violations.
 * Detects: hook inside if/for/while/switch, hook after early return.
 * Returns a list of human-readable violation descriptions.
 */
declare function findRuleOfHooksViolations(source: string): string[];
/**
 * Extract unique hook names from source (no line numbers, no cap).
 * Use when you only need the set of hooks — e.g. React context bundle.
 */
declare function extractHookNames(source: string): Set<string>;
/**
 * Extract hook calls from source with their relative line number.
 */
declare function extractHookCalls(source: string): HookCall[];
/**
 * Analyze hook usage across components and custom hooks in a repo.
 *
 * Returns:
 * - per-symbol inventory (hooks called, violations)
 * - codebase-wide hook usage summary
 * - Rule of Hooks violation count
 */
export declare function analyzeHooks(repo: string, options?: {
    component_name?: string | undefined;
    file_pattern?: string | undefined;
    include_tests?: boolean | undefined;
    max_entries?: number | undefined;
}): Promise<AnalyzeHooksResult>;
export interface RenderRisk {
    type: "inline-object" | "inline-array" | "inline-function" | "unstable-default" | "missing-memo";
    line: number;
    context: string;
    suggestion: string;
}
export interface RenderAnalysisEntry {
    name: string;
    file: string;
    start_line: number;
    is_memoized: boolean;
    risk_count: number;
    risk_level: "low" | "medium" | "high";
    risks: RenderRisk[];
    /** Components rendered as children (from JSX), useful to see impact */
    children_count: number;
    /**
     * JSX **render-tree** depth: longest path in edges from this component up to a
     * root in the reverse adjacency. Same numeric value as `prop_chain_depth`;
     * this name reflects semantics (not prop-drilling depth). `null` only when
     * `metadata.skipped === "extractor-failure"`.
     */
    jsx_render_depth: number | null;
    /**
     * @deprecated Use `jsx_render_depth`. Same value — retained for backward compatibility.
     * Render-tree depth, not prop-flow depth.
     */
    prop_chain_depth: number | null;
    /** Suggestion text including "NOT prop-drilling depth" disclaimer when depth >= 3 */
    suggestion?: string;
}
export interface AnalyzeRendersResult {
    entries: RenderAnalysisEntry[];
    total_components: number;
    high_risk_count: number;
    summary: {
        inline_objects: number;
        inline_arrays: number;
        inline_functions: number;
        unstable_defaults: number;
        missing_memo: number;
    };
    /** Diagnostic metadata — see `analyzeRenders` implementation for when this is set. */
    metadata?: {
        skipped?: "extractor-failure";
    };
}
/**
 * Analyze a single component source for re-render risks.
 */
declare function findRenderRisks(source: string): RenderRisk[];
/**
 * Format an AnalyzeRendersResult as human-readable Markdown.
 * Used by analyzeRenders when format="markdown" is requested.
 */
export declare function formatRendersMarkdown(result: AnalyzeRendersResult): string;
/**
 * Analyze re-render risk across React components in a repo.
 *
 * Detects:
 * - Inline object/array/function props in JSX (new reference every render)
 * - Unstable default parameter values ([] or {} in component params)
 * - Components not wrapped in React.memo that render children (missing-memo)
 *
 * Returns per-component risk assessment with actionable suggestions.
 */
export declare function analyzeRenders(repo: string, options?: {
    component_name?: string | undefined;
    file_pattern?: string | undefined;
    include_tests?: boolean | undefined;
    max_entries?: number | undefined;
    format?: "json" | "markdown" | undefined;
}): Promise<AnalyzeRendersResult | string>;
export interface ReactContextInfo {
    name: string;
    created_in: {
        file: string;
        line: number;
    };
    providers: {
        file: string;
        line: number;
    }[];
    consumers: {
        file: string;
        component: string;
        line: number;
    }[];
}
export interface ContextGraph {
    contexts: ReactContextInfo[];
}
/**
 * Build a graph of React Context flows: createContext → Provider → useContext consumers.
 *
 * Single-pass scan over all symbols (capped at 500). No cycle detection — relies
 * on visited set keyed by context name to prevent re-processing.
 *
 * Detection patterns:
 * - createContext call: `const X = createContext(...)` or `const X = React.createContext(...)`
 * - Provider usage: `<X.Provider value={...}>` (anywhere in any source)
 * - Consumer usage: `useContext(X)` (anywhere in any source)
 *
 * Phase 2 features (not implemented here):
 * - Cycle detection in provider chains
 * - Re-render impact analysis ("which consumers re-render when X changes")
 * - Context value type tracking
 */
export declare function buildContextGraph(symbols: CodeSymbol[]): ContextGraph;
export interface CompilerReadinessResult {
    /** 0-100 readiness score (100 = fully compatible) */
    readiness_score: number;
    total_components: number;
    /** Components with 0 bailout patterns */
    compatible_components: number;
    /** Components with ≥1 bailout pattern */
    bailout_components: number;
    /** Count of redundant manual memoization (safe to remove post-adoption) */
    redundant_memoization: number;
    /** Bailout issues by pattern, sorted by frequency */
    issues: Array<{
        pattern: string;
        count: number;
        description: string;
    }>;
    /** Top components with most bailout issues */
    top_bailout_components: Array<{
        name: string;
        file: string;
        issues: number;
    }>;
}
/**
 * Audit a React codebase for React Compiler (v1.0) adoption readiness.
 *
 * Scans all components for patterns that cause the compiler to silently
 * bail out of auto-memoization. Returns a readiness score (0-100) with
 * prioritized fix list.
 *
 * No competitor offers codebase-wide compiler readiness analysis.
 */
export declare function auditCompilerReadiness(repo: string, options?: {
    file_pattern?: string | undefined;
    include_tests?: boolean | undefined;
}): Promise<CompilerReadinessResult>;
export interface ReactQuickstartResult {
    /** Repository overview */
    overview: {
        total_components: number;
        total_custom_hooks: number;
        likely_root_component: string | null;
        stack: {
            state_management: string | null;
            routing: string | null;
            ui_library: string | null;
            form_library: string | null;
            build_tool: string | null;
        };
    };
    /**
     * High-priority pattern hits for onboarding. Entries use `severity: "critical"` for
     * XSS / Rule-of-Hooks / effect-loop issues. For **backward compatibility**, legacy
     * scans that were pre–Tier 5 (`useEffect-missing-cleanup`, `rsc-non-serializable-prop`)
     * remain in this array with `severity: "warning"` — do not assume the field name
     * implies severity. Tier 5 warning-only patterns live in `warnings`; style bucket in `style_issues`.
     */
    critical_issues: Array<{
        pattern: string;
        count: number;
        severity: "critical" | "warning";
    }>;
    /** Tier 5: warning-severity findings (derived-state, stale-closure, context value inline) */
    warnings: Array<{
        pattern: string;
        count: number;
        severity: "warning";
    }>;
    /** Tier 5: style-severity findings (button-no-type, jsx-no-target-blank) */
    style_issues: Array<{
        pattern: string;
        count: number;
        severity: "style";
    }>;
    /** Top 5 most-used hooks across components */
    top_hooks: Array<{
        name: string;
        count: number;
    }>;
    /** Suggested next queries for the agent to run */
    suggested_queries: string[];
}
/**
 * Day-1 onboarding composite for React projects. Single call that runs:
 * - Component/hook inventory
 * - Stack detection (state mgmt, routing, UI lib, form lib, build tool)
 * - Critical pattern scan (XSS, Rule of Hooks, memory leaks)
 * - Top hook usage summary
 * - Suggested follow-up queries
 *
 * Meant to be the first tool a React developer runs on an unfamiliar codebase.
 * Replaces 5-6 manual tool calls with one structured report.
 */
export declare function reactQuickstart(repo: string): Promise<ReactQuickstartResult>;
//# sourceMappingURL=react-tools.d.ts.map