Skip to content

Commit

Permalink
Added type definitions for @vimeo/player (#15593)
Browse files Browse the repository at this point in the history
* 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
denisyilmaz authored and Andy committed Apr 18, 2017
1 parent 9df4e89 commit a209273
Show file tree
Hide file tree
Showing 4 changed files with 580 additions and 0 deletions.
107 changes: 107 additions & 0 deletions types/vimeo__player/index.d.ts
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>;
}
23 changes: 23 additions & 0 deletions types/vimeo__player/tsconfig.json
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"
]
}
1 change: 1 addition & 0 deletions types/vimeo__player/tslint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }
Loading

0 comments on commit a209273

Please sign in to comment.