mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-03-11 16:10:05 +00:00
Implement _.pick to simplify serialization (#763)
Simplify the serialization code, so that we only write each prop once.
This commit is contained in:
@@ -1,12 +1,12 @@
|
||||
import type { CanvasColour, Dictionary, INodeInputSlot, INodeOutputSlot, INodeSlot, ISlotType, IWidgetInputSlot, Point, SharedIntersection } from "./interfaces"
|
||||
import type { LinkId } from "./LLink"
|
||||
import type { ISerialisableNodeInput, ISerialisableNodeOutput } from "./types/serialisation"
|
||||
import type { IWidget } from "./types/widgets"
|
||||
|
||||
import { LabelPosition, SlotShape, SlotType } from "./draw"
|
||||
import { LiteGraph } from "./litegraph"
|
||||
import { LinkDirection, RenderShape } from "./types/globalEnums"
|
||||
import { ISerialisableNodeOutput } from "./types/serialisation"
|
||||
import { ISerialisableNodeInput } from "./types/serialisation"
|
||||
import { pick } from "./utils/object"
|
||||
|
||||
export interface ConnectionColorContext {
|
||||
default_connection_color: {
|
||||
@@ -33,8 +33,19 @@ interface IDrawOptions {
|
||||
type CommonIoSlotProps = SharedIntersection<ISerialisableNodeInput, ISerialisableNodeOutput>
|
||||
|
||||
export function shallowCloneCommonProps(slot: CommonIoSlotProps): CommonIoSlotProps {
|
||||
const { color_off, color_on, dir, label, localized_name, locked, name, nameLocked, removable, shape, type } = slot
|
||||
return { color_off, color_on, dir, label, localized_name, locked, name, nameLocked, removable, shape, type }
|
||||
return pick(slot, [
|
||||
"color_off",
|
||||
"color_on",
|
||||
"dir",
|
||||
"label",
|
||||
"localized_name",
|
||||
"locked",
|
||||
"name",
|
||||
"nameLocked",
|
||||
"removable",
|
||||
"shape",
|
||||
"type",
|
||||
])
|
||||
}
|
||||
|
||||
export function inputAsSerialisable(slot: INodeInputSlot): ISerialisableNodeInput {
|
||||
|
||||
Reference in New Issue
Block a user