UNPKG

image-asset-manager

Version:

A comprehensive image asset management tool for frontend projects

142 lines 4.39 kB
import { ImageAnalyzer, ImageFile, UsageAnalysis, Reference, ImageMetadata } from "../types"; export interface SafeDeletionSuggestion { file: ImageFile; safeToDelete: boolean; reason: string; riskLevel: "low" | "medium" | "high"; recommendations: string[]; } export declare class ImageAnalyzerImpl implements ImageAnalyzer { private codeScanner; private metadataExtractor; constructor(); /** * Analyze usage of image files in the project with enhanced algorithms */ analyzeUsage(projectPath: string, imageFiles: ImageFile[]): Promise<UsageAnalysis>; /** * Build an enhanced map of image files to their usage information with detailed analysis */ private buildEnhancedUsageMap; /** * Identify unused files with advanced detection algorithms * This method considers various factors to determine if a file is truly unused */ private identifyUnusedFilesAdvanced; /** * Build a map of image files to their usage information */ private buildUsageMap; /** * Find the image file that matches a reference */ private findMatchingImageFile; /** * Extract the actual image path from a reference context */ private extractImagePathFromReference; /** * Identify unused image files */ private identifyUnusedFiles; /** * Generate safe deletion suggestions for unused files */ generateSafeDeletionSuggestions(unusedFiles: ImageFile[], projectPath: string): Promise<SafeDeletionSuggestion[]>; /** * Analyze if a file is safe to delete */ private analyzeSafeDeletion; /** * Get usage statistics for the project */ getUsageStatistics(usageAnalysis: UsageAnalysis): { totalFiles: number; usedFiles: number; unusedFiles: number; totalReferences: number; averageReferencesPerFile: number; mostReferencedFiles: Array<{ file: ImageFile; count: number; }>; }; /** * Categorize images based on their content and metadata */ categorizeImages(files: ImageFile[]): Promise<ImageFile[]>; /** * Generate metadata for an image file */ generateMetadata(file: ImageFile): Promise<ImageMetadata>; /** * Find potentially related files based on naming patterns */ findRelatedFiles(targetFile: ImageFile, allFiles: ImageFile[]): ImageFile[]; /** * Check if two strings have a common prefix of minimum length */ private hasCommonPrefix; /** * Check if two strings have a common suffix of minimum length */ private hasCommonSuffix; /** * Check if two filenames are part of a numbered sequence */ private isNumberedSequence; /** * Get detailed usage report for a specific file */ getFileUsageReport(fileId: string, usageAnalysis: UsageAnalysis): { file: ImageFile | null; isUsed: boolean; usageCount: number; references: Reference[]; referencesByType: Record<string, number>; referencesByFile: Record<string, number>; }; /** * Get files that are likely candidates for cleanup */ getCleanupCandidates(usageAnalysis: UsageAnalysis, options?: { includeUnused?: boolean; includeLowUsage?: boolean; maxUsageCount?: number; excludePatterns?: string[]; }): { unused: ImageFile[]; lowUsage: Array<{ file: ImageFile; usageCount: number; }>; suggestions: SafeDeletionSuggestion[]; }; /** * Check if a file should be excluded from cleanup suggestions */ private shouldExcludeFromCleanup; /** * Analyze usage patterns across the project */ analyzeUsagePatterns(usageAnalysis: UsageAnalysis): { mostUsedFiles: Array<{ file: ImageFile; count: number; }>; leastUsedFiles: Array<{ file: ImageFile; count: number; }>; importTypeDistribution: Record<string, number>; fileTypeUsage: Record<string, { used: number; unused: number; }>; directoryUsage: Record<string, { used: number; unused: number; }>; }; } //# sourceMappingURL=ImageAnalyzer.d.ts.map