import type { ImageFormat } from "./index.js"; export interface ImageVariant { /** URL path relative to the site root, e.g. "/images/hero.abc123def456.800w.webp". */ url: string; /** Width in pixels. */ width: number; /** Height in pixels (preserves aspect ratio). */ height: number; /** Format of the variant. */ format: ImageFormat; /** File size in bytes. */ size: number; } export interface ImageEntry { /** Original source URL, e.g. "/images/hero.jpg". */ src: string; /** Intrinsic width of the source. */ width: number; /** Intrinsic height of the source. */ height: number; /** All generated variants. */ variants: ImageVariant[]; /** Content hash of the source file. */ hash: string; } export interface ImageManifest { version: 1; entries: Record; } export interface ProcessOptions { /** Absolute path to the public directory (source images). */ publicDir: string; /** Absolute path to the output directory. */ outDir: string; /** Formats to generate. Defaults to ["webp", "avif"]. */ formats?: ImageFormat[]; /** Quality (1-100). Defaults to 80. */ quality?: number; /** Path to write the manifest JSON. */ manifestPath?: string; /** When true, missing sources or failed transforms fail the build. */ strict?: boolean; /** Max concurrent sharp transforms. Defaults to 4. */ concurrency?: number; /** Optional URL base prefix applied to variant URLs. */ base?: string; } export interface ProcessResult { manifest: ImageManifest; /** Number of variants generated. */ count: number; /** Whether sharp was available. */ optimized: boolean; } export declare function isSharpAvailable(): Promise; /** * SHA-256 transform key. Stable for identical content+options and invalidated * whenever the source bytes, the effective transform options, the encoder * version or the naming scheme change. */ export declare function transformHash(sourceBuffer: Buffer, width: number, format: ImageFormat, quality: number): string; export interface ImageRequest { src: string; alt: string; widths?: readonly number[]; formats?: readonly ImageFormat[]; sizes?: string; width?: number; height?: number; priority?: boolean; loading?: "lazy" | "eager"; decoding?: "async" | "sync" | "auto"; quality?: number; fit?: string; class?: string; attributes?: Record; } export interface GeneratedImage { url: string; width: number; height: number; format: ImageFormat; size: number; } export interface ImageMetadata { src: string; width?: number; height?: number; sources: Array<{ type: string; srcset: string; }>; attributes: Record; generated: readonly GeneratedImage[]; } export interface ImageServiceContext { publicDir: string; outDir: string; manifest: ImageManifest; } export interface ImageServiceCapabilities { /** Whether the encoder (sharp) is available. */ encoding: boolean; /** Whether remote images can be fetched. */ remote: boolean; /** Whether a runtime image endpoint exists. */ runtimeEndpoint: boolean; /** Whether the host exposes a writable filesystem. */ filesystem: boolean; } export interface ImageService { resolve(request: ImageRequest, context: ImageServiceContext): Promise; capabilities: ImageServiceCapabilities; } /** * Creates a build-time ImageService bound to a public/output directory pair. */ export declare function createImageService(options: ProcessOptions): ImageService; /** * Programmatic async image API (ยง3.1). Ensures the requested variants exist on * disk (build-time), then returns deterministic metadata (not opaque markup). */ export declare function getImage(request: ImageRequest, options: ProcessOptions): Promise; export declare function processImageBatch(images: { src: string; widths: number[]; formats?: ImageFormat[]; }[], options: ProcessOptions): Promise; /** * Read a manifest from disk, or return an empty one if it doesn't exist. */ export declare function readManifest(path: string): Promise; /** * Write a manifest to disk atomically. */ export declare function writeManifest(path: string, manifest: ImageManifest): Promise; /** * Look up an image entry in the manifest by its source URL. */ export declare function getManifestEntry(manifest: ImageManifest, src: string): ImageEntry | undefined; /** * Build a srcset string from manifest variants of a given format. * Returns e.g. "/images/hero.abc.400w.webp 400w, /images/hero.abc.800w.webp 800w". */ export declare function buildSrcset(entry: ImageEntry, format: ImageFormat): string; /** * Build the full markup for an image entry, with per format * and a fallback . */ export declare function buildPictureMarkup(entry: ImageEntry, opts: { alt: string; sizes?: string; priority?: boolean; class?: string; attributes?: Record; fallbackSrc?: string; fallbackWidth?: number; fallbackHeight?: number; }): string; /** * Validate that every variant URL in the manifest corresponds to a real file * in the output directory. Returns a list of missing URLs. */ export declare function validateManifestUrls(manifest: ImageManifest, outDir: string): Promise;