Skip to content
This repository was archived by the owner on Oct 21, 2026. It is now read-only.

feat(packages): add media type guards - #3062

Closed
mihar-22 wants to merge 12 commits into
mainfrom
t3code/media-type-guards
Closed

mihar-22 wants to merge 12 commits into
mainfrom
t3code/media-type-guards

Conversation

@mihar-22

@mihar-22 mihar-22 commented Sep 29, 2026 •

Copy link
Copy Markdown
Member

Closes videojs/video.js#9467
Stacked on #3024

Summary

useMedia() types its media generically, because it doesn't know which component you rendered, so reading engine means guessing at its shape. This adds a type guard for every public media, which narrows the media, and with it engine, to that media's type:

import { useMedia } from '@videojs/react';
import { isHlsJsAdapter } from '@videojs/react/media/hlsjs-video';

const media = useMedia();
const engine = isHlsJsAdapter(media) ? media.engine : null; // Hls | null

Each guard lives in the package that owns its adapter, and the React and HTML /media/* entry points re-export it next to the component or element.

Changes

  • @videojs/media adds MEDIA_BRANDS, a global-symbol key under which a media class lists the brands it answers to, and isBrandedMedia(value, brand), which the per-media guards build on. A brand is the import path of the class, such as '@videojs/hlsjs-video'. isBrandedMedia checks the value itself, which is what React's useMedia() returns, or its adapter, which is what a custom media element wraps in HTML.
  • Sixteen guards, one per entry point that exports an adapter:
    • isHlsJsAdapter, isNativeHlsAdapter, isDashAdapter, isShakaAdapter;
    • isHlsVideoAdapter, isHlsAudioAdapter, isHlsBackgroundVideoAdapter in @videojs/spf;
    • isMuxVideoAdapter and isMuxAudioAdapter, from both @videojs/mux-* and @videojs/mux-*/spf;
    • isYouTubeAdapter, isVimeoAdapter, isWistiaAdapter, isCloudflareAdapter, isSpotifyAdapter, isTikTokAdapter, isTwitchAdapter.
  • Brands follow the import path. Mux over hls.js also answers to isHlsJsAdapter, and Mux over SPF to isHlsVideoAdapter or isHlsAudioAdapter. Each Mux flavor's own guard recognizes only that flavor, so the guard from /hls-js narrows engine to hls.js.
  • Mux audio over hls.js isn't Mux video. It extends MuxVideoAdapter (the TODO in mux-audio already calls that upside down), so its class lists its brands explicitly and drops Mux video's. @videojs/mux-audio now depends on @videojs/media directly for the key.
  • Server entries. dash-video and wistia-video resolve to an inert stub outside the browser; the stubs carry the brand and export the guard, so a server import finds the same names.
  • Docs. The media sources guide gets a "Reach the running engine" section with a guard table for React and HTML. The Mux Player guide's engine snippet uses isMuxVideoAdapter, and the Media Chrome and Video.js 8 guides link to the new section.
Why brands and not `instanceof`
  • HTML elements aren't adapters. <hlsjs-video> proxies its adapter's members and exposes it as adapter, so instanceof HlsJsAdapter is false for the element the player registers.
  • Bundle cost. instanceof needs the class at runtime, so asking "is this hls.js?" would pull in hls.js. Each guard module imports its adapter as a type only. Bundling just isHlsJsAdapter or isDashAdapter from the package root came to about 330 bytes with both esbuild and Rolldown, with no engine code. I didn't measure webpack; the adapter packages don't declare sideEffects.
  • Duplicate copies. A global-symbol key with string brands still matches when an app bundles two copies of a package.
  • Inheritance. With instanceof, Mux audio over hls.js would count as Mux video.

For review

  • Names. Each guard is named for the adapter class it narrows to, such as isHlsJsAdapter for HlsJsAdapter. isHlsBackgroundVideoAdapter covers HlsBackgroundVideo and its MuxBackgroundVideo alias, which share one adapter.
  • Background video in HTML. <hls-background-video> and <mux-background-video> keep their adapter private and register it, not themselves, as the player's media. The guard recognizes what the player holds, not the element, and the element doesn't expose engine anyway. The HTML table in the guide leaves them out.

Testing

  • New tests/predicate.test.ts in every adapter package and in @videojs/spf's three adapters. They cover the adapter, rejection of other media, a custom media element built on the adapter (hls.js), a subclassed Wistia element, and each Mux flavor's identities.
  • isBrandedMedia tests in @videojs/media: subclass inheritance, a subclass dropping a brand, the element look-through, a second copy of the key, and unbranded values.
  • React: HlsJsVideo and MuxVideo create media their guards recognize. HTML: <hlsjs-video>, <hls-video>, and both background video tags, through the @videojs/html/media/* entries.
  • Full suites pass for media, spf, all 13 adapter packages, react, and html. One HTML poster test failed under the full parallel run and passed on its own.
  • pnpm typecheck and pnpm check:workspace pass.
  • The guide's React and HTML snippets and the Mux Player snippet typecheck against the built packages.
  • pnpm build:site passes.

🤖 Generated with Claude Code

The YouTube, Vimeo, Wistia, Cloudflare, Spotify, TikTok, and Twitch URL
parsers were pure string functions, but each lived beside its adapter class,
so nothing outside the adapter could use them without importing the whole
embed. They now live in @videojs/media, which every adapter already depends
on, and each adapter imports them and re-exports them under the same names.

The parser tests move with them.
Picks the kind of media that plays a source URL, so apps can choose between
media components the way Vidstack's provider did:

- YouTube, Vimeo, Wistia, Mux, Cloudflare Stream, Spotify, TikTok, and
  Twitch, matched by host;
- HLS and DASH manifests and video and audio files, matched by MIME type
  when one is passed, then by file extension.

Bare ids return null, because an 11-character YouTube id and a 10-character
Wistia id look alike. Vidstack's youtube/<id> and vimeo/<id> shorthands expand
to URLs the matching media accepts. YouTube expands to the nocookie host,
which is the host Vidstack played them from.

Refs #2160
…eojs/html

Apps depend on the framework packages, not on @videojs/media, so importing
detectMediaSource from @videojs/media would fail under pnpm's strict
dependency resolution. Both packages now re-export it with its
DetectedMediaSource and MediaSourceKind types.
The builder scans the media source module as a framework-neutral entry point,
since framework scans skip exports owned by other packages. The page maps
each kind to its media component for React and HTML and covers MIME types,
bare ids, and the Vidstack shorthands.
MediaSource is the Media Source Extensions API, and SPF already exports
supportsMediaSource, createMediaSource, and attachMediaSource for it, so
detectMediaSource read like MSE feature detection. The types follow:
DetectedSource and SourceKind. The reference page moves to
reference/api/detect-source.
A media class lists the brands it answers to under MEDIA_BRANDS, a global
symbol, and isBrandedMedia checks a value or the adapter a custom media
element wraps. Brands are import paths, so they still match across two
bundled copies of a package.
Each adapter class carries its brand, and a guard beside it narrows media
to that adapter, which types its engine. Mux flavors are branded per
import path and also carry their engine's brand; Mux audio over hls.js
drops the Mux video brand it would otherwise inherit.
Each @videojs/react/media and @videojs/html/media entry exports the guard
for the media it provides, so apps import it next to the component or
element, including media that ship inside the framework packages.
The media sources guide gets a section on engine access with a guard per
media, and the Mux Player, Media Chrome, and Video.js 8 guides point to it.
@vercel

vercel Bot commented Sep 29, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
v10-sandbox Ready Ready Preview Sep 30, 2026 5:15am UTC

Request Review

@pkg-pr-new

pkg-pr-new Bot commented Sep 29, 2026 •

Copy link
Copy Markdown
@videojs/cdn

pnpm add https://pkg.pr.new/@videojs/cdn@3062

@videojs/cli

pnpm add https://pkg.pr.new/@videojs/cli@3062

@videojs/core

pnpm add https://pkg.pr.new/@videojs/core@3062

@videojs/element

pnpm add https://pkg.pr.new/@videojs/element@3062

@videojs/html

pnpm add https://pkg.pr.new/@videojs/html@3062

@videojs/media

pnpm add https://pkg.pr.new/@videojs/media@3062

@videojs/react

pnpm add https://pkg.pr.new/@videojs/react@3062

@videojs/spf

pnpm add https://pkg.pr.new/@videojs/spf@3062

@videojs/store

pnpm add https://pkg.pr.new/@videojs/store@3062

@videojs/utils

pnpm add https://pkg.pr.new/@videojs/utils@3062

@videojs/cloudflare-video

pnpm add https://pkg.pr.new/@videojs/cloudflare-video@3062

@videojs/dash-video

pnpm add https://pkg.pr.new/@videojs/dash-video@3062

@videojs/hlsjs-video

pnpm add https://pkg.pr.new/@videojs/hlsjs-video@3062

@videojs/mux-audio

pnpm add https://pkg.pr.new/@videojs/mux-audio@3062

@videojs/mux-video

pnpm add https://pkg.pr.new/@videojs/mux-video@3062

@videojs/native-hls-video

pnpm add https://pkg.pr.new/@videojs/native-hls-video@3062

@videojs/shaka-video

pnpm add https://pkg.pr.new/@videojs/shaka-video@3062

@videojs/spotify-audio

pnpm add https://pkg.pr.new/@videojs/spotify-audio@3062

@videojs/tiktok-video

pnpm add https://pkg.pr.new/@videojs/tiktok-video@3062

@videojs/twitch-video

pnpm add https://pkg.pr.new/@videojs/twitch-video@3062

@videojs/vimeo-video

pnpm add https://pkg.pr.new/@videojs/vimeo-video@3062

@videojs/wistia-video

pnpm add https://pkg.pr.new/@videojs/wistia-video@3062

@videojs/youtube-video

pnpm add https://pkg.pr.new/@videojs/youtube-video@3062

@videojs/google-cast

pnpm add https://pkg.pr.new/@videojs/google-cast@3062

@videojs/mux-data

pnpm add https://pkg.pr.new/@videojs/mux-data@3062

commit: 9449867

@github-actions

github-actions Bot commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

📦 Bundle Size Report

🎨 @videojs/html — 70 small size changes
Path Base initial PR initial Initial diff Lazy diff
/video/minimal-skin 63.15 kB 63.15 kB +1 B (+0.0%) 0 B
/video/player 9.98 kB 9.99 kB +6 B (+0.1%) 0 B
/video/skin 62.66 kB 62.68 kB +17 B (+0.0%) 0 B
/audio/minimal-skin 46.87 kB 46.88 kB +11 B (+0.0%) 0 B
/audio/player 6.21 kB 6.20 kB -2 B (-0.0%) 0 B
/audio/skin 46.57 kB 46.56 kB -8 B (-0.0%) 0 B
/background/skin 10.14 kB 10.14 kB -1 B (-0.0%) 0 B
/live-video/minimal-skin 50.67 kB 50.58 kB -91 B (-0.2%) 0 B
/live-video/player 9.35 kB 9.34 kB -3 B (-0.0%) 0 B
/live-video/skin 50.59 kB 50.58 kB -14 B (-0.0%) 0 B
/live-audio/minimal-skin 36.19 kB 36.18 kB -6 B (-0.0%) 0 B
/live-audio/player 6.21 kB 6.21 kB -2 B (-0.0%) 0 B
/live-audio/skin 36.12 kB 36.11 kB -14 B (-0.0%) 0 B
/ui/airplay-button 11.53 kB 11.54 kB +7 B (+0.1%) 0 B
/ui/audio-track-radio-group 11.64 kB 11.64 kB +3 B (+0.0%) 0 B
/ui/buffering-indicator 8.87 kB 8.87 kB -3 B (-0.0%) 0 B
/ui/captions-button 11.79 kB 11.78 kB -7 B (-0.1%) 0 B
/ui/captions-radio-group 11.71 kB 11.71 kB +1 B (+0.0%) 0 B
/ui/cast-button 11.52 kB 11.51 kB -6 B (-0.1%) 0 B
/ui/controls 9.04 kB 9.04 kB +6 B (+0.1%) 0 B
/ui/fullscreen-button 11.52 kB 11.51 kB -6 B (-0.1%) 0 B
/ui/gesture 9.82 kB 9.82 kB +1 B (+0.0%) 0 B
/ui/hotkey 10.31 kB 10.32 kB +13 B (+0.1%) 0 B
/ui/live-button 10.08 kB 10.08 kB +4 B (+0.0%) 0 B
/ui/menu 19.06 kB 19.07 kB +3 B (+0.0%) 0 B
/ui/mute-button 11.53 kB 11.53 kB -5 B (-0.0%) 0 B
/ui/pip-button 11.49 kB 11.49 kB -1 B (-0.0%) 0 B
/ui/play-button 11.49 kB 11.48 kB -8 B (-0.1%) 0 B
/ui/playback-rate-button 11.59 kB 11.58 kB -7 B (-0.1%) 0 B
/ui/playback-rate-radio-group 11.64 kB 11.64 kB +3 B (+0.0%) 0 B
/ui/poster 9.17 kB 9.16 kB -12 B (-0.1%) 0 B
/ui/quality-radio-group 12.23 kB 12.23 kB -1 B (-0.0%) 0 B
/ui/seek-button 11.52 kB 11.52 kB -3 B (-0.0%) 0 B
/ui/seek-indicator 12.97 kB 12.98 kB +13 B (+0.1%) 0 B
/ui/slider 11.89 kB 11.89 kB +5 B (+0.0%) 0 B
/ui/status-announcer 10.88 kB 10.88 kB +2 B (+0.0%) 0 B
/ui/status-indicator 13.28 kB 13.27 kB -11 B (-0.1%) 0 B
/ui/thumbnail 10.59 kB 10.59 kB -2 B (-0.0%) 0 B
/ui/time 11.34 kB 11.34 kB +1 B (+0.0%) 0 B
/ui/time-slider 13.40 kB 13.39 kB -4 B (-0.0%) 0 B
/ui/time-slider-chapter-title 9.07 kB 9.07 kB +7 B (+0.1%) 0 B
/ui/time-slider-chapters 9.91 kB 9.90 kB -3 B (-0.0%) 0 B
/ui/title 8.45 kB 8.46 kB +2 B (+0.0%) 0 B
/ui/volume-indicator 13.27 kB 13.27 kB -3 B (-0.0%) 0 B
/ui/volume-popover 15.17 kB 15.18 kB +6 B (+0.0%) 0 B
/ui/volume-slider 12.57 kB 12.59 kB +22 B (+0.2%) 0 B
/media/mux-video 3.01 kB 3.04 kB +24 B (+0.8%) —
/media/mux-audio 2.68 kB 2.70 kB +20 B (+0.7%) —
/media/cloudflare-video 2.90 kB 2.91 kB +13 B (+0.4%) —
/media/dash-video 2.63 kB 2.63 kB +10 B (+0.4%) —
/media/hls-audio 23.47 kB 23.59 kB +123 B (+0.5%) —
/media/hls-background-video 17.43 kB 17.54 kB +117 B (+0.7%) —
/media/hls-video 33.61 kB 33.78 kB +171 B (+0.5%) —
/media/hlsjs-video 2.63 kB 2.64 kB +10 B (+0.4%) —
/media/mux-background-video 17.42 kB 17.58 kB +160 B (+0.9%) —
/media/native-hls-video 7.57 kB 7.73 kB +164 B (+2.1%) —
/media/shaka-video 2.62 kB 2.64 kB +17 B (+0.6%) —
/media/spotify-audio 3.02 kB 3.03 kB +11 B (+0.4%) —
/media/tiktok-video 3.12 kB 3.14 kB +13 B (+0.4%) —
/media/twitch-video 2.93 kB 2.94 kB +11 B (+0.4%) —
/media/vimeo-video 2.90 kB 2.92 kB +25 B (+0.8%) —
/media/wistia-video 607 B 622 B +15 B (+2.5%) —
/media/youtube-video 2.90 kB 2.92 kB +24 B (+0.8%) —
/video (default) 64.20 kB 64.24 kB +39 B (+0.1%) 0 B
/video (default + hls) 65.93 kB 66.03 kB +103 B (+0.2%) 0 B
/video (minimal) 64.71 kB 64.67 kB -39 B (-0.1%) 0 B
/video (minimal + hls) 66.39 kB 66.44 kB +48 B (+0.1%) 0 B
/audio (default) 48.01 kB 48.01 kB +1 B (+0.0%) 0 B
/audio (minimal) 48.26 kB 48.35 kB +90 B (+0.2%) 0 B
/background 11.88 kB 11.89 kB +6 B (+0.0%) 0 B
Presets (7)
Entry Initial Lazy
/video (default) 64.24 kB 56.03 kB
/video (default + hls) 66.03 kB 56.03 kB
/video (minimal) 64.67 kB 56.03 kB
/video (minimal + hls) 66.44 kB 56.03 kB
/audio (default) 48.01 kB 56.03 kB
/audio (minimal) 48.35 kB 56.03 kB
/background 11.89 kB 56.03 kB
Media (18)
Entry Initial
/media/mux-video 3.04 kB
/media/mux-audio 2.70 kB
/media/background-video 1.16 kB
/media/cloudflare-video 2.91 kB
/media/dash-video 2.63 kB
/media/hls-audio 23.59 kB
/media/hls-background-video 17.54 kB
/media/hls-video 33.78 kB
/media/hlsjs-video 2.64 kB
/media/mux-background-video 17.58 kB
/media/native-hls-video 7.73 kB
/media/shaka-video 2.64 kB
/media/spotify-audio 3.03 kB
/media/tiktok-video 3.14 kB
/media/twitch-video 2.94 kB
/media/vimeo-video 2.92 kB
/media/wistia-video 622 B
/media/youtube-video 2.92 kB
Players (5)
Entry Initial Lazy
/video/player 9.99 kB 56.03 kB
/audio/player 6.20 kB 56.03 kB
/background/player 4.46 kB 56.03 kB
/live-video/player 9.34 kB 56.03 kB
/live-audio/player 6.21 kB 56.03 kB
Skins (29)
Entry Type Initial Lazy
/video/minimal-skin.css css 8.29 kB —
/video/skin.css css 8.00 kB —
/video/minimal-skin js 63.15 kB 56.03 kB
/video/minimal-skin2 js 8.27 kB —
/video/skin js 62.68 kB 56.03 kB
/video/skin2 js 7.99 kB —
/audio/minimal-skin.css css 6.07 kB —
/audio/skin.css css 5.80 kB —
/audio/minimal-skin js 46.88 kB 56.03 kB
/audio/minimal-skin2 js 6.05 kB —
/audio/skin js 46.56 kB 56.03 kB
/audio/skin2 js 5.78 kB —
/background/skin.css css 141 B —
/background/skin js 10.14 kB 56.03 kB
/background/skin2 js 159 B —
/live-video/minimal-skin.css css 6.77 kB —
/live-video/skin.css css 6.69 kB —
/live-video/minimal-skin js 50.58 kB 56.03 kB
/live-video/minimal-skin2 js 6.77 kB —
/live-video/skin js 50.58 kB 56.03 kB
/live-video/skin2 js 6.67 kB —
/live-audio/minimal-skin.css css 4.77 kB —
/live-audio/skin.css css 4.67 kB —
/live-audio/minimal-skin js 36.18 kB 56.03 kB
/live-audio/minimal-skin2 js 4.77 kB —
/live-audio/skin js 36.11 kB 56.03 kB
/live-audio/skin2 js 4.66 kB —
/global.css css 239 B —
/shadow.css css 78 B —
UI Components (62)
Entry Initial Lazy
/ui/airplay-button 11.54 kB 56.03 kB
/ui/alert-dialog 8.98 kB 56.03 kB
/ui/audio-track-radio-group 11.64 kB 56.03 kB
/ui/buffering-indicator 8.87 kB 56.03 kB
/ui/captions-button 11.78 kB 56.03 kB
/ui/captions-radio-group 11.71 kB 56.03 kB
/ui/cast-button 11.51 kB 56.03 kB
/ui/container 9.74 kB 56.03 kB
/ui/controls 9.04 kB 56.03 kB
/ui/controls-backdrop 1.69 kB 56.03 kB
/ui/controls-content 1.67 kB 56.03 kB
/ui/dialog 8.92 kB 56.03 kB
/ui/dialog-backdrop 1.70 kB 56.03 kB
/ui/dialog-close 2.06 kB 56.03 kB
/ui/dialog-description 1.69 kB 56.03 kB
/ui/dialog-popup 1.90 kB 56.03 kB
/ui/dialog-title 1.70 kB 56.03 kB
/ui/error-dialog 12.65 kB 56.03 kB
/ui/fullscreen-button 11.51 kB 56.03 kB
/ui/gesture 9.82 kB 56.03 kB
/ui/hotkey 10.32 kB 56.03 kB
/ui/live-button 10.08 kB 56.03 kB
/ui/menu 19.07 kB 56.03 kB
/ui/menu-checkbox-item 1.97 kB 56.03 kB
/ui/menu-content 7.65 kB 56.03 kB
/ui/menu-group 2.09 kB 56.03 kB
/ui/menu-group-label 1.64 kB —
/ui/menu-item 2.30 kB 56.03 kB
/ui/menu-item-indicator 1.38 kB 56.03 kB
/ui/menu-radio-group 3.01 kB 56.03 kB
/ui/menu-radio-item 2.13 kB 56.03 kB
/ui/menu-separator 1.30 kB 56.03 kB
/ui/mute-button 11.53 kB 56.03 kB
/ui/pip-button 11.49 kB 56.03 kB
/ui/play-button 11.48 kB 56.03 kB
/ui/playback-rate-button 11.58 kB 56.03 kB
/ui/playback-rate-radio-group 11.64 kB 56.03 kB
/ui/popover 8.76 kB 56.03 kB
/ui/poster 9.16 kB 56.03 kB
/ui/quality-radio-group 12.23 kB 56.03 kB
/ui/seek-button 11.52 kB 56.03 kB
/ui/seek-indicator 12.98 kB 56.03 kB
/ui/seek-indicator-value 1.10 kB —
/ui/slider 11.89 kB 56.03 kB
/ui/slider-preview 2.01 kB 56.03 kB
/ui/status-announcer 10.88 kB 56.03 kB
/ui/status-indicator 13.27 kB 56.03 kB
/ui/status-indicator-value 1.10 kB —
/ui/thumbnail 10.59 kB 56.03 kB
/ui/time 11.34 kB 56.03 kB
/ui/time-slider 13.39 kB 56.03 kB
/ui/time-slider-chapter-title 9.07 kB 56.03 kB
/ui/time-slider-chapters 9.90 kB 56.03 kB
/ui/title 8.46 kB 56.03 kB
/ui/tooltip 10.13 kB 56.03 kB
/ui/tooltip-label 1.21 kB —
/ui/tooltip-shortcut 1.18 kB —
/ui/volume-indicator 13.27 kB 56.03 kB
/ui/volume-indicator-fill 1.11 kB —
/ui/volume-indicator-value 1.10 kB —
/ui/volume-popover 15.18 kB 56.03 kB
/ui/volume-slider 12.59 kB 56.03 kB
⚛️ @videojs/react — 68 small size changes
Path Base initial PR initial Initial diff Lazy diff
/media/mux-video/hls-js 1.46 kB 1.47 kB +15 B (+1.0%) —
/media/mux-video/spf 1.46 kB 1.47 kB +15 B (+1.0%) —
/media/mux-audio/hls-js 1.12 kB 1.13 kB +9 B (+0.8%) —
/media/mux-audio/spf 1.13 kB 1.14 kB +5 B (+0.4%) —
/media/cloudflare-video 1.81 kB 1.84 kB +23 B (+1.2%) —
/media/dash-video 1.11 kB 1.13 kB +14 B (+1.2%) —
/media/hls-audio 22.18 kB 22.29 kB +114 B (+0.5%) —
/media/hls-background-video 17.48 kB 17.61 kB +137 B (+0.8%) —
/media/hls-video 32.40 kB 32.50 kB +94 B (+0.3%) —
/media/hlsjs-video 1.12 kB 1.13 kB +12 B (+1.0%) —
/media/mux-audio 1.12 kB 1.13 kB +11 B (+1.0%) —
/media/mux-background-video 17.50 kB 17.62 kB +126 B (+0.7%) —
/media/mux-video 1.45 kB 1.46 kB +11 B (+0.7%) —
/media/native-hls-video 6.21 kB 6.35 kB +137 B (+2.2%) —
/media/shaka-video 1.11 kB 1.13 kB +13 B (+1.1%) —
/media/spotify-audio 1.89 kB 1.89 kB +6 B (+0.3%) —
/media/tiktok-video 1.81 kB 1.83 kB +16 B (+0.9%) —
/media/twitch-video 1.84 kB 1.85 kB +18 B (+1.0%) —
/media/vimeo-video 1.79 kB 1.81 kB +20 B (+1.1%) —
/media/wistia-video 1.41 kB 1.44 kB +25 B (+1.7%) —
/media/youtube-video 1.79 kB 1.81 kB +18 B (+1.0%) —
/video/minimal-skin 58.71 kB 58.61 kB -104 B (-0.2%) 0 B
/video/player 8.24 kB 8.26 kB +19 B (+0.2%) 0 B
/video/skin 58.60 kB 58.58 kB -22 B (-0.0%) 0 B
/audio/minimal-skin 45.47 kB 45.42 kB -52 B (-0.1%) 0 B
/audio/player 4.43 kB 4.44 kB +3 B (+0.1%) 0 B
/live-video/minimal-skin 48.43 kB 48.39 kB -40 B (-0.1%) 0 B
/live-video/player 7.62 kB 7.62 kB +1 B (+0.0%) 0 B
/live-video/skin 48.50 kB 48.42 kB -82 B (-0.2%) 0 B
/live-audio/minimal-skin 33.67 kB 33.69 kB +17 B (+0.0%) 0 B
/live-audio/skin 33.71 kB 33.71 kB +2 B (+0.0%) 0 B
/ui/airplay-button 11.24 kB 11.24 kB +1 B (+0.0%) 0 B
/ui/audio-track 8.39 kB 8.40 kB +10 B (+0.1%) 0 B
/ui/audio-track-radio-group 10.82 kB 10.82 kB -6 B (-0.1%) 0 B
/ui/buffering-indicator 8.43 kB 8.42 kB -5 B (-0.1%) 0 B
/ui/captions-button 11.24 kB 11.24 kB +1 B (+0.0%) 0 B
/ui/captions-radio-group 10.95 kB 10.93 kB -11 B (-0.1%) 0 B
/ui/cast-button 11.22 kB 11.22 kB -1 B (-0.0%) 0 B
/ui/controls 8.31 kB 8.31 kB -2 B (-0.0%) 0 B
/ui/error-dialog 12.64 kB 12.64 kB +3 B (+0.0%) 0 B
/ui/fullscreen-button 11.21 kB 11.21 kB +1 B (+0.0%) 0 B
/ui/gesture 8.45 kB 8.46 kB +5 B (+0.1%) 0 B
/ui/hotkey 8.94 kB 8.95 kB +4 B (+0.0%) 0 B
/ui/live-button 9.55 kB 9.56 kB +2 B (+0.0%) 0 B
/ui/menu 21.88 kB 21.89 kB +7 B (+0.0%) 0 B
/ui/mute-button 11.24 kB 11.24 kB +2 B (+0.0%) 0 B
/ui/pip-button 11.21 kB 11.21 kB +2 B (+0.0%) 0 B
/ui/play-button 11.17 kB 11.17 kB -3 B (-0.0%) 0 B
/ui/playback-rate 8.42 kB 8.42 kB +1 B (+0.0%) 0 B
/ui/playback-rate-button 11.17 kB 11.16 kB -4 B (-0.0%) 0 B
/ui/playback-rate-radio-group 10.85 kB 10.87 kB +14 B (+0.1%) 0 B
/ui/quality 8.87 kB 8.88 kB +1 B (+0.0%) 0 B
/ui/quality-radio-group 11.29 kB 11.29 kB +6 B (+0.1%) 0 B
/ui/seek-button 11.20 kB 11.21 kB +8 B (+0.1%) 0 B
/ui/seek-indicator 12.95 kB 12.95 kB -2 B (-0.0%) 0 B
/ui/slider 14.42 kB 14.36 kB -57 B (-0.4%) 0 B
/ui/status-announcer 10.82 kB 10.83 kB +12 B (+0.1%) 0 B
/ui/status-indicator 13.35 kB 13.35 kB +1 B (+0.0%) 0 B
/ui/thumbnail 9.78 kB 9.79 kB +3 B (+0.0%) 0 B
/ui/time 10.64 kB 10.62 kB -19 B (-0.2%) 0 B
/ui/time-slider 16.16 kB 16.17 kB +9 B (+0.1%) 0 B
/ui/title 7.91 kB 7.91 kB +1 B (+0.0%) 0 B
/ui/volume-indicator 13.44 kB 13.42 kB -24 B (-0.2%) 0 B
/video (default) 58.71 kB 58.64 kB -66 B (-0.1%) 0 B
/video (default + hls) 59.24 kB 59.28 kB +44 B (+0.1%) 0 B
/video (minimal) 58.82 kB 58.80 kB -14 B (-0.0%) 0 B
/video (minimal + hls) 59.41 kB 59.23 kB -180 B (-0.3%) 0 B
/audio (minimal) 45.52 kB 45.54 kB +19 B (+0.0%) 0 B
Presets (7)
Entry Initial Lazy
/video (default) 58.64 kB 56.03 kB
/video (default + hls) 59.28 kB 56.03 kB
/video (minimal) 58.80 kB 56.03 kB
/video (minimal + hls) 59.23 kB 56.03 kB
/audio (default) 45.53 kB 56.03 kB
/audio (minimal) 45.54 kB 56.03 kB
/background 908 B 56.03 kB
Media (22)
Entry Initial
/media/mux-video/hls-js 1.47 kB
/media/mux-video/spf 1.47 kB
/media/mux-audio/hls-js 1.13 kB
/media/mux-audio/spf 1.14 kB
/media/background-video 513 B
/media/cloudflare-video 1.84 kB
/media/dash-video 1.13 kB
/media/hls-audio 22.29 kB
/media/hls-background-video 17.61 kB
/media/hls-video 32.50 kB
/media/hlsjs-video 1.13 kB
/media/mux-audio 1.13 kB
/media/mux-background-video 17.62 kB
/media/mux-video 1.46 kB
/media/native-hls-video 6.35 kB
/media/shaka-video 1.13 kB
/media/spotify-audio 1.89 kB
/media/tiktok-video 1.83 kB
/media/twitch-video 1.85 kB
/media/vimeo-video 1.81 kB
/media/wistia-video 1.44 kB
/media/youtube-video 1.81 kB
Extensions (2)
Entry Initial
/extensions/google-cast 1.77 kB
/extensions/mux-data 1.80 kB
Players (5)
Entry Initial Lazy
/video/player 8.26 kB 56.03 kB
/audio/player 4.44 kB 56.03 kB
/background/player 2.64 kB 56.03 kB
/live-video/player 7.62 kB 56.03 kB
/live-audio/player 4.44 kB 56.03 kB
Skins (18)
Entry Type Initial Lazy
/video/minimal-skin.css css 8.12 kB —
/video/skin.css css 7.81 kB —
/video/minimal-skin js 58.61 kB 56.03 kB
/video/skin js 58.58 kB 56.03 kB
/audio/minimal-skin.css css 5.88 kB —
/audio/skin.css css 5.60 kB —
/audio/minimal-skin js 45.42 kB 56.03 kB
/audio/skin js 45.38 kB 56.03 kB
/background/skin.css css 97 B —
/background/skin js 518 B —
/live-video/minimal-skin.css css 6.60 kB —
/live-video/skin.css css 6.51 kB —
/live-video/minimal-skin js 48.39 kB 56.03 kB
/live-video/skin js 48.42 kB 56.03 kB
/live-audio/minimal-skin.css css 4.58 kB —
/live-audio/skin.css css 4.47 kB —
/live-audio/minimal-skin js 33.69 kB 56.03 kB
/live-audio/skin js 33.71 kB 56.03 kB
UI Components (39)
Entry Initial Lazy
/ui/airplay-button 11.24 kB 56.03 kB
/ui/alert-dialog 5.20 kB 56.03 kB
/ui/audio-track 8.40 kB 56.03 kB
/ui/audio-track-radio-group 10.82 kB 56.03 kB
/ui/buffering-indicator 8.42 kB 56.03 kB
/ui/captions-button 11.24 kB 56.03 kB
/ui/captions-radio-group 10.93 kB 56.03 kB
/ui/cast-button 11.22 kB 56.03 kB
/ui/controls 8.31 kB 56.03 kB
/ui/dialog 5.18 kB 56.03 kB
/ui/error-dialog 12.64 kB 56.03 kB
/ui/fullscreen-button 11.21 kB 56.03 kB
/ui/gesture 8.46 kB 56.03 kB
/ui/hotkey 8.95 kB 56.03 kB
/ui/live-button 9.56 kB 56.03 kB
/ui/menu 21.89 kB 56.03 kB
/ui/mute-button 11.24 kB 56.03 kB
/ui/pip-button 11.21 kB 56.03 kB
/ui/play-button 11.17 kB 56.03 kB
/ui/playback-rate 8.42 kB 56.03 kB
/ui/playback-rate-button 11.16 kB 56.03 kB
/ui/playback-rate-radio-group 10.87 kB 56.03 kB
/ui/popover 9.12 kB 56.03 kB
/ui/poster 8.64 kB 56.03 kB
/ui/quality 8.88 kB 56.03 kB
/ui/quality-radio-group 11.29 kB 56.03 kB
/ui/seek-button 11.21 kB 56.03 kB
/ui/seek-indicator 12.95 kB 56.03 kB
/ui/slider 14.36 kB 56.03 kB
/ui/status-announcer 10.83 kB 56.03 kB
/ui/status-indicator 13.35 kB 56.03 kB
/ui/thumbnail 9.79 kB 56.03 kB
/ui/time 10.62 kB 56.03 kB
/ui/time-slider 16.17 kB 56.03 kB
/ui/title 7.91 kB 56.03 kB
/ui/tooltip 9.98 kB 56.03 kB
/ui/volume-indicator 13.42 kB 56.03 kB
/ui/volume-popover 15.56 kB 56.03 kB
/ui/volume-slider 12.97 kB 56.03 kB
🧩 @videojs/core — 2 small size changes
Path Base initial PR initial Initial diff Lazy diff
. 13.48 kB 13.49 kB +12 B (+0.1%) —
/dom 23.28 kB 23.31 kB +29 B (+0.1%) 0 B
Entries (76)
Entry Initial Lazy
. 13.49 kB —
/dom 23.31 kB 56.03 kB
/vjsc 1.90 kB —
/i18n 3.21 kB 56.03 kB
/i18n/locales/all 33.91 kB —
/i18n/locales/ar 1.16 kB —
/i18n/locales/az 1.08 kB —
/i18n/locales/bg 1.29 kB —
/i18n/locales/bn 1.25 kB —
/i18n/locales/bs 1.02 kB —
/i18n/locales/ca 1.04 kB —
/i18n/locales/cs 1.10 kB —
/i18n/locales/cy 1.02 kB —
/i18n/locales/da 984 B —
/i18n/locales/de 1.06 kB —
/i18n/locales/el 1.42 kB —
/i18n/locales/en 801 B —
/i18n/locales/es 999 B —
/i18n/locales/et 1.02 kB —
/i18n/locales/eu 1.04 kB —
/i18n/locales/fa 1.21 kB —
/i18n/locales/fi 1.05 kB —
/i18n/locales/fr 1.01 kB —
/i18n/locales/gd 1.09 kB —
/i18n/locales/gl 1017 B —
/i18n/locales/he 1.10 kB —
/i18n/locales/hi 1.25 kB —
/i18n/locales/hr 1.05 kB —
/i18n/locales/hu 1.10 kB —
/i18n/locales/id 953 B —
/i18n/locales/it 1.01 kB —
/i18n/locales/ja 1.16 kB —
/i18n/locales/ko 1.08 kB —
/i18n/locales/lt 1.04 kB —
/i18n/locales/lv 1.09 kB —
/i18n/locales/mr 1.23 kB —
/i18n/locales/nb 990 B —
/i18n/locales/ne 1.23 kB —
/i18n/locales/nl 1.01 kB —
/i18n/locales/nn 983 B —
/i18n/locales/oc 1.05 kB —
/i18n/locales/pl 1.11 kB —
/i18n/locales/pt 1.02 kB —
/i18n/locales/pt-BR 1.02 kB —
/i18n/locales/pt-PT 1.02 kB —
/i18n/locales/ro 1.04 kB —
/i18n/locales/ru 1.36 kB —
/i18n/locales/sk 1.10 kB —
/i18n/locales/sl 1.04 kB —
/i18n/locales/sr 1.05 kB —
/i18n/locales/sv 1.01 kB —
/i18n/locales/te 1.29 kB —
/i18n/locales/th 1.20 kB —
/i18n/locales/tr 1.00 kB —
/i18n/locales/uk 1.37 kB —
/i18n/locales/vi 1.10 kB —
/i18n/locales/zh 1.01 kB —
/i18n/locales/zh-CN 1.01 kB —
/i18n/locales/zh-TW 1.02 kB —
/i18n/text/airplay 101 B —
/i18n/text/buttons 137 B —
/i18n/text/captions 93 B —
/i18n/text/cast 114 B —
/i18n/text/common 90 B —
/i18n/text/container 75 B —
/i18n/text/errors 285 B —
/i18n/text/fullscreen 98 B —
/i18n/text/live 126 B —
/i18n/text/menu 249 B —
/i18n/text/pip 101 B —
/i18n/text/playback 80 B —
/i18n/text/seek 105 B —
/i18n/text/slider 65 B —
/i18n/text/status 222 B —
/i18n/text/time 322 B —
/i18n/text/volume 133 B —
🏷️ @videojs/element — no changes
Entries (2)
Entry Initial
. 1.05 kB
/context 943 B
📦 @videojs/store — no changes
Entries (3)
Entry Initial
. 1.72 kB
/html 703 B
/react 512 B
🔧 @videojs/utils — no changes
Entries (13)
Entry Initial
/array 271 B
/dom 5.22 kB
/events 320 B
/function 414 B
/i18n 249 B
/jwt 176 B
/object 535 B
/predicate 297 B
/percent 281 B
/string 239 B
/style 212 B
/time 1018 B
/number 199 B
📦 @videojs/cdn — no changes
📦 @videojs/cloudflare-video — 1 small size change
Path Base initial PR initial Initial diff Lazy diff
. 3.70 kB 3.81 kB +108 B (+2.8%) —
📦 @videojs/dash-video — 1 small size change
Path Base initial PR initial Initial diff Lazy diff
. 3.29 kB 3.42 kB +129 B (+3.8%) —
📦 @videojs/google-cast — no changes
📦 @videojs/hlsjs-video — 1 small size change
Path Base initial PR initial Initial diff Lazy diff
. 134.70 kB 134.90 kB +212 B (+0.2%) —
📦 @videojs/media — 1 small size change
Path Base initial PR initial Initial diff Lazy diff
. 3.29 kB 3.39 kB +103 B (+3.1%) —
Entries (3)
Entry Initial
. 3.39 kB
/dom 4.12 kB
/media-tracks 2.05 kB
📦 @videojs/mux — no changes
📦 @videojs/mux-audio — 2 small size changes
Path Base initial PR initial Initial diff Lazy diff
. 135.99 kB 136.09 kB +105 B (+0.1%) —
/spf 22.67 kB 22.84 kB +180 B (+0.8%) —
Entries (2)
Entry Initial
. 136.09 kB
/spf 22.84 kB
📦 @videojs/mux-data — no changes
📦 @videojs/mux-video — 2 small size changes
Path Base initial PR initial Initial diff Lazy diff
. 135.91 kB 136.17 kB +268 B (+0.2%) —
/spf 32.75 kB 32.90 kB +149 B (+0.4%) —
Entries (2)
Entry Initial
. 136.17 kB
/spf 32.90 kB
📦 @videojs/native-hls-video — 1 small size change
Path Base initial PR initial Initial diff Lazy diff
. 5.25 kB 5.41 kB +164 B (+3.1%) —
📦 @videojs/shaka-video — 1 small size change
Path Base initial PR initial Initial diff Lazy diff
. 196.79 kB 196.95 kB +163 B (+0.1%) —
📦 @videojs/spf — 3 small size changes
Path Base initial PR initial Initial diff Lazy diff
/hls-background-video 16.46 kB 16.58 kB +118 B (+0.7%) —
/hls-audio 21.27 kB 21.34 kB +68 B (+0.3%) —
/hls-video 31.46 kB 31.62 kB +167 B (+0.5%) —
Entries (7)
Entry Initial
. 4.55 kB
/dom 7.67 kB
/hls 28.08 kB
/media-tracks 507 B
/hls-background-video 16.58 kB
/hls-audio 21.34 kB
/hls-video 31.62 kB
📦 @videojs/spotify-audio — 1 small size change
Path Base initial PR initial Initial diff Lazy diff
. 3.58 kB 3.69 kB +112 B (+3.1%) —
📦 @videojs/tiktok-video — 1 small size change
Path Base initial PR initial Initial diff Lazy diff
. 3.56 kB 3.67 kB +113 B (+3.1%) —
📦 @videojs/twitch-video — 1 small size change
Path Base initial PR initial Initial diff Lazy diff
. 3.63 kB 3.73 kB +100 B (+2.7%) —
📦 @videojs/other — 1 small size change
Path Base initial PR initial Initial diff Lazy diff
video.js 73.40 kB 73.57 kB +173 B (+0.2%) 0 B
Entries (3)
Entry Initial Lazy
video.js 73.57 kB 56.03 kB
video.js/package.json 608 B —
video.js/errors 1.03 kB —
📦 @videojs/vimeo-video — 1 small size change
Path Base initial PR initial Initial diff Lazy diff
. 10.59 kB 10.68 kB +92 B (+0.8%) —
📦 @videojs/wistia-video — 1 small size change
Path Base initial PR initial Initial diff Lazy diff
. 1.92 kB 2.04 kB +131 B (+6.7%) —
Entries (2)
Entry Initial
. 2.04 kB
/helpers 1.77 kB
📦 @videojs/youtube-video — 1 small size change
Path Base initial PR initial Initial diff Lazy diff
. 4.38 kB 4.49 kB +113 B (+2.5%) —

ℹ️ How to interpret

Each entry is independently bundled, minified, and brotli-compressed. Initial size includes its static import graph; lazy dynamic chunks are reported separately.

Entries are not additive because their dependency graphs overlap. Preset rows represent realistic combined bundles.

Changes of 300 B or less across initial, lazy, and total size are collapsed, not discarded.

Run pnpm size locally to check current initial sizes.

Each guard narrows to an adapter class, so it's named for it:
isHlsJsAdapter narrows to HlsJsAdapter. The brand constants beside them
become *_BRAND.
The engine is created one microtask after a source is set, so reading
media.engine straight away could find nothing and skip the listener. The
example now subscribes to the current engine and again on every
loadstart, removing first so a reused engine isn't subscribed twice.
Base automatically changed from t3code/media-source-detection to main September 30, 2026 23:12
@luwes luwes closed this Oct 21, 2026

This branch was successfully deployed

1 active deployment
Preview — 94498671 Deployed Sep 30, 2026 by vercel[bot]
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature: Add Stable Media Facade Type Guards

2 participants