UNPKG

sicua

Version:

A tool for analyzing project structure and dependencies

63 lines (62 loc) 1.86 kB
import { IConfigManager, ScanResult } from "../types"; export interface ParseContext { projectType: "nextjs" | "react"; routerType?: "app" | "pages"; sourceDirectory: string; projectRoot: string; } export interface PathResolutionResult { normalizedPath: string; isExternal: boolean; packageName?: string; } /** * High-performance path resolution service * Centralizes and optimizes all path normalization and resolution logic */ export declare class PathResolver { private readonly context; private readonly filePathSet; private readonly relativePathSet; constructor(config: IConfigManager, scanResult: ScanResult); /** * Normalize file path relative to appropriate base directory */ normalizeFilePath(filePath: string): string; /** * Extract directory for component relation */ extractDirectory(filePath: string): string; /** * Resolve import path considering project structure with O(1) lookup */ resolveImportPath(importPath: string, currentFile: string): PathResolutionResult; /** * Check if import is external package with O(1) performance */ isExternalPackage(importPath: string): boolean; /** * Extract package name from import path */ extractPackageName(importPath: string): string; /** * Enhanced component detection based on project structure */ shouldTreatAsComponent(filePath: string): boolean; /** * Create parse context from config */ private createParseContext; /** * Build set of relative paths for O(1) lookup */ private buildRelativePathSet; /** * Generate path variations for import matching */ private generatePathVariations; /** * Check if string matches valid npm package pattern */ private isValidPackagePattern; }