feat(components): add mergeComponents API to ComponentRegistry

Forgotten in the prior commit (case-mismatch on Windows tracked the wrong
filename). Adds the public method overlays use to splice extra components
into the picker after default-metadata load. Components with an existing
id are replaced; new ones are appended.
This commit is contained in:
David Montero Crespo 2026-05-05 10:34:43 -03:00
parent 8b14815094
commit 26e0c2be60
1 changed files with 17 additions and 0 deletions

View File

@ -176,6 +176,23 @@ export class ComponentRegistry {
return [...this.allComponents];
}
/**
* Merge additional components into the registry from an external source.
*
* Used by private overlays (e.g. the velxio.dev pro overlay) to add
* premium components after the default `/components-metadata.json` has
* loaded. Components with an existing `id` are replaced; new ones are
* appended. Categories and search index are rebuilt.
*/
mergeComponents(extras: ComponentMetadata[]): void {
if (!extras || extras.length === 0) return;
const byId = new Map(this.allComponents.map((c) => [c.id, c]));
for (const extra of extras) {
byId.set(extra.id, extra);
}
this.processMetadata(Array.from(byId.values()));
}
/**
* Get components by category
*/