@@ -47,26 +47,26 @@ import {
4747 getRectTarget ,
4848 CanvasPoint ,
4949 Designer ,
50+ IDesigner ,
5051} from '../designer' ;
5152import { parseMetadata } from './utils/parse-metadata' ;
5253import { getClosestClickableNode } from './utils/clickable' ;
5354import {
5455 IPublicTypeComponentMetadata ,
55- IPublicTypeComponentSchema ,
5656 IPublicTypePackage ,
5757 IPublicEnumTransitionType ,
5858 IPublicEnumDragObjectType ,
59- IPublicTypeDragNodeObject ,
6059 IPublicTypeNodeInstance ,
6160 IPublicTypeComponentInstance ,
6261 IPublicTypeLocationChildrenDetail ,
6362 IPublicTypeLocationDetailType ,
6463 IPublicTypeRect ,
64+ IPublicModelNode ,
6565} from '@alilc/lowcode-types' ;
6666import { BuiltinSimulatorRenderer } from './renderer' ;
6767import { clipboard } from '../designer/clipboard' ;
6868import { LiveEditing } from './live-editing/live-editing' ;
69- import { Project } from '../project' ;
69+ import { IProject , Project } from '../project' ;
7070import { IScroller } from '../designer/scroller' ;
7171import { isElementNode , isDOMNodeVisible } from '../utils/misc' ;
7272import { debounce } from 'lodash' ;
@@ -164,9 +164,9 @@ const defaultRaxEnvironment = [
164164export class BuiltinSimulatorHost implements ISimulatorHost < BuiltinSimulatorProps > {
165165 readonly isSimulator = true ;
166166
167- readonly project : Project ;
167+ readonly project : IProject ;
168168
169- readonly designer : Designer ;
169+ readonly designer : IDesigner ;
170170
171171 readonly viewport = new Viewport ( ) ;
172172
@@ -217,7 +217,7 @@ export class BuiltinSimulatorHost implements ISimulatorHost<BuiltinSimulatorProp
217217 return this . get ( 'requestHandlersMap' ) || null ;
218218 }
219219
220- get thisRequiredInJSE ( ) : any {
220+ get thisRequiredInJSE ( ) : boolean {
221221 return engineConfig . get ( 'thisRequiredInJSE' ) ?? true ;
222222 }
223223
@@ -559,8 +559,8 @@ export class BuiltinSimulatorHost implements ISimulatorHost<BuiltinSimulatorProp
559559 return ;
560560 }
561561 // FIXME: dirty fix remove label-for fro liveEditing
562- ( downEvent . target as HTMLElement ) . removeAttribute ( 'for' ) ;
563- const nodeInst = this . getNodeInstanceFromElement ( downEvent . target as Element ) ;
562+ downEvent . target ? .removeAttribute ( 'for' ) ;
563+ const nodeInst = this . getNodeInstanceFromElement ( downEvent . target ) ;
564564 const { focusNode } = documentModel ;
565565 const node = getClosestClickableNode ( nodeInst ?. node || focusNode , downEvent ) ;
566566 // 如果找不到可点击的节点,直接返回
@@ -675,11 +675,11 @@ export class BuiltinSimulatorHost implements ISimulatorHost<BuiltinSimulatorProp
675675 const x = new Event ( 'click' ) ;
676676 x . initEvent ( 'click' , true ) ;
677677 this . _iframe ?. dispatchEvent ( x ) ;
678- const target = e . target as HTMLElement ;
678+ const target = e . target ;
679679
680680 const customizeIgnoreSelectors = engineConfig . get ( 'customizeIgnoreSelectors' ) ;
681681 // TODO: need more elegant solution to ignore click events of components in designer
682- const defaultIgnoreSelectors : any = [
682+ const defaultIgnoreSelectors : string [ ] = [
683683 '.next-input-group' ,
684684 '.next-checkbox-group' ,
685685 '.next-checkbox-wrapper' ,
@@ -741,7 +741,7 @@ export class BuiltinSimulatorHost implements ISimulatorHost<BuiltinSimulatorProp
741741 }
742742 } ;
743743 const leave = ( ) => {
744- this . project . currentDocument && detecting . leave ( this . project . currentDocument )
744+ this . project . currentDocument && detecting . leave ( this . project . currentDocument ) ;
745745 } ;
746746
747747 doc . addEventListener ( 'mouseover' , hover , true ) ;
@@ -812,7 +812,7 @@ export class BuiltinSimulatorHost implements ISimulatorHost<BuiltinSimulatorProp
812812 /**
813813 * @see ISimulator
814814 */
815- setSuspense ( suspended : boolean ) {
815+ setSuspense ( /** _suspended : boolean */ ) {
816816 return false ;
817817 // if (suspended) {
818818 // /*
@@ -897,7 +897,7 @@ export class BuiltinSimulatorHost implements ISimulatorHost<BuiltinSimulatorProp
897897 return this . renderer ?. getComponent ( componentName ) || null ;
898898 }
899899
900- createComponent ( schema : IPublicTypeComponentSchema ) : Component | null {
900+ createComponent ( /** _schema : IPublicTypeComponentSchema */ ) : Component | null {
901901 return null ;
902902 // return this.renderer?.createComponent(schema) || null;
903903 }
@@ -1018,7 +1018,7 @@ export class BuiltinSimulatorHost implements ISimulatorHost<BuiltinSimulatorProp
10181018 }
10191019
10201020 if ( last ) {
1021- const r : any = new DOMRect ( last . x , last . y , last . r - last . x , last . b - last . y ) ;
1021+ const r : IPublicTypeRect = new DOMRect ( last . x , last . y , last . r - last . x , last . b - last . y ) ;
10221022 r . elements = elements ;
10231023 r . computed = _computed ;
10241024 return r ;
@@ -1186,13 +1186,14 @@ export class BuiltinSimulatorHost implements ISimulatorHost<BuiltinSimulatorProp
11861186 */
11871187 locate ( e : ILocateEvent ) : any {
11881188 const { dragObject } = e ;
1189- const { nodes } = dragObject as IPublicTypeDragNodeObject ;
1189+
1190+ const nodes = dragObject ?. nodes ;
11901191
11911192 const operationalNodes = nodes ?. filter ( ( node ) => {
11921193 const onMoveHook = node . componentMeta ?. advanced . callbacks ?. onMoveHook ;
11931194 const canMove = onMoveHook && typeof onMoveHook === 'function' ? onMoveHook ( node . internalToShellNode ( ) ) : true ;
11941195
1195- let parentContainerNode : Node | null = null ;
1196+ let parentContainerNode : INode | null = null ;
11961197 let parentNode = node . parent ;
11971198
11981199 while ( parentNode ) {
@@ -1254,7 +1255,7 @@ export class BuiltinSimulatorHost implements ISimulatorHost<BuiltinSimulatorProp
12541255 } ;
12551256
12561257 const locationData = {
1257- target : container as INode ,
1258+ target : container ,
12581259 detail,
12591260 source : `simulator${ document . id } ` ,
12601261 event : e ,
@@ -1279,12 +1280,12 @@ export class BuiltinSimulatorHost implements ISimulatorHost<BuiltinSimulatorProp
12791280 return this . designer . createLocation ( locationData ) ;
12801281 }
12811282
1282- let nearRect = null ;
1283- let nearIndex = 0 ;
1284- let nearNode = null ;
1285- let nearDistance = null ;
1286- let minTop = null ;
1287- let maxBottom = null ;
1283+ let nearRect : IPublicTypeRect | null = null ;
1284+ let nearIndex : number = 0 ;
1285+ let nearNode : INode | null = null ;
1286+ let nearDistance : number | null = null ;
1287+ let minTop : number | null = null ;
1288+ let maxBottom : number | null = null ;
12881289
12891290 for ( let i = 0 , l = children . size ; i < l ; i ++ ) {
12901291 const node = children . get ( i ) ! ;
@@ -1341,8 +1342,13 @@ export class BuiltinSimulatorHost implements ISimulatorHost<BuiltinSimulatorProp
13411342 const vertical = inline || row ;
13421343
13431344 // TODO: fix type
1344- const near : any = {
1345- node : nearNode ,
1345+ const near : {
1346+ node : IPublicModelNode ;
1347+ pos : 'before' | 'after' | 'replace' ;
1348+ rect ?: IPublicTypeRect ;
1349+ align ?: 'V' | 'H' ;
1350+ } = {
1351+ node : nearNode . internalToShellNode ( ) ! ,
13461352 pos : 'before' ,
13471353 align : vertical ? 'V' : 'H' ,
13481354 } ;
@@ -1465,7 +1471,7 @@ export class BuiltinSimulatorHost implements ISimulatorHost<BuiltinSimulatorProp
14651471 container = container . parent ;
14661472 instance = this . getClosestNodeInstance ( dropContainer . instance , container . id ) ?. instance ;
14671473 dropContainer = {
1468- container : container ,
1474+ container,
14691475 instance,
14701476 } ;
14711477 } else {
@@ -1483,12 +1489,12 @@ export class BuiltinSimulatorHost implements ISimulatorHost<BuiltinSimulatorProp
14831489 /**
14841490 * 控制接受
14851491 */
1486- handleAccept ( { container, instance } : DropContainer , e : ILocateEvent ) : boolean {
1492+ handleAccept ( { container } : DropContainer , e : ILocateEvent ) : boolean {
14871493 const { dragObject } = e ;
14881494 const document = this . currentDocument ! ;
14891495 const focusNode = document . focusNode ;
14901496 if ( isRootNode ( container ) || container . contains ( focusNode ) ) {
1491- return document . checkNesting ( focusNode , dragObject as any ) ;
1497+ return document . checkNesting ( focusNode ! , dragObject as any ) ;
14921498 }
14931499
14941500 const meta = ( container as Node ) . componentMeta ;
@@ -1509,15 +1515,12 @@ export class BuiltinSimulatorHost implements ISimulatorHost<BuiltinSimulatorProp
15091515 getNearByContainer (
15101516 { container, instance } : DropContainer ,
15111517 drillDownExcludes : Set < INode > ,
1512- e : ILocateEvent ,
15131518 ) {
15141519 const { children } = container ;
1515- const document = this . project . currentDocument ! ;
15161520 if ( ! children || children . isEmpty ( ) ) {
15171521 return null ;
15181522 }
15191523
1520- const nearDistance : any = null ;
15211524 const nearBy : any = null ;
15221525 for ( let i = 0 , l = children . size ; i < l ; i ++ ) {
15231526 let child = children . get ( i ) ;
0 commit comments