import * as ts from 'typescript/lib/tsserverlibrary'; import { ClassNameInfo, ExtractionContext } from '../core/types'; import { BaseExtractor } from './BaseExtractor'; /** * Extracts class names from tailwind-variants tv() function calls * * Supports: * - base: string with classes or array of strings * - variants: nested object with string values containing classes * - compoundVariants: array of objects with class/className properties * - slots: object where values contain classes * - Import aliasing: import { tv as myTv } from 'tailwind-variants' * - Lite version: import { tv } from 'tailwind-variants/lite' * - class property overrides: button({ color: 'primary', class: 'bg-pink-500' }) * * PERFORMANCE OPTIMIZATIONS: * - ✅ Import detection cached per file (one-time AST scan) * - ✅ Early exits for non-tv 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 TailwindVariantsExtractor extends BaseExtractor { private tvImportCache; private tvVariableCache; 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 tv() call from tailwind-variants * Supports import aliasing: import { tv as myTv } from 'tailwind-variants' */ private isTvCall; /** * Get all local names for tv imports from tailwind-variants * Supports: * - Standard: import { tv } from 'tailwind-variants' * - Lite version: import { tv } from 'tailwind-variants/lite' * - Aliasing: import { tv as myTv } -> returns Set(['myTv']) * Caches result per file for performance */ private getTvImportNames; /** * Extract class names from tv() configuration object */ private extractFromTvConfig; /** * Extract class names from the variants object * Structure: { variantName: { optionName: 'classes' } } */ private extractFromVariants; /** * Extract class names from compoundVariants array * Structure: [{ condition: value, class: 'classes' or className: 'classes' }] */ private extractFromCompoundVariants; /** * Extract class names from slots object * Structure: { slotName: 'classes' } or { slotName: { base: 'classes', variants: {...} } } */ private extractFromSlots; /** * Extract class names from any expression value */ private extractFromValue; /** * Get property name from a property assignment */ private getPropertyName; /** * Check if this call expression is calling a function created by tv() * Uses TypeChecker for accurate origin tracking * IMPORTANT: Returns false for utility functions */ private isTvCreatedFunctionCall; /** * Check if a symbol's declaration is from a tv() call * Handles: const button = tv(...), export const button = tv(...), etc. */ private isSymbolFromTvCall; /** * Extract class names from a tv() function call * Example: button({ color: 'primary', class: 'bg-pink-500' }) */ private extractFromTvFunctionCall; /** * Clear the import cache (useful for testing or when files change) */ clearCache(): void; } //# sourceMappingURL=TailwindVariantsExtractor.d.ts.map