/** * This module defines a {@linkcode ComponentRegistry}, a mapping between Optimizely CMS content types and * frontend Components (React components, Vue components, etc.) * * To define the `ComponentRegistry`, developers can provide a {@linkcode ComponentMap} object or a * {@linkcode ComponentResolver} function * * @module */ /** * A component definition that includes a default component and optional * tagged variants */ type ComponentWithVariants = { /** Default component */ default?: C; /** * Tagged variants, where the keys are tag names and the values are the corresponding components. */ tags: Record; }; /** A component entry that can be a single component or a component with tagged variants */ type ComponentEntry = C | ComponentWithVariants; /** Optional arguments to resolve a component */ type ResolverOptions = { tag?: string; }; /** * A function that dynamically resolves components based on content type and options. * * This provides a flexible alternative to static component mappings, allowing you to * implement custom logic for component resolution, such as lazy loading, conditional * rendering, or dynamic imports. */ type ComponentResolver = (contentType: string, options?: ResolverOptions) => C | undefined; /** Object mapping a content type name to a {@linkcode ComponentEntry} */ type ComponentMap = Record>; /** * Defines the component resolver as a function {@linkcode ComponentResolver} * or as an object {@linkcode ComponentMap} */ export type ComponentResolverOrObject = ComponentResolver | ComponentMap; /** A registry mapping content type names and components */ export declare class ComponentRegistry { resolver: ComponentResolverOrObject; constructor(resolverOrObject: ComponentResolverOrObject); /** Returns the component given its content type name. Returns `undefined` if not found */ getComponent(contentType: string, options?: ResolverOptions): T | undefined; } export {};