import type { BaseIntegrationContext, ComponentRenderInput, ComponentRenderResult, EcoComponent, PageMetadataProps } from '../../../types/public-types.js'; import type { ProcessedAsset } from '../../../services/assets/asset-processing-service/index.js'; import { HtmlTransformerService, type HtmlDocumentContribution } from '../../../services/html/html-transformer.service.js'; export type DocumentShellLayoutInput = { component: EcoComponent; props?: Record; }; export type DocumentShellComposeChildrenContext = { primaryComponent: EcoComponent; primaryProps: Record; primaryRender?: ComponentRenderResult; layouts: DocumentShellLayoutInput[]; rendererCache: BaseIntegrationContext['rendererCache']; renderComponentWithForeignChildren: DocumentShellRenderDependencies['renderComponentWithForeignChildren']; }; export type DocumentShellComposeChildrenResult = { /** Serialized or element children passed to the HTML template shell. */ children: unknown; layoutRenders: ComponentRenderResult[]; /** * Primary/page render assets when the hook performs unified composition. * * @remarks * Omit only when the default sequential string path runs (core renders primary first). */ primaryRender?: ComponentRenderResult; }; /** * Optional hook that replaces default sequential string layout wrapping. * * @remarks * When provided, core skips the initial primary render and expects the hook to return * `children` for the HTML template. Supply `primaryRender` so dependency assets still merge. */ export type DocumentShellComposeChildrenHook = (context: DocumentShellComposeChildrenContext) => Promise; export type DocumentShellComposeInput = { primaryComponent: EcoComponent; primaryProps: Record; layout?: DocumentShellLayoutInput; layouts?: DocumentShellLayoutInput[]; composeChildren?: DocumentShellComposeChildrenHook; htmlTemplate: EcoComponent; documentProps: Record; }; export type DocumentShellPageRenderInput = { page: { component: EcoComponent; props: Record; }; layout?: DocumentShellLayoutInput; layouts?: DocumentShellLayoutInput[]; composeChildren?: DocumentShellComposeChildrenHook; htmlTemplate: EcoComponent; metadata: PageMetadataProps; pageProps: Record; documentProps?: Record; transformDocumentHtml?: (html: string) => string; }; export type DocumentShellRenderDependencies = { renderComponentWithForeignChildren(input: ComponentRenderInput): Promise; appendProcessedDependencies(...assetGroups: Array): ProcessedAsset[]; }; export type DocumentShellAttributeStamping = { applyAttributesToFirstBodyElement(html: string, attributes: Record): string; applyAttributesToHtmlElement(html: string, attributes: Record): string; }; /** * Default sequential string-child composition for document shell layers. */ export declare function composeSequentialLayoutChildren(context: DocumentShellComposeChildrenContext): Promise; /** * Composes page or view content through optional layout and document shells. * * One execution-scoped renderer cache is threaded through every shell layer so * repeated foreign delegation reuses initialized renderers within one render pass. */ export declare function composeDocumentShell(dependencies: DocumentShellRenderDependencies, input: DocumentShellComposeInput): Promise<{ documentHtml: string; }>; /** * Applies optional component-root and document-root attribute stamping before HTML * transformation runs on explicit renderer-owned paths. */ export declare function applyDocumentShellAttributeStamping(html: string, stamping: DocumentShellAttributeStamping, options: { componentRootAttributes?: Record; documentAttributes?: Record; }): string; /** * Builds the final serialized document HTML for one route page render. */ export declare function renderPageDocumentShell(dependencies: DocumentShellRenderDependencies, input: DocumentShellPageRenderInput, docType: string): Promise; /** * Finalizes already-resolved HTML for explicit renderer-owned paths. * * @remarks * Callers append renderer bootstrap dependencies before invoking this helper. * Stamps document/root attributes and runs HTML transformation after nested * foreign-subtree resolution without routing back through shared route execution. */ export declare function finalizeDocumentShellHtml(htmlTransformer: HtmlTransformerService, options: { html: string; partial?: boolean; componentRootAttributes?: Record; documentAttributes?: Record; transformHtml?: boolean; htmlContributions?: HtmlDocumentContribution[]; }): Promise;