mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-04-24 00:09:32 +00:00
Type LGraphNode.getInnerNodes (#2498)
This commit is contained in:
@@ -856,6 +856,7 @@ export class GroupNodeHandler {
|
|||||||
for (let i = 0; i < c.nodes.length; i++) {
|
for (let i = 0; i < c.nodes.length; i++) {
|
||||||
let id = innerNodes?.[i]?.id
|
let id = innerNodes?.[i]?.id
|
||||||
// Use existing IDs if they are set on the inner nodes
|
// Use existing IDs if they are set on the inner nodes
|
||||||
|
// @ts-expect-error id can be string or number
|
||||||
if (id == null || isNaN(id)) {
|
if (id == null || isNaN(id)) {
|
||||||
id = undefined
|
id = undefined
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -151,7 +151,6 @@ app.registerExtension({
|
|||||||
height
|
height
|
||||||
)
|
)
|
||||||
|
|
||||||
// @ts-expect-error hacky override
|
|
||||||
sceneWidget.serializeValue = async () => {
|
sceneWidget.serializeValue = async () => {
|
||||||
node.properties['Camera Info'] = load3d.getCameraState()
|
node.properties['Camera Info'] = load3d.getCameraState()
|
||||||
|
|
||||||
@@ -314,7 +313,6 @@ app.registerExtension({
|
|||||||
height
|
height
|
||||||
)
|
)
|
||||||
|
|
||||||
// @ts-expect-error hacky override
|
|
||||||
sceneWidget.serializeValue = async () => {
|
sceneWidget.serializeValue = async () => {
|
||||||
node.properties['Camera Info'] = load3d.getCameraState()
|
node.properties['Camera Info'] = load3d.getCameraState()
|
||||||
|
|
||||||
|
|||||||
@@ -101,10 +101,8 @@ app.registerExtension({
|
|||||||
capture
|
capture
|
||||||
)
|
)
|
||||||
btn.disabled = true
|
btn.disabled = true
|
||||||
// @ts-expect-error hacky override
|
|
||||||
btn.serializeValue = () => undefined
|
btn.serializeValue = () => undefined
|
||||||
|
|
||||||
// @ts-expect-error hacky override
|
|
||||||
camera.serializeValue = async () => {
|
camera.serializeValue = async () => {
|
||||||
if (captureOnQueue.value) {
|
if (captureOnQueue.value) {
|
||||||
capture()
|
capture()
|
||||||
|
|||||||
@@ -1287,7 +1287,7 @@ export class ComfyApp {
|
|||||||
|
|
||||||
// Store all widget values
|
// Store all widget values
|
||||||
if (widgets) {
|
if (widgets) {
|
||||||
for (const i in widgets) {
|
for (let i = 0; i < widgets.length; i++) {
|
||||||
const widget = widgets[i]
|
const widget = widgets[i]
|
||||||
if (!widget.options || widget.options.serialize !== false) {
|
if (!widget.options || widget.options.serialize !== false) {
|
||||||
inputs[widget.name] = widget.serializeValue
|
inputs[widget.name] = widget.serializeValue
|
||||||
@@ -1298,7 +1298,7 @@ export class ComfyApp {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Store all node links
|
// Store all node links
|
||||||
for (let i in node.inputs) {
|
for (let i = 0; i < node.inputs.length; i++) {
|
||||||
let parent = node.getInputNode(i)
|
let parent = node.getInputNode(i)
|
||||||
if (parent) {
|
if (parent) {
|
||||||
let link = node.getInputLink(i)
|
let link = node.getInputLink(i)
|
||||||
@@ -1318,14 +1318,18 @@ export class ComfyApp {
|
|||||||
} else if (link && parent.mode === LGraphEventMode.BYPASS) {
|
} else if (link && parent.mode === LGraphEventMode.BYPASS) {
|
||||||
let all_inputs = [link.origin_slot]
|
let all_inputs = [link.origin_slot]
|
||||||
if (parent.inputs) {
|
if (parent.inputs) {
|
||||||
|
// @ts-expect-error convert list of strings to list of numbers
|
||||||
all_inputs = all_inputs.concat(Object.keys(parent.inputs))
|
all_inputs = all_inputs.concat(Object.keys(parent.inputs))
|
||||||
for (let parent_input in all_inputs) {
|
for (let parent_input in all_inputs) {
|
||||||
|
// @ts-expect-error assign string to number
|
||||||
parent_input = all_inputs[parent_input]
|
parent_input = all_inputs[parent_input]
|
||||||
if (
|
if (
|
||||||
parent.inputs[parent_input]?.type === node.inputs[i].type
|
parent.inputs[parent_input]?.type === node.inputs[i].type
|
||||||
) {
|
) {
|
||||||
|
// @ts-expect-error convert string to number
|
||||||
link = parent.getInputLink(parent_input)
|
link = parent.getInputLink(parent_input)
|
||||||
if (link) {
|
if (link) {
|
||||||
|
// @ts-expect-error convert string to number
|
||||||
parent = parent.getInputNode(parent_input)
|
parent = parent.getInputNode(parent_input)
|
||||||
}
|
}
|
||||||
found = true
|
found = true
|
||||||
@@ -1347,6 +1351,7 @@ export class ComfyApp {
|
|||||||
if (link) {
|
if (link) {
|
||||||
inputs[node.inputs[i].name] = [
|
inputs[node.inputs[i].name] = [
|
||||||
String(link.origin_id),
|
String(link.origin_id),
|
||||||
|
// @ts-expect-error link.origin_slot is already number.
|
||||||
parseInt(link.origin_slot)
|
parseInt(link.origin_slot)
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
4
src/types/litegraph-augmentation.d.ts
vendored
4
src/types/litegraph-augmentation.d.ts
vendored
@@ -16,6 +16,7 @@ declare module '@comfyorg/litegraph/dist/types/widgets' {
|
|||||||
interface IBaseWidget {
|
interface IBaseWidget {
|
||||||
onRemove?: () => void
|
onRemove?: () => void
|
||||||
beforeQueued?: () => unknown
|
beforeQueued?: () => unknown
|
||||||
|
serializeValue?: (node: LGraphNode, index: number) => Promise<unknown>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -43,8 +44,7 @@ declare module '@comfyorg/litegraph' {
|
|||||||
onExecuted?(output: any): void
|
onExecuted?(output: any): void
|
||||||
onNodeCreated?(this: LGraphNode): void
|
onNodeCreated?(this: LGraphNode): void
|
||||||
setInnerNodes?(nodes: LGraphNode[]): void
|
setInnerNodes?(nodes: LGraphNode[]): void
|
||||||
// TODO: Requires several coercion changes to runtime code.
|
getInnerNodes?(): LGraphNode[]
|
||||||
getInnerNodes?() // : LGraphNode[]
|
|
||||||
convertToNodes?(): LGraphNode[]
|
convertToNodes?(): LGraphNode[]
|
||||||
recreate?(): Promise<LGraphNode>
|
recreate?(): Promise<LGraphNode>
|
||||||
refreshComboInNode?(defs: Record<string, ComfyNodeDef>)
|
refreshComboInNode?(defs: Record<string, ComfyNodeDef>)
|
||||||
|
|||||||
Reference in New Issue
Block a user