@injex/core
Advanced tools
Comparing version 3.3.9 to 3.4.0
@@ -31,2 +31,3 @@ import { IConstructor, Logger } from "@injex/stdlib"; | ||
private _createHooks; | ||
private _createModulesAsync; | ||
private _createModules; | ||
@@ -33,0 +34,0 @@ private _createModule; |
@@ -49,18 +49,26 @@ "use strict"; | ||
this.hooks.afterRegistration.call(); | ||
if (!this.config.perfMode) return [3 /*break*/, 4]; | ||
return [4 /*yield*/, this._createModulesAsync()]; | ||
case 3: | ||
_a.sent(); | ||
return [3 /*break*/, 5]; | ||
case 4: | ||
this._createModules(); | ||
_a.label = 5; | ||
case 5: | ||
bootstrapModule = this.get(constants_1.bootstrapSymbol); | ||
_a.label = 3; | ||
case 3: | ||
_a.trys.push([3, 6, , 7]); | ||
_a.label = 6; | ||
case 6: | ||
_a.trys.push([6, 9, , 10]); | ||
return [4 /*yield*/, this._initializeModules()]; | ||
case 4: | ||
case 7: | ||
_a.sent(); | ||
this.hooks.bootstrapRun.call(); | ||
return [4 /*yield*/, (bootstrapModule === null || bootstrapModule === void 0 ? void 0 : bootstrapModule.run())]; | ||
case 5: | ||
case 8: | ||
_a.sent(); | ||
this.hooks.bootstrapComplete.call(); | ||
this._modulesReady(); | ||
return [3 /*break*/, 7]; | ||
case 6: | ||
return [3 /*break*/, 10]; | ||
case 9: | ||
e_1 = _a.sent(); | ||
@@ -74,4 +82,4 @@ this.hooks.bootstrapError.call(e_1); | ||
} | ||
return [3 /*break*/, 7]; | ||
case 7: return [2 /*return*/, this]; | ||
return [3 /*break*/, 10]; | ||
case 10: return [2 /*return*/, this]; | ||
} | ||
@@ -128,2 +136,26 @@ }); | ||
}; | ||
InjexContainer.prototype._createModulesAsync = function () { | ||
return tslib_1.__awaiter(this, void 0, void 0, function () { | ||
var modules, item; | ||
return tslib_1.__generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
this.hooks.beforeCreateModules.call(); | ||
modules = Array.from(this._moduleRegistry.values()); | ||
_a.label = 1; | ||
case 1: | ||
if (!modules.length) return [3 /*break*/, 3]; | ||
item = modules.shift(); | ||
this._createModule(item); | ||
return [4 /*yield*/, stdlib_1.yieldToMain()]; | ||
case 2: | ||
_a.sent(); | ||
return [3 /*break*/, 1]; | ||
case 3: | ||
this.hooks.afterCreateModules.call(); | ||
return [2 /*return*/]; | ||
} | ||
}); | ||
}); | ||
}; | ||
InjexContainer.prototype._createModules = function () { | ||
@@ -130,0 +162,0 @@ var _this = this; |
@@ -60,2 +60,3 @@ import { Hook, IConstructor, LogLevel } from "@injex/stdlib"; | ||
plugins?: IInjexPlugin[]; | ||
perfMode?: boolean; | ||
} | ||
@@ -62,0 +63,0 @@ export interface ILazyModule<T> { |
{ | ||
"name": "@injex/core", | ||
"version": "3.3.9", | ||
"version": "3.4.0", | ||
"description": "Simple, Decorated, Pluggable dependency-injection framework for TypeScript apps", | ||
@@ -47,3 +47,3 @@ "keywords": [ | ||
"dependencies": { | ||
"@injex/stdlib": "^3.3.9" | ||
"@injex/stdlib": "^3.4.0" | ||
}, | ||
@@ -57,3 +57,3 @@ "devDependencies": { | ||
}, | ||
"gitHead": "9de284e54385047ec93f16a27147e67df67f70f0" | ||
"gitHead": "352e6456d1e82b015e39cfed9a42c5f65f5a4f61" | ||
} |
@@ -71,3 +71,7 @@ import { Hook, IConstructor, isFunction, isPromise, Logger, yieldToMain } from "@injex/stdlib"; | ||
this._createModules(); | ||
if (this.config.perfMode) { | ||
await this._createModulesAsync(); | ||
} else { | ||
this._createModules(); | ||
} | ||
@@ -159,2 +163,16 @@ const bootstrapModule = this.get<IBootstrap>(bootstrapSymbol); | ||
private async _createModulesAsync() { | ||
this.hooks.beforeCreateModules.call(); | ||
const modules = Array.from(this._moduleRegistry.values()); | ||
while (modules.length) { | ||
const item = modules.shift(); | ||
this._createModule(item); | ||
await yieldToMain(); | ||
} | ||
this.hooks.afterCreateModules.call(); | ||
} | ||
private _createModules() { | ||
@@ -336,3 +354,3 @@ this.hooks.beforeCreateModules.call(); | ||
this._logger.error(err); | ||
const error = new InitializeMuduleError(metadata.name); | ||
const error = new InitializeMuduleError(metadata.name); | ||
error.stack = err?.stack ?? error.stack; | ||
@@ -339,0 +357,0 @@ throw error; |
@@ -70,2 +70,3 @@ import { Hook, IConstructor, LogLevel } from "@injex/stdlib"; | ||
plugins?: IInjexPlugin[]; | ||
perfMode?: boolean; | ||
} | ||
@@ -72,0 +73,0 @@ |
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
96764
1638
Updated@injex/stdlib@^3.4.0