From 0911e7c726d280828ae115ba3dc8ddf44835da5c Mon Sep 17 00:00:00 2001 From: Elton Lee Date: Mon, 18 Sep 2017 18:52:02 +0800 Subject: [PATCH] Modified to pass lint test. --- types/soundmanager2/index.d.ts | 65 ++++++---------------- types/soundmanager2/package.json | 21 ------- types/soundmanager2/soundmanager2-tests.ts | 8 +-- 3 files changed, 22 insertions(+), 72 deletions(-) delete mode 100644 types/soundmanager2/package.json diff --git a/types/soundmanager2/index.d.ts b/types/soundmanager2/index.d.ts index b5cdaf1368..0e1a33bb39 100644 --- a/types/soundmanager2/index.d.ts +++ b/types/soundmanager2/index.d.ts @@ -1,14 +1,15 @@ -// Type definitions for soundmanager2 V2.97a.20170601 +// Type definitions for soundmanager2 2.97 // Project: https://github.com/scottschiller/SoundManager2 // Definitions by: Elton Lee // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.3 declare var soundManager: soundmanager.SoundManager; declare namespace soundmanager { type ScriptAccess = 'always' | 'sameDomain'; - export interface DefaultOptions { + interface DefaultOptions { autoLoad?: boolean; autoPlay?: boolean; from?: number | null; @@ -36,7 +37,7 @@ declare namespace soundmanager { volume?: number; } - export interface Flash9Options { + interface Flash9Options { onfailure(): void | null; isMovieStar: true | null; usePeakData: boolean; @@ -46,7 +47,7 @@ declare namespace soundmanager { ondataerror(): void | null; } - export interface MovieStarOptions { + interface MovieStarOptions { bufferTime: number; serverURL: string | null; onconnect(): void | null; @@ -55,19 +56,23 @@ declare namespace soundmanager { interface SoundManagerProps { /** - * The directory where SM2 can find the flash movies (soundmanager2.swf, soundmanager2_flash9.swf and debug versions etc.) Note that SM2 will append the correct SWF file name, depending on flashVersion and debugMode settings. + * The directory where SM2 can find the flash movies (soundmanager2.swf, + * soundmanager2_flash9.swf and debug versions etc.) Note that SM2 will + * append the correct SWF file name, depending on flashVersion and + * debugMode settings. * @type {string} */ url: string; - allowScriptAccess?: soundmanager.ScriptAccess; + allowScriptAccess?: ScriptAccess; altURL?: string; bgColor?: string; consoleOnly?: boolean; debugMode?: boolean; debugFlash?: boolean; /** - * Some properties are dynamic, determined at initialisation or later during runtime, and should be treated as read-only. + * Some properties are dynamic, determined at initialisation or later + * during runtime, and should be treated as read-only. */ readonly features?: object; @@ -98,8 +103,7 @@ declare namespace soundmanager { ontimeout?(): void; } - export interface SoundManager extends SoundManagerProps { - + interface SoundManager extends SoundManagerProps { canPlayLink(domElement: HTMLElement): boolean; canPlayMIME(MIMEtype: string): boolean; canPlayURL(mediaURL: string): boolean; @@ -116,7 +120,7 @@ declare namespace soundmanager { setup(options: SoundManagerProps): SoundManager; } - export class SMSound { + class SMSound { // Parameters, instance options. id: string; pan: number; @@ -158,13 +162,13 @@ declare namespace soundmanager { // Methods destruct(): void; - load(options: void): SMSound; + load(options: object): SMSound; // clearOnPosition(): void; - onPosition(mescOffest: number, callback: void, []): SMSound; + onPosition(mescOffest: number, callback: object, []): SMSound; mute(): SMSound; pause(): SMSound; play(id?: string, options?: DefaultOptions): SMSound; - resume(): SMSound + resume(): SMSound; setPan(volume: number): SMSound; setPosition(msecOffset: number): SMSound; setVolume(volume: number): SMSound; @@ -175,40 +179,7 @@ declare namespace soundmanager { unmute(): SMSound; } - export interface audioFormats { - mp3: { - type: ['audio/mpeg; codecs="mp3"', 'audio/mpeg', 'audio/mp3', 'audio/MPA', 'audio/mpa-robust']; - required: true; - }, - - mp4: { - related: ['aac', 'm4a', 'm4b'], // additional formats under the MP4 container - type: ['audio/mp4; codecs="mp4a.40.2"', 'audio/aac', 'audio/x-m4a', 'audio/MP4A-LATM', 'audio/mpeg4-generic']; - required: false; - }, - - ogg: { - type: ['audio/ogg; codecs=vorbis']; - required: false; - }, - - opus: { - type: ['audio/ogg; codecs=opus', 'audio/opus']; - required: false; - }, - - wav: { - type: ['audio/wav; codecs="1"', 'audio/wav', 'audio/wave', 'audio/x-wav']; - required: false; - }, - - flac: { - type: ['audio/flac']; - required: false; - } - } - - export interface PeekData { + interface PeekData { left: number; right: number; } diff --git a/types/soundmanager2/package.json b/types/soundmanager2/package.json deleted file mode 100644 index 088f154064..0000000000 --- a/types/soundmanager2/package.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "name": "@types/soundmanager2", - "version": "1.0.0", - "description": "TypeScript definitions for soundmanager2", - "license": "MIT", - "contributors": [ - { - "name": "Elton Lee", - "url": "https://github.com/elton2048", - "githubUsername": "elton2048" - } - ], - "main": "", - "repository": { - "type": "git", - "url": "https://www.github.com/DefinitelyTyped/DefinitelyTyped.git" - }, - "scripts": {}, - "dependencies": {}, - "typeScriptVersion": "2.0" -} diff --git a/types/soundmanager2/soundmanager2-tests.ts b/types/soundmanager2/soundmanager2-tests.ts index ffea86de1a..968b2c4fef 100644 --- a/types/soundmanager2/soundmanager2-tests.ts +++ b/types/soundmanager2/soundmanager2-tests.ts @@ -1,22 +1,22 @@ // Example extracted in http://www.schillmania.com/projects/soundmanager2/doc/getstarted/ -var mySoundObject = soundManager.createSound({ +let mySoundObject = soundManager.createSound({ // optional id, for getSoundById() look-ups etc. If omitted, an id will be generated. id: 'mySound', url: '/audio/mysoundfile.mp3', // optional sound parameters here, see Sound Properties for full list volume: 50, autoPlay: true, - whileloading: function() { console.log(this.id + ' is loading'); } + whileloading() { console.log( this.id + ' is loading'); } }); soundManager.setup({ url: '/path/to/swfs/', flashVersion: 9, preferFlash: false, // prefer 100% HTML5 mode, where both supported - onready: function() { + onready: () => { // console.log('SM2 ready!'); }, - ontimeout: function() { + ontimeout: () => { // console.log('SM2 init failed!'); }, defaultOptions: {