/** * The pure attribute builder shared by every adapter `` - turns image props into CLS-safe, * responsive `` attributes (`src`/`srcSet`/`sizes`/`width`/`height`/`loading`/`decoding`/ * `fetchpriority`). The actual resize is delegated to an {@link ImageLoader} (a URL builder) - nifra * bundles no codec; point the loader at your image CDN. */ /** Builds a variant URL for `src` at a target pixel `width` (and optional `quality`). */ export type ImageLoader = (args: { src: string; width: number; quality?: number; }) => string; /** Default loader: return the source unchanged (no transform). Use when there's no image CDN - you * still get CLS-safe sizing + lazy loading, just no responsive variants. */ export declare const identityLoader: ImageLoader; export interface CloudflareLoaderOptions { /** Prefix for the source (e.g. an absolute origin) when `src` is a bare path. Default: none. */ readonly base?: string; } /** * Cloudflare Images loader - builds `/cdn-cgi/image//` URLs that the Cloudflare edge * resizes on the fly (also emits `format=auto` for webp/avif negotiation). Works on Cloudflare Pages / * Workers with Images enabled. */ export declare function cloudflareLoader(options?: CloudflareLoaderOptions): ImageLoader; export interface SelfHostedLoaderOptions { /** Path/URL where `createImageHandler` (`@nifrajs/image/server`) is mounted, e.g. `"/_image"`. */ readonly endpoint: string; /** * HMAC secret for **signed URLs**. When set, each URL gets a stable `&s=` signature and the handler * must be configured with the SAME `signing.secret` - it then rejects any unsigned/forged `(src, w, q)`, * shutting down resize-bombing. ⚠️ The signer holds the secret, so a loader created with it is * **server-only** - inject it like a session secret (from `env`), never import this config into a * route/client module. Signatures are stable (no expiry), so SSR-signed URLs hydrate + cache identically. */ readonly secret?: string; } /** * Loader for nifra's **self-hosted** resize endpoint (`createImageHandler` from `@nifrajs/image/server`, * backed by `Bun.Image`/sharp/WASM). Builds `?src=…&w=…[&q=…][&s=…]` (the endpoint negotiates * the output format). Pure + dependency-free. For runtimes without a native codec, pair the endpoint * with `wasmImageBackend`, or use the CDN `cloudflareLoader` instead. */ export declare function selfHostedLoader(options: SelfHostedLoaderOptions): ImageLoader; export interface SignImageUrlOptions { /** HMAC secret - must match the handler's `signing.secret`. */ readonly secret: string; /** Seconds until the URL expires (adds `&exp=`). Omit for a stable, cacheable-forever signed URL. */ readonly expiresIn?: number; } /** * Mint a **signed** self-hosted image URL on the server - for cases the (stable) `selfHostedLoader` * doesn't cover, chiefly **time-limited** access (`expiresIn`) to private images. Server-only (it holds * the secret). Pair with a passthrough loader, or use the signed string as a plain `src`. * * ```ts * const url = signImageUrl("/_image", { src: "/private/a.jpg", width: 800 }, { secret, expiresIn: 300 }) * ``` */ export declare function signImageUrl(endpoint: string, image: { src: string; width: number; quality?: number; }, options: SignImageUrlOptions): string; export interface ImageProps { readonly src: string; /** Intrinsic width (px) - **required**, reserves layout space (no CLS). */ readonly width: number; /** Intrinsic height (px) - **required** (no CLS). */ readonly height: number; /** Alt text - **required** for accessibility (use `alt=""` for decorative images). */ readonly alt: string; /** `sizes` attribute for responsive selection (e.g. `"(max-width: 600px) 100vw, 600px"`). */ readonly sizes?: string; /** Widths to generate `srcSet` entries for. Default: `[width, width*2]` (1×/2× retina). */ readonly widths?: readonly number[]; /** Quality passed to the loader. */ readonly quality?: number; /** `lazy` (default) or `eager`. `priority` overrides this to eager. */ readonly loading?: "lazy" | "eager"; /** Mark the LCP image: `loading="eager"` + `fetchpriority="high"`. */ readonly priority?: boolean; } export interface ResolvedImage { readonly src: string; readonly srcSet?: string; readonly sizes?: string; readonly width: number; readonly height: number; readonly alt: string; readonly loading: "lazy" | "eager"; readonly decoding: "async"; readonly fetchPriority?: "high"; } /** * Resolve {@link ImageProps} + an {@link ImageLoader} into `` attributes. CLS-safe (`width`/ * `height` required + > 0, else a dev error), lazy + async-decoding by default, with a responsive * `srcSet` built from `widths` via the loader. If every width produces the same URL (e.g. * {@link identityLoader}), `srcSet` is omitted (it'd be redundant). */ export declare function resolveImage(props: ImageProps, loader?: ImageLoader): ResolvedImage; //# sourceMappingURL=resolve.d.ts.map