refactor(packages)!: dry up core, html, and react UI architecture#699
Merged
refactor(packages)!: dry up core, html, and react UI architecture#699
Conversation
✅ Deploy Preview for vjs10-site ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Introduce UICore interface and shared base classes to eliminate duplicated patterns across HTML and React UI components. Unify slider interaction model, pending seek lifecycle, and type inference into core so both platforms share a single source of truth.
b0e2780 to
553f805
Compare
Contributor
📦 Bundle Size Report
Total: 54.16 kB · +381 B · +0.7% 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 | % | |
|---|---|---|---|---|---|
. |
4.28 kB | 4.39 kB | +104 B | +2.4% | 🔺 |
./dom |
6.03 kB | 6.03 kB | +1 B | +0.0% | 🔺 |
| total | 10.31 kB | 10.41 kB | +105 B | +1.0% |
@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/html
| Entry | Base | PR | Diff | % | |
|---|---|---|---|---|---|
. |
15.18 kB | 15.41 kB | +234 B | +1.5% | 🔺 |
./video |
1.08 kB | 1.05 kB | -26 B | -2.4% | 🔽 |
./audio |
1.06 kB | 1.03 kB | -36 B | -3.3% | 🔽 |
./background |
1.07 kB | 1.02 kB | -56 B | -5.1% | 🔽 |
| total | 18.39 kB | 18.51 kB | +116 B | +0.6% |
@videojs/icons
| Entry | Base | PR | Diff | % | |
|---|---|---|---|---|---|
./react |
2.27 kB | 2.27 kB | 0 B | 0% | ✅ |
./html |
1.52 kB | 1.52 kB | 0 B | 0% | ✅ |
| total | 3.79 kB | 3.79 kB | 0 B | 0% |
@videojs/store
| Entry | Base | PR | Diff | % | |
|---|---|---|---|---|---|
. |
1.29 kB | 1.31 kB | +18 B | +1.4% | 🔺 |
./html |
468 B | 472 B | +4 B | +0.9% | 🔺 |
./react |
204 B | 199 B | -5 B | -2.5% | 🔽 |
| total | 1.95 kB | 1.96 kB | +17 B | +0.9% |
@videojs/utils
| Entry | Base | PR | Diff | % | |
|---|---|---|---|---|---|
./array |
104 B | 104 B | 0 B | 0% | ✅ |
./dom |
928 B | 928 B | 0 B | 0% | ✅ |
./events |
227 B | 227 B | 0 B | 0% | ✅ |
./function |
261 B | 261 B | 0 B | 0% | ✅ |
./object |
119 B | 119 B | 0 B | 0% | ✅ |
./predicate |
265 B | 265 B | 0 B | 0% | ✅ |
./string |
148 B | 148 B | 0 B | 0% | ✅ |
./style |
185 B | 185 B | 0 B | 0% | ✅ |
./time |
478 B | 478 B | 0 B | 0% | ✅ |
./number |
158 B | 158 B | 0 B | 0% | ✅ |
| total | 2.81 kB | 2.81 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.
Contributor
CI Failure Diagnosis
|
Contributor
CI Failure Diagnosis
|
7f9194c to
9ccb00e
Compare
…clean up slider props
9ccb00e to
3918cfc
Compare
…atureName to displayName
…attern Replace UICore with UIComponent/MediaUIComponent interfaces. All 12 core classes now use setMedia()/setInput() + parameterless getState() instead of getState(media). PopoverInteraction renamed to PopoverInput, .interaction to .input. Add ContextPartElement base class (HTML) and createContextPart factory (React) for DRY compound-component parts. Slider Track/Fill/Buffer and PopoverArrow now use the shared pattern. stateAttrMap added to slider and popover context values. Controls gains full compound pattern: ControlsElement provides context, ControlsGroupElement consumes it for data-attribute propagation.
…enerics PopoverHandle → PopoverApi, ThumbnailHandle → ThumbnailApi, TransitionHandler → TransitionApi, createTransitionHandler → createTransition. PartContextValue and ContextPartConfig now use a generic State parameter instead of hardcoded object. Remove unnecessary StateAttrMap<object> casts from slider and controls root elements.
7e4fc62 to
295f617
Compare
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
DRY up repetitive UI code across store, core, html, and react. Introduces shared type contracts, base classes for HTML elements, factories for React components, and consistent naming across the board.
Changes
Store
Selectorconverted from intersection type to callable interface withdisplayName?: string | undefinedcreateSelectorsimplified — no separate meta object, inlines{ displayName: slice.name }nameproperty for debug labelingCore — type system
UIComponent<Props, State>andMediaUIComponent<Props, State>interfaces replace oldUICoreInferMediaState<Core>andInferComponentState<Core>use indexed access types (Parameters/ReturnType) instead of conditional types — eliminates deferred type resolution and removes allas nevercasts in consumersStateAttrMap<State>for typed data-attribute mapsCore — setMedia/setInput pattern
setMedia()/setInput()+ parameterlessgetState()#mediafields withType | null = nullSliderCoregainsgetStepPercent(),getLargeStepPercent(),adjustPercentForAlignment()Core — naming
SliderHandle→SliderApi,PopoverHandle→PopoverApi,ThumbnailHandle→ThumbnailApiTransitionHandler→TransitionApi,createTransitionHandler()→createTransition()SliderInteraction→SliderInput,.interaction→.inputdataAttrs→stateAttrMapeverywherefeatureName→displayName,NamedSelectorremovedcommitSeekremoved (media.currentTime set synchronously before first await)SliderBasePropsremoved — domain sliders extendSliderPropswith@internalon value/min/maxnamepropertyapplyElementPropsoptions changed to{ signal?: AbortSignal }HTML — base classes
MediaButtonElement<Core>abstract base — all 6 button elements extend itMediaUIElement<Core>abstract base — poster extends itContextPartElement<State>abstract base with Lit context protocol — slider Track/Fill/Buffer and controls Group extend itControlsElementprovides context,ControlsGroupElementconsumes itslider-context.ts→context.ts(directory already scopes)ctx.stateAttrMapfrom context instead of hardcoded imports#handle→#apiin ThumbnailElementReact — factories
createMediaButton<Core, Props>(config)— flat generic signature (no curry), typedstateAttrMapviaInferComponentState<Core>, automatic prop splitting viaCoreClass.defaultPropskeys. All 6 buttons use itcreateContextPart<Props, State>(config)— typeduseContextreturn,staticPropsasPartial<Props>. Slider Track/Fill/Buffer and popover Arrow use ituseSliderContext,useControlsContext) throw when used outside providercontext.stateAttrMapinstead of hardcodedPopoverDataAttrsImplementation details
super()argsInferMediaStateusesParameters<Core['setMedia']>[0]— indexed access resolves via the constraint whenCoreis generic (unlike conditional types which defer). This is why theas nevercasts are goneContextPartElement.update()keepsif (ctx)guard — Lit context protocol is async and the first update can fire before the provider's setValue. React context is synchronous so hooks throw immediatelyForwardRefExoticComponentreturn type oncreateContextPart/createMediaButtonis required for React 18 ref support (peer dep is>=16.8.0)createMediaButtonretains two casts:core.getState() as InferComponentState<Core>(deferred utility type) andas unknown as ForwardRefExoticComponent(forwardRef + dynamic prop splitting)Testing
All existing tests updated + new tests for selector displayName and slider features.