refactor(core)!: move media capability predicates to core layer#1705
Merged
Conversation
Move the media capability type guards and their sentinel constants from the DOM layer (dom/media) into the runtime-agnostic core/media layer. Replace the DOM-lib types in isQuerySelectorAllCapable with a framework-agnostic NodeListLike look-alike so it compiles under the core project's WebWorker lib. BREAKING CHANGE: the media capability guards (isMediaPauseCapable, isMediaSeekCapable, etc.) and isQuerySelectorAllCapable now export from @videojs/core instead of @videojs/core/dom.
✅ Deploy Preview for vjs10-site ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
📦 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
Entries (68)
🏷️ @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 |
1754166 to
bafeb42
Compare
…path Expose the media capability predicates as a granular @videojs/core/media/predicate subpath and re-export them from the html and react package entry points.
mihar-22
approved these changes
Jun 18, 2026
…ml and react The predicates are already re-exported via the @videojs/core/media/predicate subpath, so the explicit @videojs/core re-export block is redundant.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The media capability type guards lived in the DOM layer (
dom/media/predicate.ts) but are fundamentally runtime-agnostic — they only check object shapes. This moves them (and the sentinel constants they compare against) into thecore/medialayer where they belong, keeping the DOM layer focused on genuinely DOM-bound code.Changes
isMediaPauseCapable,isMediaSeekCapable,hasMetadata, etc.) and theEMPTY_*sentinel constants now live incore/mediaand are part of the@videojs/coresurface.isQuerySelectorAllCapablemoved too; its DOM-lib return type (NodeListOf<HTMLElementTagNameMap[...]>) is replaced with a framework-agnosticNodeListLike<Element>look-alike, and the element type is now supplied at the call site.media-host,vimeo) updated to import from the new locations.Why this needed more than a file move
The
core/project compiles withlib: ["ES2022", "WebWorker"](no DOM lib) and cannot import fromdom/. So the predicates couldn't simply be relocated:isQuerySelectorAllCapablereferencedNodeListOf/HTMLElementTagNameMap, which don't exist without the DOM lib — hence theNodeListLikelook-alike.EMPTY_TIME_RANGES/EMPTY_TEXT_TRACKS/EMPTY_REMOTE, so those constants moved alongside (they're framework-agnostic —EventTargetandObject.freezeonly).Breaking change
The guards and
isQuerySelectorAllCapablenow export from@videojs/coreinstead of@videojs/core/dom. No in-repo or cross-package code imports them by name, so nothing internal breaks.Testing
Covered by existing tests (moved alongside the source).
pnpm -F @videojs/core testpasses (1614 tests);pnpm typecheckreports zero errors inpackages/core.Note
Medium Risk
Breaking public export paths for anyone importing predicates from
@videojs/core/dom; behavior should be unchanged but widespread type-guard usage affects feature gating across the player store.Overview
Breaking: Runtime-agnostic media capability type guards (
isMediaPauseCapable,hasMetadata, etc.), theEMPTY_*sentinel constants they use, andisQuerySelectorAllCapablenow live undercore/mediaand ship from@videojs/core(main entry) and@videojs/core/media/predicate, not from@videojs/core/dom.isQuerySelectorAllCapableno longer depends on DOM lib types (NodeListOf/HTMLElementTagNameMap); it uses a framework-agnosticNodeListLike<Element>, with the element type supplied at call sites (e.g.HTMLTrackElementin the text-track feature).DOM store features,
media-host, and Vimeo imports are retargeted to../../../core/media/predicateand../../../core/media/constants.@videojs/htmland@videojs/reactre-export predicates from the new subpath so consumers keep a single import surface.Reviewed by Cursor Bugbot for commit 3724ac3. Bugbot is set up for automated code reviews on this repo. Configure here.