Refactor code structure for improved readability and maintainability

This commit is contained in:
Harvey Zhao committed 2026-01-01 19:50:00 +08:00
1 parent 4a0fbda3c4
commit 0bb4e1acdb
214 files changed
+462 -415

No files matched your search

+2 -2
View File
@@ -2,7 +2,7 @@
/*!
* artplayer.js v5.3.1-beta.1
* Github: https://github.com/zhw2590582/ArtPlayer
* (c) 2017-2025 Harvey Zack
* (c) 2017-2026 Harvey Zack
* Released under the MIT License.
*/
!function(e,t,r,a,o,i,n,s){var l="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:{},c="function"==typeof l[a]&&l[a],p=c.i||{},u=c.cache||{},d="undefined"!=typeof module&&"function"==typeof module.require&&module.require.bind(module);function f(t,r){if(!u[t]){if(!e[t]){if(o[t])return o[t];var i="function"==typeof l[a]&&l[a];if(!r&&i)return i(t,!0);if(c)return c(t,!0);if(d&&"string"==typeof t)return d(t);var n=Error("Cannot find module '"+t+"'");throw n.code="MODULE_NOT_FOUND",n}p.resolve=function(r){var a=e[t][1][r];return null!=a?a:r},p.cache={};var s=u[t]=new f.Module(t);e[t][0].call(s.exports,p,s,s.exports,l)}return u[t].exports;function p(e){var t=p.resolve(e);if(!1===t)return{};if(Array.isArray(t)){var r={__esModule:!0};return t.forEach(function(e){var t=e[0],a=e[1],o=e[2]||e[0],i=f(a);"*"===t?Object.keys(i).forEach(function(e){"default"===e||"__esModule"===e||Object.prototype.hasOwnProperty.call(r,e)||Object.defineProperty(r,e,{enumerable:!0,get:function(){return i[e]}})}):"*"===o?Object.defineProperty(r,t,{enumerable:!0,value:i}):Object.defineProperty(r,t,{enumerable:!0,get:function(){return"default"===o?i.__esModule?i.default:i:i[o]}})}),r}return f(t)}}f.isParcelRequire=!0,f.Module=function(e){this.id=e,this.bundle=f,this.require=d,this.exports={}},f.modules=e,f.cache=u,f.parent=c,f.distDir=void 0,f.publicUrl=void 0,f.devServer=void 0,f.i=p,f.register=function(t,r){e[t]=[function(e,t){t.exports=r},{}]},Object.defineProperty(f,"root",{get:function(){return l[a]}}),l[a]=f;for(var h=0;h<t.length;h++)f(t[h]);if(r){var m=f(r);"object"==typeof exports&&"undefined"!=typeof module?module.exports=m:"function"==typeof define&&define.amd&&define(function(){return m})}}({"9IAQF":[function(e,t,r,a){var o=e("@parcel/transformer-js/src/esmodule-helpers.js");o.defineInteropFlag(r);var i=e("bundle-text:./style/index.less"),n=o.interopDefault(i),s=e("option-validator"),l=o.interopDefault(s),c=e("../package.json"),p=e("./config"),u=o.interopDefault(p),d=e("./contextmenu"),f=o.interopDefault(d),h=e("./control"),m=o.interopDefault(h),g=e("./events"),v=o.interopDefault(g),y=e("./hotkey"),b=o.interopDefault(y),x=e("./i18n"),w=o.interopDefault(x),k=e("./icons"),j=o.interopDefault(k),S=e("./info"),$=o.interopDefault(S),E=e("./layer"),I=o.interopDefault(E),M=e("./loading"),T=o.interopDefault(M),C=e("./mask"),F=o.interopDefault(C),D=e("./notice"),A=o.interopDefault(D),R=e("./player"),O=o.interopDefault(R),L=e("./plugins"),P=o.interopDefault(L),Y=e("./scheme"),z=o.interopDefault(Y),_=e("./setting"),H=o.interopDefault(_),V=e("./storage"),N=o.interopDefault(V),q=e("./subtitle"),B=o.interopDefault(q),U=e("./template"),W=o.interopDefault(U),Z=e("./utils"),K=e("./utils/emitter"),G=o.interopDefault(K);let X=0,J=[];class Q extends G.default{constructor(e,t){if(super(),!Z.isBrowser)throw Error("Artplayer can only be used in the browser environment");this.id=++X;const r=Z.mergeDeep(Q.option,e);if(r.container=e.container,this.option=(0,l.default)(r,z.default),this.isLock=!1,this.isReady=!1,this.isFocus=!1,this.isInput=!1,this.isRotate=!1,this.isDestroy=!1,this.template=new(0,W.default)(this),this.events=new(0,v.default)(this),this.storage=new(0,N.default)(this),this.icons=new(0,j.default)(this),this.i18n=new(0,w.default)(this),this.notice=new(0,A.default)(this),this.player=new(0,O.default)(this),this.layers=new(0,I.default)(this),this.controls=new(0,m.default)(this),this.contextmenu=new(0,f.default)(this),this.subtitle=new(0,B.default)(this),this.info=new(0,$.default)(this),this.loading=new(0,T.default)(this),this.hotkey=new(0,b.default)(this),this.mask=new(0,F.default)(this),this.setting=new(0,H.default)(this),this.plugins=new(0,P.default)(this),"function"==typeof t&&this.on("ready",()=>t.call(this,this)),Q.DEBUG){const e=e=>console.log(`[ART.${this.id}] -> ${e}`);e(`Version@${Q.version}`);for(let t=0;t<u.default.events.length;t++)this.on(`video:${u.default.events[t]}`,t=>e(`Event@${t.type}`))}J.push(this)}static get instances(){return J}static get version(){return c.version}static get config(){return u.default}static get utils(){return Z}static get scheme(){return z.default}static get Emitter(){return G.default}static get validator(){return l.default}static get kindOf(){return l.default.kindOf}static get html(){return W.default.html}static get option(){return{id:"",container:"#artplayer",url:"",poster:"",type:"",theme:"#f00",volume:.7,isLive:!1,muted:!1,autoplay:!1,autoSize:!1,autoMini:!1,loop:!1,flip:!1,playbackRate:!1,aspectRatio:!1,screenshot:!1,setting:!1,hotkey:!0,pip:!1,mutex:!0,backdrop:!0,fullscreen:!1,fullscreenWeb:!1,subtitleOffset:!1,miniProgressBar:!1,useSSR:!1,playsInline:!0,lock:!1,gesture:!0,fastForward:!1,autoPlayback:!1,autoOrientation:!1,airplay:!1,proxy:void 0,layers:[],contextmenu:[],controls:[],settings:[],quality:[],highlight:[],plugins:[],thumbnails:{url:"",number:60,column:10,width:0,height:0,scale:1},subtitle:{url:"",tyLine truncated
!function(e,t,r,a,o,i,s,n){var l="u">typeof globalThis?globalThis:"u">typeof self?self:"u">typeof window?window:"u">typeof global?global:{},c="function"==typeof l[a]&&l[a],d=c.i||{},p=c.cache||{},u="u">typeof module&&"function"==typeof module.require&&module.require.bind(module);function f(t,r){if(!p[t]){if(!e[t]){if(o[t])return o[t];var i="function"==typeof l[a]&&l[a];if(!r&&i)return i(t,!0);if(c)return c(t,!0);if(u&&"string"==typeof t)return u(t);var s=Error("Cannot find module '"+t+"'");throw s.code="MODULE_NOT_FOUND",s}d.resolve=function(r){var a=e[t][1][r];return null!=a?a:r},d.cache={};var n=p[t]=new f.Module(t);e[t][0].call(n.exports,d,n,n.exports,l)}return p[t].exports;function d(e){var t=d.resolve(e);if(!1===t)return{};if(Array.isArray(t)){var r={__esModule:!0};return t.forEach(function(e){var t=e[0],a=e[1],o=e[2]||e[0],i=f(a);"*"===t?Object.keys(i).forEach(function(e){"default"===e||"__esModule"===e||Object.prototype.hasOwnProperty.call(r,e)||Object.defineProperty(r,e,{enumerable:!0,get:function(){return i[e]}})}):"*"===o?Object.defineProperty(r,t,{enumerable:!0,value:i}):Object.defineProperty(r,t,{enumerable:!0,get:function(){return"default"===o?i.__esModule?i.default:i:i[o]}})}),r}return f(t)}}f.isParcelRequire=!0,f.Module=function(e){this.id=e,this.bundle=f,this.require=u,this.exports={}},f.modules=e,f.cache=p,f.parent=c,f.distDir=void 0,f.publicUrl=void 0,f.devServer=void 0,f.i=d,f.register=function(t,r){e[t]=[function(e,t){t.exports=r},{}]},Object.defineProperty(f,"root",{get:function(){return l[a]}}),l[a]=f;for(var h=0;h<t.length;h++)f(t[h]);if(r){var m=f(r);"object"==typeof exports&&"u">typeof module?module.exports=m:"function"==typeof define&&define.amd&&define(function(){return m})}}({"9IAQF":[function(e,t,r,a){var o=e("@parcel/transformer-js/src/esmodule-helpers.js");o.defineInteropFlag(r);var i=e("bundle-text:./style/index.less"),s=o.interopDefault(i),n=e("option-validator"),l=o.interopDefault(n),c=e("../package.json"),d=e("./config"),p=o.interopDefault(d),u=e("./contextmenu"),f=o.interopDefault(u),h=e("./control"),m=o.interopDefault(h),g=e("./events"),v=o.interopDefault(g),y=e("./hotkey"),b=o.interopDefault(y),x=e("./i18n"),w=o.interopDefault(x),k=e("./icons"),j=o.interopDefault(k),$=e("./info"),S=o.interopDefault($),E=e("./layer"),I=o.interopDefault(E),M=e("./loading"),T=o.interopDefault(M),C=e("./mask"),F=o.interopDefault(C),D=e("./notice"),A=o.interopDefault(D),R=e("./player"),O=o.interopDefault(R),L=e("./plugins"),P=o.interopDefault(L),z=e("./scheme"),Y=o.interopDefault(z),_=e("./setting"),H=o.interopDefault(_),V=e("./storage"),N=o.interopDefault(V),q=e("./subtitle"),B=o.interopDefault(q),U=e("./template"),W=o.interopDefault(U),Z=e("./utils"),K=e("./utils/emitter"),G=o.interopDefault(K);let X=0,J=[];class Q extends G.default{constructor(e,t){if(super(),!Z.isBrowser)throw Error("Artplayer can only be used in the browser environment");this.id=++X;const r=Z.mergeDeep(Q.option,e);if(r.container=e.container,this.option=(0,l.default)(r,Y.default),this.isLock=!1,this.isReady=!1,this.isFocus=!1,this.isInput=!1,this.isRotate=!1,this.isDestroy=!1,this.template=new(0,W.default)(this),this.events=new(0,v.default)(this),this.storage=new(0,N.default)(this),this.icons=new(0,j.default)(this),this.i18n=new(0,w.default)(this),this.notice=new(0,A.default)(this),this.player=new(0,O.default)(this),this.layers=new(0,I.default)(this),this.controls=new(0,m.default)(this),this.contextmenu=new(0,f.default)(this),this.subtitle=new(0,B.default)(this),this.info=new(0,S.default)(this),this.loading=new(0,T.default)(this),this.hotkey=new(0,b.default)(this),this.mask=new(0,F.default)(this),this.setting=new(0,H.default)(this),this.plugins=new(0,P.default)(this),"function"==typeof t&&this.on("ready",()=>t.call(this,this)),Q.DEBUG){const e=e=>console.log(`[ART.${this.id}] -> ${e}`);e(`Version@${Q.version}`);for(let t=0;t<p.default.events.length;t++)this.on(`video:${p.default.events[t]}`,t=>e(`Event@${t.type}`))}J.push(this)}static get instances(){return J}static get version(){return c.version}static get config(){return p.default}static get utils(){return Z}static get scheme(){return Y.default}static get Emitter(){return G.default}static get validator(){return l.default}static get kindOf(){return l.default.kindOf}static get html(){return W.default.html}static get option(){return{id:"",container:"#artplayer",url:"",poster:"",type:"",theme:"#f00",volume:.7,isLive:!1,muted:!1,autoplay:!1,autoSize:!1,autoMini:!1,loop:!1,flip:!1,playbackRate:!1,aspectRatio:!1,screenshot:!1,setting:!1,hotkey:!0,pip:!1,mutex:!0,backdrop:!0,fullscreen:!1,fullscreenWeb:!1,subtitleOffset:!1,miniProgressBar:!1,useSSR:!1,playsInline:!0,lock:!1,gesture:!0,fastForward:!1,autoPlayback:!1,autoOrientation:!1,airplay:!1,proxy:void 0,layers:[],contextmenu:[],controls:[],settings:[],quality:[],highlight:[],plugins:[],thumbnails:{url:"",number:60,column:10,width:0,height:0,scale:1},subtitle:{url:"",type:"",style:{},name:"",escape:!0,encoding:"utf-8",onVtLine truncated