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,r,o,n,s,i,a){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||{},u=d.cache||{},c="undefined"!=typeof module&&"function"==typeof module.require&&module.require.bind(module);function p(t,r){if(!u[t]){if(!e[t]){if(n[t])return n[t];var s="function"==typeof f[o]&&f[o];if(!r&&s)return s(t,!0);if(d)return d(t,!0);if(c&&"string"==typeof t)return c(t);var i=Error("Cannot find module '"+t+"'");throw i.code="MODULE_NOT_FOUND",i}l.resolve=function(r){var o=e[t][1][r];return null!=o?o:r},l.cache={};var a=u[t]=new p.Module(t);e[t][0].call(a.exports,l,a,a.exports,f)}return u[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=c,this.exports={}},p.modules=e,p.cache=u,p.parent=d,p.distDir=void 0,p.publicUrl=void 0,p.devServer=void 0,p.i=l,p.register=function(t,r){e[t]=[function(e,t){t.exports=r},{}]},Object.defineProperty(p,"root",{get:function(){return f[o]}}),f[o]=p;for(var m=0;m<t.length;m++)p(t[m]);if(r){var h=p(r);"object"==typeof exports&&"undefined"!=typeof module?module.exports=h:"function"==typeof define&&define.amd&&define(function(){return h})}}({"4omrA":[function(e,t,r,o){e("@parcel/transformer-js/src/esmodule-helpers.js").defineInteropFlag(r);class n{static get iframe(){return window.top!==window}static postMessage({type:e,data:t,id:r=0}){if(!n.iframe)throw Error('The "ArtplayerPluginIframe.postMessage" method can only be used in iframe');window.parent.postMessage({type:e,data:t,id:r},"*")}static async onMessage(e){if(!n.iframe)throw Error('The "ArtplayerPluginIframe.onMessage" method can only be used in iframe');let{type:t,data:r,id:o}=e.data;if("commit"===t)try{if(r.match(/\bresolve\((.*?)\)/)){let e=`return new Promise(function(resolve){ ${r} })`,t=await Function(e)();n.postMessage({type:"response",data:t,id:o})}else{let e=Function(r)();n.postMessage({type:"response",data:e,id:o})}}catch(e){throw n.postMessage({type:"error",data:e.message,id:o}),e}}static inject(){if(!n.iframe)throw Error('The "ArtplayerPluginIframe.inject" method can only be used in iframe');n.postMessage({type:"inject"}),window.addEventListener("message",n.onMessage)}constructor({iframe:e,url:t}){if(e instanceof HTMLIFrameElement==!1)throw Error('"option.iframe" needs to be a HTMLIFrameElement');if("string"!=typeof t)throw Error('"option.url" needs to be a string');this.url=t,this.$iframe=e,this.promises={},this.injected=!1,this.destroyed=!1,this.messageCallback=()=>null,this.onMessage=this.onMessage.bind(this),window.addEventListener("message",this.onMessage),this.$iframe.src=this.url}onMessage(e){let{type:t,data:r,id:o}=e.data;"inject"===t&&(this.injected=!0),this.promises[o]&&("error"===t?this.promises[o].reject(Error(r)):this.promises[o].resove(r),delete this.promises[o]),this.messageCallback&&this.messageCallback({type:t,data:r})}postMessage({type:e,data:t}){return new Promise((r,o)=>{(function n(){if(this.destroyed)o(Error("The instance has been destroyed"));else if(this.injected){let n=Date.now();this.promises[n]={resove:r,reject:o},this.$iframe.contentWindow.postMessage({type:e,data:t,id:n},"*")}else setTimeout(n.bind(this),200)}).call(this)})}commit(e){if("function"!=typeof e)throw Error('"commit.callback" needs to be a function');let t=e.toString(),r=t.substring(t.indexOf("{")+1,t.lastIndexOf("}"));return this.postMessage({type:"commit",data:r})}message(e){if("function"!=typeof e)throw Error('"message.callback" needs to be a function');this.messageCallback=e}destroy(){this.destroyed=!0,window.removeEventListener("message",this.onMessage)}}r.default=n,"undefined"!=typeof window&&(window.ArtplayerPluginIframe=n)},{"@parcel/transformer-js/src/esmodule-helpers.js":"w4pLy"}],w4pLy:[function(e,t,r,o){r.interopDefault=function(e){return e&&e.__esModule?e:{default:e}},r.defineInteropFlag=function(e){Object.defineProperty(e,"__esModule",{value:!0})},r.exportAll=function(e,t){return Object.keys(e).forEach(function(r){"default"===r||"__esModule"===r||Object.prototype.hasOwnProperty.call(t,r)||Object.defineProperty(t,r,{enumerable:!0,get:function(){return e[r]}})}),t},r.export=function(e,t,r){Object.defineProperty(e,t,{enumerable:!0,get:r})}},{}]},["4omrA"],"4omrA","parcelRequire92f7",{});let{default:e}=parcelRequire92f7("4omrA");export{e as default};
!function(e,t,r,o,s,n,i,a){var f="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:{},l="function"==typeof f[o]&&f[o],d=l.i||{},u=l.cache||{},c="undefined"!=typeof module&&"function"==typeof module.require&&module.require.bind(module);function p(t,r){if(!u[t]){if(!e[t]){if(s[t])return s[t];var n="function"==typeof f[o]&&f[o];if(!r&&n)return n(t,!0);if(l)return l(t,!0);if(c&&"string"==typeof t)return c(t);var i=Error("Cannot find module '"+t+"'");throw i.code="MODULE_NOT_FOUND",i}d.resolve=function(r){var o=e[t][1][r];return null!=o?o:r},d.cache={};var a=u[t]=new p.Module(t);e[t][0].call(a.exports,d,a,a.exports,f)}return u[t].exports;function d(e){var t=d.resolve(e);return!1===t?{}:p(t)}}p.isParcelRequire=!0,p.Module=function(e){this.id=e,this.bundle=p,this.require=c,this.exports={}},p.modules=e,p.cache=u,p.parent=l,p.distDir=void 0,p.publicUrl=void 0,p.devServer=void 0,p.i=d,p.register=function(t,r){e[t]=[function(e,t){t.exports=r},{}]},Object.defineProperty(p,"root",{get:function(){return f[o]}}),f[o]=p;for(var m=0;m<t.length;m++)p(t[m]);if(r){var h=p(r);"object"==typeof exports&&"undefined"!=typeof module?module.exports=h:"function"==typeof define&&define.amd&&define(function(){return h})}}({cTaWs:[function(e,t,r,o){e("@parcel/transformer-js/src/esmodule-helpers.js").defineInteropFlag(r);class s{static get iframe(){return window.top!==window}static postMessage({type:e,data:t,id:r=0}){if(!s.iframe)throw Error('The "ArtplayerPluginIframe.postMessage" method can only be used in iframe');window.parent.postMessage({type:e,data:t,id:r},"*")}static async onMessage(e){if(!s.iframe)throw Error('The "ArtplayerPluginIframe.onMessage" method can only be used in iframe');let{type:t,data:r,id:o}=e.data;if("commit"===t)try{if(r.match(/\bresolve\((.*?)\)/)){let e=`return new Promise(function(resolve){ ${r} })`,t=await Function(e)();s.postMessage({type:"response",data:t,id:o})}else{let e=Function(r)();s.postMessage({type:"response",data:e,id:o})}}catch(e){throw s.postMessage({type:"error",data:e.message,id:o}),e}}static inject(){if(!s.iframe)throw Error('The "ArtplayerPluginIframe.inject" method can only be used in iframe');s.postMessage({type:"inject"}),window.addEventListener("message",s.onMessage)}constructor({iframe:e,url:t}){if(e instanceof HTMLIFrameElement==!1)throw TypeError('"option.iframe" needs to be a HTMLIFrameElement');if("string"!=typeof t)throw TypeError('"option.url" needs to be a string');this.url=t,this.$iframe=e,this.promises={},this.injected=!1,this.destroyed=!1,this.messageCallback=()=>null,this.onMessage=this.onMessage.bind(this),window.addEventListener("message",this.onMessage),this.$iframe.src=this.url}onMessage(e){let{type:t,data:r,id:o}=e.data;"inject"===t&&(this.injected=!0),this.promises[o]&&("error"===t?this.promises[o].reject(Error(r)):this.promises[o].resove(r),delete this.promises[o]),this.messageCallback&&this.messageCallback({type:t,data:r})}postMessage({type:e,data:t}){return new Promise((r,o)=>{(function s(){if(this.destroyed)o(Error("The instance has been destroyed"));else if(this.injected){let s=Date.now();this.promises[s]={resove:r,reject:o},this.$iframe.contentWindow.postMessage({type:e,data:t,id:s},"*")}else setTimeout(s.bind(this),200)}).call(this)})}commit(e){if("function"!=typeof e)throw TypeError('"commit.callback" needs to be a function');let t=e.toString(),r=t.substring(t.indexOf("{")+1,t.lastIndexOf("}"));return this.postMessage({type:"commit",data:r})}message(e){if("function"!=typeof e)throw TypeError('"message.callback" needs to be a function');this.messageCallback=e}destroy(){this.destroyed=!0,window.removeEventListener("message",this.onMessage)}}r.default=s,"undefined"!=typeof window&&(window.ArtplayerPluginIframe=s)},{"@parcel/transformer-js/src/esmodule-helpers.js":"5lQoW"}],"5lQoW":[function(e,t,r,o){r.interopDefault=function(e){return e&&e.__esModule?e:{default:e}},r.defineInteropFlag=function(e){Object.defineProperty(e,"__esModule",{value:!0})},r.exportAll=function(e,t){return Object.keys(e).forEach(function(r){"default"===r||"__esModule"===r||Object.prototype.hasOwnProperty.call(t,r)||Object.defineProperty(t,r,{enumerable:!0,get:function(){return e[r]}})}),t},r.export=function(e,t,r){Object.defineProperty(e,t,{enumerable:!0,get:r})}},{}]},["cTaWs"],"cTaWs","parcelRequire4dc0",{});let{default:e}=parcelRequire4dc0("cTaWs");export{e as default};
//# sourceMappingURL=artplayer-plugin-iframe.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,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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 Line 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,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,A,C,G,C,C,E,C,E,I,I,E,E,E,E,M,C,I,E,C,C,E,E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,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>","packages/artplayer-plugin-iframe/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 !== 'undLine truncated
@@ -5,4 +5,4 @@
* (c) 2017-2025 Harvey Zack
* Released under the MIT License.
*/
!function(e,t,r,o,n,s,i,a){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||{},u=d.cache||{},c="undefined"!=typeof module&&"function"==typeof module.require&&module.require.bind(module);function p(t,r){if(!u[t]){if(!e[t]){if(n[t])return n[t];var s="function"==typeof f[o]&&f[o];if(!r&&s)return s(t,!0);if(d)return d(t,!0);if(c&&"string"==typeof t)return c(t);var i=Error("Cannot find module '"+t+"'");throw i.code="MODULE_NOT_FOUND",i}l.resolve=function(r){var o=e[t][1][r];return null!=o?o:r},l.cache={};var a=u[t]=new p.Module(t);e[t][0].call(a.exports,l,a,a.exports,f)}return u[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=c,this.exports={}},p.modules=e,p.cache=u,p.parent=d,p.distDir=void 0,p.publicUrl=void 0,p.devServer=void 0,p.i=l,p.register=function(t,r){e[t]=[function(e,t){t.exports=r},{}]},Object.defineProperty(p,"root",{get:function(){return f[o]}}),f[o]=p;for(var m=0;m<t.length;m++)p(t[m]);if(r){var h=p(r);"object"==typeof exports&&"undefined"!=typeof module?module.exports=h:"function"==typeof define&&define.amd&&define(function(){return h})}}({jz4E5:[function(e,t,r,o){e("@parcel/transformer-js/src/esmodule-helpers.js").defineInteropFlag(r);class n{static get iframe(){return window.top!==window}static postMessage({type:e,data:t,id:r=0}){if(!n.iframe)throw Error('The "ArtplayerPluginIframe.postMessage" method can only be used in iframe');window.parent.postMessage({type:e,data:t,id:r},"*")}static async onMessage(e){if(!n.iframe)throw Error('The "ArtplayerPluginIframe.onMessage" method can only be used in iframe');let{type:t,data:r,id:o}=e.data;if("commit"===t)try{if(r.match(/\bresolve\((.*?)\)/)){let e=`return new Promise(function(resolve){ ${r} })`,t=await Function(e)();n.postMessage({type:"response",data:t,id:o})}else{let e=Function(r)();n.postMessage({type:"response",data:e,id:o})}}catch(e){throw n.postMessage({type:"error",data:e.message,id:o}),e}}static inject(){if(!n.iframe)throw Error('The "ArtplayerPluginIframe.inject" method can only be used in iframe');n.postMessage({type:"inject"}),window.addEventListener("message",n.onMessage)}constructor({iframe:e,url:t}){if(e instanceof HTMLIFrameElement==!1)throw Error('"option.iframe" needs to be a HTMLIFrameElement');if("string"!=typeof t)throw Error('"option.url" needs to be a string');this.url=t,this.$iframe=e,this.promises={},this.injected=!1,this.destroyed=!1,this.messageCallback=()=>null,this.onMessage=this.onMessage.bind(this),window.addEventListener("message",this.onMessage),this.$iframe.src=this.url}onMessage(e){let{type:t,data:r,id:o}=e.data;"inject"===t&&(this.injected=!0),this.promises[o]&&("error"===t?this.promises[o].reject(Error(r)):this.promises[o].resove(r),delete this.promises[o]),this.messageCallback&&this.messageCallback({type:t,data:r})}postMessage({type:e,data:t}){return new Promise((r,o)=>{(function n(){if(this.destroyed)o(Error("The instance has been destroyed"));else if(this.injected){let n=Date.now();this.promises[n]={resove:r,reject:o},this.$iframe.contentWindow.postMessage({type:e,data:t,id:n},"*")}else setTimeout(n.bind(this),200)}).call(this)})}commit(e){if("function"!=typeof e)throw Error('"commit.callback" needs to be a function');let t=e.toString(),r=t.substring(t.indexOf("{")+1,t.lastIndexOf("}"));return this.postMessage({type:"commit",data:r})}message(e){if("function"!=typeof e)throw Error('"message.callback" needs to be a function');this.messageCallback=e}destroy(){this.destroyed=!0,window.removeEventListener("message",this.onMessage)}}r.default=n,"undefined"!=typeof window&&(window.ArtplayerPluginIframe=n)},{"@parcel/transformer-js/src/esmodule-helpers.js":"7o2zS"}],"7o2zS":[function(e,t,r,o){r.interopDefault=function(e){return e&&e.__esModule?e:{default:e}},r.defineInteropFlag=function(e){Object.defineProperty(e,"__esModule",{value:!0})},r.exportAll=function(e,t){return Object.keys(e).forEach(function(r){"default"===r||"__esModule"===r||Object.prototype.hasOwnProperty.call(t,r)||Object.defineProperty(t,r,{enumerable:!0,get:function(){return e[r]}})}),t},r.export=function(e,t,r){Object.defineProperty(e,t,{enumerable:!0,get:r})}},{}]},["jz4E5"],"jz4E5","parcelRequire92f7",{});
!function(e,t,r,o,n,s,i,a){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||{},u=d.cache||{},c="undefined"!=typeof module&&"function"==typeof module.require&&module.require.bind(module);function p(t,r){if(!u[t]){if(!e[t]){if(n[t])return n[t];var s="function"==typeof f[o]&&f[o];if(!r&&s)return s(t,!0);if(d)return d(t,!0);if(c&&"string"==typeof t)return c(t);var i=Error("Cannot find module '"+t+"'");throw i.code="MODULE_NOT_FOUND",i}l.resolve=function(r){var o=e[t][1][r];return null!=o?o:r},l.cache={};var a=u[t]=new p.Module(t);e[t][0].call(a.exports,l,a,a.exports,f)}return u[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=c,this.exports={}},p.modules=e,p.cache=u,p.parent=d,p.distDir=void 0,p.publicUrl=void 0,p.devServer=void 0,p.i=l,p.register=function(t,r){e[t]=[function(e,t){t.exports=r},{}]},Object.defineProperty(p,"root",{get:function(){return f[o]}}),f[o]=p;for(var m=0;m<t.length;m++)p(t[m]);if(r){var h=p(r);"object"==typeof exports&&"undefined"!=typeof module?module.exports=h:"function"==typeof define&&define.amd&&define(function(){return h})}}({jSFRI:[function(e,t,r,o){e("@parcel/transformer-js/src/esmodule-helpers.js").defineInteropFlag(r);class n{static get iframe(){return window.top!==window}static postMessage({type:e,data:t,id:r=0}){if(!n.iframe)throw Error('The "ArtplayerPluginIframe.postMessage" method can only be used in iframe');window.parent.postMessage({type:e,data:t,id:r},"*")}static async onMessage(e){if(!n.iframe)throw Error('The "ArtplayerPluginIframe.onMessage" method can only be used in iframe');let{type:t,data:r,id:o}=e.data;if("commit"===t)try{if(r.match(/\bresolve\((.*?)\)/)){let e=`return new Promise(function(resolve){ ${r} })`,t=await Function(e)();n.postMessage({type:"response",data:t,id:o})}else{let e=Function(r)();n.postMessage({type:"response",data:e,id:o})}}catch(e){throw n.postMessage({type:"error",data:e.message,id:o}),e}}static inject(){if(!n.iframe)throw Error('The "ArtplayerPluginIframe.inject" method can only be used in iframe');n.postMessage({type:"inject"}),window.addEventListener("message",n.onMessage)}constructor({iframe:e,url:t}){if(e instanceof HTMLIFrameElement==!1)throw TypeError('"option.iframe" needs to be a HTMLIFrameElement');if("string"!=typeof t)throw TypeError('"option.url" needs to be a string');this.url=t,this.$iframe=e,this.promises={},this.injected=!1,this.destroyed=!1,this.messageCallback=()=>null,this.onMessage=this.onMessage.bind(this),window.addEventListener("message",this.onMessage),this.$iframe.src=this.url}onMessage(e){let{type:t,data:r,id:o}=e.data;"inject"===t&&(this.injected=!0),this.promises[o]&&("error"===t?this.promises[o].reject(Error(r)):this.promises[o].resove(r),delete this.promises[o]),this.messageCallback&&this.messageCallback({type:t,data:r})}postMessage({type:e,data:t}){return new Promise((r,o)=>{(function n(){if(this.destroyed)o(Error("The instance has been destroyed"));else if(this.injected){let n=Date.now();this.promises[n]={resove:r,reject:o},this.$iframe.contentWindow.postMessage({type:e,data:t,id:n},"*")}else setTimeout(n.bind(this),200)}).call(this)})}commit(e){if("function"!=typeof e)throw TypeError('"commit.callback" needs to be a function');let t=e.toString(),r=t.substring(t.indexOf("{")+1,t.lastIndexOf("}"));return this.postMessage({type:"commit",data:r})}message(e){if("function"!=typeof e)throw TypeError('"message.callback" needs to be a function');this.messageCallback=e}destroy(){this.destroyed=!0,window.removeEventListener("message",this.onMessage)}}r.default=n,"undefined"!=typeof window&&(window.ArtplayerPluginIframe=n)},{"@parcel/transformer-js/src/esmodule-helpers.js":"6ykb1"}],"6ykb1":[function(e,t,r,o){r.interopDefault=function(e){return e&&e.__esModule?e:{default:e}},r.defineInteropFlag=function(e){Object.defineProperty(e,"__esModule",{value:!0})},r.exportAll=function(e,t){return Object.keys(e).forEach(function(r){"default"===r||"__esModule"===r||Object.prototype.hasOwnProperty.call(t,r)||Object.defineProperty(t,r,{enumerable:!0,get:function(){return e[r]}})}),t},r.export=function(e,t,r){Object.defineProperty(e,t,{enumerable:!0,get:r})}},{}]},["jSFRI"],"jSFRI","parcelRequire4dc0",{});
@@ -5,4 +5,4 @@
* (c) 2017-2025 Harvey Zack
* Released under the MIT License.
*/
!function(e,t,r,n,o,i,a,s){var c="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:{},u="function"==typeof c[n]&&c[n],f=u.i||{},l=u.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 c[n]&&c[n];if(!r&&i)return i(t,!0);if(u)return u(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(r){var n=e[t][1][r];return null!=n?n:r},f.cache={};var s=l[t]=new d.Module(t);e[t][0].call(s.exports,f,s,s.exports,c)}return l[t].exports;function f(e){var t=f.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=u,d.distDir=void 0,d.publicUrl=void 0,d.devServer=void 0,d.i=f,d.register=function(t,r){e[t]=[function(e,t){t.exports=r},{}]},Object.defineProperty(d,"root",{get:function(){return c[n]}}),c[n]=d;for(var y=0;y<t.length;y++)d(t[y]);if(r){var h=d(r);"object"==typeof exports&&"undefined"!=typeof module?module.exports=h:"function"==typeof define&&define.amd&&define(function(){return h})}}({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/_class_call_check.cjs"),s=e("@swc/helpers/cjs/_create_class.cjs"),c=e("@swc/helpers/cjs/_ts_generator.cjs"),u=function(){"use strict";function e(t){var r=t.iframe,n=t.url;if((0,a._)(this,e),r instanceof HTMLIFrameElement==!1)throw Error('"option.iframe" needs to be a HTMLIFrameElement');if("string"!=typeof n)throw Error('"option.url" needs to be a string');this.url=n,this.$iframe=r,this.promises={},this.injected=!1,this.destroyed=!1,this.messageCallback=function(){return null},this.onMessage=this.onMessage.bind(this),window.addEventListener("message",this.onMessage),this.$iframe.src=this.url}return(0,s._)(e,[{key:"onMessage",value:function(e){var t=e.data,r=t.type,n=t.data,o=t.id;"inject"===r&&(this.injected=!0),this.promises[o]&&("error"===r?this.promises[o].reject(Error(n)):this.promises[o].resove(n),delete this.promises[o]),this.messageCallback&&this.messageCallback({type:r,data:n})}},{key:"postMessage",value:function(e){var t=this,r=e.type,n=e.data;return new Promise(function(e,o){(function t(){if(this.destroyed)o(Error("The instance has been destroyed"));else if(this.injected){var i=Date.now();this.promises[i]={resove:e,reject:o},this.$iframe.contentWindow.postMessage({type:r,data:n,id:i},"*")}else setTimeout(t.bind(this),200)}).call(t)})}},{key:"commit",value:function(e){if("function"!=typeof e)throw Error('"commit.callback" needs to be a function');var t=e.toString(),r=t.substring(t.indexOf("{")+1,t.lastIndexOf("}"));return this.postMessage({type:"commit",data:r})}},{key:"message",value:function(e){if("function"!=typeof e)throw Error('"message.callback" needs to be a function');this.messageCallback=e}},{key:"destroy",value:function(){this.destroyed=!0,window.removeEventListener("message",this.onMessage)}}],[{key:"iframe",get:function(){return window.top!==window}},{key:"postMessage",value:function(t){var r=t.type,n=t.data,o=t.id;if(!e.iframe)throw Error('The "ArtplayerPluginIframe.postMessage" method can only be used in iframe');window.parent.postMessage({type:r,data:n,id:void 0===o?0:o},"*")}},{key:"onMessage",value:function(t){return(0,i._)(function(){var r,n,o,i,a,s,u;return(0,c._)(this,function(c){switch(c.label){case 0:if(!e.iframe)throw Error('The "ArtplayerPluginIframe.onMessage" method can only be used in iframe');if(n=(r=t.data).type,o=r.data,i=r.id,"commit"===n)return[3,1];return[3,7];case 1:if(c.trys.push([1,5,,6]),!o.match(/\bresolve\((.*?)\)/))return[3,3];return[4,Function("return new Promise(function(resolve){\n".concat(o,"\n})"))()];case 2:return a=c.sent(),e.postMessage({type:"response",data:a,id:i}),[3,4];case 3:s=Function(o)(),e.postMessage({type:"response",data:s,id:i}),c.label=4;case 4:return[3,6];case 5:throw u=c.sent(),e.postMessage({type:"error",data:u.message,id:i}),u;case 6:case 7:return[3,8];case 8:return[2]}})})()}},{key:"inject",value:function(){if(!e.iframe)throw Error('The "ArtplayerPluginIframe.inject" method can only be used in iframe');e.postMessage({type:"inject"}),window.addEventListener("message",e.onMessage)}}]),e}();"undefined"!=typeof window&&(window.ArtplayerPluginIframe=u)},{"@swc/helpers/cjs/_async_to_generator.cjs":"4ElRo","@swc/helpers/cjs/_class_call_check.cjs":"5Lt2s","@swc/helpers/cjs/_create_class.cjs":"fExy2","@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 s=e[i](a),c=s.value}catch(e){r(e);return}s.done?t(c):Promise.resolve(c).Line truncated
!function(e,t,r,n,o,i,a,s){var c="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:{},u="function"==typeof c[n]&&c[n],f=u.i||{},l=u.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 c[n]&&c[n];if(!r&&i)return i(t,!0);if(u)return u(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(r){var n=e[t][1][r];return null!=n?n:r},f.cache={};var s=l[t]=new d.Module(t);e[t][0].call(s.exports,f,s,s.exports,c)}return l[t].exports;function f(e){var t=f.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=u,d.distDir=void 0,d.publicUrl=void 0,d.devServer=void 0,d.i=f,d.register=function(t,r){e[t]=[function(e,t){t.exports=r},{}]},Object.defineProperty(d,"root",{get:function(){return c[n]}}),c[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 _})}}({"8IkGp":[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/_class_call_check.cjs"),s=e("@swc/helpers/cjs/_create_class.cjs"),c=e("@swc/helpers/cjs/_ts_generator.cjs"),u=function(){"use strict";function e(t){var r=t.iframe,n=t.url;if((0,a._)(this,e),r instanceof HTMLIFrameElement==!1)throw TypeError('"option.iframe" needs to be a HTMLIFrameElement');if("string"!=typeof n)throw TypeError('"option.url" needs to be a string');this.url=n,this.$iframe=r,this.promises={},this.injected=!1,this.destroyed=!1,this.messageCallback=function(){return null},this.onMessage=this.onMessage.bind(this),window.addEventListener("message",this.onMessage),this.$iframe.src=this.url}return(0,s._)(e,[{key:"onMessage",value:function(e){var t=e.data,r=t.type,n=t.data,o=t.id;"inject"===r&&(this.injected=!0),this.promises[o]&&("error"===r?this.promises[o].reject(Error(n)):this.promises[o].resove(n),delete this.promises[o]),this.messageCallback&&this.messageCallback({type:r,data:n})}},{key:"postMessage",value:function(e){var t=this,r=e.type,n=e.data;return new Promise(function(e,o){(function t(){if(this.destroyed)o(Error("The instance has been destroyed"));else if(this.injected){var i=Date.now();this.promises[i]={resove:e,reject:o},this.$iframe.contentWindow.postMessage({type:r,data:n,id:i},"*")}else setTimeout(t.bind(this),200)}).call(t)})}},{key:"commit",value:function(e){if("function"!=typeof e)throw TypeError('"commit.callback" needs to be a function');var t=e.toString(),r=t.substring(t.indexOf("{")+1,t.lastIndexOf("}"));return this.postMessage({type:"commit",data:r})}},{key:"message",value:function(e){if("function"!=typeof e)throw TypeError('"message.callback" needs to be a function');this.messageCallback=e}},{key:"destroy",value:function(){this.destroyed=!0,window.removeEventListener("message",this.onMessage)}}],[{key:"iframe",get:function(){return window.top!==window}},{key:"postMessage",value:function(t){var r=t.type,n=t.data,o=t.id;if(!e.iframe)throw Error('The "ArtplayerPluginIframe.postMessage" method can only be used in iframe');window.parent.postMessage({type:r,data:n,id:void 0===o?0:o},"*")}},{key:"onMessage",value:function(t){return(0,i._)(function(){var r,n,o,i,a,s,u;return(0,c._)(this,function(c){switch(c.label){case 0:if(!e.iframe)throw Error('The "ArtplayerPluginIframe.onMessage" method can only be used in iframe');if(n=(r=t.data).type,o=r.data,i=r.id,"commit"===n)return[3,1];return[3,7];case 1:if(c.trys.push([1,5,,6]),!o.match(/\bresolve\((.*?)\)/))return[3,3];return[4,Function("return new Promise(function(resolve){\n".concat(o,"\n})"))()];case 2:return a=c.sent(),e.postMessage({type:"response",data:a,id:i}),[3,4];case 3:s=Function(o)(),e.postMessage({type:"response",data:s,id:i}),c.label=4;case 4:return[3,6];case 5:throw u=c.sent(),e.postMessage({type:"error",data:u.message,id:i}),u;case 6:case 7:return[3,8];case 8:return[2]}})})()}},{key:"inject",value:function(){if(!e.iframe)throw Error('The "ArtplayerPluginIframe.inject" method can only be used in iframe');e.postMessage({type:"inject"}),window.addEventListener("message",e.onMessage)}}]),e}();"undefined"!=typeof window&&(window.ArtplayerPluginIframe=u)},{"@swc/helpers/cjs/_async_to_generator.cjs":"cZn0e","@swc/helpers/cjs/_class_call_check.cjs":"4Uf9M","@swc/helpers/cjs/_create_class.cjs":"igUuK","@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,a){try{var s=e[i](a),c=s.value}catch(e){r(e);return}s.done?t(c):ProLine truncated
+28 -28
View File
@@ -1,30 +1,30 @@
{
"license": "MIT",
"version": "1.0.0",
"name": "artplayer-plugin-iframe",
"description": "Iframe plugin for ArtPlayer",
"main": "dist/artplayer-plugin-iframe.js",
"legacy": "dist/artplayer-plugin-iframe.legacy.js",
"module": "dist/artplayer-plugin-iframe.esm.js",
"types": "types/artplayer-plugin-iframe.d.ts",
"exports": {
"import": "./dist/artplayer-plugin-iframe.esm.js",
"require": "./dist/artplayer-plugin-iframe.js",
"default": "./dist/artplayer-plugin-iframe.js"
},
"author": "Harvey Zack <laozhaochaguan@gmail.com>",
"browserslist": "last 1 Chrome version",
"homepage": "https://artplayer.org",
"repository": {
"type": "git",
"url": "git+https://github.com/zhw2590582/ArtPlayer.git"
},
"bugs": {
"url": "https://github.com/zhw2590582/ArtPlayer/issues"
},
"keywords": [
"html5",
"video",
"player"
]
"name": "artplayer-plugin-iframe",
"version": "1.0.0",
"description": "Iframe plugin for ArtPlayer",
"author": "Harvey Zack <laozhaochaguan@gmail.com>",
"license": "MIT",
"homepage": "https://artplayer.org",
"repository": {
"type": "git",
"url": "git+https://github.com/zhw2590582/ArtPlayer.git"
},
"bugs": {
"url": "https://github.com/zhw2590582/ArtPlayer/issues"
},
"keywords": [
"html5",
"video",
"player"
],
"exports": {
"import": "./dist/artplayer-plugin-iframe.esm.js",
"require": "./dist/artplayer-plugin-iframe.js",
"default": "./dist/artplayer-plugin-iframe.js"
},
"main": "dist/artplayer-plugin-iframe.js",
"legacy": "dist/artplayer-plugin-iframe.legacy.js",
"module": "dist/artplayer-plugin-iframe.esm.js",
"types": "types/artplayer-plugin-iframe.d.ts",
"browserslist": "last 1 Chrome version"
}
+129 -122
View File
@@ -1,151 +1,158 @@
export default class ArtplayerPluginIframe {
static get iframe() {
return window.top !== window;
static get iframe() {
return window.top !== window
}
static postMessage({ type, data, id = 0 }) {
if (!ArtplayerPluginIframe.iframe) {
throw new Error('The "ArtplayerPluginIframe.postMessage" method can only be used in iframe')
}
static postMessage({ type, data, id = 0 }) {
if (!ArtplayerPluginIframe.iframe) {
throw new Error('The "ArtplayerPluginIframe.postMessage" method can only be used in iframe');
}
window.parent.postMessage(
{
type,
data,
id,
},
'*',
)
}
window.parent.postMessage(
{
type: type,
data: data,
id: id,
},
'*',
);
static async onMessage(event) {
if (!ArtplayerPluginIframe.iframe) {
throw new Error('The "ArtplayerPluginIframe.onMessage" method can only be used in iframe')
}
static async onMessage(event) {
if (!ArtplayerPluginIframe.iframe) {
throw new Error('The "ArtplayerPluginIframe.onMessage" method can only be used in iframe');
const { type, data, id } = event.data
switch (type) {
case 'commit':
try {
if (data.match(/\bresolve\((.*?)\)/)) {
const string = `return new Promise(function(resolve){\n${data}\n})`
// eslint-disable-next-line no-new-func
const result = await new Function(string)()
ArtplayerPluginIframe.postMessage({ type: 'response', data: result, id })
}
else {
// eslint-disable-next-line no-new-func
const result = new Function(data)()
ArtplayerPluginIframe.postMessage({ type: 'response', data: result, id })
}
}
catch (error) {
ArtplayerPluginIframe.postMessage({ type: 'error', data: error.message, id })
throw error
}
break
default:
break
}
}
const { type, data, id } = event.data;
switch (type) {
case 'commit':
try {
if (data.match(/\bresolve\((.*?)\)/)) {
const string = `return new Promise(function(resolve){\n${data}\n})`;
const result = await new Function(string)();
ArtplayerPluginIframe.postMessage({ type: 'response', data: result, id });
} else {
const result = new Function(data)();
ArtplayerPluginIframe.postMessage({ type: 'response', data: result, id });
}
} catch (error) {
ArtplayerPluginIframe.postMessage({ type: 'error', data: error.message, id });
throw error;
}
break;
default:
break;
}
static inject() {
if (!ArtplayerPluginIframe.iframe) {
throw new Error('The "ArtplayerPluginIframe.inject" method can only be used in iframe')
}
static inject() {
if (!ArtplayerPluginIframe.iframe) {
throw new Error('The "ArtplayerPluginIframe.inject" method can only be used in iframe');
}
ArtplayerPluginIframe.postMessage({ type: 'inject' })
window.addEventListener('message', ArtplayerPluginIframe.onMessage)
}
ArtplayerPluginIframe.postMessage({ type: 'inject' });
window.addEventListener('message', ArtplayerPluginIframe.onMessage);
constructor({ iframe, url }) {
if (iframe instanceof HTMLIFrameElement === false) {
throw new TypeError('"option.iframe" needs to be a HTMLIFrameElement')
}
constructor({ iframe, url }) {
if (iframe instanceof HTMLIFrameElement === false) {
throw new Error('"option.iframe" needs to be a HTMLIFrameElement');
}
if (typeof url !== 'string') {
throw new Error('"option.url" needs to be a string');
}
this.url = url;
this.$iframe = iframe;
this.promises = {};
this.injected = false;
this.destroyed = false;
this.messageCallback = () => null;
this.onMessage = this.onMessage.bind(this);
window.addEventListener('message', this.onMessage);
this.$iframe.src = this.url;
if (typeof url !== 'string') {
throw new TypeError('"option.url" needs to be a string')
}
onMessage(event) {
const { type, data, id } = event.data;
this.url = url
this.$iframe = iframe
this.promises = {}
this.injected = false
this.destroyed = false
this.messageCallback = () => null
this.onMessage = this.onMessage.bind(this)
window.addEventListener('message', this.onMessage)
this.$iframe.src = this.url
}
switch (type) {
case 'inject':
this.injected = true;
break;
default:
break;
}
onMessage(event) {
const { type, data, id } = event.data
if (this.promises[id]) {
if (type === 'error') {
this.promises[id].reject(new Error(data));
} else {
this.promises[id].resove(data);
}
delete this.promises[id];
}
if (this.messageCallback) {
this.messageCallback({ type, data });
}
switch (type) {
case 'inject':
this.injected = true
break
default:
break
}
postMessage({ type, data }) {
return new Promise((resove, reject) => {
(function loop() {
if (this.destroyed) {
reject(new Error('The instance has been destroyed'));
} else {
if (this.injected) {
const id = Date.now();
this.promises[id] = { resove, reject };
this.$iframe.contentWindow.postMessage(
{
type: type,
data: data,
id: id,
},
'*',
);
} else {
setTimeout(loop.bind(this), 200);
}
}
}).call(this);
});
if (this.promises[id]) {
if (type === 'error') {
this.promises[id].reject(new Error(data))
}
else {
this.promises[id].resove(data)
}
delete this.promises[id]
}
commit(callback) {
if (typeof callback !== 'function') {
throw new Error('"commit.callback" needs to be a function');
if (this.messageCallback) {
this.messageCallback({ type, data })
}
}
postMessage({ type, data }) {
return new Promise((resove, reject) => {
(function loop() {
if (this.destroyed) {
reject(new Error('The instance has been destroyed'))
}
const callbackString = callback.toString();
const bodyString = callbackString.substring(callbackString.indexOf('{') + 1, callbackString.lastIndexOf('}'));
return this.postMessage({ type: 'commit', data: bodyString });
}
message(callback) {
if (typeof callback !== 'function') {
throw new Error('"message.callback" needs to be a function');
else {
if (this.injected) {
const id = Date.now()
this.promises[id] = { resove, reject }
this.$iframe.contentWindow.postMessage(
{
type,
data,
id,
},
'*',
)
}
else {
setTimeout(loop.bind(this), 200)
}
}
this.messageCallback = callback;
}
}).call(this)
})
}
destroy() {
this.destroyed = true;
window.removeEventListener('message', this.onMessage);
commit(callback) {
if (typeof callback !== 'function') {
throw new TypeError('"commit.callback" needs to be a function')
}
const callbackString = callback.toString()
const bodyString = callbackString.substring(callbackString.indexOf('{') + 1, callbackString.lastIndexOf('}'))
return this.postMessage({ type: 'commit', data: bodyString })
}
message(callback) {
if (typeof callback !== 'function') {
throw new TypeError('"message.callback" needs to be a function')
}
this.messageCallback = callback
}
destroy() {
this.destroyed = true
window.removeEventListener('message', this.onMessage)
}
}
if (typeof window !== 'undefined') {
window['ArtplayerPluginIframe'] = ArtplayerPluginIframe;
window.ArtplayerPluginIframe = ArtplayerPluginIframe
}
@@ -1,30 +1,30 @@
export = ArtplayerPluginIframe;
export = ArtplayerPluginIframe
export as namespace ArtplayerPluginIframe;
type Message = {
type: string;
data: any;
id?: number;
};
interface Message {
type: string
data: any
id?: number
}
declare class ArtplayerPluginIframe {
constructor(option: { iframe: HTMLIFrameElement; url: string });
constructor(option: { iframe: HTMLIFrameElement, url: string })
static iframe: boolean;
static postMessage(message: Message): void;
static onMessage(event: MessageEvent & { data: Message }): void;
static inject(): void;
static iframe: boolean
static postMessage(message: Message): void
static onMessage(event: MessageEvent & { data: Message }): void
static inject(): void
readonly promises: Record<number, { resove: Function; reject: Function }>;
readonly injected: boolean;
readonly destroyed: boolean;
readonly $iframe: HTMLIFrameElement;
readonly url: string;
readonly messageCallback: (...args: any[]) => any;
readonly promises: Record<number, { resove: Function, reject: Function }>
readonly injected: boolean
readonly destroyed: boolean
readonly $iframe: HTMLIFrameElement
readonly url: string
readonly messageCallback: (...args: any[]) => any
onMessage(event: MessageEvent & { data: Message }): void;
postMessage(message: Message): Promise<any>;
commit<T extends (...args: any[]) => any>(callback: T): Promise<ReturnType<T>>;
message(callback: (...args: any[]) => any): void;
destroy(): void;
onMessage(event: MessageEvent & { data: Message }): void
postMessage(message: Message): Promise<any>
commit<T extends (...args: any[]) => any>(callback: T): Promise<ReturnType<T>>
message(callback: (...args: any[]) => any): void
destroy(): void
}