diff --git a/.changeset/beige-rice-tap.md b/.changeset/beige-rice-tap.md new file mode 100644 index 000000000000..67c7427a9317 --- /dev/null +++ b/.changeset/beige-rice-tap.md @@ -0,0 +1,5 @@ +--- +'astro': patch +--- + +Support passing the values `Infinity` and `-Infinity` as island props. diff --git a/.changeset/beige-students-compete.md b/.changeset/beige-students-compete.md new file mode 100644 index 000000000000..06588695c307 --- /dev/null +++ b/.changeset/beige-students-compete.md @@ -0,0 +1,5 @@ +--- +'@astrojs/vue': patch +--- + +Fixes a case where IDs generated by `useId()` (introduced in Vue 3.5) would not be unique between islands diff --git a/.changeset/bright-swans-shout.md b/.changeset/bright-swans-shout.md deleted file mode 100644 index 9be80e806d6a..000000000000 --- a/.changeset/bright-swans-shout.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'astro': patch ---- - -Fixes error where references in content layer schemas sometimes incorrectly report as missing diff --git a/.changeset/eighty-ligers-punch.md b/.changeset/eighty-ligers-punch.md new file mode 100644 index 000000000000..ee7acbec3b87 --- /dev/null +++ b/.changeset/eighty-ligers-punch.md @@ -0,0 +1,5 @@ +--- +'@astrojs/svelte': patch +--- + +Fixes an Reference Error that occurred during client transitions diff --git a/.changeset/large-phones-compare.md b/.changeset/large-phones-compare.md new file mode 100644 index 000000000000..a603ea0a2c0c --- /dev/null +++ b/.changeset/large-phones-compare.md @@ -0,0 +1,8 @@ +--- +'create-astro': patch +'@astrojs/upgrade': patch +'astro': patch +'@astrojs/db': patch +--- + +Removes the `strip-ansi` dependency in favor of the native Node API diff --git a/.changeset/ninety-monkeys-complain.md b/.changeset/ninety-monkeys-complain.md new file mode 100644 index 000000000000..c8a06da1f37f --- /dev/null +++ b/.changeset/ninety-monkeys-complain.md @@ -0,0 +1,5 @@ +--- +'astro': patch +--- + +Clear content layer cache when astro version changes diff --git a/.changeset/rich-apes-divide.md b/.changeset/rich-apes-divide.md deleted file mode 100644 index c0f70e5b9696..000000000000 --- a/.changeset/rich-apes-divide.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'astro': patch ---- - -Server islands: changes the server island HTML placeholder comment so that it is much less likely to get removed by HTML minifiers. diff --git a/.changeset/strange-cats-notice.md b/.changeset/strange-cats-notice.md new file mode 100644 index 000000000000..bb17a5aaed9a --- /dev/null +++ b/.changeset/strange-cats-notice.md @@ -0,0 +1,5 @@ +--- +"astro": patch +--- + +Updates Vite links to use their new domain diff --git a/.changeset/swift-snakes-hope.md b/.changeset/swift-snakes-hope.md new file mode 100644 index 000000000000..34c626b3941f --- /dev/null +++ b/.changeset/swift-snakes-hope.md @@ -0,0 +1,5 @@ +--- +'astro': patch +--- + +Allows special characters in Action names diff --git a/.changeset/thin-trains-fold.md b/.changeset/thin-trains-fold.md new file mode 100644 index 000000000000..d4df145844e0 --- /dev/null +++ b/.changeset/thin-trains-fold.md @@ -0,0 +1,5 @@ +--- +'astro': patch +--- + +Fixes missing `body` property on CollectionEntry types for content layer entries diff --git a/.changeset/wicked-sloths-cry.md b/.changeset/wicked-sloths-cry.md new file mode 100644 index 000000000000..e701bb6b860d --- /dev/null +++ b/.changeset/wicked-sloths-cry.md @@ -0,0 +1,5 @@ +--- +"@astrojs/vue": patch +--- + +Fixes an Reference Error that occurred during client transitions diff --git a/.changeset/wise-pumas-fry.md b/.changeset/wise-pumas-fry.md new file mode 100644 index 000000000000..90452298ca3f --- /dev/null +++ b/.changeset/wise-pumas-fry.md @@ -0,0 +1,5 @@ +--- +'astro': patch +--- + +Adds a helpful error when attempting to render an undefined collection entry diff --git a/.github/workflows/dispatch-event.yml b/.github/workflows/dispatch-event.yml index 5283fab4e1f3..0bca088e3d37 100644 --- a/.github/workflows/dispatch-event.yml +++ b/.github/workflows/dispatch-event.yml @@ -24,6 +24,7 @@ env: jobs: repository-dispatch: name: Repository dispatch + if: github.repository_owner == 'withastro' runs-on: ubuntu-latest steps: - name: Dispatch event on push - adapters diff --git a/examples/basics/package.json b/examples/basics/package.json index 61491cc9884c..cc794deb39dc 100644 --- a/examples/basics/package.json +++ b/examples/basics/package.json @@ -11,6 +11,6 @@ "astro": "astro" }, "dependencies": { - "astro": "^4.15.10" + "astro": "^4.15.11" } } diff --git a/examples/blog/package.json b/examples/blog/package.json index 82509d804dee..8f20c398ca6e 100644 --- a/examples/blog/package.json +++ b/examples/blog/package.json @@ -13,7 +13,7 @@ "dependencies": { "@astrojs/mdx": "^3.1.7", "@astrojs/rss": "^4.0.7", - "@astrojs/sitemap": "^3.1.6", - "astro": "^4.15.10" + "@astrojs/sitemap": "^3.2.0", + "astro": "^4.15.11" } } diff --git a/examples/component/package.json b/examples/component/package.json index 23954920fd68..350d58f40956 100644 --- a/examples/component/package.json +++ b/examples/component/package.json @@ -15,7 +15,7 @@ ], "scripts": {}, "devDependencies": { - "astro": "^4.15.10" + "astro": "^4.15.11" }, "peerDependencies": { "astro": "^4.0.0" diff --git a/examples/container-with-vitest/package.json b/examples/container-with-vitest/package.json index 470dd7af1a14..7ab82e6fff07 100644 --- a/examples/container-with-vitest/package.json +++ b/examples/container-with-vitest/package.json @@ -12,7 +12,7 @@ "test": "vitest run" }, "dependencies": { - "astro": "^4.15.10", + "astro": "^4.15.11", "@astrojs/react": "^3.6.2", "react": "^18.3.1", "react-dom": "^18.3.1", diff --git a/examples/framework-alpine/package.json b/examples/framework-alpine/package.json index da225dfe4163..672050c57a51 100644 --- a/examples/framework-alpine/package.json +++ b/examples/framework-alpine/package.json @@ -14,6 +14,6 @@ "@astrojs/alpinejs": "^0.4.0", "@types/alpinejs": "^3.13.10", "alpinejs": "^3.14.1", - "astro": "^4.15.10" + "astro": "^4.15.11" } } diff --git a/examples/framework-lit/package.json b/examples/framework-lit/package.json index 20d76f401af1..e346a30c25fb 100644 --- a/examples/framework-lit/package.json +++ b/examples/framework-lit/package.json @@ -13,7 +13,7 @@ "dependencies": { "@astrojs/lit": "^4.3.0", "@webcomponents/template-shadowroot": "^0.2.1", - "astro": "^4.15.10", + "astro": "^4.15.11", "lit": "^3.2.0" } } diff --git a/examples/framework-multiple/package.json b/examples/framework-multiple/package.json index 249d4ac6dfbf..06ddcda852a6 100644 --- a/examples/framework-multiple/package.json +++ b/examples/framework-multiple/package.json @@ -18,7 +18,7 @@ "@astrojs/vue": "^4.5.1", "@types/react": "^18.3.10", "@types/react-dom": "^18.3.0", - "astro": "^4.15.10", + "astro": "^4.15.11", "preact": "^10.24.1", "react": "^18.3.1", "react-dom": "^18.3.1", diff --git a/examples/framework-preact/package.json b/examples/framework-preact/package.json index ba60f0564b47..bf08ffed67d9 100644 --- a/examples/framework-preact/package.json +++ b/examples/framework-preact/package.json @@ -13,7 +13,7 @@ "dependencies": { "@astrojs/preact": "^3.5.3", "@preact/signals": "^1.3.0", - "astro": "^4.15.10", + "astro": "^4.15.11", "preact": "^10.24.1" } } diff --git a/examples/framework-react/package.json b/examples/framework-react/package.json index fd5ab9d07441..7216053ef802 100644 --- a/examples/framework-react/package.json +++ b/examples/framework-react/package.json @@ -14,7 +14,7 @@ "@astrojs/react": "^3.6.2", "@types/react": "^18.3.10", "@types/react-dom": "^18.3.0", - "astro": "^4.15.10", + "astro": "^4.15.11", "react": "^18.3.1", "react-dom": "^18.3.1" } diff --git a/examples/framework-solid/package.json b/examples/framework-solid/package.json index edfde49d14be..cb99bbb437b3 100644 --- a/examples/framework-solid/package.json +++ b/examples/framework-solid/package.json @@ -12,7 +12,7 @@ }, "dependencies": { "@astrojs/solid-js": "^4.4.2", - "astro": "^4.15.10", + "astro": "^4.15.11", "solid-js": "^1.9.1" } } diff --git a/examples/framework-svelte/package.json b/examples/framework-svelte/package.json index f198f9c8bc0a..48e01dd8433c 100644 --- a/examples/framework-svelte/package.json +++ b/examples/framework-svelte/package.json @@ -12,7 +12,7 @@ }, "dependencies": { "@astrojs/svelte": "^5.7.1", - "astro": "^4.15.10", + "astro": "^4.15.11", "svelte": "^4.2.19" } } diff --git a/examples/framework-vue/package.json b/examples/framework-vue/package.json index 92632633afd6..9b931b8c2dc1 100644 --- a/examples/framework-vue/package.json +++ b/examples/framework-vue/package.json @@ -12,7 +12,7 @@ }, "dependencies": { "@astrojs/vue": "^4.5.1", - "astro": "^4.15.10", + "astro": "^4.15.11", "vue": "^3.5.10" } } diff --git a/examples/hackernews/package.json b/examples/hackernews/package.json index 56e749c7189d..fcb216010a41 100644 --- a/examples/hackernews/package.json +++ b/examples/hackernews/package.json @@ -12,6 +12,6 @@ }, "dependencies": { "@astrojs/node": "^8.3.4", - "astro": "^4.15.10" + "astro": "^4.15.11" } } diff --git a/examples/integration/package.json b/examples/integration/package.json index 0b5df70f60fd..4737e512d327 100644 --- a/examples/integration/package.json +++ b/examples/integration/package.json @@ -15,7 +15,7 @@ ], "scripts": {}, "devDependencies": { - "astro": "^4.15.10" + "astro": "^4.15.11" }, "peerDependencies": { "astro": "^4.0.0" diff --git a/examples/middleware/package.json b/examples/middleware/package.json index 493fc6196ea8..bb0aae85413b 100644 --- a/examples/middleware/package.json +++ b/examples/middleware/package.json @@ -13,7 +13,7 @@ }, "dependencies": { "@astrojs/node": "^8.3.4", - "astro": "^4.15.10", + "astro": "^4.15.11", "html-minifier": "^4.0.0" }, "devDependencies": { diff --git a/examples/minimal/package.json b/examples/minimal/package.json index 038691111677..faa801c00639 100644 --- a/examples/minimal/package.json +++ b/examples/minimal/package.json @@ -11,6 +11,6 @@ "astro": "astro" }, "dependencies": { - "astro": "^4.15.10" + "astro": "^4.15.11" } } diff --git a/examples/non-html-pages/package.json b/examples/non-html-pages/package.json index 88a16c7fe96e..b7c88a476fda 100644 --- a/examples/non-html-pages/package.json +++ b/examples/non-html-pages/package.json @@ -11,6 +11,6 @@ "astro": "astro" }, "dependencies": { - "astro": "^4.15.10" + "astro": "^4.15.11" } } diff --git a/examples/portfolio/package.json b/examples/portfolio/package.json index adcf51a56da3..c05136f77071 100644 --- a/examples/portfolio/package.json +++ b/examples/portfolio/package.json @@ -11,6 +11,6 @@ "astro": "astro" }, "dependencies": { - "astro": "^4.15.10" + "astro": "^4.15.11" } } diff --git a/examples/server-islands/package.json b/examples/server-islands/package.json index 82f61d9a1821..43199037e65e 100644 --- a/examples/server-islands/package.json +++ b/examples/server-islands/package.json @@ -17,7 +17,7 @@ "@tailwindcss/forms": "^0.5.9", "@types/react": "^18.3.10", "@types/react-dom": "^18.3.0", - "astro": "^4.15.10", + "astro": "^4.15.11", "postcss": "^8.4.47", "react": "^18.3.1", "react-dom": "^18.3.1", diff --git a/examples/ssr/package.json b/examples/ssr/package.json index 4d2b73ae38f5..05e66e08f204 100644 --- a/examples/ssr/package.json +++ b/examples/ssr/package.json @@ -14,7 +14,7 @@ "dependencies": { "@astrojs/node": "^8.3.4", "@astrojs/svelte": "^5.7.1", - "astro": "^4.15.10", + "astro": "^4.15.11", "svelte": "^4.2.19" } } diff --git a/examples/starlog/package.json b/examples/starlog/package.json index d0e6ba18e2a5..e9030e34517e 100644 --- a/examples/starlog/package.json +++ b/examples/starlog/package.json @@ -10,7 +10,7 @@ "astro": "astro" }, "dependencies": { - "astro": "^4.15.10", + "astro": "^4.15.11", "sass": "^1.79.4", "sharp": "^0.33.3" } diff --git a/examples/toolbar-app/package.json b/examples/toolbar-app/package.json index f457deca934f..c53809e72fb0 100644 --- a/examples/toolbar-app/package.json +++ b/examples/toolbar-app/package.json @@ -15,6 +15,6 @@ "./app": "./dist/app.js" }, "devDependencies": { - "astro": "^4.15.10" + "astro": "^4.15.11" } } diff --git a/examples/view-transitions/package.json b/examples/view-transitions/package.json index f539e82d7e30..86dc3b9f9b11 100644 --- a/examples/view-transitions/package.json +++ b/examples/view-transitions/package.json @@ -12,6 +12,6 @@ "devDependencies": { "@astrojs/tailwind": "^5.1.1", "@astrojs/node": "^8.3.4", - "astro": "^4.15.10" + "astro": "^4.15.11" } } diff --git a/examples/with-markdoc/package.json b/examples/with-markdoc/package.json index d4377f6d911c..4678c8941a5d 100644 --- a/examples/with-markdoc/package.json +++ b/examples/with-markdoc/package.json @@ -12,6 +12,6 @@ }, "dependencies": { "@astrojs/markdoc": "^0.11.4", - "astro": "^4.15.10" + "astro": "^4.15.11" } } diff --git a/examples/with-markdown-plugins/package.json b/examples/with-markdown-plugins/package.json index 209cf4576e35..7320e6c00b4a 100644 --- a/examples/with-markdown-plugins/package.json +++ b/examples/with-markdown-plugins/package.json @@ -12,7 +12,7 @@ }, "dependencies": { "@astrojs/markdown-remark": "^5.2.0", - "astro": "^4.15.10", + "astro": "^4.15.11", "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 fe9856c3bfb0..ddaea577fb8d 100644 --- a/examples/with-markdown-shiki/package.json +++ b/examples/with-markdown-shiki/package.json @@ -11,6 +11,6 @@ "astro": "astro" }, "dependencies": { - "astro": "^4.15.10" + "astro": "^4.15.11" } } diff --git a/examples/with-mdx/package.json b/examples/with-mdx/package.json index edc755554aaf..8b31c286dd58 100644 --- a/examples/with-mdx/package.json +++ b/examples/with-mdx/package.json @@ -13,7 +13,7 @@ "dependencies": { "@astrojs/mdx": "^3.1.7", "@astrojs/preact": "^3.5.3", - "astro": "^4.15.10", + "astro": "^4.15.11", "preact": "^10.24.1" } } diff --git a/examples/with-nanostores/package.json b/examples/with-nanostores/package.json index 455a6027addf..1fbc343ff06b 100644 --- a/examples/with-nanostores/package.json +++ b/examples/with-nanostores/package.json @@ -13,7 +13,7 @@ "dependencies": { "@astrojs/preact": "^3.5.3", "@nanostores/preact": "^0.5.2", - "astro": "^4.15.10", + "astro": "^4.15.11", "nanostores": "^0.11.3", "preact": "^10.24.1" } diff --git a/examples/with-tailwindcss/package.json b/examples/with-tailwindcss/package.json index 085e86ad15a6..390f8c17fd4f 100644 --- a/examples/with-tailwindcss/package.json +++ b/examples/with-tailwindcss/package.json @@ -14,7 +14,7 @@ "@astrojs/mdx": "^3.1.7", "@astrojs/tailwind": "^5.1.1", "@types/canvas-confetti": "^1.6.4", - "astro": "^4.15.10", + "astro": "^4.15.11", "autoprefixer": "^10.4.20", "canvas-confetti": "^1.9.3", "postcss": "^8.4.47", diff --git a/examples/with-vitest/package.json b/examples/with-vitest/package.json index 8c0dbc017ff2..dc45fcaea57b 100644 --- a/examples/with-vitest/package.json +++ b/examples/with-vitest/package.json @@ -12,7 +12,7 @@ "test": "vitest" }, "dependencies": { - "astro": "^4.15.10", + "astro": "^4.15.11", "vitest": "^2.1.1" } } diff --git a/packages/astro-rss/README.md b/packages/astro-rss/README.md index c8485b02e3e8..2a5d6a7954f2 100644 --- a/packages/astro-rss/README.md +++ b/packages/astro-rss/README.md @@ -345,7 +345,7 @@ const blog = defineCollection({ ## `pagesGlobToRssItems()` -To create an RSS feed from documents in `src/pages/`, use the `pagesGlobToRssItems()` helper. This accepts an `import.meta.glob` result ([see Vite documentation](https://vitejs.dev/guide/features.html#glob-import)) and outputs an array of valid [`RSSFeedItem`s](#items). +To create an RSS feed from documents in `src/pages/`, use the `pagesGlobToRssItems()` helper. This accepts an `import.meta.glob` result ([see Vite documentation](https://vite.dev/guide/features.html#glob-import)) and outputs an array of valid [`RSSFeedItem`s](#items). This function assumes, but does not verify, you are globbing for items inside `src/pages/`, and all necessary feed properties are present in each document's frontmatter. If you encounter errors, verify each page frontmatter manually. diff --git a/packages/astro/CHANGELOG.md b/packages/astro/CHANGELOG.md index f8e804be6875..8db3a1bb83a5 100644 --- a/packages/astro/CHANGELOG.md +++ b/packages/astro/CHANGELOG.md @@ -1,5 +1,23 @@ # astro +## 4.15.11 + +### Patch Changes + +- [#12097](https://github.com/withastro/astro/pull/12097) [`11d447f`](https://github.com/withastro/astro/commit/11d447f66b1a0f39489c2600139ebfb565336ce7) Thanks [@ascorbic](https://github.com/ascorbic)! - Fixes error where references in content layer schemas sometimes incorrectly report as missing + +- [#12108](https://github.com/withastro/astro/pull/12108) [`918953b`](https://github.com/withastro/astro/commit/918953bd09f057131dfe029e810019c0909345cf) Thanks [@lameuler](https://github.com/lameuler)! - Fixes a bug where [data URL images](https://developer.mozilla.org/en-US/docs/Web/URI/Schemes/data) were not correctly handled. The bug resulted in an `ENAMETOOLONG` error. + +- [#12105](https://github.com/withastro/astro/pull/12105) [`42037f3`](https://github.com/withastro/astro/commit/42037f33e644d5a2bfba71377697fc7336ecb15b) Thanks [@ascorbic](https://github.com/ascorbic)! - Returns custom statusText that has been set in a Response + +- [#12109](https://github.com/withastro/astro/pull/12109) [`ea22558`](https://github.com/withastro/astro/commit/ea225585fd12d27006434266163512ca66ad572b) Thanks [@ematipico](https://github.com/ematipico)! - Fixes a regression that was introduced by an internal refactor of how the middleware is loaded by the Astro application. The regression was introduced by [#11550](https://github.com/withastro/astro/pull/11550). + + When the edge middleware feature is opted in, Astro removes the middleware function from the SSR manifest, and this wasn't taken into account during the refactor. + +- [#12106](https://github.com/withastro/astro/pull/12106) [`d3a74da`](https://github.com/withastro/astro/commit/d3a74da19644477ffc81acf2a3efb26ad3335a5e) Thanks [@ascorbic](https://github.com/ascorbic)! - Handles case where an immutable Response object is returned from an endpoint + +- [#12090](https://github.com/withastro/astro/pull/12090) [`d49a537`](https://github.com/withastro/astro/commit/d49a537f2aaccd132154a15f1da4db471272ee90) Thanks [@markjaquith](https://github.com/markjaquith)! - Server islands: changes the server island HTML placeholder comment so that it is much less likely to get removed by HTML minifiers. + ## 4.15.10 ### Patch Changes @@ -3810,7 +3828,7 @@ To not break existing APIs, aliases for the Toolbar-based names have been created. The previous API names will continue to function but will be deprecated in the future. All documentation has been updated to reflect Toolbar-based names. -- [#9122](https://github.com/withastro/astro/pull/9122) [`1c48ed286`](https://github.com/withastro/astro/commit/1c48ed286538ab9e354eca4e4dcd7c6385c96721) Thanks [@bluwy](https://github.com/bluwy)! - Adds Vite 5 support. There are no breaking changes from Astro. Check the [Vite migration guide](https://vitejs.dev/guide/migration.html) for details of the breaking changes from Vite instead. +- [#9122](https://github.com/withastro/astro/pull/9122) [`1c48ed286`](https://github.com/withastro/astro/commit/1c48ed286538ab9e354eca4e4dcd7c6385c96721) Thanks [@bluwy](https://github.com/bluwy)! - Adds Vite 5 support. There are no breaking changes from Astro. Check the [Vite migration guide](https://vite.dev/guide/migration.html) for details of the breaking changes from Vite instead. - [#9225](https://github.com/withastro/astro/pull/9225) [`c421a3d17`](https://github.com/withastro/astro/commit/c421a3d17911aeda29b5204f6d568ae87e329eaf) Thanks [@natemoo-re](https://github.com/natemoo-re)! - Removes the opt-in `handleForms` property for ``. Form submissions are now handled by default and this property is no longer necessary. This default behavior can be disabled by setting `data-astro-reload` on relevant `
` elements. @@ -4146,7 +4164,7 @@ The types for middlewares have also been revised. To type a middleware function, you should now use `MiddlewareHandler` instead of `MiddlewareResponseHandler`. If you used `defineMiddleware()` to type the function, no changes are needed. -- [#9122](https://github.com/withastro/astro/pull/9122) [`1c48ed286`](https://github.com/withastro/astro/commit/1c48ed286538ab9e354eca4e4dcd7c6385c96721) Thanks [@bluwy](https://github.com/bluwy)! - Adds Vite 5 support. There are no breaking changes from Astro. Check the [Vite migration guide](https://vitejs.dev/guide/migration.html) for details of the breaking changes from Vite instead. +- [#9122](https://github.com/withastro/astro/pull/9122) [`1c48ed286`](https://github.com/withastro/astro/commit/1c48ed286538ab9e354eca4e4dcd7c6385c96721) Thanks [@bluwy](https://github.com/bluwy)! - Adds Vite 5 support. There are no breaking changes from Astro. Check the [Vite migration guide](https://vite.dev/guide/migration.html) for details of the breaking changes from Vite instead. - [#9196](https://github.com/withastro/astro/pull/9196) [`37697a2c5`](https://github.com/withastro/astro/commit/37697a2c5511572dc29c0a4ea46f90c2f62be8e6) Thanks [@bluwy](https://github.com/bluwy)! - Removes support for Shiki custom language's `path` property. The language JSON file should be imported and passed to the option instead. @@ -8355,7 +8373,7 @@ ``` -- [#5685](https://github.com/withastro/astro/pull/5685) [`f6cf92b48`](https://github.com/withastro/astro/commit/f6cf92b48317a19a3840ad781b77d6d3cae143bb) Thanks [@bluwy](https://github.com/bluwy)! - Upgrade to Vite 4. Please see its [migration guide](https://vitejs.dev/guide/migration.html) for more information. +- [#5685](https://github.com/withastro/astro/pull/5685) [`f6cf92b48`](https://github.com/withastro/astro/commit/f6cf92b48317a19a3840ad781b77d6d3cae143bb) Thanks [@bluwy](https://github.com/bluwy)! - Upgrade to Vite 4. Please see its [migration guide](https://vite.dev/guide/migration.html) for more information. - [#5724](https://github.com/withastro/astro/pull/5724) [`16c7d0bfd`](https://github.com/withastro/astro/commit/16c7d0bfd49d2b9bfae45385f506bcd642f9444a) Thanks [@bluwy](https://github.com/bluwy)! - Remove outdated Vue info log. Remove `toString` support for `RenderTemplateResult`. @@ -8912,7 +8930,7 @@ - [#5716](https://github.com/withastro/astro/pull/5716) [`dd56c1941`](https://github.com/withastro/astro/commit/dd56c19411b126439b8bc42d681b6fa8c06e8c61) Thanks [@bluwy](https://github.com/bluwy)! - Remove MDX Fragment hack. This was used by `@astrojs/mdx` to access the `Fragment` component, but isn't require anymore since `@astrojs/mdx` v0.12.1. -- [#5685](https://github.com/withastro/astro/pull/5685) [`f6cf92b48`](https://github.com/withastro/astro/commit/f6cf92b48317a19a3840ad781b77d6d3cae143bb) Thanks [@bluwy](https://github.com/bluwy)! - Upgrade to Vite 4. Please see its [migration guide](https://vitejs.dev/guide/migration.html) for more information. +- [#5685](https://github.com/withastro/astro/pull/5685) [`f6cf92b48`](https://github.com/withastro/astro/commit/f6cf92b48317a19a3840ad781b77d6d3cae143bb) Thanks [@bluwy](https://github.com/bluwy)! - Upgrade to Vite 4. Please see its [migration guide](https://vite.dev/guide/migration.html) for more information. - [#5724](https://github.com/withastro/astro/pull/5724) [`16c7d0bfd`](https://github.com/withastro/astro/commit/16c7d0bfd49d2b9bfae45385f506bcd642f9444a) Thanks [@bluwy](https://github.com/bluwy)! - Remove outdated Vue info log. Remove `toString` support for `RenderTemplateResult`. diff --git a/packages/astro/client.d.ts b/packages/astro/client.d.ts index 4d4b031432af..8e1d64f23dab 100644 --- a/packages/astro/client.d.ts +++ b/packages/astro/client.d.ts @@ -24,7 +24,7 @@ interface ImportMeta { * Astro and Vite expose environment variables through `import.meta.env`. For a complete list of the environment variables available, see the two references below. * * - [Astro reference](https://docs.astro.build/en/guides/environment-variables/#default-environment-variables) - * - [Vite reference](https://vitejs.dev/guide/env-and-mode.html#env-variables) + * - [Vite reference](https://vite.dev/guide/env-and-mode.html#env-variables) */ readonly env: ImportMetaEnv; } diff --git a/packages/astro/e2e/fixtures/pass-js/src/components/React.tsx b/packages/astro/e2e/fixtures/pass-js/src/components/React.tsx index 15314461c070..be86090af0ae 100644 --- a/packages/astro/e2e/fixtures/pass-js/src/components/React.tsx +++ b/packages/astro/e2e/fixtures/pass-js/src/components/React.tsx @@ -11,12 +11,14 @@ interface Props { array: any[]; map: Map; set: Set; + infinity: number; + negativeInfinity: number; } const isNode = typeof process !== 'undefined' && Object.prototype.toString.call(process) === '[object process]'; /** a counter written in React */ -export default function Component({ undefined: undefinedProp, null: nullProp, boolean, number, string, bigint, object, array, map, set }: Props) { +export default function Component({ undefined: undefinedProp, null: nullProp, boolean, number, string, bigint, object, array, map, set, infinity, negativeInfinity }: Props) { // We are testing hydration, so don't return anything in the server. if(isNode) { return
@@ -30,6 +32,10 @@ export default function Component({ undefined: undefinedProp, null: nullProp, bo {boolean.toString()} {Object.prototype.toString.call(number)} {number.toString()} + {Object.prototype.toString.call(infinity)} + {infinity.toString()} + {Object.prototype.toString.call(negativeInfinity)} + {negativeInfinity.toString()} {Object.prototype.toString.call(string)} {string} {Object.prototype.toString.call(bigint)} diff --git a/packages/astro/e2e/fixtures/pass-js/src/pages/index.astro b/packages/astro/e2e/fixtures/pass-js/src/pages/index.astro index 24794367f30d..5d00f535d2e8 100644 --- a/packages/astro/e2e/fixtures/pass-js/src/pages/index.astro +++ b/packages/astro/e2e/fixtures/pass-js/src/pages/index.astro @@ -42,6 +42,8 @@ set.add('test2'); array={[0, "foo"]} map={map} set={set} + infinity={Infinity} + negativeInfinity={-Infinity} /> diff --git a/packages/astro/e2e/pass-js.test.js b/packages/astro/e2e/pass-js.test.js index 91e3b5c5e752..c70f2ae39be5 100644 --- a/packages/astro/e2e/pass-js.test.js +++ b/packages/astro/e2e/pass-js.test.js @@ -47,6 +47,22 @@ test.describe('Passing JS into client components', () => { await expect(numberValue, 'is visible').toBeVisible(); await expect(numberValue).toHaveText('16'); + const infinityType = page.locator('#infinity-type'); + await expect(infinityType, 'is visible').toBeVisible(); + await expect(infinityType).toHaveText('[object Number]'); + + const negativeInfinityType = page.locator('#negative-infinity-type'); + await expect(negativeInfinityType, 'is visible').toBeVisible(); + await expect(negativeInfinityType).toHaveText('[object Number]'); + + const infinityValue = page.locator('#infinity-value'); + await expect(infinityValue, 'is visible').toBeVisible(); + await expect(infinityValue).toHaveText('Infinity'); + + const negativeInfinityValue = page.locator('#negative-infinity-value'); + await expect(negativeInfinityValue, 'is visible').toBeVisible(); + await expect(negativeInfinityValue).toHaveText('-Infinity'); + // string const stringType = page.locator('#string-type'); await expect(stringType, 'is visible').toBeVisible(); diff --git a/packages/astro/package.json b/packages/astro/package.json index 7e9647e5893a..4af70bb6984f 100644 --- a/packages/astro/package.json +++ b/packages/astro/package.json @@ -1,6 +1,6 @@ { "name": "astro", - "version": "4.15.10", + "version": "4.15.11", "description": "Astro is a modern site builder with web best practices, performance, and DX front-of-mind.", "type": "module", "author": "withastro", @@ -174,7 +174,6 @@ "semver": "^7.6.3", "shiki": "^1.21.0", "string-width": "^7.2.0", - "strip-ansi": "^7.1.0", "tinyexec": "^0.3.0", "tsconfck": "^3.1.3", "unist-util-visit": "^5.0.0", diff --git a/packages/astro/src/@types/astro.ts b/packages/astro/src/@types/astro.ts index e0c85f33c0c6..4cba5610b0c1 100644 --- a/packages/astro/src/@types/astro.ts +++ b/packages/astro/src/@types/astro.ts @@ -861,7 +861,7 @@ export interface AstroUserConfig { * * Pass additional configuration options to Vite. Useful when Astro doesn't support some advanced configuration that you may need. * - * View the full `vite` configuration object documentation on [vitejs.dev](https://vitejs.dev/config/). + * View the full `vite` configuration object documentation on [vite.dev](https://vite.dev/config/). * * #### Examples * diff --git a/packages/astro/src/actions/runtime/virtual/get-action.ts b/packages/astro/src/actions/runtime/virtual/get-action.ts index b547b57c10c5..59db34cbc0cd 100644 --- a/packages/astro/src/actions/runtime/virtual/get-action.ts +++ b/packages/astro/src/actions/runtime/virtual/get-action.ts @@ -11,7 +11,10 @@ import type { ActionAccept, ActionClient } from './server.js'; export async function getAction( path: string, ): Promise> { - const pathKeys = path.replace('/_actions/', '').split('.'); + const pathKeys = path + .replace('/_actions/', '') + .split('.') + .map((key) => decodeURIComponent(key)); // @ts-expect-error virtual module let { server: actionLookup } = await import('astro:internal-actions'); diff --git a/packages/astro/src/assets/utils/transformToPath.ts b/packages/astro/src/assets/utils/transformToPath.ts index 554761487de9..e11680a12269 100644 --- a/packages/astro/src/assets/utils/transformToPath.ts +++ b/packages/astro/src/assets/utils/transformToPath.ts @@ -8,7 +8,11 @@ import { isESMImportedImage } from './imageKind.js'; export function propsToFilename(filePath: string, transform: ImageTransform, hash: string) { let filename = decodeURIComponent(removeQueryString(filePath)); const ext = extname(filename); - filename = basename(filename, ext); + if (filePath.startsWith('data:')) { + filename = shorthash(filePath); + } else { + filename = basename(filename, ext); + } const prefixDirname = isESMImportedImage(transform.src) ? dirname(filePath) : ''; let outputExt = transform.format ? `.${transform.format}` : ext; diff --git a/packages/astro/src/content/content-layer.ts b/packages/astro/src/content/content-layer.ts index c07d5dd55f8a..b2729ce4dd72 100644 --- a/packages/astro/src/content/content-layer.ts +++ b/packages/astro/src/content/content-layer.ts @@ -151,13 +151,27 @@ export class ContentLayer { const { digest: currentConfigDigest } = contentConfig.config; this.#lastConfigDigest = currentConfigDigest; + let shouldClear = false; const previousConfigDigest = await this.#store.metaStore().get('config-digest'); + const previousAstroVersion = await this.#store.metaStore().get('astro-version'); if (currentConfigDigest && previousConfigDigest !== currentConfigDigest) { - logger.info('Content config changed, clearing cache'); + logger.info('Content config changed'); + shouldClear = true; + } + if (process.env.ASTRO_VERSION && previousAstroVersion !== process.env.ASTRO_VERSION) { + logger.info('Astro version changed'); + shouldClear = true; + } + if (shouldClear) { + logger.info('Clearing content store'); this.#store.clearAll(); + } + if (process.env.ASTRO_VERSION) { + await this.#store.metaStore().set('astro-version', process.env.ASTRO_VERSION); + } + if (currentConfigDigest) { await this.#store.metaStore().set('config-digest', currentConfigDigest); } - await Promise.all( Object.entries(contentConfig.config.collections).map(async ([name, collection]) => { if (collection.type !== CONTENT_LAYER_TYPE) { diff --git a/packages/astro/src/content/runtime.ts b/packages/astro/src/content/runtime.ts index bbe4a2b1f116..98d1c4fcdbde 100644 --- a/packages/astro/src/content/runtime.ts +++ b/packages/astro/src/content/runtime.ts @@ -436,7 +436,11 @@ function updateImageReferencesInData>( export async function renderEntry( entry: DataEntry | { render: () => Promise<{ Content: AstroComponentFactory }> }, ) { - if (entry && 'render' in entry) { + if (!entry) { + throw new AstroError(AstroErrorData.RenderUndefinedEntryError); + } + + if ('render' in entry) { // This is an old content collection entry, so we use its render method return entry.render(); } diff --git a/packages/astro/src/content/types-generator.ts b/packages/astro/src/content/types-generator.ts index 3c0130cf9f83..aa5a75a2b7b3 100644 --- a/packages/astro/src/content/types-generator.ts +++ b/packages/astro/src/content/types-generator.ts @@ -497,7 +497,7 @@ async function writeContentFiles({ contentTypesStr += `};\n`; break; case CONTENT_LAYER_TYPE: - dataTypesStr += `${collectionKey}: Record;\n`; + dataTypesStr += `${collectionKey}: Record;\n`; break; case 'data': if (collectionEntryKeys.length === 0) { diff --git a/packages/astro/src/core/app/node.ts b/packages/astro/src/core/app/node.ts index f9afa6189d5a..9fa1b645ff22 100644 --- a/packages/astro/src/core/app/node.ts +++ b/packages/astro/src/core/app/node.ts @@ -107,7 +107,8 @@ export class NodeApp extends App { * @param destination NodeJS ServerResponse */ static async writeResponse(source: Response, destination: ServerResponse) { - const { status, headers, body } = source; + const { status, headers, body, statusText } = source; + destination.statusMessage = statusText; destination.writeHead(status, createOutgoingHttpHeaders(headers)); if (!body) return destination.end(); try { diff --git a/packages/astro/src/core/app/types.ts b/packages/astro/src/core/app/types.ts index 73ddea268d9a..66035e4d5697 100644 --- a/packages/astro/src/core/app/types.ts +++ b/packages/astro/src/core/app/types.ts @@ -68,7 +68,7 @@ export type SSRManifest = { serverIslandNameMap?: Map; key: Promise; i18n: SSRManifestI18n | undefined; - middleware: () => Promise | AstroMiddlewareInstance; + middleware?: () => Promise | AstroMiddlewareInstance; checkOrigin: boolean; // TODO: remove experimental prefix experimentalEnvGetSecretEnabled: boolean; diff --git a/packages/astro/src/core/base-pipeline.ts b/packages/astro/src/core/base-pipeline.ts index 8a448133ab3d..4eeb2f0525b5 100644 --- a/packages/astro/src/core/base-pipeline.ts +++ b/packages/astro/src/core/base-pipeline.ts @@ -109,7 +109,10 @@ export abstract class Pipeline { async getMiddleware(): Promise { if (this.resolvedMiddleware) { return this.resolvedMiddleware; - } else { + } + // The middleware can be undefined when using edge middleware. + // This is set to undefined by the plugin-ssr.ts + else if (this.middleware) { const middlewareInstance = await this.middleware(); const onRequest = middlewareInstance.onRequest ?? NOOP_MIDDLEWARE_FN; if (this.manifest.checkOrigin) { @@ -118,6 +121,9 @@ export abstract class Pipeline { this.resolvedMiddleware = onRequest; } return this.resolvedMiddleware; + } else { + this.resolvedMiddleware = NOOP_MIDDLEWARE_FN; + return this.resolvedMiddleware; } } } diff --git a/packages/astro/src/core/errors/dev/utils.ts b/packages/astro/src/core/errors/dev/utils.ts index 03ba7d2dff01..c0caa1d60bc6 100644 --- a/packages/astro/src/core/errors/dev/utils.ts +++ b/packages/astro/src/core/errors/dev/utils.ts @@ -1,9 +1,9 @@ import * as fs from 'node:fs'; import { isAbsolute, join } from 'node:path'; import { fileURLToPath } from 'node:url'; +import { stripVTControlCharacters } from 'node:util'; import { escape } from 'html-escaper'; import { bold, underline } from 'kleur/colors'; -import stripAnsi from 'strip-ansi'; import type { ESBuildTransformResult } from 'vite'; import { normalizePath } from 'vite'; import type { SSRError } from '../../../@types/astro.js'; @@ -27,7 +27,7 @@ export function collectErrorMetadata(e: any, rootFolder?: URL): ErrorWithMetadat if (e.stack) { const stackInfo = collectInfoFromStacktrace(e); try { - error.stack = stripAnsi(stackInfo.stack); + error.stack = stripVTControlCharacters(stackInfo.stack); } catch {} error.loc = stackInfo.loc; error.plugin = stackInfo.plugin; @@ -59,7 +59,7 @@ export function collectErrorMetadata(e: any, rootFolder?: URL): ErrorWithMetadat if (!error.frame) { const frame = codeFrame(fileContents, error.loc); - error.frame = stripAnsi(frame); + error.frame = stripVTControlCharacters(frame); } if (!error.fullCode) { @@ -75,7 +75,7 @@ export function collectErrorMetadata(e: any, rootFolder?: URL): ErrorWithMetadat // but it will be handled and added below, which is already ANSI-free if (error.message) { try { - error.message = stripAnsi(error.message); + error.message = stripVTControlCharacters(error.message); } catch { // Setting `error.message` can fail here if the message is read-only, which for the vast majority of cases will never happen, however some somewhat obscure cases can cause this to happen. } @@ -170,7 +170,7 @@ function collectInfoFromStacktrace(error: SSRError & { stack: string }): StackIn // normalize error stack line-endings to \n stackInfo.stack = normalizeLF(error.stack); - const stackText = stripAnsi(error.stack); + const stackText = stripVTControlCharacters(error.stack); // Try to find possible location from stack if we don't have one if (!stackInfo.loc || (!stackInfo.loc.column && !stackInfo.loc.line)) { diff --git a/packages/astro/src/core/errors/errors-data.ts b/packages/astro/src/core/errors/errors-data.ts index 5760c5d96726..89bc9780b1aa 100644 --- a/packages/astro/src/core/errors/errors-data.ts +++ b/packages/astro/src/core/errors/errors-data.ts @@ -888,14 +888,14 @@ export const LocalImageUsedWrongly = { * @see * - [Astro.glob](https://docs.astro.build/en/reference/api-reference/#astroglob) * @description - * `Astro.glob()` can only be used in `.astro` files. You can use [`import.meta.glob()`](https://vitejs.dev/guide/features.html#glob-import) instead to achieve the same result. + * `Astro.glob()` can only be used in `.astro` files. You can use [`import.meta.glob()`](https://vite.dev/guide/features.html#glob-import) instead to achieve the same result. */ export const AstroGlobUsedOutside = { name: 'AstroGlobUsedOutside', title: 'Astro.glob() used outside of an Astro file.', message: (globStr: string) => `\`Astro.glob(${globStr})\` can only be used in \`.astro\` files. \`import.meta.glob(${globStr})\` can be used instead to achieve a similar result.`, - hint: "See Vite's documentation on `import.meta.glob` for more information: https://vitejs.dev/guide/features.html#glob-import", + hint: "See Vite's documentation on `import.meta.glob` for more information: https://vite.dev/guide/features.html#glob-import", } satisfies ErrorData; /** @@ -967,7 +967,7 @@ export const MissingSharp = { /** * @docs * @see - * - [Vite troubleshooting guide](https://vitejs.dev/guide/troubleshooting.html) + * - [Vite troubleshooting guide](https://vite.dev/guide/troubleshooting.html) * @description * Vite encountered an unknown error while rendering your project. We unfortunately do not know what happened (or we would tell you!) * @@ -1410,6 +1410,17 @@ export const UnknownContentCollectionError = { title: 'Unknown Content Collection Error.', } satisfies ErrorData; +/** + * @docs + * @description + * Astro tried to render a content collection entry that was undefined. This can happen if you try to render an entry that does not exist. + */ +export const RenderUndefinedEntryError = { + name: 'RenderUndefinedEntryError', + title: 'Attempted to render an undefined content collection entry.', + hint: 'Check if the entry is undefined before passing it to `render()`', +} satisfies ErrorData; + /** * @docs * @description diff --git a/packages/astro/src/core/logger/vite.ts b/packages/astro/src/core/logger/vite.ts index f1ed49dce0d2..e8c9717b273c 100644 --- a/packages/astro/src/core/logger/vite.ts +++ b/packages/astro/src/core/logger/vite.ts @@ -1,5 +1,5 @@ import { fileURLToPath } from 'node:url'; -import stripAnsi from 'strip-ansi'; +import { stripVTControlCharacters } from 'node:util'; import type { LogLevel, Rollup, Logger as ViteLogger } from 'vite'; import { isAstroError } from '../errors/errors.js'; import { serverShortcuts as formatServerShortcuts } from '../messages.js'; @@ -34,7 +34,7 @@ export function createViteLogger( info(msg) { if (!isLogLevelEnabled(viteLogLevel, 'info')) return; - const stripped = stripAnsi(msg); + const stripped = stripVTControlCharacters(msg); let m; // Rewrite HMR page reload message if ((m = vitePageReloadMsg.exec(stripped))) { diff --git a/packages/astro/src/runtime/server/astro-island.ts b/packages/astro/src/runtime/server/astro-island.ts index 3c0404435afd..252ed65c8618 100644 --- a/packages/astro/src/runtime/server/astro-island.ts +++ b/packages/astro/src/runtime/server/astro-island.ts @@ -29,6 +29,7 @@ declare const Astro: { 8: (value) => new Uint8Array(value), 9: (value) => new Uint16Array(value), 10: (value) => new Uint32Array(value), + 11: (value) => Infinity * value, }; // Not using JSON.parse reviver because it's bottom-up but we want top-down diff --git a/packages/astro/src/runtime/server/endpoint.ts b/packages/astro/src/runtime/server/endpoint.ts index 900d604fd569..a8f9403fe824 100644 --- a/packages/astro/src/runtime/server/endpoint.ts +++ b/packages/astro/src/runtime/server/endpoint.ts @@ -50,7 +50,7 @@ export async function renderEndpoint( return new Response(null, { status: 500 }); } - const response = await handler.call(mod, context); + let response = await handler.call(mod, context); if (!response || response instanceof Response === false) { throw new AstroError(EndpointDidNotReturnAResponse); @@ -59,10 +59,20 @@ export async function renderEndpoint( // Endpoints explicitly returning 404 or 500 response status should // NOT be subject to rerouting to 404.astro or 500.astro. if (REROUTABLE_STATUS_CODES.includes(response.status)) { - // Only `Response.redirect` headers are immutable, therefore a `try..catch` is not necessary. - // Note: `Response.redirect` can only be called with HTTP status codes: 301, 302, 303, 307, 308. - // Source: https://developer.mozilla.org/en-US/docs/Web/API/Response/redirect_static#parameters - response.headers.set(REROUTE_DIRECTIVE_HEADER, 'no'); + try { + response.headers.set(REROUTE_DIRECTIVE_HEADER, 'no'); + } catch (err) { + // In some cases the response may have immutable headers + // This is the case if, for example, the user directly returns a `fetch` response + // There's no clean way to check if the headers are immutable, so we just catch the error + // Note that response.clone() still has immutable headers! + if ((err as Error).message?.includes('immutable')) { + response = new Response(response.body, response); + response.headers.set(REROUTE_DIRECTIVE_HEADER, 'no'); + } else { + throw err; + } + } } return response; diff --git a/packages/astro/src/runtime/server/serialize.ts b/packages/astro/src/runtime/server/serialize.ts index 522b05256601..ccce39bde3ab 100644 --- a/packages/astro/src/runtime/server/serialize.ts +++ b/packages/astro/src/runtime/server/serialize.ts @@ -13,6 +13,7 @@ const PROP_TYPE = { Uint8Array: 8, Uint16Array: 9, Uint32Array: 10, + Infinity: 11, }; function serializeArray( @@ -93,11 +94,17 @@ function convertToSerializedForm( default: { if (value !== null && typeof value === 'object') { return [PROP_TYPE.Value, serializeObject(value, metadata, parents)]; - } else if (value === undefined) { + } + if (value === Infinity) { + return [PROP_TYPE.Infinity, 1]; + } + if (value === -Infinity) { + return [PROP_TYPE.Infinity, -1]; + } + if (value === undefined) { return [PROP_TYPE.Value]; - } else { - return [PROP_TYPE.Value, value]; } + return [PROP_TYPE.Value, value]; } } } diff --git a/packages/astro/src/vite-plugin-astro-server/response.ts b/packages/astro/src/vite-plugin-astro-server/response.ts index 707a26e4091c..bc316d7c21f2 100644 --- a/packages/astro/src/vite-plugin-astro-server/response.ts +++ b/packages/astro/src/vite-plugin-astro-server/response.ts @@ -53,7 +53,7 @@ export function writeHtmlResponse(res: http.ServerResponse, statusCode: number, } export async function writeWebResponse(res: http.ServerResponse, webResponse: Response) { - const { status, headers, body } = webResponse; + const { status, headers, body, statusText } = webResponse; // Attach any set-cookie headers added via Astro.cookies.set() const setCookieHeaders = Array.from(getSetCookiesFromResponse(webResponse)); @@ -67,7 +67,7 @@ export async function writeWebResponse(res: http.ServerResponse, webResponse: Re if (headers.has('set-cookie')) { _headers['set-cookie'] = headers.getSetCookie(); } - + res.statusMessage = statusText; res.writeHead(status, _headers); if (body) { if (Symbol.for('astro.responseBody') in webResponse) { diff --git a/packages/astro/src/vite-plugin-env/README.md b/packages/astro/src/vite-plugin-env/README.md index dbaf4b8bf7cc..305cff024240 100644 --- a/packages/astro/src/vite-plugin-env/README.md +++ b/packages/astro/src/vite-plugin-env/README.md @@ -1,6 +1,6 @@ # vite-plugin-env -Improves Vite's [Env Variables](https://vitejs.dev/guide/env-and-mode.html#env-files) support to include **private** env variables during Server-Side Rendering (SSR) but never in client-side rendering (CSR). +Improves Vite's [Env Variables](https://vite.dev/guide/env-and-mode.html#env-files) support to include **private** env variables during Server-Side Rendering (SSR) but never in client-side rendering (CSR). Private env variables can be accessed through `import.meta.env.SECRET` like Vite. Where the env variable is declared changes how it is replaced when transforming it: diff --git a/packages/astro/templates/actions.mjs b/packages/astro/templates/actions.mjs index 5efd31133238..349693eba3cc 100644 --- a/packages/astro/templates/actions.mjs +++ b/packages/astro/templates/actions.mjs @@ -5,13 +5,17 @@ import { getActionQueryString, } from 'astro:actions'; +const ENCODED_DOT = '%2E'; + function toActionProxy(actionCallback = {}, aggregatedPath = '') { return new Proxy(actionCallback, { get(target, objKey) { if (objKey in target || typeof objKey === 'symbol') { return target[objKey]; } - const path = aggregatedPath + objKey.toString(); + // Add the key, encoding dots so they're not interpreted as nested properties. + const path = + aggregatedPath + encodeURIComponent(objKey.toString()).replaceAll('.', ENCODED_DOT); function action(param) { return handleAction(param, path, this); } diff --git a/packages/astro/test/actions.test.js b/packages/astro/test/actions.test.js index 17758e82c8f6..793e6ebe77b0 100644 --- a/packages/astro/test/actions.test.js +++ b/packages/astro/test/actions.test.js @@ -115,6 +115,23 @@ describe('Astro Actions', () => { assert.equal(data.success, true); assert.equal(data.isFormData, true, 'Should receive plain FormData'); }); + + it('Handles special characters in action names', async () => { + for (const name of ['with%2Fslash', 'with%20space', 'with%2Edot']) { + const res = await fixture.fetch(`/_actions/${name}`, { + method: 'POST', + body: JSON.stringify({ name: 'ben' }), + headers: { + 'Content-Type': 'application/json', + }, + }); + assert.equal(res.ok, true); + const text = await res.text(); + assert.equal(res.headers.get('Content-Type'), 'application/json+devalue'); + const data = devalue.parse(text); + assert.equal(data, 'Hello, ben!'); + } + }); }); describe('build', () => { @@ -428,6 +445,24 @@ describe('Astro Actions', () => { const dataRest = devalue.parse(await resRest.text()); assert.equal('fake', dataRest?.uploadId); }); + + it('Handles special characters in action names', async () => { + for (const name of ['with%2Fslash', 'with%20space', 'with%2Edot']) { + const req = new Request(`http://example.com/_actions/${name}`, { + method: 'POST', + body: JSON.stringify({ name: 'ben' }), + headers: { + 'Content-Type': 'application/json', + }, + }); + const res = await app.render(req); + assert.equal(res.ok, true); + const text = await res.text(); + assert.equal(res.headers.get('Content-Type'), 'application/json+devalue'); + const data = devalue.parse(text); + assert.equal(data, 'Hello, ben!'); + } + }); }); }); diff --git a/packages/astro/test/cli.test.js b/packages/astro/test/cli.test.js index 5e3ef984f8c2..01c2ba6546e9 100644 --- a/packages/astro/test/cli.test.js +++ b/packages/astro/test/cli.test.js @@ -5,7 +5,7 @@ import { join } from 'node:path'; import { Writable } from 'node:stream'; import { describe, it } from 'node:test'; import { fileURLToPath } from 'node:url'; -import stripAnsi from 'strip-ansi'; +import { stripVTControlCharacters } from 'node:util'; import { cli, cliServerLogSetup, loadFixture, parseCliDevStart } from './test-utils.js'; describe('astro cli', () => { @@ -45,7 +45,7 @@ describe('astro cli', () => { dest: new Writable({ objectMode: true, write(event, _, callback) { - logs.push({ ...event, message: stripAnsi(event.message) }); + logs.push({ ...event, message: stripVTControlCharacters(event.message) }); if (event.message.includes('1 error')) { messageResolve(logs); } diff --git a/packages/astro/test/content-layer.test.js b/packages/astro/test/content-layer.test.js index 428a4ac3f204..78cde2bff2e8 100644 --- a/packages/astro/test/content-layer.test.js +++ b/packages/astro/test/content-layer.test.js @@ -317,5 +317,12 @@ describe('Content Layer', () => { assert.ok(updated.fileLoader[0].data.temperament.includes('Bouncy')); await fixture.resetAllFiles(); }); + + it('returns an error if we render an undefined entry', async () => { + const res = await fixture.fetch('/missing'); + const text = await res.text(); + assert.equal(res.status, 500); + assert.ok(text.includes('RenderUndefinedEntryError')); + }); }); }); diff --git a/packages/astro/test/core-image.test.js b/packages/astro/test/core-image.test.js index 9c62a679ef80..887a3a35de69 100644 --- a/packages/astro/test/core-image.test.js +++ b/packages/astro/test/core-image.test.js @@ -1263,4 +1263,57 @@ describe('astro:image', () => { assert.equal(imgData instanceof Buffer, true); }); }); + + describe('build data url', () => { + before(async () => { + fixture = await loadFixture({ + root: './fixtures/core-image-data-url/', + image: { + remotePatterns: [ + { + protocol: 'data', + }, + ], + }, + }); + + await fixture.build(); + }); + + it('uses short hash for data url filename', async () => { + const html = await fixture.readFile('/index.html'); + const $ = cheerio.load(html); + const src1 = $('#data-url img').attr('src'); + assert.equal(basename(src1).length < 32, true); + const src2 = $('#data-url-no-size img').attr('src'); + assert.equal(basename(src2).length < 32, true); + assert.equal(src1.split('_')[0], src2.split('_')[0]); + }); + + it('adds file extension for data url images', async () => { + const html = await fixture.readFile('/index.html'); + const $ = cheerio.load(html); + const src = $('#data-url img').attr('src'); + assert.equal(src.endsWith('.webp'), true); + }); + + it('writes data url images to dist', async () => { + const html = await fixture.readFile('/index.html'); + const $ = cheerio.load(html); + const src = $('#data-url img').attr('src'); + assert.equal(src.length > 0, true); + const data = await fixture.readFile(src, null); + assert.equal(data instanceof Buffer, true); + }); + + it('infers size of data url images', async () => { + const html = await fixture.readFile('/index.html'); + const $ = cheerio.load(html); + const img = $('#data-url-no-size img'); + const width = img.attr('width'); + const height = img.attr('height'); + assert.equal(width, '256'); + assert.equal(height, '144'); + }); + }); }); diff --git a/packages/astro/test/fixtures/actions/src/actions/index.ts b/packages/astro/test/fixtures/actions/src/actions/index.ts index 4e6120309fd6..78cc39620baa 100644 --- a/packages/astro/test/fixtures/actions/src/actions/index.ts +++ b/packages/astro/test/fixtures/actions/src/actions/index.ts @@ -161,4 +161,28 @@ export const server = { }; }, }), + "with.dot": defineAction({ + input: z.object({ + name: z.string(), + }), + handler: async (input) => { + return `Hello, ${input.name}!` + } + }), + "with space": defineAction({ + input: z.object({ + name: z.string(), + }), + handler: async (input) => { + return `Hello, ${input.name}!` + } + }), + "with/slash": defineAction({ + input: z.object({ + name: z.string(), + }), + handler: async (input) => { + return `Hello, ${input.name}!` + } + }), }; diff --git a/packages/astro/test/fixtures/content-layer/src/pages/missing.astro b/packages/astro/test/fixtures/content-layer/src/pages/missing.astro new file mode 100644 index 000000000000..6fee7db07b4a --- /dev/null +++ b/packages/astro/test/fixtures/content-layer/src/pages/missing.astro @@ -0,0 +1,14 @@ +--- +import { getEntry, render } from "astro:content" +// Skipping the broken page in production so the build doesn't fail +if(import.meta.env.PROD) { + return new Response(null, { status: 404 }) +} + +const entry = await getEntry("spacecraft", "missing") + +const { Content } = await render(entry) + +--- + + diff --git a/packages/astro/test/fixtures/core-image-data-url/package.json b/packages/astro/test/fixtures/core-image-data-url/package.json new file mode 100644 index 000000000000..a402422dbb20 --- /dev/null +++ b/packages/astro/test/fixtures/core-image-data-url/package.json @@ -0,0 +1,8 @@ +{ + "name": "@test/core-image-data-url", + "version": "0.0.0", + "private": true, + "dependencies": { + "astro": "workspace:*" + } +} \ No newline at end of file diff --git a/packages/astro/test/fixtures/core-image-data-url/src/pages/index.astro b/packages/astro/test/fixtures/core-image-data-url/src/pages/index.astro new file mode 100644 index 000000000000..5e8d291480f9 --- /dev/null +++ b/packages/astro/test/fixtures/core-image-data-url/src/pages/index.astro @@ -0,0 +1,17 @@ +--- +import { Image } from 'astro:assets'; +const data = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAQAAAACQCAQAAABNan0aAAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAAAmJLR0QAAKqNIzIAAAAJcEhZcwAACxMAAAsTAQCanBgAAAAHdElNRQflBAsNKgIhYT8HAAAAXklEQVR42u3BMQEAAADCoPVPbQlPoAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA4G8gnwABm4i4EAAAACV0RVh0ZGF0ZTpjcmVhdGUAMjAyMS0wNC0xMVQxMzo0MjowMiswMDowMNhkaiwAAAAldEVYdGRhdGU6bW9kaWZ5ADIwMjEtMDQtMTFUMTM6NDI6MDIrMDA6MDCpOdKQAAAAAElFTkSuQmCC" +--- + + + + + +
+ transparent +
+
+ transparent +
+ + \ No newline at end of file diff --git a/packages/astro/test/fixtures/ssr-api-route/src/pages/fail.js b/packages/astro/test/fixtures/ssr-api-route/src/pages/fail.js new file mode 100644 index 000000000000..f9852dd93794 --- /dev/null +++ b/packages/astro/test/fixtures/ssr-api-route/src/pages/fail.js @@ -0,0 +1,3 @@ +export async function GET({ request }) { + return fetch("https://http.im/status/500", request) +} diff --git a/packages/astro/test/fixtures/ssr-api-route/src/pages/food.json.js b/packages/astro/test/fixtures/ssr-api-route/src/pages/food.json.js index 2d6fb6d1b236..e145757b1342 100644 --- a/packages/astro/test/fixtures/ssr-api-route/src/pages/food.json.js +++ b/packages/astro/test/fixtures/ssr-api-route/src/pages/food.json.js @@ -5,14 +5,19 @@ export function GET() { { name: 'lettuce' }, { name: 'broccoli' }, { name: 'pizza' } - ]) + ]), { + status: 200, + statusText: `tasty`, + } ) } export async function POST({ params, request }) { const body = await request.text(); - return new Response(body === `some data` ? `ok` : `not ok`, { - status: 200, + const ok = body === `some data` + return new Response( ok ? `ok` : `not ok`, { + status: ok ? 200 : 400, + statusText: ok ? `ok` : `not ok`, headers: { 'Content-Type': 'application/x-www-form-urlencoded' } diff --git a/packages/astro/test/serialize.test.js b/packages/astro/test/serialize.test.js index 89eb3cc967d3..ced02ee3177c 100644 --- a/packages/astro/test/serialize.test.js +++ b/packages/astro/test/serialize.test.js @@ -89,6 +89,11 @@ describe('serialize', () => { const output = `{"a":[10,[1,2,3]]}`; assert.equal(serializeProps(input), output); }); + it('serializes Infinity and -Infinity', () => { + const input = { a: Infinity, b: -Infinity }; + const output = `{"a":[11,1],"b":[11,-1]}`; + assert.equal(serializeProps(input), output); + }); it('cannot serialize a cyclic reference', () => { const a = {}; a.b = a; diff --git a/packages/astro/test/ssr-api-route.test.js b/packages/astro/test/ssr-api-route.test.js index 2e7405326fcc..8e9c1bb5efa8 100644 --- a/packages/astro/test/ssr-api-route.test.js +++ b/packages/astro/test/ssr-api-route.test.js @@ -33,6 +33,7 @@ describe('API routes in SSR', () => { const request = new Request('http://example.com/food.json'); const response = await app.render(request); assert.equal(response.status, 200); + assert.equal(response.statusText, 'tasty'); const body = await response.json(); assert.equal(body.length, 3); }); @@ -78,6 +79,17 @@ describe('API routes in SSR', () => { assert.equal(text, 'ok'); }); + it('Can read custom status text from API routes', async () => { + const response = await fixture.fetch('/food.json', { + method: 'POST', + body: `not some data`, + }); + assert.equal(response.status, 400); + assert.equal(response.statusText, 'not ok'); + const text = await response.text(); + assert.equal(text, 'not ok'); + }); + it('Can be passed binary data from multipart formdata', async () => { const formData = new FormData(); const raw = await fs.promises.readFile( @@ -125,23 +137,29 @@ describe('API routes in SSR', () => { assert.equal(count, 2, 'Found two separate set-cookie response headers'); }); + it('can return an immutable response object', async () => { + const response = await fixture.fetch('/fail'); + const text = await response.text(); + assert.equal(response.status, 500); + assert.equal(text, ''); + }); + it('Has valid api context', async () => { const response = await fixture.fetch('/context/any'); assert.equal(response.status, 200); const data = await response.json(); - assert.equal(data.cookiesExist, true); - assert.equal(data.requestExist, true); - assert.equal(data.redirectExist, true); - assert.equal(data.propsExist, true); + assert.ok(data.cookiesExist); + assert.ok(data.requestExist); + assert.ok(data.redirectExist); + assert.ok(data.propsExist); assert.deepEqual(data.params, { param: 'any' }); assert.match(data.generator, /^Astro v/); - assert.equal( + assert.ok( ['http://[::1]:4321/blog/context/any', 'http://127.0.0.1:4321/blog/context/any'].includes( data.url, ), - true, ); - assert.equal(['::1', '127.0.0.1'].includes(data.clientAddress), true); + assert.ok(['::1', '127.0.0.1'].includes(data.clientAddress)); assert.equal(data.site, 'https://mysite.dev/subsite/'); }); }); diff --git a/packages/astro/test/test-utils.js b/packages/astro/test/test-utils.js index 68fab03b04d1..51606e815762 100644 --- a/packages/astro/test/test-utils.js +++ b/packages/astro/test/test-utils.js @@ -2,9 +2,9 @@ import fs from 'node:fs'; import os from 'node:os'; import path from 'node:path'; import { fileURLToPath } from 'node:url'; +import { stripVTControlCharacters } from 'node:util'; import { execa } from 'execa'; import fastGlob from 'fast-glob'; -import stripAnsi from 'strip-ansi'; import { Agent } from 'undici'; import { check } from '../dist/cli/check/index.js'; import { globalContentLayer } from '../dist/content/content-layer.js'; @@ -356,8 +356,8 @@ export async function parseCliDevStart(proc) { } proc.kill(); - stdout = stripAnsi(stdout); - stderr = stripAnsi(stderr); + stdout = stripVTControlCharacters(stdout); + stderr = stripVTControlCharacters(stderr); if (stderr) { throw new Error(stderr); diff --git a/packages/astro/test/units/config/config-validate.test.js b/packages/astro/test/units/config/config-validate.test.js index fc69b595fa4f..7eead0fd63d0 100644 --- a/packages/astro/test/units/config/config-validate.test.js +++ b/packages/astro/test/units/config/config-validate.test.js @@ -1,6 +1,6 @@ import * as assert from 'node:assert/strict'; import { describe, it } from 'node:test'; -import stripAnsi from 'strip-ansi'; +import { stripVTControlCharacters } from 'node:util'; import { z } from 'zod'; import { validateConfig } from '../../../dist/core/config/validate.js'; import { formatConfigErrorMessage } from '../../../dist/core/messages.js'; @@ -19,7 +19,7 @@ describe('Config Validation', () => { it('A validation error can be formatted correctly', async () => { const configError = await validateConfig({ site: 42 }, process.cwd()).catch((err) => err); assert.equal(configError instanceof z.ZodError, true); - const formattedError = stripAnsi(formatConfigErrorMessage(configError)); + const formattedError = stripVTControlCharacters(formatConfigErrorMessage(configError)); assert.equal( formattedError, `[config] Astro found issue(s) with your configuration: @@ -34,7 +34,7 @@ describe('Config Validation', () => { }; const configError = await validateConfig(veryBadConfig, process.cwd()).catch((err) => err); assert.equal(configError instanceof z.ZodError, true); - const formattedError = stripAnsi(formatConfigErrorMessage(configError)); + const formattedError = stripVTControlCharacters(formatConfigErrorMessage(configError)); assert.equal( formattedError, `[config] Astro found issue(s) with your configuration: diff --git a/packages/create-astro/package.json b/packages/create-astro/package.json index fcae9af3d07c..d48c7065d294 100644 --- a/packages/create-astro/package.json +++ b/packages/create-astro/package.json @@ -37,7 +37,6 @@ "devDependencies": { "arg": "^5.0.2", "astro-scripts": "workspace:*", - "strip-ansi": "^7.1.0", "strip-json-comments": "^5.0.1" }, "engines": { diff --git a/packages/create-astro/src/messages.ts b/packages/create-astro/src/messages.ts index ba765f723258..898c9c728e28 100644 --- a/packages/create-astro/src/messages.ts +++ b/packages/create-astro/src/messages.ts @@ -1,8 +1,8 @@ import { exec } from 'node:child_process'; +import { stripVTControlCharacters } from 'node:util'; /* eslint no-console: 'off' */ import { color, say as houston, label, spinner as load } from '@astrojs/cli-kit'; import { align, sleep } from '@astrojs/cli-kit/utils'; -import stripAnsi from 'strip-ansi'; import { shell } from './shell.js'; // Users might lack access to the global npm registry, this function @@ -122,7 +122,7 @@ export const nextSteps = async ({ projectDir, devCmd }: { projectDir: string; de `\n${prefix}Enter your project directory using`, color.cyan(`cd ${projectDir}`, ''), ]; - const len = enter[0].length + stripAnsi(enter[1]).length; + const len = enter[0].length + stripVTControlCharacters(enter[1]).length; log(enter.join(len > max ? '\n' + prefix : ' ')); } log( diff --git a/packages/create-astro/test/utils.js b/packages/create-astro/test/utils.js index 5412c8cabce2..dfae93c33026 100644 --- a/packages/create-astro/test/utils.js +++ b/packages/create-astro/test/utils.js @@ -1,6 +1,6 @@ import fs from 'node:fs'; import { before, beforeEach } from 'node:test'; -import stripAnsi from 'strip-ansi'; +import { stripVTControlCharacters } from 'node:util'; import { setStdout } from '../dist/index.js'; export function setup() { @@ -9,7 +9,7 @@ export function setup() { setStdout( Object.assign({}, process.stdout, { write(buf) { - ctx.messages.push(stripAnsi(String(buf)).trim()); + ctx.messages.push(stripVTControlCharacters(String(buf)).trim()); return true; }, }), diff --git a/packages/db/package.json b/packages/db/package.json index 8b111edbe79e..d54cc4260c07 100644 --- a/packages/db/package.json +++ b/packages/db/package.json @@ -80,7 +80,6 @@ "open": "^10.1.0", "ora": "^8.1.0", "prompts": "^2.4.2", - "strip-ansi": "^7.1.0", "yargs-parser": "^21.1.1", "zod": "^3.23.8" }, diff --git a/packages/db/src/core/cli/migration-queries.ts b/packages/db/src/core/cli/migration-queries.ts index 94ec3763d0e1..42d00b2b13db 100644 --- a/packages/db/src/core/cli/migration-queries.ts +++ b/packages/db/src/core/cli/migration-queries.ts @@ -1,9 +1,9 @@ +import { stripVTControlCharacters } from 'node:util'; import deepDiff from 'deep-diff'; import { sql } from 'drizzle-orm'; import { SQLiteAsyncDialect } from 'drizzle-orm/sqlite-core'; import * as color from 'kleur/colors'; import { customAlphabet } from 'nanoid'; -import stripAnsi from 'strip-ansi'; import { hasPrimaryKey } from '../../runtime/index.js'; import { createRemoteDatabaseClient } from '../../runtime/index.js'; import { isSerializedSQL } from '../../runtime/types.js'; @@ -531,7 +531,7 @@ export function formatDataLossMessage(confirmations: string[], isColor = true): ); let finalMessage = messages.join('\n'); if (!isColor) { - finalMessage = stripAnsi(finalMessage); + finalMessage = stripVTControlCharacters(finalMessage); } return finalMessage; } diff --git a/packages/integrations/react/CHANGELOG.md b/packages/integrations/react/CHANGELOG.md index e6bedd08f31b..65eb7056cbd8 100644 --- a/packages/integrations/react/CHANGELOG.md +++ b/packages/integrations/react/CHANGELOG.md @@ -288,13 +288,13 @@ ### Patch Changes -- [#9122](https://github.com/withastro/astro/pull/9122) [`1c48ed286`](https://github.com/withastro/astro/commit/1c48ed286538ab9e354eca4e4dcd7c6385c96721) Thanks [@bluwy](https://github.com/bluwy)! - Adds Vite 5 support. There are no breaking changes from Astro. Check the [Vite migration guide](https://vitejs.dev/guide/migration.html) for details of the breaking changes from Vite instead. +- [#9122](https://github.com/withastro/astro/pull/9122) [`1c48ed286`](https://github.com/withastro/astro/commit/1c48ed286538ab9e354eca4e4dcd7c6385c96721) Thanks [@bluwy](https://github.com/bluwy)! - Adds Vite 5 support. There are no breaking changes from Astro. Check the [Vite migration guide](https://vite.dev/guide/migration.html) for details of the breaking changes from Vite instead. ## 3.0.7-beta.0 ### Patch Changes -- [#9122](https://github.com/withastro/astro/pull/9122) [`1c48ed286`](https://github.com/withastro/astro/commit/1c48ed286538ab9e354eca4e4dcd7c6385c96721) Thanks [@bluwy](https://github.com/bluwy)! - Adds Vite 5 support. There are no breaking changes from Astro. Check the [Vite migration guide](https://vitejs.dev/guide/migration.html) for details of the breaking changes from Vite instead. +- [#9122](https://github.com/withastro/astro/pull/9122) [`1c48ed286`](https://github.com/withastro/astro/commit/1c48ed286538ab9e354eca4e4dcd7c6385c96721) Thanks [@bluwy](https://github.com/bluwy)! - Adds Vite 5 support. There are no breaking changes from Astro. Check the [Vite migration guide](https://vite.dev/guide/migration.html) for details of the breaking changes from Vite instead. ## 3.0.6 diff --git a/packages/integrations/sitemap/CHANGELOG.md b/packages/integrations/sitemap/CHANGELOG.md index c498b97cc677..ceede43c63b5 100644 --- a/packages/integrations/sitemap/CHANGELOG.md +++ b/packages/integrations/sitemap/CHANGELOG.md @@ -1,5 +1,11 @@ # @astrojs/sitemap +## 3.2.0 + +### Minor Changes + +- [#11485](https://github.com/withastro/astro/pull/11485) [`fbe1bc5`](https://github.com/withastro/astro/commit/fbe1bc51d89994c4919c12768908658604513bd3) Thanks [@sondr3](https://github.com/sondr3)! - Adds new `xslURL` option to enable styling of sitemaps + ## 3.1.6 ### Patch Changes diff --git a/packages/integrations/sitemap/package.json b/packages/integrations/sitemap/package.json index b48e974692f9..b16ac77f84f1 100644 --- a/packages/integrations/sitemap/package.json +++ b/packages/integrations/sitemap/package.json @@ -1,7 +1,7 @@ { "name": "@astrojs/sitemap", "description": "Generate a sitemap for your Astro site", - "version": "3.1.6", + "version": "3.2.0", "type": "module", "types": "./dist/index.d.ts", "author": "withastro", diff --git a/packages/integrations/sitemap/src/index.ts b/packages/integrations/sitemap/src/index.ts index 057fc2371d62..4342ed5dba0b 100644 --- a/packages/integrations/sitemap/src/index.ts +++ b/packages/integrations/sitemap/src/index.ts @@ -88,7 +88,7 @@ const createPlugin = (options?: SitemapOptions): AstroIntegration => { const { filter, customPages, serialize, entryLimit } = opts; - let finalSiteUrl = new URL(config.base, config.site); + const finalSiteUrl = new URL(config.base, config.site); const shouldIgnoreStatus = isStatusCodePage(Object.keys(opts.i18n?.locales ?? {})); let pageUrls = pages .filter((p) => !shouldIgnoreStatus(p.pathname)) @@ -100,7 +100,7 @@ const createPlugin = (options?: SitemapOptions): AstroIntegration => { return new URL(fullPath, finalSiteUrl).href; }); - let routeUrls = routes.reduce((urls, r) => { + const routeUrls = routes.reduce((urls, r) => { // Only expose pages, not endpoints or redirects if (r.type !== 'page') return urls; @@ -116,7 +116,7 @@ const createPlugin = (options?: SitemapOptions): AstroIntegration => { if (fullPath.endsWith('/')) fullPath += r.generate(r.pathname).substring(1); else fullPath += r.generate(r.pathname); - let newUrl = new URL(fullPath, finalSiteUrl).href; + const newUrl = new URL(fullPath, finalSiteUrl).href; if (config.trailingSlash === 'never') { urls.push(newUrl); @@ -168,6 +168,7 @@ const createPlugin = (options?: SitemapOptions): AstroIntegration => { } } const destDir = fileURLToPath(dir); + const xslURL = opts.xslURL ? new URL(opts.xslURL, finalSiteUrl).href : undefined; await writeSitemap( { hostname: finalSiteUrl.href, @@ -175,6 +176,7 @@ const createPlugin = (options?: SitemapOptions): AstroIntegration => { publicBasePath: config.base, sourceData: urlData, limit: entryLimit, + xslURL: xslURL, }, config, ); diff --git a/packages/integrations/sitemap/src/schema.ts b/packages/integrations/sitemap/src/schema.ts index 17ca41b413cc..ba5438452395 100644 --- a/packages/integrations/sitemap/src/schema.ts +++ b/packages/integrations/sitemap/src/schema.ts @@ -9,6 +9,7 @@ export const SitemapOptionsSchema = z filter: z.function().args(z.string()).returns(z.boolean()).optional(), customPages: z.string().url().array().optional(), canonicalURL: z.string().url().optional(), + xslURL: z.string().optional(), i18n: z .object({ diff --git a/packages/integrations/sitemap/src/write-sitemap.ts b/packages/integrations/sitemap/src/write-sitemap.ts index 4c189ee3c990..ef36f1ab2497 100644 --- a/packages/integrations/sitemap/src/write-sitemap.ts +++ b/packages/integrations/sitemap/src/write-sitemap.ts @@ -17,6 +17,7 @@ type WriteSitemapConfig = { destinationDir: string; publicBasePath?: string; limit?: number; + xslURL?: string; }; // adapted from sitemap.js/sitemap-simple @@ -28,6 +29,7 @@ export async function writeSitemap( destinationDir, limit = 50000, publicBasePath = './', + xslURL: xslUrl, }: WriteSitemapConfig, astroConfig: AstroConfig, ) { @@ -38,6 +40,7 @@ export async function writeSitemap( getSitemapStream: (i) => { const sitemapStream = new SitemapStream({ hostname, + xslUrl, }); const path = `./sitemap-${i}.xml`; const writePath = resolve(destinationDir, path); @@ -63,7 +66,7 @@ export async function writeSitemap( }, }); - let src = Readable.from(sourceData); + const src = Readable.from(sourceData); const indexPath = resolve(destinationDir, `./sitemap-index.xml`); return promisify(pipeline)(src, sitemapAndIndexStream, createWriteStream(indexPath)); } diff --git a/packages/integrations/sitemap/test/filter.test.js b/packages/integrations/sitemap/test/config.test.js similarity index 61% rename from packages/integrations/sitemap/test/filter.test.js rename to packages/integrations/sitemap/test/config.test.js index adecb59e6c0e..e4b7c38826e8 100644 --- a/packages/integrations/sitemap/test/filter.test.js +++ b/packages/integrations/sitemap/test/config.test.js @@ -3,7 +3,7 @@ import { before, describe, it } from 'node:test'; import { sitemap } from './fixtures/static/deps.mjs'; import { loadFixture, readXML } from './test-utils.js'; -describe('Filter support', () => { +describe('Config', () => { /** @type {import('./test-utils.js').Fixture} */ let fixture; @@ -14,17 +14,26 @@ describe('Filter support', () => { integrations: [ sitemap({ filter: (page) => page === 'http://example.com/one/', + xslURL: '/sitemap.xsl', }), ], }); await fixture.build(); }); - it('Just one page is added', async () => { + it('filter: Just one page is added', async () => { const data = await readXML(fixture.readFile('/sitemap-0.xml')); const urls = data.urlset.url; assert.equal(urls.length, 1); }); + + it('xslURL: Includes xml-stylsheet', async () => { + const xml = await fixture.readFile('/sitemap-0.xml'); + assert.ok( + xml.includes(''), + xml, + ); + }); }); describe('SSR', () => { @@ -34,16 +43,25 @@ describe('Filter support', () => { integrations: [ sitemap({ filter: (page) => page === 'http://example.com/one/', + xslURL: '/sitemap.xsl', }), ], }); await fixture.build(); }); - it('Just one page is added', async () => { + it('filter: Just one page is added', async () => { const data = await readXML(fixture.readFile('/client/sitemap-0.xml')); const urls = data.urlset.url; assert.equal(urls.length, 1); }); + + it('xslURL: Includes xml-stylsheet', async () => { + const xml = await fixture.readFile('/client/sitemap-0.xml'); + assert.ok( + xml.includes(''), + xml, + ); + }); }); }); diff --git a/packages/integrations/svelte/CHANGELOG.md b/packages/integrations/svelte/CHANGELOG.md index 88c18163314e..2d6c5b42b2a9 100644 --- a/packages/integrations/svelte/CHANGELOG.md +++ b/packages/integrations/svelte/CHANGELOG.md @@ -127,7 +127,7 @@ ### Major Changes -- [#9122](https://github.com/withastro/astro/pull/9122) [`1c48ed286`](https://github.com/withastro/astro/commit/1c48ed286538ab9e354eca4e4dcd7c6385c96721) Thanks [@bluwy](https://github.com/bluwy)! - Adds Vite 5 support. There are no breaking changes from Astro. Check the [Vite migration guide](https://vitejs.dev/guide/migration.html) for details of the breaking changes from Vite instead. +- [#9122](https://github.com/withastro/astro/pull/9122) [`1c48ed286`](https://github.com/withastro/astro/commit/1c48ed286538ab9e354eca4e4dcd7c6385c96721) Thanks [@bluwy](https://github.com/bluwy)! - Adds Vite 5 support. There are no breaking changes from Astro. Check the [Vite migration guide](https://vite.dev/guide/migration.html) for details of the breaking changes from Vite instead. - [#9122](https://github.com/withastro/astro/pull/9122) [`1c48ed286`](https://github.com/withastro/astro/commit/1c48ed286538ab9e354eca4e4dcd7c6385c96721) Thanks [@bluwy](https://github.com/bluwy)! - Drops support for Svelte 3 as `@sveltejs/vite-plugin-svelte` is updated to `3.0.0` which does not support Svelte 3 @@ -135,7 +135,7 @@ ### Major Changes -- [#9122](https://github.com/withastro/astro/pull/9122) [`1c48ed286`](https://github.com/withastro/astro/commit/1c48ed286538ab9e354eca4e4dcd7c6385c96721) Thanks [@bluwy](https://github.com/bluwy)! - Adds Vite 5 support. There are no breaking changes from Astro. Check the [Vite migration guide](https://vitejs.dev/guide/migration.html) for details of the breaking changes from Vite instead. +- [#9122](https://github.com/withastro/astro/pull/9122) [`1c48ed286`](https://github.com/withastro/astro/commit/1c48ed286538ab9e354eca4e4dcd7c6385c96721) Thanks [@bluwy](https://github.com/bluwy)! - Adds Vite 5 support. There are no breaking changes from Astro. Check the [Vite migration guide](https://vite.dev/guide/migration.html) for details of the breaking changes from Vite instead. - [#9122](https://github.com/withastro/astro/pull/9122) [`1c48ed286`](https://github.com/withastro/astro/commit/1c48ed286538ab9e354eca4e4dcd7c6385c96721) Thanks [@bluwy](https://github.com/bluwy)! - Drops support for Svelte 3 as `@sveltejs/vite-plugin-svelte` is updated to `3.0.0` which does not support Svelte 3 @@ -345,7 +345,7 @@ - [#5782](https://github.com/withastro/astro/pull/5782) [`1f92d64ea`](https://github.com/withastro/astro/commit/1f92d64ea35c03fec43aff64eaf704dc5a9eb30a) Thanks [@Princesseuh](https://github.com/Princesseuh)! - Remove support for Node 14. Minimum supported Node version is now >=16.12.0 -- [#5685](https://github.com/withastro/astro/pull/5685) [`f6cf92b48`](https://github.com/withastro/astro/commit/f6cf92b48317a19a3840ad781b77d6d3cae143bb) Thanks [@bluwy](https://github.com/bluwy)! - Upgrade to Vite 4. Please see its [migration guide](https://vitejs.dev/guide/migration.html) for more information. +- [#5685](https://github.com/withastro/astro/pull/5685) [`f6cf92b48`](https://github.com/withastro/astro/commit/f6cf92b48317a19a3840ad781b77d6d3cae143bb) Thanks [@bluwy](https://github.com/bluwy)! - Upgrade to Vite 4. Please see its [migration guide](https://vite.dev/guide/migration.html) for more information. - [#5685](https://github.com/withastro/astro/pull/5685) [`f6cf92b48`](https://github.com/withastro/astro/commit/f6cf92b48317a19a3840ad781b77d6d3cae143bb) Thanks [@bluwy](https://github.com/bluwy)! - Simplify Svelte preprocess setup. `