mirror of
https://github.com/zhw2590582/ArtPlayer.git
synced 2026-10-08 19:06:15 -08:00
* chore: Bump artplayer-plugin-danmuku version to 5.1.0 * chore: Update danmuku plugin with new mount option * chore: Update danmuku plugin with new mount option * chore: Update danmuku plugin with new mount option * chore: Update danmuku plugin with new mount option * chore: Update danmuku plugin with new mount option * chore: Update danmuku plugin with new mount option * chore: Refactor getDanmuTop function to handle additional cases * chore: Refactor getDanmuTop function to handle additional cases * chore: Update danmuku plugin with new mount option * chore: Update danmuku plugin with new mount option * chore: Refactor danmuku plugin to always create a new Setting instance * Refactor danmuku plugin to always create a new Setting instance * Refactor danmuku plugin to always create a new Setting instance * Update danmuku.js * Update danmuku.js * Refactor danmuku plugin to include a new Setting instance * Refactor danmuku plugin to include a new Setting instance * Refactor danmuku plugin styles for better alignment and spacing * Refactor danmuku plugin styles for better alignment and spacing * Refactor danmuku plugin styles for better alignment and spacing * Refactor danmuku plugin styles for better alignment and spacing * Refactor danmuku plugin styles for better alignment and spacing * chore: Update package.json files * Refactor danmuku plugin to remove unnecessary whitespace in the setting template * chore: Remove ESLint configuration files and update npm dependencies * chore: Update ESLint configuration to disable console warnings and fix unused variable warnings * chore: Update ESLint configuration to fix quotes rule * Update package.json * Update package.json * Update setting.js * chore: Compress CSS code in build script * chore: Update build script to compress JavaScript code * chore: Update build script to compress JavaScript code * chore: Refactor setting.js to improve code organization and remove unused variables * chore: Add isHover flag to Control component for better control hiding behavior * chore: Update Control component to use $bottom instead of $controls for better control hiding behavior * Update package.json * Update package.json * Update package.json * chore: Update lerna.json to use independent versioning and yarn as npm client * refactor: Update Danmuku class to support configurable modes and visibility * refactor: Update Danmuku styles for better visibility and configurability * feat: Update font weight in Danmuku styles for better readability * refactor: Update Danmuku class to support configurable modes and visibility * refactor: Add opacity, area, font, and speed sliders to Danmuku settings * refactor: Initialize sliders for opacity, area, font, and speed in Danmuku settings * feat: Add slider UI for opacity, area, and speed in Danmuku settings * feat: Update slider styles in Danmuku settings for better visibility and configurability * refactor: Improve Danmuku settings UI for better visibility and configurability * refactor: Improve Danmuku settings UI for better visibility and configurability * refactor: Update slider styles in Danmuku settings for better visibility and configurability * refactor: Update margin slider initialization in Danmuku settings * refactor: Update slider styles and initialization in Danmuku settings * refactor: Update Danmuku class to support configurable visibility * refactor: Update Danmuku class to support configurable visibility * refactor: Update Danmuku class to support configurable visibility * refactor: Update Danmuku class to support configurable visibility * refactor: Update Danmuku settings UI for better visibility and configurability * refactor: Update Danmuku settings UI for better visibility and configurability * refactor: Update Danmuku settings UI for better visibility and configurability * refactor: Update Danmuku settings UI for better visibility and configurability * refactor: Improve Danmuku settings UI for better visibility and configurability * add lock * refactor: Add lock and unlock methods to Danmuku settings * refactor: Update Danmuku settings UI for better visibility and configurability * refactor: Update Danmuku settings UI for better visibility and configurability * refactor: Update Danmuku settings UI for better visibility and configurability * refactor: Update Danmuku settings UI for better visibility and configurability * Update artplayer-plugin-danmuku.d.ts * refactor: Update Danmuku settings UI for better visibility and configurability * refactor: Update Danmuku settings UI for better visibility and configurability * refactor: Update Danmuku settings UI for better visibility and configurability * refactor: Update Danmuku settings UI for better visibility and configurability * refactor: Update Danmuku settings event listeners * refactor: Update Danmuku settings UI for better visibility and configurability * refactor: Update Danmuku settings UI for better visibility and configurability * refactor: Update Danmuku settings UI for better visibility and configurability * refactor: Update Danmuku settings UI for better visibility and configurability
7 lines
15 KiB
JavaScript
7 lines
15 KiB
JavaScript
/*!
|
||
* artplayer-plugin-multiple-subtitles.js v1.0.0
|
||
* Github: https://github.com/zhw2590582/ArtPlayer
|
||
* (c) 2017-2024 Harvey Zack
|
||
* Released under the MIT License.
|
||
*/
|
||
!function(e,t,n,i,r){var a="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:{},s="function"==typeof a[i]&&a[i],o=s.cache||{},l="undefined"!=typeof module&&"function"==typeof module.require&&module.require.bind(module);function u(t,n){if(!o[t]){if(!e[t]){var r="function"==typeof a[i]&&a[i];if(!n&&r)return r(t,!0);if(s)return s(t,!0);if(l&&"string"==typeof t)return l(t);var f=Error("Cannot find module '"+t+"'");throw f.code="MODULE_NOT_FOUND",f}d.resolve=function(n){var i=e[t][1][n];return null!=i?i:n},d.cache={};var c=o[t]=new u.Module(t);e[t][0].call(c.exports,d,c,c.exports,this)}return o[t].exports;function d(e){var t=d.resolve(e);return!1===t?{}:u(t)}}u.isParcelRequire=!0,u.Module=function(e){this.id=e,this.bundle=u,this.exports={}},u.modules=e,u.cache=o,u.parent=s,u.register=function(t,n){e[t]=[function(e,t){t.exports=n},{}]},Object.defineProperty(u,"root",{get:function(){return a[i]}}),a[i]=u;for(var f=0;f<t.length;f++)u(t[f]);if(n){var c=u(n);"object"==typeof exports&&"undefined"!=typeof module?module.exports=c:"function"==typeof define&&define.amd&&define(function(){return c})}}({bt91X:[function(e,t,n){var i=e("@parcel/transformer-js/src/esmodule-helpers.js");i.defineInteropFlag(n),i.export(n,"default",()=>s);var r=e("./parser");async function a(e,{getExt:t,srtToVtt:n,assToVtt:i}){let r=await fetch(e.url),a=await r.arrayBuffer(),s=new TextDecoder(e.encoding||"utf-8").decode(a);switch(e.type||t(e.url)){case"srt":return n(s);case"ass":return i(s);case"vtt":return s;default:return""}}function s({subtitles:e=[]}){return async t=>{let{unescape:n,getExt:i,srtToVtt:s,assToVtt:o}=t.constructor.utils,l=new r.WebVTTParser,u=new r.WebVTTSerializer,f=(await Promise.all(e.map(e=>a(e,{getExt:i,srtToVtt:s,assToVtt:o})))).map((t,n)=>{let i=l.parse(t,"metadata");return i.url=e[n].url,i.name=e[n].name,i}),c="";function d(e=[]){let i=function(e){let t=new r.WebVTTParser().parse("","metadata");for(let n=0;n<e.length;n++){let i=e[n];if(!i.updated){i.updated=!0;for(let e=0;e<i.cues.length;e++){let t=i.cues[e];for(let e=0;e<t.tree.children.length;e++){let n=t.tree.children[e];n.value=`<div class="art-subtitle-${i.name}">${n.value}</div>`}}}if(0===t.cues.length)t.cues=[...i.cues];else for(let e=0;e<t.cues.length;e++){let n=t.cues[e].tree.children,r=i.cues[e]?.tree?.children;t.cues[e]={...t.cues[e],tree:{children:[...n,...r]}}}}return t}(e),a=u.serialize(i.cues);URL.revokeObjectURL(c);let s=URL.createObjectURL(new Blob([a],{type:"text/vtt"}));c=s,t.option.subtitle.escape=!1,t.subtitle.init({...t.option.subtitle,url:s,type:"vtt",onVttLoad:n})}return d(f),{name:"multipleSubtitles",tracks:(e=[])=>d(e.map(e=>f.find(t=>t.name===e))),reset:()=>d(f)}}}"undefined"!=typeof window&&(window.artplayerPluginMultipleSubtitles=s)},{"./parser":"e4aAa","@parcel/transformer-js/src/esmodule-helpers.js":"hqP7A"}],e4aAa:[function(e,t,n){!function(){var e={direction:"horizontal",snapToLines:!0,linePosition:"auto",lineAlign:"start",textPosition:"auto",positionAlign:"auto",size:100,alignment:"center"},t=function(t){t||(t={"&":"&","<":"<",">":">","&lrm":"","&rlm":""," ":" "}),this.entities=t,this.parse=function(n,a){n=n.replace(/\0/g,"�");var s=Date.now(),o=0,l=n.split(/\r\n|\r|\n/),u=!1,f=[],c=[],d=[];function p(e,t){d.push({message:e,line:o+1,col:t})}var m=l[o],g=m.length,h="WEBVTT",v=0,b=h.length;for("\uFEFF"===m[0]&&(v=1,b+=1),(g<b||m.indexOf(h)!==0+v||g>b&&" "!==m[b]&&" "!==m[b])&&p('No valid signature. (File needs to start with "WEBVTT".)'),o++;""!=l[o]&&void 0!=l[o];){if(p("No blank line after the signature."),-1!=l[o].indexOf("-->")){u=!0;break}o++}for(;void 0!=l[o];){for(;!u&&""==l[o];)o++;if(!u&&void 0==l[o])break;T=Object.assign({},e,{id:"",startTime:0,endTime:0,pauseOnExit:!1,direction:"horizontal",snapToLines:!0,linePosition:"auto",lineAlign:"start",textPosition:"auto",positionAlign:"auto",size:100,alignment:"center",text:"",tree:null});var T,y=!0;if(-1==l[o].indexOf("-->")){if(T.id=l[o],/^NOTE($|[ \t])/.test(T.id)){for(o++;""!=l[o]&&void 0!=l[o];)-1!=l[o].indexOf("-->")&&p("Cannot have timestamp in a comment."),o++;continue}if(/^STYLE($|[ \t])/.test(T.id)){var x=[],w=!1;for(o++;""!=l[o]&&void 0!=l[o];)-1!=l[o].indexOf("-->")&&(p("Cannot have timestamp in a style block."),w=!0),x.push(l[o]),o++;if(c.length){p("Style blocks cannot appear after the first cue.");continue}w||f.push(x.join("\n"));continue}if(""==l[++o]||void 0==l[o]){p("Cue identifier cannot be standalone.");continue}if(-1==l[o].indexOf("-->")){y=!1,p("Cue identifier needs to be followed by timestamp.");continue}}u=!1;var O=new i(l[o],p),P=0;if(c.length>0&&(P=c[c.length-1].startTime),y&&!O.parse(T,P)){for(T=null,o++;""!=l[o]&&void 0!=l[o];){if(-1!=l[o].indexOf("-->")){u=!0;break}o++}continue}for(o++;""!=l[o]&&void 0!=l[o];){if(-1!=l[o].indexOf("-->")){p("Blank line missing before cue."),u=!0;break}""!=T.text&&(T.text+="\n"),T.text+=l[o],o++}var A=new r(T.text,p,a,t);T.tree=A.parse(T.startTime,T.endTime),c.push(T)}return c.sort(function(e,t){return e.startTime<t.startTime?-1:e.startTime>t.startTime?1:e.endTime>t.endTime?-1:e.endTime<t.endTime?1:0}),{cues:c,errors:d,time:Date.now()-s,styles:f}}},i=function(e,t){var n=/[\u0020\t\f]/,i=/[^\u0020\t\f]/,e=e,r=0,a=function(e){t(e,r+1)};function s(t){for(;void 0!=e[r]&&t.test(e[r]);)r++}function o(t){for(var n="";void 0!=e[r]&&t.test(e[r]);)n+=e[r],r++;return n}function l(){var t,n,i,s,l="minutes";if(void 0==e[r]){a("No timestamp found.");return}if(!/\d/.test(e[r])){a("Timestamp must start with a character in the range 0-9.");return}if(((t=o(/\d/)).length>2||parseInt(t,10)>59)&&(l="hours"),":"!=e[r]){a("No time unit separator found.");return}if(r++,2!=(n=o(/\d/)).length){a("Must be exactly two digits.");return}if("hours"==l||":"==e[r]){if(":"!=e[r]){a("No seconds found or minutes is greater than 59.");return}if(r++,2!=(i=o(/\d/)).length){a("Must be exactly two digits.");return}}else{if(2!=t.length){a("Must be exactly two digits.");return}i=n,n=t,t="0"}if("."!=e[r]){a('No decimal separator (".") found.');return}if(r++,3!=(s=o(/\d/)).length){a("Milliseconds must be given in three digits.");return}if(parseInt(n,10)>59){a("You cannot have more than 59 minutes.");return}if(parseInt(i,10)>59){a("You cannot have more than 59 seconds.");return}return 3600*parseInt(t,10)+60*parseInt(n,10)+parseInt(i,10)+parseInt(s,10)/1e3}this.parse=function(t,o){if(s(n),t.startTime=l(),void 0!=t.startTime){if(t.startTime<o&&a("Start timestamp is not greater than or equal to start timestamp of previous cue."),i.test(e[r])&&a("Timestamp not separated from '-->' by whitespace."),s(n),"-"!=e[r]||"-"!=e[++r]||">"!=e[++r]){a("No valid timestamp separator found.");return}if(r++,i.test(e[r])&&a("'-->' not separated from timestamp by whitespace."),s(n),t.endTime=l(),void 0!=t.endTime)return t.endTime<=t.startTime&&a("End timestamp is not greater than start timestamp."),i.test(e[r]),s(n),function(e,t){for(var i=e.split(n),r=[],s=0;s<i.length;s++)if(""!=i[s]){var o=i[s].indexOf(":"),l=i[s].slice(0,o),u=i[s].slice(o+1);if(-1!=r.indexOf(l)&&a("Duplicate setting."),r.push(l),""==u){a("No value for setting defined.");return}if("vertical"==l){if("rl"!=u&&"lr"!=u){a("Writing direction can only be set to 'rl' or 'rl'.");continue}t.direction=u}else if("line"==l){if(/,/.test(u)){var f=u.split(",");u=f[0];var c=f[1]}if(!/^[-\d](\d*)(\.\d+)?%?$/.test(u)){a("Line position takes a number or percentage.");continue}if(-1!=u.indexOf("-",1)){a("Line position can only have '-' at the start.");continue}if(-1!=u.indexOf("%")&&u.indexOf("%")!=u.length-1){a("Line position can only have '%' at the end.");continue}if("-"==u[0]&&"%"==u[u.length-1]){a("Line position cannot be a negative percentage.");continue}var d=u,p=!1;if("%"==u[u.length-1]&&(p=!0,d=u.slice(0,u.length-1),parseInt(u,10)>100)){a("Line position cannot be >100%.");continue}if(""===d||isNaN(d)||!isFinite(d)){a("Line position needs to be a number");continue}if(void 0!==c){if(!["start","center","end"].includes(c)){a("Line alignment needs to be one of start,center or end");continue}t.lineAlign=c}t.snapToLines=!p,t.linePosition=parseFloat(d),parseFloat(d).toString()!==d&&(t.nonSerializable=!0)}else if("position"==l){if(/,/.test(u)){var f=u.split(",");u=f[0];var m=f[1]}if("%"!=u[u.length-1]){a("Text position must be a percentage.");continue}if(parseInt(u,10)>100||0>parseInt(u,10)){a("Text position needs to be between 0 and 100%.");continue}if(""===(d=u.slice(0,u.length-1))||isNaN(d)||!isFinite(d)){a("Line position needs to be a number");continue}if(void 0!==m){if(!["line-left","center","line-right"].includes(m)){a("Position alignment needs to be one of line-left,center or line-right");continue}t.positionAlign=m}t.textPosition=parseFloat(d)}else if("size"==l){if("%"!=u[u.length-1]){a("Size must be a percentage.");continue}if(parseInt(u,10)>100){a("Size cannot be >100%.");continue}var g=u.slice(0,u.length-1);if(void 0===g||""===g||isNaN(g)){a("Size needs to be a number"),g=100;continue}if((g=parseFloat(g))<0||g>100){a("Size needs to be between 0 and 100%.");continue}t.size=g}else if("align"==l){var h=["start","center","end","left","right"];if(-1==h.indexOf(u)){a("Alignment can only be set to one of "+h.join(",")+".");continue}t.alignment=u}else a("Invalid setting.")}}(e.substring(r),t),!0}},this.parseTimestamp=function(){var t=l();if(void 0!=e[r]){a("Timestamp must not have trailing characters.");return}return t}},r=function(e,t,n,r){this.entities=r;var a=this,e=e,s=0,o=function(e){"metadata"!=n&&t(e,s+1)};this.parse=function(t,l){var u={children:[]},f=u,c=[];function d(e){f.children.push({type:"object",name:e[1],classes:e[2],children:[],parent:f}),f=f.children[f.children.length-1]}for(;void 0!=e[s];){var p=function(){for(var t="data",n="",i="",l=[];void 0!=e[s-1]||0==s;){var u=e[s];if("data"==t){if("&"==u)i=u,t="escape";else if("<"==u&&""==n)t="tag";else{if("<"==u||void 0==u)return["text",n];n+=u}}else if("escape"==t){if("<"==u||void 0==u){let e;return o("Incorrect escape."),(e=i.match(/^&#([0-9]+)$/))?n+=String.fromCharCode(e[1]):a.entities[i]?n+=a.entities[i]:n+=i,["text",n]}if("&"==u)o("Incorrect escape."),n+=i,i=u;else if(/[a-z#0-9]/i.test(u))i+=u;else if(";"==u){let e;(e=i.match(/^&#(x?[0-9]+)$/))?n+=String.fromCharCode("0"+e[1]):a.entities[i+u]?n+=a.entities[i+u]:(e=Object.keys(r).find(e=>i.startsWith(e)))?n+=a.entities[e]+i.slice(e.length)+u:(o("Incorrect escape."),n+=i+";"),t="data"}else o("Incorrect escape."),n+=i+u,t="data"}else if("tag"==t){if(" "==u||"\n"==u||"\f"==u||" "==u)t="start tag annotation";else if("."==u)t="start tag class";else if("/"==u)t="end tag";else if(/\d/.test(u))n=u,t="timestamp tag";else{if(">"==u||void 0==u)return">"==u&&s++,["start tag","",[],""];n=u,t="start tag"}}else if("start tag"==t){if(" "==u||"\f"==u||" "==u)t="start tag annotation";else if("\n"==u)i=u,t="start tag annotation";else if("."==u)t="start tag class";else{if(">"==u||void 0==u)return">"==u&&s++,["start tag",n,[],""];n+=u}}else if("start tag class"==t){if(" "==u||"\f"==u||" "==u)i&&l.push(i),i="",t="start tag annotation";else if("\n"==u)i&&l.push(i),i=u,t="start tag annotation";else if("."==u)i&&l.push(i),i="";else{if(">"==u||void 0==u)return">"==u&&s++,i&&l.push(i),["start tag",n,l,""];i+=u}}else if("start tag annotation"==t){if(">"==u||void 0==u)return">"==u&&s++,["start tag",n,l,i=i.split(/[\u0020\t\f\r\n]+/).filter(function(e){if(e)return!0}).join(" ")];i+=u}else if("end tag"==t){if(">"==u||void 0==u)return">"==u&&s++,["end tag",n];n+=u}else if("timestamp tag"==t){if(">"==u||void 0==u)return">"==u&&s++,["timestamp",n];n+=u}else o("Never happens.");s++}}();if("text"==p[0])f.children.push({type:"text",value:p[1],parent:f});else if("start tag"==p[0]){"chapters"==n&&o("Start tags not allowed in chapter title text.");var m=p[1];"v"!=m&&"lang"!=m&&""!=p[3]&&o("Only<v>and<lang>can have an annotation."),"c"==m||"i"==m||"b"==m||"u"==m||"ruby"==m?d(p):"rt"==m&&"ruby"==f.name?d(p):"v"==m?(function(e){for(var t=f;t;){if("v"==t.name)return!0;t=t.parent}}(0)&&o("<v>cannot be nested inside itself."),d(p),f.value=p[3],p[3]||o("<v>requires an annotation.")):"lang"==m?(d(p),f.value=p[3]):o("Incorrect start tag.")}else if("end tag"==p[0])"chapters"==n&&o("End tags not allowed in chapter title text."),p[1]==f.name?f=f.parent:"ruby"==p[1]&&"rt"==f.name?f=f.parent.parent:o("Incorrect end tag.");else if("timestamp"==p[0]){"chapters"==n&&o("Timestamp not allowed in chapter title text.");var g=new i(p[1],o).parseTimestamp();void 0!=g&&((g<=t||g>=l)&&o("Timestamp must be between start timestamp and end timestamp."),c.length>0&&c[c.length-1]>=g&&o("Timestamp must be greater than any previous timestamp."),f.children.push({type:"timestamp",value:g,parent:f}),c.push(g))}}for(;f.parent;)"v"!=f.name&&o("Required end tag missing."),f=f.parent;return function e(t){let n={...t};return t.children&&(n.children=t.children.map(e)),n.parent&&delete n.parent,n}(u)}},a=function(){function t(e){let t=("00"+1e3*(e-Math.floor(e)).toFixed(3)).slice(-3),n=0,i=0,r=0;return e>=3600&&(n=Math.floor(e/3600)),i=Math.floor((e-3600*n)/60),r=Math.floor(e-3600*n-60*i),(n?n+":":"")+(""+i).padStart(2,"0")+":"+(""+r).padStart(2,"0")+"."+t}this.serialize=function(n,i){var r,a="WEBVTT\n\n";if(i)for(var s=0;s<i.length;s++)a+="STYLE\n"+i[s]+"\n\n";for(var s=0;s<n.length;s++)a+=(void 0!==(r=n[s]).id?r.id+"\n":"")+t(r.startTime)+" -->"+t(r.endTime)+function(t){var n="";let i=Object.keys(e).filter(n=>t[n]!==e[n]);return i.includes("direction")&&(n+=" vertical:"+t.direction),i.includes("alignment")&&(n+=" align:"+t.alignment),i.includes("size")&&(n+=" size:"+t.size+"%"),(i.includes("lineAlign")||i.includes("linePosition"))&&(n+=" line:"+t.linePosition+(t.snapToLines?"":"%")+(t.lineAlign&&t.lineAlign!=e.lineAlign?","+t.lineAlign:"")),(i.includes("textPosition")||i.includes("positionAlign"))&&(n+=" position:"+t.textPosition+"%"+(t.positionAlign&&t.positionAlign!==e.positionAlign?","+t.positionAlign:"")),n}(r)+"\n"+function e(n){for(var i="",r=0;r<n.length;r++){var a=n[r];if("text"==a.type)i+=a.value.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">");else if("object"==a.type){if(i+="<"+a.name,a.classes)for(var s=0;s<a.classes.length;s++)i+="."+a.classes[s];a.value&&(i+=" "+a.value),i+=">",a.children&&(i+=e(a.children)),i+="</"+a.name+">"}else"timestamp"==a.type?i+="<"+t(a.value)+">":i+="<"+a.value+">"}return i}(r.tree.children)+"\n\n";return a}};function s(e){e.WebVTTParser=t,e.WebVTTCueTimingsAndSettingsParser=i,e.WebVTTCueTextParser=r,e.WebVTTSerializer=a}"undefined"!=typeof window&&s(window),s(n)}()},{}],hqP7A:[function(e,t,n){n.interopDefault=function(e){return e&&e.__esModule?e:{default:e}},n.defineInteropFlag=function(e){Object.defineProperty(e,"__esModule",{value:!0})},n.exportAll=function(e,t){return Object.keys(e).forEach(function(n){"default"===n||"__esModule"===n||Object.prototype.hasOwnProperty.call(t,n)||Object.defineProperty(t,n,{enumerable:!0,get:function(){return e[n]}})}),t},n.export=function(e,t,n){Object.defineProperty(e,t,{enumerable:!0,get:n})}},{}]},["bt91X"],"bt91X","parcelRequire94c2"); |