From f286a0bc76d44c583986f3ab1e12d6b3e8030505 Mon Sep 17 00:00:00 2001
From: Princesseuh <3019731+Princesseuh@users.noreply.github.com>
Date: Thu, 15 Aug 2024 05:16:12 +0200
Subject: [PATCH] feat: refactor types
---
packages/astro/astro-jsx.d.ts | 20 +-
packages/astro/client.d.ts | 20 +-
packages/astro/env.d.ts | 2 +-
packages/astro/index.d.ts | 2 +-
packages/astro/src/@types/README.md | 5 -
packages/astro/src/actions/index.ts | 3 +-
.../astro/src/actions/runtime/middleware.ts | 3 +-
packages/astro/src/actions/runtime/route.ts | 2 +-
packages/astro/src/actions/runtime/utils.ts | 2 +-
packages/astro/src/actions/utils.ts | 4 +-
packages/astro/src/assets/build/generate.ts | 2 +-
packages/astro/src/assets/endpoint/config.ts | 2 +-
packages/astro/src/assets/endpoint/generic.ts | 2 +-
packages/astro/src/assets/endpoint/node.ts | 2 +-
packages/astro/src/assets/internal.ts | 2 +-
packages/astro/src/assets/services/service.ts | 2 +-
.../astro/src/assets/utils/remotePattern.ts | 2 +-
.../astro/src/assets/vite-plugin-assets.ts | 3 +-
packages/astro/src/cli/db/index.ts | 2 +-
packages/astro/src/cli/flags.ts | 2 +-
packages/astro/src/cli/info/index.ts | 2 +-
packages/astro/src/cli/preferences/index.ts | 2 +-
packages/astro/src/config/index.ts | 2 +-
.../src/config/vite-plugin-content-listen.ts | 2 +-
packages/astro/src/container/index.ts | 32 +-
packages/astro/src/container/pipeline.ts | 10 +-
packages/astro/src/content/content-layer.ts | 2 +-
packages/astro/src/content/data-store.ts | 2 +-
packages/astro/src/content/loaders/glob.ts | 6 +-
packages/astro/src/content/loaders/types.ts | 3 +-
packages/astro/src/content/runtime.ts | 2 +-
.../astro/src/content/server-listeners.ts | 2 +-
packages/astro/src/content/types-generator.ts | 11 +-
packages/astro/src/content/utils.ts | 9 +-
.../src/content/vite-plugin-content-assets.ts | 3 +-
.../content/vite-plugin-content-imports.ts | 16 +-
.../vite-plugin-content-virtual-mod.ts | 2 +-
packages/astro/src/core/app/index.ts | 3 +-
packages/astro/src/core/app/middlewares.ts | 2 +-
packages/astro/src/core/app/node.ts | 2 +-
packages/astro/src/core/app/pipeline.ts | 11 +-
packages/astro/src/core/app/types.ts | 12 +-
packages/astro/src/core/base-pipeline.ts | 13 +-
packages/astro/src/core/build/common.ts | 3 +-
.../astro/src/core/build/css-asset-name.ts | 2 +-
packages/astro/src/core/build/generate.ts | 23 +-
packages/astro/src/core/build/index.ts | 9 +-
packages/astro/src/core/build/internal.ts | 2 +-
packages/astro/src/core/build/page-data.ts | 2 +-
packages/astro/src/core/build/pipeline.ts | 10 +-
.../src/core/build/plugins/plugin-content.ts | 2 +-
.../build/plugins/plugin-hoisted-scripts.ts | 2 +-
.../src/core/build/plugins/plugin-ssr.ts | 3 +-
packages/astro/src/core/build/static-build.ts | 2 +-
packages/astro/src/core/build/types.ts | 14 +-
packages/astro/src/core/build/util.ts | 2 +-
packages/astro/src/core/compile/compile.ts | 2 +-
packages/astro/src/core/config/config.ts | 4 +-
packages/astro/src/core/config/logging.ts | 2 +-
packages/astro/src/core/config/schema.ts | 2 +-
packages/astro/src/core/config/settings.ts | 3 +-
packages/astro/src/core/config/validate.ts | 2 +-
packages/astro/src/core/create-vite.ts | 2 +-
packages/astro/src/core/dev/container.ts | 3 +-
packages/astro/src/core/dev/dev.ts | 2 +-
packages/astro/src/core/dev/restart.ts | 3 +-
packages/astro/src/core/errors/dev/utils.ts | 2 +-
packages/astro/src/core/errors/dev/vite.ts | 2 +-
packages/astro/src/core/errors/utils.ts | 2 +-
packages/astro/src/core/index.ts | 2 +-
.../src/core/middleware/callMiddleware.ts | 4 +-
packages/astro/src/core/middleware/index.ts | 3 +-
.../astro/src/core/middleware/sequence.ts | 3 +-
.../astro/src/core/middleware/vite-plugin.ts | 2 +-
.../astro/src/core/module-loader/loader.ts | 2 +-
packages/astro/src/core/preview/index.ts | 3 +-
.../src/core/preview/static-preview-server.ts | 2 +-
.../core/preview/vite-plugin-astro-preview.ts | 2 +-
.../astro/src/core/redirects/component.ts | 2 +-
packages/astro/src/core/redirects/helpers.ts | 3 +-
packages/astro/src/core/render-context.ts | 15 +-
packages/astro/src/core/render/index.ts | 3 +-
packages/astro/src/core/render/paginate.ts | 4 +-
.../astro/src/core/render/params-and-props.ts | 4 +-
packages/astro/src/core/render/renderer.ts | 3 +-
packages/astro/src/core/render/route-cache.ts | 8 +-
packages/astro/src/core/render/slots.ts | 2 +-
packages/astro/src/core/render/ssr-element.ts | 4 +-
.../routing/astro-designed-error-pages.ts | 3 +-
packages/astro/src/core/routing/default.ts | 3 +-
.../astro/src/core/routing/manifest/create.ts | 12 +-
.../src/core/routing/manifest/generator.ts | 4 +-
.../src/core/routing/manifest/pattern.ts | 3 +-
.../core/routing/manifest/serialization.ts | 4 +-
packages/astro/src/core/routing/match.ts | 3 +-
packages/astro/src/core/routing/params.ts | 3 +-
packages/astro/src/core/routing/priority.ts | 2 +-
packages/astro/src/core/routing/rewrite.ts | 4 +-
packages/astro/src/core/routing/validation.ts | 4 +-
.../astro/src/core/server-islands/endpoint.ts | 8 +-
.../vite-plugin-server-islands.ts | 2 +-
packages/astro/src/core/sync/index.ts | 3 +-
packages/astro/src/core/sync/write-files.ts | 4 +-
packages/astro/src/core/util.ts | 4 +-
packages/astro/src/env/sync.ts | 2 +-
packages/astro/src/env/vite-plugin-env.ts | 2 +-
packages/astro/src/events/session.ts | 3 +-
packages/astro/src/i18n/index.ts | 10 +-
packages/astro/src/i18n/middleware.ts | 5 +-
packages/astro/src/i18n/utils.ts | 2 +-
packages/astro/src/i18n/vite-plugin-i18n.ts | 3 +-
.../src/integrations/features-validation.ts | 16 +-
packages/astro/src/integrations/hooks.ts | 27 +-
packages/astro/src/jsx/renderer.ts | 5 +-
packages/astro/src/jsx/server.ts | 2 +-
packages/astro/src/jsx/transform-options.ts | 2 +-
packages/astro/src/preferences/index.ts | 3 +-
.../src/prefetch/vite-plugin-prefetch.ts | 2 +-
packages/astro/src/prerender/routing.ts | 3 +-
packages/astro/src/prerender/utils.ts | 2 +-
.../runtime/client/dev-toolbar/apps/astro.ts | 2 +-
.../client/dev-toolbar/apps/audit/index.ts | 2 +-
.../dev-toolbar/apps/audit/ui/audit-ui.ts | 2 +-
.../client/dev-toolbar/apps/settings.ts | 2 +-
.../runtime/client/dev-toolbar/apps/xray.ts | 2 +-
.../runtime/client/dev-toolbar/entrypoint.ts | 2 +-
.../src/runtime/client/dev-toolbar/toolbar.ts | 2 +-
packages/astro/src/runtime/client/idle.ts | 2 +-
packages/astro/src/runtime/client/load.ts | 2 +-
packages/astro/src/runtime/client/media.ts | 2 +-
packages/astro/src/runtime/client/only.ts | 2 +-
packages/astro/src/runtime/client/visible.ts | 3 +-
.../src/runtime/server/astro-component.ts | 2 +-
.../astro/src/runtime/server/astro-global.ts | 2 +-
packages/astro/src/runtime/server/endpoint.ts | 7 +-
.../astro/src/runtime/server/hydration.ts | 8 +-
packages/astro/src/runtime/server/jsx.ts | 2 +-
.../runtime/server/render/astro/factory.ts | 2 +-
.../runtime/server/render/astro/instance.ts | 2 +-
.../src/runtime/server/render/astro/render.ts | 2 +-
.../astro/src/runtime/server/render/common.ts | 2 +-
.../src/runtime/server/render/component.ts | 12 +-
.../astro/src/runtime/server/render/dom.ts | 3 +-
.../astro/src/runtime/server/render/head.ts | 3 +-
.../astro/src/runtime/server/render/page.ts | 2 +-
.../astro/src/runtime/server/render/script.ts | 2 +-
.../runtime/server/render/server-islands.ts | 2 +-
.../astro/src/runtime/server/render/slot.ts | 2 +-
.../astro/src/runtime/server/render/tags.ts | 2 +-
.../astro/src/runtime/server/render/util.ts | 2 +-
packages/astro/src/runtime/server/scripts.ts | 2 +-
.../astro/src/runtime/server/serialize.ts | 2 +-
.../astro/src/runtime/server/transition.ts | 6 +-
packages/astro/src/toolbar/index.ts | 2 +-
.../src/toolbar/vite-plugin-dev-toolbar.ts | 2 +-
packages/astro/src/transitions/index.ts | 6 +-
.../transitions/vite-plugin-transitions.ts | 2 +-
packages/astro/src/types/astro.ts | 97 +
packages/astro/src/types/public/common.ts | 176 ++
.../astro.ts => types/public/config.ts} | 1677 +----------------
packages/astro/src/types/public/container.ts | 10 +
packages/astro/src/types/public/content.ts | 121 ++
packages/astro/src/types/public/context.ts | 501 +++++
packages/astro/src/types/public/elements.ts | 47 +
.../{@types => types/public}/extendables.ts | 7 +-
packages/astro/src/types/public/index.ts | 44 +
.../astro/src/types/public/integrations.ts | 258 +++
packages/astro/src/types/public/internal.ts | 202 ++
packages/astro/src/types/public/preview.ts | 28 +
packages/astro/src/types/public/toolbar.ts | 96 +
.../public}/view-transitions.ts | 15 +
.../src/{@types => types}/typed-emitter.ts | 0
.../astro/src/virtual-modules/container.ts | 3 +-
packages/astro/src/virtual-modules/i18n.ts | 9 +-
.../src/vite-plugin-astro-server/base.ts | 2 +-
.../src/vite-plugin-astro-server/error.ts | 2 +-
.../src/vite-plugin-astro-server/metadata.ts | 2 +-
.../src/vite-plugin-astro-server/pipeline.ts | 20 +-
.../src/vite-plugin-astro-server/plugin.ts | 4 +-
.../src/vite-plugin-astro-server/request.ts | 2 +-
.../src/vite-plugin-astro-server/route.ts | 3 +-
.../src/vite-plugin-astro-server/scripts.ts | 2 +-
.../astro/src/vite-plugin-astro/compile.ts | 2 +-
packages/astro/src/vite-plugin-astro/index.ts | 3 +-
packages/astro/src/vite-plugin-astro/types.ts | 2 +-
.../src/vite-plugin-config-alias/index.ts | 2 +-
packages/astro/src/vite-plugin-env/index.ts | 3 +-
packages/astro/src/vite-plugin-head/index.ts | 2 +-
.../index.ts | 3 +-
.../content-entry-type.ts | 6 +-
.../astro/src/vite-plugin-markdown/index.ts | 2 +-
.../src/vite-plugin-mdx/transform-jsx.ts | 2 +-
.../astro/src/vite-plugin-scanner/index.ts | 3 +-
.../astro/src/vite-plugin-scanner/scan.ts | 2 +-
.../astro/src/vite-plugin-scripts/index.ts | 3 +-
.../astro/src/vite-plugin-scripts/page-ssr.ts | 2 +-
packages/astro/src/vite-plugin-utils/index.ts | 2 +-
packages/astro/types.d.ts | 2 +-
198 files changed, 2006 insertions(+), 2037 deletions(-)
delete mode 100644 packages/astro/src/@types/README.md
create mode 100644 packages/astro/src/types/astro.ts
create mode 100644 packages/astro/src/types/public/common.ts
rename packages/astro/src/{@types/astro.ts => types/public/config.ts} (59%)
create mode 100644 packages/astro/src/types/public/container.ts
create mode 100644 packages/astro/src/types/public/content.ts
create mode 100644 packages/astro/src/types/public/context.ts
create mode 100644 packages/astro/src/types/public/elements.ts
rename packages/astro/src/{@types => types/public}/extendables.ts (68%)
create mode 100644 packages/astro/src/types/public/index.ts
create mode 100644 packages/astro/src/types/public/integrations.ts
create mode 100644 packages/astro/src/types/public/internal.ts
create mode 100644 packages/astro/src/types/public/preview.ts
create mode 100644 packages/astro/src/types/public/toolbar.ts
rename packages/astro/src/{@types => types/public}/view-transitions.ts (61%)
rename packages/astro/src/{@types => types}/typed-emitter.ts (100%)
diff --git a/packages/astro/astro-jsx.d.ts b/packages/astro/astro-jsx.d.ts
index b26507d1db58..128709dfc528 100644
--- a/packages/astro/astro-jsx.d.ts
+++ b/packages/astro/astro-jsx.d.ts
@@ -17,23 +17,21 @@ declare namespace astroHTML.JSX {
children: {};
}
- interface IntrinsicAttributes
- extends AstroBuiltinProps,
- AstroBuiltinAttributes,
- AstroClientDirectives {
+ interface IntrinsicAttributes extends AstroComponentDirectives, AstroBuiltinAttributes {
slot?: string | undefined | null;
children?: Children;
}
- type AstroBuiltinProps = import('./dist/@types/astro.js').AstroBuiltinProps;
- type AstroClientDirectives = import('./dist/@types/astro.js').AstroClientDirectives;
- type AstroBuiltinAttributes = import('./dist/@types/astro.js').AstroBuiltinAttributes;
- type AstroDefineVarsAttribute = import('./dist/@types/astro.js').AstroDefineVarsAttribute;
- type AstroScriptAttributes = import('./dist/@types/astro.js').AstroScriptAttributes &
+ type AstroComponentDirectives =
+ import('./dist/types/public/elements.js').AstroComponentDirectives;
+ type AstroBuiltinAttributes = import('./dist/types/public/elements.js').AstroBuiltinAttributes;
+ type AstroDefineVarsAttribute =
+ import('./dist/types/public/elements.js').AstroDefineVarsAttribute;
+ type AstroScriptAttributes = import('./dist/types/public/elements.js').AstroScriptAttributes &
AstroDefineVarsAttribute;
- type AstroStyleAttributes = import('./dist/@types/astro.js').AstroStyleAttributes &
+ type AstroStyleAttributes = import('./dist/types/public/elements.js').AstroStyleAttributes &
AstroDefineVarsAttribute;
- type AstroSlotAttributes = import('./dist/@types/astro.js').AstroSlotAttributes;
+ type AstroSlotAttributes = import('./dist/types/public/elements.js').AstroSlotAttributes;
// This is an unfortunate use of `any`, but unfortunately we can't make a type that works for every framework
// without importing every single framework's types (which comes with its own set of problems).
diff --git a/packages/astro/client.d.ts b/packages/astro/client.d.ts
index ed5c1b894d28..796bf3f33deb 100644
--- a/packages/astro/client.d.ts
+++ b/packages/astro/client.d.ts
@@ -2,12 +2,6 @@
///
///
-// eslint-disable-next-line @typescript-eslint/no-namespace
-declare namespace App {
- // eslint-disable-next-line @typescript-eslint/no-empty-interface
- export interface Locals {}
-}
-
interface ImportMetaEnv {
/**
* The prefix for Astro-generated asset links if the build.assetsPrefix config option is set. This can be used to create asset links not handled by Astro.
@@ -52,7 +46,7 @@ declare module 'astro:assets' {
getImage: (
options: import('./dist/assets/types.js').UnresolvedImageTransform,
) => Promise;
- imageConfig: import('./dist/@types/astro.js').AstroConfig['image'];
+ imageConfig: import('./dist/types/public/config.js').AstroConfig['image'];
getConfiguredImageService: typeof import('./dist/assets/index.js').getConfiguredImageService;
inferRemoteSize: typeof import('./dist/assets/utils/index.js').inferRemoteSize;
Image: typeof import('./components/Image.astro').default;
@@ -172,7 +166,7 @@ declare module 'astro:components' {
export * from 'astro/components';
}
-type MD = import('./dist/@types/astro.js').MarkdownInstance>;
+type MD = import('./dist/types/public/content.js').MarkdownInstance>;
interface ExportedMarkdownModuleEntities {
frontmatter: MD['frontmatter'];
file: MD['file'];
@@ -191,7 +185,6 @@ declare module '*.md' {
file,
url,
getHeadings,
- getHeaders,
Content,
rawContent,
compiledContent,
@@ -206,7 +199,6 @@ declare module '*.markdown' {
file,
url,
getHeadings,
- getHeaders,
Content,
rawContent,
compiledContent,
@@ -221,7 +213,6 @@ declare module '*.mkdn' {
file,
url,
getHeadings,
- getHeaders,
Content,
rawContent,
compiledContent,
@@ -236,7 +227,6 @@ declare module '*.mkd' {
file,
url,
getHeadings,
- getHeaders,
Content,
rawContent,
compiledContent,
@@ -251,7 +241,6 @@ declare module '*.mdwn' {
file,
url,
getHeadings,
- getHeaders,
Content,
rawContent,
compiledContent,
@@ -266,7 +255,6 @@ declare module '*.mdown' {
file,
url,
getHeadings,
- getHeaders,
Content,
rawContent,
compiledContent,
@@ -275,7 +263,7 @@ declare module '*.mdown' {
}
declare module '*.mdx' {
- type MDX = import('./dist/@types/astro.js').MDXInstance>;
+ type MDX = import('./dist/types/public/content.js').MDXInstance>;
export const frontmatter: MDX['frontmatter'];
export const file: MDX['file'];
@@ -288,7 +276,7 @@ declare module '*.mdx' {
}
declare module 'astro:ssr-manifest' {
- export const manifest: import('./dist/@types/astro.js').SSRManifest;
+ export const manifest: import('./dist/types/public/internal.js').SSRManifest;
}
// Everything below are Vite's types (apart from image types, which are in `client.d.ts`)
diff --git a/packages/astro/env.d.ts b/packages/astro/env.d.ts
index 876a29c60f49..d2a788db3d3f 100644
--- a/packages/astro/env.d.ts
+++ b/packages/astro/env.d.ts
@@ -4,7 +4,7 @@
// As such, if the typings you're trying to add should be available inside ex: React components, they should instead
// be inside `client.d.ts`
-type Astro = import('./dist/@types/astro.js').AstroGlobal;
+type Astro = import('./dist/types/public/context.js').AstroGlobal;
// We have to duplicate the description here because editors won't show the JSDoc comment from the imported type
// However, they will for its properties, ex: Astro.request will show the AstroGlobal.request description
diff --git a/packages/astro/index.d.ts b/packages/astro/index.d.ts
index a9e679be17d9..7b7a236e7970 100644
--- a/packages/astro/index.d.ts
+++ b/packages/astro/index.d.ts
@@ -1,2 +1,2 @@
-export type * from './dist/@types/astro.js';
+export type * from './dist/types/public/index.js';
export * from './dist/core/index.js';
diff --git a/packages/astro/src/@types/README.md b/packages/astro/src/@types/README.md
deleted file mode 100644
index 397329eaf218..000000000000
--- a/packages/astro/src/@types/README.md
+++ /dev/null
@@ -1,5 +0,0 @@
-# `@types/`
-
-TypeScript definitions and types for untyped modules.
-
-[See CONTRIBUTING.md](../../../../CONTRIBUTING.md) for a code overview.
diff --git a/packages/astro/src/actions/index.ts b/packages/astro/src/actions/index.ts
index 2423b7017d43..61f5a00cc3ab 100644
--- a/packages/astro/src/actions/index.ts
+++ b/packages/astro/src/actions/index.ts
@@ -1,9 +1,10 @@
import fsMod from 'node:fs';
import type { Plugin as VitePlugin } from 'vite';
-import type { AstroIntegration, AstroSettings } from '../@types/astro.js';
import { ActionsWithoutServerOutputError } from '../core/errors/errors-data.js';
import { AstroError } from '../core/errors/errors.js';
import { isServerLikeOutput, viteID } from '../core/util.js';
+import type { AstroSettings } from '../types/astro.js';
+import type { AstroIntegration } from '../types/public/integrations.js';
import {
ACTIONS_TYPES_FILE,
NOOP_ACTIONS,
diff --git a/packages/astro/src/actions/runtime/middleware.ts b/packages/astro/src/actions/runtime/middleware.ts
index f3f01800a837..b6f3221b5700 100644
--- a/packages/astro/src/actions/runtime/middleware.ts
+++ b/packages/astro/src/actions/runtime/middleware.ts
@@ -1,8 +1,9 @@
import { yellow } from 'kleur/colors';
-import type { APIContext, MiddlewareNext } from '../../@types/astro.js';
import { ActionQueryStringInvalidError } from '../../core/errors/errors-data.js';
import { AstroError } from '../../core/errors/errors.js';
import { defineMiddleware } from '../../core/middleware/index.js';
+import type { MiddlewareNext } from '../../types/public/common.js';
+import type { APIContext } from '../../types/public/context.js';
import { ACTION_QUERY_PARAMS } from '../consts.js';
import { formContentTypes, hasContentType } from './utils.js';
import { getAction } from './virtual/get-action.js';
diff --git a/packages/astro/src/actions/runtime/route.ts b/packages/astro/src/actions/runtime/route.ts
index e4e2ad1ce5b1..7279a093d07e 100644
--- a/packages/astro/src/actions/runtime/route.ts
+++ b/packages/astro/src/actions/runtime/route.ts
@@ -1,4 +1,4 @@
-import type { APIRoute } from '../../@types/astro.js';
+import type { APIRoute } from '../../types/public/common.js';
import { formContentTypes, hasContentType } from './utils.js';
import { getAction } from './virtual/get-action.js';
import { serializeActionResult } from './virtual/shared.js';
diff --git a/packages/astro/src/actions/runtime/utils.ts b/packages/astro/src/actions/runtime/utils.ts
index 776171aa2ac5..199809d4e87c 100644
--- a/packages/astro/src/actions/runtime/utils.ts
+++ b/packages/astro/src/actions/runtime/utils.ts
@@ -1,4 +1,4 @@
-import type { APIContext } from '../../@types/astro.js';
+import type { APIContext } from '../../types/public/context.js';
export const formContentTypes = ['application/x-www-form-urlencoded', 'multipart/form-data'];
diff --git a/packages/astro/src/actions/utils.ts b/packages/astro/src/actions/utils.ts
index 5cf78626600f..f1cab8e430f2 100644
--- a/packages/astro/src/actions/utils.ts
+++ b/packages/astro/src/actions/utils.ts
@@ -1,6 +1,6 @@
-import type { APIContext } from '../@types/astro.js';
+import type { APIContext } from '../types/public/context.js';
import type { Locals } from './runtime/middleware.js';
-import { type ActionAPIContext } from './runtime/utils.js';
+import type { ActionAPIContext } from './runtime/utils.js';
import { deserializeActionResult, getActionQueryString } from './runtime/virtual/shared.js';
export function hasActionPayload(locals: APIContext['locals']): locals is Locals {
diff --git a/packages/astro/src/assets/build/generate.ts b/packages/astro/src/assets/build/generate.ts
index fcc19f4f53a9..1c4866592828 100644
--- a/packages/astro/src/assets/build/generate.ts
+++ b/packages/astro/src/assets/build/generate.ts
@@ -2,7 +2,6 @@ import fs, { readFileSync } from 'node:fs';
import { basename } from 'node:path/posix';
import { dim, green } from 'kleur/colors';
import type PQueue from 'p-queue';
-import type { AstroConfig } from '../../@types/astro.js';
import { getOutDirWithinCwd } from '../../core/build/common.js';
import type { BuildPipeline } from '../../core/build/pipeline.js';
import { getTimeStat } from '../../core/build/util.js';
@@ -12,6 +11,7 @@ import type { Logger } from '../../core/logger/core.js';
import { isRemotePath, removeLeadingForwardSlash } from '../../core/path.js';
import { isServerLikeOutput } from '../../core/util.js';
import type { MapValue } from '../../type-utils.js';
+import type { AstroConfig } from '../../types/public/config.js';
import { getConfiguredImageService } from '../internal.js';
import type { LocalImageService } from '../services/service.js';
import type { AssetsGlobalStaticImagesList, ImageMetadata, ImageTransform } from '../types.js';
diff --git a/packages/astro/src/assets/endpoint/config.ts b/packages/astro/src/assets/endpoint/config.ts
index 07cfe8faecbb..ff9dcc79a807 100644
--- a/packages/astro/src/assets/endpoint/config.ts
+++ b/packages/astro/src/assets/endpoint/config.ts
@@ -1,4 +1,4 @@
-import type { AstroSettings } from '../../@types/astro.js';
+import type { AstroSettings } from '../../types/astro.js';
export function injectImageEndpoint(settings: AstroSettings, mode: 'dev' | 'build') {
const endpointEntrypoint =
diff --git a/packages/astro/src/assets/endpoint/generic.ts b/packages/astro/src/assets/endpoint/generic.ts
index 5238f3721a4d..d453787fd87e 100644
--- a/packages/astro/src/assets/endpoint/generic.ts
+++ b/packages/astro/src/assets/endpoint/generic.ts
@@ -2,7 +2,7 @@
import { imageConfig } from 'astro:assets';
import { isRemotePath } from '@astrojs/internal-helpers/path';
import * as mime from 'mrmime';
-import type { APIRoute } from '../../@types/astro.js';
+import type { APIRoute } from '../../types/public/common.js';
import { getConfiguredImageService } from '../internal.js';
import { etag } from '../utils/etag.js';
import { isRemoteAllowed } from '../utils/remotePattern.js';
diff --git a/packages/astro/src/assets/endpoint/node.ts b/packages/astro/src/assets/endpoint/node.ts
index 4c50fe95fdb3..e3764940812f 100644
--- a/packages/astro/src/assets/endpoint/node.ts
+++ b/packages/astro/src/assets/endpoint/node.ts
@@ -7,7 +7,7 @@ import { assetsDir, imageConfig, outDir } from 'astro:assets';
import { isRemotePath, removeQueryString } from '@astrojs/internal-helpers/path';
import { readFile } from 'fs/promises';
import * as mime from 'mrmime';
-import type { APIRoute } from '../../@types/astro.js';
+import type { APIRoute } from '../../types/public/common.js';
import { getConfiguredImageService } from '../internal.js';
import { etag } from '../utils/etag.js';
import { isRemoteAllowed } from '../utils/remotePattern.js';
diff --git a/packages/astro/src/assets/internal.ts b/packages/astro/src/assets/internal.ts
index 38afbf19fc9b..9a5926e8d255 100644
--- a/packages/astro/src/assets/internal.ts
+++ b/packages/astro/src/assets/internal.ts
@@ -1,5 +1,5 @@
-import type { AstroConfig } from '../@types/astro.js';
import { AstroError, AstroErrorData } from '../core/errors/index.js';
+import type { AstroConfig } from '../types/public/config.js';
import { DEFAULT_HASH_PROPS } from './consts.js';
import { type ImageService, isLocalService } from './services/service.js';
import {
diff --git a/packages/astro/src/assets/services/service.ts b/packages/astro/src/assets/services/service.ts
index 9cd6d0ecba42..f798e1dfd142 100644
--- a/packages/astro/src/assets/services/service.ts
+++ b/packages/astro/src/assets/services/service.ts
@@ -1,6 +1,6 @@
-import type { AstroConfig } from '../../@types/astro.js';
import { AstroError, AstroErrorData } from '../../core/errors/index.js';
import { isRemotePath, joinPaths } from '../../core/path.js';
+import type { AstroConfig } from '../../types/public/config.js';
import { DEFAULT_HASH_PROPS, DEFAULT_OUTPUT_FORMAT, VALID_SUPPORTED_FORMATS } from '../consts.js';
import type { ImageOutputFormat, ImageTransform, UnresolvedSrcSetValue } from '../types.js';
import { isESMImportedImage } from '../utils/imageKind.js';
diff --git a/packages/astro/src/assets/utils/remotePattern.ts b/packages/astro/src/assets/utils/remotePattern.ts
index 5feefb89fe73..d3e832573a7f 100644
--- a/packages/astro/src/assets/utils/remotePattern.ts
+++ b/packages/astro/src/assets/utils/remotePattern.ts
@@ -1,5 +1,5 @@
import { isRemotePath } from '@astrojs/internal-helpers/path';
-import type { AstroConfig } from '../../@types/astro.js';
+import type { AstroConfig } from '../../types/public/config.js';
export type RemotePattern = {
hostname?: string;
diff --git a/packages/astro/src/assets/vite-plugin-assets.ts b/packages/astro/src/assets/vite-plugin-assets.ts
index 4c9314e85fad..57bbf847a4ff 100644
--- a/packages/astro/src/assets/vite-plugin-assets.ts
+++ b/packages/astro/src/assets/vite-plugin-assets.ts
@@ -2,7 +2,6 @@ import { extname } from 'node:path';
import MagicString from 'magic-string';
import type * as vite from 'vite';
import { normalizePath } from 'vite';
-import type { AstroPluginOptions, AstroSettings, ImageTransform } from '../@types/astro.js';
import { extendManualChunks } from '../core/build/plugins/util.js';
import { AstroError, AstroErrorData } from '../core/errors/index.js';
import {
@@ -13,7 +12,9 @@ import {
removeQueryString,
} from '../core/path.js';
import { isServerLikeOutput } from '../core/util.js';
+import type { AstroPluginOptions, AstroSettings } from '../types/astro.js';
import { VALID_INPUT_FORMATS, VIRTUAL_MODULE_ID, VIRTUAL_SERVICE_ID } from './consts.js';
+import type { ImageTransform } from './types.js';
import { getAssetsPrefix } from './utils/getAssetsPrefix.js';
import { isESMImportedImage } from './utils/imageKind.js';
import { emitESMImage } from './utils/node/emitAsset.js';
diff --git a/packages/astro/src/cli/db/index.ts b/packages/astro/src/cli/db/index.ts
index c6be7411bb2a..1461aef0cdb0 100644
--- a/packages/astro/src/cli/db/index.ts
+++ b/packages/astro/src/cli/db/index.ts
@@ -1,6 +1,6 @@
-import type { AstroConfig } from '../../@types/astro.js';
import { resolveConfig } from '../../core/config/config.js';
import { apply as applyPolyfill } from '../../core/polyfill.js';
+import type { AstroConfig } from '../../types/public/config.js';
import { type Flags, createLoggerFromFlags, flagsToAstroInlineConfig } from '../flags.js';
import { getPackage } from '../install-package.js';
diff --git a/packages/astro/src/cli/flags.ts b/packages/astro/src/cli/flags.ts
index 59dfbf00a4bd..f7ffc48e4cea 100644
--- a/packages/astro/src/cli/flags.ts
+++ b/packages/astro/src/cli/flags.ts
@@ -1,7 +1,7 @@
import type { parseArgs } from 'node:util';
-import type { AstroInlineConfig } from '../@types/astro.js';
import { type LogOptions, Logger } from '../core/logger/core.js';
import { nodeLogDestination } from '../core/logger/node.js';
+import type { AstroInlineConfig } from '../types/public/config.js';
export type ParsedArgsResult = ReturnType;
export type Flags = ParsedArgsResult['values'];
diff --git a/packages/astro/src/cli/info/index.ts b/packages/astro/src/cli/info/index.ts
index 3fa91802f26e..9f25a253516a 100644
--- a/packages/astro/src/cli/info/index.ts
+++ b/packages/astro/src/cli/info/index.ts
@@ -3,10 +3,10 @@ import { arch, platform } from 'node:os';
/* eslint-disable no-console */
import * as colors from 'kleur/colors';
import prompts from 'prompts';
-import type { AstroConfig, AstroUserConfig } from '../../@types/astro.js';
import { resolveConfig } from '../../core/config/index.js';
import { ASTRO_VERSION } from '../../core/constants.js';
import { apply as applyPolyfill } from '../../core/polyfill.js';
+import type { AstroConfig, AstroUserConfig } from '../../types/public/config.js';
import { type Flags, flagsToAstroInlineConfig } from '../flags.js';
interface InfoOptions {
diff --git a/packages/astro/src/cli/preferences/index.ts b/packages/astro/src/cli/preferences/index.ts
index 3811e7f48708..bd60343c22c5 100644
--- a/packages/astro/src/cli/preferences/index.ts
+++ b/packages/astro/src/cli/preferences/index.ts
@@ -1,5 +1,5 @@
/* eslint-disable no-console */
-import type { AstroSettings } from '../../@types/astro.js';
+import type { AstroSettings } from '../../types/astro.js';
import { fileURLToPath } from 'node:url';
import { bgGreen, black, bold, dim, yellow } from 'kleur/colors';
diff --git a/packages/astro/src/config/index.ts b/packages/astro/src/config/index.ts
index 3c5faf2fa087..b31105ec7adc 100644
--- a/packages/astro/src/config/index.ts
+++ b/packages/astro/src/config/index.ts
@@ -1,6 +1,6 @@
import type { UserConfig as ViteUserConfig } from 'vite';
-import type { AstroInlineConfig, AstroUserConfig } from '../@types/astro.js';
import { Logger } from '../core/logger/core.js';
+import type { AstroInlineConfig, AstroUserConfig } from '../types/public/config.js';
export function defineConfig(config: AstroUserConfig) {
return config;
diff --git a/packages/astro/src/config/vite-plugin-content-listen.ts b/packages/astro/src/config/vite-plugin-content-listen.ts
index 1b65c5bfbbb3..6c0408001954 100644
--- a/packages/astro/src/config/vite-plugin-content-listen.ts
+++ b/packages/astro/src/config/vite-plugin-content-listen.ts
@@ -1,8 +1,8 @@
import type fsMod from 'node:fs';
import type { Plugin, ViteDevServer } from 'vite';
-import type { AstroSettings } from '../@types/astro.js';
import { attachContentServerListeners } from '../content/server-listeners.js';
import type { Logger } from '../core/logger/core.js';
+import type { AstroSettings } from '../types/astro.js';
/**
* Listen for Astro content directory changes and generate types.
diff --git a/packages/astro/src/container/index.ts b/packages/astro/src/container/index.ts
index f0c600a40623..6613a18099bf 100644
--- a/packages/astro/src/container/index.ts
+++ b/packages/astro/src/container/index.ts
@@ -1,19 +1,4 @@
import { posix } from 'node:path';
-import type {
- AstroConfig,
- AstroUserConfig,
- ComponentInstance,
- ContainerImportRendererFn,
- MiddlewareHandler,
- NamedSSRLoadedRendererValue,
- Props,
- RouteData,
- RouteType,
- SSRLoadedRenderer,
- SSRLoadedRendererValue,
- SSRManifest,
- SSRResult,
-} from '../@types/astro.js';
import { getDefaultClientDirectives } from '../core/client-directive/index.js';
import { ASTRO_CONFIG_DEFAULTS } from '../core/config/schema.js';
import { validateConfig } from '../core/config/validate.js';
@@ -25,7 +10,20 @@ import { RenderContext } from '../core/render-context.js';
import { getParts, validateSegment } from '../core/routing/manifest/create.js';
import { getPattern } from '../core/routing/manifest/pattern.js';
import type { AstroComponentFactory } from '../runtime/server/index.js';
+import type { ComponentInstance } from '../types/astro.js';
+import type { MiddlewareHandler, Props } from '../types/public/common.js';
+import type { AstroConfig, AstroUserConfig } from '../types/public/config.js';
+import type {
+ NamedSSRLoadedRendererValue,
+ RouteData,
+ RouteType,
+ SSRLoadedRenderer,
+ SSRLoadedRendererValue,
+ SSRManifest,
+ SSRResult,
+} from '../types/public/internal.js';
import { ContainerPipeline } from './pipeline.js';
+import type { ContainerRenderer } from '../types/public/container.js';
/**
* Options to be passed when rendering a route
@@ -103,6 +101,10 @@ export type AddClientRenderer = {
entrypoint: string;
};
+type ContainerImportRendererFn = (
+ containerRenderer: ContainerRenderer,
+) => Promise;
+
function createManifest(
manifest?: AstroContainerManifest,
renderers?: SSRLoadedRenderer[],
diff --git a/packages/astro/src/container/pipeline.ts b/packages/astro/src/container/pipeline.ts
index ff2718b8fbc6..73caa4ecd9a4 100644
--- a/packages/astro/src/container/pipeline.ts
+++ b/packages/astro/src/container/pipeline.ts
@@ -1,10 +1,3 @@
-import type {
- ComponentInstance,
- RewritePayload,
- RouteData,
- SSRElement,
- SSRResult,
-} from '../@types/astro.js';
import { type HeadElements, Pipeline } from '../core/base-pipeline.js';
import type { SinglePageBuiltModule } from '../core/build/types.js';
import {
@@ -12,6 +5,9 @@ import {
createStylesheetElementSet,
} from '../core/render/ssr-element.js';
import { findRouteToRewrite } from '../core/routing/rewrite.js';
+import type { ComponentInstance } from '../types/astro.js';
+import type { RewritePayload } from '../types/public/common.js';
+import type { RouteData, SSRElement, SSRResult } from '../types/public/internal.js';
export class ContainerPipeline extends Pipeline {
/**
diff --git a/packages/astro/src/content/content-layer.ts b/packages/astro/src/content/content-layer.ts
index 9a6d4ed37542..b032dcaeaa15 100644
--- a/packages/astro/src/content/content-layer.ts
+++ b/packages/astro/src/content/content-layer.ts
@@ -3,9 +3,9 @@ import { isAbsolute } from 'node:path';
import { fileURLToPath } from 'node:url';
import type { FSWatcher } from 'vite';
import xxhash from 'xxhash-wasm';
-import type { AstroSettings } from '../@types/astro.js';
import { AstroUserError } from '../core/errors/errors.js';
import type { Logger } from '../core/logger/core.js';
+import type { AstroSettings } from '../types/astro.js';
import {
ASSET_IMPORTS_FILE,
CONTENT_LAYER_TYPE,
diff --git a/packages/astro/src/content/data-store.ts b/packages/astro/src/content/data-store.ts
index f416082f9db0..e3b00f998924 100644
--- a/packages/astro/src/content/data-store.ts
+++ b/packages/astro/src/content/data-store.ts
@@ -1,6 +1,6 @@
+import { promises as fs, type PathLike, existsSync } from 'fs';
import type { MarkdownHeading } from '@astrojs/markdown-remark';
import * as devalue from 'devalue';
-import { existsSync, promises as fs, type PathLike } from 'fs';
import { imageSrcToImportId, importIdToSymbolName } from '../assets/utils/resolveImports.js';
import { AstroError, AstroErrorData } from '../core/errors/index.js';
import { CONTENT_MODULE_FLAG, DEFERRED_MODULE } from './consts.js';
diff --git a/packages/astro/src/content/loaders/glob.ts b/packages/astro/src/content/loaders/glob.ts
index 4a4ecbcac8d3..7c903fc130f7 100644
--- a/packages/astro/src/content/loaders/glob.ts
+++ b/packages/astro/src/content/loaders/glob.ts
@@ -4,10 +4,10 @@ import fastGlob from 'fast-glob';
import { bold, green } from 'kleur/colors';
import micromatch from 'micromatch';
import pLimit from 'p-limit';
-import type { ContentEntryRenderFuction, ContentEntryType } from '../../@types/astro.js';
import type { RenderedContent } from '../data-store.js';
import { getContentEntryIdAndSlug, getEntryConfigByExtMap, posixRelative } from '../utils.js';
import type { Loader } from './types.js';
+import type { ContentEntryRenderFunction, ContentEntryType } from '../../types/public/content.js';
export interface GenerateIdOptions {
/** The path to the entry file, relative to the base directory. */
@@ -69,7 +69,7 @@ export function glob(globOptions: GlobOptions): Loader {
load: async ({ settings, logger, watcher, parseData, store, generateDigest }) => {
const renderFunctionByContentType = new WeakMap<
ContentEntryType,
- ContentEntryRenderFuction
+ ContentEntryRenderFunction
>();
const untouchedEntries = new Set(store.keys());
@@ -131,7 +131,7 @@ export function glob(globOptions: GlobOptions): Loader {
if (entryType.getRenderFunction) {
let render = renderFunctionByContentType.get(entryType);
if (!render) {
- render = await entryType.getRenderFunction(settings);
+ render = await entryType.getRenderFunction(settings.config);
// Cache the render function for this content type, so it can re-use parsers and other expensive setup
renderFunctionByContentType.set(entryType, render);
}
diff --git a/packages/astro/src/content/loaders/types.ts b/packages/astro/src/content/loaders/types.ts
index f372967277b7..e3e14a4d8d4c 100644
--- a/packages/astro/src/content/loaders/types.ts
+++ b/packages/astro/src/content/loaders/types.ts
@@ -1,6 +1,7 @@
import type { FSWatcher } from 'vite';
import type { ZodSchema } from 'zod';
-import type { AstroIntegrationLogger, AstroSettings } from '../../@types/astro.js';
+import type { AstroIntegrationLogger } from '../../core/logger/core.js';
+import type { AstroSettings } from '../../types/astro.js';
import type { MetaStore, ScopedDataStore } from '../data-store.js';
export interface ParseDataOptions> {
diff --git a/packages/astro/src/content/runtime.ts b/packages/astro/src/content/runtime.ts
index b462e2e23a46..489625532950 100644
--- a/packages/astro/src/content/runtime.ts
+++ b/packages/astro/src/content/runtime.ts
@@ -2,7 +2,7 @@ import type { MarkdownHeading } from '@astrojs/markdown-remark';
import { Traverse } from 'neotraverse/modern';
import pLimit from 'p-limit';
import { ZodIssueCode, z } from 'zod';
-import type { GetImageResult, ImageMetadata } from '../@types/astro.js';
+import type { GetImageResult, ImageMetadata } from '../assets/types.js';
import { imageSrcToImportId } from '../assets/utils/resolveImports.js';
import { AstroError, AstroErrorData, AstroUserError } from '../core/errors/index.js';
import { prependForwardSlash } from '../core/path.js';
diff --git a/packages/astro/src/content/server-listeners.ts b/packages/astro/src/content/server-listeners.ts
index 5d7868d58935..28f5b16a83e0 100644
--- a/packages/astro/src/content/server-listeners.ts
+++ b/packages/astro/src/content/server-listeners.ts
@@ -3,10 +3,10 @@ import path from 'node:path';
import { fileURLToPath, pathToFileURL } from 'node:url';
import { bold, cyan, underline } from 'kleur/colors';
import type { ViteDevServer } from 'vite';
-import type { AstroSettings } from '../@types/astro.js';
import { loadTSConfig } from '../core/config/tsconfig.js';
import type { Logger } from '../core/logger/core.js';
import { appendForwardSlash } from '../core/path.js';
+import type { AstroSettings } from '../types/astro.js';
import { createContentTypesGenerator } from './types-generator.js';
import { type ContentPaths, getContentPaths, globalContentConfigObserver } from './utils.js';
diff --git a/packages/astro/src/content/types-generator.ts b/packages/astro/src/content/types-generator.ts
index 6fa0db94beb2..15d7d032d33f 100644
--- a/packages/astro/src/content/types-generator.ts
+++ b/packages/astro/src/content/types-generator.ts
@@ -1,17 +1,17 @@
-import glob from 'fast-glob';
-import { bold, cyan } from 'kleur/colors';
import type fsMod from 'node:fs';
import * as path from 'node:path';
import { fileURLToPath, pathToFileURL } from 'node:url';
+import glob from 'fast-glob';
+import { bold, cyan } from 'kleur/colors';
import { type ViteDevServer, normalizePath } from 'vite';
-import { z, type ZodSchema } from 'zod';
+import { type ZodSchema, z } from 'zod';
import { zodToJsonSchema } from 'zod-to-json-schema';
import { printNode, zodToTs } from 'zod-to-ts';
-import type { AstroSettings, ContentEntryType } from '../@types/astro.js';
import { AstroError } from '../core/errors/errors.js';
import { AstroErrorData } from '../core/errors/index.js';
import type { Logger } from '../core/logger/core.js';
import { isRelativePath } from '../core/path.js';
+import type { AstroSettings } from '../types/astro.js';
import { CONTENT_LAYER_TYPE, CONTENT_TYPES_FILE, VIRTUAL_MODULE_ID } from './consts.js';
import {
type CollectionConfig,
@@ -28,6 +28,7 @@ import {
getEntryType,
reloadContentConfigObserver,
} from './utils.js';
+import type { ContentEntryType } from '../types/public/content.js';
type ChokidarEvent = 'add' | 'addDir' | 'change' | 'unlink' | 'unlinkDir';
type RawContentEvent = { name: ChokidarEvent; entry: string };
@@ -473,7 +474,7 @@ async function writeContentFiles({
collection.type === 'unknown'
? // Add empty / unknown collections to the data type map by default
// This ensures `getCollection('empty-collection')` doesn't raise a type error
- (collectionConfig?.type ?? 'data')
+ collectionConfig?.type ?? 'data'
: collection.type;
const collectionEntryKeys = Object.keys(collection.entries).sort();
diff --git a/packages/astro/src/content/utils.ts b/packages/astro/src/content/utils.ts
index 79a37a28d02f..b16030f26b4d 100644
--- a/packages/astro/src/content/utils.ts
+++ b/packages/astro/src/content/utils.ts
@@ -7,15 +7,11 @@ import type { PluginContext } from 'rollup';
import { type ViteDevServer, normalizePath } from 'vite';
import xxhash from 'xxhash-wasm';
import { z } from 'zod';
-import type {
- AstroConfig,
- AstroSettings,
- ContentEntryType,
- DataEntryType,
-} from '../@types/astro.js';
import { AstroError, AstroErrorData, MarkdownError, errorMap } from '../core/errors/index.js';
import { isYAMLException } from '../core/errors/utils.js';
import type { Logger } from '../core/logger/core.js';
+import type { AstroSettings } from '../types/astro.js';
+import type { AstroConfig } from '../types/public/config.js';
import {
CONTENT_FLAGS,
CONTENT_LAYER_TYPE,
@@ -24,6 +20,7 @@ import {
PROPAGATED_ASSET_FLAG,
} from './consts.js';
import { createImage } from './runtime-assets.js';
+import type { ContentEntryType, DataEntryType } from '../types/public/content.js';
/**
* Amap from a collection + slug to the local file path.
* This is used internally to resolve entry imports when using `getEntry()`.
diff --git a/packages/astro/src/content/vite-plugin-content-assets.ts b/packages/astro/src/content/vite-plugin-content-assets.ts
index b810b8f71a4e..8382142e29ff 100644
--- a/packages/astro/src/content/vite-plugin-content-assets.ts
+++ b/packages/astro/src/content/vite-plugin-content-assets.ts
@@ -1,7 +1,6 @@
import { extname } from 'node:path';
import { fileURLToPath, pathToFileURL } from 'node:url';
import type { Plugin } from 'vite';
-import type { AstroSettings, SSRElement } from '../@types/astro.js';
import { getAssetsPrefix } from '../assets/utils/getAssetsPrefix.js';
import type { BuildInternals } from '../core/build/internal.js';
import type { AstroBuildPlugin } from '../core/build/plugin.js';
@@ -9,6 +8,7 @@ import type { StaticBuildOptions } from '../core/build/types.js';
import type { ModuleLoader } from '../core/module-loader/loader.js';
import { createViteLoader } from '../core/module-loader/vite.js';
import { joinPaths, prependForwardSlash } from '../core/path.js';
+import type { AstroSettings } from '../types/astro.js';
import { getStylesForURL } from '../vite-plugin-astro-server/css.js';
import { getScriptsForURL } from '../vite-plugin-astro-server/scripts.js';
import {
@@ -20,6 +20,7 @@ import {
STYLES_PLACEHOLDER,
} from './consts.js';
import { hasContentFlag } from './utils.js';
+import type { SSRElement } from '../types/public/internal.js';
export function astroContentAssetPropagationPlugin({
mode,
diff --git a/packages/astro/src/content/vite-plugin-content-imports.ts b/packages/astro/src/content/vite-plugin-content-imports.ts
index 5a944716c353..5c545f3f34b8 100644
--- a/packages/astro/src/content/vite-plugin-content-imports.ts
+++ b/packages/astro/src/content/vite-plugin-content-imports.ts
@@ -4,19 +4,13 @@ import { pathToFileURL } from 'node:url';
import * as devalue from 'devalue';
import type { PluginContext } from 'rollup';
import type { Plugin } from 'vite';
-import type {
- AstroConfig,
- AstroSettings,
- ContentEntryModule,
- ContentEntryType,
- DataEntryModule,
- DataEntryType,
-} from '../@types/astro.js';
import { getProxyCode } from '../assets/utils/proxy.js';
import { AstroError } from '../core/errors/errors.js';
import { AstroErrorData } from '../core/errors/index.js';
import type { Logger } from '../core/logger/core.js';
import { isServerLikeOutput } from '../core/util.js';
+import type { AstroSettings } from '../types/astro.js';
+import type { AstroConfig } from '../types/public/config.js';
import { CONTENT_FLAG, DATA_FLAG } from './consts.js';
import {
type ContentConfig,
@@ -36,6 +30,12 @@ import {
reloadContentConfigObserver,
reverseSymlink,
} from './utils.js';
+import type {
+ ContentEntryType,
+ DataEntryType,
+ ContentEntryModule,
+ DataEntryModule,
+} from '../types/public/content.js';
function getContentRendererByViteId(
viteId: string,
diff --git a/packages/astro/src/content/vite-plugin-content-virtual-mod.ts b/packages/astro/src/content/vite-plugin-content-virtual-mod.ts
index 64e5d98ee410..832ca0b171ad 100644
--- a/packages/astro/src/content/vite-plugin-content-virtual-mod.ts
+++ b/packages/astro/src/content/vite-plugin-content-virtual-mod.ts
@@ -5,12 +5,12 @@ import { dataToEsm } from '@rollup/pluginutils';
import glob from 'fast-glob';
import pLimit from 'p-limit';
import type { Plugin } from 'vite';
-import type { AstroSettings } from '../@types/astro.js';
import { encodeName } from '../core/build/util.js';
import { AstroError, AstroErrorData } from '../core/errors/index.js';
import { appendForwardSlash, removeFileExtension } from '../core/path.js';
import { isServerLikeOutput } from '../core/util.js';
import { rootRelativePath } from '../core/viteUtils.js';
+import type { AstroSettings } from '../types/astro.js';
import type { AstroPluginMetadata } from '../vite-plugin-astro/index.js';
import { createDefaultAstroMetadata } from '../vite-plugin-astro/metadata.js';
import {
diff --git a/packages/astro/src/core/app/index.ts b/packages/astro/src/core/app/index.ts
index 8041dda3c6f7..3ffa5f144647 100644
--- a/packages/astro/src/core/app/index.ts
+++ b/packages/astro/src/core/app/index.ts
@@ -1,5 +1,6 @@
-import type { ManifestData, RouteData, SSRManifest } from '../../@types/astro.js';
import { normalizeTheLocale } from '../../i18n/index.js';
+import type { ManifestData } from '../../types/astro.js';
+import type { RouteData, SSRManifest } from '../../types/public/internal.js';
import {
REROUTABLE_STATUS_CODES,
REROUTE_DIRECTIVE_HEADER,
diff --git a/packages/astro/src/core/app/middlewares.ts b/packages/astro/src/core/app/middlewares.ts
index 095158b42ba3..a60b6baf4081 100644
--- a/packages/astro/src/core/app/middlewares.ts
+++ b/packages/astro/src/core/app/middlewares.ts
@@ -1,4 +1,4 @@
-import type { MiddlewareHandler } from '../../@types/astro.js';
+import type { MiddlewareHandler } from '../../types/public/common.js';
import { defineMiddleware } from '../middleware/index.js';
/**
diff --git a/packages/astro/src/core/app/node.ts b/packages/astro/src/core/app/node.ts
index f9afa6189d5a..86f0f5f65c46 100644
--- a/packages/astro/src/core/app/node.ts
+++ b/packages/astro/src/core/app/node.ts
@@ -1,6 +1,6 @@
import fs from 'node:fs';
import type { IncomingMessage, ServerResponse } from 'node:http';
-import type { RouteData } from '../../@types/astro.js';
+import type { RouteData } from '../../types/public/internal.js';
import { deserializeManifest } from './common.js';
import { createOutgoingHttpHeaders } from './createOutgoingHttpHeaders.js';
import { App } from './index.js';
diff --git a/packages/astro/src/core/app/pipeline.ts b/packages/astro/src/core/app/pipeline.ts
index b784ba916464..d42472f50493 100644
--- a/packages/astro/src/core/app/pipeline.ts
+++ b/packages/astro/src/core/app/pipeline.ts
@@ -1,11 +1,6 @@
-import type {
- ComponentInstance,
- ManifestData,
- RewritePayload,
- RouteData,
- SSRElement,
- SSRResult,
-} from '../../@types/astro.js';
+import type { ComponentInstance, ManifestData } from '../../types/astro.js';
+import type { RewritePayload } from '../../types/public/common.js';
+import type { RouteData, SSRElement, SSRResult } from '../../types/public/internal.js';
import { Pipeline } from '../base-pipeline.js';
import type { SinglePageBuiltModule } from '../build/types.js';
import { RedirectSinglePageBuiltModule } from '../redirects/component.js';
diff --git a/packages/astro/src/core/app/types.ts b/packages/astro/src/core/app/types.ts
index 00e37dacd9ba..29cb00ed4d1f 100644
--- a/packages/astro/src/core/app/types.ts
+++ b/packages/astro/src/core/app/types.ts
@@ -1,14 +1,13 @@
+import type { RoutingStrategies } from '../../i18n/utils.js';
+import type { ComponentInstance, SerializedRouteData } from '../../types/astro.js';
+import type { MiddlewareHandler } from '../../types/public/common.js';
+import type { Locales } from '../../types/public/config.js';
import type {
- ComponentInstance,
- Locales,
- MiddlewareHandler,
RouteData,
SSRComponentMetadata,
SSRLoadedRenderer,
SSRResult,
- SerializedRouteData,
-} from '../../@types/astro.js';
-import type { RoutingStrategies } from '../../i18n/utils.js';
+} from '../../types/public/internal.js';
import type { SinglePageBuiltModule } from '../build/types.js';
export type ComponentPath = string;
@@ -82,6 +81,7 @@ export type SSRManifestI18n = {
domainLookupTable: Record;
};
+/** Public type exposed through the `astro:build:ssr` integration hook */
export type SerializedSSRManifest = Omit<
SSRManifest,
| 'middleware'
diff --git a/packages/astro/src/core/base-pipeline.ts b/packages/astro/src/core/base-pipeline.ts
index 01e18bfa0356..562b651744b1 100644
--- a/packages/astro/src/core/base-pipeline.ts
+++ b/packages/astro/src/core/base-pipeline.ts
@@ -1,15 +1,14 @@
+import { setGetEnv } from '../env/runtime.js';
+import { createI18nMiddleware } from '../i18n/middleware.js';
+import type { ComponentInstance } from '../types/astro.js';
+import type { MiddlewareHandler, RewritePayload } from '../types/public/common.js';
+import type { RuntimeMode } from '../types/public/config.js';
import type {
- ComponentInstance,
- MiddlewareHandler,
- RewritePayload,
RouteData,
- RuntimeMode,
SSRLoadedRenderer,
SSRManifest,
SSRResult,
-} from '../@types/astro.js';
-import { setGetEnv } from '../env/runtime.js';
-import { createI18nMiddleware } from '../i18n/middleware.js';
+} from '../types/public/internal.js';
import { AstroError } from './errors/errors.js';
import { AstroErrorData } from './errors/index.js';
import type { Logger } from './logger/core.js';
diff --git a/packages/astro/src/core/build/common.ts b/packages/astro/src/core/build/common.ts
index a479aed390dd..f9ed45836181 100644
--- a/packages/astro/src/core/build/common.ts
+++ b/packages/astro/src/core/build/common.ts
@@ -1,7 +1,8 @@
import npath from 'node:path';
import { fileURLToPath, pathToFileURL } from 'node:url';
-import type { AstroConfig, RouteData } from '../../@types/astro.js';
import { appendForwardSlash } from '../../core/path.js';
+import type { AstroConfig } from '../../types/public/config.js';
+import type { RouteData } from '../../types/public/internal.js';
const STATUS_CODE_PAGES = new Set(['/404', '/500']);
const FALLBACK_OUT_DIR_NAME = './.astro/';
diff --git a/packages/astro/src/core/build/css-asset-name.ts b/packages/astro/src/core/build/css-asset-name.ts
index fbee7f2e2008..57277c989c2a 100644
--- a/packages/astro/src/core/build/css-asset-name.ts
+++ b/packages/astro/src/core/build/css-asset-name.ts
@@ -4,7 +4,7 @@ import crypto from 'node:crypto';
import npath from 'node:path';
import { fileURLToPath } from 'node:url';
import { normalizePath } from 'vite';
-import type { AstroSettings } from '../../@types/astro.js';
+import type { AstroSettings } from '../../types/astro.js';
import { viteID } from '../util.js';
import { getTopLevelPageModuleInfos } from './graph.js';
diff --git a/packages/astro/src/core/build/generate.ts b/packages/astro/src/core/build/generate.ts
index fae7896b9212..8cc5d97bd435 100644
--- a/packages/astro/src/core/build/generate.ts
+++ b/packages/astro/src/core/build/generate.ts
@@ -2,18 +2,6 @@ import fs from 'node:fs';
import os from 'node:os';
import { bgGreen, black, blue, bold, dim, green, magenta, red } from 'kleur/colors';
import PQueue from 'p-queue';
-import type {
- AstroConfig,
- AstroSettings,
- ComponentInstance,
- GetStaticPathsItem,
- MiddlewareHandler,
- RouteData,
- RouteType,
- SSRError,
- SSRLoadedRenderer,
- SSRManifest,
-} from '../../@types/astro.js';
import {
generateImagesForPath,
getStaticImageList,
@@ -29,7 +17,16 @@ import {
import { toRoutingStrategy } from '../../i18n/utils.js';
import { runHookBuildGenerated } from '../../integrations/hooks.js';
import { getOutputDirectory } from '../../prerender/utils.js';
-import type { SSRManifestI18n } from '../app/types.js';
+import type { AstroSettings, ComponentInstance } from '../../types/astro.js';
+import type { GetStaticPathsItem, MiddlewareHandler } from '../../types/public/common.js';
+import type { AstroConfig } from '../../types/public/config.js';
+import type {
+ RouteData,
+ RouteType,
+ SSRLoadedRenderer,
+ SSRError,
+} from '../../types/public/internal.js';
+import type { SSRManifest, SSRManifestI18n } from '../app/types.js';
import { NoPrerenderedRoutesWithDomains } from '../errors/errors-data.js';
import { AstroError, AstroErrorData } from '../errors/index.js';
import { getRedirectLocationOrThrow, routeIsRedirect } from '../redirects/index.js';
diff --git a/packages/astro/src/core/build/index.ts b/packages/astro/src/core/build/index.ts
index 72df05b89170..74a648304789 100644
--- a/packages/astro/src/core/build/index.ts
+++ b/packages/astro/src/core/build/index.ts
@@ -3,13 +3,6 @@ import { performance } from 'node:perf_hooks';
import { fileURLToPath } from 'node:url';
import { blue, bold, green } from 'kleur/colors';
import type * as vite from 'vite';
-import type {
- AstroConfig,
- AstroInlineConfig,
- AstroSettings,
- ManifestData,
- RuntimeMode,
-} from '../../@types/astro.js';
import { injectImageEndpoint } from '../../assets/endpoint/config.js';
import { telemetry } from '../../events/index.js';
import { eventCliSession } from '../../events/session.js';
@@ -19,6 +12,8 @@ import {
runHookConfigDone,
runHookConfigSetup,
} from '../../integrations/hooks.js';
+import type { AstroSettings, ManifestData } from '../../types/astro.js';
+import type { AstroConfig, AstroInlineConfig, RuntimeMode } from '../../types/public/config.js';
import { resolveConfig } from '../config/config.js';
import { createNodeLogger } from '../config/logging.js';
import { createSettings } from '../config/settings.js';
diff --git a/packages/astro/src/core/build/internal.ts b/packages/astro/src/core/build/internal.ts
index 5c28a4d40ed9..8c2d928244f2 100644
--- a/packages/astro/src/core/build/internal.ts
+++ b/packages/astro/src/core/build/internal.ts
@@ -1,5 +1,5 @@
import type { Rollup } from 'vite';
-import type { RouteData, SSRResult } from '../../@types/astro.js';
+import type { RouteData, SSRResult } from '../../types/public/internal.js';
import { prependForwardSlash, removeFileExtension } from '../path.js';
import { viteID } from '../util.js';
import { makePageDataKey } from './plugins/util.js';
diff --git a/packages/astro/src/core/build/page-data.ts b/packages/astro/src/core/build/page-data.ts
index 210b31a0e56f..06ed629f2ce6 100644
--- a/packages/astro/src/core/build/page-data.ts
+++ b/packages/astro/src/core/build/page-data.ts
@@ -1,4 +1,4 @@
-import type { AstroSettings, ManifestData } from '../../@types/astro.js';
+import type { AstroSettings, ManifestData } from '../../types/astro.js';
import type { Logger } from '../logger/core.js';
import type { AllPagesData } from './types.js';
diff --git a/packages/astro/src/core/build/pipeline.ts b/packages/astro/src/core/build/pipeline.ts
index 4e0d94c57ea6..18357e5ae62b 100644
--- a/packages/astro/src/core/build/pipeline.ts
+++ b/packages/astro/src/core/build/pipeline.ts
@@ -1,11 +1,7 @@
-import type {
- ComponentInstance,
- RewritePayload,
- RouteData,
- SSRLoadedRenderer,
- SSRResult,
-} from '../../@types/astro.js';
import { getOutputDirectory } from '../../prerender/utils.js';
+import type { ComponentInstance } from '../../types/astro.js';
+import type { RewritePayload } from '../../types/public/common.js';
+import type { RouteData, SSRLoadedRenderer, SSRResult } from '../../types/public/internal.js';
import { BEFORE_HYDRATION_SCRIPT_ID, PAGE_SCRIPT_ID } from '../../vite-plugin-scripts/index.js';
import type { SSRManifest } from '../app/types.js';
import { routeIsFallback, routeIsRedirect } from '../redirects/helpers.js';
diff --git a/packages/astro/src/core/build/plugins/plugin-content.ts b/packages/astro/src/core/build/plugins/plugin-content.ts
index 9c6d5add0b8d..5fe0b6792036 100644
--- a/packages/astro/src/core/build/plugins/plugin-content.ts
+++ b/packages/astro/src/core/build/plugins/plugin-content.ts
@@ -4,13 +4,13 @@ import { fileURLToPath } from 'node:url';
import glob from 'fast-glob';
import pLimit from 'p-limit';
import { type Plugin as VitePlugin, normalizePath } from 'vite';
-import type { AstroConfig } from '../../../@types/astro.js';
import { CONTENT_RENDER_FLAG, PROPAGATED_ASSET_FLAG } from '../../../content/consts.js';
import { type ContentLookupMap, hasContentFlag } from '../../../content/utils.js';
import {
generateContentEntryFile,
generateLookupMap,
} from '../../../content/vite-plugin-content-virtual-mod.js';
+import type { AstroConfig } from '../../../types/public/config.js';
import { configPaths } from '../../config/index.js';
import { emptyDir } from '../../fs/index.js';
import {
diff --git a/packages/astro/src/core/build/plugins/plugin-hoisted-scripts.ts b/packages/astro/src/core/build/plugins/plugin-hoisted-scripts.ts
index 7c378490938a..2992c0f2d91d 100644
--- a/packages/astro/src/core/build/plugins/plugin-hoisted-scripts.ts
+++ b/packages/astro/src/core/build/plugins/plugin-hoisted-scripts.ts
@@ -1,5 +1,5 @@
import type { BuildOptions, Rollup, Plugin as VitePlugin } from 'vite';
-import type { AstroSettings } from '../../../@types/astro.js';
+import type { AstroSettings } from '../../../types/astro.js';
import { viteID } from '../../util.js';
import type { BuildInternals } from '../internal.js';
import { getPageDataByViteID } from '../internal.js';
diff --git a/packages/astro/src/core/build/plugins/plugin-ssr.ts b/packages/astro/src/core/build/plugins/plugin-ssr.ts
index 70997e40ea67..1bc1a4f6d570 100644
--- a/packages/astro/src/core/build/plugins/plugin-ssr.ts
+++ b/packages/astro/src/core/build/plugins/plugin-ssr.ts
@@ -1,8 +1,9 @@
import { join } from 'node:path';
import { fileURLToPath, pathToFileURL } from 'node:url';
import type { Plugin as VitePlugin } from 'vite';
-import type { AstroAdapter, AstroSettings } from '../../../@types/astro.js';
import { isFunctionPerRouteEnabled } from '../../../integrations/hooks.js';
+import type { AstroSettings } from '../../../types/astro.js';
+import type { AstroAdapter } from '../../../types/public/integrations.js';
import { routeIsRedirect } from '../../redirects/index.js';
import { VIRTUAL_ISLAND_MAP_ID } from '../../server-islands/vite-plugin-server-islands.js';
import { isServerLikeOutput } from '../../util.js';
diff --git a/packages/astro/src/core/build/static-build.ts b/packages/astro/src/core/build/static-build.ts
index 7e2272dde60e..96feb85420df 100644
--- a/packages/astro/src/core/build/static-build.ts
+++ b/packages/astro/src/core/build/static-build.ts
@@ -5,7 +5,6 @@ import { teardown } from '@astrojs/compiler';
import glob from 'fast-glob';
import { bgGreen, bgMagenta, black, green } from 'kleur/colors';
import * as vite from 'vite';
-import type { RouteData } from '../../@types/astro.js';
import { PROPAGATED_ASSET_FLAG } from '../../content/consts.js';
import {
getSymlinkedContentCollections,
@@ -22,6 +21,7 @@ import { appendForwardSlash, prependForwardSlash, removeFileExtension } from '..
import { isModeServerWithNoAdapter, isServerLikeOutput } from '../../core/util.js';
import { runHookBuildSetup } from '../../integrations/hooks.js';
import { getOutputDirectory } from '../../prerender/utils.js';
+import type { RouteData } from '../../types/public/internal.js';
import { PAGE_SCRIPT_ID } from '../../vite-plugin-scripts/index.js';
import { AstroError, AstroErrorData } from '../errors/index.js';
import type { Logger } from '../logger/core.js';
diff --git a/packages/astro/src/core/build/types.ts b/packages/astro/src/core/build/types.ts
index 572140ef6669..f06f42501cf1 100644
--- a/packages/astro/src/core/build/types.ts
+++ b/packages/astro/src/core/build/types.ts
@@ -1,14 +1,9 @@
import type * as vite from 'vite';
import type { InlineConfig } from 'vite';
-import type {
- AstroSettings,
- ComponentInstance,
- ManifestData,
- MiddlewareHandler,
- RouteData,
- RuntimeMode,
- SSRLoadedRenderer,
-} from '../../@types/astro.js';
+import type { AstroSettings, ComponentInstance, ManifestData } from '../../types/astro.js';
+import type { MiddlewareHandler } from '../../types/public/common.js';
+import type { RuntimeMode } from '../../types/public/config.js';
+import type { RouteData, SSRLoadedRenderer } from '../../types/public/internal.js';
import type { Logger } from '../logger/core.js';
export type ComponentPath = string;
@@ -20,6 +15,7 @@ export type StylesheetAsset =
export type HoistedScriptAsset = { type: 'inline' | 'external'; value: string };
+/** Public type exposed through the `astro:build:setup` integration hook */
export interface PageBuildData {
key: string;
component: ComponentPath;
diff --git a/packages/astro/src/core/build/util.ts b/packages/astro/src/core/build/util.ts
index 9dc61f06fd8d..b6b313254379 100644
--- a/packages/astro/src/core/build/util.ts
+++ b/packages/astro/src/core/build/util.ts
@@ -1,5 +1,5 @@
import type { Rollup } from 'vite';
-import type { AstroConfig } from '../../@types/astro.js';
+import type { AstroConfig } from '../../types/public/config.js';
import type { ViteBuildReturn } from './types.js';
export function getTimeStat(timeStart: number, timeEnd: number) {
diff --git a/packages/astro/src/core/compile/compile.ts b/packages/astro/src/core/compile/compile.ts
index c3e6e4bb87a8..6e49f5850c63 100644
--- a/packages/astro/src/core/compile/compile.ts
+++ b/packages/astro/src/core/compile/compile.ts
@@ -1,11 +1,11 @@
import type { TransformResult } from '@astrojs/compiler';
import type { ResolvedConfig } from 'vite';
-import type { AstroConfig } from '../../@types/astro.js';
import { fileURLToPath } from 'node:url';
import { transform } from '@astrojs/compiler';
import { normalizePath } from 'vite';
import type { AstroPreferences } from '../../preferences/index.js';
+import type { AstroConfig } from '../../types/public/config.js';
import type { AstroError } from '../errors/errors.js';
import { AggregateError, CompilerError } from '../errors/errors.js';
import { AstroErrorData } from '../errors/index.js';
diff --git a/packages/astro/src/core/config/config.ts b/packages/astro/src/core/config/config.ts
index c10066ce3273..3e19db8015f8 100644
--- a/packages/astro/src/core/config/config.ts
+++ b/packages/astro/src/core/config/config.ts
@@ -3,13 +3,13 @@ import path from 'node:path';
import { fileURLToPath } from 'node:url';
import * as colors from 'kleur/colors';
import { ZodError } from 'zod';
+import { eventConfigError, telemetry } from '../../events/index.js';
import type {
AstroConfig,
AstroInlineConfig,
AstroInlineOnlyConfig,
AstroUserConfig,
-} from '../../@types/astro.js';
-import { eventConfigError, telemetry } from '../../events/index.js';
+} from '../../types/public/config.js';
import { trackAstroConfigZodError } from '../errors/errors.js';
import { AstroError, AstroErrorData } from '../errors/index.js';
import { formatConfigErrorMessage } from '../messages.js';
diff --git a/packages/astro/src/core/config/logging.ts b/packages/astro/src/core/config/logging.ts
index 004283f85f0c..bd72f8b5e978 100644
--- a/packages/astro/src/core/config/logging.ts
+++ b/packages/astro/src/core/config/logging.ts
@@ -1,4 +1,4 @@
-import type { AstroInlineConfig } from '../../@types/astro.js';
+import type { AstroInlineConfig } from '../../types/public/config.js';
import { Logger } from '../logger/core.js';
import { nodeLogDestination } from '../logger/node.js';
diff --git a/packages/astro/src/core/config/schema.ts b/packages/astro/src/core/config/schema.ts
index f49b4708e714..9db1117180b8 100644
--- a/packages/astro/src/core/config/schema.ts
+++ b/packages/astro/src/core/config/schema.ts
@@ -6,13 +6,13 @@ import type {
} from '@astrojs/markdown-remark';
import { markdownConfigDefaults } from '@astrojs/markdown-remark';
import { type BuiltinTheme, bundledThemes } from 'shiki';
-import type { AstroUserConfig, ViteUserConfig } from '../../@types/astro.js';
import type { OutgoingHttpHeaders } from 'node:http';
import path from 'node:path';
import { pathToFileURL } from 'node:url';
import { z } from 'zod';
import { EnvSchema } from '../../env/schema.js';
+import type { AstroUserConfig, ViteUserConfig } from '../../types/public/config.js';
import { appendForwardSlash, prependForwardSlash, removeTrailingForwardSlash } from '../path.js';
// The below types are required boilerplate to workaround a Zod issue since v3.21.2. Since that version,
diff --git a/packages/astro/src/core/config/settings.ts b/packages/astro/src/core/config/settings.ts
index 6c878d7f3323..902ff7d03318 100644
--- a/packages/astro/src/core/config/settings.ts
+++ b/packages/astro/src/core/config/settings.ts
@@ -1,9 +1,10 @@
import path from 'node:path';
import { fileURLToPath, pathToFileURL } from 'node:url';
import yaml from 'js-yaml';
-import type { AstroConfig, AstroSettings } from '../../@types/astro.js';
import { getContentPaths } from '../../content/index.js';
import createPreferences from '../../preferences/index.js';
+import type { AstroSettings } from '../../types/astro.js';
+import type { AstroConfig } from '../../types/public/config.js';
import { markdownContentEntryType } from '../../vite-plugin-markdown/content-entry-type.js';
import { getDefaultClientDirectives } from '../client-directive/index.js';
import { AstroError, AstroErrorData } from '../errors/index.js';
diff --git a/packages/astro/src/core/config/validate.ts b/packages/astro/src/core/config/validate.ts
index 4f4497b784d8..75a64f1f7d17 100644
--- a/packages/astro/src/core/config/validate.ts
+++ b/packages/astro/src/core/config/validate.ts
@@ -1,4 +1,4 @@
-import type { AstroConfig } from '../../@types/astro.js';
+import type { AstroConfig } from '../../types/public/config.js';
import { createRelativeSchema } from './schema.js';
/** Turn raw config values into normalized values */
diff --git a/packages/astro/src/core/create-vite.ts b/packages/astro/src/core/create-vite.ts
index 23a4068a8bda..bb9179694168 100644
--- a/packages/astro/src/core/create-vite.ts
+++ b/packages/astro/src/core/create-vite.ts
@@ -3,7 +3,6 @@ import { fileURLToPath } from 'node:url';
import glob from 'fast-glob';
import * as vite from 'vite';
import { crawlFrameworkPkgs } from 'vitefu';
-import type { AstroSettings } from '../@types/astro.js';
import { getAssetsPrefix } from '../assets/utils/getAssetsPrefix.js';
import astroAssetsPlugin from '../assets/vite-plugin-assets.js';
import astroContainer from '../container/vite-plugin-container.js';
@@ -17,6 +16,7 @@ import astroInternationalization from '../i18n/vite-plugin-i18n.js';
import astroPrefetch from '../prefetch/vite-plugin-prefetch.js';
import astroDevToolbar from '../toolbar/vite-plugin-dev-toolbar.js';
import astroTransitions from '../transitions/vite-plugin-transitions.js';
+import type { AstroSettings } from '../types/astro.js';
import astroPostprocessVitePlugin from '../vite-plugin-astro-postprocess/index.js';
import { vitePluginAstroServer } from '../vite-plugin-astro-server/index.js';
import astroVitePlugin from '../vite-plugin-astro/index.js';
diff --git a/packages/astro/src/core/dev/container.ts b/packages/astro/src/core/dev/container.ts
index 159d5e44769c..f89e331970c5 100644
--- a/packages/astro/src/core/dev/container.ts
+++ b/packages/astro/src/core/dev/container.ts
@@ -1,6 +1,6 @@
import type * as http from 'node:http';
import type { AddressInfo } from 'node:net';
-import type { AstroInlineConfig, AstroSettings } from '../../@types/astro.js';
+import type { AstroSettings } from '../../types/astro.js';
import nodeFs from 'node:fs';
import * as vite from 'vite';
@@ -11,6 +11,7 @@ import {
runHookServerDone,
runHookServerStart,
} from '../../integrations/hooks.js';
+import type { AstroInlineConfig } from '../../types/public/config.js';
import { createVite } from '../create-vite.js';
import type { Logger } from '../logger/core.js';
import { apply as applyPolyfill } from '../polyfill.js';
diff --git a/packages/astro/src/core/dev/dev.ts b/packages/astro/src/core/dev/dev.ts
index 127f34b94989..f539862535c9 100644
--- a/packages/astro/src/core/dev/dev.ts
+++ b/packages/astro/src/core/dev/dev.ts
@@ -5,13 +5,13 @@ import { green } from 'kleur/colors';
import { performance } from 'perf_hooks';
import { gt, major, minor, patch } from 'semver';
import type * as vite from 'vite';
-import type { AstroInlineConfig } from '../../@types/astro.js';
import { DATA_STORE_FILE } from '../../content/consts.js';
import { globalContentLayer } from '../../content/content-layer.js';
import { DataStore, globalDataStore } from '../../content/data-store.js';
import { attachContentServerListeners } from '../../content/index.js';
import { globalContentConfigObserver } from '../../content/utils.js';
import { telemetry } from '../../events/index.js';
+import type { AstroInlineConfig } from '../../types/public/config.js';
import * as msg from '../messages.js';
import { ensureProcessNodeEnv } from '../util.js';
import { startContainer } from './container.js';
diff --git a/packages/astro/src/core/dev/restart.ts b/packages/astro/src/core/dev/restart.ts
index 235454cb5a70..208e12ada61e 100644
--- a/packages/astro/src/core/dev/restart.ts
+++ b/packages/astro/src/core/dev/restart.ts
@@ -1,9 +1,10 @@
import type nodeFs from 'node:fs';
import { fileURLToPath } from 'node:url';
import * as vite from 'vite';
-import type { AstroInlineConfig, AstroSettings } from '../../@types/astro.js';
import { globalContentLayer } from '../../content/content-layer.js';
import { eventCliSession, telemetry } from '../../events/index.js';
+import type { AstroSettings } from '../../types/astro.js';
+import type { AstroInlineConfig } from '../../types/public/config.js';
import { createNodeLogger, createSettings, resolveConfig } from '../config/index.js';
import { collectErrorMetadata } from '../errors/dev/utils.js';
import { isAstroConfigZodError } from '../errors/errors.js';
diff --git a/packages/astro/src/core/errors/dev/utils.ts b/packages/astro/src/core/errors/dev/utils.ts
index 341c815a6762..58a061b477e6 100644
--- a/packages/astro/src/core/errors/dev/utils.ts
+++ b/packages/astro/src/core/errors/dev/utils.ts
@@ -6,12 +6,12 @@ import { bold, underline } from 'kleur/colors';
import stripAnsi from 'strip-ansi';
import type { ESBuildTransformResult } from 'vite';
import { normalizePath } from 'vite';
-import type { SSRError } from '../../../@types/astro.js';
import { removeLeadingForwardSlashWindows } from '../../path.js';
import { AggregateError, type ErrorWithMetadata } from '../errors.js';
import { AstroErrorData } from '../index.js';
import { codeFrame } from '../printer.js';
import { normalizeLF } from '../utils.js';
+import type { SSRError } from '../../../types/public/internal.js';
type EsbuildMessage = ESBuildTransformResult['warnings'][number];
diff --git a/packages/astro/src/core/errors/dev/vite.ts b/packages/astro/src/core/errors/dev/vite.ts
index 56688877a861..b45a02641e5a 100644
--- a/packages/astro/src/core/errors/dev/vite.ts
+++ b/packages/astro/src/core/errors/dev/vite.ts
@@ -7,8 +7,8 @@ import type { ModuleLoader } from '../../module-loader/index.js';
import { FailedToLoadModuleSSR, InvalidGlob, MdxIntegrationMissingError } from '../errors-data.js';
import { AstroError, type ErrorWithMetadata } from '../errors.js';
import { createSafeError } from '../utils.js';
-import type { SSRLoadedRenderer } from './../../../@types/astro.js';
import { getDocsForError, renderErrorMarkdown } from './utils.js';
+import type { SSRLoadedRenderer } from '../../../types/public/internal.js';
export function enhanceViteSSRError({
error,
diff --git a/packages/astro/src/core/errors/utils.ts b/packages/astro/src/core/errors/utils.ts
index 05dd49071a48..6754656b9134 100644
--- a/packages/astro/src/core/errors/utils.ts
+++ b/packages/astro/src/core/errors/utils.ts
@@ -1,6 +1,6 @@
import type { YAMLException } from 'js-yaml';
import type { ErrorPayload as ViteErrorPayload } from 'vite';
-import type { SSRError } from '../../@types/astro.js';
+import type { SSRError } from '../../types/public/internal.js';
/**
* Get the line and character based on the offset
diff --git a/packages/astro/src/core/index.ts b/packages/astro/src/core/index.ts
index bdd7c7f05939..14a8c2f99af0 100644
--- a/packages/astro/src/core/index.ts
+++ b/packages/astro/src/core/index.ts
@@ -1,6 +1,6 @@
// This is the main entrypoint when importing the `astro` package.
-import type { AstroInlineConfig } from '../@types/astro.js';
+import type { AstroInlineConfig } from '../types/public/config.js';
import { default as _build } from './build/index.js';
import { default as _sync } from './sync/index.js';
diff --git a/packages/astro/src/core/middleware/callMiddleware.ts b/packages/astro/src/core/middleware/callMiddleware.ts
index 3bdc6052da99..4cc7b6586685 100644
--- a/packages/astro/src/core/middleware/callMiddleware.ts
+++ b/packages/astro/src/core/middleware/callMiddleware.ts
@@ -1,9 +1,9 @@
import type {
- APIContext,
MiddlewareHandler,
MiddlewareNext,
RewritePayload,
-} from '../../@types/astro.js';
+} from '../../types/public/common.js';
+import type { APIContext } from '../../types/public/context.js';
import { AstroError, AstroErrorData } from '../errors/index.js';
/**
diff --git a/packages/astro/src/core/middleware/index.ts b/packages/astro/src/core/middleware/index.ts
index 56ce0b76c364..31988ae02eac 100644
--- a/packages/astro/src/core/middleware/index.ts
+++ b/packages/astro/src/core/middleware/index.ts
@@ -1,10 +1,11 @@
-import type { APIContext, MiddlewareHandler, Params, RewritePayload } from '../../@types/astro.js';
import { createCallAction, createGetActionResult } from '../../actions/utils.js';
import {
computeCurrentLocale,
computePreferredLocale,
computePreferredLocaleList,
} from '../../i18n/utils.js';
+import type { MiddlewareHandler, Params, RewritePayload } from '../../types/public/common.js';
+import type { APIContext } from '../../types/public/context.js';
import { ASTRO_VERSION, clientAddressSymbol, clientLocalsSymbol } from '../constants.js';
import { AstroCookies } from '../cookies/index.js';
import { AstroError, AstroErrorData } from '../errors/index.js';
diff --git a/packages/astro/src/core/middleware/sequence.ts b/packages/astro/src/core/middleware/sequence.ts
index ee08381e6fe4..aefa66a9205d 100644
--- a/packages/astro/src/core/middleware/sequence.ts
+++ b/packages/astro/src/core/middleware/sequence.ts
@@ -1,4 +1,5 @@
-import type { APIContext, MiddlewareHandler, RewritePayload } from '../../@types/astro.js';
+import type { MiddlewareHandler, RewritePayload } from '../../types/public/common.js';
+import type { APIContext } from '../../types/public/context.js';
import { AstroCookies } from '../cookies/cookies.js';
import { defineMiddleware } from './index.js';
diff --git a/packages/astro/src/core/middleware/vite-plugin.ts b/packages/astro/src/core/middleware/vite-plugin.ts
index bb7b54e727d3..8a76bed921c9 100644
--- a/packages/astro/src/core/middleware/vite-plugin.ts
+++ b/packages/astro/src/core/middleware/vite-plugin.ts
@@ -1,7 +1,7 @@
import type { Plugin as VitePlugin } from 'vite';
import { normalizePath } from 'vite';
-import type { AstroSettings } from '../../@types/astro.js';
import { getOutputDirectory } from '../../prerender/utils.js';
+import type { AstroSettings } from '../../types/astro.js';
import { addRollupInput } from '../build/add-rollup-input.js';
import type { BuildInternals } from '../build/internal.js';
import type { StaticBuildOptions } from '../build/types.js';
diff --git a/packages/astro/src/core/module-loader/loader.ts b/packages/astro/src/core/module-loader/loader.ts
index 976354448acc..9973ae6577e8 100644
--- a/packages/astro/src/core/module-loader/loader.ts
+++ b/packages/astro/src/core/module-loader/loader.ts
@@ -1,6 +1,6 @@
import { EventEmitter } from 'node:events';
import type * as fs from 'node:fs';
-import type { TypedEventEmitter } from '../../@types/typed-emitter.js';
+import type { TypedEventEmitter } from '../../types/typed-emitter.js';
// This is a generic interface for a module loader. In the astro cli this is
// fulfilled by Vite, see vite.ts
diff --git a/packages/astro/src/core/preview/index.ts b/packages/astro/src/core/preview/index.ts
index b46cf1becc57..a8a533fe85b7 100644
--- a/packages/astro/src/core/preview/index.ts
+++ b/packages/astro/src/core/preview/index.ts
@@ -1,11 +1,12 @@
import fs from 'node:fs';
import { createRequire } from 'node:module';
import { fileURLToPath, pathToFileURL } from 'node:url';
-import type { AstroInlineConfig, PreviewModule, PreviewServer } from '../../@types/astro.js';
import { AstroIntegrationLogger } from '../../core/logger/core.js';
import { telemetry } from '../../events/index.js';
import { eventCliSession } from '../../events/session.js';
import { runHookConfigDone, runHookConfigSetup } from '../../integrations/hooks.js';
+import type { AstroInlineConfig } from '../../types/public/config.js';
+import type { PreviewModule, PreviewServer } from '../../types/public/preview.js';
import { resolveConfig } from '../config/config.js';
import { createNodeLogger } from '../config/logging.js';
import { createSettings } from '../config/settings.js';
diff --git a/packages/astro/src/core/preview/static-preview-server.ts b/packages/astro/src/core/preview/static-preview-server.ts
index 68ca3236b296..0765c4fb19f6 100644
--- a/packages/astro/src/core/preview/static-preview-server.ts
+++ b/packages/astro/src/core/preview/static-preview-server.ts
@@ -2,7 +2,7 @@ import type http from 'node:http';
import { fileURLToPath } from 'node:url';
import { performance } from 'perf_hooks';
import { type PreviewServer as VitePreviewServer, preview } from 'vite';
-import type { AstroSettings } from '../../@types/astro.js';
+import type { AstroSettings } from '../../types/astro.js';
import type { Logger } from '../logger/core.js';
import * as msg from '../messages.js';
import { getResolvedHostForHttpServer } from './util.js';
diff --git a/packages/astro/src/core/preview/vite-plugin-astro-preview.ts b/packages/astro/src/core/preview/vite-plugin-astro-preview.ts
index a425807dccd2..fd9bbae66c57 100644
--- a/packages/astro/src/core/preview/vite-plugin-astro-preview.ts
+++ b/packages/astro/src/core/preview/vite-plugin-astro-preview.ts
@@ -2,8 +2,8 @@ import fs from 'node:fs';
import type { IncomingMessage, ServerResponse } from 'node:http';
import { fileURLToPath } from 'node:url';
import type { Connect, Plugin } from 'vite';
-import type { AstroSettings } from '../../@types/astro.js';
import { notFoundTemplate, subpathNotUsedTemplate } from '../../template/4xx.js';
+import type { AstroSettings } from '../../types/astro.js';
import { cleanUrl } from '../../vite-plugin-utils/index.js';
import { stripBase } from './util.js';
diff --git a/packages/astro/src/core/redirects/component.ts b/packages/astro/src/core/redirects/component.ts
index 00b8d176c1d2..12b37ae0091b 100644
--- a/packages/astro/src/core/redirects/component.ts
+++ b/packages/astro/src/core/redirects/component.ts
@@ -1,4 +1,4 @@
-import type { ComponentInstance } from '../../@types/astro.js';
+import type { ComponentInstance } from '../../types/astro.js';
import type { SinglePageBuiltModule } from '../build/types.js';
// A stub of a component instance for a given route
diff --git a/packages/astro/src/core/redirects/helpers.ts b/packages/astro/src/core/redirects/helpers.ts
index 80f18ae0f123..505bdc5bccfa 100644
--- a/packages/astro/src/core/redirects/helpers.ts
+++ b/packages/astro/src/core/redirects/helpers.ts
@@ -1,4 +1,5 @@
-import type { RedirectRouteData, RouteData } from '../../@types/astro.js';
+import type { RedirectRouteData } from '../../types/astro.js';
+import type { RouteData } from '../../types/public/internal.js';
export function routeIsRedirect(route: RouteData | undefined): route is RedirectRouteData {
return route?.type === 'redirect';
diff --git a/packages/astro/src/core/render-context.ts b/packages/astro/src/core/render-context.ts
index a19d11080a97..ab0554d0c03d 100644
--- a/packages/astro/src/core/render-context.ts
+++ b/packages/astro/src/core/render-context.ts
@@ -1,14 +1,3 @@
-import type {
- APIContext,
- AstroGlobal,
- AstroGlobalPartial,
- ComponentInstance,
- MiddlewareHandler,
- Props,
- RewritePayload,
- RouteData,
- SSRResult,
-} from '../@types/astro.js';
import type { ActionAPIContext } from '../actions/runtime/utils.js';
import { deserializeActionResult } from '../actions/runtime/virtual/shared.js';
import { createCallAction, createGetActionResult, hasActionPayload } from '../actions/utils.js';
@@ -19,6 +8,10 @@ import {
} from '../i18n/utils.js';
import { renderEndpoint } from '../runtime/server/endpoint.js';
import { renderPage } from '../runtime/server/index.js';
+import type { ComponentInstance } from '../types/astro.js';
+import type { MiddlewareHandler, Props, RewritePayload } from '../types/public/common.js';
+import type { APIContext, AstroGlobal, AstroGlobalPartial } from '../types/public/context.js';
+import type { RouteData, SSRResult } from '../types/public/internal.js';
import {
ASTRO_VERSION,
REROUTE_DIRECTIVE_HEADER,
diff --git a/packages/astro/src/core/render/index.ts b/packages/astro/src/core/render/index.ts
index db14701b0fde..b56a2eaf2cc0 100644
--- a/packages/astro/src/core/render/index.ts
+++ b/packages/astro/src/core/render/index.ts
@@ -1,4 +1,5 @@
-import type { ComponentInstance, RouteData } from '../../@types/astro.js';
+import type { ComponentInstance } from '../../types/astro.js';
+import type { RouteData } from '../../types/public/internal.js';
import type { Pipeline } from '../base-pipeline.js';
export { Pipeline } from '../base-pipeline.js';
export { getParams, getProps } from './params-and-props.js';
diff --git a/packages/astro/src/core/render/paginate.ts b/packages/astro/src/core/render/paginate.ts
index e962d98d31f4..c462cd4b8646 100644
--- a/packages/astro/src/core/render/paginate.ts
+++ b/packages/astro/src/core/render/paginate.ts
@@ -4,8 +4,8 @@ import type {
PaginateOptions,
Params,
Props,
- RouteData,
-} from '../../@types/astro.js';
+} from '../../types/public/common.js';
+import type { RouteData } from '../../types/public/internal.js';
import { AstroError, AstroErrorData } from '../errors/index.js';
export function generatePaginateFunction(
diff --git a/packages/astro/src/core/render/params-and-props.ts b/packages/astro/src/core/render/params-and-props.ts
index cf7d02d48360..a45fb16a8084 100644
--- a/packages/astro/src/core/render/params-and-props.ts
+++ b/packages/astro/src/core/render/params-and-props.ts
@@ -1,4 +1,6 @@
-import type { ComponentInstance, Params, Props, RouteData } from '../../@types/astro.js';
+import type { ComponentInstance } from '../../types/astro.js';
+import type { Params, Props } from '../../types/public/common.js';
+import type { RouteData } from '../../types/public/internal.js';
import { DEFAULT_404_COMPONENT } from '../constants.js';
import { AstroError, AstroErrorData } from '../errors/index.js';
import type { Logger } from '../logger/core.js';
diff --git a/packages/astro/src/core/render/renderer.ts b/packages/astro/src/core/render/renderer.ts
index 42cc8fd05d64..8daec8d53e5f 100644
--- a/packages/astro/src/core/render/renderer.ts
+++ b/packages/astro/src/core/render/renderer.ts
@@ -1,4 +1,5 @@
-import type { AstroRenderer, SSRLoadedRenderer } from '../../@types/astro.js';
+import type { AstroRenderer } from '../../types/public/integrations.js';
+import type { SSRLoadedRenderer } from '../../types/public/internal.js';
import type { ModuleLoader } from '../module-loader/index.js';
export async function loadRenderer(
diff --git a/packages/astro/src/core/render/route-cache.ts b/packages/astro/src/core/render/route-cache.ts
index 399795675e06..3329c42cd347 100644
--- a/packages/astro/src/core/render/route-cache.ts
+++ b/packages/astro/src/core/render/route-cache.ts
@@ -1,13 +1,13 @@
+import type { ComponentInstance } from '../../types/astro.js';
import type {
- ComponentInstance,
GetStaticPathsItem,
GetStaticPathsResult,
GetStaticPathsResultKeyed,
PaginateFunction,
Params,
- RouteData,
- RuntimeMode,
-} from '../../@types/astro.js';
+} from '../../types/public/common.js';
+import type { RuntimeMode } from '../../types/public/config.js';
+import type { RouteData } from '../../types/public/internal.js';
import type { Logger } from '../logger/core.js';
import { stringifyParams } from '../routing/params.js';
diff --git a/packages/astro/src/core/render/slots.ts b/packages/astro/src/core/render/slots.ts
index ab87204e465e..1c767083da71 100644
--- a/packages/astro/src/core/render/slots.ts
+++ b/packages/astro/src/core/render/slots.ts
@@ -1,8 +1,8 @@
-import type { SSRResult } from '../../@types/astro.js';
import { type ComponentSlots, renderSlotToString } from '../../runtime/server/index.js';
import { renderJSX } from '../../runtime/server/jsx.js';
import { chunkToString } from '../../runtime/server/render/index.js';
import { isRenderInstruction } from '../../runtime/server/render/instruction.js';
+import type { SSRResult } from '../../types/public/internal.js';
import { AstroError, AstroErrorData } from '../errors/index.js';
import type { Logger } from '../logger/core.js';
diff --git a/packages/astro/src/core/render/ssr-element.ts b/packages/astro/src/core/render/ssr-element.ts
index 7c766ee20e4a..827c8fddf40d 100644
--- a/packages/astro/src/core/render/ssr-element.ts
+++ b/packages/astro/src/core/render/ssr-element.ts
@@ -1,7 +1,7 @@
-import type { AssetsPrefix, SSRElement } from '../../@types/astro.js';
import { getAssetsPrefix } from '../../assets/utils/getAssetsPrefix.js';
import { fileExtension, joinPaths, prependForwardSlash, slash } from '../../core/path.js';
-import type { StylesheetAsset } from '../app/types.js';
+import type { SSRElement } from '../../types/public/internal.js';
+import type { AssetsPrefix, StylesheetAsset } from '../app/types.js';
export function createAssetLink(href: string, base?: string, assetsPrefix?: AssetsPrefix): string {
if (assetsPrefix) {
diff --git a/packages/astro/src/core/routing/astro-designed-error-pages.ts b/packages/astro/src/core/routing/astro-designed-error-pages.ts
index 4e4b41b70cf7..2c1c1f77c5a3 100644
--- a/packages/astro/src/core/routing/astro-designed-error-pages.ts
+++ b/packages/astro/src/core/routing/astro-designed-error-pages.ts
@@ -1,5 +1,6 @@
-import type { ComponentInstance, ManifestData, RouteData } from '../../@types/astro.js';
import notFoundTemplate from '../../template/4xx.js';
+import type { ComponentInstance, ManifestData } from '../../types/astro.js';
+import type { RouteData } from '../../types/public/internal.js';
import { DEFAULT_404_COMPONENT, DEFAULT_500_COMPONENT } from '../constants.js';
export const DEFAULT_404_ROUTE: RouteData = {
diff --git a/packages/astro/src/core/routing/default.ts b/packages/astro/src/core/routing/default.ts
index dd3c8cc538c1..8bcd473d0081 100644
--- a/packages/astro/src/core/routing/default.ts
+++ b/packages/astro/src/core/routing/default.ts
@@ -1,4 +1,5 @@
-import type { ComponentInstance, ManifestData, SSRManifest } from '../../@types/astro.js';
+import type { ComponentInstance, ManifestData } from '../../types/astro.js';
+import type { SSRManifest } from '../app/types.js';
import { DEFAULT_404_COMPONENT } from '../constants.js';
import {
SERVER_ISLAND_COMPONENT,
diff --git a/packages/astro/src/core/routing/manifest/create.ts b/packages/astro/src/core/routing/manifest/create.ts
index f9c19b9ed0fd..193b375efa7b 100644
--- a/packages/astro/src/core/routing/manifest/create.ts
+++ b/packages/astro/src/core/routing/manifest/create.ts
@@ -1,11 +1,4 @@
-import type {
- AstroConfig,
- AstroSettings,
- ManifestData,
- RouteData,
- RoutePart,
- RoutePriorityOverride,
-} from '../../../@types/astro.js';
+import type { AstroSettings, ManifestData } from '../../../types/astro.js';
import type { Logger } from '../../logger/core.js';
import { createRequire } from 'module';
@@ -15,6 +8,9 @@ import { fileURLToPath } from 'node:url';
import { bold } from 'kleur/colors';
import { toRoutingStrategy } from '../../../i18n/utils.js';
import { getPrerenderDefault } from '../../../prerender/utils.js';
+import type { AstroConfig } from '../../../types/public/config.js';
+import type { RoutePriorityOverride } from '../../../types/public/integrations.js';
+import type { RouteData, RoutePart } from '../../../types/public/internal.js';
import { SUPPORTED_MARKDOWN_FILE_EXTENSIONS } from '../../constants.js';
import { MissingIndexForInternationalization } from '../../errors/errors-data.js';
import { AstroError } from '../../errors/index.js';
diff --git a/packages/astro/src/core/routing/manifest/generator.ts b/packages/astro/src/core/routing/manifest/generator.ts
index 4ab635ec6608..e3565864d91d 100644
--- a/packages/astro/src/core/routing/manifest/generator.ts
+++ b/packages/astro/src/core/routing/manifest/generator.ts
@@ -1,6 +1,6 @@
-import type { AstroConfig, RoutePart } from '../../../@types/astro.js';
-
import { compile } from 'path-to-regexp';
+import type { AstroConfig } from '../../../types/public/config.js';
+import type { RoutePart } from '../../../types/public/internal.js';
/**
* Sanitizes the parameters object by normalizing string values and replacing certain characters with their URL-encoded equivalents.
diff --git a/packages/astro/src/core/routing/manifest/pattern.ts b/packages/astro/src/core/routing/manifest/pattern.ts
index 65f223aa0c20..8a9a9d27f9fc 100644
--- a/packages/astro/src/core/routing/manifest/pattern.ts
+++ b/packages/astro/src/core/routing/manifest/pattern.ts
@@ -1,4 +1,5 @@
-import type { AstroConfig, RoutePart } from '../../../@types/astro.js';
+import type { AstroConfig } from '../../../types/public/config.js';
+import type { RoutePart } from '../../../types/public/internal.js';
export function getPattern(
segments: RoutePart[][],
diff --git a/packages/astro/src/core/routing/manifest/serialization.ts b/packages/astro/src/core/routing/manifest/serialization.ts
index 852aa703bf9d..c0cf600f0b79 100644
--- a/packages/astro/src/core/routing/manifest/serialization.ts
+++ b/packages/astro/src/core/routing/manifest/serialization.ts
@@ -1,4 +1,6 @@
-import type { AstroConfig, RouteData, SerializedRouteData } from '../../../@types/astro.js';
+import type { SerializedRouteData } from '../../../types/astro.js';
+import type { AstroConfig } from '../../../types/public/config.js';
+import type { RouteData } from '../../../types/public/internal.js';
import { getRouteGenerator } from './generator.js';
diff --git a/packages/astro/src/core/routing/match.ts b/packages/astro/src/core/routing/match.ts
index 40a8b95fba29..403b3fb9535b 100644
--- a/packages/astro/src/core/routing/match.ts
+++ b/packages/astro/src/core/routing/match.ts
@@ -1,4 +1,5 @@
-import type { ManifestData, RouteData } from '../../@types/astro.js';
+import type { ManifestData } from '../../types/astro.js';
+import type { RouteData } from '../../types/public/internal.js';
/** Find matching route from pathname */
export function matchRoute(pathname: string, manifest: ManifestData): RouteData | undefined {
diff --git a/packages/astro/src/core/routing/params.ts b/packages/astro/src/core/routing/params.ts
index 43cd24cc13a7..802c39cc5043 100644
--- a/packages/astro/src/core/routing/params.ts
+++ b/packages/astro/src/core/routing/params.ts
@@ -1,4 +1,5 @@
-import type { GetStaticPathsItem, Params, RouteData } from '../../@types/astro.js';
+import type { GetStaticPathsItem, Params } from '../../types/public/common.js';
+import type { RouteData } from '../../types/public/internal.js';
import { trimSlashes } from '../path.js';
import { validateGetStaticPathsParameter } from './validation.js';
diff --git a/packages/astro/src/core/routing/priority.ts b/packages/astro/src/core/routing/priority.ts
index 4082683970e5..dc1c665c6156 100644
--- a/packages/astro/src/core/routing/priority.ts
+++ b/packages/astro/src/core/routing/priority.ts
@@ -1,4 +1,4 @@
-import type { RouteData } from '../../@types/astro.js';
+import type { RouteData } from '../../types/public/internal.js';
/**
* Comparator for sorting routes in resolution order.
diff --git a/packages/astro/src/core/routing/rewrite.ts b/packages/astro/src/core/routing/rewrite.ts
index f30caed08c7b..a6fce3354929 100644
--- a/packages/astro/src/core/routing/rewrite.ts
+++ b/packages/astro/src/core/routing/rewrite.ts
@@ -1,4 +1,6 @@
-import type { AstroConfig, RewritePayload, RouteData } from '../../@types/astro.js';
+import type { RewritePayload } from '../../types/public/common.js';
+import type { AstroConfig } from '../../types/public/config.js';
+import type { RouteData } from '../../types/public/internal.js';
import { shouldAppendForwardSlash } from '../build/util.js';
import { appendForwardSlash, removeTrailingForwardSlash } from '../path.js';
import { DEFAULT_404_ROUTE } from './astro-designed-error-pages.js';
diff --git a/packages/astro/src/core/routing/validation.ts b/packages/astro/src/core/routing/validation.ts
index 1f11f55e6cd4..a2f9a25ba320 100644
--- a/packages/astro/src/core/routing/validation.ts
+++ b/packages/astro/src/core/routing/validation.ts
@@ -1,4 +1,6 @@
-import type { ComponentInstance, GetStaticPathsResult, RouteData } from '../../@types/astro.js';
+import type { ComponentInstance } from '../../types/astro.js';
+import type { GetStaticPathsResult } from '../../types/public/common.js';
+import type { RouteData } from '../../types/public/internal.js';
import { AstroError, AstroErrorData } from '../errors/index.js';
import type { Logger } from '../logger/core.js';
diff --git a/packages/astro/src/core/server-islands/endpoint.ts b/packages/astro/src/core/server-islands/endpoint.ts
index 368a1b9b19ac..73ed5717704d 100644
--- a/packages/astro/src/core/server-islands/endpoint.ts
+++ b/packages/astro/src/core/server-islands/endpoint.ts
@@ -1,9 +1,3 @@
-import type {
- ComponentInstance,
- ManifestData,
- RouteData,
- SSRManifest,
-} from '../../@types/astro.js';
import {
type AstroComponentFactory,
type ComponentSlots,
@@ -11,6 +5,8 @@ import {
renderTemplate,
} from '../../runtime/server/index.js';
import { createSlotValueFromString } from '../../runtime/server/render/slot.js';
+import type { ComponentInstance, ManifestData } from '../../types/astro.js';
+import type { RouteData, SSRManifest } from '../../types/public/internal.js';
import { decryptString } from '../encryption.js';
import { getPattern } from '../routing/manifest/pattern.js';
diff --git a/packages/astro/src/core/server-islands/vite-plugin-server-islands.ts b/packages/astro/src/core/server-islands/vite-plugin-server-islands.ts
index 573ae9cf9703..8bc79e087d56 100644
--- a/packages/astro/src/core/server-islands/vite-plugin-server-islands.ts
+++ b/packages/astro/src/core/server-islands/vite-plugin-server-islands.ts
@@ -1,5 +1,5 @@
import type { ConfigEnv, ViteDevServer, Plugin as VitePlugin } from 'vite';
-import type { AstroSettings } from '../../@types/astro.js';
+import type { AstroSettings } from '../../types/astro.js';
import type { AstroPluginMetadata } from '../../vite-plugin-astro/index.js';
export const VIRTUAL_ISLAND_MAP_ID = '@astro-server-islands';
diff --git a/packages/astro/src/core/sync/index.ts b/packages/astro/src/core/sync/index.ts
index c9b2ec235b98..dd3562115e5e 100644
--- a/packages/astro/src/core/sync/index.ts
+++ b/packages/astro/src/core/sync/index.ts
@@ -2,7 +2,6 @@ import fsMod, { existsSync } from 'node:fs';
import { performance } from 'node:perf_hooks';
import { dim } from 'kleur/colors';
import { type HMRPayload, createServer } from 'vite';
-import type { AstroConfig, AstroInlineConfig, AstroSettings } from '../../@types/astro.js';
import { DATA_STORE_FILE } from '../../content/consts.js';
import { globalContentLayer } from '../../content/content-layer.js';
import { DataStore, globalDataStore } from '../../content/data-store.js';
@@ -12,6 +11,8 @@ import { syncAstroEnv } from '../../env/sync.js';
import { telemetry } from '../../events/index.js';
import { eventCliSession } from '../../events/session.js';
import { runHookConfigDone, runHookConfigSetup } from '../../integrations/hooks.js';
+import type { AstroSettings } from '../../types/astro.js';
+import type { AstroConfig, AstroInlineConfig } from '../../types/public/config.js';
import { getTimeStat } from '../build/util.js';
import { resolveConfig } from '../config/config.js';
import { createNodeLogger } from '../config/logging.js';
diff --git a/packages/astro/src/core/sync/write-files.ts b/packages/astro/src/core/sync/write-files.ts
index 56ab131f1be7..be1d22a2bb3f 100644
--- a/packages/astro/src/core/sync/write-files.ts
+++ b/packages/astro/src/core/sync/write-files.ts
@@ -3,10 +3,10 @@ import { dirname, relative } from 'node:path';
import { fileURLToPath } from 'node:url';
import { bold } from 'kleur/colors';
import { normalizePath } from 'vite';
-import type { AstroSettings } from '../../@types/astro.js';
+import type { AstroSettings } from '../../types/astro.js';
+import { AstroError, AstroErrorData } from '../errors/index.js';
import type { Logger } from '../logger/core.js';
import { REFERENCE_FILE } from './constants.js';
-import { AstroError, AstroErrorData } from '../errors/index.js';
export async function writeFiles(settings: AstroSettings, fs: typeof fsMod, logger: Logger) {
try {
diff --git a/packages/astro/src/core/util.ts b/packages/astro/src/core/util.ts
index 654d1982994c..497d54610262 100644
--- a/packages/astro/src/core/util.ts
+++ b/packages/astro/src/core/util.ts
@@ -1,7 +1,9 @@
import fs from 'node:fs';
import path from 'node:path';
import { fileURLToPath } from 'node:url';
-import type { AstroConfig, AstroSettings, RouteType } from '../@types/astro.js';
+import type { AstroSettings } from '../types/astro.js';
+import type { AstroConfig } from '../types/public/config.js';
+import type { RouteType } from '../types/public/internal.js';
import { SUPPORTED_MARKDOWN_FILE_EXTENSIONS } from './constants.js';
import { removeTrailingForwardSlash, slash } from './path.js';
diff --git a/packages/astro/src/env/sync.ts b/packages/astro/src/env/sync.ts
index 27436f967be7..90a29685dc28 100644
--- a/packages/astro/src/env/sync.ts
+++ b/packages/astro/src/env/sync.ts
@@ -1,5 +1,5 @@
import fsMod from 'node:fs';
-import type { AstroSettings } from '../@types/astro.js';
+import type { AstroSettings } from '../types/astro.js';
import { TYPES_TEMPLATE_URL } from './constants.js';
import { getEnvFieldType } from './validators.js';
diff --git a/packages/astro/src/env/vite-plugin-env.ts b/packages/astro/src/env/vite-plugin-env.ts
index fdcd6ce4015d..934ba79ca2ab 100644
--- a/packages/astro/src/env/vite-plugin-env.ts
+++ b/packages/astro/src/env/vite-plugin-env.ts
@@ -1,8 +1,8 @@
import type fsMod from 'node:fs';
import { fileURLToPath } from 'node:url';
import { type Plugin, loadEnv } from 'vite';
-import type { AstroSettings } from '../@types/astro.js';
import { AstroError, AstroErrorData } from '../core/errors/index.js';
+import type { AstroSettings } from '../types/astro.js';
import {
MODULE_TEMPLATE_URL,
VIRTUAL_MODULES_IDS,
diff --git a/packages/astro/src/events/session.ts b/packages/astro/src/events/session.ts
index 18049ac04dd0..6e919f127bee 100644
--- a/packages/astro/src/events/session.ts
+++ b/packages/astro/src/events/session.ts
@@ -1,5 +1,6 @@
-import type { AstroIntegration, AstroUserConfig } from '../@types/astro.js';
import { AstroConfigSchema } from '../core/config/schema.js';
+import type { AstroUserConfig } from '../types/public/config.js';
+import type { AstroIntegration } from '../types/public/integrations.js';
const EVENT_SESSION = 'ASTRO_CLI_SESSION_STARTED';
diff --git a/packages/astro/src/i18n/index.ts b/packages/astro/src/i18n/index.ts
index aa38b63bbe89..b8fb53543e78 100644
--- a/packages/astro/src/i18n/index.ts
+++ b/packages/astro/src/i18n/index.ts
@@ -1,17 +1,13 @@
import { appendForwardSlash, joinPaths } from '@astrojs/internal-helpers/path';
-import type {
- APIContext,
- AstroConfig,
- Locales,
- SSRManifest,
- ValidRedirectStatus,
-} from '../@types/astro.js';
import { shouldAppendForwardSlash } from '../core/build/util.js';
import { REROUTE_DIRECTIVE_HEADER } from '../core/constants.js';
import { MissingLocale, i18nNoLocaleFoundInPath } from '../core/errors/errors-data.js';
import { AstroError } from '../core/errors/index.js';
+import type { AstroConfig, Locales, ValidRedirectStatus } from '../types/public/config.js';
+import type { APIContext } from '../types/public/context.js';
import { createI18nMiddleware } from './middleware.js';
import type { RoutingStrategies } from './utils.js';
+import type { SSRManifest } from '../core/app/types.js';
export function requestHasLocale(locales: Locales) {
return function (context: APIContext): boolean {
diff --git a/packages/astro/src/i18n/middleware.ts b/packages/astro/src/i18n/middleware.ts
index 097332805759..7c2fc1406b2a 100644
--- a/packages/astro/src/i18n/middleware.ts
+++ b/packages/astro/src/i18n/middleware.ts
@@ -1,6 +1,7 @@
-import type { APIContext, MiddlewareHandler, SSRManifest } from '../@types/astro.js';
-import type { SSRManifestI18n } from '../core/app/types.js';
+import type { SSRManifest, SSRManifestI18n } from '../core/app/types.js';
import { ROUTE_TYPE_HEADER } from '../core/constants.js';
+import type { MiddlewareHandler } from '../types/public/common.js';
+import type { APIContext } from '../types/public/context.js';
import {
type MiddlewarePayload,
normalizeTheLocale,
diff --git a/packages/astro/src/i18n/utils.ts b/packages/astro/src/i18n/utils.ts
index 052fe01fce65..98a44a19ca5e 100644
--- a/packages/astro/src/i18n/utils.ts
+++ b/packages/astro/src/i18n/utils.ts
@@ -1,4 +1,4 @@
-import type { AstroConfig, Locales } from '../@types/astro.js';
+import type { AstroConfig, Locales } from '../types/public/config.js';
import { normalizeTheLocale, toCodes } from './index.js';
type BrowserLocale = {
diff --git a/packages/astro/src/i18n/vite-plugin-i18n.ts b/packages/astro/src/i18n/vite-plugin-i18n.ts
index 7aa4d327b223..5ee79a8836a8 100644
--- a/packages/astro/src/i18n/vite-plugin-i18n.ts
+++ b/packages/astro/src/i18n/vite-plugin-i18n.ts
@@ -1,7 +1,8 @@
import type * as vite from 'vite';
-import type { AstroConfig, AstroSettings } from '../@types/astro.js';
import { AstroError } from '../core/errors/errors.js';
import { AstroErrorData } from '../core/errors/index.js';
+import type { AstroSettings } from '../types/astro.js';
+import type { AstroConfig } from '../types/public/config.js';
const virtualModuleId = 'astro:i18n';
diff --git a/packages/astro/src/integrations/features-validation.ts b/packages/astro/src/integrations/features-validation.ts
index 87de3592b726..f59a25b15c28 100644
--- a/packages/astro/src/integrations/features-validation.ts
+++ b/packages/astro/src/integrations/features-validation.ts
@@ -1,11 +1,11 @@
+import type { Logger } from '../core/logger/core.js';
+import type { AstroConfig } from '../types/public/config.js';
import type {
+ AdapterSupportsKind,
+ AstroAdapterFeatureMap,
AstroAdapterFeatures,
AstroAssetsFeature,
- AstroConfig,
- AstroFeatureMap,
- SupportsKind,
-} from '../@types/astro.js';
-import type { Logger } from '../core/logger/core.js';
+} from '../types/public/integrations.js';
const STABLE = 'stable';
const DEPRECATED = 'deprecated';
@@ -19,7 +19,7 @@ const UNSUPPORTED_ASSETS_FEATURE: AstroAssetsFeature = {
};
type ValidationResult = {
- [Property in keyof AstroFeatureMap]: boolean;
+ [Property in keyof AstroAdapterFeatureMap]: boolean;
};
/**
@@ -31,7 +31,7 @@ type ValidationResult = {
*/
export function validateSupportedFeatures(
adapterName: string,
- featureMap: AstroFeatureMap,
+ featureMap: AstroAdapterFeatureMap,
config: AstroConfig,
adapterFeatures: AstroAdapterFeatures | undefined,
logger: Logger,
@@ -101,7 +101,7 @@ export function validateSupportedFeatures(
}
function validateSupportKind(
- supportKind: SupportsKind,
+ supportKind: AdapterSupportsKind,
adapterName: string,
logger: Logger,
featureName: string,
diff --git a/packages/astro/src/integrations/hooks.ts b/packages/astro/src/integrations/hooks.ts
index c0b9604335b3..a9ac630c15e1 100644
--- a/packages/astro/src/integrations/hooks.ts
+++ b/packages/astro/src/integrations/hooks.ts
@@ -3,25 +3,24 @@ import type { AddressInfo } from 'node:net';
import { fileURLToPath } from 'node:url';
import { bold } from 'kleur/colors';
import type { InlineConfig, ViteDevServer } from 'vite';
-import type {
- AstroAdapter,
- AstroConfig,
- AstroIntegration,
- AstroRenderer,
- AstroSettings,
- ContentEntryType,
- DataEntryType,
- HookParameters,
- RouteData,
- RouteOptions,
-} from '../@types/astro.js';
import type { SerializedSSRManifest } from '../core/app/types.js';
import type { PageBuildData } from '../core/build/types.js';
import { buildClientDirectiveEntrypoint } from '../core/client-directive/index.js';
import { mergeConfig } from '../core/config/index.js';
import type { AstroIntegrationLogger, Logger } from '../core/logger/core.js';
import { isServerLikeOutput } from '../core/util.js';
+import type { AstroSettings } from '../types/astro.js';
+import type { AstroConfig } from '../types/public/config.js';
+import type {
+ AstroAdapter,
+ AstroIntegration,
+ AstroRenderer,
+ HookParameters,
+ RouteOptions,
+} from '../types/public/integrations.js';
+import type { RouteData } from '../types/public/internal.js';
import { validateSupportedFeatures } from './features-validation.js';
+import type { ContentEntryType, DataEntryType } from '../types/public/content.js';
async function withTakingALongTimeMsg({
name,
@@ -198,10 +197,6 @@ export async function runHookConfigSetup({
addWatchFile: (path) => {
updatedSettings.watchFiles.push(path instanceof URL ? fileURLToPath(path) : path);
},
- addDevOverlayPlugin: (entrypoint) => {
- // TODO add a deprecation warning in Astro 5.
- hooks.addDevToolbarApp(entrypoint);
- },
addDevToolbarApp: (entrypoint) => {
updatedSettings.devToolbarApps.push(entrypoint);
},
diff --git a/packages/astro/src/jsx/renderer.ts b/packages/astro/src/jsx/renderer.ts
index 413257faab97..86f4d018743a 100644
--- a/packages/astro/src/jsx/renderer.ts
+++ b/packages/astro/src/jsx/renderer.ts
@@ -1,11 +1,8 @@
-import type { AstroRenderer } from '../@types/astro.js';
-import { jsxTransformOptions } from './transform-options.js';
+import type { AstroRenderer } from '../types/public/integrations.js';
const renderer: AstroRenderer = {
name: 'astro:jsx',
serverEntrypoint: 'astro/jsx/server.js',
- jsxImportSource: 'astro',
- jsxTransformOptions,
};
export default renderer;
diff --git a/packages/astro/src/jsx/server.ts b/packages/astro/src/jsx/server.ts
index 73b584baeaf7..bb71231c5813 100644
--- a/packages/astro/src/jsx/server.ts
+++ b/packages/astro/src/jsx/server.ts
@@ -1,7 +1,7 @@
-import type { NamedSSRLoadedRendererValue } from '../@types/astro.js';
import { AstroError, AstroUserError } from '../core/errors/errors.js';
import { AstroJSX, jsx } from '../jsx-runtime/index.js';
import { renderJSX } from '../runtime/server/jsx.js';
+import type { NamedSSRLoadedRendererValue } from '../types/public/internal.js';
const slotName = (str: string) => str.trim().replace(/[-_]([a-z])/g, (_, w) => w.toUpperCase());
diff --git a/packages/astro/src/jsx/transform-options.ts b/packages/astro/src/jsx/transform-options.ts
index ca1d50a6a131..e7405ddc0c2d 100644
--- a/packages/astro/src/jsx/transform-options.ts
+++ b/packages/astro/src/jsx/transform-options.ts
@@ -1,4 +1,4 @@
-import type { JSXTransformConfig } from '../@types/astro.js';
+import type { JSXTransformConfig } from '../types/astro.js';
/**
* @deprecated This function is no longer used. Remove in Astro 5.0
diff --git a/packages/astro/src/preferences/index.ts b/packages/astro/src/preferences/index.ts
index 2b92c5fb6cb5..7c8779b43f4e 100644
--- a/packages/astro/src/preferences/index.ts
+++ b/packages/astro/src/preferences/index.ts
@@ -1,11 +1,10 @@
-import type { AstroConfig } from '../@types/astro.js';
-
import os from 'node:os';
import path from 'node:path';
import process from 'node:process';
import { fileURLToPath } from 'node:url';
import dget from 'dlv';
+import type { AstroConfig } from '../types/public/config.js';
import { DEFAULT_PREFERENCES, type Preferences, type PublicPreferences } from './defaults.js';
import { PreferenceStore } from './store.js';
diff --git a/packages/astro/src/prefetch/vite-plugin-prefetch.ts b/packages/astro/src/prefetch/vite-plugin-prefetch.ts
index d64c6d5008b9..560895b15bfb 100644
--- a/packages/astro/src/prefetch/vite-plugin-prefetch.ts
+++ b/packages/astro/src/prefetch/vite-plugin-prefetch.ts
@@ -1,5 +1,5 @@
import type * as vite from 'vite';
-import type { AstroSettings } from '../@types/astro.js';
+import type { AstroSettings } from '../types/astro.js';
const virtualModuleId = 'astro:prefetch';
const resolvedVirtualModuleId = '\0' + virtualModuleId;
diff --git a/packages/astro/src/prerender/routing.ts b/packages/astro/src/prerender/routing.ts
index cbdddff5c8cb..888b012e0b9d 100644
--- a/packages/astro/src/prerender/routing.ts
+++ b/packages/astro/src/prerender/routing.ts
@@ -1,6 +1,7 @@
-import type { AstroSettings, ComponentInstance, RouteData } from '../@types/astro.js';
import { RedirectComponentInstance, routeIsRedirect } from '../core/redirects/index.js';
import { routeComparator } from '../core/routing/priority.js';
+import type { AstroSettings, ComponentInstance } from '../types/astro.js';
+import type { RouteData } from '../types/public/internal.js';
import type { DevPipeline } from '../vite-plugin-astro-server/pipeline.js';
import { getPrerenderStatus } from './metadata.js';
diff --git a/packages/astro/src/prerender/utils.ts b/packages/astro/src/prerender/utils.ts
index 4097b66b1f6d..e34e0d5fd024 100644
--- a/packages/astro/src/prerender/utils.ts
+++ b/packages/astro/src/prerender/utils.ts
@@ -1,6 +1,6 @@
-import type { AstroConfig } from '../@types/astro.js';
import { getOutDirWithinCwd } from '../core/build/common.js';
import { isServerLikeOutput } from '../core/util.js';
+import type { AstroConfig } from '../types/public/config.js';
export function getPrerenderDefault(config: AstroConfig) {
return config.output !== 'server';
diff --git a/packages/astro/src/runtime/client/dev-toolbar/apps/astro.ts b/packages/astro/src/runtime/client/dev-toolbar/apps/astro.ts
index e63667a12d6f..12ab602a255e 100644
--- a/packages/astro/src/runtime/client/dev-toolbar/apps/astro.ts
+++ b/packages/astro/src/runtime/client/dev-toolbar/apps/astro.ts
@@ -1,4 +1,4 @@
-import type { DevToolbarApp, DevToolbarMetadata } from '../../../../@types/astro.js';
+import type { DevToolbarApp, DevToolbarMetadata } from '../../../../types/public/toolbar.js';
import { type Icon, isDefinedIcon } from '../ui-library/icons.js';
import { colorForIntegration, iconForIntegration } from './utils/icons.js';
import {
diff --git a/packages/astro/src/runtime/client/dev-toolbar/apps/audit/index.ts b/packages/astro/src/runtime/client/dev-toolbar/apps/audit/index.ts
index 6a6aba42d120..cc58411cf3c4 100644
--- a/packages/astro/src/runtime/client/dev-toolbar/apps/audit/index.ts
+++ b/packages/astro/src/runtime/client/dev-toolbar/apps/audit/index.ts
@@ -1,4 +1,4 @@
-import type { DevToolbarApp } from '../../../../../@types/astro.js';
+import type { DevToolbarApp } from '../../../../../types/public/toolbar.js';
import { settings } from '../../settings.js';
import type { DevToolbarHighlight } from '../../ui-library/highlight.js';
import { positionHighlight } from '../utils/highlight.js';
diff --git a/packages/astro/src/runtime/client/dev-toolbar/apps/audit/ui/audit-ui.ts b/packages/astro/src/runtime/client/dev-toolbar/apps/audit/ui/audit-ui.ts
index 38559e0f9adf..34adf4f01282 100644
--- a/packages/astro/src/runtime/client/dev-toolbar/apps/audit/ui/audit-ui.ts
+++ b/packages/astro/src/runtime/client/dev-toolbar/apps/audit/ui/audit-ui.ts
@@ -1,5 +1,5 @@
import { escape as escapeHTML } from 'html-escaper';
-import type { DevToolbarMetadata } from '../../../../../../@types/astro.js';
+import type { DevToolbarMetadata } from '../../../../../../types/public/toolbar.js';
import {
attachTooltipToHighlight,
createHighlight,
diff --git a/packages/astro/src/runtime/client/dev-toolbar/apps/settings.ts b/packages/astro/src/runtime/client/dev-toolbar/apps/settings.ts
index 7ee42da84996..192e4509b504 100644
--- a/packages/astro/src/runtime/client/dev-toolbar/apps/settings.ts
+++ b/packages/astro/src/runtime/client/dev-toolbar/apps/settings.ts
@@ -1,4 +1,4 @@
-import type { DevToolbarApp } from '../../../../@types/astro.js';
+import type { DevToolbarApp } from '../../../../types/public/toolbar.js';
import { type Settings, settings } from '../settings.js';
import { isValidPlacement, placements } from '../ui-library/window.js';
import {
diff --git a/packages/astro/src/runtime/client/dev-toolbar/apps/xray.ts b/packages/astro/src/runtime/client/dev-toolbar/apps/xray.ts
index 2e56b0f244cf..fafc8e26d57e 100644
--- a/packages/astro/src/runtime/client/dev-toolbar/apps/xray.ts
+++ b/packages/astro/src/runtime/client/dev-toolbar/apps/xray.ts
@@ -1,5 +1,5 @@
import { escape as escapeHTML } from 'html-escaper';
-import type { DevToolbarApp, DevToolbarMetadata } from '../../../../@types/astro.js';
+import type { DevToolbarApp, DevToolbarMetadata } from '../../../../types/public/toolbar.js';
import type { DevToolbarHighlight } from '../ui-library/highlight.js';
import {
attachTooltipToHighlight,
diff --git a/packages/astro/src/runtime/client/dev-toolbar/entrypoint.ts b/packages/astro/src/runtime/client/dev-toolbar/entrypoint.ts
index 9731f3597fbb..86c616becb3a 100644
--- a/packages/astro/src/runtime/client/dev-toolbar/entrypoint.ts
+++ b/packages/astro/src/runtime/client/dev-toolbar/entrypoint.ts
@@ -1,6 +1,6 @@
// @ts-expect-error - This module is private and untyped
import { loadDevToolbarApps } from 'astro:toolbar:internal';
-import type { ResolvedDevToolbarApp as DevToolbarAppDefinition } from '../../../@types/astro.js';
+import type { ResolvedDevToolbarApp as DevToolbarAppDefinition } from '../../../types/public/toolbar.js';
import { ToolbarAppEventTarget } from './helpers.js';
import { settings } from './settings.js';
import type { AstroDevToolbar, DevToolbarApp } from './toolbar.js';
diff --git a/packages/astro/src/runtime/client/dev-toolbar/toolbar.ts b/packages/astro/src/runtime/client/dev-toolbar/toolbar.ts
index 08ea61cace5c..e24698d4337b 100644
--- a/packages/astro/src/runtime/client/dev-toolbar/toolbar.ts
+++ b/packages/astro/src/runtime/client/dev-toolbar/toolbar.ts
@@ -1,5 +1,5 @@
/* eslint-disable no-console */
-import type { ResolvedDevToolbarApp as DevToolbarAppDefinition } from '../../../@types/astro.js';
+import type { ResolvedDevToolbarApp as DevToolbarAppDefinition } from '../../../types/public/toolbar.js';
import { type ToolbarAppEventTarget, serverHelpers } from './helpers.js';
import { settings } from './settings.js';
import { type Icon, getIconElement, isDefinedIcon } from './ui-library/icons.js';
diff --git a/packages/astro/src/runtime/client/idle.ts b/packages/astro/src/runtime/client/idle.ts
index 990d5da6ef10..e32b1a42f698 100644
--- a/packages/astro/src/runtime/client/idle.ts
+++ b/packages/astro/src/runtime/client/idle.ts
@@ -1,4 +1,4 @@
-import type { ClientDirective } from '../../@types/astro.js';
+import type { ClientDirective } from '../../types/public/integrations.js';
const idleDirective: ClientDirective = (load) => {
const cb = async () => {
diff --git a/packages/astro/src/runtime/client/load.ts b/packages/astro/src/runtime/client/load.ts
index b603eecb3b49..98521181c528 100644
--- a/packages/astro/src/runtime/client/load.ts
+++ b/packages/astro/src/runtime/client/load.ts
@@ -1,4 +1,4 @@
-import type { ClientDirective } from '../../@types/astro.js';
+import type { ClientDirective } from '../../types/public/integrations.js';
const loadDirective: ClientDirective = async (load) => {
const hydrate = await load();
diff --git a/packages/astro/src/runtime/client/media.ts b/packages/astro/src/runtime/client/media.ts
index f894af31112d..0c6e497e3302 100644
--- a/packages/astro/src/runtime/client/media.ts
+++ b/packages/astro/src/runtime/client/media.ts
@@ -1,4 +1,4 @@
-import type { ClientDirective } from '../../@types/astro.js';
+import type { ClientDirective } from '../../types/public/integrations.js';
/**
* Hydrate this component when a matching media query is found
diff --git a/packages/astro/src/runtime/client/only.ts b/packages/astro/src/runtime/client/only.ts
index 8e072b7a3fc0..c5fc488d4bd8 100644
--- a/packages/astro/src/runtime/client/only.ts
+++ b/packages/astro/src/runtime/client/only.ts
@@ -1,4 +1,4 @@
-import type { ClientDirective } from '../../@types/astro.js';
+import type { ClientDirective } from '../../types/public/integrations.js';
/**
* Hydrate this component only on the client
diff --git a/packages/astro/src/runtime/client/visible.ts b/packages/astro/src/runtime/client/visible.ts
index 9be4d9b318a7..c7d858ffb0b4 100644
--- a/packages/astro/src/runtime/client/visible.ts
+++ b/packages/astro/src/runtime/client/visible.ts
@@ -1,4 +1,5 @@
-import type { ClientDirective, ClientVisibleOptions } from '../../@types/astro.js';
+import type { ClientVisibleOptions } from '../../types/public/elements.js';
+import type { ClientDirective } from '../../types/public/integrations.js';
/**
* Hydrate this component when one of it's children becomes visible
diff --git a/packages/astro/src/runtime/server/astro-component.ts b/packages/astro/src/runtime/server/astro-component.ts
index 928d23ad82a5..20649b64dcb4 100644
--- a/packages/astro/src/runtime/server/astro-component.ts
+++ b/packages/astro/src/runtime/server/astro-component.ts
@@ -1,5 +1,5 @@
-import type { PropagationHint } from '../../@types/astro.js';
import { AstroError, AstroErrorData } from '../../core/errors/index.js';
+import type { PropagationHint } from '../../types/public/internal.js';
import type { AstroComponentFactory } from './render/index.js';
function validateArgs(args: unknown[]): args is Parameters {
diff --git a/packages/astro/src/runtime/server/astro-global.ts b/packages/astro/src/runtime/server/astro-global.ts
index 5948c8ff3aff..74b32e331421 100644
--- a/packages/astro/src/runtime/server/astro-global.ts
+++ b/packages/astro/src/runtime/server/astro-global.ts
@@ -1,6 +1,6 @@
-import type { AstroGlobalPartial } from '../../@types/astro.js';
import { ASTRO_VERSION } from '../../core/constants.js';
import { AstroError, AstroErrorData } from '../../core/errors/index.js';
+import type { AstroGlobalPartial } from '../../types/public/context.js';
/** Create the Astro.glob() runtime function. */
function createAstroGlobFn() {
diff --git a/packages/astro/src/runtime/server/endpoint.ts b/packages/astro/src/runtime/server/endpoint.ts
index 900d604fd569..674d6209343f 100644
--- a/packages/astro/src/runtime/server/endpoint.ts
+++ b/packages/astro/src/runtime/server/endpoint.ts
@@ -1,13 +1,16 @@
import { bold } from 'kleur/colors';
-import type { APIContext, EndpointHandler } from '../../@types/astro.js';
import { REROUTABLE_STATUS_CODES, REROUTE_DIRECTIVE_HEADER } from '../../core/constants.js';
import { EndpointDidNotReturnAResponse } from '../../core/errors/errors-data.js';
import { AstroError } from '../../core/errors/errors.js';
import type { Logger } from '../../core/logger/core.js';
+import type { APIRoute } from '../../types/public/common.js';
+import type { APIContext } from '../../types/public/context.js';
/** Renders an endpoint request to completion, returning the body. */
export async function renderEndpoint(
- mod: EndpointHandler,
+ mod: {
+ [method: string]: APIRoute;
+ },
context: APIContext,
ssr: boolean,
logger: Logger,
diff --git a/packages/astro/src/runtime/server/hydration.ts b/packages/astro/src/runtime/server/hydration.ts
index ab6396566b5e..dab7ac343bde 100644
--- a/packages/astro/src/runtime/server/hydration.ts
+++ b/packages/astro/src/runtime/server/hydration.ts
@@ -1,10 +1,10 @@
+import { AstroError, AstroErrorData } from '../../core/errors/index.js';
import type {
+ SSRResult,
+ SSRLoadedRenderer,
AstroComponentMetadata,
SSRElement,
- SSRLoadedRenderer,
- SSRResult,
-} from '../../@types/astro.js';
-import { AstroError, AstroErrorData } from '../../core/errors/index.js';
+} from '../../types/public/internal.js';
import { escapeHTML } from './escape.js';
import { serializeProps } from './serialize.js';
diff --git a/packages/astro/src/runtime/server/jsx.ts b/packages/astro/src/runtime/server/jsx.ts
index 2491ab58946e..7280e216c31c 100644
--- a/packages/astro/src/runtime/server/jsx.ts
+++ b/packages/astro/src/runtime/server/jsx.ts
@@ -1,5 +1,5 @@
-import type { SSRResult } from '../../@types/astro.js';
import { AstroJSX, type AstroVNode, isVNode } from '../../jsx-runtime/index.js';
+import type { SSRResult } from '../../types/public/internal.js';
import {
HTMLString,
escapeHTML,
diff --git a/packages/astro/src/runtime/server/render/astro/factory.ts b/packages/astro/src/runtime/server/render/astro/factory.ts
index db319eb1aadd..dab33a031991 100644
--- a/packages/astro/src/runtime/server/render/astro/factory.ts
+++ b/packages/astro/src/runtime/server/render/astro/factory.ts
@@ -1,4 +1,4 @@
-import type { PropagationHint, SSRResult } from '../../../../@types/astro.js';
+import type { PropagationHint, SSRResult } from '../../../../types/public/internal.js';
import type { HeadAndContent } from './head-and-content.js';
import type { RenderTemplateResult } from './render-template.js';
diff --git a/packages/astro/src/runtime/server/render/astro/instance.ts b/packages/astro/src/runtime/server/render/astro/instance.ts
index 3246a7e1b294..16dc2bf04324 100644
--- a/packages/astro/src/runtime/server/render/astro/instance.ts
+++ b/packages/astro/src/runtime/server/render/astro/instance.ts
@@ -1,4 +1,3 @@
-import type { SSRResult } from '../../../../@types/astro.js';
import type { ComponentSlots } from '../slot.js';
import type { AstroComponentFactory } from './factory.js';
@@ -7,6 +6,7 @@ import { renderChild } from '../any.js';
import type { RenderDestination } from '../common.js';
import { isAPropagatingComponent } from './factory.js';
import { isHeadAndContent } from './head-and-content.js';
+import type { SSRResult } from '../../../../types/public/internal.js';
type ComponentProps = Record;
diff --git a/packages/astro/src/runtime/server/render/astro/render.ts b/packages/astro/src/runtime/server/render/astro/render.ts
index 41845b7b9e16..adc335495da1 100644
--- a/packages/astro/src/runtime/server/render/astro/render.ts
+++ b/packages/astro/src/runtime/server/render/astro/render.ts
@@ -1,5 +1,5 @@
-import type { RouteData, SSRResult } from '../../../../@types/astro.js';
import { AstroError, AstroErrorData } from '../../../../core/errors/index.js';
+import type { RouteData, SSRResult } from '../../../../types/public/internal.js';
import { type RenderDestination, chunkToByteArray, chunkToString, encoder } from '../common.js';
import { promiseWithResolvers } from '../util.js';
import type { AstroComponentFactory } from './factory.js';
diff --git a/packages/astro/src/runtime/server/render/common.ts b/packages/astro/src/runtime/server/render/common.ts
index 0845bdd65315..c681112204e7 100644
--- a/packages/astro/src/runtime/server/render/common.ts
+++ b/packages/astro/src/runtime/server/render/common.ts
@@ -1,4 +1,3 @@
-import type { SSRResult } from '../../../@types/astro.js';
import type { RenderInstruction } from './instruction.js';
import type { HTMLBytes, HTMLString } from '../escape.js';
@@ -12,6 +11,7 @@ import {
import { renderAllHeadContent } from './head.js';
import { isRenderInstruction } from './instruction.js';
import { type SlotString, isSlotString } from './slot.js';
+import type { SSRResult } from '../../../types/public/internal.js';
/**
* Possible chunk types to be written to the destination, and it'll
diff --git a/packages/astro/src/runtime/server/render/component.ts b/packages/astro/src/runtime/server/render/component.ts
index 449f58fbcc7d..300911acdaca 100644
--- a/packages/astro/src/runtime/server/render/component.ts
+++ b/packages/astro/src/runtime/server/render/component.ts
@@ -1,9 +1,3 @@
-import type {
- AstroComponentMetadata,
- RouteData,
- SSRLoadedRenderer,
- SSRResult,
-} from '../../../@types/astro.js';
import { createRenderInstruction } from './instruction.js';
import { clsx } from 'clsx';
@@ -17,6 +11,12 @@ import { type AstroComponentFactory, isAstroComponentFactory } from './astro/fac
import { renderTemplate } from './astro/index.js';
import { createAstroComponentInstance } from './astro/instance.js';
+import type {
+ AstroComponentMetadata,
+ RouteData,
+ SSRLoadedRenderer,
+ SSRResult,
+} from '../../../types/public/internal.js';
import {
Fragment,
type RenderDestination,
diff --git a/packages/astro/src/runtime/server/render/dom.ts b/packages/astro/src/runtime/server/render/dom.ts
index e2b194df3451..f92b4889a38f 100644
--- a/packages/astro/src/runtime/server/render/dom.ts
+++ b/packages/astro/src/runtime/server/render/dom.ts
@@ -1,5 +1,4 @@
-import type { SSRResult } from '../../../@types/astro.js';
-
+import type { SSRResult } from '../../../types/public/internal.js';
import { markHTMLString } from '../escape.js';
import { renderSlotToString } from './slot.js';
import { toAttributeString } from './util.js';
diff --git a/packages/astro/src/runtime/server/render/head.ts b/packages/astro/src/runtime/server/render/head.ts
index 49dd5abed14a..01f11f21e760 100644
--- a/packages/astro/src/runtime/server/render/head.ts
+++ b/packages/astro/src/runtime/server/render/head.ts
@@ -1,5 +1,4 @@
-import type { SSRResult } from '../../../@types/astro.js';
-
+import type { SSRResult } from '../../../types/public/internal.js';
import { markHTMLString } from '../escape.js';
import type { MaybeRenderHeadInstruction, RenderHeadInstruction } from './instruction.js';
import { createRenderInstruction } from './instruction.js';
diff --git a/packages/astro/src/runtime/server/render/page.ts b/packages/astro/src/runtime/server/render/page.ts
index 35a7ec789947..0e0bcf295ad8 100644
--- a/packages/astro/src/runtime/server/render/page.ts
+++ b/packages/astro/src/runtime/server/render/page.ts
@@ -1,7 +1,7 @@
-import type { RouteData, SSRResult } from '../../../@types/astro.js';
import { type NonAstroPageComponent, renderComponentToString } from './component.js';
import type { AstroComponentFactory } from './index.js';
+import type { RouteData, SSRResult } from '../../../types/public/internal.js';
import { isAstroComponentFactory } from './astro/index.js';
import { renderToAsyncIterable, renderToReadableStream, renderToString } from './astro/render.js';
import { encoder } from './common.js';
diff --git a/packages/astro/src/runtime/server/render/script.ts b/packages/astro/src/runtime/server/render/script.ts
index 1b9c5ce1b37e..6d9283790a06 100644
--- a/packages/astro/src/runtime/server/render/script.ts
+++ b/packages/astro/src/runtime/server/render/script.ts
@@ -1,4 +1,4 @@
-import type { SSRResult } from '../../../@types/astro.js';
+import type { SSRResult } from '../../../types/public/internal.js';
import { markHTMLString } from '../escape.js';
/**
diff --git a/packages/astro/src/runtime/server/render/server-islands.ts b/packages/astro/src/runtime/server/render/server-islands.ts
index 58cce4e14814..c4f62ea55c33 100644
--- a/packages/astro/src/runtime/server/render/server-islands.ts
+++ b/packages/astro/src/runtime/server/render/server-islands.ts
@@ -1,5 +1,5 @@
-import type { SSRResult } from '../../../@types/astro.js';
import { encryptString } from '../../../core/encryption.js';
+import type { SSRResult } from '../../../types/public/internal.js';
import { renderChild } from './any.js';
import type { RenderInstance } from './common.js';
import { type ComponentSlots, renderSlotToString } from './slot.js';
diff --git a/packages/astro/src/runtime/server/render/slot.ts b/packages/astro/src/runtime/server/render/slot.ts
index d02a32d82b5d..7d47e63ec510 100644
--- a/packages/astro/src/runtime/server/render/slot.ts
+++ b/packages/astro/src/runtime/server/render/slot.ts
@@ -1,10 +1,10 @@
-import type { SSRResult } from '../../../@types/astro.js';
import { renderTemplate } from './astro/render-template.js';
import type { RenderInstruction } from './instruction.js';
import { HTMLString, markHTMLString, unescapeHTML } from '../escape.js';
import { renderChild } from './any.js';
import { type RenderDestination, type RenderInstance, chunkToString } from './common.js';
+import type { SSRResult } from '../../../types/public/internal.js';
type RenderTemplateResult = ReturnType;
export type ComponentSlots = Record;
diff --git a/packages/astro/src/runtime/server/render/tags.ts b/packages/astro/src/runtime/server/render/tags.ts
index 093c51a3c46e..baba11a5b0d1 100644
--- a/packages/astro/src/runtime/server/render/tags.ts
+++ b/packages/astro/src/runtime/server/render/tags.ts
@@ -1,5 +1,5 @@
-import type { SSRElement, SSRResult } from '../../../@types/astro.js';
import type { StylesheetAsset } from '../../../core/app/types.js';
+import type { SSRElement, SSRResult } from '../../../types/public/internal.js';
import { renderElement } from './util.js';
export function renderScriptElement({ props, children }: SSRElement) {
diff --git a/packages/astro/src/runtime/server/render/util.ts b/packages/astro/src/runtime/server/render/util.ts
index 019bf9a40828..07766449e44b 100644
--- a/packages/astro/src/runtime/server/render/util.ts
+++ b/packages/astro/src/runtime/server/render/util.ts
@@ -1,8 +1,8 @@
-import type { SSRElement } from '../../../@types/astro.js';
import type { RenderDestination, RenderDestinationChunk, RenderFunction } from './common.js';
import { clsx } from 'clsx';
import { HTMLString, markHTMLString } from '../escape.js';
+import type { SSRElement } from '../../../types/public/internal.js';
export const voidElementNames =
/^(area|base|br|col|command|embed|hr|img|input|keygen|link|meta|param|source|track|wbr)$/i;
diff --git a/packages/astro/src/runtime/server/scripts.ts b/packages/astro/src/runtime/server/scripts.ts
index 84f2dcd525d8..ca9cad1fb186 100644
--- a/packages/astro/src/runtime/server/scripts.ts
+++ b/packages/astro/src/runtime/server/scripts.ts
@@ -1,4 +1,4 @@
-import type { SSRResult } from '../../@types/astro.js';
+import type { SSRResult } from '../../types/public/internal.js';
import islandScriptDev from './astro-island.prebuilt-dev.js';
import islandScript from './astro-island.prebuilt.js';
diff --git a/packages/astro/src/runtime/server/serialize.ts b/packages/astro/src/runtime/server/serialize.ts
index 522b05256601..6afe91917959 100644
--- a/packages/astro/src/runtime/server/serialize.ts
+++ b/packages/astro/src/runtime/server/serialize.ts
@@ -1,5 +1,5 @@
-import type { AstroComponentMetadata } from '../../@types/astro.js';
import type { ValueOf } from '../../type-utils.js';
+import type { AstroComponentMetadata } from '../../types/public/internal.js';
const PROP_TYPE = {
Value: 0,
diff --git a/packages/astro/src/runtime/server/transition.ts b/packages/astro/src/runtime/server/transition.ts
index 8887d3dae4ed..4777a287ad5e 100644
--- a/packages/astro/src/runtime/server/transition.ts
+++ b/packages/astro/src/runtime/server/transition.ts
@@ -1,13 +1,13 @@
import cssesc from 'cssesc';
+import { fade, slide } from '../../transitions/index.js';
import type {
- SSRResult,
TransitionAnimation,
TransitionAnimationPair,
TransitionAnimationValue,
TransitionDirectionalAnimations,
-} from '../../@types/astro.js';
-import { fade, slide } from '../../transitions/index.js';
+} from '../../types/public/view-transitions.js';
import { markHTMLString } from './escape.js';
+import type { SSRResult } from '../../types/public/internal.js';
const transitionNameMap = new WeakMap();
function incrementTransitionNumber(result: SSRResult) {
diff --git a/packages/astro/src/toolbar/index.ts b/packages/astro/src/toolbar/index.ts
index bd05e4417447..78d7158b20af 100644
--- a/packages/astro/src/toolbar/index.ts
+++ b/packages/astro/src/toolbar/index.ts
@@ -1,4 +1,4 @@
-import type { DevToolbarApp } from '../@types/astro.js';
+import type { DevToolbarApp } from '../types/public/toolbar.js';
export function defineToolbarApp(app: DevToolbarApp) {
return app;
diff --git a/packages/astro/src/toolbar/vite-plugin-dev-toolbar.ts b/packages/astro/src/toolbar/vite-plugin-dev-toolbar.ts
index 32c91752f30d..d4d0510e69ce 100644
--- a/packages/astro/src/toolbar/vite-plugin-dev-toolbar.ts
+++ b/packages/astro/src/toolbar/vite-plugin-dev-toolbar.ts
@@ -1,7 +1,7 @@
import type * as vite from 'vite';
-import type { AstroPluginOptions } from '../@types/astro.js';
import { telemetry } from '../events/index.js';
import { eventAppToggled } from '../events/toolbar.js';
+import type { AstroPluginOptions } from '../types/astro.js';
const PRIVATE_VIRTUAL_MODULE_ID = 'astro:toolbar:internal';
const resolvedPrivateVirtualModuleId = '\0' + PRIVATE_VIRTUAL_MODULE_ID;
diff --git a/packages/astro/src/transitions/index.ts b/packages/astro/src/transitions/index.ts
index d87052f2daf2..05bfb0972964 100644
--- a/packages/astro/src/transitions/index.ts
+++ b/packages/astro/src/transitions/index.ts
@@ -1,4 +1,8 @@
-import type { TransitionAnimationPair, TransitionDirectionalAnimations } from '../@types/astro.js';
+import type {
+ TransitionAnimationPair,
+ TransitionDirectionalAnimations,
+} from '../types/public/view-transitions.js';
+
export { createAnimationScope } from '../runtime/server/transition.js';
const EASE_IN_OUT_QUART = 'cubic-bezier(0.76, 0, 0.24, 1)';
diff --git a/packages/astro/src/transitions/vite-plugin-transitions.ts b/packages/astro/src/transitions/vite-plugin-transitions.ts
index d88c96f8919f..56f086a06a36 100644
--- a/packages/astro/src/transitions/vite-plugin-transitions.ts
+++ b/packages/astro/src/transitions/vite-plugin-transitions.ts
@@ -1,5 +1,5 @@
import type * as vite from 'vite';
-import type { AstroSettings } from '../@types/astro.js';
+import type { AstroSettings } from '../types/astro.js';
const virtualModuleId = 'astro:transitions';
const resolvedVirtualModuleId = '\0' + virtualModuleId;
diff --git a/packages/astro/src/types/astro.ts b/packages/astro/src/types/astro.ts
new file mode 100644
index 000000000000..fb2f296fcf1d
--- /dev/null
+++ b/packages/astro/src/types/astro.ts
@@ -0,0 +1,97 @@
+import type { SSRManifest } from '../core/app/types.js';
+import type { AstroTimer } from '../core/config/timer.js';
+import type { TSConfig } from '../core/config/tsconfig.js';
+import type { Logger } from '../core/logger/core.js';
+import type { AstroPreferences } from '../preferences/index.js';
+import type { AstroComponentFactory } from '../runtime/server/index.js';
+import type { GetStaticPathsOptions, GetStaticPathsResult } from './public/common.js';
+import type { AstroConfig } from './public/config.js';
+import type { ContentEntryType, DataEntryType } from './public/content.js';
+import type {
+ AstroAdapter,
+ AstroRenderer,
+ InjectedRoute,
+ InjectedScriptStage,
+ InjectedType,
+ ResolvedInjectedRoute,
+} from './public/integrations.js';
+import type { RouteData } from './public/internal.js';
+import type { DevToolbarAppEntry } from './public/toolbar.js';
+
+export type RedirectRouteData = RouteData & {
+ redirect: string;
+};
+
+export type SerializedRouteData = Omit<
+ RouteData,
+ 'generate' | 'pattern' | 'redirectRoute' | 'fallbackRoutes'
+> & {
+ generate: undefined;
+ pattern: string;
+ redirectRoute: SerializedRouteData | undefined;
+ fallbackRoutes: SerializedRouteData[];
+ _meta: {
+ trailingSlash: AstroConfig['trailingSlash'];
+ };
+};
+
+export interface AstroSettings {
+ config: AstroConfig;
+ adapter: AstroAdapter | undefined;
+ preferences: AstroPreferences;
+ injectedRoutes: InjectedRoute[];
+ resolvedInjectedRoutes: ResolvedInjectedRoute[];
+ pageExtensions: string[];
+ contentEntryTypes: ContentEntryType[];
+ dataEntryTypes: DataEntryType[];
+ renderers: AstroRenderer[];
+ scripts: {
+ stage: InjectedScriptStage;
+ content: string;
+ }[];
+ /**
+ * Map of directive name (e.g. `load`) to the directive script code
+ */
+ clientDirectives: Map;
+ devToolbarApps: (DevToolbarAppEntry | string)[];
+ middlewares: { pre: string[]; post: string[] };
+ tsConfig: TSConfig | undefined;
+ tsConfigPath: string | undefined;
+ watchFiles: string[];
+ timer: AstroTimer;
+ dotAstroDir: URL;
+ /**
+ * Latest version of Astro, will be undefined if:
+ * - unable to check
+ * - the user has disabled the check
+ * - the check has not completed yet
+ * - the user is on the latest version already
+ */
+ latestAstroVersion: string | undefined;
+ serverIslandMap: NonNullable;
+ serverIslandNameMap: NonNullable;
+ injectedTypes: Array;
+}
+
+/** Generic interface for a component (Astro, Svelte, React, etc.) */
+export interface ComponentInstance {
+ default: AstroComponentFactory;
+ css?: string[];
+ partial?: boolean;
+ prerender?: boolean;
+ getStaticPaths?: (options: GetStaticPathsOptions) => GetStaticPathsResult;
+}
+
+export type JSXTransformConfig = Pick<
+ babel.TransformOptions,
+ 'presets' | 'plugins' | 'inputSourceMap'
+>;
+
+export interface ManifestData {
+ routes: RouteData[];
+}
+
+export interface AstroPluginOptions {
+ settings: AstroSettings;
+ logger: Logger;
+}
diff --git a/packages/astro/src/types/public/common.ts b/packages/astro/src/types/public/common.ts
new file mode 100644
index 000000000000..4bb94f5cad5a
--- /dev/null
+++ b/packages/astro/src/types/public/common.ts
@@ -0,0 +1,176 @@
+import type { OmitIndexSignature, Simplify } from '../../type-utils.js';
+import type { APIContext } from './context.js';
+
+/**
+ * getStaticPaths() options
+ *
+ * [Astro Reference](https://docs.astro.build/en/reference/api-reference/#getstaticpaths)
+ */
+export interface GetStaticPathsOptions {
+ paginate: PaginateFunction;
+}
+
+export type GetStaticPathsItem = {
+ params: { [K in keyof Params]: Params[K] | number };
+ props?: Props;
+};
+export type GetStaticPathsResult = GetStaticPathsItem[];
+export type GetStaticPathsResultKeyed = GetStaticPathsResult & {
+ keyed: Map;
+};
+
+/**
+ * Return an array of pages to generate for a [dynamic route](https://docs.astro.build/en/guides/routing/#dynamic-routes). (**SSG Only**)
+ *
+ * [Astro Reference](https://docs.astro.build/en/reference/api-reference/#getstaticpaths)
+ */
+export type GetStaticPaths = (
+ options: GetStaticPathsOptions,
+) => Promise | GetStaticPathsResult;
+
+/**
+ * paginate() Options
+ *
+ * [Astro reference](https://docs.astro.build/en/reference/api-reference/#paginate)
+ */
+export interface PaginateOptions {
+ /** the number of items per-page (default: `10`) */
+ pageSize?: number;
+ /** key: value object of page params (ex: `{ tag: 'javascript' }`) */
+ params?: PaginateParams;
+ /** object of props to forward to `page` result */
+ props?: PaginateProps;
+}
+
+/**
+ * Represents a single page of data in a paginated collection
+ *
+ * [Astro reference](https://docs.astro.build/en/reference/api-reference/#the-pagination-page-prop)
+ */
+export interface Page {
+ /** result */
+ data: T[];
+ /** metadata */
+ /** the count of the first item on the page, starting from 0 */
+ start: number;
+ /** the count of the last item on the page, starting from 0 */
+ end: number;
+ /** total number of results */
+ total: number;
+ /** the current page number, starting from 1 */
+ currentPage: number;
+ /** number of items per page (default: 10) */
+ size: number;
+ /** number of last page */
+ lastPage: number;
+ url: {
+ /** url of the current page */
+ current: string;
+ /** url of the previous page (if there is one) */
+ prev: string | undefined;
+ /** url of the next page (if there is one) */
+ next: string | undefined;
+ /** url of the first page (if the current page is not the first page) */
+ first: string | undefined;
+ /** url of the next page (if the current page in not the last page) */
+ last: string | undefined;
+ };
+}
+
+export type PaginateFunction = <
+ PaginateData,
+ AdditionalPaginateProps extends Props,
+ AdditionalPaginateParams extends Params,
+>(
+ data: PaginateData[],
+ args?: PaginateOptions,
+) => {
+ params: Simplify<
+ {
+ page: string | undefined;
+ } & OmitIndexSignature
+ >;
+ props: Simplify<
+ {
+ page: Page;
+ } & OmitIndexSignature
+ >;
+}[];
+
+export type APIRoute<
+ Props extends Record = Record,
+ APIParams extends Record = Record,
+> = (context: APIContext) => Response | Promise;
+
+export type RewritePayload = string | URL | Request;
+
+export type MiddlewareNext = (rewritePayload?: RewritePayload) => Promise;
+export type MiddlewareHandler = (
+ context: APIContext,
+ next: MiddlewareNext,
+) => Promise | Response | Promise | void;
+
+/**
+ * Infers the shape of the `params` property returned by `getStaticPaths()`.
+ *
+ * @example
+ * ```ts
+ * import type { GetStaticPaths } from 'astro';
+ *
+ * export const getStaticPaths = (() => {
+ * return results.map((entry) => ({
+ * params: { slug: entry.slug },
+ * }));
+ * }) satisfies GetStaticPaths;
+ *
+ * type Params = InferGetStaticParamsType;
+ * // ^? { slug: string; }
+ *
+ * const { slug } = Astro.params as Params;
+ * ```
+ */
+export type InferGetStaticParamsType = T extends (
+ opts?: GetStaticPathsOptions,
+) => infer R | Promise
+ ? R extends Array
+ ? U extends { params: infer P }
+ ? P
+ : never
+ : never
+ : never;
+
+/**
+ * Infers the shape of the `props` property returned by `getStaticPaths()`.
+ *
+ * @example
+ * ```ts
+ * import type { GetStaticPaths } from 'astro';
+ *
+ * export const getStaticPaths = (() => {
+ * return results.map((entry) => ({
+ * params: { slug: entry.slug },
+ * props: {
+ * propA: true,
+ * propB: 42
+ * },
+ * }));
+ * }) satisfies GetStaticPaths;
+ *
+ * type Props = InferGetStaticPropsType;
+ * // ^? { propA: boolean; propB: number; }
+ *
+ * const { propA, propB } = Astro.props;
+ * ```
+ */
+export type InferGetStaticPropsType = T extends (
+ opts: GetStaticPathsOptions,
+) => infer R | Promise
+ ? R extends Array
+ ? U extends { props: infer P }
+ ? P
+ : never
+ : never
+ : never;
+
+export type Params = Record;
+export type Props = Record;
diff --git a/packages/astro/src/@types/astro.ts b/packages/astro/src/types/public/config.ts
similarity index 59%
rename from packages/astro/src/@types/astro.ts
rename to packages/astro/src/types/public/config.ts
index e728d386d3f4..01ea0be9a214 100644
--- a/packages/astro/src/@types/astro.ts
+++ b/packages/astro/src/types/public/config.ts
@@ -1,381 +1,38 @@
-import type {
- MarkdownHeading,
- MarkdownVFile,
- RehypePlugins,
- RemarkPlugins,
- RemarkRehype,
- ShikiConfig,
-} from '@astrojs/markdown-remark';
-import type * as babel from '@babel/core';
import type { OutgoingHttpHeaders } from 'node:http';
-import type { AddressInfo } from 'node:net';
-import type * as rollup from 'rollup';
-import type * as vite from 'vite';
-import type {
- ActionAccept,
- ActionClient,
- ActionInputSchema,
- ActionReturnType,
-} from '../actions/runtime/virtual/server.js';
-import type { RemotePattern } from '../assets/utils/remotePattern.js';
-import type { DataEntry, RenderedContent } from '../content/data-store.js';
-import type { AssetsPrefix, SSRManifest, SerializedSSRManifest } from '../core/app/types.js';
-import type { PageBuildData } from '../core/build/types.js';
-import type { AstroConfigType } from '../core/config/index.js';
-import type { AstroTimer } from '../core/config/timer.js';
-import type { TSConfig } from '../core/config/tsconfig.js';
-import type { AstroCookies } from '../core/cookies/index.js';
-import type { AstroIntegrationLogger, Logger, LoggerLevel } from '../core/logger/core.js';
-import type { EnvSchema } from '../env/schema.js';
-import type { getToolbarServerCommunicationHelpers } from '../integrations/hooks.js';
-import type { AstroPreferences } from '../preferences/index.js';
-import type {
- ToolbarAppEventTarget,
- ToolbarServerHelpers,
-} from '../runtime/client/dev-toolbar/helpers.js';
-import type { AstroDevToolbar, DevToolbarCanvas } from '../runtime/client/dev-toolbar/toolbar.js';
-import type { Icon } from '../runtime/client/dev-toolbar/ui-library/icons.js';
import type {
- DevToolbarBadge,
- DevToolbarButton,
- DevToolbarCard,
- DevToolbarHighlight,
- DevToolbarIcon,
- DevToolbarRadioCheckbox,
- DevToolbarSelect,
- DevToolbarToggle,
- DevToolbarTooltip,
- DevToolbarWindow,
-} from '../runtime/client/dev-toolbar/ui-library/index.js';
-import type { AstroComponentFactory, AstroComponentInstance } from '../runtime/server/index.js';
-import type {
- TransitionBeforePreparationEvent,
- TransitionBeforeSwapEvent,
-} from '../transitions/events.js';
-import type { DeepPartial, OmitIndexSignature, Simplify } from '../type-utils.js';
-import type { SUPPORTED_MARKDOWN_FILE_EXTENSIONS } from './../core/constants.js';
-import type { TransitionAnimationValue } from './view-transitions.js';
-
-export type { AstroIntegrationLogger, ToolbarServerHelpers };
-
-export type {
- MarkdownHeading,
RehypePlugins,
RemarkPlugins,
+ RemarkRehype,
ShikiConfig,
} from '@astrojs/markdown-remark';
-export type {
- ExternalImageService,
- ImageService,
- LocalImageService,
-} from '../assets/services/service.js';
-export type {
- GetImageResult,
- ImageInputFormat,
- ImageMetadata,
- ImageOutputFormat,
- ImageQuality,
- ImageQualityPreset,
- ImageTransform,
- UnresolvedImageTransform,
-} from '../assets/types.js';
-export type { RemotePattern } from '../assets/utils/remotePattern.js';
-export type { AssetsPrefix, SSRManifest } from '../core/app/types.js';
-export type {
- AstroCookieGetOptions,
- AstroCookieSetOptions,
- AstroCookies,
-} from '../core/cookies/index.js';
-
-export interface AstroComponentDirectives extends AstroClientDirectives {
- 'server:defer'?: boolean;
-}
-
-export interface AstroClientDirectives {
- 'client:load'?: boolean;
- 'client:idle'?: boolean;
- 'client:media'?: string;
- 'client:visible'?: ClientVisibleOptions | boolean;
- 'client:only'?: boolean | string;
-}
-
-export type ClientVisibleOptions = Pick;
-
-export interface AstroBuiltinAttributes {
- 'class:list'?:
- | Record
- | Record
- | Iterable
- | Iterable
- | string;
- 'set:html'?: any;
- 'set:text'?: any;
- 'is:raw'?: boolean;
- 'transition:animate'?: TransitionAnimationValue;
- 'transition:name'?: string;
- 'transition:persist'?: boolean | string;
-}
-
-export interface AstroDefineVarsAttribute {
- 'define:vars'?: any;
-}
-
-export interface AstroStyleAttributes {
- 'is:global'?: boolean;
- 'is:inline'?: boolean;
-}
-
-export interface AstroScriptAttributes {
- 'is:inline'?: boolean;
-}
-
-export interface AstroSlotAttributes {
- 'is:inline'?: boolean;
-}
+import type { UserConfig as OriginalViteUserConfig, SSROptions as ViteSSROptions } from 'vite';
+import type { RemotePattern } from '../../assets/utils/remotePattern.js';
+import type { AssetsPrefix } from '../../core/app/types.js';
+import type { AstroConfigType } from '../../core/config/schema.js';
+import type { Logger, LoggerLevel } from '../../core/logger/core.js';
+import type { EnvSchema } from '../../env/schema.js';
+import type { AstroIntegration, RoutePriorityOverride } from './integrations.js';
-export interface AstroComponentMetadata {
- displayName: string;
- hydrate?: 'load' | 'idle' | 'visible' | 'media' | 'only';
- hydrateArgs?: any;
- componentUrl?: string;
- componentExport?: { value: string; namespace?: boolean };
- astroStaticSlot: true;
-}
+export type Locales = (string | { codes: string[]; path: string })[];
-/** The flags supported by the Astro CLI */
-export interface CLIFlags {
- root?: string;
- site?: string;
- base?: string;
- host?: string | boolean;
- port?: number;
- config?: string;
- open?: string | boolean;
+export interface ImageServiceConfig = Record> {
+ entrypoint: 'astro/assets/services/sharp' | 'astro/assets/services/squoosh' | (string & {});
+ config?: T;
}
-/**
- * Astro global available in all contexts in .astro files
- *
- * [Astro reference](https://docs.astro.build/reference/api-reference/#astro-global)
- */
-export interface AstroGlobal<
- Props extends Record = Record,
- Self = AstroComponentFactory,
- Params extends Record = Record,
-> extends AstroGlobalPartial,
- AstroSharedContext {
- /**
- * A full URL object of the request URL.
- * Equivalent to: `new URL(Astro.request.url)`
- *
- * [Astro reference](https://docs.astro.build/en/reference/api-reference/#url)
- */
- url: AstroSharedContext['url'];
- /** Parameters passed to a dynamic page generated using [getStaticPaths](https://docs.astro.build/en/reference/api-reference/#getstaticpaths)
- *
- * Example usage:
- * ```astro
- * ---
- * export async function getStaticPaths() {
- * return [
- * { params: { id: '1' } },
- * ];
- * }
- *
- * const { id } = Astro.params;
- * ---
- * {id}
- * ```
- *
- * [Astro reference](https://docs.astro.build/en/reference/api-reference/#astroparams)
- */
- params: AstroSharedContext['params'];
- /** List of props passed to this component
- *
- * A common way to get specific props is through [destructuring](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment), ex:
- * ```typescript
- * const { name } = Astro.props
- * ```
- *
- * [Astro reference](https://docs.astro.build/en/basics/astro-components/#component-props)
- */
- props: AstroSharedContext['props'];
- /** Information about the current request. This is a standard [Request](https://developer.mozilla.org/en-US/docs/Web/API/Request) object
- *
- * For example, to get a URL object of the current URL, you can use:
- * ```typescript
- * const url = new URL(Astro.request.url);
- * ```
- *
- * [Astro reference](https://docs.astro.build/en/reference/api-reference/#astrorequest)
- */
- request: Request;
- /** Information about the outgoing response. This is a standard [ResponseInit](https://developer.mozilla.org/en-US/docs/Web/API/Response/Response#init) object
- *
- * For example, to change the status code you can set a different status on this object:
- * ```typescript
- * Astro.response.status = 404;
- * ```
- *
- * [Astro reference](https://docs.astro.build/en/reference/api-reference/#astroresponse)
- */
- response: ResponseInit & {
- readonly headers: Headers;
- };
- /**
- * Get an action result on the server when using a form POST.
- * Expects the action function as a parameter.
- * Returns a type-safe result with the action data when
- * a matching POST request is received
- * and `undefined` otherwise.
- *
- * Example usage:
- *
- * ```typescript
- * import { actions } from 'astro:actions';
- *
- * const result = await Astro.getActionResult(actions.myAction);
- * ```
- */
- getActionResult: AstroSharedContext['getActionResult'];
- /**
- * Call an Action directly from an Astro page or API endpoint.
- * Expects the action function as the first parameter,
- * and the type-safe action input as the second parameter.
- * Returns a Promise with the action result.
- *
- * Example usage:
- *
- * ```typescript
- * import { actions } from 'astro:actions';
- *
- * const result = await Astro.callAction(actions.getPost, { postId: 'test' });
- * ```
- */
- callAction: AstroSharedContext['callAction'];
- /** Redirect to another page
- *
- * Example usage:
- * ```typescript
- * if(!isLoggedIn) {
- * return Astro.redirect('/login');
- * }
- * ```
- *
- * [Astro reference](https://docs.astro.build/en/reference/api-reference/#astroredirect)
- */
- redirect: AstroSharedContext['redirect'];
- /**
- * It rewrites to another page. As opposed to redirects, the URL won't change, and Astro will render the HTML emitted
- * by the rewritten URL passed as argument.
- *
- * ## Example
- *
- * ```js
- * if (pageIsNotEnabled) {
- * return Astro.rewrite('/fallback-page')
- * }
- * ```
- */
- rewrite: AstroSharedContext['rewrite'];
- /**
- * The element allows a component to reference itself recursively.
- *
- * [Astro reference](https://docs.astro.build/en/reference/api-reference/#astroself)
- */
- self: Self;
- /** Utility functions for modifying an Astro component’s slotted children
- *
- * [Astro reference](https://docs.astro.build/en/reference/api-reference/#astroslots)
- */
- slots: Record & {
- /**
- * Check whether content for this slot name exists
- *
- * Example usage:
- * ```typescript
- * if (Astro.slots.has('default')) {
- * // Do something...
- * }
- * ```
- *
- * [Astro reference](https://docs.astro.build/en/reference/api-reference/#astroslots)
- */
- has(slotName: string): boolean;
- /**
- * Asynchronously renders this slot and returns a string
- *
- * Example usage:
- * ```astro
- * ---
- * let html: string = '';
- * if (Astro.slots.has('default')) {
- * html = await Astro.slots.render('default')
- * }
- * ---
- *
- * ```
- *
- * A second parameter can be used to pass arguments to a slotted callback
- *
- * Example usage:
- * ```astro
- * ---
- * html = await Astro.slots.render('default', ["Hello", "World"])
- * ---
- * ```
- * Each item in the array will be passed as an argument that you can use like so:
- * ```astro
- *
- * {(hello, world) => {hello}, {world}!
}
- *
- * ```
- *
- * [Astro reference](https://docs.astro.build/en/reference/api-reference/#astroslots)
- */
- render(slotName: string, args?: any[]): Promise;
- };
-}
+export type RuntimeMode = 'development' | 'production';
-/** Union type of supported markdown file extensions */
-type MarkdowFileExtension = (typeof SUPPORTED_MARKDOWN_FILE_EXTENSIONS)[number];
+export type ValidRedirectStatus = 300 | 301 | 302 | 303 | 304 | 307 | 308;
-export interface AstroGlobalPartial {
- /**
- * Fetch local files into your static site setup
- *
- * Example usage:
- * ```typescript
- * const posts = await Astro.glob('../pages/post/*.md');
- * ```
- *
- * [Astro reference](https://docs.astro.build/en/reference/api-reference/#astroglob)
- */
- glob(globStr: `${any}.astro`): Promise;
- glob>(
- globStr: `${any}${MarkdowFileExtension}`,
- ): Promise[]>;
- glob>(globStr: `${any}.mdx`): Promise[]>;
- glob>(globStr: string): Promise;
- /**
- * Returns a [URL](https://developer.mozilla.org/en-US/docs/Web/API/URL) object built from the [site](https://docs.astro.build/en/reference/configuration-reference/#site) config option
- *
- * [Astro reference](https://docs.astro.build/en/reference/api-reference/#astrosite)
- */
- site: URL | undefined;
- /**
- * Returns a string with the current version of Astro.
- *
- * Useful for using `` or crediting Astro in a site footer.
- *
- * [HTML Specification for `generator`](https://html.spec.whatwg.org/multipage/semantics.html#meta-generator)
- *
- * [Astro reference](https://docs.astro.build/en/reference/api-reference/#astrogenerator)
- */
- generator: string;
-}
+export type RedirectConfig =
+ | string
+ | {
+ status: ValidRedirectStatus;
+ destination: string;
+ priority?: RoutePriorityOverride;
+ };
-type ServerConfig = {
+export type ServerConfig = {
/**
* @name server.host
* @type {string | boolean}
@@ -429,14 +86,18 @@ type ServerConfig = {
open?: string | boolean;
};
-export interface ViteUserConfig extends vite.UserConfig {
- ssr?: vite.SSROptions;
+export interface ViteUserConfig extends OriginalViteUserConfig {
+ ssr?: ViteSSROptions;
}
-export interface ImageServiceConfig = Record> {
- entrypoint: 'astro/assets/services/sharp' | 'astro/assets/services/squoosh' | (string & {});
- config?: T;
-}
+// NOTE(fks): We choose to keep our hand-generated AstroUserConfig interface so that
+// we can add JSDoc-style documentation and link to the definition file in our repo.
+// However, Zod comes with the ability to auto-generate AstroConfig from the schema
+// above. If we ever get to the point where we no longer need the dedicated
+// @types/config.ts file, consider replacing it with the following lines:
+//
+// export interface AstroUserConfig extends z.input {
+// }
/**
* Astro User Config
@@ -2380,58 +2041,6 @@ export interface AstroUserConfig {
};
}
-// NOTE(fks): We choose to keep our hand-generated AstroUserConfig interface so that
-// we can add JSDoc-style documentation and link to the definition file in our repo.
-// However, Zod comes with the ability to auto-generate AstroConfig from the schema
-// above. If we ever get to the point where we no longer need the dedicated
-// @types/config.ts file, consider replacing it with the following lines:
-//
-// export interface AstroUserConfig extends z.input {
-// }
-
-/**
- * IDs for different stages of JS script injection:
- * - "before-hydration": Imported client-side, before the hydration script runs. Processed & resolved by Vite.
- * - "head-inline": Injected into a script tag in the `` of every page. Not processed or resolved by Vite.
- * - "page": Injected into the JavaScript bundle of every page. Processed & resolved by Vite.
- * - "page-ssr": Injected into the frontmatter of every Astro page. Processed & resolved by Vite.
- */
-export type InjectedScriptStage = 'before-hydration' | 'head-inline' | 'page' | 'page-ssr';
-
-/**
- * IDs for different priorities of injected routes and redirects:
- * - "normal": Merge with discovered file-based project routes, behaving the same as if the route
- * was defined as a file in the project.
- * - "legacy": Use the old ordering of routes. Inject routes will override any file-based project route,
- * and redirects will be overridden by any project route on conflict.
- */
-export type RoutePriorityOverride = 'normal' | 'legacy';
-
-export interface InjectedRoute {
- pattern: string;
- entrypoint: string;
- prerender?: boolean;
-}
-
-export interface ResolvedInjectedRoute extends InjectedRoute {
- resolvedEntryPoint?: URL;
-}
-
-export interface RouteOptions {
- /**
- * The path to this route relative to the project root. The slash is normalized as forward slash
- * across all OS.
- * @example "src/pages/blog/[...slug].astro"
- */
- readonly component: string;
- /**
- * Whether this route should be prerendered. If the route has an explicit `prerender` export,
- * the value will be passed here. Otherwise, it's undefined and will fallback to a prerender
- * default depending on the `output` option.
- */
- prerender?: boolean;
-}
-
/**
* Resolved Astro Config
* Config with user settings along with all defaults filled in.
@@ -2483,1220 +2092,10 @@ export interface AstroInlineOnlyConfig {
logger?: Logger;
}
-export type ContentEntryModule = {
- id: string;
- collection: string;
- slug: string;
- body: string;
- data: Record;
- _internal: {
- rawData: string;
- filePath: string;
- };
-};
-
-export type DataEntryModule = {
- id: string;
- collection: string;
- data: Record;
- _internal: {
- rawData: string;
- filePath: string;
- };
-};
-
-export type ContentEntryRenderFuction = (entry: DataEntry) => Promise;
-
-export interface ContentEntryType {
- extensions: string[];
- getEntryInfo(params: {
- fileUrl: URL;
- contents: string;
- }): GetContentEntryInfoReturnType | Promise;
- getRenderModule?(
- this: rollup.PluginContext,
- params: {
- contents: string;
- fileUrl: URL;
- viteId: string;
- },
- ): rollup.LoadResult | Promise;
- contentModuleTypes?: string;
- getRenderFunction?(settings: AstroSettings): Promise;
-
- /**
- * Handle asset propagation for rendered content to avoid bleed.
- * Ex. MDX content can import styles and scripts, so `handlePropagation` should be true.
- * @default true
- */
- handlePropagation?: boolean;
-}
-
-type GetContentEntryInfoReturnType = {
- data: Record;
- /**
- * Used for error hints to point to correct line and location
- * Should be the untouched data as read from the file,
- * including newlines
- */
- rawData: string;
- body: string;
- slug: string;
-};
-
-export interface DataEntryType {
- extensions: string[];
- getEntryInfo(params: {
- fileUrl: URL;
- contents: string;
- }): GetDataEntryInfoReturnType | Promise;
-}
-
-export type GetDataEntryInfoReturnType = { data: Record; rawData?: string };
-
-export interface AstroAdapterFeatures {
- /**
- * Creates an edge function that will communiate with the Astro middleware
- */
- edgeMiddleware: boolean;
- /**
- * SSR only. Each route becomes its own function/file.
- */
- functionPerRoute: boolean;
-}
-
-export interface InjectedType {
- filename: string;
- content: string;
-}
-
-export interface AstroSettings {
- config: AstroConfig;
- adapter: AstroAdapter | undefined;
- preferences: AstroPreferences;
- injectedRoutes: InjectedRoute[];
- resolvedInjectedRoutes: ResolvedInjectedRoute[];
- pageExtensions: string[];
- contentEntryTypes: ContentEntryType[];
- dataEntryTypes: DataEntryType[];
- renderers: AstroRenderer[];
- scripts: {
- stage: InjectedScriptStage;
- content: string;
- }[];
- /**
- * Map of directive name (e.g. `load`) to the directive script code
- */
- clientDirectives: Map;
- devToolbarApps: (DevToolbarAppEntry | string)[];
- middlewares: { pre: string[]; post: string[] };
- tsConfig: TSConfig | undefined;
- tsConfigPath: string | undefined;
- watchFiles: string[];
- timer: AstroTimer;
- dotAstroDir: URL;
- /**
- * Latest version of Astro, will be undefined if:
- * - unable to check
- * - the user has disabled the check
- * - the check has not completed yet
- * - the user is on the latest version already
- */
- latestAstroVersion: string | undefined;
- serverIslandMap: NonNullable;
- serverIslandNameMap: NonNullable;
- injectedTypes: Array;
-}
-
-export type AsyncRendererComponentFn = (
- Component: any,
- props: any,
- slots: Record,
- metadata?: AstroComponentMetadata,
-) => Promise;
-
-/** Generic interface for a component (Astro, Svelte, React, etc.) */
-export interface ComponentInstance {
- default: AstroComponentFactory;
- css?: string[];
- partial?: boolean;
- prerender?: boolean;
- getStaticPaths?: (options: GetStaticPathsOptions) => GetStaticPathsResult;
-}
-
-export interface AstroInstance {
- file: string;
- url: string | undefined;
- default: AstroComponentFactory;
-}
-
-export interface MarkdownInstance> {
- frontmatter: T;
- /** Absolute file path (e.g. `/home/user/projects/.../file.md`) */
- file: string;
- /** Browser URL for files under `/src/pages` (e.g. `/en/guides/markdown-content`) */
- url: string | undefined;
- /** Component to render content in `.astro` files. Usage: `` */
- Content: AstroComponentFactory;
- /** raw Markdown file content, excluding layout HTML and YAML frontmatter */
- rawContent(): string;
- /** Markdown file compiled to HTML, excluding layout HTML */
- compiledContent(): string;
- /** List of headings (h1 -> h6) with associated metadata */
- getHeadings(): MarkdownHeading[];
- default: AstroComponentFactory;
-}
-
-type MD = MarkdownInstance>;
-
-export type MDXInstance> = Omit<
- MarkdownInstance,
- 'rawContent' | 'compiledContent'
->;
-
-export interface MarkdownLayoutProps> {
- frontmatter: {
- file: MarkdownInstance['file'];
- url: MarkdownInstance['url'];
- } & T;
- file: MarkdownInstance['file'];
- url: MarkdownInstance['url'];
- headings: MarkdownHeading[];
- rawContent: MarkdownInstance['rawContent'];
- compiledContent: MarkdownInstance['compiledContent'];
-}
-
-export type MDXLayoutProps> = Omit<
- MarkdownLayoutProps,
- 'rawContent' | 'compiledContent'
->;
-
-export type GetHydrateCallback = () => Promise<() => void | Promise>;
-
-/**
- * getStaticPaths() options
- *
- * [Astro Reference](https://docs.astro.build/en/reference/api-reference/#getstaticpaths)
- */
-export interface GetStaticPathsOptions {
- paginate: PaginateFunction;
-}
-
-export type GetStaticPathsItem = {
- params: { [K in keyof Params]: Params[K] | number };
- props?: Props;
-};
-export type GetStaticPathsResult = GetStaticPathsItem[];
-export type GetStaticPathsResultKeyed = GetStaticPathsResult & {
- keyed: Map;
-};
-
-/**
- * Return an array of pages to generate for a [dynamic route](https://docs.astro.build/en/guides/routing/#dynamic-routes). (**SSG Only**)
- *
- * [Astro Reference](https://docs.astro.build/en/reference/api-reference/#getstaticpaths)
- */
-export type GetStaticPaths = (
- options: GetStaticPathsOptions,
-) => Promise | GetStaticPathsResult;
-
-/**
- * Infers the shape of the `params` property returned by `getStaticPaths()`.
- *
- * @example
- * ```ts
- * import type { GetStaticPaths } from 'astro';
- *
- * export const getStaticPaths = (() => {
- * return results.map((entry) => ({
- * params: { slug: entry.slug },
- * }));
- * }) satisfies GetStaticPaths;
- *
- * type Params = InferGetStaticParamsType;
- * // ^? { slug: string; }
- *
- * const { slug } = Astro.params as Params;
- * ```
- */
-export type InferGetStaticParamsType = T extends (
- opts?: GetStaticPathsOptions,
-) => infer R | Promise
- ? R extends Array
- ? U extends { params: infer P }
- ? P
- : never
- : never
- : never;
-
-/**
- * Infers the shape of the `props` property returned by `getStaticPaths()`.
- *
- * @example
- * ```ts
- * import type { GetStaticPaths } from 'astro';
- *
- * export const getStaticPaths = (() => {
- * return results.map((entry) => ({
- * params: { slug: entry.slug },
- * props: {
- * propA: true,
- * propB: 42
- * },
- * }));
- * }) satisfies GetStaticPaths;
- *
- * type Props = InferGetStaticPropsType;
- * // ^? { propA: boolean; propB: number; }
- *
- * const { propA, propB } = Astro.props;
- * ```
- */
-export type InferGetStaticPropsType = T extends (
- opts: GetStaticPathsOptions,
-) => infer R | Promise
- ? R extends Array
- ? U extends { props: infer P }
- ? P
- : never
- : never
- : never;
-
-export interface HydrateOptions {
- name: string;
- value?: string;
-}
-
-export type JSXTransformConfig = Pick<
- babel.TransformOptions,
- 'presets' | 'plugins' | 'inputSourceMap'
->;
-
-export type JSXTransformFn = (options: {
- mode: string;
- ssr: boolean;
-}) => Promise;
-
-export interface ManifestData {
- routes: RouteData[];
-}
-
-/** @deprecated Type is no longer used by exported APIs */
-export interface MarkdownMetadata {
- headings: MarkdownHeading[];
- source: string;
- html: string;
-}
-
-/** @deprecated Type is no longer used by exported APIs */
-export interface MarkdownRenderingResult {
- metadata: MarkdownMetadata;
- vfile: MarkdownVFile;
- code: string;
-}
-
-/** @deprecated Type is no longer used by exported APIs */
-export interface MarkdownParserResponse extends MarkdownRenderingResult {
- frontmatter: MD['frontmatter'];
-}
-
-/**
- * The `content` prop given to a Layout
- *
- * [Astro reference](https://docs.astro.build/en/guides/markdown-content/#markdown-layouts)
- */
-export type MarkdownContent = Record> = T & {
- astro: MarkdownMetadata;
- url: string | undefined;
- file: string;
-};
-
-/**
- * paginate() Options
- *
- * [Astro reference](https://docs.astro.build/en/reference/api-reference/#paginate)
- */
-export interface PaginateOptions {
- /** the number of items per-page (default: `10`) */
- pageSize?: number;
- /** key: value object of page params (ex: `{ tag: 'javascript' }`) */
- params?: PaginateParams;
- /** object of props to forward to `page` result */
- props?: PaginateProps;
-}
-
-/**
- * Represents a single page of data in a paginated collection
- *
- * [Astro reference](https://docs.astro.build/en/reference/api-reference/#the-pagination-page-prop)
- */
-export interface Page {
- /** result */
- data: T[];
- /** metadata */
- /** the count of the first item on the page, starting from 0 */
- start: number;
- /** the count of the last item on the page, starting from 0 */
- end: number;
- /** total number of results */
- total: number;
- /** the current page number, starting from 1 */
- currentPage: number;
- /** number of items per page (default: 10) */
- size: number;
- /** number of last page */
- lastPage: number;
- url: {
- /** url of the current page */
- current: string;
- /** url of the previous page (if there is one) */
- prev: string | undefined;
- /** url of the next page (if there is one) */
- next: string | undefined;
- /** url of the first page (if the current page is not the first page) */
- first: string | undefined;
- /** url of the next page (if the current page in not the last page) */
- last: string | undefined;
- };
+// HACK! astro:db augment this type that is used in the config
+declare global {
+ // eslint-disable-next-line @typescript-eslint/no-namespace
+ namespace Config {
+ type Database = Record;
+ }
}
-
-export type PaginateFunction = <
- PaginateData,
- AdditionalPaginateProps extends Props,
- AdditionalPaginateParams extends Params,
->(
- data: PaginateData[],
- args?: PaginateOptions,
-) => {
- params: Simplify<
- {
- page: string | undefined;
- } & OmitIndexSignature
- >;
- props: Simplify<
- {
- page: Page;
- } & OmitIndexSignature
- >;
-}[];
-
-export type Params = Record;
-
-export type SupportsKind = 'unsupported' | 'stable' | 'experimental' | 'deprecated';
-
-export type AstroFeatureMap = {
- /**
- * The adapter is able serve static pages
- */
- staticOutput?: SupportsKind;
- /**
- * The adapter is able to serve pages that are static or rendered via server
- */
- hybridOutput?: SupportsKind;
- /**
- * The adapter is able to serve SSR pages
- */
- serverOutput?: SupportsKind;
- /**
- * The adapter can emit static assets
- */
- assets?: AstroAssetsFeature;
-
- /**
- * List of features that orbit around the i18n routing
- */
- i18nDomains?: SupportsKind;
-
- /**
- * The adapter is able to support `getSecret` exported from `astro:env/server`
- */
- envGetSecret?: SupportsKind;
-};
-
-export interface AstroAssetsFeature {
- supportKind?: SupportsKind;
- /**
- * Whether if this adapter deploys files in an environment that is compatible with the library `sharp`
- */
- isSharpCompatible?: boolean;
- /**
- * Whether if this adapter deploys files in an environment that is compatible with the library `squoosh`
- */
- isSquooshCompatible?: boolean;
-}
-
-export interface AstroInternationalizationFeature {
- /**
- * The adapter should be able to create the proper redirects
- */
- domains?: SupportsKind;
-}
-
-export type Locales = (string | { codes: string[]; path: string })[];
-
-export interface AstroAdapter {
- name: string;
- serverEntrypoint?: string;
- previewEntrypoint?: string;
- exports?: string[];
- args?: any;
- adapterFeatures?: AstroAdapterFeatures;
- /**
- * List of features supported by an adapter.
- *
- * If the adapter is not able to handle certain configurations, Astro will throw an error.
- */
- supportedAstroFeatures: AstroFeatureMap;
-}
-
-export type ValidRedirectStatus = 300 | 301 | 302 | 303 | 304 | 307 | 308;
-
-// Shared types between `Astro` global and API context object
-interface AstroSharedContext<
- Props extends Record = Record,
- RouteParams extends Record = Record,
-> {
- /**
- * The address (usually IP address) of the user.
- *
- * Throws an error if used within a static site, or within a prerendered page.
- */
- clientAddress: string;
- /**
- * Utility for getting and setting the values of cookies.
- */
- cookies: AstroCookies;
- /**
- * Information about the current request. This is a standard [Request](https://developer.mozilla.org/en-US/docs/Web/API/Request) object
- */
- request: Request;
- /**
- * A full URL object of the request URL.
- */
- url: URL;
- /**
- * Get action result on the server when using a form POST.
- */
- getActionResult: <
- TAccept extends ActionAccept,
- TInputSchema extends ActionInputSchema,
- TAction extends ActionClient,
- >(
- action: TAction,
- ) => ActionReturnType | undefined;
- /**
- * Call action handler from the server.
- */
- callAction: <
- TAccept extends ActionAccept,
- TInputSchema extends ActionInputSchema,
- TOutput,
- TAction extends
- | ActionClient
- | ActionClient['orThrow'],
- >(
- action: TAction,
- input: Parameters[0],
- ) => Promise>;
- /**
- * Route parameters for this request if this is a dynamic route.
- */
- params: RouteParams;
- /**
- * List of props returned for this path by `getStaticPaths` (**Static Only**).
- */
- props: Props;
- /**
- * Redirect to another page (**SSR Only**).
- */
- redirect(path: string, status?: ValidRedirectStatus): Response;
-
- /**
- * It rewrites to another page. As opposed to redirects, the URL won't change, and Astro will render the HTML emitted
- * by the rerouted URL passed as argument.
- *
- * ## Example
- *
- * ```js
- * if (pageIsNotEnabled) {
- * return Astro.rewrite('/fallback-page')
- * }
- * ```
- */
- rewrite(rewritePayload: RewritePayload): Promise;
-
- /**
- * Object accessed via Astro middleware
- */
- locals: App.Locals;
-
- /**
- * The current locale that is computed from the `Accept-Language` header of the browser (**SSR Only**).
- */
- preferredLocale: string | undefined;
-
- /**
- * The list of locales computed from the `Accept-Language` header of the browser, sorted by quality value (**SSR Only**).
- */
-
- preferredLocaleList: string[] | undefined;
-
- /**
- * The current locale computed from the URL of the request. It matches the locales in `i18n.locales`, and returns `undefined` otherwise.
- */
- currentLocale: string | undefined;
-}
-
-/**
- * The `APIContext` is the object made available to endpoints and middleware.
- * It is a subset of the `Astro` global object available in pages.
- *
- * [Reference](https://docs.astro.build/en/reference/api-reference/#endpoint-context)
- */
-export interface APIContext<
- Props extends Record = Record,
- APIParams extends Record = Record,
-> extends AstroSharedContext {
- /**
- * The site provided in the astro config, parsed as an instance of `URL`, without base.
- * `undefined` if the site is not provided in the config.
- */
- site: URL | undefined;
- /**
- * A human-readable string representing the Astro version used to create the project.
- * For example, `"Astro v1.1.1"`.
- */
- generator: string;
- /**
- * The url of the current request, parsed as an instance of `URL`.
- *
- * Equivalent to:
- * ```ts
- * new URL(context.request.url)
- * ```
- */
- url: AstroSharedContext['url'];
- /**
- * Parameters matching the page’s dynamic route pattern.
- * In static builds, this will be the `params` generated by `getStaticPaths`.
- * In SSR builds, this can be any path segments matching the dynamic route pattern.
- *
- * Example usage:
- * ```ts
- * import type { APIContext } from "astro"
- *
- * export function getStaticPaths() {
- * return [
- * { params: { id: '0' }, props: { name: 'Sarah' } },
- * { params: { id: '1' }, props: { name: 'Chris' } },
- * { params: { id: '2' }, props: { name: 'Fuzzy' } },
- * ];
- * }
- *
- * export async function GET({ params }: APIContext) {
- * return new Response(`Hello user ${params.id}!`)
- * }
- * ```
- *
- * [Reference](https://docs.astro.build/en/reference/api-reference/#contextparams)
- */
- params: AstroSharedContext['params'];
- /**
- * List of props passed from `getStaticPaths`. Only available to static builds.
- *
- * Example usage:
- * ```ts
- * import type { APIContext } from "astro"
- *
- * export function getStaticPaths() {
- * return [
- * { params: { id: '0' }, props: { name: 'Sarah' } },
- * { params: { id: '1' }, props: { name: 'Chris' } },
- * { params: { id: '2' }, props: { name: 'Fuzzy' } },
- * ];
- * }
- *
- * export function GET({ props }: APIContext): Response {
- * return new Response(`Hello ${props.name}!`);
- * }
- * ```
- *
- * [Reference](https://docs.astro.build/en/reference/api-reference/#contextprops)
- */
- props: AstroSharedContext['props'];
- /**
- * Create a response that redirects to another page.
- *
- * Example usage:
- * ```ts
- * // src/pages/secret.ts
- * export function GET({ redirect }) {
- * return redirect('/login');
- * }
- * ```
- *
- * [Reference](https://docs.astro.build/en/guides/api-reference/#contextredirect)
- */
- redirect: AstroSharedContext['redirect'];
-
- /**
- * It reroutes to another page. As opposed to redirects, the URL won't change, and Astro will render the HTML emitted
- * by the rerouted URL passed as argument.
- *
- * ## Example
- *
- * ```ts
- * // src/pages/secret.ts
- * export function GET(ctx) {
- * return ctx.rewrite(new URL("../"), ctx.url);
- * }
- * ```
- */
- rewrite: AstroSharedContext['rewrite'];
-
- /**
- * An object that middlewares can use to store extra information related to the request.
- *
- * It will be made available to pages as `Astro.locals`, and to endpoints as `context.locals`.
- *
- * Example usage:
- *
- * ```ts
- * // src/middleware.ts
- * import { defineMiddleware } from "astro:middleware";
- *
- * export const onRequest = defineMiddleware((context, next) => {
- * context.locals.greeting = "Hello!";
- * return next();
- * });
- * ```
- * Inside a `.astro` file:
- * ```astro
- * ---
- * // src/pages/index.astro
- * const greeting = Astro.locals.greeting;
- * ---
- * {greeting}
- * ```
- *
- * [Reference](https://docs.astro.build/en/reference/api-reference/#contextlocals)
- */
- locals: App.Locals;
-
- /**
- * Available only when `i18n` configured and in SSR.
- *
- * It represents the preferred locale of the user. It's computed by checking the supported locales in `i18n.locales`
- * and locales supported by the users's browser via the header `Accept-Language`
- *
- * For example, given `i18n.locales` equals to `['fr', 'de']`, and the `Accept-Language` value equals to `en, de;q=0.2, fr;q=0.6`, the
- * `Astro.preferredLanguage` will be `fr` because `en` is not supported, its [quality value] is the highest.
- *
- * [quality value]: https://developer.mozilla.org/en-US/docs/Glossary/Quality_values
- */
- preferredLocale: string | undefined;
-
- /**
- * Available only when `i18n` configured and in SSR.
- *
- * It represents the list of the preferred locales that are supported by the application. The list is sorted via [quality value].
- *
- * For example, given `i18n.locales` equals to `['fr', 'pt', 'de']`, and the `Accept-Language` value equals to `en, de;q=0.2, fr;q=0.6`, the
- * `Astro.preferredLocaleList` will be equal to `['fs', 'de']` because `en` isn't supported, and `pt` isn't part of the locales contained in the
- * header.
- *
- * When the `Accept-Header` is `*`, the original `i18n.locales` are returned. The value `*` means no preferences, so Astro returns all the supported locales.
- *
- * [quality value]: https://developer.mozilla.org/en-US/docs/Glossary/Quality_values
- */
- preferredLocaleList: string[] | undefined;
-
- /**
- * The current locale computed from the URL of the request. It matches the locales in `i18n.locales`, and returns `undefined` otherwise.
- */
- currentLocale: string | undefined;
-}
-
-export type APIRoute<
- Props extends Record = Record,
- APIParams extends Record = Record,
-> = (context: APIContext) => Response | Promise;
-
-export interface EndpointHandler {
- [method: string]: APIRoute;
-}
-
-export type Props = Record;
-
-export interface AstroRenderer {
- /** Name of the renderer. */
- name: string;
- /** Import entrypoint for the client/browser renderer. */
- clientEntrypoint?: string;
- /** Import entrypoint for the server/build/ssr renderer. */
- serverEntrypoint: string;
- /** @deprecated Vite plugins should transform the JSX instead */
- jsxImportSource?: string;
- /** @deprecated Vite plugins should transform the JSX instead */
- jsxTransformOptions?: JSXTransformFn;
-}
-
-export interface NamedSSRLoadedRendererValue extends SSRLoadedRendererValue {
- name: string;
-}
-
-export interface SSRLoadedRendererValue {
- name?: string;
- check: AsyncRendererComponentFn;
- renderToStaticMarkup: AsyncRendererComponentFn<{
- html: string;
- attrs?: Record;
- }>;
- supportsAstroStaticSlot?: boolean;
- /**
- * If provided, Astro will call this function and inject the returned
- * script in the HTML before the first component handled by this renderer.
- *
- * This feature is needed by some renderers (in particular, by Solid). The
- * Solid official hydration script sets up a page-level data structure.
- * It is mainly used to transfer data between the server side render phase
- * and the browser application state. Solid Components rendered later in
- * the HTML may inject tiny scripts into the HTML that call into this
- * page-level data structure.
- */
- renderHydrationScript?: () => string;
-}
-
-export interface SSRLoadedRenderer extends Pick {
- ssr: SSRLoadedRendererValue;
-}
-
-export type HookParameters<
- Hook extends keyof AstroIntegration['hooks'],
- Fn = AstroIntegration['hooks'][Hook],
-> = Fn extends (...args: any) => any ? Parameters[0] : never;
-
-export interface BaseIntegrationHooks {
- 'astro:config:setup': (options: {
- config: AstroConfig;
- command: 'dev' | 'build' | 'preview';
- isRestart: boolean;
- updateConfig: (newConfig: DeepPartial) => AstroConfig;
- addRenderer: (renderer: AstroRenderer) => void;
- addWatchFile: (path: URL | string) => void;
- injectScript: (stage: InjectedScriptStage, content: string) => void;
- injectRoute: (injectRoute: InjectedRoute) => void;
- addClientDirective: (directive: ClientDirectiveConfig) => void;
- // TODO: Deprecate the `string` overload once a few apps have been migrated to the new API.
- addDevToolbarApp: (entrypoint: DevToolbarAppEntry | string) => void;
- addMiddleware: (mid: AstroIntegrationMiddleware) => void;
- logger: AstroIntegrationLogger;
- // TODO: Add support for `injectElement()` for full HTML element injection, not just scripts.
- // This may require some refactoring of `scripts`, `styles`, and `links` into something
- // more generalized. Consider the SSR use-case as well.
- // injectElement: (stage: vite.HtmlTagDescriptor, element: string) => void;
- }) => void | Promise;
- 'astro:config:done': (options: {
- config: AstroConfig;
- setAdapter: (adapter: AstroAdapter) => void;
- injectTypes: (injectedType: InjectedType) => URL;
- logger: AstroIntegrationLogger;
- }) => void | Promise;
- 'astro:server:setup': (options: {
- server: vite.ViteDevServer;
- logger: AstroIntegrationLogger;
- toolbar: ReturnType;
- }) => void | Promise;
- 'astro:server:start': (options: {
- address: AddressInfo;
- logger: AstroIntegrationLogger;
- }) => void | Promise;
- 'astro:server:done': (options: { logger: AstroIntegrationLogger }) => void | Promise;
- 'astro:build:ssr': (options: {
- manifest: SerializedSSRManifest;
- /**
- * This maps a {@link RouteData} to an {@link URL}, this URL represents
- * the physical file you should import.
- */
- entryPoints: Map;
- /**
- * File path of the emitted middleware
- */
- middlewareEntryPoint: URL | undefined;
- logger: AstroIntegrationLogger;
- }) => void | Promise;
- 'astro:build:start': (options: { logger: AstroIntegrationLogger }) => void | Promise;
- 'astro:build:setup': (options: {
- vite: vite.InlineConfig;
- pages: Map;
- target: 'client' | 'server';
- updateConfig: (newConfig: vite.InlineConfig) => void;
- logger: AstroIntegrationLogger;
- }) => void | Promise;
- 'astro:build:generated': (options: {
- dir: URL;
- logger: AstroIntegrationLogger;
- }) => void | Promise;
- 'astro:build:done': (options: {
- pages: { pathname: string }[];
- dir: URL;
- routes: RouteData[];
- logger: AstroIntegrationLogger;
- cacheManifest: boolean;
- }) => void | Promise;
- 'astro:route:setup': (options: {
- route: RouteOptions;
- logger: AstroIntegrationLogger;
- }) => void | Promise;
-}
-
-export interface AstroIntegration {
- /** The name of the integration. */
- name: string;
- /** The different hooks available to extend. */
- hooks: {
- [K in keyof Astro.IntegrationHooks]?: Astro.IntegrationHooks[K];
- } & Partial>;
-}
-
-export type RewritePayload = string | URL | Request;
-
-export type MiddlewareNext = (rewritePayload?: RewritePayload) => Promise;
-export type MiddlewareHandler = (
- context: APIContext,
- next: MiddlewareNext,
-) => Promise | Response | Promise | void;
-
-// NOTE: when updating this file with other functions,
-// remember to update `plugin-page.ts` too, to add that function as a no-op function.
-export type AstroMiddlewareInstance = {
- onRequest?: MiddlewareHandler;
-};
-
-export type AstroIntegrationMiddleware = {
- order: 'pre' | 'post';
- entrypoint: string;
-};
-
-export interface AstroPluginOptions {
- settings: AstroSettings;
- logger: Logger;
-}
-
-/**
- * - page: a route that lives in the file system, usually an Astro component
- * - endpoint: a route that lives in the file system, usually a JS file that exposes endpoints methods
- * - redirect: a route points to another route that lives in the file system
- * - fallback: a route that doesn't exist in the file system that needs to be handled with other means, usually the middleware
- */
-export type RouteType = 'page' | 'endpoint' | 'redirect' | 'fallback';
-
-export interface RoutePart {
- content: string;
- dynamic: boolean;
- spread: boolean;
-}
-
-type RedirectConfig =
- | string
- | {
- status: ValidRedirectStatus;
- destination: string;
- priority?: RoutePriorityOverride;
- };
-
-export interface RouteData {
- route: string;
- component: string;
- generate: (data?: any) => string;
- params: string[];
- pathname?: string;
- // expose the real path name on SSG
- distURL?: URL;
- pattern: RegExp;
- segments: RoutePart[][];
- type: RouteType;
- prerender: boolean;
- redirect?: RedirectConfig;
- redirectRoute?: RouteData;
- fallbackRoutes: RouteData[];
- isIndex: boolean;
-}
-
-export type RedirectRouteData = RouteData & {
- redirect: string;
-};
-
-export type SerializedRouteData = Omit<
- RouteData,
- 'generate' | 'pattern' | 'redirectRoute' | 'fallbackRoutes'
-> & {
- generate: undefined;
- pattern: string;
- redirectRoute: SerializedRouteData | undefined;
- fallbackRoutes: SerializedRouteData[];
- _meta: {
- trailingSlash: AstroConfig['trailingSlash'];
- };
-};
-
-export type RuntimeMode = 'development' | 'production';
-
-export type SSRError = Error & vite.ErrorPayload['err'];
-
-export interface SSRElement {
- props: Record;
- children: string;
-}
-
-/**
- * A hint on whether the Astro runtime needs to wait on a component to render head
- * content. The meanings:
- *
- * - __none__ (default) The component does not propagation head content.
- * - __self__ The component appends head content.
- * - __in-tree__ Another component within this component's dependency tree appends head content.
- *
- * These are used within the runtime to know whether or not a component should be waited on.
- */
-export type PropagationHint = 'none' | 'self' | 'in-tree';
-
-export type SSRComponentMetadata = {
- propagation: PropagationHint;
- containsHead: boolean;
-};
-
-export interface SSRResult {
- /**
- * Whether the page has failed with a non-recoverable error, or the client disconnected.
- */
- cancelled: boolean;
- base: string;
- styles: Set;
- scripts: Set;
- links: Set;
- componentMetadata: Map;
- inlinedScripts: Map;
- createAstro(
- Astro: AstroGlobalPartial,
- props: Record,
- slots: Record | null,
- ): AstroGlobal;
- params: Params;
- resolve: (s: string) => Promise;
- response: AstroGlobal['response'];
- request: AstroGlobal['request'];
- actionResult?: ReturnType;
- renderers: SSRLoadedRenderer[];
- /**
- * Map of directive name (e.g. `load`) to the directive script code
- */
- clientDirectives: Map;
- compressHTML: boolean;
- partial: boolean;
- /**
- * Only used for logging
- */
- pathname: string;
- cookies: AstroCookies | undefined;
- serverIslandNameMap: Map;
- trailingSlash: AstroConfig['trailingSlash'];
- key: Promise;
- _metadata: SSRMetadata;
-}
-
-/**
- * Ephemeral and mutable state during rendering that doesn't rely
- * on external configuration
- */
-export interface SSRMetadata {
- hasHydrationScript: boolean;
- /**
- * Names of renderers that have injected their hydration scripts
- * into the current page. For example, Solid SSR needs a hydration
- * script in the page HTML before the first Solid component.
- */
- rendererSpecificHydrationScripts: Set;
- /**
- * Used by `renderScript` to track script ids that have been rendered,
- * so we only render each once.
- */
- renderedScripts: Set;
- hasDirectives: Set;
- hasRenderedHead: boolean;
- headInTree: boolean;
- extraHead: string[];
- propagators: Set;
-}
-
-/* Preview server stuff */
-export interface PreviewServer {
- host?: string;
- port: number;
- closed(): Promise;
- stop(): Promise;
-}
-
-export interface PreviewServerParams {
- outDir: URL;
- client: URL;
- serverEntrypoint: URL;
- host: string | undefined;
- port: number;
- base: string;
- logger: AstroIntegrationLogger;
- headers?: OutgoingHttpHeaders;
-}
-
-export type CreatePreviewServer = (
- params: PreviewServerParams,
-) => PreviewServer | Promise;
-
-export interface PreviewModule {
- default: CreatePreviewServer;
-}
-
-/* Client Directives */
-type DirectiveHydrate = () => Promise;
-type DirectiveLoad = () => Promise;
-
-type DirectiveOptions = {
- /**
- * The component displayName
- */
- name: string;
- /**
- * The attribute value provided
- */
- value: string;
-};
-
-export type ClientDirective = (
- load: DirectiveLoad,
- options: DirectiveOptions,
- el: HTMLElement,
-) => void;
-
-export interface ClientDirectiveConfig {
- name: string;
- entrypoint: string;
-}
-
-type DevToolbarAppMeta = {
- id: string;
- name: string;
- icon?: Icon;
-};
-
-// The param passed to `addDevToolbarApp` in the integration
-export type DevToolbarAppEntry = DevToolbarAppMeta & {
- entrypoint: string;
-};
-
-// Public API for the dev toolbar
-export type DevToolbarApp = {
- /**
- * @deprecated The `id`, `name`, and `icon` properties should now be defined when using `addDevToolbarApp`.
- *
- * Ex: `addDevToolbarApp({ id: 'my-app', name: 'My App', icon: '🚀', entrypoint: '/path/to/app' })`
- *
- * In the future, putting these properties directly on the app object will be removed.
- */
- id?: string;
- /**
- * @deprecated The `id`, `name`, and `icon` properties should now be defined when using `addDevToolbarApp`.
- *
- * Ex: `addDevToolbarApp({ id: 'my-app', name: 'My App', icon: '🚀', entrypoint: '/path/to/app' })`
- *
- * In the future, putting these properties directly on the app object will be removed.
- */
- name?: string;
- /**
- * @deprecated The `id`, `name`, and `icon` properties should now be defined when using `addDevToolbarApp`.
- *
- * Ex: `addDevToolbarApp({ id: 'my-app', name: 'My App', icon: '🚀', entrypoint: '/path/to/app' })`
- *
- * In the future, putting these properties directly on the app object will be removed.
- */
- icon?: Icon;
- init?(
- canvas: ShadowRoot,
- app: ToolbarAppEventTarget,
- server: ToolbarServerHelpers,
- ): void | Promise;
- beforeTogglingOff?(canvas: ShadowRoot): boolean | Promise;
-};
-
-// An app that has been loaded and as such contain all of its properties
-export type ResolvedDevToolbarApp = DevToolbarAppMeta & Omit;
-
-// TODO: Remove in Astro 5.0
-export type DevOverlayPlugin = DevToolbarApp;
-
-export type DevToolbarMetadata = Window &
- typeof globalThis & {
- __astro_dev_toolbar__: {
- root: string;
- version: string;
- latestAstroVersion: AstroSettings['latestAstroVersion'];
- debugInfo: string;
- };
- };
-
-declare global {
- interface HTMLElementTagNameMap {
- 'astro-dev-toolbar': AstroDevToolbar;
- 'astro-dev-toolbar-window': DevToolbarWindow;
- 'astro-dev-toolbar-app-canvas': DevToolbarCanvas;
- 'astro-dev-toolbar-tooltip': DevToolbarTooltip;
- 'astro-dev-toolbar-highlight': DevToolbarHighlight;
- 'astro-dev-toolbar-toggle': DevToolbarToggle;
- 'astro-dev-toolbar-badge': DevToolbarBadge;
- 'astro-dev-toolbar-button': DevToolbarButton;
- 'astro-dev-toolbar-icon': DevToolbarIcon;
- 'astro-dev-toolbar-card': DevToolbarCard;
- 'astro-dev-toolbar-select': DevToolbarSelect;
- 'astro-dev-toolbar-radio-checkbox': DevToolbarRadioCheckbox;
-
- // Deprecated names
- // TODO: Remove in Astro 5.0
- 'astro-dev-overlay': AstroDevToolbar;
- 'astro-dev-overlay-window': DevToolbarWindow;
- 'astro-dev-overlay-plugin-canvas': DevToolbarCanvas;
- 'astro-dev-overlay-tooltip': DevToolbarTooltip;
- 'astro-dev-overlay-highlight': DevToolbarHighlight;
- 'astro-dev-overlay-toggle': DevToolbarToggle;
- 'astro-dev-overlay-badge': DevToolbarBadge;
- 'astro-dev-overlay-button': DevToolbarButton;
- 'astro-dev-overlay-icon': DevToolbarIcon;
- 'astro-dev-overlay-card': DevToolbarCard;
- }
- // eslint-disable-next-line @typescript-eslint/no-namespace
- namespace Config {
- type Database = Record;
- }
-
- interface DocumentEventMap {
- 'astro:before-preparation': TransitionBeforePreparationEvent;
- 'astro:after-preparation': Event;
- 'astro:before-swap': TransitionBeforeSwapEvent;
- 'astro:after-swap': Event;
- 'astro:page-load': Event;
- }
-}
-
-// Container types
-export type ContainerImportRendererFn = (
- containerRenderer: ContainerRenderer,
-) => Promise;
-
-export type ContainerRenderer = {
- /**
- * The name of the renderer.
- */
- name: string;
- /**
- * The entrypoint that is used to render a component on the server
- */
- serverEntrypoint: string;
-};
diff --git a/packages/astro/src/types/public/container.ts b/packages/astro/src/types/public/container.ts
new file mode 100644
index 000000000000..030a5b8195c3
--- /dev/null
+++ b/packages/astro/src/types/public/container.ts
@@ -0,0 +1,10 @@
+export type ContainerRenderer = {
+ /**
+ * The name of the renderer.
+ */
+ name: string;
+ /**
+ * The entrypoint that is used to render a component on the server
+ */
+ serverEntrypoint: string;
+};
diff --git a/packages/astro/src/types/public/content.ts b/packages/astro/src/types/public/content.ts
new file mode 100644
index 000000000000..e4484887e335
--- /dev/null
+++ b/packages/astro/src/types/public/content.ts
@@ -0,0 +1,121 @@
+import type { MarkdownHeading } from '@astrojs/markdown-remark';
+import type { AstroComponentFactory } from '../../runtime/server/index.js';
+import type { DataEntry, RenderedContent } from '../../content/data-store.js';
+import type { AstroConfig } from './config.js';
+import type * as rollup from 'rollup';
+
+export interface AstroInstance {
+ file: string;
+ url: string | undefined;
+ default: AstroComponentFactory;
+}
+
+export interface MarkdownInstance> {
+ frontmatter: T;
+ /** Absolute file path (e.g. `/home/user/projects/.../file.md`) */
+ file: string;
+ /** Browser URL for files under `/src/pages` (e.g. `/en/guides/markdown-content`) */
+ url: string | undefined;
+ /** Component to render content in `.astro` files. Usage: `` */
+ Content: AstroComponentFactory;
+ /** raw Markdown file content, excluding layout HTML and YAML frontmatter */
+ rawContent(): string;
+ /** Markdown file compiled to HTML, excluding layout HTML */
+ compiledContent(): string;
+ /** List of headings (h1 -> h6) with associated metadata */
+ getHeadings(): MarkdownHeading[];
+ default: AstroComponentFactory;
+}
+
+export type MDXInstance> = Omit<
+ MarkdownInstance,
+ 'rawContent' | 'compiledContent'
+>;
+
+export interface MarkdownLayoutProps> {
+ frontmatter: {
+ file: MarkdownInstance['file'];
+ url: MarkdownInstance['url'];
+ } & T;
+ file: MarkdownInstance['file'];
+ url: MarkdownInstance['url'];
+ headings: MarkdownHeading[];
+ rawContent: MarkdownInstance['rawContent'];
+ compiledContent: MarkdownInstance['compiledContent'];
+}
+
+export type MDXLayoutProps> = Omit<
+ MarkdownLayoutProps,
+ 'rawContent' | 'compiledContent'
+>;
+
+export type ContentEntryModule = {
+ id: string;
+ collection: string;
+ slug: string;
+ body: string;
+ data: Record;
+ _internal: {
+ rawData: string;
+ filePath: string;
+ };
+};
+
+export type DataEntryModule = {
+ id: string;
+ collection: string;
+ data: Record;
+ _internal: {
+ rawData: string;
+ filePath: string;
+ };
+};
+
+export type ContentEntryRenderFunction = (entry: DataEntry) => Promise;
+
+export interface ContentEntryType {
+ extensions: string[];
+ getEntryInfo(params: {
+ fileUrl: URL;
+ contents: string;
+ }): GetContentEntryInfoReturnType | Promise;
+ getRenderModule?(
+ this: rollup.PluginContext,
+ params: {
+ contents: string;
+ fileUrl: URL;
+ viteId: string;
+ },
+ ): rollup.LoadResult | Promise;
+ contentModuleTypes?: string;
+ getRenderFunction?(config: AstroConfig): Promise;
+
+ /**
+ * Handle asset propagation for rendered content to avoid bleed.
+ * Ex. MDX content can import styles and scripts, so `handlePropagation` should be true.
+ * @default true
+ */
+ handlePropagation?: boolean;
+}
+
+type GetContentEntryInfoReturnType = {
+ data: Record;
+ /**
+ * Used for error hints to point to correct line and location
+ * Should be the untouched data as read from the file,
+ * including newlines
+ */
+ rawData: string;
+ body: string;
+ slug: string;
+};
+
+export interface DataEntryType {
+ extensions: string[];
+ getEntryInfo(params: {
+ fileUrl: URL;
+ contents: string;
+ }): GetDataEntryInfoReturnType | Promise;
+}
+
+export type GetDataEntryInfoReturnType = { data: Record; rawData?: string };
diff --git a/packages/astro/src/types/public/context.ts b/packages/astro/src/types/public/context.ts
new file mode 100644
index 000000000000..5f05b7a66273
--- /dev/null
+++ b/packages/astro/src/types/public/context.ts
@@ -0,0 +1,501 @@
+import type {
+ ActionAccept,
+ ActionClient,
+ ActionInputSchema,
+ ActionReturnType,
+} from '../../actions/runtime/virtual/server.js';
+import type { SUPPORTED_MARKDOWN_FILE_EXTENSIONS } from '../../core/constants.js';
+import type { AstroCookies } from '../../core/cookies/cookies.js';
+import type { AstroComponentFactory } from '../../runtime/server/index.js';
+import type { Params, RewritePayload } from './common.js';
+import type { ValidRedirectStatus } from './config.js';
+import type { AstroInstance, MDXInstance, MarkdownInstance } from './content.js';
+
+/**
+ * Astro global available in all contexts in .astro files
+ *
+ * [Astro reference](https://docs.astro.build/reference/api-reference/#astro-global)
+ */
+export interface AstroGlobal<
+ Props extends Record = Record,
+ Self = AstroComponentFactory,
+ // eslint-disable-next-line @typescript-eslint/no-shadow
+ Params extends Record = Record,
+> extends AstroGlobalPartial,
+ AstroSharedContext {
+ /**
+ * A full URL object of the request URL.
+ * Equivalent to: `new URL(Astro.request.url)`
+ *
+ * [Astro reference](https://docs.astro.build/en/reference/api-reference/#url)
+ */
+ url: AstroSharedContext['url'];
+ /** Parameters passed to a dynamic page generated using [getStaticPaths](https://docs.astro.build/en/reference/api-reference/#getstaticpaths)
+ *
+ * Example usage:
+ * ```astro
+ * ---
+ * export async function getStaticPaths() {
+ * return [
+ * { params: { id: '1' } },
+ * ];
+ * }
+ *
+ * const { id } = Astro.params;
+ * ---
+ * {id}
+ * ```
+ *
+ * [Astro reference](https://docs.astro.build/en/reference/api-reference/#astroparams)
+ */
+ params: AstroSharedContext['params'];
+ /** List of props passed to this component
+ *
+ * A common way to get specific props is through [destructuring](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment), ex:
+ * ```typescript
+ * const { name } = Astro.props
+ * ```
+ *
+ * [Astro reference](https://docs.astro.build/en/basics/astro-components/#component-props)
+ */
+ props: AstroSharedContext['props'];
+ /** Information about the current request. This is a standard [Request](https://developer.mozilla.org/en-US/docs/Web/API/Request) object
+ *
+ * For example, to get a URL object of the current URL, you can use:
+ * ```typescript
+ * const url = new URL(Astro.request.url);
+ * ```
+ *
+ * [Astro reference](https://docs.astro.build/en/reference/api-reference/#astrorequest)
+ */
+ request: Request;
+ /** Information about the outgoing response. This is a standard [ResponseInit](https://developer.mozilla.org/en-US/docs/Web/API/Response/Response#init) object
+ *
+ * For example, to change the status code you can set a different status on this object:
+ * ```typescript
+ * Astro.response.status = 404;
+ * ```
+ *
+ * [Astro reference](https://docs.astro.build/en/reference/api-reference/#astroresponse)
+ */
+ response: ResponseInit & {
+ readonly headers: Headers;
+ };
+ /**
+ * Get an action result on the server when using a form POST.
+ * Expects the action function as a parameter.
+ * Returns a type-safe result with the action data when
+ * a matching POST request is received
+ * and `undefined` otherwise.
+ *
+ * Example usage:
+ *
+ * ```typescript
+ * import { actions } from 'astro:actions';
+ *
+ * const result = await Astro.getActionResult(actions.myAction);
+ * ```
+ */
+ getActionResult: AstroSharedContext['getActionResult'];
+ /**
+ * Call an Action directly from an Astro page or API endpoint.
+ * Expects the action function as the first parameter,
+ * and the type-safe action input as the second parameter.
+ * Returns a Promise with the action result.
+ *
+ * Example usage:
+ *
+ * ```typescript
+ * import { actions } from 'astro:actions';
+ *
+ * const result = await Astro.callAction(actions.getPost, { postId: 'test' });
+ * ```
+ */
+ callAction: AstroSharedContext['callAction'];
+ /** Redirect to another page
+ *
+ * Example usage:
+ * ```typescript
+ * if(!isLoggedIn) {
+ * return Astro.redirect('/login');
+ * }
+ * ```
+ *
+ * [Astro reference](https://docs.astro.build/en/reference/api-reference/#astroredirect)
+ */
+ redirect: AstroSharedContext['redirect'];
+ /**
+ * It rewrites to another page. As opposed to redirects, the URL won't change, and Astro will render the HTML emitted
+ * by the rewritten URL passed as argument.
+ *
+ * ## Example
+ *
+ * ```js
+ * if (pageIsNotEnabled) {
+ * return Astro.rewrite('/fallback-page')
+ * }
+ * ```
+ */
+ rewrite: AstroSharedContext['rewrite'];
+ /**
+ * The element allows a component to reference itself recursively.
+ *
+ * [Astro reference](https://docs.astro.build/en/reference/api-reference/#astroself)
+ */
+ self: Self;
+ /** Utility functions for modifying an Astro component’s slotted children
+ *
+ * [Astro reference](https://docs.astro.build/en/reference/api-reference/#astroslots)
+ */
+ slots: Record & {
+ /**
+ * Check whether content for this slot name exists
+ *
+ * Example usage:
+ * ```typescript
+ * if (Astro.slots.has('default')) {
+ * // Do something...
+ * }
+ * ```
+ *
+ * [Astro reference](https://docs.astro.build/en/reference/api-reference/#astroslots)
+ */
+ has(slotName: string): boolean;
+ /**
+ * Asynchronously renders this slot and returns a string
+ *
+ * Example usage:
+ * ```astro
+ * ---
+ * let html: string = '';
+ * if (Astro.slots.has('default')) {
+ * html = await Astro.slots.render('default')
+ * }
+ * ---
+ *
+ * ```
+ *
+ * A second parameter can be used to pass arguments to a slotted callback
+ *
+ * Example usage:
+ * ```astro
+ * ---
+ * html = await Astro.slots.render('default', ["Hello", "World"])
+ * ---
+ * ```
+ * Each item in the array will be passed as an argument that you can use like so:
+ * ```astro
+ *
+ * {(hello, world) => {hello}, {world}!
}
+ *
+ * ```
+ *
+ * [Astro reference](https://docs.astro.build/en/reference/api-reference/#astroslots)
+ */
+ render(slotName: string, args?: any[]): Promise;
+ };
+}
+
+/** Union type of supported markdown file extensions */
+type MarkdownFileExtension = (typeof SUPPORTED_MARKDOWN_FILE_EXTENSIONS)[number];
+
+export interface AstroGlobalPartial {
+ /**
+ * Fetch local files into your static site setup
+ *
+ * Example usage:
+ * ```typescript
+ * const posts = await Astro.glob('../pages/post/*.md');
+ * ```
+ *
+ * [Astro reference](https://docs.astro.build/en/reference/api-reference/#astroglob)
+ */
+ glob(globStr: `${any}.astro`): Promise;
+ glob>(
+ globStr: `${any}${MarkdownFileExtension}`,
+ ): Promise[]>;
+ glob>(globStr: `${any}.mdx`): Promise[]>;
+ glob>(globStr: string): Promise;
+ /**
+ * Returns a [URL](https://developer.mozilla.org/en-US/docs/Web/API/URL) object built from the [site](https://docs.astro.build/en/reference/configuration-reference/#site) config option
+ *
+ * [Astro reference](https://docs.astro.build/en/reference/api-reference/#astrosite)
+ */
+ site: URL | undefined;
+ /**
+ * Returns a string with the current version of Astro.
+ *
+ * Useful for using `` or crediting Astro in a site footer.
+ *
+ * [HTML Specification for `generator`](https://html.spec.whatwg.org/multipage/semantics.html#meta-generator)
+ *
+ * [Astro reference](https://docs.astro.build/en/reference/api-reference/#astrogenerator)
+ */
+ generator: string;
+}
+
+// Shared types between `Astro` global and API context object
+interface AstroSharedContext<
+ Props extends Record = Record,
+ RouteParams extends Record = Record,
+> {
+ /**
+ * The address (usually IP address) of the user.
+ *
+ * Throws an error if used within a static site, or within a prerendered page.
+ */
+ clientAddress: string;
+ /**
+ * Utility for getting and setting the values of cookies.
+ */
+ cookies: AstroCookies;
+ /**
+ * Information about the current request. This is a standard [Request](https://developer.mozilla.org/en-US/docs/Web/API/Request) object
+ */
+ request: Request;
+ /**
+ * A full URL object of the request URL.
+ */
+ url: URL;
+ /**
+ * Get action result on the server when using a form POST.
+ */
+ getActionResult: <
+ TAccept extends ActionAccept,
+ TInputSchema extends ActionInputSchema,
+ TAction extends ActionClient,
+ >(
+ action: TAction,
+ ) => ActionReturnType | undefined;
+ /**
+ * Call action handler from the server.
+ */
+ callAction: <
+ TAccept extends ActionAccept,
+ TInputSchema extends ActionInputSchema,
+ TOutput,
+ TAction extends
+ | ActionClient
+ | ActionClient['orThrow'],
+ >(
+ action: TAction,
+ input: Parameters[0],
+ ) => Promise>;
+ /**
+ * Route parameters for this request if this is a dynamic route.
+ */
+ params: RouteParams;
+ /**
+ * List of props returned for this path by `getStaticPaths` (**Static Only**).
+ */
+ props: Props;
+ /**
+ * Redirect to another page (**SSR Only**).
+ */
+ redirect(path: string, status?: ValidRedirectStatus): Response;
+
+ /**
+ * It rewrites to another page. As opposed to redirects, the URL won't change, and Astro will render the HTML emitted
+ * by the rerouted URL passed as argument.
+ *
+ * ## Example
+ *
+ * ```js
+ * if (pageIsNotEnabled) {
+ * return Astro.rewrite('/fallback-page')
+ * }
+ * ```
+ */
+ rewrite(rewritePayload: RewritePayload): Promise;
+
+ /**
+ * Object accessed via Astro middleware
+ */
+ locals: App.Locals;
+
+ /**
+ * The current locale that is computed from the `Accept-Language` header of the browser (**SSR Only**).
+ */
+ preferredLocale: string | undefined;
+
+ /**
+ * The list of locales computed from the `Accept-Language` header of the browser, sorted by quality value (**SSR Only**).
+ */
+
+ preferredLocaleList: string[] | undefined;
+
+ /**
+ * The current locale computed from the URL of the request. It matches the locales in `i18n.locales`, and returns `undefined` otherwise.
+ */
+ currentLocale: string | undefined;
+}
+
+/**
+ * The `APIContext` is the object made available to endpoints and middleware.
+ * It is a subset of the `Astro` global object available in pages.
+ *
+ * [Reference](https://docs.astro.build/en/reference/api-reference/#endpoint-context)
+ */
+export interface APIContext<
+ Props extends Record = Record,
+ APIParams extends Record = Record