imageKind.ts — astro Source File
Architecture documentation for imageKind.ts, a typescript file in the astro codebase. 1 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR 860570b1_06ee_3485_050b_5336ee0d30ce["imageKind.ts"] 416eda3d_47e6_c298_102b_b7a37d86a44e["../../assets/types.js"] 860570b1_06ee_3485_050b_5336ee0d30ce --> 416eda3d_47e6_c298_102b_b7a37d86a44e style 860570b1_06ee_3485_050b_5336ee0d30ce fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
import type { ImageMetadata, UnresolvedImageTransform } from '../types.js';
/**
* Determines if the given source is an ECMAScript Module (ESM) imported image.
*
* @param {ImageMetadata | string} src - The source to check. It can be an `ImageMetadata` object or a string.
* @return {boolean} Returns `true` if the source is an `ImageMetadata` object, otherwise `false`.
*/
export function isESMImportedImage(src: ImageMetadata | string): src is ImageMetadata {
return typeof src === 'object' || (typeof src === 'function' && 'src' in src);
}
/**
* Determines if the provided source is a remote image URL in the form of a string.
*
* @param {ImageMetadata | string} src - The source to check, which can either be an `ImageMetadata` object or a string.
* @return {boolean} Returns `true` if the source is a string, otherwise `false`.
*/
export function isRemoteImage(src: ImageMetadata | string): src is string {
return typeof src === 'string';
}
/**
* Resolves the source of an image transformation by handling asynchronous or synchronous inputs.
*
* @param {UnresolvedImageTransform['src']} src - The source of the image transformation.
* @return {Promise<string | ImageMetadata>} A promise that resolves to the image source. It returns either the default export of the resolved source or the resolved source itself if the default export doesn't exist.
*/
export async function resolveSrc(
src: UnresolvedImageTransform['src'],
): Promise<string | ImageMetadata> {
if (typeof src === 'object' && 'then' in src) {
const resource = await src;
return resource.default ?? resource;
}
return src;
}
Domain
Subdomains
Dependencies
- ../../assets/types.js
Source
Frequently Asked Questions
What does imageKind.ts do?
imageKind.ts is a source file in the astro codebase, written in typescript. It belongs to the CoreAstro domain, RenderingEngine subdomain.
What functions are defined in imageKind.ts?
imageKind.ts defines 3 function(s): isESMImportedImage, isRemoteImage, resolveSrc.
What does imageKind.ts depend on?
imageKind.ts imports 1 module(s): ../../assets/types.js.
Where is imageKind.ts in the architecture?
imageKind.ts is located at packages/astro/src/assets/utils/imageKind.ts (domain: CoreAstro, subdomain: RenderingEngine, directory: packages/astro/src/assets/utils).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free