11/* eslint-disable no-multi-assign */
2- import { Editor , EngineConfig , engineConfig } from '@alilc/lowcode-editor-core' ;
3- import { Designer , ILowCodePluginManager } from '@alilc/lowcode-designer' ;
4- import { Skeleton as InnerSkeleton } from '@alilc/lowcode-editor-skeleton' ;
2+ import { EngineConfig , engineConfig } from '@alilc/lowcode-editor-core' ;
3+ import { ILowCodePluginManager } from '@alilc/lowcode-designer' ;
54import {
65 Hotkey ,
76 Project ,
87 Skeleton ,
98 Setters ,
109 Material ,
1110 Event ,
12- editorSymbol ,
13- designerSymbol ,
14- skeletonSymbol ,
11+ Common ,
1512} from '@alilc/lowcode-shell' ;
1613import { getLogger , Logger } from '@alilc/lowcode-utils' ;
1714import {
@@ -20,45 +17,40 @@ import {
2017 ILowCodePluginPreferenceDeclaration ,
2118 PreferenceValueType ,
2219 IPluginPreferenceMananger ,
20+ ILowCodePluginContextApiAssembler ,
21+ ILowCodePluginContextPrivate ,
2322} from './plugin-types' ;
2423import { isValidPreferenceKey } from './plugin-utils' ;
2524
26- export default class PluginContext implements ILowCodePluginContext {
27- private readonly [ editorSymbol ] : Editor ;
28- private readonly [ designerSymbol ] : Designer ;
29- private readonly [ skeletonSymbol ] : InnerSkeleton ;
25+
26+ export default class PluginContext implements ILowCodePluginContext , ILowCodePluginContextPrivate {
3027 hotkey : Hotkey ;
3128 project : Project ;
3229 skeleton : Skeleton ;
33- logger : Logger ;
3430 setters : Setters ;
3531 material : Material ;
36- config : EngineConfig ;
3732 event : Event ;
33+ config : EngineConfig ;
34+ common : Common ;
35+ logger : Logger ;
3836 plugins : ILowCodePluginManager ;
3937 preference : IPluginPreferenceMananger ;
4038
41- constructor ( plugins : ILowCodePluginManager , options : IPluginContextOptions ) {
42- const editor = this [ editorSymbol ] = plugins . editor ;
43- const designer = this [ designerSymbol ] = editor . get ( 'designer' ) ! ;
44- const skeleton = this [ skeletonSymbol ] = editor . get ( 'skeleton' ) ! ;
45-
46- const { pluginName = 'anonymous' } = options ;
47- const project = designer ?. project ;
48- this . hotkey = new Hotkey ( ) ;
49- this . project = new Project ( project ) ;
50- this . skeleton = new Skeleton ( skeleton ) ;
51- this . setters = new Setters ( ) ;
52- this . material = new Material ( editor ) ;
53- this . config = engineConfig ;
39+ constructor (
40+ plugins : ILowCodePluginManager ,
41+ options : IPluginContextOptions ,
42+ contextApiAssembler : ILowCodePluginContextApiAssembler ,
43+ ) {
5444 this . plugins = plugins ;
55- this . event = new Event ( editor , { prefix : 'common ' } ) ;
45+ const { pluginName = 'anonymous ' } = options ;
5646 this . logger = getLogger ( { level : 'warn' , bizName : `designer:plugin:${ pluginName } ` } ) ;
5747
5848 const enhancePluginContextHook = engineConfig . get ( 'enhancePluginContextHook' ) ;
5949 if ( enhancePluginContextHook ) {
6050 enhancePluginContextHook ( this ) ;
6151 }
52+
53+ contextApiAssembler . assembleApis ( this ) ;
6254 }
6355
6456 setPreference (
0 commit comments