@ayana/bento
Advanced tools
Comparing version 1.0.0-beta.6 to 1.0.0-beta.7
import { Bento } from '../Bento'; | ||
import { Component } from '../components'; | ||
import { Plugin } from '../plugins'; | ||
import { ComponentReference, PluginReference } from '../references'; | ||
import { VariableDefinition } from '../variables'; | ||
import { Component } from '../components'; | ||
import { Plugin } from '../plugins'; | ||
/** | ||
@@ -7,0 +7,0 @@ * Shared functions for ComponentAPI and PluginAPI |
@@ -1,8 +0,8 @@ | ||
import { PropertyManager } from './properties/internal'; | ||
import { VariableManager } from './variables/internal'; | ||
import { Plugin } from './plugins'; | ||
import { PluginManager } from './plugins/internal'; | ||
import { Component } from './components'; | ||
import { ComponentManager } from './components/internal'; | ||
import { BentoState, EventEmitterLike } from './interfaces'; | ||
import { Plugin } from './plugins'; | ||
import { PluginManager } from './plugins/internal'; | ||
import { PropertyManager } from './properties/internal'; | ||
import { VariableManager } from './variables/internal'; | ||
export interface BentoOptions { | ||
@@ -59,3 +59,3 @@ createID?(len?: number): string; | ||
*/ | ||
addPlugins(plugins: Plugin[]): Promise<string[]>; | ||
addPlugins(plugins: Array<Plugin>): Promise<string[]>; | ||
/** | ||
@@ -62,0 +62,0 @@ * Alias for Bento.properties.hasProperty() |
@@ -5,7 +5,7 @@ 'use strict'; | ||
const errors_1 = require("@ayana/errors"); | ||
const internal_1 = require("./properties/internal"); | ||
const internal_2 = require("./variables/internal"); | ||
const internal_3 = require("./plugins/internal"); | ||
const internal_4 = require("./components/internal"); | ||
const internal_1 = require("./components/internal"); | ||
const internal_2 = require("./plugins/internal"); | ||
const internal_3 = require("./properties/internal"); | ||
const util_1 = require("./util"); | ||
const internal_4 = require("./variables/internal"); | ||
class Bento { | ||
@@ -20,6 +20,6 @@ constructor(options) { | ||
// now that options has been defined, create our managers | ||
this.properties = new internal_1.PropertyManager(this); | ||
this.variables = new internal_2.VariableManager(this); | ||
this.plugins = new internal_3.PluginManager(this); | ||
this.components = new internal_4.ComponentManager(this); | ||
this.properties = new internal_3.PropertyManager(this); | ||
this.variables = new internal_4.VariableManager(this); | ||
this.plugins = new internal_2.PluginManager(this); | ||
this.components = new internal_1.ComponentManager(this); | ||
} | ||
@@ -98,3 +98,3 @@ // COMPONENTS Aliases | ||
setProperty(name, value) { | ||
return this.properties.setProperty(name, value); | ||
this.properties.setProperty(name, value); | ||
} | ||
@@ -119,3 +119,3 @@ /** | ||
setProperties(properties) { | ||
return this.properties.setProperties(properties); | ||
this.properties.setProperties(properties); | ||
} | ||
@@ -152,3 +152,3 @@ // VARIABLES Aliases | ||
setVariable(name, value) { | ||
return this.variables.setVariable(name, value); | ||
this.variables.setVariable(name, value); | ||
} | ||
@@ -163,3 +163,3 @@ /** | ||
deleteVariable(name) { | ||
return this.variables.deleteVariable(name); | ||
this.variables.deleteVariable(name); | ||
} | ||
@@ -166,0 +166,0 @@ /** |
@@ -0,7 +1,7 @@ | ||
import { SharedAPI } from '../abstractions'; | ||
import { Bento } from '../Bento'; | ||
import { SharedAPI } from '../abstractions'; | ||
import { Component } from './interfaces'; | ||
import { EventEmitterLike } from '../interfaces'; | ||
import { ComponentReference, PluginReference } from '../references'; | ||
import { EventEmitterLike } from '../interfaces'; | ||
import { VariableDefinition } from '../variables'; | ||
import { Component } from './interfaces'; | ||
/** | ||
@@ -54,3 +54,3 @@ * The gateway of a component to the rest of the application. | ||
*/ | ||
emit(eventName: string, ...args: any[]): Promise<void>; | ||
emit(eventName: string, ...args: Array<any>): Promise<void>; | ||
/** | ||
@@ -61,3 +61,3 @@ * Emit subject event on Component Events | ||
*/ | ||
emitSubject(eventName: string, ...args: any[]): Promise<void>; | ||
emitSubject(eventName: string, ...args: Array<any>): Promise<void>; | ||
/** | ||
@@ -72,3 +72,3 @@ * Re-emits events from a standard event emitter into component events. | ||
*/ | ||
forwardEvents(fromEmitter: EventEmitterLike, events: string[]): void; | ||
forwardEvents(fromEmitter: EventEmitterLike, events: Array<string>): void; | ||
/** | ||
@@ -83,3 +83,3 @@ * Subscribe to a Component event | ||
*/ | ||
subscribe(reference: ComponentReference, name: string, handler: (...args: any[]) => void, context?: any): number; | ||
subscribe(reference: ComponentReference, name: string, handler: (...args: Array<any>) => void, context?: any): number; | ||
/** | ||
@@ -96,3 +96,3 @@ * Alias for subscribe with normal event | ||
*/ | ||
subscribeEvent(reference: ComponentReference, eventName: string, handler: (...args: any[]) => void, context?: any): number; | ||
subscribeEvent(reference: ComponentReference, eventName: string, handler: (...args: Array<any>) => void, context?: any): number; | ||
/** | ||
@@ -99,0 +99,0 @@ * Ubsubscribe from a Component Event |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const errors_1 = require("@ayana/errors"); | ||
const logger_api_1 = require("@ayana/logger-api"); | ||
const abstractions_1 = require("../abstractions"); | ||
const logger_api_1 = require("@ayana/logger-api"); | ||
/** | ||
@@ -35,3 +35,3 @@ * Logger instance for the ComponentAPI class | ||
throw new errors_1.IllegalStateError(`Component already has property "${injectName}" defined.`); | ||
if (this.hasComponent(reference) === false) | ||
if (!this.hasComponent(reference)) | ||
throw new errors_1.IllegalStateError('Unable to inject non-existent component'); | ||
@@ -77,3 +77,3 @@ Object.defineProperty(this.component, injectName, { | ||
throw new errors_1.IllegalStateError(`Component already has property "${injectName}" defined.`); | ||
if (this.hasPlugin(reference) === false) | ||
if (!this.hasPlugin(reference)) | ||
throw new errors_1.IllegalStateError('Unable to inject non-existent plugin'); | ||
@@ -80,0 +80,0 @@ Object.defineProperty(this.component, injectName, { |
@@ -0,3 +1,3 @@ | ||
import { ComponentReference, PluginReference } from '../../references'; | ||
import { ComponentAPI } from '../ComponentAPI'; | ||
import { ComponentReference, PluginReference } from '../../references'; | ||
export interface Component { | ||
@@ -4,0 +4,0 @@ api?: ComponentAPI; |
@@ -9,7 +9,7 @@ import { BentoOptions } from '../../Bento'; | ||
private readonly name; | ||
private emitter; | ||
private subject; | ||
private readonly emitter; | ||
private readonly subject; | ||
private subCount; | ||
private subscriptions; | ||
private options; | ||
private readonly subscriptions; | ||
private readonly options; | ||
constructor(name: string, options: BentoOptions); | ||
@@ -16,0 +16,0 @@ /** |
@@ -44,3 +44,3 @@ "use strict"; | ||
if (context) | ||
handler = (...args) => handler.apply(context, args); | ||
handler = handler.bind(context); | ||
// if there is subject data for this event, call now | ||
@@ -47,0 +47,0 @@ if (this.subject.has(name)) { |
import { Bento } from '../../Bento'; | ||
import { ComponentReference } from '../../references'; | ||
import { Component } from '../interfaces'; | ||
import { ComponentEvents } from './ComponentEvents'; | ||
import { ComponentReference } from '../../references'; | ||
export interface PendingComponentInfo { | ||
@@ -6,0 +6,0 @@ name: string; |
'use strict'; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const errors_1 = require("@ayana/errors"); | ||
const internal_1 = require("../../decorators/internal"); | ||
const errors_2 = require("../../errors"); | ||
const internal_2 = require("../../plugins/internal"); | ||
const internal_3 = require("../../references/internal"); | ||
const ComponentAPI_1 = require("../ComponentAPI"); | ||
const ComponentEvents_1 = require("./ComponentEvents"); | ||
const internal_1 = require("../../decorators/internal"); | ||
const internal_2 = require("../../references/internal"); | ||
const internal_3 = require("../../plugins/internal"); | ||
class ComponentManager { | ||
constructor(bento) { | ||
this.references = new internal_2.ReferenceManager(); | ||
this.references = new internal_3.ReferenceManager(); | ||
this.components = new Map(); | ||
@@ -197,3 +197,3 @@ this.pending = new Map(); | ||
// onPreComponentUnload | ||
await this.bento.plugins.__handlePluginHook(internal_3.PluginHook.onPreComponentUnload, component); | ||
await this.bento.plugins.__handlePluginHook(internal_2.PluginHook.onPreComponentUnload, component); | ||
// call unMount | ||
@@ -231,3 +231,3 @@ if (component.onUnload) { | ||
// onPostComponentUnload | ||
await this.bento.plugins.__handlePluginHook(internal_3.PluginHook.onPostComponentUnload, component); | ||
await this.bento.plugins.__handlePluginHook(internal_2.PluginHook.onPostComponentUnload, component); | ||
} | ||
@@ -311,3 +311,3 @@ /** | ||
// onPreComponentLoad | ||
await this.bento.plugins.__handlePluginHook(internal_3.PluginHook.onPreComponentLoad, component); | ||
await this.bento.plugins.__handlePluginHook(internal_2.PluginHook.onPreComponentLoad, component); | ||
// Call onLoad if present | ||
@@ -335,3 +335,3 @@ if (component.onLoad) { | ||
// onPostComponentLoad | ||
await this.bento.plugins.__handlePluginHook(internal_3.PluginHook.onPostComponentLoad, component); | ||
await this.bento.plugins.__handlePluginHook(internal_2.PluginHook.onPostComponentLoad, component); | ||
} | ||
@@ -338,0 +338,0 @@ async handlePendingComponents() { |
@@ -37,3 +37,3 @@ 'use strict'; | ||
} | ||
return Inject(internal_1.DecoratorSymbols.parent)(target, propertyKey); | ||
Inject(internal_1.DecoratorSymbols.parent)(target, propertyKey); | ||
}; | ||
@@ -40,0 +40,0 @@ } |
@@ -14,3 +14,3 @@ import { Component, ComponentAPI } from '../../components'; | ||
*/ | ||
static getSubscriptions(component: Component): DecoratorSubscription[]; | ||
static getSubscriptions(component: Component): Array<DecoratorSubscription>; | ||
/** | ||
@@ -30,5 +30,5 @@ * Handles all decorator subscriptions of a component | ||
*/ | ||
static getInjections(component: Component): DecoratorInjection[]; | ||
static getSymbolInjections(component: Component): DecoratorSymbolInjection[]; | ||
static getComponentInjections(component: Component): DecoratorComponentInjection[]; | ||
static getInjections(component: Component): Array<DecoratorInjection>; | ||
static getSymbolInjections(component: Component): Array<DecoratorSymbolInjection>; | ||
static getComponentInjections(component: Component): Array<DecoratorComponentInjection>; | ||
/** | ||
@@ -35,0 +35,0 @@ * Handles all decorator injections of a component |
@@ -58,6 +58,6 @@ 'use strict'; | ||
static getSymbolInjections(component) { | ||
return this.getInjections(component).filter(i => typeof i === 'symbol'); | ||
return DecoratorConsumer.getInjections(component).filter(i => typeof i === 'symbol'); | ||
} | ||
static getComponentInjections(component) { | ||
return this.getInjections(component).filter(i => typeof i !== 'symbol'); | ||
return DecoratorConsumer.getInjections(component).filter(i => typeof i !== 'symbol'); | ||
} | ||
@@ -71,3 +71,3 @@ /** | ||
static handleInjections(component, api) { | ||
for (const injection of this.getInjections(component)) { | ||
for (const injection of DecoratorConsumer.getInjections(component)) { | ||
if (injection.symbol != null) { | ||
@@ -74,0 +74,0 @@ // Handle parent injection |
export interface DecoratorSubscription { | ||
namespace: string | Function; | ||
name: string; | ||
handler: (...args: any[]) => void; | ||
handler: (...args: Array<any>) => void; | ||
} |
export interface EventEmitterLike { | ||
emit(event: string | symbol, ...args: any[]): boolean | void; | ||
addListener(event: string | symbol, listener: (...args: any[]) => void): EventEmitterLike | any; | ||
removeListener(event: string | symbol, listener: (...args: any[]) => void): EventEmitterLike | any; | ||
emit(event: string | symbol, ...args: Array<any>): boolean | void; | ||
addListener(event: string | symbol, listener: (...args: Array<any>) => void): EventEmitterLike | any; | ||
removeListener(event: string | symbol, listener: (...args: Array<any>) => void): EventEmitterLike | any; | ||
} |
@@ -0,3 +1,3 @@ | ||
import { Component } from '../../components'; | ||
import { PluginAPI } from '../PluginAPI'; | ||
import { Component } from '../../components'; | ||
export interface Plugin { | ||
@@ -4,0 +4,0 @@ api?: PluginAPI; |
import { Bento } from '../../Bento'; | ||
import { PluginReference } from '../../references'; | ||
import { Plugin } from '../interfaces'; | ||
import { PluginReference } from '../../references'; | ||
export declare enum PluginHook { | ||
@@ -63,3 +63,3 @@ onPreComponentLoad = "onPreComponentLoad", | ||
*/ | ||
addPlugins(plugins: Plugin[]): Promise<string[]>; | ||
addPlugins(plugins: Array<Plugin>): Promise<string[]>; | ||
private loadPlugin; | ||
@@ -66,0 +66,0 @@ /** |
@@ -0,3 +1,3 @@ | ||
import { SharedAPI } from '../abstractions'; | ||
import { Bento } from '../Bento'; | ||
import { SharedAPI } from '../abstractions'; | ||
import { Plugin } from './interfaces'; | ||
@@ -4,0 +4,0 @@ export declare class PluginAPI extends SharedAPI { |
@@ -7,3 +7,3 @@ /// <reference types="node" /> | ||
name: string; | ||
private files; | ||
private readonly files; | ||
onLoad(): Promise<void>; | ||
@@ -15,3 +15,3 @@ /** | ||
addFile(...file: Array<string>): void; | ||
removeFile(...file: string[]): void; | ||
removeFile(...file: Array<string>): void; | ||
getFileContents(file: string): Promise<Buffer>; | ||
@@ -18,0 +18,0 @@ parseFileDefinitions(data: Buffer): Promise<{ |
@@ -10,3 +10,3 @@ import { PluginAPI } from '../../PluginAPI'; | ||
name: string; | ||
private definitions; | ||
private readonly definitions; | ||
onLoad(): Promise<void>; | ||
@@ -31,5 +31,5 @@ onUnload(): Promise<void>; | ||
*/ | ||
addDefinitions(definitions: ConfigLoaderDefinition[]): Promise<void>; | ||
addDefinitions(definitions: Array<ConfigLoaderDefinition>): Promise<void>; | ||
reloadValues(): Promise<void>; | ||
private getValue; | ||
} |
@@ -17,3 +17,3 @@ import { Component } from '../../../components'; | ||
*/ | ||
abstract loadComponents(...args: any[]): Promise<void>; | ||
abstract loadComponents(...args: Array<any>): Promise<void>; | ||
/** | ||
@@ -20,0 +20,0 @@ * Detects if a value is component-like. |
import { ComponentLoader } from './ComponentLoader'; | ||
export declare class FSComponentLoader extends ComponentLoader { | ||
name: string; | ||
private directories; | ||
private components; | ||
private readonly directories; | ||
private readonly components; | ||
private pending; | ||
@@ -12,3 +12,3 @@ onLoad(): Promise<void>; | ||
*/ | ||
addDirectories(directories: string[]): Promise<void>; | ||
addDirectories(directories: Array<string>): Promise<void>; | ||
/** | ||
@@ -18,4 +18,4 @@ * Add and load all component like files and directories in given directory | ||
*/ | ||
addDirectory(...directory: string[]): Promise<void>; | ||
removeDirectory(...directory: string[]): Promise<void>; | ||
addDirectory(...directory: Array<string>): Promise<void>; | ||
removeDirectory(...directory: Array<string>): Promise<void>; | ||
/** | ||
@@ -27,3 +27,3 @@ * Should only ever be called by internally by bento | ||
*/ | ||
loadComponents(...directory: string[]): Promise<void>; | ||
loadComponents(...directory: Array<string>): Promise<void>; | ||
private createInstance; | ||
@@ -30,0 +30,0 @@ /** |
@@ -7,4 +7,4 @@ 'use strict'; | ||
const errors_1 = require("@ayana/errors"); | ||
const errors_2 = require("../../../errors"); | ||
const ComponentLoader_1 = require("./ComponentLoader"); | ||
const errors_2 = require("../../../errors"); | ||
/** | ||
@@ -176,3 +176,3 @@ * @ignore | ||
for (let i = 0; i < stats.length; i++) { | ||
contents[i].type = stats[i].isDirectory() === true ? 'DIRECTORY' : 'FILE'; | ||
contents[i].type = stats[i].isDirectory() ? 'DIRECTORY' : 'FILE'; | ||
} | ||
@@ -179,0 +179,0 @@ return contents; |
@@ -9,3 +9,3 @@ import { AyanaError } from '@ayana/errors'; | ||
export declare class LiteEmitter { | ||
private handlers; | ||
private readonly handlers; | ||
/** | ||
@@ -12,0 +12,0 @@ * Add a handler function for a given event |
@@ -9,6 +9,6 @@ import { ConfigDefinition, ConfigDefinitionType } from '../interfaces'; | ||
export declare class ConfigBuilder { | ||
private definitions; | ||
private readonly definitions; | ||
add(name: string, item: ConfigBuilderDefinition): this; | ||
delete(name: string): this; | ||
build(): ConfigDefinition[]; | ||
build(): Array<ConfigDefinition>; | ||
} |
@@ -23,3 +23,3 @@ 'use strict'; | ||
throw new errors_1.IllegalArgumentError('Definition must specify one or more sources: env, file, or value'); | ||
const definition = Object.assign({}, { name }, item); | ||
const definition = Object.assign({ name }, item); | ||
this.definitions.set(name, definition); | ||
@@ -26,0 +26,0 @@ return this; |
import { Bento } from '../../Bento'; | ||
import { VariableSource } from '../../interfaces'; | ||
export declare class VariableManager { | ||
private bento; | ||
private readonly bento; | ||
private readonly variables; | ||
@@ -66,3 +66,3 @@ private readonly validators; | ||
*/ | ||
addValidator(name: string, validator: (value: any, ...args: any[]) => boolean): void; | ||
addValidator(name: string, validator: (value: any, ...args: Array<any>) => boolean): void; | ||
/** | ||
@@ -76,2 +76,3 @@ * Remove validator from Bento | ||
* @param name validator name | ||
* @param value validator value | ||
* @param args array of args to be passed | ||
@@ -81,3 +82,3 @@ * | ||
*/ | ||
runValidator(name: string, value: any, ...args: any[]): boolean; | ||
runValidator(name: string, value: any, ...args: Array<any>): boolean; | ||
} |
@@ -153,2 +153,3 @@ 'use strict'; | ||
* @param name validator name | ||
* @param value validator value | ||
* @param args array of args to be passed | ||
@@ -155,0 +156,0 @@ * |
{ | ||
"name": "@ayana/bento", | ||
"version": "1.0.0-beta.6", | ||
"version": "1.0.0-beta.7", | ||
"description": "Modular runtime framework designed to solve complex tasks", | ||
@@ -26,3 +26,3 @@ "repository": "https://gitlab.com/ayana/libs/bento", | ||
"@ayana/test": "^2.0.1", | ||
"@ayana/tslint-config": "^1.2.2", | ||
"@ayana/tslint-config": "^1.2.4", | ||
"@types/node": "^12.6.2", | ||
@@ -29,0 +29,0 @@ "tslint": "^5.17.0", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
206530
3756