move Node to frontend

This commit is contained in:
flyingshutter 2023-04-07 19:32:27 +02:00
parent f4d88df757
commit 612f99bda6
3 changed files with 48 additions and 18 deletions

View File

@ -1059,22 +1059,6 @@ class ImagePadForOutpaint:
return (new_image, mask)
class BatchIndex:
@classmethod
def INPUT_TYPES(cls):
return {
"required": {
"batch_index": ("INT", {}),
},
}
RETURN_TYPES = ("INT", "FLOAT")
FUNCTION = "getBatchIndex"
CATEGORY = "utils"
def getBatchIndex(self, batch_index):
return (batch_index, batch_index)
NODE_CLASS_MAPPINGS = {
"KSampler": KSampler,
@ -1118,7 +1102,6 @@ NODE_CLASS_MAPPINGS = {
"unCLIPCheckpointLoader": unCLIPCheckpointLoader,
"CheckpointLoader": CheckpointLoader,
"DiffusersLoader": DiffusersLoader,
"BatchIndex": BatchIndex,
}
def load_custom_node(module_path):

View File

@ -0,0 +1,48 @@
import { ComfyWidgets } from "/scripts/widgets.js";
import { app } from "/scripts/app.js";
class BatchInfo {
constructor() {
this.addOutput("iteration", "INT");
let widget = (ComfyWidgets["INT:batch_index"](this, "iteration", ["INT",{}], app) || {}).widget;
this.serialize_widgets = true;
this.isVirtualNode = true;
}
applyToGraph() {
if (!this.outputs[0].links?.length) return;
// For each output link copy our value over the original widget value
for (const l of this.outputs[0].links) {
const linkInfo = app.graph.links[l];
const node = this.graph.getNodeById(linkInfo.target_id);
const input = node.inputs[linkInfo.target_slot];
const widgetName = input.widget.name;
if (widgetName) {
const widget = node.widgets.find((w) => w.name === widgetName);
if (widget) {
widget.value = this.widgets[0].value;
if (widget.callback) {
widget.callback(widget.value, app.canvas, node, app.canvas.graph_mouse, {});
}
}
}
}
}
}
app.registerExtension({
name: "Comfy.BatchInfo",
registerCustomNodes() {
LiteGraph.registerNodeType(
"BatchInfo",
Object.assign(BatchInfo, {
title: "BatchInfo",
})
);
BatchInfo.category = "utils";
},
});

View File

@ -48,7 +48,6 @@ export function batchIndexWidget(node, inputName, inputData) {
const { val, config } = getNumberDefaults(inputData, 1);
Object.assign(config, { precision: 0 });
const batchIndex = node.addWidget("number", inputName, val, () => {}, config)
batchIndex.forbidConvertToInput = true;
batchIndex.disabled = true;
batchIndex.onInitBatch = () => {