Skip to content

Commit

Permalink
[ci] format
Browse files Browse the repository at this point in the history
  • Loading branch information
Princesseuh authored and astrobot-houston committed Feb 15, 2024
1 parent 91f75af commit b386d2d
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 28 deletions.
6 changes: 1 addition & 5 deletions packages/astro/components/Image.astro
Original file line number Diff line number Diff line change
@@ -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';
Expand Down
6 changes: 1 addition & 5 deletions packages/astro/components/Picture.astro
Original file line number Diff line number Diff line change
@@ -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';
Expand Down
2 changes: 1 addition & 1 deletion packages/astro/src/assets/internal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<ImageService> {
if (!globalThis?.astroAsset?.imageService) {
Expand Down
5 changes: 2 additions & 3 deletions packages/astro/src/assets/utils/metadata.ts
Original file line number Diff line number Diff line change
@@ -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';

Expand All @@ -9,7 +8,7 @@ export async function imageMetadata(
): Promise<Omit<ImageMetadata, 'src' | 'fsPath'>> {
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),
Expand Down
23 changes: 11 additions & 12 deletions packages/astro/src/assets/utils/remoteProbe.ts
Original file line number Diff line number Diff line change
@@ -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<ISize> {
Expand Down Expand Up @@ -31,16 +30,16 @@ export async function probe(url: string): Promise<ISize> {
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.
}
}
}

Expand Down
3 changes: 1 addition & 2 deletions packages/astro/src/core/errors/errors-data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
/**
Expand Down

0 comments on commit b386d2d

Please sign in to comment.