(name)
| 34 | const hostUrls = { ...(opts?.defaults !== false ? DEFAULT_HOST : {}), ...(opts?.hostModules || {}) }; |
| 35 | const loadedHosts = new Map(); // name -> export names, memoized across runs |
| 36 | const loadHostModule = async (name) => { |
| 37 | if (loadedHosts.has(name)) return loadedHosts.get(name); |
| 38 | const url = hostUrls[name]; |
| 39 | if (!url) throw new Error(`no host module registered for '${name}'`); |
| 40 | const mod = await import(url); |
| 41 | const factory = mod[name] ?? mod.default; |
| 42 | const handlers = typeof factory === 'function' ? factory({ pushEvent }) : factory; |
| 43 | for (const [fnName, handler] of Object.entries(handlers)) { |
| 44 | mainThreadHandlers[`${name}:${fnName}`] = handler; |
| 45 | } |
| 46 | const exports = Object.keys(handlers); |
| 47 | loadedHosts.set(name, exports); |
| 48 | return exports; |
| 49 | }; |
| 50 | |
| 51 | worker.onmessage = async ({ data }) => { |
| 52 | if (data.type === 'line') { |
no test coverage detected