/** * @fileoverview Concrete loader for images. Exposes cache detection, aspect * ratio helpers, full control over the decode step, and advanced animation parsing. */ import TinyMediaLoader from '../TinyMediaLoader.mjs'; export type MediaEarlyDecoder = import('../TinyMediaLoader.mjs').MediaEarlyDecoder; export type AnimationFrame = { /** * - The Object URL of the single-frame blob. */ url: string; /** * - The unique key used in TinyMediaCache. */ cacheKey: string; }; export type AnimationScriptStep = { /** * - Duration of the frame in milliseconds. */ delay: number; }; export type ImageLoaderOptions = { /** * - The image source URL. */ src?: string; /** * - Maximum time in milliseconds before the load is aborted. */ timeout?: number; /** * - The CORS mode applied to the image. */ crossOrigin?: string | null; /** * - The decoding hint passed to the browser. */ decoding?: 'sync' | 'async' | 'auto'; /** * - An existing DOM element to adopt. */ element?: HTMLImageElement | null; /** * - Whether to decode the dimensions from the response headers using WebCodecs. */ earlyDecode?: boolean; /** * - Whether to show the image progressively while streaming (default true). */ progressive?: boolean; /** * - Whether an external `src` change triggers a reload. */ autoReload?: boolean; /** * - Whether to download the image through fetch for byte progress. */ stream?: boolean; /** * - Whether to perform a HEAD request to fetch HTTP headers before downloading. */ useHeadRequest?: boolean; /** * - The request body forwarded to the transport (ignored by `GET`/`HEAD`). */ body?: BodyInit; /** * - Whether concurrent loads of the same source share a single download (default true). */ mirror?: boolean; /** * - An optional shared memory cache. */ cache?: import('../utils/TinyMediaCache.mjs').default | null; /** * - How animated images are handled. */ animationControl?: 'none' | 'native' | 'script-only' | 'controlled'; }; /** * Loads a single image with full lifecycle and animation control. * @extends {TinyMediaLoader} */ declare class TinyImageLoader extends TinyMediaLoader { #private; /** * Retrieves the tag name used to create the underlying element. * @returns {string} The uppercase tag name, always `'IMG'`. */ static get tagName(): string; /** * Creates a new image loader and validates the provided options. * @param {ImageLoaderOptions} [options] - The loader configuration. * @throws {TypeError} If `crossOrigin` is not a string or null. * @throws {TypeError} If `decoding` is not a string. */ constructor(options?: ImageLoaderOptions); /** * The underlying `` element. * @returns {HTMLImageElement|null} The current image element, or `null` before the load starts. */ get image(): HTMLImageElement | null; /** * Indicates whether the image is downloaded through fetch for byte-level progress. * @returns {boolean} `true` when streaming is enabled, otherwise `false`. */ get stream(): boolean; /** * The intrinsic width of the image in pixels. * @returns {number} The intrinsic width in pixels. */ get naturalWidth(): number; /** * The intrinsic height of the image in pixels. * @returns {number} The intrinsic height in pixels. */ get naturalHeight(): number; /** * The aspect ratio of the image (width / height). * @returns {number} The width divided by the height, or 0 when unknown. */ get aspectRatio(): number; /** * Freezes the animation. In native mode, falls back to the static 1st frame blob. * @param {number|null} [frameIndex] - Frame index to freeze on (controlled mode only). */ freeze(frameIndex?: number | null): void; /** * Unfreezes and resumes the animation. */ unfreeze(): void; /** * Plays the animation (controlled mode only). */ play(): void; /** * Pauses the animation (controlled mode only). */ pause(): void; /** * Gets or sets the playback speed modifier. * @type {number} */ get playbackRate(): number; set playbackRate(value: number); /** * Gets a deep copy of the current animation script or replaces it to modify behavior. * @type {AnimationScriptStep[]} */ get animationScript(): AnimationScriptStep[]; /** * Replaces the animation script. * @param {AnimationScriptStep[]} script - The new script. * @throws {TypeError} If `script` is not an array of `{ delay: number }`. * @throws {Error} If the loader is not in controlled mode. */ set animationScript(script: AnimationScriptStep[]); /** * Resolves the target element, wires the load listeners and decodes the image. * @protected * @returns {Promise} A promise that resolves once the image is decoded and ready. */ protected _startLoad(): Promise; /** * Builds the metadata descriptor for the loaded image. * @protected * @returns {import('../TinyMediaLoader.mjs').MediaMetadataDetails} The image metadata details. */ protected _getMetadataDetails(): import('../TinyMediaLoader.mjs').MediaMetadataDetails; /** * Aborts the fetch gracefully allowing a retry process to spin up safely on the same element instance without * triggering stale asynchronous cache responses. * @protected * @returns {void} */ protected _abort(): void; /** * Releases all acquired animation frames from the cache or revokes their * object URLs. It also stops the playback loop, so a reload never leaves a * timer pointing at a frame that no longer exists. * @protected * @returns {void} */ protected _releaseAnimationFrames(): void; /** * Detaches the load handlers, revokes the object URL and clears the source of the image element. * @protected * @returns {void} This method does not return a value. */ protected _cleanup(): void; /** * Creates the `` element used by the loader. * @protected * @returns {HTMLImageElement} A new, detached image element. */ protected _createElement(): HTMLImageElement; } export default TinyImageLoader; //# sourceMappingURL=TinyImageLoader.d.mts.map