(type, payload = {})
| 90 | }; |
| 91 | |
| 92 | const send = (type, payload = {}) => new Promise((resolve, reject) => { |
| 93 | const reqId = ++reqIdCounter; |
| 94 | pending.set(reqId, { resolve, reject }); |
| 95 | worker.postMessage({ type, reqId, ...payload }); |
| 96 | }); |
| 97 | |
| 98 | /* Strip mainThreadModules/hostModules before crossing postMessage: not structured-cloneable / loaded on the page. The worker only needs eager manifests and the lazy host names. */ |
| 99 | const { mainThreadModules: _drop, hostModules: _dropHosts, ...workerOpts } = opts || {}; |