From 74c1316cf22a3d6716c1a9db5d1976b2c1e8f5ae Mon Sep 17 00:00:00 2001 From: mister-ben <1676039+mister-ben@users.noreply.github.com> Date: Thu, 12 Dec 2024 17:15:42 +0100 Subject: [PATCH] Fix type of SourceObject, MediaObject --- src/js/component.js | 4 ++-- src/js/player.js | 16 +++++++++------- src/js/tech/html5.js | 18 ++++++++++-------- src/js/tech/middleware.js | 3 ++- src/js/utils/filter-source.js | 10 ++++++---- 5 files changed, 29 insertions(+), 22 deletions(-) diff --git a/src/js/component.js b/src/js/component.js index 04ec746358..87d2a74fa8 100644 --- a/src/js/component.js +++ b/src/js/component.js @@ -1248,7 +1248,7 @@ class Component { * An object that contains width and height values of the `Component`s * computed style. Uses `window.getComputedStyle`. * - * @typedef {Object} Component~DimensionObject + * @typedef {Object} DimensionObject * * @property {number} width * The width of the `Component`s computed style. @@ -1263,7 +1263,7 @@ class Component { * * Uses `window.getComputedStyle`. * - * @return {Component~DimensionObject} + * @return {DimensionObject} * The computed dimensions of the component's element. */ currentDimensions() { diff --git a/src/js/player.js b/src/js/player.js index e6dab78d23..e3380bc572 100644 --- a/src/js/player.js +++ b/src/js/player.js @@ -3534,7 +3534,7 @@ class Player extends Component { /** * Executes source setting and getting logic * - * @param {SourceObject|SourceObject[]|string} [source] + * @param {string|SourceObject|Array.} [source] * A SourceObject, an array of SourceObjects, or a string referencing * a URL to a media source. It is _highly recommended_ that an object * or array of objects is used here, so that source selection @@ -3645,7 +3645,7 @@ class Player extends Component { /** * Get or set the video source. * - * @param {SourceObject|SourceObject[]|string} [source] + * @param {string|SourceObject|Array.} [source] * A SourceObject, an array of SourceObjects, or a string referencing * a URL to a media source. It is _highly recommended_ that an object * or array of objects is used here, so that source selection @@ -5114,8 +5114,10 @@ class Player extends Component { * Properties that are not part of this type description will be retained; so, * this can be viewed as a generic metadata storage mechanism as well. * + * Contains properties from MediaMetadata + * * @see {@link https://wicg.github.io/mediasession/#the-mediametadata-interface} - * @typedef {Object} Player~MediaObject + * @typedef {Object} MediaObject * * @property {string} [album] * Unused, except if this object is passed to the `MediaSession` @@ -5133,7 +5135,7 @@ class Player extends Component { * @property {string} [poster] * URL to an image that will display before playback. * - * @property {SourceObject|SourceObject[]|string} [src] + * @property {string|SourceObject|Array.} [src] * A single source object, an array of source objects, or a string * referencing a URL to a media source. It is _highly recommended_ * that an object or array of objects is used here, so that source @@ -5156,7 +5158,7 @@ class Player extends Component { /** * Populate the player using a {@link Player~MediaObject|MediaObject}. * - * @param {Player~MediaObject} media + * @param {MediaObject} media * A media object. * * @param {Function} ready @@ -5214,9 +5216,9 @@ class Player extends Component { * Get a clone of the current {@link Player~MediaObject} for this player. * * If the `loadMedia` method has not been used, will attempt to return a - * {@link Player~MediaObject} based on the current state of the player. + * {@link MediaObject} based on the current state of the player. * - * @return {Player~MediaObject} + * @return {MediaObject} */ getMedia() { if (!this.cache_.media) { diff --git a/src/js/tech/html5.js b/src/js/tech/html5.js index 841d2345b4..929856b1a9 100644 --- a/src/js/tech/html5.js +++ b/src/js/tech/html5.js @@ -14,6 +14,8 @@ import {NORMAL as TRACK_TYPES, REMOTE} from '../tracks/track-types'; import setupSourceset from './setup-sourceset'; import {silencePromise} from '../utils/promise'; +/** @import { SourceObject } from './tech' */ + /** * HTML5 Media Controller - Wrapper for HTML5 Media API * @@ -765,10 +767,10 @@ class Html5 extends Tech { * A getter/setter for the `Html5` Tech's source object. * > Note: Please use {@link Html5#setSource} * - * @param {Tech~SourceObject} [src] + * @param {SourceObject} [src] * The source object you want to set on the `HTML5` techs element. * - * @return {Tech~SourceObject|undefined} + * @return {string|undefined} * - The current source object when a source is not passed in. * - undefined when setting * @@ -856,8 +858,8 @@ class Html5 extends Tech { * Get the current source on the `HTML5` Tech. Falls back to returning the source from * the HTML5 media element. * - * @return {Tech~SourceObject} - * The current source object from the HTML5 tech. With a fallback to the + * @return {string} + * The current source from the HTML5 tech. With a fallback to the * elements source. */ currentSrc() { @@ -1934,7 +1936,7 @@ Html5.resetMediaElement = function(el) { * {@link Tech~SourceObject} for the media. * * @method Html5#setSrc - * @param {Tech~SourceObject} src + * @param {string} src * The source object to set as the current source. * * @see [Spec]{@link https://www.w3.org/TR/html5/embedded-content-0.html#dom-media-src} @@ -2078,7 +2080,7 @@ Tech.withSourceHandlers(Html5); /** * Native source handler for Html5, simply passes the source to the media element. * - * @property {Tech~SourceObject} source + * @property {SourceObject} source * The source object * * @property {Html5} tech @@ -2107,7 +2109,7 @@ Html5.nativeSourceHandler.canPlayType = function(type) { /** * Check if the media element can handle a source natively. * - * @param {Tech~SourceObject} source + * @param {SourceObject} source * The source object * * @param {Object} [options] @@ -2135,7 +2137,7 @@ Html5.nativeSourceHandler.canHandleSource = function(source, options) { /** * Pass the source to the native media element. * - * @param {Tech~SourceObject} source + * @param {SourceObject} source * The source object * * @param {Html5} tech diff --git a/src/js/tech/middleware.js b/src/js/tech/middleware.js index 78182c4a28..3bcb4d8870 100644 --- a/src/js/tech/middleware.js +++ b/src/js/tech/middleware.js @@ -6,6 +6,7 @@ import {toTitleCase} from '../utils/str.js'; /** @import Player from '../player' */ /** @import Tech from '../tech/tech' */ +/** @import { SourceObject } from './tech/tech' */ const middlewares = {}; const middlewareInstances = {}; @@ -75,7 +76,7 @@ export function getMiddleware(type) { * @param {Player} player * A {@link Player} instance. * - * @param {Tech~SourceObject} src + * @param {SourceObject} src * A source object. * * @param {Function} diff --git a/src/js/utils/filter-source.js b/src/js/utils/filter-source.js index 7cfe021206..90f6fe04a3 100644 --- a/src/js/utils/filter-source.js +++ b/src/js/utils/filter-source.js @@ -4,15 +4,17 @@ import {isObject} from './obj'; import {getMimetype} from './mimetypes'; +/** @import { SourceObject } from '../tech/tech' */ + /** * Filter out single bad source objects or multiple source objects in an * array. Also flattens nested source object arrays into a 1 dimensional * array of source objects. * - * @param {Tech~SourceObject|Tech~SourceObject[]} src + * @param {string|SourceObject|Array.} src * The src object to filter * - * @return {Tech~SourceObject[]} + * @return {SourceObject[]} * An array of sourceobjects containing only valid sources * * @private @@ -50,9 +52,9 @@ const filterSource = function(src) { /** * Checks src mimetype, adding it when possible * - * @param {Tech~SourceObject} src + * @param {SourceObject} src * The src object to check - * @return {Tech~SourceObject} + * @return {SourceObject} * src Object with known type */ function fixSource(src) {