From cfb20550d346a33e76e23453d5dcd084e5065c4d Mon Sep 17 00:00:00 2001 From: Nate Moore Date: Tue, 5 Dec 2023 17:41:12 -0600 Subject: [PATCH 01/11] Update `vitefu` version (#9331) --- .changeset/beige-gorillas-camp.md | 5 +++++ packages/astro/package.json | 2 +- pnpm-lock.yaml | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) create mode 100644 .changeset/beige-gorillas-camp.md diff --git a/.changeset/beige-gorillas-camp.md b/.changeset/beige-gorillas-camp.md new file mode 100644 index 000000000000..4edafccb44ea --- /dev/null +++ b/.changeset/beige-gorillas-camp.md @@ -0,0 +1,5 @@ +--- +'astro': patch +--- + +Updates an internal dependency ([`vitefu`](https://github.com/svitejs/vitefu)) to avoid a common `peerDependency` warning diff --git a/packages/astro/package.json b/packages/astro/package.json index 2557fe50b3b7..a5bff393aa36 100644 --- a/packages/astro/package.json +++ b/packages/astro/package.json @@ -169,7 +169,7 @@ "unist-util-visit": "^5.0.0", "vfile": "^6.0.1", "vite": "^5.0.0", - "vitefu": "^0.2.4", + "vitefu": "^0.2.5", "which-pm": "^2.1.1", "yargs-parser": "^21.1.1", "zod": "^3.22.4" diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 85cfe724fdec..5b63728e06c6 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -644,7 +644,7 @@ importers: specifier: ^5.0.0 version: 5.0.0(@types/node@18.18.6)(sass@1.69.5) vitefu: - specifier: ^0.2.4 + specifier: ^0.2.5 version: 0.2.5(vite@5.0.0) which-pm: specifier: ^2.1.1 From b832cd190199d4269d25d5d6e6b7efb399a69070 Mon Sep 17 00:00:00 2001 From: Nate Moore Date: Tue, 5 Dec 2023 18:38:29 -0600 Subject: [PATCH 02/11] Vue: Remove `hasDefaultExport` check from `appEntrypoint` logic (#9333) --- .changeset/selfish-lamps-build.md | 5 ++ packages/integrations/vue/src/index.ts | 27 ++++++-- .../vue/test/app-entrypoint.test.js | 64 +++++++++++++++++++ .../src/pages/_app.ts | 2 +- .../astro.config.mjs | 8 +++ .../app-entrypoint-src-absolute/package.json | 12 ++++ .../src/components/Bar.vue | 3 + .../src/components/Circle.svg | 1 + .../src/components/Foo.vue | 11 ++++ .../src/pages/index.astro | 12 ++++ .../app-entrypoint-src-absolute/src/vue.ts | 1 + pnpm-lock.yaml | 9 +++ 12 files changed, 149 insertions(+), 6 deletions(-) create mode 100644 .changeset/selfish-lamps-build.md create mode 100644 packages/integrations/vue/test/fixtures/app-entrypoint-src-absolute/astro.config.mjs create mode 100644 packages/integrations/vue/test/fixtures/app-entrypoint-src-absolute/package.json create mode 100644 packages/integrations/vue/test/fixtures/app-entrypoint-src-absolute/src/components/Bar.vue create mode 100644 packages/integrations/vue/test/fixtures/app-entrypoint-src-absolute/src/components/Circle.svg create mode 100644 packages/integrations/vue/test/fixtures/app-entrypoint-src-absolute/src/components/Foo.vue create mode 100644 packages/integrations/vue/test/fixtures/app-entrypoint-src-absolute/src/pages/index.astro create mode 100644 packages/integrations/vue/test/fixtures/app-entrypoint-src-absolute/src/vue.ts diff --git a/.changeset/selfish-lamps-build.md b/.changeset/selfish-lamps-build.md new file mode 100644 index 000000000000..155c326270f5 --- /dev/null +++ b/.changeset/selfish-lamps-build.md @@ -0,0 +1,5 @@ +--- +'@astrojs/vue': patch +--- + +Fixes issue with `appEntrypoint` when running `astro dev` diff --git a/packages/integrations/vue/src/index.ts b/packages/integrations/vue/src/index.ts index 109ca58ef4fc..636dfba6a7d8 100644 --- a/packages/integrations/vue/src/index.ts +++ b/packages/integrations/vue/src/index.ts @@ -1,7 +1,7 @@ import type { Options as VueOptions } from '@vitejs/plugin-vue'; import type { Options as VueJsxOptions } from '@vitejs/plugin-vue-jsx'; import type { AstroIntegration, AstroIntegrationLogger, AstroRenderer } from 'astro'; -import type { UserConfig, Rollup } from 'vite'; +import type { UserConfig, Plugin } from 'vite'; import { fileURLToPath } from 'node:url'; import vue from '@vitejs/plugin-vue'; @@ -42,15 +42,32 @@ function getJsxRenderer(): AstroRenderer { function virtualAppEntrypoint(options: ViteOptions) { const virtualModuleId = 'virtual:@astrojs/vue/app'; const resolvedVirtualModuleId = '\0' + virtualModuleId; + let getExports: (id: string) => Promise; return { name: '@astrojs/vue/virtual-app', + buildStart() { + if (!getExports) { + getExports = async (id: string) => { + const info = await this.load.call(this, { id }); + return info.exports ?? []; + } + } + }, + configureServer(server) { + if (!getExports) { + getExports = async (id: string) => { + const mod = await server.ssrLoadModule(id); + return Object.keys(mod) ?? []; + } + } + }, resolveId(id: string) { if (id == virtualModuleId) { return resolvedVirtualModuleId; } }, async load(id: string) { - const noop = `export const setup = () => {}`; + const noop = `export const setup = (app) => app;`; if (id === resolvedVirtualModuleId) { if (options.appEntrypoint) { try { @@ -66,8 +83,8 @@ function virtualAppEntrypoint(options: ViteOptions) { // This error is handled below, the message isn't shown to the user throw new Error('Unable to resolve appEntrypoint'); } - const loaded = await this.load(resolved); - if (!loaded.hasDefaultExport) { + const exports = await getExports(resolved.id); + if (!exports.includes('default')) { options.logger.warn( `appEntrypoint \`${options.appEntrypoint}\` does not export a default function. Check out https://docs.astro.build/en/guides/integrations-guide/vue/#appentrypoint.` ); @@ -83,7 +100,7 @@ function virtualAppEntrypoint(options: ViteOptions) { return noop; } }, - } satisfies Rollup.Plugin; + } satisfies Plugin; } async function getViteConfiguration(options: ViteOptions): Promise { diff --git a/packages/integrations/vue/test/app-entrypoint.test.js b/packages/integrations/vue/test/app-entrypoint.test.js index 308f10149fc1..7a40613544bd 100644 --- a/packages/integrations/vue/test/app-entrypoint.test.js +++ b/packages/integrations/vue/test/app-entrypoint.test.js @@ -52,6 +52,39 @@ describe('App Entrypoint', () => { }); }); +describe('App Entrypoint no export default (dev)', () => { + /** @type {import('./test-utils').Fixture} */ + let fixture; + let devServer; + + before(async () => { + fixture = await loadFixture({ + root: './fixtures/app-entrypoint-no-export-default/', + }); + devServer = await fixture.startDevServer(); + }); + + after(async () => { + await devServer.stop(); + }); + + it('loads during SSR', async () => { + const html = await fixture.fetch('/').then(res => res.text()); + const { document } = parseHTML(html); + const bar = document.querySelector('#foo > #bar'); + expect(bar).not.to.be.undefined; + expect(bar.textContent).to.eq('works'); + }); + + it('loads svg components without transforming them to assets', async () => { + const html = await fixture.fetch('/').then(res => res.text()); + const { document } = parseHTML(html); + const client = document.querySelector('astro-island svg'); + + expect(client).not.to.be.undefined; + }); +}); + describe('App Entrypoint no export default', () => { /** @type {import('./test-utils').Fixture} */ let fixture; @@ -121,3 +154,34 @@ describe('App Entrypoint relative', () => { expect(js).not.to.match(/\w+\.component\(\"Bar\"/gm); }); }); + +describe('App Entrypoint /src/absolute', () => { + /** @type {import('./test-utils').Fixture} */ + let fixture; + + before(async () => { + fixture = await loadFixture({ + root: './fixtures/app-entrypoint-src-absolute/', + }); + await fixture.build(); + }); + + it('loads during SSR', async () => { + const data = await fixture.readFile('/index.html'); + const { document } = parseHTML(data); + const bar = document.querySelector('#foo > #bar'); + expect(bar).not.to.be.undefined; + expect(bar.textContent).to.eq('works'); + }); + + it('component not included in renderer bundle', async () => { + const data = await fixture.readFile('/index.html'); + const { document } = parseHTML(data); + const island = document.querySelector('astro-island'); + const client = island.getAttribute('renderer-url'); + expect(client).not.to.be.undefined; + + const js = await fixture.readFile(client); + expect(js).not.to.match(/\w+\.component\(\"Bar\"/gm); + }); +}); diff --git a/packages/integrations/vue/test/fixtures/app-entrypoint-no-export-default/src/pages/_app.ts b/packages/integrations/vue/test/fixtures/app-entrypoint-no-export-default/src/pages/_app.ts index 808620814b9b..2fc8bde52d68 100644 --- a/packages/integrations/vue/test/fixtures/app-entrypoint-no-export-default/src/pages/_app.ts +++ b/packages/integrations/vue/test/fixtures/app-entrypoint-no-export-default/src/pages/_app.ts @@ -1,3 +1,3 @@ -console.log(123); +export const setup = () => {} // no default export diff --git a/packages/integrations/vue/test/fixtures/app-entrypoint-src-absolute/astro.config.mjs b/packages/integrations/vue/test/fixtures/app-entrypoint-src-absolute/astro.config.mjs new file mode 100644 index 000000000000..6eae67892051 --- /dev/null +++ b/packages/integrations/vue/test/fixtures/app-entrypoint-src-absolute/astro.config.mjs @@ -0,0 +1,8 @@ +import { defineConfig } from 'astro/config'; +import vue from '@astrojs/vue'; + +export default defineConfig({ + integrations: [vue({ + appEntrypoint: '/src/vue.ts' + })] +}) diff --git a/packages/integrations/vue/test/fixtures/app-entrypoint-src-absolute/package.json b/packages/integrations/vue/test/fixtures/app-entrypoint-src-absolute/package.json new file mode 100644 index 000000000000..244f9120c825 --- /dev/null +++ b/packages/integrations/vue/test/fixtures/app-entrypoint-src-absolute/package.json @@ -0,0 +1,12 @@ +{ + "name": "@test/vue-app-entrypoint-src-absolute", + "version": "0.0.0", + "private": true, + "scripts": { + "astro": "astro" + }, + "dependencies": { + "@astrojs/vue": "workspace:*", + "astro": "workspace:*" + } +} diff --git a/packages/integrations/vue/test/fixtures/app-entrypoint-src-absolute/src/components/Bar.vue b/packages/integrations/vue/test/fixtures/app-entrypoint-src-absolute/src/components/Bar.vue new file mode 100644 index 000000000000..9e690ea06adc --- /dev/null +++ b/packages/integrations/vue/test/fixtures/app-entrypoint-src-absolute/src/components/Bar.vue @@ -0,0 +1,3 @@ + diff --git a/packages/integrations/vue/test/fixtures/app-entrypoint-src-absolute/src/components/Circle.svg b/packages/integrations/vue/test/fixtures/app-entrypoint-src-absolute/src/components/Circle.svg new file mode 100644 index 000000000000..cf2bd92fc135 --- /dev/null +++ b/packages/integrations/vue/test/fixtures/app-entrypoint-src-absolute/src/components/Circle.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/packages/integrations/vue/test/fixtures/app-entrypoint-src-absolute/src/components/Foo.vue b/packages/integrations/vue/test/fixtures/app-entrypoint-src-absolute/src/components/Foo.vue new file mode 100644 index 000000000000..7f6808477f18 --- /dev/null +++ b/packages/integrations/vue/test/fixtures/app-entrypoint-src-absolute/src/components/Foo.vue @@ -0,0 +1,11 @@ + + + diff --git a/packages/integrations/vue/test/fixtures/app-entrypoint-src-absolute/src/pages/index.astro b/packages/integrations/vue/test/fixtures/app-entrypoint-src-absolute/src/pages/index.astro new file mode 100644 index 000000000000..3240cbe0fd73 --- /dev/null +++ b/packages/integrations/vue/test/fixtures/app-entrypoint-src-absolute/src/pages/index.astro @@ -0,0 +1,12 @@ +--- +import Foo from '../components/Foo.vue'; +--- + + + + Vue App Entrypoint + + + + + diff --git a/packages/integrations/vue/test/fixtures/app-entrypoint-src-absolute/src/vue.ts b/packages/integrations/vue/test/fixtures/app-entrypoint-src-absolute/src/vue.ts new file mode 100644 index 000000000000..ead516c976e9 --- /dev/null +++ b/packages/integrations/vue/test/fixtures/app-entrypoint-src-absolute/src/vue.ts @@ -0,0 +1 @@ +export default () => {} diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 5b63728e06c6..d8f8ff2ad6ea 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -4860,6 +4860,15 @@ importers: specifier: workspace:* version: link:../../../../../astro + packages/integrations/vue/test/fixtures/app-entrypoint-src-absolute: + dependencies: + '@astrojs/vue': + specifier: workspace:* + version: link:../../.. + astro: + specifier: workspace:* + version: link:../../../../../astro + packages/integrations/vue/test/fixtures/basics: dependencies: '@astrojs/vue': From dd24379f496dcc99aea3004d3d5236955d6705f9 Mon Sep 17 00:00:00 2001 From: Nate Moore Date: Wed, 6 Dec 2023 00:39:39 +0000 Subject: [PATCH 03/11] [ci] format --- packages/integrations/vue/src/index.ts | 4 ++-- packages/integrations/vue/test/app-entrypoint.test.js | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/integrations/vue/src/index.ts b/packages/integrations/vue/src/index.ts index 636dfba6a7d8..ef35055877d7 100644 --- a/packages/integrations/vue/src/index.ts +++ b/packages/integrations/vue/src/index.ts @@ -50,7 +50,7 @@ function virtualAppEntrypoint(options: ViteOptions) { getExports = async (id: string) => { const info = await this.load.call(this, { id }); return info.exports ?? []; - } + }; } }, configureServer(server) { @@ -58,7 +58,7 @@ function virtualAppEntrypoint(options: ViteOptions) { getExports = async (id: string) => { const mod = await server.ssrLoadModule(id); return Object.keys(mod) ?? []; - } + }; } }, resolveId(id: string) { diff --git a/packages/integrations/vue/test/app-entrypoint.test.js b/packages/integrations/vue/test/app-entrypoint.test.js index 7a40613544bd..3a374be1c287 100644 --- a/packages/integrations/vue/test/app-entrypoint.test.js +++ b/packages/integrations/vue/test/app-entrypoint.test.js @@ -69,7 +69,7 @@ describe('App Entrypoint no export default (dev)', () => { }); it('loads during SSR', async () => { - const html = await fixture.fetch('/').then(res => res.text()); + const html = await fixture.fetch('/').then((res) => res.text()); const { document } = parseHTML(html); const bar = document.querySelector('#foo > #bar'); expect(bar).not.to.be.undefined; @@ -77,7 +77,7 @@ describe('App Entrypoint no export default (dev)', () => { }); it('loads svg components without transforming them to assets', async () => { - const html = await fixture.fetch('/').then(res => res.text()); + const html = await fixture.fetch('/').then((res) => res.text()); const { document } = parseHTML(html); const client = document.querySelector('astro-island svg'); From 3878a91be4879988c7235f433e50a6dc82e32288 Mon Sep 17 00:00:00 2001 From: Ted Klingenberg Date: Tue, 5 Dec 2023 19:42:53 -0500 Subject: [PATCH 04/11] Prevent client-side navigation for method="dialog" (#9327) Co-authored-by: Nate Moore --- .changeset/rich-keys-rescue.md | 5 +++++ packages/astro/components/ViewTransitions.astro | 7 +++++++ .../view-transitions/src/pages/dialog.astro | 16 ++++++++++++++++ packages/astro/e2e/view-transitions.test.js | 14 ++++++++++++++ 4 files changed, 42 insertions(+) create mode 100644 .changeset/rich-keys-rescue.md create mode 100644 packages/astro/e2e/fixtures/view-transitions/src/pages/dialog.astro diff --git a/.changeset/rich-keys-rescue.md b/.changeset/rich-keys-rescue.md new file mode 100644 index 000000000000..1107f35b17cc --- /dev/null +++ b/.changeset/rich-keys-rescue.md @@ -0,0 +1,5 @@ +--- +'astro': patch +--- + +Fixes an edge case for `
` when using View Transitions. Forms with `method="dialog"` no longer require an additional `data-astro-reload` attribute. diff --git a/packages/astro/components/ViewTransitions.astro b/packages/astro/components/ViewTransitions.astro index 6ce08cec9556..d9786ac6ac32 100644 --- a/packages/astro/components/ViewTransitions.astro +++ b/packages/astro/components/ViewTransitions.astro @@ -104,6 +104,12 @@ const { fallback = 'animate' } = Astro.props; let action = submitter?.getAttribute('formaction') ?? form.action ?? location.pathname; const method = submitter?.getAttribute('formmethod') ?? form.method; + // the "dialog" method is a special keyword used within elements + // https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#attr-fs-method + if (method === "dialog") { + return + } + const options: Options = { sourceElement: submitter ?? form }; if (method === 'get') { const params = new URLSearchParams(formData as any); @@ -113,6 +119,7 @@ const { fallback = 'animate' } = Astro.props; } else { options.formData = formData; } + ev.preventDefault(); navigate(action, options); }); diff --git a/packages/astro/e2e/fixtures/view-transitions/src/pages/dialog.astro b/packages/astro/e2e/fixtures/view-transitions/src/pages/dialog.astro new file mode 100644 index 000000000000..07d4b0f00b39 --- /dev/null +++ b/packages/astro/e2e/fixtures/view-transitions/src/pages/dialog.astro @@ -0,0 +1,16 @@ +--- +import { ViewTransitions } from "astro:transitions"; +--- + + + + + + + + + + + + + diff --git a/packages/astro/e2e/view-transitions.test.js b/packages/astro/e2e/view-transitions.test.js index bfc5d7d4a92d..27b7ea6d6a76 100644 --- a/packages/astro/e2e/view-transitions.test.js +++ b/packages/astro/e2e/view-transitions.test.js @@ -1074,4 +1074,18 @@ test.describe('View Transitions', () => { await page.click('#three'); await expect(page).toHaveURL(expected); }); + + test('Dialog using form with method of "dialog" should not trigger navigation', async ({ page, astro }) => { + await page.goto(astro.resolveUrl('/dialog')); + + let requests = []; + page.on('request', request => requests.push(`${request.method()} ${request.url()}`)); + + await page.click('#open'); + await expect(page.locator("dialog")).toHaveAttribute("open") + await page.click('#close'); + await expect(page.locator("dialog")).not.toHaveAttribute("open") + + expect(requests).toHaveLength(0) + }); }); From 6404d26a22417587cac272bc473ee1c8eb8c69a3 Mon Sep 17 00:00:00 2001 From: Ted Klingenberg Date: Wed, 6 Dec 2023 00:43:56 +0000 Subject: [PATCH 05/11] [ci] format --- packages/astro/components/ViewTransitions.astro | 6 +++--- packages/astro/e2e/view-transitions.test.js | 13 ++++++++----- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/packages/astro/components/ViewTransitions.astro b/packages/astro/components/ViewTransitions.astro index d9786ac6ac32..310f1865a92c 100644 --- a/packages/astro/components/ViewTransitions.astro +++ b/packages/astro/components/ViewTransitions.astro @@ -106,8 +106,8 @@ const { fallback = 'animate' } = Astro.props; // the "dialog" method is a special keyword used within elements // https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#attr-fs-method - if (method === "dialog") { - return + if (method === 'dialog') { + return; } const options: Options = { sourceElement: submitter ?? form }; @@ -119,7 +119,7 @@ const { fallback = 'animate' } = Astro.props; } else { options.formData = formData; } - + ev.preventDefault(); navigate(action, options); }); diff --git a/packages/astro/e2e/view-transitions.test.js b/packages/astro/e2e/view-transitions.test.js index 27b7ea6d6a76..222c9dfdf2aa 100644 --- a/packages/astro/e2e/view-transitions.test.js +++ b/packages/astro/e2e/view-transitions.test.js @@ -1075,17 +1075,20 @@ test.describe('View Transitions', () => { await expect(page).toHaveURL(expected); }); - test('Dialog using form with method of "dialog" should not trigger navigation', async ({ page, astro }) => { + test('Dialog using form with method of "dialog" should not trigger navigation', async ({ + page, + astro, + }) => { await page.goto(astro.resolveUrl('/dialog')); let requests = []; - page.on('request', request => requests.push(`${request.method()} ${request.url()}`)); + page.on('request', (request) => requests.push(`${request.method()} ${request.url()}`)); await page.click('#open'); - await expect(page.locator("dialog")).toHaveAttribute("open") + await expect(page.locator('dialog')).toHaveAttribute('open'); await page.click('#close'); - await expect(page.locator("dialog")).not.toHaveAttribute("open") + await expect(page.locator('dialog')).not.toHaveAttribute('open'); - expect(requests).toHaveLength(0) + expect(requests).toHaveLength(0); }); }); From 895ebcb5bfeb2fe08ae939eaceeb0405cff91ca5 Mon Sep 17 00:00:00 2001 From: "Houston (Bot)" <108291165+astrobot-houston@users.noreply.github.com> Date: Tue, 5 Dec 2023 16:47:22 -0800 Subject: [PATCH 06/11] [ci] release (#9332) Co-authored-by: github-actions[bot] --- .changeset/beige-gorillas-camp.md | 5 -- .changeset/rich-keys-rescue.md | 5 -- .changeset/selfish-lamps-build.md | 5 -- examples/basics/package.json | 2 +- examples/blog/package.json | 2 +- examples/component/package.json | 2 +- examples/framework-alpine/package.json | 2 +- examples/framework-lit/package.json | 2 +- examples/framework-multiple/package.json | 4 +- 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 | 4 +- 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/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 | 8 +++ packages/astro/package.json | 2 +- packages/integrations/vue/CHANGELOG.md | 6 +++ packages/integrations/vue/package.json | 2 +- pnpm-lock.yaml | 56 ++++++++++----------- 34 files changed, 72 insertions(+), 73 deletions(-) delete mode 100644 .changeset/beige-gorillas-camp.md delete mode 100644 .changeset/rich-keys-rescue.md delete mode 100644 .changeset/selfish-lamps-build.md diff --git a/.changeset/beige-gorillas-camp.md b/.changeset/beige-gorillas-camp.md deleted file mode 100644 index 4edafccb44ea..000000000000 --- a/.changeset/beige-gorillas-camp.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'astro': patch ---- - -Updates an internal dependency ([`vitefu`](https://github.com/svitejs/vitefu)) to avoid a common `peerDependency` warning diff --git a/.changeset/rich-keys-rescue.md b/.changeset/rich-keys-rescue.md deleted file mode 100644 index 1107f35b17cc..000000000000 --- a/.changeset/rich-keys-rescue.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'astro': patch ---- - -Fixes an edge case for `
` when using View Transitions. Forms with `method="dialog"` no longer require an additional `data-astro-reload` attribute. diff --git a/.changeset/selfish-lamps-build.md b/.changeset/selfish-lamps-build.md deleted file mode 100644 index 155c326270f5..000000000000 --- a/.changeset/selfish-lamps-build.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'@astrojs/vue': patch ---- - -Fixes issue with `appEntrypoint` when running `astro dev` diff --git a/examples/basics/package.json b/examples/basics/package.json index e4ed24314fe7..462235462498 100644 --- a/examples/basics/package.json +++ b/examples/basics/package.json @@ -11,6 +11,6 @@ "astro": "astro" }, "dependencies": { - "astro": "^4.0.1" + "astro": "^4.0.2" } } diff --git a/examples/blog/package.json b/examples/blog/package.json index 8e4c5ac223bf..3ece054ce403 100644 --- a/examples/blog/package.json +++ b/examples/blog/package.json @@ -14,6 +14,6 @@ "@astrojs/mdx": "^2.0.0", "@astrojs/rss": "^4.0.0", "@astrojs/sitemap": "^3.0.3", - "astro": "^4.0.1" + "astro": "^4.0.2" } } diff --git a/examples/component/package.json b/examples/component/package.json index 0d916d3b713c..9cac9645df69 100644 --- a/examples/component/package.json +++ b/examples/component/package.json @@ -15,7 +15,7 @@ ], "scripts": {}, "devDependencies": { - "astro": "^4.0.1" + "astro": "^4.0.2" }, "peerDependencies": { "astro": "^3.0.0" diff --git a/examples/framework-alpine/package.json b/examples/framework-alpine/package.json index 28debb4f53fd..f9fc290954ba 100644 --- a/examples/framework-alpine/package.json +++ b/examples/framework-alpine/package.json @@ -14,6 +14,6 @@ "@astrojs/alpinejs": "^0.3.1", "@types/alpinejs": "^3.13.5", "alpinejs": "^3.13.3", - "astro": "^4.0.1" + "astro": "^4.0.2" } } diff --git a/examples/framework-lit/package.json b/examples/framework-lit/package.json index 3a4fec7fc22d..72a5bd0c45aa 100644 --- a/examples/framework-lit/package.json +++ b/examples/framework-lit/package.json @@ -13,7 +13,7 @@ "dependencies": { "@astrojs/lit": "^3.0.3", "@webcomponents/template-shadowroot": "^0.2.1", - "astro": "^4.0.1", + "astro": "^4.0.2", "lit": "^2.8.0" } } diff --git a/examples/framework-multiple/package.json b/examples/framework-multiple/package.json index cc2d1fc1e4ac..d83833e59bec 100644 --- a/examples/framework-multiple/package.json +++ b/examples/framework-multiple/package.json @@ -15,8 +15,8 @@ "@astrojs/react": "^3.0.7", "@astrojs/solid-js": "^3.0.2", "@astrojs/svelte": "^5.0.0", - "@astrojs/vue": "^4.0.1", - "astro": "^4.0.1", + "@astrojs/vue": "^4.0.2", + "astro": "^4.0.2", "preact": "^10.19.2", "react": "^18.2.0", "react-dom": "^18.2.0", diff --git a/examples/framework-preact/package.json b/examples/framework-preact/package.json index 56adb34e6ca3..08c3d7d875e1 100644 --- a/examples/framework-preact/package.json +++ b/examples/framework-preact/package.json @@ -13,7 +13,7 @@ "dependencies": { "@astrojs/preact": "^3.0.1", "@preact/signals": "^1.2.1", - "astro": "^4.0.1", + "astro": "^4.0.2", "preact": "^10.19.2" } } diff --git a/examples/framework-react/package.json b/examples/framework-react/package.json index 1e0eeed2893c..6256dcb6b779 100644 --- a/examples/framework-react/package.json +++ b/examples/framework-react/package.json @@ -14,7 +14,7 @@ "@astrojs/react": "^3.0.7", "@types/react": "^18.2.37", "@types/react-dom": "^18.2.15", - "astro": "^4.0.1", + "astro": "^4.0.2", "react": "^18.2.0", "react-dom": "^18.2.0" } diff --git a/examples/framework-solid/package.json b/examples/framework-solid/package.json index e9872b4efaa2..34d8bc50f6ba 100644 --- a/examples/framework-solid/package.json +++ b/examples/framework-solid/package.json @@ -12,7 +12,7 @@ }, "dependencies": { "@astrojs/solid-js": "^3.0.2", - "astro": "^4.0.1", + "astro": "^4.0.2", "solid-js": "^1.8.5" } } diff --git a/examples/framework-svelte/package.json b/examples/framework-svelte/package.json index e7e370518810..a9406838c3cf 100644 --- a/examples/framework-svelte/package.json +++ b/examples/framework-svelte/package.json @@ -12,7 +12,7 @@ }, "dependencies": { "@astrojs/svelte": "^5.0.0", - "astro": "^4.0.1", + "astro": "^4.0.2", "svelte": "^4.2.5" } } diff --git a/examples/framework-vue/package.json b/examples/framework-vue/package.json index 81a02293828e..f7a42cd42bf5 100644 --- a/examples/framework-vue/package.json +++ b/examples/framework-vue/package.json @@ -11,8 +11,8 @@ "astro": "astro" }, "dependencies": { - "@astrojs/vue": "^4.0.1", - "astro": "^4.0.1", + "@astrojs/vue": "^4.0.2", + "astro": "^4.0.2", "vue": "^3.3.8" } } diff --git a/examples/hackernews/package.json b/examples/hackernews/package.json index 0a354dacf866..ca4ab4ef6030 100644 --- a/examples/hackernews/package.json +++ b/examples/hackernews/package.json @@ -12,6 +12,6 @@ }, "dependencies": { "@astrojs/node": "^7.0.0", - "astro": "^4.0.1" + "astro": "^4.0.2" } } diff --git a/examples/integration/package.json b/examples/integration/package.json index 3fe356bea0c8..3708dfac7306 100644 --- a/examples/integration/package.json +++ b/examples/integration/package.json @@ -15,7 +15,7 @@ ], "scripts": {}, "devDependencies": { - "astro": "^4.0.1" + "astro": "^4.0.2" }, "peerDependencies": { "astro": "^3.0.0" diff --git a/examples/middleware/package.json b/examples/middleware/package.json index 432bb09544b1..9f6393538781 100644 --- a/examples/middleware/package.json +++ b/examples/middleware/package.json @@ -13,7 +13,7 @@ }, "dependencies": { "@astrojs/node": "^7.0.0", - "astro": "^4.0.1", + "astro": "^4.0.2", "html-minifier": "^4.0.0" } } diff --git a/examples/minimal/package.json b/examples/minimal/package.json index 62f864b52ace..7f37079799a5 100644 --- a/examples/minimal/package.json +++ b/examples/minimal/package.json @@ -11,6 +11,6 @@ "astro": "astro" }, "dependencies": { - "astro": "^4.0.1" + "astro": "^4.0.2" } } diff --git a/examples/non-html-pages/package.json b/examples/non-html-pages/package.json index 6695eda42e63..e7c51ad9cdbf 100644 --- a/examples/non-html-pages/package.json +++ b/examples/non-html-pages/package.json @@ -11,6 +11,6 @@ "astro": "astro" }, "dependencies": { - "astro": "^4.0.1" + "astro": "^4.0.2" } } diff --git a/examples/portfolio/package.json b/examples/portfolio/package.json index ad232172e8f4..c8b9e51946f3 100644 --- a/examples/portfolio/package.json +++ b/examples/portfolio/package.json @@ -11,6 +11,6 @@ "astro": "astro" }, "dependencies": { - "astro": "^4.0.1" + "astro": "^4.0.2" } } diff --git a/examples/ssr/package.json b/examples/ssr/package.json index 7665692b15ac..f7af576ce892 100644 --- a/examples/ssr/package.json +++ b/examples/ssr/package.json @@ -14,7 +14,7 @@ "dependencies": { "@astrojs/node": "^7.0.0", "@astrojs/svelte": "^5.0.0", - "astro": "^4.0.1", + "astro": "^4.0.2", "svelte": "^4.2.5" } } diff --git a/examples/view-transitions/package.json b/examples/view-transitions/package.json index 81e1799d1d17..4e2839596e52 100644 --- a/examples/view-transitions/package.json +++ b/examples/view-transitions/package.json @@ -12,6 +12,6 @@ "devDependencies": { "@astrojs/tailwind": "^5.0.3", "@astrojs/node": "^7.0.0", - "astro": "^4.0.1" + "astro": "^4.0.2" } } diff --git a/examples/with-markdoc/package.json b/examples/with-markdoc/package.json index 6ffcb62c947c..58f640c801e6 100644 --- a/examples/with-markdoc/package.json +++ b/examples/with-markdoc/package.json @@ -12,6 +12,6 @@ }, "dependencies": { "@astrojs/markdoc": "^0.8.0", - "astro": "^4.0.1" + "astro": "^4.0.2" } } diff --git a/examples/with-markdown-plugins/package.json b/examples/with-markdown-plugins/package.json index 99273393dc55..1dbbd8eda8bc 100644 --- a/examples/with-markdown-plugins/package.json +++ b/examples/with-markdown-plugins/package.json @@ -12,7 +12,7 @@ }, "dependencies": { "@astrojs/markdown-remark": "^4.0.0", - "astro": "^4.0.1", + "astro": "^4.0.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 cba6affce62a..b7c646508f27 100644 --- a/examples/with-markdown-shiki/package.json +++ b/examples/with-markdown-shiki/package.json @@ -11,6 +11,6 @@ "astro": "astro" }, "dependencies": { - "astro": "^4.0.1" + "astro": "^4.0.2" } } diff --git a/examples/with-mdx/package.json b/examples/with-mdx/package.json index 64444a5f4028..67b1428e4e12 100644 --- a/examples/with-mdx/package.json +++ b/examples/with-mdx/package.json @@ -13,7 +13,7 @@ "dependencies": { "@astrojs/mdx": "^2.0.0", "@astrojs/preact": "^3.0.1", - "astro": "^4.0.1", + "astro": "^4.0.2", "preact": "^10.19.2" } } diff --git a/examples/with-nanostores/package.json b/examples/with-nanostores/package.json index 9938024775d3..586b36bd8b6a 100644 --- a/examples/with-nanostores/package.json +++ b/examples/with-nanostores/package.json @@ -13,7 +13,7 @@ "dependencies": { "@astrojs/preact": "^3.0.1", "@nanostores/preact": "^0.5.0", - "astro": "^4.0.1", + "astro": "^4.0.2", "nanostores": "^0.9.5", "preact": "^10.19.2" } diff --git a/examples/with-tailwindcss/package.json b/examples/with-tailwindcss/package.json index b549791fcb86..f76fccaacb19 100644 --- a/examples/with-tailwindcss/package.json +++ b/examples/with-tailwindcss/package.json @@ -14,7 +14,7 @@ "@astrojs/mdx": "^2.0.0", "@astrojs/tailwind": "^5.0.3", "@types/canvas-confetti": "^1.6.3", - "astro": "^4.0.1", + "astro": "^4.0.2", "autoprefixer": "^10.4.15", "canvas-confetti": "^1.9.1", "postcss": "^8.4.28", diff --git a/examples/with-vitest/package.json b/examples/with-vitest/package.json index c2532051195e..838d13d2e65a 100644 --- a/examples/with-vitest/package.json +++ b/examples/with-vitest/package.json @@ -12,7 +12,7 @@ "test": "vitest" }, "dependencies": { - "astro": "^4.0.1", + "astro": "^4.0.2", "vitest": "^0.34.2" } } diff --git a/packages/astro/CHANGELOG.md b/packages/astro/CHANGELOG.md index 3925e15e40ab..5076fc126336 100644 --- a/packages/astro/CHANGELOG.md +++ b/packages/astro/CHANGELOG.md @@ -1,5 +1,13 @@ # astro +## 4.0.2 + +### Patch Changes + +- [#9331](https://github.com/withastro/astro/pull/9331) [`cfb20550d`](https://github.com/withastro/astro/commit/cfb20550d346a33e76e23453d5dcd084e5065c4d) Thanks [@natemoo-re](https://github.com/natemoo-re)! - Updates an internal dependency ([`vitefu`](https://github.com/svitejs/vitefu)) to avoid a common `peerDependency` warning + +- [#9327](https://github.com/withastro/astro/pull/9327) [`3878a91be`](https://github.com/withastro/astro/commit/3878a91be4879988c7235f433e50a6dc82e32288) Thanks [@doseofted](https://github.com/doseofted)! - Fixes an edge case for `` when using View Transitions. Forms with `method="dialog"` no longer require an additional `data-astro-reload` attribute. + ## 4.0.1 ### Patch Changes diff --git a/packages/astro/package.json b/packages/astro/package.json index a5bff393aa36..bfa7c54fdf04 100644 --- a/packages/astro/package.json +++ b/packages/astro/package.json @@ -1,6 +1,6 @@ { "name": "astro", - "version": "4.0.1", + "version": "4.0.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/integrations/vue/CHANGELOG.md b/packages/integrations/vue/CHANGELOG.md index 1cc63f36e626..16b28bec63fd 100644 --- a/packages/integrations/vue/CHANGELOG.md +++ b/packages/integrations/vue/CHANGELOG.md @@ -1,5 +1,11 @@ # @astrojs/vue +## 4.0.2 + +### Patch Changes + +- [#9333](https://github.com/withastro/astro/pull/9333) [`b832cd190`](https://github.com/withastro/astro/commit/b832cd190199d4269d25d5d6e6b7efb399a69070) Thanks [@natemoo-re](https://github.com/natemoo-re)! - Fixes issue with `appEntrypoint` when running `astro dev` + ## 4.0.1 ### Patch Changes diff --git a/packages/integrations/vue/package.json b/packages/integrations/vue/package.json index 79dd727ad201..9ed3417f64e8 100644 --- a/packages/integrations/vue/package.json +++ b/packages/integrations/vue/package.json @@ -1,6 +1,6 @@ { "name": "@astrojs/vue", - "version": "4.0.1", + "version": "4.0.2", "description": "Use Vue components within Astro", "type": "module", "types": "./dist/index.d.ts", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index d8f8ff2ad6ea..1dfa0f263c7d 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -125,7 +125,7 @@ importers: examples/basics: dependencies: astro: - specifier: ^4.0.1 + specifier: ^4.0.2 version: link:../../packages/astro examples/blog: @@ -140,13 +140,13 @@ importers: specifier: ^3.0.3 version: link:../../packages/integrations/sitemap astro: - specifier: ^4.0.1 + specifier: ^4.0.2 version: link:../../packages/astro examples/component: devDependencies: astro: - specifier: ^4.0.1 + specifier: ^4.0.2 version: link:../../packages/astro examples/framework-alpine: @@ -161,7 +161,7 @@ importers: specifier: ^3.13.3 version: 3.13.3 astro: - specifier: ^4.0.1 + specifier: ^4.0.2 version: link:../../packages/astro examples/framework-lit: @@ -173,7 +173,7 @@ importers: specifier: ^0.2.1 version: 0.2.1 astro: - specifier: ^4.0.1 + specifier: ^4.0.2 version: link:../../packages/astro lit: specifier: ^2.8.0 @@ -194,10 +194,10 @@ importers: specifier: ^5.0.0 version: link:../../packages/integrations/svelte '@astrojs/vue': - specifier: ^4.0.1 + specifier: ^4.0.2 version: link:../../packages/integrations/vue astro: - specifier: ^4.0.1 + specifier: ^4.0.2 version: link:../../packages/astro preact: specifier: ^10.19.2 @@ -227,7 +227,7 @@ importers: specifier: ^1.2.1 version: 1.2.1(preact@10.19.2) astro: - specifier: ^4.0.1 + specifier: ^4.0.2 version: link:../../packages/astro preact: specifier: ^10.19.2 @@ -245,7 +245,7 @@ importers: specifier: ^18.2.15 version: 18.2.15 astro: - specifier: ^4.0.1 + specifier: ^4.0.2 version: link:../../packages/astro react: specifier: ^18.2.0 @@ -260,7 +260,7 @@ importers: specifier: ^3.0.2 version: link:../../packages/integrations/solid astro: - specifier: ^4.0.1 + specifier: ^4.0.2 version: link:../../packages/astro solid-js: specifier: ^1.8.5 @@ -272,7 +272,7 @@ importers: specifier: ^5.0.0 version: link:../../packages/integrations/svelte astro: - specifier: ^4.0.1 + specifier: ^4.0.2 version: link:../../packages/astro svelte: specifier: ^4.2.5 @@ -281,10 +281,10 @@ importers: examples/framework-vue: dependencies: '@astrojs/vue': - specifier: ^4.0.1 + specifier: ^4.0.2 version: link:../../packages/integrations/vue astro: - specifier: ^4.0.1 + specifier: ^4.0.2 version: link:../../packages/astro vue: specifier: ^3.3.8 @@ -296,13 +296,13 @@ importers: specifier: ^7.0.0 version: link:../../packages/integrations/node astro: - specifier: ^4.0.1 + specifier: ^4.0.2 version: link:../../packages/astro examples/integration: devDependencies: astro: - specifier: ^4.0.1 + specifier: ^4.0.2 version: link:../../packages/astro examples/middleware: @@ -311,7 +311,7 @@ importers: specifier: ^7.0.0 version: link:../../packages/integrations/node astro: - specifier: ^4.0.1 + specifier: ^4.0.2 version: link:../../packages/astro html-minifier: specifier: ^4.0.0 @@ -320,19 +320,19 @@ importers: examples/minimal: dependencies: astro: - specifier: ^4.0.1 + specifier: ^4.0.2 version: link:../../packages/astro examples/non-html-pages: dependencies: astro: - specifier: ^4.0.1 + specifier: ^4.0.2 version: link:../../packages/astro examples/portfolio: dependencies: astro: - specifier: ^4.0.1 + specifier: ^4.0.2 version: link:../../packages/astro examples/ssr: @@ -344,7 +344,7 @@ importers: specifier: ^5.0.0 version: link:../../packages/integrations/svelte astro: - specifier: ^4.0.1 + specifier: ^4.0.2 version: link:../../packages/astro svelte: specifier: ^4.2.5 @@ -359,7 +359,7 @@ importers: specifier: ^5.0.3 version: link:../../packages/integrations/tailwind astro: - specifier: ^4.0.1 + specifier: ^4.0.2 version: link:../../packages/astro examples/with-markdoc: @@ -368,7 +368,7 @@ importers: specifier: ^0.8.0 version: link:../../packages/integrations/markdoc astro: - specifier: ^4.0.1 + specifier: ^4.0.2 version: link:../../packages/astro examples/with-markdown-plugins: @@ -377,7 +377,7 @@ importers: specifier: ^4.0.0 version: link:../../packages/markdown/remark astro: - specifier: ^4.0.1 + specifier: ^4.0.2 version: link:../../packages/astro hast-util-select: specifier: ^6.0.2 @@ -398,7 +398,7 @@ importers: examples/with-markdown-shiki: dependencies: astro: - specifier: ^4.0.1 + specifier: ^4.0.2 version: link:../../packages/astro examples/with-mdx: @@ -410,7 +410,7 @@ importers: specifier: ^3.0.1 version: link:../../packages/integrations/preact astro: - specifier: ^4.0.1 + specifier: ^4.0.2 version: link:../../packages/astro preact: specifier: ^10.19.2 @@ -425,7 +425,7 @@ importers: specifier: ^0.5.0 version: 0.5.0(nanostores@0.9.5)(preact@10.19.2) astro: - specifier: ^4.0.1 + specifier: ^4.0.2 version: link:../../packages/astro nanostores: specifier: ^0.9.5 @@ -446,7 +446,7 @@ importers: specifier: ^1.6.3 version: 1.6.3 astro: - specifier: ^4.0.1 + specifier: ^4.0.2 version: link:../../packages/astro autoprefixer: specifier: ^10.4.15 @@ -464,7 +464,7 @@ importers: examples/with-vitest: dependencies: astro: - specifier: ^4.0.1 + specifier: ^4.0.2 version: link:../../packages/astro vitest: specifier: ^0.34.2 From 0bb3d532219fb90fc08bfb472fc981fab6543d16 Mon Sep 17 00:00:00 2001 From: Shinya Fujino Date: Wed, 6 Dec 2023 19:44:07 +0900 Subject: [PATCH 07/11] Fix log message for `Disable notifications` (#9339) * Fix log message for `Disable notifications` * Add changeset --- .changeset/strange-parrots-promise.md | 5 +++++ .../astro/src/runtime/client/dev-overlay/plugins/settings.ts | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 .changeset/strange-parrots-promise.md diff --git a/.changeset/strange-parrots-promise.md b/.changeset/strange-parrots-promise.md new file mode 100644 index 000000000000..584d911eea0b --- /dev/null +++ b/.changeset/strange-parrots-promise.md @@ -0,0 +1,5 @@ +--- +'astro': patch +--- + +Fixed the log message to correctly display 'enabled' and 'disabled' when toggling 'Disable notifications' in the Toolbar. diff --git a/packages/astro/src/runtime/client/dev-overlay/plugins/settings.ts b/packages/astro/src/runtime/client/dev-overlay/plugins/settings.ts index 672b7bbda36a..dc5fe4ae3637 100644 --- a/packages/astro/src/runtime/client/dev-overlay/plugins/settings.ts +++ b/packages/astro/src/runtime/client/dev-overlay/plugins/settings.ts @@ -25,7 +25,7 @@ const settingsRows = [ } settings.updateSetting('disablePluginNotification', evt.currentTarget.checked); - const action = evt.currentTarget.checked ? 'enabled' : 'disabled'; + const action = evt.currentTarget.checked ? 'disabled' : 'enabled'; settings.log(`Plugin notification badges ${action}`); } }, From c76901065545f6a8d3de3e44d1c8ee5456a8a77a Mon Sep 17 00:00:00 2001 From: "Fred K. Schott" Date: Wed, 6 Dec 2023 04:07:52 -0800 Subject: [PATCH 08/11] Fix issue where 404/500 status codes were logged as "[200]" (#9336) --- .changeset/modern-mice-shout.md | 5 +++ packages/astro/src/core/messages.ts | 2 +- .../src/vite-plugin-astro-server/route.ts | 33 +++++++++---------- 3 files changed, 22 insertions(+), 18 deletions(-) create mode 100644 .changeset/modern-mice-shout.md diff --git a/.changeset/modern-mice-shout.md b/.changeset/modern-mice-shout.md new file mode 100644 index 000000000000..cc483b1937f6 --- /dev/null +++ b/.changeset/modern-mice-shout.md @@ -0,0 +1,5 @@ +--- +'astro': patch +--- + +dev: fix issue where 404 and 500 responses were logged as 200 diff --git a/packages/astro/src/core/messages.ts b/packages/astro/src/core/messages.ts index ebac2c51d611..b105e985cb05 100644 --- a/packages/astro/src/core/messages.ts +++ b/packages/astro/src/core/messages.ts @@ -37,7 +37,7 @@ export function req({ method?: string; reqTime?: number; }): string { - const color = statusCode >= 400 ? red : statusCode >= 300 ? yellow : blue; + const color = statusCode >= 500 ? red : statusCode >= 300 ? yellow : blue; return ( color(`[${statusCode}]`) + ` ` + diff --git a/packages/astro/src/vite-plugin-astro-server/route.ts b/packages/astro/src/vite-plugin-astro-server/route.ts index 92a7a8247a35..3196b951a796 100644 --- a/packages/astro/src/vite-plugin-astro-server/route.ts +++ b/packages/astro/src/vite-plugin-astro-server/route.ts @@ -332,7 +332,7 @@ export async function handleRoute({ req({ url: pathname, method: incomingRequest.method, - statusCode: response.status, + statusCode: status ?? response.status, reqTime: timeEnd - timeStart, }) ); @@ -356,24 +356,23 @@ export async function handleRoute({ } if (route.type === 'endpoint') { await writeWebResponse(incomingResponse, response); - } else { - if ( - // We are in a recursion, and it's possible that this function is called itself with a status code - // By default, the status code passed via parameters is computed by the matched route. - // - // By default, we should give priority to the status code passed, although it's possible that - // the `Response` emitted by the user is a redirect. If so, then return the returned response. - response.status < 400 && - response.status >= 300 - ) { - await writeSSRResult(request, response, incomingResponse); - return; - } else if (status && response.status !== status && (status === 404 || status === 500)) { - // Response.status is read-only, so a clone is required to override - response = new Response(response.body, { ...response, status }); - } + return; + } + // We are in a recursion, and it's possible that this function is called itself with a status code + // By default, the status code passed via parameters is computed by the matched route. + // + // By default, we should give priority to the status code passed, although it's possible that + // the `Response` emitted by the user is a redirect. If so, then return the returned response. + if (response.status < 400 && response.status >= 300) { await writeSSRResult(request, response, incomingResponse); + return; + } + // Apply the `status` override to the response object before responding. + // Response.status is read-only, so a clone is required to override. + if (status && response.status !== status && (status === 404 || status === 500)) { + response = new Response(response.body, { ...response, status }); } + await writeSSRResult(request, response, incomingResponse); } interface GetScriptsAndStylesParams { From eb942942d67508c07d7efaa859a7840f7c0223da Mon Sep 17 00:00:00 2001 From: Erika <3019731+Princesseuh@users.noreply.github.com> Date: Wed, 6 Dec 2023 13:09:30 +0100 Subject: [PATCH 09/11] fix: add types for `is:inline` on slots (#9342) --- .changeset/cold-toys-greet.md | 5 +++++ packages/astro/astro-jsx.d.ts | 3 ++- packages/astro/src/@types/astro.ts | 4 ++++ 3 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 .changeset/cold-toys-greet.md diff --git a/.changeset/cold-toys-greet.md b/.changeset/cold-toys-greet.md new file mode 100644 index 000000000000..7923c5567aea --- /dev/null +++ b/.changeset/cold-toys-greet.md @@ -0,0 +1,5 @@ +--- +'astro': patch +--- + +Fix missing `is:inline` type for the `` element diff --git a/packages/astro/astro-jsx.d.ts b/packages/astro/astro-jsx.d.ts index 3e8a86889282..3f73bcc613ee 100644 --- a/packages/astro/astro-jsx.d.ts +++ b/packages/astro/astro-jsx.d.ts @@ -36,6 +36,7 @@ declare namespace astroHTML.JSX { AstroDefineVarsAttribute; type AstroStyleAttributes = import('./dist/@types/astro.js').AstroStyleAttributes & AstroDefineVarsAttribute; + type AstroSlotAttributes = import('./dist/@types/astro.js').AstroSlotAttributes; // This is an unfortunate use of `any`, but unfortunately we can't make a type that works for every framework // without importing every single framework's types (which comes with its own set of problems). @@ -1415,7 +1416,7 @@ declare namespace astroHTML.JSX { ruby: HTMLAttributes; s: HTMLAttributes; samp: HTMLAttributes; - slot: SlotHTMLAttributes; + slot: SlotHTMLAttributes & AstroSlotAttributes; script: ScriptHTMLAttributes & AstroScriptAttributes; section: HTMLAttributes; select: SelectHTMLAttributes; diff --git a/packages/astro/src/@types/astro.ts b/packages/astro/src/@types/astro.ts index bbea8202523e..fa8c33920ac0 100644 --- a/packages/astro/src/@types/astro.ts +++ b/packages/astro/src/@types/astro.ts @@ -132,6 +132,10 @@ export interface AstroScriptAttributes { 'is:inline'?: boolean; } +export interface AstroSlotAttributes { + 'is:inline'?: boolean; +} + export interface AstroComponentMetadata { displayName: string; hydrate?: 'load' | 'idle' | 'visible' | 'media' | 'only'; From edfae50e6ea494f49c6d4fbf4bd4481870f994b1 Mon Sep 17 00:00:00 2001 From: Charles Villard Date: Wed, 6 Dec 2023 07:13:15 -0500 Subject: [PATCH 10/11] [@astrojs/rss] Quality-of-Life Improvement to `items` property-related error (#9299) * This commit addresses a quality-of-life concern when setting up a RSS feed when using collections. Specifically, it provides more context to the error message thrown when the object passed to the `items` property is missing any of the three required keys or if one of those keys is mistyped. * Add changeset * Update .changeset with properly formatted update structure @sarah11918 suggested a change to the verbiage that properly formatted the update detail in question. Accepting the suggestion. Co-authored-by: Sarah Rainsberger --------- Co-authored-by: Sarah Rainsberger --- .changeset/thirty-hairs-pump.md | 5 +++++ packages/astro-rss/src/index.ts | 17 +++++++++++++++-- 2 files changed, 20 insertions(+), 2 deletions(-) create mode 100644 .changeset/thirty-hairs-pump.md diff --git a/.changeset/thirty-hairs-pump.md b/.changeset/thirty-hairs-pump.md new file mode 100644 index 000000000000..acb4d1da23ee --- /dev/null +++ b/.changeset/thirty-hairs-pump.md @@ -0,0 +1,5 @@ +--- +'@astrojs/rss': patch +--- + +Improves the `@astrojs/rss` error message thrown when the object passed to the `items` property is missing any of the three required keys or if one of those keys is mistyped. diff --git a/packages/astro-rss/src/index.ts b/packages/astro-rss/src/index.ts index 48c5defe855c..738e696f39b6 100644 --- a/packages/astro-rss/src/index.ts +++ b/packages/astro-rss/src/index.ts @@ -110,8 +110,21 @@ async function validateRssOptions(rssOptions: RSSOptions) { [ `[RSS] Invalid or missing options:`, ...parsedResult.error.errors.map( - (zodError) => `${zodError.message} (${zodError.path.join('.')})` - ), + (zodError) => { + const path = zodError.path.join('.'); + const message = `${zodError.message} (${path})`; + const code = zodError.code; + + if (path === 'items' && code === 'invalid_union') { + return [ + message, + `The \`items\` property requires properly typed \`title\`, \`pubDate\`, and \`link\` keys.`, + `Check your collection's schema, and visit https://docs.astro.build/en/guides/rss/#generating-items for more info.` + ].join('\n') + } + + return message; + }), ].join('\n') ); throw formattedError; From 58d643bcd8e7ecbef5352d28054669a63b9cfa9e Mon Sep 17 00:00:00 2001 From: Charles Villard Date: Wed, 6 Dec 2023 12:14:25 +0000 Subject: [PATCH 11/11] [ci] format --- packages/astro-rss/src/index.ts | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/packages/astro-rss/src/index.ts b/packages/astro-rss/src/index.ts index 738e696f39b6..c8cf19d6022e 100644 --- a/packages/astro-rss/src/index.ts +++ b/packages/astro-rss/src/index.ts @@ -109,22 +109,21 @@ async function validateRssOptions(rssOptions: RSSOptions) { const formattedError = new Error( [ `[RSS] Invalid or missing options:`, - ...parsedResult.error.errors.map( - (zodError) => { - const path = zodError.path.join('.'); - const message = `${zodError.message} (${path})`; - const code = zodError.code; + ...parsedResult.error.errors.map((zodError) => { + const path = zodError.path.join('.'); + const message = `${zodError.message} (${path})`; + const code = zodError.code; - if (path === 'items' && code === 'invalid_union') { - return [ - message, + if (path === 'items' && code === 'invalid_union') { + return [ + message, `The \`items\` property requires properly typed \`title\`, \`pubDate\`, and \`link\` keys.`, - `Check your collection's schema, and visit https://docs.astro.build/en/guides/rss/#generating-items for more info.` - ].join('\n') - } + `Check your collection's schema, and visit https://docs.astro.build/en/guides/rss/#generating-items for more info.`, + ].join('\n'); + } - return message; - }), + return message; + }), ].join('\n') ); throw formattedError;