@eggjs/metadata 4.0.0-beta.34 → 4.0.0-beta.36
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/dist/errors.d.ts +14 -10
- package/dist/errors.js +29 -27
- package/dist/factory/EggPrototypeCreatorFactory.d.ts +13 -8
- package/dist/factory/EggPrototypeCreatorFactory.js +94 -111
- package/dist/factory/EggPrototypeFactory.d.ts +12 -8
- package/dist/factory/EggPrototypeFactory.js +40 -51
- package/dist/factory/LoadUnitFactory.d.ts +15 -11
- package/dist/factory/LoadUnitFactory.js +58 -59
- package/dist/factory/index.d.ts +3 -3
- package/dist/factory/index.js +5 -4
- package/dist/impl/EggPrototypeBuilder.d.ts +25 -21
- package/dist/impl/EggPrototypeBuilder.js +112 -127
- package/dist/impl/EggPrototypeImpl.d.ts +27 -23
- package/dist/impl/EggPrototypeImpl.js +52 -53
- package/dist/impl/LoadUnitMultiInstanceProtoHook.d.ts +10 -6
- package/dist/impl/LoadUnitMultiInstanceProtoHook.js +16 -18
- package/dist/impl/ModuleLoadUnit.d.ts +37 -33
- package/dist/impl/ModuleLoadUnit.js +208 -261
- package/dist/impl/index.d.ts +4 -4
- package/dist/impl/index.js +6 -5
- package/dist/index.d.ts +27 -6
- package/dist/index.js +28 -7
- package/dist/model/AppGraph.d.ts +38 -35
- package/dist/model/AppGraph.js +190 -253
- package/dist/model/EggPrototype.d.ts +7 -3
- package/dist/model/EggPrototype.js +7 -3
- package/dist/model/LoadUnit.d.ts +7 -3
- package/dist/model/LoadUnit.js +7 -3
- package/dist/model/ModuleDescriptor.d.ts +19 -15
- package/dist/model/ModuleDescriptor.js +32 -46
- package/dist/model/ProtoDescriptor/AbstractProtoDescriptor.d.ts +34 -30
- package/dist/model/ProtoDescriptor/AbstractProtoDescriptor.js +35 -31
- package/dist/model/ProtoDescriptor/ClassProtoDescriptor.d.ts +14 -10
- package/dist/model/ProtoDescriptor/ClassProtoDescriptor.js +26 -29
- package/dist/model/ProtoDescriptor/index.d.ts +2 -2
- package/dist/model/ProtoDescriptor/index.js +4 -3
- package/dist/model/ProtoDescriptorHelper.d.ts +30 -25
- package/dist/model/ProtoDescriptorHelper.js +113 -129
- package/dist/model/graph/GlobalGraph.d.ts +64 -60
- package/dist/model/graph/GlobalGraph.js +172 -236
- package/dist/model/graph/GlobalModuleNode.d.ts +26 -22
- package/dist/model/graph/GlobalModuleNode.js +42 -38
- package/dist/model/graph/GlobalModuleNodeBuilder.d.ts +16 -12
- package/dist/model/graph/GlobalModuleNodeBuilder.js +53 -52
- package/dist/model/graph/ProtoNode.d.ts +22 -16
- package/dist/model/graph/ProtoNode.js +42 -39
- package/dist/model/graph/ProtoSelector.d.ts +9 -5
- package/dist/model/graph/ProtoSelector.js +3 -2
- package/dist/model/graph/index.d.ts +5 -5
- package/dist/model/graph/index.js +7 -6
- package/dist/model/index.d.ts +14 -7
- package/dist/model/index.js +15 -8
- package/dist/util/ClassUtil.d.ts +8 -4
- package/dist/util/ClassUtil.js +18 -17
- package/dist/util/index.d.ts +1 -1
- package/dist/util/index.js +3 -2
- package/package.json +29 -33
package/dist/factory/index.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import { EggPrototypeFactory } from "./EggPrototypeFactory.js";
|
|
2
|
+
import { EggPrototypeCreatorFactory } from "./EggPrototypeCreatorFactory.js";
|
|
3
|
+
import { LoadUnitFactory } from "./LoadUnitFactory.js";
|
|
4
|
+
|
|
5
|
+
export { };
|
|
@@ -1,22 +1,26 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
1
|
+
import { EggPrototype, EggPrototypeLifecycleContext } from "@eggjs/tegg-types";
|
|
2
|
+
|
|
3
|
+
//#region src/impl/EggPrototypeBuilder.d.ts
|
|
4
|
+
declare class EggPrototypeBuilder {
|
|
5
|
+
private clazz;
|
|
6
|
+
private name;
|
|
7
|
+
private initType;
|
|
8
|
+
private accessLevel;
|
|
9
|
+
private filepath;
|
|
10
|
+
private injectType;
|
|
11
|
+
private injectObjects;
|
|
12
|
+
private loadUnit;
|
|
13
|
+
private qualifiers;
|
|
14
|
+
private properQualifiers;
|
|
15
|
+
private className?;
|
|
16
|
+
private multiInstanceConstructorIndex?;
|
|
17
|
+
private multiInstanceConstructorAttributes?;
|
|
18
|
+
static create(ctx: EggPrototypeLifecycleContext): EggPrototype;
|
|
19
|
+
private tryFindDefaultPrototype;
|
|
20
|
+
private tryFindContextPrototype;
|
|
21
|
+
private tryFindSelfInitTypePrototype;
|
|
22
|
+
private findInjectObjectPrototype;
|
|
23
|
+
build(): EggPrototype;
|
|
22
24
|
}
|
|
25
|
+
//#endregion
|
|
26
|
+
export { EggPrototypeBuilder };
|
|
@@ -1,129 +1,114 @@
|
|
|
1
|
-
import assert from 'node:assert';
|
|
2
|
-
import { InjectType, PrototypeUtil, QualifierUtil } from '@eggjs/core-decorator';
|
|
3
|
-
import { DEFAULT_PROTO_IMPL_TYPE, InitTypeQualifierAttribute, ObjectInitType, } from '@eggjs/tegg-types';
|
|
4
|
-
import { IdenticalUtil } from '@eggjs/lifecycle';
|
|
5
|
-
import { EggPrototypeFactory, EggPrototypeCreatorFactory } from "../factory/index.js";
|
|
6
|
-
import { EggPrototypeImpl } from "./EggPrototypeImpl.js";
|
|
7
1
|
import { EggPrototypeNotFound, MultiPrototypeFound } from "../errors.js";
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
catch (e) {
|
|
118
|
-
if (e instanceof EggPrototypeNotFound && injectObject.optional) {
|
|
119
|
-
continue;
|
|
120
|
-
}
|
|
121
|
-
throw e;
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
const id = IdenticalUtil.createProtoId(this.loadUnit.id, this.name);
|
|
125
|
-
return new EggPrototypeImpl(id, this.name, this.clazz, this.filepath, this.initType, this.accessLevel, injectObjectProtos, this.loadUnit.id, this.qualifiers, this.className, this.injectType, this.multiInstanceConstructorIndex, this.multiInstanceConstructorAttributes);
|
|
126
|
-
}
|
|
127
|
-
}
|
|
2
|
+
import { EggPrototypeFactory } from "../factory/EggPrototypeFactory.js";
|
|
3
|
+
import { EggPrototypeCreatorFactory } from "../factory/EggPrototypeCreatorFactory.js";
|
|
4
|
+
import "../factory/index.js";
|
|
5
|
+
import { EggPrototypeImpl } from "./EggPrototypeImpl.js";
|
|
6
|
+
import { DEFAULT_PROTO_IMPL_TYPE, InitTypeQualifierAttribute, ObjectInitType } from "@eggjs/tegg-types";
|
|
7
|
+
import assert from "node:assert";
|
|
8
|
+
import { InjectType, PrototypeUtil, QualifierUtil } from "@eggjs/core-decorator";
|
|
9
|
+
import { IdenticalUtil } from "@eggjs/lifecycle";
|
|
10
|
+
|
|
11
|
+
//#region src/impl/EggPrototypeBuilder.ts
|
|
12
|
+
var EggPrototypeBuilder = class EggPrototypeBuilder {
|
|
13
|
+
clazz;
|
|
14
|
+
name;
|
|
15
|
+
initType;
|
|
16
|
+
accessLevel;
|
|
17
|
+
filepath;
|
|
18
|
+
injectType;
|
|
19
|
+
injectObjects = [];
|
|
20
|
+
loadUnit;
|
|
21
|
+
qualifiers = [];
|
|
22
|
+
properQualifiers = {};
|
|
23
|
+
className;
|
|
24
|
+
multiInstanceConstructorIndex;
|
|
25
|
+
multiInstanceConstructorAttributes;
|
|
26
|
+
static create(ctx) {
|
|
27
|
+
const { clazz, loadUnit } = ctx;
|
|
28
|
+
const filepath = PrototypeUtil.getFilePath(clazz);
|
|
29
|
+
assert(filepath, "not find filepath");
|
|
30
|
+
const builder = new EggPrototypeBuilder();
|
|
31
|
+
builder.clazz = clazz;
|
|
32
|
+
builder.name = ctx.prototypeInfo.name;
|
|
33
|
+
builder.className = ctx.prototypeInfo.className;
|
|
34
|
+
builder.initType = ctx.prototypeInfo.initType;
|
|
35
|
+
builder.accessLevel = ctx.prototypeInfo.accessLevel;
|
|
36
|
+
builder.filepath = filepath;
|
|
37
|
+
builder.injectType = PrototypeUtil.getInjectType(clazz);
|
|
38
|
+
builder.injectObjects = PrototypeUtil.getInjectObjects(clazz) || [];
|
|
39
|
+
builder.loadUnit = loadUnit;
|
|
40
|
+
builder.qualifiers = QualifierUtil.mergeQualifiers(QualifierUtil.getProtoQualifiers(clazz), ctx.prototypeInfo.qualifiers ?? []);
|
|
41
|
+
builder.properQualifiers = ctx.prototypeInfo.properQualifiers ?? {};
|
|
42
|
+
builder.multiInstanceConstructorIndex = PrototypeUtil.getMultiInstanceConstructorIndex(clazz);
|
|
43
|
+
builder.multiInstanceConstructorAttributes = PrototypeUtil.getMultiInstanceConstructorAttributes(clazz);
|
|
44
|
+
return builder.build();
|
|
45
|
+
}
|
|
46
|
+
tryFindDefaultPrototype(injectObject) {
|
|
47
|
+
const propertyQualifiers = QualifierUtil.getProperQualifiers(this.clazz, injectObject.refName);
|
|
48
|
+
const multiInstancePropertyQualifiers = this.properQualifiers[injectObject.refName] ?? [];
|
|
49
|
+
return EggPrototypeFactory.instance.getPrototype(injectObject.objName, this.loadUnit, QualifierUtil.mergeQualifiers(propertyQualifiers, multiInstancePropertyQualifiers));
|
|
50
|
+
}
|
|
51
|
+
tryFindContextPrototype(injectObject) {
|
|
52
|
+
const propertyQualifiers = QualifierUtil.getProperQualifiers(this.clazz, injectObject.refName);
|
|
53
|
+
const multiInstancePropertyQualifiers = this.properQualifiers[injectObject.refName] ?? [];
|
|
54
|
+
return EggPrototypeFactory.instance.getPrototype(injectObject.objName, this.loadUnit, QualifierUtil.mergeQualifiers(propertyQualifiers, multiInstancePropertyQualifiers, [{
|
|
55
|
+
attribute: InitTypeQualifierAttribute,
|
|
56
|
+
value: ObjectInitType.CONTEXT
|
|
57
|
+
}]));
|
|
58
|
+
}
|
|
59
|
+
tryFindSelfInitTypePrototype(injectObject) {
|
|
60
|
+
const propertyQualifiers = QualifierUtil.getProperQualifiers(this.clazz, injectObject.refName);
|
|
61
|
+
const multiInstancePropertyQualifiers = this.properQualifiers[injectObject.refName] ?? [];
|
|
62
|
+
return EggPrototypeFactory.instance.getPrototype(injectObject.objName, this.loadUnit, QualifierUtil.mergeQualifiers(propertyQualifiers, multiInstancePropertyQualifiers, [{
|
|
63
|
+
attribute: InitTypeQualifierAttribute,
|
|
64
|
+
value: this.initType
|
|
65
|
+
}]));
|
|
66
|
+
}
|
|
67
|
+
findInjectObjectPrototype(injectObject) {
|
|
68
|
+
const propertyQualifiers = QualifierUtil.getProperQualifiers(this.clazz, injectObject.refName);
|
|
69
|
+
try {
|
|
70
|
+
return this.tryFindDefaultPrototype(injectObject);
|
|
71
|
+
} catch (e) {
|
|
72
|
+
if (!(e instanceof MultiPrototypeFound && !propertyQualifiers.find((t) => t.attribute === InitTypeQualifierAttribute))) throw e;
|
|
73
|
+
}
|
|
74
|
+
try {
|
|
75
|
+
return this.tryFindContextPrototype(injectObject);
|
|
76
|
+
} catch (e) {
|
|
77
|
+
if (!(e instanceof EggPrototypeNotFound)) throw e;
|
|
78
|
+
}
|
|
79
|
+
return this.tryFindSelfInitTypePrototype(injectObject);
|
|
80
|
+
}
|
|
81
|
+
build() {
|
|
82
|
+
const injectObjectProtos = [];
|
|
83
|
+
for (const injectObject of this.injectObjects) {
|
|
84
|
+
const propertyQualifiers = QualifierUtil.getProperQualifiers(this.clazz, injectObject.refName);
|
|
85
|
+
try {
|
|
86
|
+
const proto = this.findInjectObjectPrototype(injectObject);
|
|
87
|
+
let injectObjectProto;
|
|
88
|
+
if (this.injectType === InjectType.PROPERTY) injectObjectProto = {
|
|
89
|
+
refName: injectObject.refName,
|
|
90
|
+
objName: injectObject.objName,
|
|
91
|
+
qualifiers: propertyQualifiers,
|
|
92
|
+
proto
|
|
93
|
+
};
|
|
94
|
+
else injectObjectProto = {
|
|
95
|
+
refIndex: injectObject.refIndex,
|
|
96
|
+
refName: injectObject.refName,
|
|
97
|
+
objName: injectObject.objName,
|
|
98
|
+
qualifiers: propertyQualifiers,
|
|
99
|
+
proto
|
|
100
|
+
};
|
|
101
|
+
if (injectObject.optional) injectObject.optional = true;
|
|
102
|
+
injectObjectProtos.push(injectObjectProto);
|
|
103
|
+
} catch (e) {
|
|
104
|
+
if (e instanceof EggPrototypeNotFound && injectObject.optional) continue;
|
|
105
|
+
throw e;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
return new EggPrototypeImpl(IdenticalUtil.createProtoId(this.loadUnit.id, this.name), this.name, this.clazz, this.filepath, this.initType, this.accessLevel, injectObjectProtos, this.loadUnit.id, this.qualifiers, this.className, this.injectType, this.multiInstanceConstructorIndex, this.multiInstanceConstructorAttributes);
|
|
109
|
+
}
|
|
110
|
+
};
|
|
128
111
|
EggPrototypeCreatorFactory.registerPrototypeCreator(DEFAULT_PROTO_IMPL_TYPE, EggPrototypeBuilder.create);
|
|
129
|
-
|
|
112
|
+
|
|
113
|
+
//#endregion
|
|
114
|
+
export { EggPrototypeBuilder };
|
|
@@ -1,24 +1,28 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
1
|
+
import { AccessLevel, EggProtoImplClass, EggPrototype, EggPrototypeName, Id, InjectConstructorProto, InjectObjectProto, MetaDataKey, ObjectInitTypeLike, QualifierInfo, QualifierValue } from "@eggjs/tegg-types";
|
|
2
|
+
import { InjectType, QualifierAttribute } from "@eggjs/core-decorator";
|
|
3
|
+
|
|
4
|
+
//#region src/impl/EggPrototypeImpl.d.ts
|
|
5
|
+
declare class EggPrototypeImpl implements EggPrototype {
|
|
6
|
+
private readonly clazz;
|
|
7
|
+
private readonly qualifiers;
|
|
8
|
+
readonly filepath: string;
|
|
9
|
+
readonly id: string;
|
|
10
|
+
readonly name: EggPrototypeName;
|
|
11
|
+
readonly initType: ObjectInitTypeLike;
|
|
12
|
+
readonly accessLevel: AccessLevel;
|
|
13
|
+
readonly injectObjects: Array<InjectObjectProto | InjectConstructorProto>;
|
|
14
|
+
readonly injectType: InjectType;
|
|
15
|
+
readonly loadUnitId: Id;
|
|
16
|
+
readonly className?: string;
|
|
17
|
+
readonly multiInstanceConstructorIndex?: number;
|
|
18
|
+
readonly multiInstanceConstructorAttributes?: QualifierAttribute[];
|
|
19
|
+
[key: symbol]: PropertyDescriptor;
|
|
20
|
+
constructor(id: string, name: EggPrototypeName, clazz: EggProtoImplClass, filepath: string, initType: ObjectInitTypeLike, accessLevel: AccessLevel, injectObjectMap: Array<InjectObjectProto | InjectConstructorProto>, loadUnitId: Id, qualifiers: QualifierInfo[], className?: string, injectType?: InjectType, multiInstanceConstructorIndex?: number, multiInstanceConstructorAttributes?: QualifierAttribute[]);
|
|
21
|
+
verifyQualifiers(qualifiers: QualifierInfo[]): boolean;
|
|
22
|
+
verifyQualifier(qualifier: QualifierInfo): boolean;
|
|
23
|
+
getQualifier(attribute: string): QualifierValue | undefined;
|
|
24
|
+
constructEggObject(...args: any): object;
|
|
25
|
+
getMetaData<T>(metadataKey: MetaDataKey): T | undefined;
|
|
24
26
|
}
|
|
27
|
+
//#endregion
|
|
28
|
+
export { EggPrototypeImpl };
|
|
@@ -1,53 +1,52 @@
|
|
|
1
|
-
import { InjectType, MetadataUtil } from
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
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;
|
|
10
|
+
initType;
|
|
11
|
+
accessLevel;
|
|
12
|
+
injectObjects;
|
|
13
|
+
injectType;
|
|
14
|
+
loadUnitId;
|
|
15
|
+
className;
|
|
16
|
+
multiInstanceConstructorIndex;
|
|
17
|
+
multiInstanceConstructorAttributes;
|
|
18
|
+
constructor(id, name, clazz, filepath, initType, accessLevel, injectObjectMap, loadUnitId, qualifiers, className, injectType, multiInstanceConstructorIndex, multiInstanceConstructorAttributes) {
|
|
19
|
+
this.id = id;
|
|
20
|
+
this.clazz = clazz;
|
|
21
|
+
this.name = name;
|
|
22
|
+
this.filepath = filepath;
|
|
23
|
+
this.initType = initType;
|
|
24
|
+
this.accessLevel = accessLevel;
|
|
25
|
+
this.injectObjects = injectObjectMap;
|
|
26
|
+
this.loadUnitId = loadUnitId;
|
|
27
|
+
this.qualifiers = qualifiers;
|
|
28
|
+
this.className = className;
|
|
29
|
+
this.injectType = injectType || InjectType.PROPERTY;
|
|
30
|
+
this.multiInstanceConstructorIndex = multiInstanceConstructorIndex;
|
|
31
|
+
this.multiInstanceConstructorAttributes = multiInstanceConstructorAttributes;
|
|
32
|
+
}
|
|
33
|
+
verifyQualifiers(qualifiers) {
|
|
34
|
+
for (const qualifier of qualifiers) if (!this.verifyQualifier(qualifier)) return false;
|
|
35
|
+
return true;
|
|
36
|
+
}
|
|
37
|
+
verifyQualifier(qualifier) {
|
|
38
|
+
return this.qualifiers.find((t) => t.attribute === qualifier.attribute)?.value === qualifier.value;
|
|
39
|
+
}
|
|
40
|
+
getQualifier(attribute) {
|
|
41
|
+
return this.qualifiers.find((t) => t.attribute === attribute)?.value;
|
|
42
|
+
}
|
|
43
|
+
constructEggObject(...args) {
|
|
44
|
+
return Reflect.construct(this.clazz, args);
|
|
45
|
+
}
|
|
46
|
+
getMetaData(metadataKey) {
|
|
47
|
+
return MetadataUtil.getMetaData(metadataKey, this.clazz);
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
//#endregion
|
|
52
|
+
export { EggPrototypeImpl };
|
|
@@ -1,7 +1,11 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import { EggProtoImplClass, LifecycleHook, LoadUnit, LoadUnitLifecycleContext } from "@eggjs/tegg-types";
|
|
2
|
+
|
|
3
|
+
//#region src/impl/LoadUnitMultiInstanceProtoHook.d.ts
|
|
4
|
+
declare class LoadUnitMultiInstanceProtoHook implements LifecycleHook<LoadUnitLifecycleContext, LoadUnit> {
|
|
5
|
+
static multiInstanceClazzSet: Set<EggProtoImplClass>;
|
|
6
|
+
static setAllClassList(clazzList: readonly EggProtoImplClass[]): void;
|
|
7
|
+
static clear(): void;
|
|
8
|
+
preCreate(): Promise<void>;
|
|
7
9
|
}
|
|
10
|
+
//#endregion
|
|
11
|
+
export { LoadUnitMultiInstanceProtoHook };
|
|
@@ -1,18 +1,16 @@
|
|
|
1
|
-
import { PrototypeUtil } from
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
}
|
|
18
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiTG9hZFVuaXRNdWx0aUluc3RhbmNlUHJvdG9Ib29rLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL2ltcGwvTG9hZFVuaXRNdWx0aUluc3RhbmNlUHJvdG9Ib29rLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sRUFBRSxhQUFhLEVBQUUsTUFBTSx1QkFBdUIsQ0FBQztBQUd0RCxNQUFNLE9BQU8sOEJBQThCO0lBQ3pDLE1BQU0sQ0FBQyxxQkFBcUIsR0FBMkIsSUFBSSxHQUFHLEVBQUUsQ0FBQztJQUVqRSxNQUFNLENBQUMsZUFBZSxDQUFDLFNBQXVDO1FBQzVELEtBQUssTUFBTSxLQUFLLElBQUksU0FBUyxFQUFFLENBQUM7WUFDOUIsSUFBSSxhQUFhLENBQUMsMkJBQTJCLENBQUMsS0FBSyxDQUFDLEVBQUUsQ0FBQztnQkFDckQsSUFBSSxDQUFDLHFCQUFxQixDQUFDLEdBQUcsQ0FBQyxLQUFLLENBQUMsQ0FBQztZQUN4QyxDQUFDO1FBQ0gsQ0FBQztJQUNILENBQUM7SUFFRCxNQUFNLENBQUMsS0FBSztRQUNWLElBQUksQ0FBQyxxQkFBcUIsQ0FBQyxLQUFLLEVBQUUsQ0FBQztJQUNyQyxDQUFDO0lBRUQsS0FBSyxDQUFDLFNBQVM7UUFDYixNQUFNO0lBQ1IsQ0FBQyJ9
|
|
1
|
+
import { PrototypeUtil } from "@eggjs/core-decorator";
|
|
2
|
+
|
|
3
|
+
//#region src/impl/LoadUnitMultiInstanceProtoHook.ts
|
|
4
|
+
var LoadUnitMultiInstanceProtoHook = class {
|
|
5
|
+
static multiInstanceClazzSet = /* @__PURE__ */ new Set();
|
|
6
|
+
static setAllClassList(clazzList) {
|
|
7
|
+
for (const clazz of clazzList) if (PrototypeUtil.isEggMultiInstancePrototype(clazz)) this.multiInstanceClazzSet.add(clazz);
|
|
8
|
+
}
|
|
9
|
+
static clear() {
|
|
10
|
+
this.multiInstanceClazzSet.clear();
|
|
11
|
+
}
|
|
12
|
+
async preCreate() {}
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
//#endregion
|
|
16
|
+
export { LoadUnitMultiInstanceProtoHook };
|
|
@@ -1,35 +1,39 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
1
|
+
import { GlobalGraph } from "../model/graph/GlobalGraph.js";
|
|
2
|
+
import "../model/index.js";
|
|
3
|
+
import { EggLoadUnitType, EggProtoImplClass, EggPrototype, LoadUnit, LoadUnitLifecycleContext, QualifierInfo } from "@eggjs/tegg-types";
|
|
4
|
+
|
|
5
|
+
//#region src/impl/ModuleLoadUnit.d.ts
|
|
6
|
+
declare class ModuleGraph {
|
|
7
|
+
private graph;
|
|
8
|
+
clazzList: EggProtoImplClass[];
|
|
9
|
+
readonly unitPath: string;
|
|
10
|
+
readonly name: string;
|
|
11
|
+
constructor(clazzList: EggProtoImplClass[], unitPath: string, name: string);
|
|
12
|
+
private findInjectNode;
|
|
13
|
+
build(): Promise<void>;
|
|
14
|
+
sort(): void;
|
|
13
15
|
}
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
16
|
+
declare class ModuleLoadUnit implements LoadUnit {
|
|
17
|
+
private protoMap;
|
|
18
|
+
private protos;
|
|
19
|
+
private clazzList;
|
|
20
|
+
readonly id: string;
|
|
21
|
+
readonly name: string;
|
|
22
|
+
readonly unitPath: string;
|
|
23
|
+
readonly type: EggLoadUnitType;
|
|
24
|
+
get globalGraph(): GlobalGraph;
|
|
25
|
+
constructor(name: string, unitPath: string);
|
|
26
|
+
private doLoadClazz;
|
|
27
|
+
private loadClazz;
|
|
28
|
+
preLoad(): Promise<void>;
|
|
29
|
+
init(): Promise<void>;
|
|
30
|
+
containPrototype(proto: EggPrototype): boolean;
|
|
31
|
+
getEggPrototype(name: string, qualifiers: QualifierInfo[]): EggPrototype[];
|
|
32
|
+
registerEggPrototype(proto: EggPrototype): void;
|
|
33
|
+
deletePrototype(proto: EggPrototype): void;
|
|
34
|
+
destroy(): Promise<void>;
|
|
35
|
+
iterateEggPrototype(): IterableIterator<EggPrototype>;
|
|
36
|
+
static createModule(ctx: LoadUnitLifecycleContext): ModuleLoadUnit;
|
|
35
37
|
}
|
|
38
|
+
//#endregion
|
|
39
|
+
export { ModuleGraph, ModuleLoadUnit };
|