7
7
import type { UUID } from '@/lib/litegraph/src/utils/uuid'
8
8
import { createUuidv4 , zeroUuid } from '@/lib/litegraph/src/utils/uuid'
9
9
import { useLayoutMutations } from '@/renderer/core/layout/operations/LayoutMutations'
10
- import type { LayoutMutations } from '@/renderer/core/layout/operations/LayoutMutations'
11
10
import { LayoutSource } from '@/renderer/core/layout/types'
12
11
13
12
import type { DragAndScaleState } from './DragAndScale'
@@ -191,9 +190,6 @@ export class LGraph
191
190
nodes_executedAction : string [ ] = [ ]
192
191
extra : LGraphExtra = { }
193
192
194
- /** Layout mutations instance for this graph */
195
- layoutMutations ! : LayoutMutations
196
-
197
193
/** @deprecated Deserialising a workflow sets this unused property. */
198
194
version ?: number
199
195
@@ -280,9 +276,6 @@ export class LGraph
280
276
constructor ( o ?: ISerialisedGraph | SerialisableGraph ) {
281
277
if ( LiteGraph . debug ) console . log ( 'Graph created' )
282
278
283
- // Get layout mutations composable
284
- this . layoutMutations = useLayoutMutations ( )
285
-
286
279
/** @see MapProxyHandler */
287
280
const links = this . _links
288
281
MapProxyHandler . bindAllMethods ( links )
@@ -1345,6 +1338,7 @@ export class LGraph
1345
1338
* @returns The newly created reroute - typically ignored.
1346
1339
*/
1347
1340
createReroute ( pos : Point , before : LinkSegment ) : Reroute {
1341
+ const layoutMutations = useLayoutMutations ( )
1348
1342
const rerouteId = ++ this . state . lastRerouteId
1349
1343
const linkIds = before instanceof Reroute ? before . linkIds : [ before . id ]
1350
1344
const floatingLinkIds =
@@ -1360,8 +1354,8 @@ export class LGraph
1360
1354
this . reroutes . set ( rerouteId , reroute )
1361
1355
1362
1356
// Register reroute in Layout Store for spatial tracking
1363
- this . layoutMutations . setSource ( LayoutSource . Canvas )
1364
- this . layoutMutations . createReroute (
1357
+ layoutMutations . setSource ( LayoutSource . Canvas )
1358
+ layoutMutations . createReroute (
1365
1359
rerouteId ,
1366
1360
{ x : pos [ 0 ] , y : pos [ 1 ] } ,
1367
1361
before . parentId ,
@@ -1398,6 +1392,7 @@ export class LGraph
1398
1392
* @param id ID of reroute to remove
1399
1393
*/
1400
1394
removeReroute ( id : RerouteId ) : void {
1395
+ const layoutMutations = useLayoutMutations ( )
1401
1396
const { reroutes } = this
1402
1397
const reroute = reroutes . get ( id )
1403
1398
if ( ! reroute ) return
@@ -1443,8 +1438,8 @@ export class LGraph
1443
1438
reroutes . delete ( id )
1444
1439
1445
1440
// Delete reroute from Layout Store
1446
- this . layoutMutations . setSource ( LayoutSource . Canvas )
1447
- this . layoutMutations . deleteReroute ( id )
1441
+ layoutMutations . setSource ( LayoutSource . Canvas )
1442
+ layoutMutations . deleteReroute ( id )
1448
1443
1449
1444
// This does not belong here; it should be handled by the caller, or run by a remove-many API.
1450
1445
// https://github.com/Comfy-Org/litegraph.js/issues/898
@@ -2129,6 +2124,7 @@ export class LGraph
2129
2124
data : ISerialisedGraph | SerialisableGraph ,
2130
2125
keep_old ?: boolean
2131
2126
) : boolean | undefined {
2127
+ const layoutMutations = useLayoutMutations ( )
2132
2128
const options : LGraphEventMap [ 'configuring' ] = {
2133
2129
data,
2134
2130
clearGraph : ! keep_old
@@ -2270,8 +2266,8 @@ export class LGraph
2270
2266
if ( ! reroute . validateLinks ( this . _links , this . floatingLinks ) ) {
2271
2267
this . reroutes . delete ( reroute . id )
2272
2268
// Clean up layout store
2273
- this . layoutMutations . setSource ( LayoutSource . Canvas )
2274
- this . layoutMutations . deleteReroute ( reroute . id )
2269
+ layoutMutations . setSource ( LayoutSource . Canvas )
2270
+ layoutMutations . deleteReroute ( reroute . id )
2275
2271
}
2276
2272
}
2277
2273
0 commit comments