diff --git a/commitlint.config.js b/commitlint.config.js index 85b5ba75..c2f85b9f 100644 --- a/commitlint.config.js +++ b/commitlint.config.js @@ -13,6 +13,7 @@ export default { 2, 'always', [ + 'build', 'cd', 'ci', 'claude', diff --git a/internal/design/media-api.md b/internal/design/media-api.md index ac14a2bc..3bb9b929 100644 --- a/internal/design/media-api.md +++ b/internal/design/media-api.md @@ -158,66 +158,69 @@ interface MediaApi extends MediaBaseApi, // ... } -export interface MediaApiProxyTarget extends EventTarget {} - -// Proxy mixin that creates a MediaApi from the passed classes and proxies the methods and properties to the attached target. -export const MediaProxyMixin = ( - ...MediaApiTargetClasses: AnyConstructor[] -) => class MediaApiProxy { - // Logic that proxies media API to the media target - // ... - - // Attach media target to the media instance - target: MediaApiProxyTarget; - attach(target: MediaApiProxyTarget): void; - detach(): void; - - // Proxy handlers - get(prop: keyof MediaApiProxyTarget): any; - set(prop: keyof MediaApiProxyTarget, val: any): void; - call(prop: keyof MediaApiProxyTarget, ...args: any[]): any; +export interface Delegate { + attach?(target: EventTarget): void; + detach?(): void; } -// Size optimized for the most common use case of proxying HTMLMediaElement. -export class MediaApiProxy extends MediaProxyMixin(HTMLMediaElement, EventTarget) {} -export class VideoApiProxy extends MediaProxyMixin(HTMLVideoElement, HTMLMediaElement, EventTarget) {} -export class AudioApiProxy extends MediaProxyMixin(HTMLAudioElement, HTMLMediaElement, EventTarget) {} +// DelegateMixin intercepts get/set/call to route through a Delegate before falling through to the base class. +export function DelegateMixin>( + BaseClass: Base, + DelegateClass: D +): Constructor & InstanceType>; + + +// ProxyMixin creates a class that proxies methods and properties to the attached target. +export const ProxyMixin = ( + PrimaryClass: AnyConstructor, + ...AdditionalClasses: AnyConstructor[] +) => class MediaProxy { + target: EventTarget | null; + attach(target: EventTarget): void; + detach(): void; + + get(prop: keyof EventTarget): any; + set(prop: keyof EventTarget, val: any): void; + call(prop: keyof EventTarget, ...args: any[]): any; +} + +// Pre-built proxy for video elements. +export const VideoProxy = ProxyMixin(HTMLVideoElement, HTMLMediaElement, EventTarget); + +// CustomVideoElement wraps a native