import { WidgetType } from '@polymech/shared'; export interface WidgetMetadata
> {
id: WidgetType | (string & {});
name: string;
category: 'control' | 'display' | 'chart' | 'system' | 'custom' | string;
description: string;
icon?: React.ComponentType;
thumbnail?: string;
defaultProps?: P;
configSchema?: Record > {
component: React.ComponentType ;
previewComponent?: React.ComponentType ;
getNestedLayouts?: (props: P) => { id: string; label: string; layoutId: string }[];
}
class WidgetRegistry {
private widgets = new Map >(definition: WidgetDefinition ) {
if (this.widgets.has(definition.metadata.id)) {
// Allow overwriting for HMR/Dynamic loading, just log info if needed
// console.debug(`Updating existing widget registration: '${definition.metadata.id}'`);
}
this.widgets.set(definition.metadata.id, definition as WidgetDefinition