Skip to content

Commit

Permalink
Changes from review
Browse files Browse the repository at this point in the history
  • Loading branch information
ascorbic committed Nov 12, 2024
1 parent dddca70 commit 41c2c7b
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 19 deletions.
10 changes: 9 additions & 1 deletion packages/astro/src/assets/consts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,12 @@ export const VALID_SUPPORTED_FORMATS = [
] as const;
export const DEFAULT_OUTPUT_FORMAT = 'webp' as const;
export const VALID_OUTPUT_FORMATS = ['avif', 'png', 'webp', 'jpeg', 'jpg', 'svg'] as const;
export const DEFAULT_HASH_PROPS = ['src', 'width', 'height', 'format', 'quality', 'fit', 'position'];
export const DEFAULT_HASH_PROPS = [
'src',
'width',
'height',
'format',
'quality',
'fit',
'position',
];
12 changes: 6 additions & 6 deletions packages/astro/src/assets/internal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@ import { isRemotePath } from '@astrojs/internal-helpers/path';
import { AstroError, AstroErrorData } from '../core/errors/index.js';
import type { AstroConfig } from '../types/public/config.js';
import { DEFAULT_HASH_PROPS } from './consts.js';
import {
DEFAULT_RESOLUTIONS,
LIMITED_RESOLUTIONS,
getSizesAttribute,
getWidths,
} from './layout.js';
import { type ImageService, isLocalService } from './services/service.js';
import {
type GetImageResult,
Expand All @@ -12,12 +18,6 @@ import {
} from './types.js';
import { isESMImportedImage, isRemoteImage, resolveSrc } from './utils/imageKind.js';
import { inferRemoteSize } from './utils/remoteProbe.js';
import {
DEFAULT_RESOLUTIONS,
getSizesAttribute,
getWidths,
LIMITED_RESOLUTIONS,
} from './layout.js';

export async function getConfiguredImageService(): Promise<ImageService> {
if (!globalThis?.astroAsset?.imageService) {
Expand Down
4 changes: 2 additions & 2 deletions packages/astro/src/assets/services/sharp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ const fitMap: Record<ImageFit, keyof FitEnum> = {
cover: 'cover',
none: 'outside',
'scale-down': 'inside',
'outside': 'outside',
'inside': 'inside',
outside: 'outside',
inside: 'inside',
};

const sharpService: LocalImageService<SharpImageServiceConfig> = {
Expand Down
2 changes: 1 addition & 1 deletion packages/astro/src/types/public/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ import type {
ShikiConfig,
} from '@astrojs/markdown-remark';
import type { UserConfig as OriginalViteUserConfig, SSROptions as ViteSSROptions } from 'vite';
import type { ImageFit, ImageLayout } from '../../assets/types.js';
import type { RemotePattern } from '../../assets/utils/remotePattern.js';
import type { AssetsPrefix } from '../../core/app/types.js';
import type { AstroConfigType } from '../../core/config/schema.js';
import type { REDIRECT_STATUS_CODES } from '../../core/constants.js';
import type { Logger, LoggerLevel } from '../../core/logger/core.js';
import type { EnvSchema } from '../../env/schema.js';
import type { AstroIntegration } from './integrations.js';
import type { ImageFit, ImageLayout } from '../../assets/types.js';

export type Locales = (string | { codes: string[]; path: string })[];

Expand Down
4 changes: 1 addition & 3 deletions packages/astro/test/core-image-layout.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import * as cheerio from 'cheerio';
import parseSrcset from 'parse-srcset';
import { Logger } from '../dist/core/logger/core.js';
import { testImageService } from './test-image-service.js';
import { loadFixture } from './test-utils.js';
import { testRemoteImageService } from './test-remote-image-service.js';
import { loadFixture } from './test-utils.js';

describe('astro:image:layout', () => {
/** @type {import('./test-utils').Fixture} */
Expand All @@ -15,8 +15,6 @@ describe('astro:image:layout', () => {
describe('local image service', () => {
/** @type {import('./test-utils').DevServer} */
let devServer;
/** @type {Array<{ type: any, level: 'error', message: string; }>} */
let logs = [];

before(async () => {
fixture = await loadFixture({
Expand Down
8 changes: 2 additions & 6 deletions packages/astro/test/core-image-service.test.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import assert from 'node:assert/strict';
import { after, before, describe, it } from 'node:test';
import { removeDir } from '@astrojs/internal-helpers/fs';
import * as cheerio from 'cheerio';
import { loadFixture } from './test-utils.js';
import { lookup as probe } from '../dist/assets/utils/vendor/image-size/lookup.js';
import { removeDir } from '@astrojs/internal-helpers/fs';
import { loadFixture } from './test-utils.js';

async function getImageDimensionsFromFixture(fixture, path) {
/** @type { Response } */
Expand All @@ -26,8 +26,6 @@ describe('astro image service', () => {
describe('dev image service', () => {
/** @type {import('./test-utils').DevServer} */
let devServer;
/** @type {Array<{ type: any, level: 'error', message: string; }>} */
let logs = [];

before(async () => {
fixture = await loadFixture({
Expand Down Expand Up @@ -149,7 +147,6 @@ describe('astro image service', () => {

describe('generated images', () => {
let $;
let src;
before(async () => {
const html = await fixture.readFile('/build/index.html');
$ = cheerio.load(html);
Expand Down Expand Up @@ -204,7 +201,6 @@ describe('astro image service', () => {
assert.equal(width, originalWidth);
assert.equal(height, originalHeight);
});

});
});
});

0 comments on commit 41c2c7b

Please sign in to comment.