mirror of
https://github.com/zhw2590582/ArtPlayer.git
synced 2026-10-27 01:21:20 -08:00
Refactor code structure for improved readability and maintainability
This commit is contained in:
1 parent
4a0fbda3c4
commit
0bb4e1acdb
214 files changed
+462
-415
No files matched your search
@@ -2,7 +2,7 @@
|
||||
/*!
|
||||
* artplayer-plugin-danmuku.js v5.2.0
|
||||
* Github: https://github.com/zhw2590582/ArtPlayer
|
||||
* (c) 2017-2025 Harvey Zack
|
||||
* (c) 2017-2026 Harvey Zack
|
||||
* Released under the MIT License.
|
||||
*/
|
||||
!function(e,t,n,r,a,i,o,s){var l="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:{},u="function"==typeof l[r]&&l[r],c=u.i||{},d=u.cache||{},p="undefined"!=typeof module&&"function"==typeof module.require&&module.require.bind(module);function f(t,n){if(!d[t]){if(!e[t]){if(a[t])return a[t];var i="function"==typeof l[r]&&l[r];if(!n&&i)return i(t,!0);if(u)return u(t,!0);if(p&&"string"==typeof t)return p(t);var o=Error("Cannot find module '"+t+"'");throw o.code="MODULE_NOT_FOUND",o}c.resolve=function(n){var r=e[t][1][n];return null!=r?r:n},c.cache={};var s=d[t]=new f.Module(t);e[t][0].call(s.exports,c,s,s.exports,l)}return d[t].exports;function c(e){var t=c.resolve(e);if(!1===t)return{};if(Array.isArray(t)){var n={__esModule:!0};return t.forEach(function(e){var t=e[0],r=e[1],a=e[2]||e[0],i=f(r);"*"===t?Object.keys(i).forEach(function(e){"default"===e||"__esModule"===e||Object.prototype.hasOwnProperty.call(n,e)||Object.defineProperty(n,e,{enumerable:!0,get:function(){return i[e]}})}):"*"===a?Object.defineProperty(n,t,{enumerable:!0,value:i}):Object.defineProperty(n,t,{enumerable:!0,get:function(){return"default"===a?i.__esModule?i.default:i:i[a]}})}),n}return f(t)}}f.isParcelRequire=!0,f.Module=function(e){this.id=e,this.bundle=f,this.require=p,this.exports={}},f.modules=e,f.cache=d,f.parent=u,f.distDir=void 0,f.publicUrl=void 0,f.devServer=void 0,f.i=c,f.register=function(t,n){e[t]=[function(e,t){t.exports=n},{}]},Object.defineProperty(f,"root",{get:function(){return l[r]}}),l[r]=f;for(var h=0;h<t.length;h++)f(t[h]);if(n){var m=f(n);"object"==typeof exports&&"undefined"!=typeof module?module.exports=m:"function"==typeof define&&define.amd&&define(function(){return m})}}({l3CkF:[function(e,t,n,r){var a=e("@parcel/transformer-js/src/esmodule-helpers.js");a.defineInteropFlag(n),a.export(n,"default",function(){return d});var i=e("./danmuku"),o=a.interopDefault(i),s=e("./heatmap"),l=a.interopDefault(s),u=e("./setting"),c=a.interopDefault(u);function d(e){return function(t){var n=new(0,o.default)(t,e),r=new(0,c.default)(t,n);return n.option.heatmap&&(0,l.default)(t,n,n.option.heatmap),{name:"artplayerPluginDanmuku",emit:n.emit.bind(n),load:n.load.bind(n),config:n.config.bind(n),hide:n.hide.bind(n),show:n.show.bind(n),reset:n.reset.bind(n),mount:r.mount.bind(r),get option(){return n.option},get isHide(){return n.isHide},get isStop(){return n.isStop}}}}d.icons=c.default.icons,"undefined"!=typeof window&&(window.artplayerPluginDanmuku=d)},{"./danmuku":"u1ZRC","./heatmap":"hLPK6","./setting":"jpEpW","@parcel/transformer-js/src/esmodule-helpers.js":"qpMMf"}],u1ZRC:[function(e,t,n,r){var a=e("@parcel/transformer-js/src/esmodule-helpers.js");a.defineInteropFlag(n),a.export(n,"default",function(){return h});var i=e("@swc/helpers/cjs/_async_to_generator.cjs"),o=e("@swc/helpers/cjs/_class_call_check.cjs"),s=e("@swc/helpers/cjs/_create_class.cjs"),l=e("@swc/helpers/cjs/_object_spread.cjs"),u=e("@swc/helpers/cjs/_object_spread_props.cjs"),c=e("@swc/helpers/cjs/_ts_generator.cjs"),d=e("bundle-text:./worker"),p=a.interopDefault(d),f=e("./bilibili"),h=function(){"use strict";function e(t,n){(0,o._)(this,e);var r=t.constructor,a=t.template;this.utils=r.utils,this.validator=r.validator,this.$danmuku=a.$danmuku,this.$player=a.$player,this.art=t,this.queue=[],this.$refs=[],this.isStop=!1,this.isHide=!1,this.timer=null,this.index=0,this.option=e.option,this.states={wait:[],ready:[],emit:[],stop:[]},this.config(n,!0);var i=new Blob([p.default.replace("export{e as default};","")],{type:"application/javascript"});this.worker=new Worker(URL.createObjectURL(i)),this.start=this.start.bind(this),this.stop=this.stop.bind(this),this.reset=this.reset.bind(this),this.resize=this.resize.bind(this),this.destroy=this.destroy.bind(this),t.on("video:play",this.start),t.on("video:playing",this.start),t.on("video:pause",this.stop),t.on("video:waiting",this.stop),t.on("destroy",this.destroy),t.on("resize",this.resize),this.load()}return(0,s._)(e,[{key:"isRotate",get:function(){var e,t;return null==(t=this.art.plugins)||null==(e=t.autoOrientation)?void 0:e.state}},{key:"marginTop",get:function(){var t=this.utils.clamp,n=this.option.margin[0],r=this.$player.clientHeight;return"number"==typeof n?t(n,0,r):"string"==typeof n&&n.endsWith("%")?t(r*(Number.parseFloat(n)/100),0,r):e.option.margin[0]}},{key:"marginBottom",get:function(){var t=this.utils.clamp,n=this.option.margin[1],r=this.$player.clientHeight;return"number"==typeof n?t(n,0,r):"string"==typeof n&&n.endsWith("%")?t(r*(Number.parseFloat(n)/100),0,r):e.option.margin[1]}},{key:"fontSize",get:function(){var t=this.utils.clamp,n=this.$player.clientHeight,r=this.option.fontSize;return"number"==typeof r?Math.round(t(r,12,n)):"string"==typeof r&&r.endsWith("%")?Math.round(t(n*(Number.parseFloat(r)/100),12,n)):e.option.fontSize}},{key:"$ref",get:function(){var t=this.$refs.pop()||document.createElement("div");return tLine truncated
|
||||
!function(e,t,n,a,i,r,o,s){var l="u">typeof globalThis?globalThis:"u">typeof self?self:"u">typeof window?window:"u">typeof global?global:{},u="function"==typeof l[a]&&l[a],d=u.i||{},c=u.cache||{},p="u">typeof module&&"function"==typeof module.require&&module.require.bind(module);function f(t,n){if(!c[t]){if(!e[t]){if(i[t])return i[t];var r="function"==typeof l[a]&&l[a];if(!n&&r)return r(t,!0);if(u)return u(t,!0);if(p&&"string"==typeof t)return p(t);var o=Error("Cannot find module '"+t+"'");throw o.code="MODULE_NOT_FOUND",o}d.resolve=function(n){var a=e[t][1][n];return null!=a?a:n},d.cache={};var s=c[t]=new f.Module(t);e[t][0].call(s.exports,d,s,s.exports,l)}return c[t].exports;function d(e){var t=d.resolve(e);if(!1===t)return{};if(Array.isArray(t)){var n={__esModule:!0};return t.forEach(function(e){var t=e[0],a=e[1],i=e[2]||e[0],r=f(a);"*"===t?Object.keys(r).forEach(function(e){"default"===e||"__esModule"===e||Object.prototype.hasOwnProperty.call(n,e)||Object.defineProperty(n,e,{enumerable:!0,get:function(){return r[e]}})}):"*"===i?Object.defineProperty(n,t,{enumerable:!0,value:r}):Object.defineProperty(n,t,{enumerable:!0,get:function(){return"default"===i?r.__esModule?r.default:r:r[i]}})}),n}return f(t)}}f.isParcelRequire=!0,f.Module=function(e){this.id=e,this.bundle=f,this.require=p,this.exports={}},f.modules=e,f.cache=c,f.parent=u,f.distDir=void 0,f.publicUrl=void 0,f.devServer=void 0,f.i=d,f.register=function(t,n){e[t]=[function(e,t){t.exports=n},{}]},Object.defineProperty(f,"root",{get:function(){return l[a]}}),l[a]=f;for(var h=0;h<t.length;h++)f(t[h]);if(n){var m=f(n);"object"==typeof exports&&"u">typeof module?module.exports=m:"function"==typeof define&&define.amd&&define(function(){return m})}}({l3CkF:[function(e,t,n,a){var i=e("@parcel/transformer-js/src/esmodule-helpers.js");i.defineInteropFlag(n),i.export(n,"default",function(){return c});var r=e("./danmuku"),o=i.interopDefault(r),s=e("./heatmap"),l=i.interopDefault(s),u=e("./setting"),d=i.interopDefault(u);function c(e){return function(t){var n=new(0,o.default)(t,e),a=new(0,d.default)(t,n);return n.option.heatmap&&(0,l.default)(t,n,n.option.heatmap),{name:"artplayerPluginDanmuku",emit:n.emit.bind(n),load:n.load.bind(n),config:n.config.bind(n),hide:n.hide.bind(n),show:n.show.bind(n),reset:n.reset.bind(n),mount:a.mount.bind(a),get option(){return n.option},get isHide(){return n.isHide},get isStop(){return n.isStop}}}}c.icons=d.default.icons,"u">typeof window&&(window.artplayerPluginDanmuku=c)},{"./danmuku":"u1ZRC","./heatmap":"hLPK6","./setting":"jpEpW","@parcel/transformer-js/src/esmodule-helpers.js":"qpMMf"}],u1ZRC:[function(e,t,n,a){var i=e("@parcel/transformer-js/src/esmodule-helpers.js");i.defineInteropFlag(n),i.export(n,"default",function(){return h});var r=e("@swc/helpers/cjs/_async_to_generator.cjs"),o=e("@swc/helpers/cjs/_class_call_check.cjs"),s=e("@swc/helpers/cjs/_create_class.cjs"),l=e("@swc/helpers/cjs/_object_spread.cjs"),u=e("@swc/helpers/cjs/_object_spread_props.cjs"),d=e("@swc/helpers/cjs/_ts_generator.cjs"),c=e("bundle-text:./worker"),p=i.interopDefault(c),f=e("./bilibili"),h=function(){"use strict";function e(t,n){(0,o._)(this,e);var a=t.constructor,i=t.template;this.utils=a.utils,this.validator=a.validator,this.$danmuku=i.$danmuku,this.$player=i.$player,this.art=t,this.queue=[],this.$refs=[],this.isStop=!1,this.isHide=!1,this.timer=null,this.index=0,this.option=e.option,this.states={wait:[],ready:[],emit:[],stop:[]},this.config(n,!0);var r=new Blob([p.default.replace("export{e as default};","")],{type:"application/javascript"});this.worker=new Worker(URL.createObjectURL(r)),this.start=this.start.bind(this),this.stop=this.stop.bind(this),this.reset=this.reset.bind(this),this.resize=this.resize.bind(this),this.destroy=this.destroy.bind(this),t.on("video:play",this.start),t.on("video:playing",this.start),t.on("video:pause",this.stop),t.on("video:waiting",this.stop),t.on("destroy",this.destroy),t.on("resize",this.resize),this.load()}return(0,s._)(e,[{key:"isRotate",get:function(){var e,t;return null==(t=this.art.plugins)||null==(e=t.autoOrientation)?void 0:e.state}},{key:"marginTop",get:function(){var t=this.utils.clamp,n=this.option.margin[0],a=this.$player.clientHeight;return"number"==typeof n?t(n,0,a):"string"==typeof n&&n.endsWith("%")?t(a*(Number.parseFloat(n)/100),0,a):e.option.margin[0]}},{key:"marginBottom",get:function(){var t=this.utils.clamp,n=this.option.margin[1],a=this.$player.clientHeight;return"number"==typeof n?t(n,0,a):"string"==typeof n&&n.endsWith("%")?t(a*(Number.parseFloat(n)/100),0,a):e.option.margin[1]}},{key:"fontSize",get:function(){var t=this.utils.clamp,n=this.$player.clientHeight,a=this.option.fontSize;return"number"==typeof a?Math.round(t(a,12,n)):"string"==typeof a&&a.endsWith("%")?Math.round(t(n*(Number.parseFloat(a)/100),12,n)):e.option.fontSize}},{key:"$ref",get:function(){var t=this.$refs.pop()||document.createElement("div");return t.style.cssText=e.cssText,t.dataset.mode="",t.dataset.id="",t.clLine truncated
|
||||
Reference in new issue
Block a user