diff --git a/.changeset/pre.json b/.changeset/pre.json index e7eabee7b338..34bd34347bf7 100644 --- a/.changeset/pre.json +++ b/.changeset/pre.json @@ -40,6 +40,7 @@ "chilly-terms-know", "clean-camels-drive", "clean-donuts-walk", + "cold-bananas-hear", "cool-mangos-shop", "cuddly-shoes-press", "curvy-walls-kneel", @@ -54,9 +55,11 @@ "fuzzy-pugs-live", "giant-rocks-thank", "healthy-ads-scream", + "heavy-peas-sneeze", "heavy-seahorses-poke", "hip-wombats-exercise", "honest-dingos-add", + "hot-camels-move", "hungry-jokes-try", "itchy-toys-march", "large-zebras-sniff", @@ -75,9 +78,11 @@ "poor-dots-add", "poor-frogs-dream", "quick-ads-exercise", + "rotten-phones-scream", "selfish-cats-crash", "selfish-impalas-grin", "sharp-worms-sniff", + "sixty-oranges-walk", "slimy-mice-dance", "slimy-queens-hang", "small-ties-sort", diff --git a/examples/basics/package.json b/examples/basics/package.json index 1390afbc7e4a..ad9839584e6e 100644 --- a/examples/basics/package.json +++ b/examples/basics/package.json @@ -11,6 +11,6 @@ "astro": "astro" }, "dependencies": { - "astro": "^5.0.0-beta.1" + "astro": "^5.0.0-beta.2" } } diff --git a/examples/blog/package.json b/examples/blog/package.json index 7673e67be55b..5cf7be6b0a60 100644 --- a/examples/blog/package.json +++ b/examples/blog/package.json @@ -14,6 +14,6 @@ "@astrojs/mdx": "^4.0.0-beta.1", "@astrojs/rss": "^4.0.7", "@astrojs/sitemap": "^3.1.6", - "astro": "^5.0.0-beta.1" + "astro": "^5.0.0-beta.2" } } diff --git a/examples/component/package.json b/examples/component/package.json index 660700e48aff..c704256c1eb0 100644 --- a/examples/component/package.json +++ b/examples/component/package.json @@ -15,7 +15,7 @@ ], "scripts": {}, "devDependencies": { - "astro": "^5.0.0-beta.1" + "astro": "^5.0.0-beta.2" }, "peerDependencies": { "astro": "^4.0.0 || ^5.0.0" diff --git a/examples/container-with-vitest/package.json b/examples/container-with-vitest/package.json index d9cd96f5dbf1..fb0830622455 100644 --- a/examples/container-with-vitest/package.json +++ b/examples/container-with-vitest/package.json @@ -12,7 +12,7 @@ "test": "vitest run" }, "dependencies": { - "astro": "^5.0.0-beta.1", + "astro": "^5.0.0-beta.2", "@astrojs/react": "^3.6.2", "react": "^18.3.1", "react-dom": "^18.3.1", diff --git a/examples/framework-alpine/package.json b/examples/framework-alpine/package.json index 01613185492b..371b5a8f2095 100644 --- a/examples/framework-alpine/package.json +++ b/examples/framework-alpine/package.json @@ -14,6 +14,6 @@ "@astrojs/alpinejs": "^0.4.0", "@types/alpinejs": "^3.13.10", "alpinejs": "^3.14.1", - "astro": "^5.0.0-beta.1" + "astro": "^5.0.0-beta.2" } } diff --git a/examples/framework-multiple/package.json b/examples/framework-multiple/package.json index 43d2b913891b..f3ee19e0c03e 100644 --- a/examples/framework-multiple/package.json +++ b/examples/framework-multiple/package.json @@ -13,12 +13,12 @@ "dependencies": { "@astrojs/preact": "^3.5.3", "@astrojs/react": "^3.6.2", - "@astrojs/solid-js": "^4.4.1", - "@astrojs/svelte": "^5.7.0", - "@astrojs/vue": "^4.5.0", + "@astrojs/solid-js": "^4.4.2", + "@astrojs/svelte": "^6.0.0-beta.0", + "@astrojs/vue": "^5.0.0-beta.0", "@types/react": "^18.3.3", "@types/react-dom": "^18.3.0", - "astro": "^5.0.0-beta.1", + "astro": "^5.0.0-beta.2", "preact": "^10.23.2", "react": "^18.3.1", "react-dom": "^18.3.1", diff --git a/examples/framework-preact/package.json b/examples/framework-preact/package.json index 5aae221dbef2..4838579bb90b 100644 --- a/examples/framework-preact/package.json +++ b/examples/framework-preact/package.json @@ -13,7 +13,7 @@ "dependencies": { "@astrojs/preact": "^3.5.3", "@preact/signals": "^1.3.0", - "astro": "^5.0.0-beta.1", + "astro": "^5.0.0-beta.2", "preact": "^10.23.2" } } diff --git a/examples/framework-react/package.json b/examples/framework-react/package.json index cac25816fe46..c54acaeb43fe 100644 --- a/examples/framework-react/package.json +++ b/examples/framework-react/package.json @@ -14,7 +14,7 @@ "@astrojs/react": "^3.6.2", "@types/react": "^18.3.5", "@types/react-dom": "^18.3.0", - "astro": "^5.0.0-beta.1", + "astro": "^5.0.0-beta.2", "react": "^18.3.1", "react-dom": "^18.3.1" } diff --git a/examples/framework-solid/package.json b/examples/framework-solid/package.json index c69f677811b5..93b519f035f3 100644 --- a/examples/framework-solid/package.json +++ b/examples/framework-solid/package.json @@ -12,7 +12,7 @@ }, "dependencies": { "@astrojs/solid-js": "^4.4.2", - "astro": "^5.0.0-beta.1", + "astro": "^5.0.0-beta.2", "solid-js": "^1.8.22" } } diff --git a/examples/framework-svelte/package.json b/examples/framework-svelte/package.json index 5ac9a2a90ef4..e709e95deb42 100644 --- a/examples/framework-svelte/package.json +++ b/examples/framework-svelte/package.json @@ -11,8 +11,8 @@ "astro": "astro" }, "dependencies": { - "@astrojs/svelte": "^5.7.1", - "astro": "^5.0.0-beta.1", + "@astrojs/svelte": "^6.0.0-beta.0", + "astro": "^5.0.0-beta.2", "svelte": "^4.2.19" } } diff --git a/examples/framework-vue/package.json b/examples/framework-vue/package.json index 8214c631618c..2976c90fbcf8 100644 --- a/examples/framework-vue/package.json +++ b/examples/framework-vue/package.json @@ -11,8 +11,8 @@ "astro": "astro" }, "dependencies": { - "@astrojs/vue": "^4.5.1", - "astro": "^5.0.0-beta.1", + "@astrojs/vue": "^5.0.0-beta.0", + "astro": "^5.0.0-beta.2", "vue": "^3.5.3" } } diff --git a/examples/hackernews/package.json b/examples/hackernews/package.json index 0d774329d624..79d3014cdb70 100644 --- a/examples/hackernews/package.json +++ b/examples/hackernews/package.json @@ -12,6 +12,6 @@ }, "dependencies": { "@astrojs/node": "^9.0.0-alpha.1", - "astro": "^5.0.0-beta.1" + "astro": "^5.0.0-beta.2" } } diff --git a/examples/integration/package.json b/examples/integration/package.json index 163dd59fc537..6627384043f9 100644 --- a/examples/integration/package.json +++ b/examples/integration/package.json @@ -15,7 +15,7 @@ ], "scripts": {}, "devDependencies": { - "astro": "^5.0.0-beta.1" + "astro": "^5.0.0-beta.2" }, "peerDependencies": { "astro": "^4.0.0" diff --git a/examples/middleware/package.json b/examples/middleware/package.json index e3f0d89d416b..025dbd3407dd 100644 --- a/examples/middleware/package.json +++ b/examples/middleware/package.json @@ -13,7 +13,7 @@ }, "dependencies": { "@astrojs/node": "^9.0.0-alpha.1", - "astro": "^5.0.0-beta.1", + "astro": "^5.0.0-beta.2", "html-minifier": "^4.0.0" }, "devDependencies": { diff --git a/examples/minimal/package.json b/examples/minimal/package.json index 1c32aa2a67da..dc5d5c3a56a6 100644 --- a/examples/minimal/package.json +++ b/examples/minimal/package.json @@ -11,6 +11,6 @@ "astro": "astro" }, "dependencies": { - "astro": "^5.0.0-beta.1" + "astro": "^5.0.0-beta.2" } } diff --git a/examples/non-html-pages/package.json b/examples/non-html-pages/package.json index 5914a1e131fb..d4c71e7bed02 100644 --- a/examples/non-html-pages/package.json +++ b/examples/non-html-pages/package.json @@ -11,6 +11,6 @@ "astro": "astro" }, "dependencies": { - "astro": "^5.0.0-beta.1" + "astro": "^5.0.0-beta.2" } } diff --git a/examples/portfolio/package.json b/examples/portfolio/package.json index 28b4fa68fdf7..e9b712675680 100644 --- a/examples/portfolio/package.json +++ b/examples/portfolio/package.json @@ -11,6 +11,6 @@ "astro": "astro" }, "dependencies": { - "astro": "^5.0.0-beta.1" + "astro": "^5.0.0-beta.2" } } diff --git a/examples/server-islands/package.json b/examples/server-islands/package.json index 6e1379256c23..a669dcc74d85 100644 --- a/examples/server-islands/package.json +++ b/examples/server-islands/package.json @@ -17,7 +17,7 @@ "@tailwindcss/forms": "^0.5.9", "@types/react": "^18.3.5", "@types/react-dom": "^18.3.0", - "astro": "^5.0.0-beta.1", + "astro": "^5.0.0-beta.2", "postcss": "^8.4.45", "react": "^18.3.1", "react-dom": "^18.3.1", diff --git a/examples/ssr/package.json b/examples/ssr/package.json index 98a715f0c3ad..4142f3f9bfed 100644 --- a/examples/ssr/package.json +++ b/examples/ssr/package.json @@ -13,8 +13,8 @@ }, "dependencies": { "@astrojs/node": "^9.0.0-alpha.1", - "@astrojs/svelte": "^5.7.0", - "astro": "^5.0.0-beta.1", + "@astrojs/svelte": "^6.0.0-beta.0", + "astro": "^5.0.0-beta.2", "svelte": "^4.2.19" } } diff --git a/examples/starlog/package.json b/examples/starlog/package.json index 6658e43a8cc1..71c779dcdbe3 100644 --- a/examples/starlog/package.json +++ b/examples/starlog/package.json @@ -10,7 +10,7 @@ "astro": "astro" }, "dependencies": { - "astro": "^5.0.0-beta.1", + "astro": "^5.0.0-beta.2", "sass": "^1.78.0", "sharp": "^0.33.3" } diff --git a/examples/toolbar-app/package.json b/examples/toolbar-app/package.json index bb284a89c142..b697261a199e 100644 --- a/examples/toolbar-app/package.json +++ b/examples/toolbar-app/package.json @@ -15,6 +15,6 @@ "./app": "./dist/app.js" }, "devDependencies": { - "astro": "^5.0.0-beta.1" + "astro": "^5.0.0-beta.2" } } diff --git a/examples/view-transitions/package.json b/examples/view-transitions/package.json index aff845df1873..b1cc57b10963 100644 --- a/examples/view-transitions/package.json +++ b/examples/view-transitions/package.json @@ -12,6 +12,6 @@ "devDependencies": { "@astrojs/tailwind": "^5.1.1", "@astrojs/node": "^9.0.0-alpha.1", - "astro": "^5.0.0-beta.1" + "astro": "^5.0.0-beta.2" } } diff --git a/examples/with-markdoc/package.json b/examples/with-markdoc/package.json index 26af28266457..65a26dd20a43 100644 --- a/examples/with-markdoc/package.json +++ b/examples/with-markdoc/package.json @@ -12,6 +12,6 @@ }, "dependencies": { "@astrojs/markdoc": "^0.11.5-beta.0", - "astro": "^5.0.0-beta.1" + "astro": "^5.0.0-beta.2" } } diff --git a/examples/with-markdown-plugins/package.json b/examples/with-markdown-plugins/package.json index 622a6a7ab709..4ab25fc2c49a 100644 --- a/examples/with-markdown-plugins/package.json +++ b/examples/with-markdown-plugins/package.json @@ -12,7 +12,7 @@ }, "dependencies": { "@astrojs/markdown-remark": "^6.0.0-beta.1", - "astro": "^5.0.0-beta.1", + "astro": "^5.0.0-beta.2", "hast-util-select": "^6.0.2", "rehype-autolink-headings": "^7.1.0", "rehype-slug": "^6.0.0", diff --git a/examples/with-markdown-shiki/package.json b/examples/with-markdown-shiki/package.json index 208dfb46a8dd..b7bc63660506 100644 --- a/examples/with-markdown-shiki/package.json +++ b/examples/with-markdown-shiki/package.json @@ -11,6 +11,6 @@ "astro": "astro" }, "dependencies": { - "astro": "^5.0.0-beta.1" + "astro": "^5.0.0-beta.2" } } diff --git a/examples/with-mdx/package.json b/examples/with-mdx/package.json index 093c43e20535..b90445eab363 100644 --- a/examples/with-mdx/package.json +++ b/examples/with-mdx/package.json @@ -13,7 +13,7 @@ "dependencies": { "@astrojs/mdx": "^4.0.0-beta.1", "@astrojs/preact": "^3.5.3", - "astro": "^5.0.0-beta.1", + "astro": "^5.0.0-beta.2", "preact": "^10.23.2" } } diff --git a/examples/with-nanostores/package.json b/examples/with-nanostores/package.json index 40fcd204ac67..210046282f61 100644 --- a/examples/with-nanostores/package.json +++ b/examples/with-nanostores/package.json @@ -13,7 +13,7 @@ "dependencies": { "@astrojs/preact": "^3.5.3", "@nanostores/preact": "^0.5.2", - "astro": "^5.0.0-beta.1", + "astro": "^5.0.0-beta.2", "nanostores": "^0.11.3", "preact": "^10.23.2" } diff --git a/examples/with-tailwindcss/package.json b/examples/with-tailwindcss/package.json index 356a9c93b3d5..d20c28706fce 100644 --- a/examples/with-tailwindcss/package.json +++ b/examples/with-tailwindcss/package.json @@ -14,7 +14,7 @@ "@astrojs/mdx": "^4.0.0-beta.1", "@astrojs/tailwind": "^5.1.1", "@types/canvas-confetti": "^1.6.4", - "astro": "^5.0.0-beta.1", + "astro": "^5.0.0-beta.2", "autoprefixer": "^10.4.20", "canvas-confetti": "^1.9.3", "postcss": "^8.4.45", diff --git a/examples/with-vitest/package.json b/examples/with-vitest/package.json index 1473094f9094..d36841ca860e 100644 --- a/examples/with-vitest/package.json +++ b/examples/with-vitest/package.json @@ -12,7 +12,7 @@ "test": "vitest" }, "dependencies": { - "astro": "^5.0.0-beta.1", + "astro": "^5.0.0-beta.2", "vitest": "^2.0.5" } } diff --git a/packages/astro/CHANGELOG.md b/packages/astro/CHANGELOG.md index 5434731311e4..4094e4731cca 100644 --- a/packages/astro/CHANGELOG.md +++ b/packages/astro/CHANGELOG.md @@ -1,5 +1,19 @@ # astro +## 5.0.0-beta.2 + +### Patch Changes + +- [#12035](https://github.com/withastro/astro/pull/12035) [`325a57c`](https://github.com/withastro/astro/commit/325a57c543d88eab5e3ab32ee1bbfb534aed9c7c) Thanks [@ascorbic](https://github.com/ascorbic)! - Correctly parse values returned from inline loader + +- [#12022](https://github.com/withastro/astro/pull/12022) [`ddc3a08`](https://github.com/withastro/astro/commit/ddc3a08e8facdaf0b0298ee5a7adb73a53e1575e) Thanks [@Princesseuh](https://github.com/Princesseuh)! - Properly handle including trailing slash on the image endpoint route based on the trailingSlash config + +- [#12016](https://github.com/withastro/astro/pull/12016) [`837ee3a`](https://github.com/withastro/astro/commit/837ee3a4aa6b33362bd680d4a7fc786ed8639444) Thanks [@matthewp](https://github.com/matthewp)! - Fixes actions with large amount of validation errors + +- [#12030](https://github.com/withastro/astro/pull/12030) [`10a756a`](https://github.com/withastro/astro/commit/10a756ad872ab0311524fca5438bff13d4df25c1) Thanks [@ascorbic](https://github.com/ascorbic)! - Resolves image paths in content layer with initial slash as project-relative + + When using the `image()` schema helper, previously paths with an initial slash were treated as public URLs. This was to match the behavior of markdown images. However this is a change from before, where paths with an initial slash were treated as project-relative. This change restores the previous behavior, so that paths with an initial slash are treated as project-relative. + ## 5.0.0-beta.1 ### Major Changes diff --git a/packages/astro/e2e/actions-blog.test.js b/packages/astro/e2e/actions-blog.test.js index e1f5907e0f72..a6464a957a56 100644 --- a/packages/astro/e2e/actions-blog.test.js +++ b/packages/astro/e2e/actions-blog.test.js @@ -72,7 +72,10 @@ test.describe('Astro Actions - Blog', () => { await expect(form.locator('p[data-error="body"]')).toBeVisible(); }); - test('Comment action - progressive fallback lots of validation errors', async ({ page, astro }) => { + test('Comment action - progressive fallback lots of validation errors', async ({ + page, + astro, + }) => { await page.goto(astro.resolveUrl('/lots-of-fields/')); const form = page.getByTestId('lots'); @@ -81,12 +84,9 @@ test.describe('Astro Actions - Blog', () => { const expectedText = 'Expected string, received null'; - const fields = [ - 'one', 'two', 'three', 'four', 'five', - 'six', 'seven', 'eight', 'nine', 'ten' - ]; + const fields = ['one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten']; - for await(const field of fields) { + for await (const field of fields) { await expect(form.locator(`.${field}.error`)).toHaveText(expectedText); } }); diff --git a/packages/astro/package.json b/packages/astro/package.json index 4ef5a0d793b8..31bb6bcf5857 100644 --- a/packages/astro/package.json +++ b/packages/astro/package.json @@ -1,6 +1,6 @@ { "name": "astro", - "version": "5.0.0-beta.1", + "version": "5.0.0-beta.2", "description": "Astro is a modern site builder with web best practices, performance, and DX front-of-mind.", "type": "module", "author": "withastro", diff --git a/packages/astro/src/actions/runtime/middleware.ts b/packages/astro/src/actions/runtime/middleware.ts index dae0a3811934..22d4f9c7df86 100644 --- a/packages/astro/src/actions/runtime/middleware.ts +++ b/packages/astro/src/actions/runtime/middleware.ts @@ -1,3 +1,4 @@ +import { decodeBase64, encodeBase64 } from '@oslojs/encoding'; import { yellow } from 'kleur/colors'; import { defineMiddleware } from '../../core/middleware/index.js'; import type { MiddlewareNext } from '../../types/public/common.js'; @@ -10,7 +11,6 @@ import { type SerializedActionResult, serializeActionResult, } from './virtual/shared.js'; -import { encodeBase64, decodeBase64 } from '@oslojs/encoding'; export type ActionPayload = { actionResult: SerializedActionResult; @@ -46,7 +46,7 @@ export const onRequest = defineMiddleware(async (context, next) => { const actionPayloadCookie = context.cookies.get(ACTION_QUERY_PARAMS.actionPayload)?.value; if (actionPayloadCookie) { const actionPayload = JSON.parse(decoder.decode(decodeBase64(actionPayloadCookie))); - + if (!isActionPayload(actionPayload)) { throw new Error('Internal: Invalid action payload in cookie.'); } @@ -130,10 +130,14 @@ async function redirectWithResult({ actionName: string; actionResult: SafeResult; }) { - const cookieValue = encodeBase64(encoder.encode(JSON.stringify({ - actionName: actionName, - actionResult: serializeActionResult(actionResult), - }))); + const cookieValue = encodeBase64( + encoder.encode( + JSON.stringify({ + actionName: actionName, + actionResult: serializeActionResult(actionResult), + }), + ), + ); context.cookies.set(ACTION_QUERY_PARAMS.actionPayload, cookieValue); if (actionResult.error) { diff --git a/packages/astro/src/actions/runtime/virtual/shared.ts b/packages/astro/src/actions/runtime/virtual/shared.ts index 2171dabe71bb..f250b0a1a691 100644 --- a/packages/astro/src/actions/runtime/virtual/shared.ts +++ b/packages/astro/src/actions/runtime/virtual/shared.ts @@ -206,16 +206,16 @@ export function serializeActionResult(res: SafeResult): SerializedActi } let body: Record; - if(res.error instanceof ActionInputError) { + if (res.error instanceof ActionInputError) { body = { type: res.error.type, issues: res.error.issues, - fields: res.error.fields + fields: res.error.fields, }; } else { body = { ...res.error, - message: res.error.message + message: res.error.message, }; } @@ -264,7 +264,6 @@ export function deserializeActionResult(res: SerializedActionResult): SafeResult let json; try { json = JSON.parse(res.body); - } catch { return { data: undefined, diff --git a/packages/astro/src/assets/services/service.ts b/packages/astro/src/assets/services/service.ts index 4662963dc06b..e22bada898e4 100644 --- a/packages/astro/src/assets/services/service.ts +++ b/packages/astro/src/assets/services/service.ts @@ -343,10 +343,7 @@ export const baseService: Omit = { options[key] && searchParams.append(param, options[key].toString()); }); - const imageEndpoint = joinPaths( - import.meta.env.BASE_URL, - imageConfig.endpoint.route - ); + const imageEndpoint = joinPaths(import.meta.env.BASE_URL, imageConfig.endpoint.route); return `${imageEndpoint}?${searchParams}`; }, parseURL(url) { diff --git a/packages/astro/src/core/app/types.ts b/packages/astro/src/core/app/types.ts index 50ef7901c2a2..e6b5a2257f00 100644 --- a/packages/astro/src/core/app/types.ts +++ b/packages/astro/src/core/app/types.ts @@ -2,7 +2,12 @@ import type { RoutingStrategies } from '../../i18n/utils.js'; import type { ComponentInstance, SerializedRouteData } from '../../types/astro.js'; import type { AstroMiddlewareInstance } from '../../types/public/common.js'; import type { Locales } from '../../types/public/config.js'; -import type { RouteData, SSRComponentMetadata, SSRLoadedRenderer, SSRResult } from '../../types/public/internal.js'; +import type { + RouteData, + SSRComponentMetadata, + SSRLoadedRenderer, + SSRResult, +} from '../../types/public/internal.js'; import type { SinglePageBuiltModule } from '../build/types.js'; export type ComponentPath = string; diff --git a/packages/astro/src/core/base-pipeline.ts b/packages/astro/src/core/base-pipeline.ts index 4f87112c1871..5976c59b55be 100644 --- a/packages/astro/src/core/base-pipeline.ts +++ b/packages/astro/src/core/base-pipeline.ts @@ -25,106 +25,101 @@ import { createDefaultRoutes } from './routing/default.js'; * Thus, a `Pipeline` is created once at process start and then used by every `RenderContext`. */ export abstract class Pipeline { - readonly internalMiddleware: MiddlewareHandler[]; - resolvedMiddleware: MiddlewareHandler | undefined = undefined; - - constructor( - readonly logger: Logger, - readonly manifest: SSRManifest, - /** - * "development" or "production" - */ - readonly mode: RuntimeMode, - readonly renderers: SSRLoadedRenderer[], - readonly resolve: (s: string) => Promise, - /** - * Based on Astro config's `output` option, `true` if "server" or "hybrid". - */ - readonly serverLike: boolean, - readonly streaming: boolean, - /** - * Used to provide better error messages for `Astro.clientAddress` - */ - readonly adapterName = manifest.adapterName, - readonly clientDirectives = manifest.clientDirectives, - readonly inlinedScripts = manifest.inlinedScripts, - readonly compressHTML = manifest.compressHTML, - readonly i18n = manifest.i18n, - readonly middleware = manifest.middleware, - readonly routeCache = new RouteCache(logger, mode), - /** - * Used for `Astro.site`. - */ - readonly site = manifest.site ? new URL(manifest.site) : undefined, - readonly callSetGetEnv = true, - /** - * Array of built-in, internal, routes. - * Used to find the route module - */ - readonly defaultRoutes = createDefaultRoutes(manifest), - ) { - this.internalMiddleware = []; - // We do use our middleware only if the user isn't using the manual setup - if (i18n?.strategy !== 'manual') { - this.internalMiddleware.push( - createI18nMiddleware(i18n, manifest.base, manifest.trailingSlash, manifest.buildFormat), - ); - } - // In SSR, getSecret should fail by default. Setting it here will run before the - // adapter override. - if (callSetGetEnv && manifest.envGetSecretEnabled) { - setGetEnv(() => { - throw new AstroError(AstroErrorData.EnvUnsupportedGetSecret); - }, true); - } - } - - abstract headElements(routeData: RouteData): Promise | HeadElements; - - abstract componentMetadata( - routeData: RouteData, - ): Promise | void; + readonly internalMiddleware: MiddlewareHandler[]; + resolvedMiddleware: MiddlewareHandler | undefined = undefined; + constructor( + readonly logger: Logger, + readonly manifest: SSRManifest, /** - * It attempts to retrieve the `RouteData` that matches the input `url`, and the component that belongs to the `RouteData`. - * - * ## Errors - * - * - if not `RouteData` is found - * - * @param {RewritePayload} rewritePayload The payload provided by the user - * @param {Request} request The original request + * "development" or "production" */ - abstract tryRewrite( - rewritePayload: RewritePayload, - request: Request, - ): Promise; - + readonly mode: RuntimeMode, + readonly renderers: SSRLoadedRenderer[], + readonly resolve: (s: string) => Promise, /** - * Tells the pipeline how to retrieve a component give a `RouteData` - * @param routeData + * Based on Astro config's `output` option, `true` if "server" or "hybrid". */ - abstract getComponentByRoute(routeData: RouteData): Promise; - + readonly serverLike: boolean, + readonly streaming: boolean, + /** + * Used to provide better error messages for `Astro.clientAddress` + */ + readonly adapterName = manifest.adapterName, + readonly clientDirectives = manifest.clientDirectives, + readonly inlinedScripts = manifest.inlinedScripts, + readonly compressHTML = manifest.compressHTML, + readonly i18n = manifest.i18n, + readonly middleware = manifest.middleware, + readonly routeCache = new RouteCache(logger, mode), + /** + * Used for `Astro.site`. + */ + readonly site = manifest.site ? new URL(manifest.site) : undefined, + readonly callSetGetEnv = true, /** - * Resolves the middleware from the manifest, and returns the `onRequest` function. If `onRequest` isn't there, - * it returns a no-op function + * Array of built-in, internal, routes. + * Used to find the route module */ - async getMiddleware(): Promise { - if (this.resolvedMiddleware) { - return this.resolvedMiddleware; + readonly defaultRoutes = createDefaultRoutes(manifest), + ) { + this.internalMiddleware = []; + // We do use our middleware only if the user isn't using the manual setup + if (i18n?.strategy !== 'manual') { + this.internalMiddleware.push( + createI18nMiddleware(i18n, manifest.base, manifest.trailingSlash, manifest.buildFormat), + ); + } + // In SSR, getSecret should fail by default. Setting it here will run before the + // adapter override. + if (callSetGetEnv && manifest.envGetSecretEnabled) { + setGetEnv(() => { + throw new AstroError(AstroErrorData.EnvUnsupportedGetSecret); + }, true); + } + } + + abstract headElements(routeData: RouteData): Promise | HeadElements; + + abstract componentMetadata(routeData: RouteData): Promise | void; + + /** + * It attempts to retrieve the `RouteData` that matches the input `url`, and the component that belongs to the `RouteData`. + * + * ## Errors + * + * - if not `RouteData` is found + * + * @param {RewritePayload} rewritePayload The payload provided by the user + * @param {Request} request The original request + */ + abstract tryRewrite(rewritePayload: RewritePayload, request: Request): Promise; + + /** + * Tells the pipeline how to retrieve a component give a `RouteData` + * @param routeData + */ + abstract getComponentByRoute(routeData: RouteData): Promise; + + /** + * Resolves the middleware from the manifest, and returns the `onRequest` function. If `onRequest` isn't there, + * it returns a no-op function + */ + async getMiddleware(): Promise { + if (this.resolvedMiddleware) { + return this.resolvedMiddleware; + } else { + const middlewareInstance = await this.middleware(); + const onRequest = middlewareInstance.onRequest ?? NOOP_MIDDLEWARE_FN; + if (this.manifest.checkOrigin) { + this.resolvedMiddleware = sequence(createOriginCheckMiddleware(), onRequest); } else { - const middlewareInstance = await this.middleware(); - const onRequest = middlewareInstance.onRequest ?? NOOP_MIDDLEWARE_FN; - if (this.manifest.checkOrigin) { - this.resolvedMiddleware = sequence(createOriginCheckMiddleware(), onRequest); - } else { - this.resolvedMiddleware = onRequest; - } - return this.resolvedMiddleware; + this.resolvedMiddleware = onRequest; } + return this.resolvedMiddleware; } } +} // eslint-disable-next-line @typescript-eslint/no-empty-object-type export interface HeadElements extends Pick {} diff --git a/packages/astro/src/core/config/schema.ts b/packages/astro/src/core/config/schema.ts index 1c80f6abe793..ec2ac3805115 100644 --- a/packages/astro/src/core/config/schema.ts +++ b/packages/astro/src/core/config/schema.ts @@ -660,10 +660,14 @@ export function createRelativeSchema(cmd: string, fileProtocolRoot: string) { // Handle `base` and `image.endpoint.route` trailing slash based on `trailingSlash` config if (config.trailingSlash === 'never') { config.base = prependForwardSlash(removeTrailingForwardSlash(config.base)); - config.image.endpoint.route = prependForwardSlash(removeTrailingForwardSlash(config.image.endpoint.route)); + config.image.endpoint.route = prependForwardSlash( + removeTrailingForwardSlash(config.image.endpoint.route), + ); } else if (config.trailingSlash === 'always') { config.base = prependForwardSlash(appendForwardSlash(config.base)); - config.image.endpoint.route = prependForwardSlash(appendForwardSlash(config.image.endpoint.route)); + config.image.endpoint.route = prependForwardSlash( + appendForwardSlash(config.image.endpoint.route), + ); } else { config.base = prependForwardSlash(config.base); config.image.endpoint.route = prependForwardSlash(config.image.endpoint.route); diff --git a/packages/astro/src/core/middleware/noop-middleware.ts b/packages/astro/src/core/middleware/noop-middleware.ts index 2f55962d1f83..ebb7c1b34f6e 100644 --- a/packages/astro/src/core/middleware/noop-middleware.ts +++ b/packages/astro/src/core/middleware/noop-middleware.ts @@ -1,3 +1,3 @@ -import type { MiddlewareHandler } from "../../types/public/common.js"; +import type { MiddlewareHandler } from '../../types/public/common.js'; export const NOOP_MIDDLEWARE_FN: MiddlewareHandler = (_, next) => next(); diff --git a/packages/astro/src/core/routing/manifest/generator.ts b/packages/astro/src/core/routing/manifest/generator.ts index d6ed25b44360..9674a862e3f6 100644 --- a/packages/astro/src/core/routing/manifest/generator.ts +++ b/packages/astro/src/core/routing/manifest/generator.ts @@ -1,5 +1,5 @@ -import type { AstroConfig } from "../../../types/public/config.js"; -import type { RoutePart } from "../../../types/public/internal.js"; +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/test/core-image.test.js b/packages/astro/test/core-image.test.js index 379b18b73d88..d0fa7775e201 100644 --- a/packages/astro/test/core-image.test.js +++ b/packages/astro/test/core-image.test.js @@ -1273,7 +1273,7 @@ describe('astro:image', () => { const src = $('#local img').attr('src'); assert.equal(src.startsWith('/_image/?'), true); - }) + }); it('does not includes a trailing slash if trailing slash is set to never', async () => { fixture = await loadFixture({ @@ -1292,10 +1292,10 @@ describe('astro:image', () => { const src = $('#local img').attr('src'); assert.equal(src.startsWith('/_image?'), true); - }) + }); afterEach(async () => { await devServer.stop(); }); - }) + }); }); diff --git a/packages/integrations/svelte/CHANGELOG.md b/packages/integrations/svelte/CHANGELOG.md index 528b7363c200..5c0b4c5153fd 100644 --- a/packages/integrations/svelte/CHANGELOG.md +++ b/packages/integrations/svelte/CHANGELOG.md @@ -1,5 +1,11 @@ # @astrojs/svelte +## 6.0.0-beta.0 + +### Major Changes + +- [#12060](https://github.com/withastro/astro/pull/12060) [`cb5d3ae`](https://github.com/withastro/astro/commit/cb5d3ae6ee6af646c9d7d46a9d8f551edac3092e) Thanks [@Princesseuh](https://github.com/Princesseuh)! - Updates peer dependency range to support Astro 5 + ## 6.0.0-alpha.0 ### Patch Changes diff --git a/packages/integrations/svelte/package.json b/packages/integrations/svelte/package.json index 7241dbc6ad20..8a194d9e3ec2 100644 --- a/packages/integrations/svelte/package.json +++ b/packages/integrations/svelte/package.json @@ -1,6 +1,6 @@ { "name": "@astrojs/svelte", - "version": "5.7.1", + "version": "6.0.0-beta.0", "description": "Use Svelte components within Astro", "type": "module", "types": "./dist/index.d.ts", diff --git a/packages/integrations/vue/CHANGELOG.md b/packages/integrations/vue/CHANGELOG.md index a6fbc1ca6373..453aa2ecc0d3 100644 --- a/packages/integrations/vue/CHANGELOG.md +++ b/packages/integrations/vue/CHANGELOG.md @@ -1,5 +1,11 @@ # @astrojs/vue +## 5.0.0-beta.0 + +### Major Changes + +- [#12060](https://github.com/withastro/astro/pull/12060) [`cb5d3ae`](https://github.com/withastro/astro/commit/cb5d3ae6ee6af646c9d7d46a9d8f551edac3092e) Thanks [@Princesseuh](https://github.com/Princesseuh)! - Updates peer dependency range to support Astro 5 + ## 5.0.0-alpha.0 ### Patch Changes diff --git a/packages/integrations/vue/package.json b/packages/integrations/vue/package.json index eb723f8fb7ad..8b78c2a98e87 100644 --- a/packages/integrations/vue/package.json +++ b/packages/integrations/vue/package.json @@ -1,6 +1,6 @@ { "name": "@astrojs/vue", - "version": "4.5.1", + "version": "5.0.0-beta.0", "description": "Use Vue components within Astro", "type": "module", "types": "./dist/index.d.ts", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 7096c4ff58fa..1eabbc7f7e09 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -113,7 +113,7 @@ importers: examples/basics: dependencies: astro: - specifier: ^5.0.0-beta.1 + specifier: ^5.0.0-beta.2 version: link:../../packages/astro examples/blog: @@ -128,13 +128,13 @@ importers: specifier: ^3.1.6 version: link:../../packages/integrations/sitemap astro: - specifier: ^5.0.0-beta.1 + specifier: ^5.0.0-beta.2 version: link:../../packages/astro examples/component: devDependencies: astro: - specifier: ^5.0.0-beta.1 + specifier: ^5.0.0-beta.2 version: link:../../packages/astro examples/container-with-vitest: @@ -143,7 +143,7 @@ importers: specifier: ^3.6.2 version: link:../../packages/integrations/react astro: - specifier: ^5.0.0-beta.1 + specifier: ^5.0.0-beta.2 version: link:../../packages/astro react: specifier: ^18.3.1 @@ -174,7 +174,7 @@ importers: specifier: ^3.14.1 version: 3.14.1 astro: - specifier: ^5.0.0-beta.1 + specifier: ^5.0.0-beta.2 version: link:../../packages/astro examples/framework-multiple: @@ -186,13 +186,13 @@ importers: specifier: ^3.6.2 version: link:../../packages/integrations/react '@astrojs/solid-js': - specifier: ^4.4.1 + specifier: ^4.4.2 version: link:../../packages/integrations/solid '@astrojs/svelte': - specifier: ^5.7.0 + specifier: ^6.0.0-beta.0 version: link:../../packages/integrations/svelte '@astrojs/vue': - specifier: ^4.5.0 + specifier: ^5.0.0-beta.0 version: link:../../packages/integrations/vue '@types/react': specifier: ^18.3.3 @@ -201,7 +201,7 @@ importers: specifier: ^18.3.0 version: 18.3.0 astro: - specifier: ^5.0.0-beta.1 + specifier: ^5.0.0-beta.2 version: link:../../packages/astro preact: specifier: ^10.23.2 @@ -231,7 +231,7 @@ importers: specifier: ^1.3.0 version: 1.3.0(preact@10.23.2) astro: - specifier: ^5.0.0-beta.1 + specifier: ^5.0.0-beta.2 version: link:../../packages/astro preact: specifier: ^10.23.2 @@ -249,7 +249,7 @@ importers: specifier: ^18.3.0 version: 18.3.0 astro: - specifier: ^5.0.0-beta.1 + specifier: ^5.0.0-beta.2 version: link:../../packages/astro react: specifier: ^18.3.1 @@ -264,7 +264,7 @@ importers: specifier: ^4.4.2 version: link:../../packages/integrations/solid astro: - specifier: ^5.0.0-beta.1 + specifier: ^5.0.0-beta.2 version: link:../../packages/astro solid-js: specifier: ^1.8.22 @@ -273,10 +273,10 @@ importers: examples/framework-svelte: dependencies: '@astrojs/svelte': - specifier: ^5.7.1 + specifier: ^6.0.0-beta.0 version: link:../../packages/integrations/svelte astro: - specifier: ^5.0.0-beta.1 + specifier: ^5.0.0-beta.2 version: link:../../packages/astro svelte: specifier: ^4.2.19 @@ -285,10 +285,10 @@ importers: examples/framework-vue: dependencies: '@astrojs/vue': - specifier: ^4.5.1 + specifier: ^5.0.0-beta.0 version: link:../../packages/integrations/vue astro: - specifier: ^5.0.0-beta.1 + specifier: ^5.0.0-beta.2 version: link:../../packages/astro vue: specifier: ^3.5.3 @@ -300,13 +300,13 @@ importers: specifier: ^9.0.0-alpha.1 version: 9.0.0-alpha.1(astro@packages+astro) astro: - specifier: ^5.0.0-beta.1 + specifier: ^5.0.0-beta.2 version: link:../../packages/astro examples/integration: devDependencies: astro: - specifier: ^5.0.0-beta.1 + specifier: ^5.0.0-beta.2 version: link:../../packages/astro examples/middleware: @@ -315,7 +315,7 @@ importers: specifier: ^9.0.0-alpha.1 version: 9.0.0-alpha.1(astro@packages+astro) astro: - specifier: ^5.0.0-beta.1 + specifier: ^5.0.0-beta.2 version: link:../../packages/astro html-minifier: specifier: ^4.0.0 @@ -328,19 +328,19 @@ importers: examples/minimal: dependencies: astro: - specifier: ^5.0.0-beta.1 + specifier: ^5.0.0-beta.2 version: link:../../packages/astro examples/non-html-pages: dependencies: astro: - specifier: ^5.0.0-beta.1 + specifier: ^5.0.0-beta.2 version: link:../../packages/astro examples/portfolio: dependencies: astro: - specifier: ^5.0.0-beta.1 + specifier: ^5.0.0-beta.2 version: link:../../packages/astro examples/server-islands: @@ -367,7 +367,7 @@ importers: specifier: ^18.3.0 version: 18.3.0 astro: - specifier: ^5.0.0-beta.1 + specifier: ^5.0.0-beta.2 version: link:../../packages/astro postcss: specifier: ^8.4.45 @@ -388,10 +388,10 @@ importers: specifier: ^9.0.0-alpha.1 version: 9.0.0-alpha.1(astro@packages+astro) '@astrojs/svelte': - specifier: ^5.7.0 + specifier: ^6.0.0-beta.0 version: link:../../packages/integrations/svelte astro: - specifier: ^5.0.0-beta.1 + specifier: ^5.0.0-beta.2 version: link:../../packages/astro svelte: specifier: ^4.2.19 @@ -400,7 +400,7 @@ importers: examples/starlog: dependencies: astro: - specifier: ^5.0.0-beta.1 + specifier: ^5.0.0-beta.2 version: link:../../packages/astro sass: specifier: ^1.78.0 @@ -412,7 +412,7 @@ importers: examples/toolbar-app: devDependencies: astro: - specifier: ^5.0.0-beta.1 + specifier: ^5.0.0-beta.2 version: link:../../packages/astro examples/view-transitions: @@ -424,7 +424,7 @@ importers: specifier: ^5.1.1 version: link:../../packages/integrations/tailwind astro: - specifier: ^5.0.0-beta.1 + specifier: ^5.0.0-beta.2 version: link:../../packages/astro examples/with-markdoc: @@ -433,7 +433,7 @@ importers: specifier: ^0.11.5-beta.0 version: link:../../packages/integrations/markdoc astro: - specifier: ^5.0.0-beta.1 + specifier: ^5.0.0-beta.2 version: link:../../packages/astro examples/with-markdown-plugins: @@ -442,7 +442,7 @@ importers: specifier: ^6.0.0-beta.1 version: link:../../packages/markdown/remark astro: - specifier: ^5.0.0-beta.1 + specifier: ^5.0.0-beta.2 version: link:../../packages/astro hast-util-select: specifier: ^6.0.2 @@ -463,7 +463,7 @@ importers: examples/with-markdown-shiki: dependencies: astro: - specifier: ^5.0.0-beta.1 + specifier: ^5.0.0-beta.2 version: link:../../packages/astro examples/with-mdx: @@ -475,7 +475,7 @@ importers: specifier: ^3.5.3 version: link:../../packages/integrations/preact astro: - specifier: ^5.0.0-beta.1 + specifier: ^5.0.0-beta.2 version: link:../../packages/astro preact: specifier: ^10.23.2 @@ -490,7 +490,7 @@ importers: specifier: ^0.5.2 version: 0.5.2(nanostores@0.11.3)(preact@10.23.2) astro: - specifier: ^5.0.0-beta.1 + specifier: ^5.0.0-beta.2 version: link:../../packages/astro nanostores: specifier: ^0.11.3 @@ -511,7 +511,7 @@ importers: specifier: ^1.6.4 version: 1.6.4 astro: - specifier: ^5.0.0-beta.1 + specifier: ^5.0.0-beta.2 version: link:../../packages/astro autoprefixer: specifier: ^10.4.20 @@ -529,7 +529,7 @@ importers: examples/with-vitest: dependencies: astro: - specifier: ^5.0.0-beta.1 + specifier: ^5.0.0-beta.2 version: link:../../packages/astro vitest: specifier: ^2.0.5