diff --git a/.eslintrc.js b/.eslintrc.js index 1cc54050a7..d23e690a2b 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -205,5 +205,13 @@ module.exports = { 'lib/debug/asserts.js', ], }, + { + 'files': ['externs/*', 'externs/shaka/*'], + 'rules': { + // Disable rules on useless constructors so we can use ES6 classes in + // externs. + 'no-useless-constructor': 'off', + }, + }, ], }; diff --git a/externs/audiotrack.js b/externs/audiotrack.js index df2ee5b516..8496fe44e0 100644 --- a/externs/audiotrack.js +++ b/externs/audiotrack.js @@ -49,18 +49,16 @@ AudioTrack.prototype.sourceBuffer; * @extends {EventTarget} * @interface */ -function AudioTrackList() {} +class AudioTrackList { + /** @override */ + addEventListener(type, listener, useCapture) {} -/** @override */ -AudioTrackList.prototype.addEventListener = - function(type, listener, useCapture) {}; + /** @override */ + removeEventListener(type, listener, useCapture) {} -/** @override */ -AudioTrackList.prototype.removeEventListener = - function(type, listener, useCapture) {}; - -/** @override */ -AudioTrackList.prototype.dispatchEvent = function(event) {}; + /** @override */ + dispatchEvent(event) {} +} /** @type {AudioTrackList} */ diff --git a/externs/awesomplete.js b/externs/awesomplete.js index b95a48ad20..576f1f8a3b 100644 --- a/externs/awesomplete.js +++ b/externs/awesomplete.js @@ -21,16 +21,15 @@ */ -/** - * @param {!Element} input - * @constructor - */ -const Awesomplete = function(input) {}; - -/** @type {!Array.} */ -Awesomplete.prototype.list; +class Awesomplete { + /** @param {!Element} input */ + constructor(input) { + /** @type {!Array.} */ + this.list; -/** @type {number} */ -Awesomplete.prototype.minChars; + /** @type {number} */ + this.minChars; + } -Awesomplete.prototype.evaluate = function() {}; + evaluate() {} +} diff --git a/externs/chromecast.js b/externs/chromecast.js index 8f669c41a9..3d2b002c63 100644 --- a/externs/chromecast.js +++ b/externs/chromecast.js @@ -38,37 +38,27 @@ cast.receiver = {}; cast.receiver.system = {}; -/** - * @constructor - * @struct - */ -cast.receiver.system.SystemVolumeData = function() {}; - - -/** @type {number} */ -cast.receiver.system.SystemVolumeData.prototype.level; - - -/** @type {boolean} */ -cast.receiver.system.SystemVolumeData.prototype.muted; - - -/** - * @constructor - * @struct - */ -cast.receiver.CastMessageBus = function() {}; +cast.receiver.system.SystemVolumeData = class { + constructor() { + /** @type {number} */ + this.level; + /** @type {boolean} */ + this.muted; + } +}; -/** @param {*} message */ -cast.receiver.CastMessageBus.prototype.broadcast = function(message) {}; +cast.receiver.CastMessageBus = class { + /** @param {*} message */ + broadcast(message) {} -/** - * @param {string} senderId - * @return {!cast.receiver.CastChannel} - */ -cast.receiver.CastMessageBus.prototype.getCastChannel = function(senderId) {}; + /** + * @param {string} senderId + * @return {!cast.receiver.CastChannel} + */ + getCastChannel(senderId) {} +}; /** @type {Function} */ @@ -79,7 +69,7 @@ cast.receiver.CastMessageBus.prototype.onMessage; * @constructor * @struct */ -cast.receiver.CastMessageBus.Event = function() {}; +cast.receiver.CastMessageBus.Event = class {}; /** @type {?} */ @@ -90,86 +80,63 @@ cast.receiver.CastMessageBus.Event.prototype.data; cast.receiver.CastMessageBus.Event.prototype.senderId; -/** - * @constructor - * @struct - */ -cast.receiver.CastChannel = function() {}; - - -/** @param {*} message */ -cast.receiver.CastChannel.prototype.send = function(message) {}; - - -/** - * @constructor - * @struct - */ -cast.receiver.CastReceiverManager = function() {}; - - -/** @return {cast.receiver.CastReceiverManager} */ -cast.receiver.CastReceiverManager.getInstance = function() {}; - - -/** - * @param {string} namespace - * @param {string=} messageType - * @return {cast.receiver.CastMessageBus} - */ -cast.receiver.CastReceiverManager.prototype.getCastMessageBus = function( - namespace, messageType) {}; - - -/** @return {Array.} */ -cast.receiver.CastReceiverManager.prototype.getSenders = function() {}; - +cast.receiver.CastChannel = class { + /** @param {*} message */ + send(message) {} +}; -cast.receiver.CastReceiverManager.prototype.start = function() {}; +cast.receiver.CastReceiverManager = class { + constructor() { + /** @type {Function} */ + this.onSenderConnected; -cast.receiver.CastReceiverManager.prototype.stop = function() {}; + /** @type {Function} */ + this.onSenderDisconnected; + /** @type {Function} */ + this.onSystemVolumeChanged; + } -/** @return {?cast.receiver.system.SystemVolumeData} */ -cast.receiver.CastReceiverManager.prototype.getSystemVolume = function() {}; + /** @return {cast.receiver.CastReceiverManager} */ + static getInstance() {} + /** + * @param {string} namespace + * @param {string=} messageType + * @return {cast.receiver.CastMessageBus} + */ + getCastMessageBus(namespace, messageType) {} -/** @param {number} level */ -cast.receiver.CastReceiverManager.prototype.setSystemVolumeLevel = - function(level) {}; + /** @return {Array.} */ + getSenders() {} + start() {} -/** @param {number} muted */ -cast.receiver.CastReceiverManager.prototype.setSystemVolumeMuted = - function(muted) {}; + stop() {} + /** @return {?cast.receiver.system.SystemVolumeData} */ + getSystemVolume() {} -/** @return {boolean} */ -cast.receiver.CastReceiverManager.prototype.isSystemReady = function() {}; + /** @param {number} level */ + setSystemVolumeLevel(level) {} + /** @param {number} muted */ + setSystemVolumeMuted(muted) {} -/** @type {Function} */ -cast.receiver.CastReceiverManager.prototype.onSenderConnected; - - -/** @type {Function} */ -cast.receiver.CastReceiverManager.prototype.onSenderDisconnected; - - -/** @type {Function} */ -cast.receiver.CastReceiverManager.prototype.onSystemVolumeChanged; + /** @return {boolean} */ + isSystemReady() {} +}; /** @const */ -cast.__platform__; - - -/** - * @param {string} type - * @return {boolean} - */ -cast.__platform__.canDisplayType = function(type) {}; +cast.__platform__ = class { + /** + * @param {string} type + * @return {boolean} + */ + static canDisplayType(type) {} +}; /** @const */ @@ -177,7 +144,21 @@ var chrome = {}; /** @const */ -chrome.cast = {}; +chrome.cast = class { + /** + * @param {chrome.cast.ApiConfig} apiConfig + * @param {Function} successCallback + * @param {Function} errorCallback + */ + static initialize(apiConfig, successCallback, errorCallback) {} + + /** + * @param {Function} successCallback + * @param {Function} errorCallback + * @param {chrome.cast.SessionRequest=} sessionRequest + */ + static requestSession(successCallback, errorCallback, sessionRequest) {} +}; /** @type {boolean} */ @@ -192,149 +173,100 @@ chrome.cast.SessionStatus = {}; chrome.cast.SessionStatus.STOPPED; -/** - * @param {chrome.cast.ApiConfig} apiConfig - * @param {Function} successCallback - * @param {Function} errorCallback - */ -chrome.cast.initialize = function(apiConfig, successCallback, errorCallback) {}; - - -/** - * @param {Function} successCallback - * @param {Function} errorCallback - * @param {chrome.cast.SessionRequest=} sessionRequest - */ -chrome.cast.requestSession = function( - successCallback, errorCallback, sessionRequest) {}; - - -/** - * @param {chrome.cast.SessionRequest} sessionRequest - * @param {Function} sessionListener - * @param {Function} receiverListener - * @param {string=} autoJoinPolicy - * @param {string=} defaultActionPolicy - * @constructor - * @struct - */ -chrome.cast.ApiConfig = function( - sessionRequest, - sessionListener, - receiverListener, - autoJoinPolicy, - defaultActionPolicy) {}; - - -/** - * @param {string} code - * @param {string=} description - * @param {Object=} details - * @constructor - * @struct - */ -chrome.cast.Error = function(code, description, details) {}; +chrome.cast.ApiConfig = class { + /** + * @param {chrome.cast.SessionRequest} sessionRequest + * @param {Function} sessionListener + * @param {Function} receiverListener + * @param {string=} autoJoinPolicy + * @param {string=} defaultActionPolicy + */ + constructor(sessionRequest, sessionListener, receiverListener, + autoJoinPolicy, defaultActionPolicy) {} +}; -/** @type {string} */ -chrome.cast.Error.prototype.code; +chrome.cast.Error = class { + /** + * @param {string} code + * @param {string=} description + * @param {Object=} details + */ + constructor(code, description, details) { + /** @type {string} */ + this.code; + /** @type {?string} */ + this.description; -/** @type {?string} */ -chrome.cast.Error.prototype.description; + /** @type {Object} */ + this.details; + } +}; -/** @type {Object} */ -chrome.cast.Error.prototype.details; - - -/** - * @constructor - * @struct - */ -chrome.cast.Receiver = function() {}; +chrome.cast.Receiver = class { + constructor() {} +}; /** @const {string} */ chrome.cast.Receiver.prototype.friendlyName; -/** - * @constructor - * @struct - */ -chrome.cast.Session = function() {}; - - -/** @type {string} */ -chrome.cast.Session.prototype.sessionId; - - -/** @type {string} */ -chrome.cast.Session.prototype.status; - - -/** @type {chrome.cast.Receiver} */ -chrome.cast.Session.prototype.receiver; - - -/** - * @param {string} namespace - * @param {Function} listener - */ -chrome.cast.Session.prototype.addMessageListener = function( - namespace, listener) {}; - - -/** - * @param {string} namespace - * @param {Function} listener - */ -chrome.cast.Session.prototype.removeMessageListener = function( - namespace, listener) {}; - - -/** - * @param {Function} listener - */ -chrome.cast.Session.prototype.addUpdateListener = function(listener) {}; - - -/** - * @param {Function} listener - */ -chrome.cast.Session.prototype.removeUpdateListener = function(listener) {}; - - -/** - * @param {Function} successCallback - * @param {Function} errorCallback - */ -chrome.cast.Session.prototype.leave = function( - successCallback, errorCallback) {}; - - -/** - * @param {string} namespace - * @param {!Object|string} message - * @param {Function} successCallback - * @param {Function} errorCallback - */ -chrome.cast.Session.prototype.sendMessage = function( - namespace, message, successCallback, errorCallback) {}; - - -/** - * @param {Function} successCallback - * @param {Function} errorCallback - */ -chrome.cast.Session.prototype.stop = function( - successCallback, errorCallback) {}; - - -/** - * @param {string} appId - * @constructor - * @struct - */ -chrome.cast.SessionRequest = function(appId) {}; +chrome.cast.Session = class { + constructor() { + /** @type {string} */ + this.sessionId; + + /** @type {string} */ + this.status; + + /** @type {chrome.cast.Receiver} */ + this.receiver; + } + + /** + * @param {string} namespace + * @param {Function} listener + */ + addMessageListener(namespace, listener) {} + + /** + * @param {string} namespace + * @param {Function} listener + */ + removeMessageListener(namespace, listener) {} + + /** @param {Function} listener */ + addUpdateListener(listener) {} + + /** @param {Function} listener */ + removeUpdateListener(listener) {} + + /** + * @param {Function} successCallback + * @param {Function} errorCallback + */ + leave(successCallback, errorCallback) {} + + /** + * @param {string} namespace + * @param {!Object|string} message + * @param {Function} successCallback + * @param {Function} errorCallback + */ + sendMessage(namespace, message, successCallback, errorCallback) {} + + /** + * @param {Function} successCallback + * @param {Function} errorCallback + */ + stop(successCallback, errorCallback) {} +}; + + +chrome.cast.SessionRequest = class { + /** @param {string} appId */ + constructor(appId) {} +}; diff --git a/externs/dialog_polyfill.js b/externs/dialog_polyfill.js index e77a8db1ce..a80e4870f3 100644 --- a/externs/dialog_polyfill.js +++ b/externs/dialog_polyfill.js @@ -22,12 +22,10 @@ /** @const */ -const dialogPolyfill = {}; - - -/** - * @param {!Element} dialog - * @const - */ -dialogPolyfill.registerDialog = function(dialog) {}; - +const dialogPolyfill = class { + /** + * @param {!Element} dialog + * @const + */ + static registerDialog(dialog) {} +}; diff --git a/externs/jwk_set.js b/externs/jwk_set.js index 8810fa62bf..54247afaf1 100644 --- a/externs/jwk_set.js +++ b/externs/jwk_set.js @@ -21,44 +21,38 @@ */ -/** - * A JSON Web Key set. - * - * @constructor - * @struct - */ -function JWKSet() { - /** @type {Array.} */ - this.keys = []; +/** A JSON Web Key set. */ +class JWKSet { + constructor() { + /** @type {Array.} */ + this.keys = []; + } } -/** - * A JSON Web Key. - * - * @constructor - * @struct - */ -function JWK() { - /** - * A key ID. Any ASCII string. - * @type {string} - */ - this.kid = ''; +/** A JSON Web Key. */ +class JWK { + constructor() { + /** + * A key ID. Any ASCII string. + * @type {string} + */ + this.kid = ''; - /** - * A key type. One of: - * 1. "oct" (symmetric key octect sequence) - * 2. "RSA" (RSA key) - * 3. "EC" (elliptical curve key) - * Use "oct" for clearkey. - * @type {string} - */ - this.kty = ''; + /** + * A key type. One of: + * 1. "oct" (symmetric key octect sequence) + * 2. "RSA" (RSA key) + * 3. "EC" (elliptical curve key) + * Use "oct" for clearkey. + * @type {string} + */ + this.kty = ''; - /** - * A key in base 64. Used with kty="oct". - * @type {string} - */ - this.k = ''; + /** + * A key in base 64. Used with kty="oct". + * @type {string} + */ + this.k = ''; + } } diff --git a/externs/less.js b/externs/less.js index dfaf0054df..f2127b7e40 100644 --- a/externs/less.js +++ b/externs/less.js @@ -22,16 +22,14 @@ /** @const */ -var less = {}; - - -less.registerStylesheetsImmediately = function() {}; - -/** - * @param {boolean} reload - * @param {boolean} modifyVars - * @param {boolean} clearFileCache - * @return {!Promise} - */ -less.refresh = function(reload, modifyVars, clearFileCache) {}; +const less = class { + static registerStylesheetsImmediately() {} + /** + * @param {boolean} reload + * @param {boolean} modifyVars + * @param {boolean} clearFileCache + * @return {!Promise} + */ + static refresh(reload, modifyVars, clearFileCache) {} +}; diff --git a/externs/mdl.js b/externs/mdl.js index 69c93d5a37..c37f6616e4 100644 --- a/externs/mdl.js +++ b/externs/mdl.js @@ -22,16 +22,16 @@ /** @const */ -const componentHandler = {}; - -/** @const */ -componentHandler.upgradeDom = function() {}; +const componentHandler = class { + /** @const */ + static upgradeDom() {} +}; /** @constructor */ -const MaterialLayout = function() {}; - -MaterialLayout.prototype.toggleDrawer = function() {}; +const MaterialLayout = class { + toggleDrawer() {} +}; /** @const {?MaterialLayout} */ Element.prototype.MaterialLayout; diff --git a/externs/mediasession.js b/externs/mediasession.js index b0a7070a20..3c3a14125e 100644 --- a/externs/mediasession.js +++ b/externs/mediasession.js @@ -24,14 +24,12 @@ */ -/** - * @constructor - */ -var MediaMetadata = function(options) {}; - - -/** @type {string} */ -MediaMetadata.prototype.title; +const MediaMetadata = class { + constructor(options) { + /** @type {string} */ + this.title; + } +}; /** @type {MediaMetadata} */ diff --git a/externs/msmediakeys.js b/externs/msmediakeys.js index afd8d79700..2297207142 100644 --- a/externs/msmediakeys.js +++ b/externs/msmediakeys.js @@ -51,34 +51,26 @@ MSMediaKeys.prototype.createSession = * @interface * @extends {EventTarget} */ -function MSMediaKeySession() {} +class MSMediaKeySession { + constructor() { + /** @type {MSMediaKeyError} */ + this.error; + } + /** @param {Uint8Array} message */ + update(message) {} -/** - * @param {Uint8Array} message - */ -MSMediaKeySession.prototype.update = function(message) {}; - - -MSMediaKeySession.prototype.close = function() {}; - - -/** @type {MSMediaKeyError} */ -MSMediaKeySession.prototype.error; - + close() {} -/** @override */ -MSMediaKeySession.prototype.addEventListener = - function(type, listener, useCapture) {}; + /** @override */ + addEventListener(type, listener, useCapture) {} + /** @override */ + removeEventListener(type, listener, useCapture) {} -/** @override */ -MSMediaKeySession.prototype.removeEventListener = - function(type, listener, useCapture) {}; - - -/** @override */ -MSMediaKeySession.prototype.dispatchEvent = function(evt) {}; + /** @override */ + dispatchEvent(evt) {} +} /** @@ -87,16 +79,15 @@ MSMediaKeySession.prototype.dispatchEvent = function(evt) {}; HTMLMediaElement.prototype.msSetMediaKeys = function(mediaKeys) {}; -/** @constructor */ -function MSMediaKeyError() {} +class MSMediaKeyError { + constructor() { + /** @type {number} */ + this.code; - -/** @type {number} */ -MSMediaKeyError.prototype.code; - - -/** @type {number} */ -MSMediaKeyError.prototype.systemCode; + /** @type {number} */ + this.systemCode; + } +} /** @type {number} */ diff --git a/externs/mux.js b/externs/mux.js index 0f4644c608..3b2748d075 100644 --- a/externs/mux.js +++ b/externs/mux.js @@ -28,52 +28,59 @@ var muxjs = {}; /** @const */ muxjs.mp4 = {}; -/** @const */ -muxjs.mp4.probe = {}; - -/** - * @constructor - * @struct - * @param {Object=} options - */ -muxjs.mp4.Transmuxer = function(options) {}; - - -/** - * @param {number} time - */ -muxjs.mp4.Transmuxer.prototype.setBaseMediaDecodeTime = function(time) {}; - - -/** - * @param {!Uint8Array} data - */ -muxjs.mp4.Transmuxer.prototype.push = function(data) {}; - - -muxjs.mp4.Transmuxer.prototype.flush = function() {}; - -/** - * Add a handler for a specified event type. - * @param {string} type Event name - * @param {Function} listener The callback to be invoked - */ -muxjs.mp4.Transmuxer.prototype.on = function(type, listener) {}; - - -/** - * Remove a handler for a specified event type. - * @param {string} type Event name - * @param {Function} listener The callback to be removed - */ -muxjs.mp4.Transmuxer.prototype.off = function(type, listener) {}; - - -/** - * Remove all handlers and clean up. - */ -muxjs.mp4.Transmuxer.prototype.dispose = function() {}; +/** @const */ +muxjs.mp4.probe = class { + /** + * Parses an MP4 initialization segment and extracts the timescale + * values for any declared tracks. + * + * @param {Uint8Array} init The bytes of the init segment + * @return {!Object.} a hash of track ids to timescale + * values or null if the init segment is malformed. + */ + static timescale(init) {} + + /** + * Find the trackIds of the video tracks in this source. + * Found by parsing the Handler Reference and Track Header Boxes: + * + * @param {Uint8Array} init The bytes of the init segment for this source + * @return {!Array.} A list of trackIds + **/ + static videoTrackIds(init) {} +}; + + +muxjs.mp4.Transmuxer = class { + /** @param {Object=} options */ + constructor(options) {} + + /** @param {number} time */ + setBaseMediaDecodeTime(time) {} + + /** @param {!Uint8Array} data */ + push(data) {} + + flush() {} + + /** + * Add a handler for a specified event type. + * @param {string} type Event name + * @param {Function} listener The callback to be invoked + */ + on(type, listener) {} + + /** + * Remove a handler for a specified event type. + * @param {string} type Event name + * @param {Function} listener The callback to be removed + */ + off(type, listener) {} + + /** Remove all handlers and clean up. */ + dispose() {} +}; /** @@ -92,79 +99,48 @@ muxjs.mp4.Transmuxer.prototype.dispose = function() {}; muxjs.mp4.Transmuxer.Segment; -/** - * Parser for CEA closed captions embedded in video streams for Dash. - * @constructor - * @struct - */ -muxjs.mp4.CaptionParser = function() {}; +muxjs.mp4.CaptionParser = class { + /** + * Parser for CEA closed captions embedded in video streams for Dash. + * @constructor + * @struct + */ + constructor() {} + + /** Initializes the closed caption parser. */ + init() {} + + /** + * Return true if a new video track is selected or if the timescale is + * changed. + * @param {!Array.} videoTrackIds A list of video tracks found in the + * init segment. + * @param {!Object.} timescales The map of track Ids and the + * tracks' timescales in the init segment. + * @return {boolean} + */ + isNewInit(videoTrackIds, timescales) {} + + /** + * Parses embedded CEA closed captions and interacts with the underlying + * CaptionStream, and return the parsed captions. + * @param {!Uint8Array} segment The fmp4 segment containing embedded captions + * @param {!Array.} videoTrackIds A list of video tracks found in the + * init segment. + * @param {!Object.} timescales The timescales found in the + * init segment. + * @return {muxjs.mp4.ParsedClosedCaptions} + */ + parse(segment, videoTrackIds, timescales) {} + + /** Clear the parsed closed captions data for new data. */ + clearParsedCaptions() {} + + /** Reset the captions stream. */ + resetCaptionStream() {} +}; -/** - * Initializes the closed caption parser. - */ -muxjs.mp4.CaptionParser.prototype.init = function() {}; - - -/** - * Return true if a new video track is selected or if the timescale is - * changed. - * @param {!Array.} videoTrackIds A list of video tracks found in the - * init segment. - * @param {!Object.} timescales The map of track Ids and the - * tracks' timescales in the init segment. - * @return {boolean} - */ -muxjs.mp4.CaptionParser.prototype.isNewInit = function( - videoTrackIds, timescales) {}; - - -/** - * Parses embedded CEA closed captions and interacts with the underlying - * CaptionStream, and return the parsed captions. - * @param {!Uint8Array} segment The fmp4 segment containing embedded captions - * @param {!Array.} videoTrackIds A list of video tracks found in the - * init segment. - * @param {!Object.} timescales The timescales found in the - * init segment. - * @return {muxjs.mp4.ParsedClosedCaptions} - */ -muxjs.mp4.CaptionParser.prototype.parse = function( - segment, videoTrackIds, timescales) {}; - - -/** - * Clear the parsed closed captions data for new data. - */ -muxjs.mp4.CaptionParser.prototype.clearParsedCaptions = function() {}; - - -/** - * Reset the captions stream. - */ -muxjs.mp4.CaptionParser.prototype.resetCaptionStream = function() {}; - - -/** - * Parses an MP4 initialization segment and extracts the timescale - * values for any declared tracks. - * - * @param {Uint8Array} init The bytes of the init segment - * @return {!Object.} a hash of track ids to timescale - * values or null if the init segment is malformed. - */ -muxjs.mp4.probe.timescale = function(init) {}; - - -/** - * Find the trackIds of the video tracks in this source. - * Found by parsing the Handler Reference and Track Header Boxes: - * - * @param {Uint8Array} init The bytes of the init segment for this source - * @return {!Array.} A list of trackIds - **/ -muxjs.mp4.probe.videoTrackIds = function(init) {}; - /** * @typedef {{ * captionStreams: Object., diff --git a/externs/shaka/abr_manager.js b/externs/shaka/abr_manager.js index ced907793c..675570f896 100644 --- a/externs/shaka/abr_manager.js +++ b/externs/shaka/abr_manager.js @@ -36,7 +36,87 @@ * @interface * @exportDoc */ -shaka.extern.AbrManager = function() {}; +shaka.extern.AbrManager = class { + constructor() {} + + /** + * Initializes the AbrManager. + * + * @param {shaka.extern.AbrManager.SwitchCallback} switchCallback + * @exportDoc + */ + init(switchCallback) {} + + /** + * Stops any background timers and frees any objects held by this instance. + * This will only be called after a call to init. + * + * @exportDoc + */ + stop() {} + + /** + * Updates manager's variants collection. + * + * @param {!Array.} variants + * @exportDoc + */ + setVariants(variants) {} + + /** + * Chooses one variant to switch to. Called by the Player. + * @return {shaka.extern.Variant} + * @exportDoc + */ + chooseVariant() {} + + /** + * Enables automatic Variant choices from the last ones passed to setVariants. + * After this, the AbrManager may call switchCallback() at any time. + * + * @exportDoc + */ + enable() {} + + /** + * Disables automatic Stream suggestions. After this, the AbrManager may not + * call switchCallback(). + * + * @exportDoc + */ + disable() {} + + /** + * Notifies the AbrManager that a segment has been downloaded (includes MP4 + * SIDX data, WebM Cues data, initialization segments, and media segments). + * + * @param {number} deltaTimeMs The duration, in milliseconds, that the request + * took to complete. + * @param {number} numBytes The total number of bytes transferred. + * @exportDoc + */ + segmentDownloaded(deltaTimeMs, numBytes) {} + + /** + * Gets an estimate of the current bandwidth in bit/sec. This is used by the + * Player to generate stats. + * + * @return {number} + * @exportDoc + */ + getBandwidthEstimate() {} + + /** + * Sets the ABR configuration. + * + * It is the responsibility of the AbrManager implementation to implement the + * restrictions behavior described in shaka.extern.AbrConfiguration. + * + * @param {shaka.extern.AbrConfiguration} config + * @exportDoc + */ + configure(config) {} +}; /** @@ -67,91 +147,3 @@ shaka.extern.AbrManager.SwitchCallback; * @exportDoc */ shaka.extern.AbrManager.Factory; - - -/** - * Initializes the AbrManager. - * - * @param {shaka.extern.AbrManager.SwitchCallback} switchCallback - * @exportDoc - */ -shaka.extern.AbrManager.prototype.init = function(switchCallback) {}; - - -/** - * Stops any background timers and frees any objects held by this instance. - * This will only be called after a call to init. - * - * @exportDoc - */ -shaka.extern.AbrManager.prototype.stop = function() {}; - - -/** - * Updates manager's variants collection. - * - * @param {!Array.} variants - * @exportDoc - */ -shaka.extern.AbrManager.prototype.setVariants = function(variants) {}; - - -/** - * Chooses one variant to switch to. Called by the Player. - * @return {shaka.extern.Variant} - * @exportDoc - */ -shaka.extern.AbrManager.prototype.chooseVariant = function() {}; - - -/** - * Enables automatic Variant choices from the last ones passed to setVariants. - * After this, the AbrManager may call switchCallback() at any time. - * - * @exportDoc - */ -shaka.extern.AbrManager.prototype.enable = function() {}; - - -/** - * Disables automatic Stream suggestions. After this, the AbrManager may not - * call switchCallback(). - * - * @exportDoc - */ -shaka.extern.AbrManager.prototype.disable = function() {}; - - -/** - * Notifies the AbrManager that a segment has been downloaded (includes MP4 - * SIDX data, WebM Cues data, initialization segments, and media segments). - * - * @param {number} deltaTimeMs The duration, in milliseconds, that the request - * took to complete. - * @param {number} numBytes The total number of bytes transferred. - * @exportDoc - */ -shaka.extern.AbrManager.prototype.segmentDownloaded = function( - deltaTimeMs, numBytes) {}; - - -/** - * Gets an estimate of the current bandwidth in bit/sec. This is used by the - * Player to generate stats. - * - * @return {number} - * @exportDoc - */ -shaka.extern.AbrManager.prototype.getBandwidthEstimate = function() {}; - - -/** - * Sets the ABR configuration. - * - * It is the responsibility of the AbrManager implementation to implement the - * restrictions behavior described in shaka.extern.AbrConfiguration. - * - * @param {shaka.extern.AbrConfiguration} config - * @exportDoc - */ -shaka.extern.AbrManager.prototype.configure = function(config) {}; diff --git a/externs/shaka/error.js b/externs/shaka/error.js index fb94981fcd..d9330b340c 100644 --- a/externs/shaka/error.js +++ b/externs/shaka/error.js @@ -46,40 +46,36 @@ shaka.extern.RestrictionInfo; * @interface * @exportDoc */ -shaka.extern.Error = function() {}; - - -/** - * @type {shaka.util.Error.Severity} - * @exportDoc - */ -shaka.extern.Error.prototype.severity; - - -/** - * @const {shaka.util.Error.Category} - * @exportDoc - */ -shaka.extern.Error.prototype.category; - - -/** - * @const {shaka.util.Error.Code} - * @exportDoc - */ -shaka.extern.Error.prototype.code; - - -/** - * @const {!Array.<*>} - * @exportDoc - */ -shaka.extern.Error.prototype.data; - - -/** - * @type {boolean} - * @exportDoc - */ -shaka.extern.Error.prototype.handled; - +shaka.extern.Error = class { + constructor() { + /** + * @type {shaka.util.Error.Severity} + * @exportDoc + */ + this.severity; + + /** + * @const {shaka.util.Error.Category} + * @exportDoc + */ + this.category; + + /** + * @const {shaka.util.Error.Code} + * @exportDoc + */ + this.code; + + /** + * @const {!Array.<*>} + * @exportDoc + */ + this.data; + + /** + * @type {boolean} + * @exportDoc + */ + this.handled; + } +}; diff --git a/externs/shaka/manifest_parser.js b/externs/shaka/manifest_parser.js index 211072f3d7..fbbc650203 100644 --- a/externs/shaka/manifest_parser.js +++ b/externs/shaka/manifest_parser.js @@ -50,7 +50,62 @@ * @interface * @exportDoc */ -shaka.extern.ManifestParser = function() {}; +shaka.extern.ManifestParser = class { + constructor() {} + + /** + * Called by the Player to provide an updated configuration any time the + * configuration changes. Will be called at least once before start(). + * + * @param {shaka.extern.ManifestConfiguration} config + * @exportDoc + */ + configure(config) {} + + /** + * Initialize and start the parser. When |start| resolves, it should return + * the initial version of the manifest. |start| will only be called once. If + * |stop| is called while |start| is pending, |start| should reject. + * + * @param {string} uri The URI of the manifest. + * @param {shaka.extern.ManifestParser.PlayerInterface} playerInterface + * The player interface contains the callbacks and members that the parser + * can use to communicate with the player and outside world. + * @return {!Promise.} + * @exportDoc + */ + start(uri, playerInterface) {} + + /** + * Tell the parser that it must stop and free all internal resources as soon + * as possible. Only once all internal resources are stopped and freed will + * the promise resolve. Once stopped a parser will not be started again. + * + * The parser should support having |stop| called multiple times and the + * promise should always resolve. + * + * @return {!Promise} + * @exportDoc + */ + stop() {} + + /** + * Tells the parser to do a manual manifest update. Implementing this is + * optional. This is only called when 'emsg' boxes are present. + * @exportDoc + */ + update() {} + + /** + * Tells the parser that the expiration time of an EME session has changed. + * Implementing this is optional. + * + * @param {string} sessionId + * @param {number} expiration + * @exportDoc + */ + onExpirationUpdated(sessionId, expiration) {} +}; /** @@ -96,61 +151,3 @@ shaka.extern.ManifestParser.PlayerInterface; */ shaka.extern.ManifestParser.Factory; - -/** - * Called by the Player to provide an updated configuration any time the - * configuration changes. Will be called at least once before start(). - * - * @param {shaka.extern.ManifestConfiguration} config - * @exportDoc - */ -shaka.extern.ManifestParser.prototype.configure = function(config) {}; - - -/** - * Initialize and start the parser. When |start| resolves, it should return the - * initial version of the manifest. |start| will only be called once. If |stop| - * is called while |start| is pending, |start| should reject. - * - * @param {string} uri The URI of the manifest. - * @param {shaka.extern.ManifestParser.PlayerInterface} playerInterface - * The player interface contains the callbacks and members that the parser - * can use to communicate with the player and outside world. - * @return {!Promise.} - * @exportDoc - */ -shaka.extern.ManifestParser.prototype.start = function(uri, playerInterface) {}; - - -/** - * Tell the parser that it must stop and free all internal resources as soon as - * possible. Only once all internal resources are stopped and freed will the - * promise resolve. Once stopped a parser will not be started again. - * - * The parser should support having |stop| called multiple times and the promise - * should always resolve. - * - * @return {!Promise} - * @exportDoc - */ -shaka.extern.ManifestParser.prototype.stop = function() {}; - - -/** - * Tells the parser to do a manual manifest update. Implementing this is - * optional. This is only called when 'emsg' boxes are present. - * @exportDoc - */ -shaka.extern.ManifestParser.prototype.update = function() {}; - - -/** - * Tells the parser that the expiration time of an EME session has changed. - * Implementing this is optional. - * - * @param {string} sessionId - * @param {number} expiration - * @exportDoc - */ -shaka.extern.ManifestParser.prototype.onExpirationUpdated = function( - sessionId, expiration) {}; diff --git a/externs/shaka/offline.js b/externs/shaka/offline.js index 30986eccbe..85f5b9c14c 100644 --- a/externs/shaka/offline.js +++ b/externs/shaka/offline.js @@ -247,118 +247,108 @@ shaka.extern.EmeSessionDB; * * @interface */ -shaka.extern.StorageCell = function() {}; - - -/** - * Free all resources used by this cell. This should not affect the stored - * content. - * - * @return {!Promise} - */ -shaka.extern.StorageCell.prototype.destroy = function() {}; - - -/** - * Check if the cell can support new keys. If a cell has a fixed key space, - * then all add-operations will fail as no new keys can be added. All - * remove-operations and update-operations should still work. - * - * @return {boolean} - */ -shaka.extern.StorageCell.prototype.hasFixedKeySpace = function() {}; - - -/** - * Add a group of segments. Will return a promise that resolves with a list - * of keys for each segment. If one segment fails to be added, all segments - * should fail to be added. - * - * @param {!Array.} segments - * @return {!Promise.>} - */ -shaka.extern.StorageCell.prototype.addSegments = function(segments) {}; - - -/** - * Remove a group of segments using their keys to identify them. If a key - * is not found, then that removal should be considered successful. - * - * @param {!Array.} keys - * @param {function(number)} onRemove A callback for when a segment is removed - * from the cell. The key of the segment - * will be passed to the callback. - * @return {!Promise} - */ -shaka.extern.StorageCell.prototype.removeSegments = function(keys, onRemove) {}; - - -/** - * Get a group of segments using their keys to identify them. If any key is - * not found, the promise chain will be rejected. - * - * @param {!Array.} keys - * @return {!Promise.>} - */ -shaka.extern.StorageCell.prototype.getSegments = function(keys) {}; - - -/** - * Add a group of manifests. Will return a promise that resolves with a list - * of keys for each manifest. If one manifest fails to be added, all manifests - * should fail to be added. - * - * @param {!Array.} manifests - * @return {!Promise>} keys - */ -shaka.extern.StorageCell.prototype.addManifests = function(manifests) {}; - - -/** - * Replace the expiration time of the manifest stored under |key| with - * |newExpiration|. If no manifest is found under |key| then this should - * act as a no-op. - * - * @param {number} key - * @param {number} expiration - * @return {!Promise} - */ -shaka.extern.StorageCell.prototype.updateManifestExpiration = - function(key, expiration) {}; - - -/** - * Remove a group of manifests using their keys to identify them. If a key - * is not found, then that removal should be considered successful. - * - * @param {!Array.} keys - * @param {function(number)} onRemove A callback for when a manifest is removed - * from the cell. The key of the manifest - * will be passed to the callback. - * @return {!Promise} - */ -shaka.extern.StorageCell.prototype.removeManifests = - function(keys, onRemove) {}; - - -/** - * Get a group of manifests using their keys to identify them. If any key is - * not found, the promise chain will be rejected. - * - * @param {!Array.} keys - * @return {!Promise>} - */ -shaka.extern.StorageCell.prototype.getManifests = function(keys) {}; - - -/** - * Get all manifests stored in this cell. Since manifests are small compared to - * the asset they describe, it is assumed that it is feasible to have them all - * in main memory at one time. - * - * @return {!Promise>} - */ -shaka.extern.StorageCell.prototype.getAllManifests = function() {}; +shaka.extern.StorageCell = class { + constructor() {} + + /** + * Free all resources used by this cell. This should not affect the stored + * content. + * + * @return {!Promise} + */ + destroy() {} + + /** + * Check if the cell can support new keys. If a cell has a fixed key space, + * then all add-operations will fail as no new keys can be added. All + * remove-operations and update-operations should still work. + * + * @return {boolean} + */ + hasFixedKeySpace() {} + + /** + * Add a group of segments. Will return a promise that resolves with a list + * of keys for each segment. If one segment fails to be added, all segments + * should fail to be added. + * + * @param {!Array.} segments + * @return {!Promise.>} + */ + addSegments(segments) {} + + /** + * Remove a group of segments using their keys to identify them. If a key + * is not found, then that removal should be considered successful. + * + * @param {!Array.} keys + * @param {function(number)} onRemove A callback for when a segment is removed + * from the cell. The key of the segment + * will be passed to the callback. + * @return {!Promise} + */ + removeSegments(keys, onRemove) {} + + /** + * Get a group of segments using their keys to identify them. If any key is + * not found, the promise chain will be rejected. + * + * @param {!Array.} keys + * @return {!Promise.>} + */ + getSegments(keys) {} + + /** + * Add a group of manifests. Will return a promise that resolves with a list + * of keys for each manifest. If one manifest fails to be added, all manifests + * should fail to be added. + * + * @param {!Array.} manifests + * @return {!Promise>} keys + */ + addManifests(manifests) {} + + /** + * Replace the expiration time of the manifest stored under |key| with + * |newExpiration|. If no manifest is found under |key| then this should + * act as a no-op. + * + * @param {number} key + * @param {number} expiration + * @return {!Promise} + */ + updateManifestExpiration(key, expiration) {} + + /** + * Remove a group of manifests using their keys to identify them. If a key + * is not found, then that removal should be considered successful. + * + * @param {!Array.} keys + * @param {function(number)} onRemove A callback for when a manifest is + * removed from the cell. The key of the + * manifest will be passed to the callback. + * @return {!Promise} + */ + removeManifests(keys, onRemove) {} + + /** + * Get a group of manifests using their keys to identify them. If any key is + * not found, the promise chain will be rejected. + * + * @param {!Array.} keys + * @return {!Promise>} + */ + getManifests(keys) {} + + /** + * Get all manifests stored in this cell. Since manifests are small compared + * to the asset they describe, it is assumed that it is feasible to have them + * all in main memory at one time. + * + * @return {!Promise>} + */ + getAllManifests() {} +}; /** @@ -368,37 +358,35 @@ shaka.extern.StorageCell.prototype.getAllManifests = function() {}; * * @interface */ -shaka.extern.EmeSessionStorageCell = function() {}; - - -/** - * Free all resources used by this cell. This won't affect the stored content. - * @return {!Promise} - */ -shaka.extern.EmeSessionStorageCell.prototype.destroy = function() {}; - - -/** - * Gets the currently stored sessions. - * @return {!Promise.>} - */ -shaka.extern.EmeSessionStorageCell.prototype.getAll = function() {}; +shaka.extern.EmeSessionStorageCell = class { + constructor() {} + /** + * Free all resources used by this cell. This won't affect the stored content. + * @return {!Promise} + */ + destroy() {} -/** - * Adds the given sessions to the store. - * @param {!Array.} sessions - * @return {!Promise} - */ -shaka.extern.EmeSessionStorageCell.prototype.add = function(sessions) {}; + /** + * Gets the currently stored sessions. + * @return {!Promise.>} + */ + getAll() {} + /** + * Adds the given sessions to the store. + * @param {!Array.} sessions + * @return {!Promise} + */ + add(sessions) {} -/** - * Removes the given session IDs from the store. - * @param {!Array.} sessionIds - * @return {!Promise} - */ -shaka.extern.EmeSessionStorageCell.prototype.remove = function(sessionIds) {}; + /** + * Removes the given session IDs from the store. + * @param {!Array.} sessionIds + * @return {!Promise} + */ + remove(sessionIds) {} +}; /** @@ -413,52 +401,49 @@ shaka.extern.EmeSessionStorageCell.prototype.remove = function(sessionIds) {}; * * @interface */ -shaka.extern.StorageMechanism = function() {}; - - -/** - * Initialize the storage mechanism for first use. This should only be called - * once. Calling |init| multiple times has an undefined behaviour. - * - * @return {!Promise} - */ -shaka.extern.StorageMechanism.prototype.init = function() {}; - - -/** - * Free all resources used by the storage mechanism and its cells. This should - * not affect the stored content. - * - * @return {!Promise} - */ -shaka.extern.StorageMechanism.prototype.destroy = function() {}; - - -/** - * Get a map of all the cells managed by the storage mechanism. Editing the map - * should have no effect on the storage mechanism. The map key is the cell's - * address in the mechanism and should be consistent between calls to - * |getCells|. - * - * @return {!Map.} - */ -shaka.extern.StorageMechanism.prototype.getCells = function() {}; - - -/** - * Get the current EME session storage cell. - * @return {!shaka.extern.EmeSessionStorageCell} - */ -shaka.extern.StorageMechanism.prototype.getEmeSessionCell = function() {}; - - -/** - * Erase all content from storage and leave storage in an empty state. Erase may - * be called with or without |init|. This allows for storage to be wiped in - * case of a version mismatch. - * - * After calling |erase|, the mechanism will be in an initialized state. - * - * @return {!Promise} - */ -shaka.extern.StorageMechanism.prototype.erase = function() {}; +shaka.extern.StorageMechanism = class { + constructor() {} + + /** + * Initialize the storage mechanism for first use. This should only be called + * once. Calling |init| multiple times has an undefined behaviour. + * + * @return {!Promise} + */ + init() {} + + /** + * Free all resources used by the storage mechanism and its cells. This should + * not affect the stored content. + * + * @return {!Promise} + */ + destroy() {} + + /** + * Get a map of all the cells managed by the storage mechanism. Editing the + * map should have no effect on the storage mechanism. The map key is the + * cell's address in the mechanism and should be consistent between calls to + * |getCells|. + * + * @return {!Map.} + */ + getCells() {} + + /** + * Get the current EME session storage cell. + * @return {!shaka.extern.EmeSessionStorageCell} + */ + getEmeSessionCell() {} + + /** + * Erase all content from storage and leave storage in an empty state. Erase + * may be called with or without |init|. This allows for storage to be wiped + * in case of a version mismatch. + * + * After calling |erase|, the mechanism will be in an initialized state. + * + * @return {!Promise} + */ + erase() {} +}; diff --git a/externs/shaka/text.js b/externs/shaka/text.js index 920dc30895..08ce8f5b5c 100644 --- a/externs/shaka/text.js +++ b/externs/shaka/text.js @@ -25,329 +25,299 @@ * @interface * @exportDoc */ -shaka.extern.CueRegion = function() {}; - - -/** - * Region identifier. - * @type {string} - * @exportDoc - */ -shaka.extern.CueRegion.prototype.id; - - -/** - * The X offset to start the rendering area in anchorUnits of the video width. - * @type {number} - * @exportDoc - */ -shaka.extern.CueRegion.prototype.viewportAnchorX; - - -/** - * The X offset to start the rendering area in anchorUnits of the video height. - * @type {number} - * @exportDoc - */ -shaka.extern.CueRegion.prototype.viewportAnchorY; - - -/** - * The X offset to start the rendering area in percentage (0-100) of - * the region width. - * @type {number} - * @exportDoc - */ -shaka.extern.CueRegion.prototype.regionAnchorX; - - -/** - * The Y offset to start the rendering area in percentage (0-100) of - * the region height. - * @type {number} - * @exportDoc - */ -shaka.extern.CueRegion.prototype.regionAnchorY; - - -/** - * The width of the rendering area in widthUnits. - * @type {number} - * @exportDoc - */ -shaka.extern.CueRegion.prototype.width; - - -/** - * The width of the rendering area in heightUnits. - * @type {number} - * @exportDoc - */ -shaka.extern.CueRegion.prototype.height; - - -/** - * The units (percentage, pixels or lines) the region height is in. - * @type {shaka.text.CueRegion.units} - * @exportDoc - */ -shaka.extern.CueRegion.prototype.heightUnits; - - -/** - * The units (percentage or pixels) the region width is in. - * @type {shaka.text.CueRegion.units} - * @exportDoc - */ -shaka.extern.CueRegion.prototype.widthUnits; - - -/** - * The units (percentage or pixels) the region viewportAnchors are in. - * @type {shaka.text.CueRegion.units} - * @exportDoc - */ -shaka.extern.CueRegion.prototype.viewportAnchorUnits; - - -/** - * If scroll=UP, it means that cues in the region will be added to the bottom of - * the region and will push any already displayed cues in the region up. - * Otherwise (scroll=NONE) cues will stay fixed at the location - * they were first painted in. - * @type {shaka.text.CueRegion.scrollMode} - * @exportDoc - */ -shaka.extern.CueRegion.prototype.scroll; +shaka.extern.CueRegion = class { + constructor() { + /** + * Region identifier. + * @type {string} + * @exportDoc + */ + this.id; + + /** + * The X offset to start the rendering area in anchorUnits of the video + * width. + * @type {number} + * @exportDoc + */ + this.viewportAnchorX; + + /** + * The X offset to start the rendering area in anchorUnits of the video + * height. + * @type {number} + * @exportDoc + */ + this.viewportAnchorY; + + /** + * The X offset to start the rendering area in percentage (0-100) of this + * region width. + * @type {number} + * @exportDoc + */ + this.regionAnchorX; + + /** + * The Y offset to start the rendering area in percentage (0-100) of the + * region height. + * @type {number} + * @exportDoc + */ + this.regionAnchorY; + + /** + * The width of the rendering area in widthUnits. + * @type {number} + * @exportDoc + */ + this.width; + + /** + * The width of the rendering area in heightUnits. + * @type {number} + * @exportDoc + */ + this.height; + + /** + * The units (percentage, pixels or lines) the region height is in. + * @type {shaka.text.CueRegion.units} + * @exportDoc + */ + this.heightUnits; + + /** + * The units (percentage or pixels) the region width is in. + * @type {shaka.text.CueRegion.units} + * @exportDoc + */ + this.widthUnits; + + /** + * The units (percentage or pixels) the region viewportAnchors are in. + * @type {shaka.text.CueRegion.units} + * @exportDoc + */ + this.viewportAnchorUnits; + + /** + * If scroll=UP, it means that cues in the region will be added to the + * bottom of the region and will push any already displayed cues in the + * region up. Otherwise (scroll=NONE) cues will stay fixed at the location + * they were first painted in. + * @type {shaka.text.CueRegion.scrollMode} + * @exportDoc + */ + shaka.extern.CueRegion.prototype.scroll; + } +}; /** * @interface * @exportDoc */ -shaka.extern.Cue = function() {}; - - -/** - * The start time of the cue in seconds, relative to the start of the - * presentation. - * @type {number} - * @exportDoc - */ -shaka.extern.Cue.prototype.startTime; - - -/** - * The end time of the cue in seconds, relative to the start of the - * presentation. - * @type {number} - * @exportDoc - */ -shaka.extern.Cue.prototype.endTime; - - -/** - * The text payload of the cue. - * @type {!string} - * @exportDoc - */ -shaka.extern.Cue.prototype.payload; - - -/** - * The region to render the cue into. - * @type {shaka.extern.CueRegion} - * @exportDoc - */ -shaka.extern.Cue.prototype.region; - - -/** - * The indent (in percent) of the cue box in the direction defined by the - * writing direction. - * @type {?number} - * @exportDoc - */ -shaka.extern.Cue.prototype.position; - - -/** - * Position alignment of the cue. - * @type {shaka.text.Cue.positionAlign} - * @exportDoc - */ -shaka.extern.Cue.prototype.positionAlign; - - -/** - * Size of the cue box (in percents). - * @type {number} - * @exportDoc - */ -shaka.extern.Cue.prototype.size; - - -/** - * Alignment of the text inside the cue box. - * @type {shaka.text.Cue.textAlign} - * @exportDoc - */ -shaka.extern.Cue.prototype.textAlign; - - -/** - * Text direction of the cue. - * @type {shaka.text.Cue.direction} - * @exportDoc - */ -shaka.extern.Cue.prototype.direction; - - -/** - * Text writing mode of the cue. - * @type {shaka.text.Cue.writingMode} - * @exportDoc - */ -shaka.extern.Cue.prototype.writingMode; - - -/** - * The way to interpret line field. (Either as an integer line number or - * percentage from the display box). - * @type {shaka.text.Cue.lineInterpretation} - * @exportDoc - */ -shaka.extern.Cue.prototype.lineInterpretation; - - -/** - * The offset from the display box in either number of lines or - * percentage depending on the value of lineInterpretation. - * @type {?number} - * @exportDoc - */ -shaka.extern.Cue.prototype.line; - - -/** - * Separation between line areas inside the cue box in px or em - * (e.g. '100px'/'100em'). If not specified, this should be no less than - * the largest font size applied to the text in the cue. - * @type {string}. - * @exportDoc - */ -shaka.extern.Cue.prototype.lineHeight; - - -/** - * Line alignment of the cue box. - * Start alignment means the cue box’s top side (for horizontal cues), left side - * (for vertical growing right), or right side (for vertical growing left) is - * aligned at the line. - * Center alignment means the cue box is centered at the line. - * End alignment The cue box’s bottom side (for horizontal cues), right side - * (for vertical growing right), or left side (for vertical growing left) is - * aligned at the line. - * @type {shaka.text.Cue.lineAlign} - * @exportDoc - */ -shaka.extern.Cue.prototype.lineAlign; - - -/** - * Vertical alignments of the cues within their extents. - * 'BEFORE' means displaying the captions at the top of the text display - * container box, 'CENTER' means in the middle, 'AFTER' means at the bottom. - * @type {shaka.text.Cue.displayAlign} - * @exportDoc - */ -shaka.extern.Cue.prototype.displayAlign; - - -/** - * Text color represented by any string that would be accepted in CSS. - * E. g. '#FFFFFF' or 'white'. - * @type {!string} - * @exportDoc - */ -shaka.extern.Cue.prototype.color; - - -/** - * Text background color represented by any string that would be - * accepted in CSS. - * E. g. '#FFFFFF' or 'white'. - * @type {!string} - * @exportDoc - */ -shaka.extern.Cue.prototype.backgroundColor; - - -/** - * Image background represented by any string that would be - * accepted in image HTML element. - * E. g. 'data:[mime type];base64,[data]'. - * @type {!string} - * @exportDoc - */ -shaka.extern.Cue.prototype.backgroundImage; - - -/** - * Text font size in px or em (e.g. '100px'/'100em'). - * @type {string} - * @exportDoc - */ -shaka.extern.Cue.prototype.fontSize; - - -/** - * Text font weight. Either normal or bold. - * @type {shaka.text.Cue.fontWeight} - * @exportDoc - */ -shaka.extern.Cue.prototype.fontWeight; - - -/** - * Text font style. Normal, italic or oblique. - * @type {shaka.text.Cue.fontStyle} - * @exportDoc - */ -shaka.extern.Cue.prototype.fontStyle; - - -/** - * Text font family. - * @type {!string} - * @exportDoc - */ -shaka.extern.Cue.prototype.fontFamily; - - -/** - * Text decoration. A combination of underline, overline - * and line through. Empty array means no decoration. - * @type {!Array.} - * @exportDoc - */ -shaka.extern.Cue.prototype.textDecoration; - - -/** - * Whether or not line wrapping should be applied to the cue. - * @type {boolean} - * @exportDoc - */ -shaka.extern.Cue.prototype.wrapLine; - - -/** - * Id of the cue. - * @type {!string} - * @exportDoc - */ -shaka.extern.Cue.prototype.id; +shaka.extern.Cue = class { + constructor() { + /** + * The start time of the cue in seconds, relative to the start of the + * presentation. + * @type {number} + * @exportDoc + */ + this.startTime; + + /** + * The end time of the cue in seconds, relative to the start of the + * presentation. + * @type {number} + * @exportDoc + */ + this.endTime; + + /** + * The text payload of the cue. + * @type {!string} + * @exportDoc + */ + this.payload; + + /** + * The region to render the cue into. + * @type {shaka.extern.CueRegion} + * @exportDoc + */ + this.region; + + /** + * The indent (in percent) of the cue box in the direction defined by the + * writing direction. + * @type {?number} + * @exportDoc + */ + this.position; + + /** + * Position alignment of the cue. + * @type {shaka.text.Cue.positionAlign} + * @exportDoc + */ + this.positionAlign; + + /** + * Size of the cue box (in percents). + * @type {number} + * @exportDoc + */ + this.size; + + /** + * Alignment of the text inside the cue box. + * @type {shaka.text.Cue.textAlign} + * @exportDoc + */ + this.textAlign; + + /** + * Text direction of the cue. + * @type {shaka.text.Cue.direction} + * @exportDoc + */ + this.direction; + + /** + * Text writing mode of the cue. + * @type {shaka.text.Cue.writingMode} + * @exportDoc + */ + this.writingMode; + + /** + * The way to interpret line field. (Either as an integer line number or + * percentage from the display box). + * @type {shaka.text.Cue.lineInterpretation} + * @exportDoc + */ + this.lineInterpretation; + + /** + * The offset from the display box in either number of lines or + * percentage depending on the value of lineInterpretation. + * @type {?number} + * @exportDoc + */ + this.line; + + /** + * Separation between line areas inside the cue box in px or em + * (e.g. '100px'/'100em'). If not specified, this should be no less than + * the largest font size applied to the text in the cue. + * @type {string}. + * @exportDoc + */ + this.lineHeight; + + /** + * Line alignment of the cue box. + * Start alignment means the cue box’s top side (for horizontal cues), left + * side (for vertical growing right), or right side (for vertical growing + * left) is aligned at the line. + * Center alignment means the cue box is centered at the line. + * End alignment The cue box’s bottom side (for horizontal cues), right side + * (for vertical growing right), or left side (for vertical growing left) is + * aligned at the line. + * @type {shaka.text.Cue.lineAlign} + * @exportDoc + */ + this.lineAlign; + + /** + * Vertical alignments of the cues within their extents. + * 'BEFORE' means displaying the captions at the top of the text display + * container box, 'CENTER' means in the middle, 'AFTER' means at the bottom. + * @type {shaka.text.Cue.displayAlign} + * @exportDoc + */ + this.displayAlign; + + /** + * Text color represented by any string that would be accepted in CSS. + * E. g. '#FFFFFF' or 'white'. + * @type {!string} + * @exportDoc + */ + this.color; + + /** + * Text background color represented by any string that would be + * accepted in CSS. + * E. g. '#FFFFFF' or 'white'. + * @type {!string} + * @exportDoc + */ + this.backgroundColor; + + /** + * Image background represented by any string that would be + * accepted in image HTML element. + * E. g. 'data:[mime type];base64,[data]'. + * @type {!string} + * @exportDoc + */ + this.backgroundImage; + + /** + * Text font size in px or em (e.g. '100px'/'100em'). + * @type {string} + * @exportDoc + */ + this.fontSize; + + /** + * Text font weight. Either normal or bold. + * @type {shaka.text.Cue.fontWeight} + * @exportDoc + */ + this.fontWeight; + + /** + * Text font style. Normal, italic or oblique. + * @type {shaka.text.Cue.fontStyle} + * @exportDoc + */ + this.fontStyle; + + /** + * Text font family. + * @type {!string} + * @exportDoc + */ + this.fontFamily; + + /** + * Text decoration. A combination of underline, overline + * and line through. Empty array means no decoration. + * @type {!Array.} + * @exportDoc + */ + this.textDecoration; + + /** + * Whether or not line wrapping should be applied to the cue. + * @type {boolean} + * @exportDoc + */ + this.wrapLine; + + /** + * Id of the cue. + * @type {!string} + * @exportDoc + */ + this.id; + } +}; /** @@ -356,7 +326,32 @@ shaka.extern.Cue.prototype.id; * @interface * @exportDoc */ -shaka.extern.TextParser = function() {}; +shaka.extern.TextParser = class { + /** + * Parse an initialization segment. Some formats do not have init + * segments so this won't always be called. + * + * @param {!Uint8Array} data + * The data that makes up the init segment. + * + * @exportDoc + */ + parseInit(data) {} + + /** + * Parse a media segment and return the cues that make up the segment. + * + * @param {!Uint8Array} data + * The next section of buffer. + * @param {shaka.extern.TextParser.TimeContext} timeContext + * The time information that should be used to adjust the times values + * for each cue. + * @return {!Array.} + * + * @exportDoc + */ + parseMedia(data, timeContext) {} +}; /** @@ -381,33 +376,6 @@ shaka.extern.TextParser = function() {}; shaka.extern.TextParser.TimeContext; -/** - * Parse an initialization segment. Some formats do not have init - * segments so this won't always be called. - * - * @param {!Uint8Array} data - * The data that makes up the init segment. - * - * @exportDoc - */ -shaka.extern.TextParser.prototype.parseInit = function(data) {}; - - -/** - * Parse a media segment and return the cues that make up the segment. - * - * @param {!Uint8Array} data - * The next section of buffer. - * @param {shaka.extern.TextParser.TimeContext} timeContext - * The time information that should be used to adjust the times values - * for each cue. - * @return {!Array.} - * - * @exportDoc - */ -shaka.extern.TextParser.prototype.parseMedia = function(data, timeContext) {}; - - /** * @typedef {function(new:shaka.extern.TextParser)} * @exportDoc @@ -422,61 +390,56 @@ shaka.extern.TextParserPlugin; * @extends {shaka.util.IDestroyable} * @exportDoc */ -shaka.extern.TextDisplayer = function() {}; - - -/** - * @override - * @exportDoc - */ -shaka.extern.TextDisplayer.prototype.destroy = function() {}; - - -/** - * Append given text cues to the list of cues to be displayed. - * - * @param {!Array.} cues - * Text cues to be appended. - * - * @exportDoc - */ -shaka.extern.TextDisplayer.prototype.append = function(cues) {}; - - -/** - * Remove all cues that are fully contained by the given time range (relative - * to the presentation). |endTime| will be greater to equal to |startTime|. - * |remove| should only return |false| if the displayer has been destroyed. If - * the displayer has not been destroyed |remove| should return |true|. - * - * @param {number} startTime - * @param {number} endTime - * - * @return {boolean} - * - * @exportDoc - */ -shaka.extern.TextDisplayer.prototype.remove = function(startTime, endTime) {}; - - -/** - * Returns true if text is currently visible. - * - * @return {boolean} - * - * @exportDoc - */ -shaka.extern.TextDisplayer.prototype.isTextVisible = function() {}; - - -/** - * Set text visibility. - * - * @param {boolean} on - * - * @exportDoc - */ -shaka.extern.TextDisplayer.prototype.setTextVisibility = function(on) {}; +shaka.extern.TextDisplayer = class { + /** + * @override + * @exportDoc + */ + destroy() {} + + /** + * Append given text cues to the list of cues to be displayed. + * + * @param {!Array.} cues + * Text cues to be appended. + * + * @exportDoc + */ + append(cues) {} + + /** + * Remove all cues that are fully contained by the given time range (relative + * to the presentation). |endTime| will be greater to equal to |startTime|. + * |remove| should only return |false| if the displayer has been destroyed. If + * the displayer has not been destroyed |remove| should return |true|. + * + * @param {number} startTime + * @param {number} endTime + * + * @return {boolean} + * + * @exportDoc + */ + remove(startTime, endTime) {} + + /** + * Returns true if text is currently visible. + * + * @return {boolean} + * + * @exportDoc + */ + isTextVisible() {} + + /** + * Set text visibility. + * + * @param {boolean} on + * + * @exportDoc + */ + setTextVisibility(on) {} +}; /** diff --git a/test/text/ttml_text_parser_unit.js b/test/text/ttml_text_parser_unit.js index 59605c62e0..692f6cbfbf 100644 --- a/test/text/ttml_text_parser_unit.js +++ b/test/text/ttml_text_parser_unit.js @@ -814,9 +814,10 @@ describe('TtmlTextParser', () => { verifyRegion(cues[i].region, result[i].region); } + const asObj = /** @type {!Object} */ (result[i]); for (const property of properties) { if (property in cues[i]) { - expect(result[i][property]).toEqual(cues[i][property]); + expect(asObj[property]).toEqual(cues[i][property]); } } @@ -841,9 +842,10 @@ describe('TtmlTextParser', () => { 'scroll']; expect(actual).toBeTruthy(); + const asObj = /** @type {!Object} */ (actual); for (const property of properties) { if (property in expected) { - expect(actual[property]).toEqual(expected[property]); + expect(asObj[property]).toEqual(expected[property]); } } } diff --git a/test/text/vtt_text_parser_unit.js b/test/text/vtt_text_parser_unit.js index cb710d12ec..ea17681a87 100644 --- a/test/text/vtt_text_parser_unit.js +++ b/test/text/vtt_text_parser_unit.js @@ -641,9 +641,10 @@ describe('VttTextParser', () => { 'scroll']; expect(actual).toBeTruthy(); + const asObj = /** @type {!Object} */ (actual); for (const property of properties) { if (property in expected) { - expect(actual[property]).toEqual(expected[property]); + expect(asObj[property]).toEqual(expected[property]); } } }