Commit Graph

100 Commits

Author SHA1 Message Date
filtered
2d9c811aa9 [Cleanup] Remove downstream type (#632)
Removes group node type. Now exists downstream where it is used.
2025-02-27 10:38:24 +00:00
filtered
0d8e0fce17 [Refactor] Fix assignment of this to const (#631)
Refactors using arrows funcs or storing the once-off requirement as an
action, removing the need to dereference this inside the function.
2025-02-27 10:32:53 +00: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
Miguel C
7e6b64f216 Fix widget sizing logic in LGraphCanvas and LGraphNode (#609)
This fixes an issue with widget heights not coinciding with actual
computed heights.
<img
src="https://github.com/user-attachments/assets/50b4b86c-8de8-4844-9a17-6f18d32e7f5e"
height="128" alt="old">old
<img
src="https://github.com/user-attachments/assets/c34e432a-6941-469e-99cd-df15c0a527de"
height="256" alt="new">new
2025-02-26 10:56:30 -05:00
filtered
0e9b8b03b7 Enforce curly braces in multi-line if statements (#619)
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.
2025-02-26 15:08:23 +00:00
filtered
3040924d76 [TS] Use strict mode in CanvasPointer, measure, and polyfills (#617)
- Adds runtime type guard
- Adds ts-ignore that must be removed later
  * [ ] #578
2025-02-26 13:05:40 +00:00
filtered
867b9ed316 [nit] Add consistent method chaining linter (#613)
Enforces that chained accessed should **either** all be on one line, or
all on individual lines (same as imports).
2025-02-26 10:11:11 +00: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
Chenlei Hu
cdbd0899e2 [Reland][TS] Use strict mode in LGraphNode - part 2 (#604)
Reverts Comfy-Org/litegraph.js#603
2025-02-25 16:39:31 -05:00
Chenlei Hu
67d8c3177a Revert "[TS] Use strict mode in LGraphNode - part 2" (#603)
Reverts Comfy-Org/litegraph.js#601

Reason: breaks legacy reroute

On inserting a workflow with legacy reroute node
```
Uncaught (in promise) NullGraphError: Attempted to access LGraph reference that was null or undefined.
    at RerouteNode.removeOutput (LGraphNode.ts:1425:28)
    at RerouteNode.clone (rerouteNode.ts:215:18)
    at LGraphCanvas.copyToClipboard (LGraphCanvas.ts:3331:29)
    at Object.insertWorkflow (workflowService.ts:350:12)
```
2025-02-25 14:10:27 -05:00
filtered
67ee55ede1 [TS] Use strict mode in LGraphNode - part 2 (#601)
- Guards against nullish `graph`
- [Fix regression in return type -
getInputLink](143ca5f3f2)
- long-standing, so no impact apparently
- Resolves some potential null dereferencing
2025-02-25 13:40:50 -05:00
filtered
f39e1d96e8 [TS] Use strict mode in LLink & Reroute (#602)
- Adds fallback colour if reroute colour is somehow nullish
2025-02-25 18:00:33 +00: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
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
Chenlei Hu
fadece7fdf Type LGraphNode.addInput/Output (#585) 2025-02-24 19:29:04 -05:00
filtered
1800d31a5a [Refactor] Prefer modern for..of loops 2 (#569)
* [Refactor] Prefer for..of

* [Refactor] Prefer for..of - manual refactoring

* Partially revert change - potential conflict

Not worth time investment to fix - reverted.
2025-02-23 16:36:52 -05:00
filtered
4add6c3211 [Cleanup] Follow-up on #566 - fix style (#568) 2025-02-23 20:20:44 +00:00
filtered
4163cb04b8 [Refactor] Prefer modern for..of loops (#566)
- Replaces traditional incrementing `for` loops and `forEach()` calls with modern `for..of` syntax
- Improves readability
- Semantic checking used; not expecting issues to arise from this portion
2025-02-23 19:59:41 +00:00
bymyself
d17e7f567d type LGraphNode.addWidget (#562)
* type addWidget

* help out ts compiler

* Update LGraphNode.ts

---------

Co-authored-by: Chenlei Hu <huchenlei@proton.me>
2025-02-23 13:01:17 -05:00
Chenlei Hu
c8385657db Add LGraphNode.expandToFitContent (#558) 2025-02-20 13:55:02 -05:00
Chenlei Hu
dcac6dba80 [BugFix] Auto grow node if widgets need more space (#556) 2025-02-20 12:45:31 -05:00
filtered
b67f34e7f3 [Cleanup] Remove lint bypass, remove unused vars (#554) 2025-02-20 11:17:35 +11:00
filtered
485bfd1628 [Cleanup] Remove unused code (#553) 2025-02-20 10:54:24 +11:00
Chenlei Hu
7bab620986 Fix IColorable.getColorOption (#551)
* Fix IColorable.getColorOption

* nit
2025-02-19 14:57:29 -05:00
Chenlei Hu
6b1e40a011 Add IColorable interface (#549)
* Add IColorable interface

* Set color option

* nit

* nit

* nit
2025-02-19 13:56:08 -05:00
Chenlei Hu
d27ced7cf3 [BugFix] Fix unknown node with converted widgets (#547) 2025-02-18 19:32:06 -05:00
Chenlei Hu
1e71da9a38 Show widget input inplace (#535)
* Show widget input inplace

* nit

* nit
2025-02-16 11:37:47 -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
a5c89c0152 [Performance] Avoid double measure on node rendering (#529)
* [Performance] Avoid double measure on node rendering

* Move _collapsed_width calc

* nit

* nit

* nit

* nit

* nit
2025-02-14 14:15:40 -05:00
Chenlei Hu
ce44cea409 Split layout and draw for slots (#524)
* Split layout and draw for slots

* nit

* nit

* Fix serialization

* Move effect (highlight/invalid) to layout calculation

* nit

* Fix type issue

* Resolve review comments
2025-02-13 20:20:57 -05:00
Chenlei Hu
361a1a76ef Add LGraphNode.getExtraSlotMenuOptions hook (#522) 2025-02-12 15:52:27 -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
997d673bd9 [Refactor] LgraphNode.drawSlots (#503)
* wip

* nit
2025-02-09 12:53:41 -05:00
Chenlei Hu
120c606f07 [Refactor] LGraphNode.drawCollapsedSlots (#500) 2025-02-09 11:02:20 -05:00
Chenlei Hu
01b8ae5bb8 [Refactor] LGraphNode.drawWidgets (#499) 2025-02-08 23:41:01 -05:00
Chenlei Hu
de74d8a08c [Lint] Lint unused imports (#493) 2025-02-08 21:20:39 -05:00
Chenlei Hu
4d36369cd8 Refactor widget switch statement (#491) 2025-02-08 19:28:38 -05:00
Chenlei Hu
cdaceebcaa Implement SliderWidget (#485) 2025-02-08 17:28:25 -05:00
Chenlei Hu
2d688a896d Implement TextWidget (#484) 2025-02-08 17:01:54 -05:00
Chenlei Hu
ab14827f87 Implement ButtonWidget (#483) 2025-02-08 16:50:02 -05:00
Chenlei Hu
63f9f30eec Implement NumberWidget (#481) 2025-02-08 15:45:23 -05:00
Chenlei Hu
c781053bd2 Implement ComboWidget (#480)
* wip

* Implement onClick
2025-02-08 15:16:15 -05:00
Chenlei Hu
fcc09c075d Implement BooleanWidget.onClick (#479) 2025-02-08 12:45:51 -05:00
Chenlei Hu
608b5f8342 Implement NodeSlot (#476)
* Implement NodeSlot

* nit
2025-02-07 17:13:32 -05:00