/** * @squoosh-kit/avif public API */ import type { ImageInput } from '@squoosh-kit/runtime'; import { type BridgeOptions } from './bridge'; import type { AvifEncodeOptions } from './types'; export declare const AVIFTune: { readonly auto: 0; readonly psnr: 1; readonly ssim: 2; }; export type AVIFTune = (typeof AVIFTune)[keyof typeof AVIFTune]; export type { ImageInput, AvifEncodeOptions }; /** * A reusable AVIF encoder that can be terminated to clean up resources. */ export type AvifEncoderFactory = ((imageData: ImageInput, options?: AvifEncodeOptions, signal?: AbortSignal) => Promise) & { /** * Terminates the encoder and cleans up resources. * Important for worker mode to prevent memory leaks. * * @example * const encoder = createAvifEncoder('worker'); * try { * const result = await encoder(imageData, options); * } finally { * await encoder.terminate(); * } */ terminate(): Promise; }; /** * A reusable AVIF decoder that can be terminated to clean up resources. */ export type AvifDecoderFactory = ((data: BufferSource, signal?: AbortSignal) => Promise) & { /** * Terminates the decoder and cleans up resources. * Important for worker mode to prevent memory leaks. */ terminate(): Promise; }; /** * Encodes an image to AVIF format. Uses worker mode for UI responsiveness. * * @param imageData - The image data to encode. * @param options - AVIF encoding options. * @param signal - (Optional) AbortSignal to cancel the encoding operation. * @returns A Promise resolving to the encoded AVIF data as a Uint8Array. * * @example * const controller = new AbortController(); * const result = await encode(imageData, { quality: 60 }, controller.signal); */ export declare function encode(imageData: ImageInput, options?: AvifEncodeOptions, signal?: AbortSignal): Promise; /** * Decodes AVIF data to ImageData. Uses worker mode for UI responsiveness. * * @param data - The AVIF binary data to decode. * @param signal - (Optional) AbortSignal to cancel the decoding operation. * @returns A Promise resolving to the decoded ImageData. */ export declare function decode(data: BufferSource, signal?: AbortSignal): Promise; /** * Creates a reusable AVIF encoder function for a specific execution mode. * * @param mode - The execution mode, either 'worker' or 'client'. * @param options - Optional bridge configuration options. * @returns A function that encodes an image to AVIF format with optional AbortSignal. */ export declare function createAvifEncoder(mode?: 'worker' | 'client', options?: BridgeOptions): AvifEncoderFactory; /** * Creates a reusable AVIF decoder function for a specific execution mode. * * @param mode - The execution mode, either 'worker' or 'client'. * @param options - Optional bridge configuration options. * @returns A function that decodes AVIF data to ImageData with optional AbortSignal. */ export declare function createAvifDecoder(mode?: 'worker' | 'client', options?: BridgeOptions): AvifDecoderFactory; //# sourceMappingURL=index.d.ts.map