Commit Graph

982 Commits

Author SHA1 Message Date
filtered
a20bae064f Allow floating reroute switches (#862)
- Resolves https://github.com/Comfy-Org/ComfyUI_frontend/issues/3247

Bypasses the logic that automatically removed reroutes that had no
remaining links. Reroutes are now always converted to floating whenever
reroutes are reconnected.
2025-03-27 18:18:22 +00:00
Chenlei Hu
a6aec4017b [Bug] Fix link drop on widget (#860)
Resolves https://github.com/Comfy-Org/litegraph.js/issues/857
2025-03-26 15:08:04 -04:00
Chenlei Hu
6fd6c60b9f [Bug] Fix drag link from input to output (#859)
Resolves https://github.com/Comfy-Org/litegraph.js/issues/858
2025-03-26 14:53:30 -04:00
Chenlei Hu
808d78169b Early return in LGraphCanvas.deselectAll (#856)
Avoid trigger `onSelectionChange` when nothing is selected.
2025-03-25 10:22:40 -04:00
Chenlei Hu
c5db2d8736 [Bug] Fix number widget range not enforced (#850)
Resolves https://github.com/Comfy-Org/ComfyUI_frontend/issues/3204
2025-03-24 15:37:55 -04:00
filtered
123c46d28b [TS] Add placeholder interfaces for subgraph classes (#851) 2025-03-24 19:23:20 +00:00
filtered
5662aa3790 [API] Remove unused: LGraph.getSupportedTypes (#849)
Also removes unused `supported_types` static array.
2025-03-24 07:03:07 +00:00
filtered
f0bd360935 [API] Remove unused callbacks (#848)
- Follow-up on #847
- Removes now-redundant callbacks
2025-03-24 06:58:56 +00:00
filtered
28543d7d9d [API] Remove unused LGraph APIs (#847)
Removes unused, outdated helper methods from the original, incomplete
subgraph impl.
2025-03-24 06:24:28 +00:00
filtered
b1462a6274 [API] Add customisation of reroute bezier controls (#846)
Allows globally setting the bezier control point offset from the reroute
centre point. This can be increased to allow larger curves on longer
links, or set to 0 to completely disable the spline on inter-reroute
link segments.
2025-03-24 06:10:57 +00:00
filtered
642317f6bd Reroute link styles (#845)
Improves linear & straight link styles to work with native reroutes
2025-03-24 13:31:43 +11:00
Chenlei Hu
7fc8f8c897 Add lowQuality param to IWidget.draw (#843)
Currently widget needs to get access to `LGraphCanvas` instance to know
whether the canvas is rendering in low quality (Zoomed out). Usually
canvas object is obtained from `ComfyApp` instance.

This PR passes the lowQuality value to `IWidget.draw` to decouple the
dependency on `LGraphCanvas`.
2025-03-23 20:50:14 -04:00
filtered
c8bd5e43dd Add litegraph input indicator helper class (#842)
Example usage with ComfyUI_frontend, via console / devtools:

```ts
const inputIndicators = new InputIndicators(app.canvas)
// Dispose:
inputIndicators.dispose()
```
2025-03-24 11:43:36 +11:00
filtered
fd4ffbc1f8 Fix render issues after moving floating input links (#841)
- Fixes floating inputs have invisible segment after moving
- Fixes floating input can be moved onto existing input link, resulting
in the slot having two links
2025-03-24 00:16:06 +00:00
filtered
7b8f01f546 [Refactor] Split moving links (#839)
Splits moving links out to separate input and output classes.
2025-03-23 22:11:08 +00:00
filtered
05587d8a19 Fix moving existing links can result in loopback (#838)
Prevents nodes connecting links to themselves when moving existing
links.

If moving multiple links with reroutes, this will instead _reconnect_
any links that would become loopbacks, only without any rereoutes.
2025-03-23 19:00:55 +00:00
filtered
ff6281c840 Fix cannot shift-drag new link from first link segment (#836)
Fixes issue where new links can only be shift-click dragged from the
link line on link segments *after* a native reroute.
2025-03-23 15:13:06 +00:00
filtered
642e73773c [CodeHealth] Improve legibility of renderingBoxColor (#832)
Drastically reduces the cognitive complexity of
`LGraphNode.renderingBoxColor` by impl. early returns.
2025-03-22 21:53:42 +00:00
filtered
a44b8d0581 Fix bypass links on delete gives up after corrupt link (#831)
Bypass links will now continue to attempt to connect other links,
instead of silently giving up on the first corrupt link it finds.
2025-03-22 21:50:18 +00:00
filtered
ba7f870e0f [CodeHealth] Improve code readability (#830) 2025-03-22 21:48:26 +00:00
filtered
b254bae5c5 Allow floating reroutes to be chained when creating new (#828)
- Resolves #827
2025-03-23 07:38:11 +11:00
filtered
2e95ac9a71 Fix minor render issues with links / reroutes (#825)
- Fixes link centre marker highlight drawn over dragged items
- Fixes arrow-style link centre marker drawn twice
- Adds missing centre markers for output floating links
- Adds render sort order for reroutes (more links rendered on top)
2025-03-23 06:36:14 +11:00
filtered
16eddaac5f Render floating links as faded out (#826)
- Resolves #806
- Renders floating links with a faded-out effect
2025-03-23 06:35:58 +11:00
filtered
5f03d9a3cf Revert "Implement _.pick to simplify serialization (#763)" (#823)
Reason: Performance

- 40x slower slot serialisation using randomised data
- Overall 2-3x slower `graph.serialize()` on a 600 node graph

This reverts commit 77465113cd.
2025-03-23 03:39:15 +11:00
filtered
0dd060a369 [API] Require always-exported node properties be defined (#821)
Now required:

- `type`
- `pos`
- `size`
- `flags`
- `order`
- `mode`
2025-03-23 03:25:57 +11:00
filtered
6380037d1f [API] Add subgraph schema export types (serialisation) (#822)
Adds export / serialisation interfaces to support subgraph impl.
2025-03-22 15:59:01 +00:00
filtered
cd9778bb6c Fix reroutes lost when dropping output links on reroute (#820)
Blocks attempts to drag links from an output onto a reroute in any of
the links.
2025-03-22 13:49:26 +00:00
filtered
2dbd5f4cf0 Allow creating floating reroutes from new link menu (#818)
Adds an `Add Reroute` option to the new link menu. Creates a new
floating reroute connected to the source slot.
2025-03-22 09:23:20 +11:00
filtered
850d1b9652 [API] Finalise LinkConnector design, adding reroute logic (#817)
- Splits link connect logic out of `LinkConnector` to individual
`RenderLink` classes
- Add support for connecting / reconnecting reroutes in various
configurations
- Adds support for moving existing floating links from outputs / inputs
- Fixes numerous corruption issues when reconnecting reroutes / moving
links
- Tests in separate PR #816
2025-03-21 19:41:20 +00:00
filtered
87aeab16a0 [API] Fix several floating links issues & add Reroute.totalLinks (#815)
Resolves several issues with floating links.  Highlights:

- Caches floating links on slots, removing some loop checks (inefficient
/ does not scale)
- Simpler APIs
- Adds `Reroute.totalLinks` (regular and floating
2025-03-21 19:17:54 +00:00
filtered
766e69bbf1 Fix regression: shift-drag new link from link line (#814)
- Resolves #375
- Resolves https://github.com/Comfy-Org/ComfyUI_frontend/issues/2941
2025-03-21 19:10:26 +00:00
filtered
38bbf2fead Add reroute snap highlight (#813)
### Reroute snap highlight

When connecting links, a simple border now helps to indicate that a
connecting link can be dropped on a reroute below the pointer.

### Reroute ID badges

Optionally, intended for debugging purposes, drawing of ID badges can
also be manually enabled via console.
2025-03-21 19:05:09 +00:00
filtered
a043e7a72e [API] Add reroute convenience methods (#812)
Adds `LGraph.getReroute`, which accepts null & undefined IDs. Interface
overloads result in `never` when given a _known_ `undefined` or `null`
value.
2025-03-21 18:58:07 +00:00
filtered
cdbc0fa5e5 Cancel link connection by pressing Esc (#811)
Cancels connecting links if the escape key is pressed.
2025-03-21 18:53:13 +00:00
filtered
4078e3ad8b Improve reroutes - prep for LinkConnector overhaul (#810)
- Fixes TS types
- Various bug fixes for reroute / link (re)connect
- Adds reroute snap circle when connecting links
- Validates reroutes on drop (part of larger work)
- Prevent nodes linking to themselves
2025-03-21 18:47:36 +00:00
filtered
e65898b9ec [API] Remove unused: LGraph.onAction (#802) 2025-03-18 20:06:46 +00:00
filtered
7845be9b15 [TS] TS type fix & nits (#801)
Fixes downstream type specificity issues with UUID template type. No
real benefit from template literal type at present.
2025-03-17 13:52:59 +00:00
filtered
0b4b420445 Add lib export: createUuidv4 (#800) 2025-03-17 13:39:19 +00:00
filtered
257d4fc7b9 Fix old graph ID kept when configuring new graph (#798)
Prevents ID leakage when using default `LGraph.configure()` settings.
2025-03-17 23:54:44 +11:00
Chenlei Hu
94b9ecec71 [Bug] Fix remove of floatingLinks (#792)
Resolves https://github.com/Comfy-Org/litegraph.js/issues/791

This PR fixes removal of floating links.

---------

Co-authored-by: filtered <176114999+webfiltered@users.noreply.github.com>
2025-03-16 22:13:24 +00:00
filtered
dbc605e4da Add graph ID creation / serialisation (#790)
- Updates UUIDv4 generator
- Adds a unique id & revision support to graphs
- `revision` to be incremented downstream (e.g. on save)
- `id` automatically assigned if not provided
2025-03-16 18:41:08 +00:00
filtered
3447ea1981 Remove unused code (#789)
'start' and 'finish' do not exist on canvas 2d context.
2025-03-16 04:37:34 +00:00
filtered
9b16144390 [CodeHealth] Standardise & remove deprecated code (#787)
- Removes event.keyCode use (i18n-safe)
- Prefer strict equality for readability
2025-03-15 03:15:38 +00:00
filtered
cd65c4bfea Fix regression in #782 undo fails via context menu (#785)
Only breaks when adding reroute via context menu.
2025-03-14 03:09:17 +00:00
filtered
bd17247b4f Centre reroutes spawned via link context menu (#782)
- Centre reroutes spawned via link context menu
- Fix changeTracker history for reroute context menu
2025-03-14 12:46:40 +11:00
filtered
48483670f5 Fix #781 regression in reconnect floating reroutes (#783)
- Follow-up on #781
- Fixes regression when reconnecting a reroute chain from an input
2025-03-14 01:41:52 +00:00
filtered
690f7bdfb3 Improve reroute re-connecting UX (#781)
More intuitive UX when connecting reroutes to each other.
- Remove middle reroutes when connecting around them
- Fix earlier reroutes in chain lost when stitching
- Fix all reroutes removed when stitching in reverse
2025-03-14 01:15:38 +00:00
filtered
b80e1744be Snap to reroute when connecting links (#778)
Add basic snap to reroute on hover; reuses existing slot visual.
2025-03-14 00:18:17 +00:00
filtered
bb822e999f Fix new link from reroute to canvas does nothing (#779)
Resolves regression - now performs the same action as dropping a link
from an output to canvas.
2025-03-14 11:17:44 +11:00
filtered
9315a8810e Increase slot context menu hit box (#777)
Previously, gap between slots was the same height as the slot itself.

Gap is now entirely removed, bringing it inline with the
previously-modified snap and link connection hit boxes.
2025-03-13 22:30:22 +00:00