mirror of
https://github.com/zhw2590582/ArtPlayer.git
synced 2026-10-25 16:11:20 -08:00
remove sourceMap
This commit is contained in:
1 parent
c3343ad74f
commit
ab06749c15
105 files changed
+1665
-12149
No files matched your search
@@ -5,138 +5,4 @@
|
||||
* (c) 2017-2025 Harvey Zack
|
||||
* Released under the MIT License.
|
||||
*/
|
||||
|
||||
!function(t,e,i,a,n,o,s,l){var r="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:{},d="function"==typeof r[a]&&r[a],p=d.i||{},u=d.cache||{},h="undefined"!=typeof module&&"function"==typeof module.require&&module.require.bind(module);function m(e,i){if(!u[e]){if(!t[e]){if(n[e])return n[e];var o="function"==typeof r[a]&&r[a];if(!i&&o)return o(e,!0);if(d)return d(e,!0);if(h&&"string"==typeof e)return h(e);var s=Error("Cannot find module '"+e+"'");throw s.code="MODULE_NOT_FOUND",s}p.resolve=function(i){var a=t[e][1][i];return null!=a?a:i},p.cache={};var l=u[e]=new m.Module(e);t[e][0].call(l.exports,p,l,l.exports,r)}return u[e].exports;function p(t){var e=p.resolve(t);return!1===e?{}:m(e)}}m.isParcelRequire=!0,m.Module=function(t){this.id=t,this.bundle=m,this.require=h,this.exports={}},m.modules=t,m.cache=u,m.parent=d,m.distDir=void 0,m.publicUrl=void 0,m.devServer=void 0,m.i=p,m.register=function(e,i){t[e]=[function(t,e){e.exports=i},{}]},Object.defineProperty(m,"root",{get:function(){return r[a]}}),r[a]=m;for(var c=0;c<e.length;c++)m(e[c]);if(i){var f=m(i);"object"==typeof exports&&"undefined"!=typeof module?module.exports=f:"function"==typeof define&&define.amd&&define(function(){return f})}}({"6ZbtA":[function(t,e,i,a){var n=t("@parcel/transformer-js/src/esmodule-helpers.js");n.defineInteropFlag(i),n.export(i,"default",()=>u);var o=t("./danmuku"),s=n.interopDefault(o),l=t("./setting"),r=n.interopDefault(l),d=t("./heatmap"),p=n.interopDefault(d);function u(t){return e=>{let i=new(0,s.default)(e,t),a=new(0,r.default)(e,i);return i.option.heatmap&&(0,p.default)(e,i,i.option.heatmap),{name:"artplayerPluginDanmuku",emit:i.emit.bind(i),load:i.load.bind(i),config:i.config.bind(i),hide:i.hide.bind(i),show:i.show.bind(i),reset:i.reset.bind(i),mount:a.mount.bind(a),get option(){return i.option},get isHide(){return i.isHide},get isStop(){return i.isStop}}}}u.icons=r.default.icons,"undefined"!=typeof window&&(window.artplayerPluginDanmuku=u)},{"./danmuku":"6C7g0","./setting":"90QKZ","./heatmap":"h2ayY","@parcel/transformer-js/src/esmodule-helpers.js":"5lQoW"}],"6C7g0":[function(t,e,i,a){var n=t("@parcel/transformer-js/src/esmodule-helpers.js");n.defineInteropFlag(i);var o=t("./bilibili"),s=t("bundle-text:./worker"),l=n.interopDefault(s);class r{constructor(t,e){let{constructor:i,template:a}=t;this.utils=i.utils,this.validator=i.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=r.option,this.states={wait:[],ready:[],emit:[],stop:[]},this.config(e);let n=new Blob([l.default],{type:"application/javascript"});this.worker=new Worker(URL.createObjectURL(n)),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()}static get option(){return{danmuku:[],speed:5,margin:[10,"25%"],opacity:1,color:"#FFFFFF",mode:0,modes:[0,1,2],fontSize:25,antiOverlap:!0,synchronousPlayback:!1,mount:void 0,heatmap:!1,width:512,points:[],filter:()=>!0,beforeEmit:()=>!0,beforeVisible:()=>!0,visible:!0,emitter:!0,maxLength:200,lockTime:5,theme:"dark",OPACITY:{},FONT_SIZE:{},MARGIN:{},SPEED:{},COLOR:[]}}static get scheme(){return{danmuku:"array|function|string",speed:"number",margin:"array",opacity:"number",color:"string",mode:"number",modes:"array",fontSize:"number|string",antiOverlap:"boolean",synchronousPlayback:"boolean",mount:"?htmldivelement|string",heatmap:"object|boolean",width:"number",points:"array",filter:"function",beforeEmit:"function",beforeVisible:"function",visible:"boolean",emitter:"boolean",maxLength:"number",lockTime:"number",theme:"string",OPACITY:"object",FONT_SIZE:"object",MARGIN:"object",SPEED:"object",COLOR:"array"}}static get cssText(){return`
|
||||
user-select: none;
|
||||
position: absolute;
|
||||
white-space: pre;
|
||||
pointer-events: none;
|
||||
perspective: 500px;
|
||||
display: inline-block;
|
||||
will-change: transform;
|
||||
font-weight: normal;
|
||||
line-height: 1.125;
|
||||
visibility: hidden;
|
||||
font-family: SimHei, "Microsoft JhengHei", Arial, Helvetica, sans-serif;
|
||||
text-shadow: rgb(0, 0, 0) 1px 0px 1px, rgb(0, 0, 0) 0px 1px 1px, rgb(0, 0, 0) 0px -1px 1px, rgb(0, 0, 0) -1px 0px 1px;
|
||||
`}get isRotate(){return this.art.plugins?.autoOrientation?.state}get marginTop(){let{clamp:t}=this.utils,e=this.option.margin[0],{clientHeight:i}=this.$player;return"number"==typeof e?t(e,0,i):"string"==typeof e&&e.endsWith("%")?t(i*(parseFloat(e)/100),0,i):r.option.margin[0]}get marginBottom(){let{clamp:t}=this.utils,e=this.option.margin[1],{clientHeight:i}=this.$player;return"number"==typeof e?t(e,0,i):"string"==typeof e&&e.endsWith("%")?t(i*(parseFloat(e)/100),0,i):r.option.margin[1]}get fontSize(){let{clamp:t}=this.utils,{clientHeight:e}=this.$player,i=this.option.fontSize;return"number"==typeof i?Math.round(t(i,12,e)):"string"==typeof i&&i.endsWith("%")?Math.round(t(e*(parseFloat(i)/100),12,e)):r.option.fontSize}get $ref(){let t=this.$refs.pop()||document.createElement("div");return t.style.cssText=r.cssText,t.dataset.mode="",t.className="",t}get readys(){let{currentTime:t}=this.art,e=[];return this.filter("ready",t=>e.push(t)),this.filter("wait",i=>{t+.1>=i.time&&i.time>=t-.1&&e.push(i)}),e}get visibles(){let t=[],{clientWidth:e}=this.$player,i=this.getLeft(this.$player);return this.filter("emit",a=>{let n=a.$ref.offsetTop,o=this.getLeft(a.$ref)-i,s=a.$ref.clientHeight,l=a.$ref.clientWidth,r=o+l,d=r/a.$restTime,p={};p.top=n,p.left=o,p.height=s,p.width=l,p.right=e-r,p.speed=d,p.distance=r,p.time=a.$restTime,p.mode=a.mode,t.push(p)}),t}get speed(){return this.option.synchronousPlayback&&this.art.playbackRate?this.option.speed/Number(this.art.playbackRate):this.option.speed}async load(t){let{errorHandle:e}=this.utils,i=[],a=t||this.option.danmuku;try{"function"==typeof a?i=await a():a instanceof Promise?i=await a:"string"==typeof a?i=await (0,o.bilibiliDanmuParseFromUrl)(a):Array.isArray(a)&&(i=a),e(Array.isArray(i),"Danmuku need return an array as result"),void 0===t&&(this.reset(),this.queue=[],this.states={wait:[],ready:[],emit:[],stop:[]},this.$refs=[],this.$danmuku.innerText="");for(let t=0;t<i.length;t++){let e=i[t];await this.emit(e)}this.art.emit("artplayerPluginDanmuku:loaded",this.queue)}catch(t){throw this.art.emit("artplayerPluginDanmuku:error",t),t}return this}async emit(t){let{clamp:e}=this.utils;if(this.validator(t,{text:"string",mode:"?number",color:"?string",time:"?number",border:"?boolean",style:"?object"}),!t.text.trim()||(t.time?t.time=e(t.time,0,1/0):t.time=this.art.currentTime+.5,void 0===t.mode&&(t.mode=this.option.mode),void 0===t.style&&(t.style={}),void 0===t.color&&(t.color=this.option.color),![0,1,2].includes(t.mode)||!this.option.filter(t)))return this;let i={...t,$state:"wait",$id:this.index++,$ref:null,$restTime:0,$lastStartTime:0};return this.setState(i,"wait"),this.queue.push(i),this}config(t){let{clamp:e}=this.utils,{$controlsCenter:i}=this.art.template;return Object.keys(t).some(e=>JSON.stringify(this.option[e])!==JSON.stringify(t[e]))&&(this.option=Object.assign({},r.option,this.option,t),this.validator(this.option,r.scheme),this.option.mode=e(this.option.mode,0,2),this.option.speed=e(this.option.speed,1,10),this.option.opacity=e(this.option.opacity,0,1),this.option.lockTime=e(this.option.lockTime,1,60),this.option.maxLength=e(this.option.maxLength,1,1e3),this.option.mount=this.option.mount||i,t.fontSize&&this.reset(),this.option.visible?this.show():this.hide(),this.art.emit("artplayerPluginDanmuku:config",this.option)),this}getLeft(t){let e=t.getBoundingClientRect();return this.isRotate?e.top:e.left}postMessage(t={}){return new Promise(e=>{t.id=Date.now(),this.worker.postMessage(t),this.worker.onmessage=i=>{let{data:a}=i;a.id===t.id&&e(a)}})}filter(t,e){let i=this.states[t]||[];for(let t=0;t<i.length;t++)e(i[t]);return i}setState(t,e){this.states[t.$state]=this.states[t.$state].filter(e=>e!==t),t.$state=e,t.$ref&&(t.$ref.dataset.state=e),this.states[e].push(t)}makeWait(t){this.setState(t,"wait"),t.$ref&&(t.$ref.style.cssText=r.cssText,t.$ref.style.visibility="hidden",t.$ref.style.marginLeft="0px",t.$ref.style.transform="translateX(0px)",t.$ref.style.transition="transform 0s linear 0s",this.$refs.push(t.$ref),t.$ref=null)}update(){let{setStyles:t}=this.utils;return this.timer=window.requestAnimationFrame(async()=>{if(this.art.playing&&!this.isHide){this.filter("emit",t=>{let e=(Date.now()-t.$lastStartTime)/1e3;t.$restTime-=e,t.$lastStartTime=Date.now(),t.$restTime<=0&&this.makeWait(t)});let e=this.readys;for(let i=0;i<e.length;i++){let a=e[i];if(await this.option.beforeVisible(a)){let{clientWidth:e,clientHeight:i}=this.$player;a.$ref=this.$ref,a.$ref.innerText=a.text,this.$danmuku.appendChild(a.$ref),a.$ref.style.opacity=this.option.opacity,a.$ref.style.fontSize=`${this.fontSize}px`,a.$ref.style.color=a.color,a.$ref.style.border=a.border?`1px solid ${a.color}`:null,a.$ref.style.backgroundColor=a.border?"rgb(0 0 0 / 50%)":null,t(a.$ref,a.style),a.$lastStartTime=Date.now(),a.$restTime=this.speed;let n=e+a.$ref.clientWidth,{result:o}=await this.postMessage({type:"getDanmuTop",target:{mode:a.mode,height:a.$ref.clientHeight,speed:n/a.$restTime},visibles:this.visibl
Line truncated
|
||||
${o.toString()}
|
||||
${s.toString()}
|
||||
onmessage = ${l.toString()}
|
||||
`],{type:"application/javascript"});return new Worker(URL.createObjectURL(t))}();t.onmessage=i=>{let{danmus:a,id:n}=i.data;n&&a&&(e(a),t.terminate())},t.postMessage({xml:a,id:Date.now()})}catch(t){e(s(a))}})}n.defineInteropFlag(i),n.export(i,"bilibiliDanmuParseFromUrl",()=>r)},{"@parcel/transformer-js/src/esmodule-helpers.js":"5lQoW"}],"5lQoW":[function(t,e,i,a){i.interopDefault=function(t){return t&&t.__esModule?t:{default:t}},i.defineInteropFlag=function(t){Object.defineProperty(t,"__esModule",{value:!0})},i.exportAll=function(t,e){return Object.keys(t).forEach(function(i){"default"===i||"__esModule"===i||Object.prototype.hasOwnProperty.call(e,i)||Object.defineProperty(e,i,{enumerable:!0,get:function(){return t[i]}})}),e},i.export=function(t,e,i){Object.defineProperty(t,e,{enumerable:!0,get:i})}},{}],"8UAYg":[function(t,e,i,a){e.exports='!function(e,t,i,r,o,n,l,d){var f="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:{},u="function"==typeof f[r]&&f[r],p=u.i||{},s=u.cache||{},h="undefined"!=typeof module&&"function"==typeof module.require&&module.require.bind(module);function a(t,i){if(!s[t]){if(!e[t]){if(o[t])return o[t];var n="function"==typeof f[r]&&f[r];if(!i&&n)return n(t,!0);if(u)return u(t,!0);if(h&&"string"==typeof t)return h(t);var l=Error("Cannot find module \'"+t+"\'");throw l.code="MODULE_NOT_FOUND",l}p.resolve=function(i){var r=e[t][1][i];return null!=r?r:i},p.cache={};var d=s[t]=new a.Module(t);e[t][0].call(d.exports,p,d,d.exports,f)}return s[t].exports;function p(e){var t=p.resolve(e);return!1===t?{}:a(t)}}a.isParcelRequire=!0,a.Module=function(e){this.id=e,this.bundle=a,this.require=h,this.exports={}},a.modules=e,a.cache=s,a.parent=u,a.distDir=void 0,a.publicUrl=void 0,a.devServer=void 0,a.i=p,a.register=function(t,i){e[t]=[function(e,t){t.exports=i},{}]},Object.defineProperty(a,"root",{get:function(){return f[r]}}),f[r]=a;for(var c=0;c<t.length;c++)a(t[c]);if(i){var g=a(i);"object"==typeof exports&&"undefined"!=typeof module?module.exports=g:"function"==typeof define&&define.amd&&define(function(){return g})}}({"4KwZ6":[function(e,t,i,r){function o({target:e,visibles:t,clientWidth:i,clientHeight:r,marginBottom:o,marginTop:n,antiOverlap:l}){let d=r-o,f=t.filter(t=>t.mode===e.mode&&t.top<=d).sort((e,t)=>e.top-t.top);if(0===f.length)if(2===e.mode)return d-e.height;else return n;if(f.unshift({type:"top",top:0,left:0,right:0,height:n,width:i,speed:0,distance:i}),f.push({type:"bottom",top:d,left:0,right:0,height:o,width:i,speed:0,distance:i}),2===e.mode)for(let t=f.length-2;t>=0;t-=1){let i=f[t],r=f[t+1],o=i.top+i.height;if(r.top-o>=e.height)return r.top-e.height}else for(let t=1;t<f.length;t+=1){let i=f[t],r=f[t-1],o=r.top+r.height;if(i.top-o>=e.height)return o}let u=[];for(let e=1;e<f.length-1;e+=1){let t=f[e];if(u.length){let e=u[u.length-1];e[0].top===t.top?e.push(t):u.push([t])}else u.push([t])}if(l)switch(e.mode){case 0:{let t=u.find(t=>t.every(t=>!(i<t.distance)&&(!!(e.speed<t.speed)||!!(t.right/(e.speed-t.speed)>t.time))));return t&&t[0]?t[0].top:void 0}case 1:case 2:return}else{switch(e.mode){case 0:u.sort((e,t)=>{let i=Math.min(...t.map(e=>e.right)),r=Math.min(...e.map(e=>e.right));return i*t.length-r*e.length});break;case 1:case 2:u.sort((e,t)=>{let i=Math.max(...t.map(e=>e.width));return Math.max(...e.map(e=>e.width))*e.length-i*t.length})}return u[0][0].top}}onmessage=e=>{let{data:t}=e;if(!t.id||!t.type)return;let i=(0,({getDanmuTop:o})[t.type])(t);self.postMessage({result:i,id:t.id})}},{}]},["4KwZ6"],"4KwZ6","parcelRequire4dc0",{});let{"*":e}=parcelRequire4dc0("4KwZ6");export{e as default};'},{}],"90QKZ":[function(t,e,i,a){var n=t("@parcel/transformer-js/src/esmodule-helpers.js");n.defineInteropFlag(i);var o=t("bundle-text:./style.less"),s=n.interopDefault(o),l=t("bundle-text:./img/on.svg"),r=n.interopDefault(l),d=t("bundle-text:./img/off.svg"),p=n.interopDefault(d),u=t("bundle-text:./img/config.svg"),h=n.interopDefault(u),m=t("bundle-text:./img/style.svg"),c=n.interopDefault(m),f=t("bundle-text:./img/mode_0_off.svg"),g=n.interopDefault(f),y=t("bundle-text:./img/mode_0_on.svg"),v=n.interopDefault(y),x=t("bundle-text:./img/mode_1_off.svg"),k=n.interopDefault(x),b=t("bundle-text:./img/mode_1_on.svg"),$=n.interopDefault(b),w=t("bundle-text:./img/mode_2_off.svg"),M=n.interopDefault(w),E=t("bundle-text:./img/mode_2_on.svg"),S=n.interopDefault(E),D=t("bundle-text:./img/check_on.svg"),A=n.interopDefault(D),z=t("bundle-text:./img/check_off.svg"),F=n.interopDefault(z);if(i.default=class{constructor(t,e){this.art=t,this.danmuku=e,this.utils=t.constructor.utils;let{setStyle:i}=this.utils,{$controlsCenter:a}=t.template;i(a,"display","flex"),this.template={$controlsCenter:a,$mount:a,$danmuku:null,$toggle:null,$config:null,$configPanel:null,$configModes:null,$style:null,$stylePanel:null,$styleModes:null,$colors:null,$opacitySlider:null,$opacityValue:null,$marginSlider:null,$marginValue:null,$fontSize
Line truncated
|
||||
<div class="apd-toggle">
|
||||
${r.default}${p.default}
|
||||
</div>
|
||||
<div class="apd-config">
|
||||
${h.default}
|
||||
<div class="apd-config-panel">
|
||||
<div class="apd-config-panel-inner">
|
||||
<div class="apd-config-mode">
|
||||
\u{6309}\u{7C7B}\u{578B}\u{5C4F}\u{853D}
|
||||
<div class="apd-modes">
|
||||
<div data-mode="0" class="apd-mode">
|
||||
${g.default}${v.default}
|
||||
<div>\u{6EDA}\u{52A8}</div>
|
||||
</div>
|
||||
<div data-mode="1" class="apd-mode">
|
||||
${k.default}${$.default}
|
||||
<div>\u{9876}\u{90E8}</div>
|
||||
</div>
|
||||
<div data-mode="2" class="apd-mode">
|
||||
${M.default}${S.default}
|
||||
<div>\u{5E95}\u{90E8}</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="apd-config-other">
|
||||
<div class="apd-other apd-anti-overlap">
|
||||
${A.default}${F.default}
|
||||
\u{9632}\u{6B62}\u{5F39}\u{5E55}\u{91CD}\u{53E0}
|
||||
</div>
|
||||
<div class="apd-other apd-sync-video">
|
||||
${A.default}${F.default}
|
||||
\u{540C}\u{6B65}\u{89C6}\u{9891}\u{901F}\u{5EA6}
|
||||
</div>
|
||||
</div>
|
||||
<div class="apd-config-slider apd-config-opacity">
|
||||
\u{4E0D}\u{900F}\u{660E}\u{5EA6}
|
||||
<div class="apd-slider"></div>
|
||||
<div class="apd-value">\u{672A}\u{77E5}</div>
|
||||
</div>
|
||||
<div class="apd-config-slider apd-config-margin">
|
||||
\u{663E}\u{793A}\u{533A}\u{57DF}
|
||||
<div class="apd-slider"></div>
|
||||
<div class="apd-value">\u{672A}\u{77E5}</div>
|
||||
</div>
|
||||
<div class="apd-config-slider apd-config-fontSize">
|
||||
\u{5F39}\u{5E55}\u{5B57}\u{53F7}
|
||||
<div class="apd-slider"></div>
|
||||
<div class="apd-value">\u{672A}\u{77E5}</div>
|
||||
</div>
|
||||
<div class="apd-config-slider apd-config-speed">
|
||||
\u{5F39}\u{5E55}\u{901F}\u{5EA6}
|
||||
<div class="apd-slider"></div>
|
||||
<div class="apd-value">\u{672A}\u{77E5}</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="apd-emitter">
|
||||
<div class="apd-style">
|
||||
${c.default}
|
||||
<div class="apd-style-panel">
|
||||
<div class="apd-style-panel-inner">
|
||||
<div class="apd-style-mode">
|
||||
\u{6A21}\u{5F0F}
|
||||
<div class="apd-modes">
|
||||
<div data-mode="0" class="apd-mode">
|
||||
${v.default}
|
||||
<div>\u{6EDA}\u{52A8}</div>
|
||||
</div>
|
||||
<div data-mode="1" class="apd-mode">
|
||||
${$.default}
|
||||
<div>\u{9876}\u{90E8}</div>
|
||||
</div>
|
||||
<div data-mode="2" class="apd-mode">
|
||||
${S.default}
|
||||
<div>\u{5E95}\u{90E8}</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="apd-style-color">
|
||||
\u{989C}\u{8272}
|
||||
<div class="apd-colors">
|
||||
${this.COLOR.map(t=>`<div data-color="${t}" class="apd-color" style="background-color: ${t}"></div>`).join("")}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<input class="apd-input" placeholder="\u{53D1}\u{4E2A}\u{53CB}\u{5584}\u{7684}\u{5F39}\u{5E55}\u{89C1}\u{8BC1}\u{5F53}\u{4E0B}" autocomplete="off" maxLength="${t.maxLength}" />
|
||||
<div class="apd-send">\u{53D1}\u{9001}</div>
|
||||
</div>
|
||||
`}get OPACITY(){return{min:0,max:100,steps:[],...this.option.OPACITY}}get FONT_SIZE(){return{min:12,max:120,steps:[],...this.option.FONT_SIZE}}get MARGIN(){return{min:0,max:3,steps:[{name:"1/4",value:[10,"75%"]},{name:"半屏",value:[10,"50%"]},{name:"3/4",value:[10,"25%"]},{name:"满屏",value:[10,10]}],...this.option.MARGIN}}get SPEED(){return{min:0,max:4,steps:[{name:"极慢",value:10},{name:"较慢",value:7.5,hide:!0},{name:"适中",value:5},{name:"较快",value:2.5,hide:!0},{name:"极快",value:1}],...this.option.SPEED}}get COLOR(){return this.option.COLOR.length?this.option.COLOR:["#FE0302","#FF7204","#FFAA02","#FFD302","#FFFF00","#A0EE00","#00CD00","#019899","#4266BE","#89D5FF","#CC0273","#222222","#9B9B9B","#FFFFFF"]}query(t){let{query:e}=this.utils,{$danmuku:i}=this.template;return e(t,i)}append(t,e){let{append:i}=this.utils;[...t.children].some(t=>t===e)||i(t,e)}setData(t,e){let{$player:i}=this.art.template,{$mount:a}=this.template;i.dataset[t]=e,this.outside&&(a.dataset[t]=e)}createTemplate(){let{createElement:t,tooltip:e}=this.utils,i=t("div");i.className="artplayer-plugin-danmuku",i.innerHTML=this.TEMPLATE,this.template.$danmuku=i,this.template.$toggle=this.query(".apd-toggle"),this.template.$config=this.query(".apd-config"),this.template.$configPanel=this.query(".apd-config-panel"),this.template.$configModes=this.query(".apd-config-mode .apd-modes"),this.template.$style=this.query(".apd-style"),this.template.$stylePanel=this.query(".apd-style-panel"),this.template.$styleModes=this.query(".apd-style-mode .apd-modes"),this.template.$colors=this.query(".apd-colors"),this.template.$antiOverlap=this.query(".apd-anti-overlap"),this.template.$syncVideo=this.query(".apd-sync-video"),this.template.$opacitySlider=this.query(".apd-config-opacity .apd-slider"),this.template.$opacityValue=this.query(".apd-config-opacity .apd-value"),this.template.$marginSlider=this.query(".apd-config-margin .apd-slider"),this.template.$marginValue=this.query(".apd-config-margin .apd-value"),this.template.$fontSizeSlider=this.query(".apd-config-fontSize .apd-slider"),this.template.$fontSizeValue=this.query(".apd-config-fontSize .apd-value"),this.template.$speedSlider=this.query(".apd-config-speed .apd-slider"),this.template.$speedValue=this.query(".apd-config-speed .apd-value"),this.template.$input=this.query(".apd-input"),this.template.$send=this.query(".apd-send");let{$toggle:a}=this.template;this.art.on("artplayerPluginDanmuku:show",()=>{e(a,"关闭弹幕")}),this.art.on("artplayerPluginDanmuku:hide",()=>{e(a,"打开弹幕")})}createEvents(){let{$toggle:t,$configModes:e,$styleModes:i,$colors:a,$antiOverlap:n,$syncVideo:o,$send:s,$input:l}=this.template;this.art.proxy(t,"click",()=>{this.danmuku.config({visible:!this.option.visible}),this.reset()}),this.art.proxy(e,"click",t=>{let e=t.target.closest(".apd-mode");if(!e)return;let i=Number(e.dataset.mode);this.option.modes.includes(i)?this.danmuku.config({modes:this.option.modes.filter(t=>t!==i)}):this.danmuku.config({modes:[...this.option.modes,i]}),this.reset()}),this.art.proxy(n,"click",()=>{this.danmuku.config({antiOverlap:!this.option.antiOverlap}),this.reset()}),this.art.proxy(o,"click",()=>{this.danmuku.config({synchronousPlayback:!this.option.synchronousPlayback}),this.reset()}),this.art.proxy(i,"click",t=>{let e=t.target.closest(".apd-mode");if(!e)return;let i=Number(e.dataset.mode);this.danmuku.config({mode:i}),this.reset()}),this.art.proxy(a,"click",t=>{let e=t.target.closest(".apd-color");e&&(this.danmuku.config({color:e.dataset.color}),this.reset())}),this.art.proxy(s,"click",()=>this.emit()),this.art.proxy(l,"keypress",t=>{"Enter"===t.key&&(t.preventDefault(),this.emit())})}createSliders(){this.slider.opacity=this.createSlider({...this.OPACITY,container:this.template.$opacitySlider,findIndex:()=>Math.round(100*this.option.opacity),onChange:t=>{let{$opacityValue:e}=this.template;e.textContent=`${t}%`,this.danmuku.config({opacity:t/100})}}),this.slider.margin=this.createSlider({...this.MARGIN,container:this.template.$marginSlider,findIndex:()=>this.MARGIN.steps.findIndex(t=>t.value[0]===this.option.margin[0]&&t.value[1]===this.option.margin[1]),onChange:t=>{let e=this.MARGIN.steps[t];if(!e)return;let{$marginValue:i}=this.template;i.textContent=e.name,this.danmuku.config({margin:e.value})}}),this.slider.fontSize=this.createSlider({...this.FONT_SIZE,container:this.template.$fontSizeSlider,findIndex:()=>this.danmuku.fontSize,onChange:t=>{let{$fontSizeValue:e}=this.template;e.textContent=`${t}px`,t!==this.danmuku.fontSize&&this.danmuku.config({fontSize:t})}}),this.slider.speed=this.createSlider({...this.SPEED,container:this.template.$speedSlider,findIndex:()=>this.SPEED.steps.findIndex(t=>t.value===this.option.speed),onChange:t=>{let e=this.SPEED.steps[t];if(!e)return;let{$speedValue:i}=this.template;i.textContent=e.name,this.danmuku.config({speed:e.value})}})}createSlider({min:t,max:e,container:i,findIndex:a,onChange:n,steps:o=[]}){let{query:s,clamp:l,setS
Line truncated
|
||||
<div class="apd-slider-line">
|
||||
<div class="apd-slider-points">
|
||||
${o.map(()=>'<div class="apd-slider-point"></div>').join("")}
|
||||
</div>
|
||||
<div class="apd-slider-progress"></div>
|
||||
</div>
|
||||
<div class="apd-slider-dot"></div>
|
||||
<div class="apd-slider-steps">
|
||||
${o.map(t=>t.hide?"":`<div class="apd-slider-step">${t.name}</div>`).join("")}
|
||||
</div>
|
||||
`;let d=s(".apd-slider-dot",i),p=s(".apd-slider-progress",i),u=!1;function h(i=a()){if(i<t||i>e)return;let s=(i-t)/(e-t);d.style.left=`${100*s}%`,0===o.length&&(p.style.width=d.style.left),n(i)}function m(a){let{top:n,height:o,left:s,width:r}=i.getBoundingClientRect();this.art.isRotate?h(Math.round(l(a.clientY-n,0,o)/o*(e-t)+t)):h(Math.round(l(a.clientX-s,0,r)/r*(e-t)+t))}return this.art.proxy(i,"click",t=>{m.call(this,t)}),this.art.proxy(i,"pointerdown",t=>{u=0===t.button}),this.art.proxy(document,"pointermove",t=>{u&&m.call(this,t)}),this.art.proxy(document,"pointerup",t=>{u&&(u=!1,m.call(this,t))}),{reset:h}}onFullscreen(t){let{$danmuku:e,$controlsCenter:i,$mount:a}=this.template;this.outside?t?this.append(i,e):this.append(a,e):this.append(i,e)}onMouseEnter({$control:t,$panel:e}){let{$player:i}=this.art.template,a=t.getBoundingClientRect(),n=e.getBoundingClientRect(),o=i.getBoundingClientRect(),s=n.width/2-a.width/2,l=o.left-(a.left-s),r=a.right+s-o.right;l>0?e.style.left=`${-s+l}px`:r>0?e.style.left=`${-s-r}px`:e.style.left=`${-s}px`}async emit(){let{$input:t}=this.template,e=t.value.trim();if(!e.length||this.isLock||this.emitting)return;let i={text:e,mode:this.option.mode,color:this.option.color,time:this.art.currentTime};try{this.emitting=!0;let e=await this.option.beforeEmit(i);if(this.emitting=!1,!0!==e)return;i.border=!0,delete i.time,this.danmuku.emit(i),t.value="",this.lock()}catch(t){this.emitting=!1}}lock(){let{addClass:t}=this.utils,{$send:e}=this.template;this.isLock=!0;let i=this.option.lockTime;e.innerText=i,t(e,"apd-lock");let a=()=>{this.timer=setTimeout(()=>{0===i?this.unlock():(e.innerText=i-=1,a())},1e3)};a()}unlock(){let{removeClass:t}=this.utils,{$send:e}=this.template;clearTimeout(this.timer),this.isLock=!1,e.innerText="发送",t(e,"apd-lock")}resize(){if(this.outside||this.art.fullscreen||this.art.fullscreenWeb)return;let{$player:t,$controlsCenter:e}=this.art.template,{$danmuku:i}=this.template;this.art.width<this.option.width?this.append(t,i):this.append(e,i)}reset(){let{inverseClass:t,tooltip:e}=this.utils,{$toggle:i,$colors:a}=this.template;this.slider.opacity.reset(),this.slider.margin.reset(),this.slider.fontSize.reset(),this.slider.speed.reset(),this.setData("danmukuVisible",this.option.visible),this.setData("danmukuMode",this.option.mode),this.setData("danmukuColor",this.option.color),this.setData("danmukuMode0",this.option.modes.includes(0)),this.setData("danmukuMode1",this.option.modes.includes(1)),this.setData("danmukuMode2",this.option.modes.includes(2)),this.setData("danmukuAntiOverlap",this.option.antiOverlap),this.setData("danmukuSyncVideo",this.option.synchronousPlayback),this.setData("danmukuTheme",this.option.theme),this.setData("danmukuEmitter",this.option.emitter);let n=Array.from(a.children).find(t=>t.dataset.color===this.option.color.toUpperCase());n&&t(n,"apd-active"),e(i,this.option.visible?"关闭弹幕":"打开弹幕"),this.resize()}mount(t){let{errorHandle:e}=this.utils,i="string"==typeof t?document.querySelector(t):t;e(i,`Can not find the mount point: ${t}`),this.append(i,this.template.$danmuku),this.template.$mount=i,this.reset()}},"undefined"!=typeof document){let t="artplayer-plugin-danmuku",e=document.getElementById(t);e||((e=document.createElement("style")).id=t,"loading"===document.readyState?document.addEventListener("DOMContentLoaded",()=>{document.head.appendChild(e)}):(document.head||document.documentElement).appendChild(e)),e.textContent=s.default}},{"bundle-text:./style.less":"dHTK8","bundle-text:./img/on.svg":"5XkVj","bundle-text:./img/off.svg":"3WiJz","bundle-text:./img/config.svg":"DK7bp","bundle-text:./img/style.svg":"h2xX3","bundle-text:./img/mode_0_off.svg":"fp5qd","bundle-text:./img/mode_0_on.svg":"fYNQe","bundle-text:./img/mode_1_off.svg":"gQMgY","bundle-text:./img/mode_1_on.svg":"5E8Hg","bundle-text:./img/mode_2_off.svg":"89iSb","bundle-text:./img/mode_2_on.svg":"2YEb0","bundle-text:./img/check_on.svg":"iQql8","bundle-text:./img/check_off.svg":"4tC1X","@parcel/transformer-js/src/esmodule-helpers.js":"5lQoW"}],dHTK8:[function(t,e,i,a){e.exports='.artplayer-plugin-danmuku{z-index:99;color:#fff;flex-shrink:0;justify-content:center;align-items:center;gap:10px;width:100%;height:32px;font-size:12px;font-weight:300;display:flex;position:relative}.artplayer-plugin-danmuku .apd-icon{cursor:pointer;opacity:.75;fill:#fff;transition:all .2s}.artplayer-plugin-danmuku .apd-icon:hover{opacity:1}.artplayer-plugin-danmuku .apd-config{display:flex;position:relative}.artplayer-plugin-danmuku .apd-config .apd-config-panel{opacity:0;pointer-events:none;width:320px;padding:10px;position:absolute;bottom:24px;left:0}.artplayer-plugin-danmuku .apd-config .apd-config-panel .apd-config-panel-inner{background-color:#000000d9;border-radius:3px;width:100%;padding:10px}.artplayer-plugin-danmuku .apd-config:hover .apd-config-panel{opacity:100;pointer-events:all}.artplayer-plugin-danmuku .apd-config-mode,.artplayer-plugin-danmuku .apd-config-slider,.artplaye
Line truncated
|
||||
<svg viewBox="0 0 ${u.w} ${u.h}">
|
||||
<defs>
|
||||
<linearGradient id="heatmap-solids" x1="0%" y1="0%" x2="100%" y2="0%">
|
||||
<stop offset="0%" style="stop-color:var(--art-theme);stop-opacity:${h.opacity}" />
|
||||
<stop offset="0%" style="stop-color:var(--art-theme);stop-opacity:${h.opacity}" id="heatmap-start" />
|
||||
<stop offset="0%" style="stop-color:var(--art-progress-color);stop-opacity:1" id="heatmap-stop" />
|
||||
<stop offset="100%" style="stop-color:var(--art-progress-color);stop-opacity:1" />
|
||||
</linearGradient>
|
||||
</defs>
|
||||
<path fill="url(#heatmap-solids)" d="${b}"></path>
|
||||
</svg>
|
||||
`,l=a("#heatmap-start",n),r=a("#heatmap-stop",n),l.setAttribute("offset",`${100*t.played}%`),r.setAttribute("offset",`${100*t.played}%`)}t.on("video:timeupdate",()=>{l&&r&&(l.setAttribute("offset",`${100*t.played}%`),r.setAttribute("offset",`${100*t.played}%`))}),t.on("setBar",(t,e)=>{l&&r&&"played"===t&&(l.setAttribute("offset",`${100*e}%`),r.setAttribute("offset",`${100*e}%`))}),t.on("ready",()=>d()),t.on("resize",()=>d()),t.on("artplayerPluginDanmuku:loaded",()=>d()),t.on("artplayerPluginDanmuku:points",t=>d(t))}})}},{"@parcel/transformer-js/src/esmodule-helpers.js":"5lQoW"}]},["6ZbtA"],"6ZbtA","parcelRequire4dc0",{});let{default:t}=parcelRequire4dc0("6ZbtA");export{t as default};
|
||||
//# sourceMappingURL=index.js.map
|
||||
!function(t,e,i,a,n,o,s,l){var r="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:{},d="function"==typeof r[a]&&r[a],p=d.i||{},u=d.cache||{},h="undefined"!=typeof module&&"function"==typeof module.require&&module.require.bind(module);function m(e,i){if(!u[e]){if(!t[e]){if(n[e])return n[e];var o="function"==typeof r[a]&&r[a];if(!i&&o)return o(e,!0);if(d)return d(e,!0);if(h&&"string"==typeof e)return h(e);var s=Error("Cannot find module '"+e+"'");throw s.code="MODULE_NOT_FOUND",s}p.resolve=function(i){var a=t[e][1][i];return null!=a?a:i},p.cache={};var l=u[e]=new m.Module(e);t[e][0].call(l.exports,p,l,l.exports,r)}return u[e].exports;function p(t){var e=p.resolve(t);return!1===e?{}:m(e)}}m.isParcelRequire=!0,m.Module=function(t){this.id=t,this.bundle=m,this.require=h,this.exports={}},m.modules=t,m.cache=u,m.parent=d,m.distDir=void 0,m.publicUrl=void 0,m.devServer=void 0,m.i=p,m.register=function(e,i){t[e]=[function(t,e){e.exports=i},{}]},Object.defineProperty(m,"root",{get:function(){return r[a]}}),r[a]=m;for(var c=0;c<e.length;c++)m(e[c]);if(i){var f=m(i);"object"==typeof exports&&"undefined"!=typeof module?module.exports=f:"function"==typeof define&&define.amd&&define(function(){return f})}}({"7ICE7":[function(t,e,i,a){var n=t("@parcel/transformer-js/src/esmodule-helpers.js");n.defineInteropFlag(i),n.export(i,"default",()=>u);var o=t("./danmuku"),s=n.interopDefault(o),l=t("./setting"),r=n.interopDefault(l),d=t("./heatmap"),p=n.interopDefault(d);function u(t){return e=>{let i=new(0,s.default)(e,t),a=new(0,r.default)(e,i);return i.option.heatmap&&(0,p.default)(e,i,i.option.heatmap),{name:"artplayerPluginDanmuku",emit:i.emit.bind(i),load:i.load.bind(i),config:i.config.bind(i),hide:i.hide.bind(i),show:i.show.bind(i),reset:i.reset.bind(i),mount:a.mount.bind(a),get option(){return i.option},get isHide(){return i.isHide},get isStop(){return i.isStop}}}}u.icons=r.default.icons,"undefined"!=typeof window&&(window.artplayerPluginDanmuku=u)},{"./danmuku":"9bpce","./setting":"94xSe","./heatmap":"9KNY2","@parcel/transformer-js/src/esmodule-helpers.js":"loqXi"}],"9bpce":[function(t,e,i,a){var n=t("@parcel/transformer-js/src/esmodule-helpers.js");n.defineInteropFlag(i);var o=t("./bilibili"),s=t("bundle-text:./worker"),l=n.interopDefault(s);class r{constructor(t,e){let{constructor:i,template:a}=t;this.utils=i.utils,this.validator=i.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=r.option,this.states={wait:[],ready:[],emit:[],stop:[]},this.config(e);let n=new Blob([l.default],{type:"application/javascript"});this.worker=new Worker(URL.createObjectURL(n)),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()}static get option(){return{danmuku:[],speed:5,margin:[10,"25%"],opacity:1,color:"#FFFFFF",mode:0,modes:[0,1,2],fontSize:25,antiOverlap:!0,synchronousPlayback:!1,mount:void 0,heatmap:!1,width:512,points:[],filter:()=>!0,beforeEmit:()=>!0,beforeVisible:()=>!0,visible:!0,emitter:!0,maxLength:200,lockTime:5,theme:"dark",OPACITY:{},FONT_SIZE:{},MARGIN:{},SPEED:{},COLOR:[]}}static get scheme(){return{danmuku:"array|function|string",speed:"number",margin:"array",opacity:"number",color:"string",mode:"number",modes:"array",fontSize:"number|string",antiOverlap:"boolean",synchronousPlayback:"boolean",mount:"?htmldivelement|string",heatmap:"object|boolean",width:"number",points:"array",filter:"function",beforeEmit:"function",beforeVisible:"function",visible:"boolean",emitter:"boolean",maxLength:"number",lockTime:"number",theme:"string",OPACITY:"object",FONT_SIZE:"object",MARGIN:"object",SPEED:"object",COLOR:"array"}}static get cssText(){return` user-select: none; position: absolute; white-space: pre; pointer-events: none; perspective: 500px; display: inline-block; will-change: transform; font-weight: normal; line-height: 1.125; visibility: hidden; font-family: SimHei, "Microsoft JhengHei", Arial, Helvetica, sans-serif; text-shadow: rgb(0, 0, 0) 1px 0px 1px, rgb(0, 0, 0) 0px 1px 1px, rgb(0, 0, 0) 0px -1px 1px, rgb(0, 0, 0) -1px 0px 1px; `}get isRotate(){return this.art.plugins?.autoOrientation?.state}get marginTop(){let{clamp:t}=this.utils,e=this.option.margin[0],{clientHeight:i}=this.$player;return"number"==typeof e?t(e,0,i):"string"==typeof e&&e.endsWith("%")?t(i*(parseFloat(e)/100),0,i):r.option.margin[0]}get marginBottom(){let{clamp:t}=this.utils,e=this.option.margin[1],{clientHeight:i}=this.$player;return"number"==typeof e?t(e,0,i):"string"==typeof e&&e.endsWith("%")?t(i*(parseFloat(e)/100),0,i):r.option.margin[1]}get
Line truncated
|
||||
Reference in new issue
Block a user