UNPKG

denfield-webp-hero

Version:

webp image format polyfill for browsers

37 lines (36 loc) 1.32 kB
import { WebpMachineOptions, PolyfillDocumentOptions, DetectWebpImage, DetectWebpBackground } from "./interfaces.js"; export declare class WebpMachineError extends Error { } export declare const defaultDetectWebpImage: DetectWebpImage; export declare const defaultDetectWebpBackground: DetectWebpBackground; /** * Webp Machine * - decode and polyfill webp images * - can only decode images one-at-a-time (otherwise will throw busy error) */ export declare class WebpMachine { private readonly webp; private readonly webpSupport; private readonly detectWebpImage; private readonly detectWebpBackground; private processing; private busy; private cache; constructor({ webp, webpSupport, detectWebpImage, detectWebpBackground }?: WebpMachineOptions); /** * Decode raw webp data into a png data url */ decode(webpData: Uint8Array): Promise<string>; /** * Polyfill the webp format on the given <img> element */ polyfillImage(image: HTMLImageElement): Promise<void>; /** * Polyfill the webp format on the given <div> element */ polyfillBackground(el: HTMLDivElement): Promise<void>; /** * Polyfill webp format on the entire web page */ polyfillDocument({ document, selectors, }?: PolyfillDocumentOptions): Promise<void>; }