mirror of
https://github.com/withastro/astro.git
synced 2025-04-07 23:41:43 -05:00
[ci] format
This commit is contained in:
parent
91f75afbc6
commit
b386d2d7ae
6 changed files with 17 additions and 28 deletions
|
@ -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';
|
||||
|
||||
|
|
|
@ -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';
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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<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),
|
||||
|
|
|
@ -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> {
|
||||
|
@ -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.
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
/**
|
||||
|
|
Loading…
Add table
Reference in a new issue