server.ts — astro Source File
Architecture documentation for server.ts, a typescript file in the astro codebase. 7 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR d27cc44a_e2ff_86d0_e654_f90b112f1bba["server.ts"] bf82cf79_dc97_8b42_cd75_dd4f0216baa0["./context.js"] d27cc44a_e2ff_86d0_e654_f90b112f1bba --> bf82cf79_dc97_8b42_cd75_dd4f0216baa0 6312de90_53bb_06bd_d7cc_f1202630e3f4["./signals.js"] d27cc44a_e2ff_86d0_e654_f90b112f1bba --> 6312de90_53bb_06bd_d7cc_f1202630e3f4 955d3da0_5530_ff15_3977_dcd12fa1bbf1["./static-html.js"] d27cc44a_e2ff_86d0_e654_f90b112f1bba --> 955d3da0_5530_ff15_3977_dcd12fa1bbf1 88d5831c_10b7_7e11_b115_8c6e411804a3["./types.js"] d27cc44a_e2ff_86d0_e654_f90b112f1bba --> 88d5831c_10b7_7e11_b115_8c6e411804a3 f16d8c76_2866_6150_bd14_0347b59abfe9["astro"] d27cc44a_e2ff_86d0_e654_f90b112f1bba --> f16d8c76_2866_6150_bd14_0347b59abfe9 0fef379e_25c0_6f95_11fd_6d0f7db42b7e["preact"] d27cc44a_e2ff_86d0_e654_f90b112f1bba --> 0fef379e_25c0_6f95_11fd_6d0f7db42b7e 6a9a0d23_a1d2_f642_7510_458a0fc0c094["preact-render-to-string"] d27cc44a_e2ff_86d0_e654_f90b112f1bba --> 6a9a0d23_a1d2_f642_7510_458a0fc0c094 style d27cc44a_e2ff_86d0_e654_f90b112f1bba fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
import type { AstroComponentMetadata, NamedSSRLoadedRendererValue } from 'astro';
import { Component as BaseComponent, h, type VNode } from 'preact';
import { renderToStringAsync } from 'preact-render-to-string';
import { getContext } from './context.js';
import { restoreSignalsOnProps, serializeSignals } from './signals.js';
import StaticHtml from './static-html.js';
import type { AstroPreactAttrs, RendererContext } from './types.js';
const slotName = (str: string) => str.trim().replace(/[-_]([a-z])/g, (_, w) => w.toUpperCase());
let originalConsoleError: typeof console.error;
let consoleFilterRefs = 0;
async function check(
this: RendererContext,
Component: any,
props: Record<string, any>,
children: any,
) {
if (typeof Component !== 'function') return false;
if (Component.name === 'QwikComponent') return false;
if (Component.prototype != null && typeof Component.prototype.render === 'function') {
return BaseComponent.isPrototypeOf(Component);
}
useConsoleFilter();
try {
const { html } = await renderToStaticMarkup.call(this, Component, props, children, undefined);
if (typeof html !== 'string') {
return false;
}
// There are edge cases (SolidJS) where Preact *might* render a string,
// but components would be <undefined></undefined>
// It also might render an empty string.
return html == '' ? false : !html.includes('<undefined>');
} catch {
return false;
} finally {
finishUsingConsoleFilter();
}
}
function shouldHydrate(metadata: AstroComponentMetadata | undefined) {
// Adjust how this is hydrated only when the version of Astro supports `astroStaticSlot`
return metadata?.astroStaticSlot ? !!metadata.hydrate : true;
}
async function renderToStaticMarkup(
this: RendererContext,
Component: any,
props: Record<string, any>,
{ default: children, ...slotted }: Record<string, any>,
metadata: AstroComponentMetadata | undefined,
) {
const ctx = getContext(this.result);
const slots: Record<string, ReturnType<typeof h>> = {};
// ... (94 more lines)
Domain
Subdomains
Functions
Dependencies
- ./context.js
- ./signals.js
- ./static-html.js
- ./types.js
- astro
- preact
- preact-render-to-string
Source
Frequently Asked Questions
What does server.ts do?
server.ts is a source file in the astro codebase, written in typescript. It belongs to the CoreAstro domain, RoutingSystem subdomain.
What functions are defined in server.ts?
server.ts defines 7 function(s): check, filteredConsoleError, finishUsingConsoleFilter, renderToStaticMarkup, shouldHydrate, slotName, useConsoleFilter.
What does server.ts depend on?
server.ts imports 7 module(s): ./context.js, ./signals.js, ./static-html.js, ./types.js, astro, preact, preact-render-to-string.
Where is server.ts in the architecture?
server.ts is located at packages/integrations/preact/src/server.ts (domain: CoreAstro, subdomain: RoutingSystem, directory: packages/integrations/preact/src).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free