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,s,i,a,r,n,o){var h="u">typeof globalThis?globalThis:"u">typeof self?self:"u">typeof window?window:"u">typeof global?global:{},d="function"==typeof h[i]&&h[i],l=d.i||{},c=d.cache||{},u="u">typeof module&&"function"==typeof module.require&&module.require.bind(module);function m(t,s){if(!c[t]){if(!e[t]){if(a[t])return a[t];var r="function"==typeof h[i]&&h[i];if(!s&&r)return r(t,!0);if(d)return d(t,!0);if(u&&"string"==typeof t)return u(t);var n=Error("Cannot find module '"+t+"'");throw n.code="MODULE_NOT_FOUND",n}l.resolve=function(s){var i=e[t][1][s];return null!=i?i:s},l.cache={};var o=c[t]=new m.Module(t);e[t][0].call(o.exports,l,o,o.exports,h)}return c[t].exports;function l(e){var t=l.resolve(e);if(!1===t)return{};if(Array.isArray(t)){var s={__esModule:!0};return t.forEach(function(e){var t=e[0],i=e[1],a=e[2]||e[0],r=m(i);"*"===t?Object.keys(r).forEach(function(e){"default"===e||"__esModule"===e||Object.prototype.hasOwnProperty.call(s,e)||Object.defineProperty(s,e,{enumerable:!0,get:function(){return r[e]}})}):"*"===a?Object.defineProperty(s,t,{enumerable:!0,value:r}):Object.defineProperty(s,t,{enumerable:!0,get:function(){return"default"===a?r.__esModule?r.default:r:r[a]}})}),s}return m(t)}}m.isParcelRequire=!0,m.Module=function(e){this.id=e,this.bundle=m,this.require=u,this.exports={}},m.modules=e,m.cache=c,m.parent=d,m.distDir=void 0,m.publicUrl=void 0,m.devServer=void 0,m.i=l,m.register=function(t,s){e[t]=[function(e,t){t.exports=s},{}]},Object.defineProperty(m,"root",{get:function(){return h[i]}}),h[i]=m;for(var _=0;_<t.length;_++)m(t[_]);if(s){var v=m(s);"object"==typeof exports&&"u">typeof module?module.exports=v:"function"==typeof define&&define.amd&&define(function(){return v})}}({bm4Y0:[function(e,t,s,i){var a=e("@parcel/transformer-js/src/esmodule-helpers.js");a.defineInteropFlag(s),a.export(s,"default",()=>o);var r=e("./jassub.es.js"),n=a.interopDefault(r);function o(e){return t=>{let s=new(0,n.default)({video:t.video,...e});return s._canvasParent.style.zIndex=20,t.on("destroy",()=>{s.destroy()}),{name:"artplayerPluginJassub",instance:s}}}"u">typeof window&&(window.artplayerPluginJassub=o)},{"./jassub.es.js":"kL36e","@parcel/transformer-js/src/esmodule-helpers.js":"loqXi"}],kL36e:[function(e,t,s,i){var a=e("@parcel/transformer-js/src/esmodule-helpers.js");a.defineInteropFlag(s),a.export(s,"default",()=>o),"u">typeof HTMLVideoElement&&!("requestVideoFrameCallback"in HTMLVideoElement.prototype)&&"getVideoPlaybackQuality"in HTMLVideoElement.prototype&&(HTMLVideoElement.prototype._rvfcpolyfillmap={},HTMLVideoElement.prototype.requestVideoFrameCallback=function(e){let t=performance.now(),s=this.getVideoPlaybackQuality(),i=this.mozPresentedFrames||this.mozPaintedFrames||s.totalVideoFrames-s.droppedVideoFrames,a=(r,n)=>{let o=this.getVideoPlaybackQuality(),h=this.mozPresentedFrames||this.mozPaintedFrames||o.totalVideoFrames-o.droppedVideoFrames;if(h>i){let i=this.mozFrameDelay||o.totalFrameDelay-s.totalFrameDelay||0,a=n-r;e(n,{presentationTime:n+1e3*i,expectedDisplayTime:n+a,width:this.videoWidth,height:this.videoHeight,mediaTime:Math.max(0,this.currentTime||0)+a/1e3,presentedFrames:h,processingDuration:i}),delete this._rvfcpolyfillmap[t]}else this._rvfcpolyfillmap[t]=requestAnimationFrame(e=>a(n,e))};return this._rvfcpolyfillmap[t]=requestAnimationFrame(e=>a(t,e)),t},HTMLVideoElement.prototype.cancelVideoFrameCallback=function(e){cancelAnimationFrame(this._rvfcpolyfillmap[e]),delete this._rvfcpolyfillmap[e]});let r={bt709:"BT709",bt470bg:"BT601",smpte170m:"BT601"},n={BT601:{BT709:"1.0863 -0.0723 -0.014 0 0 0.0965 0.8451 0.0584 0 0 -0.0141 -0.0277 1.0418"},BT709:{BT601:"0.9137 0.0784 0.0079 0 0 -0.1049 1.1722 -0.0671 0 0 0.0096 0.0322 0.9582"},FCC:{BT709:"1.0873 -0.0736 -0.0137 0 0 0.0974 0.8494 0.0531 0 0 -0.0127 -0.0251 1.0378",BT601:"1.001 -0.0008 -0.0002 0 0 0.0009 1.005 -0.006 0 0 0.0013 0.0027 0.996"},SMPTE240M:{BT709:"0.9993 0.0006 0.0001 0 0 -0.0004 0.9812 0.0192 0 0 -0.0034 -0.0114 1.0148",BT601:"0.913 0.0774 0.0096 0 0 -0.1051 1.1508 -0.0456 0 0 0.0063 0.0207 0.973"}};class o extends EventTarget{constructor(e){if(super(),!globalThis.Worker)throw this.destroy("Worker not supported");if(!e)throw this.destroy("No options provided");this._loaded=new Promise(e=>{this._init=e});let t=o._test();if(this._onDemandRender="requestVideoFrameCallback"in HTMLVideoElement.prototype&&(e.onDemandRender??!0),this._offscreenRender="transferControlToOffscreen"in HTMLCanvasElement.prototype&&!e.canvas&&(e.offscreenRender??!0),this.timeOffset=e.timeOffset||0,this._video=e.video,this._videoHeight=0,this._videoWidth=0,this._videoColorSpace=null,this._canvas=e.canvas,this._video&&!this._canvas)this._canvasParent=document.createElement("div"),this._canvasParent.className="JASSUB",this._canvasParent.style.position="relative",this._canvas=this._createCanvas(),this._video.insertAdjacentElement("afterend",this._canvasParent);else if(!this._canvas)throw this.destroy("Don't know where to render: you should giLine truncated
!function(e,t,s,i,a){var r="u">typeof globalThis?globalThis:"u">typeof self?self:"u">typeof window?window:"u">typeof global?global:{},n="function"==typeof r[i]&&r[i],o=n.i||{},h=n.cache||{},d="u">typeof module&&"function"==typeof module.require&&module.require.bind(module);function l(t,s){if(!h[t]){if(!e[t]){if(a[t])return a[t];var o="function"==typeof r[i]&&r[i];if(!s&&o)return o(t,!0);if(n)return n(t,!0);if(d&&"string"==typeof t)return d(t);var c=Error("Cannot find module '"+t+"'");throw c.code="MODULE_NOT_FOUND",c}m.resolve=function(s){var i=e[t][1][s];return null!=i?i:s},m.cache={};var u=h[t]=new l.Module(t);e[t][0].call(u.exports,m,u,u.exports,r)}return h[t].exports;function m(e){var t=m.resolve(e);if(!1===t)return{};if(Array.isArray(t)){var s={__esModule:!0};return t.forEach(function(e){var t=e[0],i=e[1],a=e[2]||e[0],r=l(i);"*"===t?Object.keys(r).forEach(function(e){"default"===e||"__esModule"===e||Object.prototype.hasOwnProperty.call(s,e)||Object.defineProperty(s,e,{enumerable:!0,get:function(){return r[e]}})}):"*"===a?Object.defineProperty(s,t,{enumerable:!0,value:r}):Object.defineProperty(s,t,{enumerable:!0,get:function(){return"default"===a?r.__esModule?r.default:r:r[a]}})}),s}return l(t)}}l.isParcelRequire=!0,l.Module=function(e){this.id=e,this.bundle=l,this.require=d,this.exports={}},l.modules=e,l.cache=h,l.parent=n,l.distDir=void 0,l.publicUrl=void 0,l.devServer=void 0,l.i=o,l.register=function(t,s){e[t]=[function(e,t){t.exports=s},{}]},Object.defineProperty(l,"root",{get:function(){return r[i]}}),r[i]=l;for(var c=0;c<t.length;c++)l(t[c]);if(s){var u=l(s);"object"==typeof exports&&"u">typeof module?module.exports=u:"function"==typeof define&&define.amd&&define(function(){return u})}}({bm4Y0:[function(e,t,s,i){var a=e("@parcel/transformer-js/src/esmodule-helpers.js");a.defineInteropFlag(s),a.export(s,"default",()=>o);var r=e("./jassub.es.js"),n=a.interopDefault(r);function o(e){return t=>{let s=new(0,n.default)({video:t.video,...e});return s._canvasParent.style.zIndex=20,t.on("destroy",()=>{s.destroy()}),{name:"artplayerPluginJassub",instance:s}}}"u">typeof window&&(window.artplayerPluginJassub=o)},{"./jassub.es.js":"kL36e","@parcel/transformer-js/src/esmodule-helpers.js":"loqXi"}],kL36e:[function(e,t,s,i){var a=e("@parcel/transformer-js/src/esmodule-helpers.js");a.defineInteropFlag(s),a.export(s,"default",()=>o),"u">typeof HTMLVideoElement&&!("requestVideoFrameCallback"in HTMLVideoElement.prototype)&&"getVideoPlaybackQuality"in HTMLVideoElement.prototype&&(HTMLVideoElement.prototype._rvfcpolyfillmap={},HTMLVideoElement.prototype.requestVideoFrameCallback=function(e){let t=performance.now(),s=this.getVideoPlaybackQuality(),i=this.mozPresentedFrames||this.mozPaintedFrames||s.totalVideoFrames-s.droppedVideoFrames,a=(r,n)=>{let o=this.getVideoPlaybackQuality(),h=this.mozPresentedFrames||this.mozPaintedFrames||o.totalVideoFrames-o.droppedVideoFrames;if(h>i){let i=this.mozFrameDelay||o.totalFrameDelay-s.totalFrameDelay||0,a=n-r;e(n,{presentationTime:n+1e3*i,expectedDisplayTime:n+a,width:this.videoWidth,height:this.videoHeight,mediaTime:Math.max(0,this.currentTime||0)+a/1e3,presentedFrames:h,processingDuration:i}),delete this._rvfcpolyfillmap[t]}else this._rvfcpolyfillmap[t]=requestAnimationFrame(e=>a(n,e))};return this._rvfcpolyfillmap[t]=requestAnimationFrame(e=>a(t,e)),t},HTMLVideoElement.prototype.cancelVideoFrameCallback=function(e){cancelAnimationFrame(this._rvfcpolyfillmap[e]),delete this._rvfcpolyfillmap[e]});let r={bt709:"BT709",bt470bg:"BT601",smpte170m:"BT601"},n={BT601:{BT709:"1.0863 -0.0723 -0.014 0 0 0.0965 0.8451 0.0584 0 0 -0.0141 -0.0277 1.0418"},BT709:{BT601:"0.9137 0.0784 0.0079 0 0 -0.1049 1.1722 -0.0671 0 0 0.0096 0.0322 0.9582"},FCC:{BT709:"1.0873 -0.0736 -0.0137 0 0 0.0974 0.8494 0.0531 0 0 -0.0127 -0.0251 1.0378",BT601:"1.001 -0.0008 -0.0002 0 0 0.0009 1.005 -0.006 0 0 0.0013 0.0027 0.996"},SMPTE240M:{BT709:"0.9993 0.0006 0.0001 0 0 -0.0004 0.9812 0.0192 0 0 -0.0034 -0.0114 1.0148",BT601:"0.913 0.0774 0.0096 0 0 -0.1051 1.1508 -0.0456 0 0 0.0063 0.0207 0.973"}};class o extends EventTarget{constructor(e){if(super(),!globalThis.Worker)throw this.destroy("Worker not supported");if(!e)throw this.destroy("No options provided");this._loaded=new Promise(e=>{this._init=e});let t=o._test();if(this._onDemandRender="requestVideoFrameCallback"in HTMLVideoElement.prototype&&(e.onDemandRender??!0),this._offscreenRender="transferControlToOffscreen"in HTMLCanvasElement.prototype&&!e.canvas&&(e.offscreenRender??!0),this.timeOffset=e.timeOffset||0,this._video=e.video,this._videoHeight=0,this._videoWidth=0,this._videoColorSpace=null,this._canvas=e.canvas,this._video&&!this._canvas)this._canvasParent=document.createElement("div"),this._canvasParent.className="JASSUB",this._canvasParent.style.position="relative",this._canvas=this._createCanvas(),this._video.insertAdjacentElement("afterend",this._canvasParent);else if(!this._canvas)throw this.destroy("Don't know where to render: you should give vidLine truncated