Commit Graph

111 Commits

Author SHA1 Message Date
filtered
af7db40fce [chore] Clean up ignores after strict mode enabled (#680)
- Replaces all `ts-ignore` with `ts-expect-error`
- Resolves https://github.com/Comfy-Org/litegraph.js/issues/578
2025-03-02 14:56:15 +00:00
filtered
b1885ebec8 Remove redundant code - onGetInputs / onGetOutputs (#674)
- 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
2025-03-02 13:47:48 +00:00
filtered
6cb9131035 [TS] Use strict mode in LGraphCanvas (#673)
- 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
2025-03-02 13:34:02 +00:00
filtered
539fa91b0d [TS] Use strict mode in LGraphCanvas (#664)
- Prefer `undefined` over `null`
- Primarily nullable type updates
2025-03-01 21:58:50 +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
filtered
c4faaf4210 [TS] Fix ContextMenu types (#649)
- No runtime changes
- Drastically improves ContextMenu type accuracy / safety
- Allows TS strict conversion
2025-02-28 14:52:07 +00:00
filtered
0a09ecc7ac [TS] Use strict mode in LGraphNode (#642)
- 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
2025-02-27 19:03:42 +00:00
filtered
fab386275c [Refactor] Clean up LGraphNode ahead of TS strict (#641)
Preparation for TS strict conversion. Simplifies code & improves
readability.
2025-02-27 17:55:11 +00:00
filtered
38dd7b7089 [Refactor] Prefer for..of to incremental for loops (#640)
- Converts incremental for loops to for..of loops
- Improves readability
2025-02-27 16:28:10 +00:00
filtered
be8dc6867e [Refactor] Prefer event listeners to callback props (#637)
N.B.: `onerror` replacement is not a `window` or `Element` instance.
2025-02-27 14:50:39 +00:00
filtered
97bf9de83a [Refactor] Standardise code style - modern JS (#636)
Uses unicorn rules to auto-refactor code.  All verified.
2025-02-27 13:13:32 +00:00
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