UNPKG

@ayanaware/bento

Version:

Modular runtime framework designed to solve complex tasks

113 lines 3.39 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.getComponent = exports.getPlugin = exports.getEntity = exports.getEntityManager = exports.setVariable = exports.getVariable = exports.hasVariable = exports.getVariableManager = exports.setProperty = exports.getProperty = exports.hasProperty = exports.getPropertyManager = exports.getBento = exports.useBento = exports.getApplication = exports.useApplication = void 0; /** * Global Application Instance */ let application; /** * Define Application instance `getApplication()` returns * @param applicaton Application instance * @param force Force override. Only use if you know what you're doing. */ function useApplication(instance, force) { if (application && !force) throw new Error('Application instance already in use'); application = instance; } exports.useApplication = useApplication; function getApplication() { if (!application) throw new Error('Application instance not found.'); return application; } exports.getApplication = getApplication; /** * Global Bento Instance */ let bento; /** * Define Bento instance `getBento()` returns * * This function will mostly be called internally by Bento in it's constructor * * @param bento Bento instance * @param force Force override. Only use if you know what you're doing. */ function useBento(instance, force) { if (bento && !force) throw new Error('Bento instance already in use.'); bento = instance; } exports.useBento = useBento; /** * Bento Instance * @returns Bento */ function getBento() { if (!bento) throw new Error('Bento instance not found. Have you `new Bento();`?'); return bento; } exports.getBento = getBento; // PROPERTIES /** * Bento PropertyManager Instance */ function getPropertyManager() { return getBento().properties; } exports.getPropertyManager = getPropertyManager; function hasProperty(name) { return getPropertyManager().hasProperty(name); } exports.hasProperty = hasProperty; function getProperty(name) { return getPropertyManager().getProperty(name); } exports.getProperty = getProperty; function setProperty(name, value) { return getPropertyManager().setProperty(name, value); } exports.setProperty = setProperty; // VARIABLES /** * Bento VariableManager Instance */ function getVariableManager() { return getBento().variables; } exports.getVariableManager = getVariableManager; function hasVariable(name) { return getVariableManager().hasVariable(name); } exports.hasVariable = hasVariable; function getVariable(name, def) { return getVariableManager().getVariable(name, def); } exports.getVariable = getVariable; function setVariable(name, value) { return getVariableManager().setVariable(name, value); } exports.setVariable = setVariable; // ENTITIES /** * Bento EntityManager Instance */ function getEntityManager() { return getBento().entities; } exports.getEntityManager = getEntityManager; function getEntity(reference) { return getEntityManager().getEntity(reference); } exports.getEntity = getEntity; function getPlugin(reference) { return getEntityManager().getPlugin(reference); } exports.getPlugin = getPlugin; function getComponent(reference) { return getEntityManager().getComponent(reference); } exports.getComponent = getComponent; //# sourceMappingURL=Globals.js.map