Skip to content

Commit 6ad14bf

Browse files
rtibblesclaude
andcommitted
Remediate JSDoc violations in plugins/media_player
Adds typedef import for video.js Component; restores typed @param annotations across the videojs Vue mixins; fills missing block descriptions, @param descriptions, and @returns declarations on the captions/languages/transcript helper modules. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 42b4e71 commit 6ad14bf

19 files changed

Lines changed: 142 additions & 89 deletions

kolibri/plugins/media_player/frontend/mixins/videojsButtonMixin.js

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,20 @@
11
import videojs from 'video.js';
22

33
/**
4-
* @param {String} videojsComponent A string of the videojs component to extend
4+
* Build a base class extending the named video.js menu button component, with
5+
* additional behaviour for hiding the menu on mouseleave and dismissing it on
6+
* outside clicks.
7+
* @param {string} videojsComponent - The name of the videojs component to extend.
8+
* @returns {Function} A class extending the requested videojs component.
59
*/
610
export default function videojsButtonMixin(videojsComponent) {
711
return class extends videojs.getComponent(videojsComponent) {
812
/**
9-
* @param player
10-
* @param options
11-
* @param ready
13+
* Wire up the mouseleave-to-hide behaviour and the outside-click listener used
14+
* to dismiss the menu.
15+
* @param {object} player - The video.js player instance.
16+
* @param {object} [options] - Component options forwarded to videojs.
17+
* @param {Function} [ready] - Optional ready callback forwarded to videojs.
1218
*/
1319
constructor(player, options, ready) {
1420
super(player, options, ready);
@@ -29,16 +35,18 @@ export default function videojsButtonMixin(videojsComponent) {
2935
}
3036

3137
/**
32-
* Should build and return an instance of a Video.js Menu
33-
* @return {Menu}
38+
* Should build and return an instance of a Video.js Menu. The base
39+
* implementation throws; subclasses must override.
40+
* @throws {Error} Always — subclasses must override this method.
3441
*/
3542
buildMenu() {
3643
throw new Error('Not implemented');
3744
}
3845

3946
/**
4047
* @override
41-
* @return {Menu}
48+
* @returns {object} A configured video.js Menu, populated with items and wired up to
49+
* the outside-click listener.
4250
*/
4351
createMenu() {
4452
if (this.items) {
@@ -65,10 +73,10 @@ export default function videojsButtonMixin(videojsComponent) {
6573
}
6674

6775
/**
68-
* Removes class that adds specific functionality we don't want
69-
*
70-
* @param {String} classNames
71-
* @return {String}
76+
* Removes the `vjs-menu-button-popup` class that adds specific functionality
77+
* we don't want.
78+
* @param {string} classNames - Space-separated class string to filter.
79+
* @returns {string} The class string without the popup class.
7280
*/
7381
removePopupClass(classNames) {
7482
return classNames.replace(/\bvjs-menu-button-popup\b/, ' ');

kolibri/plugins/media_player/frontend/mixins/videojsMenuItemVueMixin.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
import videojsVueMixin from './videojsVueMixin';
22

3-
/**
4-
* @param {Object} vueComponent A compiled vue component object
5-
*/
63
export default function videojsMenuItemVueMixin(vueComponent) {
74
return class extends videojsVueMixin('MenuItem', vueComponent) {
85
createVueComponent(options = {}) {

kolibri/plugins/media_player/frontend/mixins/videojsMenuVueMixin.js

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,20 @@
11
import videojsVueMixin from './videojsVueMixin';
22

33
/**
4-
* @param {Object} vueComponent A compiled vue component object
4+
* @typedef {import('video.js').default.Component} VideoJsComponent
5+
*/
6+
7+
/**
8+
* Build a video.js Menu subclass that renders its content through a Vue component.
9+
* @param {object} vueComponent - A compiled vue component object
10+
* @returns {typeof VideoJsComponent} The extended Menu class
511
*/
612
export default function videojsMenuVueMixin(vueComponent) {
713
return class extends videojsVueMixin('Menu', vueComponent) {
814
/**
9-
* @param player
10-
* @param options
15+
* Initialise lock and focused-child state on top of the parent Menu constructor.
16+
* @param {VideoJsComponent} player - The video.js player instance
17+
* @param {object} [options] - Options forwarded to the parent Menu component
1118
*/
1219
constructor(player, options) {
1320
super(player, options);
@@ -19,9 +26,8 @@ export default function videojsMenuVueMixin(vueComponent) {
1926
/**
2027
* `contentEl` is used when `addItem` is called, so this allows the addition of the text track
2128
* options (the languages) in the right spot
22-
*
2329
* @override
24-
* @return {*|Element}
30+
* @returns {Element} The element into which menu items should be inserted
2531
*/
2632
contentEl() {
2733
return this.getVueComponent().contentEl();
@@ -30,9 +36,8 @@ export default function videojsMenuVueMixin(vueComponent) {
3036
/**
3137
* `contentEl` is used when `addItem` is called, so this allows the addition of the text track
3238
* options (the languages) in the right spot
33-
*
3439
* @override
35-
* @return {*|Element}
40+
* @returns {Element} The element into which menu items should be inserted
3641
*/
3742
get contentEl_() {
3843
return this.contentEl();
@@ -44,17 +49,15 @@ export default function videojsMenuVueMixin(vueComponent) {
4449

4550
/**
4651
* Override parent's method, which adds event handlers we don't want
47-
*
4852
* @override
49-
* @param {Component|String} item The name or instance of the item to add
53+
* @param {VideoJsComponent | string} item - The name or instance of the item to add
5054
*/
5155
addItem(item) {
5256
this.addChild(item);
5357
}
5458

5559
/**
5660
* Triggered by mouseenter of button container
57-
*
5861
* @override
5962
*/
6063
show() {
@@ -63,7 +66,6 @@ export default function videojsMenuVueMixin(vueComponent) {
6366

6467
/**
6568
* Triggered by mouseleave of button container
66-
*
6769
* @override
6870
*/
6971
hide() {
@@ -72,7 +74,6 @@ export default function videojsMenuVueMixin(vueComponent) {
7274

7375
/**
7476
* Triggered on click in ancestor
75-
*
7677
* @override
7778
*/
7879
lockShowing() {
@@ -81,15 +82,15 @@ export default function videojsMenuVueMixin(vueComponent) {
8182

8283
/**
8384
* Triggered on blur in ancestor
84-
*
8585
* @override
8686
*/
8787
unlockShowing() {
8888
this.doHide(true);
8989
}
9090

9191
/**
92-
* @param {Boolean} lock Whether or not to lock it open
92+
* Show the menu, optionally locking it open so mouseleave won't hide it.
93+
* @param {boolean} lock - Whether or not to lock it open
9394
*/
9495
doShow(lock = false) {
9596
const component = this.getVueComponent();
@@ -108,7 +109,8 @@ export default function videojsMenuVueMixin(vueComponent) {
108109
}
109110

110111
/**
111-
* @param {Boolean} unlock Whether or not to unlock it if it's locked open
112+
* Hide the menu, optionally unlocking it first if it was locked open.
113+
* @param {boolean} unlock - Whether or not to unlock it if it's locked open
112114
*/
113115
doHide(unlock = false) {
114116
const component = this.getVueComponent();
@@ -124,6 +126,8 @@ export default function videojsMenuVueMixin(vueComponent) {
124126

125127
/**
126128
* Called by Video.js key event handlers
129+
* @param {number} [index] - Child index to focus; defaults to the last focused child, wraps on
130+
* overflow
127131
*/
128132
focus(index) {
129133
const children = this.children();

kolibri/plugins/media_player/frontend/mixins/videojsVueMixin.js

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,10 @@ import store from 'kolibri/store';
33
import videojs from 'video.js';
44

55
/**
6-
* @param {String} videojsComponent A string of the videojs component to extend
7-
* @param {Object} vueComponent A compiled vue component object
6+
* Produce a video.js component class that renders a Vue component as its DOM element.
7+
* @param {string} videojsComponent - A string of the videojs component to extend
8+
* @param {object} vueComponent - A compiled vue component object
9+
* @returns {Function} Subclass of the named video.js component backed by the Vue component
810
*/
911
export default function videojsVueMixin(videojsComponent, vueComponent) {
1012
const VideojsComponent = videojs.getComponent(videojsComponent);
@@ -14,16 +16,16 @@ export default function videojsVueMixin(videojsComponent, vueComponent) {
1416
/**
1517
* This is called by video.js code that usually constructs an element, but here we'll leverage
1618
* vue by calling it manually.
17-
*
18-
* @return {Element}
19+
* @returns {Element} Root DOM element from the mounted Vue component
1920
*/
2021
createEl() {
2122
return this.createVueComponent().$el;
2223
}
2324

2425
/**
25-
* @param {Object} [options]
26-
* @return {VueComponent}
26+
* Destroy any existing Vue instance and mount a fresh one, storing it on the component.
27+
* @param {object} [options] - Extra options forwarded to the Vue component constructor
28+
* @returns {VueComponent} The freshly mounted Vue component
2729
*/
2830
createVueComponent(options) {
2931
this.clearVueComponent();
@@ -32,7 +34,8 @@ export default function videojsVueMixin(videojsComponent, vueComponent) {
3234
}
3335

3436
/**
35-
* @return {VueComponent}
37+
* Return the currently mounted Vue component, if any.
38+
* @returns {VueComponent} The currently held Vue component, or undefined if none is mounted
3639
*/
3740
getVueComponent() {
3841
return this._vueComponent;

kolibri/plugins/media_player/frontend/modules/captions/index.js

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@ import Settings from '../../utils/settings';
66
const { handleSelectedLanguageChange } = videojs.getComponent('TextTrackMenuItem').prototype;
77

88
/**
9-
* @return {{captionLanguage: *, captionSubtitles: boolean, captionTranscript: boolean}}
9+
* Build the default captions settings, seeded from the active Vue locale.
10+
* @returns {{captionLanguage: string, captionSubtitles: boolean, captionTranscript: boolean}}
11+
* The default captions settings object.
1012
*/
1113
const defaultSettings = () => ({
1214
captionLanguage: vue.locale,
@@ -15,16 +17,18 @@ const defaultSettings = () => ({
1517
});
1618

1719
/**
18-
* @param state
19-
* @return {TextTrack[]}
20+
* Resolve the captions module's track list to a plain array.
21+
* @param {object} state - The captions module's Vuex state.
22+
* @returns {TextTrack[]} The configured text tracks, or an empty array when none.
2023
*/
2124
const tracks = state => {
2225
return trackUtils.listToArray(state.trackList || []);
2326
};
2427

2528
/**
26-
* @param state
27-
* @return {TextTrack|null}
29+
* Find the track matching the active captions language.
30+
* @param {object} state - The captions module's Vuex state.
31+
* @returns {?TextTrack} The matching track, or undefined when no track matches.
2832
*/
2933
const languageTrack = state => {
3034
return tracks(state).find(track => state.language === track.language);
@@ -81,28 +85,32 @@ export default {
8185
},
8286
getters: {
8387
/**
84-
* @param state
85-
* @return {string}
88+
* The display label for the track matching the active captions language.
89+
* @param {object} state - The captions module's Vuex state.
90+
* @returns {string} The matching track label, or empty string when none matches.
8691
*/
8792
languageLabel(state) {
8893
const track = languageTrack(state);
8994
return track ? track.label : '';
9095
},
9196
/**
92-
* @param state
93-
* @return {TextTrack[]}
97+
* Resolve the captions module's track list to a plain array.
98+
* @param {object} state - The captions module's Vuex state.
99+
* @returns {TextTrack[]} The configured text tracks.
94100
*/
95101
tracks,
96102
/**
97-
* @param state
98-
* @return {TextTrack}
103+
* Find the currently enabled text track.
104+
* @param {object} state - The captions module's Vuex state.
105+
* @returns {?TextTrack} The enabled track, or undefined when none is enabled.
99106
*/
100107
activeTrack(state) {
101108
return tracks(state).find(track => trackUtils.isEnabled(track));
102109
},
103110
/**
104-
* @param state
105-
* @return {TextTrack|null}
111+
* Find the track matching the active captions language.
112+
* @param {object} state - The captions module's Vuex state.
113+
* @returns {?TextTrack} The matching track, or undefined when no track matches.
106114
*/
107115
languageTrack,
108116
},

kolibri/plugins/media_player/frontend/utils/track.js

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@ export const MODE_DISABLED = 'disabled';
44

55
export default {
66
/**
7-
* @param {String} mode
8-
* @return {boolean}
7+
* Check whether a track mode counts as enabled (showing or hidden).
8+
* @param {string} mode - The TextTrack mode string to check
9+
* @returns {boolean} True if the mode is showing or hidden
910
*/
1011
isEnabledMode(mode) {
1112
return mode === MODE_SHOWING || mode === MODE_HIDDEN;
@@ -14,10 +15,9 @@ export default {
1415
/**
1516
* Setting mode can cause events, which could cause loop if we don't make sure that the mode
1617
* isn't already the mode we're going to set
17-
*
18-
* @param {TextTrack} track
19-
* @param {Boolean} enabled
20-
* @param {Boolean} [hidden]
18+
* @param {TextTrack} track - The track to update
19+
* @param {boolean} enabled - Whether the track should be enabled
20+
* @param {boolean} [hidden] - If enabled, whether to hide the track's cues
2121
*/
2222
setMode(track, enabled, hidden = false) {
2323
let mode = MODE_DISABLED;
@@ -32,8 +32,9 @@ export default {
3232
},
3333

3434
/**
35-
* @param {TextTrack} track
36-
* @return {boolean}
35+
* Check whether a track is currently enabled.
36+
* @param {TextTrack} track - The track to check
37+
* @returns {boolean} True if the track's mode is showing or hidden
3738
*/
3839
isEnabled(track) {
3940
return this.isEnabledMode(track.mode);
@@ -42,9 +43,8 @@ export default {
4243
/**
4344
* Text track lists do not implement all array-like features, so this will convert it into an
4445
* array
45-
*
46-
* @param {TextTrackList|TextTrackCueList} list
47-
* @return {TextTrack[]|TextTrackCue[]}
46+
* @param {TextTrackList|TextTrackCueList} list - The list-like object to convert
47+
* @returns {TextTrack[]|TextTrackCue[]} A plain array of the list's entries
4848
*/
4949
listToArray(list) {
5050
return Array.prototype.slice.call(list, 0);

kolibri/plugins/media_player/frontend/views/MediaPlayerCaptions/SubtitlesMenuItem.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
methods: {
3030
...mapActions('mediaPlayer/captions', ['toggleSubtitles']),
3131
/**
32+
* Accessible via parent component refs.
3233
* @public
3334
*/
3435
focus() {

kolibri/plugins/media_player/frontend/views/MediaPlayerCaptions/TranscriptMenuItem.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
methods: {
3535
...mapActions('mediaPlayer/captions', ['toggleTranscript']),
3636
/**
37+
* Accessible via parent component refs.
3738
* @public
3839
*/
3940
focus() {

0 commit comments

Comments
 (0)