//#region src/media/types.d.ts /** * Media Provider Types * * Media providers are pluggable sources for browsing, uploading, and embedding media. * They enable integration with external services (Unsplash, Cloudinary, Mux, etc.) * alongside the built-in local media library. */ /** * Serializable media provider configuration descriptor * Returned by provider config functions (e.g., unsplash(), mux()) */ interface MediaProviderDescriptor> { /** Unique identifier, used in MediaValue.provider */ id: string; /** Display name for admin UI */ name: string; /** Icon for tab UI (emoji or URL) */ icon?: string; /** Module path exporting createMediaProvider function */ entrypoint: string; /** Optional React component module for custom admin UI */ adminModule?: string; /** Capability flags determine UI behavior */ capabilities: MediaProviderCapabilities; /** Serializable config passed to createMediaProvider at runtime */ config: TConfig; } /** * Provider capabilities determine what UI elements to show */ interface MediaProviderCapabilities { /** Can list/browse media */ browse: boolean; /** Supports text search */ search: boolean; /** Can upload new media */ upload: boolean; /** Can delete media */ delete: boolean; } /** * Options for listing media */ interface MediaListOptions { /** Pagination cursor */ cursor?: string; /** Max items to return (default 20) */ limit?: number; /** Search query (if capabilities.search is true) */ query?: string; /** Filter by MIME type prefix, e.g., "image/", "video/" */ mimeType?: string; } /** * Result from listing media */ interface MediaListResult { items: MediaProviderItem[]; nextCursor?: string; } /** * A media item as returned by a provider * This is the provider's view of the item, before it's selected */ interface MediaProviderItem { /** Provider-specific ID */ id: string; /** Original filename */ filename: string; /** MIME type */ mimeType: string; /** File size in bytes (if known) */ size?: number; /** Dimensions (for images/video) */ width?: number; height?: number; /** LQIP blurhash placeholder (images only) */ blurhash?: string; /** LQIP dominant-color placeholder, as a CSS color (images only) */ dominantColor?: string; /** Accessibility text */ alt?: string; /** Preview URL for admin UI thumbnail */ previewUrl?: string; /** Provider-specific metadata */ meta?: Record; } /** * Input for uploading media */ interface MediaUploadInput { file: File; filename: string; alt?: string; } /** * Options for generating embed */ interface EmbedOptions { /** Desired width (provider may use for optimization) */ width?: number; /** Desired height */ height?: number; /** Image format preference */ format?: "webp" | "avif" | "jpeg" | "png" | "auto"; } /** * Embed result types */ type EmbedResult = ImageEmbed | VideoEmbed | AudioEmbed | ComponentEmbed; interface ImageEmbed { type: "image"; src: string; srcset?: string; sizes?: string; width?: number; height?: number; /** LQIP blurhash placeholder for rendering before the image loads */ blurhash?: string; /** LQIP dominant-color placeholder, as a CSS color */ dominantColor?: string; alt?: string; /** Base URL without transforms, for responsive image generation */ cdnBaseUrl?: string; /** For providers with URL-based transforms (Cloudinary, imgix) */ getSrc?: (opts: { width?: number; height?: number; format?: string; }) => string; } interface VideoEmbed { type: "video"; /** Single source URL */ src?: string; /** Multiple sources for format fallback */ sources?: Array<{ src: string; type: string; }>; /** Poster/thumbnail image */ poster?: string; width?: number; height?: number; /** Player controls */ controls?: boolean; autoplay?: boolean; muted?: boolean; loop?: boolean; playsinline?: boolean; preload?: "none" | "metadata" | "auto"; crossorigin?: "anonymous" | "use-credentials"; } interface AudioEmbed { type: "audio"; src?: string; sources?: Array<{ src: string; type: string; }>; controls?: boolean; autoplay?: boolean; muted?: boolean; loop?: boolean; preload?: "none" | "metadata" | "auto"; } interface ComponentEmbed { type: "component"; /** Package to import from, e.g., "@mux/player-react" */ package: string; /** Named export (default export if not specified) */ export?: string; /** Props to pass to the component */ props: Record; } /** * Options for thumbnail generation */ interface ThumbnailOptions { /** Desired width */ width?: number; /** Desired height */ height?: number; } /** * Runtime media provider interface * Implemented by provider entrypoints */ interface MediaProvider { /** * List/search media items */ list(options: MediaListOptions): Promise; /** * Get a single item by ID (optional, for refresh/validation) */ get?(id: string): Promise; /** * Upload new media (if capabilities.upload is true) */ upload?(input: MediaUploadInput): Promise; /** * Delete media (if capabilities.delete is true) */ delete?(id: string): Promise; /** * Get embed information for rendering this media item * Called at runtime when rendering content */ getEmbed(value: MediaValue, options?: EmbedOptions): Promise | EmbedResult; /** * Get a thumbnail URL for admin display * For images: returns a resized image URL * For videos: returns a poster/thumbnail URL */ getThumbnailUrl?(id: string, mimeType?: string, options?: ThumbnailOptions): string; } /** * Function signature for provider entrypoint modules */ type CreateMediaProviderFn> = (config: TConfig) => MediaProvider; /** * Media value stored in content fields * This is what gets persisted when media is selected * * For backwards compatibility: * - `provider` defaults to "local" if not specified * - `src` is supported for legacy data or external URLs */ interface MediaValue { /** Provider ID, e.g., "local", "unsplash", "mux" (defaults to "local") */ provider?: string; /** Provider-specific item ID */ id: string; /** Direct URL (for local media or legacy data) */ src?: string; /** Preview URL for admin display (external providers) */ previewUrl?: string; /** Cached metadata for display without runtime lookup */ filename?: string; mimeType?: string; width?: number; height?: number; /** Cached LQIP blurhash placeholder (images only) */ blurhash?: string; /** Cached LQIP dominant-color placeholder, as a CSS color (images only) */ dominantColor?: string; alt?: string; /** Provider-specific data needed for embedding */ meta?: Record; } /** * Convert a MediaProviderItem to a MediaValue for storage */ declare function mediaItemToValue(providerId: string, item: MediaProviderItem): MediaValue; //#endregion //#region src/media/normalize.d.ts /** * Normalize a media field value into a consistent MediaValue shape. * * - `null`/`undefined` → `null` * - Bare URL string → `{ provider: "external", id: "", src: url }` * - Bare internal media URL → resolved via local provider's `get()` * - Bare local media ID → resolved via local provider's `get()` * - Object with `provider` + `id` → enriched with missing fields from provider */ declare function normalizeMediaValue(value: unknown, getProvider: (id: string) => MediaProvider | undefined): Promise; //#endregion //#region src/media/placeholder.d.ts /** * Image Placeholder Generation * * Generates blurhash and dominant color from image buffers for LQIP support. * Decodes images via jpeg-js (pure JS) and upng-js (pure JS, uses pako for * deflate). No Node-specific dependencies — works in Workers and Node SSR. */ interface PlaceholderData { blurhash: string; dominantColor: string; } /** * Generate blurhash and dominant color from an image buffer. * Returns null for non-image MIME types or on failure. * * @param dimensions - Optional pre-known dimensions. When present they are * trusted verbatim (the caller has typically already read them via * readDimensions); otherwise dimensions are read from this buffer's header. * Generation is skipped (returns null) when no dimensions are available at * all, or when the decoded size (width * height * 4) exceeds * MAX_DECODED_BYTES — both guards avoid OOM from unbounded decodes on * memory-constrained runtimes. */ declare function generatePlaceholder(buffer: Uint8Array, mimeType: string, dimensions?: { width: number; height: number; }): Promise; //#endregion export { MediaValue as _, ComponentEmbed as a, mediaItemToValue as b, EmbedResult as c, MediaListResult as d, MediaProvider as f, MediaUploadInput as g, MediaProviderItem as h, AudioEmbed as i, ImageEmbed as l, MediaProviderDescriptor as m, generatePlaceholder as n, CreateMediaProviderFn as o, MediaProviderCapabilities as p, normalizeMediaValue as r, EmbedOptions as s, PlaceholderData as t, MediaListOptions as u, ThumbnailOptions as v, VideoEmbed as y }; //# sourceMappingURL=placeholder-CZAsZ2bK.d.mts.map