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,i,o,l,a){var d="u">typeof globalThis?globalThis:"u">typeof self?self:"u">typeof window?window:"u">typeof global?global:{},u="function"==typeof d[r]&&d[r],c=u.i||{},p=u.cache||{},f="u">typeof module&&"function"==typeof module.require&&module.require.bind(module);function s(t,n){if(!p[t]){if(!e[t]){if(i[t])return i[t];var o="function"==typeof d[r]&&d[r];if(!n&&o)return o(t,!0);if(u)return u(t,!0);if(f&&"string"==typeof t)return f(t);var l=Error("Cannot find module '"+t+"'");throw l.code="MODULE_NOT_FOUND",l}c.resolve=function(n){var r=e[t][1][n];return null!=r?r:n},c.cache={};var a=p[t]=new s.Module(t);e[t][0].call(a.exports,c,a,a.exports,d)}return p[t].exports;function c(e){var t=c.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],i=e[2]||e[0],o=s(r);"*"===t?Object.keys(o).forEach(function(e){"default"===e||"__esModule"===e||Object.prototype.hasOwnProperty.call(n,e)||Object.defineProperty(n,e,{enumerable:!0,get:function(){return o[e]}})}):"*"===i?Object.defineProperty(n,t,{enumerable:!0,value:o}):Object.defineProperty(n,t,{enumerable:!0,get:function(){return"default"===i?o.__esModule?o.default:o:o[i]}})}),n}return s(t)}}s.isParcelRequire=!0,s.Module=function(e){this.id=e,this.bundle=s,this.require=f,this.exports={}},s.modules=e,s.cache=p,s.parent=u,s.distDir=void 0,s.publicUrl=void 0,s.devServer=void 0,s.i=c,s.register=function(t,n){e[t]=[function(e,t){t.exports=n},{}]},Object.defineProperty(s,"root",{get:function(){return d[r]}}),d[r]=s;for(var m=0;m<t.length;m++)s(t[m]);if(n){var h=s(n);"object"==typeof exports&&"u">typeof module?module.exports=h:"function"==typeof define&&define.amd&&define(function(){return h})}}({fiyFV:[function(e,t,n,r){var i=e("@parcel/transformer-js/src/esmodule-helpers.js");i.defineInteropFlag(n),i.export(n,"default",()=>a);var o=e("bundle-text:./style.less"),l=i.interopDefault(o);function a(e={}){let t={width:480,height:270,fallbackToVideoPiP:!0,placeholder:"Playing in Document Picture-in-Picture",...e};return e=>{let n="documentPictureInPicture"in window&&"function"==typeof window.documentPictureInPicture?.requestWindow,{proxy:r,icons:i,i18n:o,template:{$player:l},constructor:{utils:{append:a,tooltip:d,addClass:u,removeClass:c,sleep:p}}}=e,f={win:null,originalParent:null,originalNext:null,currentDoc:null,placeholder:null};async function s(){if(!n&&t.fallbackToVideoPiP){e.pip=!0,console.warn("[artplayer-plugin-document-pip] Document Picture-in-Picture is not supported, falling back to Video Picture-in-Picture");return}if(!f.win)try{let n=await window.documentPictureInPicture.requestWindow({width:t.width,height:t.height});f.win=n,f.currentDoc=n.document,f.placeholder=document.createElement("div"),f.placeholder.className="artplayer-document-pip-placeholder",f.placeholder.style.cssText="display:flex;justify-content:center;align-items:center;width:100%;height:100%;",f.placeholder.textContent=t.placeholder,f.originalParent=l.parentNode,f.originalNext=l.nextSibling,f.originalParent.insertBefore(f.placeholder,f.originalNext);let i=n.document.createElement("div");i.id="__art_dpip_root",n.document.body.appendChild(i);var r=n.document;let o=r.createElement("style");if(o.textContent=` html, body { margin:0; padding:0; width:100%; height:100%; background:#000; overflow:hidden; } #__art_dpip_root { position:absolute; inset:0; display:flex; } #__art_dpip_root > * { width:100% !important; height:100% !important; } `,r.head.appendChild(o),!r.querySelector('meta[name="viewport"]')){let e=r.createElement("meta");e.name="viewport",e.content="width=device-width,initial-scale=1",r.head.appendChild(e)}try{document.querySelectorAll('link[rel="stylesheet"]').forEach(e=>{let t=r.createElement("link");t.rel="stylesheet",t.href=e.href,e.media&&(t.media=e.media),e.crossOrigin&&(t.crossOrigin=e.crossOrigin),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),r.head.appendChild(t)})}catch{}try{document.querySelectorAll("style").forEach(e=>{let t=r.createElement("style");t.textContent=e.textContent,r.head.appendChild(t)})}catch{}let a=n.document.adoptNode(l);i.appendChild(a),f.currentDoc=n.document;let d=()=>e.resize?.(),c=()=>m();n.addEventListener("resize",d),n.addEventListener("pagehide",c),n.addEventListener("unload",c),f.cleanup=()=>{n.removeEventListener("resize",d),n.removeEventListener("pagehide",c),n.removeEventListener("unload",c)},u(l,"artplayer-document-pip"),e.events.bindGlobalEvents?.(),e.emit("document-pip",!0),await p(100),e.emit("resize")}catch(t){e.notice.show="Document Picture-in-Picture open failed",console.warn("[artplayer-plugin-document-pip] open failed:",t)}}async function m(){if(f.win)try{f.cleanup?.(),function(){if(!f.placeholder)return;let e=f.placeholder.ownerDocument||document,t=e.adoptNode(l);f.originalParent.insertBefore(t,f.placeholder),f.placeholder.remove(),f.placeholder=null,f.currentDoc=e}(),f.win.close(),f.win=null,c(l,"artplayer-document-pip"),e.events.bindGlobalEvents?.(),e.emit("docuLine truncated
!function(e,t,n,r,i){var o="u">typeof globalThis?globalThis:"u">typeof self?self:"u">typeof window?window:"u">typeof global?global:{},l="function"==typeof o[r]&&o[r],a=l.i||{},d=l.cache||{},u="u">typeof module&&"function"==typeof module.require&&module.require.bind(module);function c(t,n){if(!d[t]){if(!e[t]){if(i[t])return i[t];var a="function"==typeof o[r]&&o[r];if(!n&&a)return a(t,!0);if(l)return l(t,!0);if(u&&"string"==typeof t)return u(t);var p=Error("Cannot find module '"+t+"'");throw p.code="MODULE_NOT_FOUND",p}s.resolve=function(n){var r=e[t][1][n];return null!=r?r:n},s.cache={};var f=d[t]=new c.Module(t);e[t][0].call(f.exports,s,f,f.exports,o)}return d[t].exports;function s(e){var t=s.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],i=e[2]||e[0],o=c(r);"*"===t?Object.keys(o).forEach(function(e){"default"===e||"__esModule"===e||Object.prototype.hasOwnProperty.call(n,e)||Object.defineProperty(n,e,{enumerable:!0,get:function(){return o[e]}})}):"*"===i?Object.defineProperty(n,t,{enumerable:!0,value:o}):Object.defineProperty(n,t,{enumerable:!0,get:function(){return"default"===i?o.__esModule?o.default:o:o[i]}})}),n}return c(t)}}c.isParcelRequire=!0,c.Module=function(e){this.id=e,this.bundle=c,this.require=u,this.exports={}},c.modules=e,c.cache=d,c.parent=l,c.distDir=void 0,c.publicUrl=void 0,c.devServer=void 0,c.i=a,c.register=function(t,n){e[t]=[function(e,t){t.exports=n},{}]},Object.defineProperty(c,"root",{get:function(){return o[r]}}),o[r]=c;for(var p=0;p<t.length;p++)c(t[p]);if(n){var f=c(n);"object"==typeof exports&&"u">typeof module?module.exports=f:"function"==typeof define&&define.amd&&define(function(){return f})}}({fiyFV:[function(e,t,n,r){var i=e("@parcel/transformer-js/src/esmodule-helpers.js");i.defineInteropFlag(n),i.export(n,"default",()=>a);var o=e("bundle-text:./style.less"),l=i.interopDefault(o);function a(e={}){let t={width:480,height:270,fallbackToVideoPiP:!0,placeholder:"Playing in Document Picture-in-Picture",...e};return e=>{let n="documentPictureInPicture"in window&&"function"==typeof window.documentPictureInPicture?.requestWindow,{proxy:r,icons:i,i18n:o,template:{$player:l},constructor:{utils:{append:a,tooltip:d,addClass:u,removeClass:c,sleep:p}}}=e,f={win:null,originalParent:null,originalNext:null,currentDoc:null,placeholder:null};async function s(){if(!n&&t.fallbackToVideoPiP){e.pip=!0,console.warn("[artplayer-plugin-document-pip] Document Picture-in-Picture is not supported, falling back to Video Picture-in-Picture");return}if(!f.win)try{let n=await window.documentPictureInPicture.requestWindow({width:t.width,height:t.height});f.win=n,f.currentDoc=n.document,f.placeholder=document.createElement("div"),f.placeholder.className="artplayer-document-pip-placeholder",f.placeholder.style.cssText="display:flex;justify-content:center;align-items:center;width:100%;height:100%;",f.placeholder.textContent=t.placeholder,f.originalParent=l.parentNode,f.originalNext=l.nextSibling,f.originalParent.insertBefore(f.placeholder,f.originalNext);let i=n.document.createElement("div");i.id="__art_dpip_root",n.document.body.appendChild(i);var r=n.document;let o=r.createElement("style");if(o.textContent=` html, body { margin:0; padding:0; width:100%; height:100%; background:#000; overflow:hidden; } #__art_dpip_root { position:absolute; inset:0; display:flex; } #__art_dpip_root > * { width:100% !important; height:100% !important; } `,r.head.appendChild(o),!r.querySelector('meta[name="viewport"]')){let e=r.createElement("meta");e.name="viewport",e.content="width=device-width,initial-scale=1",r.head.appendChild(e)}try{document.querySelectorAll('link[rel="stylesheet"]').forEach(e=>{let t=r.createElement("link");t.rel="stylesheet",t.href=e.href,e.media&&(t.media=e.media),e.crossOrigin&&(t.crossOrigin=e.crossOrigin),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),r.head.appendChild(t)})}catch{}try{document.querySelectorAll("style").forEach(e=>{let t=r.createElement("style");t.textContent=e.textContent,r.head.appendChild(t)})}catch{}let a=n.document.adoptNode(l);i.appendChild(a),f.currentDoc=n.document;let d=()=>e.resize?.(),c=()=>m();n.addEventListener("resize",d),n.addEventListener("pagehide",c),n.addEventListener("unload",c),f.cleanup=()=>{n.removeEventListener("resize",d),n.removeEventListener("pagehide",c),n.removeEventListener("unload",c)},u(l,"artplayer-document-pip"),e.events.bindGlobalEvents?.(),e.emit("document-pip",!0),await p(100),e.emit("resize")}catch(t){e.notice.show="Document Picture-in-Picture open failed",console.warn("[artplayer-plugin-document-pip] open failed:",t)}}async function m(){if(f.win)try{f.cleanup?.(),function(){if(!f.placeholder)return;let e=f.placeholder.ownerDocument||document,t=e.adoptNode(l);f.originalParent.insertBefore(t,f.placeholder),f.placeholder.remove(),f.placeholder=null,f.currentDoc=e}(),f.win.close(),f.win=null,c(l,"artplayer-document-pip"),e.events.bindGlobalEvents?.(),e.emit("document-pLine truncated