Skip to content

refactor(core): move media predicates to core/media#1475

Closed
mihar-22 wants to merge 3 commits into
mainfrom
refactor/cast-any-fix
Closed

refactor(core): move media predicates to core/media#1475
mihar-22 wants to merge 3 commits into
mainfrom
refactor/cast-any-fix

Conversation

@mihar-22

@mihar-22 mihar-22 commented Apr 28, 2026

Copy link
Copy Markdown
Member

Lifting predicates out of dom/ unblocks non-DOM consumers (react-native, future shims) from using them without pulling in DOM types. The cast button cleanup keeps a single source of truth for cast support detection (the remote-playback feature) and removes the only any cast in core/ui.


Note

Low Risk
Primarily a refactor with import rewiring plus a small behavior change in cast availability reporting; risk is limited but could affect environments that previously relied on the chrome heuristic.

Overview
Moves the media capability/type-guard predicates (e.g. isMediaPauseCapable, isMediaRemotePlaybackCapable, hasMetadata) from dom/media/predicate.ts into a new core/media/predicate.ts, and updates DOM store features to import them from the core layer so non-DOM consumers can reuse the logic.

Simplifies CastButtonCore to stop using a Chromium (globalThis.chrome) check and always surface remotePlaybackAvailability from media state; corresponding tests remove the chrome stubbing and the “unsupported outside Chromium” expectation.

Reviewed by Cursor Bugbot for commit 66cb21c. Bugbot is set up for automated code reviews on this repo. Configure here.

@vercel

vercel Bot commented Apr 28, 2026

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
v10-sandbox Ready Ready Preview, Comment Apr 28, 2026 6:38am

Request Review

@netlify

netlify Bot commented Apr 28, 2026

Copy link
Copy Markdown

Deploy Preview for vjs10-site ready!

Name Link
🔨 Latest commit 66cb21c
🔍 Latest deploy log https://app.netlify.com/projects/vjs10-site/deploys/69f055d73b751400086453bb
😎 Deploy Preview https://deploy-preview-1475--vjs10-site.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@github-actions

github-actions Bot commented Apr 28, 2026

Copy link
Copy Markdown
Contributor

📦 Bundle Size Report

🎨 @videojs/html — no changes
Presets (7)
Entry Size
/video (default) 28.78 kB
/video (default + hls) 162.09 kB
/video (minimal) 26.30 kB
/video (minimal + hls) 159.60 kB
/audio (default) 26.71 kB
/audio (minimal) 24.22 kB
/background 4.16 kB
Media (8)
Entry Size
/media/background-video 1.04 kB
/media/container 1.72 kB
/media/dash-video 236.58 kB
/media/hls-video 134.69 kB
/media/mux-audio 160.91 kB
/media/mux-video 160.85 kB
/media/native-hls-video 4.62 kB
/media/simple-hls-video 15.89 kB
Players (3)
Entry Size
/video/player 7.00 kB
/audio/player 5.12 kB
/background/player 3.86 kB
Skins (29)
Entry Type Size
/video/minimal-skin.css css 3.53 kB
/video/skin.css css 3.56 kB
/video/minimal-skin js 26.29 kB
/video/minimal-skin.tailwind js 26.51 kB
/video/skin js 28.82 kB
/video/skin.tailwind js 28.90 kB
/audio/minimal-skin.css css 2.55 kB
/audio/skin.css css 2.52 kB
/audio/minimal-skin js 24.24 kB
/audio/minimal-skin.tailwind js 24.41 kB
/audio/skin js 26.64 kB
/audio/skin.tailwind js 26.81 kB
/background/skin.css css 117 B
/background/skin js 1.15 kB
/live-video/minimal-skin.css css 3.53 kB
/live-video/skin.css css 3.56 kB
/live-video/minimal-skin js 26.05 kB
/live-video/minimal-skin.tailwind js 26.13 kB
/live-video/skin js 28.51 kB
/live-video/skin.tailwind js 28.55 kB
/live-audio/minimal-skin.css css 2.55 kB
/live-audio/skin.css css 2.52 kB
/live-audio/minimal-skin js 24.07 kB
/live-audio/minimal-skin.tailwind js 24.02 kB
/live-audio/skin js 26.41 kB
/live-audio/skin.tailwind js 26.45 kB
/base.css css 157 B
/shared.css css 88 B
/skin-element js 1.36 kB
UI Components (25)
Entry Size
/ui/alert-dialog 1.02 kB
/ui/alert-dialog-close 493 B
/ui/alert-dialog-description 384 B
/ui/alert-dialog-title 424 B
/ui/buffering-indicator 2.55 kB
/ui/captions-button 2.60 kB
/ui/cast-button 2.63 kB
/ui/compounds 4.25 kB
/ui/controls 2.06 kB
/ui/error-dialog 3.14 kB
/ui/fullscreen-button 2.63 kB
/ui/hotkey 1.97 kB
/ui/mute-button 2.64 kB
/ui/pip-button 2.62 kB
/ui/play-button 2.59 kB
/ui/playback-rate-button 2.69 kB
/ui/popover 1.81 kB
/ui/poster 1.94 kB
/ui/seek-button 2.59 kB
/ui/slider 1.52 kB
/ui/thumbnail 2.98 kB
/ui/time 2.57 kB
/ui/time-slider 3.99 kB
/ui/tooltip 2.06 kB
/ui/volume-slider 2.75 kB

Sizes are marginal over the root entry point.

⚛️ @videojs/react — no changes
Presets (7)
Entry Size
/video (default) 23.53 kB
/video (default + hls) 155.65 kB
/video (minimal) 21.14 kB
/video (minimal + hls) 153.41 kB
/audio (default) 19.12 kB
/audio (minimal) 17.67 kB
/background 756 B
Media (7)
Entry Size
/media/background-video 575 B
/media/dash-video 235.21 kB
/media/hls-video 133.34 kB
/media/mux-audio 159.31 kB
/media/mux-video 159.49 kB
/media/native-hls-video 3.13 kB
/media/simple-hls-video 14.44 kB
Skins (26)
Entry Type Size
/video/minimal-skin.css css 3.46 kB
/video/skin.css css 3.48 kB
/video/minimal-skin js 21.04 kB
/video/minimal-skin.tailwind js 24.57 kB
/video/skin js 23.44 kB
/video/skin.tailwind js 24.69 kB
/audio/minimal-skin.css css 2.45 kB
/audio/skin.css css 2.41 kB
/audio/minimal-skin js 17.58 kB
/audio/minimal-skin.tailwind js 20.06 kB
/audio/skin js 19.04 kB
/audio/skin.tailwind js 20.05 kB
/background/skin.css css 90 B
/background/skin js 272 B
/live-video/minimal-skin.css css 3.46 kB
/live-video/skin.css css 3.48 kB
/live-video/minimal-skin js 17.78 kB
/live-video/minimal-skin.tailwind js 21.19 kB
/live-video/skin js 20.19 kB
/live-video/skin.tailwind js 21.35 kB
/live-audio/minimal-skin.css css 2.45 kB
/live-audio/skin.css css 2.41 kB
/live-audio/minimal-skin js 15.78 kB
/live-audio/minimal-skin.tailwind js 18.04 kB
/live-audio/skin js 17.24 kB
/live-audio/skin.tailwind js 18.17 kB
UI Components (20)
Entry Size
/ui/alert-dialog 1.11 kB
/ui/buffering-indicator 1.83 kB
/ui/captions-button 2.01 kB
/ui/cast-button 2.03 kB
/ui/controls 1.86 kB
/ui/error-dialog 2.25 kB
/ui/fullscreen-button 2.04 kB
/ui/mute-button 2.04 kB
/ui/pip-button 2.02 kB
/ui/play-button 2.00 kB
/ui/playback-rate-button 2.04 kB
/ui/popover 1.89 kB
/ui/poster 1.68 kB
/ui/seek-button 2.09 kB
/ui/slider 3.34 kB
/ui/thumbnail 1.99 kB
/ui/time 2.47 kB
/ui/time-slider 3.02 kB
/ui/tooltip 2.16 kB
/ui/volume-slider 2.38 kB

Sizes are marginal over the root entry point.

🧩 @videojs/core — no changes
Entries (9)
Entry Size
. 4.94 kB
/dom 11.93 kB
/dom/media/custom-media-element 1.90 kB
/dom/media/dash 234.36 kB
/dom/media/google-cast 4.07 kB
/dom/media/hls 132.72 kB
/dom/media/mux 158.81 kB
/dom/media/native-hls 2.52 kB
/dom/media/simple-hls 13.83 kB
🏷️ @videojs/element — no changes
Entries (2)
Entry Size
. 996 B
/context 943 B
📦 @videojs/store — no changes
Entries (3)
Entry Size
. 1.39 kB
/html 695 B
/react 360 B
🔧 @videojs/utils — no changes
Entries (10)
Entry Size
/array 104 B
/dom 1.92 kB
/events 319 B
/function 327 B
/object 275 B
/predicate 265 B
/string 148 B
/style 190 B
/time 478 B
/number 158 B
📦 @videojs/spf — no changes
Entries (3)
Entry Size
. 40 B
/dom 13.33 kB
/playback-engine 13.24 kB

ℹ️ How to interpret

All sizes are standalone totals (minified + brotli).

Icon Meaning
No change
🔺 Increased ≤ 10%
🔴 Increased > 10%
🔽 Decreased
🆕 New (no baseline)

Run pnpm size locally to check current sizes.

@mihar-22 mihar-22 changed the title refactor(core): move media predicates to core/media and drop cast button any cast refactor(core): move media predicates to core/media Apr 28, 2026
mihar-22 and others added 2 commits April 27, 2026 23:05
…core/media

Capability predicates (`isMediaPauseCapable`, `isMediaSeekCapable`, etc.)
duck-type on the capability interfaces in `core/media/types` and don't
depend on any DOM types, so they belong alongside the types they guard.

DOM-side feature consumers now import these predicates directly from
`core/media/predicate`. `dom/media/predicate.ts` keeps DOM-specific
guards like `isQuerySelectorAllCapable`.

This unblocks non-DOM consumers (e.g., react-native, future shims) from
importing the predicates without pulling DOM types.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
`media.remotePlaybackAvailability` already resolves to `'unsupported'`
when the remote-playback feature's `watchAvailability` rejects, so the
extra `(globalThis as any).chrome` guard in CastButtonCore was both
redundant and an `any` cast. Drop it and let the upstream availability
state flow through unchanged.

Tests no longer need to stub `globalThis.chrome`.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@mihar-22 mihar-22 force-pushed the refactor/cast-any-fix branch from 388ac38 to 3855729 Compare April 28, 2026 06:05
@mihar-22 mihar-22 marked this pull request as ready for review April 28, 2026 06:14
@mihar-22 mihar-22 requested a review from luwes April 28, 2026 06:14

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 3855729. Configure here.

Comment thread packages/core/src/core/ui/cast-button/tests/cast-button-core.test.ts Outdated
The replacement test added when removing the `globalThis.chrome` stub
duplicated the existing "reflects unsupported availability" case. Drop
it; the original test already covers the same code path now that the
chrome global check is gone.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

getState(): CastButtonState {
const media = this.#media!;
const castSupported = !!(globalThis as any).chrome;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

where is this logic replaced? This is needed to prevent showing the cast button on Safari.

@luwes

luwes commented Jun 18, 2026

Copy link
Copy Markdown
Collaborator

closed by #1705

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants