UNPKG

sicua

Version:

A tool for analyzing project structure and dependencies

77 lines (76 loc) 2.56 kB
import { ImportReference, ComponentFlowNode, ComponentReference } from "../types"; import { ComponentRelation } from "../../../types"; /** * Resolves component references to actual component files and handles external dependencies */ export declare class ComponentReferenceResolver { private nodeModuleDetector; private componentMap; private importMap; private resolveCache; constructor(projectRoot: string, srcDirectory: string, components: ComponentRelation[]); /** * Resolves a component reference to a ComponentFlowNode - FIXED VERSION */ resolveComponentReference(reference: ComponentReference, currentFilePath: string): ComponentFlowNode | null; /** * Resolves multiple component references */ resolveMultipleReferences(references: ComponentReference[], currentFilePath: string): ComponentFlowNode[]; /** * Gets all imports for a specific file by parsing the actual file content */ getFileImports(filePath: string): ImportReference[]; /** * Parses imports directly from file content using AST */ private parseImportsFromContent; /** * Checks if a component name is externally imported in a file */ isExternallyImported(componentName: string, filePath: string): boolean; /** * Resolves the actual file path for a component */ resolveComponentFilePath(componentName: string, currentFilePath: string): string | null; /** * Extracts the actual component name from a file path - NEW METHOD */ private extractComponentNameFromFile; /** * Extracts component name from file content using AST - NEW METHOD */ private extractComponentNameFromContent; /** * Checks if a name looks like a React component - NEW METHOD */ private isLikelyReactComponent; /** * Converts string to PascalCase - NEW METHOD */ private toPascalCase; /** * Performs the actual resolution logic - FIXED VERSION */ private performResolution; /** * Builds a map of component names to ComponentRelation objects */ private buildComponentMap; /** * Builds a map of file paths to their import references */ private buildImportMap; /** * Finds a direct component match in the component map */ private findDirectComponentMatch; /** * Finds a component in the imports list */ private findComponentInImports; /** * Finds a component by its import source */ private findComponentByImportSource; }