Skip to main content

<internal>

Index

Classes

default

default:

Provides a wrapper around PluginManager for ESComplexModule. Several convenience methods for the plugin callbacks properly manage and or create initial data that are processed by the plugins.

The default plugins loaded include:

@see

constructor

  • new default(options?: { loadDefaultPlugins: boolean }): default
  • Initializes Plugins.


    Parameters

    • options: { loadDefaultPlugins: boolean } = ...

      module options including user plugins to load including:

      (boolean)         loadDefaultPlugins - When false ESComplexModule will not load any default plugins.
      (Array<Object>) plugins - A list of ESComplexModule plugins that have already been instantiated.

    Returns default

onConfigure

  • onConfigure(options: ComplexityReporterOptions): any
  • Initializes the default settings object hash and then invokes the onConfigure plugin callback for all loaded plugins.


    Parameters

    • options: ComplexityReporterOptions

      (Optional) module processing options.

    Returns any

onEnterNode

  • onEnterNode(moduleReport: default, scopeControl: any, ignoreKeys: string[], syntaxes: any, settings: any, node: any, parent: any): string[]
  • Invokes the onEnterNode plugin callback during AST traversal when a node is entered.


    Parameters

    • moduleReport: default

      The ModuleReport being processed.

    • scopeControl: any

      The associated module report scope control.

    • ignoreKeys: string[]

      Any syntax assigned ignore keys for AST traversal.

    • syntaxes: any

      All loaded trait syntaxes for AST nodes.

    • settings: any

      Settings for module processing.

    • node: any

      The node being entered.

    • parent: any

      The parent node of the node being entered.

    Returns string[]

    A directive indicating children keys to be skipped or if null all keys entirely.

onExitNode

  • onExitNode(moduleReport: default, scopeControl: any, syntaxes: any, settings: any, node: any, parent: any): void
  • Invokes the onExitNode plugin callback during AST traversal when a node is exited.


    Parameters

    • moduleReport: default

      The ModuleReport being processed.

    • scopeControl: any

      The associated module report scope control.

    • syntaxes: any

      All loaded trait syntaxes for AST nodes.

    • settings: any

      Settings for module processing.

    • node: any

      The node being entered.

    • parent: any

      The parent node of the node being entered.

    Returns void

onLoadSyntax

  • onLoadSyntax(settings: any): any
  • Initializes the trait syntaxes object hash and then invokes the onLoadSyntax plugin callback for all loaded plugins.


    Parameters

    • settings: any

      Settings for module processing.

    Returns any

    Loaded trait syntaxes for AST nodes.

onModuleAverage

  • onModuleAverage(moduleReport: default, syntaxes: any, settings: any): default
  • Invokes the onModuleAverage plugin callback for all loaded plugins such they might average any calculated results.


    Parameters

    • moduleReport: default

      The ModuleReport being processed.

    • syntaxes: any

      All loaded trait syntaxes for AST nodes.

    • settings: any

      Settings for module processing.

    Returns default

    The ModuleReport being processed.

onModuleCalculate

  • onModuleCalculate(moduleReport: default, syntaxes: any, settings: any): default
  • Invokes the onModuleCalculate plugin callback for all loaded plugins such they might finish calculating results.


    Parameters

    • moduleReport: default

      The ModuleReport being processed.

    • syntaxes: any

      All loaded trait syntaxes for AST nodes.

    • settings: any

      Settings for module processing.

    Returns default

    The ModuleReport being processed.

onModuleEnd

  • onModuleEnd(moduleReport: default, syntaxes: any, settings: any): default
  • Invokes the onModuleEnd plugin callback for all loaded plugins at the end of module processing.


    Parameters

    • moduleReport: default

      The ModuleReport being processed.

    • syntaxes: any

      All loaded trait syntaxes for AST nodes.

    • settings: any

      Settings for module processing.

    Returns default

    The ModuleReport being processed.

onModulePostAverage

  • onModulePostAverage(moduleReport: default, syntaxes: any, settings: any): default
  • Invokes the onModulePostAverage plugin callback for all loaded plugins such they might finish any calculations that involve averaged results.


    Parameters

    • moduleReport: default

      The ModuleReport being processed.

    • syntaxes: any

      All loaded trait syntaxes for AST nodes.

    • settings: any

      Settings for module processing.

    Returns default

    The ModuleReport being processed.

onModulePostScopeCreated

  • onModulePostScopeCreated(moduleReport: default, scopeControl: any, newScope: Scope, settings: any, node: any, parent: any): void
  • Invokes the onModulePostScopeCreated plugin callback during AST traversal after a new module report scope is created.


    Parameters

    • moduleReport: default

      The ModuleReport being processed.

    • scopeControl: any

      The associated module report scope control.

    • newScope: Scope

      An object hash defining the new scope including:

    • settings: any

      Settings for module processing.

    • node: any

      The node being entered.

    • parent: any

      The parent node of the node being entered.

    Returns void

onModulePostScopePopped

  • onModulePostScopePopped(moduleReport: default, scopeControl: any, scope: Scope, settings: any, node: any, parent: any): void
  • Invokes the onModulePostScopePopped plugin callback during AST traversal after a module report scope is popped / exited.


    Parameters

    • moduleReport: default

      The ModuleReport being processed.

    • scopeControl: any

      The associated module report scope control.

    • scope: Scope

      An object hash defining the new scope including:

    • settings: any

      Settings for module processing.

    • node: any

      The node being entered.

    • parent: any

      The parent node of the node being entered.

    Returns void

onModulePreScopeCreated

  • onModulePreScopeCreated(moduleReport: default, scopeControl: any, newScope: Scope, settings: any, node: any, parent: any): void
  • Invokes the onModulePreScopeCreated plugin callback during AST traversal before a new module report scope is created.


    Parameters

    • moduleReport: default

      The ModuleReport being processed.

    • scopeControl: any

      The associated module report scope control.

    • newScope: Scope

      An object hash defining the new scope including:

    • settings: any

      Settings for module processing.

    • node: any

      The node being entered.

    • parent: any

      The parent node of the node being entered.

    Returns void

onModulePreScopePopped

  • onModulePreScopePopped(moduleReport: default, scopeControl: any, scope: Scope, settings: any, node: any, parent: any): void
  • Invokes the onModulePreScopePopped plugin callback during AST traversal before a module report scope is popped / exited.


    Parameters

    • moduleReport: default

      The ModuleReport being processed.

    • scopeControl: any

      The associated module report scope control.

    • scope: Scope

      An object hash defining the new scope including:

    • settings: any

      Settings for module processing.

    • node: any

      The node being entered.

    • parent: any

      The parent node of the node being entered.

    Returns void

onModuleStart

  • onModuleStart(ast: Node, syntaxes: any, settings: any): default
  • Initializes the default ModuleReport and then invokes the onModuleStart plugin callback for all loaded plugins.


    Parameters

    • ast: Node

      Settings for module processing.

    • syntaxes: any

      All loaded trait syntaxes for AST nodes.

    • settings: any

      Settings for module processing.

    Returns default

    The ModuleReport being processed.

default

default:

Provides a lightweight plugin manager for Node / NPM with optional backbone-esnext-events integration for plugins in a safe and protected manner across NPM modules, local files, and preloaded object instances. This pattern facilitates message passing between modules versus direct dependencies / method invocation.

It isn’t necessary to use an eventbus associated with the plugin manager though invocation then relies on invoking methods directly with the plugin manager instance.

When passing in an eventbus from backbone-esnext-events the plugin manager will register by default under these event categories:

plugins:add - PluginManager#add

plugins:add:all - PluginManager#addAll

plugins:async:add - PluginManager#addAsync

plugins:async:add:all - PluginManager#addAllAsync

plugins:async:destroy:manager - PluginManager#destroyAsync

plugins:async:invoke - PluginManager#invokeAsync

plugins:async:invoke:event - PluginManager#invokeAsyncEvent

plugins:async:remove - PluginManager#removeAsync

plugins:async:remove:all - PluginManager#removeAllAsync

plugins:create:event:proxy - PluginManager#createEventProxy

plugins:destroy:manager - PluginManager#destroy

plugins:get:all:plugin:data - PluginManager#getAllPluginData

plugins:get:extra:event:data - PluginManager#getExtraEventData

plugins:get:method:names - PluginManager#getMethodNames

plugins:get:options - PluginManager#getOptions

plugins:get:plugin:data - PluginManager#getPluginData

plugins:get:plugin:enabled - PluginManager#getPluginEnabled

plugins:get:plugin:event:names - PluginManager#getPluginEventNames

plugins:get:plugin:method:names - PluginManager#getPluginMethodNames

plugins:get:plugin:names - PluginManager#getPluginNames

plugins:get:plugin:options - PluginManager#getPluginOptions

plugins:get:plugins:enabled - PluginManager#getPluginsEnabled

plugins:get:plugins:by:event:name - PluginManager#getPluginsByEventName

plugins:get:plugins:event:names - PluginManager#getPluginsEventNames

plugins:has:method - PluginManager#hasMethod

plugins:has:plugin - PluginManager#hasPlugin

plugins:has:plugin:method - PluginManager#hasPluginMethod

plugins:invoke - PluginManager#invoke

plugins:is:valid:config - PluginManager#isValidConfig

plugins:remove - PluginManager#remove

plugins:remove:all - PluginManager#removeAll

plugins:set:extra:event:data - PluginManager#setExtraEventData

plugins:set:options - PluginManager#setOptions

plugins:set:plugin:enabled - PluginManager#setPluginEnabled

plugins:set:plugins:enabled - PluginManager#setPluginsEnabled

plugins:sync:invoke - PluginManager#invokeSync

plugins:sync:invoke:event - PluginManager#invokeSyncEvent

Automatically when a plugin is loaded and unloaded respective callbacks onPluginLoad and onPluginUnload will be attempted to be invoked on the plugin. This is an opportunity for the plugin to receive any associated eventbus and wire itself into it. It should be noted that a protected proxy around the eventbus is passed to the plugins such that when the plugin is removed automatically all events registered on the eventbus are cleaned up without a plugin author needing to do this manually in the onPluginUnload callback. This solves any dangling event binding issues.

The plugin manager also supports asynchronous operation with the methods ending in Async along with event bindings that include async. For asynchronous variations of add, destroy, and remove the lifecycle methods onPluginLoad and onPluginUnload will be awaited on such that if a plugin returns a Promise or is an async method then it must complete before execution continues. One can use Promises to interact with the plugin manager asynchronously, but usage via async / await is recommended.

If eventbus functionality is enabled it is important especially if using a process / global level eventbus such as backbone-esnext-eventbus to call PluginManager#destroy to clean up all plugin eventbus resources and the plugin manager event bindings.

@see
@example

import Events from ‘backbone-esnext-events’; // Imports the TyphonEvents class for local usage. ::or alternatively:: import eventbus from ‘backbone-esnext-eventbus’; // Imports a global / process level eventbus.

import PluginManager from ‘typhonjs-plugin-manager’;

const pluginManager = new PluginManager({ eventbus });

pluginManager.add({ name: ‘an-npm-plugin-enabled-module’ }); pluginManager.add({ name: ‘my-local-module’, target: ‘./myModule.js’ });

// Let’s say an-npm-plugin-enabled-module responds to ‘cool:event’ which returns ‘true’. // Let’s say my-local-module responds to ‘hot:event’ which returns ‘false’. // Both of the plugin / modules will have ‘onPluginLoaded’ invoked with a proxy to the eventbus and any plugin // options defined.

// One can then use the eventbus functionality to invoke associated module / plugin methods even retrieving results. assert(eventbus.triggerSync(‘cool:event’) === true); assert(eventbus.triggerSync(‘hot:event’) === false);

// One can also indirectly invoke any method of the plugin via: eventbus.triggerSync(‘plugins:invoke:sync:event’, ‘aCoolMethod’); // Any plugin with a method named aCoolMethod is invoked. eventbus.triggerSync(‘plugins:invoke:sync:event’, ‘aCoolMethod’, {}, {}, ‘an-npm-plugin-enabled-module’); // specific invocation.

// The 3rd parameter will make a copy of the hash and the 4th defines a pass through object hash sending a single // event / object hash to the invoked method.

// ———————–

// Given that backbone-esnext-eventbus defines a global / process level eventbus you can import it in an entirely // different file or even NPM module and invoke methods of loaded plugins like this:

import eventbus from ‘backbone-esnext-eventbus’;

eventbus.triggerSync(‘plugins:invoke’, ‘aCoolMethod’); // Any plugin with a method named aCoolMethod is invoked.

assert(eventbus.triggerSync(‘cool:event’) === true);

eventbus.trigger(‘plugins:remove’, ‘an-npm-plugin-enabled-module’); // Removes the plugin and unregisters events.

assert(eventbus.triggerSync(‘cool:event’) === true); // Will now fail!

// In this case though when using the global eventbus be mindful to always call pluginManager.destroy() in the main // thread of execution scope to remove all plugins and the plugin manager event bindings!

constructor

  • new default(options?: { eventPrepend?: string; eventbus?: EventEmitter; throwNoMethod: boolean; throwNoPlugin: boolean }, extraEventData?: string): default
  • Instantiates PluginManager


    Parameters

    • optionaloptions: { eventPrepend?: string; eventbus?: EventEmitter; throwNoMethod: boolean; throwNoPlugin: boolean }

      Provides various configuration options:

      options.eventbus - An instance of ‘backbone-esnext-events’ used as the plugin eventbus.

      options.eventPrepend - A customized name to prepend PluginManager events on the eventbus.

      options.throwNoMethod - If true then when a method fails to be invoked by any plugin an exception will be thrown.

      options.throwNoPlugin- If true then when no plugin is matched to be invoked an exception will be thrown.

    • optionalextraEventData: string

      Provides additional optional data to attach to PluginEvent callbacks.

    Returns default

add

  • add(pluginConfig: PluginConfig, moduleData?: any): PluginData
  • Adds a plugin by the given configuration parameters. A plugin name is always required. If no other options are provided then the name doubles as the NPM module / local file to load. The loading first checks for an existing instance to use as the plugin. Then the target is chosen as the NPM module / local file to load. By passing in options this will be stored and accessible to the plugin during all callbacks.


    Parameters

    • pluginConfig: PluginConfig

      Defines the plugin to load.

    • optionalmoduleData: any

      Optional object hash to associate with plugin.

    Returns PluginData

addAll

  • addAll(pluginConfigs?: PluginConfig[], moduleData?: any): PluginData[]
  • Initializes multiple plugins in a single call.


    Parameters

    • optionalpluginConfigs: PluginConfig[]

      An array of plugin config object hash entries.

    • optionalmoduleData: any

      Optional object hash to associate with all plugins.

    Returns PluginData[]

addAllAsync

  • addAllAsync(pluginConfigs?: PluginConfig[], moduleData?: any): Promise<PluginData[]>
  • Initializes multiple plugins in a single call.


    Parameters

    • optionalpluginConfigs: PluginConfig[]

      An array of plugin config object hash entries.

    • optionalmoduleData: any

      Optional object hash to associate with all plugins.

    Returns Promise<PluginData[]>

addAsync

  • addAsync(pluginConfig: PluginConfig, moduleData?: any): Promise<PluginData>
  • Adds a plugin by the given configuration parameters. A plugin name is always required. If no other options are provided then the name doubles as the NPM module / local file to load. The loading first checks for an existing instance to use as the plugin. Then the target is chosen as the NPM module / local file to load. By passing in options this will be stored and accessible to the plugin during all callbacks.


    Parameters

    • pluginConfig: PluginConfig

      Defines the plugin to load.

    • optionalmoduleData: any

      Optional object hash to associate with plugin.

    Returns Promise<PluginData>

createEventProxy

  • createEventProxy(): EventEmitter
  • If an eventbus is assigned to this plugin manager then a new EventEmitter wrapping this eventbus is returned.


    Returns EventEmitter

destroy

  • destroy(): void
  • Destroys all managed plugins after unloading them.


    Returns void

destroyAsync

  • destroyAsync(): Promise<void>
  • Destroys all managed plugins after unloading them.


    Returns Promise<void>

getAllPluginData

  • getAllPluginData(enabled: boolean): PluginData[]
  • Returns all plugin data or if a boolean is passed in will return plugin data by current enabled state.


    Parameters

    • enabled: boolean

      If enabled is a boolean it will return plugins given their enabled state.

    Returns PluginData[]

getEventbus

  • getEventbus(): EventEmitter
  • Returns any associated eventbus.


    Returns EventEmitter

getExtraEventData

  • getExtraEventData(): any
  • Returns any extra event data associated with PluginEvents.


    Returns any

getMethodNames

  • getMethodNames(enabled: boolean, pluginName: string): string[]
  • Returns all method names or if a boolean is passed in will return method names for plugins by current enabled state.


    Parameters

    • enabled: boolean

      If enabled is a boolean it will return plugin methods names given their enabled state.

    • pluginName: string

      If a string then just this plugins methods names are returned.

    Returns string[]

getOptions

  • getOptions(): PluginManagerOptions
  • Returns a copy of the plugin manager options.


    Returns PluginManagerOptions

getPluginData

  • getPluginData(pluginName: string): PluginData
  • Gets the plugin data for a plugin by name.


    Parameters

    • pluginName: string

      A plugin name.

    Returns PluginData

getPluginEnabled

  • getPluginEnabled(pluginName: string): boolean
  • Returns the enabled state of a plugin.


    Parameters

    • pluginName: string

      Plugin name to set state.

    Returns boolean

getPluginEventNames

  • getPluginEventNames(pluginName: string): string[]
  • Returns the event binding names registered on any associated plugin EventProxy.


    Parameters

    • pluginName: string

      Plugin name to set state.

    Returns string[]

getPluginMethodNames

  • getPluginMethodNames(enabled: boolean): { method: string; plugin: string }[]
  • Returns all plugin names or if a boolean is passed in will return plugin names by current enabled state.


    Parameters

    • enabled: boolean

      If enabled is a boolean it will return plugins given their enabled state.

    Returns { method: string; plugin: string }[]

getPluginNames

  • getPluginNames(enabled: boolean): string[]
  • Returns all plugin names or if a boolean is passed in will return plugin names by current enabled state.


    Parameters

    • enabled: boolean

      If enabled is a boolean it will return plugins given their enabled state.

    Returns string[]

getPluginOptions

  • getPluginOptions(pluginName: string): any
  • Returns a copy of the given plugin options.


    Parameters

    • pluginName: string

      Plugin name to retrieve.

    Returns any

getPluginsByEventName

  • getPluginsByEventName(eventName: string): string[]
  • Returns the plugin names that registered the given event binding name.


    Parameters

    • eventName: string

      An event name that plugins may have registered.

    Returns string[]

getPluginsEnabled

  • getPluginsEnabled(pluginNames: string[]): { enabled: boolean; pluginName: string }[]
  • Returns the enabled state of a list of plugins.


    Parameters

    • pluginNames: string[]

      An array / iterable of plugin names.

    Returns { enabled: boolean; pluginName: string }[]

getPluginsEventNames

  • getPluginsEventNames(nameOrList?: string | string[]): { events: string[]; pluginName: string }[]
  • Returns the event binding names registered from each plugin.


    Parameters

    • optionalnameOrList: string | string[]

      An array / iterable of plugin names.

    Returns { events: string[]; pluginName: string }[]

hasMethod

  • hasMethod(methodName: string): boolean
  • Returns true if there is at least one plugin loaded with the given method name.


    Parameters

    • methodName: string

      Method name to test.

    Returns boolean

hasPlugin

  • hasPlugin(pluginName: string): boolean
  • Returns true if there is a plugin loaded with the given plugin name.


    Parameters

    • pluginName: string

      Plugin name to test.

    Returns boolean

hasPluginMethod

  • hasPluginMethod(pluginName: string, methodName: string): boolean
  • Returns true if there is a plugin loaded with the given plugin name that also has a method with the given method name.


    Parameters

    • pluginName: string

      Plugin name to test.

    • methodName: string

      Method name to test.

    Returns boolean

invoke

  • invoke(methodName: string, args?: any, nameOrList?: string | string[]): void
  • This dispatch method simply invokes any plugin targets for the given methodName..


    Parameters

    • methodName: string

      Method name to invoke.

    • optionalargs: any

      Optional arguments. An array will be spread as multiple arguments.

    • optionalnameOrList: string | string[]

      An optional plugin name or array / iterable of plugin names to invoke.

    Returns void

invokeAsync

  • invokeAsync(methodName: string, args?: any[], nameOrList?: string | string[]): Promise<any>
  • This dispatch method uses ES6 Promises and adds any returned results to an array which is added to a Promise.all construction which passes back a Promise which waits until all Promises complete. Any target invoked may return a Promise or any result. This is very useful to use for any asynchronous operations.


    Parameters

    • methodName: string

      Method name to invoke.

    • optionalargs: any[]

      Optional arguments. An array will be spread as multiple arguments.

    • optionalnameOrList: string | string[]

      An optional plugin name or array / iterable of plugin names to invoke.

    Returns Promise<any>

invokeAsyncEvent

  • invokeAsyncEvent(methodName: string, copyProps?: any, passthruProps?: any, nameOrList?: string | string[]): Promise<void | default>
  • This dispatch method synchronously passes to and returns from any invoked targets a PluginEvent.


    Parameters

    • methodName: string

      Method name to invoke.

    • optionalcopyProps: any

      plugin event object.

    • optionalpassthruProps: any

      if true, event has plugin option.

    • optionalnameOrList: string | string[]

      An optional plugin name or array / iterable of plugin names to invoke.

    Returns Promise<void | default>

invokeSync

  • invokeSync(methodName: string, args?: any, nameOrList?: string | string[]): any
  • This dispatch method synchronously passes back a single value or an array with all results returned by any invoked targets.


    Parameters

    • methodName: string

      Method name to invoke.

    • optionalargs: any

      Optional arguments. An array will be spread as multiple arguments.

    • optionalnameOrList: string | string[]

      An optional plugin name or array / iterable of plugin names to invoke.

    Returns any

invokeSyncEvent

  • invokeSyncEvent(methodName: string, copyProps?: any, passthruProps?: any, nameOrList?: string | string[]): default
  • This dispatch method synchronously passes to and returns from any invoked targets a PluginEvent.


    Parameters

    • methodName: string

      Method name to invoke.

    • optionalcopyProps: any

      plugin event object.

    • optionalpassthruProps: any
    • optionalnameOrList: string | string[]

      An optional plugin name or array / iterable of plugin names to invoke.

    Returns default

isValidConfig

  • isValidConfig(pluginConfig: PluginConfig): boolean
  • Performs validation of a PluginConfig.


    Parameters

    • pluginConfig: PluginConfig

      A PluginConfig to validate.

    Returns boolean

remove

  • remove(pluginName: string): boolean
  • Removes a plugin by name after unloading it and clearing any event bindings automatically.


    Parameters

    • pluginName: string

      The plugin name to remove.

    Returns boolean

removeAll

  • removeAll(): void
  • Removes all plugins after unloading them and clearing any event bindings automatically.


    Returns void

removeAllAsync

  • removeAllAsync(): Promise<any>
  • Removes all plugins after unloading them and clearing any event bindings automatically.


    Returns Promise<any>

removeAsync

  • removeAsync(pluginName: string): Promise<boolean>
  • Removes a plugin by name after unloading it and clearing any event bindings automatically.


    Parameters

    • pluginName: string

      The plugin name to remove.

    Returns Promise<boolean>

setEventbus

  • setEventbus(targetEventbus: EventEmitter, eventPrepend?: string): default
  • Sets the eventbus associated with this plugin manager. If any previous eventbus was associated all plugin manager events will be removed then added to the new eventbus. If there are any existing plugins being managed their events will be removed from the old eventbus and then onPluginLoad will be called with the new eventbus.


    Parameters

    • targetEventbus: EventEmitter

      The target eventbus to associate.

    • optionaleventPrepend: string

      An optional string to prepend to all of the event binding targets.

    Returns default

setEventbusAsync

  • setEventbusAsync(targetEventbus: EventEmitter, eventPrepend?: string): Promise<default>
  • Sets the eventbus associated with this plugin manager. If any previous eventbus was associated all plugin manager events will be removed then added to the new eventbus. If there are any existing plugins being managed their events will be removed from the old eventbus and then onPluginLoad will be called with the new eventbus.


    Parameters

    • targetEventbus: EventEmitter

      The target eventbus to associate.

    • optionaleventPrepend: string

      An optional string to prepend to all of the event binding targets.

    Returns Promise<default>

setExtraEventData

  • setExtraEventData(extraEventData?: any): void
  • Sets any extra event data attached to PluginEvent extra field.


    Parameters

    • optionalextraEventData: any

      Adds extra data to PluginEvent extra field.

    Returns void

setOptions

  • setOptions(options?: PluginManagerOptions): void
  • Set optional parameters. All parameters are off by default.


    Parameters

    • optionaloptions: PluginManagerOptions

      Defines optional parameters to set.

    Returns void

setPluginEnabled

  • setPluginEnabled(pluginName: string, enabled: boolean): boolean
  • Enables or disables a single plugin.


    Parameters

    • pluginName: string

      Plugin name to set state.

    • enabled: boolean

      The new enabled state.

    Returns boolean

setPluginsEnabled

  • setPluginsEnabled(pluginNames: string[], enabled: boolean): boolean
  • Enables or disables a set of plugins given an array or iterabe of plugin names.


    Parameters

    • pluginNames: string[]

      An array / iterable of plugin names.

    • enabled: boolean

      The new enabled state.

    Returns boolean

default

default:

Defines a class holding the data associated with a plugin including its instance.

constructor

  • new default(name: string, data: any, instance: any, eventProxy: EventEmitter): default
  • Instantiates a PluginEntry.


    Parameters

    • name: string

      The plugin name.

    • data: any

      Data describing the plugin, manager, and optional module data.

    • instance: any

      The loaded plugin instance.

    • eventProxy: EventEmitter

      An EventEmitter associated with the plugin wrapping the plugin manager eventbus.

    Returns default

data

  • get data(): any
  • Get plugin data.


    Returns any

enabled

  • get enabled(): boolean
  • set enabled(enabled: boolean): void
  • Get enabled.


    Returns boolean

  • Set enabled.


    Parameters

    • enabled: boolean

      New enabled state.

    Returns void

eventProxy

  • get eventProxy(): EventEmitter
  • set eventProxy(eventProxy: EventEmitter): void
  • Get associated EventProxy.


    Returns EventEmitter

  • Parameters

    • eventProxy: EventEmitter

    Returns void

instance

  • get instance(): any
  • Get plugin instance.


    Returns any

name

  • get name(): string
  • Get plugin name.


    Returns string

staticescape

  • escape(value: string): string
  • Provides a convenience method to escape file paths.


    Parameters

    • value: string

      A string to escape.

    Returns string

default

default:

Provides the data / event passed to all invoked methods in PluginManager#invokeSyncEvent. The event.data field is returned to the caller. Before returning though additional the following additional metadata is attached:

(number) $$plugin_invoke_count - The count of plugins invoked.

(Array

<string>
) $$plugin_invoke_names - The names of plugins invoked.

constructor

  • new default(copyProps?: {}, passthruProps?: {}, extraEventData?: any): default
  • Initializes PluginEvent.


    Parameters

    • optionalcopyProps: {}

      Event data to copy.

    • optionalpassthruProps: {}

      Event data to pass through.

    • optionalextraEventData: any

      Extra event data attached to extra.

    Returns default

data

data: any

Provides the unified event data assigning any pass through data to the copied data supplied.

eventbus

eventbus: EventEmitter

The active EventProxy for that particular plugin.

extra

extra: any

Stores any extra event data added to all PluginEvents.

ignoreKeys

ignoreKeys: any

list of keys to ignore

pluginName

pluginName: string

The active plugin name.

pluginOptions

pluginOptions: any

The active plugin options.

projectReport

projectReport: default

TODO: i don’t know where this is set, but it is used in excomplex-project/plugins

settings

settings: any

settings for the plugin instance

syntaxes

syntaxes: any

All loaded trait syntaxes for AST nodes

Type Aliases

PluginConfig

PluginConfig: { instance?: string; name: string; options?: any; target?: string }

Type declaration

  • optionalinstance?: string

    Defines an existing object instance to use as the plugin.

  • name: string

    Defines the name of the plugin; if no target entry is present the name doubles as the target (please see target).

  • optionaloptions?: any

    Defines an object of options for the plugin.

  • optionaltarget?: string

    Defines the target NPM module to load or defines a local file (full path or relative to current working directory to load.

PluginData

PluginData: { managerEventPrepend: string; name: string; option: any; scopedName: string; target: string; targetEscaped: string; type: string }

Type declaration

  • managerEventPrepend: string

    The plugin manager event prepend string.

  • name: string

    The name of the plugin.

  • option: any

    Defines an object of options for the plugin.

  • scopedName: string

    The name of the plugin with the plugin managers event prepend string.

  • target: string

    Defines the target NPM module to loaded or defines a local file (full path or relative to current working directory to load.

  • targetEscaped: string

    Provides the target, but properly escaped for RegExp usage.

  • type: string

    The type of plugin: instance, require-module, or require-path.

PluginManagerOptions

PluginManagerOptions: { noEventAdd: boolean; noEventDestroy: boolean; noEventOptions: boolean; noEventRemoval: boolean; pluginsEnabled: boolean; throwNoMethod: boolean; throwNoPlugin: boolean }

Type declaration

  • noEventAdd: boolean

    If true this prevents plugins from being added by plugins:add and plugins:add:all events forcing direct method invocation for addition.

  • noEventDestroy: boolean

    If true this prevents the plugin manager from being destroyed by plugins:destroy:manager forcing direct method invocation for destruction.

  • noEventOptions: boolean

    If true this prevents setting options for the plugin manager by plugins:destroy:manager forcing direct method invocation for destruction.

  • noEventRemoval: boolean

    If true this prevents plugins from being removed by plugins:remove and plugins:remove:all events forcing direct method invocation for removal.

  • pluginsEnabled: boolean

    If false all plugins are disabled.

  • throwNoMethod: boolean

    If true then when a method fails to be invoked by any plugin an exception will be thrown.

  • throwNoPlugin: boolean

    If true then when no plugin is matched to be invoked an exception will be thrown.

Scope

Scope: { lineEnd: number; lineStart: number; name: string; paramCount: number; type: string }

Type declaration

  • lineEnd: number

    End line of method

  • lineStart: number

    Start line of method

  • name: string

    Name of the class or method

  • paramCount: number

    (For method scopes) Number of parameters for method

  • type: string

    Type of report to create