11import { Type } from '@angular/core' ;
2- import { ClassicPreset , getUID } from 'rete' ;
3- import { AreaPlugin } from 'rete-area-plugin' ;
2+ import { ClassicPreset , getUID , Scope } from 'rete' ;
43import { classicConnectionPath , loopConnectionPath , SocketPositionWatcher , getDOMSocketPosition } from 'rete-render-utils' ;
54import { AngularArea2D , ClassicScheme , ExtractPayload } from './types' ;
65import { NodeComponent } from './components/node/node.component' ;
@@ -9,18 +8,18 @@ import { ControlComponent } from './components/control/control.component';
98import { ConnectionComponent } from './components/connection/connection.component' ;
109import { ConnectionWrapperComponent } from './components/connection/connection-wrapper.component' ;
1110import { Position } from '../../types' ;
12- import { RenderPreset } from '../types'
11+ import { RenderPreset } from '../types'
1312
1413type AngularComponent = Type < any >
15- type CustomizationProps < Schemes extends ClassicScheme > = {
14+ type CustomizationProps < Schemes extends ClassicScheme > = {
1615 node ?: ( data : ExtractPayload < Schemes , 'node' > ) => AngularComponent | null
1716 connection ?: ( data : ExtractPayload < Schemes , 'connection' > ) => AngularComponent | null
1817 socket ?: ( data : ExtractPayload < Schemes , 'socket' > ) => AngularComponent | null
1918 control ?: ( data : ExtractPayload < Schemes , 'control' > ) => AngularComponent | null
2019}
2120
2221type ClassicProps < Schemes extends ClassicScheme , K > = {
23- socketPositionWatcher ?: SocketPositionWatcher < AreaPlugin < Schemes , K > >
22+ socketPositionWatcher ?: SocketPositionWatcher < Scope < never , [ K ] > >
2423 customize ?: CustomizationProps < Schemes >
2524}
2625
@@ -35,9 +34,7 @@ export function setup<Schemes extends ClassicScheme, K extends AngularArea2D<Sch
3534
3635 return {
3736 attach ( plugin ) {
38- if ( ! plugin . hasParent ( ) ) return
39-
40- positionWatcher . attach ( plugin . parentScope < AreaPlugin < Schemes , any > > ( AreaPlugin ) )
37+ positionWatcher . attach ( plugin as unknown as Scope < never , [ K ] > )
4138 } ,
4239 update ( context ) {
4340 const data = context . data . payload
@@ -89,13 +86,16 @@ export function setup<Schemes extends ClassicScheme, K extends AngularArea2D<Sch
8986 end : end || ( ( change : any ) => positionWatcher . listen ( target , 'input' , targetInput , change ) ) ,
9087 path : async ( start , end ) => {
9188 const response = await plugin . emit ( { type : 'connectionpath' , data : { payload, points : [ start , end ] } } )
89+
90+ if ( ! response ) return ''
91+
9292 const { path, points } = response . data
9393 const curvature = 0.3
9494
9595 if ( ! path && points . length !== 2 ) throw new Error ( 'cannot render connection with a custom number of points' )
9696 if ( ! path ) return payload . isLoop
97- ? loopConnectionPath ( points as [ Position , Position ] , curvature , 120 )
98- : classicConnectionPath ( points as [ Position , Position ] , curvature )
97+ ? loopConnectionPath ( points as [ Position , Position ] , curvature , 120 )
98+ : classicConnectionPath ( points as [ Position , Position ] , curvature )
9999
100100 return path
101101 } ,
@@ -120,8 +120,8 @@ export function setup<Schemes extends ClassicScheme, K extends AngularArea2D<Sch
120120 ? control ( context . data )
121121 : (
122122 context . data . payload instanceof ClassicPreset . InputControl
123- ? ControlComponent
124- : null
123+ ? ControlComponent
124+ : null
125125 )
126126
127127 if ( component ) {
0 commit comments