import { fabric } from "fabric"; /** * Cleanup manager for tracking and disposing resources */ export declare class CleanupManager { private canvases; private timeouts; protected _animationFrames: Set; private eventListeners; /** Get animation frames set for external access */ get animationFrames(): Set; /** * Track a temporary canvas for cleanup */ trackCanvas(canvas: HTMLCanvasElement): void; /** * Track a timeout for cleanup */ trackTimeout(id: ReturnType): void; /** * Track an animation frame for cleanup */ trackAnimationFrame(id: number): void; /** * Track an event listener for cleanup */ trackEventListener(target: EventTarget, type: string, listener: EventListener, options?: boolean | AddEventListenerOptions): void; /** * Clear a specific timeout */ clearTrackedTimeout(id: ReturnType): void; /** * Cancel a specific animation frame */ cancelTrackedAnimationFrame(id: number): void; /** * Dispose a temporary canvas */ disposeCanvas(canvas: HTMLCanvasElement): void; /** * Cleanup all tracked resources */ cleanup(): void; } /** * Create a temporary canvas with cleanup tracking */ export declare function createTempCanvas(width: number, height: number, cleanup?: CleanupManager): { canvas: HTMLCanvasElement; ctx: CanvasRenderingContext2D | null; }; /** * Dispose a Fabric.js canvas properly */ export declare function disposeFabricCanvas(canvas: fabric.Canvas | null): void; /** * Remove all custom objects from canvas (keep original image) */ export declare function clearCanvasObjects(canvas: fabric.Canvas, keepOriginalImage?: boolean): void; /** * Debounce function with cleanup support */ export declare function createDebouncedFunction void>(func: T, wait: number, cleanup?: CleanupManager): { fn: (...args: Parameters) => void; cancel: () => void; }; /** * Throttle function with cleanup support */ export declare function createThrottledFunction void>(func: T, limit: number, cleanup?: CleanupManager): { fn: (...args: Parameters) => void; cancel: () => void; }; /** * Safe requestAnimationFrame with cleanup support */ export declare function safeRequestAnimationFrame(callback: FrameRequestCallback, cleanup?: CleanupManager): number; /** * Add event listener with automatic cleanup tracking */ export declare function addTrackedEventListener(target: Window, type: K, listener: (this: Window, ev: WindowEventMap[K]) => void, cleanup: CleanupManager, options?: boolean | AddEventListenerOptions): void; export declare function addTrackedEventListener(target: Document, type: K, listener: (this: Document, ev: DocumentEventMap[K]) => void, cleanup: CleanupManager, options?: boolean | AddEventListenerOptions): void; export declare function addTrackedEventListener(target: EventTarget, type: string, listener: EventListener, cleanup: CleanupManager, options?: boolean | AddEventListenerOptions): void;