Commit Graph

50 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
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
c2a88d3088 [Refactor] Use Rectangle for canvas visible area (#1041) 2025-05-12 11:01:36 +00:00
filtered
6ff80cfd36 [Cleanup] Fix node background drawn twice / misc (#1040) 2025-05-10 14:47:48 +00:00
filtered
1b37502d70 [API] Improve widget typing (#1027) 2025-05-08 06:37:16 +10:00
filtered
c344a73739 [API] Export widget classes for downstream use (#1018)
Exports all widget classes.

- BaseSteppedWidget
- BaseWidget
- BooleanWidget
- ButtonWidget
- ComboWidget
- KnobWidget
- NumberWidget
- SliderWidget
- TextWidget
2025-05-06 06:50:17 +10: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
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
79ce3199d4 [Cleanup] Documentation (#963)
Adds / cleans JSDoc.
2025-04-24 22:47:20 +10:00
filtered
5c76bec611 [TS] Export types (#933)
Re-exports module-level exports at the package level.
2025-04-18 21:01:10 +10: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
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
0b4b420445 Add lib export: createUuidv4 (#800) 2025-03-17 13:39:19 +00:00
filtered
7e2009188d [Refactor] Split functions out to file (#713)
Splits code out from `LGraphCanvas`.
2025-03-07 09:07:38 +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
6737828a2b Lint module entry point (#635)
- Adds module entry point tests
- Manually resolved lint rules for module entry point imports / exports
(autofix could not resolve without causing issues)
2025-02-27 12:02:03 +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
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
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
a4b9704a80 Remove entry point import, merge modules (#590)
* Remove unused import in lib entry point

* [Refactor] Merge type util modules
2025-02-25 01:25:42 +00:00
filtered
ad8dd7a9d8 Export enum (#589)
* Revert "Export enum (#587)"

This reverts commit cf8565eb13.

* Export enums
2025-02-25 01:08:04 +00:00
Chenlei Hu
cf8565eb13 Export enum (#587) 2025-02-24 19:37:18 -05:00
Chenlei Hu
86f823b7d5 [nit] Move isColorable out of interfaces.ts (#564) 2025-02-23 13:06:03 -05: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
817214e6da [Refactor] Move strokeShape from LGraphCanvas to draw (#435)
* [Refactor] Move strokeShape from LGraphCanvas to draw

* Fix round radius

* nit

* nit

* nit
2025-02-02 22:29:26 -05:00
Chenlei Hu
e442732a09 Emit node-double-click event (#383)
* Emit node-double-click event

* nit
2024-12-19 16:37:29 -08:00
filtered
71f8a1decf Export Reroute class the same as other similar classes (#378)
* Export Reroute class the same as other similar classes

* Update test expectations
2024-12-15 10:54:50 -08:00
Chenlei Hu
c69bbdfb10 Export LGraphEventMode (#369) 2024-12-05 11:32:08 -05:00
Chenlei Hu
83ba7a8df7 Export ISerialisedGraph for frontend repo DTS (#354) 2024-11-27 23:50:16 -05:00
filtered
5469bfdd52 Add ESLint, pre-commit hook & format all files (#319)
* Add ESLint config

* Add ESLint packages

* Add prettier config

* Fix ESLint package version

* Format all files

* Format static assets

* Format project root config

* Add pre-commit code formatting

Formats .css & .js files automatically.  If any .ts or .mts files are staged, the entire project is type-checked.

Packages:
- lint-staged
- husky
- prettier
2024-11-20 21:50:58 -05:00
filtered
b29a32c1ae Add CanvasPointer API (#308)
* Add position rounding feature

Replaces previous impls. which only worked on some items, and were triggered when unexpected e.g. clicking a node that hadn't been moved.

Update test expectations

* Narrow TS types - readonly

* nit - Clean up, Doc

* nit - Clean up legacy accessors

Marks as deprecated

* Fix TS type - IContextMenuOptions.scale

* [Refactor] dist2 for use in pointer API

* Add CanvasPointer - API for pointer events

Add TS strict types
Add final click drag distance math
Add option to retain events

* nit - Rename

* nit

* Remove Subgraph - unused & not maintained

* Remove live_mode

Unused, not maintained.

* Update README

Remove live_mode reference

* Update delete selected - include reroutes & groups

* Bypass link menu if alt/shift pressed

* Remove old dragged_node interface

Incomplete impl. - unused.
Superceded by selectedItems

* Fix top/left edge of rectangles not in hitbox

* [Refactor] Match function names to interface names

* Add interface to find widgets by Point

LGraphNode.getWidgetOnPos

* Add widget search param - includeDisabled

* nit - Doc

* Rewrite canvas mouse handling

- Rewrites most pointer handling to use CanvasPointer callbacks
- All callbacks are declared ahead of time during the initial pointerdown event, logically grouped together
- Drastically simplifies the alteration or creation of new click / drag interactions
- Click events are all clicks, rather than some processed on mouse down, others on mouse up

- Functions return instead of setting and repeatedly checking multiple state vars
- Removes all lines that needed THIRTEEN tab indents

* Split middle click out from processMouseDown

* Use pointer API for link menus

* Narrow canvas event interfaces

* Fix canvas event types

Replaces original workarounds with final types

* Refactor - deprecated isInsideRectangle

* Add canvas hovering over state

- Centralises cursor set behaviour
- Provides simple downstream override

* nit

* [Refactor] Use measure functions

* Add double-click API to CanvasPointer

a

* nit - Doc

* Allow larger gap between double click events

* Rewrite double-click into CanvasPointer actions

* Improve double-click UX

Prefer down events over up events

* Add production defaults

* Add middle-click handling

* Remove debug code

* Remove redundant code

* Fix add reroute alt-click adds two undo steps

* Fix click on connected input disconnects

Old behaviour was to disconnect, then recreate a new link on drop.

* Add module export: CanvasPointer
2024-11-16 17:35:30 -05:00
filtered
3d6adf0225 Add Reroutes (#301)
* Add Reroute

- Initial Reroute implementation
- LLink and Reroute both implement the new LinkSegment interface
- LinkSegments can have a parentId, which always points to a Reroute

* Narrow TS type of schema v0.4 extras

* Add reroutes to schema 0.4

Use extras.reroutes to store additional data

* Add Reroute POC to LLink

* Add Reroute rendering

* Add Reroute context menu - Delete Reroute

* Update delete selected - include reroutes & groups

* Add Reroute select & move

* Include reroutes in area-select

* Move disconnect link logic to LLink

* Add Reroute connect

* nit

* Add Reroute support - connecting links

* Add Add Reroute from link menu (menu)

* nit

* Add shift-drag from reroute to add new link

* Prevent Reroutes from disappearing

Add keepReroutes option to prevent Reroute GC

* Add fourth param to connectInputToOutput

* Allow both connecting in/out to be null

* Move ConnectingLink start pos to Reroute

* Add link render options

* Refactor renderLink - spline / bezier

* Refactor renderLink - linear, straight

* Fix centre points on all link types

Improves link render time

* [Refactor] Generic recursive interface / flat set

* nit

* Allow Reroutes to be members of groups

* Start links from the closest reroute

For the "shift-click drag link from link" feature

* Add Reroutes using alt-click on link paths

* nit - Refactor

* nit - Refactor

* Fix reroute deselect UX

Temporary workaround

* Add Reroute link centre-marker handling

* Add optional link arrow markers

Add enum for link markers
-> Pointing the way forward ->
Set default centre marker to arrow

* Add module export: LinkMarkerShape

* Add link arrow direction for all link types

* Add Reroute auto-swivel with custom curves

* Add state switch to disable reroutes

Works at root of all canvas interactions, should leave existing reroutes untouched but invisible until e.g. links are edited / changed.

* Fix cannot deselect when reroutes disabled

* Include reroutes in select-all
2024-11-12 11:18:48 -05:00
Chenlei Hu
c7d5c863ec Move createBounds to measure.ts (#290)
* nit

* Move createBounds to measure

* Export createBounds
2024-11-08 13:49:30 -05:00
filtered
87c6d59546 Keep links connected when deleting nodes (#288)
* Allow node delete to keep more links connected

* Allow node delete to match every link

* Add config for connectInputToOutput
2024-11-08 11:13:14 -05:00
filtered
fc0b8087db Graph serialisation update - Links & Reroutes (#279)
* nit

* Add LGraph state POCO

Moves last_link_id, last_node_id and creates same for group and reroute

fix import

* Add new serialisation to LGraph

Add LGraph schema 1
Remove reroute from old serialised graph
Remove brittle inherited types
Ensure stale links are not kept when clearing graph

* Add serialisable exports

* Ensure valid LGraph.state during deserialise
2024-11-07 18:33:54 -05:00
Chenlei Hu
6200aa8602 Reland animateToNode (#259)
* Reland animateToNode

* nit
2024-11-03 10:45:42 -05:00
Chenlei Hu
7c0240857c Revert branch to cb6e80a645 (#257) 2024-11-03 09:12:47 -05:00
dmx
79c53e0095 (prettier formatting) 2024-11-03 09:20:57 +04:00
filtered
0b174adfeb Move canvas state to plain object (#233)
* Move canvas state to plain object

POCO that can be proxied without side-effects.
LGraphCanvasState interface added to package exports

* Add item dragging to canvas state
2024-10-29 21:39:46 -04:00
filtered
5070866299 Add / improve Node interfaces: Find slots & before connect callback (#226)
* Add connectByType wrappers

Can find slots without actually connecting.  Will be used for link snapping.

* Refactor - generic find free slot

* Fix link/links TS types - should not be undefined

* Fix / add TS types, docs

* Refactor - fix overloads TS types

* Refactor - optional chaining

* Extend node before-connect callback

The callback can now determine if connection is to a specific input, or just trying to connect any valid slot on the node.

* Add TS types - finish IOptionalInputsData
2024-10-28 18:59:43 -04:00
filtered
3f5499f955 Canvas refactors - standardising (#221)
* Add distribute nodes

* Fix node alt-clone does not work like copy/paste

* Impl. emitEvent across LGraphCanvas

- Create TS types and union for all events
- Replaces all relevant dispatchEvent calls with emitEvent()

* Remove unused code

- showShowGraphOptionsPanel throws an exception when run.  Safe to assume this function not in use.
- Remove old commented code

* Refactor - minor changes to clear TS errors

* Add TS types

* nit - ts-expect-error, comments

* Remove legacy hook

* Refactor - prefer typeof / instanceof / isArray

* Refactor - TS type narrowing

* nit
2024-10-26 13:13:42 -04:00
filtered
955daac9e6 Fix circular dependency (#219)
* Fix circular dependency - LGraphCanvas static init

* Remove dependency workaround
2024-10-25 20:17:31 -04:00
filtered
96866e8624 Typescript LGraphNode (#207)
* nit - Fix whitespace

* nit - Remove outdated comments

* nit - Remove redundant jsdoc tag

* Format only

* Add TS types

* nit - Auto let/const

* Convert special-case vars

* nit - Redeclared params / vars

* nit - const/let

* Refactor - minor logic change

* Add TS types - overloads w/workaround

* Refactor - prefer typeof over constructor check

* Add TS types

* Remove unused params

* nit - Refactor

* Refactor LGraphNode.findSlotByType

* nit - Refactor / format

* Refactor - optional chaining

* Fix TS type - node shape
2024-10-12 10:53:25 -04:00
filtered
5d510cd674 Revert "Format all code with prettier (#197)" (#198)
This reverts commit 28382b7e45.
2024-10-08 13:14:36 -04:00
Chenlei Hu
28382b7e45 Format all code with prettier (#197)
* Add formatter support

* Format all code

* Fix moved @ts-expect-error
2024-10-07 14:06:44 -04:00
Chenlei Hu
142c22ea41 Typescript conversion 0.7.84 (#194)
* Convert litegraph.js to TS

* Overhaul static litegraph.d.ts with updated types

* Fix rename oversights and revert fix unused param

- Some functions were broken by merging updated TS function signatures which included param renames
- Removal of unused params does not belong in the TS conversion PR, and has been reverted

* Remove legacy static .d.ts file

* Add callback decl from #180

Support allowing links to widgets (#180)
c23e610c11

* Convert NodeId to string | number

Results in significantly less downstream changes, despite being a change from the old static file.

---------

Co-authored-by: filtered <176114999+webfiltered@users.noreply.github.com>
2024-10-07 11:15:29 -04:00