From f4bca41a2d85968a2c9f2379f99954c7bcb06df1 Mon Sep 17 00:00:00 2001 From: matthewp Date: Wed, 28 Sep 2022 14:57:53 +0000 Subject: [PATCH] [ci] format --- packages/astro/src/runtime/server/render/any.ts | 6 +++--- .../astro/src/runtime/server/render/component.ts | 10 ++++++---- packages/astro/src/runtime/server/render/index.ts | 2 +- packages/astro/src/runtime/server/render/slot.ts | 12 ++++++------ 4 files changed, 16 insertions(+), 14 deletions(-) diff --git a/packages/astro/src/runtime/server/render/any.ts b/packages/astro/src/runtime/server/render/any.ts index 9d55938735..f4ffc21af9 100644 --- a/packages/astro/src/runtime/server/render/any.ts +++ b/packages/astro/src/runtime/server/render/any.ts @@ -4,9 +4,9 @@ import { SlotString } from './slot.js'; export async function* renderChild(child: any): AsyncIterable { child = await child; - if(child instanceof SlotString) { - if(child.instructions) { - yield * child.instructions; + if (child instanceof SlotString) { + if (child.instructions) { + yield* child.instructions; } yield child; } else if (child instanceof HTMLString) { diff --git a/packages/astro/src/runtime/server/render/component.ts b/packages/astro/src/runtime/server/render/component.ts index 45ac5c3efc..e6aad1698d 100644 --- a/packages/astro/src/runtime/server/render/component.ts +++ b/packages/astro/src/runtime/server/render/component.ts @@ -5,7 +5,6 @@ import { HTMLBytes, markHTMLString } from '../escape.js'; import { extractDirectives, generateHydrateScript } from '../hydration.js'; import { serializeProps } from '../serialize.js'; import { shorthash } from '../shorthash.js'; -import { renderSlot, renderSlots } from './slot.js'; import { isAstroComponentFactory, renderAstroComponent, @@ -14,6 +13,7 @@ import { } from './astro.js'; import { Fragment, Renderer, stringifyChunk } from './common.js'; import { componentIsHTMLElement, renderHTMLElement } from './dom.js'; +import { renderSlot, renderSlots } from './slot.js'; import { formatList, internalSpreadAttributes, renderElement, voidElementNames } from './util.js'; const rendererAliases = new Map([['solid', 'solid-js']]); @@ -70,7 +70,9 @@ export async function renderComponent( case 'html': { const { slotInstructions, children } = await renderSlots(result, slots); const html = (Component as any).render({ slots: children }); - const hydrationHtml = slotInstructions ? slotInstructions.map(instr => stringifyChunk(result, instr)).join('') : ''; + const hydrationHtml = slotInstructions + ? slotInstructions.map((instr) => stringifyChunk(result, instr)).join('') + : ''; return markHTMLString(hydrationHtml + html); } @@ -328,8 +330,8 @@ If you're still stuck, please open an issue on GitHub or join us at https://astr } async function* renderAll() { - if(slotInstructions) { - yield * slotInstructions; + if (slotInstructions) { + yield* slotInstructions; } yield { type: 'directive', hydration, result }; yield markHTMLString(renderElement('astro-island', island, false)); diff --git a/packages/astro/src/runtime/server/render/index.ts b/packages/astro/src/runtime/server/render/index.ts index 15bf963cbf..537482691a 100644 --- a/packages/astro/src/runtime/server/render/index.ts +++ b/packages/astro/src/runtime/server/render/index.ts @@ -1,12 +1,12 @@ import { renderTemplate } from './astro.js'; -export { renderSlot } from './slot.js'; export { renderAstroComponent, renderTemplate, renderToString } from './astro.js'; export { Fragment, Renderer, stringifyChunk } from './common.js'; export { renderComponent } from './component.js'; export { renderHTMLElement } from './dom.js'; export { maybeRenderHead, renderHead } from './head.js'; export { renderPage } from './page.js'; +export { renderSlot } from './slot.js'; export type { RenderInstruction } from './types'; export { addAttribute, defineScriptVars, voidElementNames } from './util.js'; diff --git a/packages/astro/src/runtime/server/render/slot.ts b/packages/astro/src/runtime/server/render/slot.ts index a96bc3106d..5aee6dfa41 100644 --- a/packages/astro/src/runtime/server/render/slot.ts +++ b/packages/astro/src/runtime/server/render/slot.ts @@ -1,8 +1,8 @@ -import type { RenderInstruction } from './types.js'; import type { SSRResult } from '../../../@types/astro.js'; +import type { RenderInstruction } from './types.js'; -import { renderChild } from './any.js'; import { HTMLString, markHTMLString } from '../escape.js'; +import { renderChild } from './any.js'; export class SlotString extends HTMLString { public instructions: null | RenderInstruction[]; @@ -19,7 +19,7 @@ export async function renderSlot(_result: any, slotted: string, fallback?: any): let instructions: null | RenderInstruction[] = null; for await (const chunk of iterator) { if ((chunk as any).type === 'directive') { - if(instructions === null) { + if (instructions === null) { instructions = []; } instructions.push(chunk); @@ -33,7 +33,7 @@ export async function renderSlot(_result: any, slotted: string, fallback?: any): } interface RenderSlotsResult { - slotInstructions: null | RenderInstruction[], + slotInstructions: null | RenderInstruction[]; children: Record; } @@ -44,8 +44,8 @@ export async function renderSlots(result: SSRResult, slots: any = {}): Promise renderSlot(result, value as string).then((output: any) => { - if(output.instructions) { - if(slotInstructions === null) { + if (output.instructions) { + if (slotInstructions === null) { slotInstructions = []; } slotInstructions.push(...output.instructions);