feat: update changelog with Parcel to Vite refactor

feat: add danmuku plugin documentation and i18n setup guide

- Created a new documentation file for the danmuku plugin with code examples.
- Added a comprehensive guide for language settings (i18n) including default languages, importing languages, adding new languages, and modifying existing languages.
- Included code snippets for initializing the Artplayer with different language settings.

Add internationalization support for multiple languages in Artplayer

- Introduced Arabic (ar), Czech (cs), Spanish (es), Persian (fa), French (fr), Indonesian (id), Polish (pl), Russian (ru), Turkish (tr), Vietnamese (vi), and Traditional Chinese (zh-tw) translations.
- Created corresponding JavaScript and ES module files for each language containing translated strings for player controls and settings.
- Added a new documentation file for language settings in the project.

feat: add initial implementation of start option page with interactive code execution buttons

feat: add danmuku plugin documentation and i18n setup guide

- Created a new documentation file for the danmuku plugin, providing code examples for usage.
- Added a comprehensive guide for language settings, including default languages, importing languages, adding new languages, and modifying existing languages.
- Included code snippets for initializing the Artplayer with different language settings and importing language files.

refactor: update danmuku worker implementation and remove unused i18n files

- Changed the way the Danmuku class creates a Web Worker by using a worker loader instead of creating a blob.
- Removed Arabic, Czech, Spanish, Persian, French, Indonesian, Polish, Russian, Turkish, Vietnamese, and Traditional Chinese i18n files as they are no longer needed.
- Updated the Vite build configuration to disable banners for inline workers and added a plugin to remove worker banners from generated code.

feat: add danmuku plugin and i18n setup documentation

- Created a new documentation file for the danmuku plugin, providing code examples for usage.
- Added a new documentation file for language settings (i18n), detailing how to set default languages, import languages, and add new languages.
- Included code snippets for initializing the Artplayer with different language settings and examples for modifying existing languages.

feat: add danmuku plugin and i18n setup documentation

- Created a new documentation file for the danmuku plugin with code examples.
- Added a new documentation file for language settings (i18n) including import instructions and examples for setting default and custom languages.
- Updated the i18n documentation to include details on adding and modifying languages.

feat: add danmuku plugin and i18n setup documentation

- Created a new JavaScript file for the danmuku plugin documentation with multiple code execution buttons.
- Added a new JavaScript file for i18n (internationalization) setup documentation, including instructions for language settings, importing languages, and modifying language options.
- Included examples for setting default languages and adding new languages in the i18n documentation.

Refactor code structure for improved readability and maintainability
This commit is contained in:
Harvey Zhao committed 2026-03-07 15:21:34 +08:00
1 parent ddb78cf850
commit 699bf09577
397 files changed
+99776 -8638

No files matched your search

@@ -1,8 +1,7 @@
/*!
* artplayer-plugin-websr.js v1.0.0
* artplayer-plugin-websr.js v1.0.1
* Github: https://github.com/zhw2590582/ArtPlayer
* (c) 2017-2026 Harvey Zhao
* Released under the MIT License.
*/
!function(e,t,r,n,s){var o="u">typeof globalThis?globalThis:"u">typeof self?self:"u">typeof window?window:"u">typeof global?global:{},i="function"==typeof o[n]&&o[n],a=i.i||{},c=i.cache||{},l="u">typeof module&&"function"==typeof module.require&&module.require.bind(module);function u(t,r){if(!c[t]){if(!e[t]){if(s[t])return s[t];var a="function"==typeof o[n]&&o[n];if(!r&&a)return a(t,!0);if(i)return i(t,!0);if(l&&"string"==typeof t)return l(t);var d=Error("Cannot find module '"+t+"'");throw d.code="MODULE_NOT_FOUND",d}h.resolve=function(r){var n=e[t][1][r];return null!=n?n:r},h.cache={};var f=c[t]=new u.Module(t);e[t][0].call(f.exports,h,f,f.exports,o)}return c[t].exports;function h(e){var t=h.resolve(e);if(!1===t)return{};if(Array.isArray(t)){var r={__esModule:!0};return t.forEach(function(e){var t=e[0],n=e[1],s=e[2]||e[0],o=u(n);"*"===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]}})}):"*"===s?Object.defineProperty(r,t,{enumerable:!0,value:o}):Object.defineProperty(r,t,{enumerable:!0,get:function(){return"default"===s?o.__esModule?o.default:o:o[s]}})}),r}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=c,u.parent=i,u.distDir=void 0,u.publicUrl=void 0,u.devServer=void 0,u.i=a,u.register=function(t,r){e[t]=[function(e,t){t.exports=r},{}]},Object.defineProperty(u,"root",{get:function(){return o[n]}}),o[n]=u;for(var d=0;d<t.length;d++)u(t[d]);if(r){var f=u(r);"object"==typeof exports&&"u">typeof module?module.exports=f:"function"==typeof define&&define.amd&&define(function(){return f})}}({hrC3O:[function(e,t,r,n){var s=e("@parcel/transformer-js/src/esmodule-helpers.js"),o=e("@swc/helpers/cjs/_async_to_generator.cjs"),i=e("@swc/helpers/cjs/_type_of.cjs"),a=e("@swc/helpers/cjs/_ts_generator.cjs"),c=e("./Upscaler.js"),l=s.interopDefault(c);window.artplayerPluginWebsr=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{networkSize:"medium",compare:!1,weightsBaseUrl:"/weights",workerUrl:"/worker/main.js",videoScale:2};return function(t){var r=t.template,n=r.$video,s=r.$player,c=document.createElement("canvas");function u(){var e=t.video,r=s.offsetWidth||640,n=s.offsetHeight||360,o=(e.videoWidth||640)/(e.videoHeight||360),i=r,a=n;return r/n>o?i=n*o:a=r/o,{displayWidth:i,displayHeight:a}}if(s.appendChild(c),c.style.position="absolute",c.style.zIndex="11",c.style.pointerEvents="none",c.style.top="50%",c.style.left="50%",c.style.transform="translate(-50%, -50%)",c.style.opacity="0",c.style.transition="opacity 0.2s ease",!l.default||!l.default.isSupported||!l.default.isSupported())return void console.warn("Upscaler is not supported in this environment");var d=new(0,l.default)({networkSize:e.networkSize||"medium",weightsBaseUrl:e.weightsBaseUrl||"/weights",workerUrl:e.workerUrl||"/worker/main.js",videoScale:e.videoScale||2}),f=!1;function h(){return(0,o._)(function(){return(0,a._)(this,function(t){switch(t.label){case 0:if(f)return[2];f=!0,t.label=1;case 1:return t.trys.push([1,4,,5]),[4,new Promise(function(e,t){if(n.readyState>=1)return void e();var r=function(){o(),e()},s=function(){o(),t(Error("Failed to load video metadata"))},o=function(){n.removeEventListener("loadedmetadata",r),n.removeEventListener("error",s)};n.addEventListener("loadedmetadata",r),n.addEventListener("error",s)})];case 2:return t.sent(),[4,d.startRealtimeUpscale(n,c,e.networkSize||d.networkSize)];case 3:return t.sent(),requestAnimationFrame(function(){c.style.opacity="1"}),[3,5];case 4:return console.error("artplayer-plugin-upscaler: failed to start realtime",t.sent()),[3,5];case 5:return[2]}})})()}var p=u(),m=p.displayWidth,v=p.displayHeight;c.style.width=m+"px",c.style.height=v+"px";var g=50,y=!1,w=!!e.compare,b=document.createElement("div");function k(){if(w){var e=u(),t=e.displayWidth,r=e.displayHeight,n="linear-gradient(to right, transparent 0%, transparent ".concat(g,"%, black ").concat(g,"%, black 100%)");c.style.maskImage=n;var o=s.offsetWidth||640,i=s.offsetHeight||360,a=(o-t)/2+t*g/100;b.style.top=(i-r)/2+"px",b.style.left=a+"px",b.style.height=r+"px",b.style.transform="translateX(-50%)"}else c.style.maskImage="none"}function _(e){w&&(y=!0)}function j(e){if(w&&y){var t=s.getBoundingClientRect(),r=u().displayWidth,n=s.offsetWidth||640;g=Math.max(0,Math.min(100,g=(e.clientX-t.left-(n-r)/2)/r*100)),k()}}function E(e){y=!1}return b.style.position="absolute",b.style.width="3px",b.style.backgroundColor="rgba(255, 255, 255, 0.75)",b.style.cursor="ew-resize",b.style.zIndex="12",b.style.pointerEvents="auto",b.style.display=w?"block":"none",b.style.boxShadow="0 0 2px rgba(0, 0, 0, 0.1)",w&&(s.appendChild(b),b.addEventListener("mousedown",_),document.addEventListener("mousemove",j),document.addEventListener("mouseup",E),k()),t.on("destroy",function(){d&&"function"==typeof d.dispose&&d.dispose(),b.removeEventListeLine truncated
!function(e,t){"object"===typeof exports&&"undefined"!==typeof module?module.exports=t():"function"==typeof define&&define.amd?(t.ArtplayerPluginWebsr=t(),define(function(){return t.ArtplayerPluginWebsr})):(e="undefined"!==typeof globalThis?globalThis:e||self).ArtplayerPluginWebsr=t()}(this,function(){"use strict";var e=Object.defineProperty,t=Object.getOwnPropertySymbols,r=Object.prototype.hasOwnProperty,s=Object.prototype.propertyIsEnumerable,i=Math.pow,n=(t,r,s)=>r in t?e(t,r,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[r]=s,o=(e,i)=>{for(var o in i||(i={}))r.call(i,o)&&n(e,o,i[o]);if(t)for(var o of t(i))s.call(i,o)&&n(e,o,i[o]);return e},a=(e,t,r)=>n(e,"symbol"!==typeof t?t+"":t,r),l=(e,t,r)=>new Promise((s,i)=>{var n=e=>{try{a(r.next(e))}catch(t){i(t)}},o=e=>{try{a(r.throw(e))}catch(t){i(t)}},a=e=>e.done?s(e.value):Promise.resolve(e.value).then(n,o);a((r=r.apply(e,t)).next())});const d=class e{static isSupported(){try{const e="undefined"!==typeof Worker,t="undefined"!==typeof OffscreenCanvas||"undefined"!==typeof document&&!!document.createElement("canvas").transferControlToOffscreen,r="undefined"!==typeof Blob;return e&&t&&r}catch(e){return!1}}static isVideoSupported(){try{return"undefined"!==typeof VideoEncoder&&"undefined"!==typeof VideoDecoder}catch(e){return!1}}constructor(t={}){const r=t.weightsBaseUrl||"/weights";this.networks=t.networks||{small:{name:"anime4k/cnn-2x-l",weightsUrl:`${r}/cnn-8.json`},medium:{name:"anime4k/cnn-2x-16",weightsUrl:`${r}/cnn-16.json`},large:{name:"anime4k/cnn-2x-28",weightsUrl:`${r}/cnn-28.json`}},this.weightsBaseUrl=r,this.networkSize=t.networkSize||"medium",this.workerUrl=t.workerUrl||"/worker/main.js",this.timeouts=o(o({},e.DEFAULT_TIMEOUTS),t.timeouts||{}),this.delays=o(o({},e.DEFAULT_DELAYS),t.delays||{}),this.imageScale="number"===typeof t.imageScale&&t.imageScale>0?t.imageScale:2,this.videoScale="number"===typeof t.videoScale&&t.videoScale>0?t.videoScale:2,this.weightsCache=new Map,this.workerInstance=null,this.messageHandlers={},this.progressCallback=null,this.processingType=null,this.realtimeLoopId=null,this.realtimeState=null,this.init()}init({prewarm:t=!0}={}){if(!e.isSupported())throw new Error("Upscaler is not supported in this environment");return t&&this.getWorker().postMessage({cmd:"isSupported"}),this}getWorker(){return this.workerInstance||(this.workerInstance=new Worker(this.workerUrl),this.workerInstance.onmessage=e=>this.handleWorkerMessage(e)),this.workerInstance}static extractProgressValue(e){var t,r,s;const i=null!=(s=null!=(r=null!=(t=e.data)?t:e.progress)?r:e.value)?s:e.percentage;return"number"===typeof i?Math.min(100,Math.max(0,Math.round(i))):null}handleBlobResponse(e){const t="video"===this.processingType?"videoBlob":"imageBlob",r=this.messageHandlers[t];e.data instanceof Blob&&r&&r({[t]:e.data})}requestBlob(){const e="video"===this.processingType?"getVideoBlob":"getImageBlob";this.getWorker().postMessage({cmd:e})}handleWorkerMessage(t){const{data:r}=t;if(!r.cmd)return;const{cmd:s}=r;if("progress"===s){const t=e.extractProgressValue(r);null!==t&&this.progressCallback&&this.progressCallback(t),this.messageHandlers.progress&&this.messageHandlers.progress(r)}else"finished"===s?r.data instanceof Blob?this.handleBlobResponse(r):this.requestBlob():this.messageHandlers[s]&&this.messageHandlers[s](r)}loadWeights(e){return l(this,null,function*(){if(this.validateNetworkSize(e),this.weightsCache.has(e))return this.weightsCache.get(e);const t=this.networks[e],r=yield fetch(t.weightsUrl);if(!r.ok)throw new Error(`Failed to fetch weights: ${r.statusText}`);const s=yield r.json();return this.weightsCache.set(e,s),s})}static loadImageMetadata(e,t){return new Promise((r,s)=>{const i=new Blob([e],{type:t}),n=URL.createObjectURL(i),o=new Image;o.onload=()=>{URL.revokeObjectURL(n),r({width:o.width,height:o.height})},o.onerror=()=>{URL.revokeObjectURL(n),s(new Error("Failed to load image"))},o.src=n})}static loadVideoMetadata(e,t){return new Promise((r,s)=>{const i=URL.createObjectURL(e),n=document.createElement("video");n.src=i;const o=setTimeout(()=>s(new Error("Timeout")),t);n.onloadedmetadata=()=>{clearTimeout(o),URL.revokeObjectURL(i),r({width:n.videoWidth,height:n.videoHeight,duration:n.duration})},n.onerror=()=>{clearTimeout(o),URL.revokeObjectURL(i),s(new Error("Failed to load video"))}})}createOffscreenCanvas(e,t,r=2){const s="number"===typeof r&&r>0?r:1,i=document.createElement("canvas");if(i.width=e*s,i.height=t*s,"function"!==typeof i.transferControlToOffscreen)throw new TypeError("OffscreenCanvas is not supported in this environment");return i.transferControlToOffscreen()}createBlobPromise(e,t){return new Promise((r,s)=>{const i=setTimeout(()=>{this.messageHandlers[e]&&(delete this.messageHandlers[e],s(new Error(`${e} processing timeout`)))},t);this.messageHandlers[e]=t=>{delete this.messageHandlers[e],clearTimeout(i);const n=t[e]||t.data;n instanceof Blob?r(n):s(new Error(`Invalid ${e} format`))}})}validateNetworkSize(e){if(!this.netLine truncated