Repository: withastro/astro
File: packages/integrations/cloudflare/src/index.ts (TypeScript)

Code before:
	/**
	 * When `imageService` is set to `cloudflare-binding`, the Cloudflare Images binding will be used
	 * to transform images. The binding will be automatically configured for you.
	 *
	 * By default, the binding is named `IMAGES`, but you can override this by providing a different name here.
	 * If you define the binding manually in your wrangler config, Astro will use your configuration instead.
	 *
	 * See https://developers.cloudflare.com/images/transform-images/bindings/ for more details.
	 */
	imagesBindingName?: string;
};

export default function createIntegration(args?: Options): AstroIntegration {
	let _config: AstroConfig;

	let _routes: IntegrationResolvedRoute[];
	let _isFullyStatic = false;

	const sessionKVBindingName = args?.sessionKVBindingName ?? DEFAULT_SESSION_KV_BINDING_NAME;
	const imagesBindingName = args?.imagesBindingName ?? DEFAULT_IMAGES_BINDING_NAME;

	return {
		name: '@astrojs/cloudflare',
		hooks: {
			'astro:config:setup': ({ command, config, updateConfig, logger, addWatchFile }) => {
				let session = config.session;

				if (args?.imageService === 'cloudflare-binding') {
					logger.info(
						`Enabling image processing with Cloudflare Images for production with the "${imagesBindingName}" Images binding.`,
					);
				}

				if (!session?.driver) {
					logger.info(
						`Enabling sessions with Cloudflare KV with the "${sessionKVBindingName}" KV binding.`,
					);

					session = {
						driver: sessionDrivers.cloudflareKVBinding({
							binding: sessionKVBindingName,
						}),
						cookie: session?.cookie,
						ttl: session?.ttl,
					};
				}
				const cfPluginConfig: PluginConfig = {
					viteEnvironment: { name: 'ssr' },
					config: cloudflareConfigCustomizer({
						sessionKVBindingName: args?.sessionKVBindingName,
						imagesBindingName:

Review comment (suggestion):
Are there any docs for this? I found various references to it on GitHub but no documentation.

I noticed `std-env` [also check `process.env.SHELL`](https://github.com/unjs/std-env/pull/63/changes#diff-2b7ff992842c6f8113f826af7e81b310a87148e85eef65304868dfc91dad5febR119) but no idea what matters where.

Code after:
	/**
	 * When `imageService` is set to `cloudflare-binding`, the Cloudflare Images binding will be used
	 * to transform images. The binding will be automatically configured for you.
	 *
	 * By default, the binding is named `IMAGES`, but you can override this by providing a different name here.
	 * If you define the binding manually in your wrangler config, Astro will use your configuration instead.
	 *
	 * See https://developers.cloudflare.com/images/transform-images/bindings/ for more details.
	 */
	imagesBindingName?: string;
};

export default function createIntegration(args?: Options): AstroIntegration {
	let _config: AstroConfig;

	let _routes: IntegrationResolvedRoute[];
	let _isFullyStatic = false;

	const sessionKVBindingName = args?.sessionKVBindingName ?? DEFAULT_SESSION_KV_BINDING_NAME;
	const imagesBindingName = args?.imagesBindingName ?? DEFAULT_IMAGES_BINDING_NAME;

	return {
		name: '@astrojs/cloudflare',
		hooks: {
			'astro:config:setup': ({ command, config, updateConfig, logger, addWatchFile }) => {
				if (!!process.versions.webcontainer) {
					throw new Error('`workerd` does not run on Stackblitz.')
				}

				let session = config.session;

				if (args?.imageService === 'cloudflare-binding') {
					logger.info(
						`Enabling image processing with Cloudflare Images for production with the "${imagesBindingName}" Images binding.`,
					);
				}

				if (!session?.driver) {
					logger.info(
						`Enabling sessions with Cloudflare KV with the "${sessionKVBindingName}" KV binding.`,
					);

					session = {
						driver: sessionDrivers.cloudflareKVBinding({
							binding: sessionKVBindingName,
						}),
						cookie: session?.cookie,
						ttl: session?.ttl,
					};
				}
				const cfPluginConfig: PluginConfig = {