build all

Refactor utility functions for improved readability and consistency

- Updated compatibility.js to use consistent line endings and formatting.
- Refactored component.js for better readability and structure, including consistent use of arrow functions and binding.
- Simplified dom.js functions with consistent formatting and improved readability.
- Enhanced emitter.js with consistent formatting and arrow function usage.
- Streamlined error.js for improved readability and consistency.
- Refactored file.js to use consistent formatting and improved readability.
- Improved format.js functions for better readability and consistency.
- Updated index.js to maintain consistent export formatting.
- Refactored property.js for improved readability and consistency.
- Enhanced subtitle.js with consistent formatting and improved readability.
- Refactored time.js for better readability and consistent formatting.

fix: update lint script to target only source files for consistency

Revert "fix: restore export statements for various plugins and update type definitions for better clarity"

This reverts commit b5e969d81ec765cd8a34b06e6ef4f232ef25087f.

fix: restore export statements for various plugins and update type definitions for better clarity

Refactor type definitions to use interfaces instead of type aliases for better extensibility and clarity across i18n, icons, option, player, quality, setting, subtitle, template, and utils modules.
This commit is contained in:
Harvey Zack committed 2025-08-03 13:17:33 +08:00
1 parent 532dd67cfd
commit 35ad9883af
447 files changed
+18248 -17946

No files matched your search

@@ -5,5 +5,5 @@
* (c) 2017-2025 Harvey Zack
* Released under the MIT License.
*/
!function(e,t,n,r,o,i,a,u){var f="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:{},d="function"==typeof f[r]&&f[r],l=d.i||{},c=d.cache||{},p="undefined"!=typeof module&&"function"==typeof module.require&&module.require.bind(module);function s(t,n){if(!c[t]){if(!e[t]){if(o[t])return o[t];var i="function"==typeof f[r]&&f[r];if(!n&&i)return i(t,!0);if(d)return d(t,!0);if(p&&"string"==typeof t)return p(t);var a=Error("Cannot find module '"+t+"'");throw a.code="MODULE_NOT_FOUND",a}l.resolve=function(n){var r=e[t][1][n];return null!=r?r:n},l.cache={};var u=c[t]=new s.Module(t);e[t][0].call(u.exports,l,u,u.exports,f)}return c[t].exports;function l(e){var t=l.resolve(e);return!1===t?{}:s(t)}}s.isParcelRequire=!0,s.Module=function(e){this.id=e,this.bundle=s,this.require=p,this.exports={}},s.modules=e,s.cache=c,s.parent=d,s.distDir=void 0,s.publicUrl=void 0,s.devServer=void 0,s.i=l,s.register=function(t,n){e[t]=[function(e,t){t.exports=n},{}]},Object.defineProperty(s,"root",{get:function(){return f[r]}}),f[r]=s;for(var y=0;y<t.length;y++)s(t[y]);if(n){var m=s(n);"object"==typeof exports&&"undefined"!=typeof module?module.exports=m:"function"==typeof define&&define.amd&&define(function(){return m})}}({"4omrA":[function(e,t,n,r){var o=e("@parcel/transformer-js/src/esmodule-helpers.js");function i(e){return t=>{let{constructor:n}=t,{createElement:r}=n.utils,o=r("canvas"),i=r("video"),a=o.getContext("2d"),u=null,f={};for(let e in o)"function"==typeof o[e]&&(f[e]=o[e].bind(o));for(let e in i)e in o||Object.defineProperty(o,e,{get(){let t=i[e];return"function"==typeof t?t.bind(i):t},set(t){i[e]=t},configurable:!0,enumerable:!0});for(let e in f)o[e]=function(...t){return e in f?f[e](...t):i[e].apply(i,t)};return function(){let{events:e}=n.config;setTimeout(()=>{e.forEach(e=>{t.proxy(i,e,e=>{t.emit(`video:${e.type}`,e)})})})}(),t.on("video:loadedmetadata",()=>{o.width=i.videoWidth,o.height=i.videoHeight}),t.on("video:play",()=>{cancelAnimationFrame(u),l()}),t.on("video:pause",()=>{cancelAnimationFrame(u)}),t.on("resize",()=>{!function(){let e,n,r=t.template?.$player;if(!r||t.option.autoSize)return;let a=i.videoWidth/i.videoHeight,u=r.clientWidth,f=r.clientHeight;u/f>a?e=(n=f)*a:n=(e=u)/a,o.width=e,o.height=n;let d=(u-e)/2,l=(f-n)/2;Object.assign(o.style,{padding:`${l}px ${d}px`})}(),d()}),t.on("destroy",()=>{cancelAnimationFrame(u)}),o;async function d(){try{if("undefined"!=typeof createImageBitmap){let e=await createImageBitmap(i);a.drawImage(e,0,0,o.width,o.height),e.close()}else a.drawImage(i,0,0,o.width,o.height);e&&e(a,i),t.emit("artplayerProxyCanvas:draw",a,i)}catch(e){t.emit("artplayerProxyCanvas:error",e)}}async function l(){await d(),u=requestAnimationFrame(l)}}}o.defineInteropFlag(n),o.export(n,"default",()=>i),"undefined"!=typeof window&&(window.artplayerProxyCanvas=i)},{"@parcel/transformer-js/src/esmodule-helpers.js":"w4pLy"}],w4pLy:[function(e,t,n,r){n.interopDefault=function(e){return e&&e.__esModule?e:{default:e}},n.defineInteropFlag=function(e){Object.defineProperty(e,"__esModule",{value:!0})},n.exportAll=function(e,t){return Object.keys(e).forEach(function(n){"default"===n||"__esModule"===n||Object.prototype.hasOwnProperty.call(t,n)||Object.defineProperty(t,n,{enumerable:!0,get:function(){return e[n]}})}),t},n.export=function(e,t,n){Object.defineProperty(e,t,{enumerable:!0,get:n})}},{}]},["4omrA"],"4omrA","parcelRequire7358",{});let{default:e}=parcelRequire7358("4omrA");export{e as default};
!function(e,t,n,o,r,i,a,u){var l="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:{},d="function"==typeof l[o]&&l[o],f=d.i||{},c=d.cache||{},p="undefined"!=typeof module&&"function"==typeof module.require&&module.require.bind(module);function s(t,n){if(!c[t]){if(!e[t]){if(r[t])return r[t];var i="function"==typeof l[o]&&l[o];if(!n&&i)return i(t,!0);if(d)return d(t,!0);if(p&&"string"==typeof t)return p(t);var a=Error("Cannot find module '"+t+"'");throw a.code="MODULE_NOT_FOUND",a}f.resolve=function(n){var o=e[t][1][n];return null!=o?o:n},f.cache={};var u=c[t]=new s.Module(t);e[t][0].call(u.exports,f,u,u.exports,l)}return c[t].exports;function f(e){var t=f.resolve(e);return!1===t?{}:s(t)}}s.isParcelRequire=!0,s.Module=function(e){this.id=e,this.bundle=s,this.require=p,this.exports={}},s.modules=e,s.cache=c,s.parent=d,s.distDir=void 0,s.publicUrl=void 0,s.devServer=void 0,s.i=f,s.register=function(t,n){e[t]=[function(e,t){t.exports=n},{}]},Object.defineProperty(s,"root",{get:function(){return l[o]}}),l[o]=s;for(var h=0;h<t.length;h++)s(t[h]);if(n){var y=s(n);"object"==typeof exports&&"undefined"!=typeof module?module.exports=y:"function"==typeof define&&define.amd&&define(function(){return y})}}({loCXh:[function(e,t,n,o){var r=e("@parcel/transformer-js/src/esmodule-helpers.js");function i(e){return t=>{let{constructor:n}=t,{createElement:o}=n.utils,r=o("canvas"),i=o("video"),a=r.getContext("2d"),u=null,l={};for(let e in r)"function"==typeof r[e]&&(l[e]=r[e].bind(r));for(let e in i)e in r||Object.defineProperty(r,e,{get(){let t=i[e];return"function"==typeof t?t.bind(i):t},set(t){i[e]=t},configurable:!0,enumerable:!0});for(let e in l)r[e]=function(...t){return e in l?l[e](...t):i[e](...t)};return function(){let{events:e}=n.config;setTimeout(()=>{e.forEach(e=>{t.proxy(i,e,e=>{t.emit(`video:${e.type}`,e)})})})}(),t.on("video:loadedmetadata",()=>{r.width=i.videoWidth,r.height=i.videoHeight}),t.on("video:play",()=>{cancelAnimationFrame(u),f()}),t.on("video:pause",()=>{cancelAnimationFrame(u)}),t.on("resize",()=>{!function(){let e,n,o=t.template?.$player;if(!o||t.option.autoSize)return;let a=i.videoWidth/i.videoHeight,u=o.clientWidth,l=o.clientHeight;u/l>a?e=(n=l)*a:n=(e=u)/a,r.width=e,r.height=n;let d=(u-e)/2,f=(l-n)/2;Object.assign(r.style,{padding:`${f}px ${d}px`})}(),d()}),t.on("destroy",()=>{cancelAnimationFrame(u)}),r;async function d(){try{if("undefined"!=typeof createImageBitmap){let e=await createImageBitmap(i);a.drawImage(e,0,0,r.width,r.height),e.close()}else a.drawImage(i,0,0,r.width,r.height);e&&e(a,i),t.emit("artplayerProxyCanvas:draw",a,i)}catch(e){t.emit("artplayerProxyCanvas:error",e)}}async function f(){await d(),u=requestAnimationFrame(f)}}}r.defineInteropFlag(n),r.export(n,"default",()=>i),"undefined"!=typeof window&&(window.artplayerProxyCanvas=i)},{"@parcel/transformer-js/src/esmodule-helpers.js":"5lQoW"}],"5lQoW":[function(e,t,n,o){n.interopDefault=function(e){return e&&e.__esModule?e:{default:e}},n.defineInteropFlag=function(e){Object.defineProperty(e,"__esModule",{value:!0})},n.exportAll=function(e,t){return Object.keys(e).forEach(function(n){"default"===n||"__esModule"===n||Object.prototype.hasOwnProperty.call(t,n)||Object.defineProperty(t,n,{enumerable:!0,get:function(){return e[n]}})}),t},n.export=function(e,t,n){Object.defineProperty(e,t,{enumerable:!0,get:n})}},{}]},["loCXh"],"loCXh","parcelRequire4dc0",{});let{default:e}=parcelRequire4dc0("loCXh");export{e as default};
//# sourceMappingURL=artplayer-proxy-canvas.esm.js.map
@@ -1 +1 @@
{"mappings":"C,A,S,C,C,C,C,C,C,C,C,C,C,C,C,C,C,C,E,I,E,A,a,O,W,W,A,a,O,K,K,A,a,O,O,O,A,a,O,O,O,C,E,E,A,Y,O,C,C,E,E,C,C,E,C,E,E,C,E,C,E,E,E,K,E,C,E,E,A,a,O,Q,A,Y,O,O,O,E,O,O,C,I,C,Q,S,E,C,C,C,E,G,C,C,C,E,C,C,G,C,C,C,E,C,C,G,C,C,E,C,O,C,C,E,C,I,E,A,Y,O,C,C,E,E,C,C,E,C,G,C,G,E,O,E,E,C,G,G,E,O,E,E,C,G,G,G,A,U,O,E,O,E,G,I,E,A,M,uB,E,I,O,E,I,C,mB,C,C,E,O,C,S,C,E,I,E,C,C,E,C,E,C,E,C,O,A,M,E,E,C,E,E,K,C,C,E,I,E,C,C,E,C,I,E,M,C,G,C,C,E,C,E,C,I,C,E,O,C,E,E,E,O,C,E,C,O,C,C,E,C,O,C,S,E,C,E,I,E,E,O,C,G,M,A,C,I,E,C,E,E,E,C,C,E,e,C,C,E,E,M,C,S,C,E,I,C,E,C,E,I,C,M,C,E,I,C,O,C,E,I,C,O,C,C,C,E,E,O,C,E,E,K,C,E,E,M,C,E,E,O,C,K,E,E,S,C,K,E,E,S,C,K,E,E,C,C,E,E,Q,C,S,C,C,C,E,C,C,E,C,C,S,C,C,C,E,E,O,C,C,E,C,E,A,E,O,c,C,E,O,C,I,W,O,C,C,E,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A,GAAY,EAAS,EAAK,GAC1B,EAAI,IAAI,CAAC,4BAA6B,EAAK,EAC/C,CAAE,MAAO,EAAO,CACZ,EAAI,IAAI,CAAC,6BAA8B,EAC3C,CACJ,CAEA,eAAe,IACX,MAAM,IACN,EAAc,sBAAsB,EACxC,CAuDJ,CACJ,C,E,iB,C,GAtIwB,EAAA,MAAA,CAAA,EAAA,UAAA,IAAA,GAwIpB,AAAkB,aAAlB,OAAO,QACP,CAAA,OAAO,oBAAuB,CAAG,CADrC,C,E,C,iD,O,E,C,M,C,S,C,C,C,C,C,C,C,ECxIA,EAAQ,cAAc,CAAG,SAAU,CAAC,EAClC,OAAO,GAAK,EAAE,UAAU,CAAG,EAAI,CAAC,QAAS,CAAC,CAC5C,EAEA,EAAQ,iBAAiB,CAAG,SAAU,CAAC,EACrC,OAAO,cAAc,CAAC,EAAG,aAAc,CAAC,MAAO,CAAA,CAAI,EACrD,EAEA,EAAQ,SAAS,CAAG,SAAU,CAAM,CAAE,CAAI,EAkBxC,OAjBA,OAAO,IAAI,CAAC,GAAQ,OAAO,CAAC,SAAU,CAAG,EAE7B,YAAR,GACA,AAAQ,eAAR,GACA,OAAO,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,EAAM,IAK7C,OAAO,cAAc,CAAC,EAAM,EAAK,CAC/B,WAAY,CAAA,EACZ,IAAK,WACH,OAAO,CAAM,CAAC,EAAI,AACpB,CACF,EACF,GAEO,CACT,EAEA,EAAQ,MAAM,CAAG,SAAU,CAAI,CAAE,CAAQ,CAAE,CAAG,EAC5C,OAAO,cAAc,CAAC,EAAM,EAAU,CACpC,WAAY,CAAA,EACZ,IAAK,CACP,EACF,C,E,C,E,E,C,Q,C,Q,oB,C,G,G,C,Q,C,C,C,kB,gB,K,O","sources":["<anon>","src/index.js","../../node_modules/@parcel/transformer-js/src/esmodule-helpers.js"],"sourcesContent":["// modules are defined as an array\n// [ module function, map of requires ]\n//\n// map of requires is short require name -> numeric require\n//\n// anything defined in a previous bundle is accessed via the\n// orig method which is the require for previous bundles\n\n(function (\n modules,\n entry,\n mainEntry,\n parcelRequireName,\n externals,\n distDir,\n publicUrl,\n devServer\n) {\n /* eslint-disable no-undef */\n var globalObject =\n typeof globalThis !== 'undefined'\n ? globalThis\n : typeof self !== 'undefined'\n ? self\n : typeof window !== 'undefined'\n ? window\n : typeof global !== 'undefined'\n ? global\n : {};\n /* eslint-enable no-undef */\n\n // Save the require from previous bundle to this closure if any\n var previousRequire =\n typeof globalObject[parcelRequireName] === 'function' &&\n globalObject[parcelRequireName];\n\n var importMap = previousRequire.i || {};\n var cache = previousRequire.cache || {};\n // Do not use `require` to prevent Webpack from trying to bundle this call\n var nodeRequire =\n typeof module !== 'undefined' &&\n typeof module.reqLine truncated
{"mappings":"C,A,S,C,C,C,C,C,C,C,C,C,C,C,C,C,C,C,E,I,E,A,a,O,W,W,A,a,O,K,K,A,a,O,O,O,A,a,O,O,O,C,E,E,A,Y,O,C,C,E,E,C,C,E,C,E,E,C,E,C,E,E,E,K,E,C,E,E,A,a,O,Q,A,Y,O,O,O,E,O,O,C,I,C,Q,S,E,C,C,C,E,G,C,C,C,E,C,C,G,C,C,C,E,C,C,G,C,C,E,C,O,C,C,E,C,I,E,A,Y,O,C,C,E,E,C,C,E,C,G,C,G,E,O,E,E,C,G,G,E,O,E,E,C,G,G,G,A,U,O,E,O,E,G,I,E,A,M,uB,E,I,O,E,I,C,mB,C,C,E,O,C,S,C,E,I,E,C,C,E,C,E,C,E,C,O,A,M,E,E,C,E,E,K,C,C,E,I,E,C,C,E,C,I,E,M,C,G,C,C,E,C,E,C,I,C,E,O,C,E,E,E,O,C,E,C,O,C,C,E,C,O,C,S,E,C,E,I,E,E,O,C,G,M,A,C,I,E,C,E,E,E,C,C,E,e,C,C,E,E,M,C,S,C,E,I,C,E,C,E,I,C,M,C,E,I,C,O,C,E,I,C,O,C,C,C,E,E,O,C,E,E,K,C,E,E,M,C,E,E,O,C,K,E,E,S,C,K,E,E,S,C,K,E,E,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"],"sourcesContent":["// modules are defined as an array\n// [ module function, map of requires ]\n//\n// map of requires is short require name -> numeric require\n//\n// anything defined in a previous bundle is accessed via the\n// orig method which is the require for previous bundles\n\n(function (\n modules,\n entry,\n mainEntry,\n parcelRequireName,\n externals,\n distDir,\n publicUrl,\n devServer\n) {\n /* eslint-disable no-undef */\n var globalObject =\n typeof globalThis !== 'undefined'\n ? globalThis\n : typeof self !== 'undefined'\n ? self\n : typeof window !== 'undefined'\n ? window\n : typeof global !== 'undefined'\n ? global\n : {};\n /* eslint-enable no-undef */\n\n // Save the require from previous bundle to this closure if any\n var previousRequire =\n typeof globalObject[parcelRequireName] === 'function' &&\n globalObject[parcelRequireName];\n\n var importMap = previousRequire.i || {};\n var cache = previousRequire.cache || {};\n // Do not use `require` to prevent Webpack from trying to bundle this call\n var nodeRequire =\n typeof module !== 'undefined' &&\n typeofLine truncated
@@ -5,4 +5,4 @@
* (c) 2017-2025 Harvey Zack
* Released under the MIT License.
*/
!function(e,t,n,o,r,i,a,u){var f="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:{},d="function"==typeof f[o]&&f[o],l=d.i||{},c=d.cache||{},p="undefined"!=typeof module&&"function"==typeof module.require&&module.require.bind(module);function s(t,n){if(!c[t]){if(!e[t]){if(r[t])return r[t];var i="function"==typeof f[o]&&f[o];if(!n&&i)return i(t,!0);if(d)return d(t,!0);if(p&&"string"==typeof t)return p(t);var a=Error("Cannot find module '"+t+"'");throw a.code="MODULE_NOT_FOUND",a}l.resolve=function(n){var o=e[t][1][n];return null!=o?o:n},l.cache={};var u=c[t]=new s.Module(t);e[t][0].call(u.exports,l,u,u.exports,f)}return c[t].exports;function l(e){var t=l.resolve(e);return!1===t?{}:s(t)}}s.isParcelRequire=!0,s.Module=function(e){this.id=e,this.bundle=s,this.require=p,this.exports={}},s.modules=e,s.cache=c,s.parent=d,s.distDir=void 0,s.publicUrl=void 0,s.devServer=void 0,s.i=l,s.register=function(t,n){e[t]=[function(e,t){t.exports=n},{}]},Object.defineProperty(s,"root",{get:function(){return f[o]}}),f[o]=s;for(var y=0;y<t.length;y++)s(t[y]);if(n){var m=s(n);"object"==typeof exports&&"undefined"!=typeof module?module.exports=m:"function"==typeof define&&define.amd&&define(function(){return m})}}({jz4E5:[function(e,t,n,o){var r=e("@parcel/transformer-js/src/esmodule-helpers.js");function i(e){return t=>{let{constructor:n}=t,{createElement:o}=n.utils,r=o("canvas"),i=o("video"),a=r.getContext("2d"),u=null,f={};for(let e in r)"function"==typeof r[e]&&(f[e]=r[e].bind(r));for(let e in i)e in r||Object.defineProperty(r,e,{get(){let t=i[e];return"function"==typeof t?t.bind(i):t},set(t){i[e]=t},configurable:!0,enumerable:!0});for(let e in f)r[e]=function(...t){return e in f?f[e](...t):i[e].apply(i,t)};return function(){let{events:e}=n.config;setTimeout(()=>{e.forEach(e=>{t.proxy(i,e,e=>{t.emit(`video:${e.type}`,e)})})})}(),t.on("video:loadedmetadata",()=>{r.width=i.videoWidth,r.height=i.videoHeight}),t.on("video:play",()=>{cancelAnimationFrame(u),l()}),t.on("video:pause",()=>{cancelAnimationFrame(u)}),t.on("resize",()=>{!function(){let e,n,o=t.template?.$player;if(!o||t.option.autoSize)return;let a=i.videoWidth/i.videoHeight,u=o.clientWidth,f=o.clientHeight;u/f>a?e=(n=f)*a:n=(e=u)/a,r.width=e,r.height=n;let d=(u-e)/2,l=(f-n)/2;Object.assign(r.style,{padding:`${l}px ${d}px`})}(),d()}),t.on("destroy",()=>{cancelAnimationFrame(u)}),r;async function d(){try{if("undefined"!=typeof createImageBitmap){let e=await createImageBitmap(i);a.drawImage(e,0,0,r.width,r.height),e.close()}else a.drawImage(i,0,0,r.width,r.height);e&&e(a,i),t.emit("artplayerProxyCanvas:draw",a,i)}catch(e){t.emit("artplayerProxyCanvas:error",e)}}async function l(){await d(),u=requestAnimationFrame(l)}}}r.defineInteropFlag(n),r.export(n,"default",()=>i),"undefined"!=typeof window&&(window.artplayerProxyCanvas=i)},{"@parcel/transformer-js/src/esmodule-helpers.js":"7o2zS"}],"7o2zS":[function(e,t,n,o){n.interopDefault=function(e){return e&&e.__esModule?e:{default:e}},n.defineInteropFlag=function(e){Object.defineProperty(e,"__esModule",{value:!0})},n.exportAll=function(e,t){return Object.keys(e).forEach(function(n){"default"===n||"__esModule"===n||Object.prototype.hasOwnProperty.call(t,n)||Object.defineProperty(t,n,{enumerable:!0,get:function(){return e[n]}})}),t},n.export=function(e,t,n){Object.defineProperty(e,t,{enumerable:!0,get:n})}},{}]},["jz4E5"],"jz4E5","parcelRequire7358",{});
!function(e,t,n,r,o,i,a,f){var u="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:{},d="function"==typeof u[r]&&u[r],l=d.i||{},c=d.cache||{},s="undefined"!=typeof module&&"function"==typeof module.require&&module.require.bind(module);function p(t,n){if(!c[t]){if(!e[t]){if(o[t])return o[t];var i="function"==typeof u[r]&&u[r];if(!n&&i)return i(t,!0);if(d)return d(t,!0);if(s&&"string"==typeof t)return s(t);var a=Error("Cannot find module '"+t+"'");throw a.code="MODULE_NOT_FOUND",a}l.resolve=function(n){var r=e[t][1][n];return null!=r?r:n},l.cache={};var f=c[t]=new p.Module(t);e[t][0].call(f.exports,l,f,f.exports,u)}return c[t].exports;function l(e){var t=l.resolve(e);return!1===t?{}:p(t)}}p.isParcelRequire=!0,p.Module=function(e){this.id=e,this.bundle=p,this.require=s,this.exports={}},p.modules=e,p.cache=c,p.parent=d,p.distDir=void 0,p.publicUrl=void 0,p.devServer=void 0,p.i=l,p.register=function(t,n){e[t]=[function(e,t){t.exports=n},{}]},Object.defineProperty(p,"root",{get:function(){return u[r]}}),u[r]=p;for(var y=0;y<t.length;y++)p(t[y]);if(n){var m=p(n);"object"==typeof exports&&"undefined"!=typeof module?module.exports=m:"function"==typeof define&&define.amd&&define(function(){return m})}}({fsIOq:[function(e,t,n,r){var o=e("@parcel/transformer-js/src/esmodule-helpers.js");function i(e){return t=>{let{constructor:n}=t,{createElement:r}=n.utils,o=r("canvas"),i=r("video"),a=o.getContext("2d"),f=null,u={};for(let e in o)"function"==typeof o[e]&&(u[e]=o[e].bind(o));for(let e in i)e in o||Object.defineProperty(o,e,{get(){let t=i[e];return"function"==typeof t?t.bind(i):t},set(t){i[e]=t},configurable:!0,enumerable:!0});for(let e in u)o[e]=function(...t){return e in u?u[e](...t):i[e](...t)};return function(){let{events:e}=n.config;setTimeout(()=>{e.forEach(e=>{t.proxy(i,e,e=>{t.emit(`video:${e.type}`,e)})})})}(),t.on("video:loadedmetadata",()=>{o.width=i.videoWidth,o.height=i.videoHeight}),t.on("video:play",()=>{cancelAnimationFrame(f),l()}),t.on("video:pause",()=>{cancelAnimationFrame(f)}),t.on("resize",()=>{!function(){let e,n,r=t.template?.$player;if(!r||t.option.autoSize)return;let a=i.videoWidth/i.videoHeight,f=r.clientWidth,u=r.clientHeight;f/u>a?e=(n=u)*a:n=(e=f)/a,o.width=e,o.height=n;let d=(f-e)/2,l=(u-n)/2;Object.assign(o.style,{padding:`${l}px ${d}px`})}(),d()}),t.on("destroy",()=>{cancelAnimationFrame(f)}),o;async function d(){try{if("undefined"!=typeof createImageBitmap){let e=await createImageBitmap(i);a.drawImage(e,0,0,o.width,o.height),e.close()}else a.drawImage(i,0,0,o.width,o.height);e&&e(a,i),t.emit("artplayerProxyCanvas:draw",a,i)}catch(e){t.emit("artplayerProxyCanvas:error",e)}}async function l(){await d(),f=requestAnimationFrame(l)}}}o.defineInteropFlag(n),o.export(n,"default",()=>i),"undefined"!=typeof window&&(window.artplayerProxyCanvas=i)},{"@parcel/transformer-js/src/esmodule-helpers.js":"6ykb1"}],"6ykb1":[function(e,t,n,r){n.interopDefault=function(e){return e&&e.__esModule?e:{default:e}},n.defineInteropFlag=function(e){Object.defineProperty(e,"__esModule",{value:!0})},n.exportAll=function(e,t){return Object.keys(e).forEach(function(n){"default"===n||"__esModule"===n||Object.prototype.hasOwnProperty.call(t,n)||Object.defineProperty(t,n,{enumerable:!0,get:function(){return e[n]}})}),t},n.export=function(e,t,n){Object.defineProperty(e,t,{enumerable:!0,get:n})}},{}]},["fsIOq"],"fsIOq","parcelRequire4dc0",{});
@@ -5,4 +5,4 @@
* (c) 2017-2025 Harvey Zack
* Released under the MIT License.
*/
!function(e,t,r,n,o,i,a,c){var u="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:{},f="function"==typeof u[n]&&u[n],s=f.i||{},l=f.cache||{},p="undefined"!=typeof module&&"function"==typeof module.require&&module.require.bind(module);function d(t,r){if(!l[t]){if(!e[t]){if(o[t])return o[t];var i="function"==typeof u[n]&&u[n];if(!r&&i)return i(t,!0);if(f)return f(t,!0);if(p&&"string"==typeof t)return p(t);var a=Error("Cannot find module '"+t+"'");throw a.code="MODULE_NOT_FOUND",a}s.resolve=function(r){var n=e[t][1][r];return null!=n?n:r},s.cache={};var c=l[t]=new d.Module(t);e[t][0].call(c.exports,s,c,c.exports,u)}return l[t].exports;function s(e){var t=s.resolve(e);return!1===t?{}:d(t)}}d.isParcelRequire=!0,d.Module=function(e){this.id=e,this.bundle=d,this.require=p,this.exports={}},d.modules=e,d.cache=l,d.parent=f,d.distDir=void 0,d.publicUrl=void 0,d.devServer=void 0,d.i=s,d.register=function(t,r){e[t]=[function(e,t){t.exports=r},{}]},Object.defineProperty(d,"root",{get:function(){return u[n]}}),u[n]=d;for(var y=0;y<t.length;y++)d(t[y]);if(r){var _=d(r);"object"==typeof exports&&"undefined"!=typeof module?module.exports=_:"function"==typeof define&&define.amd&&define(function(){return _})}}({bzF6W:[function(e,t,r,n){var o=e("@parcel/transformer-js/src/esmodule-helpers.js");o.defineInteropFlag(r),o.export(r,"default",function(){return u});var i=e("@swc/helpers/cjs/_async_to_generator.cjs"),a=e("@swc/helpers/cjs/_to_consumable_array.cjs"),c=e("@swc/helpers/cjs/_ts_generator.cjs");function u(e){return function(t){var r,n=function(e){e in s||Object.defineProperty(s,e,{get:function(){var t=l[e];return"function"==typeof t?t.bind(l):t},set:function(t){l[e]=t},configurable:!0,enumerable:!0})},o=function(e){s[e]=function(){for(var t=arguments.length,r=Array(t),n=0;n<t;n++)r[n]=arguments[n];return e in y?y[e].apply(y,(0,a._)(r)):l[e].apply(l,r)}},u=t.constructor,f=u.utils.createElement,s=f("canvas"),l=f("video"),p=s.getContext("2d"),d=null,y={};for(var _ in s)"function"==typeof s[_]&&(y[_]=s[_].bind(s));for(var h in l)n(h);for(var v in y)o(v);return r=u.config.events,setTimeout(function(){r.forEach(function(e){t.proxy(l,e,function(e){t.emit("video:".concat(e.type),e)})})}),t.on("video:loadedmetadata",function(){s.width=l.videoWidth,s.height=l.videoHeight}),t.on("video:play",function(){cancelAnimationFrame(d),w()}),t.on("video:pause",function(){cancelAnimationFrame(d)}),t.on("resize",function(){!function(){var e,r,n,o=null==(e=t.template)?void 0:e.$player;if(o&&!t.option.autoSize){var i=l.videoWidth/l.videoHeight,a=o.clientWidth,c=o.clientHeight;a/c>i?r=(n=c)*i:n=(r=a)/i,s.width=r,s.height=n;var u=(a-r)/2,f=(c-n)/2;Object.assign(s.style,{padding:"".concat(f,"px ").concat(u,"px")})}}(),b()}),t.on("destroy",function(){cancelAnimationFrame(d)}),s;function b(){return m.apply(this,arguments)}function m(){return(m=(0,i._)(function(){var r,n;return(0,c._)(this,function(o){switch(o.label){case 0:if(o.trys.push([0,4,,5]),"undefined"==typeof createImageBitmap)return[3,2];return[4,createImageBitmap(l)];case 1:return r=o.sent(),p.drawImage(r,0,0,s.width,s.height),r.close(),[3,3];case 2:p.drawImage(l,0,0,s.width,s.height),o.label=3;case 3:return e&&e(p,l),t.emit("artplayerProxyCanvas:draw",p,l),[3,5];case 4:return n=o.sent(),t.emit("artplayerProxyCanvas:error",n),[3,5];case 5:return[2]}})})).apply(this,arguments)}function w(){return g.apply(this,arguments)}function g(){return(g=(0,i._)(function(){return(0,c._)(this,function(e){switch(e.label){case 0:return[4,b()];case 1:return e.sent(),d=requestAnimationFrame(w),[2]}})})).apply(this,arguments)}}}"undefined"!=typeof window&&(window.artplayerProxyCanvas=u)},{"@swc/helpers/cjs/_async_to_generator.cjs":"4ElRo","@swc/helpers/cjs/_to_consumable_array.cjs":"1LaMX","@swc/helpers/cjs/_ts_generator.cjs":"a4h1C","@parcel/transformer-js/src/esmodule-helpers.js":"ihnSZ"}],"4ElRo":[function(e,t,r,n){"use strict";function o(e,t,r,n,o,i,a){try{var c=e[i](a),u=c.value}catch(e){r(e);return}c.done?t(u):Promise.resolve(u).then(n,o)}r._=function(e){return function(){var t=this,r=arguments;return new Promise(function(n,i){var a=e.apply(t,r);function c(e){o(a,n,i,c,u,"next",e)}function u(e){o(a,n,i,c,u,"throw",e)}c(void 0)})}}},{}],"1LaMX":[function(e,t,r,n){"use strict";var o=e("39b649abd35ac2e2"),i=e("8428e13fa0ef5403"),a=e("8d50a6b373b717fa"),c=e("3c184cf684436bb9");r._=function(e){return o._(e)||i._(e)||c._(e)||a._()}},{"39b649abd35ac2e2":"i3OgW","8428e13fa0ef5403":"5CLcV","8d50a6b373b717fa":"cpcPX","3c184cf684436bb9":"ikxEb"}],i3OgW:[function(e,t,r,n){"use strict";var o=e("ec82543f1393b568");r._=function(e){if(Array.isArray(e))return o._(e)}},{ec82543f1393b568:"8HLaN"}],"8HLaN":[function(e,t,r,n){"use strict";r._=function(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}},{}],"5CLcV":[function(e,t,r,n){"use strict";r._=function(e){if("undefined"!=typeof Symbol&&nullLine truncated
!function(e,t,r,n,o,i,c,a){var u="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:{},f="function"==typeof u[n]&&u[n],s=f.i||{},l=f.cache||{},p="undefined"!=typeof module&&"function"==typeof module.require&&module.require.bind(module);function d(t,r){if(!l[t]){if(!e[t]){if(o[t])return o[t];var i="function"==typeof u[n]&&u[n];if(!r&&i)return i(t,!0);if(f)return f(t,!0);if(p&&"string"==typeof t)return p(t);var c=Error("Cannot find module '"+t+"'");throw c.code="MODULE_NOT_FOUND",c}s.resolve=function(r){var n=e[t][1][r];return null!=n?n:r},s.cache={};var a=l[t]=new d.Module(t);e[t][0].call(a.exports,s,a,a.exports,u)}return l[t].exports;function s(e){var t=s.resolve(e);return!1===t?{}:d(t)}}d.isParcelRequire=!0,d.Module=function(e){this.id=e,this.bundle=d,this.require=p,this.exports={}},d.modules=e,d.cache=l,d.parent=f,d.distDir=void 0,d.publicUrl=void 0,d.devServer=void 0,d.i=s,d.register=function(t,r){e[t]=[function(e,t){t.exports=r},{}]},Object.defineProperty(d,"root",{get:function(){return u[n]}}),u[n]=d;for(var y=0;y<t.length;y++)d(t[y]);if(r){var _=d(r);"object"==typeof exports&&"undefined"!=typeof module?module.exports=_:"function"==typeof define&&define.amd&&define(function(){return _})}}({LnyEn:[function(e,t,r,n){var o=e("@parcel/transformer-js/src/esmodule-helpers.js");o.defineInteropFlag(r),o.export(r,"default",function(){return u});var i=e("@swc/helpers/cjs/_async_to_generator.cjs"),c=e("@swc/helpers/cjs/_to_consumable_array.cjs"),a=e("@swc/helpers/cjs/_ts_generator.cjs");function u(e){return function(t){var r,n=function(e){e in s||Object.defineProperty(s,e,{get:function(){var t=l[e];return"function"==typeof t?t.bind(l):t},set:function(t){l[e]=t},configurable:!0,enumerable:!0})},o=function(e){s[e]=function(){for(var t=arguments.length,r=Array(t),n=0;n<t;n++)r[n]=arguments[n];return e in y?y[e].apply(y,(0,c._)(r)):l[e].apply(l,(0,c._)(r))}},u=t.constructor,f=u.utils.createElement,s=f("canvas"),l=f("video"),p=s.getContext("2d"),d=null,y={};for(var _ in s)"function"==typeof s[_]&&(y[_]=s[_].bind(s));for(var h in l)n(h);for(var v in y)o(v);return r=u.config.events,setTimeout(function(){r.forEach(function(e){t.proxy(l,e,function(e){t.emit("video:".concat(e.type),e)})})}),t.on("video:loadedmetadata",function(){s.width=l.videoWidth,s.height=l.videoHeight}),t.on("video:play",function(){cancelAnimationFrame(d),function e(){return(0,i._)(function(){return(0,a._)(this,function(t){switch(t.label){case 0:return[4,b()];case 1:return t.sent(),d=requestAnimationFrame(e),[2]}})})()}()}),t.on("video:pause",function(){cancelAnimationFrame(d)}),t.on("resize",function(){!function(){var e,r,n,o=null==(e=t.template)?void 0:e.$player;if(o&&!t.option.autoSize){var i=l.videoWidth/l.videoHeight,c=o.clientWidth,a=o.clientHeight;c/a>i?r=(n=a)*i:n=(r=c)/i,s.width=r,s.height=n;var u=(c-r)/2,f=(a-n)/2;Object.assign(s.style,{padding:"".concat(f,"px ").concat(u,"px")})}}(),b()}),t.on("destroy",function(){cancelAnimationFrame(d)}),s;function b(){return(0,i._)(function(){var r,n;return(0,a._)(this,function(o){switch(o.label){case 0:if(o.trys.push([0,4,,5]),"undefined"==typeof createImageBitmap)return[3,2];return[4,createImageBitmap(l)];case 1:return r=o.sent(),p.drawImage(r,0,0,s.width,s.height),r.close(),[3,3];case 2:p.drawImage(l,0,0,s.width,s.height),o.label=3;case 3:return e&&e(p,l),t.emit("artplayerProxyCanvas:draw",p,l),[3,5];case 4:return n=o.sent(),t.emit("artplayerProxyCanvas:error",n),[3,5];case 5:return[2]}})})()}}}"undefined"!=typeof window&&(window.artplayerProxyCanvas=u)},{"@swc/helpers/cjs/_async_to_generator.cjs":"cZn0e","@swc/helpers/cjs/_to_consumable_array.cjs":"i81N6","@swc/helpers/cjs/_ts_generator.cjs":"eltGh","@parcel/transformer-js/src/esmodule-helpers.js":"qpMMf"}],cZn0e:[function(e,t,r,n){"use strict";function o(e,t,r,n,o,i,c){try{var a=e[i](c),u=a.value}catch(e){r(e);return}a.done?t(u):Promise.resolve(u).then(n,o)}r._=function(e){return function(){var t=this,r=arguments;return new Promise(function(n,i){var c=e.apply(t,r);function a(e){o(c,n,i,a,u,"next",e)}function u(e){o(c,n,i,a,u,"throw",e)}a(void 0)})}}},{}],i81N6:[function(e,t,r,n){"use strict";var o=e("d402183024004bc7"),i=e("3209e2b12672cd18"),c=e("fc58adb8f1bff142"),a=e("5e213dc122a10171");r._=function(e){return o._(e)||i._(e)||a._(e)||c._()}},{d402183024004bc7:"hfQG0","3209e2b12672cd18":"fQrlQ",fc58adb8f1bff142:"fWabh","5e213dc122a10171":"fh7mx"}],hfQG0:[function(e,t,r,n){"use strict";var o=e("5bd5b10bf87fc8e");r._=function(e){if(Array.isArray(e))return o._(e)}},{"5bd5b10bf87fc8e":"1WOAB"}],"1WOAB":[function(e,t,r,n){"use strict";r._=function(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}},{}],fQrlQ:[function(e,t,r,n){"use strict";r._=function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}},{}],fWabh:[function(e,t,r,n){"use strict";r._=function(){throw TypeErroLine truncated
+119 -115
View File
@@ -1,139 +1,143 @@
export default function artplayerProxyCanvas(callback) {
return (art) => {
const { constructor } = art;
const { createElement } = constructor.utils;
return (art) => {
const { constructor } = art
const { createElement } = constructor.utils
const canvas = createElement('canvas');
const video = createElement('video');
const ctx = canvas.getContext('2d');
const canvas = createElement('canvas')
const video = createElement('video')
const ctx = canvas.getContext('2d')
let animationId = null;
let animationId = null
const originalCanvasMethods = {};
for (const prop in canvas) {
if (typeof canvas[prop] === 'function') {
originalCanvasMethods[prop] = canvas[prop].bind(canvas);
}
const originalCanvasMethods = {}
for (const prop in canvas) {
if (typeof canvas[prop] === 'function') {
originalCanvasMethods[prop] = canvas[prop].bind(canvas)
}
}
for (const prop in video) {
if (!(prop in canvas)) {
Object.defineProperty(canvas, prop, {
get() {
const value = video[prop]
return typeof value === 'function' ? value.bind(video) : value
},
set(value) {
video[prop] = value
},
configurable: true,
enumerable: true,
})
}
}
for (const prop in originalCanvasMethods) {
canvas[prop] = function (...args) {
if (prop in originalCanvasMethods) {
return originalCanvasMethods[prop](...args)
}
return video[prop](...args)
}
}
for (const prop in video) {
if (!(prop in canvas)) {
Object.defineProperty(canvas, prop, {
get() {
const value = video[prop];
return typeof value === 'function' ? value.bind(video) : value;
},
set(value) {
video[prop] = value;
},
configurable: true,
enumerable: true,
});
}
setupEventListeners()
setupArtPlayerEvents()
return canvas
function setupEventListeners() {
const { events } = constructor.config
setTimeout(() => {
events.forEach((event) => {
art.proxy(video, event, (event) => {
art.emit(`video:${event.type}`, event)
})
})
})
}
async function draw() {
try {
if (typeof createImageBitmap !== 'undefined') {
const bitmap = await createImageBitmap(video)
ctx.drawImage(bitmap, 0, 0, canvas.width, canvas.height)
bitmap.close()
}
for (const prop in originalCanvasMethods) {
canvas[prop] = function (...args) {
if (prop in originalCanvasMethods) {
return originalCanvasMethods[prop](...args);
}
return video[prop].apply(video, args);
};
else {
ctx.drawImage(video, 0, 0, canvas.width, canvas.height)
}
callback && callback(ctx, video)
art.emit('artplayerProxyCanvas:draw', ctx, video)
}
catch (error) {
art.emit('artplayerProxyCanvas:error', error)
}
}
setupEventListeners();
setupArtPlayerEvents();
async function animation() {
await draw()
animationId = requestAnimationFrame(animation)
}
return canvas;
function resize() {
const player = art.template?.$player
if (!player || art.option.autoSize)
return
function setupEventListeners() {
const { events } = constructor.config;
setTimeout(() => {
events.forEach((event) => {
art.proxy(video, event, (event) => {
art.emit(`video:${event.type}`, event);
});
});
});
}
const aspectRatio = video.videoWidth / video.videoHeight
const containerWidth = player.clientWidth
const containerHeight = player.clientHeight
const containerRatio = containerWidth / containerHeight
async function draw() {
try {
if (typeof createImageBitmap !== 'undefined') {
const bitmap = await createImageBitmap(video);
ctx.drawImage(bitmap, 0, 0, canvas.width, canvas.height);
bitmap.close();
} else {
ctx.drawImage(video, 0, 0, canvas.width, canvas.height);
}
callback && callback(ctx, video);
art.emit('artplayerProxyCanvas:draw', ctx, video);
} catch (error) {
art.emit('artplayerProxyCanvas:error', error);
}
}
let canvasWidth, canvasHeight
if (containerRatio > aspectRatio) {
canvasHeight = containerHeight
canvasWidth = canvasHeight * aspectRatio
}
else {
canvasWidth = containerWidth
canvasHeight = canvasWidth / aspectRatio
}
async function animation() {
await draw();
animationId = requestAnimationFrame(animation);
}
canvas.width = canvasWidth
canvas.height = canvasHeight
function resize() {
const player = art.template?.$player;
if (!player || art.option.autoSize) return;
const paddingLeft = (containerWidth - canvasWidth) / 2
const paddingTop = (containerHeight - canvasHeight) / 2
const aspectRatio = video.videoWidth / video.videoHeight;
const containerWidth = player.clientWidth;
const containerHeight = player.clientHeight;
const containerRatio = containerWidth / containerHeight;
Object.assign(canvas.style, {
padding: `${paddingTop}px ${paddingLeft}px`,
})
}
let canvasWidth, canvasHeight;
if (containerRatio > aspectRatio) {
canvasHeight = containerHeight;
canvasWidth = canvasHeight * aspectRatio;
} else {
canvasWidth = containerWidth;
canvasHeight = canvasWidth / aspectRatio;
}
function setupArtPlayerEvents() {
art.on('video:loadedmetadata', () => {
canvas.width = video.videoWidth
canvas.height = video.videoHeight
})
canvas.width = canvasWidth;
canvas.height = canvasHeight;
art.on('video:play', () => {
cancelAnimationFrame(animationId)
animation()
})
const paddingLeft = (containerWidth - canvasWidth) / 2;
const paddingTop = (containerHeight - canvasHeight) / 2;
art.on('video:pause', () => {
cancelAnimationFrame(animationId)
})
Object.assign(canvas.style, {
padding: `${paddingTop}px ${paddingLeft}px`,
});
}
art.on('resize', () => {
resize()
draw()
})
function setupArtPlayerEvents() {
art.on('video:loadedmetadata', () => {
canvas.width = video.videoWidth;
canvas.height = video.videoHeight;
});
art.on('video:play', () => {
cancelAnimationFrame(animationId);
animation();
});
art.on('video:pause', () => {
cancelAnimationFrame(animationId);
});
art.on('resize', () => {
resize();
draw();
});
art.on('destroy', () => {
cancelAnimationFrame(animationId);
});
}
};
art.on('destroy', () => {
cancelAnimationFrame(animationId)
})
}
}
}
if (typeof window !== 'undefined') {
window['artplayerProxyCanvas'] = artplayerProxyCanvas;
window.artplayerProxyCanvas = artplayerProxyCanvas
}
@@ -1,10 +1,10 @@
import type Artplayer from 'artplayer';
import type Artplayer from 'artplayer'
export = artplayerProxyCanvas;
export = artplayerProxyCanvas
export as namespace artplayerProxyCanvas;
type Option = (ctx: CanvasRenderingContext2D, video: HTMLVideoElement) => void;
type Option = (ctx: CanvasRenderingContext2D, video: HTMLVideoElement) => void
type Result = HTMLCanvasElement;
type Result = HTMLCanvasElement
declare const artplayerProxyCanvas: (option: Option) => (art: Artplayer) => Result;
declare const artplayerProxyCanvas: (option: Option) => (art: Artplayer) => Result