9 changed files with 177 additions and 206 deletions
@ -1,24 +0,0 @@ |
|||
import { NodeType } from "@/types"; |
|||
|
|||
export const HIDDEN_SIDEBAR_NODE_TYPES = new Set<NodeType>([ |
|||
"smartImage", |
|||
"smartVideo", |
|||
"prompt", |
|||
"output", |
|||
"outputGallery", |
|||
"router", |
|||
"switch", |
|||
"conditionalSwitch", |
|||
"generate3d", |
|||
"glbViewer", |
|||
]); |
|||
|
|||
export const HIDDEN_CONNECTION_MENU_NODE_TYPES = new Set<NodeType>([ |
|||
"output", |
|||
"outputGallery", |
|||
"router", |
|||
"switch", |
|||
"conditionalSwitch", |
|||
"generate3d", |
|||
"glbViewer", |
|||
]); |
|||
@ -0,0 +1,116 @@ |
|||
import type { NodeType, SelectedModel } from "@/types"; |
|||
|
|||
export type ConnectionMediaGroup = "text" | "image" | "video" | "audio" | "3d"; |
|||
export type ConnectionInputGroup = ConnectionMediaGroup | "easeCurve"; |
|||
|
|||
export const CONNECTION_GROUP_SOURCE_NODES = { |
|||
text: ["smartText", "promptConstructor", "array"], |
|||
image: ["smartImage", "videoFrameGrab", "annotation"], |
|||
video: ["smartVideo", "videoStitch", "easeCurve", "videoTrim"], |
|||
audio: ["smartAudio"], |
|||
"3d": [], |
|||
} as const satisfies Record<ConnectionMediaGroup, readonly NodeType[]>; |
|||
|
|||
export const NODE_OUTPUT_GROUPS: Partial<Record<NodeType, ConnectionMediaGroup>> = { |
|||
imageInput: "image", |
|||
smartImage: "image", |
|||
nanoBanana: "image", |
|||
annotation: "image", |
|||
splitGrid: "image", |
|||
videoFrameGrab: "image", |
|||
glbViewer: "image", |
|||
|
|||
videoInput: "video", |
|||
smartVideo: "video", |
|||
generateVideo: "video", |
|||
videoStitch: "video", |
|||
easeCurve: "video", |
|||
videoTrim: "video", |
|||
|
|||
audioInput: "audio", |
|||
smartAudio: "audio", |
|||
generateAudio: "audio", |
|||
|
|||
prompt: "text", |
|||
smartText: "text", |
|||
llmGenerate: "text", |
|||
array: "text", |
|||
promptConstructor: "text", |
|||
switch: "text", |
|||
conditionalSwitch: "text", |
|||
|
|||
generate3d: "3d", |
|||
}; |
|||
|
|||
export const NODE_INPUT_GROUPS: Partial<Record<NodeType, readonly ConnectionInputGroup[]>> = { |
|||
imageInput: ["image", "text"], |
|||
videoInput: ["video", "text"], |
|||
audioInput: ["audio", "text"], |
|||
prompt: ["text"], |
|||
|
|||
promptConstructor: ["text"], |
|||
array: ["text"], |
|||
|
|||
annotation: ["image"], |
|||
splitGrid: ["image"], |
|||
imageCompare: ["image"], |
|||
|
|||
videoStitch: ["video", "audio"], |
|||
videoTrim: ["video"], |
|||
videoFrameGrab: ["video"], |
|||
easeCurve: ["video"], |
|||
|
|||
glbViewer: ["3d"], |
|||
output: ["image", "text", "video", "audio", "3d"], |
|||
outputGallery: ["image", "text", "video", "audio"], |
|||
router: ["image", "text", "video", "audio", "3d"], |
|||
switch: ["text"], |
|||
conditionalSwitch: ["text"], |
|||
}; |
|||
|
|||
export const MODEL_BACKED_CONNECTION_NODE_TYPES = new Set<NodeType>([ |
|||
"smartImage", |
|||
"smartVideo", |
|||
"smartAudio", |
|||
"smartText", |
|||
"nanoBanana", |
|||
"generateVideo", |
|||
"generateAudio", |
|||
"generate3d", |
|||
"llmGenerate", |
|||
]); |
|||
|
|||
export function selectedModelSupportsConnectionGroup( |
|||
model: SelectedModel | null | undefined, |
|||
group: ConnectionInputGroup |
|||
): boolean { |
|||
if (group === "text") return true; |
|||
if (group === "3d" || group === "easeCurve") return false; |
|||
|
|||
const metadata = model?.metadata; |
|||
if (!metadata) return true; |
|||
|
|||
if (group === "image") return metadata.isSupportImages !== false; |
|||
if (group === "video") return metadata.isSupportVideos === true; |
|||
return metadata.isSupportAudios === true || metadata.isSupportAudio === true; |
|||
} |
|||
|
|||
export function getModelBackedInputGroups( |
|||
model: SelectedModel | null | undefined |
|||
): ConnectionInputGroup[] { |
|||
return [ |
|||
"text", |
|||
...(["image", "video", "audio"] as const).filter((group) => selectedModelSupportsConnectionGroup(model, group)), |
|||
]; |
|||
} |
|||
|
|||
export function getNodeAcceptedConnectionGroups( |
|||
nodeType: NodeType, |
|||
selectedModel?: SelectedModel | null |
|||
): ConnectionInputGroup[] { |
|||
if (MODEL_BACKED_CONNECTION_NODE_TYPES.has(nodeType)) { |
|||
return getModelBackedInputGroups(selectedModel); |
|||
} |
|||
|
|||
return [...(NODE_INPUT_GROUPS[nodeType] ?? [])]; |
|||
} |
|||
Loading…
Reference in new issue