UNPKG

@tsparticles/plugin-export-image

Version:

tsParticles export image plugin

2 lines 1.29 kB
/*! For license information please see tsparticles.plugin.export.image.min.js.LICENSE.txt */ !function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var o=t();for(var n in o)("object"==typeof exports?exports:e)[n]=o[n]}}(this,(()=>(()=>{var e={d:(t,o)=>{for(var n in o)e.o(o,n)&&!e.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:o[n]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};e.r(t),e.d(t,{loadExportImagePlugin:()=>r});class o{constructor(e,t){this._exportImage=async e=>{const t=this._container.canvas.element;if(t)return new Promise((o=>{t.toBlob((e=>{o(e||void 0)}),e.type??"image/png",e.quality)}))},this._container=e,this._engine=t}async export(e,t){const o={supported:!1};if("image"===e)o.supported=!0,o.blob=await this._exportImage(t);return o}}class n{constructor(e){this.id="export-image",this._engine=e}getPlugin(e){return Promise.resolve(new o(e,this._engine))}loadOptions(){}needsPlugin(){return!0}}async function r(e,t=!0){e.checkVersion("3.9.1"),await e.addPlugin(new n(e),t)}return t})()));