Commit Graph

92 Commits

Author SHA1 Message Date
filtered
bcaaa00770 Add Subgraphs (#1000) 2025-06-28 15:21:56 -07:00
filtered
de21f5ccd3 Fix unnecessary module loading for type imports (#1053) 2025-05-15 23:16:27 +00:00
filtered
19b7d28d97 [API] Add dirty state flag for selectedItems (#1050) 2025-05-15 19:33:51 +10:00
filtered
de32560816 [TS] Improve types and (#1043) 2025-05-12 19:02:57 +00:00
filtered
10118d95e3 Export the viewport offset and scale with the graph (#1042) 2025-05-12 18:47:10 +00:00
filtered
6ff80cfd36 [Cleanup] Fix node background drawn twice / misc (#1040) 2025-05-10 14:47:48 +00: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
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
c695b2e2bd Fix LGraph attach/detach canvas silently fails (#986)
Attach would allow duplicate entries.
Detach left the canvas.graph property set, if list_of_graphcanvas was
not set.
2025-04-30 18:10:45 +00:00
filtered
b3d030e36b [API] Add LLink.resolve static / instance methods (#974)
- `LLink.resolve`: Resolves all IDs on the link to their respective
objects (node IDs, slot indexes)
- `LinkNetwork.getLink`: a more concise pattern to resolve links
2025-04-26 20:51:41 +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
2e72031344 [API] Remove deprecated: getAncestors (#919)
Removes unused and deprecated API: LGraph.getAncestors
2025-04-11 17:29:53 +00:00
filtered
ed34080e46 Remove auto-generated serialisation data on load (#900)
- Resolves #883
2025-04-06 15:10:08 +00:00
filtered
3b5cc8cd19 Add alt-right-click to delete reroutes (#899)
Alt-right-click to remove, regular right-click to show context menu.
2025-04-06 14:55:17 +00:00
filtered
6cafeeff19 Fix corruption of selected link highlights (#897)
Occurred when deselecting one side of a link when both sides were
selected.
2025-04-06 14:30:22 +00:00
filtered
05b0918915 Support dragging reroutes from floating links (#878)
Allows dragging reroutes from floating links.
2025-04-03 12:08:28 +00:00
filtered
5662aa3790 [API] Remove unused: LGraph.getSupportedTypes (#849)
Also removes unused `supported_types` static array.
2025-03-24 07:03:07 +00:00
filtered
f0bd360935 [API] Remove unused callbacks (#848)
- Follow-up on #847
- Removes now-redundant callbacks
2025-03-24 06:58:56 +00:00
filtered
28543d7d9d [API] Remove unused LGraph APIs (#847)
Removes unused, outdated helper methods from the original, incomplete
subgraph impl.
2025-03-24 06:24:28 +00: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
87aeab16a0 [API] Fix several floating links issues & add Reroute.totalLinks (#815)
Resolves several issues with floating links.  Highlights:

- Caches floating links on slots, removing some loop checks (inefficient
/ does not scale)
- Simpler APIs
- Adds `Reroute.totalLinks` (regular and floating
2025-03-21 19:17:54 +00:00
filtered
a043e7a72e [API] Add reroute convenience methods (#812)
Adds `LGraph.getReroute`, which accepts null & undefined IDs. Interface
overloads result in `never` when given a _known_ `undefined` or `null`
value.
2025-03-21 18:58:07 +00:00
filtered
4078e3ad8b Improve reroutes - prep for LinkConnector overhaul (#810)
- Fixes TS types
- Various bug fixes for reroute / link (re)connect
- Adds reroute snap circle when connecting links
- Validates reroutes on drop (part of larger work)
- Prevent nodes linking to themselves
2025-03-21 18:47:36 +00:00
filtered
e65898b9ec [API] Remove unused: LGraph.onAction (#802) 2025-03-18 20:06:46 +00:00
filtered
257d4fc7b9 Fix old graph ID kept when configuring new graph (#798)
Prevents ID leakage when using default `LGraph.configure()` settings.
2025-03-17 23:54:44 +11:00
Chenlei Hu
94b9ecec71 [Bug] Fix remove of floatingLinks (#792)
Resolves https://github.com/Comfy-Org/litegraph.js/issues/791

This PR fixes removal of floating links.

---------

Co-authored-by: filtered <176114999+webfiltered@users.noreply.github.com>
2025-03-16 22:13:24 +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
e6a914117b Add floating reroutes (#773)
### Floating reroutes

Native reroutes can now be kept in a disconnected state.

Link chains may be kept provided they are connected to _either_ an input
or an output. By design, reroutes will be automatically removed if both
sides are disconnected.
2025-03-13 19:56:57 +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
835e22d754 [Cleanup] Removed unused convenience setter - reroutes (#768)
- New features are making the reroutes convenience setter unmanageable.
- Not currently in use.
- Prefer `configure()`, as it includes validation.
2025-03-13 14:53:26 +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
bcaeccfc45 Fix #346 last reroute is never deleted (#766)
Clears the reroutes in extras when exporting for serialisation, if none
exist.

- Resolves #346
2025-03-13 00:35:05 +00:00
filtered
68945cb54d Remove getTime workaround and Node.js type bleeding (#723)
- Removes legacy timer workaround (redundant on Chrome v6 / Node.js v16)
- Removes old type workarounds
- Improves type inference speed
2025-03-08 13:27:49 +00:00
filtered
8bee428375 [API] Remove unused LGraph.onNodeConnectionChange (#701)
Confirmed unused via code search.
2025-03-04 09:18:38 +00: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
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
78175e2c1b [TS] Add strict nullability to LGraphCanvas (#669)
- Updates typing in copy & paste
- Clean up
2025-03-02 08:34:26 +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
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
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
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
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
0b84ca83d8 [TS] Use strict mode in LGraphGroup (#599)
- Adds `NullGraphError` to reduce boilerplate null check code
- Prefer optional `undefined` to explicit `null`
  - Related: https://github.com/Comfy-Org/litegraph.js/issues/595
- Adds strict types
2025-02-25 17:15:48 +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
bcd5a77837 [TS] Strict initializers - LGraph (#573)
Duplicates values from clear() to property initializers.
2025-02-24 03:30:20 +00:00