Skip to content

Commit

Permalink
fix(xgplayer):类型声明修正
Browse files Browse the repository at this point in the history
  • Loading branch information
hongqx committed Jan 19, 2024
1 parent 90ecd1a commit 970c2a0
Show file tree
Hide file tree
Showing 26 changed files with 98 additions and 46 deletions.
5 changes: 5 additions & 0 deletions packages/xgplayer/src/mediaProxy.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,22 +106,27 @@ class MediaProxy extends EventEmitter {
constructor (options) {
super(options)
/**
* @type { boolean }
* @private
*/
this._hasStart = false
/**
* @type { number }
* @private
*/
this._currentTime = 0
/**
* @type { number }
* @private
*/
this._duration = 0
/**
* @type {{[propName: string]: any}}
* @private
*/
this._internalOp = {}
/**
* @type { boolean }
* @private
*/
this._lastMuted = false
Expand Down
4 changes: 2 additions & 2 deletions packages/xgplayer/src/player.js
Original file line number Diff line number Diff line change
Expand Up @@ -545,7 +545,7 @@ class Player extends MediaProxy {

/**
*
* @param { any } url
* @param { any } [url]
* @returns
*/
_startInit (url) {
Expand Down Expand Up @@ -2456,7 +2456,7 @@ class Player extends MediaProxy {

/**
* 累计观看时长
* @type number
* @type { number }
*/
get cumulateTime () {
const { acc, t } = this._accPlayed
Expand Down
9 changes: 4 additions & 5 deletions packages/xgplayer/src/plugin/plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ function registerTextObj (textConfig, plugin) {
class Plugin extends BasePlugin {
/**
* 插入dom结构
* @param { String | HTMLElement } html html字符串或者dom
* @param { string | HTMLElement } html html字符串或者dom
* @param { HTMLElement } parent
* @param { number } index
* @returns { HTMLElement }
Expand Down Expand Up @@ -193,8 +193,8 @@ class Plugin extends BasePlugin {
/**
*
* @param { HTMLElement } root
* @param { String } querySelector
* @param { String | Array<String> } eventType
* @param { string } querySelector
* @param { string | Array<string> } eventType
* @param { Function } callback
* @param { boolean } [capture=false]
* @returns
Expand Down Expand Up @@ -573,7 +573,6 @@ class Plugin extends BasePlugin {
}

/**
*
* @param { string } [value]
* @returns
*/
Expand All @@ -585,7 +584,7 @@ class Plugin extends BasePlugin {
const cs = window.getComputedStyle(this.root, null)
const cssDisplayValue = cs.getPropertyValue('display')
if (cssDisplayValue === 'none') {
return (this.root.style.display = 'block')
this.root.style.display = 'block'
}
}

Expand Down
1 change: 1 addition & 0 deletions packages/xgplayer/src/plugins/common/optionList.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ export default class OptionList {
return obj
}


show () {
Util.removeClass(this.root, 'hide')
Util.addClass(this.root, 'active')
Expand Down
6 changes: 5 additions & 1 deletion packages/xgplayer/src/plugins/common/optionsIcon.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,11 @@ export default class OptionsIcon extends Plugin {
Util.addClass(this.find('.xgplayer-icon'), 'btn-text')
}

show () {
/**
* @param {string} [value]
* @returns
*/
show (value) {
if (!this.config.list || this.config.list.length < 2) {
return
}
Expand Down
6 changes: 5 additions & 1 deletion packages/xgplayer/src/plugins/controls/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,11 @@ class Controls extends Plugin {
Util.removeClass(this.root, STATE_CLASS.CONTROLS_AUTOHIDE)
}

show () {
/**
* @param {string} [value]
* @returns
*/
show (value) {
this.root.style.display = ''
this.player.focus()
}
Expand Down
1 change: 1 addition & 0 deletions packages/xgplayer/src/plugins/danmu/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ class Danmu extends Plugin {
this.seekCost = 0
/**
* @readonly
* @type {number}
*/
this.intervalId = 0
/**
Expand Down
6 changes: 5 additions & 1 deletion packages/xgplayer/src/plugins/definition/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,11 @@ export default class DefinitionIcon extends OptionsIcon {
}
}

show () {
/**
* @param {string} [value]
* @returns
*/
show (value) {
if (!this.config.list || this.config.list.length < 2){
return
}
Expand Down
2 changes: 1 addition & 1 deletion packages/xgplayer/src/plugins/dynamicBg/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ function nowTime () {

/**
* Check whether the current environment supports canvas
* @returns { Boolean }
* @returns { boolean }
*/
function checkIsSupportCanvas () {
try {
Expand Down
3 changes: 3 additions & 0 deletions packages/xgplayer/src/plugins/fpsDetect/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ export default class FpsDetect extends BasePlugin {

afterCreate () {
const { player, config } = this
/**
* @type {null | number}
*/
this.timer = null
this._lastDecodedFrames = 0
this._currentStuckCount = 0
Expand Down
15 changes: 0 additions & 15 deletions packages/xgplayer/src/plugins/fullscreen/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,6 @@ export default class Fullscreen extends IconPlugin {
}
}

/**
* @private
*/
afterCreate () {
super.afterCreate()
const { config, playerConfig } = this
Expand Down Expand Up @@ -110,9 +107,6 @@ export default class Fullscreen extends IconPlugin {
}
}

/**
* @private
*/
registerIcons () {
return {
fullscreen: { icon: FullScreenSvg, class: 'xg-get-fullscreen' },
Expand Down Expand Up @@ -187,16 +181,7 @@ export default class Fullscreen extends IconPlugin {
}
}

show () {
super.show()
}

hide () {
super.hide()
}

/**
* @private
* @returns
*/
render () {
Expand Down
4 changes: 0 additions & 4 deletions packages/xgplayer/src/plugins/mobile/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,10 +113,6 @@ class MobilePlugin extends Plugin {
return this.playerConfig.timeOffset || 0
}

/**
* @private
* @returns {[propName: string]: any}
*/
registerIcons () {
return {
seekTipIcon: { icon: SeekTipIcon, class: 'xg-seek-pre' }
Expand Down
6 changes: 6 additions & 0 deletions packages/xgplayer/src/plugins/mobile/touch.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,13 @@ class Touche {
})
this.root = dom
this.events = config.eventType === 'mouse' ? MOUSES : TOUCHS
/**
* @type { null | number}
*/
this.pressIntrvalId = null
/**
* @type { null | number}
*/
this.dbIntrvalId = null
this.__handlers = {}
this._initEvent()
Expand Down
3 changes: 3 additions & 0 deletions packages/xgplayer/src/plugins/netAdaption/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ export default class NetAdaption extends BasePlugin {
}

afterCreate () {
/**
* @type {null | number}
*/
this._timer = setInterval(this._checkStatus.bind(this), 300)
}

Expand Down
6 changes: 5 additions & 1 deletion packages/xgplayer/src/plugins/playbackRate/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,11 @@ export default class PlaybackRate extends OptionsIcon {
this.renderItemList()
}

show () {
/**
* @param {string} [value]
* @returns
*/
show (value) {
if (!this.config.list || this.config.list.length === 0) {
return
}
Expand Down
6 changes: 5 additions & 1 deletion packages/xgplayer/src/plugins/poster/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,11 @@ class Poster extends Plugin {
Util.addClass(this.root, 'hide')
}

show () {
/**
* @param {string} [value]
* @returns
*/
show (value) {
Util.removeClass(this.root, 'hide')
}

Expand Down
14 changes: 9 additions & 5 deletions packages/xgplayer/src/plugins/progress/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,11 @@ class Progress extends Plugin {
this.useable = useable
}

show () {
/**
* @param {string} [value]
* @returns
*/
show (value) {
this.root && (this.root.style.display = 'flex')
}
/**
Expand Down Expand Up @@ -566,10 +570,10 @@ class Progress extends Plugin {

/**
* @description 根据currenTime和占用百分比更新进度条
* @param {Number} currentTime 需要更新到的时间
* @param {Number} seekTime 实际seek的时间
* @param {Number} percent 更新时间占比
* @param {Int} type 触发类型 0-down 1-move 2-up
* @param {number} currentTime 需要更新到的时间
* @param {number} seekTime 实际seek的时间
* @param {number} percent 更新时间占比
* @param {int} type 触发类型 0-down 1-move 2-up
*/
updateWidth (currentTime, seekTime, percent, type) {
const { config, player } = this
Expand Down
6 changes: 5 additions & 1 deletion packages/xgplayer/src/plugins/progressPreview/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,11 @@ export default class ProgressPreview extends Plugin {
Util.addClass(this.root, 'hide')
}

show () {
/**
* @param {string} [value]
* @returns
*/
show (value) {
Util.removeClass(this.root, 'hide')
}

Expand Down
7 changes: 5 additions & 2 deletions packages/xgplayer/src/plugins/prompt/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ class Prompt extends Plugin {
}

afterCreate () {
/**
* @type {number}
*/
this.intervalId = 0
this.customConfig = null
this.bind('.highlight', ['click', 'touchend'], (e) => {
Expand All @@ -36,7 +39,7 @@ class Prompt extends Plugin {
})

this.player.showPrompt = (...args) => {
this.show(...args)
this.showPrompt(...args)
}

this.player.hidePrompt = () => {
Expand All @@ -50,7 +53,7 @@ class Prompt extends Plugin {
})
}

show (detail, config = {}, onClick = () => {}) {
showPrompt (detail, config = {}, onClick = () => {}) {
if (!detail) {
return
}
Expand Down
6 changes: 5 additions & 1 deletion packages/xgplayer/src/plugins/replay/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,11 @@ class Replay extends Plugin {
Util.removeClass(this.player.root, 'replay')
}

show () {
/**
* @param {string} [value]
* @returns
*/
show (value) {
if (this.config.disable) {
return
}
Expand Down
6 changes: 5 additions & 1 deletion packages/xgplayer/src/plugins/start/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,11 @@ class Start extends Plugin {
Util.addClass(this.root, 'hide')
}

show () {
/**
* @param {string} [value]
* @returns
*/
show (value) {
Util.removeClass(this.root, 'hide')
}

Expand Down
3 changes: 3 additions & 0 deletions packages/xgplayer/src/plugins/testspeed/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ export default class TestSpeed extends BasePlugin {
}
this.initSpeedList()
this.on('real_time_speed', this._onRealSpeedChange)
/**
* @type {null || number }
*/
this.timer = null
this.cnt = 0
this.xhr = null
Expand Down
6 changes: 5 additions & 1 deletion packages/xgplayer/src/plugins/time/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,11 @@ class Time extends Plugin {
})
}

show () {
/**
* @param {string} [value]
* @returns
*/
show (value) {
if (this.mode === 'flex') {
this.centerCurDom && (this.centerCurDom.style.display = 'block')
this.centerDurDom && (this.centerDurDom.style.display = 'block')
Expand Down
6 changes: 5 additions & 1 deletion packages/xgplayer/src/plugins/track/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,11 @@ export default class TextTrack extends OptionsIcon {
}
}

show () {
/**
* @param {string} [value]
* @returns
*/
show (value) {
if (!this.config.list || this.config.list.length < 1){
return
}
Expand Down
3 changes: 3 additions & 0 deletions packages/xgplayer/src/plugins/waitingTimeoutJump/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ export default class WaitingTimeoutJump extends BasePlugin {
}
this.hasPlayed = false
this.jumpCnt = 0
/**
* @type {null | number}
*/
this.timer = null
this.jumpSize = jumpSize
this.on(Events.WAITING, this.onWaiting)
Expand Down
Loading

0 comments on commit 970c2a0

Please sign in to comment.