UNPKG

web-signature

Version:

Primitive and fast framework for rendering web interfaces

56 lines (55 loc) 2.08 kB
import { ComponentConstructor } from "./Component.js"; type LibMeta = { name: string; version?: string; author?: string; components: string[]; dependencies: Record<string, LibMeta>; }; export default class Library { readonly name: string; readonly version?: string; readonly author?: string; libs: Record<string, LibMeta>; private components; /** * @param {string} name The name of the library. * @param {string} [author] Optional author of the library. * @param {string} [version] Optional version of the library. */ constructor(name: string, author?: string, version?: string); /** * Registers a component in the library. * @param {ComponentConstructor} component The component to register. * @param {string} [name] Optional name for the component. If not provided, uses the component's name property. */ add(component: ComponentConstructor, name?: string): void; /** * Registers a library. * @import {Library} from "./Library.js"; * @param {Library} library The library to register. * @param {string[]} exclude Optional array of component names to exclude from the library registration. */ register(library: Library, ...exclude: string[]): void; /** * Retrieves a component by its name. * @param {string} name The name of the component to retrieve. * @return {ComponentConstructor | undefined} The component associated with the name, or undefined if it does not exist. */ get(name: string): ComponentConstructor | undefined; /** * Returns a library. * @param {string} name The name of the library. * @return {LibMeta} */ lib(name: string): LibMeta | undefined; /** * Lists all registered components in the library. * @return {Array<{ component: ComponentConstructor, name: string }>} An array of objects containing component constructors and their names. */ list(): Array<{ component: ComponentConstructor; name: string; }>; } export { LibMeta };