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,r,o,a,c,i){var s="u">typeof globalThis?globalThis:"u">typeof self?self:"u">typeof window?window:"u">typeof global?global:{},l="function"==typeof s[r]&&s[r],u=l.i||{},f=l.cache||{},d="u">typeof module&&"function"==typeof module.require&&module.require.bind(module);function p(t,n){if(!f[t]){if(!e[t]){if(o[t])return o[t];var a="function"==typeof s[r]&&s[r];if(!n&&a)return a(t,!0);if(l)return l(t,!0);if(d&&"string"==typeof t)return d(t);var c=Error("Cannot find module '"+t+"'");throw c.code="MODULE_NOT_FOUND",c}u.resolve=function(n){var r=e[t][1][n];return null!=r?r:n},u.cache={};var i=f[t]=new p.Module(t);e[t][0].call(i.exports,u,i,i.exports,s)}return f[t].exports;function u(e){var t=u.resolve(e);if(!1===t)return{};if(Array.isArray(t)){var n={__esModule:!0};return t.forEach(function(e){var t=e[0],r=e[1],o=e[2]||e[0],a=p(r);"*"===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]}})}):"*"===o?Object.defineProperty(n,t,{enumerable:!0,value:a}):Object.defineProperty(n,t,{enumerable:!0,get:function(){return"default"===o?a.__esModule?a.default:a:a[o]}})}),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=f,p.parent=l,p.distDir=void 0,p.publicUrl=void 0,p.devServer=void 0,p.i=u,p.register=function(t,n){e[t]=[function(e,t){t.exports=n},{}]},Object.defineProperty(p,"root",{get:function(){return s[r]}}),s[r]=p;for(var w=0;w<t.length;w++)p(t[w]);if(n){var h=p(n);"object"==typeof exports&&"u">typeof module?module.exports=h:"function"==typeof define&&define.amd&&define(function(){return h})}}({"1xnGs":[function(e,t,n,r){var o=e("@parcel/transformer-js/src/esmodule-helpers.js");o.defineInteropFlag(n),o.export(n,"default",function(){return i});var a=e("@swc/helpers/cjs/_async_to_generator.cjs"),c=e("@swc/helpers/cjs/_ts_generator.cjs");function i(e){var t=!1,n=null,r=null,o=function(e){var t=document.querySelector(".art-icon-cast");if(t)switch(e){case"connected":t.style.color="red";break;case"connecting":case"disconnecting":t.style.color="orange";break;default:t.style.color="white"}},i=function(t,n){var r=e.url||t.option.url,o=new window.chrome.cast.media.MediaInfo(r,e.mimeType||({mp4:"video/mp4",webm:"video/webm",ogg:"video/ogg",ogv:"video/ogg",mp3:"audio/mp3",wav:"audio/wav",flv:"video/x-flv",mov:"video/quicktime",avi:"video/x-msvideo",wmv:"video/x-ms-wmv",mpd:"application/dash+xml",m3u8:"application/x-mpegURL"})[r.split("?")[0].split("#")[0].split(".").pop().toLowerCase()]||"application/octet-stream"),a=new window.chrome.cast.media.LoadRequest(o);n.loadMedia(a).then(function(){var n;t.notice.show="Casting started",null==(n=e.onCastStart)||n.call(e)}).catch(function(n){var r;throw t.notice.show="Error casting media",null==(r=e.onError)||r.call(e,n),n})};return function(s){return(0,a._)(function(){return(0,c._)(this,function(l){return s.controls.add({name:"chromecast",position:"right",tooltip:"Chromecast",html:'<i class="art-icon art-icon-cast">'.concat(e.icon||'<svg height="20" width="20" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 576 512"><path d="M512 96H64v99c-13-2-26.4-3-40-3H0V96C0 60.7 28.7 32 64 32H512c35.3 0 64 28.7 64 64V416c0 35.3-28.7 64-64 64H288V456c0-13.6-1-27-3-40H512V96zM24 224c128.1 0 232 103.9 232 232c0 13.3-10.7 24-24 24s-24-10.7-24-24c0-101.6-82.4-184-184-184c-13.3 0-24-10.7-24-24s10.7-24 24-24zm8 192a32 32 0 1 1 0 64 32 32 0 1 1 0-64zM0 344c0-13.3 10.7-24 24-24c75.1 0 136 60.9 136 136c0 13.3-10.7 24-24 24s-24-10.7-24-24c0-48.6-39.4-88-88-88c-13.3 0-24-10.7-24-24z"/></svg>',"</i>"),click:function(){return(0,a._)(function(){var a,l,u,f,d;return(0,c._)(this,function(c){switch(c.label){case 0:if(t)return[3,4];c.label=1;case 1:return c.trys.push([1,3,,4]),[4,new Promise(function(a,c){var i;window.__onGCastApiAvailable=function(i){if(i){var s=window.cast.framework.CastContext.getInstance();s.setOptions({receiverApplicationId:window.chrome.cast.media.DEFAULT_MEDIA_RECEIVER_APP_ID,autoJoinPolicy:window.chrome.cast.AutoJoinPolicy.ORIGIN_SCOPED}),s.addEventListener(window.cast.framework.CastContextEventType.SESSION_STATE_CHANGED,function(t){var a,c,i,s,l,u=window.cast.framework.SessionState;switch(r=t.sessionState,n=t.session,t.sessionState){case u.NO_SESSION:null==(a=e.onStateChange)||a.call(e,"disconnected"),o("disconnected");break;case u.SESSION_STARTING:null==(c=e.onStateChange)||c.call(e,"connecting"),o("connecting");break;case u.SESSION_STARTED:null==(i=e.onStateChange)||i.call(e,"connected"),o("connected");break;case u.SESSION_ENDING:null==(s=e.onStateChange)||s.call(e,"disconnecting"),o("disconnecting");break;case u.SESSION_RESUMED:null==(l=e.onStateChange)||l.call(e,"connected"),o("connected")}}),s.addEventListener(window.cast.framework.CastContextEventType.CAST_STATE_CHANGED,function(t){var n,r,o,a=window.cast.framework.CastState;switch(t.castState){case a.NO_DEVICES_AVALine truncated
!function(e,t,n,r,o){var a="u">typeof globalThis?globalThis:"u">typeof self?self:"u">typeof window?window:"u">typeof global?global:{},c="function"==typeof a[r]&&a[r],i=c.i||{},s=c.cache||{},l="u">typeof module&&"function"==typeof module.require&&module.require.bind(module);function u(t,n){if(!s[t]){if(!e[t]){if(o[t])return o[t];var i="function"==typeof a[r]&&a[r];if(!n&&i)return i(t,!0);if(c)return c(t,!0);if(l&&"string"==typeof t)return l(t);var f=Error("Cannot find module '"+t+"'");throw f.code="MODULE_NOT_FOUND",f}p.resolve=function(n){var r=e[t][1][n];return null!=r?r:n},p.cache={};var d=s[t]=new u.Module(t);e[t][0].call(d.exports,p,d,d.exports,a)}return s[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],r=e[1],o=e[2]||e[0],a=u(r);"*"===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]}})}):"*"===o?Object.defineProperty(n,t,{enumerable:!0,value:a}):Object.defineProperty(n,t,{enumerable:!0,get:function(){return"default"===o?a.__esModule?a.default:a:a[o]}})}),n}return u(t)}}u.isParcelRequire=!0,u.Module=function(e){this.id=e,this.bundle=u,this.require=l,this.exports={}},u.modules=e,u.cache=s,u.parent=c,u.distDir=void 0,u.publicUrl=void 0,u.devServer=void 0,u.i=i,u.register=function(t,n){e[t]=[function(e,t){t.exports=n},{}]},Object.defineProperty(u,"root",{get:function(){return a[r]}}),a[r]=u;for(var f=0;f<t.length;f++)u(t[f]);if(n){var d=u(n);"object"==typeof exports&&"u">typeof module?module.exports=d:"function"==typeof define&&define.amd&&define(function(){return d})}}({"1xnGs":[function(e,t,n,r){var o=e("@parcel/transformer-js/src/esmodule-helpers.js");o.defineInteropFlag(n),o.export(n,"default",function(){return i});var a=e("@swc/helpers/cjs/_async_to_generator.cjs"),c=e("@swc/helpers/cjs/_ts_generator.cjs");function i(e){var t=!1,n=null,r=null,o=function(e){var t=document.querySelector(".art-icon-cast");if(t)switch(e){case"connected":t.style.color="red";break;case"connecting":case"disconnecting":t.style.color="orange";break;default:t.style.color="white"}},i=function(t,n){var r=e.url||t.option.url,o=new window.chrome.cast.media.MediaInfo(r,e.mimeType||({mp4:"video/mp4",webm:"video/webm",ogg:"video/ogg",ogv:"video/ogg",mp3:"audio/mp3",wav:"audio/wav",flv:"video/x-flv",mov:"video/quicktime",avi:"video/x-msvideo",wmv:"video/x-ms-wmv",mpd:"application/dash+xml",m3u8:"application/x-mpegURL"})[r.split("?")[0].split("#")[0].split(".").pop().toLowerCase()]||"application/octet-stream"),a=new window.chrome.cast.media.LoadRequest(o);n.loadMedia(a).then(function(){var n;t.notice.show="Casting started",null==(n=e.onCastStart)||n.call(e)}).catch(function(n){var r;throw t.notice.show="Error casting media",null==(r=e.onError)||r.call(e,n),n})};return function(s){return(0,a._)(function(){return(0,c._)(this,function(l){return s.controls.add({name:"chromecast",position:"right",tooltip:"Chromecast",html:'<i class="art-icon art-icon-cast">'.concat(e.icon||'<svg height="20" width="20" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 576 512"><path d="M512 96H64v99c-13-2-26.4-3-40-3H0V96C0 60.7 28.7 32 64 32H512c35.3 0 64 28.7 64 64V416c0 35.3-28.7 64-64 64H288V456c0-13.6-1-27-3-40H512V96zM24 224c128.1 0 232 103.9 232 232c0 13.3-10.7 24-24 24s-24-10.7-24-24c0-101.6-82.4-184-184-184c-13.3 0-24-10.7-24-24s10.7-24 24-24zm8 192a32 32 0 1 1 0 64 32 32 0 1 1 0-64zM0 344c0-13.3 10.7-24 24-24c75.1 0 136 60.9 136 136c0 13.3-10.7 24-24 24s-24-10.7-24-24c0-48.6-39.4-88-88-88c-13.3 0-24-10.7-24-24z"/></svg>',"</i>"),click:function(){return(0,a._)(function(){var a,l,u,f,d;return(0,c._)(this,function(c){switch(c.label){case 0:if(t)return[3,4];c.label=1;case 1:return c.trys.push([1,3,,4]),[4,new Promise(function(a,c){var i;window.__onGCastApiAvailable=function(i){if(i){var s=window.cast.framework.CastContext.getInstance();s.setOptions({receiverApplicationId:window.chrome.cast.media.DEFAULT_MEDIA_RECEIVER_APP_ID,autoJoinPolicy:window.chrome.cast.AutoJoinPolicy.ORIGIN_SCOPED}),s.addEventListener(window.cast.framework.CastContextEventType.SESSION_STATE_CHANGED,function(t){var a,c,i,s,l,u=window.cast.framework.SessionState;switch(r=t.sessionState,n=t.session,t.sessionState){case u.NO_SESSION:null==(a=e.onStateChange)||a.call(e,"disconnected"),o("disconnected");break;case u.SESSION_STARTING:null==(c=e.onStateChange)||c.call(e,"connecting"),o("connecting");break;case u.SESSION_STARTED:null==(i=e.onStateChange)||i.call(e,"connected"),o("connected");break;case u.SESSION_ENDING:null==(s=e.onStateChange)||s.call(e,"disconnecting"),o("disconnecting");break;case u.SESSION_RESUMED:null==(l=e.onStateChange)||l.call(e,"connected"),o("connected")}}),s.addEventListener(window.cast.framework.CastContextEventType.CAST_STATE_CHANGED,function(t){var n,r,o,a=window.cast.framework.CastState;switch(t.castState){case a.NO_DEVICES_AVAILABLELine truncated