feat(core): add buffering indicator component#527
Merged
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. 1 Skipped Deployment
|
✅ Deploy Preview for vjs10-site ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Contributor
📦 Bundle Size Report
Total: 24.79 kB · +797 B · +3.2% Entry BreakdownSubpath sizes are the additional bytes on top of the root entry point, measured by bundling root + subpath together and subtracting the root-only size.
|
| 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.
…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).
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.
Closes #270
Summary
Add the
BufferingIndicatorcomponent for HTML and React. Core usescreateStatefrom@videojs/storefor reactive state management, making it compatible with both HTML elements (state.subscribe) and React (useSyncExternalStore).Changes
BufferingIndicatorCorewith configurable delay (default 500ms) to avoid flashing on quick buffersupdate(media)manages the delay timer (idempotent, safe to call on every render)state.current.visiblefor pure reads,state.subscribe()for reactivity<media-buffering-indicator>HTML custom element withdelayproperty<BufferingIndicator />React component withdelayprop, render prop, and className/style as functions of statedata-visibleattribute as the CSS hookImplementation details
The core uses
createStatefrom@videojs/storeas its reactive state container. This providesObject.is()equality checks (no spurious notifications), batched microtask flush, andAbortSignalsupport on subscriptions.update(media)is the only side-effectful method — it manages the delay timer and patchesstateon 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:
state.subscribe(() => requestUpdate())inconnectedCallbackwithAbortSignaluseSyncExternalStore(cb => core.state.subscribe(cb), () => core.state.current)withcore.update(playback)in the render pathTesting
pnpm -F @videojs/core test src/core/ui/buffering-indicator19 tests covering delay timing, state transitions, idempotency, subscribe notifications, custom delay, mid-buffering setProps, and destroy cleanup.