-
Notifications
You must be signed in to change notification settings - Fork 512
[refactor] Type createNode options parameter #9262
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,13 +3,17 @@ import type { CanvasPointerEvent } from '@/lib/litegraph/src/types/events' | |
| import type { TWidgetValue } from '@/lib/litegraph/src/types/widgets' | ||
|
|
||
| import type { ContextMenu } from './ContextMenu' | ||
| import type { LGraphNode, NodeId } from './LGraphNode' | ||
| import type { LGraphNode, NodeId, NodeProperty } from './LGraphNode' | ||
| import type { LLink, LinkId } from './LLink' | ||
| import type { Reroute, RerouteId } from './Reroute' | ||
| import type { SubgraphInput } from './subgraph/SubgraphInput' | ||
| import type { SubgraphInputNode } from './subgraph/SubgraphInputNode' | ||
| import type { SubgraphOutputNode } from './subgraph/SubgraphOutputNode' | ||
| import type { LinkDirection, RenderShape } from './types/globalEnums' | ||
| import type { | ||
| LGraphEventMode, | ||
| LinkDirection, | ||
| RenderShape | ||
| } from './types/globalEnums' | ||
| import type { IBaseWidget } from './types/widgets' | ||
|
|
||
| export type Dictionary<T> = { [key: string]: T } | ||
|
|
@@ -373,6 +377,22 @@ export interface INodeOutputSlot extends INodeSlot { | |
| slot_index?: number | ||
| } | ||
|
|
||
| /** Options for {@link LiteGraphGlobal.createNode}. Shallow-copied onto the new node. */ | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. question:
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done: renamed to ModelNodeCreateOptions in the previous commit
christian-byrne marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| export interface CreateNodeOptions { | ||
| pos?: Point | ||
| size?: Size | ||
| properties?: Dictionary<NodeProperty | undefined> | ||
| flags?: Partial<INodeFlags> | ||
| mode?: LGraphEventMode | ||
| color?: string | ||
| bgcolor?: string | ||
| boxcolor?: string | ||
| title?: string | ||
| shape?: RenderShape | ||
| inputs?: Partial<INodeInputSlot>[] | ||
| outputs?: Partial<INodeOutputSlot>[] | ||
|
Comment on lines
+392
to
+393
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: # First, let's find the interfaces.ts file and examine the current type definitions
fd "interfaces\.ts" src/lib/litegraph --exec wc -l {}Repository: Comfy-Org/ComfyUI_frontend Length of output: 109 🏁 Script executed: # Look at the CreateNodeOptions type and related interfaces
rg -n "type CreateNodeOptions|interface CreateNodeOptions" --type ts src/lib/litegraphRepository: Comfy-Org/ComfyUI_frontend Length of output: 146 🏁 Script executed: # Find the INodeInputSlot and INodeOutputSlot definitions
rg -n "interface INodeInputSlot|interface INodeOutputSlot" --type ts src/lib/litegraphRepository: Comfy-Org/ComfyUI_frontend Length of output: 254 🏁 Script executed: # Search for createNode function calls to see actual usage patterns
rg -n "createNode\s*\(" --type ts -C 2 src/lib/litegraphRepository: Comfy-Org/ComfyUI_frontend Length of output: 14236 🏁 Script executed: # Search for where inputs and outputs are being set in node creation context
rg -n "inputs\s*:\s*\[" --type ts -C 2 src/lib/litegraph | head -50Repository: Comfy-Org/ComfyUI_frontend Length of output: 3957 🏁 Script executed: # Also check for outputs assignments
rg -n "outputs\s*:\s*\[" --type ts -C 2 src/lib/litegraph | head -50Repository: Comfy-Org/ComfyUI_frontend Length of output: 3337 🏁 Script executed: # Read the interfaces.ts file around the relevant definitions
sed -n '355,400p' src/lib/litegraph/src/interfaces.tsRepository: Comfy-Org/ComfyUI_frontend Length of output: 1102 🏁 Script executed: # Read more to see INodeSlot definition
sed -n '350,365p' src/lib/litegraph/src/interfaces.tsRepository: Comfy-Org/ComfyUI_frontend Length of output: 536 🏁 Script executed: # Search for all usages of inputs/outputs in CreateNodeOptions context
# to understand if empty arrays and partial objects are common
rg "inputs\s*:\s*\[\s*\]|outputs\s*:\s*\[\s*\]" --type ts src/lib/litegraph -C 1Repository: Comfy-Org/ComfyUI_frontend Length of output: 2888 🏁 Script executed: # Check if there are any createNode calls that pass inputs/outputs with incomplete fields
rg "createNode\s*\([^)]*\{[^}]*inputs|outputs" --type ts -A 5 src/lib/litegraph | head -80Repository: Comfy-Org/ComfyUI_frontend Length of output: 5485 🏁 Script executed: # Look for any createNode calls with inputs/outputs that have incomplete field definitions
# Search for patterns where inputs/outputs have objects but might be missing name or type
rg "inputs\s*:\s*\[\s*\{" --type ts -A 3 src/lib/litegraph | grep -v "name\|type"Repository: Comfy-Org/ComfyUI_frontend Length of output: 12762 🏁 Script executed: # Check the actual createNode implementation to see how it handles inputs/outputs
rg -n "createNode\(" --type ts -A 20 src/lib/litegraph/src/LiteGraphGlobal.ts | head -80Repository: Comfy-Org/ComfyUI_frontend Length of output: 668 🏁 Script executed: # Look for SubgraphConversion test's createNode to understand the test helper
sed -n '16,50p' src/lib/litegraph/src/subgraph/SubgraphConversion.test.tsRepository: Comfy-Org/ComfyUI_frontend Length of output: 1153 🏁 Script executed: # Look at how createNode actually uses the inputs/outputs from CreateNodeOptions
sed -n '531,600p' src/lib/litegraph/src/LiteGraphGlobal.tsRepository: Comfy-Org/ComfyUI_frontend Length of output: 1863 🏁 Script executed: # Check if there are any real cases where inputs/outputs objects are provided without name field
rg "inputs\s*:\s*\[\s*\{[^}]*\}" --type ts src/lib/litegraph -A 1 | grep -B 1 -v "name"Repository: Comfy-Org/ComfyUI_frontend Length of output: 10134 🏁 Script executed: # Search for actual complete usage of createNode with inputs/outputs options
rg "LiteGraph\.createNode\([^)]*inputs:|LiteGraph\.createNode\([^)]*outputs:" --type ts -B 2 -A 5 src/lib/litegraphRepository: Comfy-Org/ComfyUI_frontend Length of output: 52 Tighten The current 🤖 Prompt for AI Agents |
||
| } | ||
|
|
||
| /** Links */ | ||
| export interface ConnectingLink extends IInputOrOutput { | ||
| node: LGraphNode | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
note (non-blocking): the old
for...inloop traversed the prototype chain, whileObject.assignonly copies own enumerable properties. That's actually safer behavior - just flagging the subtle semantic difference in case any caller relied on inherited properties (unlikely with plain object literals).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Acknowledged: all callers pass plain object literals, so the behavior change is safe. The stricter semantics are actually preferable here