@ayanaware/bento
Version:
Modular runtime framework designed to solve complex tasks
208 lines (207 loc) • 7.06 kB
TypeScript
import { EntityManager } from './entities/EntityManager';
import { Component } from './entities/interfaces/Component';
import { Entity } from './entities/interfaces/Entity';
import { Plugin } from './entities/interfaces/Plugin';
import { ComponentReference } from './entities/types/ComponentReference';
import { EntityReference } from './entities/types/EntityReference';
import { PluginReference } from './entities/types/PluginReference';
import { BentoState } from './interfaces/BentoState';
import { EventEmitterLike } from './interfaces/EventEmitterLike';
import { PropertyManager } from './properties/PropertyManager';
import { InstanceType } from './types/InstanceType';
import { VariableManager } from './variables/VariableManager';
export interface BentoOptions {
eventEmitter?(): EventEmitterLike;
}
export declare class Bento {
readonly properties: PropertyManager;
readonly variables: VariableManager;
readonly entities: EntityManager;
readonly options: BentoOptions;
readonly version: string;
constructor(options?: BentoOptions);
/**
* Alias for Bento.entities.getEntity()
* @param reference EntityReference
*
* @see EntityManager#getEntity
* @returns See Bento.entities.getEntity()
*/
getEntity<T extends Entity>(reference: EntityReference<T>): T;
/**
* Alias for Bento.entities.addEntity()
* @param entity Entity
*
* @see EntityManager#addEntity
* @returns See Bento.entities.addEntity()
*/
addEntity(entity: Entity | InstanceType<Entity>): Promise<string>;
/**
* Alias for Bento.entities.replaceEntity()
* @param reference EntityReference
* @param entity Entity
*
* @see EntityManager#replaceEntity
* @returns See Bento.entities.replaceEntity()
*/
replaceEntity(reference: EntityReference, entity: Entity | InstanceType<Entity>): Promise<string>;
/**
* Alias for Bento.entities.removeEntity()
* @param reference EntityReference
*
* @see EntityManager#removeEntity
* @returns See Bento.entities.removeEntity()
*/
removeEntity(reference: EntityReference): Promise<Array<Entity>>;
/**
* Alias for Bento.entities.getPlugin()
* @param reference PluginReference
*
* @see EntityManager#getPlugin
* @returns {Plugin}
*/
getPlugin<T extends Plugin>(reference: PluginReference<T>): T;
/**
* Alias for Bento.entities.addPlugins()
* @param plugins Array of Plugins
*
* @see EntityManager#addPlugins
* @returns See Bento.entities.addPlugins()
*/
addPlugins(plugins: Array<Plugin | InstanceType<Plugin>>): Promise<Array<string>>;
/**
* Alias for Bento.entities.addPlugin()
* @param plugin Plugin
*
* @see EntityManager#addPlugin
* @returns See Bento.entities.addPlugin()
*/
addPlugin(plugin: Plugin | InstanceType<Plugin>): Promise<string>;
/**
*
* @param reference PluginReference
* @param plugin Plugin
*
* @see EntityManager#replacePlugin
* @returns See Bento.entities.replacePlugin()
*/
replacePlugin(reference: PluginReference, plugin: Plugin | InstanceType<Plugin>): Promise<string>;
/**
* Alias for Bento.entities.removePlugin()
* @param reference PluginReference
*
* @see EntityManager#removePlugin
* @returns See Bento.entities.removePlugin()
*/
removePlugin(reference: PluginReference): Promise<Array<Entity>>;
/**
* Alias for Bento.entities.getComponent()
* @param reference ComponentReference
*
* @see EntityManager#getComponent
* @returns See Bento.entities.getComponent()
*/
getComponent<T extends Component>(reference: ComponentReference<T>): T;
/**
* Alias for Bento.entities.addComponent()
* @param component Component
*
* @see EntityManager#addComponent
* @returns See Bento.entities.addComponent()
*/
addComponent(component: Component): Promise<string>;
/**
*
* @param reference ComponentReference
* @param component Plugin
*
* @see EntityManager#replaceComponent
* @returns See Bento.entities.replaceComponent()
*/
replaceComponent(reference: ComponentReference, component: Component | InstanceType<Component>): Promise<string>;
/**
* Alias for Bento.entities.removeComponent()
* @param reference ComponentReference
*
* @see EntityManager#removeComponent
*/
removeComponent(reference: ComponentReference): Promise<Array<Entity>>;
/**
* Alias for Bento.properties.hasProperty()
* @param name Property name
*
* @see PropertyManager#hasProperty
* @returns See Bento.properties.hasProperty()
*/
hasProperty(name: string): boolean;
/**
* Alias for Bento.properties.getProperty()
* @param name Property name
*
* @see PropertyManager#getProperty
* @returns See Bento.properties.getProperty()
*/
getProperty<T extends unknown>(name: string): T;
/**
* Alias for Bento.properties.setProperties()
* @param properties Object with property key: value pairs
*
* @see PropertyManager#setProperties
* @returns See Bento.properties.setProperties()
*/
setProperties(properties: {
[key: string]: any;
}): void;
/**
* Alias for Bento.properties.setProperty()
* @param name Property name
* @param value Property value
*
* @see PropertyManager#setProperty
* @returns See Bento.properties.setProperty()
*/
setProperty<T>(name: string, value: T): void;
/**
* Alias for Bento.variables.hasVariable()
* @param name Variable name
*
* @see VariableManager#hasVariable
* @returns See Bento.variables.hasVariable()
*/
hasVariable(name: string): boolean;
/**
* Alias for Bento.variables.getVariable()
* @param name Variable name
*
* @see VariableManager#getVariable
* @returns See Bento.variables.getVariable()
*/
getVariable<T extends unknown>(name: string): T;
/**
* Alias for Bento.variables.setVariable()
* @param name Variable name
* @param value Variable value
*
* @see VariableManager#setVariable
* @returns See Bento.variables.setVariable()
*/
setVariable<T>(name: string, value: T): void;
/**
* Alias for Bento.variables.deleteVariable()
* @param name Variable name
*
* @see VariableManager#deleteVariable
* @returns See Bento.variables.deleteVariable()
*/
deleteVariable(name: string): void;
/**
* Verifies the state of your Application, Will throw an error at anything
* "weird" looking. For example if any entities are pending.
*
* Also indirectly calls .onVerify() lifecycle event. Bento expects this to be called
* and may introduce a auto-kill in the future if it is not.
*
* @returns Application state Object
*/
verify(): Promise<BentoState>;
}