@anu3ev/fabric-image-editor 0.6.7 → 0.6.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,2 @@
1
+ (function(){self.onmessage=async e=>{let{action:t,payload:n,requestId:r}=e.data;try{switch(t){case`resizeImage`:{let{dataURL:e,maxWidth:i,maxHeight:a,minWidth:o,minHeight:s,contentType:c,quality:l,sizeType:u}=n,d=await createImageBitmap(await(await fetch(e)).blob()),{width:f,height:p}=d,m=Math.min(i/f,a/p);u===`min`&&(m=Math.max(o/f,s/p)),f=Math.floor(f*m),p=Math.floor(p*m);let h=new OffscreenCanvas(f,p),g=h.getContext(`2d`);if(!g)throw Error(`Failed to get 2D context from OffscreenCanvas`);g.drawImage(d,0,0,f,p);let _=await h.convertToBlob({type:c,quality:l});self.postMessage({requestId:r,action:t,success:!0,data:_});break}case`toDataURL`:{let{bitmap:e,contentType:i,quality:a,returnBlob:o}=n,{width:s,height:c}=e,l=new OffscreenCanvas(e.width,e.height),u=l.getContext(`2d`);if(!u)throw Error(`Failed to get 2D context from OffscreenCanvas`);u.drawImage(e,0,0,s,c);let d=await l.convertToBlob({type:i,quality:a});if(o){self.postMessage({requestId:r,action:t,success:!0,data:d});break}let f=await new Promise(e=>{let t=new FileReader;t.onload=()=>e(t.result),t.readAsDataURL(d)});self.postMessage({requestId:r,action:t,success:!0,data:f});break}default:throw Error(`Unknown action ${t}`)}}catch(e){self.postMessage({requestId:r,action:t,success:!1,error:e.message})}}})();
2
+ //# sourceMappingURL=worker-CA0Zz9Rg.js.map