/** * `` — drop-in component for displaying Aithos-hosted * binary content with the simplest possible API: * * * * * * Download my CV (PDF) * * * The component handles the full lifecycle: * - Fetch + decrypt via the assets client (from context or `client` prop). * - Show `fallback` while loading. * - Show `errorFallback` (or alt text in img-mode) on failure. * - Revoke the `blob:` URL on unmount or URN change. * * For public assets attached to the Ethos public zone, you can also * just use the stable CloudFront URL directly (``). * This component is meant for private regime assets that require * client-side decryption. */ import type { ReactNode, ImgHTMLAttributes, VideoHTMLAttributes, AudioHTMLAttributes, AnchorHTMLAttributes } from "react"; import type { AssetsClient } from "../assets.js"; interface AithosAssetBaseProps { /** Asset URN, e.g. `urn:aithos:asset:did:aithos:z6Mkr…:asset_01J…`. */ readonly urn: string; /** Override the assets client from context. */ readonly client?: AssetsClient | null; /** Rendered while the fetch+decrypt is in flight. */ readonly fallback?: ReactNode; /** Rendered on fetch/decrypt failure. `as="img"` defaults to showing alt instead. */ readonly errorFallback?: ReactNode; /** Called once the asset is decrypted and ready to display. */ readonly onLoad?: () => void; /** Called when the fetch/decrypt fails. */ readonly onError?: (err: Error) => void; /** * If `true`, keep the previous asset visible while a new URN is * being fetched, instead of flashing the fallback. Default `false`. */ readonly keepPreviousOnUrnChange?: boolean; } export interface AithosImageProps extends AithosAssetBaseProps, Omit, "src" | "onLoad" | "onError"> { readonly as?: "img"; } export interface AithosVideoProps extends AithosAssetBaseProps, Omit, "src" | "onLoad" | "onError"> { readonly as: "video"; } export interface AithosAudioProps extends AithosAssetBaseProps, Omit, "src" | "onLoad" | "onError"> { readonly as: "audio"; } export interface AithosDownloadProps extends AithosAssetBaseProps, Omit, "href" | "onLoad" | "onError"> { readonly as: "download"; /** Suggested filename in the browser's download dialog. */ readonly filename?: string; readonly children?: ReactNode; } export type AithosAssetProps = AithosImageProps | AithosVideoProps | AithosAudioProps | AithosDownloadProps; /** * One component, four media kinds. The `as` prop selects between * `` (default), `