diff --git a/packages/astro/components/Image.astro b/packages/astro/components/Image.astro index 4b496daa6270..aee198a60278 100644 --- a/packages/astro/components/Image.astro +++ b/packages/astro/components/Image.astro @@ -1,9 +1,5 @@ --- -import { - getImage, - type LocalImageProps, - type RemoteImageProps, -} from 'astro:assets'; +import { getImage, type LocalImageProps, type RemoteImageProps } from 'astro:assets'; import { AstroError, AstroErrorData } from '../dist/core/errors/index.js'; import type { HTMLAttributes } from '../types'; diff --git a/packages/astro/components/Picture.astro b/packages/astro/components/Picture.astro index 2ddee3125014..b37b2d5451dc 100644 --- a/packages/astro/components/Picture.astro +++ b/packages/astro/components/Picture.astro @@ -1,9 +1,5 @@ --- -import { - getImage, - type LocalImageProps, - type RemoteImageProps, -} from 'astro:assets'; +import { getImage, type LocalImageProps, type RemoteImageProps } from 'astro:assets'; import type { GetImageResult, ImageOutputFormat } from '../dist/@types/astro'; import { isESMImportedImage } from '../dist/assets/utils/imageKind'; import { AstroError, AstroErrorData } from '../dist/core/errors/index.js'; diff --git a/packages/astro/src/assets/internal.ts b/packages/astro/src/assets/internal.ts index cf758f8f1f5a..1c55c84d5053 100644 --- a/packages/astro/src/assets/internal.ts +++ b/packages/astro/src/assets/internal.ts @@ -9,7 +9,7 @@ import type { UnresolvedImageTransform, } from './types.js'; import { isESMImportedImage, isRemoteImage } from './utils/imageKind.js'; -import { probe } from "./utils/remoteProbe.js" +import { probe } from './utils/remoteProbe.js'; export async function getConfiguredImageService(): Promise { if (!globalThis?.astroAsset?.imageService) { diff --git a/packages/astro/src/assets/utils/metadata.ts b/packages/astro/src/assets/utils/metadata.ts index adc75bfb3c4e..bf8dfb9b3767 100644 --- a/packages/astro/src/assets/utils/metadata.ts +++ b/packages/astro/src/assets/utils/metadata.ts @@ -1,5 +1,4 @@ - -import { lookup as probe } from '../utils/vendor/image-size/lookup.js' +import { lookup as probe } from '../utils/vendor/image-size/lookup.js'; import { AstroError, AstroErrorData } from '../../core/errors/index.js'; import type { ImageInputFormat, ImageMetadata } from '../types.js'; @@ -9,7 +8,7 @@ export async function imageMetadata( ): Promise> { const result = probe(data); - if (!result.height || !result.width || !result.type ) { + if (!result.height || !result.width || !result.type) { throw new AstroError({ ...AstroErrorData.NoImageMetadata, message: AstroErrorData.NoImageMetadata.message(src), diff --git a/packages/astro/src/assets/utils/remoteProbe.ts b/packages/astro/src/assets/utils/remoteProbe.ts index 0c045d1292f6..1cda4ca45818 100644 --- a/packages/astro/src/assets/utils/remoteProbe.ts +++ b/packages/astro/src/assets/utils/remoteProbe.ts @@ -1,5 +1,4 @@ - -import { lookup } from './vendor/image-size/lookup.js' +import { lookup } from './vendor/image-size/lookup.js'; import type { ISize } from './vendor/image-size/types/interface.ts'; export async function probe(url: string): Promise { @@ -31,16 +30,16 @@ export async function probe(url: string): Promise { accumulatedChunks = tmp; try { - // Attempt to determine the size with each new chunk - const dimensions = lookup(accumulatedChunks); - if (dimensions) { - await reader.cancel(); // stop stream as we have size now - return dimensions; - } - } catch (error) { - // This catch block is specifically for `sizeOf` failures, - // which might occur if the accumulated data isn't yet sufficient. - } + // Attempt to determine the size with each new chunk + const dimensions = lookup(accumulatedChunks); + if (dimensions) { + await reader.cancel(); // stop stream as we have size now + return dimensions; + } + } catch (error) { + // This catch block is specifically for `sizeOf` failures, + // which might occur if the accumulated data isn't yet sufficient. + } } } diff --git a/packages/astro/src/core/errors/errors-data.ts b/packages/astro/src/core/errors/errors-data.ts index b7585d42194b..6df25c748a10 100644 --- a/packages/astro/src/core/errors/errors-data.ts +++ b/packages/astro/src/core/errors/errors-data.ts @@ -543,8 +543,7 @@ export const MissingImageDimension = { export const FailedToFetchRemoteImageDimensions = { name: 'FailedToFetchRemoteImageDimensions', title: 'Failed to retrieve remote image dimensions', - message: (imageURL: string) => - `Failed to get the dimensions for ${imageURL}.`, + message: (imageURL: string) => `Failed to get the dimensions for ${imageURL}.`, hint: 'Verify your remote image URL is accurate, and that you are not using `inferSize` with a file located in your `public/` folder.', } satisfies ErrorData; /**