/*! HEIC decoding uses libheif-js 1.23.5 / libheif / libde265 (LGPL-3.0). * Licenses, corresponding source and rebuild instructions: /third-party/heic/index.html */ // This entire module (including embedded WASM) loads only when a HEIC fallback // starts. It never fetches a codec or photo from another origin. import createLibheif from 'libheif-js/libheif-wasm/libheif-bundle.mjs'; import { decodeHeicPixels, encodeHeicPixels } from './heicDecodeCore.js'; globalThis.onmessage = async ({ data }) => { try { const libheif = await createLibheif({ print: () => {}, printErr: () => {} }); const pixels = await decodeHeicPixels(data.buffer, libheif, data.profile); const blob = await encodeHeicPixels(pixels, data.profile); globalThis.postMessage({ blob }); } catch (error) { const code = /^HEIC_[A-Z_]+$/.test(error?.code || '') ? error.code : 'HEIC_DECODE_FAILED'; globalThis.postMessage({ error: code }); } };