UNPKG

image-asset-manager

Version:

A comprehensive image asset management tool for frontend projects

226 lines 6.44 kB
export interface CLIOptions { projectPath: string; port: number; config?: string; exclude: string[]; include: string[]; watch: boolean; optimize: boolean; } export interface CLICommand { scan(options: CLIOptions, scanOptions?: any): Promise<void>; serve(options: CLIOptions, serveOptions?: any): Promise<void>; optimize(options: CLIOptions, optimizeOptions?: any): Promise<void>; generate(options: CLIOptions, generateOptions?: any): Promise<void>; } export interface ImageFile { id: string; path: string; relativePath: string; name: string; extension: string; size: number; hash: string; dimensions: { width: number; height: number; }; createdAt: Date; modifiedAt: Date; category: string; } export interface ScanOptions { extensions: string[]; excludePatterns: string[]; recursive: boolean; maxDepth: number; } export interface FileChangeEvent { type: "add" | "change" | "unlink"; path: string; file?: ImageFile; } export interface FileScanner { scanDirectory(path: string, options: ScanOptions): Promise<ImageFile[]>; detectDuplicates(files: ImageFile[]): Promise<DuplicateGroup[]>; watchChanges(callback: (event: FileChangeEvent) => void): void; } export interface DuplicateGroup { hash: string; files: ImageFile[]; totalSize: number; recommendation: string; } export interface UsageAnalysis { usedFiles: Map<string, UsageInfo>; unusedFiles: ImageFile[]; totalReferences: number; } export interface UsageInfo { file: ImageFile; references: Reference[]; usageCount: number; } export interface Reference { filePath: string; lineNumber: number; context: string; importType: "import" | "require" | "url" | "inline"; } export interface ImageMetadata { colorPalette: string[]; hasTransparency: boolean; isAnimated: boolean; compressionLevel: number; } export interface ImageAnalyzer { analyzeUsage(projectPath: string, imageFiles: ImageFile[]): Promise<UsageAnalysis>; categorizeImages(files: ImageFile[]): Promise<ImageFile[]>; generateMetadata(file: ImageFile): Promise<ImageMetadata>; } export interface OptimizeOptions { png: { quality: number; progressive: boolean; }; jpg: { quality: number; progressive: boolean; }; svg: { removeComments: boolean; minifyStyles: boolean; }; webp: { quality: number; lossless: boolean; }; outputDir?: string; keepOriginal: boolean; } export interface OptimizedResult { originalFile: ImageFile; optimizedPath: string; originalSize: number; optimizedSize: number; compressionRatio: number; success: boolean; error?: string; } export interface OptimizationPreview { estimatedSize: number; estimatedRatio: number; qualityScore: number; } export interface ImageOptimizer { optimizeImage(file: ImageFile, options: OptimizeOptions): Promise<OptimizedResult>; batchOptimize(files: ImageFile[], options: OptimizeOptions): Promise<OptimizedResult[]>; previewOptimization(file: ImageFile, options: OptimizeOptions): Promise<OptimizationPreview>; } export type Framework = "react" | "vue" | "html" | "angular" | "svelte"; export interface CodeTemplate { framework: Framework; importTemplate: string; usageTemplate: string; componentTemplate?: string; inlineTemplate?: string; } export interface GeneratedCode { import: string; usage: string; component?: string; inline?: string; } export interface CodeGenerator { generateTypeDefinitions(files: ImageFile[]): Promise<string>; generateImportFile(files: ImageFile[]): Promise<string>; generateUsageCode(file: ImageFile, framework: Framework): string; generateIconComponent(file: ImageFile, framework: Framework): string; } export interface ProjectStats { totalImages: number; totalSize: number; duplicateCount: number; unusedCount: number; categoryBreakdown: Record<string, number>; sizeBreakdown: Record<string, number>; formatBreakdown: Record<string, number>; } export interface ProjectConfig { projectPath: string; excludePatterns: string[]; includePatterns: string[]; optimizeOptions: OptimizeOptions; frameworks: Framework[]; } export interface ServerData { images: ImageFile[]; usage: UsageAnalysis; duplicates: DuplicateGroup[]; stats: ProjectStats; config: ProjectConfig; } export interface WebServer { start(port: number, data: ServerData): Promise<void>; stop(): Promise<void>; broadcast(event: string, data: any): void; setupWebSocket(): void; } export interface WatchOptions { ignored: string[]; persistent: boolean; ignoreInitial: boolean; followSymlinks: boolean; depth: number; } export interface FileWatcher { watch(path: string, options: WatchOptions): void; unwatch(): void; onFileChange(callback: (event: FileChangeEvent) => void): void; } export interface AppState { images: Map<string, ImageFile>; usage: Map<string, UsageInfo>; duplicates: Map<string, DuplicateGroup>; stats: ProjectStats; config: ProjectConfig; lastScan: Date; } export interface CacheFile { version: string; timestamp: number; projectPath: string; data: { images: ImageFile[]; usage: UsageAnalysis; duplicates: DuplicateGroup[]; stats: ProjectStats; }; } export interface CacheManager { save(data: AppState): Promise<void>; load(projectPath: string): Promise<AppState | null>; clear(): Promise<void>; isValid(cacheFile: CacheFile): boolean; } export declare enum ErrorCode { FILE_NOT_FOUND = "FILE_NOT_FOUND", INVALID_IMAGE_FORMAT = "INVALID_IMAGE_FORMAT", OPTIMIZATION_FAILED = "OPTIMIZATION_FAILED", PERMISSION_DENIED = "PERMISSION_DENIED", SERVER_START_FAILED = "SERVER_START_FAILED", WATCH_FAILED = "WATCH_FAILED" } export interface AppError { code: ErrorCode; message: string; details?: any; recoverable: boolean; } export declare class ImageAssetError extends Error { code: ErrorCode; details?: any | undefined; recoverable: boolean; constructor(code: ErrorCode, message: string, details?: any | undefined, recoverable?: boolean); } //# sourceMappingURL=index.d.ts.map