@ayanaware/bento
Version:
Modular runtime framework designed to solve complex tasks
82 lines (81 loc) • 2.31 kB
TypeScript
import { PluginAPI } from '../../entities/api/PluginAPI';
import { Plugin } from '../../entities/interfaces/Plugin';
/**
* A Simple Bento Variable Loader. Automatically looks to the enviorment for values.
* If you `VariableLoader.addVariable('HELLO_WORLD')` this Plugin will automatically
* search `process.env.HELLO_WORLD`
*/
export declare class VariableLoader implements Plugin {
name: string;
api: PluginAPI;
/**
* Variables that this Loader is handling
*/
protected readonly variables: Set<string>;
/**
* Variable defaults if exist
*/
protected readonly defaults: Map<string, unknown>;
/**
* A cache of pending Variable Keys and Values
* The only purpose is a place to put values if we don't have Bento API access yet
*/
private readonly pending;
onLoad(): Promise<void>;
onUnload(): Promise<void>;
private handlePending;
/**
* Add multiple Variables
* @param kv String Array or Key/Value Object
*/
addVariables(kv: Array<string> | {
[key: string]: unknown;
}): void;
/**
* Add Variable
* @param key Key
* @param value Value
*/
addVariable<T = unknown>(key: string, value?: T): void;
/**
* Add multiple default values
* @param kv Key/Default Object
*/
addDefaults(kv: {
[key: string]: unknown;
}): void;
/**
* Add Default Value for Variable
* @param key Key
* @param def Default
*/
addDefault<T = unknown>(key: string, def: T): void;
/**
* Remove Variable
* @param key Key
*/
removeVariable(key: string): void;
/**
* Get variable value, from underlying eniroment
*
* Note: This function will look on `process.env` and `window`
* @param key Key
*/
protected getVariableValue(key: string): string;
/**
* Process Variable Key
* @param key Variable Key
*/
protected processVariable<T = unknown>(key: string, override?: T): void;
/**
* Load Variable into Bento
* @param key Key
* @param value Value
*/
protected loadVariable<T = unknown>(key: string, value: T): void;
/**
* Unload Variable from Bento
* @param key Key
*/
protected unloadVariable(key: string): void;
}