diff --git a/packages/astro/src/runtime/server/hydration.ts b/packages/astro/src/runtime/server/hydration.ts index 1e7760814..e14924dfe 100644 --- a/packages/astro/src/runtime/server/hydration.ts +++ b/packages/astro/src/runtime/server/hydration.ts @@ -15,7 +15,7 @@ export interface HydrationMetadata { value: string; componentUrl: string; componentExport: { value: string }; -}; +} interface ExtractedProps { isPage: boolean; diff --git a/packages/astro/src/runtime/server/index.ts b/packages/astro/src/runtime/server/index.ts index d3c838266..ebec0487a 100644 --- a/packages/astro/src/runtime/server/index.ts +++ b/packages/astro/src/runtime/server/index.ts @@ -135,7 +135,7 @@ export async function renderSlot(result: any, slotted: string, fallback?: any): let iterator = _render(slotted); let content = ''; for await (const chunk of iterator) { - if((chunk as any).type === 'directive') { + if ((chunk as any).type === 'directive') { content += stringifyChunk(result, chunk); } else { content += chunk; @@ -230,7 +230,11 @@ export async function renderComponent( } if (Component && (Component as any).isAstroComponentFactory) { - async function* renderAstroComponentInline(): AsyncGenerator { + async function* renderAstroComponentInline(): AsyncGenerator< + string | RenderInstruction, + void, + undefined + > { let iterable = await renderToIterable(result, Component as any, _props, slots); yield* iterable; } @@ -482,7 +486,7 @@ If you're still stuck, please open an issue on GitHub or join us at https://astr island.props['await-children'] = ''; } - async function * renderAll() { + async function* renderAll() { yield { type: 'directive', hydration, result }; yield markHTMLString(renderElement('astro-island', island, false)); } @@ -777,7 +781,7 @@ const encoder = new TextEncoder(); // These directive instructions bubble all the way up to renderPage so that we // can ensure they are added only once, and as soon as possible. export function stringifyChunk(result: SSRResult, chunk: string | RenderInstruction) { - switch((chunk as any).type) { + switch ((chunk as any).type) { case 'directive': { const { hydration } = chunk as RenderInstruction; let needsHydrationScript = hydration && determineIfNeedsHydrationScript(result); @@ -785,11 +789,11 @@ export function stringifyChunk(result: SSRResult, chunk: string | RenderInstruct hydration && determinesIfNeedsDirectiveScript(result, hydration.directive); let prescriptType: PrescriptType = needsHydrationScript - ? 'both' - : needsDirectiveScript - ? 'directive' - : null; - if(prescriptType) { + ? 'both' + : needsDirectiveScript + ? 'directive' + : null; + if (prescriptType) { let prescripts = getPrescripts(prescriptType, hydration.directive); return markHTMLString(prescripts); } else { @@ -942,7 +946,7 @@ export async function* renderAstroComponent( for await (const value of component) { if (value || value === 0) { for await (const chunk of _render(value)) { - switch(chunk.type) { + switch (chunk.type) { case 'directive': { yield chunk; break; diff --git a/packages/astro/src/runtime/server/jsx.ts b/packages/astro/src/runtime/server/jsx.ts index add4c0ca4..a284b061f 100644 --- a/packages/astro/src/runtime/server/jsx.ts +++ b/packages/astro/src/runtime/server/jsx.ts @@ -6,8 +6,8 @@ import { escapeHTML, HTMLString, markHTMLString, - RenderInstruction, renderComponent, + RenderInstruction, renderToString, spreadAttributes, stringifyChunk, @@ -139,7 +139,7 @@ export async function renderJSX(result: SSRResult, vnode: any): Promise { slots ); } - if(typeof output !== 'string' && Symbol.asyncIterator in output) { + if (typeof output !== 'string' && Symbol.asyncIterator in output) { let body = ''; for await (const chunk of output) { let html = stringifyChunk(result, chunk); diff --git a/packages/astro/src/runtime/server/scripts.ts b/packages/astro/src/runtime/server/scripts.ts index ab073fe67..1d57c07e9 100644 --- a/packages/astro/src/runtime/server/scripts.ts +++ b/packages/astro/src/runtime/server/scripts.ts @@ -8,10 +8,10 @@ import visiblePrebuilt from '../client/visible.prebuilt.js'; import islandScript from './astro-island.prebuilt.js'; export function determineIfNeedsHydrationScript(result: SSRResult): boolean { - if(result._metadata.hasHydrationScript) { + if (result._metadata.hasHydrationScript) { return false; } - return result._metadata.hasHydrationScript = true; + return (result._metadata.hasHydrationScript = true); } export const hydrationScripts: Record = { @@ -23,7 +23,7 @@ export const hydrationScripts: Record = { }; export function determinesIfNeedsDirectiveScript(result: SSRResult, directive: string): boolean { - if(result._metadata.hasDirectives.has(directive)) { + if (result._metadata.hasDirectives.has(directive)) { return false; } result._metadata.hasDirectives.add(directive);