Home / File/ astro-global.ts — astro Source File

astro-global.ts — astro Source File

Architecture documentation for astro-global.ts, a typescript file in the astro codebase. 3 imports, 0 dependents.

File typescript CoreAstro RenderingEngine 3 imports 2 functions

Entity Profile

Dependency Diagram

graph LR
  79d578d0_f5f2_07a8_25f9_c215243ca5bc["astro-global.ts"]
  7216d952_4e4a_2d18_a85b_74b4ace79e2b["../core/constants.js"]
  79d578d0_f5f2_07a8_25f9_c215243ca5bc --> 7216d952_4e4a_2d18_a85b_74b4ace79e2b
  ef8a1e3f_e350_75a6_b92d_62a8566d8db9["../core/errors/index.js"]
  79d578d0_f5f2_07a8_25f9_c215243ca5bc --> ef8a1e3f_e350_75a6_b92d_62a8566d8db9
  28857b9f_4720_3f29_4abb_a7eec34dcca5["../types/public/context.js"]
  79d578d0_f5f2_07a8_25f9_c215243ca5bc --> 28857b9f_4720_3f29_4abb_a7eec34dcca5
  style 79d578d0_f5f2_07a8_25f9_c215243ca5bc fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

import { ASTRO_GENERATOR } from '../../core/constants.js';
import { AstroError, AstroErrorData } from '../../core/errors/index.js';
import type { AstroGlobal } from '../../types/public/context.js';

function createError(name: string) {
	return new AstroError({
		...AstroErrorData.UnavailableAstroGlobal,
		message: AstroErrorData.UnavailableAstroGlobal.message(name),
	});
}

// This is used to create the top-level Astro global; the one that you can use
// inside of getStaticPaths. See the `astroGlobalArgs` option for parameter type.
export function createAstro(site: string | undefined): AstroGlobal {
	return {
		// TODO: throw in Astro 7
		get site() {
			// This is created inside of the runtime so we don't have access to the Astro logger.
			console.warn(
				`Astro.site inside getStaticPaths is deprecated and will be removed in a future major version of Astro. Use import.meta.env.SITE instead`,
			);
			return site ? new URL(site) : undefined;
		},
		// TODO: throw in Astro 7
		get generator() {
			// This is created inside of the runtime so we don't have access to the Astro logger.
			console.warn(
				`Astro.generator inside getStaticPaths is deprecated and will be removed in a future major version of Astro.`,
			);
			return ASTRO_GENERATOR;
		},
		get callAction(): any {
			throw createError('callAction');
		},
		get clientAddress(): any {
			throw createError('clientAddress');
		},
		get cookies(): any {
			throw createError('cookies');
		},
		get csp(): any {
			throw createError('csp');
		},
		get currentLocale(): any {
			throw createError('currentLocale');
		},
		get getActionResult(): any {
			throw createError('getActionResult');
		},
		get isPrerendered(): any {
			throw createError('isPrerendered');
		},
		get locals(): any {
			throw createError('locals');
		},
		get originPathname(): any {
			throw createError('originPathname');
		},
		get params(): any {
			throw createError('params');
		},
		get preferredLocale(): any {
			throw createError('preferredLocale');
		},
		get preferredLocaleList(): any {
			throw createError('preferredLocaleList');
		},
		get props(): any {
			throw createError('props');
		},
		get redirect(): any {
			throw createError('redirect');
		},
		get request(): any {
			throw createError('request');
		},
		get response(): any {
			throw createError('response');
		},
		get rewrite(): any {
			throw createError('rewrite');
		},
		get routePattern(): any {
			throw createError('routePattern');
		},
		get self(): any {
			throw createError('self');
		},
		get slots(): any {
			throw createError('slots');
		},
		get url(): any {
			throw createError('url');
		},
		get session(): any {
			throw createError('session');
		},
	};
}

Domain

Subdomains

Dependencies

  • ../core/constants.js
  • ../core/errors/index.js
  • ../types/public/context.js

Frequently Asked Questions

What does astro-global.ts do?
astro-global.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 astro-global.ts?
astro-global.ts defines 2 function(s): createAstro, createError.
What does astro-global.ts depend on?
astro-global.ts imports 3 module(s): ../core/constants.js, ../core/errors/index.js, ../types/public/context.js.
Where is astro-global.ts in the architecture?
astro-global.ts is located at packages/astro/src/runtime/server/astro-global.ts (domain: CoreAstro, subdomain: RenderingEngine, directory: packages/astro/src/runtime/server).

Analyze Your Own Codebase

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

Try Supermodel Free