Home / File/ shared.ts — astro Source File

shared.ts — astro Source File

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

File typescript CoreAstro RoutingSystem 2 imports 3 functions

Entity Profile

Dependency Diagram

graph LR
  a016e3b9_7fbf_ffde_b5f4_749606ced138["shared.ts"]
  f16d8c76_2866_6150_bd14_0347b59abfe9["astro"]
  a016e3b9_7fbf_ffde_b5f4_749606ced138 --> f16d8c76_2866_6150_bd14_0347b59abfe9
  f8ab2297_5406_4f9e_e15c_c4eb026871f9["utils"]
  a016e3b9_7fbf_ffde_b5f4_749606ced138 --> f8ab2297_5406_4f9e_e15c_c4eb026871f9
  style a016e3b9_7fbf_ffde_b5f4_749606ced138 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

import type { AstroConfig, ImageQualityPreset, ImageTransform } from 'astro';
import { isESMImportedImage } from 'astro/assets/utils';

export function getDefaultImageConfig(astroImageConfig: AstroConfig['image']): VercelImageConfig {
	return {
		sizes: [640, 750, 828, 1080, 1200, 1920, 2048, 3840],
		domains: astroImageConfig.domains ?? [],
		// Cast is necessary here because Vercel's types are slightly different from ours regarding allowed protocols. Behavior should be the same, however.
		remotePatterns: (astroImageConfig.remotePatterns as VercelImageConfig['remotePatterns']) ?? [],
	};
}

export type DevImageService = 'sharp' | (string & {});

// https://vercel.com/docs/build-output-api/v3/configuration#images
type ImageFormat = 'image/avif' | 'image/webp';

export type RemotePattern = {
	protocol?: 'http' | 'https';
	hostname: string;
	port?: string;
	pathname?: string;
};

export type VercelImageConfig = {
	/**
	 * Supported image widths.
	 */
	sizes: number[];
	/**
	 * Allowed external domains that can use Image Optimization. Set to `[]` to only allow the deployment domain to use Image Optimization.
	 */
	domains?: string[];
	/**
	 * Allowed external patterns that can use Image Optimization. Similar to `domains` but provides more control with RegExp.
	 */
	remotePatterns?: RemotePattern[];
	/**
	 * Cache duration (in seconds) for the optimized images.
	 */
	minimumCacheTTL?: number;
	/**
	 * Supported output image formats
	 */
	formats?: ImageFormat[];
	/**
	 * Allow SVG input image URLs. This is disabled by default for security purposes.
	 */
	dangerouslyAllowSVG?: boolean;
	/**
	 * Change the [Content Security Policy](https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP) of the optimized images.
	 */
	contentSecurityPolicy?: string;
};

const qualityTable: Record<ImageQualityPreset, number> = {
	low: 25,
	mid: 50,
	high: 80,
	max: 100,
// ... (112 more lines)

Domain

Subdomains

Dependencies

  • astro
  • utils

Frequently Asked Questions

What does shared.ts do?
shared.ts is a source file in the astro codebase, written in typescript. It belongs to the CoreAstro domain, RoutingSystem subdomain.
What functions are defined in shared.ts?
shared.ts defines 3 function(s): getAstroImageConfig, getDefaultImageConfig, sharedValidateOptions.
What does shared.ts depend on?
shared.ts imports 2 module(s): astro, utils.
Where is shared.ts in the architecture?
shared.ts is located at packages/integrations/vercel/src/image/shared.ts (domain: CoreAstro, subdomain: RoutingSystem, 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