Skip to content

Commit

Permalink
fix(FEC-12097): More plugins - Update relevant types (#563)
Browse files Browse the repository at this point in the history
Update relevant TS types

solves: FEC-12097

related pr:
kaltura/playkit-js-ui-managers#10
  • Loading branch information
JonathanTGold authored Sep 25, 2022
1 parent 4c8c54c commit 2fb7bd4
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 3 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@
"shaka-player": "4.2.1"
},
"devDependencies": {
"@types/preact-i18n": "^2.3.1",
"@babel/cli": "^7.10.1",
"@babel/core": "^7.10.2",
"@babel/plugin-proposal-class-properties": "^7.10.1",
Expand Down
65 changes: 62 additions & 3 deletions types.d.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
import {Store} from 'redux';
import * as preactLib from 'preact';
import * as preacti18nLib from 'preact-i18n';
import * as reduxLib from 'react-redux';
import {BasePlugin} from 'kaltura-player-js';

declare module 'kaltura-player-js' {
export function setup(config: any): KalturaPlayer;
export const ui: typeof PlaykitUI;
export class FakeEvent implements CustomEvent {
readonly payload: any;
Expand Down Expand Up @@ -34,27 +38,44 @@ declare module 'kaltura-player-js' {
export class BasePlugin<ConfigType> {
protected config: ConfigType;
protected static defaultConfig: {};
protected constructor(name: string, player: KalturaPlayer, config: ConfigType);
protected constructor(name: string, player: KalturaPlayer, config?: ConfigType);
protected logger: Logger;
protected loadMedia(): void;
public player: KalturaPlayer;
public reset(): void;
public destroy(): void;
public static isValid(): boolean;
public eventManager: any;
public eventManager: PlaykitUI.EventManager;
}
export function registerPlugin<ConfigType>(pluginName: string, plugin: IBasePlugin<ConfigType>): void;
}

type Target = KalturaPlayer | HTMLElement | Document;
type CallbackFunction = (...args: any) => void;

export interface IBasePlugin<ConfigType> {
new (name: string, player: KalturaPlayer, config: ConfigType): BasePlugin<ConfigType>;
new (name: string, player: KalturaPlayer, config?: ConfigType): BasePlugin<ConfigType>;
}

export class KalturaPlayer {
public setMedia(config: any): void;
public registerService(pluginName: string, service: Object): void;
public getService<T>(serviceName: string): T;
public get ui(): UIWrapper;
public get Event(): EventTypes;
public get paused(): boolean;
public configure(config: Object): void;
public ready(): Promise<void>;
public load(): void;
public play(): void;
public pause(): void;
public getView(): HTMLElement;
public getVideoElement(): HTMLVideoElement;
public reset(isChangeMedia?: boolean): void;
public isLive(): boolean;
public isOnLiveEdge(): boolean;
public isDvr(): boolean;
public seekToLiveEdge(): void;
}

export class UIWrapper {
Expand Down Expand Up @@ -83,6 +104,14 @@ export interface EventTypes {
}

declare module PlaykitUI {
export class EventManager {
listen: (target: Target, event: string, cb: CallbackFunction) => void;
listenOnce: (target: Target, event: string, cb: CallbackFunction) => void;
unlisten: (target: Target, event: string, cb?: CallbackFunction) => void;
destroy: () => void;
removeAll: () => void;
}

export type SidePanelPosition = 'top' | 'bottom' | 'right' | 'left';
export type SidePanelMode = 'alongside' | 'hidden' | 'over';
export type ReservedPresetName = 'Playback' | 'Live' | 'Idle' | 'Ads' | 'Error';
Expand Down Expand Up @@ -142,7 +171,37 @@ declare module PlaykitUI {
};
};
};

enum IconState {
INACTIVE = 0,
ACTIVE = 1
}

export const Components: {
Tooltip: preactLib.ComponentClass<{label: string}>;
Icon: preactLib.ComponentClass<{
id: string | number;
path: string;
state?: IconState;
color?: string;
activeColor?: string;
width?: number;
height?: number;
viewBox?: string;
}>;
PLAYER_SIZE: {
TINY: 'tiny';
EXTRA_SMALL: 'extrasmall';
SMALL: 'small';
MEDIUM: 'medium';
LARGE: 'large';
EXTRA_LARGE: 'extralarge';
};
};
export const style: {[cssClassName: string]: string};
export const h: typeof preact.h;
export const preact: typeof preactLib;
export const redux: typeof reduxLib;
export const preacti18n: typeof preacti18nLib;
export const Event: any;
}
12 changes: 12 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1247,6 +1247,13 @@
resolved "https://registry.yarnpkg.com/@types/parse-json/-/parse-json-4.0.0.tgz#2f8bb441434d163b35fb8ffdccd7138927ffb8c0"
integrity sha512-//oorEZjL6sbPcKUaCdIGlIUeH26mgzimjBB77G6XRgnDl/L5wOnpyBGRe/Mmf5CVW3PwEBE1NjiMZ/ssFh4wA==

"@types/preact-i18n@^2.3.1":
version "2.3.1"
resolved "https://registry.yarnpkg.com/@types/preact-i18n/-/preact-i18n-2.3.1.tgz#ec36d934796a44d37e4c7c0b5f72f7b7d8e66634"
integrity sha512-cjJf4P1b8a8BdvsPyDrp/lKgnN1U3eXFJtDbd5/JjCFrxL6wWMMVsxFGNyl8EnLqWvxWe/z4alv6Q+SHlVKfdQ==
dependencies:
preact "^10.0.0"

"@types/unist@^2.0.0", "@types/unist@^2.0.2":
version "2.0.3"
resolved "https://registry.yarnpkg.com/@types/unist/-/unist-2.0.3.tgz#9c088679876f374eb5983f150d4787aa6fb32d7e"
Expand Down Expand Up @@ -7795,6 +7802,11 @@ preact-i18n@^2.0.0-preactx.2:
dependencies:
dlv "^1.1.2"

preact@^10.0.0:
version "10.10.6"
resolved "https://registry.yarnpkg.com/preact/-/preact-10.10.6.tgz#1fe62aecf93974b64e6a42e09ba1f00f93207d14"
integrity sha512-w0mCL5vICUAZrh1DuHEdOWBjxdO62lvcO++jbzr8UhhYcTbFkpegLH9XX+7MadjTl/y0feoqwQ/zAnzkc/EGog==

preact@^10.3.4:
version "10.4.6"
resolved "https://registry.yarnpkg.com/preact/-/preact-10.4.6.tgz#86cc43396e4bdd755726a2b4b1f0529e78067cd3"
Expand Down

0 comments on commit 2fb7bd4

Please sign in to comment.