@robotlegsjs/core
Version:
An architecture-based IoC framework for JavaScript/TypeScript
62 lines • 2.6 kB
JavaScript
;
// ------------------------------------------------------------------------------
// Copyright (c) 2017-present, RobotlegsJS. All Rights Reserved.
//
// NOTICE: You are permitted to use, modify, and distribute this file
// in accordance with the terms of the license agreement accompanying it.
// ------------------------------------------------------------------------------
Object.defineProperty(exports, "__esModule", { value: true });
exports.ExtensionInstaller = void 0;
/**
* Installs custom extensions into a given context
*
* @private
*/
var ExtensionInstaller = /** @class */ (function () {
/*============================================================================*/
/* Constructor */
/*============================================================================*/
/**
* @private
*/
function ExtensionInstaller(context) {
/*============================================================================*/
/* Private Properties */
/*============================================================================*/
this._classes = new Map();
this._context = context;
this._logger = this._context.getLogger(this);
}
/*============================================================================*/
/* Public Functions */
/*============================================================================*/
/**
* Installs the supplied extension
*
* @param extension An object or class implementing IExtension
*/
ExtensionInstaller.prototype.install = function (extension) {
if (typeof extension === "function" && extension.prototype.extend !== undefined) {
if (!this._classes.get(extension)) {
this.install(new extension());
}
}
else {
var extensionClass = extension.constructor;
if (!this._classes.get(extensionClass)) {
this._logger.debug("Installing extension {0}", [extension]);
this._classes.set(extensionClass, true);
extension.extend(this._context);
}
}
};
/**
* Destroy
*/
ExtensionInstaller.prototype.destroy = function () {
this._classes.clear();
};
return ExtensionInstaller;
}());
exports.ExtensionInstaller = ExtensionInstaller;
//# sourceMappingURL=ExtensionInstaller.js.map