feat(react): add createMediaComponent - #2604
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
d56298a to
84cab08
Compare
@videojs/cdn
@videojs/cloudflare-video
@videojs/core
@videojs/dash-video
@videojs/element
@videojs/google-cast
@videojs/hlsjs-video
@videojs/html
@videojs/media
@videojs/mux-audio
@videojs/mux-data
@videojs/mux-video
@videojs/native-hls-video
@videojs/react
@videojs/shaka-video
@videojs/spf
@videojs/spotify-audio
@videojs/store
@videojs/tiktok-video
@videojs/twitch-video
@videojs/utils
@videojs/vimeo-video
@videojs/wistia-video
@videojs/youtube-video
commit: |
📦 Bundle Size Report🎨 @videojs/html — no changesPresets (7)
Media (18)
Players (5)
Skins (29)
UI Components (62)
⚛️ @videojs/react — 22 small size changes
Presets (7)
Media (22)
Extensions (2)
Players (5)
Skins (18)
UI Components (39)
🧩 @videojs/core — no changesEntries (76)
🏷️ @videojs/element — no changesEntries (2)
📦 @videojs/store — no changesEntries (3)
🔧 @videojs/utils — no changesEntries (13)
📦 @videojs/cdn — no changes📦 @videojs/cloudflare-video — no changes📦 @videojs/dash-video — no changes📦 @videojs/google-cast — no changes📦 @videojs/hlsjs-video — no changes📦 @videojs/media — no changesEntries (3)
📦 @videojs/mux — no changes📦 @videojs/mux-audio — no changesEntries (2)
📦 @videojs/mux-data — no changes📦 @videojs/mux-video — no changesEntries (2)
📦 @videojs/native-hls-video — no changes📦 @videojs/shaka-video — no changes📦 @videojs/spf — no changesEntries (7)
📦 @videojs/spotify-audio — no changes📦 @videojs/tiktok-video — no changes📦 @videojs/twitch-video — no changes📦 @videojs/vimeo-video — no changes📦 @videojs/wistia-video — no changesEntries (2)
📦 @videojs/youtube-video — no changesℹ️ How to interpretEach 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 |
✅ Deploy Preview for vjs10-site ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
84cab08 to
7c1d2e6
Compare
7c1d2e6 to
e155a0c
Compare
e155a0c to
46f504b
Compare
46f504b to
fa437f8
Compare
fa437f8 to
3601865
Compare
3601865 to
3e68162
Compare
3e68162 to
b81d177
Compare
7878580 to
82c5e3d
Compare
|
E2E triage: real regression — the generated Next.js registry consumer cannot resolve the required |
82c5e3d to
8ae67eb
Compare
8ae67eb to
eac3726
Compare
eac3726 to
5fc9903
Compare
5fc9903 to
657b514
Compare
657b514 to
30e54dc
Compare
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 30e54dc. Configure here.
30e54dc to
4ff3522
Compare
`createMediaComponent(tag, Adapter, options?)` builds a component that renders a native `<video>` or `<audio>`, drives it through one adapter instance, syncs the adapter's props from React props against `Adapter.defaultProps`, forwards everything else (and the ref) to the element, and registers with the Player. The six built-in components that followed that exact shape now use it. The media reference builder reads the target and defaults straight from the factory call, so those components keep their generated React prop tables. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
4ff3522 to
06d6e5d
Compare

What this does
Adds
createMediaComponent, the React façade factory, and builds every React media component with it exceptWistiaVideoandHlsBackgroundVideo.Shape
createMediaComponent(Adapter, render, options?)The render callback receives:
adapterpropschildrenrefinitialPropssrc)Types follow from the adapter alone: the ref and native attributes come from its
attach()target (MediaAdapterTarget), and the adapter props from its staticdefaultProps. No tag parameter, so iframe embeds and the Mux components (with their storyboard child) use the same factory.Also
useAttachMediaaccepts any element target;useAttachIframeis gone.createMediaComponentreference page.Validation
Build, typecheck, lint,
@videojs/reacttests, builder e2e suite, site tests, regenerated media references.🤖 Generated with Claude Code
Note
Medium Risk
Wide refactor across every migrated media component and public prop typings; behavior should be equivalent but regressions in embed initial URLs, prop sync, or Mux storyboard wiring are the main risk areas.
Overview
Introduces
createMediaComponent, a shared factory that wiresuseMediaInstance, prop sync, attach refs, and frozeninitialPropsinto a render callback, and rebuilds nearly all built-in React media components (video/audio<video>/<audio>and iframe embeds) on top of it instead of duplicatedforwardRef+ hooks.Public API: exports the factory plus
MediaComponentPropsand related types from@videojs/react; component prop types are nowMediaComponentProps<typeof SomeAdapter>rather than hand-written intersections (notably simpler Mux variants). Embed components keep first-mount URL behavior viainitialPropsand read live adapter state (e.g.referrerPolicy, Spotifycontrols/visibility) fromadapter.Internals: removes
useAttachIframeand loosensuseAttachMediato generic element targets. Adds unit tests for attach, prop splitting,initialProps, and ref/displayName.Docs/tooling: new reference page and sidebar entry; the API docs builder detects
createMediaComponent(Adapter, render)to infer DOM target from the callback’s root JSX and defaults fromAdapter.defaultProps, with fixture/e2e updates.Reviewed by Cursor Bugbot for commit 06d6e5d. Bugbot is set up for automated code reviews on this repo. Configure here.