export class WorkerWrapper{constructor(e){this._workerPromise=new Promise((s=>{const r=new Worker(e,{type:"module"});r.onmessage=e=>{console.assert("workerReady"===e.data),r.onmessage=null,s(r)}}))}static fromURL(e){return new WorkerWrapper(e)}postMessage(e){this._workerPromise.then((s=>{this._disposed||s.postMessage(e)}))}dispose(){this._disposed=!0,this._workerPromise.then((e=>e.terminate()))}terminate(){this.dispose()}set onmessage(e){this._workerPromise.then((s=>{s.onmessage=e}))}set onerror(e){this._workerPromise.then((s=>{s.onerror=e}))}}