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

+1 -1
View File
@@ -5,4 +5,4 @@
* (c) 2017-2026 Harvey Zack
* Released under the MIT License.
*/
!function(e,t,r,a,n,o,i,l){var d="u">typeof globalThis?globalThis:"u">typeof self?self:"u">typeof window?window:"u">typeof global?global:{},p="function"==typeof d[a]&&d[a],s=p.i||{},u=p.cache||{},c="u">typeof module&&"function"==typeof module.require&&module.require.bind(module);function f(t,r){if(!u[t]){if(!e[t]){if(n[t])return n[t];var o="function"==typeof d[a]&&d[a];if(!r&&o)return o(t,!0);if(p)return p(t,!0);if(c&&"string"==typeof t)return c(t);var i=Error("Cannot find module '"+t+"'");throw i.code="MODULE_NOT_FOUND",i}s.resolve=function(r){var a=e[t][1][r];return null!=a?a:r},s.cache={};var l=u[t]=new f.Module(t);e[t][0].call(l.exports,s,l,l.exports,d)}return u[t].exports;function s(e){var t=s.resolve(e);if(!1===t)return{};if(Array.isArray(t)){var r={__esModule:!0};return t.forEach(function(e){var t=e[0],a=e[1],n=e[2]||e[0],o=f(a);"*"===t?Object.keys(o).forEach(function(e){"default"===e||"__esModule"===e||Object.prototype.hasOwnProperty.call(r,e)||Object.defineProperty(r,e,{enumerable:!0,get:function(){return o[e]}})}):"*"===n?Object.defineProperty(r,t,{enumerable:!0,value:o}):Object.defineProperty(r,t,{enumerable:!0,get:function(){return"default"===n?o.__esModule?o.default:o:o[n]}})}),r}return f(t)}}f.isParcelRequire=!0,f.Module=function(e){this.id=e,this.bundle=f,this.require=c,this.exports={}},f.modules=e,f.cache=u,f.parent=p,f.distDir=void 0,f.publicUrl=void 0,f.devServer=void 0,f.i=s,f.register=function(t,r){e[t]=[function(e,t){t.exports=r},{}]},Object.defineProperty(f,"root",{get:function(){return d[a]}}),d[a]=f;for(var h=0;h<t.length;h++)f(t[h]);if(r){var g=f(r);"object"==typeof exports&&"u">typeof module?module.exports=g:"function"==typeof define&&define.amd&&define(function(){return g})}}({fwWaD:[function(e,t,r,a){var n=e("@parcel/transformer-js/src/esmodule-helpers.js");n.defineInteropFlag(r),n.export(r,"default",()=>l);var o=e("bundle-text:./style.less"),i=n.interopDefault(o);function l(e={}){return t=>{let{$player:r}=t.template,{setStyle:a,append:n,clamp:o,query:i,addClass:l,removeClass:d}=t.constructor.utils,p=`<div class="art-chapter"><div class="art-chapter-inner"><div class="art-progress-hover"></div><div class="art-progress-loaded"></div><div class="art-progress-played"></div></div></div>`,s=[],u=t.query(".art-control-progress-inner"),c=n(u,'<div class="art-chapters"></div>'),f=n(u,'<div class="art-chapter-title"></div>');function h(e=[]){if((s=[],c.textContent="",d(r,"artplayer-plugin-chapter"),Array.isArray(e)&&e.length)&&t.duration){e=e.sort((e,t)=>e.start-t.start);for(let r=0;r<e.length;r++){let a=e[r],n=e[r+1];if(a.end===1/0&&(a.end=t.duration),"number"!=typeof a.start||"number"!=typeof a.end||"string"!=typeof a.title)throw TypeError("Illegal chapter data type");if(a.start<0||a.end>t.duration||a.start>=a.end||n&&a.end>n.start)throw Error("Illegal chapter time point")}e[0].start>0&&e.unshift({start:0,end:e[0].start,title:""}),e[e.length-1].end<t.duration&&e.push({start:e[e.length-1].end,end:t.duration,title:""});for(let t=0;t<e.length-1;t++)e[t].end!==e[t+1].start&&e.splice(t+1,0,{start:e[t].end,end:e[t+1].start,title:""});s=e.map(e=>{let r=n(c,p),a=o(e.start,0,t.duration),l=o(e.end,0,t.duration),d=l-a,s=d/t.duration;return r.dataset.start=a,r.dataset.end=l,r.dataset.duration=d,r.dataset.title=e.title.trim(),r.style.width=`${100*s}%`,{$chapter:r,$hover:i(".art-progress-hover",r),$loaded:i(".art-progress-loaded",r),$played:i(".art-progress-played",r)}}),l(r,"artplayer-plugin-chapter"),t.emit("setBar","loaded",t.loaded||0)}}return t.on("setBar",(e,r)=>{if(s.length)for(let n=0;n<s.length;n++){let{$chapter:o,$loaded:i,$played:l,$hover:d}=s[n],p={hover:d,loaded:i,played:l}[e];if(!p)return;let h=c.clientWidth*r,g=t.duration*r,y=Number.parseFloat(o.dataset.duration),m=Number.parseFloat(o.dataset.start),v=Number.parseFloat(o.dataset.end);if(g<m&&a(p,"width",0),g>v&&a(p,"width","100%"),g>=m&&g<=v){let t=(g-m)/y;a(p,"width",`${100*t}%`),"hover"===e&&h>0&&function({$chapter:e,width:t}){let r=e.dataset.title.trim();if(r){f.textContent=r;let e=f.clientWidth;t<=e/2?a(f,"left",0):t>u.clientWidth-e/2?a(f,"left",`${u.clientWidth-e}px`):a(f,"left",`${t-e/2}px`)}}({$chapter:o,width:h})}}}),t.once("video:loadedmetadata",()=>h(e.chapters)),{name:"artplayerPluginChapter",update:({chapters:e})=>h(e)}}}if("u">typeof document){let e="artplayer-plugin-chapter",t=document.getElementById(e);t||((t=document.createElement("style")).id=e,"loading"===document.readyState?document.addEventListener("DOMContentLoaded",()=>{document.head.appendChild(t)}):(document.head||document.documentElement).appendChild(t)),t.textContent=i.default}"u">typeof window&&(window.artplayerPluginChapter=l)},{"bundle-text:./style.less":"3lhZb","@parcel/transformer-js/src/esmodule-helpers.js":"loqXi"}],"3lhZb":[function(e,t,r,a){t.exports=".artplayer-plugin-chapter .art-control-progress-inner{background-color:#0000!important;height:100%!important}.artplayer-plugin-chapter .art-control-progress-inner>.art-progress-hover,.artplayer-plugin-cLine truncated
!function(e,t,r,a,n){var o="u">typeof globalThis?globalThis:"u">typeof self?self:"u">typeof window?window:"u">typeof global?global:{},i="function"==typeof o[a]&&o[a],l=i.i||{},d=i.cache||{},p="u">typeof module&&"function"==typeof module.require&&module.require.bind(module);function s(t,r){if(!d[t]){if(!e[t]){if(n[t])return n[t];var l="function"==typeof o[a]&&o[a];if(!r&&l)return l(t,!0);if(i)return i(t,!0);if(p&&"string"==typeof t)return p(t);var u=Error("Cannot find module '"+t+"'");throw u.code="MODULE_NOT_FOUND",u}f.resolve=function(r){var a=e[t][1][r];return null!=a?a:r},f.cache={};var c=d[t]=new s.Module(t);e[t][0].call(c.exports,f,c,c.exports,o)}return d[t].exports;function f(e){var t=f.resolve(e);if(!1===t)return{};if(Array.isArray(t)){var r={__esModule:!0};return t.forEach(function(e){var t=e[0],a=e[1],n=e[2]||e[0],o=s(a);"*"===t?Object.keys(o).forEach(function(e){"default"===e||"__esModule"===e||Object.prototype.hasOwnProperty.call(r,e)||Object.defineProperty(r,e,{enumerable:!0,get:function(){return o[e]}})}):"*"===n?Object.defineProperty(r,t,{enumerable:!0,value:o}):Object.defineProperty(r,t,{enumerable:!0,get:function(){return"default"===n?o.__esModule?o.default:o:o[n]}})}),r}return s(t)}}s.isParcelRequire=!0,s.Module=function(e){this.id=e,this.bundle=s,this.require=p,this.exports={}},s.modules=e,s.cache=d,s.parent=i,s.distDir=void 0,s.publicUrl=void 0,s.devServer=void 0,s.i=l,s.register=function(t,r){e[t]=[function(e,t){t.exports=r},{}]},Object.defineProperty(s,"root",{get:function(){return o[a]}}),o[a]=s;for(var u=0;u<t.length;u++)s(t[u]);if(r){var c=s(r);"object"==typeof exports&&"u">typeof module?module.exports=c:"function"==typeof define&&define.amd&&define(function(){return c})}}({fwWaD:[function(e,t,r,a){var n=e("@parcel/transformer-js/src/esmodule-helpers.js");n.defineInteropFlag(r),n.export(r,"default",()=>l);var o=e("bundle-text:./style.less"),i=n.interopDefault(o);function l(e={}){return t=>{let{$player:r}=t.template,{setStyle:a,append:n,clamp:o,query:i,addClass:l,removeClass:d}=t.constructor.utils,p=`<div class="art-chapter"><div class="art-chapter-inner"><div class="art-progress-hover"></div><div class="art-progress-loaded"></div><div class="art-progress-played"></div></div></div>`,s=[],u=t.query(".art-control-progress-inner"),c=n(u,'<div class="art-chapters"></div>'),f=n(u,'<div class="art-chapter-title"></div>');function h(e=[]){if((s=[],c.textContent="",d(r,"artplayer-plugin-chapter"),Array.isArray(e)&&e.length)&&t.duration){e=e.sort((e,t)=>e.start-t.start);for(let r=0;r<e.length;r++){let a=e[r],n=e[r+1];if(a.end===1/0&&(a.end=t.duration),"number"!=typeof a.start||"number"!=typeof a.end||"string"!=typeof a.title)throw TypeError("Illegal chapter data type");if(a.start<0||a.end>t.duration||a.start>=a.end||n&&a.end>n.start)throw Error("Illegal chapter time point")}e[0].start>0&&e.unshift({start:0,end:e[0].start,title:""}),e[e.length-1].end<t.duration&&e.push({start:e[e.length-1].end,end:t.duration,title:""});for(let t=0;t<e.length-1;t++)e[t].end!==e[t+1].start&&e.splice(t+1,0,{start:e[t].end,end:e[t+1].start,title:""});s=e.map(e=>{let r=n(c,p),a=o(e.start,0,t.duration),l=o(e.end,0,t.duration),d=l-a,s=d/t.duration;return r.dataset.start=a,r.dataset.end=l,r.dataset.duration=d,r.dataset.title=e.title.trim(),r.style.width=`${100*s}%`,{$chapter:r,$hover:i(".art-progress-hover",r),$loaded:i(".art-progress-loaded",r),$played:i(".art-progress-played",r)}}),l(r,"artplayer-plugin-chapter"),t.emit("setBar","loaded",t.loaded||0)}}return t.on("setBar",(e,r)=>{if(s.length)for(let n=0;n<s.length;n++){let{$chapter:o,$loaded:i,$played:l,$hover:d}=s[n],p={hover:d,loaded:i,played:l}[e];if(!p)return;let h=c.clientWidth*r,g=t.duration*r,y=Number.parseFloat(o.dataset.duration),m=Number.parseFloat(o.dataset.start),v=Number.parseFloat(o.dataset.end);if(g<m&&a(p,"width",0),g>v&&a(p,"width","100%"),g>=m&&g<=v){let t=(g-m)/y;a(p,"width",`${100*t}%`),"hover"===e&&h>0&&function({$chapter:e,width:t}){let r=e.dataset.title.trim();if(r){f.textContent=r;let e=f.clientWidth;t<=e/2?a(f,"left",0):t>u.clientWidth-e/2?a(f,"left",`${u.clientWidth-e}px`):a(f,"left",`${t-e/2}px`)}}({$chapter:o,width:h})}}}),t.once("video:loadedmetadata",()=>h(e.chapters)),{name:"artplayerPluginChapter",update:({chapters:e})=>h(e)}}}if("u">typeof document){let e="artplayer-plugin-chapter",t=document.getElementById(e);t||((t=document.createElement("style")).id=e,"loading"===document.readyState?document.addEventListener("DOMContentLoaded",()=>{document.head.appendChild(t)}):(document.head||document.documentElement).appendChild(t)),t.textContent=i.default}"u">typeof window&&(window.artplayerPluginChapter=l)},{"bundle-text:./style.less":"3lhZb","@parcel/transformer-js/src/esmodule-helpers.js":"loqXi"}],"3lhZb":[function(e,t,r,a){t.exports=".artplayer-plugin-chapter .art-control-progress-inner{background-color:#0000!important;height:100%!important}.artplayer-plugin-chapter .art-control-progress-inner>.art-progress-hover,.artplayer-plugin-chapterLine truncated