@artus/core
Advanced tools
Comparing version 1.0.0-beta.22 to 1.0.0-beta.23
@@ -13,2 +13,3 @@ import { Constructable, Container } from '@artus/injection'; | ||
private container; | ||
private hookUnitSet; | ||
constructor(app: Application, container: Container); | ||
@@ -15,0 +16,0 @@ insertHook(existHookName: string, newHookName: string): void; |
@@ -16,2 +16,3 @@ "use strict"; | ||
this.hookFnMap = new Map(); | ||
this.hookUnitSet = new Set(); | ||
this.app = app; | ||
@@ -39,2 +40,6 @@ this.container = container; | ||
registerHookUnit(extClazz) { | ||
if (this.hookUnitSet.has(extClazz)) { | ||
return; | ||
} | ||
this.hookUnitSet.add(extClazz); | ||
const fnMetaKeys = Reflect.getMetadataKeys(extClazz); | ||
@@ -41,0 +46,0 @@ const extClazzInstance = this.container.get(extClazz); |
@@ -72,3 +72,3 @@ "use strict"; | ||
const loader = this.getLoader(loaderName); | ||
loader.state = item._loaderState; | ||
loader.state = item.loaderState; | ||
return loader.load(item); | ||
@@ -75,0 +75,0 @@ } |
@@ -1,3 +0,2 @@ | ||
import { Constructable } from '@artus/injection'; | ||
import { ApplicationLifecycle } from '../../types'; | ||
import { LifecycleManager } from '../../lifecycle'; | ||
import { ManifestItem, Loader } from '../types'; | ||
@@ -7,4 +6,5 @@ declare class LifecycleLoader implements Loader { | ||
constructor(container: any); | ||
load(item: ManifestItem): Promise<Constructable<ApplicationLifecycle>>; | ||
get lifecycleManager(): LifecycleManager; | ||
load(item: ManifestItem): Promise<any[]>; | ||
} | ||
export default LifecycleLoader; |
@@ -11,8 +11,16 @@ "use strict"; | ||
} | ||
get lifecycleManager() { | ||
return this.container.get(constant_1.ArtusInjectEnum.LifecycleManager); | ||
} | ||
async load(item) { | ||
const extClazz = await (0, compatible_require_1.default)(item.path); | ||
const lifecycleManager = this.container.get(constant_1.ArtusInjectEnum.LifecycleManager); | ||
this.container.set({ type: extClazz }); | ||
lifecycleManager.registerHookUnit(extClazz); | ||
return extClazz; | ||
const origin = await (0, compatible_require_1.default)(item.path, true); | ||
item.loaderState = Object.assign({ exportNames: ['default'] }, item.loaderState); | ||
const { loaderState: state } = item; | ||
const lifecycleClazzList = []; | ||
for (const name of state.exportNames) { | ||
const clazz = origin[name]; | ||
this.container.set({ type: clazz }); | ||
this.lifecycleManager.registerHookUnit(clazz); | ||
} | ||
return lifecycleClazzList; | ||
} | ||
@@ -19,0 +27,0 @@ }; |
@@ -14,4 +14,4 @@ "use strict"; | ||
const origin = await (0, compatible_require_1.default)(item.path, true); | ||
item._loaderState = Object.assign({ exportNames: ['default'] }, item._loaderState); | ||
const { _loaderState: state } = item; | ||
item.loaderState = Object.assign({ exportNames: ['default'] }, item.loaderState); | ||
const { loaderState: state } = item; | ||
const modules = []; | ||
@@ -18,0 +18,0 @@ for (const name of state.exportNames) { |
@@ -27,3 +27,3 @@ "use strict"; | ||
} | ||
const loaderState = item._loaderState; | ||
const loaderState = item.loaderState; | ||
pluginConfigItem.path = plugin_1.ArtusPlugin.getPath(pluginConfigItem.package, [loaderState === null || loaderState === void 0 ? void 0 : loaderState.baseDir]); | ||
@@ -30,0 +30,0 @@ delete pluginConfigItem.package; |
@@ -14,3 +14,3 @@ import { Container } from '@artus/injection'; | ||
unitName?: string; | ||
_loaderState?: LoaderState; | ||
loaderState?: LoaderState; | ||
} | ||
@@ -17,0 +17,0 @@ interface LoaderFindOptions { |
@@ -154,3 +154,3 @@ "use strict"; | ||
source: 'config', | ||
_loaderState: { | ||
loaderState: { | ||
baseDir, | ||
@@ -157,0 +157,0 @@ }, |
@@ -68,3 +68,3 @@ "use strict"; | ||
if (loaderState) { | ||
item._loaderState = loaderState; | ||
item.loaderState = loaderState; | ||
} | ||
@@ -71,0 +71,0 @@ unitName && (item.unitName = unitName); |
{ | ||
"name": "@artus/core", | ||
"version": "1.0.0-beta.22", | ||
"version": "1.0.0-beta.23", | ||
"description": "Core package of Artus", | ||
@@ -5,0 +5,0 @@ "main": "./lib/index.js", |
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
167706
2563