-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
[WIP] 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
Draft
gxkl
wants to merge
14
commits into
next
Choose a base branch
from
feat/module-plugin-core
base: next
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+3,112
−1,011
Draft
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
a9826f0
feat(core): add module plugin core mechanism
gxkl bc70853
feat(standalone): two-phase StandaloneApp with module plugin support
gxkl ff97944
feat(tegg-plugin): instantiate InnerObjectLoadUnit in app mode
gxkl b386da4
feat(tegg): convert built-in framework hooks to module plugins
gxkl e0ad514
docs(wiki): record tegg module plugin architecture
gxkl f4267df
refactor(tegg): address module-plugin review - dedupe hook, untangle …
gxkl 9eab204
refactor(tegg): built-in framework hooks load through the module scan
gxkl c14a699
refactor(tegg): decentralize module plugins - enabling the plugin IS …
gxkl 37f88da
refactor(tegg): the aop PLUGIN is the aop module; provided objects jo…
gxkl 6e593e5
refactor(runtime): provided inner objects are ordinary protos end to end
gxkl 9a6948b
chore(aop-runtime): drop leftover InnerObjects re-export
gxkl 03da2e2
refactor(tegg): discovery stays deps/module.json-declared; drop enabl…
gxkl a40a7d0
refactor(runtime): name the provided-instance factory for what it is
gxkl 7bcfd38
docs(aop): explain why AopContextHook stays imperatively registered
gxkl File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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'; | ||
|
|
||
| /** | ||
| * 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); | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
tegg/core/core-decorator/src/decorator/EggLifecycleProto.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| import assert from 'node:assert'; | ||
|
|
||
| import type { CommonEggLifecycleProtoParams, EggLifecycleProtoParams, EggProtoImplClass } from '@eggjs/tegg-types'; | ||
|
|
||
| import { PrototypeUtil } from '../util/PrototypeUtil.ts'; | ||
| import { InnerObjectProto } from './InnerObjectProto.ts'; | ||
|
|
||
| export function EggLifecycleProto(params: CommonEggLifecycleProtoParams) { | ||
| return function (clazz: EggProtoImplClass) { | ||
| const { type, ...protoParams } = params || {}; | ||
| assert(type, 'EggLifecycle decorator should have type property'); | ||
|
|
||
| InnerObjectProto(protoParams)(clazz); | ||
|
|
||
| PrototypeUtil.setIsEggLifecyclePrototype(clazz); | ||
| PrototypeUtil.setEggLifecyclePrototypeMetadata(clazz, { type }); | ||
| }; | ||
| } | ||
|
|
||
| const createLifecycleProto = (type: CommonEggLifecycleProtoParams['type']) => { | ||
| return (params?: EggLifecycleProtoParams) => EggLifecycleProto({ type, ...params }); | ||
| }; | ||
|
|
||
| export const LoadUnitLifecycleProto = createLifecycleProto('LoadUnit'); | ||
| export const LoadUnitInstanceLifecycleProto = createLifecycleProto('LoadUnitInstance'); | ||
| export const EggObjectLifecycleProto = createLifecycleProto('EggObject'); | ||
| export const EggPrototypeLifecycleProto = createLifecycleProto('EggPrototype'); | ||
| export const EggContextLifecycleProto = createLifecycleProto('EggContext'); |
16 changes: 16 additions & 0 deletions
16
tegg/core/core-decorator/src/decorator/InnerObjectProto.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| import { EGG_INNER_OBJECT_PROTO_IMPL_TYPE } from '@eggjs/tegg-types'; | ||
| import type { EggProtoImplClass, InnerObjectProtoParams } from '@eggjs/tegg-types'; | ||
|
|
||
| import { PrototypeUtil } from '../util/PrototypeUtil.ts'; | ||
| import { SingletonProto } from './SingletonProto.ts'; | ||
|
|
||
| export function InnerObjectProto(params?: InnerObjectProtoParams) { | ||
| return function (clazz: EggProtoImplClass) { | ||
| const protoParams = { | ||
| protoImplType: EGG_INNER_OBJECT_PROTO_IMPL_TYPE, | ||
| ...params, | ||
| }; | ||
| SingletonProto(protoParams)(clazz); | ||
| PrototypeUtil.setIsEggInnerObject(clazz); | ||
| }; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The 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
.tsextension instead of.jsto maintain consistency across the codebase.References