From 32a4039f7c2b94d334b7e66fd560de041654c5b4 Mon Sep 17 00:00:00 2001 From: Manuel Raynaud Date: Sun, 20 Dec 2020 10:18:53 +0100 Subject: [PATCH] Enhance types (#1841) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 🏷️(type) enhance QualityOptions type Some optional properties in the QualityOptions were missing. The forced and onChange property allwoing to use an external handler. * ♻️(type) use Plyr.Provider for the readonly provider property A type exists to define all available providers. This type isn't used in the Plyr class definition and the same provider list is also defined. This code is refactored to use the Plyr.Provider type * 🏷️(type) add missing elements property in Plyr class In Plyr class, you can access elements set in cache. This property is missing in the class definition. The Plyr.Elements is for now incomplete. --- src/js/plyr.d.ts | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/src/js/plyr.d.ts b/src/js/plyr.d.ts index 4b332aeb..479cfa98 100644 --- a/src/js/plyr.d.ts +++ b/src/js/plyr.d.ts @@ -138,10 +138,15 @@ declare class Plyr { */ ratio?: string; + /** + * Access Elements cache + */ + elements: Plyr.Elements; + /** * Returns the current video Provider */ - readonly provider: 'html5' | 'vimeo' | 'youtube'; + readonly provider: Plyr.Provider; /** * Returns the native API for Vimeo or Youtube players @@ -510,6 +515,8 @@ declare namespace Plyr { interface QualityOptions { default: number; + forced?: boolean; + onChange?: (quality: number) => void; options: number[]; } @@ -560,6 +567,27 @@ declare namespace Plyr { src?: string | string[]; } + export interface Elements { + buttons: { + airplay?: HTMLButtonElement; + captions?: HTMLButtonElement; + download?: HTMLButtonElement; + fastForward?: HTMLButtonElement; + fullscreen?: HTMLButtonElement; + mute?: HTMLButtonElement; + pip?: HTMLButtonElement; + play?: HTMLButtonElement | HTMLButtonElement[]; + restart?: HTMLButtonElement; + rewind?: HTMLButtonElement; + settings?: HTMLButtonElement; + }; + captions: HTMLElement | null; + container: HTMLElement | null; + controls: HTMLElement | null; + fullscreen: HTMLElement | null; + wrapper: HTMLElement | null; + } + interface SourceInfo { /** * Note: YouTube and Vimeo are currently not supported as audio sources.