Skip to content

Commit

Permalink
fix(): worker support for safari (#2869)
Browse files Browse the repository at this point in the history
  • Loading branch information
manucorporat committed Mar 30, 2021
1 parent 17a2fee commit f91548f
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/compiler/bundle/worker-plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -196,12 +196,18 @@ const WORKER_SUFFIX = ['.worker.ts', '.worker.tsx', '.worker/index.ts', '.worker
const WORKER_HELPER_ID = '@worker-helper';

const GET_TRANSFERABLES = `
const isInstanceOf = (value, className) => {
const C = globalThis[className];
return C != null && value instanceof C;
}
const getTransferables = (value) => {
if (value != null) {
if (value instanceof ArrayBuffer
|| value instanceof MessagePort
|| value instanceof ImageBitmap
|| value instanceof OffscreenCanvas) {
if (
isInstanceOf(value, "ArrayBuffer") ||
isInstanceOf(value, "MessagePort") ||
isInstanceOf(value, "ImageBitmap") ||
isInstanceOf(value, "OffscreenCanvas")
) {
return [value];
}
if (typeof value === "object") {
Expand Down

0 comments on commit f91548f

Please sign in to comment.