From 0e136f298e8fe8b6667584762cea735ba6ad5a1b Mon Sep 17 00:00:00 2001 From: Princesseuh Date: Mon, 16 Jan 2023 12:35:17 +0100 Subject: [PATCH] fix(squoosh): Remove fetch of local wasm binary since undici doesn't support that --- .../src/vendor/squoosh/avif/avif_node_dec.ts | 36 +------------------ .../src/vendor/squoosh/avif/avif_node_enc.ts | 36 +------------------ .../squoosh/mozjpeg/mozjpeg_node_dec.ts | 36 +------------------ .../squoosh/mozjpeg/mozjpeg_node_enc.ts | 36 +------------------ .../src/vendor/squoosh/webp/webp_node_dec.ts | 36 +------------------ .../src/vendor/squoosh/webp/webp_node_enc.ts | 36 +------------------ 6 files changed, 6 insertions(+), 210 deletions(-) diff --git a/packages/integrations/image/src/vendor/squoosh/avif/avif_node_dec.ts b/packages/integrations/image/src/vendor/squoosh/avif/avif_node_dec.ts index cc076bb2b821..8f2bbbbf8c15 100644 --- a/packages/integrations/image/src/vendor/squoosh/avif/avif_node_dec.ts +++ b/packages/integrations/image/src/vendor/squoosh/avif/avif_node_dec.ts @@ -384,22 +384,6 @@ var Module = (function () { } } function getBinaryPromise() { - if (!wasmBinary && (ENVIRONMENT_IS_WEB || ENVIRONMENT_IS_WORKER)) { - if (typeof fetch === 'function') { - return fetch(wasmBinaryFile, { credentials: 'same-origin' }) - .then(function (response) { - if (!response['ok']) { - throw ( - "failed to load wasm binary file at '" + wasmBinaryFile + "'" - ) - } - return response['arrayBuffer']() - }) - .catch(function () { - return getBinary(wasmBinaryFile) - }) - } - } return Promise.resolve().then(function () { return getBinary(wasmBinaryFile) }) @@ -431,25 +415,7 @@ var Module = (function () { }) } function instantiateAsync() { - if ( - !wasmBinary && - typeof WebAssembly.instantiateStreaming === 'function' && - !isDataURI(wasmBinaryFile) && - typeof fetch === 'function' - ) { - return fetch(wasmBinaryFile, { credentials: 'same-origin' }).then( - function (response) { - var result = WebAssembly.instantiateStreaming(response, info) - return result.then(receiveInstantiationResult, function (reason) { - err('wasm streaming compile failed: ' + reason) - err('falling back to ArrayBuffer instantiation') - return instantiateArrayBuffer(receiveInstantiationResult) - }) - } - ) - } else { - return instantiateArrayBuffer(receiveInstantiationResult) - } + return instantiateArrayBuffer(receiveInstantiationResult) } if (Module['instantiateWasm']) { try { diff --git a/packages/integrations/image/src/vendor/squoosh/avif/avif_node_enc.ts b/packages/integrations/image/src/vendor/squoosh/avif/avif_node_enc.ts index 8d4fa44097e3..cc1a3df22efd 100644 --- a/packages/integrations/image/src/vendor/squoosh/avif/avif_node_enc.ts +++ b/packages/integrations/image/src/vendor/squoosh/avif/avif_node_enc.ts @@ -384,22 +384,6 @@ var Module = (function () { } } function getBinaryPromise() { - if (!wasmBinary && (ENVIRONMENT_IS_WEB || ENVIRONMENT_IS_WORKER)) { - if (typeof fetch === 'function') { - return fetch(wasmBinaryFile, { credentials: 'same-origin' }) - .then(function (response) { - if (!response['ok']) { - throw ( - "failed to load wasm binary file at '" + wasmBinaryFile + "'" - ) - } - return response['arrayBuffer']() - }) - .catch(function () { - return getBinary(wasmBinaryFile) - }) - } - } return Promise.resolve().then(function () { return getBinary(wasmBinaryFile) }) @@ -431,25 +415,7 @@ var Module = (function () { }) } function instantiateAsync() { - if ( - !wasmBinary && - typeof WebAssembly.instantiateStreaming === 'function' && - !isDataURI(wasmBinaryFile) && - typeof fetch === 'function' - ) { - return fetch(wasmBinaryFile, { credentials: 'same-origin' }).then( - function (response) { - var result = WebAssembly.instantiateStreaming(response, info) - return result.then(receiveInstantiationResult, function (reason) { - err('wasm streaming compile failed: ' + reason) - err('falling back to ArrayBuffer instantiation') - return instantiateArrayBuffer(receiveInstantiationResult) - }) - } - ) - } else { - return instantiateArrayBuffer(receiveInstantiationResult) - } + return instantiateArrayBuffer(receiveInstantiationResult) } if (Module['instantiateWasm']) { try { diff --git a/packages/integrations/image/src/vendor/squoosh/mozjpeg/mozjpeg_node_dec.ts b/packages/integrations/image/src/vendor/squoosh/mozjpeg/mozjpeg_node_dec.ts index f18f5db1be6a..7e8e62c3bfcb 100644 --- a/packages/integrations/image/src/vendor/squoosh/mozjpeg/mozjpeg_node_dec.ts +++ b/packages/integrations/image/src/vendor/squoosh/mozjpeg/mozjpeg_node_dec.ts @@ -391,22 +391,6 @@ var Module = (function () { } } function getBinaryPromise() { - if (!wasmBinary && (ENVIRONMENT_IS_WEB || ENVIRONMENT_IS_WORKER)) { - if (typeof fetch === 'function') { - return fetch(wasmBinaryFile, { credentials: 'same-origin' }) - .then(function (response) { - if (!response['ok']) { - throw ( - "failed to load wasm binary file at '" + wasmBinaryFile + "'" - ) - } - return response['arrayBuffer']() - }) - .catch(function () { - return getBinary(wasmBinaryFile) - }) - } - } return Promise.resolve().then(function () { return getBinary(wasmBinaryFile) }) @@ -438,25 +422,7 @@ var Module = (function () { }) } function instantiateAsync() { - if ( - !wasmBinary && - typeof WebAssembly.instantiateStreaming === 'function' && - !isDataURI(wasmBinaryFile) && - typeof fetch === 'function' - ) { - return fetch(wasmBinaryFile, { credentials: 'same-origin' }).then( - function (response) { - var result = WebAssembly.instantiateStreaming(response, info) - return result.then(receiveInstantiationResult, function (reason) { - err('wasm streaming compile failed: ' + reason) - err('falling back to ArrayBuffer instantiation') - return instantiateArrayBuffer(receiveInstantiationResult) - }) - } - ) - } else { - return instantiateArrayBuffer(receiveInstantiationResult) - } + return instantiateArrayBuffer(receiveInstantiationResult) } if (Module['instantiateWasm']) { try { diff --git a/packages/integrations/image/src/vendor/squoosh/mozjpeg/mozjpeg_node_enc.ts b/packages/integrations/image/src/vendor/squoosh/mozjpeg/mozjpeg_node_enc.ts index 283884bbb1d1..82f274648256 100644 --- a/packages/integrations/image/src/vendor/squoosh/mozjpeg/mozjpeg_node_enc.ts +++ b/packages/integrations/image/src/vendor/squoosh/mozjpeg/mozjpeg_node_enc.ts @@ -391,22 +391,6 @@ var Module = (function () { } } function getBinaryPromise() { - if (!wasmBinary && (ENVIRONMENT_IS_WEB || ENVIRONMENT_IS_WORKER)) { - if (typeof fetch === 'function') { - return fetch(wasmBinaryFile, { credentials: 'same-origin' }) - .then(function (response) { - if (!response['ok']) { - throw ( - "failed to load wasm binary file at '" + wasmBinaryFile + "'" - ) - } - return response['arrayBuffer']() - }) - .catch(function () { - return getBinary(wasmBinaryFile) - }) - } - } return Promise.resolve().then(function () { return getBinary(wasmBinaryFile) }) @@ -438,25 +422,7 @@ var Module = (function () { }) } function instantiateAsync() { - if ( - !wasmBinary && - typeof WebAssembly.instantiateStreaming === 'function' && - !isDataURI(wasmBinaryFile) && - typeof fetch === 'function' - ) { - return fetch(wasmBinaryFile, { credentials: 'same-origin' }).then( - function (response) { - var result = WebAssembly.instantiateStreaming(response, info) - return result.then(receiveInstantiationResult, function (reason) { - err('wasm streaming compile failed: ' + reason) - err('falling back to ArrayBuffer instantiation') - return instantiateArrayBuffer(receiveInstantiationResult) - }) - } - ) - } else { - return instantiateArrayBuffer(receiveInstantiationResult) - } + return instantiateArrayBuffer(receiveInstantiationResult) } if (Module['instantiateWasm']) { try { diff --git a/packages/integrations/image/src/vendor/squoosh/webp/webp_node_dec.ts b/packages/integrations/image/src/vendor/squoosh/webp/webp_node_dec.ts index b23af7bf0738..12c9f39216a5 100644 --- a/packages/integrations/image/src/vendor/squoosh/webp/webp_node_dec.ts +++ b/packages/integrations/image/src/vendor/squoosh/webp/webp_node_dec.ts @@ -367,22 +367,6 @@ var Module = (function () { } } function getBinaryPromise() { - if (!wasmBinary && (ENVIRONMENT_IS_WEB || ENVIRONMENT_IS_WORKER)) { - if (typeof fetch === 'function') { - return fetch(wasmBinaryFile, { credentials: 'same-origin' }) - .then(function (response) { - if (!response['ok']) { - throw ( - "failed to load wasm binary file at '" + wasmBinaryFile + "'" - ) - } - return response['arrayBuffer']() - }) - .catch(function () { - return getBinary(wasmBinaryFile) - }) - } - } return Promise.resolve().then(function () { return getBinary(wasmBinaryFile) }) @@ -414,25 +398,7 @@ var Module = (function () { }) } function instantiateAsync() { - if ( - !wasmBinary && - typeof WebAssembly.instantiateStreaming === 'function' && - !isDataURI(wasmBinaryFile) && - typeof fetch === 'function' - ) { - return fetch(wasmBinaryFile, { credentials: 'same-origin' }).then( - function (response) { - var result = WebAssembly.instantiateStreaming(response, info) - return result.then(receiveInstantiationResult, function (reason) { - err('wasm streaming compile failed: ' + reason) - err('falling back to ArrayBuffer instantiation') - return instantiateArrayBuffer(receiveInstantiationResult) - }) - } - ) - } else { - return instantiateArrayBuffer(receiveInstantiationResult) - } + return instantiateArrayBuffer(receiveInstantiationResult) } if (Module['instantiateWasm']) { try { diff --git a/packages/integrations/image/src/vendor/squoosh/webp/webp_node_enc.ts b/packages/integrations/image/src/vendor/squoosh/webp/webp_node_enc.ts index c34118ebeda6..aa4a139eb465 100644 --- a/packages/integrations/image/src/vendor/squoosh/webp/webp_node_enc.ts +++ b/packages/integrations/image/src/vendor/squoosh/webp/webp_node_enc.ts @@ -367,22 +367,6 @@ var Module = (function () { } } function getBinaryPromise() { - if (!wasmBinary && (ENVIRONMENT_IS_WEB || ENVIRONMENT_IS_WORKER)) { - if (typeof fetch === 'function') { - return fetch(wasmBinaryFile, { credentials: 'same-origin' }) - .then(function (response) { - if (!response['ok']) { - throw ( - "failed to load wasm binary file at '" + wasmBinaryFile + "'" - ) - } - return response['arrayBuffer']() - }) - .catch(function () { - return getBinary(wasmBinaryFile) - }) - } - } return Promise.resolve().then(function () { return getBinary(wasmBinaryFile) }) @@ -414,25 +398,7 @@ var Module = (function () { }) } function instantiateAsync() { - if ( - !wasmBinary && - typeof WebAssembly.instantiateStreaming === 'function' && - !isDataURI(wasmBinaryFile) && - typeof fetch === 'function' - ) { - return fetch(wasmBinaryFile, { credentials: 'same-origin' }).then( - function (response) { - var result = WebAssembly.instantiateStreaming(response, info) - return result.then(receiveInstantiationResult, function (reason) { - err('wasm streaming compile failed: ' + reason) - err('falling back to ArrayBuffer instantiation') - return instantiateArrayBuffer(receiveInstantiationResult) - }) - } - ) - } else { - return instantiateArrayBuffer(receiveInstantiationResult) - } + return instantiateArrayBuffer(receiveInstantiationResult) } if (Module['instantiateWasm']) { try {