Skip to content

feat(html): refactor attach contexts to carry state and setter#1024

Merged
mihar-22 merged 1 commit intomainfrom
claude/jovial-lichterman
Mar 19, 2026
Merged

feat(html): refactor attach contexts to carry state and setter#1024
mihar-22 merged 1 commit intomainfrom
claude/jovial-lichterman

Conversation

@mihar-22
Copy link
Copy Markdown
Member

@mihar-22 mihar-22 commented Mar 19, 2026

Summary

  • Refactors HTML custom element contexts from simple setter callbacks (mediaAttachContext, containerAttachContext) to richer context objects carrying both current value and setter (mediaContext, containerContext)
  • Adds container to React PlayerContextValue and exposes useContainer() hook
  • Enables descendant elements to read current media/container reference without a separate context

Extracted from #805 to land independently — #805 will rebase on top.

Test plan

  • pnpm typecheck passes
  • pnpm -F @videojs/html test — 86 tests pass
  • pnpm -F @videojs/react test — 195 tests pass (includes new useContainer tests)
  • pnpm build:packages succeeds

🤖 Generated with Claude Code

Co-authored-by: Wesley Luyten @luwes

@vercel
Copy link
Copy Markdown

vercel bot commented Mar 19, 2026

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

Project Deployment Actions Updated (UTC)
v10-sandbox Ready Ready Preview, Comment Mar 19, 2026 7:44am

Request Review

@netlify
Copy link
Copy Markdown

netlify bot commented Mar 19, 2026

Deploy Preview for vjs10-site ready!

Name Link
🔨 Latest commit f6d178d
🔍 Latest deploy log https://app.netlify.com/projects/vjs10-site/deploys/69bba95a8a9d2900083820a2
😎 Deploy Preview https://deploy-preview-1024--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.

@mihar-22 mihar-22 changed the title feat(html,react): refactor attach contexts to carry state and setter feat(html): refactor attach contexts to carry state and setter Mar 19, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Mar 19, 2026

📦 Bundle Size Report

🎨 @videojs/html — no changes
Presets (7)
Entry Size
/video (default) 23.17 kB
/video (default + hls) 153.69 kB
/video (minimal) 23.03 kB
/video (minimal + hls) 153.51 kB
/audio (default) 21.42 kB
/audio (minimal) 21.40 kB
/background 6.38 kB
Media (5)
Entry Size
/media/background-video 1.03 kB
/media/container 1.59 kB
/media/dash-video 236.04 kB
/media/hls-video 131.57 kB
/media/simple-hls-video 12.33 kB
Players (3)
Entry Size
/video/player 6.24 kB
/audio/player 6.23 kB
/background/player 6.23 kB
Skins (16)
Entry Type Size
/video/minimal-skin.css css 3.11 kB
/video/skin.css css 3.14 kB
/video/minimal-skin js 22.24 kB
/video/minimal-skin.tailwind js 22.45 kB
/video/skin js 22.36 kB
/video/skin.tailwind js 22.71 kB
/audio/minimal-skin.css css 2.25 kB
/audio/skin.css css 2.29 kB
/audio/minimal-skin js 20.61 kB
/audio/minimal-skin.tailwind js 20.66 kB
/audio/skin js 20.63 kB
/audio/skin.tailwind js 20.86 kB
/background/skin.css css 117 B
/background/skin js 1003 B
/base.css css 157 B
/shared.css css 43 B
UI Components (21)
Entry Size
/ui/alert-dialog 2.08 kB
/ui/alert-dialog-close 1.58 kB
/ui/alert-dialog-description 1.50 kB
/ui/alert-dialog-title 1.51 kB
/ui/buffering-indicator 1.78 kB
/ui/captions-button 1.78 kB
/ui/controls 1.65 kB
/ui/fullscreen-button 1.78 kB
/ui/mute-button 1.80 kB
/ui/pip-button 1.80 kB
/ui/play-button 1.80 kB
/ui/playback-rate-button 1.84 kB
/ui/popover 3.24 kB
/ui/poster 1.70 kB
/ui/seek-button 1.80 kB
/ui/slider 1.98 kB
/ui/thumbnail 2.14 kB
/ui/time 1.62 kB
/ui/time-slider 2.11 kB
/ui/tooltip 2.41 kB
/ui/volume-slider 2.19 kB

Sizes are marginal over the root entry point.

⚛️ @videojs/react — no changes
Presets (7)
Entry Size
/video (default) 18.94 kB
/video (default + hls) 149.81 kB
/video (minimal) 18.98 kB
/video (minimal + hls) 149.69 kB
/audio (default) 14.94 kB
/audio (minimal) 14.98 kB
/background 3.13 kB
Media (4)
Entry Size
/media/background-video 476 B
/media/dash-video 236.19 kB
/media/hls-video 131.59 kB
/media/simple-hls-video 12.34 kB
Skins (14)
Entry Type Size
/video/minimal-skin.css css 3.11 kB
/video/skin.css css 3.14 kB
/video/minimal-skin js 18.90 kB
/video/minimal-skin.tailwind js 22.08 kB
/video/skin js 18.89 kB
/video/skin.tailwind js 22.08 kB
/audio/minimal-skin.css css 2.25 kB
/audio/skin.css css 2.29 kB
/audio/minimal-skin js 14.90 kB
/audio/minimal-skin.tailwind js 16.98 kB
/audio/skin js 14.90 kB
/audio/skin.tailwind js 17.24 kB
/background/skin.css css 90 B
/background/skin js 272 B
UI Components (18)
Entry Size
/ui/alert-dialog 2.23 kB
/ui/buffering-indicator 2.22 kB
/ui/captions-button 2.27 kB
/ui/controls 2.23 kB
/ui/fullscreen-button 2.23 kB
/ui/mute-button 2.28 kB
/ui/pip-button 2.23 kB
/ui/play-button 2.25 kB
/ui/playback-rate-button 2.26 kB
/ui/popover 2.85 kB
/ui/poster 2.07 kB
/ui/seek-button 2.26 kB
/ui/slider 3.16 kB
/ui/thumbnail 2.06 kB
/ui/time 1.93 kB
/ui/time-slider 2.67 kB
/ui/tooltip 2.71 kB
/ui/volume-slider 2.70 kB

Sizes are marginal over the root entry point.

🧩 @videojs/core — no changes
Entries (6)
Entry Size
. 4.80 kB
/dom 8.41 kB
/dom/media/custom-media-element 1.81 kB
/dom/media/dash 235.62 kB
/dom/media/hls 131.27 kB
/dom/media/simple-hls 11.85 kB
🏷️ @videojs/element — no changes
Entries (2)
Entry Size
. 999 B
/context 943 B
📦 @videojs/store — no changes
Entries (3)
Entry Size
. 1.32 kB
/html 700 B
/react 360 B
🔧 @videojs/utils — no changes
Entries (10)
Entry Size
/array 104 B
/dom 1.25 kB
/events 227 B
/function 261 B
/object 119 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 10.04 kB
/playback-engine 9.94 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.

@github-actions
Copy link
Copy Markdown
Contributor

CI Failure Diagnosis

File Type What failed
packages/html/src/store/media-attach-mixin.ts typecheck Imports MediaAttachContext and mediaAttachContext from ../player/context, but those exports don't exist (did you mean MediaContext / mediaContext?).

Refactors the HTML custom element context system from simple setter
callbacks (`mediaAttachContext`, `containerAttachContext`) to richer
context objects that carry both the current value and its setter
(`mediaContext`, `containerContext`). This enables descendant elements
to read the current media/container reference without needing a
separate context.

On the React side, adds `container` to `PlayerContextValue` and
exposes a `useContainer()` hook for accessing the container element.

Extracted from #805.

Co-authored-by: Wesley Luyten <luwes@users.noreply.github.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@mihar-22 mihar-22 force-pushed the claude/jovial-lichterman branch from 396f2c8 to f6d178d Compare March 19, 2026 07:44
@mihar-22 mihar-22 marked this pull request as ready for review March 19, 2026 07:46
Copilot AI review requested due to automatic review settings March 19, 2026 07:46
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Refactors the HTML custom element “attach” contexts to provide richer media/container context objects (current value + setter), and extends the React player context to expose the current container element via a new useContainer() hook.

Changes:

  • HTML: Replace mediaAttachContext / containerAttachContext (setter-only) with mediaContext / containerContext (value + setter) and update mixins/providers to publish/consume them.
  • React: Add container to PlayerContextValue, plumb it through the Provider, and export a new useContainer() hook.
  • Tests: Update React mocks/tests to include container and add coverage for useContainer().

Reviewed changes

Copilot reviewed 13 out of 13 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
packages/react/src/testing/mocks.tsx Updates test wrapper context value shape to include container.
packages/react/src/player/tests/context.test.tsx Adds tests for useContainer() and updates context value helper.
packages/react/src/player/create-player.tsx Passes container through the Provider context value.
packages/react/src/player/context.tsx Adds container to context, introduces useContainer(), and exports it.
packages/react/src/media/tests/video.test.tsx Updates context values used by Video tests to include container.
packages/react/src/media/tests/audio.test.tsx Updates context values used by Audio tests to include container.
packages/react/src/index.ts Re-exports useContainer.
packages/html/src/store/provider-mixin.ts Provider now publishes media/container context objects (value + setter).
packages/html/src/store/media-attach-mixin.ts Consumes mediaContext and uses value.setMedia instead of a bare callback.
packages/html/src/store/container-mixin.ts Consumes containerContext and uses value.setContainer instead of a bare callback.
packages/html/src/player/create-player.ts Wires new mediaContext / containerContext into mixins.
packages/html/src/player/context.ts Introduces mediaContext / containerContext and switches keys to Symbol.for.
packages/html/src/media/container-element.ts Updates container element to use the new containerContext.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

Comment thread packages/react/src/player/context.tsx
Comment thread packages/react/src/player/create-player.tsx
@mihar-22 mihar-22 merged commit c07da27 into main Mar 19, 2026
24 checks passed
@mihar-22 mihar-22 deleted the claude/jovial-lichterman branch March 19, 2026 07:49
@luwes luwes mentioned this pull request Mar 19, 2026
This was referenced Apr 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants