Refactor code structure for improved readability and maintainability

Remove debugging border from the websr plugin's styling

Enhance canvas sizing logic in artplayer-plugin-websr

- Updated canvas positioning to center it within the player.
- Introduced a new function to calculate canvas size based on the video aspect ratio.
- Adjusted canvas dimensions during initialization and on resize events to maintain aspect ratio.
- Ensured canvas styles are updated to reflect the calculated dimensions.

feat: add comparison mode to artplayer-plugin-websr

- Updated README.md to reflect new comparison feature and simplified content.
- Modified package.json to remove unnecessary keywords.
- Enhanced index.js to implement comparison functionality, allowing users to compare original and upscaled video.
- Added new methods for enabling, disabling, and toggling comparison mode, as well as setting and getting the comparison position.
- Updated TypeScript definitions to include new comparison options and methods.
This commit is contained in:
Harvey Zhao committed 2026-02-10 23:02:31 +08:00
1 parent 07a5b0c0f0
commit 7dffd99cfd
308 files changed
+3175 -852

No files matched your search

@@ -5,4 +5,4 @@
* (c) 2017-2026 Harvey Zack
* Released under the MIT License.
*/
!function(e,t,n,i,r,a,o,s){var l="u">typeof globalThis?globalThis:"u">typeof self?self:"u">typeof window?window:"u">typeof global?global:{},u="function"==typeof l[i]&&l[i],f=u.i||{},c=u.cache||{},d="u">typeof module&&"function"==typeof module.require&&module.require.bind(module);function p(t,n){if(!c[t]){if(!e[t]){if(r[t])return r[t];var a="function"==typeof l[i]&&l[i];if(!n&&a)return a(t,!0);if(u)return u(t,!0);if(d&&"string"==typeof t)return d(t);var o=Error("Cannot find module '"+t+"'");throw o.code="MODULE_NOT_FOUND",o}f.resolve=function(n){var i=e[t][1][n];return null!=i?i:n},f.cache={};var s=c[t]=new p.Module(t);e[t][0].call(s.exports,f,s,s.exports,l)}return c[t].exports;function f(e){var t=f.resolve(e);if(!1===t)return{};if(Array.isArray(t)){var n={__esModule:!0};return t.forEach(function(e){var t=e[0],i=e[1],r=e[2]||e[0],a=p(i);"*"===t?Object.keys(a).forEach(function(e){"default"===e||"__esModule"===e||Object.prototype.hasOwnProperty.call(n,e)||Object.defineProperty(n,e,{enumerable:!0,get:function(){return a[e]}})}):"*"===r?Object.defineProperty(n,t,{enumerable:!0,value:a}):Object.defineProperty(n,t,{enumerable:!0,get:function(){return"default"===r?a.__esModule?a.default:a:a[r]}})}),n}return p(t)}}p.isParcelRequire=!0,p.Module=function(e){this.id=e,this.bundle=p,this.require=d,this.exports={}},p.modules=e,p.cache=c,p.parent=u,p.distDir=void 0,p.publicUrl=void 0,p.devServer=void 0,p.i=f,p.register=function(t,n){e[t]=[function(e,t){t.exports=n},{}]},Object.defineProperty(p,"root",{get:function(){return l[i]}}),l[i]=p;for(var m=0;m<t.length;m++)p(t[m]);if(n){var g=p(n);"object"==typeof exports&&"u">typeof module?module.exports=g:"function"==typeof define&&define.amd&&define(function(){return g})}}({b4OMP:[function(e,t,n,i){var r=e("@parcel/transformer-js/src/esmodule-helpers.js");r.defineInteropFlag(n),r.export(n,"default",()=>s);var a=e("./parser");async function o(e,{getExt:t,srtToVtt:n,assToVtt:i}){let r=await fetch(e.url),a=await r.arrayBuffer(),o=new TextDecoder(e.encoding||"utf-8").decode(a);switch(e.type||t(e.url)){case"srt":return n(o);case"ass":return i(o);case"vtt":return o;default:return""}}function s({subtitles:e=[]}){return async t=>{let{unescape:n,getExt:i,srtToVtt:r,assToVtt:s}=t.constructor.utils,l=new(0,a.WebVTTParser),u=new(0,a.WebVTTSerializer),f=(await Promise.all(e.map(e=>o(e,{getExt:i,srtToVtt:r,assToVtt:s})))).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(0,a.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>`}}}t.cues.push(...i.cues)}return t}(e),r=u.serialize(i.cues);URL.revokeObjectURL(c);let o=URL.createObjectURL(new Blob([r],{type:"text/vtt"}));c=o,t.option.subtitle.escape=!1,t.subtitle.init({...t.option.subtitle,url:o,type:"vtt",onVttLoad:n})}return d(f),{name:"multipleSubtitles",tracks:(e=[])=>d(e.map(e=>f.find(t=>t.name===e))),reset:()=>d(f)}}}"u">typeof window&&(window.artplayerPluginMultipleSubtitles=s)},{"./parser":"3iLlq","@parcel/transformer-js/src/esmodule-helpers.js":"loqXi"}],"3iLlq":[function(e,t,n,i){!function(){var e={direction:"horizontal",snapToLines:!0,linePosition:"auto",lineAlign:"start",textPosition:"auto",positionAlign:"auto",size:100,alignment:"center"},t=function(t){t||(t={"&amp":"&","&lt":"<","&gt":">","&lrm":"‎","&rlm":"‏","&nbsp":" "}),this.entities=t,this.parse=function(n,a){n=n.replace(/\0/g,"�");var o=Date.now(),s=0,l=n.split(/\r\n|\r|\n/),u=!1,f=[],c=[],d=[];function p(e,t){d.push({message:e,line:s+1,col:t})}var m=l[s],g=m.length,v="WEBVTT",h=0,b=v.length;for("\uFEFF"===m[0]&&(h=1,b+=1),(g<b||m.indexOf(v)!==0+h||g>b&&" "!==m[b]&&" "!==m[b])&&p('No valid signature. (File needs to start with "WEBVTT".)'),s++;""!=l[s]&&void 0!=l[s];){if(p("No blank line after the signature."),-1!=l[s].indexOf("--\x3e")){u=!0;break}s++}for(;void 0!=l[s];){for(;!u&&""==l[s];)s++;if(!u&&void 0==l[s])break;var 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}),y=!0;if(-1==l[s].indexOf("--\x3e")){if(T.id=l[s],/^NOTE($|[ \t])/.test(T.id)){for(s++;""!=l[s]&&void 0!=l[s];)-1!=l[s].indexOf("--\x3e")&&p("Cannot have timestamp in a comment."),s++;continue}if(/^STYLE($|[ \t])/.test(T.id)){var x=[],w=!1;for(s++;""!=l[s]&&void 0!=l[s];)-1!=l[s].indexOf("--\x3e")&&(p("Cannot have timestamp in a style block."),w=!0),x.push(l[s]),s++;if(c.length){p("Style blocks cannot appear after the first cue.");continue}w||f.push(x.join("\n"));continue}if(""==l[++s]||void 0==l[s]){p("Cue identifier cannot be standalone.");continue}if(-1==l[s].indexOf("--\x3e")){y=!1,p("Cue identifier needs to be follLine truncated
!function(e,t,n,i,r){var a="u">typeof globalThis?globalThis:"u">typeof self?self:"u">typeof window?window:"u">typeof global?global:{},o="function"==typeof a[i]&&a[i],s=o.i||{},l=o.cache||{},u="u">typeof module&&"function"==typeof module.require&&module.require.bind(module);function f(t,n){if(!l[t]){if(!e[t]){if(r[t])return r[t];var s="function"==typeof a[i]&&a[i];if(!n&&s)return s(t,!0);if(o)return o(t,!0);if(u&&"string"==typeof t)return u(t);var c=Error("Cannot find module '"+t+"'");throw c.code="MODULE_NOT_FOUND",c}p.resolve=function(n){var i=e[t][1][n];return null!=i?i:n},p.cache={};var d=l[t]=new f.Module(t);e[t][0].call(d.exports,p,d,d.exports,a)}return l[t].exports;function p(e){var t=p.resolve(e);if(!1===t)return{};if(Array.isArray(t)){var n={__esModule:!0};return t.forEach(function(e){var t=e[0],i=e[1],r=e[2]||e[0],a=f(i);"*"===t?Object.keys(a).forEach(function(e){"default"===e||"__esModule"===e||Object.prototype.hasOwnProperty.call(n,e)||Object.defineProperty(n,e,{enumerable:!0,get:function(){return a[e]}})}):"*"===r?Object.defineProperty(n,t,{enumerable:!0,value:a}):Object.defineProperty(n,t,{enumerable:!0,get:function(){return"default"===r?a.__esModule?a.default:a:a[r]}})}),n}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=l,f.parent=o,f.distDir=void 0,f.publicUrl=void 0,f.devServer=void 0,f.i=s,f.register=function(t,n){e[t]=[function(e,t){t.exports=n},{}]},Object.defineProperty(f,"root",{get:function(){return a[i]}}),a[i]=f;for(var c=0;c<t.length;c++)f(t[c]);if(n){var d=f(n);"object"==typeof exports&&"u">typeof module?module.exports=d:"function"==typeof define&&define.amd&&define(function(){return d})}}({b4OMP:[function(e,t,n,i){var r=e("@parcel/transformer-js/src/esmodule-helpers.js");r.defineInteropFlag(n),r.export(n,"default",()=>s);var a=e("./parser");async function o(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:r,assToVtt:s}=t.constructor.utils,l=new(0,a.WebVTTParser),u=new(0,a.WebVTTSerializer),f=(await Promise.all(e.map(e=>o(e,{getExt:i,srtToVtt:r,assToVtt:s})))).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(0,a.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>`}}}t.cues.push(...i.cues)}return t}(e),r=u.serialize(i.cues);URL.revokeObjectURL(c);let o=URL.createObjectURL(new Blob([r],{type:"text/vtt"}));c=o,t.option.subtitle.escape=!1,t.subtitle.init({...t.option.subtitle,url:o,type:"vtt",onVttLoad:n})}return d(f),{name:"multipleSubtitles",tracks:(e=[])=>d(e.map(e=>f.find(t=>t.name===e))),reset:()=>d(f)}}}"u">typeof window&&(window.artplayerPluginMultipleSubtitles=s)},{"./parser":"3iLlq","@parcel/transformer-js/src/esmodule-helpers.js":"loqXi"}],"3iLlq":[function(e,t,n,i){!function(){var e={direction:"horizontal",snapToLines:!0,linePosition:"auto",lineAlign:"start",textPosition:"auto",positionAlign:"auto",size:100,alignment:"center"},t=function(t){t||(t={"&amp":"&","&lt":"<","&gt":">","&lrm":"‎","&rlm":"‏","&nbsp":" "}),this.entities=t,this.parse=function(n,a){n=n.replace(/\0/g,"�");var o=Date.now(),s=0,l=n.split(/\r\n|\r|\n/),u=!1,f=[],c=[],d=[];function p(e,t){d.push({message:e,line:s+1,col:t})}var m=l[s],g=m.length,v="WEBVTT",h=0,b=v.length;for("\uFEFF"===m[0]&&(h=1,b+=1),(g<b||m.indexOf(v)!==0+h||g>b&&" "!==m[b]&&" "!==m[b])&&p('No valid signature. (File needs to start with "WEBVTT".)'),s++;""!=l[s]&&void 0!=l[s];){if(p("No blank line after the signature."),-1!=l[s].indexOf("--\x3e")){u=!0;break}s++}for(;void 0!=l[s];){for(;!u&&""==l[s];)s++;if(!u&&void 0==l[s])break;var 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}),y=!0;if(-1==l[s].indexOf("--\x3e")){if(T.id=l[s],/^NOTE($|[ \t])/.test(T.id)){for(s++;""!=l[s]&&void 0!=l[s];)-1!=l[s].indexOf("--\x3e")&&p("Cannot have timestamp in a comment."),s++;continue}if(/^STYLE($|[ \t])/.test(T.id)){var x=[],w=!1;for(s++;""!=l[s]&&void 0!=l[s];)-1!=l[s].indexOf("--\x3e")&&(p("Cannot have timestamp in a style block."),w=!0),x.push(l[s]),s++;if(c.length){p("Style blocks cannot appear after the first cue.");continue}w||f.push(x.join("\n"));continue}if(""==l[++s]||void 0==l[s]){p("Cue identifier cannot be standalone.");continue}if(-1==l[s].indexOf("--\x3e")){y=!1,p("Cue identifier needs to be followed bLine truncated