import type { ProcessedAsset } from '../../../services/assets/asset-processing-service/index.js'; import type { BaseIntegrationContext, ComponentRenderInput, ComponentRenderResult, EcoComponent, ForeignSubtreeRenderPayload } from '../../../types/public-types.js'; import { type ForeignChildRuntime } from './component-render-context.js'; export type QueuedForeignChildDecisionInput = { currentIntegration: string; targetIntegration?: string; component: EcoComponent; props: Record; }; export type QueuedForeignSubtreeResolution = { token: string; component: EcoComponent; props: Record; componentInstanceId: string; }; /** * Shared mutable state for one renderer-owned queued foreign-subtree runtime. */ export type QueuedForeignSubtreeResolutionContext = { rendererCache: Map; componentInstanceScope?: string; nextForeignSubtreeId: number; queuedResolutions: QueuedForeignSubtreeResolution[]; }; type QueuedForeignSubtreeIntegrationContext = BaseIntegrationContext & Record; type QueuedForeignSubtreeChildRenderResult = { assets: ProcessedAsset[]; html?: string; children?: unknown; }; export interface ForeignSubtreeExecutionOwningRenderer { readonly name: string; renderComponentWithForeignChildren(input: ComponentRenderInput): Promise; } export interface ForeignSubtreeExecutionDecisionInput { currentIntegration: string; targetIntegration?: string; } export interface ForeignSubtreeExecutionRenderOptions { currentIntegrationName: string; input: ComponentRenderInput; renderComponent(input: ComponentRenderInput): Promise; normalizeComponentRenderOutput(result: ComponentRenderResult): ComponentRenderResult; hasForeignChildDescendants(component: EcoComponent): boolean; createForeignChildRuntime(options: { renderInput: ComponentRenderInput; rendererCache: Map; }): ForeignChildRuntime; getOwningRenderer(integrationName: string, rendererCache: Map): Promise; } export interface ForeignSubtreeQueuedRuntimeOptions { renderInput: ComponentRenderInput; rendererCache: Map; runtimeContextKey: string; tokenPrefix: string; createRuntimeContext?: (integrationContext: BaseIntegrationContext & Record, rendererCache: Map) => TContext; } export interface ForeignSubtreeStringQueuedHtmlOptions { currentIntegrationName: string; renderInput: ComponentRenderInput; html: string; runtimeContextKey: string; queueLabel: string; getOwningRenderer(integrationName: string, rendererCache: Map): Promise; applyAttributesToFirstElement(html: string, attributes: Record): string; dedupeProcessedAssets(assets: ProcessedAsset[]): ProcessedAsset[]; } export interface ForeignSubtreeQueuedHtmlOptions { currentIntegrationName: string; html: string; runtimeContext?: TContext; queueLabel: string; renderQueuedChildren(children: unknown, runtimeContext: TContext, queuedResolutionsByToken: Map, resolveToken: (token: string) => Promise): Promise<{ assets: ProcessedAsset[]; children?: unknown; html?: string; }>; getOwningRenderer(integrationName: string, rendererCache: Map): Promise; applyAttributesToFirstElement(html: string, attributes: Record): string; dedupeProcessedAssets(assets: ProcessedAsset[]): ProcessedAsset[]; } export interface ResolveQueuedForeignSubtreeTokensOptions { html: string; runtimeContext?: TContext; queueLabel: string; renderQueuedChildren: (children: unknown, runtimeContext: TContext, queuedResolutionsByToken: Map, resolveToken: (token: string) => Promise) => Promise; resolveForeignSubtree: (input: ComponentRenderInput, rendererCache: Map) => Promise; applyAttributesToFirstElement: (html: string, attributes: Record) => string; dedupeProcessedAssets: (assets: ProcessedAsset[]) => ProcessedAsset[]; } /** * Maps one component render result into the foreign-subtree payload shape used by * queue resolution and integration tests. */ export declare function toForeignSubtreeRenderPayload(result: ComponentRenderResult): ForeignSubtreeRenderPayload; /** * Executes one component render tree under Foreign Child support. * * This service owns mixed-integration execution policy and the queued token * mechanics renderers use when foreign children cannot resolve inline. */ export declare class ForeignSubtreeExecutionService { private requiresForeignChildRuntime; shouldDelegateForeignChild(input: ForeignSubtreeExecutionDecisionInput): boolean; createFailFastRuntime(rendererName: string): ForeignChildRuntime; getQueuedRuntimeContext(input: ComponentRenderInput, runtimeContextKey: string): TContext | undefined; createQueuedRuntime(options: ForeignSubtreeQueuedRuntimeOptions): ForeignChildRuntime; createQueueRuntime(options: { renderInput: ComponentRenderInput; rendererCache: Map; runtimeContextKey: string; tokenPrefix: string; shouldQueueForeignChild: (input: QueuedForeignChildDecisionInput) => boolean; createRuntimeContext?: (integrationContext: QueuedForeignSubtreeIntegrationContext, rendererCache: Map) => TContext; }): ForeignChildRuntime; getRuntimeContext(input: ComponentRenderInput, runtimeContextKey: string): TContext | undefined; resolveStringQueuedHtml(options: ForeignSubtreeStringQueuedHtmlOptions): Promise<{ assets: ProcessedAsset[]; html: string; }>; resolveQueuedHtml(options: ForeignSubtreeQueuedHtmlOptions): Promise<{ assets: ProcessedAsset[]; html: string; }>; resolveQueuedForeignSubtreeTokens(options: ResolveQueuedForeignSubtreeTokensOptions): Promise<{ assets: ProcessedAsset[]; html: string; }>; executeComponentRender(options: ForeignSubtreeExecutionRenderOptions): Promise; private getRendererCache; private withRendererCache; private getForeignOwnerIntegrationName; private resolveForeignChildInOwningRenderer; private resolveForeignSubtreeInOwningRenderer; private runInForeignOwningRenderer; resolveQueuedTokens(html: string, queuedResolutionsByToken: Map, resolveToken: (token: string) => Promise): Promise; private createForeignSubtreeToken; private ensureRuntimeContext; } export {};