Commit Graph

838 Commits

Author SHA1 Message Date
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
6f51767451 Add ESLint unicorn plugin (#627)
Rules disabled by default to allow incremental integration.
2025-02-27 08:41:51 +00:00
Chenlei Hu
e8c238b70e Update serialisation.ts (#624)
Update ISerialisedNodeInputSlot.widget type. Overwrite original widget
prop type.
2025-02-26 16:40:36 -05:00
Miguel C
fbcc396880 Knob (#600)
Resolved issues with history due to merges, opened a new pull request.
A more visual widget that the usual number/slider. Differentiates itself
from the functionality of a slider by not setting the value on click,
only stepping, emulating an actual knob.

- Left/Right takes 1 step at a time
- Up/Down moves 1% or 1 step, whichever is larger
- Move + Shift moves by 10% or 1 step, whichever is larger

This also includes a fixes to some size logic.
- [x] ~~Still missing being able to drag the knob itself, as the
clicking of the widget is not recognized if it's outside of where a
normal height widget would be.~~

![knob-node](https://github.com/user-attachments/assets/9d0ce70d-a220-49d0-987f-8dcef2b1d299)
2025-02-26 15:07:32 -05:00
Chenlei Hu
963e4b0904 [Type] Mark name as required prop for IBaseWidget (#623) 2025-02-26 15:03:31 -05:00
Chenlei Hu
d20aab757c Serialize NodeInputSlot.widget (#622)
Serialize linked widget on node input slot properly according to current
save format in
76818b54e6/src/extensions/core/widgetInputs.ts
2025-02-26 14:15:31 -05:00
filtered
c166a34fd8 Add ESLint rules to enforce existing lib style (#621)
Adds a few rules that enforce consistency across the repo.

Only change is one top-level const arrow function is now a function
definition.
2025-02-26 18:12:26 +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
0b59c00597 [API] Remove deprecated: DragAndScale mouse (#615)
Removed unused public methods (unmaintained, non-functional):
- bindEvents
- onMouse

`onredraw` is in use by extension authors.

This file now passes TS strict checks.
2025-02-26 11:59:12 +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
dbe016b934 Move widget prop to INodeInputSlot (#606)
Ref: https://github.com/Comfy-Org/ComfyUI_frontend/pull/2728
2025-02-25 19:37:40 -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
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
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
4920e10f0c [TS] Use strict mode in LiteGraphGlobal (#593)
- Adds minor type coercions to resolve type errors
- Adds ts-ignore that must be removed later
2025-02-25 11:59:39 +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
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
fadece7fdf Type LGraphNode.addInput/Output (#585) 2025-02-24 19:29:04 -05:00
Chenlei Hu
59dea644f2 Move marker property from BaseWidget to SliderWidget (#584)
* Move marker property from BaseWidget to SliderWidget

* nit
2025-02-24 16:35:34 -05:00
Chenlei Hu
170341db73 Type ButtonWidget (#583)
* Type ButtonWidget

* nit
2025-02-24 16:30:04 -05:00
filtered
630fd00086 [API] Remove unused LiteGraph APIs (#582)
* [API] Remove unused LiteGraph APIs

These features have not been maintained, and would require refactoring / rewrites. As code search revealed them to be unused, they are being removed.

- addNodeMethod
- compareObjects
- auto_sort_node_types

* Udpate API.md
2025-02-24 12:04:07 +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
9d6c867607 [TS] Strict mode: CurveEditor (#580)
- Converts `CurveEditor` to ts strict
- Two runtime changes: explicit throws instead of `TypeError` on following line
2025-02-24 10:21:35 +00:00
filtered
bcd5a77837 [TS] Strict initializers - LGraph (#573)
Duplicates values from clear() to property initializers.
2025-02-24 03:30:20 +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
Chenlei Hu
f300e37a89 Remove NodeSlot.pos when serializing WidgetInputSlot (#570) 2025-02-23 16:11:56 -05:00
filtered
4add6c3211 [Cleanup] Follow-up on #566 - fix style (#568) 2025-02-23 20:20:44 +00: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
Chenlei Hu
86f823b7d5 [nit] Move isColorable out of interfaces.ts (#564) 2025-02-23 13:06:03 -05: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
dc9a76200b [BugFix] Call LGraphCanvas.deleteSelected on context menu remove (#560) 2025-02-20 15:22:53 -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
1dee497e40 Fix drag event throws introduced in #554 (#555) 2025-02-20 16:30:38 +11: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