@@ -99,6 +99,7 @@ export interface BuiltinSimulatorProps {
9999 simulatorUrl ?: Asset ;
100100 theme ?: Asset ;
101101 componentsAsset ?: Asset ;
102+ // eslint-disable-next-line @typescript-eslint/member-ordering
102103 [ key : string ] : any ;
103104}
104105
@@ -184,40 +185,6 @@ export class BuiltinSimulatorHost implements ISimulatorHost<BuiltinSimulatorProp
184185 */
185186 autoRender = true ;
186187
187- stopAutoRepaintNode ( ) {
188- this . renderer ?. stopAutoRepaintNode ( ) ;
189- }
190-
191- enableAutoRepaintNode ( ) {
192- this . renderer ?. enableAutoRepaintNode ( ) ;
193- }
194-
195- constructor ( project : Project , designer : Designer ) {
196- makeObservable ( this ) ;
197- this . project = project ;
198- this . designer = designer ;
199- this . scroller = this . designer . createScroller ( this . viewport ) ;
200- this . autoRender = ! engineConfig . get ( 'disableAutoRender' , false ) ;
201- this . componentsConsumer = new ResourceConsumer < Asset | undefined > ( ( ) => this . componentsAsset ) ;
202- this . injectionConsumer = new ResourceConsumer ( ( ) => {
203- return {
204- appHelper : engineConfig . get ( 'appHelper' ) ,
205- } ;
206- } ) ;
207-
208- this . i18nConsumer = new ResourceConsumer ( ( ) => this . project . i18n ) ;
209-
210- transactionManager . onStartTransaction ( ( ) => {
211- this . stopAutoRepaintNode ( ) ;
212- } , IPublicEnumTransitionType . REPAINT ) ;
213- // 防止批量调用 transaction 时,执行多次 rerender
214- const rerender = debounce ( this . rerender . bind ( this ) , 28 ) ;
215- transactionManager . onEndTransaction ( ( ) => {
216- rerender ( ) ;
217- this . enableAutoRepaintNode ( ) ;
218- } , IPublicEnumTransitionType . REPAINT ) ;
219- }
220-
221188 get currentDocument ( ) {
222189 return this . project . currentDocument ;
223190 }
@@ -285,6 +252,87 @@ export class BuiltinSimulatorHost implements ISimulatorHost<BuiltinSimulatorProp
285252
286253 @obx . ref _props : BuiltinSimulatorProps = { } ;
287254
255+ @obx . ref private _contentWindow ?: Window ;
256+
257+ get contentWindow ( ) {
258+ return this . _contentWindow ;
259+ }
260+
261+ @obx . ref private _contentDocument ?: Document ;
262+
263+ get contentDocument ( ) {
264+ return this . _contentDocument ;
265+ }
266+
267+ private _renderer ?: BuiltinSimulatorRenderer ;
268+
269+ get renderer ( ) {
270+ return this . _renderer ;
271+ }
272+
273+ readonly asyncLibraryMap : { [ key : string ] : { } } = { } ;
274+
275+ readonly libraryMap : { [ key : string ] : string } = { } ;
276+
277+ private _iframe ?: HTMLIFrameElement ;
278+
279+ private disableHovering ?: ( ) => void ;
280+
281+ private disableDetecting ?: ( ) => void ;
282+
283+ readonly liveEditing = new LiveEditing ( ) ;
284+
285+ @obx private instancesMap : {
286+ [ docId : string ] : Map < string , IPublicTypeComponentInstance [ ] > ;
287+ } = { } ;
288+
289+ private tryScrollAgain : number | null = null ;
290+
291+ private _sensorAvailable = true ;
292+
293+ /**
294+ * @see IPublicModelSensor
295+ */
296+ get sensorAvailable ( ) : boolean {
297+ return this . _sensorAvailable ;
298+ }
299+
300+ private sensing = false ;
301+
302+ constructor ( project : Project , designer : Designer ) {
303+ makeObservable ( this ) ;
304+ this . project = project ;
305+ this . designer = designer ;
306+ this . scroller = this . designer . createScroller ( this . viewport ) ;
307+ this . autoRender = ! engineConfig . get ( 'disableAutoRender' , false ) ;
308+ this . componentsConsumer = new ResourceConsumer < Asset | undefined > ( ( ) => this . componentsAsset ) ;
309+ this . injectionConsumer = new ResourceConsumer ( ( ) => {
310+ return {
311+ appHelper : engineConfig . get ( 'appHelper' ) ,
312+ } ;
313+ } ) ;
314+
315+ this . i18nConsumer = new ResourceConsumer ( ( ) => this . project . i18n ) ;
316+
317+ transactionManager . onStartTransaction ( ( ) => {
318+ this . stopAutoRepaintNode ( ) ;
319+ } , IPublicEnumTransitionType . REPAINT ) ;
320+ // 防止批量调用 transaction 时,执行多次 rerender
321+ const rerender = debounce ( this . rerender . bind ( this ) , 28 ) ;
322+ transactionManager . onEndTransaction ( ( ) => {
323+ rerender ( ) ;
324+ this . enableAutoRepaintNode ( ) ;
325+ } , IPublicEnumTransitionType . REPAINT ) ;
326+ }
327+
328+ stopAutoRepaintNode ( ) {
329+ this . renderer ?. stopAutoRepaintNode ( ) ;
330+ }
331+
332+ enableAutoRepaintNode ( ) {
333+ this . renderer ?. enableAutoRepaintNode ( ) ;
334+ }
335+
288336 /**
289337 * @see ISimulator
290338 */
@@ -337,30 +385,6 @@ export class BuiltinSimulatorHost implements ISimulatorHost<BuiltinSimulatorProp
337385 this . viewport . mount ( viewport ) ;
338386 }
339387
340- @obx . ref private _contentWindow ?: Window ;
341-
342- get contentWindow ( ) {
343- return this . _contentWindow ;
344- }
345-
346- @obx . ref private _contentDocument ?: Document ;
347-
348- get contentDocument ( ) {
349- return this . _contentDocument ;
350- }
351-
352- private _renderer ?: BuiltinSimulatorRenderer ;
353-
354- get renderer ( ) {
355- return this . _renderer ;
356- }
357-
358- readonly asyncLibraryMap : { [ key : string ] : { } } = { } ;
359-
360- readonly libraryMap : { [ key : string ] : string } = { } ;
361-
362- private _iframe ?: HTMLIFrameElement ;
363-
364388 /**
365389 * {
366390 * "title":"BizCharts",
@@ -544,7 +568,7 @@ export class BuiltinSimulatorHost implements ISimulatorHost<BuiltinSimulatorProp
544568 return ;
545569 }
546570 // 触发 onMouseDownHook 钩子
547- const onMouseDownHook = node . componentMeta ?. getMetadata ( ) ?. configure . advanced ? .callbacks ?. onMouseDownHook ;
571+ const onMouseDownHook = node . componentMeta . advanced . callbacks ?. onMouseDownHook ;
548572 if ( onMouseDownHook ) {
549573 onMouseDownHook ( downEvent , node . internalToShellNode ( ) ) ;
550574 }
@@ -689,10 +713,6 @@ export class BuiltinSimulatorHost implements ISimulatorHost<BuiltinSimulatorProp
689713 ) ;
690714 }
691715
692- private disableHovering ?: ( ) => void ;
693-
694- private disableDetecting ?: ( ) => void ;
695-
696716 /**
697717 * 设置悬停处理
698718 */
@@ -742,8 +762,6 @@ export class BuiltinSimulatorHost implements ISimulatorHost<BuiltinSimulatorProp
742762 // };
743763 }
744764
745- readonly liveEditing = new LiveEditing ( ) ;
746-
747765 setupLiveEditing ( ) {
748766 const doc = this . contentDocument ! ;
749767 // cause edit
@@ -880,9 +898,6 @@ export class BuiltinSimulatorHost implements ISimulatorHost<BuiltinSimulatorProp
880898 // return this.renderer?.createComponent(schema) || null;
881899 }
882900
883- @obx private instancesMap : {
884- [ docId : string ] : Map < string , IPublicTypeComponentInstance [ ] > ;
885- } = { } ;
886901 setInstance ( docId : string , id : string , instances : IPublicTypeComponentInstance [ ] | null ) {
887902 if ( ! hasOwnProperty ( this . instancesMap , docId ) ) {
888903 this . instancesMap [ docId ] = new Map ( ) ;
@@ -1045,8 +1060,6 @@ export class BuiltinSimulatorHost implements ISimulatorHost<BuiltinSimulatorProp
10451060 } ;
10461061 }
10471062
1048- private tryScrollAgain : number | null = null ;
1049-
10501063 /**
10511064 * @see ISimulator
10521065 */
@@ -1107,15 +1120,6 @@ export class BuiltinSimulatorHost implements ISimulatorHost<BuiltinSimulatorProp
11071120 this . renderer ?. clearState ( ) ;
11081121 }
11091122
1110- private _sensorAvailable = true ;
1111-
1112- /**
1113- * @see IPublicModelSensor
1114- */
1115- get sensorAvailable ( ) : boolean {
1116- return this . _sensorAvailable ;
1117- }
1118-
11191123 /**
11201124 * @see IPublicModelSensor
11211125 */
@@ -1160,8 +1164,6 @@ export class BuiltinSimulatorHost implements ISimulatorHost<BuiltinSimulatorProp
11601164 ) ;
11611165 }
11621166
1163- private sensing = false ;
1164-
11651167 /**
11661168 * @see IPublicModelSensor
11671169 */
@@ -1180,7 +1182,7 @@ export class BuiltinSimulatorHost implements ISimulatorHost<BuiltinSimulatorProp
11801182 const { nodes } = dragObject as IPublicTypeDragNodeObject ;
11811183
11821184 const operationalNodes = nodes ?. filter ( ( node ) => {
1183- const onMoveHook = node . componentMeta ?. getMetadata ( ) ?. configure . advanced ? .callbacks ?. onMoveHook ;
1185+ const onMoveHook = node . componentMeta ?. advanced . callbacks ?. onMoveHook ;
11841186 const canMove = onMoveHook && typeof onMoveHook === 'function' ? onMoveHook ( node . internalToShellNode ( ) ) : true ;
11851187
11861188 let parentContainerNode : Node | null = null ;
@@ -1195,7 +1197,7 @@ export class BuiltinSimulatorHost implements ISimulatorHost<BuiltinSimulatorProp
11951197 parentNode = parentNode . parent ;
11961198 }
11971199
1198- const onChildMoveHook = parentContainerNode ?. componentMeta ?. getMetadata ( ) ?. configure . advanced ? .callbacks ?. onChildMoveHook ;
1200+ const onChildMoveHook = parentContainerNode ?. componentMeta ?. advanced . callbacks ?. onChildMoveHook ;
11991201
12001202 const childrenCanMove = onChildMoveHook && parentContainerNode && typeof onChildMoveHook === 'function' ? onChildMoveHook ( node . internalToShellNode ( ) , parentContainerNode . internalToShellNode ( ) ) : true ;
12011203
0 commit comments