From 53e8bb6d5ffb71ec42b152ecc15f1817e8c2cd00 Mon Sep 17 00:00:00 2001 From: Emanuele Stoppa Date: Thu, 20 Jun 2024 07:10:23 +0100 Subject: [PATCH 01/42] chore: update biome (#11288) --- biome.json | 17 ++++++--- package.json | 10 +++--- pnpm-lock.yaml | 95 ++++++++++++++++++++++++++++++-------------------- 3 files changed, 76 insertions(+), 46 deletions(-) diff --git a/biome.json b/biome.json index df61ec83b2..9da3b4db06 100644 --- a/biome.json +++ b/biome.json @@ -1,5 +1,5 @@ { - "$schema": "https://biomejs.dev/schemas/1.7.1/schema.json", + "$schema": "https://biomejs.dev/schemas/1.8.1/schema.json", "files": { "ignore": [ "vendor", @@ -20,7 +20,6 @@ "benchmark/results/", ".changeset", "pnpm-lock.yaml", - "package.json", "*.astro" ] }, @@ -30,7 +29,7 @@ "linter": { "enabled": false }, "javascript": { "formatter": { - "trailingComma": "es5", + "trailingCommas": "es5", "quoteStyle": "single", "semicolons": "always" } @@ -44,5 +43,15 @@ "indentStyle": "space", "trailingCommas": "none" } - } + }, + "overrides": [ + { + "include": ["package.json"], + "json": { + "formatter": { + "lineWidth": 1 + } + } + } + ] } diff --git a/package.json b/package.json index 7310bde62c..cc68c58443 100644 --- a/package.json +++ b/package.json @@ -16,10 +16,10 @@ "dev": "turbo run dev --concurrency=40 --parallel --filter=astro --filter=create-astro --filter=\"@astrojs/*\" --filter=\"@benchmark/*\"", "format": "pnpm run format:code && pnpm run format:imports", "format:ci": "pnpm run format:code:ci && pnpm run format:imports:ci", - "format:code": "biome format ./ --write && prettier -w \"**/*\" --ignore-unknown --cache", - "format:code:ci": "biome format ./ && prettier -w \"**/*\" --ignore-unknown --cache --check", - "format:imports": "biome check --apply .", - "format:imports:ci": "biome ci .", + "format:code": "biome format --write && prettier -w \"**/*\" --ignore-unknown --cache", + "format:code:ci": "biome format && prettier -w \"**/*\" --ignore-unknown --cache --check", + "format:imports": "biome check --formatter-enabled=false --write", + "format:imports:ci": "biome ci --formatter-enabled=false", "test": "turbo run test --concurrency=1 --filter=astro --filter=create-astro --filter=\"@astrojs/*\"", "test:citgm": "pnpm -r --filter=astro test", "test:match": "cd packages/astro && pnpm run test:match", @@ -52,7 +52,7 @@ }, "devDependencies": { "@astrojs/check": "^0.7.0", - "@biomejs/biome": "1.7.1", + "@biomejs/biome": "1.8.1", "@changesets/changelog-github": "^0.5.0", "@changesets/cli": "^2.27.5", "@eslint/eslintrc": "^3.1.0", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index b5a6463015..9361d07b49 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -22,8 +22,8 @@ importers: specifier: ^0.7.0 version: 0.7.0(prettier-plugin-astro@0.14.0)(prettier@3.3.2)(typescript@5.4.5) '@biomejs/biome': - specifier: 1.7.1 - version: 1.7.1 + specifier: 1.8.1 + version: 1.8.1 '@changesets/changelog-github': specifier: ^0.5.0 version: 0.5.0 @@ -2569,6 +2569,27 @@ importers: specifier: ^3.4.29 version: 3.4.29(typescript@5.4.5) + packages/astro/test/fixtures/container-dev-renderers: + dependencies: + '@astrojs/react': + specifier: workspace:* + version: link:../../../../integrations/react + '@astrojs/vue': + specifier: workspace:* + version: link:../../../../integrations/vue + astro: + specifier: workspace:* + version: link:../../.. + react: + specifier: ^18.3.1 + version: 18.3.1 + react-dom: + specifier: ^18.3.1 + version: 18.3.1(react@18.3.1) + vue: + specifier: ^3.4.29 + version: 3.4.29(typescript@5.4.5) + packages/astro/test/fixtures/content: dependencies: '@astrojs/mdx': @@ -6161,55 +6182,55 @@ packages: resolution: {integrity: sha512-XEFXSlxiG5td2EJRe8vOmRbaXVgfcBlszKujvVmWIK/UpywWljQCfzAv3RQCGujWQ1RD4YYWEAqDXfuJiy8f5Q==} engines: {node: '>=6.9.0'} - '@biomejs/biome@1.7.1': - resolution: {integrity: sha512-wb2UNoFXcgaMdKXKT5ytsYntaogl2FSTjDt20CZynF3v7OXQUcIpTrr+be3XoOGpoZRj3Ytq9TSpmplUREXmeA==} + '@biomejs/biome@1.8.1': + resolution: {integrity: sha512-fQXGfvq6DIXem12dGQCM2tNF+vsNHH1qs3C7WeOu75Pd0trduoTmoO7G4ntLJ2qDs5wuw981H+cxQhi1uHnAtA==} engines: {node: '>=14.21.3'} hasBin: true - '@biomejs/cli-darwin-arm64@1.7.1': - resolution: {integrity: sha512-qfLrIIB58dkgiY/1tgG6fSCBK22PZaSIf6blweZBsG6iMij05mEuJt50ne+zPnNFNUmt8t43NC/qOXT3iFHQBA==} + '@biomejs/cli-darwin-arm64@1.8.1': + resolution: {integrity: sha512-XLiB7Uu6GALIOBWzQ2aMD0ru4Ly5/qSeQF7kk3AabzJ/kwsEWSe33iVySBP/SS2qv25cgqNiLksjGcw2bHT3mw==} engines: {node: '>=14.21.3'} cpu: [arm64] os: [darwin] - '@biomejs/cli-darwin-x64@1.7.1': - resolution: {integrity: sha512-OGeyNsEcp5VnKbF9/TBjPCTHNEOm7oHegEve07U3KZmzqfpw2Oe3i9DVW8t6vvj1TYbrwWYCld25H34kBDY7Vg==} + '@biomejs/cli-darwin-x64@1.8.1': + resolution: {integrity: sha512-uMTSxVLMfqkBVqyc25hSn83jBbp+wtWjzM/pHFlKXt3htJuw7FErVGW0nmQ9Sxa9vJ7GcqoltLMl28VQRIMYzg==} engines: {node: '>=14.21.3'} cpu: [x64] os: [darwin] - '@biomejs/cli-linux-arm64-musl@1.7.1': - resolution: {integrity: sha512-giH0/CzLOJ+wbxLxd5Shnr5xQf5fGnTRWLDe3lzjaF7IplVydNCEeZJtncB01SvyA6DAFJsvQ4LNxzAOQfEVCg==} + '@biomejs/cli-linux-arm64-musl@1.8.1': + resolution: {integrity: sha512-UQ8Wc01J0wQL+5AYOc7qkJn20B4PZmQL1KrmDZh7ot0DvD6aX4+8mmfd/dG5b6Zjo/44QvCKcvkFGCMRYuhWZA==} engines: {node: '>=14.21.3'} cpu: [arm64] os: [linux] - '@biomejs/cli-linux-arm64@1.7.1': - resolution: {integrity: sha512-MQDf5wErj1iBvlcxCyOa0XqZYN8WJrupVgbNnqhntO3yVATg8GxduVUn1fDSaolznkDRsj7Pz3Xu1esBFwvfmg==} + '@biomejs/cli-linux-arm64@1.8.1': + resolution: {integrity: sha512-3SzZRuC/9Oi2P2IBNPsEj0KXxSXUEYRR2kfRF/Ve8QAfGgrt4qnwuWd6QQKKN5R+oYH691qjm+cXBKEcrP1v/Q==} engines: {node: '>=14.21.3'} cpu: [arm64] os: [linux] - '@biomejs/cli-linux-x64-musl@1.7.1': - resolution: {integrity: sha512-ySNDtPhsLxU125IFHHAxfpoHBpkM56s4mEXeO70GZtgZay/o1h8IUPWCWf5Z7gKgc4jwgYN1U1U9xabI3hZVAg==} + '@biomejs/cli-linux-x64-musl@1.8.1': + resolution: {integrity: sha512-fYbP/kNu/rtZ4kKzWVocIdqZOtBSUEg9qUhZaao3dy3CRzafR6u6KDtBeSCnt47O+iLnks1eOR1TUxzr5+QuqA==} engines: {node: '>=14.21.3'} cpu: [x64] os: [linux] - '@biomejs/cli-linux-x64@1.7.1': - resolution: {integrity: sha512-3wmCsGcC3KZ4pfTknXHfyMMlXPMhgfXVAcG5GlrR+Tq2JGiAw0EUydaLpsSBEbcG7IxH6OiUZEJZ95kAycCHBA==} + '@biomejs/cli-linux-x64@1.8.1': + resolution: {integrity: sha512-AeBycVdNrTzsyYKEOtR2R0Ph0hCD0sCshcp2aOnfGP0hCZbtFg09D0SdKLbyzKntisY41HxKVrydYiaApp+2uw==} engines: {node: '>=14.21.3'} cpu: [x64] os: [linux] - '@biomejs/cli-win32-arm64@1.7.1': - resolution: {integrity: sha512-8hIDakEqZn0i6+388noYKdZ0ZrovTwnvMU/Qp/oJou0G7EPVdXupOe0oxiQSdRN0W7f6CS/yjPCYuVGzDG6r0g==} + '@biomejs/cli-win32-arm64@1.8.1': + resolution: {integrity: sha512-6tEd1H/iFKpgpE3OIB7oNgW5XkjiVMzMRPL8zYoZ036YfuJ5nMYm9eB9H/y81+8Z76vL48fiYzMPotJwukGPqQ==} engines: {node: '>=14.21.3'} cpu: [arm64] os: [win32] - '@biomejs/cli-win32-x64@1.7.1': - resolution: {integrity: sha512-3W9k3uH6Ea6VOpAS9xkkAlS0LTfnGQjmIUCegZ8SDtK2NgJ1gO+qdEkGJb0ltahusFTN1QxJ107dM7ASA9IUEg==} + '@biomejs/cli-win32-x64@1.8.1': + resolution: {integrity: sha512-g2H31jJzYmS4jkvl6TiyEjEX+Nv79a5km/xn+5DARTp5MBFzC9gwceusSSB2AkJKqZzY131AiACAWjKrVt5Ijw==} engines: {node: '>=14.21.3'} cpu: [x64] os: [win32] @@ -12462,39 +12483,39 @@ snapshots: '@babel/helper-validator-identifier': 7.24.7 to-fast-properties: 2.0.0 - '@biomejs/biome@1.7.1': + '@biomejs/biome@1.8.1': optionalDependencies: - '@biomejs/cli-darwin-arm64': 1.7.1 - '@biomejs/cli-darwin-x64': 1.7.1 - '@biomejs/cli-linux-arm64': 1.7.1 - '@biomejs/cli-linux-arm64-musl': 1.7.1 - '@biomejs/cli-linux-x64': 1.7.1 - '@biomejs/cli-linux-x64-musl': 1.7.1 - '@biomejs/cli-win32-arm64': 1.7.1 - '@biomejs/cli-win32-x64': 1.7.1 + '@biomejs/cli-darwin-arm64': 1.8.1 + '@biomejs/cli-darwin-x64': 1.8.1 + '@biomejs/cli-linux-arm64': 1.8.1 + '@biomejs/cli-linux-arm64-musl': 1.8.1 + '@biomejs/cli-linux-x64': 1.8.1 + '@biomejs/cli-linux-x64-musl': 1.8.1 + '@biomejs/cli-win32-arm64': 1.8.1 + '@biomejs/cli-win32-x64': 1.8.1 - '@biomejs/cli-darwin-arm64@1.7.1': + '@biomejs/cli-darwin-arm64@1.8.1': optional: true - '@biomejs/cli-darwin-x64@1.7.1': + '@biomejs/cli-darwin-x64@1.8.1': optional: true - '@biomejs/cli-linux-arm64-musl@1.7.1': + '@biomejs/cli-linux-arm64-musl@1.8.1': optional: true - '@biomejs/cli-linux-arm64@1.7.1': + '@biomejs/cli-linux-arm64@1.8.1': optional: true - '@biomejs/cli-linux-x64-musl@1.7.1': + '@biomejs/cli-linux-x64-musl@1.8.1': optional: true - '@biomejs/cli-linux-x64@1.7.1': + '@biomejs/cli-linux-x64@1.8.1': optional: true - '@biomejs/cli-win32-arm64@1.7.1': + '@biomejs/cli-win32-arm64@1.8.1': optional: true - '@biomejs/cli-win32-x64@1.7.1': + '@biomejs/cli-win32-x64@1.8.1': optional: true '@builder.io/partytown@0.10.2': {} From 7f8f34799528ed0b2011e1ea273bd0636f6e767d Mon Sep 17 00:00:00 2001 From: Jacob Jenkins Date: Thu, 20 Jun 2024 08:34:11 +0100 Subject: [PATCH 02/42] bug: removes type override from defineAction (#11292) * bug: removes type override * add changeset * Update .changeset/quiet-doors-eat.md Co-authored-by: Florian Lefebvre --------- Co-authored-by: Florian Lefebvre --- .changeset/quiet-doors-eat.md | 5 +++++ packages/astro/src/actions/runtime/virtual/server.ts | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 .changeset/quiet-doors-eat.md diff --git a/.changeset/quiet-doors-eat.md b/.changeset/quiet-doors-eat.md new file mode 100644 index 0000000000..587dba8ba7 --- /dev/null +++ b/.changeset/quiet-doors-eat.md @@ -0,0 +1,5 @@ +--- +"astro": patch +--- + +Fixes a case where `defineAction` autocomplete for the `accept` prop would not show `"form"` as a possible value diff --git a/packages/astro/src/actions/runtime/virtual/server.ts b/packages/astro/src/actions/runtime/virtual/server.ts index ce4d5f6966..d52a284ce3 100644 --- a/packages/astro/src/actions/runtime/virtual/server.ts +++ b/packages/astro/src/actions/runtime/virtual/server.ts @@ -50,7 +50,7 @@ export type ActionClient< export function defineAction< TOutput, - TAccept extends Accept = 'json', + TAccept extends Accept, TInputSchema extends InputSchema | undefined = TAccept extends 'form' ? // If `input` is omitted, default to `FormData` for forms and `any` for JSON. z.ZodType From fd3645fe8364ec5e280b6802d1468867890d463c Mon Sep 17 00:00:00 2001 From: Matt Kane Date: Thu, 20 Jun 2024 11:08:17 +0100 Subject: [PATCH 03/42] fix: allow cookies to be set in rewritten responses (#11280) * fix: allow cookies to be set in rewritten responses * Merge cookies * Add support for endpoints and more tests --- .changeset/big-eyes-share.md | 5 ++ packages/astro/src/core/cookies/cookies.ts | 13 +++++ packages/astro/src/core/cookies/response.ts | 2 +- packages/astro/src/core/render-context.ts | 19 +++++-- packages/astro/test/astro-cookies.test.js | 54 +++++++++++++++++++ .../astro-cookies/src/pages/from-endpoint.ts | 3 ++ .../astro-cookies/src/pages/from.astro | 5 ++ .../src/pages/rewrite-target.astro | 18 +++++++ .../astro-cookies/src/pages/to-endpoint.ts | 4 ++ 9 files changed, 118 insertions(+), 5 deletions(-) create mode 100644 .changeset/big-eyes-share.md create mode 100644 packages/astro/test/fixtures/astro-cookies/src/pages/from-endpoint.ts create mode 100644 packages/astro/test/fixtures/astro-cookies/src/pages/from.astro create mode 100644 packages/astro/test/fixtures/astro-cookies/src/pages/rewrite-target.astro create mode 100644 packages/astro/test/fixtures/astro-cookies/src/pages/to-endpoint.ts diff --git a/.changeset/big-eyes-share.md b/.changeset/big-eyes-share.md new file mode 100644 index 0000000000..f08f87c504 --- /dev/null +++ b/.changeset/big-eyes-share.md @@ -0,0 +1,5 @@ +--- +'astro': patch +--- + +Fixes a bug that prevented cookies from being set when using experimental rewrites diff --git a/packages/astro/src/core/cookies/cookies.ts b/packages/astro/src/core/cookies/cookies.ts index 069afc796e..c176fc7572 100644 --- a/packages/astro/src/core/cookies/cookies.ts +++ b/packages/astro/src/core/cookies/cookies.ts @@ -191,6 +191,19 @@ class AstroCookies implements AstroCookiesInterface { } } + /** + * Merges a new AstroCookies instance into the current instance. Any new cookies + * will be added to the current instance, overwriting any existing cookies with the same name. + */ + merge(cookies: AstroCookies) { + const outgoing = cookies.#outgoing; + if (outgoing) { + for (const [key, value] of outgoing) { + this.#ensureOutgoingMap().set(key, value); + } + } + } + /** * Astro.cookies.header() returns an iterator for the cookies that have previously * been set by either Astro.cookies.set() or Astro.cookies.delete(). diff --git a/packages/astro/src/core/cookies/response.ts b/packages/astro/src/core/cookies/response.ts index c4dd388934..26f032fdd3 100644 --- a/packages/astro/src/core/cookies/response.ts +++ b/packages/astro/src/core/cookies/response.ts @@ -10,7 +10,7 @@ export function responseHasCookies(response: Response): boolean { return Reflect.has(response, astroCookiesSymbol); } -function getFromResponse(response: Response): AstroCookies | undefined { +export function getFromResponse(response: Response): AstroCookies | undefined { let cookies = Reflect.get(response, astroCookiesSymbol); if (cookies != null) { return cookies as AstroCookies; diff --git a/packages/astro/src/core/render-context.ts b/packages/astro/src/core/render-context.ts index d46f809882..4139220422 100644 --- a/packages/astro/src/core/render-context.ts +++ b/packages/astro/src/core/render-context.ts @@ -27,6 +27,7 @@ import { responseSentSymbol, } from './constants.js'; import { AstroCookies, attachCookiesToResponse } from './cookies/index.js'; +import { getFromResponse } from './cookies/response.js'; import { AstroError, AstroErrorData } from './errors/index.js'; import { callMiddleware } from './middleware/callMiddleware.js'; import { sequence } from './middleware/index.js'; @@ -151,14 +152,17 @@ export class RenderContext { ); } } + let response: Response; + switch (this.routeData.type) { - case 'endpoint': - return renderEndpoint(componentInstance as any, ctx, serverLike, logger); + case 'endpoint': { + response = await renderEndpoint(componentInstance as any, ctx, serverLike, logger); + break; + } case 'redirect': return renderRedirect(this); case 'page': { const result = await this.createResult(componentInstance!); - let response: Response; try { response = await renderPage( result, @@ -185,12 +189,19 @@ export class RenderContext { ) { response.headers.set(REROUTE_DIRECTIVE_HEADER, 'no'); } - return response; + break; } case 'fallback': { return new Response(null, { status: 500, headers: { [ROUTE_TYPE_HEADER]: 'fallback' } }); } } + // We need to merge the cookies from the response back into this.cookies + // because they may need to be passed along from a rewrite. + const responseCookies = getFromResponse(response); + if (responseCookies) { + cookies.merge(responseCookies); + } + return response; }; const response = await callMiddleware( diff --git a/packages/astro/test/astro-cookies.test.js b/packages/astro/test/astro-cookies.test.js index 9d7136c4f8..482474b54b 100644 --- a/packages/astro/test/astro-cookies.test.js +++ b/packages/astro/test/astro-cookies.test.js @@ -52,6 +52,31 @@ describe('Astro.cookies', () => { assert.equal(response.headers.has('set-cookie'), true); } }); + + it('can set cookies in a rewritten page request', async () => { + const response = await fixture.fetch('/from'); + assert.equal(response.status, 200); + + assert.match(response.headers.get('set-cookie'), /my_cookie=value/); + }); + + it('overwrites cookie values set in the source page with values from the target page', async () => { + const response = await fixture.fetch('/from'); + assert.equal(response.status, 200); + assert.match(response.headers.get('set-cookie'), /another=set-in-target/); + }); + + it('allows cookies to be set in the source page', async () => { + const response = await fixture.fetch('/from'); + assert.equal(response.status, 200); + assert.match(response.headers.get('set-cookie'), /set-in-from=yes/); + }); + + it('can set cookies in a rewritten endpoint request', async () => { + const response = await fixture.fetch('/from-endpoint'); + assert.equal(response.status, 200); + assert.match(response.headers.get('set-cookie'), /test=value/); + }); }); describe('Production', () => { @@ -140,5 +165,34 @@ describe('Astro.cookies', () => { assert.equal(typeof data, 'object'); assert.equal(data.mode, 'dark'); }); + + it('can set cookies in a rewritten page request', async () => { + const request = new Request('http://example.com/from'); + const response = await app.render(request, { addCookieHeader: true }); + assert.equal(response.status, 200); + + assert.match(response.headers.get('Set-Cookie'), /my_cookie=value/); + }); + + it('overwrites cookie values set in the source page with values from the target page', async () => { + const request = new Request('http://example.com/from'); + const response = await app.render(request, { addCookieHeader: true }); + assert.equal(response.status, 200); + assert.match(response.headers.get('Set-Cookie'), /another=set-in-target/); + }); + + it('allows cookies to be set in the source page', async () => { + const request = new Request('http://example.com/from'); + const response = await app.render(request, { addCookieHeader: true }); + assert.equal(response.status, 200); + assert.match(response.headers.get('Set-Cookie'), /set-in-from=yes/); + }); + + it('can set cookies in a rewritten endpoint request', async () => { + const request = new Request('http://example.com/from-endpoint'); + const response = await app.render(request, { addCookieHeader: true }); + assert.equal(response.status, 200); + assert.match(response.headers.get('Set-Cookie'), /test=value/); + }); }); }); diff --git a/packages/astro/test/fixtures/astro-cookies/src/pages/from-endpoint.ts b/packages/astro/test/fixtures/astro-cookies/src/pages/from-endpoint.ts new file mode 100644 index 0000000000..08c586dcf5 --- /dev/null +++ b/packages/astro/test/fixtures/astro-cookies/src/pages/from-endpoint.ts @@ -0,0 +1,3 @@ +export async function GET(context) { + return context.rewrite('/to-endpoint'); +} diff --git a/packages/astro/test/fixtures/astro-cookies/src/pages/from.astro b/packages/astro/test/fixtures/astro-cookies/src/pages/from.astro new file mode 100644 index 0000000000..893858a283 --- /dev/null +++ b/packages/astro/test/fixtures/astro-cookies/src/pages/from.astro @@ -0,0 +1,5 @@ +--- +Astro.cookies.set('another','set-in-from'); +Astro.cookies.set('set-in-from','yes'); +return Astro.rewrite('/rewrite-target'); +--- diff --git a/packages/astro/test/fixtures/astro-cookies/src/pages/rewrite-target.astro b/packages/astro/test/fixtures/astro-cookies/src/pages/rewrite-target.astro new file mode 100644 index 0000000000..72b62ef865 --- /dev/null +++ b/packages/astro/test/fixtures/astro-cookies/src/pages/rewrite-target.astro @@ -0,0 +1,18 @@ +--- +Astro.cookies.set('my_cookie', 'value') +Astro.cookies.set('another','set-in-target'); + +--- + + + + + + + + Page 2 + + +

Page 2

+ + diff --git a/packages/astro/test/fixtures/astro-cookies/src/pages/to-endpoint.ts b/packages/astro/test/fixtures/astro-cookies/src/pages/to-endpoint.ts new file mode 100644 index 0000000000..26b8ed46c9 --- /dev/null +++ b/packages/astro/test/fixtures/astro-cookies/src/pages/to-endpoint.ts @@ -0,0 +1,4 @@ +export async function GET(context) { + context.cookies.set('test', 'value'); + return Response.json({hi: "world"}) +} From 58a321193e0c8c1974827d7364eae11722e15607 Mon Sep 17 00:00:00 2001 From: "Houston (Bot)" <108291165+astrobot-houston@users.noreply.github.com> Date: Thu, 20 Jun 2024 03:58:37 -0700 Subject: [PATCH 04/42] [ci] release (#11276) Co-authored-by: github-actions[bot] --- .changeset/big-eyes-share.md | 5 -- .changeset/duplicated-brackets-generation.md | 5 -- .changeset/five-owls-check.md | 5 -- .changeset/fluffy-carrots-search.md | 27 ------- .changeset/honest-shirts-trade.md | 5 -- .changeset/light-bugs-shake.md | 5 -- .changeset/old-walls-report.md | 5 -- .changeset/quiet-doors-eat.md | 5 -- .changeset/rich-dolls-compete.md | 22 ------ .changeset/silly-pens-fetch.md | 7 -- .changeset/six-fans-kiss.md | 7 -- examples/basics/package.json | 2 +- examples/blog/package.json | 2 +- examples/component/package.json | 2 +- examples/container-with-vitest/package.json | 2 +- examples/framework-alpine/package.json | 2 +- examples/framework-lit/package.json | 2 +- examples/framework-multiple/package.json | 2 +- examples/framework-preact/package.json | 2 +- examples/framework-react/package.json | 2 +- examples/framework-solid/package.json | 2 +- examples/framework-svelte/package.json | 2 +- examples/framework-vue/package.json | 2 +- examples/hackernews/package.json | 2 +- examples/integration/package.json | 2 +- examples/middleware/package.json | 2 +- examples/minimal/package.json | 2 +- examples/non-html-pages/package.json | 2 +- examples/portfolio/package.json | 2 +- examples/ssr/package.json | 2 +- examples/starlog/package.json | 2 +- examples/toolbar-app/package.json | 2 +- examples/view-transitions/package.json | 2 +- examples/with-markdoc/package.json | 2 +- examples/with-markdown-plugins/package.json | 2 +- examples/with-markdown-shiki/package.json | 2 +- examples/with-mdx/package.json | 2 +- examples/with-nanostores/package.json | 2 +- examples/with-tailwindcss/package.json | 2 +- examples/with-vitest/package.json | 2 +- packages/astro/CHANGELOG.md | 70 +++++++++++++++++ packages/astro/package.json | 2 +- pnpm-lock.yaml | 79 +++++++------------- 43 files changed, 129 insertions(+), 178 deletions(-) delete mode 100644 .changeset/big-eyes-share.md delete mode 100644 .changeset/duplicated-brackets-generation.md delete mode 100644 .changeset/five-owls-check.md delete mode 100644 .changeset/fluffy-carrots-search.md delete mode 100644 .changeset/honest-shirts-trade.md delete mode 100644 .changeset/light-bugs-shake.md delete mode 100644 .changeset/old-walls-report.md delete mode 100644 .changeset/quiet-doors-eat.md delete mode 100644 .changeset/rich-dolls-compete.md delete mode 100644 .changeset/silly-pens-fetch.md delete mode 100644 .changeset/six-fans-kiss.md diff --git a/.changeset/big-eyes-share.md b/.changeset/big-eyes-share.md deleted file mode 100644 index f08f87c504..0000000000 --- a/.changeset/big-eyes-share.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'astro': patch ---- - -Fixes a bug that prevented cookies from being set when using experimental rewrites diff --git a/.changeset/duplicated-brackets-generation.md b/.changeset/duplicated-brackets-generation.md deleted file mode 100644 index 4d8e0a4a16..0000000000 --- a/.changeset/duplicated-brackets-generation.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'astro': patch ---- - -Drop duplicated brackets in data collections schema generation. diff --git a/.changeset/five-owls-check.md b/.changeset/five-owls-check.md deleted file mode 100644 index 68b6929034..0000000000 --- a/.changeset/five-owls-check.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'astro': patch ---- - -Fixes a case where rewriting `/` would cause an issue, when `trailingSlash` was set to `"never"`. diff --git a/.changeset/fluffy-carrots-search.md b/.changeset/fluffy-carrots-search.md deleted file mode 100644 index 79b7e7a3b7..0000000000 --- a/.changeset/fluffy-carrots-search.md +++ /dev/null @@ -1,27 +0,0 @@ ---- -'astro': minor ---- - -Adds [`ShikiTransformer`](https://shiki.style/packages/transformers#shikijs-transformers) support to the [``](https://docs.astro.build/en/reference/api-reference/#code-) component with a new `transformers` prop. - -Note that `transformers` only applies classes and you must provide your own CSS rules to target the elements of your code block. - -```astro ---- -import { transformerNotationFocus } from '@shikijs/transformers' -import { Code } from 'astro:components' - -const code = `const foo = 'hello' -const bar = ' world' -console.log(foo + bar) // [!code focus] -` ---- - - - - -``` diff --git a/.changeset/honest-shirts-trade.md b/.changeset/honest-shirts-trade.md deleted file mode 100644 index 7708e709ab..0000000000 --- a/.changeset/honest-shirts-trade.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'astro': patch ---- - -Reverts a logic where it wasn't possible to rewrite `/404` in static mode. It's **now possible** again diff --git a/.changeset/light-bugs-shake.md b/.changeset/light-bugs-shake.md deleted file mode 100644 index c5fe720934..0000000000 --- a/.changeset/light-bugs-shake.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'astro': patch ---- - -Fixes type generation for empty content collections diff --git a/.changeset/old-walls-report.md b/.changeset/old-walls-report.md deleted file mode 100644 index 64dc1f5d2d..0000000000 --- a/.changeset/old-walls-report.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'astro': patch ---- - -Improves type-checking and error handling to catch case where an image import is passed directly to `getImage()` diff --git a/.changeset/quiet-doors-eat.md b/.changeset/quiet-doors-eat.md deleted file mode 100644 index 587dba8ba7..0000000000 --- a/.changeset/quiet-doors-eat.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -"astro": patch ---- - -Fixes a case where `defineAction` autocomplete for the `accept` prop would not show `"form"` as a possible value diff --git a/.changeset/rich-dolls-compete.md b/.changeset/rich-dolls-compete.md deleted file mode 100644 index 1254be9f78..0000000000 --- a/.changeset/rich-dolls-compete.md +++ /dev/null @@ -1,22 +0,0 @@ ---- -"astro": minor ---- - -Improves the developer experience of the `500.astro` file by passing it a new `error` prop. - -When an error is thrown, the special `src/pages/500.astro` page now automatically receives the error as a prop. This allows you to display more specific information about the error on a custom 500 page. - -```astro ---- -// src/pages/500.astro -interface Props { - error: unknown -} - -const { error } = Astro.props ---- - -
{error instanceof Error ? error.message : 'Unknown error'}
-``` - -If an error occurs rendering this page, your host's default 500 error page will be shown to your visitor in production, and Astro's default error overlay will be shown in development. diff --git a/.changeset/silly-pens-fetch.md b/.changeset/silly-pens-fetch.md deleted file mode 100644 index ff336a7990..0000000000 --- a/.changeset/silly-pens-fetch.md +++ /dev/null @@ -1,7 +0,0 @@ ---- -'astro': patch ---- - -Corrects an inconsistency in dev where middleware would run for prerendered 404 routes. -Middleware is not run for prerendered 404 routes in production, so this was incorrect. - diff --git a/.changeset/six-fans-kiss.md b/.changeset/six-fans-kiss.md deleted file mode 100644 index f80b87b02d..0000000000 --- a/.changeset/six-fans-kiss.md +++ /dev/null @@ -1,7 +0,0 @@ ---- -'astro': patch ---- - -Fixes an issue that would break `Astro.request.url` and `Astro.request.headers` in `astro dev` if HTTP/2 was enabled. - -HTTP/2 is now enabled by default in `astro dev` if `https` is configured in the Vite config. diff --git a/examples/basics/package.json b/examples/basics/package.json index e3d952e50d..f8749c7421 100644 --- a/examples/basics/package.json +++ b/examples/basics/package.json @@ -11,6 +11,6 @@ "astro": "astro" }, "dependencies": { - "astro": "^4.10.3" + "astro": "^4.11.0" } } diff --git a/examples/blog/package.json b/examples/blog/package.json index 6db52dae24..abf81e7ded 100644 --- a/examples/blog/package.json +++ b/examples/blog/package.json @@ -14,6 +14,6 @@ "@astrojs/mdx": "^3.1.1", "@astrojs/rss": "^4.0.6", "@astrojs/sitemap": "^3.1.6", - "astro": "^4.10.3" + "astro": "^4.11.0" } } diff --git a/examples/component/package.json b/examples/component/package.json index 0a53d80c96..b26658e0cd 100644 --- a/examples/component/package.json +++ b/examples/component/package.json @@ -15,7 +15,7 @@ ], "scripts": {}, "devDependencies": { - "astro": "^4.10.3" + "astro": "^4.11.0" }, "peerDependencies": { "astro": "^4.0.0" diff --git a/examples/container-with-vitest/package.json b/examples/container-with-vitest/package.json index 38e2543fd4..7b4030a3e5 100644 --- a/examples/container-with-vitest/package.json +++ b/examples/container-with-vitest/package.json @@ -12,7 +12,7 @@ "test": "vitest run" }, "dependencies": { - "astro": "^4.10.3", + "astro": "^4.11.0", "@astrojs/react": "^3.6.0", "react": "^18.3.1", "react-dom": "^18.3.1", diff --git a/examples/framework-alpine/package.json b/examples/framework-alpine/package.json index aca1189f14..f92b1ce066 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.0", - "astro": "^4.10.3" + "astro": "^4.11.0" } } diff --git a/examples/framework-lit/package.json b/examples/framework-lit/package.json index 81467a629f..de9e88f6f2 100644 --- a/examples/framework-lit/package.json +++ b/examples/framework-lit/package.json @@ -13,7 +13,7 @@ "dependencies": { "@astrojs/lit": "^4.3.0", "@webcomponents/template-shadowroot": "^0.2.1", - "astro": "^4.10.3", + "astro": "^4.11.0", "lit": "^3.1.4" } } diff --git a/examples/framework-multiple/package.json b/examples/framework-multiple/package.json index 31bd9c9c95..b3c5510490 100644 --- a/examples/framework-multiple/package.json +++ b/examples/framework-multiple/package.json @@ -18,7 +18,7 @@ "@astrojs/vue": "^4.5.0", "@types/react": "^18.3.3", "@types/react-dom": "^18.3.0", - "astro": "^4.10.3", + "astro": "^4.11.0", "preact": "^10.22.0", "react": "^18.3.1", "react-dom": "^18.3.1", diff --git a/examples/framework-preact/package.json b/examples/framework-preact/package.json index 1938295a73..bd7e3bf9a6 100644 --- a/examples/framework-preact/package.json +++ b/examples/framework-preact/package.json @@ -13,7 +13,7 @@ "dependencies": { "@astrojs/preact": "^3.5.0", "@preact/signals": "^1.2.3", - "astro": "^4.10.3", + "astro": "^4.11.0", "preact": "^10.22.0" } } diff --git a/examples/framework-react/package.json b/examples/framework-react/package.json index 65ac56ac6d..ef027d7da9 100644 --- a/examples/framework-react/package.json +++ b/examples/framework-react/package.json @@ -14,7 +14,7 @@ "@astrojs/react": "^3.6.0", "@types/react": "^18.3.3", "@types/react-dom": "^18.3.0", - "astro": "^4.10.3", + "astro": "^4.11.0", "react": "^18.3.1", "react-dom": "^18.3.1" } diff --git a/examples/framework-solid/package.json b/examples/framework-solid/package.json index 330c432011..184ce175f4 100644 --- a/examples/framework-solid/package.json +++ b/examples/framework-solid/package.json @@ -12,7 +12,7 @@ }, "dependencies": { "@astrojs/solid-js": "^4.4.0", - "astro": "^4.10.3", + "astro": "^4.11.0", "solid-js": "^1.8.17" } } diff --git a/examples/framework-svelte/package.json b/examples/framework-svelte/package.json index e6d4ab8e83..19400e015e 100644 --- a/examples/framework-svelte/package.json +++ b/examples/framework-svelte/package.json @@ -12,7 +12,7 @@ }, "dependencies": { "@astrojs/svelte": "^5.6.0", - "astro": "^4.10.3", + "astro": "^4.11.0", "svelte": "^4.2.18" } } diff --git a/examples/framework-vue/package.json b/examples/framework-vue/package.json index 9b2cbbb8b9..69e9bbbcec 100644 --- a/examples/framework-vue/package.json +++ b/examples/framework-vue/package.json @@ -12,7 +12,7 @@ }, "dependencies": { "@astrojs/vue": "^4.5.0", - "astro": "^4.10.3", + "astro": "^4.11.0", "vue": "^3.4.29" } } diff --git a/examples/hackernews/package.json b/examples/hackernews/package.json index 85221d768a..a42622b497 100644 --- a/examples/hackernews/package.json +++ b/examples/hackernews/package.json @@ -12,6 +12,6 @@ }, "dependencies": { "@astrojs/node": "^8.3.1", - "astro": "^4.10.3" + "astro": "^4.11.0" } } diff --git a/examples/integration/package.json b/examples/integration/package.json index d474df38c2..35b888bfbf 100644 --- a/examples/integration/package.json +++ b/examples/integration/package.json @@ -15,7 +15,7 @@ ], "scripts": {}, "devDependencies": { - "astro": "^4.10.3" + "astro": "^4.11.0" }, "peerDependencies": { "astro": "^4.0.0" diff --git a/examples/middleware/package.json b/examples/middleware/package.json index 5c49204258..29887ce788 100644 --- a/examples/middleware/package.json +++ b/examples/middleware/package.json @@ -13,7 +13,7 @@ }, "dependencies": { "@astrojs/node": "^8.3.1", - "astro": "^4.10.3", + "astro": "^4.11.0", "html-minifier": "^4.0.0" }, "devDependencies": { diff --git a/examples/minimal/package.json b/examples/minimal/package.json index f21a2648c3..589deeb2f4 100644 --- a/examples/minimal/package.json +++ b/examples/minimal/package.json @@ -11,6 +11,6 @@ "astro": "astro" }, "dependencies": { - "astro": "^4.10.3" + "astro": "^4.11.0" } } diff --git a/examples/non-html-pages/package.json b/examples/non-html-pages/package.json index 9e8b3fa0a6..1b963a4dcc 100644 --- a/examples/non-html-pages/package.json +++ b/examples/non-html-pages/package.json @@ -11,6 +11,6 @@ "astro": "astro" }, "dependencies": { - "astro": "^4.10.3" + "astro": "^4.11.0" } } diff --git a/examples/portfolio/package.json b/examples/portfolio/package.json index 87302014de..5bb098874b 100644 --- a/examples/portfolio/package.json +++ b/examples/portfolio/package.json @@ -11,6 +11,6 @@ "astro": "astro" }, "dependencies": { - "astro": "^4.10.3" + "astro": "^4.11.0" } } diff --git a/examples/ssr/package.json b/examples/ssr/package.json index 98e6446738..4d61c4b0b6 100644 --- a/examples/ssr/package.json +++ b/examples/ssr/package.json @@ -14,7 +14,7 @@ "dependencies": { "@astrojs/node": "^8.3.1", "@astrojs/svelte": "^5.6.0", - "astro": "^4.10.3", + "astro": "^4.11.0", "svelte": "^4.2.18" } } diff --git a/examples/starlog/package.json b/examples/starlog/package.json index b3ec85ebaa..b0c3cf066b 100644 --- a/examples/starlog/package.json +++ b/examples/starlog/package.json @@ -10,7 +10,7 @@ "astro": "astro" }, "dependencies": { - "astro": "^4.10.3", + "astro": "^4.11.0", "sass": "^1.77.5", "sharp": "^0.33.3" } diff --git a/examples/toolbar-app/package.json b/examples/toolbar-app/package.json index 29cbbbb5e5..c1b5f52b53 100644 --- a/examples/toolbar-app/package.json +++ b/examples/toolbar-app/package.json @@ -15,6 +15,6 @@ "./app": "./dist/app.js" }, "devDependencies": { - "astro": "^4.10.3" + "astro": "^4.11.0" } } diff --git a/examples/view-transitions/package.json b/examples/view-transitions/package.json index f9437e2737..7d1735eb3f 100644 --- a/examples/view-transitions/package.json +++ b/examples/view-transitions/package.json @@ -12,6 +12,6 @@ "devDependencies": { "@astrojs/tailwind": "^5.1.0", "@astrojs/node": "^8.3.1", - "astro": "^4.10.3" + "astro": "^4.11.0" } } diff --git a/examples/with-markdoc/package.json b/examples/with-markdoc/package.json index 4c1ca16f6e..5b55755462 100644 --- a/examples/with-markdoc/package.json +++ b/examples/with-markdoc/package.json @@ -12,6 +12,6 @@ }, "dependencies": { "@astrojs/markdoc": "^0.11.0", - "astro": "^4.10.3" + "astro": "^4.11.0" } } diff --git a/examples/with-markdown-plugins/package.json b/examples/with-markdown-plugins/package.json index 519743eed0..e4a09be9c8 100644 --- a/examples/with-markdown-plugins/package.json +++ b/examples/with-markdown-plugins/package.json @@ -12,7 +12,7 @@ }, "dependencies": { "@astrojs/markdown-remark": "^5.1.0", - "astro": "^4.10.3", + "astro": "^4.11.0", "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 51c40eee2e..57725bf489 100644 --- a/examples/with-markdown-shiki/package.json +++ b/examples/with-markdown-shiki/package.json @@ -11,6 +11,6 @@ "astro": "astro" }, "dependencies": { - "astro": "^4.10.3" + "astro": "^4.11.0" } } diff --git a/examples/with-mdx/package.json b/examples/with-mdx/package.json index 0a09588371..9008692ab1 100644 --- a/examples/with-mdx/package.json +++ b/examples/with-mdx/package.json @@ -13,7 +13,7 @@ "dependencies": { "@astrojs/mdx": "^3.1.1", "@astrojs/preact": "^3.5.0", - "astro": "^4.10.3", + "astro": "^4.11.0", "preact": "^10.22.0" } } diff --git a/examples/with-nanostores/package.json b/examples/with-nanostores/package.json index 57a6581c9c..b9c2e4e194 100644 --- a/examples/with-nanostores/package.json +++ b/examples/with-nanostores/package.json @@ -13,7 +13,7 @@ "dependencies": { "@astrojs/preact": "^3.5.0", "@nanostores/preact": "^0.5.1", - "astro": "^4.10.3", + "astro": "^4.11.0", "nanostores": "^0.10.3", "preact": "^10.22.0" } diff --git a/examples/with-tailwindcss/package.json b/examples/with-tailwindcss/package.json index bbb4eb46cd..6b1f771a1d 100644 --- a/examples/with-tailwindcss/package.json +++ b/examples/with-tailwindcss/package.json @@ -14,7 +14,7 @@ "@astrojs/mdx": "^3.1.1", "@astrojs/tailwind": "^5.1.0", "@types/canvas-confetti": "^1.6.4", - "astro": "^4.10.3", + "astro": "^4.11.0", "autoprefixer": "^10.4.19", "canvas-confetti": "^1.9.3", "postcss": "^8.4.38", diff --git a/examples/with-vitest/package.json b/examples/with-vitest/package.json index ed6a7500b4..141ac97cef 100644 --- a/examples/with-vitest/package.json +++ b/examples/with-vitest/package.json @@ -12,7 +12,7 @@ "test": "vitest" }, "dependencies": { - "astro": "^4.10.3", + "astro": "^4.11.0", "vitest": "^1.6.0" } } diff --git a/packages/astro/CHANGELOG.md b/packages/astro/CHANGELOG.md index 0552d97580..b3ffa414e9 100644 --- a/packages/astro/CHANGELOG.md +++ b/packages/astro/CHANGELOG.md @@ -1,5 +1,75 @@ # astro +## 4.11.0 + +### Minor Changes + +- [#11197](https://github.com/withastro/astro/pull/11197) [`4b46bd9`](https://github.com/withastro/astro/commit/4b46bd9bdcbb302f294aa27b8aa07099e104fa17) Thanks [@braebo](https://github.com/braebo)! - Adds [`ShikiTransformer`](https://shiki.style/packages/transformers#shikijs-transformers) support to the [``](https://docs.astro.build/en/reference/api-reference/#code-) component with a new `transformers` prop. + + Note that `transformers` only applies classes and you must provide your own CSS rules to target the elements of your code block. + + ```astro + --- + import { transformerNotationFocus } from '@shikijs/transformers'; + import { Code } from 'astro:components'; + + const code = `const foo = 'hello' + const bar = ' world' + console.log(foo + bar) // [!code focus] + `; + --- + + + + + ``` + +- [#11134](https://github.com/withastro/astro/pull/11134) [`9042be0`](https://github.com/withastro/astro/commit/9042be049157ce859355f911565bc0c3d68f0aa1) Thanks [@florian-lefebvre](https://github.com/florian-lefebvre)! - Improves the developer experience of the `500.astro` file by passing it a new `error` prop. + + When an error is thrown, the special `src/pages/500.astro` page now automatically receives the error as a prop. This allows you to display more specific information about the error on a custom 500 page. + + ```astro + --- + // src/pages/500.astro + interface Props { + error: unknown; + } + + const { error } = Astro.props; + --- + +
{error instanceof Error ? error.message : 'Unknown error'}
+ ``` + + If an error occurs rendering this page, your host's default 500 error page will be shown to your visitor in production, and Astro's default error overlay will be shown in development. + +### Patch Changes + +- [#11280](https://github.com/withastro/astro/pull/11280) [`fd3645f`](https://github.com/withastro/astro/commit/fd3645fe8364ec5e280b6802d1468867890d463c) Thanks [@ascorbic](https://github.com/ascorbic)! - Fixes a bug that prevented cookies from being set when using experimental rewrites + +- [#11275](https://github.com/withastro/astro/pull/11275) [`bab700d`](https://github.com/withastro/astro/commit/bab700d69085b1de8f03fc1b0b31651f709cbfe3) Thanks [@syhily](https://github.com/syhily)! - Drop duplicated brackets in data collections schema generation. + +- [#11272](https://github.com/withastro/astro/pull/11272) [`ea987d7`](https://github.com/withastro/astro/commit/ea987d7da589ead9aa4b550f167f5e2f6c939d2e) Thanks [@ematipico](https://github.com/ematipico)! - Fixes a case where rewriting `/` would cause an issue, when `trailingSlash` was set to `"never"`. + +- [#11272](https://github.com/withastro/astro/pull/11272) [`ea987d7`](https://github.com/withastro/astro/commit/ea987d7da589ead9aa4b550f167f5e2f6c939d2e) Thanks [@ematipico](https://github.com/ematipico)! - Reverts a logic where it wasn't possible to rewrite `/404` in static mode. It's **now possible** again + +- [#11264](https://github.com/withastro/astro/pull/11264) [`5a9c9a6`](https://github.com/withastro/astro/commit/5a9c9a60e7c32aa461b86b5bc667cb955e23d4d9) Thanks [@Fryuni](https://github.com/Fryuni)! - Fixes type generation for empty content collections + +- [#11279](https://github.com/withastro/astro/pull/11279) [`9a08d74`](https://github.com/withastro/astro/commit/9a08d74bc00ae2c3bc254f99580a22ce4df1d002) Thanks [@ascorbic](https://github.com/ascorbic)! - Improves type-checking and error handling to catch case where an image import is passed directly to `getImage()` + +- [#11292](https://github.com/withastro/astro/pull/11292) [`7f8f347`](https://github.com/withastro/astro/commit/7f8f34799528ed0b2011e1ea273bd0636f6e767d) Thanks [@jdtjenkins](https://github.com/jdtjenkins)! - Fixes a case where `defineAction` autocomplete for the `accept` prop would not show `"form"` as a possible value + +- [#11273](https://github.com/withastro/astro/pull/11273) [`cb4d078`](https://github.com/withastro/astro/commit/cb4d07819f0dbdfd94bc4f084edf7720ada01323) Thanks [@ascorbic](https://github.com/ascorbic)! - Corrects an inconsistency in dev where middleware would run for prerendered 404 routes. + Middleware is not run for prerendered 404 routes in production, so this was incorrect. + +- [#11284](https://github.com/withastro/astro/pull/11284) [`f4b029b`](https://github.com/withastro/astro/commit/f4b029b08264268c68fc81ea25b264e81f47e683) Thanks [@ascorbic](https://github.com/ascorbic)! - Fixes an issue that would break `Astro.request.url` and `Astro.request.headers` in `astro dev` if HTTP/2 was enabled. + + HTTP/2 is now enabled by default in `astro dev` if `https` is configured in the Vite config. + ## 4.10.3 ### Patch Changes diff --git a/packages/astro/package.json b/packages/astro/package.json index aaa9034f9e..663a458830 100644 --- a/packages/astro/package.json +++ b/packages/astro/package.json @@ -1,6 +1,6 @@ { "name": "astro", - "version": "4.10.3", + "version": "4.11.0", "description": "Astro is a modern site builder with web best practices, performance, and DX front-of-mind.", "type": "module", "author": "withastro", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 9361d07b49..c67d31e95d 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -128,7 +128,7 @@ importers: examples/basics: dependencies: astro: - specifier: ^4.10.3 + specifier: ^4.11.0 version: link:../../packages/astro examples/blog: @@ -143,13 +143,13 @@ importers: specifier: ^3.1.6 version: link:../../packages/integrations/sitemap astro: - specifier: ^4.10.3 + specifier: ^4.11.0 version: link:../../packages/astro examples/component: devDependencies: astro: - specifier: ^4.10.3 + specifier: ^4.11.0 version: link:../../packages/astro examples/container-with-vitest: @@ -158,7 +158,7 @@ importers: specifier: ^3.6.0 version: link:../../packages/integrations/react astro: - specifier: ^4.10.3 + specifier: ^4.11.0 version: link:../../packages/astro react: specifier: ^18.3.1 @@ -189,7 +189,7 @@ importers: specifier: ^3.14.0 version: 3.14.0 astro: - specifier: ^4.10.3 + specifier: ^4.11.0 version: link:../../packages/astro examples/framework-lit: @@ -201,7 +201,7 @@ importers: specifier: ^0.2.1 version: 0.2.1 astro: - specifier: ^4.10.3 + specifier: ^4.11.0 version: link:../../packages/astro lit: specifier: ^3.1.4 @@ -231,7 +231,7 @@ importers: specifier: ^18.3.0 version: 18.3.0 astro: - specifier: ^4.10.3 + specifier: ^4.11.0 version: link:../../packages/astro preact: specifier: ^10.22.0 @@ -261,7 +261,7 @@ importers: specifier: ^1.2.3 version: 1.2.3(preact@10.22.0) astro: - specifier: ^4.10.3 + specifier: ^4.11.0 version: link:../../packages/astro preact: specifier: ^10.22.0 @@ -279,7 +279,7 @@ importers: specifier: ^18.3.0 version: 18.3.0 astro: - specifier: ^4.10.3 + specifier: ^4.11.0 version: link:../../packages/astro react: specifier: ^18.3.1 @@ -294,7 +294,7 @@ importers: specifier: ^4.4.0 version: link:../../packages/integrations/solid astro: - specifier: ^4.10.3 + specifier: ^4.11.0 version: link:../../packages/astro solid-js: specifier: ^1.8.17 @@ -306,7 +306,7 @@ importers: specifier: ^5.6.0 version: link:../../packages/integrations/svelte astro: - specifier: ^4.10.3 + specifier: ^4.11.0 version: link:../../packages/astro svelte: specifier: ^4.2.18 @@ -318,7 +318,7 @@ importers: specifier: ^4.5.0 version: link:../../packages/integrations/vue astro: - specifier: ^4.10.3 + specifier: ^4.11.0 version: link:../../packages/astro vue: specifier: ^3.4.29 @@ -330,13 +330,13 @@ importers: specifier: ^8.3.1 version: link:../../packages/integrations/node astro: - specifier: ^4.10.3 + specifier: ^4.11.0 version: link:../../packages/astro examples/integration: devDependencies: astro: - specifier: ^4.10.3 + specifier: ^4.11.0 version: link:../../packages/astro examples/middleware: @@ -345,7 +345,7 @@ importers: specifier: ^8.3.1 version: link:../../packages/integrations/node astro: - specifier: ^4.10.3 + specifier: ^4.11.0 version: link:../../packages/astro html-minifier: specifier: ^4.0.0 @@ -358,19 +358,19 @@ importers: examples/minimal: dependencies: astro: - specifier: ^4.10.3 + specifier: ^4.11.0 version: link:../../packages/astro examples/non-html-pages: dependencies: astro: - specifier: ^4.10.3 + specifier: ^4.11.0 version: link:../../packages/astro examples/portfolio: dependencies: astro: - specifier: ^4.10.3 + specifier: ^4.11.0 version: link:../../packages/astro examples/ssr: @@ -382,7 +382,7 @@ importers: specifier: ^5.6.0 version: link:../../packages/integrations/svelte astro: - specifier: ^4.10.3 + specifier: ^4.11.0 version: link:../../packages/astro svelte: specifier: ^4.2.18 @@ -391,7 +391,7 @@ importers: examples/starlog: dependencies: astro: - specifier: ^4.10.3 + specifier: ^4.11.0 version: link:../../packages/astro sass: specifier: ^1.77.5 @@ -403,7 +403,7 @@ importers: examples/toolbar-app: devDependencies: astro: - specifier: ^4.10.3 + specifier: ^4.11.0 version: link:../../packages/astro examples/view-transitions: @@ -415,7 +415,7 @@ importers: specifier: ^5.1.0 version: link:../../packages/integrations/tailwind astro: - specifier: ^4.10.3 + specifier: ^4.11.0 version: link:../../packages/astro examples/with-markdoc: @@ -424,7 +424,7 @@ importers: specifier: ^0.11.0 version: link:../../packages/integrations/markdoc astro: - specifier: ^4.10.3 + specifier: ^4.11.0 version: link:../../packages/astro examples/with-markdown-plugins: @@ -433,7 +433,7 @@ importers: specifier: ^5.1.0 version: link:../../packages/markdown/remark astro: - specifier: ^4.10.3 + specifier: ^4.11.0 version: link:../../packages/astro hast-util-select: specifier: ^6.0.2 @@ -454,7 +454,7 @@ importers: examples/with-markdown-shiki: dependencies: astro: - specifier: ^4.10.3 + specifier: ^4.11.0 version: link:../../packages/astro examples/with-mdx: @@ -466,7 +466,7 @@ importers: specifier: ^3.5.0 version: link:../../packages/integrations/preact astro: - specifier: ^4.10.3 + specifier: ^4.11.0 version: link:../../packages/astro preact: specifier: ^10.22.0 @@ -481,7 +481,7 @@ importers: specifier: ^0.5.1 version: 0.5.1(nanostores@0.10.3)(preact@10.22.0) astro: - specifier: ^4.10.3 + specifier: ^4.11.0 version: link:../../packages/astro nanostores: specifier: ^0.10.3 @@ -502,7 +502,7 @@ importers: specifier: ^1.6.4 version: 1.6.4 astro: - specifier: ^4.10.3 + specifier: ^4.11.0 version: link:../../packages/astro autoprefixer: specifier: ^10.4.19 @@ -520,7 +520,7 @@ importers: examples/with-vitest: dependencies: astro: - specifier: ^4.10.3 + specifier: ^4.11.0 version: link:../../packages/astro vitest: specifier: ^1.6.0 @@ -2569,27 +2569,6 @@ importers: specifier: ^3.4.29 version: 3.4.29(typescript@5.4.5) - packages/astro/test/fixtures/container-dev-renderers: - dependencies: - '@astrojs/react': - specifier: workspace:* - version: link:../../../../integrations/react - '@astrojs/vue': - specifier: workspace:* - version: link:../../../../integrations/vue - astro: - specifier: workspace:* - version: link:../../.. - react: - specifier: ^18.3.1 - version: 18.3.1 - react-dom: - specifier: ^18.3.1 - version: 18.3.1(react@18.3.1) - vue: - specifier: ^3.4.29 - version: 3.4.29(typescript@5.4.5) - packages/astro/test/fixtures/content: dependencies: '@astrojs/mdx': From dc41ece28fb3b79a1c0df04a3f421c6262c7a2ec Mon Sep 17 00:00:00 2001 From: Emanuele Stoppa Date: Thu, 20 Jun 2024 13:25:08 +0100 Subject: [PATCH 05/42] chore(deps): remove deprecated pkg, `preferred-pm` now ships its types (#11294) --- packages/upgrade/package.json | 1 - pnpm-lock.yaml | 11 ----------- 2 files changed, 12 deletions(-) diff --git a/packages/upgrade/package.json b/packages/upgrade/package.json index 6a654ebf03..7fe27e1b55 100644 --- a/packages/upgrade/package.json +++ b/packages/upgrade/package.json @@ -36,7 +36,6 @@ }, "devDependencies": { "@types/semver": "^7.5.8", - "@types/preferred-pm": "^3.0.0", "arg": "^5.0.2", "astro-scripts": "workspace:*", "strip-ansi": "^7.1.0" diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index c67d31e95d..34871ca646 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -5832,9 +5832,6 @@ importers: specifier: ^3.0.0 version: 3.0.0 devDependencies: - '@types/preferred-pm': - specifier: ^3.0.0 - version: 3.0.0 '@types/semver': specifier: ^7.5.8 version: 7.5.8 @@ -7382,10 +7379,6 @@ packages: '@types/normalize-package-data@2.4.4': resolution: {integrity: sha512-37i+OaWTh9qeK4LSHPsyRC7NahnGotNuZvjLSgcPzblpHB3rrCJxAOgI5gCdKm7coonsaX1Of0ILiTcnZjbfxA==} - '@types/preferred-pm@3.0.0': - resolution: {integrity: sha512-Ub1de7EkdavsyM1KNrTb1K1QL+ISepEELELh2QWccyDcVEcyUDiGoYzzOJfonpGNwpymYXY13oRFpXQluGOC5w==} - deprecated: This is a stub types definition. preferred-pm provides its own type definitions, so you do not need this installed. - '@types/prismjs@1.26.4': resolution: {integrity: sha512-rlAnzkW2sZOjbqZ743IHUhFcvzaGbqijwOu8QZnZCjfQzBqFE3s4lOTJEsxikImav9uzz/42I+O7YUs1mWgMlg==} @@ -13739,10 +13732,6 @@ snapshots: '@types/normalize-package-data@2.4.4': {} - '@types/preferred-pm@3.0.0': - dependencies: - preferred-pm: 3.1.3 - '@types/prismjs@1.26.4': {} '@types/probe-image-size@7.2.4': From 9056d8dd059504c144ab88d46dad1d871e702748 Mon Sep 17 00:00:00 2001 From: Mark Gaze Date: Thu, 20 Jun 2024 13:30:43 +0100 Subject: [PATCH 06/42] Add a test to ensure that `types.d.ts` is valid (#11277) --- packages/astro/test/astro-sync.test.js | 16 ++++++++++++++++ .../content-collections/src/content/config.ts | 8 ++++++++ .../src/content/with-data/one.json | 3 +++ .../src/content/with-data/three.json | 3 +++ .../src/content/with-data/two.json | 3 +++ 5 files changed, 33 insertions(+) create mode 100644 packages/astro/test/fixtures/content-collections/src/content/with-data/one.json create mode 100644 packages/astro/test/fixtures/content-collections/src/content/with-data/three.json create mode 100644 packages/astro/test/fixtures/content-collections/src/content/with-data/two.json diff --git a/packages/astro/test/astro-sync.test.js b/packages/astro/test/astro-sync.test.js index 8cc15f7dd8..835929ff3c 100644 --- a/packages/astro/test/astro-sync.test.js +++ b/packages/astro/test/astro-sync.test.js @@ -1,6 +1,7 @@ import assert from 'node:assert/strict'; import * as fs from 'node:fs'; import { before, describe, it } from 'node:test'; +import ts from 'typescript'; import { loadFixture } from './test-utils.js'; const createFixture = () => { @@ -62,6 +63,20 @@ const createFixture = () => { const expectedPath = new URL(path, astroFixture.config.root).href; assert.equal(writtenFiles[expectedPath].includes(content), true, error); }, + thenFileShouldBeValidTypescript(path) { + const expectedPath = new URL(path, astroFixture.config.root).href; + try { + const content = writtenFiles[expectedPath]; + const result = ts.transpileModule(content, { + compilerOptions: { + module: ts.ModuleKind.ESNext, + }, + }); + assert.equal(result.outputText, '', `${path} should be valid TypeScript. Output: ${result.outputText}`); + } catch (error) { + assert.fail(`${path} is not valid TypeScript. Error: ${error.message}`); + } + }, }; }; @@ -87,6 +102,7 @@ describe('astro sync', () => { `declare module 'astro:content' {`, 'Types file does not include `astro:content` module declaration' ); + fixture.thenFileShouldBeValidTypescript('.astro/types.d.ts'); }); it('Writes types for empty collections', async () => { diff --git a/packages/astro/test/fixtures/content-collections/src/content/config.ts b/packages/astro/test/fixtures/content-collections/src/content/config.ts index de770acede..23908e32cb 100644 --- a/packages/astro/test/fixtures/content-collections/src/content/config.ts +++ b/packages/astro/test/fixtures/content-collections/src/content/config.ts @@ -1,5 +1,12 @@ import { defineCollection, z } from 'astro:content'; +const withData = defineCollection({ + type: 'data', + schema: z.object({ + title: z.string(), + }), +}); + const withCustomSlugs = defineCollection({ // Ensure schema passes even when `slug` is present schema: z.object({}).strict(), @@ -46,6 +53,7 @@ const withSymlinkedContent = defineCollection({ }); export const collections = { + 'with-data': withData, 'with-custom-slugs': withCustomSlugs, 'with-schema-config': withSchemaConfig, 'with-union-schema': withUnionSchema, diff --git a/packages/astro/test/fixtures/content-collections/src/content/with-data/one.json b/packages/astro/test/fixtures/content-collections/src/content/with-data/one.json new file mode 100644 index 0000000000..efc60137d6 --- /dev/null +++ b/packages/astro/test/fixtures/content-collections/src/content/with-data/one.json @@ -0,0 +1,3 @@ +{ + "title": "One" +} diff --git a/packages/astro/test/fixtures/content-collections/src/content/with-data/three.json b/packages/astro/test/fixtures/content-collections/src/content/with-data/three.json new file mode 100644 index 0000000000..7d028e937a --- /dev/null +++ b/packages/astro/test/fixtures/content-collections/src/content/with-data/three.json @@ -0,0 +1,3 @@ +{ + "title": "Three" +} diff --git a/packages/astro/test/fixtures/content-collections/src/content/with-data/two.json b/packages/astro/test/fixtures/content-collections/src/content/with-data/two.json new file mode 100644 index 0000000000..1a8215509b --- /dev/null +++ b/packages/astro/test/fixtures/content-collections/src/content/with-data/two.json @@ -0,0 +1,3 @@ +{ + "title": "Two" +} From e67d7e66a9e9f09b316d87f27d0d9c861b7adca7 Mon Sep 17 00:00:00 2001 From: Mark Gaze Date: Thu, 20 Jun 2024 12:31:41 +0000 Subject: [PATCH 07/42] [ci] format --- packages/astro/test/astro-sync.test.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/astro/test/astro-sync.test.js b/packages/astro/test/astro-sync.test.js index 835929ff3c..85f6551e66 100644 --- a/packages/astro/test/astro-sync.test.js +++ b/packages/astro/test/astro-sync.test.js @@ -72,7 +72,11 @@ const createFixture = () => { module: ts.ModuleKind.ESNext, }, }); - assert.equal(result.outputText, '', `${path} should be valid TypeScript. Output: ${result.outputText}`); + assert.equal( + result.outputText, + '', + `${path} should be valid TypeScript. Output: ${result.outputText}` + ); } catch (error) { assert.fail(`${path} is not valid TypeScript. Error: ${error.message}`); } From 5848d9786768d1290de982670bcc7773280ef08d Mon Sep 17 00:00:00 2001 From: Florian Lefebvre Date: Thu, 20 Jun 2024 15:54:54 +0200 Subject: [PATCH 08/42] fix: astro:env getSecret (#11296) --- .changeset/small-sloths-yawn.md | 6 ++++++ packages/integrations/node/src/index.ts | 17 ++++++++++++++++- packages/integrations/node/src/server.ts | 7 ++----- .../vercel/src/serverless/adapter.ts | 15 ++++++++++++++- .../vercel/src/serverless/entrypoint.ts | 7 ++----- 5 files changed, 40 insertions(+), 12 deletions(-) create mode 100644 .changeset/small-sloths-yawn.md diff --git a/.changeset/small-sloths-yawn.md b/.changeset/small-sloths-yawn.md new file mode 100644 index 0000000000..652bce3fd8 --- /dev/null +++ b/.changeset/small-sloths-yawn.md @@ -0,0 +1,6 @@ +--- +'@astrojs/vercel': patch +'@astrojs/node': patch +--- + +Fixes `astro:env` getSecret compatibility diff --git a/packages/integrations/node/src/index.ts b/packages/integrations/node/src/index.ts index e11576990e..eb3c98a9b7 100644 --- a/packages/integrations/node/src/index.ts +++ b/packages/integrations/node/src/index.ts @@ -24,6 +24,16 @@ export function getAdapter(options: Options): AstroAdapter { }; } +// TODO: remove once we don't use a TLA anymore +async function shouldExternalizeAstroEnvSetup() { + try { + await import('astro/env/setup'); + return false; + } catch { + return true; + } +} + export default function createIntegration(userOptions: UserOptions): AstroIntegration { if (!userOptions?.mode) { throw new AstroError(`Setting the 'mode' option is required.`); @@ -33,7 +43,7 @@ export default function createIntegration(userOptions: UserOptions): AstroIntegr return { name: '@astrojs/node', hooks: { - 'astro:config:setup': ({ updateConfig, config }) => { + 'astro:config:setup': async ({ updateConfig, config }) => { updateConfig({ image: { endpoint: config.image.endpoint ?? 'astro/assets/endpoint/node', @@ -41,6 +51,11 @@ export default function createIntegration(userOptions: UserOptions): AstroIntegr vite: { ssr: { noExternal: ['@astrojs/node'], + ...((await shouldExternalizeAstroEnvSetup()) + ? { + external: ['astro/env/setup'], + } + : {}), }, }, }); diff --git a/packages/integrations/node/src/server.ts b/packages/integrations/node/src/server.ts index febace938f..e5b503292d 100644 --- a/packages/integrations/node/src/server.ts +++ b/packages/integrations/node/src/server.ts @@ -5,13 +5,10 @@ import { createStandaloneHandler } from './standalone.js'; import startServer from './standalone.js'; import type { Options } from './types.js'; -type EnvSetupModule = typeof import('astro/env/setup'); - // Won't throw if the virtual module is not available because it's not supported in // the users's astro version or if astro:env is not enabled in the project -const setupModule = 'astro/env/setup'; -await import(/* @vite-ignore */ setupModule) - .then((mod: EnvSetupModule) => mod.setGetEnv((key) => process.env[key])) +await import('astro/env/setup') + .then((mod) => mod.setGetEnv((key) => process.env[key])) .catch(() => {}); applyPolyfills(); diff --git a/packages/integrations/vercel/src/serverless/adapter.ts b/packages/integrations/vercel/src/serverless/adapter.ts index 4481275129..aade471508 100644 --- a/packages/integrations/vercel/src/serverless/adapter.ts +++ b/packages/integrations/vercel/src/serverless/adapter.ts @@ -263,7 +263,10 @@ export default function vercelServerless({ vite: { ...getSpeedInsightsViteConfig(speedInsights?.enabled), ssr: { - external: ['@vercel/nft'], + external: [ + '@vercel/nft', + ...((await shouldExternalizeAstroEnvSetup()) ? ['astro/env/setup'] : []), + ], }, }, ...getAstroImageConfig( @@ -442,6 +445,16 @@ export default function vercelServerless({ type Runtime = `nodejs${string}.x`; +// TODO: remove once we don't use a TLA anymore +async function shouldExternalizeAstroEnvSetup() { + try { + await import('astro/env/setup'); + return false; + } catch { + return true; + } +} + class VercelBuilder { readonly NTF_CACHE = {}; diff --git a/packages/integrations/vercel/src/serverless/entrypoint.ts b/packages/integrations/vercel/src/serverless/entrypoint.ts index 1e0b75d649..11d3c3a91e 100644 --- a/packages/integrations/vercel/src/serverless/entrypoint.ts +++ b/packages/integrations/vercel/src/serverless/entrypoint.ts @@ -8,13 +8,10 @@ import { ASTRO_PATH_PARAM, } from './adapter.js'; -type EnvSetupModule = typeof import('astro/env/setup'); - // Won't throw if the virtual module is not available because it's not supported in // the users's astro version or if astro:env is not enabled in the project -const setupModule = 'astro/env/setup'; -await import(/* @vite-ignore */ setupModule) - .then((mod: EnvSetupModule) => mod.setGetEnv((key) => process.env[key])) +await import('astro/env/setup') + .then((mod) => mod.setGetEnv((key) => process.env[key])) .catch(() => {}); applyPolyfills(); From 7f956f07958e1a486ca0e28d4135c33ec7c347b0 Mon Sep 17 00:00:00 2001 From: Florian Lefebvre Date: Thu, 20 Jun 2024 16:18:39 +0200 Subject: [PATCH 09/42] feat(underscore-redirects): add support for force (#11271) Co-authored-by: Bjorn Lu --- .changeset/funny-cats-sell.md | 16 ++++++++++++++++ packages/underscore-redirects/src/print.ts | 3 ++- packages/underscore-redirects/src/redirects.ts | 1 + .../underscore-redirects/test/print.test.js | 17 +++++++++++++++++ 4 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 .changeset/funny-cats-sell.md diff --git a/.changeset/funny-cats-sell.md b/.changeset/funny-cats-sell.md new file mode 100644 index 0000000000..f2e6802b18 --- /dev/null +++ b/.changeset/funny-cats-sell.md @@ -0,0 +1,16 @@ +--- +'@astrojs/underscore-redirects': patch +--- + +Adds support for forced redirects + +Redirects can be forced by setting `force` to `true`: + +```ts +redirects.add({ + // ... + force: true +}) +``` + +It will append a `!` after the status. \ No newline at end of file diff --git a/packages/underscore-redirects/src/print.ts b/packages/underscore-redirects/src/print.ts index 2a9bec2578..7e2f1c4023 100644 --- a/packages/underscore-redirects/src/print.ts +++ b/packages/underscore-redirects/src/print.ts @@ -29,7 +29,8 @@ export function print( ' '.repeat(inputSpaces) + definition.target + ' '.repeat(Math.abs(targetSpaces)) + - definition.status; + definition.status + + (definition.force ? '!' : ''); } return _redirects; diff --git a/packages/underscore-redirects/src/redirects.ts b/packages/underscore-redirects/src/redirects.ts index c33e85b736..11ed9085e6 100644 --- a/packages/underscore-redirects/src/redirects.ts +++ b/packages/underscore-redirects/src/redirects.ts @@ -9,6 +9,7 @@ export type RedirectDefinition = { // a priority once inserted. weight: number; status: number; + force?: number; }; export class Redirects { diff --git a/packages/underscore-redirects/test/print.test.js b/packages/underscore-redirects/test/print.test.js index 90c790bfd3..5b175e5534 100644 --- a/packages/underscore-redirects/test/print.test.js +++ b/packages/underscore-redirects/test/print.test.js @@ -47,4 +47,21 @@ describe('Printing', () => { const expectedParts = ['/pets/:cat', '/pets/:cat/index.html', '200']; assert.deepEqual(parts, expectedParts); }); + + it('Properly handles force redirects', () => { + const _redirects = new Redirects(); + _redirects.add({ + dynamic: false, + input: '/a', + target: '/b', + status: 200, + weight: 1, + force: true + }); + let out = _redirects.print(); + let parts = out.split(/\s+/); + + const expectedParts = ['/a', '/b', '200!']; + assert.deepEqual(parts, expectedParts); + }) }); From dbbd0a22e249bb62d406aed016ed626a651a332d Mon Sep 17 00:00:00 2001 From: Florian Lefebvre Date: Thu, 20 Jun 2024 14:19:27 +0000 Subject: [PATCH 10/42] [ci] format --- packages/underscore-redirects/test/print.test.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/underscore-redirects/test/print.test.js b/packages/underscore-redirects/test/print.test.js index 5b175e5534..284aae0ecb 100644 --- a/packages/underscore-redirects/test/print.test.js +++ b/packages/underscore-redirects/test/print.test.js @@ -49,19 +49,19 @@ describe('Printing', () => { }); it('Properly handles force redirects', () => { - const _redirects = new Redirects(); + const _redirects = new Redirects(); _redirects.add({ dynamic: false, input: '/a', target: '/b', status: 200, weight: 1, - force: true + force: true, }); let out = _redirects.print(); let parts = out.split(/\s+/); const expectedParts = ['/a', '/b', '200!']; assert.deepEqual(parts, expectedParts); - }) + }); }); From 8ce66f2ef7328546d823f1076f9bab4217a6be7d Mon Sep 17 00:00:00 2001 From: Emanuele Stoppa Date: Thu, 20 Jun 2024 22:14:49 +0100 Subject: [PATCH 11/42] fix(rss): correct types for `RSSFeedItem` (#11299) --- .changeset/tricky-mirrors-carry.md | 5 +++++ packages/astro-rss/src/index.ts | 6 +++--- 2 files changed, 8 insertions(+), 3 deletions(-) create mode 100644 .changeset/tricky-mirrors-carry.md diff --git a/.changeset/tricky-mirrors-carry.md b/.changeset/tricky-mirrors-carry.md new file mode 100644 index 0000000000..f137210cbf --- /dev/null +++ b/.changeset/tricky-mirrors-carry.md @@ -0,0 +1,5 @@ +--- +'@astrojs/rss': patch +--- + +Fixes an issue where the `pagesGlobToRssItems` returned an incorrect type for `items` diff --git a/packages/astro-rss/src/index.ts b/packages/astro-rss/src/index.ts index f2cb37c86b..84cdad0d90 100644 --- a/packages/astro-rss/src/index.ts +++ b/packages/astro-rss/src/index.ts @@ -32,13 +32,13 @@ export type RSSOptions = { export type RSSFeedItem = { /** Link to item */ - link: z.infer['link']; + link?: z.infer['link']; /** Full content of the item. Should be valid HTML */ content?: z.infer['content']; /** Title of item */ - title: z.infer['title']; + title?: z.infer['title']; /** Publication date of item */ - pubDate: z.infer['pubDate']; + pubDate?: z.infer['pubDate']; /** Item description */ description?: z.infer['description']; /** Append some other XML-valid data to this item */ From 06225673269201044358788f2a81dbe13912adce Mon Sep 17 00:00:00 2001 From: Martin Trapp <94928215+martrapp@users.noreply.github.com> Date: Fri, 21 Jun 2024 06:58:18 +0200 Subject: [PATCH 12/42] Fall back to page reload when redirected to a cross origin URL (#11302) * fall back to page reload when redirected to a cross origin URL * Make redirect work with dynamically assigned ports * undo --- .changeset/small-badgers-juggle.md | 5 +++++ .../view-transitions/src/pages/one.astro | 1 + .../view-transitions/src/pages/redirect.astro | 10 ++++++++++ packages/astro/e2e/view-transitions.test.js | 20 +++++++++++++++++++ packages/astro/src/transitions/router.ts | 8 +++++++- 5 files changed, 43 insertions(+), 1 deletion(-) create mode 100644 .changeset/small-badgers-juggle.md create mode 100644 packages/astro/e2e/fixtures/view-transitions/src/pages/redirect.astro diff --git a/.changeset/small-badgers-juggle.md b/.changeset/small-badgers-juggle.md new file mode 100644 index 0000000000..0f532fdfd1 --- /dev/null +++ b/.changeset/small-badgers-juggle.md @@ -0,0 +1,5 @@ +--- +'astro': patch +--- + +Fixes an issue with the view transition router when redirecting to an URL with different origin. diff --git a/packages/astro/e2e/fixtures/view-transitions/src/pages/one.astro b/packages/astro/e2e/fixtures/view-transitions/src/pages/one.astro index 8e34eb5559..4f11cbbc0d 100644 --- a/packages/astro/e2e/fixtures/view-transitions/src/pages/one.astro +++ b/packages/astro/e2e/fixtures/view-transitions/src/pages/one.astro @@ -11,6 +11,7 @@ import Layout from '../components/Layout.astro'; go to top go to redirect 2 go to a redirect external + redirect cross-origin go to undefined page