82 lines
2.3 KiB
TypeScript
82 lines
2.3 KiB
TypeScript
import { A2UIComponentProps, ComponentRegistration } from "../types.mjs";
|
|
import { ComponentType } from "react";
|
|
import { Types } from "@a2ui/lit/0.8";
|
|
|
|
//#region src/react-renderer/registry/ComponentRegistry.d.ts
|
|
/**
|
|
* Registry for A2UI components. Allows registration of custom components
|
|
* and supports lazy loading for code splitting.
|
|
*
|
|
* @example
|
|
* ```tsx
|
|
* const registry = new ComponentRegistry();
|
|
*
|
|
* // Register a component directly
|
|
* registry.register('Text', { component: Text });
|
|
*
|
|
* // Register with lazy loading
|
|
* registry.register('Modal', {
|
|
* component: () => import('./components/Modal'),
|
|
* lazy: true
|
|
* });
|
|
*
|
|
* // Use with A2UIRenderer
|
|
* <A2UIRenderer surfaceId="main" registry={registry} />
|
|
* ```
|
|
*/
|
|
declare class ComponentRegistry {
|
|
private static _instance;
|
|
private registry;
|
|
private lazyCache;
|
|
/**
|
|
* Get the singleton instance of the registry.
|
|
* Use this for the default global registry.
|
|
*/
|
|
static getInstance(): ComponentRegistry;
|
|
/**
|
|
* Reset the singleton instance.
|
|
* Useful for testing.
|
|
*/
|
|
static resetInstance(): void;
|
|
/**
|
|
* Register a component type.
|
|
*
|
|
* @param type - The A2UI component type name (e.g., 'Text', 'Button')
|
|
* @param registration - The component registration
|
|
*/
|
|
register<T extends Types.AnyComponentNode>(type: string, registration: ComponentRegistration<T>): void;
|
|
/**
|
|
* Unregister a component type.
|
|
*
|
|
* @param type - The component type to unregister
|
|
*/
|
|
unregister(type: string): void;
|
|
/**
|
|
* Check if a component type is registered.
|
|
*
|
|
* @param type - The component type to check
|
|
* @returns True if the component is registered
|
|
*/
|
|
has(type: string): boolean;
|
|
/**
|
|
* Get a component by type. If the component is registered with lazy loading,
|
|
* returns a React.lazy wrapped component.
|
|
*
|
|
* @param type - The component type to get
|
|
* @returns The React component, or null if not found
|
|
*/
|
|
get(type: string): ComponentType<A2UIComponentProps> | null;
|
|
/**
|
|
* Get all registered component types.
|
|
*
|
|
* @returns Array of registered type names
|
|
*/
|
|
getRegisteredTypes(): string[];
|
|
/**
|
|
* Clear all registrations.
|
|
*/
|
|
clear(): void;
|
|
}
|
|
//#endregion
|
|
export { ComponentRegistry };
|
|
//# sourceMappingURL=ComponentRegistry.d.mts.map
|