diff --git a/.changeset/beige-forks-cough.md b/.changeset/beige-forks-cough.md deleted file mode 100644 index 282beb5191d81..0000000000000 --- a/.changeset/beige-forks-cough.md +++ /dev/null @@ -1,7 +0,0 @@ ---- -'@astrojs/cloudflare': patch -'@astrojs/deno': patch -'@astrojs/netlify': patch ---- - -Update esbuild dependency diff --git a/.changeset/chilled-papayas-build.md b/.changeset/chilled-papayas-build.md deleted file mode 100644 index 374f6ed944443..0000000000000 --- a/.changeset/chilled-papayas-build.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'astro': patch ---- - -Exclude astro from Vite optimization diff --git a/.changeset/cool-jobs-draw.md b/.changeset/cool-jobs-draw.md deleted file mode 100644 index 1fee55e544397..0000000000000 --- a/.changeset/cool-jobs-draw.md +++ /dev/null @@ -1,7 +0,0 @@ ---- -'astro': patch ---- - -Low-level head propagation - -This adds low-level head propagation ability within the Astro runtime. This is not really useable within an Astro app at the moment, but provides the APIs necessary for `renderEntry` to do head propagation. diff --git a/.changeset/sour-otters-exercise.md b/.changeset/sour-otters-exercise.md deleted file mode 100644 index 45d1fa711ea9f..0000000000000 --- a/.changeset/sour-otters-exercise.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'astro': patch ---- - -Removed premature optimization diff --git a/examples/basics/package.json b/examples/basics/package.json index fc572693d99a8..0e5498d6ae18e 100644 --- a/examples/basics/package.json +++ b/examples/basics/package.json @@ -11,6 +11,6 @@ "astro": "astro" }, "dependencies": { - "astro": "^1.6.13" + "astro": "^1.6.14" } } diff --git a/examples/blog/package.json b/examples/blog/package.json index 1f155e39a27d7..42a9028160989 100644 --- a/examples/blog/package.json +++ b/examples/blog/package.json @@ -11,7 +11,7 @@ "astro": "astro" }, "dependencies": { - "astro": "^1.6.13", + "astro": "^1.6.14", "@astrojs/mdx": "^0.12.1", "@astrojs/rss": "^1.0.3", "@astrojs/sitemap": "^1.0.0" diff --git a/examples/component/package.json b/examples/component/package.json index 24565ffa933a4..3ef49e29ad4f1 100644 --- a/examples/component/package.json +++ b/examples/component/package.json @@ -15,9 +15,9 @@ ], "scripts": {}, "devDependencies": { - "astro": "^1.6.13" + "astro": "^1.6.14" }, "peerDependencies": { - "astro": "^1.6.13" + "astro": "^1.6.14" } } diff --git a/examples/deno/package.json b/examples/deno/package.json index e2721411e5235..378ea852b3600 100644 --- a/examples/deno/package.json +++ b/examples/deno/package.json @@ -10,9 +10,9 @@ "astro": "astro" }, "dependencies": { - "astro": "^1.6.13" + "astro": "^1.6.14" }, "devDependencies": { - "@astrojs/deno": "^2.0.0" + "@astrojs/deno": "^2.0.1" } } diff --git a/examples/docs/package.json b/examples/docs/package.json index 3d561a2fe2621..089dfb2338088 100644 --- a/examples/docs/package.json +++ b/examples/docs/package.json @@ -12,7 +12,7 @@ "astro": "astro" }, "dependencies": { - "astro": "^1.6.13", + "astro": "^1.6.14", "preact": "^10.7.3", "react": "^18.1.0", "react-dom": "^18.1.0", diff --git a/examples/framework-alpine/package.json b/examples/framework-alpine/package.json index 003e78cd881d6..344ec2bb6d455 100644 --- a/examples/framework-alpine/package.json +++ b/examples/framework-alpine/package.json @@ -11,7 +11,7 @@ "astro": "astro" }, "dependencies": { - "astro": "^1.6.13", + "astro": "^1.6.14", "alpinejs": "^3.10.2", "@astrojs/alpinejs": "^0.1.2", "@types/alpinejs": "^3.7.0" diff --git a/examples/framework-lit/package.json b/examples/framework-lit/package.json index fbd6dd8b98595..d11a800bd1275 100644 --- a/examples/framework-lit/package.json +++ b/examples/framework-lit/package.json @@ -11,7 +11,7 @@ "astro": "astro" }, "dependencies": { - "astro": "^1.6.13", + "astro": "^1.6.14", "lit": "^2.2.5", "@astrojs/lit": "^1.0.0", "@webcomponents/template-shadowroot": "^0.1.0" diff --git a/examples/framework-multiple/package.json b/examples/framework-multiple/package.json index 3d961699de7ba..3678cc0d72742 100644 --- a/examples/framework-multiple/package.json +++ b/examples/framework-multiple/package.json @@ -11,7 +11,7 @@ "astro": "astro" }, "dependencies": { - "astro": "^1.6.13", + "astro": "^1.6.14", "preact": "^10.7.3", "react": "^18.1.0", "react-dom": "^18.1.0", diff --git a/examples/framework-preact/package.json b/examples/framework-preact/package.json index c2a8a4026ace3..7e5f756b7eac4 100644 --- a/examples/framework-preact/package.json +++ b/examples/framework-preact/package.json @@ -11,7 +11,7 @@ "astro": "astro" }, "dependencies": { - "astro": "^1.6.13", + "astro": "^1.6.14", "preact": "^10.7.3", "@astrojs/preact": "^1.2.0", "@preact/signals": "^1.1.0" diff --git a/examples/framework-react/package.json b/examples/framework-react/package.json index d6e33f0501d20..c7a6461f0f423 100644 --- a/examples/framework-react/package.json +++ b/examples/framework-react/package.json @@ -11,7 +11,7 @@ "astro": "astro" }, "dependencies": { - "astro": "^1.6.13", + "astro": "^1.6.14", "react": "^18.1.0", "react-dom": "^18.1.0", "@astrojs/react": "^1.2.2", diff --git a/examples/framework-solid/package.json b/examples/framework-solid/package.json index 27e68e623b7e9..a38240258a758 100644 --- a/examples/framework-solid/package.json +++ b/examples/framework-solid/package.json @@ -11,7 +11,7 @@ "astro": "astro" }, "dependencies": { - "astro": "^1.6.13", + "astro": "^1.6.14", "solid-js": "^1.4.3", "@astrojs/solid-js": "^1.2.3" } diff --git a/examples/framework-svelte/package.json b/examples/framework-svelte/package.json index be4047d0c850e..174eddf6392eb 100644 --- a/examples/framework-svelte/package.json +++ b/examples/framework-svelte/package.json @@ -13,6 +13,6 @@ "dependencies": { "svelte": "^3.48.0", "@astrojs/svelte": "^1.0.2", - "astro": "^1.6.13" + "astro": "^1.6.14" } } diff --git a/examples/framework-vue/package.json b/examples/framework-vue/package.json index 271431e45a37b..b1c22452c3103 100644 --- a/examples/framework-vue/package.json +++ b/examples/framework-vue/package.json @@ -11,7 +11,7 @@ "astro": "astro" }, "dependencies": { - "astro": "^1.6.13", + "astro": "^1.6.14", "vue": "^3.2.37", "@astrojs/vue": "^1.2.1" } diff --git a/examples/hackernews/package.json b/examples/hackernews/package.json index 8f240ea32c233..6fbac8b44bcbc 100644 --- a/examples/hackernews/package.json +++ b/examples/hackernews/package.json @@ -13,6 +13,6 @@ }, "dependencies": { "@astrojs/node": "^3.1.0", - "astro": "^1.6.13" + "astro": "^1.6.14" } } diff --git a/examples/integration/package.json b/examples/integration/package.json index 185725888816f..c9c5814b2523d 100644 --- a/examples/integration/package.json +++ b/examples/integration/package.json @@ -15,9 +15,9 @@ ], "scripts": {}, "devDependencies": { - "astro": "^1.6.13" + "astro": "^1.6.14" }, "peerDependencies": { - "astro": "^1.6.13" + "astro": "^1.6.14" } } diff --git a/examples/minimal/package.json b/examples/minimal/package.json index 3d477be8db030..05c7b0e17e0dc 100644 --- a/examples/minimal/package.json +++ b/examples/minimal/package.json @@ -11,6 +11,6 @@ "astro": "astro" }, "dependencies": { - "astro": "^1.6.13" + "astro": "^1.6.14" } } diff --git a/examples/non-html-pages/package.json b/examples/non-html-pages/package.json index 2819f3629dd76..d9327c4b4fd17 100644 --- a/examples/non-html-pages/package.json +++ b/examples/non-html-pages/package.json @@ -11,6 +11,6 @@ "astro": "astro" }, "dependencies": { - "astro": "^1.6.13" + "astro": "^1.6.14" } } diff --git a/examples/portfolio/package.json b/examples/portfolio/package.json index a147ac01a0627..802c2701a2ff0 100644 --- a/examples/portfolio/package.json +++ b/examples/portfolio/package.json @@ -11,6 +11,6 @@ "astro": "astro" }, "dependencies": { - "astro": "^1.6.13" + "astro": "^1.6.14" } } diff --git a/examples/ssr/package.json b/examples/ssr/package.json index 98c8e8b68b7c4..d4f508818b3c0 100644 --- a/examples/ssr/package.json +++ b/examples/ssr/package.json @@ -12,7 +12,7 @@ "server": "node dist/server/entry.mjs" }, "dependencies": { - "astro": "^1.6.13", + "astro": "^1.6.14", "svelte": "^3.48.0", "@astrojs/svelte": "^1.0.2", "@astrojs/node": "^3.1.0", diff --git a/examples/with-markdown-plugins/package.json b/examples/with-markdown-plugins/package.json index bf2f4101642ea..de0956c11fb14 100644 --- a/examples/with-markdown-plugins/package.json +++ b/examples/with-markdown-plugins/package.json @@ -11,7 +11,7 @@ "astro": "astro" }, "dependencies": { - "astro": "^1.6.13", + "astro": "^1.6.14", "@astrojs/markdown-remark": "^1.1.3", "hast-util-select": "5.0.1", "rehype-autolink-headings": "^6.1.1", diff --git a/examples/with-markdown-shiki/package.json b/examples/with-markdown-shiki/package.json index 932ccc150f4fa..adf321f6dd580 100644 --- a/examples/with-markdown-shiki/package.json +++ b/examples/with-markdown-shiki/package.json @@ -11,6 +11,6 @@ "astro": "astro" }, "dependencies": { - "astro": "^1.6.13" + "astro": "^1.6.14" } } diff --git a/examples/with-mdx/package.json b/examples/with-mdx/package.json index d19ac3d83e2cd..370e499dc367e 100644 --- a/examples/with-mdx/package.json +++ b/examples/with-mdx/package.json @@ -11,7 +11,7 @@ "astro": "astro" }, "dependencies": { - "astro": "^1.6.13", + "astro": "^1.6.14", "preact": "^10.6.5", "@astrojs/preact": "^1.2.0", "@astrojs/mdx": "^0.12.1" diff --git a/examples/with-nanostores/package.json b/examples/with-nanostores/package.json index 07b45733f53bd..007000fe580f2 100644 --- a/examples/with-nanostores/package.json +++ b/examples/with-nanostores/package.json @@ -11,7 +11,7 @@ "astro": "astro" }, "dependencies": { - "astro": "^1.6.13", + "astro": "^1.6.14", "preact": "^10.7.3", "@astrojs/preact": "^1.2.0", "nanostores": "^0.5.12", diff --git a/examples/with-tailwindcss/package.json b/examples/with-tailwindcss/package.json index c6cc9d6586e79..ced83f639237a 100644 --- a/examples/with-tailwindcss/package.json +++ b/examples/with-tailwindcss/package.json @@ -14,7 +14,7 @@ "@astrojs/mdx": "^0.12.1", "@astrojs/tailwind": "^2.1.3", "@types/canvas-confetti": "^1.4.3", - "astro": "^1.6.13", + "astro": "^1.6.14", "autoprefixer": "^10.4.7", "canvas-confetti": "^1.5.1", "postcss": "^8.4.14", diff --git a/examples/with-vite-plugin-pwa/package.json b/examples/with-vite-plugin-pwa/package.json index 822312eb0e6e9..474b5214123fc 100644 --- a/examples/with-vite-plugin-pwa/package.json +++ b/examples/with-vite-plugin-pwa/package.json @@ -11,7 +11,7 @@ "astro": "astro" }, "dependencies": { - "astro": "^1.6.13", + "astro": "^1.6.14", "vite-plugin-pwa": "0.11.11", "workbox-window": "^6.5.3" } diff --git a/examples/with-vitest/package.json b/examples/with-vitest/package.json index 436e673f8491b..7888464a2246a 100644 --- a/examples/with-vitest/package.json +++ b/examples/with-vitest/package.json @@ -12,7 +12,7 @@ "test": "vitest" }, "dependencies": { - "astro": "^1.6.13", + "astro": "^1.6.14", "vitest": "^0.20.3" } } diff --git a/packages/astro/CHANGELOG.md b/packages/astro/CHANGELOG.md index 3bc3591920efb..2356bcb7e8712 100644 --- a/packages/astro/CHANGELOG.md +++ b/packages/astro/CHANGELOG.md @@ -1,5 +1,17 @@ # astro +## 1.6.14 + +### Patch Changes + +- [#5545](https://github.com/withastro/astro/pull/5545) [`9082a850e`](https://github.com/withastro/astro/commit/9082a850eef4ab0187fc3bfdd5a377f0c7040070) Thanks [@bluwy](https://github.com/bluwy)! - Exclude astro from Vite optimization + +- [#5511](https://github.com/withastro/astro/pull/5511) [`05915fec0`](https://github.com/withastro/astro/commit/05915fec01a51f27ab5051644f01e6112ecf06bc) Thanks [@matthewp](https://github.com/matthewp)! - Low-level head propagation + + This adds low-level head propagation ability within the Astro runtime. This is not really useable within an Astro app at the moment, but provides the APIs necessary for `renderEntry` to do head propagation. + +- [#5548](https://github.com/withastro/astro/pull/5548) [`8f3f67c96`](https://github.com/withastro/astro/commit/8f3f67c96aee63be64de77f374293761ff73f6ce) Thanks [@ido-pluto](https://github.com/ido-pluto)! - Removed premature optimization + ## 1.6.13 ### Patch Changes diff --git a/packages/astro/package.json b/packages/astro/package.json index f75ca1131cd79..ac7976fd4a032 100644 --- a/packages/astro/package.json +++ b/packages/astro/package.json @@ -1,6 +1,6 @@ { "name": "astro", - "version": "1.6.13", + "version": "1.6.14", "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/astro/src/@types/astro.ts b/packages/astro/src/@types/astro.ts index ce117f3ac3104..4bbbe996fc778 100644 --- a/packages/astro/src/@types/astro.ts +++ b/packages/astro/src/@types/astro.ts @@ -1401,11 +1401,11 @@ export interface SSRMetadata { /** * A hint on whether the Astro runtime needs to wait on a component to render head * content. The meanings: - * + * * - __none__ (default) The component does not propagation head content. * - __self__ The component appends head content. * - __in-tree__ Another component within this component's dependency tree appends head content. - * + * * These are used within the runtime to know whether or not a component should be waited on. */ export type PropagationHint = 'none' | 'self' | 'in-tree'; diff --git a/packages/astro/src/core/render/dev/head.ts b/packages/astro/src/core/render/dev/head.ts index 9294192b31495..d4e375b1fc4f2 100644 --- a/packages/astro/src/core/render/dev/head.ts +++ b/packages/astro/src/core/render/dev/head.ts @@ -13,7 +13,7 @@ export async function getPropagationMap( const map: SSRResult['propagation'] = new Map(); const rootID = viteID(filePath); - addInjection(map, loader.getModuleInfo(rootID)) + addInjection(map, loader.getModuleInfo(rootID)); for await (const moduleNode of crawlGraph(loader, rootID, true)) { const id = moduleNode.id; if (id) { @@ -25,10 +25,10 @@ export async function getPropagationMap( } function addInjection(map: SSRResult['propagation'], modInfo: ModuleInfo | null) { - if(modInfo) { + if (modInfo) { const astro = getAstroMetadata(modInfo); - if(astro && astro.propagation) { - map.set(modInfo.id, astro.propagation) + if (astro && astro.propagation) { + map.set(modInfo.id, astro.propagation); } } } diff --git a/packages/astro/src/runtime/server/astro-component.ts b/packages/astro/src/runtime/server/astro-component.ts index 52b993f62fad2..f3df3a78f198a 100644 --- a/packages/astro/src/runtime/server/astro-component.ts +++ b/packages/astro/src/runtime/server/astro-component.ts @@ -21,7 +21,7 @@ function createComponentWithOptions(opts: CreateComponentOptions) { } // Used in creating the component. aka the main export. export function createComponent(arg1: AstroComponentFactory, moduleId: string) { - if(typeof arg1 === 'function') { + if (typeof arg1 === 'function') { return baseCreateComponent(arg1, moduleId); } else { return createComponentWithOptions(arg1); diff --git a/packages/astro/src/runtime/server/index.ts b/packages/astro/src/runtime/server/index.ts index 519703b95de63..45c0414a971e2 100644 --- a/packages/astro/src/runtime/server/index.ts +++ b/packages/astro/src/runtime/server/index.ts @@ -24,7 +24,11 @@ export { voidElementNames, } from './render/index.js'; export { createComponent } from './astro-component.js'; -export type { AstroComponentFactory, AstroComponentInstance, RenderInstruction } from './render/index.js'; +export type { + AstroComponentFactory, + AstroComponentInstance, + RenderInstruction, +} from './render/index.js'; import { markHTMLString } from './escape.js'; import { Renderer } from './render/index.js'; diff --git a/packages/astro/src/runtime/server/render/any.ts b/packages/astro/src/runtime/server/render/any.ts index 119dbc1054939..5da9356fb32de 100644 --- a/packages/astro/src/runtime/server/render/any.ts +++ b/packages/astro/src/runtime/server/render/any.ts @@ -25,10 +25,9 @@ export async function* renderChild(child: any): AsyncIterable { yield markHTMLString(escapeHTML(child)); } else if (!child && child !== 0) { // do nothing, safe to ignore falsey values. - } - else if(isRenderTemplateResult(child)) { + } else if (isRenderTemplateResult(child)) { yield* renderAstroTemplateResult(child); - } else if(isAstroComponentInstance(child)) { + } else if (isAstroComponentInstance(child)) { yield* child.render(); } else if (ArrayBuffer.isView(child)) { yield child; diff --git a/packages/astro/src/runtime/server/render/astro/factory.ts b/packages/astro/src/runtime/server/render/astro/factory.ts index 50cda589dbb24..d43a2913f53c3 100644 --- a/packages/astro/src/runtime/server/render/astro/factory.ts +++ b/packages/astro/src/runtime/server/render/astro/factory.ts @@ -40,13 +40,15 @@ export async function renderToString( parts.append(chunk, result); } - return parts.toString(); } -export function isAPropagatingComponent(result: SSRResult, factory: AstroComponentFactory): boolean { +export function isAPropagatingComponent( + result: SSRResult, + factory: AstroComponentFactory +): boolean { let hint: PropagationHint = factory.propagation || 'none'; - if(factory.moduleId && result.propagation.has(factory.moduleId) && hint === 'none') { + if (factory.moduleId && result.propagation.has(factory.moduleId) && hint === 'none') { hint = result.propagation.get(factory.moduleId)!; } return hint === 'in-tree' || hint === 'self'; diff --git a/packages/astro/src/runtime/server/render/astro/head-and-content.ts b/packages/astro/src/runtime/server/render/astro/head-and-content.ts index e4491142441eb..57f05425d3915 100644 --- a/packages/astro/src/runtime/server/render/astro/head-and-content.ts +++ b/packages/astro/src/runtime/server/render/astro/head-and-content.ts @@ -5,11 +5,11 @@ const headAndContentSym = Symbol.for('astro.headAndContent'); export type HeadAndContent = { [headAndContentSym]: true; head: string | RenderTemplateResult; - content: RenderTemplateResult; -} + content: RenderTemplateResult; +}; export function isHeadAndContent(obj: unknown): obj is HeadAndContent { - return typeof obj === 'object' && !!((obj as any)[headAndContentSym]); + return typeof obj === 'object' && !!(obj as any)[headAndContentSym]; } export function createHeadAndContent( @@ -19,6 +19,6 @@ export function createHeadAndContent( return { [headAndContentSym]: true, head, - content - } + content, + }; } diff --git a/packages/astro/src/runtime/server/render/astro/index.ts b/packages/astro/src/runtime/server/render/astro/index.ts index 0dc39805d84c5..6c592568368f6 100644 --- a/packages/astro/src/runtime/server/render/astro/index.ts +++ b/packages/astro/src/runtime/server/render/astro/index.ts @@ -1,25 +1,11 @@ - -export { - createAstroComponentInstance, - isAstroComponentInstance -} from './instance.js'; -export { - isAstroComponentFactory, - renderToString -} from './factory.js'; +export { createAstroComponentInstance, isAstroComponentInstance } from './instance.js'; +export { isAstroComponentFactory, renderToString } from './factory.js'; export { isRenderTemplateResult, renderAstroTemplateResult, - renderTemplate + renderTemplate, } from './render-template.js'; -export { - isHeadAndContent, - createHeadAndContent -} from './head-and-content.js'; +export { isHeadAndContent, createHeadAndContent } from './head-and-content.js'; -export type { - AstroComponentFactory -} from './factory'; -export type { - AstroComponentInstance -} from './instance'; +export type { AstroComponentFactory } from './factory'; +export type { AstroComponentInstance } from './instance'; diff --git a/packages/astro/src/runtime/server/render/astro/instance.ts b/packages/astro/src/runtime/server/render/astro/instance.ts index db3916a496803..294e859ba22e8 100644 --- a/packages/astro/src/runtime/server/render/astro/instance.ts +++ b/packages/astro/src/runtime/server/render/astro/instance.ts @@ -19,7 +19,12 @@ export class AstroComponentInstance { private readonly slots: any; private readonly factory: AstroComponentFactory; private returnValue: ReturnType | undefined; - constructor(result: SSRResult, props: ComponentProps, slots: any, factory: AstroComponentFactory) { + constructor( + result: SSRResult, + props: ComponentProps, + slots: any, + factory: AstroComponentFactory + ) { this.result = result; this.props = props; this.slots = slots; @@ -32,18 +37,18 @@ export class AstroComponentInstance { } async *render() { - if(this.returnValue === undefined) { + if (this.returnValue === undefined) { await this.init(); } let value: AstroFactoryReturnValue | undefined = this.returnValue; - if(isPromise(value)) { + if (isPromise(value)) { value = await value; } - if(isHeadAndContent(value)) { - yield * value.content; + if (isHeadAndContent(value)) { + yield* value.content; } else { - yield * renderChild(value); + yield* renderChild(value); } } } @@ -71,12 +76,12 @@ export function createAstroComponentInstance( ) { validateComponentProps(props, displayName); const instance = new AstroComponentInstance(result, props, slots, factory); - if(isAPropagatingComponent(result, factory) && !result.propagators.has(factory)) { + if (isAPropagatingComponent(result, factory) && !result.propagators.has(factory)) { result.propagators.set(factory, instance); } return instance; } export function isAstroComponentInstance(obj: unknown): obj is AstroComponentInstance { - return typeof obj === 'object' && !!((obj as any)[astroComponentInstanceSym]); + return typeof obj === 'object' && !!(obj as any)[astroComponentInstanceSym]; } diff --git a/packages/astro/src/runtime/server/render/astro/render-template.ts b/packages/astro/src/runtime/server/render/astro/render-template.ts index 2c637f3c8192e..66930594babe2 100644 --- a/packages/astro/src/runtime/server/render/astro/render-template.ts +++ b/packages/astro/src/runtime/server/render/astro/render-template.ts @@ -52,9 +52,7 @@ export class RenderTemplateResult { // Determines if a component is an .astro component export function isRenderTemplateResult(obj: unknown): obj is RenderTemplateResult { - return ( - typeof obj === 'object' && !!((obj as any)[renderTemplateResultSym]) - ); + return typeof obj === 'object' && !!(obj as any)[renderTemplateResultSym]; } export async function* renderAstroTemplateResult( diff --git a/packages/astro/src/runtime/server/render/component.ts b/packages/astro/src/runtime/server/render/component.ts index 0e25d70142c8b..db24f53b7794b 100644 --- a/packages/astro/src/runtime/server/render/component.ts +++ b/packages/astro/src/runtime/server/render/component.ts @@ -17,7 +17,7 @@ import { isAstroComponentInstance, renderAstroTemplateResult, renderTemplate, - type AstroComponentInstance + type AstroComponentInstance, } from './astro/index.js'; import { Fragment, Renderer, stringifyChunk } from './common.js'; import { componentIsHTMLElement, renderHTMLElement } from './dom.js'; @@ -55,9 +55,7 @@ function isFragmentComponent(Component: unknown) { } function isHTMLComponent(Component: unknown) { - return ( - Component && typeof Component === 'object' && (Component as any)['astro:html'] - ); + return Component && typeof Component === 'object' && (Component as any)['astro:html']; } async function renderFrameworkComponent( @@ -65,7 +63,7 @@ async function renderFrameworkComponent( displayName: string, Component: unknown, _props: Record, - slots: any = {}, + slots: any = {} ): Promise { if (!Component && !_props['client:only']) { throw new Error( @@ -358,22 +356,22 @@ export function renderComponent( props: Record, slots: any = {} ): Promise | ComponentIterable | AstroComponentInstance { - if(isPromise(Component)) { - return Promise.resolve(Component).then(Unwrapped => { + if (isPromise(Component)) { + return Promise.resolve(Component).then((Unwrapped) => { return renderComponent(result, displayName, Unwrapped, props, slots) as any; }); } - if(isFragmentComponent(Component)) { + if (isFragmentComponent(Component)) { return renderFragmentComponent(result, slots); } // .html components - if(isHTMLComponent(Component)) { + if (isHTMLComponent(Component)) { return renderHTMLComponent(result, Component, props, slots); } - if(isAstroComponentFactory(Component)) { + if (isAstroComponentFactory(Component)) { return createAstroComponentInstance(result, displayName, Component, props, slots); } @@ -388,7 +386,7 @@ export function renderComponentToIterable( slots: any = {} ): Promise | ComponentIterable { const renderResult = renderComponent(result, displayName, Component, props, slots); - if(isAstroComponentInstance(renderResult)) { + if (isAstroComponentInstance(renderResult)) { return renderResult.render(); } return renderResult; diff --git a/packages/astro/src/runtime/server/render/head.ts b/packages/astro/src/runtime/server/render/head.ts index 701432c2ad2ca..a7649b5a0603a 100644 --- a/packages/astro/src/runtime/server/render/head.ts +++ b/packages/astro/src/runtime/server/render/head.ts @@ -13,10 +13,10 @@ const uniqueElements = (item: any, index: number, all: any[]) => { ); }; -async function * renderExtraHead(result: SSRResult, base: string) { +async function* renderExtraHead(result: SSRResult, base: string) { yield base; - for(const part of result.extraHead) { - yield * renderChild(part); + for (const part of result.extraHead) { + yield* renderChild(part); } } @@ -35,9 +35,9 @@ function renderAllHeadContent(result: SSRResult) { .filter(uniqueElements) .map((link) => renderElement('link', link, false)); - const baseHeadContent = markHTMLString(links.join('\n') + styles.join('\n') + scripts.join('\n')) + const baseHeadContent = markHTMLString(links.join('\n') + styles.join('\n') + scripts.join('\n')); - if(result.extraHead.length > 0) { + if (result.extraHead.length > 0) { return renderExtraHead(result, baseHeadContent); } else { return baseHeadContent; diff --git a/packages/astro/src/runtime/server/render/index.ts b/packages/astro/src/runtime/server/render/index.ts index 15a4d19774bb7..dfd704f003c25 100644 --- a/packages/astro/src/runtime/server/render/index.ts +++ b/packages/astro/src/runtime/server/render/index.ts @@ -1,7 +1,12 @@ export type { RenderInstruction } from './types'; export type { AstroComponentFactory, AstroComponentInstance } from './astro/index'; -export { createHeadAndContent, renderAstroTemplateResult, renderToString, renderTemplate } from './astro/index.js'; +export { + createHeadAndContent, + renderAstroTemplateResult, + renderToString, + renderTemplate, +} from './astro/index.js'; export { Fragment, Renderer, stringifyChunk } from './common.js'; export { renderComponent, renderComponentToIterable } from './component.js'; export { renderHTMLElement } from './dom.js'; diff --git a/packages/astro/src/runtime/server/render/page.ts b/packages/astro/src/runtime/server/render/page.ts index 9f9c7ae4090a0..1af4396eee348 100644 --- a/packages/astro/src/runtime/server/render/page.ts +++ b/packages/astro/src/runtime/server/render/page.ts @@ -10,7 +10,7 @@ import { isAstroComponentInstance, isRenderTemplateResult, isHeadAndContent, - renderAstroTemplateResult + renderAstroTemplateResult, } from './astro/index.js'; import { chunkToByteArray, encoder, HTMLParts } from './common.js'; import { renderComponent } from './component.js'; @@ -55,13 +55,13 @@ async function iterableToHTMLBytes( // to be propagated up. async function bufferHeadContent(result: SSRResult) { const iterator = result.propagators.values(); - while(true) { + while (true) { const { value, done } = iterator.next(); - if(done) { + if (done) { break; } const returnValue = await value.init(); - if(isHeadAndContent(returnValue)) { + if (isHeadAndContent(returnValue)) { result.extraHead.push(returnValue.head); } } @@ -85,9 +85,9 @@ export async function renderPage( componentFactory.name, componentFactory, pageProps, - null, + null ); - if(isAstroComponentInstance(renderResult)) { + if (isAstroComponentInstance(renderResult)) { output = renderResult.render(); } else { output = renderResult; @@ -123,7 +123,9 @@ export async function renderPage( if (isRenderTemplateResult(factoryReturnValue) || factoryIsHeadAndContent) { // Wait for head content to be buffered up await bufferHeadContent(result); - const templateResult = factoryIsHeadAndContent ? factoryReturnValue.content : factoryReturnValue; + const templateResult = factoryIsHeadAndContent + ? factoryReturnValue.content + : factoryReturnValue; let iterable = renderAstroTemplateResult(templateResult); let init = result.response; diff --git a/packages/astro/src/runtime/server/render/stylesheet.ts b/packages/astro/src/runtime/server/render/stylesheet.ts index cc704bc0b65cd..1a74039091336 100644 --- a/packages/astro/src/runtime/server/render/stylesheet.ts +++ b/packages/astro/src/runtime/server/render/stylesheet.ts @@ -5,18 +5,24 @@ import { markHTMLString } from '../escape.js'; const stylesheetRel = 'stylesheet'; export function renderStylesheet({ href }: { href: string }) { - return markHTMLString(renderElement('link', { - props: { - rel: stylesheetRel, - href - }, - children: '' - }, false)); + return markHTMLString( + renderElement( + 'link', + { + props: { + rel: stylesheetRel, + href, + }, + children: '', + }, + false + ) + ); } export function renderUniqueStylesheet(result: SSRResult, link: { href: string }) { for (const existingLink of result.links) { - if(existingLink.props.rel === stylesheetRel && existingLink.props.href === link.href) { + if (existingLink.props.rel === stylesheetRel && existingLink.props.href === link.href) { return ''; } } diff --git a/packages/astro/src/vite-plugin-astro/metadata.ts b/packages/astro/src/vite-plugin-astro/metadata.ts index 866d0127778c3..7091bd8c3d881 100644 --- a/packages/astro/src/vite-plugin-astro/metadata.ts +++ b/packages/astro/src/vite-plugin-astro/metadata.ts @@ -2,7 +2,7 @@ import type { PluginMetadata } from './types'; import type { ModuleInfo } from '../core/module-loader'; export function getAstroMetadata(modInfo: ModuleInfo): PluginMetadata['astro'] | undefined { - if(modInfo.meta?.astro) { + if (modInfo.meta?.astro) { return modInfo.meta.astro as PluginMetadata['astro']; } return undefined; diff --git a/packages/astro/src/vite-plugin-head-propagation/index.ts b/packages/astro/src/vite-plugin-head-propagation/index.ts index dd8355c0f8c1c..9375b133c1755 100644 --- a/packages/astro/src/vite-plugin-head-propagation/index.ts +++ b/packages/astro/src/vite-plugin-head-propagation/index.ts @@ -16,17 +16,22 @@ export default function configHeadPropagationVitePlugin({ }: { settings: AstroSettings; }): vite.Plugin { - function addHeadInjectionInTree(graph: vite.ModuleGraph, id: string, getInfo: (id: string) => ModuleInfo | null, seen: Set = new Set()) { + function addHeadInjectionInTree( + graph: vite.ModuleGraph, + id: string, + getInfo: (id: string) => ModuleInfo | null, + seen: Set = new Set() + ) { const mod = server.moduleGraph.getModuleById(id); - for(const parent of mod?.importers || []) { - if(parent.id) { - if(seen.has(parent.id)) { + for (const parent of mod?.importers || []) { + if (parent.id) { + if (seen.has(parent.id)) { continue; } const info = getInfo(parent.id); - if(info?.meta.astro) { + if (info?.meta.astro) { const astroMetadata = getAstroMetadata(info); - if(astroMetadata) { + if (astroMetadata) { astroMetadata.propagation = 'in-tree'; } } @@ -42,13 +47,13 @@ export default function configHeadPropagationVitePlugin({ server = _server; }, transform(source, id) { - if(!server) { + if (!server) { return; } - if(injectExp.test(source)) { + if (injectExp.test(source)) { addHeadInjectionInTree(server.moduleGraph, id, (child) => this.getModuleInfo(child)); } - } + }, }; } diff --git a/packages/astro/src/vite-plugin-markdown-legacy/index.ts b/packages/astro/src/vite-plugin-markdown-legacy/index.ts index f55f4724852d0..e0d3f4d62a8da 100644 --- a/packages/astro/src/vite-plugin-markdown-legacy/index.ts +++ b/packages/astro/src/vite-plugin-markdown-legacy/index.ts @@ -233,7 +233,7 @@ ${tsResult}`; clientOnlyComponents: transformResult.clientOnlyComponents, hydratedComponents: transformResult.hydratedComponents, scripts: transformResult.scripts, - propagation: 'none' + propagation: 'none', }; return { diff --git a/packages/astro/test/units/dev/head-injection.test.js b/packages/astro/test/units/dev/head-injection.test.js index 5f57d2400042c..0426b4c78f34a 100644 --- a/packages/astro/test/units/dev/head-injection.test.js +++ b/packages/astro/test/units/dev/head-injection.test.js @@ -55,24 +55,28 @@ describe('head injection', () => { root ); - await runInContainer({ - fs, root, - userConfig: { - vite: { server: { middlewareMode: true } } - } - }, async (container) => { - const { req, res, done, text } = createRequestAndResponse({ - method: 'GET', - url: '/', - }); - container.handle(req, res); - await done; - const html = await text(); - const $ = cheerio.load(html); + await runInContainer( + { + fs, + root, + userConfig: { + vite: { server: { middlewareMode: true } }, + }, + }, + async (container) => { + const { req, res, done, text } = createRequestAndResponse({ + method: 'GET', + url: '/', + }); + container.handle(req, res); + await done; + const html = await text(); + const $ = cheerio.load(html); - expect($('link[rel=stylesheet][href="/some/fake/styles.css"]')).to.have.a.lengthOf(1); - expect($('#other')).to.have.a.lengthOf(1); - }); + expect($('link[rel=stylesheet][href="/some/fake/styles.css"]')).to.have.a.lengthOf(1); + expect($('#other')).to.have.a.lengthOf(1); + } + ); }); it('Dynamic injection from a layout component', async () => { @@ -138,23 +142,27 @@ describe('head injection', () => { root ); - await runInContainer({ - fs, root, - userConfig: { - vite: { server: { middlewareMode: true } } - } - }, async (container) => { - const { req, res, done, text } = createRequestAndResponse({ - method: 'GET', - url: '/', - }); - container.handle(req, res); - await done; - const html = await text(); - const $ = cheerio.load(html); + await runInContainer( + { + fs, + root, + userConfig: { + vite: { server: { middlewareMode: true } }, + }, + }, + async (container) => { + const { req, res, done, text } = createRequestAndResponse({ + method: 'GET', + url: '/', + }); + container.handle(req, res); + await done; + const html = await text(); + const $ = cheerio.load(html); - expect($('link[rel=stylesheet][href="/some/fake/styles.css"]')).to.have.a.lengthOf(1); - expect($('#other')).to.have.a.lengthOf(1); - }); + expect($('link[rel=stylesheet][href="/some/fake/styles.css"]')).to.have.a.lengthOf(1); + expect($('#other')).to.have.a.lengthOf(1); + } + ); }); }); diff --git a/packages/integrations/cloudflare/CHANGELOG.md b/packages/integrations/cloudflare/CHANGELOG.md index c71e087f7a887..8e88039814493 100644 --- a/packages/integrations/cloudflare/CHANGELOG.md +++ b/packages/integrations/cloudflare/CHANGELOG.md @@ -1,5 +1,14 @@ # @astrojs/cloudflare +## 4.1.1 + +### Patch Changes + +- [#5534](https://github.com/withastro/astro/pull/5534) [`fabd9124b`](https://github.com/withastro/astro/commit/fabd9124bd3e654e885054f30e9c0d01eabf0470) Thanks [@bluwy](https://github.com/bluwy)! - Update esbuild dependency + +- Updated dependencies [[`9082a850e`](https://github.com/withastro/astro/commit/9082a850eef4ab0187fc3bfdd5a377f0c7040070), [`05915fec0`](https://github.com/withastro/astro/commit/05915fec01a51f27ab5051644f01e6112ecf06bc), [`8f3f67c96`](https://github.com/withastro/astro/commit/8f3f67c96aee63be64de77f374293761ff73f6ce)]: + - astro@1.6.14 + ## 4.1.0 ### Minor Changes diff --git a/packages/integrations/cloudflare/package.json b/packages/integrations/cloudflare/package.json index 2f45c547ca409..578eda3bd9690 100644 --- a/packages/integrations/cloudflare/package.json +++ b/packages/integrations/cloudflare/package.json @@ -1,7 +1,7 @@ { "name": "@astrojs/cloudflare", "description": "Deploy your site to cloudflare workers or cloudflare pages", - "version": "4.1.0", + "version": "4.1.1", "type": "module", "types": "./dist/index.d.ts", "author": "withastro", @@ -38,7 +38,7 @@ "tiny-glob": "^0.2.9" }, "peerDependencies": { - "astro": "^1.6.13" + "astro": "^1.6.14" }, "devDependencies": { "astro": "workspace:*", diff --git a/packages/integrations/deno/CHANGELOG.md b/packages/integrations/deno/CHANGELOG.md index 890e579e4bf3f..e5f63755efce4 100644 --- a/packages/integrations/deno/CHANGELOG.md +++ b/packages/integrations/deno/CHANGELOG.md @@ -1,5 +1,14 @@ # @astrojs/deno +## 2.0.1 + +### Patch Changes + +- [#5534](https://github.com/withastro/astro/pull/5534) [`fabd9124b`](https://github.com/withastro/astro/commit/fabd9124bd3e654e885054f30e9c0d01eabf0470) Thanks [@bluwy](https://github.com/bluwy)! - Update esbuild dependency + +- Updated dependencies [[`9082a850e`](https://github.com/withastro/astro/commit/9082a850eef4ab0187fc3bfdd5a377f0c7040070), [`05915fec0`](https://github.com/withastro/astro/commit/05915fec01a51f27ab5051644f01e6112ecf06bc), [`8f3f67c96`](https://github.com/withastro/astro/commit/8f3f67c96aee63be64de77f374293761ff73f6ce)]: + - astro@1.6.14 + ## 2.0.0 ### Major Changes diff --git a/packages/integrations/deno/package.json b/packages/integrations/deno/package.json index 2d75e15d5905e..5e50d6b45a696 100644 --- a/packages/integrations/deno/package.json +++ b/packages/integrations/deno/package.json @@ -1,7 +1,7 @@ { "name": "@astrojs/deno", "description": "Deploy your site to a Deno server", - "version": "2.0.0", + "version": "2.0.1", "type": "module", "types": "./dist/index.d.ts", "author": "withastro", @@ -32,7 +32,7 @@ "esbuild": "^0.15.18" }, "peerDependencies": { - "astro": "^1.6.13" + "astro": "^1.6.14" }, "devDependencies": { "astro": "workspace:*", diff --git a/packages/integrations/netlify/CHANGELOG.md b/packages/integrations/netlify/CHANGELOG.md index 3b970c401bfb1..fc7e33f4af2f9 100644 --- a/packages/integrations/netlify/CHANGELOG.md +++ b/packages/integrations/netlify/CHANGELOG.md @@ -1,5 +1,11 @@ # @astrojs/netlify +## 1.2.2 + +### Patch Changes + +- [#5534](https://github.com/withastro/astro/pull/5534) [`fabd9124b`](https://github.com/withastro/astro/commit/fabd9124bd3e654e885054f30e9c0d01eabf0470) Thanks [@bluwy](https://github.com/bluwy)! - Update esbuild dependency + ## 1.2.1 ### Patch Changes diff --git a/packages/integrations/netlify/package.json b/packages/integrations/netlify/package.json index 2df3b9d025349..43413247fd5cb 100644 --- a/packages/integrations/netlify/package.json +++ b/packages/integrations/netlify/package.json @@ -1,7 +1,7 @@ { "name": "@astrojs/netlify", "description": "Deploy your site to Netlify", - "version": "1.2.1", + "version": "1.2.2", "type": "module", "types": "./dist/index.d.ts", "author": "withastro", diff --git a/packages/integrations/node/package.json b/packages/integrations/node/package.json index d325095b11960..815bf8ca5f89d 100644 --- a/packages/integrations/node/package.json +++ b/packages/integrations/node/package.json @@ -34,7 +34,7 @@ "send": "^0.18.0" }, "peerDependencies": { - "astro": "^1.6.13" + "astro": "^1.6.14" }, "devDependencies": { "@types/node-fetch": "^2.6.2", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index fd205edfcdf82..daab57a243aff 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -61,7 +61,7 @@ importers: examples/basics: specifiers: - astro: ^1.6.13 + astro: ^1.6.14 dependencies: astro: link:../../packages/astro @@ -70,7 +70,7 @@ importers: '@astrojs/mdx': ^0.12.1 '@astrojs/rss': ^1.0.3 '@astrojs/sitemap': ^1.0.0 - astro: ^1.6.13 + astro: ^1.6.14 dependencies: '@astrojs/mdx': link:../../packages/integrations/mdx '@astrojs/rss': link:../../packages/astro-rss @@ -79,14 +79,14 @@ importers: examples/component: specifiers: - astro: ^1.6.13 + astro: ^1.6.14 devDependencies: astro: link:../../packages/astro examples/deno: specifiers: - '@astrojs/deno': ^2.0.0 - astro: ^1.6.13 + '@astrojs/deno': ^2.0.1 + astro: ^1.6.14 dependencies: astro: link:../../packages/astro devDependencies: @@ -102,7 +102,7 @@ importers: '@types/node': ^18.0.0 '@types/react': ^17.0.45 '@types/react-dom': ^18.0.0 - astro: ^1.6.13 + astro: ^1.6.14 html-escaper: ^3.0.3 preact: ^10.7.3 react: ^18.1.0 @@ -128,7 +128,7 @@ importers: '@astrojs/alpinejs': ^0.1.2 '@types/alpinejs': ^3.7.0 alpinejs: ^3.10.2 - astro: ^1.6.13 + astro: ^1.6.14 dependencies: '@astrojs/alpinejs': link:../../packages/integrations/alpinejs '@types/alpinejs': 3.7.1 @@ -139,7 +139,7 @@ importers: specifiers: '@astrojs/lit': ^1.0.0 '@webcomponents/template-shadowroot': ^0.1.0 - astro: ^1.6.13 + astro: ^1.6.14 lit: ^2.2.5 dependencies: '@astrojs/lit': link:../../packages/integrations/lit @@ -154,7 +154,7 @@ importers: '@astrojs/solid-js': ^1.2.3 '@astrojs/svelte': ^1.0.2 '@astrojs/vue': ^1.2.1 - astro: ^1.6.13 + astro: ^1.6.14 preact: ^10.7.3 react: ^18.1.0 react-dom: ^18.1.0 @@ -179,7 +179,7 @@ importers: specifiers: '@astrojs/preact': ^1.2.0 '@preact/signals': ^1.1.0 - astro: ^1.6.13 + astro: ^1.6.14 preact: ^10.7.3 dependencies: '@astrojs/preact': link:../../packages/integrations/preact @@ -192,7 +192,7 @@ importers: '@astrojs/react': ^1.2.2 '@types/react': ^18.0.10 '@types/react-dom': ^18.0.5 - astro: ^1.6.13 + astro: ^1.6.14 react: ^18.1.0 react-dom: ^18.1.0 dependencies: @@ -206,7 +206,7 @@ importers: examples/framework-solid: specifiers: '@astrojs/solid-js': ^1.2.3 - astro: ^1.6.13 + astro: ^1.6.14 solid-js: ^1.4.3 dependencies: '@astrojs/solid-js': link:../../packages/integrations/solid @@ -216,7 +216,7 @@ importers: examples/framework-svelte: specifiers: '@astrojs/svelte': ^1.0.2 - astro: ^1.6.13 + astro: ^1.6.14 svelte: ^3.48.0 dependencies: '@astrojs/svelte': link:../../packages/integrations/svelte @@ -226,7 +226,7 @@ importers: examples/framework-vue: specifiers: '@astrojs/vue': ^1.2.1 - astro: ^1.6.13 + astro: ^1.6.14 vue: ^3.2.37 dependencies: '@astrojs/vue': link:../../packages/integrations/vue @@ -236,32 +236,32 @@ importers: examples/hackernews: specifiers: '@astrojs/node': ^3.1.0 - astro: ^1.6.13 + astro: ^1.6.14 dependencies: '@astrojs/node': link:../../packages/integrations/node astro: link:../../packages/astro examples/integration: specifiers: - astro: ^1.6.13 + astro: ^1.6.14 devDependencies: astro: link:../../packages/astro examples/minimal: specifiers: - astro: ^1.6.13 + astro: ^1.6.14 dependencies: astro: link:../../packages/astro examples/non-html-pages: specifiers: - astro: ^1.6.13 + astro: ^1.6.14 dependencies: astro: link:../../packages/astro examples/portfolio: specifiers: - astro: ^1.6.13 + astro: ^1.6.14 dependencies: astro: link:../../packages/astro @@ -269,7 +269,7 @@ importers: specifiers: '@astrojs/node': ^3.1.0 '@astrojs/svelte': ^1.0.2 - astro: ^1.6.13 + astro: ^1.6.14 concurrently: ^7.2.1 svelte: ^3.48.0 unocss: ^0.15.6 @@ -286,7 +286,7 @@ importers: examples/with-markdown-plugins: specifiers: '@astrojs/markdown-remark': ^1.1.3 - astro: ^1.6.13 + astro: ^1.6.14 hast-util-select: 5.0.1 rehype-autolink-headings: ^6.1.1 rehype-slug: ^5.0.1 @@ -303,7 +303,7 @@ importers: examples/with-markdown-shiki: specifiers: - astro: ^1.6.13 + astro: ^1.6.14 dependencies: astro: link:../../packages/astro @@ -311,7 +311,7 @@ importers: specifiers: '@astrojs/mdx': ^0.12.1 '@astrojs/preact': ^1.2.0 - astro: ^1.6.13 + astro: ^1.6.14 preact: ^10.6.5 dependencies: '@astrojs/mdx': link:../../packages/integrations/mdx @@ -323,7 +323,7 @@ importers: specifiers: '@astrojs/preact': ^1.2.0 '@nanostores/preact': ^0.1.3 - astro: ^1.6.13 + astro: ^1.6.14 nanostores: ^0.5.12 preact: ^10.7.3 dependencies: @@ -338,7 +338,7 @@ importers: '@astrojs/mdx': ^0.12.1 '@astrojs/tailwind': ^2.1.3 '@types/canvas-confetti': ^1.4.3 - astro: ^1.6.13 + astro: ^1.6.14 autoprefixer: ^10.4.7 canvas-confetti: ^1.5.1 postcss: ^8.4.14 @@ -355,7 +355,7 @@ importers: examples/with-vite-plugin-pwa: specifiers: - astro: ^1.6.13 + astro: ^1.6.14 vite-plugin-pwa: 0.11.11 workbox-window: ^6.5.3 dependencies: @@ -365,7 +365,7 @@ importers: examples/with-vitest: specifiers: - astro: ^1.6.13 + astro: ^1.6.14 vitest: ^0.20.3 dependencies: astro: link:../../packages/astro @@ -18428,7 +18428,7 @@ packages: optional: true dependencies: '@types/node': 18.11.9 - esbuild: 0.15.18 + esbuild: 0.15.14 postcss: 8.4.19 resolve: 1.22.1 rollup: 2.79.1