How niknah/quick-connections works
Project Type and Purpose
• This is an open-source plugin/tool for ComfyUI (a Python-based node editor), written in Python (for package registration) and JavaScript (for front-end feature injection). It enhances the graph UI with “quick connections” and “circuit board” style lines. It also offers a standalone demo and optional integration with litegraph.js.
File Structure
• Top Level
• .github/workflows/publish.yml → CI/CD for releases
• package.json / pyproject.toml → npm and Python packaging metadata
• __init__.py → Python package entrypoint for ComfyUI manager
• README.md → description and usage
• js/
• QuickConnection.js → main quick-connect logic
• CircuitBoardLines.js → custom line-drawing algorithms
• quick_conn_start.js → bootstrap code to register into ComfyUI front end
• docs/ & example/
• Example HTML/JS and demo pages showing how the plugin is loaded in a browser or via ComfyUI
• imgs/ → screenshots and animations for the README
Core Components
a. ComfyUI Host Application (Python back end + front-end UI)
b. ComfyUI Manager (plugin installer)
c. quick-connections Python Package
d. JavaScript Modules
• quick_conn_start.js (initializer)
• QuickConnection.js (UI event hooks)
• CircuitBoardLines.js (rendering engine)
e. Browser Rendering Context (HTML canvas / DOM)
f. Optional litegraph.js Integration
g. Example/Web Server (for demo pages)
Relationships & Data Flows
• Plugin Installation
ComfyUI Manager → pip/npm installs quick-connections (Python package + JS assets)
• Initialization at Runtime
ComfyUI Python process loads __init__.py → exposes plugin metadata
Front-end loads quick_conn_start.js → imports QuickConnection.js & CircuitBoardLines.js
• Event Hooking
quick_conn_start → registers “onConnectAttempt” handlers in ComfyUI UI
QuickConnection → intercepts drag events, computes connector endpoints
CircuitBoardLines → generates path coordinates (90°/45° or free angle)
Rendering → UI’s canvas draws custom SVG/Canvas paths instead of default lines
• Example / Demo Mode
Local http.server → serves example HTML → browser loads JS modules directly → shows plugin in isolation
• Optional Path
If litegraph.js is detected → plugin registers adapters to hook into litegraph’s node events
Architectural Patterns & Design Principles
• Plugin / Extension Architecture: clear separation between host (ComfyUI) and extension.
• Layered Separation:
• Packaging Layer (Python + npm)
• Initialization Layer (quick_conn_start.js)
• Core Logic Layer (QuickConnection, CircuitBoardLines)
• Integration Layer (ComfyUI hooks, litegraph adapter)
• Configuration / Feature Flags: toggle “Quick connections” and “Circuit Board lines” at runtime