/** * Registry Utility * src/utils/Registry.ts * * This module provides a Registry function that allows for registering, * removing, checking, getting, and listing class constructors. * * It is designed to manage class extensions, ensuring that all registered * classes extend a specified base constructor. * * @module Utils * @name Registry * @author Paul Köhler (komed3) * @license MIT */ import type { RegistryConstructor, RegistryService } from './Types'; /** * Global registry object to hold multiple registries. * Each registry is keyed by a string identifier. * * @type {Record< string, RegistryService< any > >} */ export declare const registry: Record>; /** * Factory object to hold factory functions for creating instances. * This is used to create instances of registered classes. * * @type {Record< string, ( cls: string, ...args: any[] ) => InstanceType< any > >} */ export declare const factory: Record InstanceType>; /** * Registry function to create a service for managing class constructors. * * @template T - The basic type of all registry class constructors * @param {string} reg - The name of the registry * @param {RegistryConstructor< T >} ctor - The base constructor that all registered classes must extend * @returns {RegistryService< T >} - An object with methods to register, remove, check, get, and list classes * @throws {Error} - If the registry already exists (overwriting is forbidden) */ export declare function Registry(reg: string, ctor: RegistryConstructor): RegistryService; /** * Resolve a class constructor from a specific registry. * * @template T - Type of the registry class constructor * @param {string} reg - The name of the registry * @param {T | string} cls - The class itself or name of the class to resolve * @returns {T | undefined} - The class constructor if found, otherwise undefined * @throws {CmpStrNotFoundError} - If the registry or class does not exist */ export declare function resolveCls>(reg: string, cls: T | string): T; /** * Create an instance of a class from a specific registry. * * @template T - Type of the registry class constructor * @param {string} reg - The name of the registry * @param {T | string} cls - The class itself or name of the class to instantiate * @param {...any} args - Arguments to pass to the class constructor * @returns {T} - An instance of the class * @throws {CmpStrInternalError} - If instantiation fails due to an internal error */ export declare function createFromRegistry>(reg: string, cls: T | string, ...args: any[]): InstanceType;