From c01194b9d899cc8dcdaca5f92d8f4858ba7e1bae Mon Sep 17 00:00:00 2001 From: natemoo-re Date: Wed, 7 Sep 2022 18:50:48 +0000 Subject: [PATCH] [ci] format --- .../src/runtime/server/render/component.ts | 5 +++- .../astro/src/runtime/server/serialize.ts | 26 +++++++++++++------ .../src/vite-plugin-astro-server/index.ts | 2 +- packages/integrations/preact/client-dev.js | 4 +-- 4 files changed, 25 insertions(+), 12 deletions(-) diff --git a/packages/astro/src/runtime/server/render/component.ts b/packages/astro/src/runtime/server/render/component.ts index 389fdecf4..75398d2b9 100644 --- a/packages/astro/src/runtime/server/render/component.ts +++ b/packages/astro/src/runtime/server/render/component.ts @@ -302,7 +302,10 @@ If you're still stuck, please open an issue on GitHub or join us at https://astr // Include componentExport name, componentUrl, and props in hash to dedupe identical islands const astroId = shorthash( - `\n${html}\n${serializeProps(props, metadata)}` + `\n${html}\n${serializeProps( + props, + metadata + )}` ); const island = await generateHydrateScript( diff --git a/packages/astro/src/runtime/server/serialize.ts b/packages/astro/src/runtime/server/serialize.ts index 4de21c08d..10812ab75 100644 --- a/packages/astro/src/runtime/server/serialize.ts +++ b/packages/astro/src/runtime/server/serialize.ts @@ -1,6 +1,4 @@ -import type { - AstroComponentMetadata, -} from '../../@types/astro'; +import type { AstroComponentMetadata } from '../../@types/astro'; type ValueOf = T[keyof T]; @@ -19,11 +17,14 @@ function serializeArray(value: any[], metadata: AstroComponentMetadata): any[] { return value.map((v) => convertToSerializedForm(v, metadata)); } -function serializeObject(value: Record, metadata: AstroComponentMetadata): Record { +function serializeObject( + value: Record, + metadata: AstroComponentMetadata +): Record { if (cyclicRefs.has(value)) { throw new Error(`Cyclic reference detected while serializing props for <${metadata.displayName} client:${metadata.hydrate}>! -Cyclic references cannot be safely serialized for client-side usage. Please remove the cyclic reference.`) +Cyclic references cannot be safely serialized for client-side usage. Please remove the cyclic reference.`); } cyclicRefs.add(value); return Object.fromEntries( @@ -33,7 +34,10 @@ Cyclic references cannot be safely serialized for client-side usage. Please remo ); } -function convertToSerializedForm(value: any, metadata: AstroComponentMetadata): [ValueOf, any] { +function convertToSerializedForm( + value: any, + metadata: AstroComponentMetadata +): [ValueOf, any] { const tag = Object.prototype.toString.call(value); switch (tag) { case '[object Date]': { @@ -43,10 +47,16 @@ function convertToSerializedForm(value: any, metadata: AstroComponentMetadata): return [PROP_TYPE.RegExp, (value as RegExp).source]; } case '[object Map]': { - return [PROP_TYPE.Map, JSON.stringify(serializeArray(Array.from(value as Map), metadata))]; + return [ + PROP_TYPE.Map, + JSON.stringify(serializeArray(Array.from(value as Map), metadata)), + ]; } case '[object Set]': { - return [PROP_TYPE.Set, JSON.stringify(serializeArray(Array.from(value as Set), metadata))]; + return [ + PROP_TYPE.Set, + JSON.stringify(serializeArray(Array.from(value as Set), metadata)), + ]; } case '[object BigInt]': { return [PROP_TYPE.BigInt, (value as bigint).toString()]; diff --git a/packages/astro/src/vite-plugin-astro-server/index.ts b/packages/astro/src/vite-plugin-astro-server/index.ts index 883e3c91d..5a550ec18 100644 --- a/packages/astro/src/vite-plugin-astro-server/index.ts +++ b/packages/astro/src/vite-plugin-astro-server/index.ts @@ -120,7 +120,7 @@ async function handle500Response( ) { res.on('close', () => setTimeout(() => viteServer.ws.send(getViteErrorPayload(err)), 200)); if (res.headersSent) { - res.write(``) + res.write(``); res.end(); } else { writeHtmlResponse( diff --git a/packages/integrations/preact/client-dev.js b/packages/integrations/preact/client-dev.js index 8f264a903..d37e6e0af 100644 --- a/packages/integrations/preact/client-dev.js +++ b/packages/integrations/preact/client-dev.js @@ -1,4 +1,4 @@ -import "preact/debug" -import clientFn from "./client.js"; +import 'preact/debug'; +import clientFn from './client.js'; export default clientFn;