/** * Blob URL Download Handler * * P1 - Handle downloads initiated via createObjectURL / URL.createObjectURL * * Supports: * - Detection of blob URL downloads * - Intercepting blob URL creation * - Capturing blob content * - Validating blob downloads * - Converting blobs to files * * @see https://developer.mozilla.org/en-US/docs/Web/API/URL/createObjectURL */ export interface BlobDownloadConfig { /** Directory to save blob downloads */ downloadDir?: string; /** Whether to capture blob content automatically */ captureContent?: boolean; /** Maximum blob size to capture (bytes) */ maxCaptureSize?: number; } export interface BlobDownloadInfo { /** Blob URL */ url: string; /** Blob ID (internal) */ blobId: string; /** MIME type */ mimeType: string; /** Size in bytes */ size: number; /** Content (if captured) */ content?: Buffer; /** Timestamp */ timestamp: number; /** Source element that triggered download */ source?: string; } export interface BlobDownloadResult { success: boolean; blob?: BlobDownloadInfo; error?: string; } /** * Blob URL Download Handler class */ export declare class BlobURLDownloadHandler { private downloads; private downloadDir; private captureContent; private maxCaptureSize; private stats; constructor(config?: BlobDownloadConfig); private ensureDownloadDir; /** * Setup blob URL interception on a page * Overrides URL.createObjectURL to capture blob creation */ setupBlobInterception(page: any): Promise; /** * Wait for blob URL creation matching a pattern */ waitForBlob(page: any, options?: { /** MIME type to match */ mimeType?: string | RegExp; /** Minimum size */ minSize?: number; /** Maximum size */ maxSize?: number; /** Timeout in ms */ timeout?: number; }): Promise; /** * Trigger a blob download by clicking an element */ clickAndWaitForBlob(page: any, selector: string, options?: { mimeType?: string | RegExp; timeout?: number; action?: 'click' | 'dblclick'; }): Promise; /** * Save a blob to a file */ saveBlob(blob: BlobDownloadInfo, filename?: string): Promise; /** * Get all captured blobs */ getAllBlobs(): BlobDownloadInfo[]; /** * Get blob by ID */ getBlob(blobId: string): BlobDownloadInfo | undefined; /** * Get the last blob */ getLastBlob(): BlobDownloadInfo | undefined; /** * Get all blobs by MIME type */ getBlobsByMimeType(mimeType: string | RegExp): BlobDownloadInfo[]; /** * Clear all captured blobs */ clearBlobs(): void; /** * Get file extension from MIME type */ private getExtension; /** * Get statistics */ getStats(): { totalBlobs: number; capturedBlobs: number; totalSize: number; averageSize: number; }; /** * Reset statistics */ resetStats(): void; /** * Get download directory */ getDownloadDir(): string; /** * Verify blob content */ verifyBlob(blob: BlobDownloadInfo, verification: { /** Expected content pattern */ contentPattern?: string | RegExp; /** Minimum size */ minSize?: number; /** Maximum size */ maxSize?: number; }): Promise<{ valid: boolean; errors: string[]; }>; } /** * Factory function to create Blob URL Download Handler */ export declare function createBlobURLDownloadHandler(config?: BlobDownloadConfig): BlobURLDownloadHandler; export default BlobURLDownloadHandler;