mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-02-02 14:27:40 +00:00
Type serialized NodeSlot (#605)
This commit is contained in:
@@ -707,8 +707,8 @@ export class LGraphNode implements Positionable, IPinnable, IColorable {
|
||||
if (this.constructor === LGraphNode && this.last_serialization)
|
||||
return this.last_serialization
|
||||
|
||||
if (this.inputs) o.inputs = this.inputs.map(serializeSlot)
|
||||
if (this.outputs) o.outputs = this.outputs.map(serializeSlot)
|
||||
if (this.inputs) o.inputs = this.inputs.map(input => serializeSlot(input))
|
||||
if (this.outputs) o.outputs = this.outputs.map(output => serializeSlot(output))
|
||||
|
||||
if (this.title && this.title != this.constructor.title) o.title = this.title
|
||||
|
||||
|
||||
@@ -4,6 +4,8 @@ import type { LinkId } from "./LLink"
|
||||
import { LinkDirection, RenderShape } from "./types/globalEnums"
|
||||
import { LabelPosition, SlotShape, SlotType } from "./draw"
|
||||
import { LiteGraph } from "./litegraph"
|
||||
import { ISerialisedNodeOutputSlot } from "./types/serialisation"
|
||||
import { ISerialisedNodeInputSlot } from "./types/serialisation"
|
||||
|
||||
export interface ConnectionColorContext {
|
||||
default_connection_color: {
|
||||
@@ -27,7 +29,9 @@ interface IDrawOptions {
|
||||
highlight?: boolean
|
||||
}
|
||||
|
||||
export function serializeSlot<T extends INodeSlot>(slot: T): T {
|
||||
export function serializeSlot(slot: INodeInputSlot): ISerialisedNodeInputSlot
|
||||
export function serializeSlot(slot: INodeOutputSlot): ISerialisedNodeOutputSlot
|
||||
export function serializeSlot(slot: INodeInputSlot | INodeOutputSlot): ISerialisedNodeInputSlot | ISerialisedNodeOutputSlot {
|
||||
const serialized = { ...slot }
|
||||
delete serialized._layoutElement
|
||||
if ("_data" in serialized) {
|
||||
|
||||
@@ -40,6 +40,11 @@ export interface SerialisableGraph {
|
||||
extra?: Record<any, any>
|
||||
}
|
||||
|
||||
export type ISerialisedNodeInputSlot = Omit<INodeInputSlot, "_layoutElement"> & {
|
||||
widget?: { name?: string }
|
||||
}
|
||||
export type ISerialisedNodeOutputSlot = Omit<INodeOutputSlot, "_layoutElement" | "_data">
|
||||
|
||||
/** Serialised LGraphNode */
|
||||
export interface ISerialisedNode {
|
||||
title?: string
|
||||
@@ -50,8 +55,8 @@ export interface ISerialisedNode {
|
||||
flags?: INodeFlags
|
||||
order?: number
|
||||
mode?: number
|
||||
outputs?: INodeOutputSlot[]
|
||||
inputs?: INodeInputSlot[]
|
||||
outputs?: ISerialisedNodeOutputSlot[]
|
||||
inputs?: ISerialisedNodeInputSlot[]
|
||||
properties?: Dictionary<unknown>
|
||||
shape?: RenderShape
|
||||
boxcolor?: string
|
||||
|
||||
Reference in New Issue
Block a user