Skip to content

Commit

Permalink
feat(wasm): only run worker.js effect in WorkerGlobalScope
Browse files Browse the repository at this point in the history
  • Loading branch information
tim-hm committed Aug 1, 2024
1 parent c750bb3 commit 0ed1172
Showing 1 changed file with 30 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,28 +11,33 @@ export function startWorker(e, o, t, r, s) {
);
}

"WorkerGlobalScope" in self &&
self instanceof WorkerGlobalScope &&
(self.onmessage = async (e) => {
let [o, t, r, s] = e.data;
const a =
"function" == typeof __webpack_require__
? import("../../../index.js")
: import(s);
try {
const { default: e, worker_entry_point: s } = await a;
await e(o, t),
s(r),
postMessage("started"),
(self.onmessage = (e) => {
console.error("Unexpected message", e);
});
} catch (e) {
throw (
(setTimeout(() => {
throw e;
}),
e)
);
}
});
if (
typeof WorkerGlobalScope !== "undefined" &&
self instanceof WorkerGlobalScope
) {
"WorkerGlobalScope" in self &&
self instanceof WorkerGlobalScope &&
(self.onmessage = async (e) => {
let [o, t, r, s] = e.data;
const a =
"function" == typeof __webpack_require__
? import("../../../index.js")
: import(s);
try {
const { default: e, worker_entry_point: s } = await a;
await e(o, t),
s(r),
postMessage("started"),
(self.onmessage = (e) => {
console.error("Unexpected message", e);
});
} catch (e) {
throw (
(setTimeout(() => {
throw e;
}),
e)
);
}
});
}

0 comments on commit 0ed1172

Please sign in to comment.