import { removeBackground } from '@imgly/background-removal'; self.onmessage = async (event: MessageEvent) => { const { imagePath, doc, addDoc } = event.data; try { // Perform the background removal const result = await removeBackground(imagePath); // Send the result back to the main thread self.postMessage({ success: true, result, doc, addDoc }); } catch (error) { // Send the error back to the main thread self.postMessage({ success: false, error: (error as any).message }); } };