-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
feat(tegg): declarative module plugin mechanism #6021
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: next
Are you sure you want to change the base?
Changes from all commits
9824fbd
28fd1a8
0297ba2
32c9e98
ec04a77
4db8a71
5ce2924
3450a26
9f5151a
59a0ce2
8f43888
11719ed
08e66c1
9e8c992
6be3dc1
b47dd83
f5c919a
d039632
a5a1bb7
faddefd
774a543
0d5faa3
74f4ce0
0cda175
488006b
118510a
c7c4f1f
4d7cb82
589f4fe
3c51287
a86b5f2
ea724e6
1c63005
d7b9ede
ab57cc9
0140cc8
cb3d29c
32f326b
796d279
46326b1
fd2161a
832dd03
29290e4
f63888a
24364ee
df9aadf
9282e2e
f97739f
d82f600
4ccd29f
01407c0
8abee4b
e61ce22
771f6f1
b16bfab
b9dd087
17b5314
92c8c53
fad791b
7773876
a316936
0ca40eb
17f4819
1132499
294c78e
10c6e62
9c26cfd
ac38700
eba836b
c356ead
5c42a6d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| import { InnerObjectProto } from '@eggjs/core-decorator'; | ||
| import { ObjectInitType } from '@eggjs/tegg-types'; | ||
| import type { EggPrototype } from '@eggjs/tegg-types'; | ||
|
|
||
| export interface ProtoToCreate { | ||
| name: string; | ||
| proto: EggPrototype; | ||
| } | ||
|
|
||
| @InnerObjectProto() | ||
| export class AopContextAdviceRegistry { | ||
| readonly #requestProtoList: ProtoToCreate[] = []; | ||
|
|
||
| addAdvice(name: string, proto: EggPrototype): void { | ||
| if (proto.initType !== ObjectInitType.CONTEXT) { | ||
| return; | ||
| } | ||
| if (this.#requestProtoList.some((t) => t.name === name && t.proto === proto)) { | ||
| return; | ||
| } | ||
| this.#requestProtoList.push({ name, proto }); | ||
| } | ||
|
|
||
| getRequestProtos(): readonly ProtoToCreate[] { | ||
| return this.#requestProtoList; | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,27 @@ | ||||||||||
| import { InnerObjectProto } from '@eggjs/core-decorator'; | ||||||||||
| import { LifecyclePostInject } from '@eggjs/lifecycle'; | ||||||||||
| import { GlobalGraph } from '@eggjs/metadata'; | ||||||||||
|
|
||||||||||
| import { crossCutGraphHook } from './CrossCutGraphHook.js'; | ||||||||||
| import { pointCutGraphHook } from './PointCutGraphHook.js'; | ||||||||||
|
Comment on lines
+5
to
+6
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. According to the repository's general rules, TypeScript source file imports should use the
Suggested change
References
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 不采纳这里的 |
||||||||||
|
|
||||||||||
| /** | ||||||||||
| * Registers the AOP graph build hooks declaratively. Instantiated with the | ||||||||||
| * InnerObjectLoadUnit, which both hosts run AFTER the business GlobalGraph is | ||||||||||
| * created and BEFORE build() consumes the hooks — the only valid window. | ||||||||||
| */ | ||||||||||
| @InnerObjectProto() | ||||||||||
| export class AopGraphHookRegistrar { | ||||||||||
| @LifecyclePostInject() | ||||||||||
| protected registerGraphHooks(): void { | ||||||||||
| const globalGraph = GlobalGraph.instance; | ||||||||||
| if (!globalGraph) { | ||||||||||
| throw new Error( | ||||||||||
| '[aop-runtime] GlobalGraph must be created before AopGraphHookRegistrar is instantiated, ' + | ||||||||||
| 'cross-loadUnit crosscut/pointcut weaving would silently never happen', | ||||||||||
| ); | ||||||||||
| } | ||||||||||
| globalGraph.registerBuildHook(crossCutGraphHook); | ||||||||||
| globalGraph.registerBuildHook(pointCutGraphHook); | ||||||||||
| } | ||||||||||
| } | ||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,8 @@ | ||
| export * from './AopContextAdviceRegistry.js'; | ||
| export * from './AspectExecutor.js'; | ||
| export * from './CrossCutGraphHook.js'; | ||
| export * from './EggObjectAopHook.js'; | ||
| export * from './EggPrototypeCrossCutHook.js'; | ||
| export * from './LoadUnitAopHook.js'; | ||
| export * from './PointCutGraphHook.js'; | ||
| export * from './AopGraphHookRegistrar.js'; |
Uh oh!
There was an error while loading. Please reload this page.