Skip to content

Commit

Permalink
fix(squoosh): Remove fetch of local wasm binary since undici doesn't …
Browse files Browse the repository at this point in the history
…support that
  • Loading branch information
Princesseuh committed Jan 16, 2023
1 parent ec6bc6d commit 0e136f2
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 210 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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)
})
Expand Down Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
})
Expand Down Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
})
Expand Down Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
})
Expand Down Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
})
Expand Down Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
})
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 0e136f2

Please sign in to comment.