dev-service.ts — astro Source File
Architecture documentation for dev-service.ts, a typescript file in the astro codebase. 3 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR 17912ece_5add_1411_7656_29ddd31d5757["dev-service.ts"] cfb4b52d_c8c5_00ab_78f5_04579c234507["./shared-dev-service.js"] 17912ece_5add_1411_7656_29ddd31d5757 --> cfb4b52d_c8c5_00ab_78f5_04579c234507 f16d8c76_2866_6150_bd14_0347b59abfe9["astro"] 17912ece_5add_1411_7656_29ddd31d5757 --> f16d8c76_2866_6150_bd14_0347b59abfe9 c4de3c03_a113_13e0_b940_cd1b823e4350["sharp"] 17912ece_5add_1411_7656_29ddd31d5757 --> c4de3c03_a113_13e0_b940_cd1b823e4350 style 17912ece_5add_1411_7656_29ddd31d5757 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
import type { LocalImageService } from 'astro';
import sharpService from 'astro/assets/services/sharp';
import { baseDevService } from './shared-dev-service.js';
const service: LocalImageService = {
...baseDevService,
getHTMLAttributes(options, serviceOptions) {
const { inputtedWidth, ...props } = options;
// If `validateOptions` returned a different width than the one of the image, use it for attributes
if (inputtedWidth) {
props.width = inputtedWidth;
}
return sharpService.getHTMLAttributes
? sharpService.getHTMLAttributes(props, serviceOptions)
: {};
},
transform(inputBuffer, transform, serviceOptions) {
// NOTE: Hardcoding webp here isn't accurate to how the Vercel Image Optimization API works, normally what we should
// do is setup a custom endpoint that sniff the user's accept-content header and serve the proper format based on the
// user's Vercel config. However, that's: a lot of work for: not much. The dev service is inaccurate to the prod service
// in many more ways, this is one of the less offending cases and is, imo, okay, erika - 2023-04-27
transform.format = transform.src.endsWith('svg') ? 'svg' : 'webp';
// The base sharp service works the same way as the Vercel Image Optimization API, so it's a safe fallback in local
return sharpService.transform(inputBuffer, transform, serviceOptions);
},
};
export default service;
Domain
Subdomains
Dependencies
- ./shared-dev-service.js
- astro
- sharp
Source
Frequently Asked Questions
What does dev-service.ts do?
dev-service.ts is a source file in the astro codebase, written in typescript. It belongs to the CoreAstro domain, CoreMiddleware subdomain.
What functions are defined in dev-service.ts?
dev-service.ts defines 2 function(s): service.getHTMLAttributes, service.transform.
What does dev-service.ts depend on?
dev-service.ts imports 3 module(s): ./shared-dev-service.js, astro, sharp.
Where is dev-service.ts in the architecture?
dev-service.ts is located at packages/integrations/vercel/src/image/dev-service.ts (domain: CoreAstro, subdomain: CoreMiddleware, directory: packages/integrations/vercel/src/image).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free