// epg-worker.js — module worker that parses XMLTV off the main thread. // // Keeps the guide responsive when a 50MB+ EPG feed lands: the expensive parse // happens here, the main thread only receives the finished program array. // Launched as `new Worker('./epg-worker.js', { type: 'module' })`. import { parseXmltv } from './lib/xmltv-parse.js'; self.onmessage = (e) => { const { id, xml } = e.data || {}; try { const programs = parseXmltv(xml); self.postMessage({ id, ok: true, programs }); } catch (err) { self.postMessage({ id, ok: false, error: String(err) }); } };