@eggjs/tegg-dynamic-inject-runtime 4.0.0-beta.7 → 4.0.0-beta.8
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/index.d.ts +51 -3
- package/dist/index.js +124 -3
- package/package.json +10 -10
- package/dist/EggObjectFactory.d.ts +0 -16
- package/dist/EggObjectFactory.js +0 -42
- package/dist/EggObjectFactoryObject.d.ts +0 -20
- package/dist/EggObjectFactoryObject.js +0 -35
- package/dist/EggObjectFactoryPrototype.d.ts +0 -24
- package/dist/EggObjectFactoryPrototype.js +0 -50
- package/dist/_virtual/_@oxc-project_runtime@0.93.0/helpers/decorate.js +0 -10
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,52 @@
|
|
|
1
|
-
import { EggObjectFactory } from "
|
|
2
|
-
import {
|
|
3
|
-
|
|
1
|
+
import { AccessLevel, EggAbstractClazz, EggObject, EggObjectFactory as EggObjectFactory$1, EggObjectName, EggProtoImplClass, EggPrototype, EggPrototypeInfo, EggPrototypeLifecycleContext, EggPrototypeName, EggRuntimeContext, Id, InjectObjectProto, LoadUnit, MetaDataKey, ObjectInitTypeLike, QualifierInfo, QualifierValue } from "@eggjs/tegg-types";
|
|
2
|
+
import { EggContainerFactory } from "@eggjs/tegg-runtime";
|
|
3
|
+
|
|
4
|
+
//#region src/EggObjectFactory.d.ts
|
|
5
|
+
declare class EggObjectFactory implements EggObjectFactory$1 {
|
|
6
|
+
eggContainerFactory: typeof EggContainerFactory;
|
|
7
|
+
getEggObject<T extends object>(abstractClazz: EggAbstractClazz<T>, qualifierValue: QualifierValue): Promise<T>;
|
|
8
|
+
getEggObjects<T extends object>(abstractClazz: EggAbstractClazz<T>): Promise<{
|
|
9
|
+
[Symbol.asyncIterator](): {
|
|
10
|
+
key: number;
|
|
11
|
+
next(): Promise<IteratorResult<T, any>>;
|
|
12
|
+
};
|
|
13
|
+
}>;
|
|
14
|
+
}
|
|
15
|
+
//#endregion
|
|
16
|
+
//#region src/EggObjectFactoryPrototype.d.ts
|
|
17
|
+
declare const EGG_OBJECT_FACTORY_PROTO_IMPLE_TYPE = "EGG_OBJECT_FACTORY_PROTOTYPE";
|
|
18
|
+
declare class EggObjectFactoryPrototype implements EggPrototype {
|
|
19
|
+
[key: symbol]: PropertyDescriptor;
|
|
20
|
+
readonly clazz: EggProtoImplClass<EggObjectFactory$1>;
|
|
21
|
+
readonly accessLevel: AccessLevel;
|
|
22
|
+
readonly id: Id;
|
|
23
|
+
readonly initType: ObjectInitTypeLike;
|
|
24
|
+
readonly injectObjects: InjectObjectProto[];
|
|
25
|
+
readonly loadUnitId: string;
|
|
26
|
+
readonly name: EggPrototypeName;
|
|
27
|
+
readonly qualifiers: QualifierInfo[];
|
|
28
|
+
constructor(clazz: EggProtoImplClass<EggObjectFactory$1>, loadUnit: LoadUnit, prototypeInfo: EggPrototypeInfo);
|
|
29
|
+
constructEggObject(): EggObjectFactory$1;
|
|
30
|
+
getMetaData<T>(metadataKey: MetaDataKey): T | undefined;
|
|
31
|
+
verifyQualifier(qualifier: QualifierInfo): boolean;
|
|
32
|
+
getQualifier(attribute: string): QualifierValue | undefined;
|
|
33
|
+
verifyQualifiers(qualifiers: QualifierInfo[]): boolean;
|
|
34
|
+
static create(ctx: EggPrototypeLifecycleContext): EggObjectFactoryPrototype;
|
|
35
|
+
}
|
|
36
|
+
//#endregion
|
|
37
|
+
//#region src/EggObjectFactoryObject.d.ts
|
|
38
|
+
declare const OBJ: unique symbol;
|
|
39
|
+
declare class EggObjectFactoryObject implements EggObject {
|
|
40
|
+
readonly proto: EggObjectFactoryPrototype;
|
|
41
|
+
readonly name: EggObjectName;
|
|
42
|
+
readonly ctx?: EggRuntimeContext;
|
|
43
|
+
readonly id: string;
|
|
44
|
+
private [OBJ];
|
|
45
|
+
constructor(name: EggObjectName, proto: EggObjectFactoryPrototype);
|
|
46
|
+
get obj(): EggObjectFactory;
|
|
47
|
+
static createObject(name: EggObjectName, proto: EggPrototype): Promise<EggObjectFactoryObject>;
|
|
48
|
+
readonly isReady: true;
|
|
49
|
+
injectProperty(): any;
|
|
50
|
+
}
|
|
51
|
+
//#endregion
|
|
4
52
|
export { EGG_OBJECT_FACTORY_PROTO_IMPLE_TYPE, EggObjectFactory, EggObjectFactoryObject, EggObjectFactoryPrototype };
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,126 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { AccessLevel } from "@eggjs/tegg-types";
|
|
2
|
+
import { MetadataUtil, PrototypeUtil, QualifierUtil, SingletonProto } from "@eggjs/core-decorator";
|
|
3
|
+
import { QualifierImplUtil } from "@eggjs/tegg-dynamic-inject";
|
|
4
|
+
import { EggPrototypeCreatorFactory } from "@eggjs/tegg-metadata";
|
|
5
|
+
import { NameUtil } from "@eggjs/tegg-common-util";
|
|
6
|
+
import { IdenticalUtil } from "@eggjs/tegg-lifecycle";
|
|
7
|
+
import { EggContainerFactory, EggObjectFactory as EggObjectFactory$2 } from "@eggjs/tegg-runtime";
|
|
4
8
|
|
|
9
|
+
//#region src/EggObjectFactoryPrototype.ts
|
|
10
|
+
const EGG_OBJECT_FACTORY_PROTO_IMPLE_TYPE = "EGG_OBJECT_FACTORY_PROTOTYPE";
|
|
11
|
+
var EggObjectFactoryPrototype = class EggObjectFactoryPrototype {
|
|
12
|
+
clazz;
|
|
13
|
+
accessLevel;
|
|
14
|
+
id;
|
|
15
|
+
initType;
|
|
16
|
+
injectObjects;
|
|
17
|
+
loadUnitId;
|
|
18
|
+
name;
|
|
19
|
+
qualifiers;
|
|
20
|
+
constructor(clazz, loadUnit, prototypeInfo) {
|
|
21
|
+
this.clazz = clazz;
|
|
22
|
+
this.qualifiers = QualifierUtil.mergeQualifiers(QualifierUtil.getProtoQualifiers(clazz), prototypeInfo.qualifiers ?? []);
|
|
23
|
+
this.id = IdenticalUtil.createProtoId(loadUnit.id, NameUtil.getClassName(this.clazz));
|
|
24
|
+
this.initType = prototypeInfo.initType;
|
|
25
|
+
this.accessLevel = prototypeInfo.accessLevel;
|
|
26
|
+
this.loadUnitId = loadUnit.id;
|
|
27
|
+
this.name = prototypeInfo.name || NameUtil.getClassName(this.clazz);
|
|
28
|
+
this.injectObjects = [];
|
|
29
|
+
}
|
|
30
|
+
constructEggObject() {
|
|
31
|
+
return Reflect.construct(this.clazz, []);
|
|
32
|
+
}
|
|
33
|
+
getMetaData(metadataKey) {
|
|
34
|
+
return MetadataUtil.getMetaData(metadataKey, this.clazz);
|
|
35
|
+
}
|
|
36
|
+
verifyQualifier(qualifier) {
|
|
37
|
+
return this.qualifiers.find((t) => t.attribute === qualifier.attribute)?.value === qualifier.value;
|
|
38
|
+
}
|
|
39
|
+
getQualifier(attribute) {
|
|
40
|
+
return this.qualifiers.find((t) => t.attribute === attribute)?.value;
|
|
41
|
+
}
|
|
42
|
+
verifyQualifiers(qualifiers) {
|
|
43
|
+
for (const qualifier of qualifiers) if (!this.verifyQualifier(qualifier)) return false;
|
|
44
|
+
return true;
|
|
45
|
+
}
|
|
46
|
+
static create(ctx) {
|
|
47
|
+
return new EggObjectFactoryPrototype(ctx.clazz, ctx.loadUnit, ctx.prototypeInfo);
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
EggPrototypeCreatorFactory.registerPrototypeCreator(EGG_OBJECT_FACTORY_PROTO_IMPLE_TYPE, EggObjectFactoryPrototype.create);
|
|
51
|
+
|
|
52
|
+
//#endregion
|
|
53
|
+
//#region \0@oxc-project+runtime@0.93.0/helpers/decorate.js
|
|
54
|
+
function __decorate(decorators, target, key, desc) {
|
|
55
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
56
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
57
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
58
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
//#endregion
|
|
62
|
+
//#region src/EggObjectFactory.ts
|
|
63
|
+
let EggObjectFactory = class EggObjectFactory$3 {
|
|
64
|
+
eggContainerFactory;
|
|
65
|
+
async getEggObject(abstractClazz, qualifierValue) {
|
|
66
|
+
const implClazz = QualifierImplUtil.getQualifierImp(abstractClazz, qualifierValue);
|
|
67
|
+
if (!implClazz) throw new Error(`has no impl for ${abstractClazz.name} with qualifier ${qualifierValue}`);
|
|
68
|
+
const protoObj = PrototypeUtil.getClazzProto(implClazz);
|
|
69
|
+
if (!protoObj) throw new Error(`can not get proto for clazz ${implClazz.name}`);
|
|
70
|
+
return (await this.eggContainerFactory.getOrCreateEggObject(protoObj, protoObj.name)).obj;
|
|
71
|
+
}
|
|
72
|
+
async getEggObjects(abstractClazz) {
|
|
73
|
+
const implClazzMap = QualifierImplUtil.getQualifierImpMap(abstractClazz);
|
|
74
|
+
const getEggObject = this.getEggObject.bind(this);
|
|
75
|
+
const qualifierValues = Array.from(implClazzMap.keys());
|
|
76
|
+
return { [Symbol.asyncIterator]() {
|
|
77
|
+
return {
|
|
78
|
+
key: 0,
|
|
79
|
+
async next() {
|
|
80
|
+
if (this.key === qualifierValues.length) return { done: true };
|
|
81
|
+
return {
|
|
82
|
+
value: await getEggObject(abstractClazz, qualifierValues[this.key++]),
|
|
83
|
+
done: false
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
} };
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
EggObjectFactory = __decorate([SingletonProto({
|
|
91
|
+
protoImplType: EGG_OBJECT_FACTORY_PROTO_IMPLE_TYPE,
|
|
92
|
+
name: "eggObjectFactory",
|
|
93
|
+
accessLevel: AccessLevel.PUBLIC
|
|
94
|
+
})], EggObjectFactory);
|
|
95
|
+
|
|
96
|
+
//#endregion
|
|
97
|
+
//#region src/EggObjectFactoryObject.ts
|
|
98
|
+
const OBJ = Symbol("EggObjectFactoryObject#obj");
|
|
99
|
+
var EggObjectFactoryObject = class EggObjectFactoryObject {
|
|
100
|
+
proto;
|
|
101
|
+
name;
|
|
102
|
+
ctx;
|
|
103
|
+
id;
|
|
104
|
+
[OBJ];
|
|
105
|
+
constructor(name, proto) {
|
|
106
|
+
this.proto = proto;
|
|
107
|
+
this.name = name;
|
|
108
|
+
this.id = IdenticalUtil.createObjectId(this.proto.id, this.ctx?.id);
|
|
109
|
+
}
|
|
110
|
+
get obj() {
|
|
111
|
+
if (!this[OBJ]) {
|
|
112
|
+
this[OBJ] = this.proto.constructEggObject();
|
|
113
|
+
this[OBJ].eggContainerFactory = EggContainerFactory;
|
|
114
|
+
}
|
|
115
|
+
return this[OBJ];
|
|
116
|
+
}
|
|
117
|
+
static async createObject(name, proto) {
|
|
118
|
+
return new EggObjectFactoryObject(name, proto);
|
|
119
|
+
}
|
|
120
|
+
isReady;
|
|
121
|
+
injectProperty() {}
|
|
122
|
+
};
|
|
123
|
+
EggObjectFactory$2.registerEggObjectCreateMethod(EggObjectFactoryPrototype, EggObjectFactoryObject.createObject);
|
|
124
|
+
|
|
125
|
+
//#endregion
|
|
5
126
|
export { EGG_OBJECT_FACTORY_PROTO_IMPLE_TYPE, EggObjectFactory, EggObjectFactoryObject, EggObjectFactoryPrototype };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eggjs/tegg-dynamic-inject-runtime",
|
|
3
|
-
"version": "4.0.0-beta.
|
|
3
|
+
"version": "4.0.0-beta.8",
|
|
4
4
|
"description": "tegg dynamic inject",
|
|
5
5
|
"eggModule": {
|
|
6
6
|
"name": "teggDyniamicInjectRuntime"
|
|
@@ -37,21 +37,21 @@
|
|
|
37
37
|
"access": "public"
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@eggjs/core-decorator": "4.0.0-beta.
|
|
41
|
-
"@eggjs/tegg-
|
|
42
|
-
"@eggjs/tegg-
|
|
43
|
-
"@eggjs/tegg-
|
|
44
|
-
"@eggjs/tegg-metadata": "4.0.0-beta.
|
|
45
|
-
"@eggjs/tegg-
|
|
46
|
-
"@eggjs/tegg-
|
|
40
|
+
"@eggjs/core-decorator": "4.0.0-beta.8",
|
|
41
|
+
"@eggjs/tegg-dynamic-inject": "4.0.0-beta.8",
|
|
42
|
+
"@eggjs/tegg-lifecycle": "4.0.0-beta.8",
|
|
43
|
+
"@eggjs/tegg-common-util": "4.0.0-beta.8",
|
|
44
|
+
"@eggjs/tegg-metadata": "4.0.0-beta.8",
|
|
45
|
+
"@eggjs/tegg-runtime": "4.0.0-beta.8",
|
|
46
|
+
"@eggjs/tegg-types": "4.0.0-beta.8"
|
|
47
47
|
},
|
|
48
48
|
"devDependencies": {
|
|
49
49
|
"@types/node": "^22.10.5",
|
|
50
50
|
"typescript": "^5.9.3",
|
|
51
51
|
"tsdown": "^0.15.6",
|
|
52
52
|
"unplugin-unused": "^0.5.3",
|
|
53
|
-
"@eggjs/
|
|
54
|
-
"@eggjs/
|
|
53
|
+
"@eggjs/tegg-loader": "4.0.0-beta.8",
|
|
54
|
+
"@eggjs/module-test-util": "4.0.0-beta.4"
|
|
55
55
|
},
|
|
56
56
|
"main": "./dist/index.js",
|
|
57
57
|
"module": "./dist/index.js",
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { EggAbstractClazz, EggObjectFactory, QualifierValue } from "@eggjs/tegg-types";
|
|
2
|
-
import { EggContainerFactory } from "@eggjs/tegg-runtime";
|
|
3
|
-
|
|
4
|
-
//#region src/EggObjectFactory.d.ts
|
|
5
|
-
declare class EggObjectFactory$2 implements EggObjectFactory {
|
|
6
|
-
eggContainerFactory: typeof EggContainerFactory;
|
|
7
|
-
getEggObject<T extends object>(abstractClazz: EggAbstractClazz<T>, qualifierValue: QualifierValue): Promise<T>;
|
|
8
|
-
getEggObjects<T extends object>(abstractClazz: EggAbstractClazz<T>): Promise<{
|
|
9
|
-
[Symbol.asyncIterator](): {
|
|
10
|
-
key: number;
|
|
11
|
-
next(): Promise<IteratorResult<T, any>>;
|
|
12
|
-
};
|
|
13
|
-
}>;
|
|
14
|
-
}
|
|
15
|
-
//#endregion
|
|
16
|
-
export { EggObjectFactory$2 as EggObjectFactory };
|
package/dist/EggObjectFactory.js
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import { EGG_OBJECT_FACTORY_PROTO_IMPLE_TYPE } from "./EggObjectFactoryPrototype.js";
|
|
2
|
-
import { __decorate } from "./_virtual/_@oxc-project_runtime@0.93.0/helpers/decorate.js";
|
|
3
|
-
import { AccessLevel } from "@eggjs/tegg-types";
|
|
4
|
-
import { PrototypeUtil, SingletonProto } from "@eggjs/core-decorator";
|
|
5
|
-
import { QualifierImplUtil } from "@eggjs/tegg-dynamic-inject";
|
|
6
|
-
|
|
7
|
-
//#region src/EggObjectFactory.ts
|
|
8
|
-
let EggObjectFactory$1 = class EggObjectFactory$2 {
|
|
9
|
-
eggContainerFactory;
|
|
10
|
-
async getEggObject(abstractClazz, qualifierValue) {
|
|
11
|
-
const implClazz = QualifierImplUtil.getQualifierImp(abstractClazz, qualifierValue);
|
|
12
|
-
if (!implClazz) throw new Error(`has no impl for ${abstractClazz.name} with qualifier ${qualifierValue}`);
|
|
13
|
-
const protoObj = PrototypeUtil.getClazzProto(implClazz);
|
|
14
|
-
if (!protoObj) throw new Error(`can not get proto for clazz ${implClazz.name}`);
|
|
15
|
-
return (await this.eggContainerFactory.getOrCreateEggObject(protoObj, protoObj.name)).obj;
|
|
16
|
-
}
|
|
17
|
-
async getEggObjects(abstractClazz) {
|
|
18
|
-
const implClazzMap = QualifierImplUtil.getQualifierImpMap(abstractClazz);
|
|
19
|
-
const getEggObject = this.getEggObject.bind(this);
|
|
20
|
-
const qualifierValues = Array.from(implClazzMap.keys());
|
|
21
|
-
return { [Symbol.asyncIterator]() {
|
|
22
|
-
return {
|
|
23
|
-
key: 0,
|
|
24
|
-
async next() {
|
|
25
|
-
if (this.key === qualifierValues.length) return { done: true };
|
|
26
|
-
return {
|
|
27
|
-
value: await getEggObject(abstractClazz, qualifierValues[this.key++]),
|
|
28
|
-
done: false
|
|
29
|
-
};
|
|
30
|
-
}
|
|
31
|
-
};
|
|
32
|
-
} };
|
|
33
|
-
}
|
|
34
|
-
};
|
|
35
|
-
EggObjectFactory$1 = __decorate([SingletonProto({
|
|
36
|
-
protoImplType: EGG_OBJECT_FACTORY_PROTO_IMPLE_TYPE,
|
|
37
|
-
name: "eggObjectFactory",
|
|
38
|
-
accessLevel: AccessLevel.PUBLIC
|
|
39
|
-
})], EggObjectFactory$1);
|
|
40
|
-
|
|
41
|
-
//#endregion
|
|
42
|
-
export { EggObjectFactory$1 as EggObjectFactory };
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { EggObjectFactory as EggObjectFactory$1 } from "./EggObjectFactory.js";
|
|
2
|
-
import { EggObjectFactoryPrototype } from "./EggObjectFactoryPrototype.js";
|
|
3
|
-
import { EggObject, EggObjectName, EggPrototype, EggRuntimeContext } from "@eggjs/tegg-types";
|
|
4
|
-
|
|
5
|
-
//#region src/EggObjectFactoryObject.d.ts
|
|
6
|
-
declare const OBJ: unique symbol;
|
|
7
|
-
declare class EggObjectFactoryObject implements EggObject {
|
|
8
|
-
readonly proto: EggObjectFactoryPrototype;
|
|
9
|
-
readonly name: EggObjectName;
|
|
10
|
-
readonly ctx?: EggRuntimeContext;
|
|
11
|
-
readonly id: string;
|
|
12
|
-
private [OBJ];
|
|
13
|
-
constructor(name: EggObjectName, proto: EggObjectFactoryPrototype);
|
|
14
|
-
get obj(): EggObjectFactory$1;
|
|
15
|
-
static createObject(name: EggObjectName, proto: EggPrototype): Promise<EggObjectFactoryObject>;
|
|
16
|
-
readonly isReady: true;
|
|
17
|
-
injectProperty(): any;
|
|
18
|
-
}
|
|
19
|
-
//#endregion
|
|
20
|
-
export { EggObjectFactoryObject };
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { EggObjectFactoryPrototype } from "./EggObjectFactoryPrototype.js";
|
|
2
|
-
import "./EggObjectFactory.js";
|
|
3
|
-
import { IdenticalUtil } from "@eggjs/tegg-lifecycle";
|
|
4
|
-
import { EggContainerFactory, EggObjectFactory } from "@eggjs/tegg-runtime";
|
|
5
|
-
|
|
6
|
-
//#region src/EggObjectFactoryObject.ts
|
|
7
|
-
const OBJ = Symbol("EggObjectFactoryObject#obj");
|
|
8
|
-
var EggObjectFactoryObject = class EggObjectFactoryObject {
|
|
9
|
-
proto;
|
|
10
|
-
name;
|
|
11
|
-
ctx;
|
|
12
|
-
id;
|
|
13
|
-
[OBJ];
|
|
14
|
-
constructor(name, proto) {
|
|
15
|
-
this.proto = proto;
|
|
16
|
-
this.name = name;
|
|
17
|
-
this.id = IdenticalUtil.createObjectId(this.proto.id, this.ctx?.id);
|
|
18
|
-
}
|
|
19
|
-
get obj() {
|
|
20
|
-
if (!this[OBJ]) {
|
|
21
|
-
this[OBJ] = this.proto.constructEggObject();
|
|
22
|
-
this[OBJ].eggContainerFactory = EggContainerFactory;
|
|
23
|
-
}
|
|
24
|
-
return this[OBJ];
|
|
25
|
-
}
|
|
26
|
-
static async createObject(name, proto) {
|
|
27
|
-
return new EggObjectFactoryObject(name, proto);
|
|
28
|
-
}
|
|
29
|
-
isReady;
|
|
30
|
-
injectProperty() {}
|
|
31
|
-
};
|
|
32
|
-
EggObjectFactory.registerEggObjectCreateMethod(EggObjectFactoryPrototype, EggObjectFactoryObject.createObject);
|
|
33
|
-
|
|
34
|
-
//#endregion
|
|
35
|
-
export { EggObjectFactoryObject };
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { AccessLevel, EggObjectFactory, EggProtoImplClass, EggPrototype, EggPrototypeInfo, EggPrototypeLifecycleContext, EggPrototypeName, Id, InjectObjectProto, LoadUnit, MetaDataKey, ObjectInitTypeLike, QualifierInfo, QualifierValue } from "@eggjs/tegg-types";
|
|
2
|
-
|
|
3
|
-
//#region src/EggObjectFactoryPrototype.d.ts
|
|
4
|
-
declare const EGG_OBJECT_FACTORY_PROTO_IMPLE_TYPE = "EGG_OBJECT_FACTORY_PROTOTYPE";
|
|
5
|
-
declare class EggObjectFactoryPrototype implements EggPrototype {
|
|
6
|
-
[key: symbol]: PropertyDescriptor;
|
|
7
|
-
readonly clazz: EggProtoImplClass<EggObjectFactory>;
|
|
8
|
-
readonly accessLevel: AccessLevel;
|
|
9
|
-
readonly id: Id;
|
|
10
|
-
readonly initType: ObjectInitTypeLike;
|
|
11
|
-
readonly injectObjects: InjectObjectProto[];
|
|
12
|
-
readonly loadUnitId: string;
|
|
13
|
-
readonly name: EggPrototypeName;
|
|
14
|
-
readonly qualifiers: QualifierInfo[];
|
|
15
|
-
constructor(clazz: EggProtoImplClass<EggObjectFactory>, loadUnit: LoadUnit, prototypeInfo: EggPrototypeInfo);
|
|
16
|
-
constructEggObject(): EggObjectFactory;
|
|
17
|
-
getMetaData<T>(metadataKey: MetaDataKey): T | undefined;
|
|
18
|
-
verifyQualifier(qualifier: QualifierInfo): boolean;
|
|
19
|
-
getQualifier(attribute: string): QualifierValue | undefined;
|
|
20
|
-
verifyQualifiers(qualifiers: QualifierInfo[]): boolean;
|
|
21
|
-
static create(ctx: EggPrototypeLifecycleContext): EggObjectFactoryPrototype;
|
|
22
|
-
}
|
|
23
|
-
//#endregion
|
|
24
|
-
export { EGG_OBJECT_FACTORY_PROTO_IMPLE_TYPE, EggObjectFactoryPrototype };
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import { MetadataUtil, QualifierUtil } from "@eggjs/core-decorator";
|
|
2
|
-
import { EggPrototypeCreatorFactory } from "@eggjs/tegg-metadata";
|
|
3
|
-
import { NameUtil } from "@eggjs/tegg-common-util";
|
|
4
|
-
import { IdenticalUtil } from "@eggjs/tegg-lifecycle";
|
|
5
|
-
|
|
6
|
-
//#region src/EggObjectFactoryPrototype.ts
|
|
7
|
-
const EGG_OBJECT_FACTORY_PROTO_IMPLE_TYPE = "EGG_OBJECT_FACTORY_PROTOTYPE";
|
|
8
|
-
var EggObjectFactoryPrototype = class EggObjectFactoryPrototype {
|
|
9
|
-
clazz;
|
|
10
|
-
accessLevel;
|
|
11
|
-
id;
|
|
12
|
-
initType;
|
|
13
|
-
injectObjects;
|
|
14
|
-
loadUnitId;
|
|
15
|
-
name;
|
|
16
|
-
qualifiers;
|
|
17
|
-
constructor(clazz, loadUnit, prototypeInfo) {
|
|
18
|
-
this.clazz = clazz;
|
|
19
|
-
this.qualifiers = QualifierUtil.mergeQualifiers(QualifierUtil.getProtoQualifiers(clazz), prototypeInfo.qualifiers ?? []);
|
|
20
|
-
this.id = IdenticalUtil.createProtoId(loadUnit.id, NameUtil.getClassName(this.clazz));
|
|
21
|
-
this.initType = prototypeInfo.initType;
|
|
22
|
-
this.accessLevel = prototypeInfo.accessLevel;
|
|
23
|
-
this.loadUnitId = loadUnit.id;
|
|
24
|
-
this.name = prototypeInfo.name || NameUtil.getClassName(this.clazz);
|
|
25
|
-
this.injectObjects = [];
|
|
26
|
-
}
|
|
27
|
-
constructEggObject() {
|
|
28
|
-
return Reflect.construct(this.clazz, []);
|
|
29
|
-
}
|
|
30
|
-
getMetaData(metadataKey) {
|
|
31
|
-
return MetadataUtil.getMetaData(metadataKey, this.clazz);
|
|
32
|
-
}
|
|
33
|
-
verifyQualifier(qualifier) {
|
|
34
|
-
return this.qualifiers.find((t) => t.attribute === qualifier.attribute)?.value === qualifier.value;
|
|
35
|
-
}
|
|
36
|
-
getQualifier(attribute) {
|
|
37
|
-
return this.qualifiers.find((t) => t.attribute === attribute)?.value;
|
|
38
|
-
}
|
|
39
|
-
verifyQualifiers(qualifiers) {
|
|
40
|
-
for (const qualifier of qualifiers) if (!this.verifyQualifier(qualifier)) return false;
|
|
41
|
-
return true;
|
|
42
|
-
}
|
|
43
|
-
static create(ctx) {
|
|
44
|
-
return new EggObjectFactoryPrototype(ctx.clazz, ctx.loadUnit, ctx.prototypeInfo);
|
|
45
|
-
}
|
|
46
|
-
};
|
|
47
|
-
EggPrototypeCreatorFactory.registerPrototypeCreator(EGG_OBJECT_FACTORY_PROTO_IMPLE_TYPE, EggObjectFactoryPrototype.create);
|
|
48
|
-
|
|
49
|
-
//#endregion
|
|
50
|
-
export { EGG_OBJECT_FACTORY_PROTO_IMPLE_TYPE, EggObjectFactoryPrototype };
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
//#region \0@oxc-project+runtime@0.93.0/helpers/decorate.js
|
|
2
|
-
function __decorate(decorators, target, key, desc) {
|
|
3
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
//#endregion
|
|
10
|
-
export { __decorate };
|