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:
parent
8b14815094
commit
26e0c2be60
|
|
@ -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
|
||||
*/
|
||||
|
|
|
|||
Loading…
Reference in New Issue