66 IPublicTypeComponentAction ,
77 IPublicTypeNpmInfo ,
88 IPublicModelEditor ,
9- IPublicTypeCompositeObject ,
109 IPublicTypePropsList ,
1110 IPublicTypeNodeSchema ,
1211 IPublicTypePropsTransducer ,
@@ -17,15 +16,16 @@ import {
1716 IPublicTypeLocationData ,
1817 IPublicEnumTransformStage ,
1918 IPublicModelLocateEvent ,
19+ IPublicTypePropsMap ,
2020} from '@alilc/lowcode-types' ;
2121import { mergeAssets , IPublicTypeAssetsJson , isNodeSchema , isDragNodeObject , isDragNodeDataObject , isLocationChildrenDetail , Logger } from '@alilc/lowcode-utils' ;
2222import { IProject , Project } from '../project' ;
23- import { Node , DocumentModel , insertChildren , INode , ISelection } from '../document' ;
23+ import { Node , DocumentModel , insertChildren , INode } from '../document' ;
2424import { ComponentMeta , IComponentMeta } from '../component-meta' ;
2525import { INodeSelector , Component } from '../simulator' ;
2626import { Scroller } from './scroller' ;
2727import { Dragon , IDragon } from './dragon' ;
28- import { ActiveTracker , IActiveTracker } from './active-tracker' ;
28+ import { ActiveTracker } from './active-tracker' ;
2929import { Detecting } from './detecting' ;
3030import { DropLocation } from './location' ;
3131import { OffsetObserver , createOffsetObserver } from './offset-observer' ;
@@ -47,7 +47,7 @@ export interface DesignerProps {
4747 viewName ?: string ;
4848 simulatorProps ?: Record < string , any > | ( ( document : DocumentModel ) => object ) ;
4949 simulatorComponent ?: ComponentType < any > ;
50- dragGhostComponent ?: ComponentType < any > ;
50+ dragGhostComponent ?: ComponentType < { designer : IDesigner } > ;
5151 suspensed ?: boolean ;
5252 componentMetadatas ?: IPublicTypeComponentMetadata [ ] ;
5353 globalComponentActions ?: IPublicTypeComponentAction [ ] ;
@@ -60,70 +60,10 @@ export interface DesignerProps {
6060 ) => void ;
6161}
6262
63- export interface IDesigner {
64- readonly shellModelFactory : IShellModelFactory ;
65-
66- viewName : string | undefined ;
67-
68- readonly project : IProject ;
69-
70- get dragon ( ) : IDragon ;
71-
72- get activeTracker ( ) : IActiveTracker ;
73-
74- get componentActions ( ) : ComponentActions ;
75-
76- get contextMenuActions ( ) : ContextMenuActions ;
77-
78- get editor ( ) : IPublicModelEditor ;
79-
80- get detecting ( ) : Detecting ;
81-
82- get simulatorComponent ( ) : ComponentType < any > | undefined ;
83-
84- get currentSelection ( ) : ISelection ;
85-
86- createScroller ( scrollable : IPublicTypeScrollable ) : IPublicModelScroller ;
87-
88- refreshComponentMetasMap ( ) : void ;
89-
90- createOffsetObserver ( nodeInstance : INodeSelector ) : OffsetObserver | null ;
91-
92- /**
93- * 创建插入位置,考虑放到 dragon 中
94- */
95- createLocation ( locationData : IPublicTypeLocationData < INode > ) : DropLocation ;
96-
97- get componentsMap ( ) : { [ key : string ] : IPublicTypeNpmInfo | Component } ;
98-
99- loadIncrementalAssets ( incrementalAssets : IPublicTypeAssetsJson ) : Promise < void > ;
100-
101- getComponentMeta (
102- componentName : string ,
103- generateMetadata ?: ( ) => IPublicTypeComponentMetadata | null ,
104- ) : IComponentMeta ;
105-
106- clearLocation ( ) : void ;
107-
108- createComponentMeta ( data : IPublicTypeComponentMetadata ) : IComponentMeta | null ;
109-
110- getComponentMetasMap ( ) : Map < string , IComponentMeta > ;
111-
112- addPropsReducer ( reducer : IPublicTypePropsTransducer , stage : IPublicEnumTransformStage ) : void ;
113-
114- postEvent ( event : string , ...args : any [ ] ) : void ;
115-
116- transformProps ( props : IPublicTypeCompositeObject | IPublicTypePropsList , node : Node , stage : IPublicEnumTransformStage ) : IPublicTypeCompositeObject | IPublicTypePropsList ;
117-
118- createSettingEntry ( nodes : INode [ ] ) : ISettingTopEntry ;
119-
120- autorun ( effect : ( reaction : IReactionPublic ) => void , options ?: IReactionOptions < any , any > ) : IReactionDisposer ;
121- }
122-
123- export class Designer implements IDesigner {
63+ export class Designer {
12464 dragon : IDragon ;
12565
126- viewName : string | undefined ;
66+ readonly viewName : string | undefined ;
12767
12868 readonly componentActions = new ComponentActions ( ) ;
12969
@@ -423,7 +363,7 @@ export class Designer implements IDesigner {
423363 if ( props . simulatorProps !== this . props . simulatorProps ) {
424364 this . _simulatorProps = props . simulatorProps ;
425365 // 重新 setupSelection
426- if ( props . simulatorProps ?. designMode !== this . props . simulatorProps ?. designMode ) {
366+ if ( ( props . simulatorProps as any ) ?. designMode !== ( this . props . simulatorProps as any ) ?. designMode ) {
427367 this . setupSelection ( ) ;
428368 }
429369 }
@@ -612,7 +552,7 @@ export class Designer implements IDesigner {
612552 return maps ;
613553 }
614554
615- transformProps ( props : IPublicTypeCompositeObject | IPublicTypePropsList , node : Node , stage : IPublicEnumTransformStage ) {
555+ transformProps ( props : IPublicTypePropsMap | IPublicTypePropsList , node : Node , stage : IPublicEnumTransformStage ) : IPublicTypePropsMap | IPublicTypePropsList {
616556 if ( Array . isArray ( props ) ) {
617557 // current not support, make this future
618558 return props ;
@@ -623,7 +563,7 @@ export class Designer implements IDesigner {
623563 return props ;
624564 }
625565
626- return reducers . reduce ( ( xprops , reducer ) => {
566+ return reducers . reduce ( ( xprops , reducer : IPublicTypePropsTransducer ) => {
627567 try {
628568 return reducer ( xprops , node . internalToShellNode ( ) as any , { stage } ) ;
629569 } catch ( e ) {
@@ -655,3 +595,5 @@ export class Designer implements IDesigner {
655595 // TODO:
656596 }
657597}
598+
599+ export interface IDesigner extends Designer { }
0 commit comments