UNPKG

ranui

Version:

A framework-agnostic Web Components UI library built on native custom elements, with TypeScript types, light/dark theming, SSR and PWA support.

37 lines (36 loc) 1.86 kB
/** * Thumbnail scrubbing preview — parses a WebVTT sprite-sheet manifest, the * same convention YouTube/Video.js use: a cue's text is * `spritesheet.jpg#xywh=x,y,w,h` (`docs/PLAYER_ROADMAP.md` Phase 3). Cue * *timing* parsing is generic enough to live in `ranuts/utils` * (`parseVttCueTiming`/`parseVttTimestamp`) — the sprite-rect fragment below * is the only genuinely player-specific parsing left. */ export interface ThumbnailCue { start: number; end: number; url: string; x: number; y: number; w: number; h: number; } /** * Parses a WebVTT sprite-sheet manifest into thumbnail cues, resolving each * cue's image reference against `baseUrl` (the VTT file's own URL, so * relative sprite paths work). Malformed cues are skipped, never thrown — * the caller treats this as a best-effort enhancement. Result is sorted by * `start` (VTT files are normally authored in order already). */ export declare function parseThumbnailVtt(vttText: string, baseUrl: string): ThumbnailCue[]; /** * Finds the cue covering `time` (seconds) — the last cue whose `start` is * `<= time`, falling back to the first cue for anything before it (matches * how a scrub before the first cue should still show *a* thumbnail rather * than none). Assumes `cues` is sorted, as `parseThumbnailVtt` returns it. */ export declare function findThumbnailCue(cues: ThumbnailCue[], time: number): ThumbnailCue | undefined; /** Fetches and parses a thumbnail VTT manifest. Never throws — resolves to `[]` on any network/parse failure. */ export declare function loadThumbnailCues(url: string): Promise<ThumbnailCue[]>; /** Renders (or hides, when `cue` is `undefined`) a cropped sprite thumbnail into `el` via `background-position`. */ export declare function applyThumbnailPreview(el: HTMLElement, cue: ThumbnailCue | undefined): void;