@eggjs/tegg-aop-plugin 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/AopContextHook-DlKgkulD.js +35 -0
- package/dist/app.js +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/lib/AopContextHook.js +1 -33
- package/dist/types-DnHXjuLw.d.ts +1 -0
- package/dist/types-rcblRL_0.js +3 -0
- package/dist/types.d.ts +1 -1
- package/dist/types.js +1 -1
- package/package.json +10 -10
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { TeggError } from "@eggjs/tegg-metadata";
|
|
2
|
+
import { ObjectInitType, PrototypeUtil } from "@eggjs/tegg";
|
|
3
|
+
import { AspectInfoUtil } from "@eggjs/aop-decorator";
|
|
4
|
+
import { ROOT_PROTO } from "@eggjs/egg-module-common";
|
|
5
|
+
|
|
6
|
+
//#region src/lib/AopContextHook.ts
|
|
7
|
+
var AopContextHook = class {
|
|
8
|
+
moduleHandler;
|
|
9
|
+
requestProtoList = [];
|
|
10
|
+
constructor(moduleHandler) {
|
|
11
|
+
this.moduleHandler = moduleHandler;
|
|
12
|
+
for (const loadUnitInstance of this.moduleHandler.loadUnitInstances) {
|
|
13
|
+
const iterator = loadUnitInstance.loadUnit.iterateEggPrototype();
|
|
14
|
+
for (const proto of iterator) {
|
|
15
|
+
const clazz = proto.clazz;
|
|
16
|
+
if (!clazz) continue;
|
|
17
|
+
const aspects = AspectInfoUtil.getAspectList(clazz);
|
|
18
|
+
for (const aspect of aspects) for (const advice of aspect.adviceList) {
|
|
19
|
+
const adviceProto = PrototypeUtil.getClazzProto(advice.clazz);
|
|
20
|
+
if (!adviceProto) throw TeggError.create(`Aop Advice(${advice.clazz.name}) not found in loadUnits`, "advice_not_found");
|
|
21
|
+
if (adviceProto.initType === ObjectInitType.CONTEXT) this.requestProtoList.push({
|
|
22
|
+
name: advice.name,
|
|
23
|
+
proto: adviceProto
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
async preCreate(_, ctx) {
|
|
30
|
+
if (!ctx.get(ROOT_PROTO)) for (const proto of this.requestProtoList) ctx.addProtoToCreate(proto.name, proto.proto);
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
//#endregion
|
|
35
|
+
export { AopContextHook };
|
package/dist/app.js
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
import "./types-DnHXjuLw.js";
|
package/dist/index.js
CHANGED
|
@@ -1,35 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { ObjectInitType, PrototypeUtil } from "@eggjs/tegg";
|
|
3
|
-
import { AspectInfoUtil } from "@eggjs/aop-decorator";
|
|
4
|
-
import { ROOT_PROTO } from "@eggjs/egg-module-common";
|
|
1
|
+
import { AopContextHook } from "../AopContextHook-DlKgkulD.js";
|
|
5
2
|
|
|
6
|
-
//#region src/lib/AopContextHook.ts
|
|
7
|
-
var AopContextHook = class {
|
|
8
|
-
moduleHandler;
|
|
9
|
-
requestProtoList = [];
|
|
10
|
-
constructor(moduleHandler) {
|
|
11
|
-
this.moduleHandler = moduleHandler;
|
|
12
|
-
for (const loadUnitInstance of this.moduleHandler.loadUnitInstances) {
|
|
13
|
-
const iterator = loadUnitInstance.loadUnit.iterateEggPrototype();
|
|
14
|
-
for (const proto of iterator) {
|
|
15
|
-
const clazz = proto.clazz;
|
|
16
|
-
if (!clazz) continue;
|
|
17
|
-
const aspects = AspectInfoUtil.getAspectList(clazz);
|
|
18
|
-
for (const aspect of aspects) for (const advice of aspect.adviceList) {
|
|
19
|
-
const adviceProto = PrototypeUtil.getClazzProto(advice.clazz);
|
|
20
|
-
if (!adviceProto) throw TeggError.create(`Aop Advice(${advice.clazz.name}) not found in loadUnits`, "advice_not_found");
|
|
21
|
-
if (adviceProto.initType === ObjectInitType.CONTEXT) this.requestProtoList.push({
|
|
22
|
-
name: advice.name,
|
|
23
|
-
proto: adviceProto
|
|
24
|
-
});
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
async preCreate(_, ctx) {
|
|
30
|
-
if (!ctx.get(ROOT_PROTO)) for (const proto of this.requestProtoList) ctx.addProtoToCreate(proto.name, proto.proto);
|
|
31
|
-
}
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
//#endregion
|
|
35
3
|
export { AopContextHook };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import "@eggjs/tegg-plugin/types";
|
package/dist/types.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import "
|
|
1
|
+
import "./types-DnHXjuLw.js";
|
package/dist/types.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eggjs/tegg-aop-plugin",
|
|
3
|
-
"version": "4.0.0-beta.
|
|
3
|
+
"version": "4.0.0-beta.8",
|
|
4
4
|
"eggPlugin": {
|
|
5
5
|
"name": "aopModule",
|
|
6
6
|
"dependencies": [
|
|
@@ -40,16 +40,16 @@
|
|
|
40
40
|
"node": ">=22.18.0"
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"@eggjs/aop-decorator": "4.0.0-beta.
|
|
44
|
-
"@eggjs/egg-module-common": "4.0.0-beta.
|
|
45
|
-
"@eggjs/tegg": "4.0.0-beta.
|
|
46
|
-
"@eggjs/tegg-aop-runtime": "4.0.0-beta.
|
|
47
|
-
"@eggjs/tegg-
|
|
48
|
-
"@eggjs/tegg-
|
|
43
|
+
"@eggjs/aop-decorator": "4.0.0-beta.8",
|
|
44
|
+
"@eggjs/egg-module-common": "4.0.0-beta.8",
|
|
45
|
+
"@eggjs/tegg": "4.0.0-beta.8",
|
|
46
|
+
"@eggjs/tegg-aop-runtime": "4.0.0-beta.8",
|
|
47
|
+
"@eggjs/tegg-runtime": "4.0.0-beta.8",
|
|
48
|
+
"@eggjs/tegg-metadata": "4.0.0-beta.8"
|
|
49
49
|
},
|
|
50
50
|
"peerDependencies": {
|
|
51
51
|
"egg": "beta",
|
|
52
|
-
"@eggjs/tegg-plugin": "4.0.0-beta.
|
|
52
|
+
"@eggjs/tegg-plugin": "4.0.0-beta.8"
|
|
53
53
|
},
|
|
54
54
|
"devDependencies": {
|
|
55
55
|
"@eggjs/mock": "beta",
|
|
@@ -58,8 +58,8 @@
|
|
|
58
58
|
"typescript": "^5.9.3",
|
|
59
59
|
"tsdown": "^0.15.6",
|
|
60
60
|
"unplugin-unused": "^0.5.3",
|
|
61
|
-
"@eggjs/tegg-
|
|
62
|
-
"@eggjs/tegg-
|
|
61
|
+
"@eggjs/tegg-plugin": "4.0.0-beta.8",
|
|
62
|
+
"@eggjs/tegg-config": "4.0.0-beta.8"
|
|
63
63
|
},
|
|
64
64
|
"publishConfig": {
|
|
65
65
|
"access": "public"
|