[refactor] Extract Vue node entry point logic into focused composables (#5390)

* refactor: Extract Vue node entry point logic into focused composables

- Extract logic from GraphCanvas.vue (735→200 lines) into 3 composables:
  - useVueNodeLifecycle: Node manager initialization and cleanup
  - useViewportCulling: Viewport culling with transform sync
  - useNodeEventHandlers: Node selection, collapse, title handlers

- Remove type assertions by using comfyApp.canvas instead of canvasStore.canvas
- Eliminate getter anti-pattern with proper Vue reactive refs
- Fix all TypeScript compatibility issues without workarounds
- Maintain proper separation of concerns and Vue-idiomatic patterns

* style: Remove extra comments from return statement

* [auto-fix] Apply ESLint and Prettier fixes

* style: Remove conversational comments

- Remove temporary comments that only made sense in refactoring context
- Clean up comment wording to be more permanent/professional
- Keep meaningful comments about code behavior and architecture

---------

Co-authored-by: GitHub Action <action@github.com>
This commit is contained in:
Christian Byrne
2025-09-06 04:26:23 -07:00
committed by GitHub
parent 8445605777
commit b4b732ad8f
5 changed files with 703 additions and 351 deletions

View File

@@ -2,7 +2,7 @@
* Vue node lifecycle management for LiteGraph integration
* Provides event-driven reactivity with performance optimizations
*/
import { nextTick, reactive, readonly } from 'vue'
import { nextTick, reactive } from 'vue'
import { useLayoutMutations } from '@/renderer/core/layout/operations/layoutMutations'
import { LayoutSource } from '@/renderer/core/layout/types'
@@ -604,7 +604,7 @@ export const useGraphNodeManager = (graph: LGraph): GraphNodeManager => {
// Set up widget callbacks BEFORE extracting data (critical order)
setupNodeWidgetCallbacks(node)
// Extract safe data for Vue (now with proper callbacks)
// Extract safe data for Vue
vueNodeData.set(id, extractVueNodeData(node))
// Set up reactive tracking state
@@ -789,16 +789,10 @@ export const useGraphNodeManager = (graph: LGraph): GraphNodeManager => {
}
return {
vueNodeData: readonly(vueNodeData) as ReadonlyMap<string, VueNodeData>,
nodeState: readonly(nodeState) as ReadonlyMap<string, NodeState>,
nodePositions: readonly(nodePositions) as ReadonlyMap<
string,
{ x: number; y: number }
>,
nodeSizes: readonly(nodeSizes) as ReadonlyMap<
string,
{ width: number; height: number }
>,
vueNodeData,
nodeState,
nodePositions,
nodeSizes,
getNode,
setupEventListeners,
cleanup,
@@ -807,7 +801,7 @@ export const useGraphNodeManager = (graph: LGraph): GraphNodeManager => {
detectChangesInRAF,
getVisibleNodeIds,
performanceMetrics,
spatialMetrics: readonly(spatialMetrics),
spatialMetrics,
getSpatialIndexDebugInfo: () => spatialIndex.getDebugInfo()
}
}