UNPKG

@ordojs/core

Version:

Core compiler and runtime for OrdoJS framework

109 lines 2.97 kB
/** * @fileoverview OrdoJS SSR Engine - Server-side rendering implementation */ import { type ComponentAST, type ComponentData, type HydrationData, type Props } from '../types/index.js'; /** * SSR Engine options */ export interface SSROptions { /** * Whether to include hydration markers in the generated HTML */ includeHydrationMarkers: boolean; /** * Whether to include component data for client-side hydration */ includeHydrationData: boolean; /** * Custom data fetching function */ dataFetcher?: (component: string, props: Props) => Promise<Record<string, any>>; /** * Route configuration for server-side routing */ routes?: RouteConfig[]; } /** * Route configuration for server-side routing */ export interface RouteConfig { /** * Route path pattern (e.g., '/users/:id') */ path: string; /** * Component name to render for this route */ component: string; /** * Data fetching function for this route */ dataFetcher?: (params: Record<string, string>, query: Record<string, string>) => Promise<Record<string, any>>; /** * Layout component to wrap the route component */ layout?: string; } /** * OrdoJS SSR Engine * Handles server-side rendering of components */ export declare class OrdoJSSSR { options: SSROptions; private codeGenerator; private componentRegistry; constructor(options?: Partial<SSROptions>); /** * Register a component for SSR */ registerComponent(ast: ComponentAST): void; /** * Register multiple components for SSR */ registerComponents(components: ComponentAST[]): void; /** * Render a component to HTML string */ renderComponent(componentName: string, props?: Props): Promise<string>; /** * Generate hydration data for a component */ generateHydrationData(ast: ComponentAST, data?: Record<string, any>): HydrationData; /** * Extract initial state from component AST */ private extractInitialState; /** * Inject hydration data into HTML */ private injectHydrationData; /** * Handle data fetching for SSR */ handleDataFetching(componentName: string, props?: Props): Promise<ComponentData>; /** * Render a route to HTML */ renderRoute(url: string): Promise<string>; /** * Find a matching route for a path */ private findMatchingRoute; /** * Extract route parameters from path */ private extractRouteParams; /** * Extract query parameters from URL */ private extractQueryParams; /** * Wrap component HTML with a layout */ private wrapWithLayout; /** * Generate a complete HTML document with SSR content */ generateDocument(content: string, title?: string, scripts?: string[], styles?: string[]): string; } //# sourceMappingURL=ssr-engine.d.ts.map