This should allow frontend drop the stroke logic in hijack of
`drawNodeShape`. Example usage:
```ts
node.strokeStyles["executionError"] = (this: LGraphNode) =>
app.lastNodeErrors?.[this.id] ? { colour: 'red', thickness: 2 } : undefined
```
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`.
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.
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
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.
### Floating reroutes
Native reroutes can now be kept in a disconnected state.
Link chains may be kept provided they are connected to _either_ an input
or an output. By design, reroutes will be automatically removed if both
sides are disconnected.
- Fixes root cause of minor in-memory-only corruption when deleting
reroutes from output slots
- Already automatically corrected via serialisation
- If `reroutes` or `links` are empty arrays, removes them from newer
object-based serialised output entirely
- Minor refactors
- Removes unused code
- Fixes some serialisation types
- Adds `ReadonlyLinkNetwork` interface
- Removes null widget skip - this _should_ throw
- Removes widget locator that was on LGraphCanvas - canvas should not
functions that find things in graph space.
### LinkConnector
Replaces the minimal-change effort of `connecting_links` with a more
reliable implementation.
- Subscribable, event-based API
- Uses browser-standard `e.preventDefault()` to cancel `before-*` events
- Uses standard `state` POJO - can be proxied without issue
- Structures code and separates concerns out of `LGraphCanvas`
- Link creation calls can now be made from anywhere, without the need
for a rewrite
- New canvas sub-components now live in `src/canvas/`
### Rendering
- Skips link segments by setting a `_dragging` bool flag on the LLink or
Reroute
- Moves some previously nested code to event listeners, configured in
the `LGraphCanvas` constructor
### Deprecation
`LGraphCanvas.connecting_links` is now deprecated and will later be
removed.
Until it is removed, to prevent breaking extensions it will continue to
be set and cleared by a legacy callback. The contents of this property
are ignored; code search revealed no exentsions actually modifying the
array.
- Returns object with slot, index, and pos
- Locate-by-type returns object with slot & index
- Uses standard `undefined` return for concise chaining & validation
- Free 10x perf increase over getConnectionPos (used basic random data
to test, out of curiosity)
`LGraphNode.connect()` has been altered many times and attempts to
handle too many scenarios in a single public call.
- Moves link creation to a separate function
- Allows the legacy duck-typed API to continue functioning as-is
### Current
- Connections are disconnected the moment a link starts being dragged
- Reseating a connection where it came from creates a new connection
- If the process is somehow interrupted, the links are already gone
### Proposed
- Connection is disconnected after a new connection is made
- Rendering is bypassed for the link segment being moved
- Does nothing if dropping a link exactly where it came from
- Adds early return when trying to connect a node to itself
- Removes unused context menu for optional in/outputs
- At the top of the node context menu, greyed out `Inputs` and `Outputs`
- API does not fit with current design
- If required, rewrite would be simpler
- Adds remaining TS nullable types
- Adds type guards to allow strict mode
- Uses explicit throw in places that would throw regardless
- Adds ts-ignore that must be removed later
* [ ] #578
- Adds minor type coercions to resolve type errors
- Deprecates unused public APIs
- 7a0336e3ad7239b7bb588bbbe7912322257e9ae2 works around a bug in the tsc
strict plugin
- Adds ts-ignore that must be removed later
* [ ] #578
Removes formatters' ability to print code that goes to a new line, but
uses no braces to delineate.
It becomes more difficult to follow when using JS-style indents (two
spaces).
No effort required - braces added by auto-fixer.