Commit Graph

66 Commits

Author SHA1 Message Date
filtered
f6ef85e7c3 [Test] Add measure unit tests (#905) 2025-04-09 16:28:05 +10:00
Chenlei Hu
bf5e3f3c77 [Bug] Fix layout issue caused by absolute positioned slots (#908)
Before:

![image](https://github.com/user-attachments/assets/00bbbf14-a153-4301-b4c4-0c30cb2ebcc7)

After:

![image](https://github.com/user-attachments/assets/2247a0a5-2757-478c-b701-9ceab7a133cc)

Workflow:

[dynamically_added_input.json](https://github.com/user-attachments/files/19640371/dynamically_added_input.json)

This PR also fixes the issue that output slot's `pos` property is not
relative to node pos.
2025-04-07 19:52:58 -04:00
filtered
64c7113440 Fix link corruption (#888)
- Adds link & floating link integrity tests to all LinkConnector
integration tests
- Fixes link changes may be lost when moving floating links
2025-04-05 05:34:55 +00:00
Chenlei Hu
c4373deeea [Test] Add test on moving output links (#887)
Ref: https://github.com/Comfy-Org/litegraph.js/issues/881

Verifies that moving output links does not cause link corruption.
2025-04-04 14:57:19 -04:00
Chenlei Hu
29c923e0e3 [Bug] Fix slot link state corruption on moving link between sockets (#882)
Ref: https://github.com/Comfy-Org/litegraph.js/issues/881

This PR fixes the corrupted link state when moving link from one input
socket to another.
2025-04-04 14:28:41 -04:00
Chenlei Hu
d17b86a6b8 [Test] Validate slot links after each test (#886)
Disable `"Should move input links"` test case as it fails validation.

Ref: https://github.com/Comfy-Org/litegraph.js/issues/881
2025-04-04 14:22:02 -04:00
Chenlei Hu
30a7f19a64 Upstream progressbar rendering (#871)
Upstreams progress bar rendering from ComfyUI_frontend.
2025-03-30 17:14:09 -04:00
Chenlei Hu
854ac4350f Add LGraphNode.strokeStyles API (#868)
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
```
2025-03-30 11:29:37 -04:00
Chenlei Hu
27a2b785ac [Cleanup] Remove use_legacy_node_error_indicator (#867)
The fallback option was added in
https://github.com/Comfy-Org/litegraph.js/pull/358. So far no code is
using this legacy fallback option. Removing it now.
2025-03-30 10:30:39 -04:00
filtered
7b3ea64714 Fix 862 (#864)
- Follow-up on #862
- Corrects issues with floating reroute switch logic
- Updates test expectations
2025-03-28 09:00:58 +11:00
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
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
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
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
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
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
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
7c6245ab1c [Test] Add LinkConnector unit & integration tests (#816)
- Follow-up on #817

### Unit tests

Adds tests for:

- LinkConnector
- LGraph

### Integration tests for LinkConnector

- Uses and configures a real graph + LGraph
- Avoids mocks
  - User input is still mocked
- Performs actual tasks as would be called by LGraphCanvas
- A little verbose in places, but _many_ edge cases are caught by these
tests
2025-03-22 06:47:40 +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
9e64bf7278 [Test] Add LinkConnector tests (#808) 2025-03-20 22:20:11 +11:00
filtered
39a9799db7 [Test] Add unit tests - complex floating links & nodes (#796) 2025-03-17 13:25:57 +11:00
Chenlei Hu
b71150a939 [Test] Add more tests on reroute (#793) 2025-03-16 19:12:57 -04: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
84dad03f4d Remove static circular dependency workaround (#734)
Workaround originally implemented when converting to ES modules, but is
now redundant.

`DEFAULT_EVENT_LINK_COLOR` confirmed unused in code search (litegraph
events).
2025-03-10 15:29:33 +00:00
filtered
e632f5c69b Fix all unknown slot props are serialised (#732)
Ensures only specified properties are cloned for serialisation.
2025-03-10 12:20:34 +00:00
filtered
68945cb54d Remove getTime workaround and Node.js type bleeding (#723)
- Removes legacy timer workaround (redundant on Chrome v6 / Node.js v16)
- Removes old type workarounds
- Improves type inference speed
2025-03-08 13:27:49 +00:00
Chenlei Hu
c66ca2ae66 Remove magic 10% scale on numeric widget step (#643)
There are external code still dependent on the fact that
Widget.options.step is scaled 10x, so the 10x-ed value is still kept
there, while we use the new unscaled step2 within our code now.

Ref:
https://cs.comfy.org/search?q=context:global+%22step+/+10%22&patternType=keyword&sm=0
2025-02-27 16:23:53 -05:00
filtered
6737828a2b Lint module entry point (#635)
- Adds module entry point tests
- Manually resolved lint rules for module entry point imports / exports
(autofix could not resolve without causing issues)
2025-02-27 12:02:03 +00:00
Chenlei Hu
d20aab757c Serialize NodeInputSlot.widget (#622)
Serialize linked widget on node input slot properly according to current
save format in
76818b54e6/src/extensions/core/widgetInputs.ts
2025-02-26 14:15:31 -05:00
filtered
6224d2dc06 [Cleanup] Update ESLint rules with stricter auto-fixes (#614)
Stylistic plugin falls short in a few areas when it comes to consistent
lists and chaining. Replaced some key rules with antfu's personal
variants.

`eslint` can now be run repo-wide without params.
2025-02-26 11:12:03 +00:00
filtered
477d498d6b [API] Remove unused: optional_inputs & outputs (#597)
Code search shows zero usage. If kept, typing properly would require
effort.

Removed:
- `LGraphNode.optional_inputs`
- `LGraphNode.optional_outputs`
2025-02-25 16:33:21 +00:00
filtered
2c3535c983 [Test] Add integration test: LGraph snapshot (#591)
- Runs basic Litegraph init before performing the snapshot
- Allows a significantly more useful verification of the public API
2025-02-25 08:58:29 +00:00
filtered
630fd00086 [API] Remove unused LiteGraph APIs (#582)
* [API] Remove unused LiteGraph APIs

These features have not been maintained, and would require refactoring / rewrites. As code search revealed them to be unused, they are being removed.

- addNodeMethod
- compareObjects
- auto_sort_node_types

* Udpate API.md
2025-02-24 12:04:07 +00:00
filtered
f3b51a534e [Test] Standardise unit test infrastructure (#572)
* [Test] Revert custom name for test context

- Removes "lgTest", replaces with default "test"

* nit - Rename test extensions file

* Split test graphs out to separate file
2025-02-24 01:56:22 +00:00
Chenlei Hu
f300e37a89 Remove NodeSlot.pos when serializing WidgetInputSlot (#570) 2025-02-23 16:11:56 -05:00
Chenlei Hu
d23a320f9f Upstream frontend widgets layout logic (#531)
* Upstream frontend widgets layout logic

* Add back LGraphNode.freeWidgetSpace

* nit

* update expectations
2025-02-14 19:22:37 -05:00
Chenlei Hu
9abcf0fd32 Remove LGraphNode.horizontal (#521)
* Remove LGraphNode.horizontal

* nit
2025-02-12 15:11:59 -05:00
Chenlei Hu
7813e5207a Revert "Revert "Convert i/o slot to class in LGraphNode.configure"" (#518)
* Revert "Revert "Convert i/o slot to class in LGraphNode.configure (#506)" (#511)"

This reverts commit d029bd8924.

* nit
2025-02-12 11:06:35 -05:00
Chenlei Hu
d029bd8924 Revert "Convert i/o slot to class in LGraphNode.configure (#506)" (#511)
This reverts commit c75157e86e.
2025-02-09 23:35:40 -05:00
Chenlei Hu
c75157e86e Convert i/o slot to class in LGraphNode.configure (#506) 2025-02-09 15:23:38 -05:00
Chenlei Hu
3cd08e9e0c Remove LGraph._subgraph_node (Legacy subgraph) (#456) 2025-02-03 23:36:38 -05:00
Chenlei Hu
b3dbc41368 Remove LGraphNode.subgraph (Legacy subgraph) (#453)
* Remove LGraphNode.subgraph (Legacy subgraph)

* Update snapshot
2025-02-03 23:27:11 -05:00
Chenlei Hu
817214e6da [Refactor] Move strokeShape from LGraphCanvas to draw (#435)
* [Refactor] Move strokeShape from LGraphCanvas to draw

* Fix round radius

* nit

* nit

* nit
2025-02-02 22:29:26 -05:00
bymyself
9a8c3dff89 Remove scaling of context menus (#431)
* remove scaling of context menus based on graph scale

* deprecate scale in interface

* Add option to restore old context scaling behaviour

Revert "remove scaling of context menus based on graph scale"

This reverts commit d91ecaa86c671aea272844c3900a18da1af7bf01.

* Update test expectations

---------

Co-authored-by: filtered <176114999+webfiltered@users.noreply.github.com>
2025-01-27 19:41:08 +11:00
Chenlei Hu
11ce8e0f7b Fix NODE_DEFAULT_SHAPE (#389)
* Fix NODE_DEFAULT_SHAPE

* update snapshot
2024-12-23 20:04:32 -05:00
filtered
71f8a1decf Export Reroute class the same as other similar classes (#378)
* Export Reroute class the same as other similar classes

* Update test expectations
2024-12-15 10:54:50 -08:00
filtered
91077aa20b Redesign invalid node indicator (#358)
* nit

* Remove unused code

Gradient can (and should) be impl. directly by caching a CanvasGradient.

* nit

* nit - Refactor

* Remove redundant code

* Add line width & colour options to shape stroke

* Rename drawSelectionBounding to strokeShape

* nit - Doc

* Fix rounded corners not scaling with padding

* Optimise node badge draw

* Redesign invalid node visual indication

Customisable boundary indicator now used, replacing red background.

* Update snapshot

---------

Co-authored-by: huchenlei <huchenlei@proton.me>
2024-11-29 16:26:25 -05:00
filtered
ee45593558 Move Snap to Grid control to LiteGraphGlobal (#329)
* Fix snap to grid - now toggled at app level

Was impl. as per workflow.

* Update test expectations
2024-11-21 10:19:00 -05:00