From 34202616c2ad0bd4b7a808217718ee74d1b20eae Mon Sep 17 00:00:00 2001 From: matthewp Date: Wed, 17 May 2023 14:20:24 +0000 Subject: [PATCH] [ci] format --- .../src/runtime/server/render/component.ts | 12 ++++++++---- packages/integrations/preact/src/server.ts | 19 +++++++++++++------ .../integrations/preact/src/static-html.ts | 2 +- packages/integrations/react/server-v17.js | 2 +- packages/integrations/react/server.js | 4 ++-- packages/integrations/vue/server.js | 13 +++++++------ 6 files changed, 32 insertions(+), 20 deletions(-) diff --git a/packages/astro/src/runtime/server/render/component.ts b/packages/astro/src/runtime/server/render/component.ts index a4254e4d34..d954a53969 100644 --- a/packages/astro/src/runtime/server/render/component.ts +++ b/packages/astro/src/runtime/server/render/component.ts @@ -77,7 +77,7 @@ async function renderFrameworkComponent( const { renderers, clientDirectives } = result._metadata; const metadata: AstroComponentMetadata = { astroStaticSlot: true, - displayName + displayName, }; const { hydration, isPage, props } = extractDirectives(_props, clientDirectives); @@ -273,7 +273,9 @@ If you're still stuck, please open an issue on GitHub or join us at https://astr if (isPage || renderer?.name === 'astro:jsx') { yield html; } else if (html && html.length > 0) { - yield markHTMLString(removeStaticAstroSlot(html, renderer?.ssr?.supportsAstroStaticSlot ?? false)); + yield markHTMLString( + removeStaticAstroSlot(html, renderer?.ssr?.supportsAstroStaticSlot ?? false) + ); } else { yield ''; } @@ -298,8 +300,10 @@ If you're still stuck, please open an issue on GitHub or join us at https://astr if (html) { if (Object.keys(children).length > 0) { for (const key of Object.keys(children)) { - let tagName = renderer?.ssr?.supportsAstroStaticSlot ? - !!metadata.hydrate ? 'astro-slot' : 'astro-static-slot' + let tagName = renderer?.ssr?.supportsAstroStaticSlot + ? !!metadata.hydrate + ? 'astro-slot' + : 'astro-static-slot' : 'astro-slot'; let expectedHTML = key === 'default' ? `<${tagName}>` : `<${tagName} name="${key}">`; if (!html.includes(expectedHTML)) { diff --git a/packages/integrations/preact/src/server.ts b/packages/integrations/preact/src/server.ts index 57e08c945d..9efd6017f7 100644 --- a/packages/integrations/preact/src/server.ts +++ b/packages/integrations/preact/src/server.ts @@ -11,7 +11,7 @@ const slotName = (str: string) => str.trim().replace(/[-_]([a-z])/g, (_, w) => w let originalConsoleError: typeof console.error; let consoleFilterRefs = 0; -function check(this: RendererContext, Component: any, props: Record, children: any, ) { +function check(this: RendererContext, Component: any, props: Record, children: any) { if (typeof Component !== 'function') return false; if (Component.prototype != null && typeof Component.prototype.render === 'function') { @@ -49,7 +49,7 @@ function renderToStaticMarkup( Component: any, props: Record, { default: children, ...slotted }: Record, - metadata: AstroComponentMetadata | undefined, + metadata: AstroComponentMetadata | undefined ) { const ctx = getContext(this.result); @@ -59,7 +59,7 @@ function renderToStaticMarkup( slots[name] = h(StaticHtml, { hydrate: shouldHydrate(metadata), value, - name + name, }); } @@ -72,9 +72,16 @@ function renderToStaticMarkup( serializeSignals(ctx, props, attrs, propsMap); const html = render( - h(Component, newProps, children != null ? h(StaticHtml, { - hydrate: shouldHydrate(metadata), - value: children}) : children) + h( + Component, + newProps, + children != null + ? h(StaticHtml, { + hydrate: shouldHydrate(metadata), + value: children, + }) + : children + ) ); return { attrs, diff --git a/packages/integrations/preact/src/static-html.ts b/packages/integrations/preact/src/static-html.ts index c1e44515f8..f0fbd885ca 100644 --- a/packages/integrations/preact/src/static-html.ts +++ b/packages/integrations/preact/src/static-html.ts @@ -4,7 +4,7 @@ type Props = { value: string; name?: string; hydrate?: boolean; -} +}; /** * Astro passes `children` as a string of HTML, so we need diff --git a/packages/integrations/react/server-v17.js b/packages/integrations/react/server-v17.js index 551b350d59..522837a16d 100644 --- a/packages/integrations/react/server-v17.js +++ b/packages/integrations/react/server-v17.js @@ -68,7 +68,7 @@ function renderToStaticMarkup(Component, props, { default: children, ...slotted newProps.children = React.createElement(StaticHtml, { // Adjust how this is hydrated only when the version of Astro supports `astroStaticSlot` hydrate: metadata.astroStaticSlot ? !!metadata.hydrate : true, - value: newChildren + value: newChildren, }); } const vnode = React.createElement(Component, newProps); diff --git a/packages/integrations/react/server.js b/packages/integrations/react/server.js index e84b8bf272..b6829e3387 100644 --- a/packages/integrations/react/server.js +++ b/packages/integrations/react/server.js @@ -77,7 +77,7 @@ async function renderToStaticMarkup(Component, props, { default: children, ...sl slots[name] = React.createElement(StaticHtml, { hydrate: needsHydration(metadata), value, - name + name, }); } // Note: create newProps to avoid mutating `props` before they are serialized @@ -89,7 +89,7 @@ async function renderToStaticMarkup(Component, props, { default: children, ...sl if (newChildren != null) { newProps.children = React.createElement(StaticHtml, { hydrate: needsHydration(metadata), - value: newChildren + value: newChildren, }); } const vnode = React.createElement(Component, newProps); diff --git a/packages/integrations/vue/server.js b/packages/integrations/vue/server.js index 6f7cdce681..4e06baa5f6 100644 --- a/packages/integrations/vue/server.js +++ b/packages/integrations/vue/server.js @@ -10,12 +10,13 @@ function check(Component) { async function renderToStaticMarkup(Component, props, slotted, metadata) { const slots = {}; for (const [key, value] of Object.entries(slotted)) { - slots[key] = () => h(StaticHtml, { - value, - name: key === 'default' ? undefined : key, - // Adjust how this is hydrated only when the version of Astro supports `astroStaticSlot` - hydrate: metadata.astroStaticSlot ? !!metadata.hydrate : true, - }); + slots[key] = () => + h(StaticHtml, { + value, + name: key === 'default' ? undefined : key, + // Adjust how this is hydrated only when the version of Astro supports `astroStaticSlot` + hydrate: metadata.astroStaticSlot ? !!metadata.hydrate : true, + }); } const app = createSSRApp({ render: () => h(Component, props, slots) }); await setup(app);