Skip to content

Commit

Permalink
fix(): worker support for safari (ionic-team#2869)
Browse files Browse the repository at this point in the history
  • Loading branch information
manucorporat authored and John Jenkins committed Apr 8, 2021
1 parent 2ff9b9d commit 67689ed
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 67689ed

Please sign in to comment.