Commit Graph

78 Commits

Author SHA1 Message Date
filtered
bcaaa00770 Add Subgraphs (#1000) 2025-06-28 15:21:56 -07:00
filtered
71928af112 Allow node resize from any corner or edge (#1063) 2025-05-26 06:36:03 +00:00
filtered
de21f5ccd3 Fix unnecessary module loading for type imports (#1053) 2025-05-15 23:16:27 +00:00
filtered
de32560816 [TS] Improve types and (#1043) 2025-05-12 19:02:57 +00:00
filtered
441f14c12e [TS] Fix callback type prevents use as method (#1035) 2025-05-09 10:34:45 +10:00
filtered
1b37502d70 [API] Improve widget typing (#1027) 2025-05-08 06:37:16 +10:00
filtered
c6df437662 [CodeHealth] Replace temporary TS conversion widget types (#1019) 2025-05-06 19:53:49 +10:00
filtered
bfc87af9d1 [TS] Force explicit override & property access (#1006)
Enables TypeScript rules that improve code legibility.

- Requires `override` keyword
- Prevent indexed properties from being accessed with dot notation

```ts
const obj: Record<string, unknown> = {}

// Prefer
obj["property"]

// Over
obj.property
```
2025-05-03 20:37:01 +00:00
filtered
199eeae269 Add subgraph skeleton classes (#997)
Allows downstream consumers to use subgraph types ahead of impl.
2025-05-01 23:16:19 +00:00
filtered
8e8818c24d Minor subgraph ts fixes (#973) 2025-04-26 20:34:02 +00:00
filtered
5c41e4e09c Add virtual slots to Reroutes (#970)
### Virtual helper "slots"

Adds a virtual input and output slot to native reroutes, allowing links
to be dragged from them to other reroutes or nodes.


https://github.com/user-attachments/assets/67d308c4-4732-4b04-a2b9-0a2b0c79b413

### Notes

- Reroute slots automatically show an outline as the pointer gets close
- When the slot is clickable, it will highlight in the same colour as
the reroute
- Enables opposite direction connecting: from reroute to node outputs
- Floating reroutes only show one slot - to whichever side is not
connected
2025-04-27 03:00:01 +10:00
filtered
a28effc9f1 Add socketless widget option (#958)
Declares `socketless` property on `IWidgetOptions`.

- Ref: https://github.com/comfyanonymous/ComfyUI/pull/7714
2025-04-21 19:36:38 +00:00
filtered
2ad1481f02 Remove LayoutElement, resolve root TS issues (#953)
- Converts type assertions to use inference via discriminated unions
- Removes the LayoutElement class (only used by node slots, and recently
reduced to a single function)
- Splits `boundingRect` property out from `Positionable` interface
- Slots now use the standard `boundingRect` property
- Perf improvements / Removes redundant code
2025-04-21 22:23:09 +10:00
Chenlei Hu
197a6cbae8 Add IBaseWidget.serialize flag (#915)
https://github.com/Comfy-Org/ComfyUI_frontend/pull/3323

Some widgets are only used for display purpose (The preview image
widget), their value shouldn't be serialized into the workflow. This PR
adds a flag to allow widget to skip value serialization.
2025-04-09 16:06:05 -04:00
filtered
04b4485cc9 Add Disposable interface & polyfill (#914)
Adds the `Disposable` and `AsyncDisposable` interfaces via polyfill.

Implements Disposable interface in `InputIndicator`.

Ref:
https://www.typescriptlang.org/docs/handbook/release-notes/typescript-5-2.html#using-declarations-and-explicit-resource-management
2025-04-09 11:05:39 +00:00
filtered
079a18a391 Reland "Support associated socket for widgets" (#904)
- Reverts Comfy-Org/litegraph.js#896
- Relands #891
2025-04-06 11:35:42 -04:00
filtered
ee625b4112 Revert "Support associated socket for widgets" (#896)
Reverts Comfy-Org/litegraph.js#891

Temporary revert to unblock other PRs (causing test failures; frontend
PR for this has not yet been merged).
2025-04-06 12:38:18 +00:00
Chenlei Hu
1ef4921c0a Support associated socket for widgets (#891)
This PR is the litegraph side change necessary for widget sockets
feature in ComfyUI_frontend. Changes include

- Add readonly `Widget.computedDisabled` property for getting the
computed disabled state. When the associated socket is connected, the
widget is disabled
- Dynamically show the associated socket when
      - the mouse is over the widget
      - the slot is valid during link drop
      - the slot is connected
- Removes the legacy widget drop behavior

Ref: https://github.com/Comfy-Org/rfcs/pull/9
2025-04-05 16:29:37 -04: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
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
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
18811f50fc Add serialisation support for floating links (#771)
Adds the serialisation code to support the new floating links impl.
2025-03-13 15:20:14 +00:00
filtered
2e9f877bbd [Cleanup] Reroute and serialisation (#767)
- 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
2025-03-13 14:40:12 +00:00
filtered
a7f2ff16a9 [TS] Remove optional from widget y and type (#752)
- Fixes widget `type` marked as optional - it is required
- Fixes widget `y` marked as optional - now initialised to 0
2025-03-11 15:46:10 +00:00
Chenlei Hu
214defbdb4 [TS] Remove IBaseWidget.element prop (#741)
Remove the prop as it is a impl detail of the frontend.
2025-03-10 14:34:09 -04:00
filtered
1a482d750b [TMP] Support downstream output widget in serialisation (#735)
- Ref: https://github.com/Comfy-Org/litegraph.js/pull/732#issuecomment-2710796369
2025-03-10 16:05:06 +00:00
filtered
c5cb4cea43 [TS] Clean up serialisation interfaces (#733)
Removes legacy generic & dynamic typing, and standardises TS styles.
2025-03-10 15:07:56 +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
b36bf3d4a2 [CodeHealth] Apply modern standards to LGraphCanvas (#650)
- Prefer template string
- Prefer explicit throw to undefined TypeError
- Remove unnecessary `this` assignment
2025-02-28 22:08:23 +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
1e8938ceff Add unicorn lint rules - DOM built-in functions (#628)
- Prefer append(), remove(), replaceAll()
- Wrap nested ternaries in parenthesis
2025-02-27 09:18:25 +00:00
Chenlei Hu
e8c238b70e Update serialisation.ts (#624)
Update ISerialisedNodeInputSlot.widget type. Overwrite original widget
prop type.
2025-02-26 16:40:36 -05:00
Miguel C
fbcc396880 Knob (#600)
Resolved issues with history due to merges, opened a new pull request.
A more visual widget that the usual number/slider. Differentiates itself
from the functionality of a slider by not setting the value on click,
only stepping, emulating an actual knob.

- Left/Right takes 1 step at a time
- Up/Down moves 1% or 1 step, whichever is larger
- Move + Shift moves by 10% or 1 step, whichever is larger

This also includes a fixes to some size logic.
- [x] ~~Still missing being able to drag the knob itself, as the
clicking of the widget is not recognized if it's outside of where a
normal height widget would be.~~

![knob-node](https://github.com/user-attachments/assets/9d0ce70d-a220-49d0-987f-8dcef2b1d299)
2025-02-26 15:07:32 -05:00
Chenlei Hu
963e4b0904 [Type] Mark name as required prop for IBaseWidget (#623) 2025-02-26 15:03:31 -05: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
5cdd0581fa Add import / export sort rules (#612)
- Adds ESLint package
- Applies import/export rules to all files
- Uses newline delineated grouping, with type-only imports first
2025-02-26 09:21:33 +00:00
filtered
9ded97d189 [Doc] Add JSDoc linter & general comment clean up (#611)
- Prefer comments above lines over end-of-line comments
  - Makes auto-formatting easier
  - Subjective, but it is generally easier to read in JS
- Standardises JSdoc format
- Auto-fixes for many issues (applies on save w/ESLint extension)
2025-02-26 08:54:18 +00:00
Chenlei Hu
953ae434ea Type serialized NodeSlot (#605) 2025-02-25 19:38:14 -05:00
filtered
4636367de2 [TS] Use strict mode in LGraphNode - initial (#598)
- Part of effort to convert LGraphNode to TS strict
- Adds some small runtime changes - no impact expected, but it is
possible
- Runtime changes are in separate commits from compile-time type changes
- Risk of downstream impact is low
2025-02-25 17:19:27 +00:00
Chenlei Hu
59dea644f2 Move marker property from BaseWidget to SliderWidget (#584)
* Move marker property from BaseWidget to SliderWidget

* nit
2025-02-24 16:35:34 -05:00
Chenlei Hu
170341db73 Type ButtonWidget (#583)
* Type ButtonWidget

* nit
2025-02-24 16:30:04 -05:00
Chenlei Hu
7a25899ecc Reverse computeSize and computeLayoutSize priority (#533) 2025-02-15 14:35:09 -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
adff23bb84 Add ISerialisedNode.widgets_values documentation (#513) 2025-02-10 11:17:09 -05:00
Chenlei Hu
de74d8a08c [Lint] Lint unused imports (#493) 2025-02-08 21:20:39 -05:00
Chenlei Hu
cdaceebcaa Implement SliderWidget (#485) 2025-02-08 17:28:25 -05:00
Chenlei Hu
75f067dbb3 Implement BooleanWidget (#466)
* Implement BooleanWidget

* Merge function of addWidget

* Class conversion

* nit
2025-02-07 17:10:30 -05:00
filtered
604a3e651c Fix TS types - Widgets (#428)
* Remove downstream types

These optional type definitions were test code and should not have been upstreamed.

* Remove unnecessary workaround

Build workaround TS conversion; no longer relevant.

* Fix TS type - widget size callback
2025-01-20 14:02:37 -05:00
filtered
c64c81882c Add workaround for Firefox pointer events (#412)
* Add workaround for Firefox pointer events

Co-Authored-By: catboxanon <122327233+catboxanon@users.noreply.github.com>

* nit

---------

Co-authored-by: catboxanon <122327233+catboxanon@users.noreply.github.com>
Co-authored-by: huchenlei <huchenlei@proton.me>
2025-01-01 19:34:58 -05:00