From 30cf82ac3e970a6a3c0f07db1340dd7152d1c35d Mon Sep 17 00:00:00 2001 From: Robert van Hoesel Date: Tue, 23 Apr 2024 22:52:55 +0200 Subject: [PATCH 001/151] Prevents inputs from changing ViewTransitions' form method or action (#10856) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Prevents inputs from changing ViewTransitions' form method or action. Fixes #10849 * Consistency 🧘‍♂️ --- .changeset/tasty-swans-refuse.md | 5 +++++ .../astro/components/ViewTransitions.astro | 11 +++++++++-- .../src/pages/form-seven.astro | 11 +++++++++++ .../view-transitions/src/pages/form-six.astro | 11 +++++++++++ packages/astro/e2e/view-transitions.test.js | 19 +++++++++++++++++++ 5 files changed, 55 insertions(+), 2 deletions(-) create mode 100644 .changeset/tasty-swans-refuse.md create mode 100644 packages/astro/e2e/fixtures/view-transitions/src/pages/form-seven.astro create mode 100644 packages/astro/e2e/fixtures/view-transitions/src/pages/form-six.astro diff --git a/.changeset/tasty-swans-refuse.md b/.changeset/tasty-swans-refuse.md new file mode 100644 index 000000000000..8a8d6dde5732 --- /dev/null +++ b/.changeset/tasty-swans-refuse.md @@ -0,0 +1,5 @@ +--- +"astro": patch +--- + +Prevents inputs with a name attribute of action or method to break ViewTransitions' form submission diff --git a/packages/astro/components/ViewTransitions.astro b/packages/astro/components/ViewTransitions.astro index c33d9a3f5f2f..84a68d61e6f9 100644 --- a/packages/astro/components/ViewTransitions.astro +++ b/packages/astro/components/ViewTransitions.astro @@ -108,9 +108,16 @@ const { fallback = 'animate' } = Astro.props; const form = el as HTMLFormElement; const submitter = ev.submitter; const formData = new FormData(form, submitter); + // form.action and form.method can point to an or + // in which case should fallback to the form attribute + const formAction = + typeof form.action === 'string' ? form.action : form.getAttribute('action'); + const formMethod = + typeof form.method === 'string' ? form.method : form.getAttribute('method'); // Use the form action, if defined, otherwise fallback to current path. - let action = submitter?.getAttribute('formaction') ?? form.action ?? location.pathname; - const method = submitter?.getAttribute('formmethod') ?? form.method; + let action = submitter?.getAttribute('formaction') ?? formAction ?? location.pathname; + // Use the form method, if defined, otherwise fallback to "get" + const method = submitter?.getAttribute('formmethod') ?? formMethod ?? 'get'; // the "dialog" method is a special keyword used within elements // https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#attr-fs-method diff --git a/packages/astro/e2e/fixtures/view-transitions/src/pages/form-seven.astro b/packages/astro/e2e/fixtures/view-transitions/src/pages/form-seven.astro new file mode 100644 index 000000000000..71befd924782 --- /dev/null +++ b/packages/astro/e2e/fixtures/view-transitions/src/pages/form-seven.astro @@ -0,0 +1,11 @@ +--- +import Layout from '../components/Layout.astro'; + +--- + +
+

This form has an no method defined, but input with `name=method`

+ + +
+
diff --git a/packages/astro/e2e/fixtures/view-transitions/src/pages/form-six.astro b/packages/astro/e2e/fixtures/view-transitions/src/pages/form-six.astro new file mode 100644 index 000000000000..699fb1842a9f --- /dev/null +++ b/packages/astro/e2e/fixtures/view-transitions/src/pages/form-six.astro @@ -0,0 +1,11 @@ +--- +import Layout from '../components/Layout.astro'; + +--- + +
+

This form has an input with `name=action`

+ + +
+
diff --git a/packages/astro/e2e/view-transitions.test.js b/packages/astro/e2e/view-transitions.test.js index ef76010a5871..5e2ea0acebc0 100644 --- a/packages/astro/e2e/view-transitions.test.js +++ b/packages/astro/e2e/view-transitions.test.js @@ -1168,6 +1168,25 @@ test.describe('View Transitions', () => { ).toEqual(['application/x-www-form-urlencoded']); }); + + test('form POST that includes an input with name action should not override action', async ({ page, astro }) => { + await page.goto(astro.resolveUrl('/form-six')); + page.on('request', (request) => { + expect(request.url()).toContain('/bar') + }); + // Submit the form + await page.click('#submit'); + }); + + test('form without method that includes an input with name method should not override default method', async ({ page, astro }) => { + await page.goto(astro.resolveUrl('/form-seven')); + page.on('request', (request) => { + expect(request.method()).toBe('GET') + }); + // Submit the form + await page.click('#submit'); + }); + test('Route announcer is invisible on page transition', async ({ page, astro }) => { await page.goto(astro.resolveUrl('/no-directive-one')); From 9326531333016f15e7d8338b2888cb734ef85d60 Mon Sep 17 00:00:00 2001 From: Robert van Hoesel Date: Tue, 23 Apr 2024 20:53:46 +0000 Subject: [PATCH 002/151] [ci] format --- packages/astro/e2e/view-transitions.test.js | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/packages/astro/e2e/view-transitions.test.js b/packages/astro/e2e/view-transitions.test.js index 5e2ea0acebc0..0913380c6377 100644 --- a/packages/astro/e2e/view-transitions.test.js +++ b/packages/astro/e2e/view-transitions.test.js @@ -1168,20 +1168,25 @@ test.describe('View Transitions', () => { ).toEqual(['application/x-www-form-urlencoded']); }); - - test('form POST that includes an input with name action should not override action', async ({ page, astro }) => { + test('form POST that includes an input with name action should not override action', async ({ + page, + astro, + }) => { await page.goto(astro.resolveUrl('/form-six')); page.on('request', (request) => { - expect(request.url()).toContain('/bar') + expect(request.url()).toContain('/bar'); }); // Submit the form await page.click('#submit'); }); - test('form without method that includes an input with name method should not override default method', async ({ page, astro }) => { + test('form without method that includes an input with name method should not override default method', async ({ + page, + astro, + }) => { await page.goto(astro.resolveUrl('/form-seven')); page.on('request', (request) => { - expect(request.method()).toBe('GET') + expect(request.method()).toBe('GET'); }); // Submit the form await page.click('#submit'); From f6bddd3a155cd10a9f85c92d43b1af8b74786a42 Mon Sep 17 00:00:00 2001 From: Lam <150060045+lamATnginx@users.noreply.github.com> Date: Tue, 23 Apr 2024 14:29:38 -0700 Subject: [PATCH 003/151] fix: allow redoc to render on react components (#10855) * fix: removed redoc from noExternal for react * Add changeset --------- Co-authored-by: Matthew Phillips --- .changeset/metal-walls-fly.md | 5 +++++ packages/integrations/react/src/index.ts | 1 - 2 files changed, 5 insertions(+), 1 deletion(-) create mode 100644 .changeset/metal-walls-fly.md diff --git a/.changeset/metal-walls-fly.md b/.changeset/metal-walls-fly.md new file mode 100644 index 000000000000..fb906acc4e8e --- /dev/null +++ b/.changeset/metal-walls-fly.md @@ -0,0 +1,5 @@ +--- +"@astrojs/react": patch +--- + +Fix Redoc usage in React integration diff --git a/packages/integrations/react/src/index.ts b/packages/integrations/react/src/index.ts index c6bf1a200ff5..e0149e8e76c1 100644 --- a/packages/integrations/react/src/index.ts +++ b/packages/integrations/react/src/index.ts @@ -82,7 +82,6 @@ function getViteConfiguration({ '@mui/material', '@mui/base', '@babel/runtime', - 'redoc', 'use-immer', '@material-tailwind/react', ], From a94046588cce2d34ce4bd0c935f580d0616ab5b2 Mon Sep 17 00:00:00 2001 From: "Houston (Bot)" <108291165+astrobot-houston@users.noreply.github.com> Date: Tue, 23 Apr 2024 16:30:37 -0700 Subject: [PATCH 004/151] [ci] release (#10842) Co-authored-by: github-actions[bot] --- .changeset/bright-chefs-develop.md | 5 -- .changeset/metal-walls-fly.md | 5 -- .changeset/spotty-dots-beg.md | 5 -- .changeset/sweet-coins-shop.md | 5 -- .changeset/tasty-swans-refuse.md | 5 -- .changeset/thick-wasps-know.md | 7 --- .changeset/thirty-walls-yell.md | 15 ----- .changeset/weak-swans-sparkle.md | 5 -- .changeset/wet-apples-accept.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 | 4 +- 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/view-transitions/package.json | 2 +- examples/with-markdoc/package.json | 4 +- 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 | 24 ++++++++ packages/astro/package.json | 2 +- packages/db/CHANGELOG.md | 6 ++ packages/db/package.json | 2 +- packages/integrations/markdoc/CHANGELOG.md | 10 ++++ packages/integrations/markdoc/package.json | 2 +- packages/integrations/partytown/CHANGELOG.md | 6 ++ packages/integrations/partytown/package.json | 2 +- packages/integrations/react/CHANGELOG.md | 6 ++ packages/integrations/react/package.json | 2 +- packages/integrations/vercel/CHANGELOG.md | 6 ++ packages/integrations/vercel/package.json | 2 +- pnpm-lock.yaml | 61 ++++++++++---------- 49 files changed, 125 insertions(+), 123 deletions(-) delete mode 100644 .changeset/bright-chefs-develop.md delete mode 100644 .changeset/metal-walls-fly.md delete mode 100644 .changeset/spotty-dots-beg.md delete mode 100644 .changeset/sweet-coins-shop.md delete mode 100644 .changeset/tasty-swans-refuse.md delete mode 100644 .changeset/thick-wasps-know.md delete mode 100644 .changeset/thirty-walls-yell.md delete mode 100644 .changeset/weak-swans-sparkle.md delete mode 100644 .changeset/wet-apples-accept.md diff --git a/.changeset/bright-chefs-develop.md b/.changeset/bright-chefs-develop.md deleted file mode 100644 index b0078e085d25..000000000000 --- a/.changeset/bright-chefs-develop.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -"@astrojs/markdoc": minor ---- - -Updates `@markdoc/markdoc` to v0.4 diff --git a/.changeset/metal-walls-fly.md b/.changeset/metal-walls-fly.md deleted file mode 100644 index fb906acc4e8e..000000000000 --- a/.changeset/metal-walls-fly.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -"@astrojs/react": patch ---- - -Fix Redoc usage in React integration diff --git a/.changeset/spotty-dots-beg.md b/.changeset/spotty-dots-beg.md deleted file mode 100644 index 91a7c8526adf..000000000000 --- a/.changeset/spotty-dots-beg.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -"@astrojs/db": patch ---- - -Add `astro login` support from online editors like Stackblitz and GitHub Codespaces diff --git a/.changeset/sweet-coins-shop.md b/.changeset/sweet-coins-shop.md deleted file mode 100644 index 02d69af15c6e..000000000000 --- a/.changeset/sweet-coins-shop.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -"astro": patch ---- - -Prevent getCollection breaking in vitest diff --git a/.changeset/tasty-swans-refuse.md b/.changeset/tasty-swans-refuse.md deleted file mode 100644 index 8a8d6dde5732..000000000000 --- a/.changeset/tasty-swans-refuse.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -"astro": patch ---- - -Prevents inputs with a name attribute of action or method to break ViewTransitions' form submission diff --git a/.changeset/thick-wasps-know.md b/.changeset/thick-wasps-know.md deleted file mode 100644 index 855a9c7b72b8..000000000000 --- a/.changeset/thick-wasps-know.md +++ /dev/null @@ -1,7 +0,0 @@ ---- -"@astrojs/markdoc": patch -"@astrojs/vercel": patch -"astro": patch ---- - -Updates `esbuild` dependency to v0.20. This should not affect projects in most cases. diff --git a/.changeset/thirty-walls-yell.md b/.changeset/thirty-walls-yell.md deleted file mode 100644 index 8e63d6e1cfeb..000000000000 --- a/.changeset/thirty-walls-yell.md +++ /dev/null @@ -1,15 +0,0 @@ ---- -"astro": patch ---- - -Fixes an issue where images in MD required a relative specifier (e.g. `./`) - -Now, you can use the standard `![](relative/img.png)` syntax in MD files for images colocated in the same folder: no relative specifier required! - -There is no need to update your project; your existing images will still continue to work. However, you may wish to remove any relative specifiers from these MD images as they are no longer necessary: - -```diff -- ![A cute dog](./dog.jpg) -+ ![A cute dog](dog.jpg) - -``` diff --git a/.changeset/weak-swans-sparkle.md b/.changeset/weak-swans-sparkle.md deleted file mode 100644 index ee99d8bc705b..000000000000 --- a/.changeset/weak-swans-sparkle.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -"astro": patch ---- - -Due to regression on mobile WebKit browsers, reverts a change made for JavaScript animations during view transitions. diff --git a/.changeset/wet-apples-accept.md b/.changeset/wet-apples-accept.md deleted file mode 100644 index 97420fbf3330..000000000000 --- a/.changeset/wet-apples-accept.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -"@astrojs/partytown": minor ---- - -Updates the `@builder.io/partytown` dependency to v0.10. This should not affect projects in most cases. diff --git a/examples/basics/package.json b/examples/basics/package.json index 02522acb7a68..6939c16fddf8 100644 --- a/examples/basics/package.json +++ b/examples/basics/package.json @@ -11,6 +11,6 @@ "astro": "astro" }, "dependencies": { - "astro": "^4.6.3" + "astro": "^4.6.4" } } diff --git a/examples/blog/package.json b/examples/blog/package.json index 072a6a331779..4e092776e5d8 100644 --- a/examples/blog/package.json +++ b/examples/blog/package.json @@ -14,6 +14,6 @@ "@astrojs/mdx": "^2.3.1", "@astrojs/rss": "^4.0.5", "@astrojs/sitemap": "^3.1.4", - "astro": "^4.6.3" + "astro": "^4.6.4" } } diff --git a/examples/component/package.json b/examples/component/package.json index bcfcb66ac8d8..e8dfba6f36ce 100644 --- a/examples/component/package.json +++ b/examples/component/package.json @@ -15,7 +15,7 @@ ], "scripts": {}, "devDependencies": { - "astro": "^4.6.3" + "astro": "^4.6.4" }, "peerDependencies": { "astro": "^4.0.0" diff --git a/examples/framework-alpine/package.json b/examples/framework-alpine/package.json index f6639d87d714..a5c4aff455a2 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.5", "alpinejs": "^3.13.3", - "astro": "^4.6.3" + "astro": "^4.6.4" } } diff --git a/examples/framework-lit/package.json b/examples/framework-lit/package.json index 3c70813b7588..987cbb8c8e30 100644 --- a/examples/framework-lit/package.json +++ b/examples/framework-lit/package.json @@ -13,7 +13,7 @@ "dependencies": { "@astrojs/lit": "^4.0.1", "@webcomponents/template-shadowroot": "^0.2.1", - "astro": "^4.6.3", + "astro": "^4.6.4", "lit": "^3.1.2" } } diff --git a/examples/framework-multiple/package.json b/examples/framework-multiple/package.json index b0fd48b55ba5..80113b6df40d 100644 --- a/examples/framework-multiple/package.json +++ b/examples/framework-multiple/package.json @@ -12,13 +12,13 @@ }, "dependencies": { "@astrojs/preact": "^3.2.0", - "@astrojs/react": "^3.3.0", + "@astrojs/react": "^3.3.1", "@astrojs/solid-js": "^4.1.0", "@astrojs/svelte": "^5.4.0", "@astrojs/vue": "^4.1.0", "@types/react": "^18.2.37", "@types/react-dom": "^18.2.15", - "astro": "^4.6.3", + "astro": "^4.6.4", "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 657eaf8bb5aa..b19748ff250e 100644 --- a/examples/framework-preact/package.json +++ b/examples/framework-preact/package.json @@ -13,7 +13,7 @@ "dependencies": { "@astrojs/preact": "^3.2.0", "@preact/signals": "^1.2.1", - "astro": "^4.6.3", + "astro": "^4.6.4", "preact": "^10.19.2" } } diff --git a/examples/framework-react/package.json b/examples/framework-react/package.json index b96a70e073f0..a291d122295d 100644 --- a/examples/framework-react/package.json +++ b/examples/framework-react/package.json @@ -11,10 +11,10 @@ "astro": "astro" }, "dependencies": { - "@astrojs/react": "^3.3.0", + "@astrojs/react": "^3.3.1", "@types/react": "^18.2.37", "@types/react-dom": "^18.2.15", - "astro": "^4.6.3", + "astro": "^4.6.4", "react": "^18.2.0", "react-dom": "^18.2.0" } diff --git a/examples/framework-solid/package.json b/examples/framework-solid/package.json index 410555d9f6bc..6b6a13de5722 100644 --- a/examples/framework-solid/package.json +++ b/examples/framework-solid/package.json @@ -12,7 +12,7 @@ }, "dependencies": { "@astrojs/solid-js": "^4.1.0", - "astro": "^4.6.3", + "astro": "^4.6.4", "solid-js": "^1.8.5" } } diff --git a/examples/framework-svelte/package.json b/examples/framework-svelte/package.json index 9a37664b2ecb..3eaaf67fb676 100644 --- a/examples/framework-svelte/package.json +++ b/examples/framework-svelte/package.json @@ -12,7 +12,7 @@ }, "dependencies": { "@astrojs/svelte": "^5.4.0", - "astro": "^4.6.3", + "astro": "^4.6.4", "svelte": "^4.2.5" } } diff --git a/examples/framework-vue/package.json b/examples/framework-vue/package.json index b7a1e49e9959..5ff7026d1e71 100644 --- a/examples/framework-vue/package.json +++ b/examples/framework-vue/package.json @@ -12,7 +12,7 @@ }, "dependencies": { "@astrojs/vue": "^4.1.0", - "astro": "^4.6.3", + "astro": "^4.6.4", "vue": "^3.3.8" } } diff --git a/examples/hackernews/package.json b/examples/hackernews/package.json index a7ea4297ae75..0abad55532c5 100644 --- a/examples/hackernews/package.json +++ b/examples/hackernews/package.json @@ -12,6 +12,6 @@ }, "dependencies": { "@astrojs/node": "^8.2.5", - "astro": "^4.6.3" + "astro": "^4.6.4" } } diff --git a/examples/integration/package.json b/examples/integration/package.json index 7121e8c347b5..295947d1ec92 100644 --- a/examples/integration/package.json +++ b/examples/integration/package.json @@ -15,7 +15,7 @@ ], "scripts": {}, "devDependencies": { - "astro": "^4.6.3" + "astro": "^4.6.4" }, "peerDependencies": { "astro": "^4.0.0" diff --git a/examples/middleware/package.json b/examples/middleware/package.json index 1d84d858045d..7c872f2b2d29 100644 --- a/examples/middleware/package.json +++ b/examples/middleware/package.json @@ -13,7 +13,7 @@ }, "dependencies": { "@astrojs/node": "^8.2.5", - "astro": "^4.6.3", + "astro": "^4.6.4", "html-minifier": "^4.0.0" }, "devDependencies": { diff --git a/examples/minimal/package.json b/examples/minimal/package.json index 8b3a8dfedbc4..b350ff3efed8 100644 --- a/examples/minimal/package.json +++ b/examples/minimal/package.json @@ -11,6 +11,6 @@ "astro": "astro" }, "dependencies": { - "astro": "^4.6.3" + "astro": "^4.6.4" } } diff --git a/examples/non-html-pages/package.json b/examples/non-html-pages/package.json index 884f8d7591af..34a84ff56545 100644 --- a/examples/non-html-pages/package.json +++ b/examples/non-html-pages/package.json @@ -11,6 +11,6 @@ "astro": "astro" }, "dependencies": { - "astro": "^4.6.3" + "astro": "^4.6.4" } } diff --git a/examples/portfolio/package.json b/examples/portfolio/package.json index 3af8adde6a83..e2facb815381 100644 --- a/examples/portfolio/package.json +++ b/examples/portfolio/package.json @@ -11,6 +11,6 @@ "astro": "astro" }, "dependencies": { - "astro": "^4.6.3" + "astro": "^4.6.4" } } diff --git a/examples/ssr/package.json b/examples/ssr/package.json index 8ebd90fd163b..eb5e2ab4bc48 100644 --- a/examples/ssr/package.json +++ b/examples/ssr/package.json @@ -14,7 +14,7 @@ "dependencies": { "@astrojs/node": "^8.2.5", "@astrojs/svelte": "^5.4.0", - "astro": "^4.6.3", + "astro": "^4.6.4", "svelte": "^4.2.5" } } diff --git a/examples/starlog/package.json b/examples/starlog/package.json index 0778ec8f8820..7668d0d76127 100644 --- a/examples/starlog/package.json +++ b/examples/starlog/package.json @@ -10,7 +10,7 @@ "astro": "astro" }, "dependencies": { - "astro": "^4.6.3", + "astro": "^4.6.4", "sass": "^1.69.5", "sharp": "^0.32.6" } diff --git a/examples/view-transitions/package.json b/examples/view-transitions/package.json index 61865cdee016..116bcad529ef 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.2.5", - "astro": "^4.6.3" + "astro": "^4.6.4" } } diff --git a/examples/with-markdoc/package.json b/examples/with-markdoc/package.json index 085a5b1b9305..1ac4e0761ffb 100644 --- a/examples/with-markdoc/package.json +++ b/examples/with-markdoc/package.json @@ -11,7 +11,7 @@ "astro": "astro" }, "dependencies": { - "@astrojs/markdoc": "^0.10.0", - "astro": "^4.6.3" + "@astrojs/markdoc": "^0.11.0", + "astro": "^4.6.4" } } diff --git a/examples/with-markdown-plugins/package.json b/examples/with-markdown-plugins/package.json index 095b2e5d69c2..34a17734dce3 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.6.3", + "astro": "^4.6.4", "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 e06edaee9fe8..257d3b09fae9 100644 --- a/examples/with-markdown-shiki/package.json +++ b/examples/with-markdown-shiki/package.json @@ -11,6 +11,6 @@ "astro": "astro" }, "dependencies": { - "astro": "^4.6.3" + "astro": "^4.6.4" } } diff --git a/examples/with-mdx/package.json b/examples/with-mdx/package.json index 056c1ad1aa7f..5725e958bd6d 100644 --- a/examples/with-mdx/package.json +++ b/examples/with-mdx/package.json @@ -13,7 +13,7 @@ "dependencies": { "@astrojs/mdx": "^2.3.1", "@astrojs/preact": "^3.2.0", - "astro": "^4.6.3", + "astro": "^4.6.4", "preact": "^10.19.2" } } diff --git a/examples/with-nanostores/package.json b/examples/with-nanostores/package.json index 4c3093f01df0..328eb997115b 100644 --- a/examples/with-nanostores/package.json +++ b/examples/with-nanostores/package.json @@ -13,7 +13,7 @@ "dependencies": { "@astrojs/preact": "^3.2.0", "@nanostores/preact": "^0.5.0", - "astro": "^4.6.3", + "astro": "^4.6.4", "nanostores": "^0.9.5", "preact": "^10.19.2" } diff --git a/examples/with-tailwindcss/package.json b/examples/with-tailwindcss/package.json index b0322860f62f..ba725f89c6e3 100644 --- a/examples/with-tailwindcss/package.json +++ b/examples/with-tailwindcss/package.json @@ -14,7 +14,7 @@ "@astrojs/mdx": "^2.3.1", "@astrojs/tailwind": "^5.1.0", "@types/canvas-confetti": "^1.6.3", - "astro": "^4.6.3", + "astro": "^4.6.4", "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 989f1a301a27..a1d0ee1b9540 100644 --- a/examples/with-vitest/package.json +++ b/examples/with-vitest/package.json @@ -12,7 +12,7 @@ "test": "vitest" }, "dependencies": { - "astro": "^4.6.3", + "astro": "^4.6.4", "vitest": "^1.5.0" } } diff --git a/packages/astro/CHANGELOG.md b/packages/astro/CHANGELOG.md index 2cf022a65824..5561b785ff04 100644 --- a/packages/astro/CHANGELOG.md +++ b/packages/astro/CHANGELOG.md @@ -1,5 +1,29 @@ # astro +## 4.6.4 + +### Patch Changes + +- [#10846](https://github.com/withastro/astro/pull/10846) [`3294f7a`](https://github.com/withastro/astro/commit/3294f7a343e036d2ad9ac8d5f792ad0d4f43a399) Thanks [@matthewp](https://github.com/matthewp)! - Prevent getCollection breaking in vitest + +- [#10856](https://github.com/withastro/astro/pull/10856) [`30cf82a`](https://github.com/withastro/astro/commit/30cf82ac3e970a6a3c0f07db1340dd7152d1c35d) Thanks [@robertvanhoesel](https://github.com/robertvanhoesel)! - Prevents inputs with a name attribute of action or method to break ViewTransitions' form submission + +- [#10833](https://github.com/withastro/astro/pull/10833) [`8d5f3e8`](https://github.com/withastro/astro/commit/8d5f3e8656027023f9fda51c66b0213ffe16d3a5) Thanks [@renovate](https://github.com/apps/renovate)! - Updates `esbuild` dependency to v0.20. This should not affect projects in most cases. + +- [#10801](https://github.com/withastro/astro/pull/10801) [`204b782`](https://github.com/withastro/astro/commit/204b7820e6de22d97fa2a7b988180c42155c8387) Thanks [@rishi-raj-jain](https://github.com/rishi-raj-jain)! - Fixes an issue where images in MD required a relative specifier (e.g. `./`) + + Now, you can use the standard `![](relative/img.png)` syntax in MD files for images colocated in the same folder: no relative specifier required! + + There is no need to update your project; your existing images will still continue to work. However, you may wish to remove any relative specifiers from these MD images as they are no longer necessary: + + ```diff + - ![A cute dog](./dog.jpg) + + ![A cute dog](dog.jpg) + + ``` + +- [#10841](https://github.com/withastro/astro/pull/10841) [`a2df344`](https://github.com/withastro/astro/commit/a2df344bff15647c2bfb3f49e3f7b66aa069d6f4) Thanks [@martrapp](https://github.com/martrapp)! - Due to regression on mobile WebKit browsers, reverts a change made for JavaScript animations during view transitions. + ## 4.6.3 ### Patch Changes diff --git a/packages/astro/package.json b/packages/astro/package.json index a8d882489230..b28c73403c83 100644 --- a/packages/astro/package.json +++ b/packages/astro/package.json @@ -1,6 +1,6 @@ { "name": "astro", - "version": "4.6.3", + "version": "4.6.4", "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/db/CHANGELOG.md b/packages/db/CHANGELOG.md index b909fffe0aac..2b89cae73ccc 100644 --- a/packages/db/CHANGELOG.md +++ b/packages/db/CHANGELOG.md @@ -1,5 +1,11 @@ # @astrojs/db +## 0.10.6 + +### Patch Changes + +- [#10816](https://github.com/withastro/astro/pull/10816) [`8e6eb62`](https://github.com/withastro/astro/commit/8e6eb624aee40bac66a58169a30107f624a8c539) Thanks [@bholmesdev](https://github.com/bholmesdev)! - Add `astro login` support from online editors like Stackblitz and GitHub Codespaces + ## 0.10.5 ### Patch Changes diff --git a/packages/db/package.json b/packages/db/package.json index 6b7357dca527..ac6b8a8053b8 100644 --- a/packages/db/package.json +++ b/packages/db/package.json @@ -1,6 +1,6 @@ { "name": "@astrojs/db", - "version": "0.10.5", + "version": "0.10.6", "description": "Add libSQL and Astro Studio support to your Astro site", "license": "MIT", "repository": { diff --git a/packages/integrations/markdoc/CHANGELOG.md b/packages/integrations/markdoc/CHANGELOG.md index 83f7dae2fd93..b99674d424ec 100644 --- a/packages/integrations/markdoc/CHANGELOG.md +++ b/packages/integrations/markdoc/CHANGELOG.md @@ -1,5 +1,15 @@ # @astrojs/markdoc +## 0.11.0 + +### Minor Changes + +- [#10833](https://github.com/withastro/astro/pull/10833) [`8d5f3e8`](https://github.com/withastro/astro/commit/8d5f3e8656027023f9fda51c66b0213ffe16d3a5) Thanks [@renovate](https://github.com/apps/renovate)! - Updates `@markdoc/markdoc` to v0.4 + +### Patch Changes + +- [#10833](https://github.com/withastro/astro/pull/10833) [`8d5f3e8`](https://github.com/withastro/astro/commit/8d5f3e8656027023f9fda51c66b0213ffe16d3a5) Thanks [@renovate](https://github.com/apps/renovate)! - Updates `esbuild` dependency to v0.20. This should not affect projects in most cases. + ## 0.10.0 ### Minor Changes diff --git a/packages/integrations/markdoc/package.json b/packages/integrations/markdoc/package.json index ab0e1930103b..acb7720eb255 100644 --- a/packages/integrations/markdoc/package.json +++ b/packages/integrations/markdoc/package.json @@ -1,7 +1,7 @@ { "name": "@astrojs/markdoc", "description": "Add support for Markdoc in your Astro site", - "version": "0.10.0", + "version": "0.11.0", "type": "module", "types": "./dist/index.d.ts", "author": "withastro", diff --git a/packages/integrations/partytown/CHANGELOG.md b/packages/integrations/partytown/CHANGELOG.md index 51490a593b94..1d2e86938aac 100644 --- a/packages/integrations/partytown/CHANGELOG.md +++ b/packages/integrations/partytown/CHANGELOG.md @@ -1,5 +1,11 @@ # @astrojs/partytown +## 2.1.0 + +### Minor Changes + +- [#10833](https://github.com/withastro/astro/pull/10833) [`8d5f3e8`](https://github.com/withastro/astro/commit/8d5f3e8656027023f9fda51c66b0213ffe16d3a5) Thanks [@renovate](https://github.com/apps/renovate)! - Updates the `@builder.io/partytown` dependency to v0.10. This should not affect projects in most cases. + ## 2.0.4 ### Patch Changes diff --git a/packages/integrations/partytown/package.json b/packages/integrations/partytown/package.json index 065ed78c4d55..74381e85f57a 100644 --- a/packages/integrations/partytown/package.json +++ b/packages/integrations/partytown/package.json @@ -1,7 +1,7 @@ { "name": "@astrojs/partytown", "description": "Use Partytown to move scripts into a web worker in your Astro project", - "version": "2.0.4", + "version": "2.1.0", "type": "module", "types": "./dist/index.d.ts", "author": "withastro", diff --git a/packages/integrations/react/CHANGELOG.md b/packages/integrations/react/CHANGELOG.md index aa8f833b6e08..b1664f60123c 100644 --- a/packages/integrations/react/CHANGELOG.md +++ b/packages/integrations/react/CHANGELOG.md @@ -1,5 +1,11 @@ # @astrojs/react +## 3.3.1 + +### Patch Changes + +- [#10855](https://github.com/withastro/astro/pull/10855) [`f6bddd3`](https://github.com/withastro/astro/commit/f6bddd3a155cd10a9f85c92d43b1af8b74786a42) Thanks [@lamATnginx](https://github.com/lamATnginx)! - Fix Redoc usage in React integration + ## 3.3.0 ### Minor Changes diff --git a/packages/integrations/react/package.json b/packages/integrations/react/package.json index 3fe01d49fb14..a3213503a318 100644 --- a/packages/integrations/react/package.json +++ b/packages/integrations/react/package.json @@ -1,7 +1,7 @@ { "name": "@astrojs/react", "description": "Use React components within Astro", - "version": "3.3.0", + "version": "3.3.1", "type": "module", "types": "./dist/index.d.ts", "author": "withastro", diff --git a/packages/integrations/vercel/CHANGELOG.md b/packages/integrations/vercel/CHANGELOG.md index 9b7d2ff51c82..12ce0a3c257b 100644 --- a/packages/integrations/vercel/CHANGELOG.md +++ b/packages/integrations/vercel/CHANGELOG.md @@ -1,5 +1,11 @@ # @astrojs/vercel +## 7.5.4 + +### Patch Changes + +- [#10833](https://github.com/withastro/astro/pull/10833) [`8d5f3e8`](https://github.com/withastro/astro/commit/8d5f3e8656027023f9fda51c66b0213ffe16d3a5) Thanks [@renovate](https://github.com/apps/renovate)! - Updates `esbuild` dependency to v0.20. This should not affect projects in most cases. + ## 7.5.3 ### Patch Changes diff --git a/packages/integrations/vercel/package.json b/packages/integrations/vercel/package.json index 0e1ea59adf5d..f826f5b8d7e4 100644 --- a/packages/integrations/vercel/package.json +++ b/packages/integrations/vercel/package.json @@ -1,7 +1,7 @@ { "name": "@astrojs/vercel", "description": "Deploy your site to Vercel", - "version": "7.5.3", + "version": "7.5.4", "type": "module", "author": "withastro", "license": "MIT", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 15bc13293cdf..f4f5d9cb6729 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -134,7 +134,7 @@ importers: examples/basics: dependencies: astro: - specifier: ^4.6.3 + specifier: ^4.6.4 version: link:../../packages/astro examples/blog: @@ -149,13 +149,13 @@ importers: specifier: ^3.1.4 version: link:../../packages/integrations/sitemap astro: - specifier: ^4.6.3 + specifier: ^4.6.4 version: link:../../packages/astro examples/component: devDependencies: astro: - specifier: ^4.6.3 + specifier: ^4.6.4 version: link:../../packages/astro examples/framework-alpine: @@ -170,7 +170,7 @@ importers: specifier: ^3.13.3 version: 3.13.8 astro: - specifier: ^4.6.3 + specifier: ^4.6.4 version: link:../../packages/astro examples/framework-lit: @@ -182,7 +182,7 @@ importers: specifier: ^0.2.1 version: 0.2.1 astro: - specifier: ^4.6.3 + specifier: ^4.6.4 version: link:../../packages/astro lit: specifier: ^3.1.2 @@ -194,7 +194,7 @@ importers: specifier: ^3.2.0 version: link:../../packages/integrations/preact '@astrojs/react': - specifier: ^3.3.0 + specifier: ^3.3.1 version: link:../../packages/integrations/react '@astrojs/solid-js': specifier: ^4.1.0 @@ -212,7 +212,7 @@ importers: specifier: ^18.2.15 version: 18.2.25 astro: - specifier: ^4.6.3 + specifier: ^4.6.4 version: link:../../packages/astro preact: specifier: ^10.19.2 @@ -242,7 +242,7 @@ importers: specifier: ^1.2.1 version: 1.2.1(preact@10.20.2) astro: - specifier: ^4.6.3 + specifier: ^4.6.4 version: link:../../packages/astro preact: specifier: ^10.19.2 @@ -251,7 +251,7 @@ importers: examples/framework-react: dependencies: '@astrojs/react': - specifier: ^3.3.0 + specifier: ^3.3.1 version: link:../../packages/integrations/react '@types/react': specifier: ^18.2.37 @@ -260,7 +260,7 @@ importers: specifier: ^18.2.15 version: 18.2.25 astro: - specifier: ^4.6.3 + specifier: ^4.6.4 version: link:../../packages/astro react: specifier: ^18.2.0 @@ -275,7 +275,7 @@ importers: specifier: ^4.1.0 version: link:../../packages/integrations/solid astro: - specifier: ^4.6.3 + specifier: ^4.6.4 version: link:../../packages/astro solid-js: specifier: ^1.8.5 @@ -287,7 +287,7 @@ importers: specifier: ^5.4.0 version: link:../../packages/integrations/svelte astro: - specifier: ^4.6.3 + specifier: ^4.6.4 version: link:../../packages/astro svelte: specifier: ^4.2.5 @@ -299,7 +299,7 @@ importers: specifier: ^4.1.0 version: link:../../packages/integrations/vue astro: - specifier: ^4.6.3 + specifier: ^4.6.4 version: link:../../packages/astro vue: specifier: ^3.3.8 @@ -311,13 +311,13 @@ importers: specifier: ^8.2.5 version: link:../../packages/integrations/node astro: - specifier: ^4.6.3 + specifier: ^4.6.4 version: link:../../packages/astro examples/integration: devDependencies: astro: - specifier: ^4.6.3 + specifier: ^4.6.4 version: link:../../packages/astro examples/middleware: @@ -326,7 +326,7 @@ importers: specifier: ^8.2.5 version: link:../../packages/integrations/node astro: - specifier: ^4.6.3 + specifier: ^4.6.4 version: link:../../packages/astro html-minifier: specifier: ^4.0.0 @@ -339,19 +339,19 @@ importers: examples/minimal: dependencies: astro: - specifier: ^4.6.3 + specifier: ^4.6.4 version: link:../../packages/astro examples/non-html-pages: dependencies: astro: - specifier: ^4.6.3 + specifier: ^4.6.4 version: link:../../packages/astro examples/portfolio: dependencies: astro: - specifier: ^4.6.3 + specifier: ^4.6.4 version: link:../../packages/astro examples/ssr: @@ -363,7 +363,7 @@ importers: specifier: ^5.4.0 version: link:../../packages/integrations/svelte astro: - specifier: ^4.6.3 + specifier: ^4.6.4 version: link:../../packages/astro svelte: specifier: ^4.2.5 @@ -372,7 +372,7 @@ importers: examples/starlog: dependencies: astro: - specifier: ^4.6.3 + specifier: ^4.6.4 version: link:../../packages/astro sass: specifier: ^1.69.5 @@ -390,16 +390,16 @@ importers: specifier: ^5.1.0 version: link:../../packages/integrations/tailwind astro: - specifier: ^4.6.3 + specifier: ^4.6.4 version: link:../../packages/astro examples/with-markdoc: dependencies: '@astrojs/markdoc': - specifier: ^0.10.0 + specifier: ^0.11.0 version: link:../../packages/integrations/markdoc astro: - specifier: ^4.6.3 + specifier: ^4.6.4 version: link:../../packages/astro examples/with-markdown-plugins: @@ -408,7 +408,7 @@ importers: specifier: ^5.1.0 version: link:../../packages/markdown/remark astro: - specifier: ^4.6.3 + specifier: ^4.6.4 version: link:../../packages/astro hast-util-select: specifier: ^6.0.2 @@ -429,7 +429,7 @@ importers: examples/with-markdown-shiki: dependencies: astro: - specifier: ^4.6.3 + specifier: ^4.6.4 version: link:../../packages/astro examples/with-mdx: @@ -441,7 +441,7 @@ importers: specifier: ^3.2.0 version: link:../../packages/integrations/preact astro: - specifier: ^4.6.3 + specifier: ^4.6.4 version: link:../../packages/astro preact: specifier: ^10.19.2 @@ -456,7 +456,7 @@ importers: specifier: ^0.5.0 version: 0.5.1(nanostores@0.9.5)(preact@10.20.2) astro: - specifier: ^4.6.3 + specifier: ^4.6.4 version: link:../../packages/astro nanostores: specifier: ^0.9.5 @@ -477,7 +477,7 @@ importers: specifier: ^1.6.3 version: 1.6.4 astro: - specifier: ^4.6.3 + specifier: ^4.6.4 version: link:../../packages/astro autoprefixer: specifier: ^10.4.15 @@ -495,7 +495,7 @@ importers: examples/with-vitest: dependencies: astro: - specifier: ^4.6.3 + specifier: ^4.6.4 version: link:../../packages/astro vitest: specifier: ^1.5.0 @@ -15444,6 +15444,7 @@ packages: /string_decoder@1.3.0: resolution: {integrity: sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA==} + requiresBuild: true dependencies: safe-buffer: 5.2.1 dev: false From b673bc850593d5af25793d0358c00797477fa373 Mon Sep 17 00:00:00 2001 From: Ming-jun Lu <40516784+mingjunlu@users.noreply.github.com> Date: Wed, 24 Apr 2024 19:01:51 +0800 Subject: [PATCH 005/151] Fix an issue where `astro build` writes type declaration files to `outDir` (#10861) * Fix an issue where `astro build` also writes type declaration files to `outDir` * Add changeset --- .changeset/curvy-humans-judge.md | 5 +++++ packages/astro/src/core/build/static-build.ts | 7 +++++++ 2 files changed, 12 insertions(+) create mode 100644 .changeset/curvy-humans-judge.md diff --git a/.changeset/curvy-humans-judge.md b/.changeset/curvy-humans-judge.md new file mode 100644 index 000000000000..a9768726ce32 --- /dev/null +++ b/.changeset/curvy-humans-judge.md @@ -0,0 +1,5 @@ +--- +"astro": patch +--- + +Fixes an issue where `astro build` writes type declaration files to `outDir` when it's outside of root directory. diff --git a/packages/astro/src/core/build/static-build.ts b/packages/astro/src/core/build/static-build.ts index cdd24e1c0053..6e8fb0be4421 100644 --- a/packages/astro/src/core/build/static-build.ts +++ b/packages/astro/src/core/build/static-build.ts @@ -442,6 +442,13 @@ async function cleanServerOutput( // Clean out directly if the outDir is outside of root if (out.toString() !== opts.settings.config.outDir.toString()) { + // Remove .d.ts files + const fileNames = await fs.promises.readdir(out); + await Promise.all( + fileNames + .filter((fileName) => fileName.endsWith('.d.ts')) + .map((fileName) => fs.promises.rm(new URL(fileName, out))) + ); // Copy assets before cleaning directory if outside root await copyFiles(out, opts.settings.config.outDir, true); await fs.promises.rm(out, { recursive: true }); From 8b59d5d078ff40576b8cbee432279c6ad044a1a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Peter=20Dr=C3=A4xler?= Date: Wed, 24 Apr 2024 11:20:07 -0300 Subject: [PATCH 006/151] Update sharp to 0.33 to fix issue with Alpine Linux (#10684) * Update sharp to 0.33 to fix issue with Alpine Linux It was impossible for me to use the Astro image service in an Alpine Linux docker container. Even though I would install sharp `0.33.3` in my app, pnpm would download version `0.32.6`, which doesn't work in Alpine Linux container. Currently, I have to override the downloaded version in my package.json. For more details see: - https://github.com/lovell/sharp/issues/4054 - https://discord.com/channels/830184174198718474/1224861729792458803/1224861729792458803 This PR updates the version of the `sharp` dependency to `^0.33` and thus makes Astro compatible with Alpine Linux. * update lock file * add changelog * Update packages/astro/package.json * Update pnpm-lock.yaml * ci: update check-merge.yml action (#10690) * test(@astrojs/node) listen for server setup errors in test-utils (#10692) * Add disableremoteplayback attribute to VideoHTMLAttributes interface (#10693) * Add disableremoteplayback attribute to VideoHTMLAttributes interface * Move disableremoteplayback from VideoHTMLAttributes to MediaHTMLAttributes * Create olive-camels-greet.md * Update packages/astro/astro-jsx.d.ts --------- Co-authored-by: Erika <3019731+Princesseuh@users.noreply.github.com> * test(@astrojs/node) wait for server listening in trailing-slash tests (#10694) * test(@astrojs/node) wait for server listening in trailing-slash tests * fix missing waitServerListen * fix import statement --------- Co-authored-by: Emanuele Stoppa * chore: add `test:citgm` command that would run tests without caching and `build:ci:no-cache` to skip caching for build as well (#10696) * chore: add test:citgm command that would run tests without caching * adding build ci with no cache * chore: fix build:ci:no-cache test:citgm (#10698) * Improve dev toolbar notification contrast on hover (#10657) * fix(#10399, PLT-1786): improve notification contrast on hover * chore: add changeset * fix test:citgm --force flag not passed correctly (#10706) * Skip prerender chunk in static output (#10695) * Remove unused config in Vue JSX integration (#10687) * Refactor MDX transformJSX handling (#10688) * Fix vue-jsx change (#10716) * Fix script inline with directRenderScript (#10686) * Provide better messaging when renaming a table (#10600) * Provide better messaging when renaming a table * Update based on review * [ci] format * [ci] update lockfile (#10718) Co-authored-by: matthewp * Increase log severity when a page's `getStaticPaths` fails (#10707) * [ci] release (#10680) Co-authored-by: github-actions[bot] * fix: use just pnpm to run the build and tests in citgm (#10727) * fix(devtool): do not trigger interaction check for `div` and `span` (#10719) * fix(devtool): do not trigger interaction check for `div` and `span` * add test * add tests * Rephrase changeset * remove log * add reference link * Update .changeset/swift-coats-teach.md Co-authored-by: Florian Lefebvre --------- Co-authored-by: Florian Lefebvre * fix: regression for astro attributes escaping (#10728) * Fix db seeding when srcDir is root (#10720) * ci: add ref when checking out the repository (#10733) * fix(dev): break implicit rerouting loop (#10737) * fix(dev): infinite implicit rerouting * test adapter * changeset * [ci] format * [ci] release (#10729) Co-authored-by: github-actions[bot] * fix: Fixed errorOverlay theme toggle bug. (#10661) * fix: save `localStorage.astroErrorOverlayTheme` when detected dark mode * add changeset * Fix theme toggle in ErrorOverlay * update changeset * [ci] format * feat: add origin check for CSRF protection (#10678) * feat: add origin check for CSRF protection * add tests * chore: documentation * changeset and grammar * chore: add casing check * split function * better naming * make the whole object experimental * remove unused type * update changeset * manually apply Sarah's suggestions * Apply suggestions from code review Co-authored-by: Sarah Rainsberger --------- Co-authored-by: Sarah Rainsberger * feat: upgrade the minimum Node.js maintainance LTS version (#10689) * feat: upgrade the minimum Node.js maintainance LTS version * chore: update minimum npm version * chore: revert npm change * chore: address Erika's feedback * chore: apply further suggestions * Update .changeset/empty-rules-type.md Co-authored-by: Sarah Rainsberger --------- Co-authored-by: Sarah Rainsberger * [ci] format * Accept common cookie attributes when deleting a cookie (#10671) * Accept common cookie attributes when deleting a cookie * Fix AstroCookieSetOptions IDE annotations * Use AstroCookieSetOptions to construct AstroCookieDeleteOptions * Update .changeset/shaggy-cats-film.md Co-authored-by: Florian Lefebvre --------- Co-authored-by: Florian Lefebvre * feat(i18n): manual routing (#10193) * feat(i18n): manual routing * one more function * different typing * tests * fix merge * throw error for missing middleware * rename function * fix conflicts * lock file update * fix options, error thrown and added tests * rebase * add tests * docs * lock file black magic * increase timeout? * fix regression * merge conflict * add changeset * chore: apply suggestions * apply suggestion * Update .changeset/little-hornets-give.md Co-authored-by: Erika <3019731+Princesseuh@users.noreply.github.com> * chore: address feedback * fix regression of last commit * update name * add comments * fix regression * remove unused code * Apply suggestions from code review Co-authored-by: Sarah Rainsberger * chore: update reference * Update packages/astro/src/@types/astro.ts Co-authored-by: Sarah Rainsberger * chore: improve types * fix regression in tests * apply Sarah's suggestion --------- Co-authored-by: Erika <3019731+Princesseuh@users.noreply.github.com> Co-authored-by: Sarah Rainsberger * [ci] format * feat(toolbar): allow the user to change the placement (#10591) * feat(toolbar): add `placement` to settings * feat(toolbar): update `settings.placement` with ` + + + + + + ); +} +``` + +For a complete overview, and to give feedback on this experimental API, see the [Actions RFC](https://github.com/withastro/roadmap/blob/actions/proposals/0046-actions.md). diff --git a/packages/astro/client.d.ts b/packages/astro/client.d.ts index 9128e9dd0ce7..f81d652e3808 100644 --- a/packages/astro/client.d.ts +++ b/packages/astro/client.d.ts @@ -1,5 +1,6 @@ /// /// +/// // eslint-disable-next-line @typescript-eslint/no-namespace declare namespace App { diff --git a/packages/astro/e2e/actions-blog.test.js b/packages/astro/e2e/actions-blog.test.js new file mode 100644 index 000000000000..b98f74143ebd --- /dev/null +++ b/packages/astro/e2e/actions-blog.test.js @@ -0,0 +1,58 @@ +import { expect } from '@playwright/test'; +import { testFactory } from './test-utils.js'; + +const test = testFactory({ root: './fixtures/actions-blog/' }); + +let devServer; + +test.beforeAll(async ({ astro }) => { + devServer = await astro.startDevServer(); +}); + +test.afterAll(async () => { + await devServer.stop(); +}); + +test.describe('Astro Actions - Blog', () => { + test('Like action', async ({ page, astro }) => { + await page.goto(astro.resolveUrl('/blog/first-post/')); + + const likeButton = page.getByLabel('Like'); + await expect(likeButton, 'like button starts with 10 likes').toContainText('10'); + await likeButton.click(); + await expect(likeButton, 'like button should increment likes').toContainText('11'); + }); + + test('Comment action - validation error', async ({ page, astro }) => { + await page.goto(astro.resolveUrl('/blog/first-post/')); + + const authorInput = page.locator('input[name="author"]'); + const bodyInput = page.locator('textarea[name="body"]'); + + await authorInput.fill('Ben'); + await bodyInput.fill('Too short'); + + const submitButton = page.getByLabel('Post comment'); + await submitButton.click(); + + await expect(page.locator('p[data-error="body"]')).toBeVisible(); + }); + + test('Comment action - success', async ({ page, astro }) => { + await page.goto(astro.resolveUrl('/blog/first-post/')); + + const authorInput = page.locator('input[name="author"]'); + const bodyInput = page.locator('textarea[name="body"]'); + + const body = 'This should be long enough.'; + await authorInput.fill('Ben'); + await bodyInput.fill(body); + + const submitButton = page.getByLabel('Post comment'); + await submitButton.click(); + + const comment = await page.getByTestId('comment'); + await expect(comment).toBeVisible(); + await expect(comment).toContainText(body); + }); +}); diff --git a/packages/astro/e2e/fixtures/actions-blog/astro.config.mjs b/packages/astro/e2e/fixtures/actions-blog/astro.config.mjs new file mode 100644 index 000000000000..acbed1768b3c --- /dev/null +++ b/packages/astro/e2e/fixtures/actions-blog/astro.config.mjs @@ -0,0 +1,17 @@ +import { defineConfig } from 'astro/config'; +import db from '@astrojs/db'; +import react from '@astrojs/react'; +import node from '@astrojs/node'; + +// https://astro.build/config +export default defineConfig({ + site: 'https://example.com', + integrations: [db(), react()], + output: 'hybrid', + adapter: node({ + mode: 'standalone', + }), + experimental: { + actions: true, + }, +}); diff --git a/packages/astro/e2e/fixtures/actions-blog/db/config.ts b/packages/astro/e2e/fixtures/actions-blog/db/config.ts new file mode 100644 index 000000000000..da005471e10c --- /dev/null +++ b/packages/astro/e2e/fixtures/actions-blog/db/config.ts @@ -0,0 +1,21 @@ +import { column, defineDb, defineTable } from "astro:db"; + +const Comment = defineTable({ + columns: { + postId: column.text(), + author: column.text(), + body: column.text(), + }, +}); + +const Likes = defineTable({ + columns: { + postId: column.text(), + likes: column.number(), + }, +}); + +// https://astro.build/db/config +export default defineDb({ + tables: { Comment, Likes }, +}); diff --git a/packages/astro/e2e/fixtures/actions-blog/db/seed.ts b/packages/astro/e2e/fixtures/actions-blog/db/seed.ts new file mode 100644 index 000000000000..11dc55f7fe00 --- /dev/null +++ b/packages/astro/e2e/fixtures/actions-blog/db/seed.ts @@ -0,0 +1,15 @@ +import { db, Likes, Comment } from "astro:db"; + +// https://astro.build/db/seed +export default async function seed() { + await db.insert(Likes).values({ + postId: "first-post.md", + likes: 10, + }); + + await db.insert(Comment).values({ + postId: "first-post.md", + author: "Alice", + body: "Great post!", + }); +} diff --git a/packages/astro/e2e/fixtures/actions-blog/package.json b/packages/astro/e2e/fixtures/actions-blog/package.json new file mode 100644 index 000000000000..0c69e9a98be5 --- /dev/null +++ b/packages/astro/e2e/fixtures/actions-blog/package.json @@ -0,0 +1,24 @@ +{ + "name": "@e2e/astro-actions-basics", + "type": "module", + "version": "0.0.1", + "scripts": { + "dev": "astro dev", + "start": "astro dev", + "build": "astro check && astro build", + "preview": "astro preview", + "astro": "astro" + }, + "dependencies": { + "@astrojs/check": "^0.5.10", + "@astrojs/db": "workspace:*", + "@astrojs/node": "workspace:*", + "@astrojs/react": "workspace:*", + "@types/react": "^18.2.79", + "@types/react-dom": "^18.2.25", + "astro": "workspace:*", + "react": "^18.3.0", + "react-dom": "^18.3.0", + "typescript": "^5.4.5" + } +} diff --git a/packages/astro/e2e/fixtures/actions-blog/src/actions/index.ts b/packages/astro/e2e/fixtures/actions-blog/src/actions/index.ts new file mode 100644 index 000000000000..4574caaaf50b --- /dev/null +++ b/packages/astro/e2e/fixtures/actions-blog/src/actions/index.ts @@ -0,0 +1,45 @@ +import { db, Comment, Likes, eq, sql } from 'astro:db'; +import { defineAction, z } from 'astro:actions'; + +export const server = { + blog: { + like: defineAction({ + input: z.object({ postId: z.string() }), + handler: async ({ postId }) => { + await new Promise((r) => setTimeout(r, 200)); + + const { likes } = await db + .update(Likes) + .set({ + likes: sql`likes + 1`, + }) + .where(eq(Likes.postId, postId)) + .returning() + .get(); + + return likes; + }, + }), + + comment: defineAction({ + accept: 'form', + input: z.object({ + postId: z.string(), + author: z.string(), + body: z.string().min(10), + }), + handler: async ({ postId, author, body }) => { + const comment = await db + .insert(Comment) + .values({ + postId, + body, + author, + }) + .returning() + .get(); + return comment; + }, + }), + }, +}; diff --git a/packages/astro/e2e/fixtures/actions-blog/src/components/BaseHead.astro b/packages/astro/e2e/fixtures/actions-blog/src/components/BaseHead.astro new file mode 100644 index 000000000000..344124012bbf --- /dev/null +++ b/packages/astro/e2e/fixtures/actions-blog/src/components/BaseHead.astro @@ -0,0 +1,47 @@ +--- +// Import the global.css file here so that it is included on +// all pages through the use of the component. +import '../styles/global.css'; + +interface Props { + title: string; + description: string; + image?: string; +} + +const canonicalURL = new URL(Astro.url.pathname, Astro.site); + +const { title, description, image = '/blog-placeholder-1.jpg' } = Astro.props; +--- + + + + + + + + + + + + + + + +{title} + + + + + + + + + + + + + + + + diff --git a/packages/astro/e2e/fixtures/actions-blog/src/components/Footer.astro b/packages/astro/e2e/fixtures/actions-blog/src/components/Footer.astro new file mode 100644 index 000000000000..96c2fce91208 --- /dev/null +++ b/packages/astro/e2e/fixtures/actions-blog/src/components/Footer.astro @@ -0,0 +1,62 @@ +--- +const today = new Date(); +--- + + + diff --git a/packages/astro/e2e/fixtures/actions-blog/src/components/FormattedDate.astro b/packages/astro/e2e/fixtures/actions-blog/src/components/FormattedDate.astro new file mode 100644 index 000000000000..1bcce73a2b67 --- /dev/null +++ b/packages/astro/e2e/fixtures/actions-blog/src/components/FormattedDate.astro @@ -0,0 +1,17 @@ +--- +interface Props { + date: Date; +} + +const { date } = Astro.props; +--- + + diff --git a/packages/astro/e2e/fixtures/actions-blog/src/components/Header.astro b/packages/astro/e2e/fixtures/actions-blog/src/components/Header.astro new file mode 100644 index 000000000000..71b8cdc55c58 --- /dev/null +++ b/packages/astro/e2e/fixtures/actions-blog/src/components/Header.astro @@ -0,0 +1,83 @@ +--- +import HeaderLink from './HeaderLink.astro'; +import { SITE_TITLE } from '../consts'; +--- + +
+ +
+ diff --git a/packages/astro/e2e/fixtures/actions-blog/src/components/HeaderLink.astro b/packages/astro/e2e/fixtures/actions-blog/src/components/HeaderLink.astro new file mode 100644 index 000000000000..bb600fb65ac3 --- /dev/null +++ b/packages/astro/e2e/fixtures/actions-blog/src/components/HeaderLink.astro @@ -0,0 +1,25 @@ +--- +import type { HTMLAttributes } from 'astro/types'; + +type Props = HTMLAttributes<'a'>; + +const { href, class: className, ...props } = Astro.props; + +const { pathname } = Astro.url; +const subpath = pathname.match(/[^\/]+/g); +const isActive = href === pathname || href === '/' + subpath?.[0]; +--- + + + + + diff --git a/packages/astro/e2e/fixtures/actions-blog/src/components/Like.tsx b/packages/astro/e2e/fixtures/actions-blog/src/components/Like.tsx new file mode 100644 index 000000000000..7d4e6a53d161 --- /dev/null +++ b/packages/astro/e2e/fixtures/actions-blog/src/components/Like.tsx @@ -0,0 +1,22 @@ +import { actions } from 'astro:actions'; +import { useState } from 'react'; + +export function Like({ postId, initial }: { postId: string; initial: number }) { + const [likes, setLikes] = useState(initial); + const [pending, setPending] = useState(false); + + return ( + + ); +} diff --git a/packages/astro/e2e/fixtures/actions-blog/src/components/PostComment.tsx b/packages/astro/e2e/fixtures/actions-blog/src/components/PostComment.tsx new file mode 100644 index 000000000000..1b0d10a063fc --- /dev/null +++ b/packages/astro/e2e/fixtures/actions-blog/src/components/PostComment.tsx @@ -0,0 +1,66 @@ +import { getActionProps, actions, isInputError } from 'astro:actions'; +import { useState } from 'react'; + +export function PostComment({ + postId, + serverBodyError, +}: { + postId: string; + serverBodyError?: string; +}) { + const [comments, setComments] = useState<{ author: string; body: string }[]>([]); + const [bodyError, setBodyError] = useState(serverBodyError); + + return ( + <> +
{ + e.preventDefault(); + const form = e.target as HTMLFormElement; + const formData = new FormData(form); + const { data, error } = await actions.blog.comment.safe(formData); + if (isInputError(error)) { + return setBodyError(error.fields.body?.join(' ')); + } + if (data) { + setBodyError(undefined); + setComments((c) => [data, ...c]); + } + form.reset(); + }} + > + + + + + + {bodyError && ( +

+ {bodyError} +

+ )} + +
+ {comments.map((c) => ( +
+

{c.body}

+

{c.author}

+
+ ))} + + ); +} diff --git a/packages/astro/e2e/fixtures/actions-blog/src/consts.ts b/packages/astro/e2e/fixtures/actions-blog/src/consts.ts new file mode 100644 index 000000000000..0df8a61f4cf7 --- /dev/null +++ b/packages/astro/e2e/fixtures/actions-blog/src/consts.ts @@ -0,0 +1,5 @@ +// Place any global data in this file. +// You can import this data from anywhere in your site by using the `import` keyword. + +export const SITE_TITLE = 'Astro Blog'; +export const SITE_DESCRIPTION = 'Welcome to my website!'; diff --git a/packages/astro/e2e/fixtures/actions-blog/src/content/blog/first-post.md b/packages/astro/e2e/fixtures/actions-blog/src/content/blog/first-post.md new file mode 100644 index 000000000000..ee51f1541097 --- /dev/null +++ b/packages/astro/e2e/fixtures/actions-blog/src/content/blog/first-post.md @@ -0,0 +1,15 @@ +--- +title: 'First post' +description: 'Lorem ipsum dolor sit amet' +pubDate: 'Jul 08 2022' +--- + +Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Vitae ultricies leo integer malesuada nunc vel risus commodo viverra. Adipiscing enim eu turpis egestas pretium. Euismod elementum nisi quis eleifend quam adipiscing. In hac habitasse platea dictumst vestibulum. Sagittis purus sit amet volutpat. Netus et malesuada fames ac turpis egestas. Eget magna fermentum iaculis eu non diam phasellus vestibulum lorem. Varius sit amet mattis vulputate enim. Habitasse platea dictumst quisque sagittis. Integer quis auctor elit sed vulputate mi. Dictumst quisque sagittis purus sit amet. + +Morbi tristique senectus et netus. Id semper risus in hendrerit gravida rutrum quisque non tellus. Habitasse platea dictumst quisque sagittis purus sit amet. Tellus molestie nunc non blandit massa. Cursus vitae congue mauris rhoncus. Accumsan tortor posuere ac ut. Fringilla urna porttitor rhoncus dolor. Elit ullamcorper dignissim cras tincidunt lobortis. In cursus turpis massa tincidunt dui ut ornare lectus. Integer feugiat scelerisque varius morbi enim nunc. Bibendum neque egestas congue quisque egestas diam. Cras ornare arcu dui vivamus arcu felis bibendum. Dignissim suspendisse in est ante in nibh mauris. Sed tempus urna et pharetra pharetra massa massa ultricies mi. + +Mollis nunc sed id semper risus in. Convallis a cras semper auctor neque. Diam sit amet nisl suscipit. Lacus viverra vitae congue eu consequat ac felis donec. Egestas integer eget aliquet nibh praesent tristique magna sit amet. Eget magna fermentum iaculis eu non diam. In vitae turpis massa sed elementum. Tristique et egestas quis ipsum suspendisse ultrices. Eget lorem dolor sed viverra ipsum. Vel turpis nunc eget lorem dolor sed viverra. Posuere ac ut consequat semper viverra nam. Laoreet suspendisse interdum consectetur libero id faucibus. Diam phasellus vestibulum lorem sed risus ultricies tristique. Rhoncus dolor purus non enim praesent elementum facilisis. Ultrices tincidunt arcu non sodales neque. Tempus egestas sed sed risus pretium quam vulputate. Viverra suspendisse potenti nullam ac tortor vitae purus faucibus ornare. Fringilla urna porttitor rhoncus dolor purus non. Amet dictum sit amet justo donec enim. + +Mattis ullamcorper velit sed ullamcorper morbi tincidunt. Tortor posuere ac ut consequat semper viverra. Tellus mauris a diam maecenas sed enim ut sem viverra. Venenatis urna cursus eget nunc scelerisque viverra mauris in. Arcu ac tortor dignissim convallis aenean et tortor at. Curabitur gravida arcu ac tortor dignissim convallis aenean et tortor. Egestas tellus rutrum tellus pellentesque eu. Fusce ut placerat orci nulla pellentesque dignissim enim sit amet. Ut enim blandit volutpat maecenas volutpat blandit aliquam etiam. Id donec ultrices tincidunt arcu. Id cursus metus aliquam eleifend mi. + +Tempus quam pellentesque nec nam aliquam sem. Risus at ultrices mi tempus imperdiet. Id porta nibh venenatis cras sed felis eget velit. Ipsum a arcu cursus vitae. Facilisis magna etiam tempor orci eu lobortis elementum. Tincidunt dui ut ornare lectus sit. Quisque non tellus orci ac. Blandit libero volutpat sed cras. Nec tincidunt praesent semper feugiat nibh sed pulvinar proin gravida. Egestas integer eget aliquet nibh praesent tristique magna. diff --git a/packages/astro/e2e/fixtures/actions-blog/src/content/config.ts b/packages/astro/e2e/fixtures/actions-blog/src/content/config.ts new file mode 100644 index 000000000000..667a31cc7391 --- /dev/null +++ b/packages/astro/e2e/fixtures/actions-blog/src/content/config.ts @@ -0,0 +1,16 @@ +import { defineCollection, z } from 'astro:content'; + +const blog = defineCollection({ + type: 'content', + // Type-check frontmatter using a schema + schema: z.object({ + title: z.string(), + description: z.string(), + // Transform string to Date object + pubDate: z.coerce.date(), + updatedDate: z.coerce.date().optional(), + heroImage: z.string().optional(), + }), +}); + +export const collections = { blog }; diff --git a/packages/astro/e2e/fixtures/actions-blog/src/layouts/BlogPost.astro b/packages/astro/e2e/fixtures/actions-blog/src/layouts/BlogPost.astro new file mode 100644 index 000000000000..e67b2b30f859 --- /dev/null +++ b/packages/astro/e2e/fixtures/actions-blog/src/layouts/BlogPost.astro @@ -0,0 +1,85 @@ +--- +import type { CollectionEntry } from 'astro:content'; +import BaseHead from '../components/BaseHead.astro'; +import Header from '../components/Header.astro'; +import Footer from '../components/Footer.astro'; +import FormattedDate from '../components/FormattedDate.astro'; + +type Props = CollectionEntry<'blog'>['data']; + +const { title, description, pubDate, updatedDate, heroImage } = Astro.props; +--- + + + + + + + + +
+
+
+
+ {heroImage && } +
+
+
+
+ + { + updatedDate && ( +
+ Last updated on +
+ ) + } +
+

{title}

+
+
+ +
+
+
+