summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--packages/astro/src/runtime/server/render/component.ts5
-rw-r--r--packages/astro/src/runtime/server/serialize.ts26
-rw-r--r--packages/astro/src/vite-plugin-astro-server/index.ts2
-rw-r--r--packages/integrations/preact/client-dev.js4
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(
- `<!--${metadata.componentExport!.value}:${metadata.componentUrl}-->\n${html}\n${serializeProps(props, metadata)}`
+ `<!--${metadata.componentExport!.value}:${metadata.componentUrl}-->\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> = 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<any, any>, metadata: AstroComponentMetadata): Record<any, any> {
+function serializeObject(
+ value: Record<any, any>,
+ metadata: AstroComponentMetadata
+): Record<any, any> {
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<typeof PROP_TYPE>, any] {
+function convertToSerializedForm(
+ value: any,
+ metadata: AstroComponentMetadata
+): [ValueOf<typeof PROP_TYPE>, 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<any, any>), metadata))];
+ return [
+ PROP_TYPE.Map,
+ JSON.stringify(serializeArray(Array.from(value as Map<any, any>), metadata)),
+ ];
}
case '[object Set]': {
- return [PROP_TYPE.Set, JSON.stringify(serializeArray(Array.from(value as Set<any>), metadata))];
+ return [
+ PROP_TYPE.Set,
+ JSON.stringify(serializeArray(Array.from(value as Set<any>), 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(`<script type="module" src="/@vite/client"></script>`)
+ res.write(`<script type="module" src="/@vite/client"></script>`);
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;