SharedServiceProps Type — astro Architecture
Architecture documentation for the SharedServiceProps type/interface in service.ts from the astro codebase.
Entity Profile
Dependency Diagram
graph TD 40f243a5_c5fb_9eaf_d64c_252413ad7833["SharedServiceProps"] c5e6f24e_4c8e_68c8_222a_2da9372d19ce["service.ts"] 40f243a5_c5fb_9eaf_d64c_252413ad7833 -->|defined in| c5e6f24e_4c8e_68c8_222a_2da9372d19ce style 40f243a5_c5fb_9eaf_d64c_252413ad7833 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
packages/astro/src/assets/services/service.ts lines 40–92
interface SharedServiceProps<T extends Record<string, any> = Record<string, any>> {
/**
* Return the URL to the endpoint or URL your images are generated from.
*
* For a local service, your service should expose an endpoint handling the image requests, or use Astro's which by default, is located at `/_image`.
*
* For external services, this should point to the URL your images are coming from, for instance, `/_vercel/image`
*
*/
getURL: (options: ImageTransform, imageConfig: ImageConfig<T>) => string | Promise<string>;
/**
* Generate additional `srcset` values for the image.
*
* While in most cases this is exclusively used for `srcset`, it can also be used in a more generic way to generate
* multiple variants of the same image. For instance, you can use this to generate multiple aspect ratios or multiple formats.
*/
getSrcSet?: (
options: ImageTransform,
imageConfig: ImageConfig<T>,
) => UnresolvedSrcSetValue[] | Promise<UnresolvedSrcSetValue[]>;
/**
* Return any additional HTML attributes separate from `src` that your service requires to show the image properly.
*
* For example, you might want to return the `width` and `height` to avoid CLS, or a particular `class` or `style`.
* In most cases, you'll want to return directly what your user supplied you, minus the attributes that were used to generate the image.
*/
getHTMLAttributes?: (
options: ImageTransform,
imageConfig: ImageConfig<T>,
) => Record<string, any> | Promise<Record<string, any>>;
/**
* Validate and return the options passed by the user.
*
* This method is useful to present errors to users who have entered invalid options.
* For instance, if they are missing a required property or have entered an invalid image format.
*
* This method should returns options, and can be used to set defaults (ex: a default output format to be used if the user didn't specify one.)
*/
validateOptions?: (
options: ImageTransform,
imageConfig: ImageConfig<T>,
) => ImageTransform | Promise<ImageTransform>;
/**
* Return the dimensions of a remote image.
*
* This is used to infer the width and height of an image from its URL,
* allowing the service to provide necessary metadata when it's not available locally.
*/
getRemoteSize?: (
url: string,
imageConfig: ImageConfig<T>,
) => Omit<ImageMetadata, 'src' | 'fsPath'> | Promise<Omit<ImageMetadata, 'src' | 'fsPath'>>;
}
Source
Frequently Asked Questions
What is the SharedServiceProps type?
SharedServiceProps is a type/interface in the astro codebase, defined in packages/astro/src/assets/services/service.ts.
Where is SharedServiceProps defined?
SharedServiceProps is defined in packages/astro/src/assets/services/service.ts at line 40.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free