typhonjs-plugin-manager
Version:
Provides a plugin manager that dispatches events to loaded plugins.
75 lines (60 loc) • 2.43 kB
JavaScript
Object.defineProperty(exports, "__esModule", {
value: true
});
var _stringify = require("babel-runtime/core-js/json/stringify");
var _stringify2 = _interopRequireDefault(_stringify);
var _assign = require("babel-runtime/core-js/object/assign");
var _assign2 = _interopRequireDefault(_assign);
var _classCallCheck2 = require("babel-runtime/helpers/classCallCheck");
var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
/**
* PluginEvent - Provides the data / event passed to all invoked methods in {@link 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.
*/
var PluginEvent =
/**
* Initializes PluginEvent.
*
* @param {object} copyProps - Event data to copy.
* @param {object} passthruProps - Event data to pass through.
* @param {object} extraEventData - Extra event data attached to `extra`.
*/
function PluginEvent() {
var copyProps = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
var passthruProps = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
var extraEventData = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : void 0;
(0, _classCallCheck3.default)(this, PluginEvent);
/**
* Provides the unified event data assigning any pass through data to the copied data supplied.
*/
this.data = (0, _assign2.default)(JSON.parse((0, _stringify2.default)(copyProps)), passthruProps);
/**
* Stores any extra event data added to all PluginEvents.
* @type {Object}
*/
this.extra = extraEventData;
/**
* Unique data available in each plugin invoked.
* @type {EventProxy} - The active EventProxy for that particular plugin.
*/
this.eventbus = void 0;
/**
* Unique data available in each plugin invoked.
* @type {string} - The active plugin name.
*/
this.pluginName = void 0;
/**
* Unique data available in each plugin invoked.
* @type {object} - The active plugin options.
*/
this.pluginOptions = void 0;
};
exports.default = PluginEvent;
module.exports = exports["default"];
;