/** worker.js — HEIC 编码工作线程（避免阻塞 UI） */
import { encodeHeicWithLivePhotoMeta } from './heic.js';

self.onmessage = async (ev) => {
  const { id, rgba, width, height, quality, exifTiff, uuid } = ev.data;
  try {
    const heic = await encodeHeicWithLivePhotoMeta(rgba, width, height, quality, exifTiff, uuid);
    self.postMessage({ id, ok: true, heic }, [heic.buffer]);
  } catch (e) {
    self.postMessage({ id, ok: false, error: String(e && e.message || e) });
  }
};
