File size: 1,182 Bytes
3d5837a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import {app} from "../../../scripts/app.js";
import {ComfyWidgets} from "../../../scripts/widgets.js";

app.registerExtension({
    name: "derfuu.Debug.ShowDataText",
    async beforeRegisterNodeDef(nodeType, nodeData, app) {
        if (nodeData.name === "DF_To_text_(Debug)") {
            function set_text_wid(text) {
                if (this.widgets) {
                    for (let i = 0; i < this.widgets.length; i++) {
                        this.widgets[i].onRemove?.();
                    }
                    this.widgets.length = 0;
                }

                const widget = ComfyWidgets.STRING(this, "DEBUG INFO", ["STRING", {multiline: true}], app).widget;
                widget.inputEl.readOnly = true;
                widget.inputEl.style.opacity = 0.75;
                widget.value = text;
            }
            const onExecuted = nodeType.prototype.onExecuted;
            nodeType.prototype.onExecuted = function (message) {
                onExecuted?.apply(this, arguments);
                set_text_wid.call(this, message.text);
            };
            app.graph.setDirtyCanvas(true, true);
        }
    },
});