web-signature
Version:
Primitive and fast framework for rendering web interfaces
60 lines (59 loc) • 2.26 kB
TypeScript
import { ComponentConstructor } from "./Component.js";
import Library, { LibMeta } from "./Library.js";
type ResolvedLib = {
components: string[];
dependencies: Record<string, ResolvedLib>;
};
export default class Signature {
private components;
private refs;
private libs;
private bank;
constructor();
/**
* Adds a component to the signature.
* @param {ComponentConstructor} component The component to add.
* @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 in the signature.
* @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;
/**
* Returns a library.
* @param {string} name The name of the library.
* @return {LibMeta}
*/
lib(name: string): LibMeta | undefined;
/**
* Returns a formatted object of all libraries in the signature.
* @return {Record<string, ResolvedLib>} A object of formatted libraries with their components and dependencies.
*/
libraries(): Record<string, ResolvedLib>;
/**
* Contacts the Component.onContact method through its reference.
* @param {string} name The name of the reference.
* @param {...any[]} props The properties to pass to the component's onContact method.
*/
contactWith(name: string, ...props: any[]): any;
/**
* Updates the reference.
* @param {string} name The name of the reference to update.
*/
updateRef(name: string): void;
/**
* Starts rendering in the specified area.
* @param {string} selector The selector of the element where the signature should be rendered.
* @param {() => void} [callback] Optional callback that will be called after rendering is complete.
*/
contact(selector: string, callback?: () => void): void;
private templateToString;
private fillTemplate;
private templateToElement;
private render;
}
export {};