Skip to content

Commit

Permalink
chore(resize): ensure resize js contains patch script
Browse files Browse the repository at this point in the history
  • Loading branch information
jamsinclair committed Apr 2, 2024
1 parent a5cdb09 commit cec51d2
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions packages/resize/lib/resize/pkg/squoosh_resize.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,3 +157,27 @@ async function __wbg_init(input) {

export { initSync }
export default __wbg_init;
const isServiceWorker = globalThis.ServiceWorkerGlobalScope !== undefined;
const isRunningInCloudFlareWorkers = isServiceWorker && typeof self !== 'undefined' && globalThis.caches && globalThis.caches.default !== undefined;
const isRunningInNode = typeof process === 'object' && process.release && process.release.name === 'node';

if (isRunningInCloudFlareWorkers || isRunningInNode) {
if (!globalThis.ImageData) {
// Simple Polyfill for ImageData Object
globalThis.ImageData = class ImageData {
constructor(data, width, height) {
this.data = data;
this.width = width;
this.height = height;
}
};
}

if (import.meta.url === undefined) {
import.meta.url = 'https://localhost';
}

if (typeof self !== 'undefined' && self.location === undefined) {
self.location = { href: '' };
}
}

0 comments on commit cec51d2

Please sign in to comment.