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-multiple-subtitles.js v1.1.0
* artplayer-plugin-multiple-subtitles.js v1.1.1
* Github: https://github.com/zhw2590582/ArtPlayer
* (c) 2017-2026 Harvey Zhao
* Released under the MIT License.
*/
!function(e,t,n,r,i){var o="u">typeof globalThis?globalThis:"u">typeof self?self:"u">typeof window?window:"u">typeof global?global:{},a="function"==typeof o[r]&&o[r],s=a.i||{},c=a.cache||{},l="u">typeof module&&"function"==typeof module.require&&module.require.bind(module);function u(t,n){if(!c[t]){if(!e[t]){if(i[t])return i[t];var s="function"==typeof o[r]&&o[r];if(!n&&s)return s(t,!0);if(a)return a(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=c[t]=new u.Module(t);e[t][0].call(d.exports,p,d,d.exports,o)}return c[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],i=e[2]||e[0],o=u(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 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=a,u.distDir=void 0,u.publicUrl=void 0,u.devServer=void 0,u.i=s,u.register=function(t,n){e[t]=[function(e,t){t.exports=n},{}]},Object.defineProperty(u,"root",{get:function(){return o[r]}}),o[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})}}({bNEbP:[function(e,t,n,r){var i=e("@parcel/transformer-js/src/esmodule-helpers.js");i.defineInteropFlag(n),i.export(n,"default",function(){return f});var o=e("@swc/helpers/cjs/_async_to_generator.cjs"),a=e("@swc/helpers/cjs/_object_spread.cjs"),s=e("@swc/helpers/cjs/_object_spread_props.cjs"),c=e("@swc/helpers/cjs/_to_consumable_array.cjs"),l=e("@swc/helpers/cjs/_ts_generator.cjs"),u=e("./parser");function f(e){var t=e.subtitles,n=void 0===t?[]:t;return function(e){return(0,o._)(function(){var t,r,i,f,d,p,v,h,m;function b(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],n=function(e){for(var t=new(0,u.WebVTTParser)().parse("","metadata"),n=0;n<e.length;n++){var r,i=e[n];if(!i.updated){i.updated=!0;for(var o=0;o<i.cues.length;o++)for(var a=i.cues[o],s=0;s<a.tree.children.length;s++){var l=a.tree.children[s];l.value='<div class="art-subtitle-'.concat(i.name,'">').concat(l.value,"</div>")}}(r=t.cues).push.apply(r,(0,c._)(i.cues))}return t}(t),i=v.serialize(n.cues);URL.revokeObjectURL(m);var o=URL.createObjectURL(new Blob([i],{type:"text/vtt"}));m=o,e.option.subtitle.escape=!1,e.subtitle.init((0,s._)((0,a._)({},e.option.subtitle),{url:o,type:"vtt",onVttLoad:r}))}return(0,l._)(this,function(a){switch(a.label){case 0:return r=(t=e.constructor.utils).unescape,i=t.getExt,f=t.srtToVtt,d=t.assToVtt,p=new(0,u.WebVTTParser),v=new(0,u.WebVTTSerializer),[4,Promise.all(n.map(function(e){return function(e,t){return(0,o._)(function(e,t){var n,r,i,o,a;return(0,l._)(this,function(s){switch(s.label){case 0:return n=t.getExt,r=t.srtToVtt,i=t.assToVtt,[4,fetch(e.url)];case 1:return[4,s.sent().arrayBuffer()];case 2:switch(o=s.sent(),a=new TextDecoder(e.encoding||"utf-8").decode(o),e.type||n(e.url)){case"srt":return[2,r(a)];case"ass":return[2,i(a)];case"vtt":return[2,a];default:return[2,""]}}})}).apply(this,arguments)}(e,{getExt:i,srtToVtt:f,assToVtt:d})}))];case 1:return h=a.sent().map(function(e,t){var r=p.parse(e,"metadata");return r.url=n[t].url,r.name=n[t].name,r}),m="",b(h),[2,{name:"multipleSubtitles",tracks:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return b(e.map(function(e){return h.find(function(t){return t.name===e})}))},reset:function(){return b(h)}}]}})})()}}"u">typeof window&&(window.artplayerPluginMultipleSubtitles=f)},{"@swc/helpers/cjs/_async_to_generator.cjs":"cZn0e","@swc/helpers/cjs/_object_spread.cjs":"kyoEj","@swc/helpers/cjs/_object_spread_props.cjs":"3G1wX","@swc/helpers/cjs/_to_consumable_array.cjs":"i81N6","@swc/helpers/cjs/_ts_generator.cjs":"eltGh","./parser":"hxyrW","@parcel/transformer-js/src/esmodule-helpers.js":"qpMMf"}],cZn0e:[function(e,t,n,r){"use strict";function i(e,t,n,r,i,o,a){try{var s=e[o](a),c=s.value}catch(e){n(e);return}s.done?t(c):Promise.resolve(c).then(r,i)}n._=function(e){return function(){var t=this,n=arguments;return new Promise(function(r,o){var a=e.apply(t,n);function s(e){i(a,r,o,s,c,"next",e)}function c(e){i(a,r,o,s,c,"throw",e)}s(void 0)})}}},{}],kyoEj:[function(e,t,n,r){"use strict";var i=e("9f9b8a24218ee51e");n._=function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){returLine truncated
!function(e,t){"object"===typeof exports&&"undefined"!==typeof module?module.exports=t():"function"==typeof define&&define.amd?(t.ArtplayerPluginMultipleSubtitles=t(),define(function(){return t.ArtplayerPluginMultipleSubtitles})):(e="undefined"!==typeof globalThis?globalThis:e||self).ArtplayerPluginMultipleSubtitles=t()}(this,function(){"use strict";var e=Object.defineProperty,t=Object.defineProperties,n=Object.getOwnPropertyDescriptors,i=Object.getOwnPropertySymbols,a=Object.prototype.hasOwnProperty,r=Object.prototype.propertyIsEnumerable,s=(t,n,i)=>n in t?e(t,n,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[n]=i,o=(e,t)=>{for(var n in t||(t={}))a.call(t,n)&&s(e,n,t[n]);if(i)for(var n of i(t))r.call(t,n)&&s(e,n,t[n]);return e},l=(e,t,n)=>new Promise((i,a)=>{var r=e=>{try{o(n.next(e))}catch(t){a(t)}},s=e=>{try{o(n.throw(e))}catch(t){a(t)}},o=e=>e.done?i(e.value):Promise.resolve(e.value).then(r,s);o((n=n.apply(e,t)).next())}),f={direction:"horizontal",snapToLines:!0,linePosition:"auto",lineAlign:"start",textPosition:"auto",positionAlign:"auto",size:100,alignment:"center"},u=function(e){e||(e={"&amp":"&","&lt":"<","&gt":">","&lrm":"\u200e","&rlm":"\u200f","&nbsp":"\xa0"}),this.entities=e,this.parse=function(t,n){t=t.replace(/\0/g,"\ufffd");var i=Date.now(),a=0,r=t.split(/\r\n|\r|\n/),s=!1,o=[],l=[],u=[];function p(e,t){u.push({message:e,line:a+1,col:t})}var m=r[a],g=m.length,h="WEBVTT",v=0,b=6;for("\ufeff"===m[0]&&(v=1,b+=1),(g<b||m.indexOf(h)!==0+v||g>b&&" "!==m[b]&&"\t"!==m[b])&&p('No valid signature. (File needs to start with "WEBVTT".)'),a++;""!=r[a]&&void 0!=r[a];){if(p("No blank line after the signature."),-1!=r[a].indexOf("--\x3e")){s=!0;break}a++}for(;void 0!=r[a];){for(var x;!s&&""==r[a];)a++;if(!s&&void 0==r[a])break;x=Object.assign({},f,{id:"",startTime:0,endTime:0,pauseOnExit:!1,direction:"horizontal",snapToLines:!0,linePosition:"auto",lineAlign:"start",textPosition:"auto",positionAlign:"auto",size:100,alignment:"center",text:"",tree:null});var T=!0;if(-1==r[a].indexOf("--\x3e")){if(x.id=r[a],/^NOTE($|[ \t])/.test(x.id)){for(a++;""!=r[a]&&void 0!=r[a];)-1!=r[a].indexOf("--\x3e")&&p("Cannot have timestamp in a comment."),a++;continue}if(/^STYLE($|[ \t])/.test(x.id)){var y=[],w=!1;for(a++;""!=r[a]&&void 0!=r[a];)-1!=r[a].indexOf("--\x3e")&&(p("Cannot have timestamp in a style block."),w=!0),y.push(r[a]),a++;if(l.length){p("Style blocks cannot appear after the first cue.");continue}w||o.push(y.join("\n"));continue}if(""==r[++a]||void 0==r[a]){p("Cue identifier cannot be standalone.");continue}if(-1==r[a].indexOf("--\x3e")){T=!1,p("Cue identifier needs to be followed by timestamp.");continue}}s=!1;var O=new c(r[a],p),P=0;if(l.length>0&&(P=l[l.length-1].startTime),!T||O.parse(x,P)){for(a++;""!=r[a]&&void 0!=r[a];){if(-1!=r[a].indexOf("--\x3e")){p("Blank line missing before cue."),s=!0;break}""!=x.text&&(x.text+="\n"),x.text+=r[a],a++}var I=new d(x.text,p,n,e);x.tree=I.parse(x.startTime,x.endTime),l.push(x)}else for(x=null,a++;""!=r[a]&&void 0!=r[a];){if(-1!=r[a].indexOf("--\x3e")){s=!0;break}a++}}return l.sort(function(e,t){return e.startTime<t.startTime?-1:e.startTime>t.startTime?1:e.endTime>t.endTime?-1:e.endTime<t.endTime?1:0}),{cues:l,errors:u,time:Date.now()-i,styles:o}}},c=function(e,t){var n=/[\u0020\t\f]/,i=/[^\u0020\t\f]/,a=(e=e,0),r=function(e){t(e,a+1)};function s(t){for(;void 0!=e[a]&&t.test(e[a]);)a++}function o(t){for(var n="";void 0!=e[a]&&t.test(e[a]);)n+=e[a],a++;return n}function l(){var t,n,i,s,l="minutes";if(void 0!=e[a])if(/\d/.test(e[a]))if(((t=o(/\d/)).length>2||parseInt(t,10)>59)&&(l="hours"),":"==e[a])if(a++,2==(n=o(/\d/)).length){if("hours"==l||":"==e[a]){if(":"!=e[a])return void r("No seconds found or minutes is greater than 59.");if(a++,2!=(i=o(/\d/)).length)return void r("Must be exactly two digits.")}else{if(2!=t.length)return void r("Must be exactly two digits.");i=n,n=t,t="0"}if("."==e[a])if(a++,3==(s=o(/\d/)).length)if(parseInt(n,10)>59)r("You cannot have more than 59 minutes.");else{if(!(parseInt(i,10)>59))return 60*parseInt(t,10)*60+60*parseInt(n,10)+parseInt(i,10)+parseInt(s,10)/1e3;r("You cannot have more than 59 seconds.")}else r("Milliseconds must be given in three digits.");else r('No decimal separator (".") found.')}else r("Must be exactly two digits.");else r("No time unit separator found.");else r("Timestamp must start with a character in the range 0-9.");else r("No timestamp found.")}this.parse=function(t,o){if(s(n),t.startTime=l(),void 0!=t.startTime)if(t.startTime<o&&r("Start timestamp is not greater than or equal to start timestamp of previous cue."),i.test(e[a])&&r("Timestamp not separated from '--\x3e' by whitespace."),s(n),"-"==e[a])if(a++,"-"==e[a])if(a++,">"==e[a]){if(a++,i.test(e[a])&&r("'--\x3e' not separated from timestamp by whitespace."),s(n),t.endTime=l(),void 0!=t.endTime)return t.endTime<=t.startTime&&r("End timestamp is not greater than start timestamp."),i.test(e[a]),s(n),function(e,t){for(var i=e.split(n),a=[],s=0;s<i.length;s++)ifLine truncated