summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.changeset/chatty-teachers-sit.md5
-rw-r--r--.changeset/config.json2
-rw-r--r--.changeset/poor-frogs-dream.md7
-rw-r--r--.changeset/pre.json35
-rw-r--r--.changeset/quick-ads-exercise.md10
-rw-r--r--.changeset/small-ties-sort.md50
-rw-r--r--.github/labeler.yml2
-rw-r--r--.github/workflows/check.yml2
-rw-r--r--.github/workflows/ci.yml2
-rw-r--r--CONTRIBUTING.md12
-rw-r--r--packages/astro/astro-jsx.d.ts20
-rwxr-xr-xpackages/astro/astro.js2
-rw-r--r--packages/astro/client.d.ts20
-rw-r--r--packages/astro/components/Picture.astro2
-rw-r--r--packages/astro/config.d.ts8
-rw-r--r--packages/astro/env.d.ts2
-rw-r--r--packages/astro/index.d.ts2
-rw-r--r--packages/astro/src/@types/README.md5
-rw-r--r--packages/astro/src/@types/app.d.ts9
-rw-r--r--packages/astro/src/actions/index.ts3
-rw-r--r--packages/astro/src/actions/runtime/middleware.ts3
-rw-r--r--packages/astro/src/actions/runtime/route.ts2
-rw-r--r--packages/astro/src/actions/runtime/utils.ts2
-rw-r--r--packages/astro/src/actions/utils.ts4
-rw-r--r--packages/astro/src/assets/build/generate.ts2
-rw-r--r--packages/astro/src/assets/endpoint/config.ts2
-rw-r--r--packages/astro/src/assets/endpoint/generic.ts2
-rw-r--r--packages/astro/src/assets/endpoint/node.ts2
-rw-r--r--packages/astro/src/assets/internal.ts2
-rw-r--r--packages/astro/src/assets/services/service.ts2
-rw-r--r--packages/astro/src/assets/utils/remotePattern.ts2
-rw-r--r--packages/astro/src/assets/vite-plugin-assets.ts3
-rw-r--r--packages/astro/src/cli/db/index.ts2
-rw-r--r--packages/astro/src/cli/flags.ts2
-rw-r--r--packages/astro/src/cli/info/index.ts2
-rw-r--r--packages/astro/src/cli/preferences/index.ts2
-rw-r--r--packages/astro/src/config/index.ts2
-rw-r--r--packages/astro/src/config/vite-plugin-content-listen.ts2
-rw-r--r--packages/astro/src/container/index.ts43
-rw-r--r--packages/astro/src/container/pipeline.ts10
-rw-r--r--packages/astro/src/content/content-layer.ts2
-rw-r--r--packages/astro/src/content/loaders/glob.ts6
-rw-r--r--packages/astro/src/content/loaders/types.ts3
-rw-r--r--packages/astro/src/content/runtime.ts2
-rw-r--r--packages/astro/src/content/server-listeners.ts2
-rw-r--r--packages/astro/src/content/types-generator.ts3
-rw-r--r--packages/astro/src/content/utils.ts9
-rw-r--r--packages/astro/src/content/vite-plugin-content-assets.ts3
-rw-r--r--packages/astro/src/content/vite-plugin-content-imports.ts16
-rw-r--r--packages/astro/src/content/vite-plugin-content-virtual-mod.ts2
-rw-r--r--packages/astro/src/core/app/index.ts3
-rw-r--r--packages/astro/src/core/app/middlewares.ts2
-rw-r--r--packages/astro/src/core/app/node.ts2
-rw-r--r--packages/astro/src/core/app/pipeline.ts11
-rw-r--r--packages/astro/src/core/app/types.ts12
-rw-r--r--packages/astro/src/core/base-pipeline.ts13
-rw-r--r--packages/astro/src/core/build/common.ts3
-rw-r--r--packages/astro/src/core/build/css-asset-name.ts2
-rw-r--r--packages/astro/src/core/build/generate.ts23
-rw-r--r--packages/astro/src/core/build/index.ts9
-rw-r--r--packages/astro/src/core/build/internal.ts2
-rw-r--r--packages/astro/src/core/build/page-data.ts2
-rw-r--r--packages/astro/src/core/build/pipeline.ts10
-rw-r--r--packages/astro/src/core/build/plugins/plugin-content.ts2
-rw-r--r--packages/astro/src/core/build/plugins/plugin-hoisted-scripts.ts2
-rw-r--r--packages/astro/src/core/build/plugins/plugin-ssr.ts3
-rw-r--r--packages/astro/src/core/build/static-build.ts2
-rw-r--r--packages/astro/src/core/build/types.ts14
-rw-r--r--packages/astro/src/core/build/util.ts2
-rw-r--r--packages/astro/src/core/compile/compile.ts2
-rw-r--r--packages/astro/src/core/config/config.ts4
-rw-r--r--packages/astro/src/core/config/logging.ts2
-rw-r--r--packages/astro/src/core/config/schema.ts2
-rw-r--r--packages/astro/src/core/config/settings.ts3
-rw-r--r--packages/astro/src/core/config/validate.ts2
-rw-r--r--packages/astro/src/core/create-vite.ts4
-rw-r--r--packages/astro/src/core/dev/container.ts3
-rw-r--r--packages/astro/src/core/dev/dev.ts2
-rw-r--r--packages/astro/src/core/dev/restart.ts3
-rw-r--r--packages/astro/src/core/errors/dev/utils.ts2
-rw-r--r--packages/astro/src/core/errors/dev/vite.ts2
-rw-r--r--packages/astro/src/core/errors/errors-data.ts2
-rw-r--r--packages/astro/src/core/errors/utils.ts2
-rw-r--r--packages/astro/src/core/index.ts2
-rw-r--r--packages/astro/src/core/middleware/callMiddleware.ts4
-rw-r--r--packages/astro/src/core/middleware/index.ts3
-rw-r--r--packages/astro/src/core/middleware/sequence.ts3
-rw-r--r--packages/astro/src/core/middleware/vite-plugin.ts2
-rw-r--r--packages/astro/src/core/module-loader/loader.ts2
-rw-r--r--packages/astro/src/core/preview/index.ts3
-rw-r--r--packages/astro/src/core/preview/static-preview-server.ts2
-rw-r--r--packages/astro/src/core/preview/vite-plugin-astro-preview.ts2
-rw-r--r--packages/astro/src/core/redirects/component.ts2
-rw-r--r--packages/astro/src/core/redirects/helpers.ts6
-rw-r--r--packages/astro/src/core/render-context.ts15
-rw-r--r--packages/astro/src/core/render/index.ts3
-rw-r--r--packages/astro/src/core/render/paginate.ts4
-rw-r--r--packages/astro/src/core/render/params-and-props.ts4
-rw-r--r--packages/astro/src/core/render/renderer.ts3
-rw-r--r--packages/astro/src/core/render/route-cache.ts8
-rw-r--r--packages/astro/src/core/render/slots.ts2
-rw-r--r--packages/astro/src/core/render/ssr-element.ts4
-rw-r--r--packages/astro/src/core/routing/astro-designed-error-pages.ts3
-rw-r--r--packages/astro/src/core/routing/default.ts3
-rw-r--r--packages/astro/src/core/routing/manifest/create.ts12
-rw-r--r--packages/astro/src/core/routing/manifest/generator.ts4
-rw-r--r--packages/astro/src/core/routing/manifest/pattern.ts3
-rw-r--r--packages/astro/src/core/routing/manifest/serialization.ts4
-rw-r--r--packages/astro/src/core/routing/match.ts3
-rw-r--r--packages/astro/src/core/routing/params.ts3
-rw-r--r--packages/astro/src/core/routing/priority.ts2
-rw-r--r--packages/astro/src/core/routing/rewrite.ts4
-rw-r--r--packages/astro/src/core/routing/validation.ts4
-rw-r--r--packages/astro/src/core/server-islands/endpoint.ts8
-rw-r--r--packages/astro/src/core/server-islands/vite-plugin-server-islands.ts2
-rw-r--r--packages/astro/src/core/sync/index.ts3
-rw-r--r--packages/astro/src/core/sync/write-files.ts2
-rw-r--r--packages/astro/src/core/util.ts4
-rw-r--r--packages/astro/src/env/sync.ts2
-rw-r--r--packages/astro/src/env/vite-plugin-env.ts2
-rw-r--r--packages/astro/src/events/session.ts3
-rw-r--r--packages/astro/src/i18n/index.ts10
-rw-r--r--packages/astro/src/i18n/middleware.ts5
-rw-r--r--packages/astro/src/i18n/utils.ts2
-rw-r--r--packages/astro/src/i18n/vite-plugin-i18n.ts3
-rw-r--r--packages/astro/src/integrations/features-validation.ts16
-rw-r--r--packages/astro/src/integrations/hooks.ts27
-rw-r--r--packages/astro/src/jsx/renderer.ts5
-rw-r--r--packages/astro/src/jsx/server.ts2
-rw-r--r--packages/astro/src/jsx/transform-options.ts2
-rw-r--r--packages/astro/src/preferences/index.ts3
-rw-r--r--packages/astro/src/prefetch/vite-plugin-prefetch.ts2
-rw-r--r--packages/astro/src/prerender/routing.ts3
-rw-r--r--packages/astro/src/prerender/utils.ts2
-rw-r--r--packages/astro/src/runtime/client/dev-toolbar/apps/astro.ts2
-rw-r--r--packages/astro/src/runtime/client/dev-toolbar/apps/audit/index.ts2
-rw-r--r--packages/astro/src/runtime/client/dev-toolbar/apps/audit/ui/audit-ui.ts2
-rw-r--r--packages/astro/src/runtime/client/dev-toolbar/apps/settings.ts2
-rw-r--r--packages/astro/src/runtime/client/dev-toolbar/apps/xray.ts2
-rw-r--r--packages/astro/src/runtime/client/dev-toolbar/entrypoint.ts2
-rw-r--r--packages/astro/src/runtime/client/dev-toolbar/toolbar.ts2
-rw-r--r--packages/astro/src/runtime/client/idle.ts2
-rw-r--r--packages/astro/src/runtime/client/load.ts2
-rw-r--r--packages/astro/src/runtime/client/media.ts2
-rw-r--r--packages/astro/src/runtime/client/only.ts2
-rw-r--r--packages/astro/src/runtime/client/visible.ts3
-rw-r--r--packages/astro/src/runtime/server/astro-component.ts2
-rw-r--r--packages/astro/src/runtime/server/astro-global.ts2
-rw-r--r--packages/astro/src/runtime/server/endpoint.ts7
-rw-r--r--packages/astro/src/runtime/server/hydration.ts4
-rw-r--r--packages/astro/src/runtime/server/jsx.ts2
-rw-r--r--packages/astro/src/runtime/server/render/astro/factory.ts2
-rw-r--r--packages/astro/src/runtime/server/render/astro/instance.ts2
-rw-r--r--packages/astro/src/runtime/server/render/astro/render.ts2
-rw-r--r--packages/astro/src/runtime/server/render/common.ts2
-rw-r--r--packages/astro/src/runtime/server/render/component.ts12
-rw-r--r--packages/astro/src/runtime/server/render/dom.ts3
-rw-r--r--packages/astro/src/runtime/server/render/head.ts3
-rw-r--r--packages/astro/src/runtime/server/render/page.ts2
-rw-r--r--packages/astro/src/runtime/server/render/script.ts2
-rw-r--r--packages/astro/src/runtime/server/render/server-islands.ts2
-rw-r--r--packages/astro/src/runtime/server/render/slot.ts2
-rw-r--r--packages/astro/src/runtime/server/render/tags.ts2
-rw-r--r--packages/astro/src/runtime/server/render/util.ts23
-rw-r--r--packages/astro/src/runtime/server/scripts.ts2
-rw-r--r--packages/astro/src/runtime/server/serialize.ts2
-rw-r--r--packages/astro/src/runtime/server/transition.ts6
-rw-r--r--packages/astro/src/toolbar/index.ts2
-rw-r--r--packages/astro/src/toolbar/vite-plugin-dev-toolbar.ts2
-rw-r--r--packages/astro/src/transitions/index.ts6
-rw-r--r--packages/astro/src/transitions/vite-plugin-transitions.ts2
-rw-r--r--packages/astro/src/types/README.md5
-rw-r--r--packages/astro/src/types/astro.ts93
-rw-r--r--packages/astro/src/types/public/common.ts176
-rw-r--r--packages/astro/src/types/public/config.ts (renamed from packages/astro/src/@types/astro.ts)1703
-rw-r--r--packages/astro/src/types/public/content.ts121
-rw-r--r--packages/astro/src/types/public/context.ts501
-rw-r--r--packages/astro/src/types/public/elements.ts47
-rw-r--r--packages/astro/src/types/public/extendables.ts21
-rw-r--r--packages/astro/src/types/public/index.ts44
-rw-r--r--packages/astro/src/types/public/integrations.ts258
-rw-r--r--packages/astro/src/types/public/internal.ts202
-rw-r--r--packages/astro/src/types/public/preview.ts28
-rw-r--r--packages/astro/src/types/public/toolbar.ts96
-rw-r--r--packages/astro/src/types/public/view-transitions.ts40
-rw-r--r--packages/astro/src/types/typed-emitter.ts (renamed from packages/astro/src/@types/typed-emitter.ts)0
-rw-r--r--packages/astro/src/virtual-modules/container.ts3
-rw-r--r--packages/astro/src/virtual-modules/i18n.ts9
-rw-r--r--packages/astro/src/vite-plugin-astro-server/base.ts2
-rw-r--r--packages/astro/src/vite-plugin-astro-server/error.ts2
-rw-r--r--packages/astro/src/vite-plugin-astro-server/metadata.ts2
-rw-r--r--packages/astro/src/vite-plugin-astro-server/pipeline.ts20
-rw-r--r--packages/astro/src/vite-plugin-astro-server/plugin.ts4
-rw-r--r--packages/astro/src/vite-plugin-astro-server/request.ts2
-rw-r--r--packages/astro/src/vite-plugin-astro-server/route.ts3
-rw-r--r--packages/astro/src/vite-plugin-astro-server/scripts.ts2
-rw-r--r--packages/astro/src/vite-plugin-astro/compile.ts2
-rw-r--r--packages/astro/src/vite-plugin-astro/index.ts3
-rw-r--r--packages/astro/src/vite-plugin-astro/types.ts2
-rw-r--r--packages/astro/src/vite-plugin-config-alias/index.ts2
-rw-r--r--packages/astro/src/vite-plugin-env/index.ts3
-rw-r--r--packages/astro/src/vite-plugin-head/index.ts2
-rw-r--r--packages/astro/src/vite-plugin-integrations-container/index.ts3
-rw-r--r--packages/astro/src/vite-plugin-markdown/content-entry-type.ts6
-rw-r--r--packages/astro/src/vite-plugin-markdown/index.ts2
-rw-r--r--packages/astro/src/vite-plugin-mdx/transform-jsx.ts2
-rw-r--r--packages/astro/src/vite-plugin-scanner/index.ts3
-rw-r--r--packages/astro/src/vite-plugin-scanner/scan.ts2
-rw-r--r--packages/astro/src/vite-plugin-scripts/index.ts3
-rw-r--r--packages/astro/src/vite-plugin-scripts/page-ssr.ts2
-rw-r--r--packages/astro/src/vite-plugin-utils/index.ts2
-rw-r--r--packages/astro/templates/actions.mjs2
-rw-r--r--packages/astro/test/astro-attrs.test.js38
-rw-r--r--packages/astro/test/astro-component-code.test.js8
-rw-r--r--packages/astro/test/core-image-unconventional-settings.test.js2
-rw-r--r--packages/astro/test/fixtures/astro-attrs/src/pages/index.astro35
-rw-r--r--packages/astro/test/fixtures/core-image-ssr/src/pages/api.ts2
-rw-r--r--packages/astro/test/fixtures/ssr-prerender-chunks/deps/test-adapter/index.js4
-rw-r--r--packages/astro/test/test-adapter.js10
-rw-r--r--packages/astro/test/test-image-service.js2
-rw-r--r--packages/astro/test/test-utils.js4
-rw-r--r--packages/astro/test/types/call-action.ts2
-rw-r--r--packages/astro/test/units/test-utils.js6
-rw-r--r--packages/astro/types.d.ts2
-rw-r--r--packages/integrations/mdx/test/mdx-vite-env-vars.test.js4
-rw-r--r--packages/integrations/node/test/api-route.test.js2
-rw-r--r--packages/markdown/remark/src/shiki.ts30
227 files changed, 2248 insertions, 2173 deletions
diff --git a/.changeset/chatty-teachers-sit.md b/.changeset/chatty-teachers-sit.md
new file mode 100644
index 000000000..9e4fd89b4
--- /dev/null
+++ b/.changeset/chatty-teachers-sit.md
@@ -0,0 +1,5 @@
+---
+"astro": major
+---
+
+The lowest version of Node supported by Astro is now Node v18.17.1 and higher.
diff --git a/.changeset/config.json b/.changeset/config.json
index 030941db2..7920f52b8 100644
--- a/.changeset/config.json
+++ b/.changeset/config.json
@@ -4,7 +4,7 @@
"commit": false,
"linked": [],
"access": "public",
- "baseBranch": "main",
+ "baseBranch": "next",
"updateInternalDependencies": "patch",
"___experimentalUnsafeOptions_WILL_CHANGE_IN_PATCH": {
"onlyUpdatePeerDependentsWhenOutOfRange": true
diff --git a/.changeset/poor-frogs-dream.md b/.changeset/poor-frogs-dream.md
new file mode 100644
index 000000000..fdb3daa85
--- /dev/null
+++ b/.changeset/poor-frogs-dream.md
@@ -0,0 +1,7 @@
+---
+'astro': major
+---
+
+Refactor the exported types from the `astro` module. There should normally be no breaking changes, but if you relied on some previously deprecated types, these might now have been fully removed.
+
+In most cases, updating your code to move away from previously deprecated APIs in previous versions of Astro should be enough to fix any issues.
diff --git a/.changeset/pre.json b/.changeset/pre.json
new file mode 100644
index 000000000..f239e523d
--- /dev/null
+++ b/.changeset/pre.json
@@ -0,0 +1,35 @@
+{
+ "mode": "pre",
+ "tag": "alpha",
+ "initialVersions": {
+ "astro": "4.13.1",
+ "@astrojs/prism": "3.1.0",
+ "@astrojs/rss": "4.0.7",
+ "create-astro": "4.8.1",
+ "@astrojs/db": "0.12.0",
+ "@astrojs/alpinejs": "0.4.0",
+ "@astrojs/cloudflare": "0.0.0",
+ "@astrojs/lit": "4.3.0",
+ "@astrojs/markdoc": "0.11.3",
+ "@astrojs/mdx": "3.1.3",
+ "@astrojs/netlify": "0.0.0",
+ "@astrojs/node": "8.3.2",
+ "@astrojs/partytown": "2.1.1",
+ "@astrojs/preact": "3.5.1",
+ "@astrojs/react": "3.6.1",
+ "@astrojs/sitemap": "3.1.6",
+ "@astrojs/solid-js": "4.4.0",
+ "@astrojs/svelte": "5.7.0",
+ "@astrojs/tailwind": "5.1.0",
+ "@astrojs/vercel": "7.7.2",
+ "@astrojs/vue": "4.5.0",
+ "@astrojs/web-vitals": "1.0.0",
+ "@astrojs/internal-helpers": "0.4.1",
+ "@astrojs/markdown-remark": "5.2.0",
+ "@astrojs/studio": "0.1.1",
+ "@astrojs/telemetry": "3.1.0",
+ "@astrojs/underscore-redirects": "0.3.4",
+ "@astrojs/upgrade": "0.3.1"
+ },
+ "changesets": []
+}
diff --git a/.changeset/quick-ads-exercise.md b/.changeset/quick-ads-exercise.md
new file mode 100644
index 000000000..dd4285a4c
--- /dev/null
+++ b/.changeset/quick-ads-exercise.md
@@ -0,0 +1,10 @@
+---
+'@astrojs/markdown-remark': major
+---
+
+Renames the following CSS variables theme color token names to better align with the Shiki v1 defaults:
+
+- `--astro-code-color-text` => `--astro-code-foreground`
+- `--astro-code-color-background` => `--astro-code-background`
+
+You can perform a global find and replace in your project to migrate to the new token names.
diff --git a/.changeset/small-ties-sort.md b/.changeset/small-ties-sort.md
new file mode 100644
index 000000000..e3f3d67eb
--- /dev/null
+++ b/.changeset/small-ties-sort.md
@@ -0,0 +1,50 @@
+---
+'astro': major
+---
+
+Fixes attribute rendering for non-[boolean HTML attributes](https://developer.mozilla.org/en-US/docs/Glossary/Boolean/HTML) with boolean values to match proper attribute handling in browsers.
+
+Previously, non-boolean attributes may not have included their values when rendered to HTML. In Astro v5.0, the values are now explicitly rendered as `="true"` or `="false"`
+
+In the following `.astro` examples, only `allowfullscreen` is a boolean attribute:
+
+```astro
+<!-- src/pages/index.astro -->
+<!-- `allowfullscreen` is a boolean attribute -->
+<p allowfullscreen={true}></p>
+<p allowfullscreen={false}></p>
+
+<!-- `inherit` is *not* a boolean attribute -->
+<p inherit={true}></p>
+<p inherit={false}></p>
+
+<!-- `data-*` attributes are not boolean attributes -->
+<p data-light={true}></p>
+<p data-light={false}></p>
+```
+
+Astro v5.0 now preserves the full data attribute with its value when rendering the HTML of non-boolean attributes:
+
+```diff
+ <p allowfullscreen></p>
+ <p></p>
+
+ <p inherit="true"></p>
+- <p inherit></p>
++ <p inherit="false"></p>
+
+- <p data-light></p>
++ <p data-light="true"></p>
+- <p></p>
++ <p data-light="false"></p>
+```
+
+If you rely on attribute values, for example to locate elements or to conditionally render, update your code to match the new non-boolean attribute values:
+
+```diff
+- el.getAttribute('inherit') === ''
++ el.getAttribute('inherit') === 'false'
+
+- el.hasAttribute('data-light')
++ el.dataset.light === 'true'
+```
diff --git a/.github/labeler.yml b/.github/labeler.yml
index c1025ad11..b0d27800b 100644
--- a/.github/labeler.yml
+++ b/.github/labeler.yml
@@ -40,5 +40,5 @@
- packages/integrations/vue/**
'docs pr':
-- packages/astro/src/@types/astro.ts
+- packages/astro/src/types/public/**
- packages/astro/src/core/errors/errors-data.ts
diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml
index c1b491990..2ce9ac1db 100644
--- a/.github/workflows/check.yml
+++ b/.github/workflows/check.yml
@@ -11,7 +11,7 @@ on:
- "examples/**"
- ".github/workflows/check.yml"
- "scripts/smoke/check.js"
- - "packages/astro/src/@types/astro.ts"
+ - "packages/astro/src/types/public/**"
- "pnpm-lock.yaml"
- "packages/astro/types.d.ts"
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 79962c07e..d516ab47a 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -229,7 +229,7 @@ jobs:
filters: |
docs:
- 'packages/integrations/*/README.md'
- - 'packages/astro/src/@types/astro.ts'
+ - "packages/astro/src/types/public/**"
- 'packages/astro/src/core/errors/errors-data.ts'
- name: Build autogenerated docs pages from current astro branch
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index 2f2e63786..6a657068d 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -289,7 +289,7 @@ Server-side rendering (SSR) can be complicated. The Astro package (`packages/ast
- `components/`: Built-in components to use in your project (e.g. `import Code from 'astro/components/Code.astro'`)
- `src/`: Astro source
- - `@types/`: TypeScript types. These are centralized to cut down on circular dependencies
+ - `types/`: TypeScript types. These are centralized to cut down on circular dependencies
- `cli/`: Code that powers the `astro` CLI command
- `core/`: Code that executes **in the top-level scope** (in Node). Within, you’ll find code that powers the `astro build` and `astro dev` commands, as well as top-level SSR code.
- `runtime/`: Code that executes **in different scopes** (i.e. not in a pure Node context). You’ll have to think about code differently here.
@@ -369,20 +369,22 @@ Full documentation: https://github.com/changesets/changesets/blob/main/docs/prer
### Entering prerelease mode
-If you have gotten permission from the core contributors, you can enter into prerelease mode by following the following steps:
+If you have gotten permission from the core contributors, you can enter into prerelease mode with the following steps:
- Run: `pnpm exec changeset pre enter next` in the project root
+- Update `.changeset/config.json` with `"baseBranch": "next"` (for easier changesets creation)
- Create a new PR from the changes created by this command
-- Review, approve, and more the PR to enter prerelease mode.
+- Review, approve, and merge the PR to enter prerelease mode.
- If successful, The "[ci] release" PR (if one exists) will now say "[ci] release (next)".
### Exiting prerelease mode
-Exiting prerelease mode should happen once an experimental release is ready to go from `npm install astro@next` to `npm install astro`. Only a core contributor run these steps. These steps should be run before
+Exiting prerelease mode should happen once an experimental release is ready to go from `npm install astro@next` to `npm install astro`. Only a core contributor can run these steps:
- Run: `pnpm exec changeset pre exit` in the project root
+- Update `.changeset/config.json` with `"baseBranch": "main"`
- Create a new PR from the changes created by this command.
-- Review, approve, and more the PR to enter prerelease mode.
+- Review, approve, and merge the PR to enter prerelease mode.
- If successful, The "[ci] release (next)" PR (if one exists) will now say "[ci] release".
### Releasing `astro@latest` while in prerelease mode
diff --git a/packages/astro/astro-jsx.d.ts b/packages/astro/astro-jsx.d.ts
index b26507d1d..128709dfc 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/astro.js b/packages/astro/astro.js
index 2000ca566..a02e60b76 100755
--- a/packages/astro/astro.js
+++ b/packages/astro/astro.js
@@ -12,7 +12,7 @@ const CI_INSTRUCTIONS = {
};
// Hardcode supported Node.js version so we don't have to read differently in CJS & ESM.
-const engines = '>=18.14.1';
+const engines = '>=18.17.1';
const skipSemverCheckIfAbove = 19;
/** `astro *` */
diff --git a/packages/astro/client.d.ts b/packages/astro/client.d.ts
index ed5c1b894..796bf3f33 100644
--- a/packages/astro/client.d.ts
+++ b/packages/astro/client.d.ts
@@ -2,12 +2,6 @@
/// <reference path="./types/content.d.ts" />
/// <reference path="./types/actions.d.ts" />
-// 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<import('./dist/assets/types.js').GetImageResult>;
- 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<Record<string, any>>;
+type MD = import('./dist/types/public/content.js').MarkdownInstance<Record<string, any>>;
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<Record<string, any>>;
+ type MDX = import('./dist/types/public/content.js').MDXInstance<Record<string, any>>;
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/components/Picture.astro b/packages/astro/components/Picture.astro
index c85548404..6686faf15 100644
--- a/packages/astro/components/Picture.astro
+++ b/packages/astro/components/Picture.astro
@@ -1,7 +1,7 @@
---
import { type LocalImageProps, type RemoteImageProps, getImage } from 'astro:assets';
import * as mime from 'mrmime';
-import type { GetImageResult, ImageOutputFormat } from '../dist/@types/astro';
+import type { GetImageResult, ImageOutputFormat } from '../dist/types/public/index.js';
import { isESMImportedImage, resolveSrc } from '../dist/assets/utils/imageKind';
import { AstroError, AstroErrorData } from '../dist/core/errors/index.js';
import type { HTMLAttributes } from '../types';
diff --git a/packages/astro/config.d.ts b/packages/astro/config.d.ts
index 9f4c6bfd1..675c783a1 100644
--- a/packages/astro/config.d.ts
+++ b/packages/astro/config.d.ts
@@ -1,8 +1,8 @@
type ViteUserConfig = import('vite').UserConfig;
type ViteUserConfigFn = import('vite').UserConfigFn;
-type AstroUserConfig = import('./dist/@types/astro.js').AstroUserConfig;
-type AstroInlineConfig = import('./dist/@types/astro.js').AstroInlineConfig;
-type ImageServiceConfig = import('./dist/@types/astro.js').ImageServiceConfig;
+type AstroUserConfig = import('./dist/types/public/config.js').AstroUserConfig;
+type AstroInlineConfig = import('./dist/types/public/config.js').AstroInlineConfig;
+type ImageServiceConfig = import('./dist/types/public/config.js').ImageServiceConfig;
type SharpImageServiceConfig = import('./dist/assets/services/sharp.js').SharpImageServiceConfig;
type EnvField = typeof import('./dist/env/config.js').envField;
@@ -42,4 +42,4 @@ export function passthroughImageService(): ImageServiceConfig;
/**
* Return a valid env field to use in this Astro config for `experimental.env.schema`.
*/
-export const envField: EnvField;
+export declare const envField: EnvField;
diff --git a/packages/astro/env.d.ts b/packages/astro/env.d.ts
index 876a29c60..d2a788db3 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 a9e679be1..7b7a236e7 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 397329eaf..000000000
--- 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/@types/app.d.ts b/packages/astro/src/@types/app.d.ts
deleted file mode 100644
index 1c0908bb8..000000000
--- a/packages/astro/src/@types/app.d.ts
+++ /dev/null
@@ -1,9 +0,0 @@
-/**
- * Shared interfaces throughout the application that can be overridden by the user.
- */
-declare namespace App {
- /**
- * Used by middlewares to store information, that can be read by the user via the global `Astro.locals`
- */
- interface Locals {}
-}
diff --git a/packages/astro/src/actions/index.ts b/packages/astro/src/actions/index.ts
index 2423b7017..61f5a00cc 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 f3f01800a..b6f3221b5 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 e4e2ad1ce..7279a093d 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 776171aa2..199809d4e 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 5cf786266..f1cab8e43 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 fcc19f4f5..1c4866592 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 07cfe8fae..ff9dcc79a 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 5238f3721..d453787fd 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 cb3ae7806..04275652c 100644
--- a/packages/astro/src/assets/endpoint/node.ts
+++ b/packages/astro/src/assets/endpoint/node.ts
@@ -7,7 +7,7 @@ import { fileURLToPath, pathToFileURL } from 'node:url';
import { assetsDir, imageConfig, outDir } from 'astro:assets';
import { isRemotePath, removeQueryString } 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/internal.ts b/packages/astro/src/assets/internal.ts
index 38afbf19f..9a5926e8d 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 9cd6d0ecb..f798e1dfd 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 5feefb89f..d3e832573 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 4c9314e85..57bbf847a 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 ae97e498f..7aaea302c 100644
--- a/packages/astro/src/cli/db/index.ts
+++ b/packages/astro/src/cli/db/index.ts
@@ -1,5 +1,5 @@
import type { Arguments } from 'yargs-parser';
-import type { AstroConfig } from '../../@types/astro.js';
+import type { AstroConfig } from '../../types/public/config.js';
import { resolveConfig } from '../../core/config/config.js';
import { apply as applyPolyfill } from '../../core/polyfill.js';
import { createLoggerFromFlags, flagsToAstroInlineConfig } from '../flags.js';
diff --git a/packages/astro/src/cli/flags.ts b/packages/astro/src/cli/flags.ts
index 9d57c0316..e890b242c 100644
--- a/packages/astro/src/cli/flags.ts
+++ b/packages/astro/src/cli/flags.ts
@@ -1,7 +1,7 @@
import type { Arguments } from 'yargs-parser';
-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';
// Alias for now, but allows easier migration to node's `parseArgs` in the future.
export type Flags = Arguments;
diff --git a/packages/astro/src/cli/info/index.ts b/packages/astro/src/cli/info/index.ts
index 3fa91802f..9f25a2535 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 3811e7f48..bd60343c2 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 3c5faf2fa..b31105ec7 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 1b65c5bfb..6c0408001 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 f0c600a40..8a8c83e07 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,8 +10,32 @@ 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';
+/** Public type, used for integrations to define a renderer for the container API */
+export type ContainerRenderer = {
+ /**
+ * The name of the renderer.
+ */
+ name: string;
+ /**
+ * The entrypoint that is used to render a component on the server
+ */
+ serverEntrypoint: string;
+};
+
/**
* Options to be passed when rendering a route
*/
@@ -103,6 +112,10 @@ export type AddClientRenderer = {
entrypoint: string;
};
+type ContainerImportRendererFn = (
+ containerRenderer: ContainerRenderer,
+) => Promise<SSRLoadedRenderer>;
+
function createManifest(
manifest?: AstroContainerManifest,
renderers?: SSRLoadedRenderer[],
diff --git a/packages/astro/src/container/pipeline.ts b/packages/astro/src/container/pipeline.ts
index ff2718b8f..73caa4ecd 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 4861f3f61..c0ccf27c6 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/loaders/glob.ts b/packages/astro/src/content/loaders/glob.ts
index 4a4ecbcac..27af34196 100644
--- a/packages/astro/src/content/loaders/glob.ts
+++ b/packages/astro/src/content/loaders/glob.ts
@@ -4,7 +4,7 @@ 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 { ContentEntryRenderFunction, ContentEntryType } from '../../types/public/content.js';
import type { RenderedContent } from '../data-store.js';
import { getContentEntryIdAndSlug, getEntryConfigByExtMap, posixRelative } from '../utils.js';
import type { Loader } from './types.js';
@@ -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 26be0495a..5edfb5ef7 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 '../mutable-data-store.js';
export interface ParseDataOptions<TData extends Record<string, unknown>> {
diff --git a/packages/astro/src/content/runtime.ts b/packages/astro/src/content/runtime.ts
index b462e2e23..489625532 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 5d7868d58..28f5b16a8 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 faf02d95d..9923a0c34 100644
--- a/packages/astro/src/content/types-generator.ts
+++ b/packages/astro/src/content/types-generator.ts
@@ -7,11 +7,12 @@ import { type ViteDevServer, normalizePath } from 'vite';
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 type { ContentEntryType } from '../types/public/content.js';
import { CONTENT_LAYER_TYPE, CONTENT_TYPES_FILE, VIRTUAL_MODULE_ID } from './consts.js';
import {
type CollectionConfig,
diff --git a/packages/astro/src/content/utils.ts b/packages/astro/src/content/utils.ts
index 6d0627247..27b0e1915 100644
--- a/packages/astro/src/content/utils.ts
+++ b/packages/astro/src/content/utils.ts
@@ -7,15 +7,12 @@ 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 type { ContentEntryType, DataEntryType } from '../types/public/content.js';
import {
CONTENT_FLAGS,
CONTENT_LAYER_TYPE,
diff --git a/packages/astro/src/content/vite-plugin-content-assets.ts b/packages/astro/src/content/vite-plugin-content-assets.ts
index b810b8f71..059cd92fa 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,8 @@ 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 type { SSRElement } from '../types/public/internal.js';
import { getStylesForURL } from '../vite-plugin-astro-server/css.js';
import { getScriptsForURL } from '../vite-plugin-astro-server/scripts.js';
import {
diff --git a/packages/astro/src/content/vite-plugin-content-imports.ts b/packages/astro/src/content/vite-plugin-content-imports.ts
index 5a944716c..62f129052 100644
--- a/packages/astro/src/content/vite-plugin-content-imports.ts
+++ b/packages/astro/src/content/vite-plugin-content-imports.ts
@@ -4,19 +4,19 @@ 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 type {
+ ContentEntryModule,
+ ContentEntryType,
+ DataEntryModule,
+ DataEntryType,
+} from '../types/public/content.js';
import { CONTENT_FLAG, DATA_FLAG } from './consts.js';
import {
type ContentConfig,
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 64e5d98ee..832ca0b17 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 8041dda3c..3ffa5f144 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 095158b42..a60b6baf4 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 f9afa6189..86f0f5f65 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 b784ba916..d42472f50 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 00e37dacd..29cb00ed4 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<string, string>;
};
+/** 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 01e18bfa0..562b65174 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 a479aed39..f9ed45836 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 fbee7f2e2..57277c989 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 fae7896b9..1f71f2d8a 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,
+ SSRError,
+ SSRLoadedRenderer,
+} 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 72df05b89..74a648304 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 5c28a4d40..8c2d92824 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 210b31a0e..06ed629f2 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 4e0d94c57..18357e5ae 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 9c6d5add0..5fe0b6792 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 7c3784909..2992c0f2d 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 e9eda1dc9..888a4d44b 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 7e2272dde..96feb8542 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 572140ef6..f06f42501 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 9dc61f06f..b6b313254 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 c3e6e4bb8..6e49f5850 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 c10066ce3..3e19db801 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 004283f85..bd72f8b5e 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 f49b4708e..9db111718 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 6c878d7f3..902ff7d03 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 4f4497b78..75a64f1f7 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 23a4068a8..f2931523a 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';
@@ -185,7 +185,7 @@ export async function createVite(
{
// Typings are imported from 'astro' (e.g. import { Type } from 'astro')
find: /^astro$/,
- replacement: fileURLToPath(new URL('../@types/astro.js', import.meta.url)),
+ replacement: fileURLToPath(new URL('../types/public/index.js', import.meta.url)),
},
{
find: 'astro:middleware',
diff --git a/packages/astro/src/core/dev/container.ts b/packages/astro/src/core/dev/container.ts
index 159d5e447..f89e33197 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 12b6d3b55..73ec0fa71 100644
--- a/packages/astro/src/core/dev/dev.ts
+++ b/packages/astro/src/core/dev/dev.ts
@@ -5,13 +5,13 @@ import { performance } from 'node:perf_hooks';
import { green } from 'kleur/colors';
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 { attachContentServerListeners } from '../../content/index.js';
import { MutableDataStore } from '../../content/mutable-data-store.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 ee0ba995c..8fb6e46a3 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 341c815a6..c082a8193 100644
--- a/packages/astro/src/core/errors/dev/utils.ts
+++ b/packages/astro/src/core/errors/dev/utils.ts
@@ -6,7 +6,7 @@ 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 type { SSRError } from '../../../types/public/internal.js';
import { removeLeadingForwardSlashWindows } from '../../path.js';
import { AggregateError, type ErrorWithMetadata } from '../errors.js';
import { AstroErrorData } from '../index.js';
diff --git a/packages/astro/src/core/errors/dev/vite.ts b/packages/astro/src/core/errors/dev/vite.ts
index 56688877a..c944ad78d 100644
--- a/packages/astro/src/core/errors/dev/vite.ts
+++ b/packages/astro/src/core/errors/dev/vite.ts
@@ -3,11 +3,11 @@ import { fileURLToPath } from 'node:url';
import { codeToHtml, createCssVariablesTheme } from 'shiki';
import type { ShikiTransformer } from 'shiki';
import type { ErrorPayload } from 'vite';
+import type { SSRLoadedRenderer } from '../../../types/public/internal.js';
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';
export function enhanceViteSSRError({
diff --git a/packages/astro/src/core/errors/errors-data.ts b/packages/astro/src/core/errors/errors-data.ts
index 24b9ad687..e083ba2f5 100644
--- a/packages/astro/src/core/errors/errors-data.ts
+++ b/packages/astro/src/core/errors/errors-data.ts
@@ -1,5 +1,5 @@
// BEFORE ADDING AN ERROR: Please look at the README.md in this folder for general guidelines on writing error messages
-// Additionally, this code, much like `@types/astro.ts`, is used to generate documentation, so make sure to pass
+// Additionally, this code, much like `types/public/config.ts`, is used to generate documentation, so make sure to pass
// your changes by our wonderful docs team before merging!
import type { ZodError } from 'zod';
diff --git a/packages/astro/src/core/errors/utils.ts b/packages/astro/src/core/errors/utils.ts
index 05dd49071..6754656b9 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 bdd7c7f05..14a8c2f99 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 3bdc6052d..4cc7b6586 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 56ce0b76c..31988ae02 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 ee08381e6..aefa66a92 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 bb7b54e72..8a76bed92 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 976354448..9973ae657 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 b46cf1bec..a8a533fe8 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 0afa34b60..855506ef9 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 { performance } from 'node:perf_hooks';
import { fileURLToPath } from 'node:url';
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 a425807dc..fd9bbae66 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 00b8d176c..12b37ae00 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 80f18ae0f..a2dc42df9 100644
--- a/packages/astro/src/core/redirects/helpers.ts
+++ b/packages/astro/src/core/redirects/helpers.ts
@@ -1,4 +1,8 @@
-import type { RedirectRouteData, RouteData } from '../../@types/astro.js';
+import type { RouteData } from '../../types/public/internal.js';
+
+type RedirectRouteData = RouteData & {
+ redirect: string;
+};
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 a19d11080..ab0554d0c 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 db14701b0..b56a2eaf2 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 e962d98d3..c462cd4b8 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 cf7d02d48..a45fb16a8 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 42cc8fd05..8daec8d53 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 399795675..3329c42cd 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 ab87204e4..1c767083d 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 7c766ee20..827c8fddf 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 4e4b41b70..2c1c1f77c 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 dd3c8cc53..8bcd473d0 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 df548ec82..14980f63e 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 nodeFs from 'node:fs';
@@ -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 4ab635ec6..e3565864d 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 65f223aa0..8a9a9d27f 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 852aa703b..c0cf600f0 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 40a8b95fb..403b3fb95 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 43cd24cc1..802c39cc5 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 408268397..dc1c665c6 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 f30caed08..a6fce3354 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 1f11f55e6..a2f9a25ba 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 368a1b9b1..73ed57177 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 573ae9cf9..8bc79e087 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 92b3478e3..02ab6bf9e 100644
--- a/packages/astro/src/core/sync/index.ts
+++ b/packages/astro/src/core/sync/index.ts
@@ -3,7 +3,6 @@ import { performance } from 'node:perf_hooks';
import { fileURLToPath } from 'node:url';
import { dim } from 'kleur/colors';
import { type HMRPayload, createServer } from 'vite';
-import type { AstroConfig, AstroInlineConfig, AstroSettings } from '../../@types/astro.js';
import { CONTENT_TYPES_FILE, DATA_STORE_FILE } from '../../content/consts.js';
import { globalContentLayer } from '../../content/content-layer.js';
import { createContentTypesGenerator } from '../../content/index.js';
@@ -13,6 +12,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 91084c36f..1f7d1d304 100644
--- a/packages/astro/src/core/sync/write-files.ts
+++ b/packages/astro/src/core/sync/write-files.ts
@@ -3,7 +3,7 @@ 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';
diff --git a/packages/astro/src/core/util.ts b/packages/astro/src/core/util.ts
index 654d19829..497d54610 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 27436f967..90a29685d 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 fdcd6ce40..934ba79ca 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 18049ac04..6e919f127 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 aa38b63bb..c7e676f75 100644
--- a/packages/astro/src/i18n/index.ts
+++ b/packages/astro/src/i18n/index.ts
@@ -1,15 +1,11 @@
import { appendForwardSlash, joinPaths } from '@astrojs/internal-helpers/path';
-import type {
- APIContext,
- AstroConfig,
- Locales,
- SSRManifest,
- ValidRedirectStatus,
-} from '../@types/astro.js';
+import type { SSRManifest } from '../core/app/types.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';
diff --git a/packages/astro/src/i18n/middleware.ts b/packages/astro/src/i18n/middleware.ts
index 097332805..7c2fc1406 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 052fe01fc..98a44a19c 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 7aa4d327b..5ee79a883 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 87de3592b..f59a25b15 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 c0b960433..39d8ab69f 100644
--- a/packages/astro/src/integrations/hooks.ts
+++ b/packages/astro/src/integrations/hooks.ts
@@ -3,24 +3,23 @@ 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 { ContentEntryType, DataEntryType } from '../types/public/content.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';
async function withTakingALongTimeMsg<T>({
@@ -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 413257faa..86f4d0187 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 73b584bae..bb71231c5 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 ca1d50a6a..e7405ddc0 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 2b92c5fb6..7c8779b43 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 d64c6d500..560895b15 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 cbdddff5c..888b012e0 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 4097b66b1..e34e0d5fd 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 e63667a12..12ab602a2 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 6a6aba42d..cc58411cf 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 38559e0f9..34adf4f01 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 7ee42da84..192e4509b 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 2e56b0f24..fafc8e26d 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 9731f3597..86c616bec 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 08ea61cac..e24698d43 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 990d5da6e..e32b1a42f 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 b603eecb3..98521181c 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 f894af311..0c6e497e3 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 8e072b7a3..c5fc488d4 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 9be4d9b31..c7d858ffb 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 928d23ad8..20649b64d 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<AstroComponentFactory> {
diff --git a/packages/astro/src/runtime/server/astro-global.ts b/packages/astro/src/runtime/server/astro-global.ts
index 5948c8ff3..74b32e331 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 900d604fd..674d62093 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 ab6396566..982ff9977 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 {
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 2491ab589..7280e216c 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 db319eb1a..dab33a031 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 3246a7e1b..029231a28 100644
--- a/packages/astro/src/runtime/server/render/astro/instance.ts
+++ b/packages/astro/src/runtime/server/render/astro/instance.ts
@@ -1,7 +1,7 @@
-import type { SSRResult } from '../../../../@types/astro.js';
import type { ComponentSlots } from '../slot.js';
import type { AstroComponentFactory } from './factory.js';
+import type { SSRResult } from '../../../../types/public/internal.js';
import { isPromise } from '../../util.js';
import { renderChild } from '../any.js';
import type { RenderDestination } from '../common.js';
diff --git a/packages/astro/src/runtime/server/render/astro/render.ts b/packages/astro/src/runtime/server/render/astro/render.ts
index 41845b7b9..adc335495 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 0845bdd65..77f05dfcc 100644
--- a/packages/astro/src/runtime/server/render/common.ts
+++ b/packages/astro/src/runtime/server/render/common.ts
@@ -1,6 +1,6 @@
-import type { SSRResult } from '../../../@types/astro.js';
import type { RenderInstruction } from './instruction.js';
+import type { SSRResult } from '../../../types/public/internal.js';
import type { HTMLBytes, HTMLString } from '../escape.js';
import { markHTMLString } from '../escape.js';
import {
diff --git a/packages/astro/src/runtime/server/render/component.ts b/packages/astro/src/runtime/server/render/component.ts
index 449f58fbc..300911acd 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 e2b194df3..f92b4889a 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 49dd5abed..01f11f21e 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 35a7ec789..0e0bcf295 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 1b9c5ce1b..6d9283790 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 0a0721134..fce702364 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 d02a32d82..0df374406 100644
--- a/packages/astro/src/runtime/server/render/slot.ts
+++ b/packages/astro/src/runtime/server/render/slot.ts
@@ -1,7 +1,7 @@
-import type { SSRResult } from '../../../@types/astro.js';
import { renderTemplate } from './astro/render-template.js';
import type { RenderInstruction } from './instruction.js';
+import type { SSRResult } from '../../../types/public/internal.js';
import { HTMLString, markHTMLString, unescapeHTML } from '../escape.js';
import { renderChild } from './any.js';
import { type RenderDestination, type RenderInstance, chunkToString } from './common.js';
diff --git a/packages/astro/src/runtime/server/render/tags.ts b/packages/astro/src/runtime/server/render/tags.ts
index 093c51a3c..baba11a5b 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 5dc821aa5..19ac2f2b1 100644
--- a/packages/astro/src/runtime/server/render/util.ts
+++ b/packages/astro/src/runtime/server/render/util.ts
@@ -1,16 +1,13 @@
-import type { SSRElement } from '../../../@types/astro.js';
import type { RenderDestination, RenderDestinationChunk, RenderFunction } from './common.js';
import { clsx } from 'clsx';
+import type { SSRElement } from '../../../types/public/internal.js';
import { HTMLString, markHTMLString } from '../escape.js';
export const voidElementNames =
/^(area|base|br|col|command|embed|hr|img|input|keygen|link|meta|param|source|track|wbr)$/i;
const htmlBooleanAttributes =
/^(?:allowfullscreen|async|autofocus|autoplay|controls|default|defer|disabled|disablepictureinpicture|disableremoteplayback|formnovalidate|hidden|loop|nomodule|novalidate|open|playsinline|readonly|required|reversed|scoped|seamless|itemscope)$/i;
-const htmlEnumAttributes = /^(?:contenteditable|draggable|spellcheck|value)$/i;
-// Note: SVG is case-sensitive!
-const svgEnumAttributes = /^(?:autoReverse|externalResourcesRequired|focusable|preserveAlpha)$/i;
const AMPERSAND_REGEX = /&/g;
const DOUBLE_QUOTE_REGEX = /"/g;
@@ -67,13 +64,6 @@ export function addAttribute(value: any, key: string, shouldEscape = true) {
return '';
}
- if (value === false) {
- if (htmlEnumAttributes.test(key) || svgEnumAttributes.test(key)) {
- return markHTMLString(` ${key}="false"`);
- }
- return '';
- }
-
// compiler directives cannot be applied dynamically, log a warning and ignore.
if (STATIC_DIRECTIVES.has(key)) {
// eslint-disable-next-line no-console
@@ -115,11 +105,16 @@ Make sure to use the static attribute syntax (\`${key}={value}\`) instead of the
}
// Boolean values only need the key
- if (value === true && (key.startsWith('data-') || htmlBooleanAttributes.test(key))) {
+ if (htmlBooleanAttributes.test(key)) {
+ return markHTMLString(value ? ` ${key}` : '');
+ }
+
+ // Other attributes with an empty string value can omit rendering the value
+ if (value === '') {
return markHTMLString(` ${key}`);
- } else {
- return markHTMLString(` ${key}="${toAttributeString(value, shouldEscape)}"`);
}
+
+ return markHTMLString(` ${key}="${toAttributeString(value, shouldEscape)}"`);
}
// Adds support for `<Component {...value} />
diff --git a/packages/astro/src/runtime/server/scripts.ts b/packages/astro/src/runtime/server/scripts.ts
index 84f2dcd52..ca9cad1fb 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 522b05256..6afe91917 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 8887d3dae..4baae442a 100644
--- a/packages/astro/src/runtime/server/transition.ts
+++ b/packages/astro/src/runtime/server/transition.ts
@@ -1,12 +1,12 @@
import cssesc from 'cssesc';
+import { fade, slide } from '../../transitions/index.js';
+import type { SSRResult } from '../../types/public/internal.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';
const transitionNameMap = new WeakMap<SSRResult, number>();
diff --git a/packages/astro/src/toolbar/index.ts b/packages/astro/src/toolbar/index.ts
index bd05e4417..78d7158b2 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 32c91752f..d4d0510e6 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 d87052f2d..05bfb0972 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 d88c96f89..56f086a06 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/README.md b/packages/astro/src/types/README.md
new file mode 100644
index 000000000..103312106
--- /dev/null
+++ b/packages/astro/src/types/README.md
@@ -0,0 +1,5 @@
+# `types/`
+
+In this folder rest the types that are used throughout Astro. Typically folders for corresponding features will have a corresponding `types.ts` file in their folder. For example, the `src/assets/types.ts` contain the types for `astro:assets`. However this folder can be useful for types that are used across multiple features, or generally don't fit in any other folder.
+
+This folder additionally contain a `public` folder, which contains types that are exposed to users one way or another. Remember that these types are part of the public API, and as such follow the same semver contract as the rest of Astro.
diff --git a/packages/astro/src/types/astro.ts b/packages/astro/src/types/astro.ts
new file mode 100644
index 000000000..6aa79a959
--- /dev/null
+++ b/packages/astro/src/types/astro.ts
@@ -0,0 +1,93 @@
+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 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<string, string>;
+ 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<SSRManifest['serverIslandMap']>;
+ serverIslandNameMap: NonNullable<SSRManifest['serverIslandNameMap']>;
+ injectedTypes: Array<InjectedType>;
+}
+
+/** 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 000000000..4bb94f5ca
--- /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<string, GetStaticPathsItem>;
+};
+
+/**
+ * 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> | GetStaticPathsResult;
+
+/**
+ * paginate() Options
+ *
+ * [Astro reference](https://docs.astro.build/en/reference/api-reference/#paginate)
+ */
+export interface PaginateOptions<PaginateProps extends Props, PaginateParams extends Params> {
+ /** 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<T = any> {
+ /** 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<AdditionalPaginateProps, AdditionalPaginateParams>,
+) => {
+ params: Simplify<
+ {
+ page: string | undefined;
+ } & OmitIndexSignature<AdditionalPaginateParams>
+ >;
+ props: Simplify<
+ {
+ page: Page<PaginateData>;
+ } & OmitIndexSignature<AdditionalPaginateProps>
+ >;
+}[];
+
+export type APIRoute<
+ Props extends Record<string, any> = Record<string, any>,
+ APIParams extends Record<string, string | undefined> = Record<string, string | undefined>,
+> = (context: APIContext<Props, APIParams>) => Response | Promise<Response>;
+
+export type RewritePayload = string | URL | Request;
+
+export type MiddlewareNext = (rewritePayload?: RewritePayload) => Promise<Response>;
+export type MiddlewareHandler = (
+ context: APIContext,
+ next: MiddlewareNext,
+) => Promise<Response> | Response | Promise<void> | 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<typeof getStaticPaths>;
+ * // ^? { slug: string; }
+ *
+ * const { slug } = Astro.params as Params;
+ * ```
+ */
+export type InferGetStaticParamsType<T> = T extends (
+ opts?: GetStaticPathsOptions,
+) => infer R | Promise<infer R>
+ ? R extends Array<infer U>
+ ? 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<typeof getStaticPaths>;
+ * // ^? { propA: boolean; propB: number; }
+ *
+ * const { propA, propB } = Astro.props;
+ * ```
+ */
+export type InferGetStaticPropsType<T> = T extends (
+ opts: GetStaticPathsOptions,
+) => infer R | Promise<infer R>
+ ? R extends Array<infer U>
+ ? U extends { props: infer P }
+ ? P
+ : never
+ : never
+ : never;
+
+export type Params = Record<string, string | undefined>;
+export type Props = Record<string, unknown>;
diff --git a/packages/astro/src/@types/astro.ts b/packages/astro/src/types/public/config.ts
index a10ad5126..178b9edf7 100644
--- a/packages/astro/src/@types/astro.ts
+++ b/packages/astro/src/types/public/config.ts
@@ -1,408 +1,38 @@
-import type { OutgoingHttpHeaders } from 'node:http';
-import type { AddressInfo } from 'node:net';
import type {
- MarkdownHeading,
- MarkdownVFile,
RehypePlugins,
RemarkPlugins,
RemarkRehype,
ShikiConfig,
} from '@astrojs/markdown-remark';
-import type * as babel from '@babel/core';
-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';
-
-export type { AstroIntegrationLogger, ToolbarServerHelpers };
-
-export type {
- MarkdownHeading,
- RehypePlugins,
- RemarkPlugins,
- 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 AstroBuiltinProps {
- 'client:load'?: boolean;
- 'client:idle'?: boolean;
- 'client:media'?: string;
- 'client:visible'?: ClientVisibleOptions | boolean;
- 'client:only'?: boolean | string;
- 'server:defer'?: boolean;
-}
-
-export type ClientVisibleOptions = Pick<IntersectionObserverInit, 'rootMargin'>;
-
-export interface TransitionAnimation {
- name: string; // The name of the keyframe
- delay?: number | string;
- duration?: number | string;
- easing?: string;
- fillMode?: string;
- direction?: string;
-}
-
-export interface TransitionAnimationPair {
- old: TransitionAnimation | TransitionAnimation[];
- new: TransitionAnimation | TransitionAnimation[];
-}
-
-export interface TransitionDirectionalAnimations {
- forwards: TransitionAnimationPair;
- backwards: TransitionAnimationPair;
-}
-
-export type TransitionAnimationValue =
- | 'initial'
- | 'slide'
- | 'fade'
- | 'none'
- | TransitionDirectionalAnimations;
-
-// Allow users to extend this for astro-jsx.d.ts
-
-// eslint-disable-next-line @typescript-eslint/no-empty-object-type
-export interface AstroClientDirectives {}
-
-export interface AstroBuiltinAttributes {
- 'class:list'?:
- | Record<string, boolean>
- | Record<any, any>
- | Iterable<string>
- | Iterable<any>
- | 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 { OutgoingHttpHeaders } from 'node:http';
+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<T extends Record<string, any> = Record<string, any>> {
+ 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<string, any> = Record<string, any>,
- Self = AstroComponentFactory,
- Params extends Record<string, string | undefined> = Record<string, string | undefined>,
-> extends AstroGlobalPartial,
- AstroSharedContext<Props, Params> {
- /**
- * 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;
- * ---
- * <h1>{id}</h1>
- * ```
- *
- * [Astro reference](https://docs.astro.build/en/reference/api-reference/#astroparams)
- */
- params: AstroSharedContext<Props, Params>['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, Params>['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 <Astro.self /> 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<string, true | undefined> & {
- /**
- * 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')
- * }
- * ---
- * <Fragment set:html={html} />
- * ```
- *
- * 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
- * <Component>
- * {(hello, world) => <div>{hello}, {world}!</div>}
- * </Component>
- * ```
- *
- * [Astro reference](https://docs.astro.build/en/reference/api-reference/#astroslots)
- */
- render(slotName: string, args?: any[]): Promise<string>;
- };
-}
+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<AstroInstance[]>;
- glob<T extends Record<string, any>>(
- globStr: `${any}${MarkdowFileExtension}`,
- ): Promise<MarkdownInstance<T>[]>;
- glob<T extends Record<string, any>>(globStr: `${any}.mdx`): Promise<MDXInstance<T>[]>;
- glob<T extends Record<string, any>>(globStr: string): Promise<T[]>;
- /**
- * 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 `<meta name="generator" content={Astro.generator} />` 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}
@@ -456,14 +86,17 @@ type ServerConfig = {
open?: string | boolean;
};
-export interface ViteUserConfig extends vite.UserConfig {
- ssr?: vite.SSROptions;
+export interface ViteUserConfig extends OriginalViteUserConfig {
+ ssr?: ViteSSROptions;
}
-export interface ImageServiceConfig<T extends Record<string, any> = Record<string, any>> {
- 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 type,
+// consider replacing it with the following lines:
+// export interface AstroUserConfig extends z.input<typeof AstroConfigSchema> {
+// }
/**
* Astro User Config
@@ -2407,58 +2040,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<typeof AstroConfigSchema> {
-// }
-
-/**
- * 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 `<head>` 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.
@@ -2510,1230 +2091,10 @@ export interface AstroInlineOnlyConfig {
logger?: Logger;
}
-export type ContentEntryModule = {
- id: string;
- collection: string;
- slug: string;
- body: string;
- data: Record<string, unknown>;
- _internal: {
- rawData: string;
- filePath: string;
- };
-};
-
-export type DataEntryModule = {
- id: string;
- collection: string;
- data: Record<string, unknown>;
- _internal: {
- rawData: string;
- filePath: string;
- };
-};
-
-export type ContentEntryRenderFuction = (entry: DataEntry) => Promise<RenderedContent>;
-
-export interface ContentEntryType {
- extensions: string[];
- getEntryInfo(params: {
- fileUrl: URL;
- contents: string;
- }): GetContentEntryInfoReturnType | Promise<GetContentEntryInfoReturnType>;
- getRenderModule?(
- this: rollup.PluginContext,
- params: {
- contents: string;
- fileUrl: URL;
- viteId: string;
- },
- ): rollup.LoadResult | Promise<rollup.LoadResult>;
- contentModuleTypes?: string;
- getRenderFunction?(settings: AstroSettings): Promise<ContentEntryRenderFuction>;
-
- /**
- * 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<string, unknown>;
- /**
- * 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<GetDataEntryInfoReturnType>;
-}
-
-export type GetDataEntryInfoReturnType = { data: Record<string, unknown>; 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<string, string>;
- 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<SSRManifest['serverIslandMap']>;
- serverIslandNameMap: NonNullable<SSRManifest['serverIslandNameMap']>;
- injectedTypes: Array<InjectedType>;
-}
-
-export type AsyncRendererComponentFn<U> = (
- Component: any,
- props: any,
- slots: Record<string, string>,
- metadata?: AstroComponentMetadata,
-) => Promise<U>;
-
-/** 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<T extends Record<string, any>> {
- 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 />` */
- 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<Record<string, any>>;
-
-export type MDXInstance<T extends Record<string, any>> = Omit<
- MarkdownInstance<T>,
- 'rawContent' | 'compiledContent'
->;
-
-export interface MarkdownLayoutProps<T extends Record<string, any>> {
- frontmatter: {
- file: MarkdownInstance<T>['file'];
- url: MarkdownInstance<T>['url'];
- } & T;
- file: MarkdownInstance<T>['file'];
- url: MarkdownInstance<T>['url'];
- headings: MarkdownHeading[];
- rawContent: MarkdownInstance<T>['rawContent'];
- compiledContent: MarkdownInstance<T>['compiledContent'];
-}
-
-export type MDXLayoutProps<T extends Record<string, any>> = Omit<
- MarkdownLayoutProps<T>,
- 'rawContent' | 'compiledContent'
->;
-
-export type GetHydrateCallback = () => Promise<() => void | Promise<void>>;
-
-/**
- * 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<string, GetStaticPathsItem>;
-};
-
-/**
- * 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> | 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<typeof getStaticPaths>;
- * // ^? { slug: string; }
- *
- * const { slug } = Astro.params as Params;
- * ```
- */
-export type InferGetStaticParamsType<T> = T extends (
- opts?: GetStaticPathsOptions,
-) => infer R | Promise<infer R>
- ? R extends Array<infer U>
- ? 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<typeof getStaticPaths>;
- * // ^? { propA: boolean; propB: number; }
- *
- * const { propA, propB } = Astro.props;
- * ```
- */
-export type InferGetStaticPropsType<T> = T extends (
- opts: GetStaticPathsOptions,
-) => infer R | Promise<infer R>
- ? R extends Array<infer U>
- ? 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<JSXTransformConfig>;
-
-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<T extends Record<string, any> = Record<string, any>> = T & {
- astro: MarkdownMetadata;
- url: string | undefined;
- file: string;
-};
-
-/**
- * paginate() Options
- *
- * [Astro reference](https://docs.astro.build/en/reference/api-reference/#paginate)
- */
-export interface PaginateOptions<PaginateProps extends Props, PaginateParams extends Params> {
- /** 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<T = any> {
- /** 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<AdditionalPaginateProps, AdditionalPaginateParams>,
-) => {
- params: Simplify<
- {
- page: string | undefined;
- } & OmitIndexSignature<AdditionalPaginateParams>
- >;
- props: Simplify<
- {
- page: Page<PaginateData>;
- } & OmitIndexSignature<AdditionalPaginateProps>
- >;
-}[];
-
-export type Params = Record<string, string | undefined>;
-
-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<string, any> = Record<string, any>,
- RouteParams extends Record<string, string | undefined> = Record<string, string | undefined>,
-> {
- /**
- * 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<TAccept>,
- TAction extends ActionClient<unknown, TAccept, TInputSchema>,
- >(
- action: TAction,
- ) => ActionReturnType<TAction> | undefined;
- /**
- * Call action handler from the server.
- */
- callAction: <
- TAccept extends ActionAccept,
- TInputSchema extends ActionInputSchema<TAccept>,
- TOutput,
- TAction extends
- | ActionClient<TOutput, TAccept, TInputSchema>
- | ActionClient<TOutput, TAccept, TInputSchema>['orThrow'],
- >(
- action: TAction,
- input: Parameters<TAction>[0],
- ) => Promise<ActionReturnType<TAction>>;
- /**
- * 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<Response>;
-
- /**
- * 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<string, any> = Record<string, any>,
- APIParams extends Record<string, string | undefined> = Record<string, string | undefined>,
-> extends AstroSharedContext<Props, Params> {
- /**
- * 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<Props, APIParams>['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, APIParams>['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;
- * ---
- * <h1>{greeting}</h1>
- * ```
- *
- * [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<string, any> = Record<string, any>,
- APIParams extends Record<string, string | undefined> = Record<string, string | undefined>,
-> = (context: APIContext<Props, APIParams>) => Response | Promise<Response>;
-
-export interface EndpointHandler {
- [method: string]: APIRoute;
-}
-
-export type Props = Record<string, unknown>;
-
-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<boolean>;
- renderToStaticMarkup: AsyncRendererComponentFn<{
- html: string;
- attrs?: Record<string, string>;
- }>;
- 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<AstroRenderer, 'name' | 'clientEntrypoint'> {
- ssr: SSRLoadedRendererValue;
-}
-
-export type HookParameters<
- Hook extends keyof AstroIntegration['hooks'],
- Fn = AstroIntegration['hooks'][Hook],
-> = Fn extends (...args: any) => any ? Parameters<Fn>[0] : never;
-
-declare global {
- // eslint-disable-next-line @typescript-eslint/no-namespace
- namespace Astro {
- export interface IntegrationHooks {
- 'astro:config:setup': (options: {
- config: AstroConfig;
- command: 'dev' | 'build' | 'preview';
- isRestart: boolean;
- updateConfig: (newConfig: DeepPartial<AstroConfig>) => AstroConfig;
- addRenderer: (renderer: AstroRenderer) => void;
- addWatchFile: (path: URL | string) => void;
- injectScript: (stage: InjectedScriptStage, content: string) => void;
- injectRoute: (injectRoute: InjectedRoute) => void;
- addClientDirective: (directive: ClientDirectiveConfig) => void;
- /**
- * @deprecated Use `addDevToolbarApp` instead.
- * TODO: Fully remove in Astro 5.0
- */
- addDevOverlayPlugin: (entrypoint: string) => 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<void>;
- 'astro:config:done': (options: {
- config: AstroConfig;
- setAdapter: (adapter: AstroAdapter) => void;
- injectTypes: (injectedType: InjectedType) => URL;
- logger: AstroIntegrationLogger;
- }) => void | Promise<void>;
- 'astro:server:setup': (options: {
- server: vite.ViteDevServer;
- logger: AstroIntegrationLogger;
- toolbar: ReturnType<typeof getToolbarServerCommunicationHelpers>;
- }) => void | Promise<void>;
- 'astro:server:start': (options: {
- address: AddressInfo;
- logger: AstroIntegrationLogger;
- }) => void | Promise<void>;
- 'astro:server:done': (options: { logger: AstroIntegrationLogger }) => void | Promise<void>;
- '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<RouteData, URL>;
- /**
- * File path of the emitted middleware
- */
- middlewareEntryPoint: URL | undefined;
- logger: AstroIntegrationLogger;
- }) => void | Promise<void>;
- 'astro:build:start': (options: { logger: AstroIntegrationLogger }) => void | Promise<void>;
- 'astro:build:setup': (options: {
- vite: vite.InlineConfig;
- pages: Map<string, PageBuildData>;
- target: 'client' | 'server';
- updateConfig: (newConfig: vite.InlineConfig) => void;
- logger: AstroIntegrationLogger;
- }) => void | Promise<void>;
- 'astro:build:generated': (options: {
- dir: URL;
- logger: AstroIntegrationLogger;
- }) => void | Promise<void>;
- 'astro:build:done': (options: {
- pages: { pathname: string }[];
- dir: URL;
- routes: RouteData[];
- logger: AstroIntegrationLogger;
- cacheManifest: boolean;
- }) => void | Promise<void>;
- 'astro:route:setup': (options: {
- route: RouteOptions;
- logger: AstroIntegrationLogger;
- }) => void | Promise<void>;
- }
- }
-}
-
-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<Record<string, unknown>>;
-}
-
-export type RewritePayload = string | URL | Request;
-
-export type MiddlewareNext = (rewritePayload?: RewritePayload) => Promise<Response>;
-export type MiddlewareHandler = (
- context: APIContext,
- next: MiddlewareNext,
-) => Promise<Response> | Response | Promise<void> | 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<string, any>;
- 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<SSRElement>;
- scripts: Set<SSRElement>;
- links: Set<SSRElement>;
- componentMetadata: Map<string, SSRComponentMetadata>;
- inlinedScripts: Map<string, string>;
- createAstro(
- Astro: AstroGlobalPartial,
- props: Record<string, any>,
- slots: Record<string, any> | null,
- ): AstroGlobal;
- params: Params;
- resolve: (s: string) => Promise<string>;
- response: AstroGlobal['response'];
- request: AstroGlobal['request'];
- actionResult?: ReturnType<AstroGlobal['getActionResult']>;
- renderers: SSRLoadedRenderer[];
- /**
- * Map of directive name (e.g. `load`) to the directive script code
- */
- clientDirectives: Map<string, string>;
- compressHTML: boolean;
- partial: boolean;
- /**
- * Only used for logging
- */
- pathname: string;
- cookies: AstroCookies | undefined;
- serverIslandNameMap: Map<string, string>;
- trailingSlash: AstroConfig['trailingSlash'];
- key: Promise<CryptoKey>;
- _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<string>;
- /**
- * Used by `renderScript` to track script ids that have been rendered,
- * so we only render each once.
- */
- renderedScripts: Set<string>;
- hasDirectives: Set<string>;
- hasRenderedHead: boolean;
- headInTree: boolean;
- extraHead: string[];
- propagators: Set<AstroComponentInstance>;
-}
-
-/* Preview server stuff */
-export interface PreviewServer {
- host?: string;
- port: number;
- closed(): Promise<void>;
- stop(): Promise<void>;
-}
-
-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<PreviewServer>;
-
-export interface PreviewModule {
- default: CreatePreviewServer;
-}
-
-/* Client Directives */
-type DirectiveHydrate = () => Promise<void>;
-type DirectiveLoad = () => Promise<DirectiveHydrate>;
-
-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<void>;
- beforeTogglingOff?(canvas: ShadowRoot): boolean | Promise<boolean>;
-};
-
-// An app that has been loaded and as such contain all of its properties
-export type ResolvedDevToolbarApp = DevToolbarAppMeta & Omit<DevToolbarApp, 'id' | 'name' | 'icon'>;
-
-// 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;
- };
- };
-
+// HACK! astro:db augment this type that is used in the config
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<string, any>;
}
-
- 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<SSRLoadedRenderer>;
-
-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 000000000..ac58c918f
--- /dev/null
+++ b/packages/astro/src/types/public/content.ts
@@ -0,0 +1,121 @@
+import type { MarkdownHeading } from '@astrojs/markdown-remark';
+import type * as rollup from 'rollup';
+import type { DataEntry, RenderedContent } from '../../content/data-store.js';
+import type { AstroComponentFactory } from '../../runtime/server/index.js';
+import type { AstroConfig } from './config.js';
+
+export interface AstroInstance {
+ file: string;
+ url: string | undefined;
+ default: AstroComponentFactory;
+}
+
+export interface MarkdownInstance<T extends Record<string, any>> {
+ 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 />` */
+ 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<T extends Record<string, any>> = Omit<
+ MarkdownInstance<T>,
+ 'rawContent' | 'compiledContent'
+>;
+
+export interface MarkdownLayoutProps<T extends Record<string, any>> {
+ frontmatter: {
+ file: MarkdownInstance<T>['file'];
+ url: MarkdownInstance<T>['url'];
+ } & T;
+ file: MarkdownInstance<T>['file'];
+ url: MarkdownInstance<T>['url'];
+ headings: MarkdownHeading[];
+ rawContent: MarkdownInstance<T>['rawContent'];
+ compiledContent: MarkdownInstance<T>['compiledContent'];
+}
+
+export type MDXLayoutProps<T extends Record<string, any>> = Omit<
+ MarkdownLayoutProps<T>,
+ 'rawContent' | 'compiledContent'
+>;
+
+export type ContentEntryModule = {
+ id: string;
+ collection: string;
+ slug: string;
+ body: string;
+ data: Record<string, unknown>;
+ _internal: {
+ rawData: string;
+ filePath: string;
+ };
+};
+
+export type DataEntryModule = {
+ id: string;
+ collection: string;
+ data: Record<string, unknown>;
+ _internal: {
+ rawData: string;
+ filePath: string;
+ };
+};
+
+export type ContentEntryRenderFunction = (entry: DataEntry) => Promise<RenderedContent>;
+
+export interface ContentEntryType {
+ extensions: string[];
+ getEntryInfo(params: {
+ fileUrl: URL;
+ contents: string;
+ }): GetContentEntryInfoReturnType | Promise<GetContentEntryInfoReturnType>;
+ getRenderModule?(
+ this: rollup.PluginContext,
+ params: {
+ contents: string;
+ fileUrl: URL;
+ viteId: string;
+ },
+ ): rollup.LoadResult | Promise<rollup.LoadResult>;
+ contentModuleTypes?: string;
+ getRenderFunction?(config: AstroConfig): Promise<ContentEntryRenderFunction>;
+
+ /**
+ * 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<string, unknown>;
+ /**
+ * 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<GetDataEntryInfoReturnType>;
+}
+
+export type GetDataEntryInfoReturnType = { data: Record<string, unknown>; 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 000000000..5f05b7a66
--- /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<string, any> = Record<string, any>,
+ Self = AstroComponentFactory,
+ // eslint-disable-next-line @typescript-eslint/no-shadow
+ Params extends Record<string, string | undefined> = Record<string, string | undefined>,
+> extends AstroGlobalPartial,
+ AstroSharedContext<Props, Params> {
+ /**
+ * 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;
+ * ---
+ * <h1>{id}</h1>
+ * ```
+ *
+ * [Astro reference](https://docs.astro.build/en/reference/api-reference/#astroparams)
+ */
+ params: AstroSharedContext<Props, Params>['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, Params>['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 <Astro.self /> 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<string, true | undefined> & {
+ /**
+ * 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')
+ * }
+ * ---
+ * <Fragment set:html={html} />
+ * ```
+ *
+ * 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
+ * <Component>
+ * {(hello, world) => <div>{hello}, {world}!</div>}
+ * </Component>
+ * ```
+ *
+ * [Astro reference](https://docs.astro.build/en/reference/api-reference/#astroslots)
+ */
+ render(slotName: string, args?: any[]): Promise<string>;
+ };
+}
+
+/** 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<AstroInstance[]>;
+ glob<T extends Record<string, any>>(
+ globStr: `${any}${MarkdownFileExtension}`,
+ ): Promise<MarkdownInstance<T>[]>;
+ glob<T extends Record<string, any>>(globStr: `${any}.mdx`): Promise<MDXInstance<T>[]>;
+ glob<T extends Record<string, any>>(globStr: string): Promise<T[]>;
+ /**
+ * 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 `<meta name="generator" content={Astro.generator} />` 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<string, any> = Record<string, any>,
+ RouteParams extends Record<string, string | undefined> = Record<string, string | undefined>,
+> {
+ /**
+ * 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<TAccept>,
+ TAction extends ActionClient<unknown, TAccept, TInputSchema>,
+ >(
+ action: TAction,
+ ) => ActionReturnType<TAction> | undefined;
+ /**
+ * Call action handler from the server.
+ */
+ callAction: <
+ TAccept extends ActionAccept,
+ TInputSchema extends ActionInputSchema<TAccept>,
+ TOutput,
+ TAction extends
+ | ActionClient<TOutput, TAccept, TInputSchema>
+ | ActionClient<TOutput, TAccept, TInputSchema>['orThrow'],
+ >(
+ action: TAction,
+ input: Parameters<TAction>[0],
+ ) => Promise<ActionReturnType<TAction>>;
+ /**
+ * 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<Response>;
+
+ /**
+ * 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<string, any> = Record<string, any>,
+ APIParams extends Record<string, string | undefined> = Record<string, string | undefined>,
+> extends AstroSharedContext<Props, Params> {
+ /**
+ * 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<Props, APIParams>['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, APIParams>['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;
+ * ---
+ * <h1>{greeting}</h1>
+ * ```
+ *
+ * [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;
+}
diff --git a/packages/astro/src/types/public/elements.ts b/packages/astro/src/types/public/elements.ts
new file mode 100644
index 000000000..83301f7b8
--- /dev/null
+++ b/packages/astro/src/types/public/elements.ts
@@ -0,0 +1,47 @@
+import type { TransitionAnimationValue } from './view-transitions.js';
+
+export interface AstroComponentDirectives extends Astro.ClientDirectives {
+ '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<IntersectionObserverInit, 'rootMargin'>;
+
+export interface AstroBuiltinAttributes {
+ 'class:list'?:
+ | Record<string, boolean>
+ | Record<any, any>
+ | Iterable<string>
+ | Iterable<any>
+ | 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;
+}
diff --git a/packages/astro/src/types/public/extendables.ts b/packages/astro/src/types/public/extendables.ts
new file mode 100644
index 000000000..1592eda19
--- /dev/null
+++ b/packages/astro/src/types/public/extendables.ts
@@ -0,0 +1,21 @@
+/* eslint-disable @typescript-eslint/no-namespace */
+/* eslint-disable @typescript-eslint/no-empty-object-type */
+import type { AstroClientDirectives } from './elements.js';
+import type { BaseIntegrationHooks } from './integrations.js';
+
+// The interfaces in this file can be extended by users
+declare global {
+ namespace App {
+ /**
+ * Used by middlewares to store information, that can be read by the user via the global `Astro.locals`
+ */
+ export interface Locals {}
+ }
+
+ namespace Astro {
+ export interface IntegrationHooks extends BaseIntegrationHooks {}
+ export interface ClientDirectives extends AstroClientDirectives {}
+ }
+}
+
+export {};
diff --git a/packages/astro/src/types/public/index.ts b/packages/astro/src/types/public/index.ts
new file mode 100644
index 000000000..5df509013
--- /dev/null
+++ b/packages/astro/src/types/public/index.ts
@@ -0,0 +1,44 @@
+export type * from './config.js';
+export type * from './elements.js';
+export type * from './extendables.js';
+export type * from './toolbar.js';
+export type * from './view-transitions.js';
+export type * from './integrations.js';
+export type * from './internal.js';
+export type * from './context.js';
+export type * from './preview.js';
+export type * from './content.js';
+export type * from './common.js';
+
+export type { AstroIntegrationLogger } from '../../core/logger/core.js';
+export type { ToolbarServerHelpers } from '../../runtime/client/dev-toolbar/helpers.js';
+
+export type {
+ MarkdownHeading,
+ RehypePlugins,
+ RemarkPlugins,
+ 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 type { ContainerRenderer } from '../../container/index.js';
diff --git a/packages/astro/src/types/public/integrations.ts b/packages/astro/src/types/public/integrations.ts
new file mode 100644
index 000000000..d41abd835
--- /dev/null
+++ b/packages/astro/src/types/public/integrations.ts
@@ -0,0 +1,258 @@
+import type { AddressInfo } from 'node:net';
+import type { ViteDevServer, InlineConfig as ViteInlineConfig } from 'vite';
+import type { SerializedSSRManifest } from '../../core/app/types.js';
+import type { PageBuildData } from '../../core/build/types.js';
+import type { AstroIntegrationLogger } from '../../core/logger/core.js';
+import type { getToolbarServerCommunicationHelpers } from '../../integrations/hooks.js';
+import type { DeepPartial } from '../../type-utils.js';
+import type { AstroConfig } from './config.js';
+import type { RouteData } from './internal.js';
+import type { DevToolbarAppEntry } from './toolbar.js';
+
+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;
+}
+
+/* Client Directives */
+type DirectiveHydrate = () => Promise<void>;
+type DirectiveLoad = () => Promise<DirectiveHydrate>;
+
+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;
+}
+
+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;
+}
+
+export type AdapterSupportsKind = 'unsupported' | 'stable' | 'experimental' | 'deprecated';
+
+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 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: AstroAdapterFeatureMap;
+}
+
+export type AstroAdapterFeatureMap = {
+ /**
+ * The adapter is able serve static pages
+ */
+ staticOutput?: AdapterSupportsKind;
+ /**
+ * The adapter is able to serve pages that are static or rendered via server
+ */
+ hybridOutput?: AdapterSupportsKind;
+ /**
+ * The adapter is able to serve SSR pages
+ */
+ serverOutput?: AdapterSupportsKind;
+ /**
+ * The adapter can emit static assets
+ */
+ assets?: AstroAssetsFeature;
+
+ /**
+ * List of features that orbit around the i18n routing
+ */
+ i18nDomains?: AdapterSupportsKind;
+
+ /**
+ * The adapter is able to support `getSecret` exported from `astro:env/server`
+ */
+ envGetSecret?: AdapterSupportsKind;
+};
+
+export interface AstroAssetsFeature {
+ supportKind?: AdapterSupportsKind;
+ /**
+ * 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?: AdapterSupportsKind;
+}
+
+/**
+ * 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 `<head>` 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 InjectedType {
+ filename: string;
+ content: string;
+}
+
+export type AstroIntegrationMiddleware = {
+ order: 'pre' | 'post';
+ entrypoint: string;
+};
+
+export type HookParameters<
+ Hook extends keyof AstroIntegration['hooks'],
+ Fn = AstroIntegration['hooks'][Hook],
+> = Fn extends (...args: any) => any ? Parameters<Fn>[0] : never;
+
+export interface BaseIntegrationHooks {
+ 'astro:config:setup': (options: {
+ config: AstroConfig;
+ command: 'dev' | 'build' | 'preview';
+ isRestart: boolean;
+ updateConfig: (newConfig: DeepPartial<AstroConfig>) => 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;
+ }) => void | Promise<void>;
+ 'astro:config:done': (options: {
+ config: AstroConfig;
+ setAdapter: (adapter: AstroAdapter) => void;
+ injectTypes: (injectedType: InjectedType) => URL;
+ logger: AstroIntegrationLogger;
+ }) => void | Promise<void>;
+ 'astro:server:setup': (options: {
+ server: ViteDevServer;
+ logger: AstroIntegrationLogger;
+ toolbar: ReturnType<typeof getToolbarServerCommunicationHelpers>;
+ }) => void | Promise<void>;
+ 'astro:server:start': (options: {
+ address: AddressInfo;
+ logger: AstroIntegrationLogger;
+ }) => void | Promise<void>;
+ 'astro:server:done': (options: { logger: AstroIntegrationLogger }) => void | Promise<void>;
+ '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<RouteData, URL>;
+ /**
+ * File path of the emitted middleware
+ */
+ middlewareEntryPoint: URL | undefined;
+ logger: AstroIntegrationLogger;
+ }) => void | Promise<void>;
+ 'astro:build:start': (options: { logger: AstroIntegrationLogger }) => void | Promise<void>;
+ 'astro:build:setup': (options: {
+ vite: ViteInlineConfig;
+ pages: Map<string, PageBuildData>;
+ target: 'client' | 'server';
+ updateConfig: (newConfig: ViteInlineConfig) => void;
+ logger: AstroIntegrationLogger;
+ }) => void | Promise<void>;
+ 'astro:build:generated': (options: {
+ dir: URL;
+ logger: AstroIntegrationLogger;
+ }) => void | Promise<void>;
+ 'astro:build:done': (options: {
+ pages: { pathname: string }[];
+ dir: URL;
+ routes: RouteData[];
+ logger: AstroIntegrationLogger;
+ cacheManifest: boolean;
+ }) => void | Promise<void>;
+ 'astro:route:setup': (options: {
+ route: RouteOptions;
+ logger: AstroIntegrationLogger;
+ }) => void | Promise<void>;
+}
+
+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<Record<string, unknown>>;
+}
diff --git a/packages/astro/src/types/public/internal.ts b/packages/astro/src/types/public/internal.ts
new file mode 100644
index 000000000..bee15c6f7
--- /dev/null
+++ b/packages/astro/src/types/public/internal.ts
@@ -0,0 +1,202 @@
+// TODO: Should the types here really be public?
+
+import type { ErrorPayload as ViteErrorPayload } from 'vite';
+import type { AstroCookies } from '../../core/cookies/cookies.js';
+import type { AstroComponentInstance } from '../../runtime/server/index.js';
+import type { Params } from './common.js';
+import type { AstroConfig, RedirectConfig } from './config.js';
+import type { AstroGlobal, AstroGlobalPartial } from './context.js';
+import type { AstroRenderer } from './integrations.js';
+
+export type { SSRManifest } from '../../core/app/types.js';
+
+export interface NamedSSRLoadedRendererValue extends SSRLoadedRendererValue {
+ name: string;
+}
+
+export interface SSRLoadedRendererValue {
+ name?: string;
+ check: AsyncRendererComponentFn<boolean>;
+ renderToStaticMarkup: AsyncRendererComponentFn<{
+ html: string;
+ attrs?: Record<string, string>;
+ }>;
+ 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 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;
+}
+
+/**
+ * - 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;
+}
+
+export interface AstroComponentMetadata {
+ displayName: string;
+ hydrate?: 'load' | 'idle' | 'visible' | 'media' | 'only';
+ hydrateArgs?: any;
+ componentUrl?: string;
+ componentExport?: { value: string; namespace?: boolean };
+ astroStaticSlot: true;
+}
+
+export type AsyncRendererComponentFn<U> = (
+ Component: any,
+ props: any,
+ slots: Record<string, string>,
+ metadata?: AstroComponentMetadata,
+) => Promise<U>;
+
+export interface NamedSSRLoadedRendererValue extends SSRLoadedRendererValue {
+ name: string;
+}
+
+export interface SSRLoadedRendererValue {
+ name?: string;
+ check: AsyncRendererComponentFn<boolean>;
+ renderToStaticMarkup: AsyncRendererComponentFn<{
+ html: string;
+ attrs?: Record<string, string>;
+ }>;
+ 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<AstroRenderer, 'name' | 'clientEntrypoint'> {
+ ssr: SSRLoadedRendererValue;
+}
+
+export interface SSRElement {
+ props: Record<string, any>;
+ children: string;
+}
+
+export interface SSRResult {
+ /**
+ * Whether the page has failed with a non-recoverable error, or the client disconnected.
+ */
+ cancelled: boolean;
+ base: string;
+ styles: Set<SSRElement>;
+ scripts: Set<SSRElement>;
+ links: Set<SSRElement>;
+ componentMetadata: Map<string, SSRComponentMetadata>;
+ inlinedScripts: Map<string, string>;
+ createAstro(
+ Astro: AstroGlobalPartial,
+ props: Record<string, any>,
+ slots: Record<string, any> | null,
+ ): AstroGlobal;
+ params: Params;
+ resolve: (s: string) => Promise<string>;
+ response: AstroGlobal['response'];
+ request: AstroGlobal['request'];
+ actionResult?: ReturnType<AstroGlobal['getActionResult']>;
+ renderers: SSRLoadedRenderer[];
+ /**
+ * Map of directive name (e.g. `load`) to the directive script code
+ */
+ clientDirectives: Map<string, string>;
+ compressHTML: boolean;
+ partial: boolean;
+ /**
+ * Only used for logging
+ */
+ pathname: string;
+ cookies: AstroCookies | undefined;
+ serverIslandNameMap: Map<string, string>;
+ trailingSlash: AstroConfig['trailingSlash'];
+ key: Promise<CryptoKey>;
+ _metadata: SSRMetadata;
+}
+
+/**
+ * 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;
+};
+
+/**
+ * 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<string>;
+ /**
+ * Used by `renderScript` to track script ids that have been rendered,
+ * so we only render each once.
+ */
+ renderedScripts: Set<string>;
+ hasDirectives: Set<string>;
+ hasRenderedHead: boolean;
+ headInTree: boolean;
+ extraHead: string[];
+ propagators: Set<AstroComponentInstance>;
+}
+
+export type SSRError = Error & ViteErrorPayload['err'];
diff --git a/packages/astro/src/types/public/preview.ts b/packages/astro/src/types/public/preview.ts
new file mode 100644
index 000000000..e2794303f
--- /dev/null
+++ b/packages/astro/src/types/public/preview.ts
@@ -0,0 +1,28 @@
+import type { OutgoingHttpHeaders } from 'node:http';
+import type { AstroIntegrationLogger } from '../../core/logger/core.js';
+
+export interface PreviewServer {
+ host?: string;
+ port: number;
+ closed(): Promise<void>;
+ stop(): Promise<void>;
+}
+
+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<PreviewServer>;
+
+export interface PreviewModule {
+ default: CreatePreviewServer;
+}
diff --git a/packages/astro/src/types/public/toolbar.ts b/packages/astro/src/types/public/toolbar.ts
new file mode 100644
index 000000000..7beaab3bb
--- /dev/null
+++ b/packages/astro/src/types/public/toolbar.ts
@@ -0,0 +1,96 @@
+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';
+
+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;
+ }
+}
+
+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<void>;
+ beforeTogglingOff?(canvas: ShadowRoot): boolean | Promise<boolean>;
+};
+
+// An app that has been loaded and as such contain all of its properties
+export type ResolvedDevToolbarApp = DevToolbarAppMeta & Omit<DevToolbarApp, 'id' | 'name' | 'icon'>;
+
+export type DevToolbarMetadata = Window &
+ typeof globalThis & {
+ __astro_dev_toolbar__: {
+ root: string;
+ version: string;
+ latestAstroVersion: string | undefined;
+ debugInfo: string;
+ };
+ };
diff --git a/packages/astro/src/types/public/view-transitions.ts b/packages/astro/src/types/public/view-transitions.ts
new file mode 100644
index 000000000..1acd5003b
--- /dev/null
+++ b/packages/astro/src/types/public/view-transitions.ts
@@ -0,0 +1,40 @@
+import type {
+ TransitionBeforePreparationEvent,
+ TransitionBeforeSwapEvent,
+} from '../../transitions/events.js';
+
+export interface TransitionAnimation {
+ name: string; // The name of the keyframe
+ delay?: number | string;
+ duration?: number | string;
+ easing?: string;
+ fillMode?: string;
+ direction?: string;
+}
+
+export interface TransitionAnimationPair {
+ old: TransitionAnimation | TransitionAnimation[];
+ new: TransitionAnimation | TransitionAnimation[];
+}
+
+export interface TransitionDirectionalAnimations {
+ forwards: TransitionAnimationPair;
+ backwards: TransitionAnimationPair;
+}
+
+export type TransitionAnimationValue =
+ | 'initial'
+ | 'slide'
+ | 'fade'
+ | 'none'
+ | TransitionDirectionalAnimations;
+
+declare global {
+ interface DocumentEventMap {
+ 'astro:before-preparation': TransitionBeforePreparationEvent;
+ 'astro:after-preparation': Event;
+ 'astro:before-swap': TransitionBeforeSwapEvent;
+ 'astro:after-swap': Event;
+ 'astro:page-load': Event;
+ }
+}
diff --git a/packages/astro/src/@types/typed-emitter.ts b/packages/astro/src/types/typed-emitter.ts
index 43139bd4e..43139bd4e 100644
--- a/packages/astro/src/@types/typed-emitter.ts
+++ b/packages/astro/src/types/typed-emitter.ts
diff --git a/packages/astro/src/virtual-modules/container.ts b/packages/astro/src/virtual-modules/container.ts
index 420b3e3e2..3efc626d9 100644
--- a/packages/astro/src/virtual-modules/container.ts
+++ b/packages/astro/src/virtual-modules/container.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';
/**
* Use this function to provide renderers to the `AstroContainer`:
diff --git a/packages/astro/src/virtual-modules/i18n.ts b/packages/astro/src/virtual-modules/i18n.ts
index aacdd80a9..927d479aa 100644
--- a/packages/astro/src/virtual-modules/i18n.ts
+++ b/packages/astro/src/virtual-modules/i18n.ts
@@ -1,9 +1,3 @@
-import type {
- APIContext,
- AstroConfig,
- MiddlewareHandler,
- ValidRedirectStatus,
-} from '../@types/astro.js';
import type { SSRManifest } from '../core/app/types.js';
import { IncorrectStrategyForI18n } from '../core/errors/errors-data.js';
import { AstroError } from '../core/errors/index.js';
@@ -11,6 +5,9 @@ import * as I18nInternals from '../i18n/index.js';
import type { RedirectToFallback } from '../i18n/index.js';
import { toRoutingStrategy } from '../i18n/utils.js';
import type { I18nInternalConfig } from '../i18n/vite-plugin-i18n.js';
+import type { MiddlewareHandler } from '../types/public/common.js';
+import type { AstroConfig, ValidRedirectStatus } from '../types/public/config.js';
+import type { APIContext } from '../types/public/context.js';
export { normalizeTheLocale, toCodes, toPaths } from '../i18n/index.js';
diff --git a/packages/astro/src/vite-plugin-astro-server/base.ts b/packages/astro/src/vite-plugin-astro-server/base.ts
index bea642f6f..562b89ba2 100644
--- a/packages/astro/src/vite-plugin-astro-server/base.ts
+++ b/packages/astro/src/vite-plugin-astro-server/base.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';
import * as fs from 'node:fs';
import path from 'node:path';
diff --git a/packages/astro/src/vite-plugin-astro-server/error.ts b/packages/astro/src/vite-plugin-astro-server/error.ts
index 24db9dc49..25a237cc2 100644
--- a/packages/astro/src/vite-plugin-astro-server/error.ts
+++ b/packages/astro/src/vite-plugin-astro-server/error.ts
@@ -1,10 +1,10 @@
-import type { AstroConfig } from '../@types/astro.js';
import type { ModuleLoader } from '../core/module-loader/index.js';
import type { DevPipeline } from './pipeline.js';
import { collectErrorMetadata } from '../core/errors/dev/index.js';
import { createSafeError } from '../core/errors/index.js';
import { formatErrorMessage } from '../core/messages.js';
+import type { AstroConfig } from '../types/public/config.js';
export function recordServerError(
loader: ModuleLoader,
diff --git a/packages/astro/src/vite-plugin-astro-server/metadata.ts b/packages/astro/src/vite-plugin-astro-server/metadata.ts
index 793ee5669..7f358ade0 100644
--- a/packages/astro/src/vite-plugin-astro-server/metadata.ts
+++ b/packages/astro/src/vite-plugin-astro-server/metadata.ts
@@ -1,6 +1,6 @@
-import type { SSRComponentMetadata, SSRResult } from '../@types/astro.js';
import type { ModuleInfo, ModuleLoader } from '../core/module-loader/index.js';
import { viteID } from '../core/util.js';
+import type { SSRComponentMetadata, SSRResult } from '../types/public/internal.js';
import { getAstroMetadata } from '../vite-plugin-astro/index.js';
import { crawlGraph } from './vite.js';
diff --git a/packages/astro/src/vite-plugin-astro-server/pipeline.ts b/packages/astro/src/vite-plugin-astro-server/pipeline.ts
index 4386eb154..5a672279e 100644
--- a/packages/astro/src/vite-plugin-astro-server/pipeline.ts
+++ b/packages/astro/src/vite-plugin-astro-server/pipeline.ts
@@ -1,15 +1,4 @@
import { fileURLToPath } from 'node:url';
-import type {
- AstroSettings,
- ComponentInstance,
- DevToolbarMetadata,
- ManifestData,
- RewritePayload,
- RouteData,
- SSRElement,
- SSRLoadedRenderer,
- SSRManifest,
-} from '../@types/astro.js';
import { getInfoOutput } from '../cli/info/index.js';
import { type HeadElements } from '../core/base-pipeline.js';
import { ASTRO_VERSION } from '../core/constants.js';
@@ -22,6 +11,15 @@ import { createDefaultRoutes } from '../core/routing/default.js';
import { findRouteToRewrite } from '../core/routing/rewrite.js';
import { isPage, isServerLikeOutput, viteID } from '../core/util.js';
import { resolveIdToUrl } from '../core/viteUtils.js';
+import type { AstroSettings, ComponentInstance, ManifestData } from '../types/astro.js';
+import type { RewritePayload } from '../types/public/common.js';
+import type {
+ RouteData,
+ SSRElement,
+ SSRLoadedRenderer,
+ SSRManifest,
+} from '../types/public/internal.js';
+import type { DevToolbarMetadata } from '../types/public/toolbar.js';
import { PAGE_SCRIPT_ID } from '../vite-plugin-scripts/index.js';
import { getStylesForURL } from './css.js';
import { getComponentMetadata } from './metadata.js';
diff --git a/packages/astro/src/vite-plugin-astro-server/plugin.ts b/packages/astro/src/vite-plugin-astro-server/plugin.ts
index 2458b5b8d..3015f1003 100644
--- a/packages/astro/src/vite-plugin-astro-server/plugin.ts
+++ b/packages/astro/src/vite-plugin-astro-server/plugin.ts
@@ -2,8 +2,7 @@ import { AsyncLocalStorage } from 'node:async_hooks';
import type fs from 'node:fs';
import { IncomingMessage } from 'node:http';
import type * as vite from 'vite';
-import type { AstroSettings, ManifestData, SSRManifest } from '../@types/astro.js';
-import type { SSRManifestI18n } from '../core/app/types.js';
+import type { SSRManifest, SSRManifestI18n } from '../core/app/types.js';
import { createKey } from '../core/encryption.js';
import { getViteErrorPayload } from '../core/errors/dev/index.js';
import { AstroError, AstroErrorData } from '../core/errors/index.js';
@@ -13,6 +12,7 @@ import { createViteLoader } from '../core/module-loader/index.js';
import { injectDefaultRoutes } from '../core/routing/default.js';
import { createRouteManifest } from '../core/routing/index.js';
import { toRoutingStrategy } from '../i18n/utils.js';
+import type { AstroSettings, ManifestData } from '../types/astro.js';
import { baseMiddleware } from './base.js';
import { createController } from './controller.js';
import { recordServerError } from './error.js';
diff --git a/packages/astro/src/vite-plugin-astro-server/request.ts b/packages/astro/src/vite-plugin-astro-server/request.ts
index b231bfde3..98cf2b502 100644
--- a/packages/astro/src/vite-plugin-astro-server/request.ts
+++ b/packages/astro/src/vite-plugin-astro-server/request.ts
@@ -1,6 +1,6 @@
import type http from 'node:http';
-import type { ManifestData } from '../@types/astro.js';
import { removeTrailingForwardSlash } from '../core/path.js';
+import type { ManifestData } from '../types/astro.js';
import type { DevServerController } from './controller.js';
import { runWithErrorHandling } from './controller.js';
import { recordServerError } from './error.js';
diff --git a/packages/astro/src/vite-plugin-astro-server/route.ts b/packages/astro/src/vite-plugin-astro-server/route.ts
index aa70d5324..c59af5c80 100644
--- a/packages/astro/src/vite-plugin-astro-server/route.ts
+++ b/packages/astro/src/vite-plugin-astro-server/route.ts
@@ -1,5 +1,4 @@
import type http from 'node:http';
-import type { ComponentInstance, ManifestData, RouteData } from '../@types/astro.js';
import {
REROUTE_DIRECTIVE_HEADER,
REWRITE_DIRECTIVE_HEADER_KEY,
@@ -13,6 +12,8 @@ import { type SSROptions, getProps } from '../core/render/index.js';
import { createRequest } from '../core/request.js';
import { matchAllRoutes } from '../core/routing/index.js';
import { getSortedPreloadedMatches } from '../prerender/routing.js';
+import type { ComponentInstance, ManifestData } from '../types/astro.js';
+import type { RouteData } from '../types/public/internal.js';
import type { DevPipeline } from './pipeline.js';
import { writeSSRResult, writeWebResponse } from './response.js';
diff --git a/packages/astro/src/vite-plugin-astro-server/scripts.ts b/packages/astro/src/vite-plugin-astro-server/scripts.ts
index e21d44116..95763ab34 100644
--- a/packages/astro/src/vite-plugin-astro-server/scripts.ts
+++ b/packages/astro/src/vite-plugin-astro-server/scripts.ts
@@ -1,8 +1,8 @@
-import type { SSRElement } from '../@types/astro.js';
import type { ModuleInfo, ModuleLoader } from '../core/module-loader/index.js';
import { createModuleScriptElementWithSrc } from '../core/render/ssr-element.js';
import { viteID } from '../core/util.js';
import { rootRelativePath } from '../core/viteUtils.js';
+import type { SSRElement } from '../types/public/internal.js';
import type { PluginMetadata as AstroPluginMetadata } from '../vite-plugin-astro/types.js';
import { crawlGraph } from './vite.js';
diff --git a/packages/astro/src/vite-plugin-astro/compile.ts b/packages/astro/src/vite-plugin-astro/compile.ts
index 8dfb68a16..78d6c416f 100644
--- a/packages/astro/src/vite-plugin-astro/compile.ts
+++ b/packages/astro/src/vite-plugin-astro/compile.ts
@@ -1,7 +1,7 @@
import { type ESBuildTransformResult, transformWithEsbuild } from 'vite';
-import type { AstroConfig } from '../@types/astro.js';
import { type CompileProps, type CompileResult, compile } from '../core/compile/index.js';
import type { Logger } from '../core/logger/core.js';
+import type { AstroConfig } from '../types/public/config.js';
import { getFileInfo } from '../vite-plugin-utils/index.js';
import type { CompileMetadata } from './types.js';
import { frontmatterRE } from './utils.js';
diff --git a/packages/astro/src/vite-plugin-astro/index.ts b/packages/astro/src/vite-plugin-astro/index.ts
index d5968a905..b7dd0a2b6 100644
--- a/packages/astro/src/vite-plugin-astro/index.ts
+++ b/packages/astro/src/vite-plugin-astro/index.ts
@@ -1,7 +1,7 @@
import type { SourceDescription } from 'rollup';
import type * as vite from 'vite';
-import type { AstroConfig, AstroSettings } from '../@types/astro.js';
import type { Logger } from '../core/logger/core.js';
+import type { AstroSettings } from '../types/astro.js';
import type {
PluginCssMetadata as AstroPluginCssMetadata,
PluginMetadata as AstroPluginMetadata,
@@ -9,6 +9,7 @@ import type {
} from './types.js';
import { normalizePath } from 'vite';
+import type { AstroConfig } from '../types/public/config.js';
import { hasSpecialQueries, normalizeFilename } from '../vite-plugin-utils/index.js';
import { type CompileAstroResult, compileAstro } from './compile.js';
import { handleHotUpdate } from './hmr.js';
diff --git a/packages/astro/src/vite-plugin-astro/types.ts b/packages/astro/src/vite-plugin-astro/types.ts
index ee5003941..195745443 100644
--- a/packages/astro/src/vite-plugin-astro/types.ts
+++ b/packages/astro/src/vite-plugin-astro/types.ts
@@ -1,6 +1,6 @@
import type { HoistedScript, TransformResult } from '@astrojs/compiler';
-import type { PropagationHint } from '../@types/astro.js';
import type { CompileCssResult } from '../core/compile/types.js';
+import type { PropagationHint } from '../types/public/internal.js';
export interface PageOptions {
prerender?: boolean;
diff --git a/packages/astro/src/vite-plugin-config-alias/index.ts b/packages/astro/src/vite-plugin-config-alias/index.ts
index cb9bdc48c..9b102c564 100644
--- a/packages/astro/src/vite-plugin-config-alias/index.ts
+++ b/packages/astro/src/vite-plugin-config-alias/index.ts
@@ -1,7 +1,7 @@
import path from 'node:path';
import type { CompilerOptions } from 'typescript';
import { type ResolvedConfig, type Plugin as VitePlugin, normalizePath } from 'vite';
-import type { AstroSettings } from '../@types/astro.js';
+import type { AstroSettings } from '../types/astro.js';
type Alias = {
find: RegExp;
diff --git a/packages/astro/src/vite-plugin-env/index.ts b/packages/astro/src/vite-plugin-env/index.ts
index 79bdad4cf..0408e645d 100644
--- a/packages/astro/src/vite-plugin-env/index.ts
+++ b/packages/astro/src/vite-plugin-env/index.ts
@@ -4,8 +4,9 @@ import { bold } from 'kleur/colors';
import MagicString from 'magic-string';
import type * as vite from 'vite';
import { loadEnv } from 'vite';
-import type { AstroConfig, AstroSettings } from '../@types/astro.js';
import type { Logger } from '../core/logger/core.js';
+import type { AstroSettings } from '../types/astro.js';
+import type { AstroConfig } from '../types/public/config.js';
interface EnvPluginOptions {
settings: AstroSettings;
diff --git a/packages/astro/src/vite-plugin-head/index.ts b/packages/astro/src/vite-plugin-head/index.ts
index a7e35dedb..c9ec2460d 100644
--- a/packages/astro/src/vite-plugin-head/index.ts
+++ b/packages/astro/src/vite-plugin-head/index.ts
@@ -1,11 +1,11 @@
import type { ModuleInfo } from 'rollup';
import type * as vite from 'vite';
-import type { SSRComponentMetadata, SSRResult } from '../@types/astro.js';
import type { AstroBuildPlugin } from '../core/build/plugin.js';
import type { PluginMetadata } from '../vite-plugin-astro/types.js';
import { getParentModuleInfos, getTopLevelPageModuleInfos } from '../core/build/graph.js';
import type { BuildInternals } from '../core/build/internal.js';
+import type { SSRComponentMetadata, SSRResult } from '../types/public/internal.js';
import { getAstroMetadata } from '../vite-plugin-astro/index.js';
// Detect this in comments, both in .astro components and in js/ts files.
diff --git a/packages/astro/src/vite-plugin-integrations-container/index.ts b/packages/astro/src/vite-plugin-integrations-container/index.ts
index 49122b24f..22623284e 100644
--- a/packages/astro/src/vite-plugin-integrations-container/index.ts
+++ b/packages/astro/src/vite-plugin-integrations-container/index.ts
@@ -1,10 +1,11 @@
import type { PluginContext } from 'rollup';
import type { Plugin as VitePlugin } from 'vite';
-import type { AstroSettings, InjectedRoute, ResolvedInjectedRoute } from '../@types/astro.js';
import type { Logger } from '../core/logger/core.js';
+import type { AstroSettings } from '../types/astro.js';
import { normalizePath } from 'vite';
import { runHookServerSetup } from '../integrations/hooks.js';
+import type { InjectedRoute, ResolvedInjectedRoute } from '../types/public/integrations.js';
/** Connect Astro integrations into Vite, as needed. */
export default function astroIntegrationsContainerPlugin({
diff --git a/packages/astro/src/vite-plugin-markdown/content-entry-type.ts b/packages/astro/src/vite-plugin-markdown/content-entry-type.ts
index 9b78d8f35..48a45294e 100644
--- a/packages/astro/src/vite-plugin-markdown/content-entry-type.ts
+++ b/packages/astro/src/vite-plugin-markdown/content-entry-type.ts
@@ -1,7 +1,7 @@
import { fileURLToPath, pathToFileURL } from 'node:url';
import { createMarkdownProcessor } from '@astrojs/markdown-remark';
-import type { ContentEntryType } from '../@types/astro.js';
import { safeParseFrontmatter } from '../content/utils.js';
+import type { ContentEntryType } from '../types/public/content.js';
export const markdownContentEntryType: ContentEntryType = {
extensions: ['.md'],
@@ -17,8 +17,8 @@ export const markdownContentEntryType: ContentEntryType = {
// We need to handle propagation for Markdown because they support layouts which will bring in styles.
handlePropagation: true,
- async getRenderFunction(settings) {
- const processor = await createMarkdownProcessor(settings.config.markdown);
+ async getRenderFunction(config) {
+ const processor = await createMarkdownProcessor(config.markdown);
return async function renderToString(entry) {
if (!entry.body) {
return {
diff --git a/packages/astro/src/vite-plugin-markdown/index.ts b/packages/astro/src/vite-plugin-markdown/index.ts
index 37af2dc50..694b96448 100644
--- a/packages/astro/src/vite-plugin-markdown/index.ts
+++ b/packages/astro/src/vite-plugin-markdown/index.ts
@@ -7,12 +7,12 @@ import {
} from '@astrojs/markdown-remark';
import type { Plugin } from 'vite';
import { normalizePath } from 'vite';
-import type { AstroSettings } from '../@types/astro.js';
import { safeParseFrontmatter } from '../content/utils.js';
import { AstroError, AstroErrorData } from '../core/errors/index.js';
import type { Logger } from '../core/logger/core.js';
import { isMarkdownFile } from '../core/util.js';
import { shorthash } from '../runtime/server/shorthash.js';
+import type { AstroSettings } from '../types/astro.js';
import { createDefaultAstroMetadata } from '../vite-plugin-astro/metadata.js';
import { getFileInfo } from '../vite-plugin-utils/index.js';
import { type MarkdownImagePath, getMarkdownCodeForImages } from './images.js';
diff --git a/packages/astro/src/vite-plugin-mdx/transform-jsx.ts b/packages/astro/src/vite-plugin-mdx/transform-jsx.ts
index c3bb8ed76..31db27931 100644
--- a/packages/astro/src/vite-plugin-mdx/transform-jsx.ts
+++ b/packages/astro/src/vite-plugin-mdx/transform-jsx.ts
@@ -1,7 +1,7 @@
import babel from '@babel/core';
import type { TransformResult } from 'rollup';
-import type { JSXTransformConfig } from '../@types/astro.js';
import { jsxTransformOptions } from '../jsx/transform-options.js';
+import type { JSXTransformConfig } from '../types/astro.js';
import type { PluginMetadata } from '../vite-plugin-astro/types.js';
import { tagExportsPlugin } from './tag.js';
diff --git a/packages/astro/src/vite-plugin-scanner/index.ts b/packages/astro/src/vite-plugin-scanner/index.ts
index 842857777..2633743ae 100644
--- a/packages/astro/src/vite-plugin-scanner/index.ts
+++ b/packages/astro/src/vite-plugin-scanner/index.ts
@@ -2,12 +2,13 @@ import { extname } from 'node:path';
import { bold } from 'kleur/colors';
import type { Plugin as VitePlugin } from 'vite';
import { normalizePath } from 'vite';
-import type { AstroSettings, RouteOptions } from '../@types/astro.js';
import { type Logger } from '../core/logger/core.js';
import { isEndpoint, isPage, isServerLikeOutput } from '../core/util.js';
import { rootRelativePath } from '../core/viteUtils.js';
import { runHookRouteSetup } from '../integrations/hooks.js';
import { getPrerenderDefault } from '../prerender/utils.js';
+import type { AstroSettings } from '../types/astro.js';
+import type { RouteOptions } from '../types/public/integrations.js';
import type { PageOptions } from '../vite-plugin-astro/types.js';
import { scan } from './scan.js';
diff --git a/packages/astro/src/vite-plugin-scanner/scan.ts b/packages/astro/src/vite-plugin-scanner/scan.ts
index 52b2d6bd8..35e3de20a 100644
--- a/packages/astro/src/vite-plugin-scanner/scan.ts
+++ b/packages/astro/src/vite-plugin-scanner/scan.ts
@@ -1,4 +1,4 @@
-import type { AstroSettings } from '../@types/astro.js';
+import type { AstroSettings } from '../types/astro.js';
import type { PageOptions } from '../vite-plugin-astro/types.js';
import * as eslexer from 'es-module-lexer';
diff --git a/packages/astro/src/vite-plugin-scripts/index.ts b/packages/astro/src/vite-plugin-scripts/index.ts
index 9b2848923..f87f6a381 100644
--- a/packages/astro/src/vite-plugin-scripts/index.ts
+++ b/packages/astro/src/vite-plugin-scripts/index.ts
@@ -1,5 +1,6 @@
import type { ConfigEnv, Plugin as VitePlugin } from 'vite';
-import type { AstroSettings, InjectedScriptStage } from '../@types/astro.js';
+import type { AstroSettings } from '../types/astro.js';
+import type { InjectedScriptStage } from '../types/public/integrations.js';
// NOTE: We can't use the virtual "\0" ID convention because we need to
// inject these as ESM imports into actual code, where they would not
diff --git a/packages/astro/src/vite-plugin-scripts/page-ssr.ts b/packages/astro/src/vite-plugin-scripts/page-ssr.ts
index 00e907b03..05d8be18d 100644
--- a/packages/astro/src/vite-plugin-scripts/page-ssr.ts
+++ b/packages/astro/src/vite-plugin-scripts/page-ssr.ts
@@ -1,7 +1,7 @@
import MagicString from 'magic-string';
import { type Plugin as VitePlugin, normalizePath } from 'vite';
-import type { AstroSettings } from '../@types/astro.js';
import { isPage } from '../core/util.js';
+import type { AstroSettings } from '../types/astro.js';
import { PAGE_SSR_SCRIPT_ID } from './index.js';
export default function astroScriptsPostPlugin({
diff --git a/packages/astro/src/vite-plugin-utils/index.ts b/packages/astro/src/vite-plugin-utils/index.ts
index a0133104c..2e7948bdd 100644
--- a/packages/astro/src/vite-plugin-utils/index.ts
+++ b/packages/astro/src/vite-plugin-utils/index.ts
@@ -1,12 +1,12 @@
import { fileURLToPath } from 'node:url';
import ancestor from 'common-ancestor-path';
-import type { AstroConfig } from '../@types/astro.js';
import {
appendExtension,
appendForwardSlash,
removeLeadingForwardSlashWindows,
} from '../core/path.js';
import { viteID } from '../core/util.js';
+import type { AstroConfig } from '../types/public/config.js';
export function getFileInfo(id: string, config: AstroConfig) {
const sitePathname = appendForwardSlash(
diff --git a/packages/astro/templates/actions.mjs b/packages/astro/templates/actions.mjs
index 587f6ed9b..823699e15 100644
--- a/packages/astro/templates/actions.mjs
+++ b/packages/astro/templates/actions.mjs
@@ -55,7 +55,7 @@ function toActionProxy(actionCallback = {}, aggregatedPath = '') {
/**
* @param {*} param argument passed to the action when called server or client-side.
* @param {string} path Built path to call action by path name.
- * @param {import('../dist/@types/astro.d.ts').APIContext | undefined} context Injected API context when calling actions from the server.
+ * @param {import('../dist/types/public/context.js').APIContext | undefined} context Injected API context when calling actions from the server.
* Usage: `actions.[name](param)`.
* @returns {Promise<import('../dist/actions/runtime/virtual/shared.js').SafeResult<any, any>>}
*/
diff --git a/packages/astro/test/astro-attrs.test.js b/packages/astro/test/astro-attrs.test.js
index 2e020f8ea..a981a5b15 100644
--- a/packages/astro/test/astro-attrs.test.js
+++ b/packages/astro/test/astro-attrs.test.js
@@ -16,21 +16,41 @@ describe('Attributes', async () => {
const $ = cheerio.load(html);
const attrs = {
- 'false-str': { attribute: 'attr', value: 'false' },
- 'true-str': { attribute: 'attr', value: 'true' },
- false: { attribute: 'attr', value: undefined },
- true: { attribute: 'attr', value: 'true' },
- empty: { attribute: 'attr', value: '' },
+ 'boolean-attr-true': { attribute: 'allowfullscreen', value: '' },
+ 'boolean-attr-false': { attribute: 'allowfullscreen', value: undefined },
+ 'boolean-attr-string-truthy': { attribute: 'allowfullscreen', value: '' },
+ 'boolean-attr-string-falsy': { attribute: 'allowfullscreen', value: undefined },
+ 'boolean-attr-number-truthy': { attribute: 'allowfullscreen', value: '' },
+ 'boolean-attr-number-falsy': { attribute: 'allowfullscreen', value: undefined },
+ 'data-attr-true': { attribute: 'data-foobar', value: 'true' },
+ 'data-attr-false': { attribute: 'data-foobar', value: 'false' },
+ 'data-attr-string-truthy': { attribute: 'data-foobar', value: 'foo' },
+ 'data-attr-string-falsy': { attribute: 'data-foobar', value: '' },
+ 'data-attr-number-truthy': { attribute: 'data-foobar', value: '1' },
+ 'data-attr-number-falsy': { attribute: 'data-foobar', value: '0' },
+ 'normal-attr-true': { attribute: 'foobar', value: 'true' },
+ 'normal-attr-false': { attribute: 'foobar', value: 'false' },
+ 'normal-attr-string-truthy': { attribute: 'foobar', value: 'foo' },
+ 'normal-attr-string-falsy': { attribute: 'foobar', value: '' },
+ 'normal-attr-number-truthy': { attribute: 'foobar', value: '1' },
+ 'normal-attr-number-falsy': { attribute: 'foobar', value: '0' },
null: { attribute: 'attr', value: undefined },
undefined: { attribute: 'attr', value: undefined },
- 'html-boolean': { attribute: 'async', value: 'async' },
- 'html-boolean-true': { attribute: 'async', value: 'async' },
- 'html-boolean-false': { attribute: 'async', value: undefined },
'html-enum': { attribute: 'draggable', value: 'true' },
'html-enum-true': { attribute: 'draggable', value: 'true' },
'html-enum-false': { attribute: 'draggable', value: 'false' },
};
+ assert.ok(!/allowfullscreen=/.test(html), 'boolean attributes should not have values');
+ assert.ok(
+ !/id="data-attr-string-falsy"\s+data-foobar=/.test(html),
+ "data attributes should not have values if it's an empty string"
+ );
+ assert.ok(
+ !/id="normal-attr-string-falsy"\s+data-foobar=/.test(html),
+ "normal attributes should not have values if it's an empty string"
+ );
+
// cheerio will unescape the values, so checking that the url rendered unescaped to begin with has to be done manually
assert.equal(
html.includes('https://example.com/api/og?title=hello&description=somedescription'),
@@ -46,7 +66,7 @@ describe('Attributes', async () => {
for (const id of Object.keys(attrs)) {
const { attribute, value } = attrs[id];
const attr = $(`#${id}`).attr(attribute);
- assert.equal(attr, value);
+ assert.equal(attr, value, `Expected ${attribute} to be ${value} for #${id}`);
}
});
diff --git a/packages/astro/test/astro-component-code.test.js b/packages/astro/test/astro-component-code.test.js
index 6124e6054..bc8b5f172 100644
--- a/packages/astro/test/astro-component-code.test.js
+++ b/packages/astro/test/astro-component-code.test.js
@@ -88,13 +88,13 @@ describe('<Code>', () => {
.map((i, f) => (f.attribs ? f.attribs.style : 'no style found'))
.toArray(),
[
- 'background-color:var(--astro-code-color-background);color:var(--astro-code-color-text); overflow-x: auto;',
+ 'background-color:var(--astro-code-background);color:var(--astro-code-foreground); overflow-x: auto;',
'color:var(--astro-code-token-constant)',
'color:var(--astro-code-token-function)',
- 'color:var(--astro-code-color-text)',
+ 'color:var(--astro-code-foreground)',
'color:var(--astro-code-token-string-expression)',
- 'color:var(--astro-code-color-text)',
- ],
+ 'color:var(--astro-code-foreground)',
+ ]
);
});
diff --git a/packages/astro/test/core-image-unconventional-settings.test.js b/packages/astro/test/core-image-unconventional-settings.test.js
index edbfab6f6..b5d5fc664 100644
--- a/packages/astro/test/core-image-unconventional-settings.test.js
+++ b/packages/astro/test/core-image-unconventional-settings.test.js
@@ -6,7 +6,7 @@ import { testImageService } from './test-image-service.js';
import { loadFixture } from './test-utils.js';
/**
- ** @typedef {import('../src/@types/astro').AstroInlineConfig & { root?: string | URL }} AstroInlineConfig
+ ** @typedef {import('../src/types/public/config.js').AstroInlineConfig & { root?: string | URL }} AstroInlineConfig
*/
/** @type {AstroInlineConfig} */
diff --git a/packages/astro/test/fixtures/astro-attrs/src/pages/index.astro b/packages/astro/test/fixtures/astro-attrs/src/pages/index.astro
index 7ac96635f..8f2576650 100644
--- a/packages/astro/test/fixtures/astro-attrs/src/pages/index.astro
+++ b/packages/astro/test/fixtures/astro-attrs/src/pages/index.astro
@@ -1,19 +1,30 @@
-<span id="false-str" attr="false" />
-<span id="true-str" attr="true" />
-<span id="true" attr={true} />
-<span id="false" attr={false} />
-<span id="empty" attr="" />
+<span id="boolean-attr-true" allowfullscreen={true} />
+<span id="boolean-attr-false" allowfullscreen={false} />
+<span id="boolean-attr-string-truthy" allowfullscreen={'foo'} />
+<span id="boolean-attr-string-falsy" allowfullscreen={''} />
+<span id="boolean-attr-number-truthy" allowfullscreen={1} />
+<span id="boolean-attr-number-falsy" allowfullscreen={0} />
+
+<span id="data-attr-true" data-foobar={true} />
+<span id="data-attr-false" data-foobar={false} />
+<span id="data-attr-string-truthy" data-foobar={'foo'} />
+<span id="data-attr-string-falsy" data-foobar={''} />
+<span id="data-attr-number-truthy" data-foobar={1} />
+<span id="data-attr-number-falsy" data-foobar={0} />
+
+<span id="normal-attr-true" foobar={true} />
+<span id="normal-attr-false" foobar={false} />
+<span id="normal-attr-string-truthy" foobar={'foo'} />
+<span id="normal-attr-string-falsy" foobar={''} />
+<span id="normal-attr-number-truthy" foobar={1} />
+<span id="normal-attr-number-falsy" foobar={0} />
+
<span id="null" attr={null} />
<span id="undefined" attr={undefined} />
+
<span id="url" attr={"https://example.com/api/og?title=hello&description=somedescription"}/>
<span id="code" attr={"cmd: echo \"foo\" && echo \"bar\" > /tmp/hello.txt"} />
-<!--
- Per HTML spec, some attributes should be treated as booleans
- These should always render <span async /> or <span /> (without a string value)
--->
-<span id='html-boolean' async />
-<span id='html-boolean-true' async={true} />
-<span id='html-boolean-false' async={false} />
+
<!--
Other attributes should be treated as string enums
These should always render <span draggable="true" /> or <span draggable="false" />
diff --git a/packages/astro/test/fixtures/core-image-ssr/src/pages/api.ts b/packages/astro/test/fixtures/core-image-ssr/src/pages/api.ts
index 261fb6bb7..25777dce8 100644
--- a/packages/astro/test/fixtures/core-image-ssr/src/pages/api.ts
+++ b/packages/astro/test/fixtures/core-image-ssr/src/pages/api.ts
@@ -1,4 +1,4 @@
-import type { APIRoute } from "../../../../../src/@types/astro";
+import type { APIRoute } from "astro"
export const GET = (async ({ params, request }) => {
const url = new URL(request.url);
diff --git a/packages/astro/test/fixtures/ssr-prerender-chunks/deps/test-adapter/index.js b/packages/astro/test/fixtures/ssr-prerender-chunks/deps/test-adapter/index.js
index 82b7b64b1..06eb02e2c 100644
--- a/packages/astro/test/fixtures/ssr-prerender-chunks/deps/test-adapter/index.js
+++ b/packages/astro/test/fixtures/ssr-prerender-chunks/deps/test-adapter/index.js
@@ -1,6 +1,6 @@
/**
*
- * @returns {import('../src/@types/astro').AstroIntegration}
+ * @returns {import('../../../../../src/types/public/integrations.js').AstroIntegration}
*/
export default function () {
return {
@@ -82,4 +82,4 @@ export default function () {
},
},
};
-} \ No newline at end of file
+}
diff --git a/packages/astro/test/test-adapter.js b/packages/astro/test/test-adapter.js
index fc5249561..4a2ac65d0 100644
--- a/packages/astro/test/test-adapter.js
+++ b/packages/astro/test/test-adapter.js
@@ -1,11 +1,11 @@
import { viteID } from '../dist/core/util.js';
/**
- * @typedef {import('../src/@types/astro.js').AstroAdapter} AstroAdapter
- * @typedef {import('../src/@types/astro.js').AstroIntegration} AstroIntegration
- * @typedef {import('../src/@types/astro.js').HookParameters<"astro:build:ssr">['entryPoints']} EntryPoints
- * @typedef {import('../src/@types/astro.js').HookParameters<"astro:build:ssr">['middlewareEntryPoint']} MiddlewareEntryPoint
- * @typedef {import('../src/@types/astro.js').HookParameters<"astro:build:done">['routes']} Routes
+ * @typedef {import('../src/types/public/integrations.js').AstroAdapter} AstroAdapter
+ * @typedef {import('../src/types/public/integrations.js').AstroIntegration} AstroIntegration
+ * @typedef {import('../src/types/public/integrations.js').HookParameters<"astro:build:ssr">['entryPoints']} EntryPoints
+ * @typedef {import('../src/types/public/integrations.js').HookParameters<"astro:build:ssr">['middlewareEntryPoint']} MiddlewareEntryPoint
+ * @typedef {import('../src/types/public/integrations.js').HookParameters<"astro:build:done">['routes']} Routes
*/
/**
diff --git a/packages/astro/test/test-image-service.js b/packages/astro/test/test-image-service.js
index 35a5fa2c8..de076425c 100644
--- a/packages/astro/test/test-image-service.js
+++ b/packages/astro/test/test-image-service.js
@@ -12,7 +12,7 @@ export function testImageService(config = {}) {
};
}
-/** @type {import("../dist/@types/astro").LocalImageService} */
+/** @type {import("../dist/types/public/index.js").LocalImageService} */
export default {
...baseService,
propertiesToHash: [...baseService.propertiesToHash, 'data-custom'],
diff --git a/packages/astro/test/test-utils.js b/packages/astro/test/test-utils.js
index 95edeebd2..115f3c2d5 100644
--- a/packages/astro/test/test-utils.js
+++ b/packages/astro/test/test-utils.js
@@ -23,8 +23,8 @@ process.env.ASTRO_TELEMETRY_DISABLED = true;
/**
* @typedef {import('../src/core/dev/dev').DevServer} DevServer
- * @typedef {import('../src/@types/astro').AstroInlineConfig & { root?: string | URL }} AstroInlineConfig
- * @typedef {import('../src/@types/astro').AstroConfig} AstroConfig
+ * @typedef {import('../src/types/public/config.js').AstroInlineConfig & { root?: string | URL }} AstroInlineConfig
+ * @typedef {import('../src/types/public/config.js').AstroConfig} AstroConfig
* @typedef {import('../src/core/preview/index').PreviewServer} PreviewServer
* @typedef {import('../src/core/app/index').App} App
* @typedef {import('../src/cli/check/index').AstroChecker} AstroChecker
diff --git a/packages/astro/test/types/call-action.ts b/packages/astro/test/types/call-action.ts
index 916105585..8cadd1fb0 100644
--- a/packages/astro/test/types/call-action.ts
+++ b/packages/astro/test/types/call-action.ts
@@ -1,6 +1,6 @@
import { describe, it } from 'node:test';
import { expectTypeOf } from 'expect-type';
-import type { APIContext } from '../../dist/@types/astro.js';
+import type { APIContext } from '../../dist/types/public/context.js';
import { type ActionReturnType, defineAction } from '../../dist/actions/runtime/virtual/server.js';
import { z } from '../../zod.mjs';
diff --git a/packages/astro/test/units/test-utils.js b/packages/astro/test/units/test-utils.js
index bab850b68..a104ef2a4 100644
--- a/packages/astro/test/units/test-utils.js
+++ b/packages/astro/test/units/test-utils.js
@@ -211,8 +211,8 @@ export function createBasicPipeline(options = {}) {
}
/**
- * @param {import('../../src/@types/astro.js').AstroInlineConfig} inlineConfig
- * @returns {Promise<import('../../src/@types/astro.js').AstroSettings>}
+ * @param {import('../../src/types/public/config.js').AstroInlineConfig} inlineConfig
+ * @returns {Promise<import('../../src/types/astro.js').AstroSettings>}
*/
export async function createBasicSettings(inlineConfig = {}) {
if (!inlineConfig.root) {
@@ -225,7 +225,7 @@ export async function createBasicSettings(inlineConfig = {}) {
/**
* @typedef {{
* fs?: typeof realFS,
- * inlineConfig?: import('../../src/@types/astro.js').AstroInlineConfig,
+ * inlineConfig?: import('../../src/types/public/config.js').AstroInlineConfig,
* logging?: import('../../src/core/logger/core').LogOptions,
* }} RunInContainerOptions
*/
diff --git a/packages/astro/types.d.ts b/packages/astro/types.d.ts
index b04f062fd..cc0f1c3d2 100644
--- a/packages/astro/types.d.ts
+++ b/packages/astro/types.d.ts
@@ -1,6 +1,6 @@
import './astro-jsx';
-import type { AstroBuiltinAttributes } from './dist/@types/astro.js';
import type { OmitIndexSignature, Simplify } from './dist/type-utils.js';
+import type { AstroBuiltinAttributes } from './dist/types/public/elements.js';
/** Any supported HTML or SVG element name, as defined by the HTML specification */
export type HTMLTag = keyof astroHTML.JSX.DefinedIntrinsicElements;
diff --git a/packages/integrations/mdx/test/mdx-vite-env-vars.test.js b/packages/integrations/mdx/test/mdx-vite-env-vars.test.js
index 80a9b1cec..213386ceb 100644
--- a/packages/integrations/mdx/test/mdx-vite-env-vars.test.js
+++ b/packages/integrations/mdx/test/mdx-vite-env-vars.test.js
@@ -57,8 +57,8 @@ describe('MDX - Vite env vars', () => {
const dataAttrDump = document.querySelector('[data-env-dump]');
assert.notEqual(dataAttrDump, null);
- assert.notEqual(dataAttrDump.getAttribute('data-env-prod'), null);
- assert.equal(dataAttrDump.getAttribute('data-env-dev'), null);
+ assert.equal(dataAttrDump.getAttribute('data-env-prod'), 'true');
+ assert.equal(dataAttrDump.getAttribute('data-env-dev'), 'false');
assert.equal(dataAttrDump.getAttribute('data-env-base-url'), '/');
assert.equal(dataAttrDump.getAttribute('data-env-mode'), 'production');
});
diff --git a/packages/integrations/node/test/api-route.test.js b/packages/integrations/node/test/api-route.test.js
index 804a5ccf4..9743ce42d 100644
--- a/packages/integrations/node/test/api-route.test.js
+++ b/packages/integrations/node/test/api-route.test.js
@@ -7,7 +7,7 @@ import { createRequestAndResponse, loadFixture } from './test-utils.js';
describe('API routes', () => {
/** @type {import('./test-utils').Fixture} */
let fixture;
- /** @type {import('astro/src/@types/astro.js').PreviewServer} */
+ /** @type {import('../../../astro/src/types/public/preview.js').PreviewServer} */
let previewServer;
/** @type {URL} */
let baseUri;
diff --git a/packages/markdown/remark/src/shiki.ts b/packages/markdown/remark/src/shiki.ts
index 0028ec927..011431e50 100644
--- a/packages/markdown/remark/src/shiki.ts
+++ b/packages/markdown/remark/src/shiki.ts
@@ -5,7 +5,6 @@ import {
getHighlighter,
isSpecialLang,
} from 'shiki';
-import { visit } from 'unist-util-visit';
import type { ShikiConfig } from './types.js';
export interface ShikiHighlighter {
@@ -23,16 +22,6 @@ export interface ShikiHighlighter {
): Promise<string>;
}
-// TODO: Remove this special replacement in Astro 5
-const ASTRO_COLOR_REPLACEMENTS: Record<string, string> = {
- '--astro-code-foreground': '--astro-code-color-text',
- '--astro-code-background': '--astro-code-color-background',
-};
-const COLOR_REPLACEMENT_REGEX = new RegExp(
- `${Object.keys(ASTRO_COLOR_REPLACEMENTS).join('|')}`,
- 'g',
-);
-
let _cssVariablesTheme: ReturnType<typeof createCssVariablesTheme>;
const cssVariablesTheme = () =>
_cssVariablesTheme ??
@@ -145,21 +134,6 @@ export async function createShikiHighlighter({
return node.children[0] as typeof node;
}
},
- root(node) {
- if (Object.values(themes).length) {
- return;
- }
-
- const themeName = typeof theme === 'string' ? theme : theme.name;
- if (themeName === 'css-variables') {
- // Replace special color tokens to CSS variables
- visit(node as any, 'element', (child) => {
- if (child.properties?.style) {
- child.properties.style = replaceCssVariables(child.properties.style);
- }
- });
- }
- },
},
...transformers,
],
@@ -171,7 +145,3 @@ export async function createShikiHighlighter({
function normalizePropAsString(value: Properties[string]): string | null {
return Array.isArray(value) ? value.join(' ') : (value as string | null);
}
-
-function replaceCssVariables(str: string) {
- return str.replace(COLOR_REPLACEMENT_REGEX, (match) => ASTRO_COLOR_REPLACEMENTS[match] || match);
-}