/** * Rich inline embed-player detection. * * Ported from Bluesky's `src/lib/strings/embed-player.ts` and adapted to the * gitgram-web stack: this is a pure, framework-agnostic URL -> embed mapping * with no React Native / iframe-host dependencies. Given an arbitrary URL it * returns the parameters needed to render an inline player (YouTube, YouTube * Shorts, Twitch, Spotify, Vimeo, SoundCloud, Apple Music, Giphy) or * `undefined` when the URL is not a recognised media provider. * * The detection is intentionally a flat, well-tested table of host/path rules * so new providers can be added without touching the rendering layer. */ export const embedPlayerSources = [ 'youtube', 'youtubeShorts', 'twitch', 'spotify', 'soundcloud', 'appleMusic', 'vimeo', 'giphy', ] as const export type EmbedPlayerSource = (typeof embedPlayerSources)[number] export type EmbedPlayerType = | 'youtube_video' | 'youtube_short' | 'twitch_video' | 'spotify_album' | 'spotify_playlist' | 'spotify_song' | 'soundcloud_track' | 'soundcloud_set' | 'apple_music_playlist' | 'apple_music_album' | 'apple_music_song' | 'vimeo_video' | 'giphy_gif' /** Human-readable provider labels, used for accessibility / fallbacks. */ export const EMBED_PLAYER_LABELS: Record = { youtube: 'YouTube', youtubeShorts: 'YouTube Shorts', vimeo: 'Vimeo', twitch: 'Twitch', giphy: 'GIPHY', spotify: 'Spotify', appleMusic: 'Apple Music', soundcloud: 'SoundCloud', } export interface EmbedPlayerParams { type: EmbedPlayerType /** The iframe / image `src` to render. */ playerUri: string source: EmbedPlayerSource /** GIFs render as `` rather than `