Home / File/ internal.ts — astro Source File

internal.ts — astro Source File

Architecture documentation for internal.ts, a typescript file in the astro codebase. 12 imports, 0 dependents.

File typescript CoreAstro RenderingEngine 12 imports 2 functions

Entity Profile

Dependency Diagram

graph LR
  aac8b1fe_d242_0071_1169_4222f10fb7b6["internal.ts"]
  ef8a1e3f_e350_75a6_b92d_62a8566d8db9["../core/errors/index.js"]
  aac8b1fe_d242_0071_1169_4222f10fb7b6 --> ef8a1e3f_e350_75a6_b92d_62a8566d8db9
  c32d12e2_d85e_28c0_eea7_9b29629857e0["../types/public/config.js"]
  aac8b1fe_d242_0071_1169_4222f10fb7b6 --> c32d12e2_d85e_28c0_eea7_9b29629857e0
  4c453c0b_17bb_ebc3_f7de_e2a632e42c1e["../types/public/integrations.js"]
  aac8b1fe_d242_0071_1169_4222f10fb7b6 --> 4c453c0b_17bb_ebc3_f7de_e2a632e42c1e
  a19b6b68_b1f2_2d3e_2481_283031d370ff["./consts.js"]
  aac8b1fe_d242_0071_1169_4222f10fb7b6 --> a19b6b68_b1f2_2d3e_2481_283031d370ff
  2834bf61_a356_cb32_0f4e_976c4d0a2291["./layout.js"]
  aac8b1fe_d242_0071_1169_4222f10fb7b6 --> 2834bf61_a356_cb32_0f4e_976c4d0a2291
  af2a1f33_901c_456d_9c42_3a41fec45451["./services/service.js"]
  aac8b1fe_d242_0071_1169_4222f10fb7b6 --> af2a1f33_901c_456d_9c42_3a41fec45451
  416eda3d_47e6_c298_102b_b7a37d86a44e["../../assets/types.js"]
  aac8b1fe_d242_0071_1169_4222f10fb7b6 --> 416eda3d_47e6_c298_102b_b7a37d86a44e
  80bf2525_a1f9_c3a9_2b60_06003012b8d8["./utils/imageAttributes.js"]
  aac8b1fe_d242_0071_1169_4222f10fb7b6 --> 80bf2525_a1f9_c3a9_2b60_06003012b8d8
  885fe8eb_6b3c_f392_ce65_d81fa1101fb3["./imageKind.js"]
  aac8b1fe_d242_0071_1169_4222f10fb7b6 --> 885fe8eb_6b3c_f392_ce65_d81fa1101fb3
  b8692cae_bcd5_338a_dfc3_de76a0aac53c["../utils/remoteProbe.js"]
  aac8b1fe_d242_0071_1169_4222f10fb7b6 --> b8692cae_bcd5_338a_dfc3_de76a0aac53c
  80b76311_6bb4_2889_b892_492680843683["./utils/url.js"]
  aac8b1fe_d242_0071_1169_4222f10fb7b6 --> 80b76311_6bb4_2889_b892_492680843683
  e4df8f29_fb2f_3d70_a962_fdf6a3670b22["path"]
  aac8b1fe_d242_0071_1169_4222f10fb7b6 --> e4df8f29_fb2f_3d70_a962_fdf6a3670b22
  style aac8b1fe_d242_0071_1169_4222f10fb7b6 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

import { isRemotePath } from '@astrojs/internal-helpers/path';
import { AstroError, AstroErrorData } from '../core/errors/index.js';
import type { AstroConfig } from '../types/public/config.js';
import type { AstroAdapterClientConfig } from '../types/public/integrations.js';
import { DEFAULT_HASH_PROPS } from './consts.js';
import {
	DEFAULT_RESOLUTIONS,
	getSizesAttribute,
	getWidths,
	LIMITED_RESOLUTIONS,
} from './layout.js';
import { type ImageService, isLocalService } from './services/service.js';
import {
	type GetImageResult,
	type ImageTransform,
	isImageMetadata,
	type SrcSetValue,
	type UnresolvedImageTransform,
} from './types.js';
import { addCSSVarsToStyle, cssFitValues } from './utils/imageAttributes.js';
import { isESMImportedImage, isRemoteImage, resolveSrc } from './utils/imageKind.js';
import { inferRemoteSize } from './utils/remoteProbe.js';
import { createPlaceholderURL, stringifyPlaceholderURL } from './utils/url.js';

export async function getConfiguredImageService(): Promise<ImageService> {
	if (!globalThis?.astroAsset?.imageService) {
		const { default: service }: { default: ImageService } = await import(
			// @ts-expect-error
			'virtual:image-service'
		).catch((e) => {
			const error = new AstroError(AstroErrorData.InvalidImageService);
			error.cause = e;
			throw error;
		});

		if (!globalThis.astroAsset) globalThis.astroAsset = {};
		globalThis.astroAsset.imageService = service;
		return service;
	}

	return globalThis.astroAsset.imageService;
}

export async function getImage(
	options: UnresolvedImageTransform,
	imageConfig: AstroConfig['image'] & AstroAdapterClientConfig,
): Promise<GetImageResult> {
	if (!options || typeof options !== 'object') {
		throw new AstroError({
			...AstroErrorData.ExpectedImageOptions,
			message: AstroErrorData.ExpectedImageOptions.message(JSON.stringify(options)),
		});
	}
	if (typeof options.src === 'undefined') {
		throw new AstroError({
			...AstroErrorData.ExpectedImage,
			message: AstroErrorData.ExpectedImage.message(
				options.src,
				'undefined',
				JSON.stringify(options),
// ... (194 more lines)

Domain

Subdomains

Dependencies

  • ../../assets/types.js
  • ../core/errors/index.js
  • ../types/public/config.js
  • ../types/public/integrations.js
  • ../utils/remoteProbe.js
  • ./consts.js
  • ./imageKind.js
  • ./layout.js
  • ./services/service.js
  • ./utils/imageAttributes.js
  • ./utils/url.js
  • path

Frequently Asked Questions

What does internal.ts do?
internal.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 internal.ts?
internal.ts defines 2 function(s): getConfiguredImageService, getImage.
What does internal.ts depend on?
internal.ts imports 12 module(s): ../../assets/types.js, ../core/errors/index.js, ../types/public/config.js, ../types/public/integrations.js, ../utils/remoteProbe.js, ./consts.js, ./imageKind.js, ./layout.js, and 4 more.
Where is internal.ts in the architecture?
internal.ts is located at packages/astro/src/assets/internal.ts (domain: CoreAstro, subdomain: RenderingEngine, directory: packages/astro/src/assets).

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free