codebase-asset-optimizer
Version:
Professional CLI development tool for optimizing and managing assets in codebases. Detects unused assets, optimizes images to WebP, optimizes videos, and automatically replaces asset references. GIFs are preserved unchanged to maintain animation functiona
84 lines • 2.17 kB
TypeScript
import { AssetInfo, AuditResults, OptimizerConfig, ProcessingStats } from "./types.js";
/**
* Main asset optimizer class with smart size detection
*/
export declare class AssetOptimizer {
private config;
private assets;
private results;
constructor(config: OptimizerConfig);
/**
* Reset audit results to initial state
*/
private resetResults;
/**
* Run complete audit of assets
*/
audit(): Promise<AuditResults>;
/**
* Discover all image and video assets
*/
private discoverAssets;
/**
* Check if each asset is used in the codebase
*/
private checkAssetUsage;
/**
* Check if an asset is used by searching for references
*/
private isAssetUsed;
/**
* Identify assets that can be optimized
*/
private identifyOptimizableAssets;
/**
* Check if an asset can be optimized
*/
private isOptimizable;
/**
* Optimize assets with smart size detection
*/
optimizeAssets(createBackup?: boolean): Promise<ProcessingStats>;
/**
* Optimize a single image using Sharp with size verification
*/
private optimizeImage;
/**
* Optimize a single video using FFmpeg with size verification
*/
private optimizeVideo;
/**
* Replace original asset with optimized version and update references
*/
private replaceAsset;
/**
* Update all references to an asset with new extension
*/
private updateAssetReferences;
/**
* Create backup of assets before optimization
*/
private createBackup;
/**
* Remove unused assets safely
*/
removeUnusedAssets(createBackup?: boolean): Promise<{
removed: number;
savedSpace: number;
backupPath?: string;
}>;
/**
* Generate detailed audit report
*/
private generateReport;
/**
* Display audit results
*/
displayResults(): void;
private getAssetType;
private formatBytes;
get auditResults(): AuditResults;
get unusedAssets(): AssetInfo[];
get optimizableAssets(): AssetInfo[];
}
//# sourceMappingURL=optimizer.d.ts.map