Refactor code structure for improved readability and maintainability

This commit is contained in:
Harvey Zack committed 2025-07-05 16:04:21 +08:00
1 parent 6d640062c9
commit 84bc5a85bc
8 files changed
+8 -8

No files matched your search

@@ -5,4 +5,4 @@
* (c) 2017-2025 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);return!1===t?{}: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("./setting"),l=a.interopDefault(s),u=e("./heatmap"),c=a.interopDefault(u);function d(e){return function(t){var n=new(0,o.default)(t,e),r=new(0,l.default)(t,n);return n.option.heatmap&&(0,c.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=l.default.icons,"undefined"!=typeof window&&(window.artplayerPluginDanmuku=d)},{"./danmuku":"u1ZRC","./setting":"jpEpW","./heatmap":"hLPK6","@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("./bilibili"),p=e("bundle-text:./worker"),f=a.interopDefault(p),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);var i=new Blob([f.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*(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*(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*(parseFloat(r)/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.className="",t}},{key:"readys",get:function(){var e=this.art.currentTime,t=[];return this.filter("ready",function(e){return t.push(e)}),this.filter("wait",function(n){e+.1>=n.time&&n.time>=e-.1&&t.push(n)}),t}},{key:"visibles",get:function(){var e=this,t=[],n=this.$player.clientWidth,r=this.getLeft(this.$player);return this.filter("emit",function(a){var i=a.$ref.offsetTop,o=e.getLeft(a.$ref)-r,s=a.$ref.clientHeight,l=a.$ref.clientWidth,u=o+l,c=u/a.$restTime,dLine truncated
!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);return!1===t?{}: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})}}({bzF6W:[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("./setting"),l=a.interopDefault(s),u=e("./heatmap"),c=a.interopDefault(u);function d(e){return function(t){var n=new(0,o.default)(t,e),r=new(0,l.default)(t,n);return n.option.heatmap&&(0,c.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=l.default.icons,"undefined"!=typeof window&&(window.artplayerPluginDanmuku=d)},{"./danmuku":"atzAj","./setting":"1ROJF","./heatmap":"4srjK","@parcel/transformer-js/src/esmodule-helpers.js":"ihnSZ"}],atzAj:[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("./bilibili"),p=e("bundle-text:./worker"),f=a.interopDefault(p),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([f.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*(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*(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*(parseFloat(r)/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.className="",t}},{key:"readys",get:function(){var e=this.art.currentTime,t=[];return this.filter("ready",function(e){return t.push(e)}),this.filter("wait",function(n){e+.1>=n.time&&n.time>=e-.1&&t.push(n)}),t}},{key:"visibles",get:function(){var e=this,t=[],n=this.$player.clientWidth,r=this.getLeft(this.$player);return this.filter("emit",function(a){var i=a.$ref.offsetTop,o=e.getLeft(a.$ref)-r,s=a.$ref.clientHeight,l=a.$ref.clientWidth,u=o+l,c=u/a.$restTimLine truncated