import module from "./lib/tiff_wasm.js";

const { FS, callMain } = await module();

self.onmessage = (event) => {
    FS.writeFile("/input.tiff", new Uint8Array(event.data.response));
    callMain(["/input.tiff", "/output.jpg"]);
    const response = FS.readFile("/output.jpg");
    self.postMessage({ response }, [response.buffer]);
};

postMessage("READY");
