Commit Graph

87 Commits

Author SHA1 Message Date
filtered
cab707a32c [Test] Fix circular test imports in CI (#1088) 2025-06-28 15:30:42 -07:00
filtered
bcaaa00770 Add Subgraphs (#1000) 2025-06-28 15:21:56 -07:00
filtered
b86f2b58e6 Remove node edge resize (#1066) 2025-05-26 22:10:41 +00:00
filtered
71928af112 Allow node resize from any corner or edge (#1063) 2025-05-26 06:36:03 +00:00
filtered
d1ec780dbd Add rectangle resize methods, use in DragAndScale (#1057) 2025-05-16 17:22:51 +00:00
filtered
de21f5ccd3 Fix unnecessary module loading for type imports (#1053) 2025-05-15 23:16:27 +00:00
filtered
10118d95e3 Export the viewport offset and scale with the graph (#1042) 2025-05-12 18:47:10 +00:00
filtered
ccbdff0ad1 Fix Rectangle subarray end offset logic (#1021) 2025-05-06 18:10:59 +00:00
filtered
df6e4debb5 Fix widget snap to work with input sockets (#1017) 2025-05-07 02:02:49 +10:00
filtered
75df19521b Widget overhaul (#1010)
### Widget text overhaul

#### Current
- Numbers and text overlap
- Combo boxes truncate the value before the label

![image](https://github.com/user-attachments/assets/c991b0b6-879f-4455-92d4-4254ef25b55c)

#### Proposed

**By default, widgets will now truncate their labels before their
values.**


https://github.com/user-attachments/assets/296ea5ab-d2ff-44f2-9139-5d97789e4f12

- Changes the way widget text is rendered, calculated, and truncated
- Truncation now applies in a standard way to the following widgets:
  - Text
  - Combo
  - Number
- Centralises widget draw routines in base class

### Config

```ts
// Truncate **both** widgets and labels evenly
LiteGraph.truncateWidgetTextEvenly = true

// Swap the default from truncating labels before values, to truncating values first (restores legacy behaviour)
// truncateWidgetTextEvenly **must** be `false`.
LiteGraph.truncateWidgetValuesFirst = true
```

### API / interfaces  

- Adds rich `Rectangle` concrete impl., with many methods and helpful
accessors (e.g. `right`, `bottom`)
- Actually _improves_ performance due to switch from Float32Array to
Float64Array
- Impact vs plain Float64Array was not detectable outside of a 2M+
instantiation-loop with random data
  - Lazy `pos` & `size` `subarray` properties
- Adds `ReadOnlySize`
- Adds higher-level text draw functions to abstract the nitty gritty in
a performant way (binary search)

- Resolves Comfy-Org/ComfyUI_frontend/issues/457
2025-05-05 10:48:06 +10:00
filtered
81eed7a1fa Add macOS trackpad gesture support (#1007)
Adds trackpad gesture support to canvas interaction.  Supports:

- Pinch to zoom
- Two-finger panning

Feature is off by default. Also by default, the browser user-agent must
include "Mac" (even if the feature has been enabled).

```ts
// Enable mac trackpad gestures
LiteGraph.macTrackpadGestures = true

// Disable the default Mac user-agent check
LiteGraph.macGesturesRequireMac = false
```
2025-05-04 11:58:24 +10:00
filtered
ee89fc575f [Cleanup] Removes unused code (#996)
- Removes unused code
- Removes unnecessary globalAlpha reset when drawing reroute highlight
2025-05-01 22:38:54 +00:00
filtered
0cdee75460 [API] Allow canvas font customisation (#987)
Allows customisation of fonts via `LiteGraph` global var:

```ts
LiteGraph.NODE_FONT = "wingdings"
```


![image](https://github.com/user-attachments/assets/36bec38d-ea5f-4ec6-a2a3-bc5a57826c1e)
2025-05-01 00:19:36 +00:00
filtered
ccc588b842 [API] Remove unused: LGraphNode.addConnection (#980)
Confirmed unused via code search
2025-04-28 01:52:53 +00:00
filtered
ee222c794b Fade invalid increment/decrement widget buttons (#978)
When a widget cannot be incremented/decremented further, show a disabled
effect on the widget buttons.


https://github.com/user-attachments/assets/7770a9f1-31f6-430b-ab02-420327621148
2025-04-28 05:47:48 +10:00
filtered
c10ce1caa1 [API] Add deprecated warning logging (#967)
Adds a global API to notify devs / users of deprecated features.

- Custom callbacks may be added
- By default, remembers message text and only sends each message once
- Sends to console.warn by default

```ts
// Add a custom notification when a warning is encountered
const warnMessage = (message: string, source?: object) => {
  addToast({ message, detail: object })
}
LiteGraph.onDeprecationWarning.push(warnMessage)
```

```ts
// Debugging flag. Repeats deprecation warnings every time they are reported.
// May impact performance.
LiteGraph.alwaysRepeatWarnings = true
```

Generate a warning
```ts
import { warnDeprecated } from "@/utils/feedback"

warnDeprecated(
  "[DEPRECATED] graph.oldFeature() will be removed from Litegraph. " +
  "Please use graph.newFeature() instead. https://helpful.site/faq",
  objectThatCausedThis
)
```
2025-04-26 02:16:01 +10:00
filtered
d70260615b [Refactor] Split NodeSlot out to separate files (#960)
Split files only; no code changes.  New files moved to `/node`.
2025-04-23 14:43:55 +00:00
filtered
b988238155 [Cleanup] Assorted minor code clean-up (#943)
Adds one warning log for an extreme edge case.
2025-04-20 08:35:45 +00:00
filtered
6293b4bbe0 Disconnect moved output links when dropped on canvas (#936)
- Resolves #884
2025-04-18 23:22:28 +10:00
filtered
02d165bf2a [API] LinkConnector reset no longer run after drop (#935)
`reset()` is no longer automatically called after `dropLinks`. This
brings the API in line with original intent, and how canvas is already
configured; reset is called by `pointer.finally()`.
2025-04-18 11:45:36 +00:00
Chenlei Hu
bdffdc9f10 [Bug] Fix configure of non-serializable widget (#921)
Follow up on https://github.com/Comfy-Org/litegraph.js/pull/915

Filter out non-serializable widgets during node configuration. Current
usage in frontend should not be affected as preview media widgets are
mostly dynamically added at the end of widget list.
2025-04-12 21:01:31 -04:00
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