mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-02-21 15:24:09 +00:00
[Refactor] Move Widget.beforeQueued invocation from graphToPrompt to queuePrompt (#2667)
This commit is contained in:
@@ -15,14 +15,6 @@ export const graphToPrompt = async (
|
||||
const { sortNodes = false } = options
|
||||
|
||||
for (const outerNode of graph.computeExecutionOrder(false)) {
|
||||
if (outerNode.widgets) {
|
||||
for (const widget of outerNode.widgets) {
|
||||
// Allow widgets to run callbacks before a prompt has been queued
|
||||
// e.g. random seed before every gen
|
||||
widget.beforeQueued?.()
|
||||
}
|
||||
}
|
||||
|
||||
const innerNodes = outerNode.getInnerNodes
|
||||
? outerNode.getInnerNodes()
|
||||
: [outerNode]
|
||||
|
||||
@@ -42,3 +42,14 @@ export const getItemsColorOption = (items: unknown[]): ColorOption | null => {
|
||||
? _.head(colorOptions)!
|
||||
: null
|
||||
}
|
||||
|
||||
export function executeWidgetsCallback(
|
||||
nodes: LGraphNode[],
|
||||
callbackName: 'onRemove' | 'beforeQueued' | 'afterQueued'
|
||||
) {
|
||||
for (const node of nodes) {
|
||||
for (const widget of node.widgets ?? []) {
|
||||
widget[callbackName]?.()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user