import * as ts from 'typescript/lib/tsserverlibrary'; import { ClassNameInfo, ExtractionContext } from '../core/types'; import { BaseExtractor } from './BaseExtractor'; /** * Extracts class names from class-variance-authority cva() function calls * * Supports: * - base: array of strings or single string (first argument) * - variants: nested object with string/array values containing classes * - compoundVariants: array of objects with class/className properties * - boolean variants: { disabled: { true: [...], false: null } } * - Import aliasing: import { cva as myCva } from 'class-variance-authority' * - class property overrides: button({ intent: 'primary', class: 'extra-class' }) * * PERFORMANCE OPTIMIZATIONS: * - ✅ Import detection cached per file (one-time AST scan) * - ✅ Early exits for non-cva calls (fast path) * - ✅ Direct property access (no unnecessary traversal) * - ✅ Inline hot paths (string literal extraction) * - ✅ Short-circuit evaluation (skip work when possible) * - ✅ TypeChecker-based origin tracking (cached per symbol) */ export declare class CvaExtractor extends BaseExtractor { private cvaImportCache; private cvaVariableCache; private expressionExtractor; private variableExtractor; constructor(); canHandle(node: ts.Node, context: ExtractionContext): boolean; extract(node: ts.Node, context: ExtractionContext): ClassNameInfo[]; /** * Check if this call expression is a cva() call from class-variance-authority * Supports import aliasing: import { cva as myCva } from 'class-variance-authority' */ private isCvaCall; /** * Get all local names for cva imports from class-variance-authority * Supports aliasing: import { cva as myCva } -> returns Set(['myCva']) * Caches result per file for performance */ private getCvaImportNames; /** * Extract class names from cva() definition * cva(['base', 'classes'], { variants: {...}, compoundVariants: [...] }) */ private extractFromCvaDefinition; /** * Extract class names from cva() configuration object */ private extractFromCvaConfig; /** * Extract class names from the variants object * Structure: { variantName: { optionName: 'classes' | ['classes'] | null } } */ private extractFromVariants; /** * Extract class names from compoundVariants array * Structure: [{ condition: value, class: 'classes' | className: 'classes' }] */ private extractFromCompoundVariants; /** * Extract class names from any expression value * Handles: strings, arrays, template literals, variable references */ private extractFromValue; /** * Check if this call expression is calling a function created by cva() * Uses TypeChecker for accurate origin tracking * IMPORTANT: Returns false for utility functions */ private isCvaCreatedFunctionCall; /** * Check if a symbol's declaration is from a cva() call * Handles: const button = cva(...), export const button = cva(...), etc. */ private isSymbolFromCvaCall; /** * Extract class names from a cva() function call * Example: button({ intent: 'primary', class: 'extra-class' }) */ private extractFromCvaFunctionCall; /** * Get property name from a property assignment */ private getPropertyName; /** * Clear the import cache (useful for testing or when files change) */ clearCache(): void; } //# sourceMappingURL=CvaExtractor.d.ts.map