From 7a231e476380b2cf384c4afc20908932e3e347a4 Mon Sep 17 00:00:00 2001 From: "Fred K. Schott" Date: Mon, 4 Dec 2023 05:24:22 -0800 Subject: [PATCH 01/59] [Toolbar] Fix tooltip overlap bug (#9283) --- .../src/runtime/client/dev-overlay/plugins/utils/highlight.ts | 4 ++++ packages/astro/src/runtime/client/dev-overlay/plugins/xray.ts | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/astro/src/runtime/client/dev-overlay/plugins/utils/highlight.ts b/packages/astro/src/runtime/client/dev-overlay/plugins/utils/highlight.ts index 9dad2b0f597c..73d7fe112757 100644 --- a/packages/astro/src/runtime/client/dev-overlay/plugins/utils/highlight.ts +++ b/packages/astro/src/runtime/client/dev-overlay/plugins/utils/highlight.ts @@ -57,9 +57,12 @@ export function attachTooltipToHighlight( originalElement: Element ) { highlight.shadowRoot.append(tooltip); + // Track the original z-index so that we can restore it after hover + const originalZIndex = highlight.style.zIndex; (['mouseover', 'focus'] as const).forEach((event) => { highlight.addEventListener(event, () => { + highlight.style.zIndex = '9999999999'; tooltip.dataset.show = 'true'; const originalRect = originalElement.getBoundingClientRect(); const dialogRect = tooltip.getBoundingClientRect(); @@ -77,6 +80,7 @@ export function attachTooltipToHighlight( (['mouseout', 'blur'] as const).forEach((event) => { highlight.addEventListener(event, () => { tooltip.dataset.show = 'false'; + highlight.style.zIndex = originalZIndex; }); }); } diff --git a/packages/astro/src/runtime/client/dev-overlay/plugins/xray.ts b/packages/astro/src/runtime/client/dev-overlay/plugins/xray.ts index ed1be3edead5..8ce16f7c4f6c 100644 --- a/packages/astro/src/runtime/client/dev-overlay/plugins/xray.ts +++ b/packages/astro/src/runtime/client/dev-overlay/plugins/xray.ts @@ -80,7 +80,6 @@ export default { const rect = islandElement.getBoundingClientRect(); const highlight = createHighlight(rect); const tooltip = buildIslandTooltip(island); - attachTooltipToHighlight(highlight, tooltip, islandElement); // Set the z-index to be 1 higher than the greatest z-index in the stack. // And also set the highlight/tooltip as being fixed position if they are inside @@ -94,6 +93,7 @@ export default { tooltip.style.position = highlight.style.position = 'fixed'; } + attachTooltipToHighlight(highlight, tooltip, islandElement); canvas.append(highlight); islandsOverlays.push({ highlightElement: highlight, island: islandElement }); }); From 97e43022defaa9ddccd7bb62956d6cdda74bb36b Mon Sep 17 00:00:00 2001 From: "Fred K. Schott" Date: Mon, 4 Dec 2023 05:25:10 -0800 Subject: [PATCH 02/59] [Toolbar] Improve third party plugin load performance (#9281) --- .../astro/src/runtime/client/dev-overlay/entrypoint.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/astro/src/runtime/client/dev-overlay/entrypoint.ts b/packages/astro/src/runtime/client/dev-overlay/entrypoint.ts index 2124c21e07e0..d2145d9ee643 100644 --- a/packages/astro/src/runtime/client/dev-overlay/entrypoint.ts +++ b/packages/astro/src/runtime/client/dev-overlay/entrypoint.ts @@ -1,12 +1,14 @@ import type { DevOverlayPlugin as DevOverlayPluginDefinition } from '../../../@types/astro.js'; import { type AstroDevOverlay, type DevOverlayPlugin } from './overlay.js'; import { settings } from './settings.js'; +// @ts-expect-error +import {loadDevOverlayPlugins} from 'astro:dev-overlay'; let overlay: AstroDevOverlay; document.addEventListener('DOMContentLoaded', async () => { const [ - { loadDevOverlayPlugins }, + customPluginsDefinitions, { default: astroDevToolPlugin }, { default: astroAuditPlugin }, { default: astroXrayPlugin }, @@ -23,8 +25,7 @@ document.addEventListener('DOMContentLoaded', async () => { DevOverlayIcon, }, ] = await Promise.all([ - // @ts-expect-error - import('astro:dev-overlay'), + loadDevOverlayPlugins() as DevOverlayPluginDefinition[], import('./plugins/astro.js'), import('./plugins/audit.js'), import('./plugins/xray.js'), @@ -239,7 +240,6 @@ document.addEventListener('DOMContentLoaded', async () => { }, } satisfies DevOverlayPluginDefinition; - const customPluginsDefinitions = (await loadDevOverlayPlugins()) as DevOverlayPluginDefinition[]; const plugins: DevOverlayPlugin[] = [ ...[ astroDevToolPlugin, From 54fac60ee0826608ea7b1b00c1b233561b666de0 Mon Sep 17 00:00:00 2001 From: "Fred K. Schott" Date: Mon, 4 Dec 2023 13:26:20 +0000 Subject: [PATCH 03/59] [ci] format --- packages/astro/src/runtime/client/dev-overlay/entrypoint.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/astro/src/runtime/client/dev-overlay/entrypoint.ts b/packages/astro/src/runtime/client/dev-overlay/entrypoint.ts index d2145d9ee643..773d2493104e 100644 --- a/packages/astro/src/runtime/client/dev-overlay/entrypoint.ts +++ b/packages/astro/src/runtime/client/dev-overlay/entrypoint.ts @@ -2,7 +2,7 @@ import type { DevOverlayPlugin as DevOverlayPluginDefinition } from '../../../@t import { type AstroDevOverlay, type DevOverlayPlugin } from './overlay.js'; import { settings } from './settings.js'; // @ts-expect-error -import {loadDevOverlayPlugins} from 'astro:dev-overlay'; +import { loadDevOverlayPlugins } from 'astro:dev-overlay'; let overlay: AstroDevOverlay; From 29fa5044672988393878f1b7ba8eeb3acca7b270 Mon Sep 17 00:00:00 2001 From: "Fred K. Schott" Date: Mon, 4 Dec 2023 05:26:34 -0800 Subject: [PATCH 04/59] [Toolbar] Final style polish and code cleanup (#9282) Co-authored-by: Princesseuh <3019731+Princesseuh@users.noreply.github.com> --- packages/astro/e2e/dev-overlay.test.js | 2 +- .../src/runtime/client/dev-overlay/overlay.ts | 36 ++++------------- .../client/dev-overlay/plugins/audit.ts | 26 ++++++++++++- .../client/dev-overlay/plugins/settings.ts | 25 +++++++----- .../client/dev-overlay/plugins/xray.ts | 39 ++++++++++++++----- .../client/dev-overlay/ui-library/tooltip.ts | 9 ++++- .../client/dev-overlay/ui-library/window.ts | 4 ++ 7 files changed, 91 insertions(+), 50 deletions(-) diff --git a/packages/astro/e2e/dev-overlay.test.js b/packages/astro/e2e/dev-overlay.test.js index a5e3560e905a..b4188b1e7817 100644 --- a/packages/astro/e2e/dev-overlay.test.js +++ b/packages/astro/e2e/dev-overlay.test.js @@ -200,7 +200,7 @@ test.describe('Dev Overlay', () => { await expect(settingsWindow).toHaveCount(1); await expect(settingsWindow).toBeVisible(); - const hideOverlay = settingsWindow.getByRole('heading', { name: 'Hide overlay' }); + const hideOverlay = settingsWindow.getByRole('heading', { name: 'Hide toolbar' }); await expect(hideOverlay).toBeVisible(); }); }); diff --git a/packages/astro/src/runtime/client/dev-overlay/overlay.ts b/packages/astro/src/runtime/client/dev-overlay/overlay.ts index 2def988020ac..1a3457ceb153 100644 --- a/packages/astro/src/runtime/client/dev-overlay/overlay.ts +++ b/packages/astro/src/runtime/client/dev-overlay/overlay.ts @@ -71,7 +71,7 @@ export class AstroDevOverlay extends HTMLElement { } #dev-overlay[data-hidden] #dev-bar .item { - opacity: 0; + opacity: 0.2; } #dev-bar-hitbox-above, @@ -340,38 +340,18 @@ export class AstroDevOverlay extends HTMLElement { }); }); - // On click, show the overlay if it's hidden, it's likely the user wants to interact with it - this.shadowRoot.addEventListener('click', () => { - if (!this.isHidden()) return; - this.setOverlayVisible(true); - }); - - this.devOverlay!.addEventListener('keyup', (event) => { - if (event.code === 'Space' || event.code === 'Enter') { - if (!this.isHidden()) return; - this.setOverlayVisible(true); - } - if (event.key === 'Escape') { - if (this.isHidden()) return; - if (this.getActivePlugin()) return; - this.setOverlayVisible(false); - } - }); - document.addEventListener('keyup', (event) => { - if (event.key !== 'Escape') { - return; - } - if (this.isHidden()) { - return; - } + if (event.key !== 'Escape') return; + if (this.isHidden()) return; const activePlugin = this.getActivePlugin(); if (activePlugin) { - this.setPluginStatus(activePlugin, false); - return; + this.togglePluginStatus(activePlugin); + } else { + this.setOverlayVisible(false); } - this.setOverlayVisible(false); }); + + } async initPlugin(plugin: DevOverlayPlugin) { diff --git a/packages/astro/src/runtime/client/dev-overlay/plugins/audit.ts b/packages/astro/src/runtime/client/dev-overlay/plugins/audit.ts index 51d63f7ab42c..08c8b6434ff2 100644 --- a/packages/astro/src/runtime/client/dev-overlay/plugins/audit.ts +++ b/packages/astro/src/runtime/client/dev-overlay/plugins/audit.ts @@ -31,6 +31,27 @@ export default { document.addEventListener('astro:after-swap', async () => lint()); document.addEventListener('astro:page-load', async () => refreshLintPositions); + function onPageClick(event: MouseEvent) { + const target = event.target as Element | null; + if (!target) return; + if (!target.closest) return; + if (target.closest('astro-dev-toolbar')) return; + eventTarget.dispatchEvent( + new CustomEvent('toggle-plugin', { + detail: { + state: false, + }, + }) + ); + } + eventTarget.addEventListener('plugin-toggled', (event: any) => { + if (event.detail.state === true) { + document.addEventListener('click', onPageClick, true); + } else { + document.removeEventListener('click', onPageClick, true); + } + }); + async function lint() { audits.forEach(({ highlightElement }) => { highlightElement.remove(); @@ -89,8 +110,11 @@ export default { }
-

No issues detected.

+

No accessibility issues detected.

+

+ Nice work! This app scans the page and highlights common accessibility issues for you, like a missing "alt" attribute on an image. +

` ); diff --git a/packages/astro/src/runtime/client/dev-overlay/plugins/settings.ts b/packages/astro/src/runtime/client/dev-overlay/plugins/settings.ts index daf1cae00031..672b7bbda36a 100644 --- a/packages/astro/src/runtime/client/dev-overlay/plugins/settings.ts +++ b/packages/astro/src/runtime/client/dev-overlay/plugins/settings.ts @@ -80,7 +80,7 @@ export default { font-size: 16px; font-weight: 400; color: white; - margin-bottom: 0; + margin-bottom: 4px; } label { @@ -114,30 +114,37 @@ export default { padding: .3em; } + label > section { + max-width: 67%; + } p { - line-height: 2em; + line-height: 1.5em; } - a, a:visited { color: var(--color-purple); } + a:hover { + color: #f4ecfd; + }

Settings

-
+
-

General

-
-

Hide overlay

-

Run astro preferences disable devOverlay in your terminal to disable this dev overlay in this project. Learn more.

+ ` ); const general = windowElement.querySelector('#general')!; for (const settingsRow of settingsRows) { - general.after(getElementForSettingAsString(settingsRow)); general.after(document.createElement('hr')); + general.after(getElementForSettingAsString(settingsRow)); } canvas.append(windowElement); diff --git a/packages/astro/src/runtime/client/dev-overlay/plugins/xray.ts b/packages/astro/src/runtime/client/dev-overlay/plugins/xray.ts index 8ce16f7c4f6c..a460e2a3b04b 100644 --- a/packages/astro/src/runtime/client/dev-overlay/plugins/xray.ts +++ b/packages/astro/src/runtime/client/dev-overlay/plugins/xray.ts @@ -15,7 +15,7 @@ export default { id: 'astro:xray', name: 'Inspect', icon: icon, - init(canvas) { + init(canvas, eventTarget) { let islandsOverlays: { highlightElement: DevOverlayHighlight; island: HTMLElement }[] = []; addIslandsOverlay(); @@ -23,6 +23,30 @@ export default { document.addEventListener('astro:after-swap', addIslandsOverlay); document.addEventListener('astro:page-load', refreshIslandsOverlayPositions); + function onPageClick(event: MouseEvent) { + const target = event.target as Element | null; + if (!target) return; + if (!target.closest) return; + if (target.closest('astro-dev-toolbar')) return; + event.preventDefault(); + event.stopPropagation(); + eventTarget.dispatchEvent( + new CustomEvent('toggle-plugin', { + detail: { + state: false, + }, + }) + ); + } + + eventTarget.addEventListener('plugin-toggled', (event: any) => { + if (event.detail.state === true) { + document.addEventListener('click', onPageClick, true); + } else { + document.removeEventListener('click', onPageClick, true); + } + }); + function addIslandsOverlay() { islandsOverlays.forEach(({ highlightElement }) => { highlightElement.remove(); @@ -60,6 +84,9 @@ export default {

No islands detected.

+

+ It looks like there are no interactive component islands on this page. Did you forget to add a client directive to your interactive UI component? +

` ); @@ -131,9 +158,8 @@ export default { if (Object.keys(islandProps).length > 0) { tooltip.sections.push({ title: 'Props', - content: `${Object.entries(islandProps) - .map((prop) => `${prop[0]}=${getPropValue(prop[1] as any)}`) - .join(', ')}`, + content: `
${JSON.stringify(Object.fromEntries(Object.entries(islandProps)
+						.map((prop: any) =>([prop[0], prop[1][1]]))), undefined, 2)}
`, }); } @@ -159,10 +185,5 @@ export default { return tooltip; } - - function getPropValue(prop: [number, any]) { - const [_, value] = prop; - return JSON.stringify(value, null, 2); - } }, } satisfies DevOverlayPlugin; diff --git a/packages/astro/src/runtime/client/dev-overlay/ui-library/tooltip.ts b/packages/astro/src/runtime/client/dev-overlay/ui-library/tooltip.ts index dbd7add5dd51..d535865cf79e 100644 --- a/packages/astro/src/runtime/client/dev-overlay/ui-library/tooltip.ts +++ b/packages/astro/src/runtime/client/dev-overlay/ui-library/tooltip.ts @@ -101,13 +101,18 @@ export class DevOverlayTooltip extends HTMLElement { cursor: pointer; } - code { - background: rgba(136, 58, 234, 0.33); + pre, code { + background: rgb(78, 27, 145); font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace; border-radius: 2px; font-size: 14px; padding: 2px; } + pre { + padding: 1em; + margin: 0 0; + overflow: auto; + } `; const fragment = new DocumentFragment(); diff --git a/packages/astro/src/runtime/client/dev-overlay/ui-library/window.ts b/packages/astro/src/runtime/client/dev-overlay/ui-library/window.ts index 0873d888d8a9..bab936d4bbd8 100644 --- a/packages/astro/src/runtime/client/dev-overlay/ui-library/window.ts +++ b/packages/astro/src/runtime/client/dev-overlay/ui-library/window.ts @@ -70,6 +70,10 @@ export class DevOverlayWindow extends HTMLElement { border: 1px solid rgba(27, 30, 36, 1); margin: 1em 0; } + + p, ::slotted(p) { + line-height: 1.5em; + } From 2fdcd6d71997bc50ea1b4b36a5c775b03f42ce9b Mon Sep 17 00:00:00 2001 From: "Fred K. Schott" Date: Mon, 4 Dec 2023 13:27:45 +0000 Subject: [PATCH 05/59] [ci] format --- packages/astro/src/runtime/client/dev-overlay/overlay.ts | 2 -- .../astro/src/runtime/client/dev-overlay/plugins/xray.ts | 9 +++++++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/packages/astro/src/runtime/client/dev-overlay/overlay.ts b/packages/astro/src/runtime/client/dev-overlay/overlay.ts index 1a3457ceb153..98663911434d 100644 --- a/packages/astro/src/runtime/client/dev-overlay/overlay.ts +++ b/packages/astro/src/runtime/client/dev-overlay/overlay.ts @@ -350,8 +350,6 @@ export class AstroDevOverlay extends HTMLElement { this.setOverlayVisible(false); } }); - - } async initPlugin(plugin: DevOverlayPlugin) { diff --git a/packages/astro/src/runtime/client/dev-overlay/plugins/xray.ts b/packages/astro/src/runtime/client/dev-overlay/plugins/xray.ts index a460e2a3b04b..5b7327029686 100644 --- a/packages/astro/src/runtime/client/dev-overlay/plugins/xray.ts +++ b/packages/astro/src/runtime/client/dev-overlay/plugins/xray.ts @@ -158,8 +158,13 @@ export default { if (Object.keys(islandProps).length > 0) { tooltip.sections.push({ title: 'Props', - content: `
${JSON.stringify(Object.fromEntries(Object.entries(islandProps)
-						.map((prop: any) =>([prop[0], prop[1][1]]))), undefined, 2)}
`, + content: `
${JSON.stringify(
+						Object.fromEntries(
+							Object.entries(islandProps).map((prop: any) => [prop[0], prop[1][1]])
+						),
+						undefined,
+						2
+					)}
`, }); } From bd9907867b0a491cb6c747ec51c2313687af501e Mon Sep 17 00:00:00 2001 From: Emanuele Stoppa Date: Mon, 4 Dec 2023 08:43:57 -0500 Subject: [PATCH 06/59] chore: remove `experimental` from i18n configuration (#9264) * update types and schema * update typescript files * update tests * chore: update JSDoc --- packages/astro/src/@types/astro.ts | 226 +++++++++--------- packages/astro/src/core/build/generate.ts | 14 +- .../src/core/build/plugins/plugin-manifest.ts | 10 +- packages/astro/src/core/build/util.ts | 4 +- packages/astro/src/core/config/schema.ts | 144 +++++------ packages/astro/src/core/create-vite.ts | 2 +- .../astro/src/core/routing/manifest/create.ts | 3 +- packages/astro/src/i18n/vite-plugin-i18n.ts | 2 +- .../src/vite-plugin-astro-server/plugin.ts | 10 +- .../src/vite-plugin-astro-server/route.ts | 16 +- .../i18n-routing-base/astro.config.mjs | 2 - .../i18n-routing-fallback/astro.config.mjs | 2 - .../astro.config.mjs | 4 +- .../astro.config.mjs | 13 +- .../astro.config.mjs | 14 +- .../fixtures/i18n-routing/astro.config.mjs | 2 - packages/astro/test/i18n-routing.test.js | 218 ++++++++--------- .../test/units/config/config-validate.test.js | 84 +++---- 18 files changed, 360 insertions(+), 410 deletions(-) diff --git a/packages/astro/src/@types/astro.ts b/packages/astro/src/@types/astro.ts index a689c0479e5e..df475e3d6b69 100644 --- a/packages/astro/src/@types/astro.ts +++ b/packages/astro/src/@types/astro.ts @@ -1414,145 +1414,147 @@ export interface AstroUserConfig { * Astro offers experimental flags to give users early access to new features. * These flags are not guaranteed to be stable. */ - experimental?: { + + /** + * @docs + * @name i18n + * @type {object} + * @version 3.5.0 + * @type {object} + * @description + * + * Configures experimental i18n routing and allows you to specify some customization options. + * + * See our guide for more information on [internationalization in Astro](/en/guides/internationalization/) + */ + i18n?: { /** * @docs - * @name experimental.optimizeHoistedScript - * @type {boolean} - * @default `false` - * @version 2.10.4 + * @kind h4 + * @name i18n.defaultLocale + * @type {string} + * @version 3.5.0 * @description - * Prevents unused components' scripts from being included in a page unexpectedly. - * The optimization is best-effort and may inversely miss including the used scripts. Make sure to double-check your built pages - * before publishing. - * Enable hoisted script analysis optimization by adding the experimental flag: * - * ```js - * { - * experimental: { - * optimizeHoistedScript: true, - * }, - * } - * ``` + * The default locale of your website/application. This is a required field. + * + * No particular language format or syntax is enforced, but we suggest using lower-case and hyphens as needed (e.g. "es", "pt-br") for greatest compatibility. */ - optimizeHoistedScript?: boolean; + defaultLocale: string; + /** + * @docs + * @kind h4 + * @name i18n.locales + * @type {Locales} + * @version 3.5.0 + * @description + * + * A list of all locales supported by the website, including the `defaultLocale`. This is a required field. + * + * Languages can be listed either as individual codes (e.g. `['en', 'es', 'pt-br']`) or mapped to a shared `path` of codes (e.g. `{ path: "english", codes: ["en", "en-US"]}`). These codes will be used to determine the URL structure of your deployed site. + * + * No particular language code format or syntax is enforced, but your project folders containing your content files must match exactly the `locales` items in the list. In the case of multiple `codes` pointing to a custom URL path prefix, store your content files in a folder with the same name as the `path` configured. + */ + locales: Locales; /** * @docs - * @name experimental.i18n - * @type {object} + * @kind h4 + * @name i18n.fallback + * @type {Record} * @version 3.5.0 - * @type {object} * @description * - * Configures experimental i18n routing and allows you to specify some customization options. + * The fallback strategy when navigating to pages that do not exist (e.g. a translated page has not been created). + * + * Use this object to declare a fallback `locale` route for each language you support. If no fallback is specified, then unavailable pages will return a 404. * - * See our guide for more information on [internationalization in Astro](/en/guides/internationalization/) + * ##### Example + * + * The following example configures your content fallback strategy to redirect unavailable pages in `/pt-br/` to their `es` version, and unavailable pages in `/fr/` to their `en` version. Unavailable `/es/` pages will return a 404. + * + * ```js + * export default defineConfig({ + * experimental: { + * i18n: { + * defaultLocale: "en", + * locales: ["en", "fr", "pt-br", "es"], + * fallback: { + * pt: "es", + * fr: "en" + * } + * } + * } + * }) + * ``` */ - i18n?: { - /** - * @docs - * @kind h4 - * @name experimental.i18n.defaultLocale - * @type {string} - * @version 3.5.0 - * @description - * - * The default locale of your website/application. This is a required field. - * - * No particular language format or syntax is enforced, but we suggest using lower-case and hyphens as needed (e.g. "es", "pt-br") for greatest compatibility. - */ - defaultLocale: string; - /** - * @docs - * @kind h4 - * @name experimental.i18n.locales - * @type {Locales} - * @version 3.5.0 - * @description - * - * A list of all locales supported by the website, including the `defaultLocale`. This is a required field. - * - * Languages can be listed either as individual codes (e.g. `['en', 'es', 'pt-br']`) or mapped to a shared `path` of codes (e.g. `{ path: "english", codes: ["en", "en-US"]}`). These codes will be used to determine the URL structure of your deployed site. - * - * No particular language code format or syntax is enforced, but your project folders containing your content files must match exactly the `locales` items in the list. In the case of multiple `codes` pointing to a custom URL path prefix, store your content files in a folder with the same name as the `path` configured. - */ - locales: Locales; + fallback?: Record; + /** + * @docs + * @kind h4 + * @name i18n.routing + * @type {Routing} + * @version 3.7.0 + * @description + * + * Controls the routing strategy to determine your site URLs. Set this based on your folder/URL path configuration for your default language. + */ + routing?: { /** * @docs - * @kind h4 - * @name experimental.i18n.fallback - * @type {Record} - * @version 3.5.0 + * @name i18n.routing.prefixDefaultLocale + * @type {boolean} + * @default `false` + * @version 3.7.0 * @description * - * The fallback strategy when navigating to pages that do not exist (e.g. a translated page has not been created). - * - * Use this object to declare a fallback `locale` route for each language you support. If no fallback is specified, then unavailable pages will return a 404. + * When `false`, only non-default languages will display a language prefix. + * The `defaultLocale` will not show a language prefix and content files do not exist in a localized folder. + * URLs will be of the form `example.com/[locale]/content/` for all non-default languages, but `example.com/content/` for the default locale. * - * ##### Example - * - * The following example configures your content fallback strategy to redirect unavailable pages in `/pt-br/` to their `es` version, and unavailable pages in `/fr/` to their `en` version. Unavailable `/es/` pages will return a 404. - * - * ```js - * export default defineConfig({ - * experimental: { - * i18n: { - * defaultLocale: "en", - * locales: ["en", "fr", "pt-br", "es"], - * fallback: { - * pt: "es", - * fr: "en" - * } - * } - * } - * }) - * ``` + * When `true`, all URLs will display a language prefix. + * URLs will be of the form `example.com/[locale]/content/` for every route, including the default language. + * Localized folders are used for every language, including the default. */ - fallback?: Record; + prefixDefaultLocale: boolean; /** - * @docs - * @kind h4 - * @name experimental.i18n.routing - * @type {Routing} + * @name i18n.routing.strategy + * @type {"pathname"} + * @default `"pathname"` * @version 3.7.0 * @description * - * Controls the routing strategy to determine your site URLs. Set this based on your folder/URL path configuration for your default language. + * - `"pathanme": The strategy is applied to the pathname of the URLs */ - routing?: { - /** - * @docs - * @name experimental.i18n.routing.prefixDefaultLocale - * @type {boolean} - * @default `false` - * @version 3.7.0 - * @description - * - * When `false`, only non-default languages will display a language prefix. - * The `defaultLocale` will not show a language prefix and content files do not exist in a localized folder. - * URLs will be of the form `example.com/[locale]/content/` for all non-default languages, but `example.com/content/` for the default locale. - * - * When `true`, all URLs will display a language prefix. - * URLs will be of the form `example.com/[locale]/content/` for every route, including the default language. - * Localized folders are used for every language, including the default. - */ - prefixDefaultLocale: boolean; - - /** - * @name experimental.i18n.routing.strategy - * @type {"pathname"} - * @default `"pathname"` - * @version 3.7.0 - * @description - * - * - `"pathanme": The strategy is applied to the pathname of the URLs - */ - strategy: 'pathname'; - }; + strategy: 'pathname'; }; + }; + + experimental?: { + /** + * @docs + * @name experimental.optimizeHoistedScript + * @type {boolean} + * @default `false` + * @version 2.10.4 + * @description + * Prevents unused components' scripts from being included in a page unexpectedly. + * The optimization is best-effort and may inversely miss including the used scripts. Make sure to double-check your built pages + * before publishing. + * Enable hoisted script analysis optimization by adding the experimental flag: + * + * ```js + * { + * experimental: { + * optimizeHoistedScript: true, + * }, + * } + * ``` + */ + optimizeHoistedScript?: boolean; + /** * @docs * @name experimental.contentCollectionCache diff --git a/packages/astro/src/core/build/generate.ts b/packages/astro/src/core/build/generate.ts index 5fc439c154d4..d9c061567d57 100644 --- a/packages/astro/src/core/build/generate.ts +++ b/packages/astro/src/core/build/generate.ts @@ -270,7 +270,7 @@ async function generatePage( pipeline.getManifest().base, pipeline.getManifest().trailingSlash ); - if (config.experimental.i18n && i18nMiddleware) { + if (config.i18n && i18nMiddleware) { if (onRequest) { pipeline.setMiddlewareFunction(sequence(i18nMiddleware, onRequest)); } else { @@ -546,7 +546,7 @@ async function generatePath( logger: pipeline.getLogger(), ssr, }); - const i18n = pipeline.getConfig().experimental.i18n; + const i18n = pipeline.getConfig().i18n; const renderContext = await createRenderContext({ pathname, @@ -629,12 +629,12 @@ export function createBuildManifest( renderers: SSRLoadedRenderer[] ): SSRManifest { let i18nManifest: SSRManifestI18n | undefined = undefined; - if (settings.config.experimental.i18n) { + if (settings.config.i18n) { i18nManifest = { - fallback: settings.config.experimental.i18n.fallback, - routing: settings.config.experimental.i18n.routing, - defaultLocale: settings.config.experimental.i18n.defaultLocale, - locales: settings.config.experimental.i18n.locales, + fallback: settings.config.i18n.fallback, + routing: settings.config.i18n.routing, + defaultLocale: settings.config.i18n.defaultLocale, + locales: settings.config.i18n.locales, }; } return { diff --git a/packages/astro/src/core/build/plugins/plugin-manifest.ts b/packages/astro/src/core/build/plugins/plugin-manifest.ts index 6f9ec6326e07..1a313b6bbdb4 100644 --- a/packages/astro/src/core/build/plugins/plugin-manifest.ts +++ b/packages/astro/src/core/build/plugins/plugin-manifest.ts @@ -240,12 +240,12 @@ function buildManifest( entryModules[BEFORE_HYDRATION_SCRIPT_ID] = ''; } let i18nManifest: SSRManifestI18n | undefined = undefined; - if (settings.config.experimental.i18n) { + if (settings.config.i18n) { i18nManifest = { - fallback: settings.config.experimental.i18n.fallback, - routing: settings.config.experimental.i18n.routing, - locales: settings.config.experimental.i18n.locales, - defaultLocale: settings.config.experimental.i18n.defaultLocale, + fallback: settings.config.i18n.fallback, + routing: settings.config.i18n.routing, + locales: settings.config.i18n.locales, + defaultLocale: settings.config.i18n.defaultLocale, }; } diff --git a/packages/astro/src/core/build/util.ts b/packages/astro/src/core/build/util.ts index fc12b486f164..3d59cf45ce9a 100644 --- a/packages/astro/src/core/build/util.ts +++ b/packages/astro/src/core/build/util.ts @@ -29,9 +29,9 @@ export function shouldAppendForwardSlash( } export function i18nHasFallback(config: AstroConfig): boolean { - if (config.experimental.i18n && config.experimental.i18n.fallback) { + if (config.i18n && config.i18n.fallback) { // we have some fallback and the control is not none - return Object.keys(config.experimental.i18n.fallback).length > 0; + return Object.keys(config.i18n.fallback).length > 0; } return false; diff --git a/packages/astro/src/core/config/schema.ts b/packages/astro/src/core/config/schema.ts index 95e3964b43f6..833fd63d7faa 100644 --- a/packages/astro/src/core/config/schema.ts +++ b/packages/astro/src/core/config/schema.ts @@ -318,90 +318,90 @@ export const AstroConfigSchema = z.object({ vite: z .custom((data) => data instanceof Object && !Array.isArray(data)) .default(ASTRO_CONFIG_DEFAULTS.vite), - experimental: z - .object({ - optimizeHoistedScript: z - .boolean() - .optional() - .default(ASTRO_CONFIG_DEFAULTS.experimental.optimizeHoistedScript), - i18n: z.optional( - z + i18n: z.optional( + z + .object({ + defaultLocale: z.string(), + locales: z.array( + z.union([ + z.string(), + z.object({ + path: z.string(), + codes: z.string().array().nonempty(), + }), + ]) + ), + fallback: z.record(z.string(), z.string()).optional(), + routing: z .object({ - defaultLocale: z.string(), - locales: z.array( - z.union([ - z.string(), - z.object({ - path: z.string(), - codes: z.string().array().nonempty(), - }), - ]) - ), - fallback: z.record(z.string(), z.string()).optional(), - routing: z - .object({ - prefixDefaultLocale: z.boolean().default(false), - strategy: z.enum(['pathname']).default('pathname'), - }) - .default({}) - .transform((routing) => { - let strategy: RoutingStrategies; - switch (routing.strategy) { - case 'pathname': { - if (routing.prefixDefaultLocale === true) { - strategy = 'prefix-always'; - } else { - strategy = 'prefix-other-locales'; - } - } - } - return strategy; - }), + prefixDefaultLocale: z.boolean().default(false), + strategy: z.enum(['pathname']).default('pathname'), }) - .optional() - .superRefine((i18n, ctx) => { - if (i18n) { - const { defaultLocale, locales: _locales, fallback } = i18n; - const locales = _locales.map((locale) => { - if (typeof locale === 'string') { - return locale; + .default({}) + .transform((routing) => { + let strategy: RoutingStrategies; + switch (routing.strategy) { + case 'pathname': { + if (routing.prefixDefaultLocale === true) { + strategy = 'prefix-always'; } else { - return locale.path; + strategy = 'prefix-other-locales'; } - }); - if (!locales.includes(defaultLocale)) { + } + } + return strategy; + }), + }) + .optional() + .superRefine((i18n, ctx) => { + if (i18n) { + const { defaultLocale, locales: _locales, fallback } = i18n; + const locales = _locales.map((locale) => { + if (typeof locale === 'string') { + return locale; + } else { + return locale.path; + } + }); + if (!locales.includes(defaultLocale)) { + ctx.addIssue({ + code: z.ZodIssueCode.custom, + message: `The default locale \`${defaultLocale}\` is not present in the \`i18n.locales\` array.`, + }); + } + if (fallback) { + for (const [fallbackFrom, fallbackTo] of Object.entries(fallback)) { + if (!locales.includes(fallbackFrom)) { ctx.addIssue({ code: z.ZodIssueCode.custom, - message: `The default locale \`${defaultLocale}\` is not present in the \`i18n.locales\` array.`, + message: `The locale \`${fallbackFrom}\` key in the \`i18n.fallback\` record doesn't exist in the \`i18n.locales\` array.`, }); } - if (fallback) { - for (const [fallbackFrom, fallbackTo] of Object.entries(fallback)) { - if (!locales.includes(fallbackFrom)) { - ctx.addIssue({ - code: z.ZodIssueCode.custom, - message: `The locale \`${fallbackFrom}\` key in the \`i18n.fallback\` record doesn't exist in the \`i18n.locales\` array.`, - }); - } - if (fallbackFrom === defaultLocale) { - ctx.addIssue({ - code: z.ZodIssueCode.custom, - message: `You can't use the default locale as a key. The default locale can only be used as value.`, - }); - } + if (fallbackFrom === defaultLocale) { + ctx.addIssue({ + code: z.ZodIssueCode.custom, + message: `You can't use the default locale as a key. The default locale can only be used as value.`, + }); + } - if (!locales.includes(fallbackTo)) { - ctx.addIssue({ - code: z.ZodIssueCode.custom, - message: `The locale \`${fallbackTo}\` value in the \`i18n.fallback\` record doesn't exist in the \`i18n.locales\` array.`, - }); - } - } + if (!locales.includes(fallbackTo)) { + ctx.addIssue({ + code: z.ZodIssueCode.custom, + message: `The locale \`${fallbackTo}\` value in the \`i18n.fallback\` record doesn't exist in the \`i18n.locales\` array.`, + }); } } - }) - ), + } + } + }) + ), + experimental: z + .object({ + optimizeHoistedScript: z + .boolean() + .optional() + .default(ASTRO_CONFIG_DEFAULTS.experimental.optimizeHoistedScript), contentCollectionCache: z .boolean() .optional() diff --git a/packages/astro/src/core/create-vite.ts b/packages/astro/src/core/create-vite.ts index 418e6387be14..bd3af4e292a5 100644 --- a/packages/astro/src/core/create-vite.ts +++ b/packages/astro/src/core/create-vite.ts @@ -141,7 +141,7 @@ export async function createVite( astroPrefetch({ settings }), astroTransitions({ settings }), astroDevOverlay({ settings, logger }), - !!settings.config.experimental.i18n && astroInternationalization({ settings }), + !!settings.config.i18n && astroInternationalization({ settings }), ], publicDir: fileURLToPath(settings.config.publicDir), root: fileURLToPath(settings.config.root), diff --git a/packages/astro/src/core/routing/manifest/create.ts b/packages/astro/src/core/routing/manifest/create.ts index c582281ec323..c9c0bb071685 100644 --- a/packages/astro/src/core/routing/manifest/create.ts +++ b/packages/astro/src/core/routing/manifest/create.ts @@ -18,7 +18,6 @@ import { SUPPORTED_MARKDOWN_FILE_EXTENSIONS } from '../../constants.js'; import { removeLeadingForwardSlash, slash } from '../../path.js'; import { resolvePages } from '../../util.js'; import { getRouteGenerator } from './generator.js'; -import { getPathByLocale } from '../../../i18n/index.js'; const require = createRequire(import.meta.url); interface Item { @@ -491,7 +490,7 @@ export function createRouteManifest( // Didn't find a good place, insert last routes.push(routeData); }); - const i18n = settings.config.experimental.i18n; + const i18n = settings.config.i18n; if (i18n) { // In this block of code we group routes based on their locale diff --git a/packages/astro/src/i18n/vite-plugin-i18n.ts b/packages/astro/src/i18n/vite-plugin-i18n.ts index a28481cac513..cd4c3f854bd3 100644 --- a/packages/astro/src/i18n/vite-plugin-i18n.ts +++ b/packages/astro/src/i18n/vite-plugin-i18n.ts @@ -35,7 +35,7 @@ export default function astroInternationalization({ const trailingSlash = ${JSON.stringify(settings.config.trailingSlash)}; const format = ${JSON.stringify(settings.config.build.format)}; const site = ${JSON.stringify(settings.config.site)}; - const i18n = ${JSON.stringify(settings.config.experimental.i18n)}; + const i18n = ${JSON.stringify(settings.config.i18n)}; export const getRelativeLocaleUrl = (locale, path = "", opts) => _getLocaleRelativeUrl({ locale, diff --git a/packages/astro/src/vite-plugin-astro-server/plugin.ts b/packages/astro/src/vite-plugin-astro-server/plugin.ts index d324dfdc6e4a..f0df0e3ebfc3 100644 --- a/packages/astro/src/vite-plugin-astro-server/plugin.ts +++ b/packages/astro/src/vite-plugin-astro-server/plugin.ts @@ -87,12 +87,12 @@ export default function createVitePluginAstroServer({ */ export function createDevelopmentManifest(settings: AstroSettings): SSRManifest { let i18nManifest: SSRManifestI18n | undefined = undefined; - if (settings.config.experimental.i18n) { + if (settings.config.i18n) { i18nManifest = { - fallback: settings.config.experimental.i18n.fallback, - routing: settings.config.experimental.i18n.routing, - defaultLocale: settings.config.experimental.i18n.defaultLocale, - locales: settings.config.experimental.i18n.locales, + fallback: settings.config.i18n.fallback, + routing: settings.config.i18n.routing, + defaultLocale: settings.config.i18n.defaultLocale, + locales: settings.config.i18n.locales, }; } return { diff --git a/packages/astro/src/vite-plugin-astro-server/route.ts b/packages/astro/src/vite-plugin-astro-server/route.ts index e677a81a745d..04e33d82797f 100644 --- a/packages/astro/src/vite-plugin-astro-server/route.ts +++ b/packages/astro/src/vite-plugin-astro-server/route.ts @@ -173,7 +173,7 @@ export async function handleRoute({ const config = pipeline.getConfig(); const moduleLoader = pipeline.getModuleLoader(); const { logger } = env; - if (!matchedRoute && !config.experimental.i18n) { + if (!matchedRoute && !config.i18n) { if (isLoggedRequest(pathname)) { logger.info(null, req({ url: pathname, method: incomingRequest.method, statusCode: 404 })); } @@ -190,8 +190,8 @@ export async function handleRoute({ const middleware = await loadMiddleware(moduleLoader); if (!matchedRoute) { - if (config.experimental.i18n) { - const locales = config.experimental.i18n.locales; + if (config.i18n) { + const locales = config.i18n.locales; const pathNameHasLocale = pathname .split('/') .filter(Boolean) @@ -288,7 +288,7 @@ export async function handleRoute({ filePath: options.filePath, }); - const i18n = pipeline.getConfig().experimental.i18n; + const i18n = pipeline.getConfig().i18n; renderContext = await createRenderContext({ request: options.request, @@ -307,12 +307,8 @@ export async function handleRoute({ } const onRequest = middleware?.onRequest as MiddlewareHandler | undefined; - if (config.experimental.i18n) { - const i18Middleware = createI18nMiddleware( - config.experimental.i18n, - config.base, - config.trailingSlash - ); + if (config.i18n) { + const i18Middleware = createI18nMiddleware(config.i18n, config.base, config.trailingSlash); if (i18Middleware) { if (onRequest) { diff --git a/packages/astro/test/fixtures/i18n-routing-base/astro.config.mjs b/packages/astro/test/fixtures/i18n-routing-base/astro.config.mjs index 4d512896695c..ee4909209d5a 100644 --- a/packages/astro/test/fixtures/i18n-routing-base/astro.config.mjs +++ b/packages/astro/test/fixtures/i18n-routing-base/astro.config.mjs @@ -2,7 +2,6 @@ import { defineConfig} from "astro/config"; export default defineConfig({ base: "new-site", - experimental: { i18n: { defaultLocale: 'en', locales: [ @@ -14,6 +13,5 @@ export default defineConfig({ routing: { prefixDefaultLocale: true } - } } }) diff --git a/packages/astro/test/fixtures/i18n-routing-fallback/astro.config.mjs b/packages/astro/test/fixtures/i18n-routing-fallback/astro.config.mjs index f7524a64210d..45c3b49a064d 100644 --- a/packages/astro/test/fixtures/i18n-routing-fallback/astro.config.mjs +++ b/packages/astro/test/fixtures/i18n-routing-fallback/astro.config.mjs @@ -2,7 +2,6 @@ import { defineConfig} from "astro/config"; export default defineConfig({ base: "new-site", - experimental: { i18n: { defaultLocale: 'en', locales: [ @@ -13,5 +12,4 @@ export default defineConfig({ pt: "en" } } - } }) diff --git a/packages/astro/test/fixtures/i18n-routing-prefix-always/astro.config.mjs b/packages/astro/test/fixtures/i18n-routing-prefix-always/astro.config.mjs index 03fd2b11d0e8..58eb50540ec1 100644 --- a/packages/astro/test/fixtures/i18n-routing-prefix-always/astro.config.mjs +++ b/packages/astro/test/fixtures/i18n-routing-prefix-always/astro.config.mjs @@ -1,7 +1,6 @@ import { defineConfig} from "astro/config"; export default defineConfig({ - experimental: { i18n: { defaultLocale: 'en', locales: [ @@ -13,7 +12,6 @@ export default defineConfig({ routing: { prefixDefaultLocale: true } - } - }, + }, base: "/new-site" }) diff --git a/packages/astro/test/fixtures/i18n-routing-prefix-other-locales/astro.config.mjs b/packages/astro/test/fixtures/i18n-routing-prefix-other-locales/astro.config.mjs index 4eb0abf1bffc..93ecee2941b2 100644 --- a/packages/astro/test/fixtures/i18n-routing-prefix-other-locales/astro.config.mjs +++ b/packages/astro/test/fixtures/i18n-routing-prefix-other-locales/astro.config.mjs @@ -1,14 +1,11 @@ import { defineConfig} from "astro/config"; export default defineConfig({ - experimental: { - i18n: { - defaultLocale: 'en', - locales: [ - 'en', 'pt', 'it' - ], - }, - + i18n: { + defaultLocale: 'en', + locales: [ + 'en', 'pt', 'it' + ], }, base: "/new-site" }) diff --git a/packages/astro/test/fixtures/i18n-routing-redirect-preferred-language/astro.config.mjs b/packages/astro/test/fixtures/i18n-routing-redirect-preferred-language/astro.config.mjs index 209ad40fd057..259b10d07d3f 100644 --- a/packages/astro/test/fixtures/i18n-routing-redirect-preferred-language/astro.config.mjs +++ b/packages/astro/test/fixtures/i18n-routing-redirect-preferred-language/astro.config.mjs @@ -1,12 +1,10 @@ import { defineConfig} from "astro/config"; export default defineConfig({ - experimental: { - i18n: { - defaultLocale: 'en', - locales: [ - 'en', 'pt', 'it' - ] - } - }, + i18n: { + defaultLocale: 'en', + locales: [ + 'en', 'pt', 'it' + ] + } }) diff --git a/packages/astro/test/fixtures/i18n-routing/astro.config.mjs b/packages/astro/test/fixtures/i18n-routing/astro.config.mjs index a3ee1e9c605f..42559e778a30 100644 --- a/packages/astro/test/fixtures/i18n-routing/astro.config.mjs +++ b/packages/astro/test/fixtures/i18n-routing/astro.config.mjs @@ -1,7 +1,6 @@ import { defineConfig} from "astro/config"; export default defineConfig({ - experimental: { i18n: { defaultLocale: 'en', locales: [ @@ -14,5 +13,4 @@ export default defineConfig({ } ] } - }, }) diff --git a/packages/astro/test/i18n-routing.test.js b/packages/astro/test/i18n-routing.test.js index f074cbb248ce..3c292ef2a48b 100644 --- a/packages/astro/test/i18n-routing.test.js +++ b/packages/astro/test/i18n-routing.test.js @@ -157,22 +157,20 @@ describe('[DEV] i18n routing', () => { before(async () => { fixture = await loadFixture({ root: './fixtures/i18n-routing-prefix-other-locales/', - experimental: { - i18n: { - defaultLocale: 'en', - locales: [ - 'en', - 'pt', - 'it', - { - path: 'spanish', - codes: ['es', 'es-AR'], - }, - ], - fallback: { - it: 'en', - spanish: 'en', + i18n: { + defaultLocale: 'en', + locales: [ + 'en', + 'pt', + 'it', + { + path: 'spanish', + codes: ['es', 'es-AR'], }, + ], + fallback: { + it: 'en', + spanish: 'en', }, }, }); @@ -336,25 +334,23 @@ describe('[DEV] i18n routing', () => { before(async () => { fixture = await loadFixture({ root: './fixtures/i18n-routing-fallback/', - experimental: { - i18n: { - defaultLocale: 'en', - locales: [ - 'en', - 'pt', - 'it', - { - path: 'spanish', - codes: ['es', 'es-AR'], - }, - ], - fallback: { - it: 'en', - spanish: 'en', - }, - routing: { - prefixDefaultLocale: false, + i18n: { + defaultLocale: 'en', + locales: [ + 'en', + 'pt', + 'it', + { + path: 'spanish', + codes: ['es', 'es-AR'], }, + ], + fallback: { + it: 'en', + spanish: 'en', + }, + routing: { + prefixDefaultLocale: false, }, }, }); @@ -703,22 +699,20 @@ describe('[SSG] i18n routing', () => { before(async () => { fixture = await loadFixture({ root: './fixtures/i18n-routing-fallback/', - experimental: { - i18n: { - defaultLocale: 'en', - locales: [ - 'en', - 'pt', - 'it', - { - path: 'spanish', - codes: ['es', 'es-AR'], - }, - ], - fallback: { - it: 'en', - spanish: 'en', + i18n: { + defaultLocale: 'en', + locales: [ + 'en', + 'pt', + 'it', + { + path: 'spanish', + codes: ['es', 'es-AR'], }, + ], + fallback: { + it: 'en', + spanish: 'en', }, }, }); @@ -789,16 +783,14 @@ describe('[SSG] i18n routing', () => { before(async () => { fixture = await loadFixture({ root: './fixtures/i18n-routing-prefix-always/', - experimental: { - i18n: { - defaultLocale: 'en', - locales: ['en', 'pt', 'it'], - fallback: { - it: 'en', - }, - routing: { - prefixDefaultLocale: true, - }, + i18n: { + defaultLocale: 'en', + locales: ['en', 'pt', 'it'], + fallback: { + it: 'en', + }, + routing: { + prefixDefaultLocale: true, }, }, }); @@ -825,13 +817,11 @@ describe('[SSG] i18n routing', () => { redirects: { '/': '/en', }, - experimental: { - i18n: { - defaultLocale: 'en', - locales: ['en', 'pt', 'it'], - fallback: { - it: 'en', - }, + i18n: { + defaultLocale: 'en', + locales: ['en', 'pt', 'it'], + fallback: { + it: 'en', }, }, }); @@ -856,16 +846,14 @@ describe('[SSG] i18n routing', () => { build: { format: 'directory', }, - experimental: { - i18n: { - defaultLocale: 'en', - locales: ['en', 'pt', 'it'], - fallback: { - it: 'en', - }, - routing: { - prefixDefaultLocale: false, - }, + i18n: { + defaultLocale: 'en', + locales: ['en', 'pt', 'it'], + fallback: { + it: 'en', + }, + routing: { + prefixDefaultLocale: false, }, }, }); @@ -1115,22 +1103,20 @@ describe('[SSR] i18n routing', () => { root: './fixtures/i18n-routing-fallback/', output: 'server', adapter: testAdapter(), - experimental: { - i18n: { - defaultLocale: 'en', - locales: [ - 'en', - 'pt', - 'it', - { - codes: ['es', 'es-AR'], - path: 'spanish', - }, - ], - fallback: { - it: 'en', - spanish: 'en', + i18n: { + defaultLocale: 'en', + locales: [ + 'en', + 'pt', + 'it', + { + codes: ['es', 'es-AR'], + path: 'spanish', }, + ], + fallback: { + it: 'en', + spanish: 'en', }, }, }); @@ -1178,16 +1164,14 @@ describe('[SSR] i18n routing', () => { root: './fixtures/i18n-routing-fallback/', output: 'server', adapter: testAdapter(), - experimental: { - i18n: { - defaultLocale: 'en', - locales: ['en', 'pt', 'it'], - fallback: { - it: 'en', - }, - routing: { - prefixDefaultLocale: false, - }, + i18n: { + defaultLocale: 'en', + locales: ['en', 'pt', 'it'], + fallback: { + it: 'en', + }, + routing: { + prefixDefaultLocale: false, }, }, }); @@ -1272,11 +1256,9 @@ describe('[SSR] i18n routing', () => { root: './fixtures/i18n-routing/', output: 'server', adapter: testAdapter(), - experimental: { - i18n: { - defaultLocale: 'en', - locales: ['en_AU', 'pt_BR', 'es_US'], - }, + i18n: { + defaultLocale: 'en', + locales: ['en_AU', 'pt_BR', 'es_US'], }, }); await fixture.build(); @@ -1303,16 +1285,14 @@ describe('[SSR] i18n routing', () => { root: './fixtures/i18n-routing/', output: 'server', adapter: testAdapter(), - experimental: { - i18n: { - defaultLocale: 'en', - locales: [ - { - path: 'english', - codes: ['en', 'en-AU', 'pt-BR', 'es-US'], - }, - ], - }, + i18n: { + defaultLocale: 'en', + locales: [ + { + path: 'english', + codes: ['en', 'en-AU', 'pt-BR', 'es-US'], + }, + ], }, }); await fixture.build(); @@ -1410,11 +1390,9 @@ describe('i18n routing does not break assets and endpoints', () => { before(async () => { fixture = await loadFixture({ root: './fixtures/core-image-base/', - experimental: { - i18n: { - defaultLocale: 'en', - locales: ['en', 'es'], - }, + i18n: { + defaultLocale: 'en', + locales: ['en', 'es'], }, base: '/blog', }); diff --git a/packages/astro/test/units/config/config-validate.test.js b/packages/astro/test/units/config/config-validate.test.js index f759be9b92b5..341ed47b422c 100644 --- a/packages/astro/test/units/config/config-validate.test.js +++ b/packages/astro/test/units/config/config-validate.test.js @@ -82,11 +82,9 @@ describe('Config Validation', () => { it('defaultLocale is not in locales', async () => { const configError = await validateConfig( { - experimental: { - i18n: { - defaultLocale: 'en', - locales: ['es'], - }, + i18n: { + defaultLocale: 'en', + locales: ['es'], }, }, process.cwd() @@ -100,17 +98,15 @@ describe('Config Validation', () => { it('errors if codes are empty', async () => { const configError = await validateConfig( { - experimental: { - i18n: { - defaultLocale: 'uk', - locales: [ - 'es', - { - path: 'something', - codes: [], - }, - ], - }, + i18n: { + defaultLocale: 'uk', + locales: [ + 'es', + { + path: 'something', + codes: [], + }, + ], }, }, process.cwd() @@ -122,17 +118,15 @@ describe('Config Validation', () => { it('errors if the default locale is not in path', async () => { const configError = await validateConfig( { - experimental: { - i18n: { - defaultLocale: 'uk', - locales: [ - 'es', - { - path: 'something', - codes: ['en-UK'], - }, - ], - }, + i18n: { + defaultLocale: 'uk', + locales: [ + 'es', + { + path: 'something', + codes: ['en-UK'], + }, + ], }, }, process.cwd() @@ -146,13 +140,11 @@ describe('Config Validation', () => { it('errors if a fallback value does not exist', async () => { const configError = await validateConfig( { - experimental: { - i18n: { - defaultLocale: 'en', - locales: ['es', 'en'], - fallback: { - es: 'it', - }, + i18n: { + defaultLocale: 'en', + locales: ['es', 'en'], + fallback: { + es: 'it', }, }, }, @@ -167,13 +159,11 @@ describe('Config Validation', () => { it('errors if a fallback key does not exist', async () => { const configError = await validateConfig( { - experimental: { - i18n: { - defaultLocale: 'en', - locales: ['es', 'en'], - fallback: { - it: 'en', - }, + i18n: { + defaultLocale: 'en', + locales: ['es', 'en'], + fallback: { + it: 'en', }, }, }, @@ -188,13 +178,11 @@ describe('Config Validation', () => { it('errors if a fallback key contains the default locale', async () => { const configError = await validateConfig( { - experimental: { - i18n: { - defaultLocale: 'en', - locales: ['es', 'en'], - fallback: { - en: 'es', - }, + i18n: { + defaultLocale: 'en', + locales: ['es', 'en'], + fallback: { + en: 'es', }, }, }, From 4aa80915829388e3e696975ac8c3b0332c47b5ea Mon Sep 17 00:00:00 2001 From: Erika <3019731+Princesseuh@users.noreply.github.com> Date: Mon, 4 Dec 2023 17:56:32 +0100 Subject: [PATCH 07/59] fix: enforce separate type imports (#9288) --- .eslintrc.cjs | 10 ++++++++++ packages/astro-rss/test/rss.test.js | 10 +++++----- packages/astro/src/assets/build/generate.ts | 2 +- packages/astro/src/core/build/buildPipeline.ts | 2 +- packages/astro/src/core/build/generate.ts | 1 - packages/astro/src/core/build/index.ts | 3 ++- packages/astro/src/core/compile/compile.ts | 3 ++- packages/astro/src/core/dev/restart.ts | 2 +- packages/astro/src/core/logger/node.ts | 2 +- packages/astro/src/core/render/params-and-props.ts | 3 ++- packages/astro/src/core/render/route-cache.ts | 1 - packages/astro/src/integrations/index.ts | 2 +- .../src/runtime/client/dev-overlay/entrypoint.ts | 2 +- packages/astro/src/runtime/server/render/common.ts | 3 ++- .../astro/src/runtime/server/render/component.ts | 3 ++- packages/astro/src/transitions/router.ts | 9 ++------- packages/astro/src/vite-plugin-astro/hmr.ts | 8 ++------ packages/astro/test/i18n-routing.test.js | 2 +- packages/integrations/markdoc/components/TreeNode.ts | 12 ++++++------ packages/integrations/node/src/types.ts | 2 +- packages/integrations/sitemap/src/index.ts | 8 ++------ 21 files changed, 45 insertions(+), 45 deletions(-) diff --git a/.eslintrc.cjs b/.eslintrc.cjs index e6085ac647f6..95f00b476289 100644 --- a/.eslintrc.cjs +++ b/.eslintrc.cjs @@ -58,6 +58,16 @@ module.exports = { '@typescript-eslint/unbound-method': 'off', '@typescript-eslint/no-explicit-any': 'off', + // Enforce separate type imports for type-only imports to avoid bundling unneeded code + '@typescript-eslint/consistent-type-imports': [ + 'error', + { + prefer: 'type-imports', + fixStyle: 'separate-type-imports', + disallowTypeAnnotations: false, + }, + ], + // These rules enabled by the preset configs don't work well for us '@typescript-eslint/await-thenable': 'off', 'prefer-const': 'off', diff --git a/packages/astro-rss/test/rss.test.js b/packages/astro-rss/test/rss.test.js index cc7bff82b2ed..e6f68a272f5f 100644 --- a/packages/astro-rss/test/rss.test.js +++ b/packages/astro-rss/test/rss.test.js @@ -1,18 +1,18 @@ -import rss, { getRssString } from '../dist/index.js'; -import { rssSchema } from '../dist/schema.js'; import chai from 'chai'; import chaiPromises from 'chai-as-promised'; import chaiXml from 'chai-xml'; +import rss, { getRssString } from '../dist/index.js'; +import { rssSchema } from '../dist/schema.js'; import { - title, description, - site, phpFeedItem, phpFeedItemWithContent, phpFeedItemWithCustomData, + site, + title, web1FeedItem, - web1FeedItemWithContent, web1FeedItemWithAllData, + web1FeedItemWithContent, } from './test-utils.js'; chai.use(chaiPromises); diff --git a/packages/astro/src/assets/build/generate.ts b/packages/astro/src/assets/build/generate.ts index c4109ea1edb1..1c55a93b9874 100644 --- a/packages/astro/src/assets/build/generate.ts +++ b/packages/astro/src/assets/build/generate.ts @@ -1,7 +1,7 @@ import { dim, green } from 'kleur/colors'; import fs, { readFileSync } from 'node:fs'; import { basename, join } from 'node:path/posix'; -import PQueue from 'p-queue'; +import type PQueue from 'p-queue'; import type { AstroConfig } from '../../@types/astro.js'; import type { BuildPipeline } from '../../core/build/buildPipeline.js'; import { getOutDirWithinCwd } from '../../core/build/common.js'; diff --git a/packages/astro/src/core/build/buildPipeline.ts b/packages/astro/src/core/build/buildPipeline.ts index 87166b4f4a1b..623e89630fcf 100644 --- a/packages/astro/src/core/build/buildPipeline.ts +++ b/packages/astro/src/core/build/buildPipeline.ts @@ -2,7 +2,7 @@ import type { AstroConfig, AstroSettings, SSRLoadedRenderer } from '../../@types import { getOutputDirectory, isServerLikeOutput } from '../../prerender/utils.js'; import { BEFORE_HYDRATION_SCRIPT_ID } from '../../vite-plugin-scripts/index.js'; import type { SSRManifest } from '../app/types.js'; -import { Logger } from '../logger/core.js'; +import type { Logger } from '../logger/core.js'; import { Pipeline } from '../pipeline.js'; import { routeIsFallback, routeIsRedirect } from '../redirects/helpers.js'; import { createEnvironment } from '../render/index.js'; diff --git a/packages/astro/src/core/build/generate.ts b/packages/astro/src/core/build/generate.ts index d9c061567d57..99a7ad121b79 100644 --- a/packages/astro/src/core/build/generate.ts +++ b/packages/astro/src/core/build/generate.ts @@ -10,7 +10,6 @@ import type { GetStaticPathsItem, RouteData, RouteType, - SSRElement, SSRError, SSRLoadedRenderer, SSRManifest, diff --git a/packages/astro/src/core/build/index.ts b/packages/astro/src/core/build/index.ts index 0245e50c2ff1..fa45c9d6b6e3 100644 --- a/packages/astro/src/core/build/index.ts +++ b/packages/astro/src/core/build/index.ts @@ -24,7 +24,8 @@ import { resolveConfig } from '../config/config.js'; import { createNodeLogger } from '../config/logging.js'; import { createSettings } from '../config/settings.js'; import { createVite } from '../create-vite.js'; -import { Logger, levels, timerMessage } from '../logger/core.js'; +import type { Logger } from '../logger/core.js'; +import { levels, timerMessage } from '../logger/core.js'; import { apply as applyPolyfill } from '../polyfill.js'; import { RouteCache } from '../render/route-cache.js'; import { createRouteManifest } from '../routing/index.js'; diff --git a/packages/astro/src/core/compile/compile.ts b/packages/astro/src/core/compile/compile.ts index 2985dcab963e..ed2369f7f328 100644 --- a/packages/astro/src/core/compile/compile.ts +++ b/packages/astro/src/core/compile/compile.ts @@ -5,7 +5,8 @@ import type { AstroConfig } from '../../@types/astro.js'; import { transform } from '@astrojs/compiler'; import { fileURLToPath } from 'node:url'; import { normalizePath } from 'vite'; -import { AggregateError, AstroError, CompilerError } from '../errors/errors.js'; +import type { AstroError } from '../errors/errors.js'; +import { AggregateError, CompilerError } from '../errors/errors.js'; import { AstroErrorData } from '../errors/index.js'; import { resolvePath } from '../util.js'; import { createStylePreprocessor } from './style.js'; diff --git a/packages/astro/src/core/dev/restart.ts b/packages/astro/src/core/dev/restart.ts index b19eae4ac461..3d77ef0c0cc5 100644 --- a/packages/astro/src/core/dev/restart.ts +++ b/packages/astro/src/core/dev/restart.ts @@ -1,4 +1,4 @@ -import nodeFs from 'node:fs'; +import type nodeFs from 'node:fs'; import { fileURLToPath } from 'node:url'; import * as vite from 'vite'; import type { AstroInlineConfig, AstroSettings } from '../../@types/astro.js'; diff --git a/packages/astro/src/core/logger/node.ts b/packages/astro/src/core/logger/node.ts index 727cafd1b220..2c75968d2f85 100644 --- a/packages/astro/src/core/logger/node.ts +++ b/packages/astro/src/core/logger/node.ts @@ -1,5 +1,5 @@ import debugPackage from 'debug'; -import { Writable } from 'node:stream'; +import type { Writable } from 'node:stream'; import { getEventPrefix, levels, type LogMessage, type LogWritable } from './core.js'; type ConsoleStream = Writable & { diff --git a/packages/astro/src/core/render/params-and-props.ts b/packages/astro/src/core/render/params-and-props.ts index 0ad5df205f5b..3532c5f83726 100644 --- a/packages/astro/src/core/render/params-and-props.ts +++ b/packages/astro/src/core/render/params-and-props.ts @@ -4,7 +4,8 @@ import type { Logger } from '../logger/core.js'; import { routeIsFallback } from '../redirects/helpers.js'; import { routeIsRedirect } from '../redirects/index.js'; import { getParams } from '../routing/params.js'; -import { RouteCache, callGetStaticPaths, findPathItemByKey } from './route-cache.js'; +import type { RouteCache } from './route-cache.js'; +import { callGetStaticPaths, findPathItemByKey } from './route-cache.js'; interface GetParamsAndPropsOptions { mod: ComponentInstance | undefined; diff --git a/packages/astro/src/core/render/route-cache.ts b/packages/astro/src/core/render/route-cache.ts index 4db5b75fd494..8a4e821a523c 100644 --- a/packages/astro/src/core/render/route-cache.ts +++ b/packages/astro/src/core/render/route-cache.ts @@ -8,7 +8,6 @@ import type { RouteData, RuntimeMode, } from '../../@types/astro.js'; -import { AstroError, AstroErrorData } from '../errors/index.js'; import type { Logger } from '../logger/core.js'; import { stringifyParams } from '../routing/params.js'; diff --git a/packages/astro/src/integrations/index.ts b/packages/astro/src/integrations/index.ts index 9031eeb2dfe2..d082c438fbaa 100644 --- a/packages/astro/src/integrations/index.ts +++ b/packages/astro/src/integrations/index.ts @@ -18,7 +18,7 @@ import type { SerializedSSRManifest } from '../core/app/types.js'; import type { PageBuildData } from '../core/build/types.js'; import { buildClientDirectiveEntrypoint } from '../core/client-directive/index.js'; import { mergeConfig } from '../core/config/index.js'; -import { AstroIntegrationLogger, type Logger } from '../core/logger/core.js'; +import type { AstroIntegrationLogger, Logger } from '../core/logger/core.js'; import { isServerLikeOutput } from '../prerender/utils.js'; import { validateSupportedFeatures } from './astroFeaturesValidation.js'; diff --git a/packages/astro/src/runtime/client/dev-overlay/entrypoint.ts b/packages/astro/src/runtime/client/dev-overlay/entrypoint.ts index 773d2493104e..f7c09dea6d99 100644 --- a/packages/astro/src/runtime/client/dev-overlay/entrypoint.ts +++ b/packages/astro/src/runtime/client/dev-overlay/entrypoint.ts @@ -1,5 +1,5 @@ import type { DevOverlayPlugin as DevOverlayPluginDefinition } from '../../../@types/astro.js'; -import { type AstroDevOverlay, type DevOverlayPlugin } from './overlay.js'; +import type { AstroDevOverlay, DevOverlayPlugin } from './overlay.js'; import { settings } from './settings.js'; // @ts-expect-error import { loadDevOverlayPlugins } from 'astro:dev-overlay'; diff --git a/packages/astro/src/runtime/server/render/common.ts b/packages/astro/src/runtime/server/render/common.ts index 4087ef1a7ec5..f595dc78cf13 100644 --- a/packages/astro/src/runtime/server/render/common.ts +++ b/packages/astro/src/runtime/server/render/common.ts @@ -1,7 +1,8 @@ import type { SSRResult } from '../../../@types/astro.js'; import type { RenderInstruction } from './instruction.js'; -import { HTMLBytes, HTMLString, markHTMLString } from '../escape.js'; +import type { HTMLBytes, HTMLString } from '../escape.js'; +import { markHTMLString } from '../escape.js'; import { determineIfNeedsHydrationScript, determinesIfNeedsDirectiveScript, diff --git a/packages/astro/src/runtime/server/render/component.ts b/packages/astro/src/runtime/server/render/component.ts index dfc5d6c5b62a..42987f011e90 100644 --- a/packages/astro/src/runtime/server/render/component.ts +++ b/packages/astro/src/runtime/server/render/component.ts @@ -8,7 +8,8 @@ import { createRenderInstruction, type RenderInstruction } from './instruction.j import { clsx } from 'clsx'; import { AstroError, AstroErrorData } from '../../../core/errors/index.js'; -import { HTMLBytes, markHTMLString } from '../escape.js'; +import type { HTMLBytes } from '../escape.js'; +import { markHTMLString } from '../escape.js'; import { extractDirectives, generateHydrateScript } from '../hydration.js'; import { serializeProps } from '../serialize.js'; import { shorthash } from '../shorthash.js'; diff --git a/packages/astro/src/transitions/router.ts b/packages/astro/src/transitions/router.ts index 92d8bb4a219f..e5bf35b7fd51 100644 --- a/packages/astro/src/transitions/router.ts +++ b/packages/astro/src/transitions/router.ts @@ -1,10 +1,5 @@ -import { - TRANSITION_AFTER_SWAP, - TransitionBeforeSwapEvent, - doPreparation, - doSwap, - type TransitionBeforePreparationEvent, -} from './events.js'; +import type { TransitionBeforePreparationEvent, TransitionBeforeSwapEvent } from './events.js'; +import { TRANSITION_AFTER_SWAP, doPreparation, doSwap } from './events.js'; import type { Direction, Fallback, Options } from './types.js'; type State = { diff --git a/packages/astro/src/vite-plugin-astro/hmr.ts b/packages/astro/src/vite-plugin-astro/hmr.ts index 4e5d3237dcb1..d06a8338f662 100644 --- a/packages/astro/src/vite-plugin-astro/hmr.ts +++ b/packages/astro/src/vite-plugin-astro/hmr.ts @@ -1,11 +1,7 @@ import type { HmrContext, ModuleNode } from 'vite'; import type { AstroConfig } from '../@types/astro.js'; -import { - cachedCompilation, - invalidateCompilation, - isCached, - type CompileResult, -} from '../core/compile/index.js'; +import type { cachedCompilation } from '../core/compile/index.js'; +import { invalidateCompilation, isCached, type CompileResult } from '../core/compile/index.js'; import type { Logger } from '../core/logger/core.js'; import { isAstroSrcFile } from '../core/logger/vite.js'; import { isAstroScript } from './query.js'; diff --git a/packages/astro/test/i18n-routing.test.js b/packages/astro/test/i18n-routing.test.js index 3c292ef2a48b..4b9a032306e3 100644 --- a/packages/astro/test/i18n-routing.test.js +++ b/packages/astro/test/i18n-routing.test.js @@ -1,7 +1,7 @@ -import { loadFixture } from './test-utils.js'; import { expect } from 'chai'; import * as cheerio from 'cheerio'; import testAdapter from './test-adapter.js'; +import { loadFixture } from './test-utils.js'; describe('astro:i18n virtual module', () => { /** @type {import('./test-utils').Fixture} */ diff --git a/packages/integrations/markdoc/components/TreeNode.ts b/packages/integrations/markdoc/components/TreeNode.ts index dce10f6cc422..abec17d7be7a 100644 --- a/packages/integrations/markdoc/components/TreeNode.ts +++ b/packages/integrations/markdoc/components/TreeNode.ts @@ -1,17 +1,17 @@ -import type { AstroInstance } from 'astro'; import type { RenderableTreeNode } from '@markdoc/markdoc'; import Markdoc from '@markdoc/markdoc'; +import type { AstroInstance } from 'astro'; +import type { HTMLString } from 'astro/runtime/server/index.js'; import { createComponent, - renderComponent, + createHeadAndContent, + isHTMLString, render, + renderComponent, renderScriptElement, + renderTemplate, renderUniqueStylesheet, - createHeadAndContent, unescapeHTML, - renderTemplate, - HTMLString, - isHTMLString, } from 'astro/runtime/server/index.js'; export type TreeNode = diff --git a/packages/integrations/node/src/types.ts b/packages/integrations/node/src/types.ts index 1917d8cf3696..273b805292cc 100644 --- a/packages/integrations/node/src/types.ts +++ b/packages/integrations/node/src/types.ts @@ -1,4 +1,4 @@ -import { IncomingMessage, ServerResponse } from 'node:http'; +import type { IncomingMessage, ServerResponse } from 'node:http'; export interface UserOptions { /** diff --git a/packages/integrations/sitemap/src/index.ts b/packages/integrations/sitemap/src/index.ts index 45f694887733..79f6f9dfcb07 100644 --- a/packages/integrations/sitemap/src/index.ts +++ b/packages/integrations/sitemap/src/index.ts @@ -1,12 +1,8 @@ import type { AstroConfig, AstroIntegration } from 'astro'; import path from 'node:path'; import { fileURLToPath } from 'node:url'; -import { - EnumChangefreq, - simpleSitemapAndIndex, - type LinkItem as LinkItemBase, - type SitemapItemLoose, -} from 'sitemap'; +import type { EnumChangefreq, LinkItem as LinkItemBase, SitemapItemLoose } from 'sitemap'; +import { simpleSitemapAndIndex } from 'sitemap'; import { ZodError } from 'zod'; import { generateSitemap } from './generate-sitemap.js'; From 8a228fce0114daeea2100e50ddc5cf2ea0a03b5d Mon Sep 17 00:00:00 2001 From: Nate Moore Date: Mon, 4 Dec 2023 11:16:27 -0600 Subject: [PATCH 08/59] Implement new a11y audits for the Dev Toolbar app (#9170) Co-authored-by: Sarah Rainsberger Co-authored-by: Princesseuh <3019731+Princesseuh@users.noreply.github.com> Co-authored-by: Fred K. Schott --- .changeset/orange-candles-sip.md | 9 + LICENSE | 2 - packages/astro/package.json | 3 + .../runtime/client/dev-overlay/entrypoint.ts | 2 +- .../client/dev-overlay/plugins/audit/a11y.ts | 628 ++++++++++++++++++ .../plugins/{audit.ts => audit/index.ts} | 86 ++- .../client/dev-overlay/ui-library/tooltip.ts | 2 +- pnpm-lock.yaml | 19 + 8 files changed, 727 insertions(+), 24 deletions(-) create mode 100644 .changeset/orange-candles-sip.md create mode 100644 packages/astro/src/runtime/client/dev-overlay/plugins/audit/a11y.ts rename packages/astro/src/runtime/client/dev-overlay/plugins/{audit.ts => audit/index.ts} (74%) diff --git a/.changeset/orange-candles-sip.md b/.changeset/orange-candles-sip.md new file mode 100644 index 000000000000..442e386b7447 --- /dev/null +++ b/.changeset/orange-candles-sip.md @@ -0,0 +1,9 @@ +--- +'astro': patch +--- + +Adds new accessibility audits to the Dev Toolbar's built-in Audits app. + +The audits Astro performs are non-exhaustive and only capable of detecting a handful of common accessibility issues. Please take care to perform a thorough, **manual** audit of your site to ensure compliance with the [Web Content Accessibility Guidelines (WCAG) international standard](https://www.w3.org/WAI/standards-guidelines/wcag/) _before_ publishing your site. + +🧡 Huge thanks to the [Svelte](https://github.com/sveltejs/svelte) team for providing the basis of these accessibility audits! diff --git a/LICENSE b/LICENSE index 1f0bcaa7dcef..b3cd0c0f0e01 100644 --- a/LICENSE +++ b/LICENSE @@ -20,7 +20,6 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - """ This license applies to parts of the `packages/create-astro` and `packages/astro` subdirectories originating from the https://github.com/sveltejs/kit repository: @@ -33,7 +32,6 @@ The above copyright notice and this permission notice shall be included in all c THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. """ - """ This license applies to parts of the `packages/create-astro` and `packages/astro` subdirectories originating from the https://github.com/vitejs/vite repository: diff --git a/packages/astro/package.json b/packages/astro/package.json index 23b2d68b08dd..7641ce2b5c83 100644 --- a/packages/astro/package.json +++ b/packages/astro/package.json @@ -124,6 +124,8 @@ "@babel/types": "^7.23.3", "@types/babel__core": "^7.20.4", "acorn": "^8.11.2", + "aria-query": "^5.3.0", + "axobject-query": "^4.0.0", "boxen": "^7.1.1", "chokidar": "^3.5.3", "ci-info": "^4.0.0", @@ -180,6 +182,7 @@ "devDependencies": { "@astrojs/check": "^0.3.1", "@playwright/test": "1.40.0", + "@types/aria-query": "^5.0.4", "@types/babel__generator": "^7.6.7", "@types/babel__traverse": "^7.20.4", "@types/chai": "^4.3.10", diff --git a/packages/astro/src/runtime/client/dev-overlay/entrypoint.ts b/packages/astro/src/runtime/client/dev-overlay/entrypoint.ts index f7c09dea6d99..ffd9ea32b57f 100644 --- a/packages/astro/src/runtime/client/dev-overlay/entrypoint.ts +++ b/packages/astro/src/runtime/client/dev-overlay/entrypoint.ts @@ -27,7 +27,7 @@ document.addEventListener('DOMContentLoaded', async () => { ] = await Promise.all([ loadDevOverlayPlugins() as DevOverlayPluginDefinition[], import('./plugins/astro.js'), - import('./plugins/audit.js'), + import('./plugins/audit/index.js'), import('./plugins/xray.js'), import('./plugins/settings.js'), import('./overlay.js'), diff --git a/packages/astro/src/runtime/client/dev-overlay/plugins/audit/a11y.ts b/packages/astro/src/runtime/client/dev-overlay/plugins/audit/a11y.ts new file mode 100644 index 000000000000..fd3763564bca --- /dev/null +++ b/packages/astro/src/runtime/client/dev-overlay/plugins/audit/a11y.ts @@ -0,0 +1,628 @@ +/** + * https://github.com/sveltejs/svelte/blob/61e5e53eee82e895c1a5b4fd36efb87eafa1fc2d/LICENSE.md + * @license MIT + * + * Copyright (c) 2016-23 [these people](https://github.com/sveltejs/svelte/graphs/contributors) + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +import type { ARIARoleDefinitionKey } from 'aria-query'; +import { aria, roles } from 'aria-query'; +import type { AuditRuleWithSelector } from './index.js'; +// @ts-expect-error package does not provide types +import { AXObjectRoles, elementAXObjects } from 'axobject-query'; + +const a11y_required_attributes = { + a: ['href'], + area: ['alt', 'aria-label', 'aria-labelledby'], + // html-has-lang + html: ['lang'], + // iframe-has-title + iframe: ['title'], + img: ['alt'], + object: ['title', 'aria-label', 'aria-labelledby'], +}; + +const interactiveElements = ['button', 'details', 'embed', 'iframe', 'label', 'select', 'textarea']; + +const aria_non_interactive_roles = [ + 'alert', + 'alertdialog', + 'application', + 'article', + 'banner', + 'button', + 'cell', + 'checkbox', + 'columnheader', + 'combobox', + 'complementary', + 'contentinfo', + 'definition', + 'dialog', + 'directory', + 'document', + 'feed', + 'figure', + 'form', + 'grid', + 'gridcell', + 'group', + 'heading', + 'img', + 'link', + 'list', + 'listbox', + 'listitem', + 'log', + 'main', + 'marquee', + 'math', + 'menu', + 'menubar', + 'menuitem', + 'menuitemcheckbox', + 'menuitemradio', + 'navigation', + 'none', + 'note', + 'option', + 'presentation', + 'progressbar', + 'radio', + 'radiogroup', + 'region', + 'row', + 'rowgroup', + 'rowheader', + 'scrollbar', + 'search', + 'searchbox', + 'separator', + 'slider', + 'spinbutton', + 'status', + 'switch', + 'tab', + 'tablist', + 'tabpanel', + 'term', + 'textbox', + 'timer', + 'toolbar', + 'tooltip', + 'tree', + 'treegrid', + 'treeitem', +]; + +const a11y_required_content = [ + // anchor-has-content + 'a', + // heading-has-content + 'h1', + 'h2', + 'h3', + 'h4', + 'h5', + 'h6', +]; + +const a11y_distracting_elements = ['blink', 'marquee']; + +const a11y_nested_implicit_semantics = new Map([ + ['header', 'banner'], + ['footer', 'contentinfo'], +]); +const a11y_implicit_semantics = new Map([ + ['a', 'link'], + ['area', 'link'], + ['article', 'article'], + ['aside', 'complementary'], + ['body', 'document'], + ['button', 'button'], + ['datalist', 'listbox'], + ['dd', 'definition'], + ['dfn', 'term'], + ['dialog', 'dialog'], + ['details', 'group'], + ['dt', 'term'], + ['fieldset', 'group'], + ['figure', 'figure'], + ['form', 'form'], + ['h1', 'heading'], + ['h2', 'heading'], + ['h3', 'heading'], + ['h4', 'heading'], + ['h5', 'heading'], + ['h6', 'heading'], + ['hr', 'separator'], + ['img', 'img'], + ['li', 'listitem'], + ['link', 'link'], + ['main', 'main'], + ['menu', 'list'], + ['meter', 'progressbar'], + ['nav', 'navigation'], + ['ol', 'list'], + ['option', 'option'], + ['optgroup', 'group'], + ['output', 'status'], + ['progress', 'progressbar'], + ['section', 'region'], + ['summary', 'button'], + ['table', 'table'], + ['tbody', 'rowgroup'], + ['textarea', 'textbox'], + ['tfoot', 'rowgroup'], + ['thead', 'rowgroup'], + ['tr', 'row'], + ['ul', 'list'], +]); +const menuitem_type_to_implicit_role = new Map([ + ['command', 'menuitem'], + ['checkbox', 'menuitemcheckbox'], + ['radio', 'menuitemradio'], +]); +const input_type_to_implicit_role = new Map([ + ['button', 'button'], + ['image', 'button'], + ['reset', 'button'], + ['submit', 'button'], + ['checkbox', 'checkbox'], + ['radio', 'radio'], + ['range', 'slider'], + ['number', 'spinbutton'], + ['email', 'textbox'], + ['search', 'searchbox'], + ['tel', 'textbox'], + ['text', 'textbox'], + ['url', 'textbox'], +]); + +const ariaAttributes = new Set( + 'activedescendant atomic autocomplete busy checked colcount colindex colspan controls current describedby description details disabled dropeffect errormessage expanded flowto grabbed haspopup hidden invalid keyshortcuts label labelledby level live modal multiline multiselectable orientation owns placeholder posinset pressed readonly relevant required roledescription rowcount rowindex rowspan selected setsize sort valuemax valuemin valuenow valuetext'.split( + ' ' + ) +); + +const ariaRoles = new Set( + 'alert alertdialog application article banner button cell checkbox columnheader combobox complementary contentinfo definition dialog directory document feed figure form grid gridcell group heading img link list listbox listitem log main marquee math menu menubar menuitem menuitemcheckbox menuitemradio navigation none note option presentation progressbar radio radiogroup region row rowgroup rowheader scrollbar search searchbox separator slider spinbutton status tab tablist tabpanel textbox timer toolbar tooltip tree treegrid treeitem'.split( + ' ' + ) +); + +export const a11y: AuditRuleWithSelector[] = [ + { + code: 'a11y-accesskey', + title: 'Avoid using `accesskey`', + message: + "The `accesskey` attribute can cause accessibility issues. The shortcuts can conflict with the browser's or operating system's shortcuts, and they are difficult for users to discover and use.", + selector: '[accesskey]', + }, + { + code: 'a11y-aria-activedescendant-has-tabindex', + title: 'Elements with attribute `aria-activedescendant` must be tabbable', + message: + 'This element must either have an inherent `tabindex` or declare `tabindex` as an attribute.', + selector: '[aria-activedescendant]', + match(element) { + if (!(element as HTMLElement).tabIndex && !element.hasAttribute('tabindex')) return true; + }, + }, + { + code: 'a11y-aria-attributes', + title: 'Element does not support ARIA roles.', + message: 'Elements like `meta`, `html`, `script`, `style` do not support having ARIA roles.', + selector: ':is(meta, html, script, style)[role]', + match(element) { + for (const attribute of element.attributes) { + if (attribute.name.startsWith('aria-')) return true; + } + }, + }, + { + code: 'a11y-autofocus', + title: 'Avoid using `autofocus`', + message: + 'The `autofocus` attribute can cause accessibility issues, as it can cause the focus to move around unexpectedly for screen reader users.', + selector: '[autofocus]', + }, + { + code: 'a11y-distracting-elements', + title: 'Distracting elements should not be used', + message: + 'Elements that can be visually distracting like `` or `` can cause accessibility issues for visually impaired users and should be avoided.', + selector: `:is(${a11y_distracting_elements.join(',')})`, + }, + { + code: 'a11y-hidden', + title: 'Certain DOM elements are useful for screen reader navigation and should not be hidden', + message: (element) => `${element.localName} element should not be hidden.`, + selector: '[aria-hidden]:is(h1,h2,h3,h4,h5,h6)', + }, + { + code: 'a11y-img-redundant-alt', + title: 'Redundant text in alt attribute', + message: + 'Screen readers already announce `img` elements as an image. There is no need to use words such as "image", "photo", and/or "picture".', + selector: 'img[alt]:not([aria-hidden])', + match: (img: HTMLImageElement) => /\b(image|picture|photo)\b/i.test(img.alt), + }, + { + code: 'a11y-incorrect-aria-attribute-type', + title: 'Incorrect value for ARIA attribute.', + message: '`aria-hidden` should only receive a boolean.', + selector: '[aria-hidden]', + match(element) { + const value = element.getAttribute('aria-hidden'); + if (!value) return true; + if (!['true', 'false'].includes(value)) return true; + }, + }, + { + code: 'a11y-invalid-attribute', + title: 'Attributes important for accessibility should have a valid value', + message: "`href` should not be empty, `'#'`, or `javascript:`.", + selector: 'a[href]:is([href=""], [href="#"], [href^="javascript:" i])', + }, + { + code: 'a11y-label-has-associated-control', + title: '`label` tag should have an associated control and a text content.', + message: + 'The `label` tag must be associated with a control using either `for` or having a nested input. Additionally, the `label` tag must have text content.', + selector: 'label:not([for])', + match(element) { + const inputChild = element.querySelector('input'); + if (!inputChild?.textContent) return true; + }, + }, + { + code: 'a11y-media-has-caption', + title: 'Unmuted video elements should have captions', + message: + 'Videos without captions can be difficult for deaf and hard-of-hearing users to follow along with. If the video does not need captions, add the `muted` attribute.', + selector: 'video:not([muted])', + match(element) { + const tracks = element.querySelectorAll('track'); + if (!tracks.length) return true; + + const hasCaptionTrack = Array.from(tracks).some( + (track) => track.getAttribute('kind') === 'captions' + ); + + return !hasCaptionTrack; + }, + }, + { + code: 'a11y-misplaced-scope', + title: 'The `scope` attribute should only be used on `` elements', + message: + 'The `scope` attribute tells the browser and screen readers how to navigate tables. In HTML5, it should only be used on `` elements.', + selector: ':not(th)[scope]', + }, + { + code: 'a11y-missing-attribute', + title: 'Required attributes missing.', + message: (element) => { + const requiredAttributes = + a11y_required_attributes[element.localName as keyof typeof a11y_required_attributes]; + + const missingAttributes = requiredAttributes.filter( + (attribute) => !element.hasAttribute(attribute) + ); + + return `${ + element.localName + } element is missing required attributes for accessibility: ${missingAttributes.join(', ')} `; + }, + selector: Object.keys(a11y_required_attributes).join(','), + match(element) { + const requiredAttributes = + a11y_required_attributes[element.localName as keyof typeof a11y_required_attributes]; + + if (!requiredAttributes) return true; + for (const attribute of requiredAttributes) { + if (!element.hasAttribute(attribute)) return true; + } + + return false; + }, + }, + { + code: 'a11y-missing-content', + title: 'Missing content on element important for accessibility', + message: 'Headings and anchors must have content to be accessible.', + selector: a11y_required_content.join(','), + match(element) { + if (!element.textContent) return true; + }, + }, + { + code: 'a11y-no-redundant-roles', + title: 'HTML element has redundant ARIA roles', + message: + 'Giving these elements an ARIA role that is already set by the browser has no effect and is redundant.', + selector: [...a11y_implicit_semantics.keys()].join(','), + match(element) { + const role = element.getAttribute('role'); + + if (element.localName === 'input') { + const type = element.getAttribute('type'); + if (!type) return true; + + const implicitRoleForType = input_type_to_implicit_role.get(type); + if (!implicitRoleForType) return true; + + if (role === implicitRoleForType) return false; + } + + // TODO: Handle menuitem and elements that inherit their role from their parent + + const implicitRole = a11y_implicit_semantics.get(element.localName); + if (!implicitRole) return true; + + if (role === implicitRole) return false; + }, + }, + { + code: 'a11y-no-interactive-element-to-noninteractive-role', + title: 'Non-interactive ARIA role used on interactive HTML element.', + message: + 'Interactive HTML elements like `` and ` + + + + + + + diff --git a/packages/astro/e2e/view-transitions.test.js b/packages/astro/e2e/view-transitions.test.js index bfc5d7d4a92d..27b7ea6d6a76 100644 --- a/packages/astro/e2e/view-transitions.test.js +++ b/packages/astro/e2e/view-transitions.test.js @@ -1074,4 +1074,18 @@ test.describe('View Transitions', () => { await page.click('#three'); await expect(page).toHaveURL(expected); }); + + test('Dialog using form with method of "dialog" should not trigger navigation', async ({ page, astro }) => { + await page.goto(astro.resolveUrl('/dialog')); + + let requests = []; + page.on('request', request => requests.push(`${request.method()} ${request.url()}`)); + + await page.click('#open'); + await expect(page.locator("dialog")).toHaveAttribute("open") + await page.click('#close'); + await expect(page.locator("dialog")).not.toHaveAttribute("open") + + expect(requests).toHaveLength(0) + }); }); From 6404d26a22417587cac272bc473ee1c8eb8c69a3 Mon Sep 17 00:00:00 2001 From: Ted Klingenberg Date: Wed, 6 Dec 2023 00:43:56 +0000 Subject: [PATCH 50/59] [ci] format --- packages/astro/components/ViewTransitions.astro | 6 +++--- packages/astro/e2e/view-transitions.test.js | 13 ++++++++----- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/packages/astro/components/ViewTransitions.astro b/packages/astro/components/ViewTransitions.astro index d9786ac6ac32..310f1865a92c 100644 --- a/packages/astro/components/ViewTransitions.astro +++ b/packages/astro/components/ViewTransitions.astro @@ -106,8 +106,8 @@ const { fallback = 'animate' } = Astro.props; // the "dialog" method is a special keyword used within elements // https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#attr-fs-method - if (method === "dialog") { - return + if (method === 'dialog') { + return; } const options: Options = { sourceElement: submitter ?? form }; @@ -119,7 +119,7 @@ const { fallback = 'animate' } = Astro.props; } else { options.formData = formData; } - + ev.preventDefault(); navigate(action, options); }); diff --git a/packages/astro/e2e/view-transitions.test.js b/packages/astro/e2e/view-transitions.test.js index 27b7ea6d6a76..222c9dfdf2aa 100644 --- a/packages/astro/e2e/view-transitions.test.js +++ b/packages/astro/e2e/view-transitions.test.js @@ -1075,17 +1075,20 @@ test.describe('View Transitions', () => { await expect(page).toHaveURL(expected); }); - test('Dialog using form with method of "dialog" should not trigger navigation', async ({ page, astro }) => { + test('Dialog using form with method of "dialog" should not trigger navigation', async ({ + page, + astro, + }) => { await page.goto(astro.resolveUrl('/dialog')); let requests = []; - page.on('request', request => requests.push(`${request.method()} ${request.url()}`)); + page.on('request', (request) => requests.push(`${request.method()} ${request.url()}`)); await page.click('#open'); - await expect(page.locator("dialog")).toHaveAttribute("open") + await expect(page.locator('dialog')).toHaveAttribute('open'); await page.click('#close'); - await expect(page.locator("dialog")).not.toHaveAttribute("open") + await expect(page.locator('dialog')).not.toHaveAttribute('open'); - expect(requests).toHaveLength(0) + expect(requests).toHaveLength(0); }); }); From 895ebcb5bfeb2fe08ae939eaceeb0405cff91ca5 Mon Sep 17 00:00:00 2001 From: "Houston (Bot)" <108291165+astrobot-houston@users.noreply.github.com> Date: Tue, 5 Dec 2023 16:47:22 -0800 Subject: [PATCH 51/59] [ci] release (#9332) Co-authored-by: github-actions[bot] --- .changeset/beige-gorillas-camp.md | 5 -- .changeset/rich-keys-rescue.md | 5 -- .changeset/selfish-lamps-build.md | 5 -- examples/basics/package.json | 2 +- examples/blog/package.json | 2 +- examples/component/package.json | 2 +- examples/framework-alpine/package.json | 2 +- examples/framework-lit/package.json | 2 +- examples/framework-multiple/package.json | 4 +- examples/framework-preact/package.json | 2 +- examples/framework-react/package.json | 2 +- examples/framework-solid/package.json | 2 +- examples/framework-svelte/package.json | 2 +- examples/framework-vue/package.json | 4 +- examples/hackernews/package.json | 2 +- examples/integration/package.json | 2 +- examples/middleware/package.json | 2 +- examples/minimal/package.json | 2 +- examples/non-html-pages/package.json | 2 +- examples/portfolio/package.json | 2 +- examples/ssr/package.json | 2 +- examples/view-transitions/package.json | 2 +- examples/with-markdoc/package.json | 2 +- examples/with-markdown-plugins/package.json | 2 +- examples/with-markdown-shiki/package.json | 2 +- examples/with-mdx/package.json | 2 +- examples/with-nanostores/package.json | 2 +- examples/with-tailwindcss/package.json | 2 +- examples/with-vitest/package.json | 2 +- packages/astro/CHANGELOG.md | 8 +++ packages/astro/package.json | 2 +- packages/integrations/vue/CHANGELOG.md | 6 +++ packages/integrations/vue/package.json | 2 +- pnpm-lock.yaml | 56 ++++++++++----------- 34 files changed, 72 insertions(+), 73 deletions(-) delete mode 100644 .changeset/beige-gorillas-camp.md delete mode 100644 .changeset/rich-keys-rescue.md delete mode 100644 .changeset/selfish-lamps-build.md diff --git a/.changeset/beige-gorillas-camp.md b/.changeset/beige-gorillas-camp.md deleted file mode 100644 index 4edafccb44ea..000000000000 --- a/.changeset/beige-gorillas-camp.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'astro': patch ---- - -Updates an internal dependency ([`vitefu`](https://github.com/svitejs/vitefu)) to avoid a common `peerDependency` warning diff --git a/.changeset/rich-keys-rescue.md b/.changeset/rich-keys-rescue.md deleted file mode 100644 index 1107f35b17cc..000000000000 --- a/.changeset/rich-keys-rescue.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'astro': patch ---- - -Fixes an edge case for `
` when using View Transitions. Forms with `method="dialog"` no longer require an additional `data-astro-reload` attribute. diff --git a/.changeset/selfish-lamps-build.md b/.changeset/selfish-lamps-build.md deleted file mode 100644 index 155c326270f5..000000000000 --- a/.changeset/selfish-lamps-build.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'@astrojs/vue': patch ---- - -Fixes issue with `appEntrypoint` when running `astro dev` diff --git a/examples/basics/package.json b/examples/basics/package.json index e4ed24314fe7..462235462498 100644 --- a/examples/basics/package.json +++ b/examples/basics/package.json @@ -11,6 +11,6 @@ "astro": "astro" }, "dependencies": { - "astro": "^4.0.1" + "astro": "^4.0.2" } } diff --git a/examples/blog/package.json b/examples/blog/package.json index 8e4c5ac223bf..3ece054ce403 100644 --- a/examples/blog/package.json +++ b/examples/blog/package.json @@ -14,6 +14,6 @@ "@astrojs/mdx": "^2.0.0", "@astrojs/rss": "^4.0.0", "@astrojs/sitemap": "^3.0.3", - "astro": "^4.0.1" + "astro": "^4.0.2" } } diff --git a/examples/component/package.json b/examples/component/package.json index 0d916d3b713c..9cac9645df69 100644 --- a/examples/component/package.json +++ b/examples/component/package.json @@ -15,7 +15,7 @@ ], "scripts": {}, "devDependencies": { - "astro": "^4.0.1" + "astro": "^4.0.2" }, "peerDependencies": { "astro": "^3.0.0" diff --git a/examples/framework-alpine/package.json b/examples/framework-alpine/package.json index 28debb4f53fd..f9fc290954ba 100644 --- a/examples/framework-alpine/package.json +++ b/examples/framework-alpine/package.json @@ -14,6 +14,6 @@ "@astrojs/alpinejs": "^0.3.1", "@types/alpinejs": "^3.13.5", "alpinejs": "^3.13.3", - "astro": "^4.0.1" + "astro": "^4.0.2" } } diff --git a/examples/framework-lit/package.json b/examples/framework-lit/package.json index 3a4fec7fc22d..72a5bd0c45aa 100644 --- a/examples/framework-lit/package.json +++ b/examples/framework-lit/package.json @@ -13,7 +13,7 @@ "dependencies": { "@astrojs/lit": "^3.0.3", "@webcomponents/template-shadowroot": "^0.2.1", - "astro": "^4.0.1", + "astro": "^4.0.2", "lit": "^2.8.0" } } diff --git a/examples/framework-multiple/package.json b/examples/framework-multiple/package.json index cc2d1fc1e4ac..d83833e59bec 100644 --- a/examples/framework-multiple/package.json +++ b/examples/framework-multiple/package.json @@ -15,8 +15,8 @@ "@astrojs/react": "^3.0.7", "@astrojs/solid-js": "^3.0.2", "@astrojs/svelte": "^5.0.0", - "@astrojs/vue": "^4.0.1", - "astro": "^4.0.1", + "@astrojs/vue": "^4.0.2", + "astro": "^4.0.2", "preact": "^10.19.2", "react": "^18.2.0", "react-dom": "^18.2.0", diff --git a/examples/framework-preact/package.json b/examples/framework-preact/package.json index 56adb34e6ca3..08c3d7d875e1 100644 --- a/examples/framework-preact/package.json +++ b/examples/framework-preact/package.json @@ -13,7 +13,7 @@ "dependencies": { "@astrojs/preact": "^3.0.1", "@preact/signals": "^1.2.1", - "astro": "^4.0.1", + "astro": "^4.0.2", "preact": "^10.19.2" } } diff --git a/examples/framework-react/package.json b/examples/framework-react/package.json index 1e0eeed2893c..6256dcb6b779 100644 --- a/examples/framework-react/package.json +++ b/examples/framework-react/package.json @@ -14,7 +14,7 @@ "@astrojs/react": "^3.0.7", "@types/react": "^18.2.37", "@types/react-dom": "^18.2.15", - "astro": "^4.0.1", + "astro": "^4.0.2", "react": "^18.2.0", "react-dom": "^18.2.0" } diff --git a/examples/framework-solid/package.json b/examples/framework-solid/package.json index e9872b4efaa2..34d8bc50f6ba 100644 --- a/examples/framework-solid/package.json +++ b/examples/framework-solid/package.json @@ -12,7 +12,7 @@ }, "dependencies": { "@astrojs/solid-js": "^3.0.2", - "astro": "^4.0.1", + "astro": "^4.0.2", "solid-js": "^1.8.5" } } diff --git a/examples/framework-svelte/package.json b/examples/framework-svelte/package.json index e7e370518810..a9406838c3cf 100644 --- a/examples/framework-svelte/package.json +++ b/examples/framework-svelte/package.json @@ -12,7 +12,7 @@ }, "dependencies": { "@astrojs/svelte": "^5.0.0", - "astro": "^4.0.1", + "astro": "^4.0.2", "svelte": "^4.2.5" } } diff --git a/examples/framework-vue/package.json b/examples/framework-vue/package.json index 81a02293828e..f7a42cd42bf5 100644 --- a/examples/framework-vue/package.json +++ b/examples/framework-vue/package.json @@ -11,8 +11,8 @@ "astro": "astro" }, "dependencies": { - "@astrojs/vue": "^4.0.1", - "astro": "^4.0.1", + "@astrojs/vue": "^4.0.2", + "astro": "^4.0.2", "vue": "^3.3.8" } } diff --git a/examples/hackernews/package.json b/examples/hackernews/package.json index 0a354dacf866..ca4ab4ef6030 100644 --- a/examples/hackernews/package.json +++ b/examples/hackernews/package.json @@ -12,6 +12,6 @@ }, "dependencies": { "@astrojs/node": "^7.0.0", - "astro": "^4.0.1" + "astro": "^4.0.2" } } diff --git a/examples/integration/package.json b/examples/integration/package.json index 3fe356bea0c8..3708dfac7306 100644 --- a/examples/integration/package.json +++ b/examples/integration/package.json @@ -15,7 +15,7 @@ ], "scripts": {}, "devDependencies": { - "astro": "^4.0.1" + "astro": "^4.0.2" }, "peerDependencies": { "astro": "^3.0.0" diff --git a/examples/middleware/package.json b/examples/middleware/package.json index 432bb09544b1..9f6393538781 100644 --- a/examples/middleware/package.json +++ b/examples/middleware/package.json @@ -13,7 +13,7 @@ }, "dependencies": { "@astrojs/node": "^7.0.0", - "astro": "^4.0.1", + "astro": "^4.0.2", "html-minifier": "^4.0.0" } } diff --git a/examples/minimal/package.json b/examples/minimal/package.json index 62f864b52ace..7f37079799a5 100644 --- a/examples/minimal/package.json +++ b/examples/minimal/package.json @@ -11,6 +11,6 @@ "astro": "astro" }, "dependencies": { - "astro": "^4.0.1" + "astro": "^4.0.2" } } diff --git a/examples/non-html-pages/package.json b/examples/non-html-pages/package.json index 6695eda42e63..e7c51ad9cdbf 100644 --- a/examples/non-html-pages/package.json +++ b/examples/non-html-pages/package.json @@ -11,6 +11,6 @@ "astro": "astro" }, "dependencies": { - "astro": "^4.0.1" + "astro": "^4.0.2" } } diff --git a/examples/portfolio/package.json b/examples/portfolio/package.json index ad232172e8f4..c8b9e51946f3 100644 --- a/examples/portfolio/package.json +++ b/examples/portfolio/package.json @@ -11,6 +11,6 @@ "astro": "astro" }, "dependencies": { - "astro": "^4.0.1" + "astro": "^4.0.2" } } diff --git a/examples/ssr/package.json b/examples/ssr/package.json index 7665692b15ac..f7af576ce892 100644 --- a/examples/ssr/package.json +++ b/examples/ssr/package.json @@ -14,7 +14,7 @@ "dependencies": { "@astrojs/node": "^7.0.0", "@astrojs/svelte": "^5.0.0", - "astro": "^4.0.1", + "astro": "^4.0.2", "svelte": "^4.2.5" } } diff --git a/examples/view-transitions/package.json b/examples/view-transitions/package.json index 81e1799d1d17..4e2839596e52 100644 --- a/examples/view-transitions/package.json +++ b/examples/view-transitions/package.json @@ -12,6 +12,6 @@ "devDependencies": { "@astrojs/tailwind": "^5.0.3", "@astrojs/node": "^7.0.0", - "astro": "^4.0.1" + "astro": "^4.0.2" } } diff --git a/examples/with-markdoc/package.json b/examples/with-markdoc/package.json index 6ffcb62c947c..58f640c801e6 100644 --- a/examples/with-markdoc/package.json +++ b/examples/with-markdoc/package.json @@ -12,6 +12,6 @@ }, "dependencies": { "@astrojs/markdoc": "^0.8.0", - "astro": "^4.0.1" + "astro": "^4.0.2" } } diff --git a/examples/with-markdown-plugins/package.json b/examples/with-markdown-plugins/package.json index 99273393dc55..1dbbd8eda8bc 100644 --- a/examples/with-markdown-plugins/package.json +++ b/examples/with-markdown-plugins/package.json @@ -12,7 +12,7 @@ }, "dependencies": { "@astrojs/markdown-remark": "^4.0.0", - "astro": "^4.0.1", + "astro": "^4.0.2", "hast-util-select": "^6.0.2", "rehype-autolink-headings": "^7.1.0", "rehype-slug": "^6.0.0", diff --git a/examples/with-markdown-shiki/package.json b/examples/with-markdown-shiki/package.json index cba6affce62a..b7c646508f27 100644 --- a/examples/with-markdown-shiki/package.json +++ b/examples/with-markdown-shiki/package.json @@ -11,6 +11,6 @@ "astro": "astro" }, "dependencies": { - "astro": "^4.0.1" + "astro": "^4.0.2" } } diff --git a/examples/with-mdx/package.json b/examples/with-mdx/package.json index 64444a5f4028..67b1428e4e12 100644 --- a/examples/with-mdx/package.json +++ b/examples/with-mdx/package.json @@ -13,7 +13,7 @@ "dependencies": { "@astrojs/mdx": "^2.0.0", "@astrojs/preact": "^3.0.1", - "astro": "^4.0.1", + "astro": "^4.0.2", "preact": "^10.19.2" } } diff --git a/examples/with-nanostores/package.json b/examples/with-nanostores/package.json index 9938024775d3..586b36bd8b6a 100644 --- a/examples/with-nanostores/package.json +++ b/examples/with-nanostores/package.json @@ -13,7 +13,7 @@ "dependencies": { "@astrojs/preact": "^3.0.1", "@nanostores/preact": "^0.5.0", - "astro": "^4.0.1", + "astro": "^4.0.2", "nanostores": "^0.9.5", "preact": "^10.19.2" } diff --git a/examples/with-tailwindcss/package.json b/examples/with-tailwindcss/package.json index b549791fcb86..f76fccaacb19 100644 --- a/examples/with-tailwindcss/package.json +++ b/examples/with-tailwindcss/package.json @@ -14,7 +14,7 @@ "@astrojs/mdx": "^2.0.0", "@astrojs/tailwind": "^5.0.3", "@types/canvas-confetti": "^1.6.3", - "astro": "^4.0.1", + "astro": "^4.0.2", "autoprefixer": "^10.4.15", "canvas-confetti": "^1.9.1", "postcss": "^8.4.28", diff --git a/examples/with-vitest/package.json b/examples/with-vitest/package.json index c2532051195e..838d13d2e65a 100644 --- a/examples/with-vitest/package.json +++ b/examples/with-vitest/package.json @@ -12,7 +12,7 @@ "test": "vitest" }, "dependencies": { - "astro": "^4.0.1", + "astro": "^4.0.2", "vitest": "^0.34.2" } } diff --git a/packages/astro/CHANGELOG.md b/packages/astro/CHANGELOG.md index 3925e15e40ab..5076fc126336 100644 --- a/packages/astro/CHANGELOG.md +++ b/packages/astro/CHANGELOG.md @@ -1,5 +1,13 @@ # astro +## 4.0.2 + +### Patch Changes + +- [#9331](https://github.com/withastro/astro/pull/9331) [`cfb20550d`](https://github.com/withastro/astro/commit/cfb20550d346a33e76e23453d5dcd084e5065c4d) Thanks [@natemoo-re](https://github.com/natemoo-re)! - Updates an internal dependency ([`vitefu`](https://github.com/svitejs/vitefu)) to avoid a common `peerDependency` warning + +- [#9327](https://github.com/withastro/astro/pull/9327) [`3878a91be`](https://github.com/withastro/astro/commit/3878a91be4879988c7235f433e50a6dc82e32288) Thanks [@doseofted](https://github.com/doseofted)! - Fixes an edge case for `` when using View Transitions. Forms with `method="dialog"` no longer require an additional `data-astro-reload` attribute. + ## 4.0.1 ### Patch Changes diff --git a/packages/astro/package.json b/packages/astro/package.json index a5bff393aa36..bfa7c54fdf04 100644 --- a/packages/astro/package.json +++ b/packages/astro/package.json @@ -1,6 +1,6 @@ { "name": "astro", - "version": "4.0.1", + "version": "4.0.2", "description": "Astro is a modern site builder with web best practices, performance, and DX front-of-mind.", "type": "module", "author": "withastro", diff --git a/packages/integrations/vue/CHANGELOG.md b/packages/integrations/vue/CHANGELOG.md index 1cc63f36e626..16b28bec63fd 100644 --- a/packages/integrations/vue/CHANGELOG.md +++ b/packages/integrations/vue/CHANGELOG.md @@ -1,5 +1,11 @@ # @astrojs/vue +## 4.0.2 + +### Patch Changes + +- [#9333](https://github.com/withastro/astro/pull/9333) [`b832cd190`](https://github.com/withastro/astro/commit/b832cd190199d4269d25d5d6e6b7efb399a69070) Thanks [@natemoo-re](https://github.com/natemoo-re)! - Fixes issue with `appEntrypoint` when running `astro dev` + ## 4.0.1 ### Patch Changes diff --git a/packages/integrations/vue/package.json b/packages/integrations/vue/package.json index 79dd727ad201..9ed3417f64e8 100644 --- a/packages/integrations/vue/package.json +++ b/packages/integrations/vue/package.json @@ -1,6 +1,6 @@ { "name": "@astrojs/vue", - "version": "4.0.1", + "version": "4.0.2", "description": "Use Vue components within Astro", "type": "module", "types": "./dist/index.d.ts", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index d8f8ff2ad6ea..1dfa0f263c7d 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -125,7 +125,7 @@ importers: examples/basics: dependencies: astro: - specifier: ^4.0.1 + specifier: ^4.0.2 version: link:../../packages/astro examples/blog: @@ -140,13 +140,13 @@ importers: specifier: ^3.0.3 version: link:../../packages/integrations/sitemap astro: - specifier: ^4.0.1 + specifier: ^4.0.2 version: link:../../packages/astro examples/component: devDependencies: astro: - specifier: ^4.0.1 + specifier: ^4.0.2 version: link:../../packages/astro examples/framework-alpine: @@ -161,7 +161,7 @@ importers: specifier: ^3.13.3 version: 3.13.3 astro: - specifier: ^4.0.1 + specifier: ^4.0.2 version: link:../../packages/astro examples/framework-lit: @@ -173,7 +173,7 @@ importers: specifier: ^0.2.1 version: 0.2.1 astro: - specifier: ^4.0.1 + specifier: ^4.0.2 version: link:../../packages/astro lit: specifier: ^2.8.0 @@ -194,10 +194,10 @@ importers: specifier: ^5.0.0 version: link:../../packages/integrations/svelte '@astrojs/vue': - specifier: ^4.0.1 + specifier: ^4.0.2 version: link:../../packages/integrations/vue astro: - specifier: ^4.0.1 + specifier: ^4.0.2 version: link:../../packages/astro preact: specifier: ^10.19.2 @@ -227,7 +227,7 @@ importers: specifier: ^1.2.1 version: 1.2.1(preact@10.19.2) astro: - specifier: ^4.0.1 + specifier: ^4.0.2 version: link:../../packages/astro preact: specifier: ^10.19.2 @@ -245,7 +245,7 @@ importers: specifier: ^18.2.15 version: 18.2.15 astro: - specifier: ^4.0.1 + specifier: ^4.0.2 version: link:../../packages/astro react: specifier: ^18.2.0 @@ -260,7 +260,7 @@ importers: specifier: ^3.0.2 version: link:../../packages/integrations/solid astro: - specifier: ^4.0.1 + specifier: ^4.0.2 version: link:../../packages/astro solid-js: specifier: ^1.8.5 @@ -272,7 +272,7 @@ importers: specifier: ^5.0.0 version: link:../../packages/integrations/svelte astro: - specifier: ^4.0.1 + specifier: ^4.0.2 version: link:../../packages/astro svelte: specifier: ^4.2.5 @@ -281,10 +281,10 @@ importers: examples/framework-vue: dependencies: '@astrojs/vue': - specifier: ^4.0.1 + specifier: ^4.0.2 version: link:../../packages/integrations/vue astro: - specifier: ^4.0.1 + specifier: ^4.0.2 version: link:../../packages/astro vue: specifier: ^3.3.8 @@ -296,13 +296,13 @@ importers: specifier: ^7.0.0 version: link:../../packages/integrations/node astro: - specifier: ^4.0.1 + specifier: ^4.0.2 version: link:../../packages/astro examples/integration: devDependencies: astro: - specifier: ^4.0.1 + specifier: ^4.0.2 version: link:../../packages/astro examples/middleware: @@ -311,7 +311,7 @@ importers: specifier: ^7.0.0 version: link:../../packages/integrations/node astro: - specifier: ^4.0.1 + specifier: ^4.0.2 version: link:../../packages/astro html-minifier: specifier: ^4.0.0 @@ -320,19 +320,19 @@ importers: examples/minimal: dependencies: astro: - specifier: ^4.0.1 + specifier: ^4.0.2 version: link:../../packages/astro examples/non-html-pages: dependencies: astro: - specifier: ^4.0.1 + specifier: ^4.0.2 version: link:../../packages/astro examples/portfolio: dependencies: astro: - specifier: ^4.0.1 + specifier: ^4.0.2 version: link:../../packages/astro examples/ssr: @@ -344,7 +344,7 @@ importers: specifier: ^5.0.0 version: link:../../packages/integrations/svelte astro: - specifier: ^4.0.1 + specifier: ^4.0.2 version: link:../../packages/astro svelte: specifier: ^4.2.5 @@ -359,7 +359,7 @@ importers: specifier: ^5.0.3 version: link:../../packages/integrations/tailwind astro: - specifier: ^4.0.1 + specifier: ^4.0.2 version: link:../../packages/astro examples/with-markdoc: @@ -368,7 +368,7 @@ importers: specifier: ^0.8.0 version: link:../../packages/integrations/markdoc astro: - specifier: ^4.0.1 + specifier: ^4.0.2 version: link:../../packages/astro examples/with-markdown-plugins: @@ -377,7 +377,7 @@ importers: specifier: ^4.0.0 version: link:../../packages/markdown/remark astro: - specifier: ^4.0.1 + specifier: ^4.0.2 version: link:../../packages/astro hast-util-select: specifier: ^6.0.2 @@ -398,7 +398,7 @@ importers: examples/with-markdown-shiki: dependencies: astro: - specifier: ^4.0.1 + specifier: ^4.0.2 version: link:../../packages/astro examples/with-mdx: @@ -410,7 +410,7 @@ importers: specifier: ^3.0.1 version: link:../../packages/integrations/preact astro: - specifier: ^4.0.1 + specifier: ^4.0.2 version: link:../../packages/astro preact: specifier: ^10.19.2 @@ -425,7 +425,7 @@ importers: specifier: ^0.5.0 version: 0.5.0(nanostores@0.9.5)(preact@10.19.2) astro: - specifier: ^4.0.1 + specifier: ^4.0.2 version: link:../../packages/astro nanostores: specifier: ^0.9.5 @@ -446,7 +446,7 @@ importers: specifier: ^1.6.3 version: 1.6.3 astro: - specifier: ^4.0.1 + specifier: ^4.0.2 version: link:../../packages/astro autoprefixer: specifier: ^10.4.15 @@ -464,7 +464,7 @@ importers: examples/with-vitest: dependencies: astro: - specifier: ^4.0.1 + specifier: ^4.0.2 version: link:../../packages/astro vitest: specifier: ^0.34.2 From 0bb3d532219fb90fc08bfb472fc981fab6543d16 Mon Sep 17 00:00:00 2001 From: Shinya Fujino Date: Wed, 6 Dec 2023 19:44:07 +0900 Subject: [PATCH 52/59] Fix log message for `Disable notifications` (#9339) * Fix log message for `Disable notifications` * Add changeset --- .changeset/strange-parrots-promise.md | 5 +++++ .../astro/src/runtime/client/dev-overlay/plugins/settings.ts | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 .changeset/strange-parrots-promise.md diff --git a/.changeset/strange-parrots-promise.md b/.changeset/strange-parrots-promise.md new file mode 100644 index 000000000000..584d911eea0b --- /dev/null +++ b/.changeset/strange-parrots-promise.md @@ -0,0 +1,5 @@ +--- +'astro': patch +--- + +Fixed the log message to correctly display 'enabled' and 'disabled' when toggling 'Disable notifications' in the Toolbar. diff --git a/packages/astro/src/runtime/client/dev-overlay/plugins/settings.ts b/packages/astro/src/runtime/client/dev-overlay/plugins/settings.ts index 672b7bbda36a..dc5fe4ae3637 100644 --- a/packages/astro/src/runtime/client/dev-overlay/plugins/settings.ts +++ b/packages/astro/src/runtime/client/dev-overlay/plugins/settings.ts @@ -25,7 +25,7 @@ const settingsRows = [ } settings.updateSetting('disablePluginNotification', evt.currentTarget.checked); - const action = evt.currentTarget.checked ? 'enabled' : 'disabled'; + const action = evt.currentTarget.checked ? 'disabled' : 'enabled'; settings.log(`Plugin notification badges ${action}`); } }, From c76901065545f6a8d3de3e44d1c8ee5456a8a77a Mon Sep 17 00:00:00 2001 From: "Fred K. Schott" Date: Wed, 6 Dec 2023 04:07:52 -0800 Subject: [PATCH 53/59] Fix issue where 404/500 status codes were logged as "[200]" (#9336) --- .changeset/modern-mice-shout.md | 5 +++ packages/astro/src/core/messages.ts | 2 +- .../src/vite-plugin-astro-server/route.ts | 33 +++++++++---------- 3 files changed, 22 insertions(+), 18 deletions(-) create mode 100644 .changeset/modern-mice-shout.md diff --git a/.changeset/modern-mice-shout.md b/.changeset/modern-mice-shout.md new file mode 100644 index 000000000000..cc483b1937f6 --- /dev/null +++ b/.changeset/modern-mice-shout.md @@ -0,0 +1,5 @@ +--- +'astro': patch +--- + +dev: fix issue where 404 and 500 responses were logged as 200 diff --git a/packages/astro/src/core/messages.ts b/packages/astro/src/core/messages.ts index ebac2c51d611..b105e985cb05 100644 --- a/packages/astro/src/core/messages.ts +++ b/packages/astro/src/core/messages.ts @@ -37,7 +37,7 @@ export function req({ method?: string; reqTime?: number; }): string { - const color = statusCode >= 400 ? red : statusCode >= 300 ? yellow : blue; + const color = statusCode >= 500 ? red : statusCode >= 300 ? yellow : blue; return ( color(`[${statusCode}]`) + ` ` + diff --git a/packages/astro/src/vite-plugin-astro-server/route.ts b/packages/astro/src/vite-plugin-astro-server/route.ts index 92a7a8247a35..3196b951a796 100644 --- a/packages/astro/src/vite-plugin-astro-server/route.ts +++ b/packages/astro/src/vite-plugin-astro-server/route.ts @@ -332,7 +332,7 @@ export async function handleRoute({ req({ url: pathname, method: incomingRequest.method, - statusCode: response.status, + statusCode: status ?? response.status, reqTime: timeEnd - timeStart, }) ); @@ -356,24 +356,23 @@ export async function handleRoute({ } if (route.type === 'endpoint') { await writeWebResponse(incomingResponse, response); - } else { - if ( - // We are in a recursion, and it's possible that this function is called itself with a status code - // By default, the status code passed via parameters is computed by the matched route. - // - // By default, we should give priority to the status code passed, although it's possible that - // the `Response` emitted by the user is a redirect. If so, then return the returned response. - response.status < 400 && - response.status >= 300 - ) { - await writeSSRResult(request, response, incomingResponse); - return; - } else if (status && response.status !== status && (status === 404 || status === 500)) { - // Response.status is read-only, so a clone is required to override - response = new Response(response.body, { ...response, status }); - } + return; + } + // We are in a recursion, and it's possible that this function is called itself with a status code + // By default, the status code passed via parameters is computed by the matched route. + // + // By default, we should give priority to the status code passed, although it's possible that + // the `Response` emitted by the user is a redirect. If so, then return the returned response. + if (response.status < 400 && response.status >= 300) { await writeSSRResult(request, response, incomingResponse); + return; + } + // Apply the `status` override to the response object before responding. + // Response.status is read-only, so a clone is required to override. + if (status && response.status !== status && (status === 404 || status === 500)) { + response = new Response(response.body, { ...response, status }); } + await writeSSRResult(request, response, incomingResponse); } interface GetScriptsAndStylesParams { From eb942942d67508c07d7efaa859a7840f7c0223da Mon Sep 17 00:00:00 2001 From: Erika <3019731+Princesseuh@users.noreply.github.com> Date: Wed, 6 Dec 2023 13:09:30 +0100 Subject: [PATCH 54/59] fix: add types for `is:inline` on slots (#9342) --- .changeset/cold-toys-greet.md | 5 +++++ packages/astro/astro-jsx.d.ts | 3 ++- packages/astro/src/@types/astro.ts | 4 ++++ 3 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 .changeset/cold-toys-greet.md diff --git a/.changeset/cold-toys-greet.md b/.changeset/cold-toys-greet.md new file mode 100644 index 000000000000..7923c5567aea --- /dev/null +++ b/.changeset/cold-toys-greet.md @@ -0,0 +1,5 @@ +--- +'astro': patch +--- + +Fix missing `is:inline` type for the `` element diff --git a/packages/astro/astro-jsx.d.ts b/packages/astro/astro-jsx.d.ts index 3e8a86889282..3f73bcc613ee 100644 --- a/packages/astro/astro-jsx.d.ts +++ b/packages/astro/astro-jsx.d.ts @@ -36,6 +36,7 @@ declare namespace astroHTML.JSX { AstroDefineVarsAttribute; type AstroStyleAttributes = import('./dist/@types/astro.js').AstroStyleAttributes & AstroDefineVarsAttribute; + type AstroSlotAttributes = import('./dist/@types/astro.js').AstroSlotAttributes; // This is an unfortunate use of `any`, but unfortunately we can't make a type that works for every framework // without importing every single framework's types (which comes with its own set of problems). @@ -1415,7 +1416,7 @@ declare namespace astroHTML.JSX { ruby: HTMLAttributes; s: HTMLAttributes; samp: HTMLAttributes; - slot: SlotHTMLAttributes; + slot: SlotHTMLAttributes & AstroSlotAttributes; script: ScriptHTMLAttributes & AstroScriptAttributes; section: HTMLAttributes; select: SelectHTMLAttributes; diff --git a/packages/astro/src/@types/astro.ts b/packages/astro/src/@types/astro.ts index bbea8202523e..fa8c33920ac0 100644 --- a/packages/astro/src/@types/astro.ts +++ b/packages/astro/src/@types/astro.ts @@ -132,6 +132,10 @@ export interface AstroScriptAttributes { 'is:inline'?: boolean; } +export interface AstroSlotAttributes { + 'is:inline'?: boolean; +} + export interface AstroComponentMetadata { displayName: string; hydrate?: 'load' | 'idle' | 'visible' | 'media' | 'only'; From edfae50e6ea494f49c6d4fbf4bd4481870f994b1 Mon Sep 17 00:00:00 2001 From: Charles Villard Date: Wed, 6 Dec 2023 07:13:15 -0500 Subject: [PATCH 55/59] [@astrojs/rss] Quality-of-Life Improvement to `items` property-related error (#9299) * This commit addresses a quality-of-life concern when setting up a RSS feed when using collections. Specifically, it provides more context to the error message thrown when the object passed to the `items` property is missing any of the three required keys or if one of those keys is mistyped. * Add changeset * Update .changeset with properly formatted update structure @sarah11918 suggested a change to the verbiage that properly formatted the update detail in question. Accepting the suggestion. Co-authored-by: Sarah Rainsberger --------- Co-authored-by: Sarah Rainsberger --- .changeset/thirty-hairs-pump.md | 5 +++++ packages/astro-rss/src/index.ts | 17 +++++++++++++++-- 2 files changed, 20 insertions(+), 2 deletions(-) create mode 100644 .changeset/thirty-hairs-pump.md diff --git a/.changeset/thirty-hairs-pump.md b/.changeset/thirty-hairs-pump.md new file mode 100644 index 000000000000..acb4d1da23ee --- /dev/null +++ b/.changeset/thirty-hairs-pump.md @@ -0,0 +1,5 @@ +--- +'@astrojs/rss': patch +--- + +Improves the `@astrojs/rss` error message thrown when the object passed to the `items` property is missing any of the three required keys or if one of those keys is mistyped. diff --git a/packages/astro-rss/src/index.ts b/packages/astro-rss/src/index.ts index 48c5defe855c..738e696f39b6 100644 --- a/packages/astro-rss/src/index.ts +++ b/packages/astro-rss/src/index.ts @@ -110,8 +110,21 @@ async function validateRssOptions(rssOptions: RSSOptions) { [ `[RSS] Invalid or missing options:`, ...parsedResult.error.errors.map( - (zodError) => `${zodError.message} (${zodError.path.join('.')})` - ), + (zodError) => { + const path = zodError.path.join('.'); + const message = `${zodError.message} (${path})`; + const code = zodError.code; + + if (path === 'items' && code === 'invalid_union') { + return [ + message, + `The \`items\` property requires properly typed \`title\`, \`pubDate\`, and \`link\` keys.`, + `Check your collection's schema, and visit https://docs.astro.build/en/guides/rss/#generating-items for more info.` + ].join('\n') + } + + return message; + }), ].join('\n') ); throw formattedError; From 58d643bcd8e7ecbef5352d28054669a63b9cfa9e Mon Sep 17 00:00:00 2001 From: Charles Villard Date: Wed, 6 Dec 2023 12:14:25 +0000 Subject: [PATCH 56/59] [ci] format --- packages/astro-rss/src/index.ts | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/packages/astro-rss/src/index.ts b/packages/astro-rss/src/index.ts index 738e696f39b6..c8cf19d6022e 100644 --- a/packages/astro-rss/src/index.ts +++ b/packages/astro-rss/src/index.ts @@ -109,22 +109,21 @@ async function validateRssOptions(rssOptions: RSSOptions) { const formattedError = new Error( [ `[RSS] Invalid or missing options:`, - ...parsedResult.error.errors.map( - (zodError) => { - const path = zodError.path.join('.'); - const message = `${zodError.message} (${path})`; - const code = zodError.code; + ...parsedResult.error.errors.map((zodError) => { + const path = zodError.path.join('.'); + const message = `${zodError.message} (${path})`; + const code = zodError.code; - if (path === 'items' && code === 'invalid_union') { - return [ - message, + if (path === 'items' && code === 'invalid_union') { + return [ + message, `The \`items\` property requires properly typed \`title\`, \`pubDate\`, and \`link\` keys.`, - `Check your collection's schema, and visit https://docs.astro.build/en/guides/rss/#generating-items for more info.` - ].join('\n') - } + `Check your collection's schema, and visit https://docs.astro.build/en/guides/rss/#generating-items for more info.`, + ].join('\n'); + } - return message; - }), + return message; + }), ].join('\n') ); throw formattedError; From ab0281aee419e58c6079ca393987fe1ff0541dd5 Mon Sep 17 00:00:00 2001 From: Martin Trapp <94928215+martrapp@users.noreply.github.com> Date: Wed, 6 Dec 2023 16:20:08 +0100 Subject: [PATCH 57/59] Adds source file properties to HTML elements only if devToolbar is enabled (#9343) --- .changeset/famous-bobcats-vanish.md | 5 +++++ packages/astro/src/core/compile/compile.ts | 8 +++++++- packages/astro/src/vite-plugin-astro/index.ts | 2 ++ 3 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 .changeset/famous-bobcats-vanish.md diff --git a/.changeset/famous-bobcats-vanish.md b/.changeset/famous-bobcats-vanish.md new file mode 100644 index 000000000000..873cea592eb8 --- /dev/null +++ b/.changeset/famous-bobcats-vanish.md @@ -0,0 +1,5 @@ +--- +'astro': patch +--- + +Adds source file properties to HTML elements only if devToolbar is enabled diff --git a/packages/astro/src/core/compile/compile.ts b/packages/astro/src/core/compile/compile.ts index c2f58fb9f859..97625f021a55 100644 --- a/packages/astro/src/core/compile/compile.ts +++ b/packages/astro/src/core/compile/compile.ts @@ -10,10 +10,12 @@ import { AggregateError, CompilerError } from '../errors/errors.js'; import { AstroErrorData } from '../errors/index.js'; import { resolvePath } from '../util.js'; import { createStylePreprocessor } from './style.js'; +import type { AstroPreferences } from '../../preferences/index.js'; export interface CompileProps { astroConfig: AstroConfig; viteConfig: ResolvedConfig; + preferences: AstroPreferences; filename: string; source: string; } @@ -26,6 +28,7 @@ export interface CompileResult extends TransformResult { export async function compile({ astroConfig, viteConfig, + preferences, filename, source, }: CompileProps): Promise { @@ -48,7 +51,10 @@ export async function compile({ resultScopedSlot: true, transitionsAnimationURL: 'astro/components/viewtransitions.css', annotateSourceFile: - viteConfig.command === 'serve' && astroConfig.devToolbar && astroConfig.devToolbar.enabled, + viteConfig.command === 'serve' && + astroConfig.devToolbar && + astroConfig.devToolbar.enabled && + (await preferences.get('devToolbar.enabled')), preprocessStyle: createStylePreprocessor({ filename, viteConfig, diff --git a/packages/astro/src/vite-plugin-astro/index.ts b/packages/astro/src/vite-plugin-astro/index.ts index 2aa6236ffe95..d02d78d6ae6a 100644 --- a/packages/astro/src/vite-plugin-astro/index.ts +++ b/packages/astro/src/vite-plugin-astro/index.ts @@ -139,6 +139,7 @@ export default function astro({ settings, logger }: AstroPluginOptions): vite.Pl const compileProps: CompileProps = { astroConfig: config, viteConfig: resolvedConfig, + preferences: settings.preferences, filename: normalizePath(parsedId.filename), source, }; @@ -179,6 +180,7 @@ export default function astro({ settings, logger }: AstroPluginOptions): vite.Pl cachedCompilation({ astroConfig: config, viteConfig: resolvedConfig, + preferences: settings.preferences, filename, source, }); From 1685cc42b51603eb98b5ba3e072cf2d3953339f2 Mon Sep 17 00:00:00 2001 From: Matthew Phillips Date: Wed, 6 Dec 2023 14:58:35 -0500 Subject: [PATCH 58/59] Define the Vercel adapter's peerDependency (#9348) * Define the Vercel adapter's peerDependency * Update .changeset/nasty-carrots-study.md Co-authored-by: Alexander Niebuhr --------- Co-authored-by: Alexander Niebuhr --- .changeset/nasty-carrots-study.md | 5 +++++ packages/integrations/vercel/package.json | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 .changeset/nasty-carrots-study.md diff --git a/.changeset/nasty-carrots-study.md b/.changeset/nasty-carrots-study.md new file mode 100644 index 000000000000..13ee46022a59 --- /dev/null +++ b/.changeset/nasty-carrots-study.md @@ -0,0 +1,5 @@ +--- +'@astrojs/vercel': patch +--- + +Uses the latest astro as the peerDependency diff --git a/packages/integrations/vercel/package.json b/packages/integrations/vercel/package.json index 730020c04762..935baee36f4d 100644 --- a/packages/integrations/vercel/package.json +++ b/packages/integrations/vercel/package.json @@ -59,7 +59,7 @@ "web-vitals": "^3.4.0" }, "peerDependencies": { - "astro": "^4.0.0-beta.0" + "astro": "^4.0.2" }, "devDependencies": { "@types/set-cookie-parser": "^2.4.6", From 3e4109b08f7cf79492724f145c44e0c561d21954 Mon Sep 17 00:00:00 2001 From: "Houston (Bot)" <108291165+astrobot-houston@users.noreply.github.com> Date: Wed, 6 Dec 2023 12:09:30 -0800 Subject: [PATCH 59/59] [ci] release (#9340) Co-authored-by: github-actions[bot] --- .changeset/cold-toys-greet.md | 5 -- .changeset/famous-bobcats-vanish.md | 5 -- .changeset/modern-mice-shout.md | 5 -- .changeset/nasty-carrots-study.md | 5 -- .changeset/strange-parrots-promise.md | 5 -- .changeset/thirty-hairs-pump.md | 5 -- examples/basics/package.json | 2 +- examples/blog/package.json | 4 +- examples/component/package.json | 2 +- examples/framework-alpine/package.json | 2 +- examples/framework-lit/package.json | 2 +- examples/framework-multiple/package.json | 2 +- examples/framework-preact/package.json | 2 +- examples/framework-react/package.json | 2 +- examples/framework-solid/package.json | 2 +- examples/framework-svelte/package.json | 2 +- examples/framework-vue/package.json | 2 +- examples/hackernews/package.json | 2 +- examples/integration/package.json | 2 +- examples/middleware/package.json | 2 +- examples/minimal/package.json | 2 +- examples/non-html-pages/package.json | 2 +- examples/portfolio/package.json | 2 +- examples/ssr/package.json | 2 +- examples/view-transitions/package.json | 2 +- examples/with-markdoc/package.json | 2 +- examples/with-markdown-plugins/package.json | 2 +- examples/with-markdown-shiki/package.json | 2 +- examples/with-mdx/package.json | 2 +- examples/with-nanostores/package.json | 2 +- examples/with-tailwindcss/package.json | 2 +- examples/with-vitest/package.json | 2 +- packages/astro-rss/CHANGELOG.md | 6 +++ packages/astro-rss/package.json | 2 +- packages/astro/CHANGELOG.md | 12 +++++ packages/astro/package.json | 2 +- packages/integrations/vercel/CHANGELOG.md | 6 +++ packages/integrations/vercel/package.json | 2 +- pnpm-lock.yaml | 54 ++++++++++----------- 39 files changed, 81 insertions(+), 87 deletions(-) delete mode 100644 .changeset/cold-toys-greet.md delete mode 100644 .changeset/famous-bobcats-vanish.md delete mode 100644 .changeset/modern-mice-shout.md delete mode 100644 .changeset/nasty-carrots-study.md delete mode 100644 .changeset/strange-parrots-promise.md delete mode 100644 .changeset/thirty-hairs-pump.md diff --git a/.changeset/cold-toys-greet.md b/.changeset/cold-toys-greet.md deleted file mode 100644 index 7923c5567aea..000000000000 --- a/.changeset/cold-toys-greet.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'astro': patch ---- - -Fix missing `is:inline` type for the `` element diff --git a/.changeset/famous-bobcats-vanish.md b/.changeset/famous-bobcats-vanish.md deleted file mode 100644 index 873cea592eb8..000000000000 --- a/.changeset/famous-bobcats-vanish.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'astro': patch ---- - -Adds source file properties to HTML elements only if devToolbar is enabled diff --git a/.changeset/modern-mice-shout.md b/.changeset/modern-mice-shout.md deleted file mode 100644 index cc483b1937f6..000000000000 --- a/.changeset/modern-mice-shout.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'astro': patch ---- - -dev: fix issue where 404 and 500 responses were logged as 200 diff --git a/.changeset/nasty-carrots-study.md b/.changeset/nasty-carrots-study.md deleted file mode 100644 index 13ee46022a59..000000000000 --- a/.changeset/nasty-carrots-study.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'@astrojs/vercel': patch ---- - -Uses the latest astro as the peerDependency diff --git a/.changeset/strange-parrots-promise.md b/.changeset/strange-parrots-promise.md deleted file mode 100644 index 584d911eea0b..000000000000 --- a/.changeset/strange-parrots-promise.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'astro': patch ---- - -Fixed the log message to correctly display 'enabled' and 'disabled' when toggling 'Disable notifications' in the Toolbar. diff --git a/.changeset/thirty-hairs-pump.md b/.changeset/thirty-hairs-pump.md deleted file mode 100644 index acb4d1da23ee..000000000000 --- a/.changeset/thirty-hairs-pump.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'@astrojs/rss': patch ---- - -Improves the `@astrojs/rss` error message thrown when the object passed to the `items` property is missing any of the three required keys or if one of those keys is mistyped. diff --git a/examples/basics/package.json b/examples/basics/package.json index 462235462498..d33671b1fb9f 100644 --- a/examples/basics/package.json +++ b/examples/basics/package.json @@ -11,6 +11,6 @@ "astro": "astro" }, "dependencies": { - "astro": "^4.0.2" + "astro": "^4.0.3" } } diff --git a/examples/blog/package.json b/examples/blog/package.json index 3ece054ce403..0c42df70d5fb 100644 --- a/examples/blog/package.json +++ b/examples/blog/package.json @@ -12,8 +12,8 @@ }, "dependencies": { "@astrojs/mdx": "^2.0.0", - "@astrojs/rss": "^4.0.0", + "@astrojs/rss": "^4.0.1", "@astrojs/sitemap": "^3.0.3", - "astro": "^4.0.2" + "astro": "^4.0.3" } } diff --git a/examples/component/package.json b/examples/component/package.json index 9cac9645df69..3a72bb72e0bb 100644 --- a/examples/component/package.json +++ b/examples/component/package.json @@ -15,7 +15,7 @@ ], "scripts": {}, "devDependencies": { - "astro": "^4.0.2" + "astro": "^4.0.3" }, "peerDependencies": { "astro": "^3.0.0" diff --git a/examples/framework-alpine/package.json b/examples/framework-alpine/package.json index f9fc290954ba..d37a79bc0e55 100644 --- a/examples/framework-alpine/package.json +++ b/examples/framework-alpine/package.json @@ -14,6 +14,6 @@ "@astrojs/alpinejs": "^0.3.1", "@types/alpinejs": "^3.13.5", "alpinejs": "^3.13.3", - "astro": "^4.0.2" + "astro": "^4.0.3" } } diff --git a/examples/framework-lit/package.json b/examples/framework-lit/package.json index 72a5bd0c45aa..96593eb37f47 100644 --- a/examples/framework-lit/package.json +++ b/examples/framework-lit/package.json @@ -13,7 +13,7 @@ "dependencies": { "@astrojs/lit": "^3.0.3", "@webcomponents/template-shadowroot": "^0.2.1", - "astro": "^4.0.2", + "astro": "^4.0.3", "lit": "^2.8.0" } } diff --git a/examples/framework-multiple/package.json b/examples/framework-multiple/package.json index d83833e59bec..498b56f78207 100644 --- a/examples/framework-multiple/package.json +++ b/examples/framework-multiple/package.json @@ -16,7 +16,7 @@ "@astrojs/solid-js": "^3.0.2", "@astrojs/svelte": "^5.0.0", "@astrojs/vue": "^4.0.2", - "astro": "^4.0.2", + "astro": "^4.0.3", "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 08c3d7d875e1..5ed6833731ec 100644 --- a/examples/framework-preact/package.json +++ b/examples/framework-preact/package.json @@ -13,7 +13,7 @@ "dependencies": { "@astrojs/preact": "^3.0.1", "@preact/signals": "^1.2.1", - "astro": "^4.0.2", + "astro": "^4.0.3", "preact": "^10.19.2" } } diff --git a/examples/framework-react/package.json b/examples/framework-react/package.json index 6256dcb6b779..1732ec7906c4 100644 --- a/examples/framework-react/package.json +++ b/examples/framework-react/package.json @@ -14,7 +14,7 @@ "@astrojs/react": "^3.0.7", "@types/react": "^18.2.37", "@types/react-dom": "^18.2.15", - "astro": "^4.0.2", + "astro": "^4.0.3", "react": "^18.2.0", "react-dom": "^18.2.0" } diff --git a/examples/framework-solid/package.json b/examples/framework-solid/package.json index 34d8bc50f6ba..709d10f81572 100644 --- a/examples/framework-solid/package.json +++ b/examples/framework-solid/package.json @@ -12,7 +12,7 @@ }, "dependencies": { "@astrojs/solid-js": "^3.0.2", - "astro": "^4.0.2", + "astro": "^4.0.3", "solid-js": "^1.8.5" } } diff --git a/examples/framework-svelte/package.json b/examples/framework-svelte/package.json index a9406838c3cf..c99ea913456f 100644 --- a/examples/framework-svelte/package.json +++ b/examples/framework-svelte/package.json @@ -12,7 +12,7 @@ }, "dependencies": { "@astrojs/svelte": "^5.0.0", - "astro": "^4.0.2", + "astro": "^4.0.3", "svelte": "^4.2.5" } } diff --git a/examples/framework-vue/package.json b/examples/framework-vue/package.json index f7a42cd42bf5..3a4480862d1b 100644 --- a/examples/framework-vue/package.json +++ b/examples/framework-vue/package.json @@ -12,7 +12,7 @@ }, "dependencies": { "@astrojs/vue": "^4.0.2", - "astro": "^4.0.2", + "astro": "^4.0.3", "vue": "^3.3.8" } } diff --git a/examples/hackernews/package.json b/examples/hackernews/package.json index ca4ab4ef6030..28a3310acbcf 100644 --- a/examples/hackernews/package.json +++ b/examples/hackernews/package.json @@ -12,6 +12,6 @@ }, "dependencies": { "@astrojs/node": "^7.0.0", - "astro": "^4.0.2" + "astro": "^4.0.3" } } diff --git a/examples/integration/package.json b/examples/integration/package.json index 3708dfac7306..a92a888b46e6 100644 --- a/examples/integration/package.json +++ b/examples/integration/package.json @@ -15,7 +15,7 @@ ], "scripts": {}, "devDependencies": { - "astro": "^4.0.2" + "astro": "^4.0.3" }, "peerDependencies": { "astro": "^3.0.0" diff --git a/examples/middleware/package.json b/examples/middleware/package.json index 9f6393538781..9af03a263845 100644 --- a/examples/middleware/package.json +++ b/examples/middleware/package.json @@ -13,7 +13,7 @@ }, "dependencies": { "@astrojs/node": "^7.0.0", - "astro": "^4.0.2", + "astro": "^4.0.3", "html-minifier": "^4.0.0" } } diff --git a/examples/minimal/package.json b/examples/minimal/package.json index 7f37079799a5..4e4fb33d36ea 100644 --- a/examples/minimal/package.json +++ b/examples/minimal/package.json @@ -11,6 +11,6 @@ "astro": "astro" }, "dependencies": { - "astro": "^4.0.2" + "astro": "^4.0.3" } } diff --git a/examples/non-html-pages/package.json b/examples/non-html-pages/package.json index e7c51ad9cdbf..52b4c9fc71e2 100644 --- a/examples/non-html-pages/package.json +++ b/examples/non-html-pages/package.json @@ -11,6 +11,6 @@ "astro": "astro" }, "dependencies": { - "astro": "^4.0.2" + "astro": "^4.0.3" } } diff --git a/examples/portfolio/package.json b/examples/portfolio/package.json index c8b9e51946f3..01d5effb6220 100644 --- a/examples/portfolio/package.json +++ b/examples/portfolio/package.json @@ -11,6 +11,6 @@ "astro": "astro" }, "dependencies": { - "astro": "^4.0.2" + "astro": "^4.0.3" } } diff --git a/examples/ssr/package.json b/examples/ssr/package.json index f7af576ce892..5c6c5c20f62d 100644 --- a/examples/ssr/package.json +++ b/examples/ssr/package.json @@ -14,7 +14,7 @@ "dependencies": { "@astrojs/node": "^7.0.0", "@astrojs/svelte": "^5.0.0", - "astro": "^4.0.2", + "astro": "^4.0.3", "svelte": "^4.2.5" } } diff --git a/examples/view-transitions/package.json b/examples/view-transitions/package.json index 4e2839596e52..bb19a4f032a8 100644 --- a/examples/view-transitions/package.json +++ b/examples/view-transitions/package.json @@ -12,6 +12,6 @@ "devDependencies": { "@astrojs/tailwind": "^5.0.3", "@astrojs/node": "^7.0.0", - "astro": "^4.0.2" + "astro": "^4.0.3" } } diff --git a/examples/with-markdoc/package.json b/examples/with-markdoc/package.json index 58f640c801e6..4d63d789ce6b 100644 --- a/examples/with-markdoc/package.json +++ b/examples/with-markdoc/package.json @@ -12,6 +12,6 @@ }, "dependencies": { "@astrojs/markdoc": "^0.8.0", - "astro": "^4.0.2" + "astro": "^4.0.3" } } diff --git a/examples/with-markdown-plugins/package.json b/examples/with-markdown-plugins/package.json index 1dbbd8eda8bc..bd86abdde00d 100644 --- a/examples/with-markdown-plugins/package.json +++ b/examples/with-markdown-plugins/package.json @@ -12,7 +12,7 @@ }, "dependencies": { "@astrojs/markdown-remark": "^4.0.0", - "astro": "^4.0.2", + "astro": "^4.0.3", "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 b7c646508f27..56de8c8716ef 100644 --- a/examples/with-markdown-shiki/package.json +++ b/examples/with-markdown-shiki/package.json @@ -11,6 +11,6 @@ "astro": "astro" }, "dependencies": { - "astro": "^4.0.2" + "astro": "^4.0.3" } } diff --git a/examples/with-mdx/package.json b/examples/with-mdx/package.json index 67b1428e4e12..b0e08746819f 100644 --- a/examples/with-mdx/package.json +++ b/examples/with-mdx/package.json @@ -13,7 +13,7 @@ "dependencies": { "@astrojs/mdx": "^2.0.0", "@astrojs/preact": "^3.0.1", - "astro": "^4.0.2", + "astro": "^4.0.3", "preact": "^10.19.2" } } diff --git a/examples/with-nanostores/package.json b/examples/with-nanostores/package.json index 586b36bd8b6a..66bd31e66dff 100644 --- a/examples/with-nanostores/package.json +++ b/examples/with-nanostores/package.json @@ -13,7 +13,7 @@ "dependencies": { "@astrojs/preact": "^3.0.1", "@nanostores/preact": "^0.5.0", - "astro": "^4.0.2", + "astro": "^4.0.3", "nanostores": "^0.9.5", "preact": "^10.19.2" } diff --git a/examples/with-tailwindcss/package.json b/examples/with-tailwindcss/package.json index f76fccaacb19..c62ad3343514 100644 --- a/examples/with-tailwindcss/package.json +++ b/examples/with-tailwindcss/package.json @@ -14,7 +14,7 @@ "@astrojs/mdx": "^2.0.0", "@astrojs/tailwind": "^5.0.3", "@types/canvas-confetti": "^1.6.3", - "astro": "^4.0.2", + "astro": "^4.0.3", "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 838d13d2e65a..54f7fdf99720 100644 --- a/examples/with-vitest/package.json +++ b/examples/with-vitest/package.json @@ -12,7 +12,7 @@ "test": "vitest" }, "dependencies": { - "astro": "^4.0.2", + "astro": "^4.0.3", "vitest": "^0.34.2" } } diff --git a/packages/astro-rss/CHANGELOG.md b/packages/astro-rss/CHANGELOG.md index 89179a9a7026..df205874890d 100644 --- a/packages/astro-rss/CHANGELOG.md +++ b/packages/astro-rss/CHANGELOG.md @@ -1,5 +1,11 @@ # @astrojs/rss +## 4.0.1 + +### Patch Changes + +- [#9299](https://github.com/withastro/astro/pull/9299) [`edfae50e6`](https://github.com/withastro/astro/commit/edfae50e6ea494f49c6d4fbf4bd4481870f994b1) Thanks [@cdvillard](https://github.com/cdvillard)! - Improves the `@astrojs/rss` error message thrown when the object passed to the `items` property is missing any of the three required keys or if one of those keys is mistyped. + ## 4.0.0 ### Major Changes diff --git a/packages/astro-rss/package.json b/packages/astro-rss/package.json index 9c9adb849903..c262452daf0b 100644 --- a/packages/astro-rss/package.json +++ b/packages/astro-rss/package.json @@ -1,7 +1,7 @@ { "name": "@astrojs/rss", "description": "Add RSS feeds to your Astro projects", - "version": "4.0.0", + "version": "4.0.1", "type": "module", "types": "./dist/index.d.ts", "author": "withastro", diff --git a/packages/astro/CHANGELOG.md b/packages/astro/CHANGELOG.md index 5076fc126336..da96a03cb6be 100644 --- a/packages/astro/CHANGELOG.md +++ b/packages/astro/CHANGELOG.md @@ -1,5 +1,17 @@ # astro +## 4.0.3 + +### Patch Changes + +- [#9342](https://github.com/withastro/astro/pull/9342) [`eb942942d`](https://github.com/withastro/astro/commit/eb942942d67508c07d7efaa859a7840f7c0223da) Thanks [@Princesseuh](https://github.com/Princesseuh)! - Fix missing `is:inline` type for the `` element + +- [#9343](https://github.com/withastro/astro/pull/9343) [`ab0281aee`](https://github.com/withastro/astro/commit/ab0281aee419e58c6079ca393987fe1ff0541dd5) Thanks [@martrapp](https://github.com/martrapp)! - Adds source file properties to HTML elements only if devToolbar is enabled + +- [#9336](https://github.com/withastro/astro/pull/9336) [`c76901065`](https://github.com/withastro/astro/commit/c76901065545f6a8d3de3e44d1c8ee5456a8a77a) Thanks [@FredKSchott](https://github.com/FredKSchott)! - dev: fix issue where 404 and 500 responses were logged as 200 + +- [#9339](https://github.com/withastro/astro/pull/9339) [`0bb3d5322`](https://github.com/withastro/astro/commit/0bb3d532219fb90fc08bfb472fc981fab6543d16) Thanks [@morinokami](https://github.com/morinokami)! - Fixed the log message to correctly display 'enabled' and 'disabled' when toggling 'Disable notifications' in the Toolbar. + ## 4.0.2 ### Patch Changes diff --git a/packages/astro/package.json b/packages/astro/package.json index bfa7c54fdf04..c7dd43ae3d1f 100644 --- a/packages/astro/package.json +++ b/packages/astro/package.json @@ -1,6 +1,6 @@ { "name": "astro", - "version": "4.0.2", + "version": "4.0.3", "description": "Astro is a modern site builder with web best practices, performance, and DX front-of-mind.", "type": "module", "author": "withastro", diff --git a/packages/integrations/vercel/CHANGELOG.md b/packages/integrations/vercel/CHANGELOG.md index aaec3b144866..abb304360da0 100644 --- a/packages/integrations/vercel/CHANGELOG.md +++ b/packages/integrations/vercel/CHANGELOG.md @@ -1,5 +1,11 @@ # @astrojs/vercel +## 6.0.1 + +### Patch Changes + +- [#9348](https://github.com/withastro/astro/pull/9348) [`1685cc42b`](https://github.com/withastro/astro/commit/1685cc42b51603eb98b5ba3e072cf2d3953339f2) Thanks [@matthewp](https://github.com/matthewp)! - Uses the latest astro as the peerDependency + ## 6.0.0 ### Major Changes diff --git a/packages/integrations/vercel/package.json b/packages/integrations/vercel/package.json index 935baee36f4d..db1b63a900e2 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": "6.0.0", + "version": "6.0.1", "type": "module", "author": "withastro", "license": "MIT", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 1dfa0f263c7d..9b42c6504f62 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -125,7 +125,7 @@ importers: examples/basics: dependencies: astro: - specifier: ^4.0.2 + specifier: ^4.0.3 version: link:../../packages/astro examples/blog: @@ -134,19 +134,19 @@ importers: specifier: ^2.0.0 version: link:../../packages/integrations/mdx '@astrojs/rss': - specifier: ^4.0.0 + specifier: ^4.0.1 version: link:../../packages/astro-rss '@astrojs/sitemap': specifier: ^3.0.3 version: link:../../packages/integrations/sitemap astro: - specifier: ^4.0.2 + specifier: ^4.0.3 version: link:../../packages/astro examples/component: devDependencies: astro: - specifier: ^4.0.2 + specifier: ^4.0.3 version: link:../../packages/astro examples/framework-alpine: @@ -161,7 +161,7 @@ importers: specifier: ^3.13.3 version: 3.13.3 astro: - specifier: ^4.0.2 + specifier: ^4.0.3 version: link:../../packages/astro examples/framework-lit: @@ -173,7 +173,7 @@ importers: specifier: ^0.2.1 version: 0.2.1 astro: - specifier: ^4.0.2 + specifier: ^4.0.3 version: link:../../packages/astro lit: specifier: ^2.8.0 @@ -197,7 +197,7 @@ importers: specifier: ^4.0.2 version: link:../../packages/integrations/vue astro: - specifier: ^4.0.2 + specifier: ^4.0.3 version: link:../../packages/astro preact: specifier: ^10.19.2 @@ -227,7 +227,7 @@ importers: specifier: ^1.2.1 version: 1.2.1(preact@10.19.2) astro: - specifier: ^4.0.2 + specifier: ^4.0.3 version: link:../../packages/astro preact: specifier: ^10.19.2 @@ -245,7 +245,7 @@ importers: specifier: ^18.2.15 version: 18.2.15 astro: - specifier: ^4.0.2 + specifier: ^4.0.3 version: link:../../packages/astro react: specifier: ^18.2.0 @@ -260,7 +260,7 @@ importers: specifier: ^3.0.2 version: link:../../packages/integrations/solid astro: - specifier: ^4.0.2 + specifier: ^4.0.3 version: link:../../packages/astro solid-js: specifier: ^1.8.5 @@ -272,7 +272,7 @@ importers: specifier: ^5.0.0 version: link:../../packages/integrations/svelte astro: - specifier: ^4.0.2 + specifier: ^4.0.3 version: link:../../packages/astro svelte: specifier: ^4.2.5 @@ -284,7 +284,7 @@ importers: specifier: ^4.0.2 version: link:../../packages/integrations/vue astro: - specifier: ^4.0.2 + specifier: ^4.0.3 version: link:../../packages/astro vue: specifier: ^3.3.8 @@ -296,13 +296,13 @@ importers: specifier: ^7.0.0 version: link:../../packages/integrations/node astro: - specifier: ^4.0.2 + specifier: ^4.0.3 version: link:../../packages/astro examples/integration: devDependencies: astro: - specifier: ^4.0.2 + specifier: ^4.0.3 version: link:../../packages/astro examples/middleware: @@ -311,7 +311,7 @@ importers: specifier: ^7.0.0 version: link:../../packages/integrations/node astro: - specifier: ^4.0.2 + specifier: ^4.0.3 version: link:../../packages/astro html-minifier: specifier: ^4.0.0 @@ -320,19 +320,19 @@ importers: examples/minimal: dependencies: astro: - specifier: ^4.0.2 + specifier: ^4.0.3 version: link:../../packages/astro examples/non-html-pages: dependencies: astro: - specifier: ^4.0.2 + specifier: ^4.0.3 version: link:../../packages/astro examples/portfolio: dependencies: astro: - specifier: ^4.0.2 + specifier: ^4.0.3 version: link:../../packages/astro examples/ssr: @@ -344,7 +344,7 @@ importers: specifier: ^5.0.0 version: link:../../packages/integrations/svelte astro: - specifier: ^4.0.2 + specifier: ^4.0.3 version: link:../../packages/astro svelte: specifier: ^4.2.5 @@ -359,7 +359,7 @@ importers: specifier: ^5.0.3 version: link:../../packages/integrations/tailwind astro: - specifier: ^4.0.2 + specifier: ^4.0.3 version: link:../../packages/astro examples/with-markdoc: @@ -368,7 +368,7 @@ importers: specifier: ^0.8.0 version: link:../../packages/integrations/markdoc astro: - specifier: ^4.0.2 + specifier: ^4.0.3 version: link:../../packages/astro examples/with-markdown-plugins: @@ -377,7 +377,7 @@ importers: specifier: ^4.0.0 version: link:../../packages/markdown/remark astro: - specifier: ^4.0.2 + specifier: ^4.0.3 version: link:../../packages/astro hast-util-select: specifier: ^6.0.2 @@ -398,7 +398,7 @@ importers: examples/with-markdown-shiki: dependencies: astro: - specifier: ^4.0.2 + specifier: ^4.0.3 version: link:../../packages/astro examples/with-mdx: @@ -410,7 +410,7 @@ importers: specifier: ^3.0.1 version: link:../../packages/integrations/preact astro: - specifier: ^4.0.2 + specifier: ^4.0.3 version: link:../../packages/astro preact: specifier: ^10.19.2 @@ -425,7 +425,7 @@ importers: specifier: ^0.5.0 version: 0.5.0(nanostores@0.9.5)(preact@10.19.2) astro: - specifier: ^4.0.2 + specifier: ^4.0.3 version: link:../../packages/astro nanostores: specifier: ^0.9.5 @@ -446,7 +446,7 @@ importers: specifier: ^1.6.3 version: 1.6.3 astro: - specifier: ^4.0.2 + specifier: ^4.0.3 version: link:../../packages/astro autoprefixer: specifier: ^10.4.15 @@ -464,7 +464,7 @@ importers: examples/with-vitest: dependencies: astro: - specifier: ^4.0.2 + specifier: ^4.0.3 version: link:../../packages/astro vitest: specifier: ^0.34.2