refactor(core): rework media config as a plain getter/setter#1697
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
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.
Want higher recall? High effort reviews run extra passes and find more bugs. A team admin can switch effort levels in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit f029512. Configure here.
Split media utils into components/config modules and rework how component config is exposed on the host. - Component config is no longer bridged via Object.defineProperty on the config object. The getter enumerates registered components live under their configKey; the setter routes matching keys onto the component. - Assigning a new config object now resets the free-form host/engine bag (start-fresh intent) instead of merging. Component state is preserved and only overwritten per-key by the incoming config. - Reading config returns a fresh object, so mutating the result no longer writes through to components; use the setter instead. Stacked on #1695.
writeConfig clears the entire free-form bag on assignment, but component
namespace values staged before addComponent lived in that bag. A later
host.config = {…} that omitted the namespace silently dropped the staged
settings, so they were never adopted when the component registered.
Keep staged config in a separate per-host store that survives free-form
resets; components adopt their namespace from it on registration.
9a542da to
800c3b8
Compare
✅ Deploy Preview for vjs10-site ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
📦 Bundle Size Report🎨 @videojs/html — no changesPresets (7)
Media (10)
Players (5)
Skins (30)
UI Components (38)
Sizes are marginal over the root entry point. ⚛️ @videojs/react — no changesPresets (7)
Media (9)
Skins (27)
UI Components (32)
Sizes are marginal over the root entry point. 🧩 @videojs/core — no changesEntries (13)
🏷️ @videojs/element — no changesEntries (2)
📦 @videojs/store — no changesEntries (3)
🔧 @videojs/utils — no changesEntries (10)
📦 @videojs/spf — no changesEntries (4)
ℹ️ How to interpretAll sizes are standalone totals (minified + brotli).
Run |

Summary
Make
media.configa plain getter/setter and route media method calls through component overrides.Changes
configgetter returns exactly what was assigned — plain values and POJOs, never component instances.JSON.stringify(media.config)is valid input back into the setter.media.config = {...}replaces the object wholesale, so stale host/engine keys are dropped. This matches declarative usage where frameworks pass the full config each render.muxData,googleCast, …) is applied onto the registered component. Components keep their applied state when a later config omits their namespace.play,pause,load,canPlayType, andaddTextTrackresolve their owner viagetOwnerdirectly, replacing thecallProphelper.Behavior note
configno longer reflects live component instances or component-internal defaults (e.g.MuxData.playerSoftwareName). Read those from the component directly. Callers relying on incremental config merges must pass the full object or spread{ ...media.config, ... }. HTML/React elements setconfigas a whole property, so they're unaffected.Testing
Covered by existing + updated unit tests:
@videojs/coresrc/dom/media(288), plus@videojs/htmland@videojs/reactmedia suites green.Note
Medium Risk
Core media host config semantics change (replace vs merge) can break code that relied on partial
media.configassignments; playback delegation changes are localized but touch critical APIs.Overview
media.confignow replaces the whole config object instead of merging into the previous bag. Assigning{ hlsJs: … }alone drops other host/engine keys (e.g.preferPlayback,contentType); callers that need incremental updates must pass{ ...media.config, … }.Component config is decoupled from the config bag.
host.config.muxData(and otherconfigKeynamespaces) are plain POJOs—not live component instances—and only the setter applies namespace values onto registered components. In-place mutation ofhost.config.fake = { … }no longer updates components; omitted namespaces on a later assignment no longer clear already-applied component state (partial updates merge onto the instance).Component registration adopts staged namespace values from the current config when a component is added, without installing per-key proxies; destroy no longer strips component keys from config.
Media host delegation routes
play,pause,load,canPlayType, andaddTextTrackthroughgetOwnerdirectly;getPropno longer auto-binds methods. Tests cover HLS, Mux,MuxVideo, and host config edge cases.Reviewed by Cursor Bugbot for commit c02f39f. Bugbot is set up for automated code reviews on this repo. Configure here.