-
-
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
Open
gxkl
wants to merge
41
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,374
−1,059
Open
Changes from all commits
Commits
Show all changes
41 commits
Select commit
Hold shift + click to select a range
cf7eb49
feat(core): add module plugin core mechanism
gxkl 17e64b1
feat(standalone): two-phase StandaloneApp with module plugin support
gxkl fa6cb8e
feat(tegg-plugin): instantiate InnerObjectLoadUnit in app mode
gxkl bae48ee
feat(tegg): convert built-in framework hooks to module plugins
gxkl 77bf847
docs(wiki): record tegg module plugin architecture
gxkl 5dc8d65
refactor(tegg): address module-plugin review - dedupe hook, untangle …
gxkl 76094c0
refactor(tegg): built-in framework hooks load through the module scan
gxkl d66f4b0
refactor(tegg): decentralize module plugins - enabling the plugin IS …
gxkl 888b427
refactor(tegg): the aop PLUGIN is the aop module; provided objects jo…
gxkl a3db4cf
refactor(runtime): provided inner objects are ordinary protos end to end
gxkl 1e8901d
chore(aop-runtime): drop leftover InnerObjects re-export
gxkl 93b3abb
refactor(tegg): discovery stays deps/module.json-declared; drop enabl…
gxkl 013ef5c
refactor(runtime): name the provided-instance factory for what it is
gxkl bffe51b
docs(aop): explain why AopContextHook stays imperatively registered
gxkl 234961d
docs(tegg): explain why inner objects use provided instances, not egg…
gxkl 8396f02
docs(tegg): state why ConfigSourceLoadUnitHook is a host built-in
gxkl 97de01b
refactor(tegg): ConfigSourceLoadUnitHook lives in @eggjs/tegg-config,…
gxkl e00f50d
fix(tegg): gate optional modules' hooks; fix the enabled-promotion match
gxkl 16784ec
revert(tegg-config): framework discovery reads package.json only
gxkl ed70cd4
refactor(standalone): defer module scan out of the StandaloneApp cons…
gxkl 172072d
refactor(standalone): drop deprecated StandaloneAppOptions.innerObjects
gxkl 0c21e5b
refactor(standalone): keep innerObjects assembly in the constructor, …
gxkl 368d202
refactor(standalone): make runtimeConfig a placeholder filled at init
gxkl 943bcb3
feat(standalone): accept a logger via StandaloneAppOptions
gxkl 669506f
refactor(standalone): make StandaloneApp.init idempotent
gxkl a797445
fix(standalone): keep host moduleConfig handler override semantics
gxkl 34c8619
refactor(standalone): build framework base inner objects at the point…
gxkl 8752841
refactor(standalone): align StandaloneApp API with tegg#325
gxkl f24677e
refactor(standalone): discover builtin framework plugins via own pack…
gxkl df3af31
refactor(standalone): move dal manager cleanup into the dal module it…
gxkl 8f2542b
feat(dal): declare the mysqlDataSourceManager injection surface in th…
gxkl 54abd7f
fix(dal): declare manager cleanup via @LifecycleDestroy
gxkl 2d31e55
refactor(dal): type MysqlDataSourceManagerObject via declaration merging
gxkl 61eb83e
fix(standalone): allowlist scan-declaration deps for unplugin-unused
gxkl dd80199
fix(core-decorator): explicit return types for isolatedDeclarations
gxkl ae83327
fix(config): default the framework module scan to egg
gxkl d632166
refactor(config): resolve the framework dir with getFrameworkPath
gxkl 9a5cc21
fix(config): tolerate non-materialized module dirs from bundle manifests
gxkl 9c05389
fix(tegg): JSON-safe descriptor dump and bundle-tolerant module confi…
gxkl 8f4bad1
test(tegg): explicit boot-hook timeouts for slow Windows runners
gxkl 79594a6
test(tegg): align boot-hook timeouts with the root config values
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
32 changes: 32 additions & 0 deletions
32
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,32 @@ | ||
| 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'; | ||
| import type { PrototypeDecorator } from './Prototype.ts'; | ||
|
|
||
| export function EggLifecycleProto(params: CommonEggLifecycleProtoParams): PrototypeDecorator { | ||
| 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 }); | ||
| }; | ||
| } | ||
|
|
||
| type EggLifecycleProtoDecoratorFactory = (params?: EggLifecycleProtoParams) => PrototypeDecorator; | ||
|
|
||
| const createLifecycleProto = (type: CommonEggLifecycleProtoParams['type']): EggLifecycleProtoDecoratorFactory => { | ||
| return (params?: EggLifecycleProtoParams) => EggLifecycleProto({ type, ...params }); | ||
| }; | ||
|
|
||
| export const LoadUnitLifecycleProto: EggLifecycleProtoDecoratorFactory = createLifecycleProto('LoadUnit'); | ||
| export const LoadUnitInstanceLifecycleProto: EggLifecycleProtoDecoratorFactory = | ||
| createLifecycleProto('LoadUnitInstance'); | ||
| export const EggObjectLifecycleProto: EggLifecycleProtoDecoratorFactory = createLifecycleProto('EggObject'); | ||
| export const EggPrototypeLifecycleProto: EggLifecycleProtoDecoratorFactory = createLifecycleProto('EggPrototype'); | ||
| export const EggContextLifecycleProto: EggLifecycleProtoDecoratorFactory = createLifecycleProto('EggContext'); |
17 changes: 17 additions & 0 deletions
17
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,17 @@ | ||
| 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 type { PrototypeDecorator } from './Prototype.ts'; | ||
| import { SingletonProto } from './SingletonProto.ts'; | ||
|
|
||
| export function InnerObjectProto(params?: InnerObjectProtoParams): PrototypeDecorator { | ||
| 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