/** Typed Baked Motion failure and diagnostics contracts. */ /** Observable lifecycle state for one Baked Motion instance. */ export type BakedMotionState = 'loading' | 'admitting' | 'ready' | 'suspended' | 'failed' | 'disposed'; /** Stable failure codes exposed to hosts so poster/fallback policy never depends on messages. */ export type BakedMotionErrorCode = 'manifest-invalid' | 'network' | 'integrity' | 'resource-budget' | 'webcodecs-unavailable' | 'decoder-unsupported' | 'decoder-stalled' | 'gpu-upload' | 'aborted' | 'disposed'; /** Serializable subset of a WebCodecs configuration retained in diagnostics. */ export interface BakedMotionDecoderConfigDiagnostics { readonly codec: string; readonly codedWidth: number | null; readonly codedHeight: number | null; readonly hardwareAcceleration: HardwareAcceleration | null; readonly optimizeForLatency: boolean; } /** Stage at which one decoder candidate was rejected or accepted. */ export type BakedMotionDecoderAttemptStep = 'advisory' | 'configure' | 'first-decode' | 'watchdog' | 'accepted'; /** One immutable decoder admission attempt. */ export interface BakedMotionDecoderAttemptDiagnostics { readonly stream: string; readonly config: BakedMotionDecoderConfigDiagnostics; readonly advisoryApproved: boolean; readonly step: BakedMotionDecoderAttemptStep; readonly errorName: string | null; readonly errorMessage: string | null; } /** Transport a fetched track actually negotiated; `'unknown'` until its first request settles. */ export type BakedMotionTrackTransport = 'unknown' | 'range' | 'full'; /** Per-track delivery attribution for the selected rendition's media resources. */ export interface BakedMotionTrackDeliveryDiagnostics { /** Configured delivery: whole-file `'full'`, indexed `'segments'`, or `'skipped'` (depth opt-out). */ readonly mode: 'full' | 'segments' | 'skipped'; /** Transport the fetch actually used (a segment source may fall back to whole-file). */ readonly transport: BakedMotionTrackTransport; readonly requestCount: number; /** Encoded bytes received from the network so far. */ readonly fetchedBytes: number; /** Bytes that passed SHA-256 verification so far. */ readonly verifiedBytes: number; } /** Network/cache counters accumulated locally for one Baked Motion instance. */ export interface BakedMotionNetworkDiagnostics { readonly mode: 'full' | 'segments' | null; readonly requestedBytes: number; readonly verifiedBytes: number; readonly probeBytes: number; readonly cacheBytes: number; readonly requestCount: number; /** Live per-track delivery mode and byte counters for the selected rendition's tracks. */ readonly delivery: { readonly albedo: BakedMotionTrackDeliveryDiagnostics | null; readonly depth: BakedMotionTrackDeliveryDiagnostics | null; }; } /** Scrub-scheduler measurements accumulated locally for one Baked Motion instance. */ export interface BakedMotionScrubDiagnostics { readonly decodeUploadMs: number | null; readonly freshCornerLatencyMs: number | null; readonly incompleteBlendMs: number; } /** Per-channel attribution for decoded-frame GPU luma uploads and CPU copies. */ export interface BakedMotionUploadChannelDiagnostics { readonly gpuLumaUploads: number; readonly cpuCopyToCalls: number; readonly cpuCopyToTotalMs: number; readonly cpuCopyToMaxMs: number; } /** Upload/copy attribution for one decoded Baked Motion track. */ export interface BakedMotionUploadTrackDiagnostics { readonly color: BakedMotionUploadChannelDiagnostics; readonly alpha: BakedMotionUploadChannelDiagnostics; } /** Point-in-time upload/copy attribution for the semantic Baked Motion tracks. */ export interface BakedMotionUploadDiagnostics { readonly albedo: BakedMotionUploadTrackDiagnostics | null; readonly depth: BakedMotionUploadTrackDiagnostics | null; } /** Codec-activity counters accumulated by one decoded track's playback decoders. */ export interface BakedMotionPlaybackDecoderDiagnostics { /** Post-admission codec resets (each one abandons queued decode work). */ readonly resets: number; /** Requests appended to the live codec's forward run without a reset. */ readonly forwardExtensions: number; /** Frames that emerged from the codec, including GOP-walk frames. */ readonly decodedFrames: number; /** Delivered frames dropped by the monotonic forward-playback presentation guard. */ readonly droppedLateFrames: number; } /** Forward-playback presentation facts for one decoded Baked Motion track. */ export interface BakedMotionPlaybackTrackDiagnostics { /** Last frame id whose pixels were published to a presentation slot. */ readonly presentedFrame: number | null; /** Requested nearest frame minus the presented frame — the visible decode lag. */ readonly presentationLagFrames: number | null; readonly decoder: BakedMotionPlaybackDecoderDiagnostics; } /** Point-in-time playback presentation facts for the semantic Baked Motion tracks. */ export interface BakedMotionPlaybackDiagnostics { readonly albedo: BakedMotionPlaybackTrackDiagnostics | null; readonly depth: BakedMotionPlaybackTrackDiagnostics | null; } /** Decoded-view residency retained at each quality tier. */ export interface BakedMotionResidencyDiagnostics { /** Full-resolution decoded-view GPU LRU shared by interactive sampling. */ readonly cache: { readonly resident: number; readonly capacity: number; readonly hits: number; readonly misses: number; }; /** Full-resolution views currently assigned to presentation slots. */ readonly fresh: { readonly resident: number; readonly total: number; }; } /** Selected media representation and its actual owned GPU destinations. */ export interface BakedMotionRepresentationDiagnostics { readonly alphaStorage: 'opaque' | 'spatial' | 'separate' | null; readonly codedSizes: { readonly albedo: { readonly width: number; readonly height: number; } | null; readonly alpha: { readonly width: number; readonly height: number; } | null; readonly depth: { readonly width: number; readonly height: number; } | null; }; readonly destinations: { readonly albedo: BakedMotionTextureDestinationDiagnostics | null; readonly alpha: BakedMotionTextureDestinationDiagnostics | null; readonly depth: BakedMotionTextureDestinationDiagnostics | null; }; /** Decoded-view array caches and coarse textures; excludes upload slots, warp targets, and decoder-private surfaces. */ readonly ownedResidentBytes: number; readonly logicalUploadedBytes: number; readonly copyCounts: { readonly copyExternalImageToTexture: number; readonly copyTextureToTexture: number; readonly videoFrameCopyTo: number; }; } /** One actual owned decoded-texture allocation. */ export interface BakedMotionTextureDestinationDiagnostics { readonly format: 'rgba8unorm' | 'r8unorm'; readonly width: number; readonly height: number; readonly layers: number; readonly bytesPerLayer: number; readonly residentBytes: number; } /** Immutable local-only diagnostic snapshot. */ export interface BakedMotionDiagnostics { readonly state: BakedMotionState; readonly attemptedRenditions: readonly string[]; readonly selectedRendition: string | null; readonly network: BakedMotionNetworkDiagnostics; readonly decoderAttempts: readonly BakedMotionDecoderAttemptDiagnostics[]; readonly decoderCount: number; /** * Coarse-atlas state: `null` when the package ships none, `'ready'` once decoded, otherwise the * reason it could not be used. A failed floor is never fatal — presentation falls back to the * bare decode path — so this is the only place that failure is visible. */ readonly coarseFloor: 'ready' | null | string; readonly decoderHighWater: number; readonly videoFrameCount: number; readonly videoFrameHighWater: number; readonly groupAttempts: number; readonly sampleGeneration: number; readonly residentSlots: number; readonly representation: BakedMotionRepresentationDiagnostics; readonly residency: BakedMotionResidencyDiagnostics; readonly scrub: BakedMotionScrubDiagnostics; readonly uploads: BakedMotionUploadDiagnostics; readonly playback: BakedMotionPlaybackDiagnostics; readonly fallbackReason: string | null; readonly terminalErrorCode: BakedMotionErrorCode | null; } /** Clone and deeply freeze a diagnostics value before it crosses the public boundary. */ export declare function freezeBakedMotionDiagnostics(diagnostics: BakedMotionDiagnostics): Readonly; /** Stable Baked Motion failure carrying a point-in-time immutable diagnostic snapshot. */ export declare class BakedMotionError extends Error { /** Stable machine-readable failure category. */ readonly code: BakedMotionErrorCode; /** Immutable runtime state captured when the failure occurred. */ readonly diagnostics: Readonly; /** Optional underlying error or rejected value. */ readonly cause?: unknown; /** Create a typed Baked Motion failure with an immutable diagnostic snapshot. */ constructor(code: BakedMotionErrorCode, message: string, diagnostics: BakedMotionDiagnostics, options?: { cause?: unknown; }); }