Skip to content

feat(core): add buffering indicator component#527

Merged
mihar-22 merged 4 commits intomainfrom
feat/buffering-indicator
Feb 13, 2026
Merged

feat(core): add buffering indicator component#527
mihar-22 merged 4 commits intomainfrom
feat/buffering-indicator

Conversation

@mihar-22
Copy link
Member

@mihar-22 mihar-22 commented Feb 13, 2026

Closes #270

Summary

Add the BufferingIndicator component for HTML and React. Core uses createState from @videojs/store for reactive state management, making it compatible with both HTML elements (state.subscribe) and React (useSyncExternalStore).

Changes

  • BufferingIndicatorCore with configurable delay (default 500ms) to avoid flashing on quick buffers
  • update(media) manages the delay timer (idempotent, safe to call on every render)
  • state.current.visible for pure reads, state.subscribe() for reactivity
  • <media-buffering-indicator> HTML custom element with delay property
  • <BufferingIndicator /> React component with delay prop, render prop, and className/style as functions of state
  • Single data-visible attribute as the CSS hook
Implementation details

The core uses createState from @videojs/store as its reactive state container. This provides Object.is() equality checks (no spurious notifications), batched microtask flush, and AbortSignal support on subscriptions.

update(media) is the only side-effectful method — it manages the delay timer and patches state on transitions. It's idempotent: calling it repeatedly with the same input won't restart the timer. This makes it safe to call on every render in both HTML elements and React.

Platform wiring:

  • HTML: state.subscribe(() => requestUpdate()) in connectedCallback with AbortSignal
  • React: useSyncExternalStore(cb => core.state.subscribe(cb), () => core.state.current) with core.update(playback) in the render path

Testing

pnpm -F @videojs/core test src/core/ui/buffering-indicator

19 tests covering delay timing, state transitions, idempotency, subscribe notifications, custom delay, mid-buffering setProps, and destroy cleanup.

@vercel
Copy link

vercel bot commented Feb 13, 2026

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

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
vjs-10-demo-react Ignored Ignored Preview Feb 13, 2026 1:17pm

Request Review

@netlify
Copy link

netlify bot commented Feb 13, 2026

Deploy Preview for vjs10-site ready!

Name Link
🔨 Latest commit b1b60af
🔍 Latest deploy log https://app.netlify.com/projects/vjs10-site/deploys/698f246680582e0008ce3c2c
😎 Deploy Preview https://deploy-preview-527--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
Copy link
Contributor

github-actions bot commented Feb 13, 2026

📦 Bundle Size Report

Package Size Diff %
@videojs/core 4.60 kB +409 B ████████ +9.5% 🔺
@videojs/element 1.60 kB 0 B ░░░░░░░░ 0%
@videojs/html 7.85 kB +178 B ██░░░░░░ +2.3% 🔺
@videojs/react 7.01 kB +210 B ███░░░░░ +3.0% 🔺
@videojs/store 1.86 kB 0 B ░░░░░░░░ 0%
@videojs/utils 1.87 kB 0 B ░░░░░░░░ 0%

Total: 24.79 kB · +797 B · +3.2%


Entry Breakdown

Subpath sizes are the additional bytes on top of the root entry point, measured by bundling root + subpath together and subtracting the root-only size.

@videojs/core
Entry Base PR Diff %
. 1.52 kB 1.97 kB +463 B +29.7% 🔴
./dom 2.67 kB 2.62 kB -54 B -2.0% 🔽
total 4.20 kB 4.60 kB +409 B +9.5%
@videojs/element
Entry Base PR Diff %
. 817 B 817 B 0 B 0%
./context 823 B 823 B 0 B 0%
total 1.60 kB 1.60 kB 0 B 0%
@videojs/store
Entry Base PR Diff %
. 1.29 kB 1.29 kB 0 B 0%
./html 394 B 394 B 0 B 0%
./react 190 B 190 B 0 B 0%
total 1.86 kB 1.86 kB 0 B 0%
@videojs/utils
Entry Base PR Diff %
./array 104 B 104 B 0 B 0%
./dom 553 B 553 B 0 B 0%
./events 227 B 227 B 0 B 0%
./function 181 B 181 B 0 B 0%
./object 119 B 119 B 0 B 0%
./predicate 265 B 265 B 0 B 0%
./time 465 B 465 B 0 B 0%
total 1.87 kB 1.87 kB 0 B 0%

ℹ️ How to interpret

Sizes are minified + brotli, measured with esbuild.
Package totals are computed as root size + marginal subpath costs.
Subpath marginal cost = (root + subpath bundled together) − root alone.

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 feat(packages): add buffering indicator component feat(core): add buffering indicator component Feb 13, 2026
…state

Replace side-effectful getState() with pure state.current read and
separate update() method. Core now uses createState from @videojs/store
for reactive state management with subscribe support, making it
compatible with both HTML elements and React (useSyncExternalStore).
@mihar-22 mihar-22 merged commit aa0fb7c into main Feb 13, 2026
11 checks passed
@mihar-22 mihar-22 deleted the feat/buffering-indicator branch February 13, 2026 13:28
@github-actions github-actions bot mentioned this pull request Feb 13, 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.

UI: Buffering Indicator Component

1 participant