Commit Graph

203 Commits

Author SHA1 Message Date
filtered
32b6b7eff9 Fix reroutes lost when moving links via outputs (#699)
- Resolves #309

https://github.com/user-attachments/assets/70c8b9ba-b4e6-4293-a254-6ae95930d1f1
2025-03-03 19:16:55 +00:00
filtered
aca81a99c8 Fix regression in legacy search (#698)
- Resolves https://github.com/Comfy-Org/ComfyUI_frontend/issues/2828
- Issue caused by earlier instantiation of `input` object
2025-03-03 17:42:00 +00:00
filtered
b227eefbdd Improve connecting link logic (#697)
### Current

- Connections are disconnected the moment a link starts being dragged
- Reseating a connection where it came from creates a new connection
- If the process is somehow interrupted, the links are already gone

### Proposed

- Connection is disconnected after a new connection is made
- Rendering is bypassed for the link segment being moved
- Does nothing if dropping a link exactly where it came from
- Adds early return when trying to connect a node to itself
2025-03-03 17:03:31 +00:00
filtered
cef6ab6ced Improve link drag & drop (#380)
- Resolves
https://github.com/Comfy-Org/litegraph.js/issues/309#issuecomment-2508726168
- Output issue still pending
- Splits connecting links `pointerup` handler to separate function,
which can now be called from `CanvasPointer` callbacks
  - Minor refactor; no functional changes

### Behaviour change

When moving existing links from an input slot, the link will not be
disconnected until the drop event occurs.

### Current

Shift + drag


https://github.com/user-attachments/assets/0b98f9bf-3d5f-467e-9a9b-e5695e5a0d0b

### Proposed

Shift + drag

https://github.com/user-attachments/assets/0bc36215-0247-41da-8050-e8df09addf23
2025-03-04 01:26:56 +11:00
bymyself
83fb246119 Fix Selection Marquee display is offset when DPI < 1 (#692)
Fixes https://github.com/Comfy-Org/ComfyUI_frontend/issues/2481. The
canvas scaling behavior is not consistent with DPI which is the source
of many bugs. To verify, add console log somewhere:
2025-03-03 17:06:15 +11:00
Chenlei Hu
4cbf12849e [BugFix] Fix add node via context menu (2) (#689)
https://github.com/Comfy-Org/litegraph.js/pull/647 failed to convert
`return` to `continue` when converting forEach to for-lop.
2025-03-02 21:21:39 -05:00
Chenlei Hu
9af4ee120c Revert "[BugFix] Fix adding node via context menu" (#688)
Reverts Comfy-Org/litegraph.js#682

Reason: Revert improper fix.
2025-03-02 21:15:45 -05:00
Chenlei Hu
326670206d [BugFix] Fix adding node via context menu (#682)
Resolves https://github.com/Comfy-Org/ComfyUI_frontend/issues/2814

Culprit: https://github.com/Comfy-Org/litegraph.js/pull/647
2025-03-02 18:38:31 -05:00
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
a815ce92a8 Add final refactoring to enable TS strict (#678)
- Removes long-deprecated onMenuNodePin
  - Code search empty
- Fixes TS types
- Minor refactors to ensure type-safety
- Adds explicit throws and null checks
2025-03-02 14:42:24 +00:00
filtered
972527de70 [Refactor] Use strict mode in Add Node menus (#677)
- Improves TS types
- Adds type guards / null checks
2025-03-02 14:17:25 +00:00
filtered
77b274f27f Add link context menu info to replace console error (#676)
Shows a single menu item with an error message when a link is corrupt.
2025-03-02 14:10:43 +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
02d991d669 [Refactor] Minor refactors to support strict mode (#671)
- Removes unnecessary `null`-init
- Deprecates unused drag / drop code
- Adds null checks
2025-03-02 09:02:29 +00:00
filtered
1aba15bbca Fix incorrect links highlighted (#670)
Fixes rare issue where incorrect links could be highlighted (and
seemingly remain highlighted).

Requires corrupt links & null coercion.
2025-03-02 08:49:13 +00:00
filtered
78175e2c1b [TS] Add strict nullability to LGraphCanvas (#669)
- Updates typing in copy & paste
- Clean up
2025-03-02 08:34:26 +00:00
filtered
d597271954 Add runtime type guards to search box (#668)
- Prevents unnecessary property access exceptions
- Adds TS strict types
- Removes inline polyfill for `Array.filter`
2025-03-02 08:12:15 +00:00
filtered
9b6a78e7df [Refactor] Prefer createElement over innerHTML (#667)
- Part of TS strict conversion
- Improves type safety of canvas panel / dialog functions
- Removes more instances of pointer event wrapper
2025-03-02 02:47:22 +00:00
filtered
193b09999f [TS] Use strict mode in dialog & panel (#666)
Includes minor refactors to retain inferred types in branches.
2025-03-02 02:27:10 +00:00
filtered
6a42484669 [TS] Use strict nullability in LGraphCanvas (#665)
- Adds runtime null checking
- Converts canvas context to non-nullable
- Adds explicit throws for some edge cases
- Improves TS types
2025-03-01 22:44:34 +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
ab25d1fc6e [Cleanup] Remove redundant code (#663)
Removes:

- Unused option from public API `getWidgetAtCursor` - use without params
- Unused workaround impl. for WebGL
- Invalid code (incorrect `tabIndex` casing)
2025-03-01 17:54:35 +00:00
filtered
7b4bea8e62 Remove deprecated code - webGL (#660)
Removes long-deprecated WebGL code.
2025-03-01 16:33:17 +00:00
filtered
177a5a0d54 [CodeHealth] Remove wheel listener & event wrapper (#656)
- Replaces the long-deprecated `mousewheel` and `DOMMouseScroll` event
listeners with `wheel` listener
  - Verified no change in Chromium behaviour (desktop, mouse)
- Removes redundant pointer listener wrapper
- Fixes types
2025-03-01 13:18:15 +00:00
filtered
c473130499 [TS] Use strict mode in LGraphCanvas (#654)
- Prefer creating HTML elements in JS and `append()` over innerHTML &
`querySelector()`
- Removes redundant code
- Adds/fixes TS types
2025-03-01 11:52:42 +00:00
filtered
bad923a7f0 [Refactor] Remove deprecated mousewheel events (#652)
Prefer "wheel" event (added around Chrome v31).
2025-03-01 11:34:23 +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
b877312336 [Refactor] Fix TS types, remove redundant code (#648)
Minor clean up and graph null deref checks.

Minor runtime change: due to optional chaining, it is possible a
downstream consumer is catching this extremely rare behaviour on purpose
and handling it.
2025-02-28 11:13:23 +00:00
filtered
4365873039 [Refactor] Prefer NullGraphError & standardisation (#647)
- Best effort code search for convert explicit `null` to `undefined`
- Prefer explicit throw over `TypeError`
- Prefer template strings
2025-02-28 20:16:34 +11:00
filtered
b4688e18f9 [Refactor] Prefer includes over indexOf -1 (#646)
Enables ESLint auto-fix rule.
2025-02-28 08:53:29 +00:00
filtered
7b19abf83a [TS] Use strict mode in Canvas: initializers (#645)
- Code search verified no consumers expecting explicit null on callbacks
(best effort)
- Removes redundant code
2025-02-28 08:48:53 +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
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
2104f2a8a9 [Refactor] Prefer textContent over innerText (#630)
Only setters are used, so getter differences aren't involved. This may
result in a runtime change to consumers passing a Node that isn't
actually a HTMLElement.
2025-02-27 10:11:07 +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
a43109d58a [TS] Use strict mode in ContextMenu (#618)
- Adds minor type coercions to resolve type errors
- Uses the same type-coercion behaviour of the target DOM object
properties
- Resolves a long-standing type issue in context menu interfaces
(converts to generic - `unknown` by default)
- Fixes several incorrect types
- Adds ts-ignore that must be removed later
2025-02-26 14:29:45 +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
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
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
6bd151c91e [API] Remove LiteGraph.searchbox_extras (#592)
- Unused, loose typing
- Code search shows usage is limited to code copy & paste of litegraph
code
- So long as the `searchbox_extras` property exists and is empty, there
is no change to downstream consumers
2025-02-25 09:16:49 +00:00
filtered
c8ffacf172 [TS] Use strict mode in LGraph (#579)
* [TS] Undefined is not a valid object key

* Deprecate unused code

Adds ts-expect-error to TS strict issues on unmaintained public interfaces.

* [TS] Fix nullability: asSerialisable return type

* nit - Remove outdated comment

* [TS] Strict mode: LGraph

- Adds minor coercion changes; would need extremely specific hacks performed to result in runtime change

* [TMP] Work around typescript-strict-plugin

Must be reverted once plugin removed.
See #578
2025-02-24 11:12:46 +00: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
46535409c8 [CI] Fix existing lint warnings & disallow in future (#567)
* Fix lint warnings

* [CI] Fail lint checks instead of warning

* [CI] Fail stylistic lint checks instead of warning
2025-02-23 20:12:04 +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