aboutsummaryrefslogtreecommitdiff
path: root/packages/astro/src/core/render/environment.ts
blob: 32dfb454be66e5bf17f2a32dbc84fc76ea2df2c0 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import type { AstroSettings, RuntimeMode, SSRLoadedRenderer } from '../../@types/astro';
import type { LogOptions } from '../logger/core.js';
import type { ModuleLoader } from '../module-loader';
import type { RouteCache } from './route-cache.js';

/**
 * An environment represents the static parts of rendering that do not change
 * between requests. These are mostly known when the server first starts up and do not change.
 * Thus, they can be created once and passed through to renderPage on each request.
 */
export interface Environment {
	/**
	 * Used to provide better error messages for `Astro.clientAddress`
	 */
	adapterName?: string;
	/** logging options */
	logging: LogOptions;
	/** "development" or "production" */
	mode: RuntimeMode;
	compressHTML: boolean;
	renderers: SSRLoadedRenderer[];
	clientDirectives: Map<string, string>;
	resolve: (s: string) => Promise<string>;
	routeCache: RouteCache;
	/**
	 * Used for `Astro.site`
	 */
	site?: string;
	/**
	 * Value of Astro config's `output` option, true if "server" or "hybrid"
	 */
	ssr: boolean;
	streaming: boolean;
}

export type CreateEnvironmentArgs = Environment;

export function createEnvironment(options: CreateEnvironmentArgs): Environment {
	return options;
}

export type DevelopmentEnvironment = Environment & {
	loader: ModuleLoader;
	settings: AstroSettings;
};