@copilotkit/a2ui-renderer
Version:
A2UI Renderer for CopilotKit - render A2UI surfaces in React applications
26 lines (24 loc) • 1.19 kB
JavaScript
const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
let _a2ui_web_core_v0_9 = require("@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 _a2ui_web_core_v0_9.Catalog(catalog.id, keptComponents, functions, catalog.themeSchema);
}
//#endregion
exports.filterCatalog = filterCatalog;
//# sourceMappingURL=filter-catalog.cjs.map