@eggjs/tegg-metadata
Advanced tools
Comparing version 3.43.1 to 3.43.2
@@ -1,2 +0,2 @@ | ||
import type { EggLoadUnitTypeLike, Id, LoadUnit, Loader, LoadUnitCreator } from '@eggjs/tegg-types'; | ||
import type { EggLoadUnitTypeLike, Id, LoadUnit, LoadUnitLifecycleContext, Loader, LoadUnitCreator } from '@eggjs/tegg-types'; | ||
export declare class LoadUnitFactory { | ||
@@ -6,3 +6,5 @@ private static loadUnitCreatorMap; | ||
private static loadUnitIdMap; | ||
protected static getLoanUnit(ctx: LoadUnitLifecycleContext, type: EggLoadUnitTypeLike): Promise<LoadUnit>; | ||
static createLoadUnit(unitPath: string, type: EggLoadUnitTypeLike, loader: Loader): Promise<LoadUnit>; | ||
static createPreloadLoadUnit(unitPath: string, type: EggLoadUnitTypeLike, loader: Loader): Promise<LoadUnit>; | ||
static destroyLoadUnit(loadUnit: LoadUnit): Promise<void>; | ||
@@ -9,0 +11,0 @@ static getLoadUnitById(id: Id): LoadUnit | undefined; |
@@ -6,10 +6,13 @@ "use strict"; | ||
class LoadUnitFactory { | ||
static async createLoadUnit(unitPath, type, loader) { | ||
if (this.loadUnitMap.has(unitPath)) { | ||
return this.loadUnitMap.get(unitPath).loadUnit; | ||
} | ||
const creator = this.loadUnitCreatorMap.get(type); | ||
static async getLoanUnit(ctx, type) { | ||
const creator = LoadUnitFactory.loadUnitCreatorMap.get(type); | ||
if (!creator) { | ||
throw new Error(`not find creator for load unit type ${type}`); | ||
} | ||
return await creator(ctx); | ||
} | ||
static async createLoadUnit(unitPath, type, loader) { | ||
if (LoadUnitFactory.loadUnitMap.has(unitPath)) { | ||
return LoadUnitFactory.loadUnitMap.get(unitPath).loadUnit; | ||
} | ||
const ctx = { | ||
@@ -19,3 +22,3 @@ unitPath, | ||
}; | ||
const loadUnit = await creator(ctx); | ||
const loadUnit = await LoadUnitFactory.getLoanUnit(ctx, type); | ||
await LoadUnit_1.LoadUnitLifecycleUtil.objectPreCreate(ctx, loadUnit); | ||
@@ -26,8 +29,15 @@ if (loadUnit.init) { | ||
await LoadUnit_1.LoadUnitLifecycleUtil.objectPostCreate(ctx, loadUnit); | ||
this.loadUnitMap.set(unitPath, { loadUnit, ctx }); | ||
this.loadUnitIdMap.set(loadUnit.id, loadUnit); | ||
LoadUnitFactory.loadUnitMap.set(unitPath, { loadUnit, ctx }); | ||
LoadUnitFactory.loadUnitIdMap.set(loadUnit.id, loadUnit); | ||
return loadUnit; | ||
} | ||
static async createPreloadLoadUnit(unitPath, type, loader) { | ||
const ctx = { | ||
unitPath, | ||
loader, | ||
}; | ||
return await LoadUnitFactory.getLoanUnit(ctx, type); | ||
} | ||
static async destroyLoadUnit(loadUnit) { | ||
const { ctx } = this.loadUnitMap.get(loadUnit.unitPath); | ||
const { ctx } = LoadUnitFactory.loadUnitMap.get(loadUnit.unitPath); | ||
try { | ||
@@ -40,4 +50,4 @@ await LoadUnit_1.LoadUnitLifecycleUtil.objectPreDestroy(ctx, loadUnit); | ||
finally { | ||
this.loadUnitMap.delete(loadUnit.unitPath); | ||
this.loadUnitIdMap.delete(loadUnit.id); | ||
LoadUnitFactory.loadUnitMap.delete(loadUnit.unitPath); | ||
LoadUnitFactory.loadUnitIdMap.delete(loadUnit.id); | ||
LoadUnit_1.LoadUnitLifecycleUtil.clearObjectLifecycle(loadUnit); | ||
@@ -47,6 +57,6 @@ } | ||
static getLoadUnitById(id) { | ||
return this.loadUnitIdMap.get(id); | ||
return LoadUnitFactory.loadUnitIdMap.get(id); | ||
} | ||
static registerLoadUnitCreator(type, creator) { | ||
this.loadUnitCreatorMap.set(type, creator); | ||
LoadUnitFactory.loadUnitCreatorMap.set(type, creator); | ||
} | ||
@@ -58,2 +68,2 @@ } | ||
LoadUnitFactory.loadUnitIdMap = new Map(); | ||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiTG9hZFVuaXRGYWN0b3J5LmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4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FHLEVBQUUsQ0FBQztBQUMxRSwyQkFBVyxHQUE4QixJQUFJLEdBQUcsRUFBRSxDQUFDO0FBQ25ELDZCQUFhLEdBQXNCLElBQUksR0FBRyxFQUFFLENBQUMifQ== |
{ | ||
"name": "@eggjs/tegg-metadata", | ||
"version": "3.43.1", | ||
"version": "3.43.2", | ||
"description": "tegg metadata", | ||
@@ -38,6 +38,6 @@ "keywords": [ | ||
"dependencies": { | ||
"@eggjs/core-decorator": "^3.43.1", | ||
"@eggjs/tegg-common-util": "^3.43.1", | ||
"@eggjs/tegg-lifecycle": "^3.43.1", | ||
"@eggjs/tegg-types": "^3.43.1", | ||
"@eggjs/core-decorator": "^3.43.2", | ||
"@eggjs/tegg-common-util": "^3.43.2", | ||
"@eggjs/tegg-lifecycle": "^3.43.2", | ||
"@eggjs/tegg-types": "^3.43.2", | ||
"egg-errors": "^2.2.3" | ||
@@ -58,3 +58,3 @@ }, | ||
}, | ||
"gitHead": "c4338979552fc6fa52fc1a5c1b41e3696019712e" | ||
"gitHead": "6e13b2697b3356681ca649b0d89d4b88163694dd" | ||
} |
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
86885
1048