[TMP] Support downstream output widget in serialisation (#735)

- Ref: https://github.com/Comfy-Org/litegraph.js/pull/732#issuecomment-2710796369
This commit is contained in:
filtered
2025-03-11 03:05:06 +11:00
committed by GitHub
parent 84dad03f4d
commit 1a482d750b
2 changed files with 18 additions and 8 deletions

View File

@@ -38,23 +38,31 @@ export function shallowCloneCommonProps(slot: CommonIoSlotProps): CommonIoSlotPr
}
export function inputAsSerialisable(slot: INodeInputSlot): ISerialisableNodeInput {
const widgetInputProps = slot.widget
const { link } = slot
const widgetOrPos = slot.widget
? { widget: { name: slot.widget.name } }
: { pos: slot.pos }
return {
...shallowCloneCommonProps(slot),
...widgetInputProps,
link: slot.link,
...widgetOrPos,
link,
}
}
export function outputAsSerialisable(slot: INodeOutputSlot): ISerialisableNodeOutput {
export function outputAsSerialisable(slot: INodeOutputSlot & { widget?: IWidget }): ISerialisableNodeOutput {
const { pos, slot_index, links, widget } = slot
// Output widgets do not exist in Litegraph; this is a temporary downstream workaround.
const outputWidget = widget
? { widget: { name: widget.name } }
: null
return {
...shallowCloneCommonProps(slot),
pos: slot.pos,
slot_index: slot.slot_index,
links: slot.links,
...outputWidget,
pos,
slot_index,
links,
}
}

View File

@@ -43,7 +43,9 @@ export interface SerialisableGraph {
export type ISerialisableNodeInput = Omit<INodeInputSlot, "_layoutElement" | "widget"> & {
widget?: { name: string }
}
export type ISerialisableNodeOutput = Omit<INodeOutputSlot, "_layoutElement" | "_data">
export type ISerialisableNodeOutput = Omit<INodeOutputSlot, "_layoutElement" | "_data"> & {
widget?: { name: string }
}
/** Serialised LGraphNode */
export interface ISerialisedNode {