UNPKG

sicua

Version:

A tool for analyzing project structure and dependencies

122 lines (121 loc) 3.75 kB
import { ScanResult } from "../../../types"; import { ComponentLookupService } from "../../../core/componentLookupService"; import { ComponentFlowNode, FileFlowAnalysis, ComponentFlowConfig } from "../types"; import { PathResolver } from "../../../parsers/pathResolver"; /** * Enhanced component flow scanner using optimized services and existing parsed files */ export declare class ComponentFlowScanner { private jsxAnalyzer; private lookupService; private pathResolver; private scanResult; private maxDepth; private config; private analyzedComponents; private conditionalIds; private analysisInProgress; constructor(lookupService: ComponentLookupService, pathResolver: PathResolver, scanResult: ScanResult, maxDepth?: number, config?: ComponentFlowConfig); /** * Analyzes a component file and builds its complete flow tree using optimized services */ scanComponentFlow(filePath: string, depth?: number): ComponentFlowNode | null; /** * FIXED: Normalize file path to match scanResult format (forward slashes) */ private normalizeFilePath; /** * Analyzes multiple component files */ scanMultipleComponentFlows(filePaths: string[]): ComponentFlowNode[]; /** * Gets detailed analysis for a specific file without building the tree */ getFileAnalysis(filePath: string): FileFlowAnalysis | null; /** * Creates a unique key for component identification */ private createComponentKey; /** * Creates a unique key for conditional identification */ private createConditionalKey; /** * Analyzes a single file using existing parsed content from ScanResult */ private analyzeFile; /** * Builds a ComponentFlowNode from file analysis using optimized services */ private buildComponentFlowNode; /** * Builds conditional render objects with optimized deduplication */ private buildConditionalRenders; /** * Extracts child components with optimized deduplication */ private extractChildComponents; /** * Adds components to list if not already seen */ private addUniqueComponents; /** * Resolves component references to ComponentFlowNodes using optimized services */ private resolveComponentReferences; /** * Resolves a component reference using optimized lookup services */ private resolveComponentReference; /** * Checks if a component name is externally imported using PathResolver */ private isExternallyImported; /** * Checks if a component reference is a native HTML element */ private isNativeHTMLElement; /** * Checks if a component reference is a React built-in */ private isReactBuiltIn; /** * Extracts component name from file path or AST */ private extractComponentName; /** * Extracts import statements from AST */ private extractImports; /** * Resets the analyzer state */ reset(): void; /** * Gets summary statistics */ getSummaryStats(rootComponents: ComponentFlowNode[]): { totalConditionals: number; totalComponents: number; uniqueComponents: number; htmlElementsEnabled: boolean; totalHtmlElementsInConditionals: number; }; /** * Gets all analyzed components */ getAllAnalyzedComponents(): ComponentFlowNode[]; /** * Gets conditional count */ getConditionalCount(): number; /** * Updates configuration */ updateConfig(config: Partial<ComponentFlowConfig>): void; /** * Gets current configuration */ getConfig(): ComponentFlowConfig; }