UNPKG

@copilotkit/a2ui-renderer

Version:

A2UI Renderer for CopilotKit - render A2UI surfaces in React applications

25 lines (23 loc) 1.07 kB
import { Catalog } from "@a2ui/web_core/v0_9"; //#region src/react-renderer/filter-catalog.ts /** * Rebuild a Catalog keeping only components whose `name` passes `predicate`. * * Pure: does not mutate the source catalog. The returned catalog preserves the * original `id`, all `functions`, and the `themeSchema`; only the component set * is narrowed. Used by react-core to enforce per-component enable/disable on * BOTH the advertisement path (context) and the render path. * * @typeParam T - The component implementation type carried by the catalog. * @param catalog - The source catalog. * @param predicate - Returns true to KEEP a component with the given name. */ function filterCatalog(catalog, predicate) { const keptComponents = []; for (const [name, component] of catalog.components) if (predicate(name)) keptComponents.push(component); const functions = Array.from(catalog.functions.values()); return new Catalog(catalog.id, keptComponents, functions, catalog.themeSchema); } //#endregion export { filterCatalog }; //# sourceMappingURL=filter-catalog.mjs.map