-
Notifications
You must be signed in to change notification settings - Fork 30.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added type definitions for @vimeo/player (#15593)
* Added type definitions for @vimeo/player * Added path to index.d.ts * Deleted unused interface * changed package to new scoped packages resolution support references microsoft/TypeScript@4e29b18 * clean types for updating forked repository * declare module in d.ts file waiting for typescript 2.3.1 for support of scoped packages * changed to greatest minor version * undo modifications * move files to types folder and renaming tests file * delete typescript version declaration * removed dtslint errors * disable „no-single-declare-module“ needed untill typescript 2.3.1 is out. * deleted extra space in URLs * changed mail-address to github username
- Loading branch information
1 parent
9df4e89
commit a209273
Showing
4 changed files
with
580 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
// Type definitions for @vimeo/player 2.0 | ||
// Project: https://github.com/vimeo/player.js | ||
// Definitions by: Denis Yılmaz <https://github.com/denisyilmaz>, Felix Albert <f.albert.work@icloud.com> | ||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped | ||
// tslint:disable-next-line no-single-declare-module | ||
declare module "@vimeo/player" { | ||
function myMethod(a: string): string; | ||
function myOtherMethod(a: number): number; | ||
|
||
type CallbackFunction = (...args: any[]) => any; | ||
|
||
interface Error {name: string; message: string; method: string; } | ||
|
||
interface PasswordError extends Error {name: "PasswordError"; message: string; method: string; } | ||
interface PrivacyError extends Error {name: "PrivacyError"; message: string; method: string; } | ||
interface InvalidTrackLanguageError extends Error {name: "InvalidTrackLanguageError"; message: string; method: string; } | ||
interface InvalidTrackError extends Error {name: "InvalidTrackError"; message: string; method: string; } | ||
interface UnsupportedError extends Error {name: "UnsupportedError"; message: string; method: string; } | ||
interface ContrastError extends Error {name: "ContrastError"; message: string; method: string; } | ||
interface InvalidCuePoint extends Error {name: "InvalidCuePoint"; message: string; method: string; } | ||
interface RangeError extends Error {name: "RangeError"; message: string; method: string; } | ||
interface TypeError extends Error {name: "TypeError"; message: string; method: string; } | ||
|
||
type EventName = "play" | "pause" | "ended" | "timeupdate" | "progress" | "seeked" | "texttrackchange" | "cuechange" | "cuepoint" | "volumechange" | "error" | "loaded" | string; | ||
type EventCallback = (data: any) => any; | ||
|
||
class Player { | ||
constructor(element: HTMLIFrameElement|HTMLElement|string, options: Options); | ||
|
||
on(event: EventName, callback: EventCallback): void; | ||
off(event: EventName, callback?: EventCallback): void; | ||
loadVideo(id: number): VimeoPromise<number, TypeError | PasswordError | PrivacyError | Error>; | ||
ready(): VimeoPromise<void, Error>; | ||
enableTextTrack(language: string, kind?: string): VimeoPromise<VimeoTextTrack, InvalidTrackLanguageError | InvalidTrackError | Error>; | ||
disableTextTrack(): VimeoPromise<void, Error>; | ||
pause(): VimeoPromise<void, PasswordError | PrivacyError |Error>; | ||
play(): VimeoPromise<void, PasswordError | PrivacyError |Error>; | ||
unload(): VimeoPromise<void, Error>; | ||
getAutopause(): VimeoPromise<boolean, UnsupportedError | Error>; | ||
setAutopause(autopause: boolean): VimeoPromise<boolean, UnsupportedError | Error>; | ||
getColor(): VimeoPromise<string, Error>; | ||
setColor(color: string): VimeoPromise<string, ContrastError | TypeError | Error>; | ||
addCuePoint(time: number, data: VimeoCuePointData): VimeoPromise<string, UnsupportedError | RangeError | Error>; | ||
removeCuePoint(id: string): VimeoPromise<string, UnsupportedError | InvalidCuePoint | Error>; | ||
getCuePoints(): VimeoPromise<VimeoCuePoint[], UnsupportedError | Error>; | ||
getCurrentTime(): VimeoPromise<number, Error>; | ||
setCurrentTime(seconds: number): VimeoPromise<number, RangeError | Error>; | ||
getDuration(): VimeoPromise<number, Error>; | ||
getEnded(): VimeoPromise<boolean, Error>; | ||
getLoop(): VimeoPromise<boolean, Error>; | ||
setLoop(loop: boolean): VimeoPromise<boolean, Error>; | ||
getPaused(): VimeoPromise<boolean, Error>; | ||
getTextTracks(): VimeoPromise<VimeoTextTrack[], Error>; | ||
getVideoEmbedCode(): VimeoPromise<string, Error>; | ||
getVideoId(): VimeoPromise<number, Error>; | ||
getVideoTitle(): VimeoPromise<string, Error>; | ||
getVideoWidth(): VimeoPromise<number, Error>; | ||
getVideoHeight(): VimeoPromise<number, Error>; | ||
getVideoUrl(): VimeoPromise<string, PrivacyError | Error>; | ||
getVolume(): VimeoPromise<number, Error>; | ||
setVolume(volume: number): VimeoPromise<number, RangeError | Error>; | ||
} | ||
|
||
interface VimeoCuePoint { | ||
time: number; | ||
data: VimeoCuePointData; | ||
id: string; | ||
} | ||
|
||
interface VimeoCuePointData extends Object { | ||
customKey: string; | ||
} | ||
|
||
interface VimeoTextTrack { | ||
language: string; | ||
kind: string; | ||
label: string; | ||
mode?: string; | ||
} | ||
|
||
interface Options { | ||
id?: number; | ||
url?: string; | ||
autopause?: boolean; | ||
autoplay?: boolean; | ||
byline?: boolean; | ||
color?: string; | ||
height?: number; | ||
loop?: boolean; | ||
maxheight?: number; | ||
maxwidth?: number; | ||
portrait?: boolean; | ||
title?: boolean; | ||
width?: number; | ||
} | ||
|
||
interface VimeoPromise<Result, Reason> extends Promise<Result> { | ||
( | ||
successCallback?: (promiseValue: Result) => void, | ||
rejectCallback?: (reasonValue: Reason) => void | ||
): Promise<Result>; | ||
} | ||
|
||
/*~ You can declare properties of the module using const, let, or var */ | ||
const playerMap: WeakMap<any, any>; | ||
const readyMap: WeakMap<any, any>; | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
{ | ||
"compilerOptions": { | ||
"module": "commonjs", | ||
"lib": [ | ||
"es6", | ||
"dom" | ||
], | ||
"noImplicitAny": true, | ||
"noImplicitThis": true, | ||
"strictNullChecks": true, | ||
"baseUrl": "types", | ||
"typeRoots": [ | ||
"types" | ||
], | ||
"types": [], | ||
"noEmit": true, | ||
"forceConsistentCasingInFileNames": true | ||
}, | ||
"files": [ | ||
"index.d.ts", | ||
"vimeo__player-tests.ts" | ||
] | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{ "extends": "dtslint/dt.json" } |
Oops, something went wrong.