UNPKG

@ayanaware/bento

Version:

Modular runtime framework designed to solve complex tasks

91 lines (90 loc) 2.97 kB
import { PluginAPI } from '../../entities/api/PluginAPI'; import { Component } from '../../entities/interfaces/Component'; import { Entity, EntityType } from '../../entities/interfaces/Entity'; import { Plugin } from '../../entities/interfaces/Plugin'; import { InstanceType } from '../../types/InstanceType'; export declare class EntityLoader implements Plugin { name: string; api: PluginAPI; /** * Entities we manage */ protected entities: Set<string>; private readonly pending; onLoad(): Promise<void>; onUnload(): Promise<void>; protected handlePending(): Promise<void>; /** * Detects if a value is Entitylike * Entitylike values are not null objects or functions * * @param v Value * @returns boolean */ protected isEntitylike(v: unknown): boolean; /** * Detects if a value is Classlike. * Classlike values are functions that have a prototype object * * @param v Value * @returns boolean */ protected isClasslike(v: unknown): boolean; /** * Detects if a value is Functionlike * Functionlike values are functions that have no prototype object * * @param v Value * @returns boolean */ protected isFunctionlike(v: unknown): boolean; /** * Tries to find Entity and then instantiate it. An Entity can be a class or an object. * * @param entity Uninstantiated Entity * * @throws ProcessingError If no Entity found or fails to instantiate * @returns EntityInstance */ protected instantiate<T extends Entity = Entity>(entity: Entity | InstanceType<T>): T; /** * Bulk Instantiate Entities and add them to Bento * * @param entities Class or Object Array * @param type EntityType */ addEntities(entities: Array<Entity | InstanceType<Entity>>, type: EntityType): Promise<Array<void>>; /** * Instantiate Entity and add to Bento * * @param entity Class or Object * @param type EntityType */ addEntity(entity: Entity | InstanceType<Entity>, type: EntityType): Promise<void>; /** * Bulk Instantiate Plugins and add them to Bento * * @param plugins Class or Object Array */ addPlugins(plugins: Array<Plugin | InstanceType<Plugin>>): Promise<Array<void>>; /** * Instantiate Plugin and add to Bento * @param plugin Class or Object * * @returns Promise */ addPlugin(plugin: Plugin | InstanceType<Plugin>): Promise<void>; /** * Bulk Instantiate Components and add them to Bento * * @param components Class or Object Array */ addComponents(components: Array<Component | InstanceType<Component>>): Promise<Array<void>>; /** * Instantiate Component and add to Bento * @param component Class or Object * * @returns Promise */ addComponent(component: Component | InstanceType<Component>): Promise<void>; }