diff --git a/packages/integrations/image/src/build/ssg.ts b/packages/integrations/image/src/build/ssg.ts index 964a6d367..4cf418ad0 100644 --- a/packages/integrations/image/src/build/ssg.ts +++ b/packages/integrations/image/src/build/ssg.ts @@ -9,7 +9,6 @@ import type { SSRImageService, TransformOptions } from '../loaders/index.js'; import { loadLocalImage, loadRemoteImage } from '../utils/images.js'; import { debug, info, LoggerLevel, warn } from '../utils/logger.js'; import { isRemoteImage } from '../utils/paths.js'; -import { processBuffer } from '../vendor/squoosh/main.js'; function getTimeStat(timeStart: number, timeEnd: number) { const buildTime = timeEnd - timeStart; diff --git a/packages/integrations/image/src/vendor/squoosh/codecs.ts b/packages/integrations/image/src/vendor/squoosh/codecs.ts index 94cca5d61..ace08a317 100644 --- a/packages/integrations/image/src/vendor/squoosh/codecs.ts +++ b/packages/integrations/image/src/vendor/squoosh/codecs.ts @@ -83,8 +83,8 @@ const resizeInit = () => resize.default(fsp.readFile(pathify(resizeWasm.toString const rotateWasm = new URL('./rotate/rotate.wasm', import.meta.url) // Our decoders currently rely on a `ImageData` global. -import ImageData from './image_data.js' -;(global as any).ImageData = ImageData +import ImageData from './image_data.js'; +(global as any).ImageData = ImageData function resizeNameToIndex( name: 'triangle' | 'catrom' | 'mitchell' | 'lanczos3' diff --git a/packages/integrations/image/src/vendor/squoosh/impl.ts b/packages/integrations/image/src/vendor/squoosh/impl.ts index f02c06675..c0fd26843 100644 --- a/packages/integrations/image/src/vendor/squoosh/impl.ts +++ b/packages/integrations/image/src/vendor/squoosh/impl.ts @@ -72,7 +72,7 @@ export async function resize({ image, width, height }: ResizeOpts) { export async function encodeJpeg( image: ImageData, { quality }: { quality: number } -): Promise { +): Promise { image = ImageData.from(image) const e = supportedFormats['mozjpeg'] @@ -88,7 +88,7 @@ export async function encodeJpeg( export async function encodeWebp( image: ImageData, { quality }: { quality: number } -): Promise { +): Promise { image = ImageData.from(image) const e = supportedFormats['webp'] @@ -104,7 +104,7 @@ export async function encodeWebp( export async function encodeAvif( image: ImageData, { quality }: { quality: number } -): Promise { +): Promise { image = ImageData.from(image) const e = supportedFormats['avif'] @@ -122,7 +122,7 @@ export async function encodeAvif( export async function encodePng( image: ImageData -): Promise { +): Promise { image = ImageData.from(image) const e = supportedFormats['oxipng'] diff --git a/packages/integrations/image/src/vendor/squoosh/main.ts b/packages/integrations/image/src/vendor/squoosh/main.ts index d669e720b..a0e1c8564 100644 --- a/packages/integrations/image/src/vendor/squoosh/main.ts +++ b/packages/integrations/image/src/vendor/squoosh/main.ts @@ -33,13 +33,13 @@ export async function processBuffer( switch (encoding) { case 'jpeg': case 'jpg': - return Buffer.from(await worker.encodeJpeg(imageData, { quality })) + return await worker.encodeJpeg(imageData, { quality }) case 'webp': - return Buffer.from(await worker.encodeWebp(imageData, { quality })) + return await worker.encodeWebp(imageData, { quality }) case 'avif': - return Buffer.from(await worker.encodeAvif(imageData, { quality })) + return await worker.encodeAvif(imageData, { quality }) case 'png': - return Buffer.from(await worker.encodePng(imageData)) + return await worker.encodePng(imageData) default: throw Error(`Unsupported encoding format`) }