/** Asset metadata for eagerly-loaded components (script/style paths). */ export interface ComponentDescriptor { component?: string; scripts?: string[]; styles?: string[]; modules?: (() => Promise)[]; mapping?: (config: unknown) => Record | undefined; renderer?: string; src?: string | string[]; [key: string]: unknown; } type ComponentDescriptorMap = Record; type LazyComponent = ((props: Record) => unknown) | (new (props: Record) => unknown); type LazyComponentMap = Record; declare class ComponentsRegistry { customComponentLazyMap: LazyComponentMap; componentMap: ComponentDescriptorMap; overrideMap: ComponentDescriptorMap; lazyMap: LazyComponentMap; constructor(); /** * Registers the component with core so that renderer can * get the right component while rendering. * * @param componentName Name of the component eq., Currency * @param component component object example * { * component: "Currency", * scripts: ["components/Currency/index.js"] * } * @example PCore.getComponentsRegistry().register(componentName, component) * PCore.getComponentsRegistry().register("Currency", { * component: "Currency", * scripts: ["components/Currency/index.js"] * }); * * @memberof ComponentsRegistry */ register(componentName: string, component: ComponentDescriptor): void; /** * Registers a React component in the lazy map so the renderer can * resolve it by name at render time. * * @param componentName - Name of the component, e.g. "Currency" * @param component - A React component (function, memo, forwardRef, or lazy) * @example * PCore.getComponentsRegistry().registerLazyMap('Currency', CurrencyComponent); * * @memberof ComponentsRegistry */ registerLazyMap(componentName: string, component: LazyComponent): void; /** * Registers a custom React component in the custom component lazy map. * * @param componentName - Name of the component, e.g. "MyCustomWidget" * @param component - A React component (function, memo, forwardRef, or lazy) * @example * PCore.getComponentsRegistry().registerCustomComponentLazyMap('MyWidget', MyWidgetComponent); * * @memberof ComponentsRegistry */ registerCustomComponentLazyMap(componentName: string, component: LazyComponent): void; /** * Gets the component object registered with core. * * @param componentName Name of the component eq., Currency * @example PCore.getComponentsRegistry().getComponent(componentName) * const component = PCore.getComponentsRegistry().getComponent("Currency"); * @returns component object example * { * component: "Currency", * scripts: ["components/Currency/index.js"] * } * @memberof ComponentsRegistry */ getComponent(componentName: string): ComponentDescriptor | undefined; /** * Gets the React component registered in the lazy map. * * @param componentName - Name of the component, e.g. "Currency" * @returns The React component, or undefined if not registered. * @example * const CurrencyComponent = PCore.getComponentsRegistry().getLazyComponent('Currency'); * * @memberof ComponentsRegistry */ getLazyComponent(componentName: string): LazyComponent | undefined; /** * Gets a custom React component registered in the custom component lazy map. * * @param componentName - Name of the component, e.g. "MyCustomWidget" * @returns The React component, or undefined if not registered. * @example * const MyWidget = PCore.getComponentsRegistry().getCustomComponent('MyWidget'); * * @memberof ComponentsRegistry */ getCustomComponent(componentName: string): LazyComponent | undefined; /** * Merges the componentMap to registry. * * @example PCore.getComponentsRegistry().mergeComponentsMap(componentsMap) * const component = PCore.getComponentsRegistry().mergeComponentsMap(reactComponentsMap); * @param componentsMap object which holds component definitions eq., * const reactComponentsMap = { * Renderer: { * renderer: "PegaReactRenderer", * scripts: ["renderer/react_renderer.js"] * }, * Currency: { * component: "Currency", * scripts: ["components/Currency/index.js"] * } * } * @memberof ComponentsRegistry */ mergeComponentsMap(componentsMap?: ComponentDescriptorMap): void; /** * Merges override map * @param overrideMap object that holds override map. * @memberof ComponentsRegistry */ mergeOverrideMap(overrideMap?: ComponentDescriptorMap): void; /** * returns override map * @memberof ComponentsRegistry */ getOverrideMap(): ComponentDescriptorMap; /** * returns Lazy map * @memberof ComponentsRegistry */ getLazyMap(): LazyComponentMap; } declare const _default: ComponentsRegistry; export default _default;