@eggjs/tegg-metadata 4.0.0-beta.4 → 4.0.0-beta.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +12 -0
- package/dist/errors.d.ts +18 -0
- package/dist/errors.js +29 -0
- package/dist/factory/EggPrototypeCreatorFactory.d.ts +13 -0
- package/dist/factory/EggPrototypeCreatorFactory.js +95 -0
- package/dist/factory/EggPrototypeFactory.d.ts +13 -0
- package/dist/factory/EggPrototypeFactory.js +41 -0
- package/dist/factory/LoadUnitFactory.d.ts +16 -0
- package/dist/factory/LoadUnitFactory.js +58 -0
- package/dist/factory/index.js +5 -0
- package/dist/impl/EggPrototypeBuilder.d.ts +26 -0
- package/dist/impl/EggPrototypeBuilder.js +115 -0
- package/dist/impl/EggPrototypeImpl.d.ts +28 -0
- package/dist/impl/EggPrototypeImpl.js +52 -0
- package/dist/impl/LoadUnitMultiInstanceProtoHook.d.ts +11 -0
- package/dist/impl/LoadUnitMultiInstanceProtoHook.js +16 -0
- package/dist/impl/ModuleLoadUnit.d.ts +38 -0
- package/dist/impl/ModuleLoadUnit.js +211 -0
- package/dist/impl/index.js +6 -0
- package/dist/index.d.ts +23 -0
- package/dist/index.js +28 -0
- package/dist/model/AppGraph.d.ts +42 -0
- package/dist/model/AppGraph.js +195 -0
- package/dist/model/EggPrototype.d.ts +7 -0
- package/dist/model/EggPrototype.js +7 -0
- package/dist/model/LoadUnit.d.ts +7 -0
- package/dist/model/LoadUnit.js +7 -0
- package/dist/model/ModuleDescriptor.d.ts +22 -0
- package/dist/model/ModuleDescriptor.js +33 -0
- package/dist/model/ProtoDescriptor/AbstractProtoDescriptor.d.ts +36 -0
- package/dist/model/ProtoDescriptor/AbstractProtoDescriptor.js +35 -0
- package/dist/model/ProtoDescriptor/ClassProtoDescriptor.d.ts +16 -0
- package/dist/model/ProtoDescriptor/ClassProtoDescriptor.js +27 -0
- package/dist/model/ProtoDescriptor/index.js +4 -0
- package/dist/model/ProtoDescriptorHelper.d.ts +30 -0
- package/dist/model/ProtoDescriptorHelper.js +113 -0
- package/dist/model/graph/GlobalGraph.d.ts +67 -0
- package/dist/model/graph/GlobalGraph.js +176 -0
- package/dist/model/graph/GlobalModuleNode.d.ts +29 -0
- package/dist/model/graph/GlobalModuleNode.js +42 -0
- package/dist/model/graph/GlobalModuleNodeBuilder.d.ts +17 -0
- package/dist/model/graph/GlobalModuleNodeBuilder.js +56 -0
- package/dist/model/graph/ProtoNode.d.ts +25 -0
- package/dist/model/graph/ProtoNode.js +43 -0
- package/dist/model/graph/ProtoSelector.d.ts +10 -0
- package/dist/model/graph/ProtoSelector.js +3 -0
- package/dist/model/graph/index.js +7 -0
- package/dist/model/index.js +15 -0
- package/dist/util/ClassUtil.d.ts +9 -0
- package/dist/util/ClassUtil.js +18 -0
- package/dist/util/index.js +3 -0
- package/package.json +27 -26
- package/src/errors.d.ts +0 -14
- package/src/errors.js +0 -27
- package/src/factory/EggPrototypeCreatorFactory.d.ts +0 -9
- package/src/factory/EggPrototypeCreatorFactory.js +0 -103
- package/src/factory/EggPrototypeFactory.d.ts +0 -9
- package/src/factory/EggPrototypeFactory.js +0 -52
- package/src/factory/LoadUnitFactory.d.ts +0 -12
- package/src/factory/LoadUnitFactory.js +0 -59
- package/src/factory/index.d.ts +0 -3
- package/src/factory/index.js +0 -4
- package/src/impl/EggPrototypeBuilder.d.ts +0 -22
- package/src/impl/EggPrototypeBuilder.js +0 -124
- package/src/impl/EggPrototypeImpl.d.ts +0 -24
- package/src/impl/EggPrototypeImpl.js +0 -53
- package/src/impl/LoadUnitMultiInstanceProtoHook.d.ts +0 -7
- package/src/impl/LoadUnitMultiInstanceProtoHook.js +0 -18
- package/src/impl/ModuleLoadUnit.d.ts +0 -35
- package/src/impl/ModuleLoadUnit.js +0 -268
- package/src/impl/index.d.ts +0 -4
- package/src/impl/index.js +0 -5
- package/src/index.d.ts +0 -6
- package/src/index.js +0 -7
- package/src/model/AppGraph.d.ts +0 -39
- package/src/model/AppGraph.js +0 -264
- package/src/model/EggPrototype.d.ts +0 -3
- package/src/model/EggPrototype.js +0 -3
- package/src/model/LoadUnit.d.ts +0 -3
- package/src/model/LoadUnit.js +0 -3
- package/src/model/ModuleDescriptor.d.ts +0 -18
- package/src/model/ModuleDescriptor.js +0 -38
- package/src/model/ProtoDescriptor/AbstractProtoDescriptor.d.ts +0 -32
- package/src/model/ProtoDescriptor/AbstractProtoDescriptor.js +0 -30
- package/src/model/ProtoDescriptor/ClassProtoDescriptor.d.ts +0 -12
- package/src/model/ProtoDescriptor/ClassProtoDescriptor.js +0 -30
- package/src/model/ProtoDescriptor/index.d.ts +0 -2
- package/src/model/ProtoDescriptor/index.js +0 -3
- package/src/model/ProtoDescriptorHelper.d.ts +0 -26
- package/src/model/ProtoDescriptorHelper.js +0 -129
- package/src/model/graph/GlobalGraph.d.ts +0 -63
- package/src/model/graph/GlobalGraph.js +0 -233
- package/src/model/graph/GlobalModuleNode.d.ts +0 -25
- package/src/model/graph/GlobalModuleNode.js +0 -38
- package/src/model/graph/GlobalModuleNodeBuilder.d.ts +0 -13
- package/src/model/graph/GlobalModuleNodeBuilder.js +0 -53
- package/src/model/graph/ProtoNode.d.ts +0 -19
- package/src/model/graph/ProtoNode.js +0 -37
- package/src/model/graph/ProtoSelector.d.ts +0 -6
- package/src/model/graph/ProtoSelector.js +0 -2
- package/src/model/graph/index.d.ts +0 -5
- package/src/model/graph/index.js +0 -6
- package/src/model/index.d.ts +0 -7
- package/src/model/index.js +0 -8
- package/src/util/ClassUtil.d.ts +0 -5
- package/src/util/ClassUtil.js +0 -17
- package/src/util/index.d.ts +0 -1
- package/src/util/index.js +0 -2
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { AbstractProtoDescriptor, AbstractProtoDescriptorOptions } from "./AbstractProtoDescriptor.js";
|
|
2
|
+
import { EggProtoImplClass, ProtoDescriptor } from "@eggjs/tegg-types";
|
|
3
|
+
|
|
4
|
+
//#region src/model/ProtoDescriptor/ClassProtoDescriptor.d.ts
|
|
5
|
+
interface ClassProtoDescriptorOptions extends Omit<AbstractProtoDescriptorOptions, 'type'> {
|
|
6
|
+
clazz: EggProtoImplClass;
|
|
7
|
+
}
|
|
8
|
+
declare class ClassProtoDescriptor extends AbstractProtoDescriptor {
|
|
9
|
+
clazz: EggProtoImplClass;
|
|
10
|
+
clazzName: string;
|
|
11
|
+
static isClassProtoDescriptor(descriptor: ProtoDescriptor): descriptor is ClassProtoDescriptor;
|
|
12
|
+
constructor(options: ClassProtoDescriptorOptions);
|
|
13
|
+
equal(protoDescriptor: ProtoDescriptor): boolean;
|
|
14
|
+
}
|
|
15
|
+
//#endregion
|
|
16
|
+
export { ClassProtoDescriptor, ClassProtoDescriptorOptions };
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { AbstractProtoDescriptor } from "./AbstractProtoDescriptor.js";
|
|
2
|
+
import { ProtoDescriptorType } from "@eggjs/tegg-types";
|
|
3
|
+
import { QualifierUtil } from "@eggjs/core-decorator";
|
|
4
|
+
|
|
5
|
+
//#region src/model/ProtoDescriptor/ClassProtoDescriptor.ts
|
|
6
|
+
var ClassProtoDescriptor = class ClassProtoDescriptor extends AbstractProtoDescriptor {
|
|
7
|
+
clazz;
|
|
8
|
+
clazzName;
|
|
9
|
+
static isClassProtoDescriptor(descriptor) {
|
|
10
|
+
return descriptor.type === ProtoDescriptorType.CLASS;
|
|
11
|
+
}
|
|
12
|
+
constructor(options) {
|
|
13
|
+
super({
|
|
14
|
+
type: ProtoDescriptorType.CLASS,
|
|
15
|
+
...options
|
|
16
|
+
});
|
|
17
|
+
this.clazz = options.clazz;
|
|
18
|
+
this.className = this.clazz.name;
|
|
19
|
+
}
|
|
20
|
+
equal(protoDescriptor) {
|
|
21
|
+
if (!ClassProtoDescriptor.isClassProtoDescriptor(protoDescriptor)) return false;
|
|
22
|
+
return this.clazz === protoDescriptor.clazz && this.name === protoDescriptor.name && this.accessLevel === protoDescriptor.accessLevel && this.initType === protoDescriptor.initType && this.instanceModuleName === protoDescriptor.instanceModuleName && QualifierUtil.equalQualifiers(this.qualifiers, protoDescriptor.qualifiers);
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
//#endregion
|
|
27
|
+
export { ClassProtoDescriptor };
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { ProtoSelectorContext } from "./graph/ProtoSelector.js";
|
|
2
|
+
import { EggProtoImplClass, MultiInstancePrototypeGetObjectsContext, ObjectInitTypeLike, ProtoDescriptor, QualifierInfo } from "@eggjs/tegg-types";
|
|
3
|
+
|
|
4
|
+
//#region src/model/ProtoDescriptorHelper.d.ts
|
|
5
|
+
declare class ProtoDescriptorHelper {
|
|
6
|
+
#private;
|
|
7
|
+
static addDefaultQualifier(qualifiers: QualifierInfo[], initType: ObjectInitTypeLike, loadUnitName: string): QualifierInfo[];
|
|
8
|
+
static createByMultiInstanceClazz(clazz: EggProtoImplClass, options: {
|
|
9
|
+
defineModuleName: string;
|
|
10
|
+
defineUnitPath: string;
|
|
11
|
+
instanceModuleName: string;
|
|
12
|
+
instanceDefineUnitPath: string;
|
|
13
|
+
}): Promise<ProtoDescriptor[]>;
|
|
14
|
+
static createByDynamicMultiInstanceClazz(clazz: EggProtoImplClass, options: {
|
|
15
|
+
defineModuleName: string;
|
|
16
|
+
defineUnitPath: string;
|
|
17
|
+
instanceModuleName: string;
|
|
18
|
+
instanceDefineUnitPath: string;
|
|
19
|
+
}): Promise<ProtoDescriptor[]>;
|
|
20
|
+
static createByStaticMultiInstanceClazz(clazz: EggProtoImplClass, options: {
|
|
21
|
+
defineModuleName: string;
|
|
22
|
+
defineUnitPath: string;
|
|
23
|
+
instanceModuleName: string;
|
|
24
|
+
instanceDefineUnitPath: string;
|
|
25
|
+
}): ProtoDescriptor[];
|
|
26
|
+
static createByInstanceClazz(clazz: EggProtoImplClass, ctx: MultiInstancePrototypeGetObjectsContext): ProtoDescriptor;
|
|
27
|
+
static selectProto(proto: ProtoDescriptor, ctx: ProtoSelectorContext): boolean;
|
|
28
|
+
}
|
|
29
|
+
//#endregion
|
|
30
|
+
export { ProtoDescriptorHelper };
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import { ClassProtoDescriptor } from "./ProtoDescriptor/ClassProtoDescriptor.js";
|
|
2
|
+
import "./ProtoDescriptor/index.js";
|
|
3
|
+
import "./graph/index.js";
|
|
4
|
+
import { AccessLevel, InitTypeQualifierAttribute, LoadUnitNameQualifierAttribute, MultiInstanceType } from "@eggjs/tegg-types";
|
|
5
|
+
import assert from "node:assert";
|
|
6
|
+
import { PrototypeUtil, QualifierUtil } from "@eggjs/core-decorator";
|
|
7
|
+
|
|
8
|
+
//#region src/model/ProtoDescriptorHelper.ts
|
|
9
|
+
var ProtoDescriptorHelper = class ProtoDescriptorHelper {
|
|
10
|
+
static addDefaultQualifier(qualifiers, initType, loadUnitName) {
|
|
11
|
+
const defaultQualifiers = [{
|
|
12
|
+
attribute: InitTypeQualifierAttribute,
|
|
13
|
+
value: initType
|
|
14
|
+
}, {
|
|
15
|
+
attribute: LoadUnitNameQualifierAttribute,
|
|
16
|
+
value: loadUnitName
|
|
17
|
+
}];
|
|
18
|
+
const res = [...qualifiers];
|
|
19
|
+
for (const defaultQualifier of defaultQualifiers) if (!qualifiers.find((t) => t.attribute === defaultQualifier.attribute)) res.push(defaultQualifier);
|
|
20
|
+
return res;
|
|
21
|
+
}
|
|
22
|
+
static async createByMultiInstanceClazz(clazz, options) {
|
|
23
|
+
assert(PrototypeUtil.isEggMultiInstancePrototype(clazz), `clazz ${clazz.name} is not MultiInstancePrototype`);
|
|
24
|
+
const type = PrototypeUtil.getEggMultiInstancePrototypeType(clazz);
|
|
25
|
+
if (type === MultiInstanceType.DYNAMIC) return await ProtoDescriptorHelper.createByDynamicMultiInstanceClazz(clazz, options);
|
|
26
|
+
else if (type === MultiInstanceType.STATIC) {
|
|
27
|
+
if (options.defineModuleName === options.instanceModuleName) return ProtoDescriptorHelper.createByStaticMultiInstanceClazz(clazz, options);
|
|
28
|
+
}
|
|
29
|
+
return [];
|
|
30
|
+
}
|
|
31
|
+
static async createByDynamicMultiInstanceClazz(clazz, options) {
|
|
32
|
+
assert(PrototypeUtil.isEggMultiInstancePrototype(clazz), `clazz ${clazz.name} is not MultiInstancePrototype`);
|
|
33
|
+
const instanceProperty = await PrototypeUtil.getDynamicMultiInstanceProperty(clazz, {
|
|
34
|
+
moduleName: options.instanceModuleName,
|
|
35
|
+
unitPath: options.instanceDefineUnitPath
|
|
36
|
+
});
|
|
37
|
+
assert(instanceProperty, `not found PrototypeInfo for clazz ${clazz.name}`);
|
|
38
|
+
return ProtoDescriptorHelper.#createByMultiInstanceClazz(clazz, instanceProperty, options);
|
|
39
|
+
}
|
|
40
|
+
static createByStaticMultiInstanceClazz(clazz, options) {
|
|
41
|
+
assert(PrototypeUtil.isEggMultiInstancePrototype(clazz), `clazz ${clazz.name} is not MultiInstancePrototype`);
|
|
42
|
+
const instanceProperty = PrototypeUtil.getStaticMultiInstanceProperty(clazz);
|
|
43
|
+
assert(instanceProperty, `not found PrototypeInfo for clazz ${clazz.name}`);
|
|
44
|
+
return ProtoDescriptorHelper.#createByMultiInstanceClazz(clazz, instanceProperty, options);
|
|
45
|
+
}
|
|
46
|
+
static #createByMultiInstanceClazz(clazz, instanceProperty, options) {
|
|
47
|
+
const res = [];
|
|
48
|
+
for (const obj of instanceProperty.objects) {
|
|
49
|
+
let qualifiers = QualifierUtil.mergeQualifiers(QualifierUtil.getProtoQualifiers(clazz), obj.qualifiers);
|
|
50
|
+
qualifiers = ProtoDescriptorHelper.addDefaultQualifier(qualifiers, instanceProperty.initType, options.instanceModuleName);
|
|
51
|
+
const injectObjects = PrototypeUtil.getInjectObjects(clazz).map((t) => {
|
|
52
|
+
const qualifiers$1 = QualifierUtil.getProperQualifiers(clazz, t.refName);
|
|
53
|
+
const instanceQualifier = obj.properQualifiers?.[t.refName] ?? [];
|
|
54
|
+
return {
|
|
55
|
+
...t,
|
|
56
|
+
qualifiers: QualifierUtil.mergeQualifiers(qualifiers$1, instanceQualifier)
|
|
57
|
+
};
|
|
58
|
+
});
|
|
59
|
+
res.push(new ClassProtoDescriptor({
|
|
60
|
+
name: obj.name,
|
|
61
|
+
accessLevel: instanceProperty.accessLevel,
|
|
62
|
+
initType: instanceProperty.initType,
|
|
63
|
+
protoImplType: instanceProperty.protoImplType,
|
|
64
|
+
qualifiers,
|
|
65
|
+
injectObjects,
|
|
66
|
+
instanceModuleName: options.instanceModuleName,
|
|
67
|
+
instanceDefineUnitPath: options.instanceDefineUnitPath,
|
|
68
|
+
defineModuleName: options.defineModuleName,
|
|
69
|
+
defineUnitPath: options.defineUnitPath,
|
|
70
|
+
clazz,
|
|
71
|
+
properQualifiers: obj.properQualifiers || {}
|
|
72
|
+
}));
|
|
73
|
+
}
|
|
74
|
+
return res;
|
|
75
|
+
}
|
|
76
|
+
static createByInstanceClazz(clazz, ctx) {
|
|
77
|
+
assert(PrototypeUtil.isEggPrototype(clazz), `clazz ${clazz.name} is not EggPrototype`);
|
|
78
|
+
assert(!PrototypeUtil.isEggMultiInstancePrototype(clazz), `clazz ${clazz.name} is not Prototype`);
|
|
79
|
+
const property = PrototypeUtil.getProperty(clazz);
|
|
80
|
+
assert(property, `not found PrototypeInfo for clazz ${clazz.name}`);
|
|
81
|
+
const protoQualifiers = ProtoDescriptorHelper.addDefaultQualifier(QualifierUtil.getProtoQualifiers(clazz), property.initType, ctx.moduleName);
|
|
82
|
+
const injectObjects = PrototypeUtil.getInjectObjects(clazz).map((t) => {
|
|
83
|
+
const qualifiers = QualifierUtil.getProperQualifiers(clazz, t.refName);
|
|
84
|
+
return {
|
|
85
|
+
...t,
|
|
86
|
+
qualifiers
|
|
87
|
+
};
|
|
88
|
+
});
|
|
89
|
+
return new ClassProtoDescriptor({
|
|
90
|
+
name: property.name,
|
|
91
|
+
protoImplType: property.protoImplType,
|
|
92
|
+
accessLevel: property.accessLevel,
|
|
93
|
+
initType: property.initType,
|
|
94
|
+
qualifiers: protoQualifiers,
|
|
95
|
+
injectObjects,
|
|
96
|
+
instanceDefineUnitPath: ctx.unitPath,
|
|
97
|
+
instanceModuleName: ctx.moduleName,
|
|
98
|
+
defineUnitPath: ctx.unitPath,
|
|
99
|
+
defineModuleName: ctx.moduleName,
|
|
100
|
+
clazz,
|
|
101
|
+
properQualifiers: {}
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
static selectProto(proto, ctx) {
|
|
105
|
+
if (proto.name !== ctx.name) return false;
|
|
106
|
+
if (proto.accessLevel !== AccessLevel.PUBLIC && proto.instanceModuleName !== ctx.moduleName) return false;
|
|
107
|
+
if (!QualifierUtil.matchQualifiers(proto.qualifiers, ctx.qualifiers)) return false;
|
|
108
|
+
return true;
|
|
109
|
+
}
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
//#endregion
|
|
113
|
+
export { ProtoDescriptorHelper };
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { ProtoDependencyMeta, ProtoNode } from "./ProtoNode.js";
|
|
2
|
+
import { GlobalModuleNode, ModuleDependencyMeta } from "./GlobalModuleNode.js";
|
|
3
|
+
import { ModuleDescriptor } from "../ModuleDescriptor.js";
|
|
4
|
+
import { Graph, GraphNode, ModuleReference } from "@eggjs/tegg-common-util";
|
|
5
|
+
import { InjectObjectDescriptor, ProtoDescriptor } from "@eggjs/tegg-types";
|
|
6
|
+
|
|
7
|
+
//#region src/model/graph/GlobalGraph.d.ts
|
|
8
|
+
interface GlobalGraphOptions {
|
|
9
|
+
strict?: boolean;
|
|
10
|
+
}
|
|
11
|
+
type GlobalGraphBuildHook = (globalGraph: GlobalGraph) => void;
|
|
12
|
+
/**
|
|
13
|
+
* Sort all prototypes and modules in app.
|
|
14
|
+
* - 1. LoaderFactory.loadApp: get ModuleDescriptors
|
|
15
|
+
* - 2. GlobalGraph.create: create global graph instance
|
|
16
|
+
* - 3. graph.build:
|
|
17
|
+
* - check duplicated prototypes exits
|
|
18
|
+
* - check inject object exists (only in strict mode,
|
|
19
|
+
* can register proto in hooks now, in next major version,
|
|
20
|
+
* should use load to create dynamic ProtoDescriptor and delete
|
|
21
|
+
* strict false options
|
|
22
|
+
* )
|
|
23
|
+
* - 4. graph.sort: build moduleConfigList and moduleProtoDescriptorMap
|
|
24
|
+
*/
|
|
25
|
+
declare class GlobalGraph {
|
|
26
|
+
#private;
|
|
27
|
+
/**
|
|
28
|
+
* Vertex: ModuleNode, collect prototypes in module
|
|
29
|
+
* Edge: ModuleDependencyMeta, prototype and it's inject object
|
|
30
|
+
* @private
|
|
31
|
+
*/
|
|
32
|
+
moduleGraph: Graph<GlobalModuleNode, ModuleDependencyMeta>;
|
|
33
|
+
/**
|
|
34
|
+
* Vertex: ProtoNode, collect all prototypes in app
|
|
35
|
+
* Edge: ProtoDependencyMeta, inject object
|
|
36
|
+
* @private
|
|
37
|
+
*/
|
|
38
|
+
protoGraph: Graph<ProtoNode, ProtoDependencyMeta>;
|
|
39
|
+
/**
|
|
40
|
+
* The order of the moduleConfigList is the order in which they are instantiated
|
|
41
|
+
*/
|
|
42
|
+
moduleConfigList: readonly ModuleReference[];
|
|
43
|
+
/**
|
|
44
|
+
* key: module name
|
|
45
|
+
* value: ProtoDescriptor in module, the order is the order in which they are instantiated
|
|
46
|
+
*/
|
|
47
|
+
moduleProtoDescriptorMap: Map<string, ProtoDescriptor[]>;
|
|
48
|
+
strict: boolean;
|
|
49
|
+
private buildHooks;
|
|
50
|
+
/**
|
|
51
|
+
* The global instance used in ModuleLoadUnit
|
|
52
|
+
*/
|
|
53
|
+
static instance?: GlobalGraph;
|
|
54
|
+
constructor(options?: GlobalGraphOptions);
|
|
55
|
+
registerBuildHook(hook: GlobalGraphBuildHook): void;
|
|
56
|
+
addModuleNode(moduleNode: GlobalModuleNode): void;
|
|
57
|
+
build(): void;
|
|
58
|
+
buildInjectEdge(moduleNode: GraphNode<GlobalModuleNode, ModuleDependencyMeta>, protoNode: GraphNode<ProtoNode, ProtoDependencyMeta>, injectObj: InjectObjectDescriptor): void;
|
|
59
|
+
addInject(moduleNode: GraphNode<GlobalModuleNode, ModuleDependencyMeta>, protoNode: GraphNode<ProtoNode, ProtoDependencyMeta>, injectNode: GraphNode<ProtoNode, ProtoDependencyMeta>, injectName: PropertyKey): void;
|
|
60
|
+
findInjectProto(proto: ProtoDescriptor, injectObject: InjectObjectDescriptor): ProtoDescriptor | undefined;
|
|
61
|
+
findDependencyProtoNode(proto: ProtoDescriptor, injectObject: InjectObjectDescriptor): GraphNode<ProtoNode, ProtoDependencyMeta> | undefined;
|
|
62
|
+
findModuleNode(moduleName: string): GraphNode<GlobalModuleNode, ModuleDependencyMeta>;
|
|
63
|
+
sort(): void;
|
|
64
|
+
static create(moduleDescriptors: ModuleDescriptor[], options?: GlobalGraphOptions): Promise<GlobalGraph>;
|
|
65
|
+
}
|
|
66
|
+
//#endregion
|
|
67
|
+
export { GlobalGraph, GlobalGraphBuildHook, GlobalGraphOptions };
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
import { EggPrototypeNotFound, MultiPrototypeFound } from "../../errors.js";
|
|
2
|
+
import { ProtoDependencyMeta, ProtoNode } from "./ProtoNode.js";
|
|
3
|
+
import { ModuleDependencyMeta } from "./GlobalModuleNode.js";
|
|
4
|
+
import { GlobalModuleNodeBuilder } from "./GlobalModuleNodeBuilder.js";
|
|
5
|
+
import { Graph, GraphNode } from "@eggjs/tegg-common-util";
|
|
6
|
+
import { InitTypeQualifierAttribute, LoadUnitNameQualifierAttribute, ObjectInitType } from "@eggjs/tegg-types";
|
|
7
|
+
import { FrameworkErrorFormater } from "egg-errors";
|
|
8
|
+
import { debuglog } from "node:util";
|
|
9
|
+
import { QualifierUtil } from "@eggjs/core-decorator";
|
|
10
|
+
|
|
11
|
+
//#region src/model/graph/GlobalGraph.ts
|
|
12
|
+
const debug = debuglog("tegg/core/metadata/model/graph/GlobalGraph");
|
|
13
|
+
/**
|
|
14
|
+
* Sort all prototypes and modules in app.
|
|
15
|
+
* - 1. LoaderFactory.loadApp: get ModuleDescriptors
|
|
16
|
+
* - 2. GlobalGraph.create: create global graph instance
|
|
17
|
+
* - 3. graph.build:
|
|
18
|
+
* - check duplicated prototypes exits
|
|
19
|
+
* - check inject object exists (only in strict mode,
|
|
20
|
+
* can register proto in hooks now, in next major version,
|
|
21
|
+
* should use load to create dynamic ProtoDescriptor and delete
|
|
22
|
+
* strict false options
|
|
23
|
+
* )
|
|
24
|
+
* - 4. graph.sort: build moduleConfigList and moduleProtoDescriptorMap
|
|
25
|
+
*/
|
|
26
|
+
var GlobalGraph = class GlobalGraph {
|
|
27
|
+
/**
|
|
28
|
+
* Vertex: ModuleNode, collect prototypes in module
|
|
29
|
+
* Edge: ModuleDependencyMeta, prototype and it's inject object
|
|
30
|
+
* @private
|
|
31
|
+
*/
|
|
32
|
+
moduleGraph;
|
|
33
|
+
/**
|
|
34
|
+
* Vertex: ProtoNode, collect all prototypes in app
|
|
35
|
+
* Edge: ProtoDependencyMeta, inject object
|
|
36
|
+
* @private
|
|
37
|
+
*/
|
|
38
|
+
protoGraph;
|
|
39
|
+
/**
|
|
40
|
+
* The order of the moduleConfigList is the order in which they are instantiated
|
|
41
|
+
*/
|
|
42
|
+
moduleConfigList;
|
|
43
|
+
/**
|
|
44
|
+
* key: module name
|
|
45
|
+
* value: ProtoDescriptor in module, the order is the order in which they are instantiated
|
|
46
|
+
*/
|
|
47
|
+
moduleProtoDescriptorMap;
|
|
48
|
+
strict;
|
|
49
|
+
buildHooks;
|
|
50
|
+
/**
|
|
51
|
+
* The global instance used in ModuleLoadUnit
|
|
52
|
+
*/
|
|
53
|
+
static instance;
|
|
54
|
+
constructor(options) {
|
|
55
|
+
this.moduleGraph = new Graph();
|
|
56
|
+
this.protoGraph = new Graph();
|
|
57
|
+
this.strict = options?.strict ?? false;
|
|
58
|
+
this.moduleProtoDescriptorMap = /* @__PURE__ */ new Map();
|
|
59
|
+
this.buildHooks = [];
|
|
60
|
+
}
|
|
61
|
+
registerBuildHook(hook) {
|
|
62
|
+
this.buildHooks.push(hook);
|
|
63
|
+
}
|
|
64
|
+
addModuleNode(moduleNode) {
|
|
65
|
+
if (!this.moduleGraph.addVertex(new GraphNode(moduleNode))) throw new Error(`duplicate module: ${moduleNode}`);
|
|
66
|
+
for (const protoNode of moduleNode.protos) if (!this.protoGraph.addVertex(protoNode)) throw new Error(`duplicate proto: ${protoNode.val}`);
|
|
67
|
+
}
|
|
68
|
+
build() {
|
|
69
|
+
for (const moduleNode of this.moduleGraph.nodes.values()) for (const protoNode of moduleNode.val.protos) for (const injectObj of protoNode.val.proto.injectObjects) this.buildInjectEdge(moduleNode, protoNode, injectObj);
|
|
70
|
+
for (const buildHook of this.buildHooks) buildHook(this);
|
|
71
|
+
}
|
|
72
|
+
buildInjectEdge(moduleNode, protoNode, injectObj) {
|
|
73
|
+
const injectProto = this.findDependencyProtoNode(protoNode.val.proto, injectObj);
|
|
74
|
+
if (!injectProto) {
|
|
75
|
+
if (!this.strict) return;
|
|
76
|
+
throw FrameworkErrorFormater.formatError(new EggPrototypeNotFound(injectObj.objName, protoNode.val.proto.instanceModuleName));
|
|
77
|
+
}
|
|
78
|
+
this.addInject(moduleNode, protoNode, injectProto, injectObj.objName);
|
|
79
|
+
}
|
|
80
|
+
addInject(moduleNode, protoNode, injectNode, injectName) {
|
|
81
|
+
this.protoGraph.addEdge(protoNode, injectNode, new ProtoDependencyMeta({ injectObj: injectName }));
|
|
82
|
+
const injectModule = this.findModuleNode(injectNode.val.proto.instanceModuleName);
|
|
83
|
+
if (!injectModule) {
|
|
84
|
+
if (!this.strict) return;
|
|
85
|
+
throw new Error(`not found module ${injectNode.val.proto.instanceModuleName}`);
|
|
86
|
+
}
|
|
87
|
+
if (moduleNode.val.id !== injectModule.val.id) this.moduleGraph.addEdge(moduleNode, injectModule, new ModuleDependencyMeta(protoNode.val.proto, injectName));
|
|
88
|
+
}
|
|
89
|
+
findInjectProto(proto, injectObject) {
|
|
90
|
+
return this.protoGraph.findToNode(ProtoNode.createProtoId(proto), new ProtoDependencyMeta({ injectObj: injectObject.objName }))?.val.proto;
|
|
91
|
+
}
|
|
92
|
+
#findDependencyProtoWithDefaultQualifiers(proto, injectObject, qualifiers) {
|
|
93
|
+
const result = [];
|
|
94
|
+
for (const node of this.protoGraph.nodes.values()) if (node.val.selectProto({
|
|
95
|
+
name: injectObject.objName,
|
|
96
|
+
qualifiers: QualifierUtil.mergeQualifiers(injectObject.qualifiers, qualifiers),
|
|
97
|
+
moduleName: proto.instanceModuleName
|
|
98
|
+
})) result.push(node);
|
|
99
|
+
return result;
|
|
100
|
+
}
|
|
101
|
+
findDependencyProtoNode(proto, injectObject) {
|
|
102
|
+
const protos = this.#findDependencyProtoWithDefaultQualifiers(proto, injectObject, []);
|
|
103
|
+
if (protos.length === 0) return;
|
|
104
|
+
if (protos.length === 1) return protos[0];
|
|
105
|
+
const protoWithContext = this.#findDependencyProtoWithDefaultQualifiers(proto, injectObject, [{
|
|
106
|
+
attribute: InitTypeQualifierAttribute,
|
|
107
|
+
value: ObjectInitType.CONTEXT
|
|
108
|
+
}]);
|
|
109
|
+
if (protoWithContext.length === 1) return protoWithContext[0];
|
|
110
|
+
const protoWithSelfInitType = this.#findDependencyProtoWithDefaultQualifiers(proto, injectObject, [{
|
|
111
|
+
attribute: InitTypeQualifierAttribute,
|
|
112
|
+
value: proto.initType
|
|
113
|
+
}]);
|
|
114
|
+
if (protoWithSelfInitType.length === 1) return protoWithSelfInitType[0];
|
|
115
|
+
if (!injectObject.qualifiers.find((t) => t.attribute === LoadUnitNameQualifierAttribute)) return this.findDependencyProtoNode(proto, {
|
|
116
|
+
...injectObject,
|
|
117
|
+
qualifiers: QualifierUtil.mergeQualifiers(injectObject.qualifiers, [{
|
|
118
|
+
attribute: LoadUnitNameQualifierAttribute,
|
|
119
|
+
value: proto.instanceModuleName
|
|
120
|
+
}])
|
|
121
|
+
});
|
|
122
|
+
throw FrameworkErrorFormater.formatError(new MultiPrototypeFound(injectObject.objName, injectObject.qualifiers));
|
|
123
|
+
}
|
|
124
|
+
findModuleNode(moduleName) {
|
|
125
|
+
for (const node of this.moduleGraph.nodes.values()) if (node.val.name === moduleName) return node;
|
|
126
|
+
}
|
|
127
|
+
#sortModule() {
|
|
128
|
+
const loopPath = this.moduleGraph.loopPath();
|
|
129
|
+
if (loopPath) throw new Error("module has recursive deps: " + loopPath);
|
|
130
|
+
debug("sortModule, loopPath: %o", loopPath);
|
|
131
|
+
this.moduleConfigList = this.moduleGraph.sort().filter((t) => {
|
|
132
|
+
return t.val.optional !== true || t.fromNodeMap.size > 0;
|
|
133
|
+
}).map((t) => {
|
|
134
|
+
return {
|
|
135
|
+
name: t.val.name,
|
|
136
|
+
path: t.val.unitPath,
|
|
137
|
+
optional: t.val.optional
|
|
138
|
+
};
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
#sortClazz() {
|
|
142
|
+
const loopPath = this.protoGraph.loopPath();
|
|
143
|
+
if (loopPath) throw new Error("proto has recursive deps: " + loopPath);
|
|
144
|
+
debug("sortClazz, loopPath: %o", loopPath);
|
|
145
|
+
for (const proto of this.protoGraph.sort()) {
|
|
146
|
+
const instanceModuleName = proto.val.proto.instanceModuleName;
|
|
147
|
+
let moduleProtoList = this.moduleProtoDescriptorMap.get(instanceModuleName);
|
|
148
|
+
if (!moduleProtoList) {
|
|
149
|
+
moduleProtoList = [];
|
|
150
|
+
this.moduleProtoDescriptorMap.set(instanceModuleName, moduleProtoList);
|
|
151
|
+
}
|
|
152
|
+
moduleProtoList.push(proto.val.proto);
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
sort() {
|
|
156
|
+
this.#sortModule();
|
|
157
|
+
this.#sortClazz();
|
|
158
|
+
}
|
|
159
|
+
static async create(moduleDescriptors, options) {
|
|
160
|
+
const graph = new GlobalGraph(options);
|
|
161
|
+
for (const moduleDescriptor of moduleDescriptors) {
|
|
162
|
+
const moduleNodeBuilder = new GlobalModuleNodeBuilder({
|
|
163
|
+
name: moduleDescriptor.name,
|
|
164
|
+
unitPath: moduleDescriptor.unitPath,
|
|
165
|
+
optional: moduleDescriptor.optional ?? false
|
|
166
|
+
});
|
|
167
|
+
for (const clazz of moduleDescriptor.clazzList) moduleNodeBuilder.addClazz(clazz);
|
|
168
|
+
for (const clazz of moduleDescriptor.multiInstanceClazzList) await moduleNodeBuilder.addMultiInstanceClazz(clazz, moduleDescriptor.name, moduleDescriptor.unitPath);
|
|
169
|
+
graph.addModuleNode(moduleNodeBuilder.build());
|
|
170
|
+
}
|
|
171
|
+
return graph;
|
|
172
|
+
}
|
|
173
|
+
};
|
|
174
|
+
|
|
175
|
+
//#endregion
|
|
176
|
+
export { GlobalGraph };
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { ProtoDependencyMeta, ProtoNode } from "./ProtoNode.js";
|
|
2
|
+
import { EdgeMeta, GraphNode, GraphNodeObj } from "@eggjs/tegg-common-util";
|
|
3
|
+
import { ProtoDescriptor } from "@eggjs/tegg-types";
|
|
4
|
+
|
|
5
|
+
//#region src/model/graph/GlobalModuleNode.d.ts
|
|
6
|
+
interface GlobalModuleNodeOptions {
|
|
7
|
+
name: string;
|
|
8
|
+
unitPath: string;
|
|
9
|
+
optional: boolean;
|
|
10
|
+
}
|
|
11
|
+
declare class ModuleDependencyMeta implements EdgeMeta {
|
|
12
|
+
readonly obj: ProtoDescriptor;
|
|
13
|
+
readonly injectObj: PropertyKey;
|
|
14
|
+
constructor(obj: ProtoDescriptor, injectObj: PropertyKey);
|
|
15
|
+
equal(meta: ModuleDependencyMeta): boolean;
|
|
16
|
+
toString(): string;
|
|
17
|
+
}
|
|
18
|
+
declare class GlobalModuleNode implements GraphNodeObj {
|
|
19
|
+
readonly id: string;
|
|
20
|
+
readonly name: string;
|
|
21
|
+
readonly unitPath: string;
|
|
22
|
+
readonly optional: boolean;
|
|
23
|
+
readonly protos: GraphNode<ProtoNode, ProtoDependencyMeta>[];
|
|
24
|
+
constructor(options: GlobalModuleNodeOptions);
|
|
25
|
+
addProto(proto: ProtoDescriptor): void;
|
|
26
|
+
toString(): string;
|
|
27
|
+
}
|
|
28
|
+
//#endregion
|
|
29
|
+
export { GlobalModuleNode, GlobalModuleNodeOptions, ModuleDependencyMeta };
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { ProtoNode } from "./ProtoNode.js";
|
|
2
|
+
import { GraphNode } from "@eggjs/tegg-common-util";
|
|
3
|
+
import "@eggjs/tegg-types";
|
|
4
|
+
|
|
5
|
+
//#region src/model/graph/GlobalModuleNode.ts
|
|
6
|
+
var ModuleDependencyMeta = class {
|
|
7
|
+
obj;
|
|
8
|
+
injectObj;
|
|
9
|
+
constructor(obj, injectObj) {
|
|
10
|
+
this.obj = obj;
|
|
11
|
+
this.injectObj = injectObj;
|
|
12
|
+
}
|
|
13
|
+
equal(meta) {
|
|
14
|
+
return this.obj.equal(meta.obj) && this.injectObj === meta.injectObj;
|
|
15
|
+
}
|
|
16
|
+
toString() {
|
|
17
|
+
return `Object ${String(this.obj.name)} inject ${String(this.injectObj)}`;
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
var GlobalModuleNode = class {
|
|
21
|
+
id;
|
|
22
|
+
name;
|
|
23
|
+
unitPath;
|
|
24
|
+
optional;
|
|
25
|
+
protos;
|
|
26
|
+
constructor(options) {
|
|
27
|
+
this.id = options.unitPath;
|
|
28
|
+
this.name = options.name;
|
|
29
|
+
this.unitPath = options.unitPath;
|
|
30
|
+
this.optional = options.optional;
|
|
31
|
+
this.protos = [];
|
|
32
|
+
}
|
|
33
|
+
addProto(proto) {
|
|
34
|
+
this.protos.push(new GraphNode(new ProtoNode(proto)));
|
|
35
|
+
}
|
|
36
|
+
toString() {
|
|
37
|
+
return `${this.name}@${this.unitPath}`;
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
//#endregion
|
|
42
|
+
export { GlobalModuleNode, ModuleDependencyMeta };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { GlobalModuleNode, GlobalModuleNodeOptions } from "./GlobalModuleNode.js";
|
|
2
|
+
import { EggProtoImplClass } from "@eggjs/tegg-types";
|
|
3
|
+
|
|
4
|
+
//#region src/model/graph/GlobalModuleNodeBuilder.d.ts
|
|
5
|
+
declare class GlobalModuleNodeBuilder {
|
|
6
|
+
private readonly name;
|
|
7
|
+
private readonly unitPath;
|
|
8
|
+
private readonly optional;
|
|
9
|
+
private readonly protos;
|
|
10
|
+
constructor(options: GlobalModuleNodeOptions);
|
|
11
|
+
addClazz(clazz: EggProtoImplClass): this;
|
|
12
|
+
addMultiInstanceClazz(clazz: EggProtoImplClass, defineModuleName: string, defineUnitPath: string): Promise<this>;
|
|
13
|
+
build(): GlobalModuleNode;
|
|
14
|
+
static create(unitPath: string, optional?: boolean): GlobalModuleNodeBuilder;
|
|
15
|
+
}
|
|
16
|
+
//#endregion
|
|
17
|
+
export { GlobalModuleNodeBuilder };
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { ProtoDescriptorHelper } from "../ProtoDescriptorHelper.js";
|
|
2
|
+
import { GlobalModuleNode } from "./GlobalModuleNode.js";
|
|
3
|
+
import { ModuleConfigUtil } from "@eggjs/tegg-common-util";
|
|
4
|
+
import "@eggjs/tegg-types";
|
|
5
|
+
|
|
6
|
+
//#region src/model/graph/GlobalModuleNodeBuilder.ts
|
|
7
|
+
var GlobalModuleNodeBuilder = class GlobalModuleNodeBuilder {
|
|
8
|
+
name;
|
|
9
|
+
unitPath;
|
|
10
|
+
optional;
|
|
11
|
+
protos;
|
|
12
|
+
constructor(options) {
|
|
13
|
+
this.name = options.name;
|
|
14
|
+
this.unitPath = options.unitPath;
|
|
15
|
+
this.optional = options.optional;
|
|
16
|
+
this.protos = [];
|
|
17
|
+
}
|
|
18
|
+
addClazz(clazz) {
|
|
19
|
+
const proto = ProtoDescriptorHelper.createByInstanceClazz(clazz, {
|
|
20
|
+
moduleName: this.name,
|
|
21
|
+
unitPath: this.unitPath
|
|
22
|
+
});
|
|
23
|
+
this.protos.push(proto);
|
|
24
|
+
return this;
|
|
25
|
+
}
|
|
26
|
+
async addMultiInstanceClazz(clazz, defineModuleName, defineUnitPath) {
|
|
27
|
+
const protos = await ProtoDescriptorHelper.createByMultiInstanceClazz(clazz, {
|
|
28
|
+
defineModuleName,
|
|
29
|
+
defineUnitPath,
|
|
30
|
+
instanceModuleName: this.name,
|
|
31
|
+
instanceDefineUnitPath: this.unitPath
|
|
32
|
+
});
|
|
33
|
+
this.protos.push(...protos);
|
|
34
|
+
return this;
|
|
35
|
+
}
|
|
36
|
+
build() {
|
|
37
|
+
const node = new GlobalModuleNode({
|
|
38
|
+
name: this.name,
|
|
39
|
+
unitPath: this.unitPath,
|
|
40
|
+
optional: this.optional
|
|
41
|
+
});
|
|
42
|
+
for (const proto of this.protos) node.addProto(proto);
|
|
43
|
+
return node;
|
|
44
|
+
}
|
|
45
|
+
static create(unitPath, optional = false) {
|
|
46
|
+
const name = ModuleConfigUtil.readModuleNameSync(unitPath);
|
|
47
|
+
return new GlobalModuleNodeBuilder({
|
|
48
|
+
name,
|
|
49
|
+
unitPath,
|
|
50
|
+
optional
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
//#endregion
|
|
56
|
+
export { GlobalModuleNodeBuilder };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { ProtoSelectorContext } from "./ProtoSelector.js";
|
|
2
|
+
import { EdgeMeta } from "@eggjs/tegg-common-util";
|
|
3
|
+
import { GraphNodeObj as GraphNodeObj$1, ProtoDescriptor } from "@eggjs/tegg-types";
|
|
4
|
+
|
|
5
|
+
//#region src/model/graph/ProtoNode.d.ts
|
|
6
|
+
declare class ProtoDependencyMeta implements EdgeMeta {
|
|
7
|
+
injectObj: PropertyKey;
|
|
8
|
+
constructor({
|
|
9
|
+
injectObj
|
|
10
|
+
}: {
|
|
11
|
+
injectObj: PropertyKey;
|
|
12
|
+
});
|
|
13
|
+
equal(meta: ProtoDependencyMeta): boolean;
|
|
14
|
+
toString(): string;
|
|
15
|
+
}
|
|
16
|
+
declare class ProtoNode implements GraphNodeObj$1 {
|
|
17
|
+
readonly id: string;
|
|
18
|
+
readonly proto: ProtoDescriptor;
|
|
19
|
+
constructor(proto: ProtoDescriptor);
|
|
20
|
+
toString(): string;
|
|
21
|
+
selectProto(ctx: ProtoSelectorContext): boolean;
|
|
22
|
+
static createProtoId(proto: ProtoDescriptor): string;
|
|
23
|
+
}
|
|
24
|
+
//#endregion
|
|
25
|
+
export { ProtoDependencyMeta, ProtoNode };
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { ProtoDescriptorHelper } from "../ProtoDescriptorHelper.js";
|
|
2
|
+
import "./ProtoSelector.js";
|
|
3
|
+
import "@eggjs/tegg-common-util";
|
|
4
|
+
import "@eggjs/tegg-types";
|
|
5
|
+
|
|
6
|
+
//#region src/model/graph/ProtoNode.ts
|
|
7
|
+
var ProtoDependencyMeta = class {
|
|
8
|
+
injectObj;
|
|
9
|
+
constructor({ injectObj }) {
|
|
10
|
+
this.injectObj = injectObj;
|
|
11
|
+
}
|
|
12
|
+
equal(meta) {
|
|
13
|
+
return this.injectObj === meta.injectObj;
|
|
14
|
+
}
|
|
15
|
+
toString() {
|
|
16
|
+
return `inject ${String(this.injectObj)}`;
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
var ProtoNode = class ProtoNode {
|
|
20
|
+
id;
|
|
21
|
+
proto;
|
|
22
|
+
constructor(proto) {
|
|
23
|
+
this.id = ProtoNode.createProtoId(proto);
|
|
24
|
+
this.proto = proto;
|
|
25
|
+
}
|
|
26
|
+
toString() {
|
|
27
|
+
return `${String(this.proto.name)}@${this.proto.instanceDefineUnitPath}`;
|
|
28
|
+
}
|
|
29
|
+
selectProto(ctx) {
|
|
30
|
+
return ProtoDescriptorHelper.selectProto(this.proto, ctx);
|
|
31
|
+
}
|
|
32
|
+
static createProtoId(proto) {
|
|
33
|
+
return [
|
|
34
|
+
proto.name,
|
|
35
|
+
proto.instanceModuleName,
|
|
36
|
+
proto.initType,
|
|
37
|
+
...proto.qualifiers.map((t) => String(t.attribute) + String(t.value))
|
|
38
|
+
].join("@");
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
//#endregion
|
|
43
|
+
export { ProtoDependencyMeta, ProtoNode };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { QualifierInfo } from "@eggjs/tegg-types";
|
|
2
|
+
|
|
3
|
+
//#region src/model/graph/ProtoSelector.d.ts
|
|
4
|
+
interface ProtoSelectorContext {
|
|
5
|
+
name: PropertyKey;
|
|
6
|
+
qualifiers: QualifierInfo[];
|
|
7
|
+
moduleName: string;
|
|
8
|
+
}
|
|
9
|
+
//#endregion
|
|
10
|
+
export { ProtoSelectorContext };
|