/** * Turns a piece of CMS content into everything a framework needs to render it: * which component to use, with which props, and which preview attributes belong * on a wrapper. * * Pure — no framework, no DOM. * * @module */ import type { ExperienceCompositionNode, PreviewContext } from '../../infer.js'; import { type ResolveComponentOptions } from './registry.js'; /** Content data from the CMS, as the render layer reads it. */ export type OptimizelyContent = { /** Content type name */ __typename: string; /** Display template tag (if any) */ __tag?: string; displayTemplateKey?: string | null; /** Preview context */ __context?: PreviewContext; __composition?: ExperienceCompositionNode; composition?: ExperienceCompositionNode; /** metadata */ _metadata?: { types?: string[]; displayOption?: string | null; }; }; export type ResolvedContentComponent = { /** The component to render, or `undefined` when nothing is registered for it. */ component: C | undefined; /** The content type the lookup finally matched, for the fallback message. */ typename: string | undefined; /** The tag the lookup used. */ tag: string | undefined; /** The content to hand the component, with {@linkcode OptimizelyContent.__tag} applied. */ contentProps: Record; /** Caller props, minus the preview attributes. */ componentProps: Record; /** `data-epi-*` props, or `undefined` when there are none. Always `undefined` outside edit mode. */ previewAttrs: Record | undefined; }; /** * Resolves the tag to use for component lookup. * Checks tag override first, then falls back to content.__tag or display template tag. */ export declare function resolveTag(content: OptimizelyContent, componentTag?: string): string | undefined; /** Splits caller props into preview attributes and everything else. */ export declare function splitPreviewAttrs(props: Record, isEditMode: boolean): { previewAttrs: Record | undefined; componentProps: Record; }; /** * Resolves the component and props for one piece of content. * * @param content Content read from the CMS. * @param options.tag Manual tag override, taking priority over the content's own. * @param options.props Extra props from the caller. `data-epi-*` entries are separated out. * @param options.registry Looked up instead of the global registries. */ export declare function resolveContentComponent(content: OptimizelyContent, options?: ResolveComponentOptions & { props?: Record; }): ResolvedContentComponent;