mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-04-28 02:02:08 +00:00
Merging with (the)Master and nodeWebcam_Fix
This commit is contained in:
@@ -509,7 +509,7 @@
|
|||||||
position: absolute;
|
position: absolute;
|
||||||
top: 10px;
|
top: 10px;
|
||||||
left: 10px;
|
left: 10px;
|
||||||
min-height: 2em;
|
/*min-height: 2em;*/
|
||||||
background-color: #333;
|
background-color: #333;
|
||||||
font-size: 1.2em;
|
font-size: 1.2em;
|
||||||
box-shadow: 0 0 10px black !important;
|
box-shadow: 0 0 10px black !important;
|
||||||
@@ -529,6 +529,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.graphdialog input,
|
.graphdialog input,
|
||||||
|
.graphdialog textarea,
|
||||||
.graphdialog select {
|
.graphdialog select {
|
||||||
margin: 3px;
|
margin: 3px;
|
||||||
min-width: 60px;
|
min-width: 60px;
|
||||||
@@ -540,9 +541,15 @@
|
|||||||
outline: none;
|
outline: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.graphdialog textarea {
|
||||||
|
min-height: 150px;
|
||||||
|
}
|
||||||
|
|
||||||
.graphdialog button {
|
.graphdialog button {
|
||||||
margin-top: 3px;
|
margin-top: 3px;
|
||||||
vertical-align: top;
|
vertical-align: top;
|
||||||
|
background-color: #999;
|
||||||
|
border: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.graphdialog button.rounded,
|
.graphdialog button.rounded,
|
||||||
|
|||||||
@@ -89,6 +89,7 @@ function TestWidgetsNode()
|
|||||||
this.number = this.addWidget("number","Number", 0.5, function(v){}, { min: 0, max: 100} );
|
this.number = this.addWidget("number","Number", 0.5, function(v){}, { min: 0, max: 100} );
|
||||||
this.combo = this.addWidget("combo","Combo", "red", function(v){}, { values:["red","green","blue"]} );
|
this.combo = this.addWidget("combo","Combo", "red", function(v){}, { values:["red","green","blue"]} );
|
||||||
this.text = this.addWidget("text","Text", "edit me", function(v){}, {} );
|
this.text = this.addWidget("text","Text", "edit me", function(v){}, {} );
|
||||||
|
this.text2 = this.addWidget("text","Text", "multiline", function(v){}, { multiline:true } );
|
||||||
this.toggle = this.addWidget("toggle","Toggle", true, function(v){}, { on: "enabled", off:"disabled"} );
|
this.toggle = this.addWidget("toggle","Toggle", true, function(v){}, { on: "enabled", off:"disabled"} );
|
||||||
this.button = this.addWidget("button","Button", null, function(v){}, {} );
|
this.button = this.addWidget("button","Button", null, function(v){}, {} );
|
||||||
this.toggle2 = this.addWidget("toggle","Disabled", true, function(v){}, { on: "enabled", off:"disabled"} );
|
this.toggle2 = this.addWidget("toggle","Disabled", true, function(v){}, { on: "enabled", off:"disabled"} );
|
||||||
|
|||||||
@@ -71,7 +71,7 @@ graph.start();</pre>
|
|||||||
|
|
||||||
<h2>Example of editor</h2>
|
<h2>Example of editor</h2>
|
||||||
<ul>
|
<ul>
|
||||||
<li><a href="demo">Module editor</a></li>
|
<li><a href="editor">Module editor</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
<h2>Documentation</h2>
|
<h2>Documentation</h2>
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "litegraph.js",
|
"name": "litegraph.js",
|
||||||
"version": "0.7.8",
|
"version": "0.7.9",
|
||||||
"description": "A graph node editor similar to PD or UDK Blueprints. It works in an HTML5 Canvas and allows to export graphs to be included in applications.",
|
"description": "A graph node editor similar to PD or UDK Blueprints. It works in an HTML5 Canvas and allows to export graphs to be included in applications.",
|
||||||
"main": "build/litegraph.js",
|
"main": "build/litegraph.js",
|
||||||
"types": "src/litegraph.d.ts",
|
"types": "src/litegraph.d.ts",
|
||||||
|
|||||||
31
src/litegraph.d.ts
vendored
31
src/litegraph.d.ts
vendored
@@ -740,7 +740,7 @@ export declare class LGraphNode {
|
|||||||
name: string,
|
name: string,
|
||||||
type: string | -1,
|
type: string | -1,
|
||||||
extra_info?: Partial<INodeOutputSlot>
|
extra_info?: Partial<INodeOutputSlot>
|
||||||
): void;
|
): INodeOutputSlot;
|
||||||
/**
|
/**
|
||||||
* add a new output slot to use in this node
|
* add a new output slot to use in this node
|
||||||
* @param array of triplets like [[name,type,extra_info],[...]]
|
* @param array of triplets like [[name,type,extra_info],[...]]
|
||||||
@@ -760,7 +760,7 @@ export declare class LGraphNode {
|
|||||||
name: string,
|
name: string,
|
||||||
type: string | -1,
|
type: string | -1,
|
||||||
extra_info?: Partial<INodeInputSlot>
|
extra_info?: Partial<INodeInputSlot>
|
||||||
): void;
|
): INodeInputSlot;
|
||||||
/**
|
/**
|
||||||
* add several new input slots in this node
|
* add several new input slots in this node
|
||||||
* @param array of triplets like [[name,type,extra_info],[...]]
|
* @param array of triplets like [[name,type,extra_info],[...]]
|
||||||
@@ -953,13 +953,34 @@ export declare class LGraphNode {
|
|||||||
/**
|
/**
|
||||||
* if returns false the incoming connection will be canceled
|
* if returns false the incoming connection will be canceled
|
||||||
* Called by `LGraph.connect`
|
* Called by `LGraph.connect`
|
||||||
|
* @param inputIndex target input slot number
|
||||||
|
* @param outputType type of output slot
|
||||||
|
* @param outputSlot output slot object
|
||||||
|
* @param outputNode node containing the output
|
||||||
|
* @param outputIndex index of output slot
|
||||||
*/
|
*/
|
||||||
onConnectInput?(
|
onConnectInput?(
|
||||||
inputIndex: number,
|
inputIndex: number,
|
||||||
type: INodeOutputSlot["type"],
|
outputType: INodeOutputSlot["type"],
|
||||||
outputSlot: INodeOutputSlot,
|
outputSlot: INodeOutputSlot,
|
||||||
_this: this,
|
outputNode: LGraphNode,
|
||||||
slotIndex: number
|
outputIndex: number
|
||||||
|
): boolean;
|
||||||
|
/**
|
||||||
|
* if returns false the incoming connection will be canceled
|
||||||
|
* Called by `LGraph.connect`
|
||||||
|
* @param outputIndex target output slot number
|
||||||
|
* @param inputType type of input slot
|
||||||
|
* @param inputSlot input slot object
|
||||||
|
* @param inputNode node containing the input
|
||||||
|
* @param inputIndex index of input slot
|
||||||
|
*/
|
||||||
|
onConnectOutput?(
|
||||||
|
outputIndex: number,
|
||||||
|
inputType: INodeInputSlot["type"],
|
||||||
|
inputSlot: INodeInputSlot,
|
||||||
|
inputNode: LGraphNode,
|
||||||
|
inputIndex: number
|
||||||
): boolean;
|
): boolean;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -1365,6 +1365,8 @@
|
|||||||
return;
|
return;
|
||||||
} //cannot be removed
|
} //cannot be removed
|
||||||
|
|
||||||
|
this.beforeChange(); //sure?
|
||||||
|
|
||||||
//disconnect inputs
|
//disconnect inputs
|
||||||
if (node.inputs) {
|
if (node.inputs) {
|
||||||
for (var i = 0; i < node.inputs.length; i++) {
|
for (var i = 0; i < node.inputs.length; i++) {
|
||||||
@@ -1423,6 +1425,7 @@
|
|||||||
this.sendActionToCanvas("checkPanels");
|
this.sendActionToCanvas("checkPanels");
|
||||||
|
|
||||||
this.setDirtyCanvas(true, true);
|
this.setDirtyCanvas(true, true);
|
||||||
|
this.afterChange(); //sure?
|
||||||
this.change();
|
this.change();
|
||||||
|
|
||||||
this.updateExecutionOrder();
|
this.updateExecutionOrder();
|
||||||
@@ -8622,6 +8625,7 @@ LGraphNode.prototype.executeAction = function(action)
|
|||||||
ctx.strokeStyle = outline_color;
|
ctx.strokeStyle = outline_color;
|
||||||
ctx.fillStyle = "#222";
|
ctx.fillStyle = "#222";
|
||||||
ctx.textAlign = "left";
|
ctx.textAlign = "left";
|
||||||
|
//ctx.lineWidth = 2;
|
||||||
if(w.disabled)
|
if(w.disabled)
|
||||||
ctx.globalAlpha *= 0.5;
|
ctx.globalAlpha *= 0.5;
|
||||||
var widget_width = w.width || width;
|
var widget_width = w.width || width;
|
||||||
@@ -8769,13 +8773,15 @@ LGraphNode.prototype.executeAction = function(action)
|
|||||||
else
|
else
|
||||||
ctx.rect( margin, posY, widget_width - margin * 2, H );
|
ctx.rect( margin, posY, widget_width - margin * 2, H );
|
||||||
ctx.fill();
|
ctx.fill();
|
||||||
if (show_text) {
|
if (show_text) {
|
||||||
ctx.save();
|
if(!w.disabled)
|
||||||
|
ctx.stroke();
|
||||||
|
ctx.save();
|
||||||
ctx.beginPath();
|
ctx.beginPath();
|
||||||
ctx.rect(margin, posY, widget_width - margin * 2, H);
|
ctx.rect(margin, posY, widget_width - margin * 2, H);
|
||||||
ctx.clip();
|
ctx.clip();
|
||||||
|
|
||||||
ctx.stroke();
|
//ctx.stroke();
|
||||||
ctx.fillStyle = secondary_text_color;
|
ctx.fillStyle = secondary_text_color;
|
||||||
if (w.name != null) {
|
if (w.name != null) {
|
||||||
ctx.fillText(w.name, margin * 2, y + H * 0.7);
|
ctx.fillText(w.name, margin * 2, y + H * 0.7);
|
||||||
@@ -8850,10 +8856,8 @@ LGraphNode.prototype.executeAction = function(action)
|
|||||||
break;
|
break;
|
||||||
case "slider":
|
case "slider":
|
||||||
var range = w.options.max - w.options.min;
|
var range = w.options.max - w.options.min;
|
||||||
var nvalue = Math.clamp((x - 10) / (widget_width - 20), 0, 1);
|
var nvalue = Math.clamp((x - 15) / (widget_width - 30), 0, 1);
|
||||||
w.value =
|
w.value = w.options.min + (w.options.max - w.options.min) * nvalue;
|
||||||
w.options.min +
|
|
||||||
(w.options.max - w.options.min) * nvalue;
|
|
||||||
if (w.callback) {
|
if (w.callback) {
|
||||||
setTimeout(function() {
|
setTimeout(function() {
|
||||||
inner_value_change(w, w.value);
|
inner_value_change(w, w.value);
|
||||||
@@ -8963,7 +8967,7 @@ LGraphNode.prototype.executeAction = function(action)
|
|||||||
this.value = v;
|
this.value = v;
|
||||||
inner_value_change(this, v);
|
inner_value_change(this, v);
|
||||||
}.bind(w),
|
}.bind(w),
|
||||||
event);
|
event,w.options ? w.options.multiline : false );
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@@ -9550,18 +9554,18 @@ LGraphNode.prototype.executeAction = function(action)
|
|||||||
|
|
||||||
var dialog = document.createElement("div");
|
var dialog = document.createElement("div");
|
||||||
dialog.className = "graphdialog";
|
dialog.className = "graphdialog";
|
||||||
dialog.innerHTML =
|
dialog.innerHTML = "<span class='name'></span><input autofocus type='text' class='value'/><button>OK</button>";
|
||||||
"<span class='name'></span><input autofocus type='text' class='value'/><button>OK</button>";
|
//dialog.innerHTML = "<span class='name'></span><textarea autofocus class='value'></textarea><button>OK</button>";
|
||||||
var title = dialog.querySelector(".name");
|
var title = dialog.querySelector(".name");
|
||||||
title.innerText = property;
|
title.innerText = property;
|
||||||
var input = dialog.querySelector("input");
|
var input = dialog.querySelector(".value");
|
||||||
if (input) {
|
if (input) {
|
||||||
input.value = value;
|
input.value = value;
|
||||||
input.addEventListener("blur", function(e) {
|
input.addEventListener("blur", function(e) {
|
||||||
this.focus();
|
this.focus();
|
||||||
});
|
});
|
||||||
input.addEventListener("keydown", function(e) {
|
input.addEventListener("keydown", function(e) {
|
||||||
if (e.keyCode != 13) {
|
if (e.keyCode != 13 && e.target.localName != "textarea") {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
inner();
|
inner();
|
||||||
@@ -9611,7 +9615,7 @@ LGraphNode.prototype.executeAction = function(action)
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
LGraphCanvas.prototype.prompt = function(title, value, callback, event) {
|
LGraphCanvas.prototype.prompt = function(title, value, callback, event, multiline) {
|
||||||
var that = this;
|
var that = this;
|
||||||
var input_html = "";
|
var input_html = "";
|
||||||
title = title || "";
|
title = title || "";
|
||||||
@@ -9620,8 +9624,10 @@ LGraphNode.prototype.executeAction = function(action)
|
|||||||
|
|
||||||
var dialog = document.createElement("div");
|
var dialog = document.createElement("div");
|
||||||
dialog.className = "graphdialog rounded";
|
dialog.className = "graphdialog rounded";
|
||||||
dialog.innerHTML =
|
if(multiline)
|
||||||
"<span class='name'></span> <input autofocus type='text' class='value'/><button class='rounded'>OK</button>";
|
dialog.innerHTML = "<span class='name'></span> <textarea autofocus class='value'></textarea><button class='rounded'>OK</button>";
|
||||||
|
else
|
||||||
|
dialog.innerHTML = "<span class='name'></span> <input autofocus type='text' class='value'/><button class='rounded'>OK</button>";
|
||||||
dialog.close = function() {
|
dialog.close = function() {
|
||||||
that.prompt_box = null;
|
that.prompt_box = null;
|
||||||
if (dialog.parentNode) {
|
if (dialog.parentNode) {
|
||||||
@@ -9653,13 +9659,13 @@ LGraphNode.prototype.executeAction = function(action)
|
|||||||
var value_element = dialog.querySelector(".value");
|
var value_element = dialog.querySelector(".value");
|
||||||
value_element.value = value;
|
value_element.value = value;
|
||||||
|
|
||||||
var input = dialog.querySelector("input");
|
var input = value_element;
|
||||||
input.addEventListener("keydown", function(e) {
|
input.addEventListener("keydown", function(e) {
|
||||||
modified = true;
|
modified = true;
|
||||||
if (e.keyCode == 27) {
|
if (e.keyCode == 27) {
|
||||||
//ESC
|
//ESC
|
||||||
dialog.close();
|
dialog.close();
|
||||||
} else if (e.keyCode == 13) {
|
} else if (e.keyCode == 13 && e.target.localName != "textarea") {
|
||||||
if (callback) {
|
if (callback) {
|
||||||
callback(this.value);
|
callback(this.value);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -716,6 +716,21 @@
|
|||||||
|
|
||||||
LiteGraph.registerNodeType("basic/string", ConstantString);
|
LiteGraph.registerNodeType("basic/string", ConstantString);
|
||||||
|
|
||||||
|
function ConstantObject() {
|
||||||
|
this.addOutput("obj", "object");
|
||||||
|
this.size = [120, 30];
|
||||||
|
this._object = {};
|
||||||
|
}
|
||||||
|
|
||||||
|
ConstantObject.title = "Const Object";
|
||||||
|
ConstantObject.desc = "Constant Object";
|
||||||
|
|
||||||
|
ConstantObject.prototype.onExecute = function() {
|
||||||
|
this.setOutputData(0, this._object);
|
||||||
|
};
|
||||||
|
|
||||||
|
LiteGraph.registerNodeType( "basic/object", ConstantObject );
|
||||||
|
|
||||||
function ConstantFile() {
|
function ConstantFile() {
|
||||||
this.addInput("url", "");
|
this.addInput("url", "");
|
||||||
this.addOutput("", "");
|
this.addOutput("", "");
|
||||||
@@ -851,14 +866,14 @@
|
|||||||
|
|
||||||
//to store json objects
|
//to store json objects
|
||||||
function ConstantArray() {
|
function ConstantArray() {
|
||||||
|
this._value = [];
|
||||||
this.addInput("", "");
|
this.addInput("", "");
|
||||||
this.addOutput("", "array");
|
this.addOutput("", "array");
|
||||||
this.addOutput("length", "number");
|
this.addOutput("length", "number");
|
||||||
this.addProperty("value", "");
|
this.addProperty("value", "[]");
|
||||||
this.widget = this.addWidget("text","array","","value");
|
this.widget = this.addWidget("text","array",this.properties.value,"value");
|
||||||
this.widgets_up = true;
|
this.widgets_up = true;
|
||||||
this.size = [140, 50];
|
this.size = [140, 50];
|
||||||
this._value = null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ConstantArray.title = "Const Array";
|
ConstantArray.title = "Const Array";
|
||||||
@@ -891,7 +906,7 @@
|
|||||||
for(var i = 0; i < v.length; ++i)
|
for(var i = 0; i < v.length; ++i)
|
||||||
this._value[i] = v[i];
|
this._value[i] = v[i];
|
||||||
}
|
}
|
||||||
this.setOutputData(0, this._value);
|
this.setOutputData(0, this._value );
|
||||||
this.setOutputData(1, this._value ? ( this._value.length || 0) : 0 );
|
this.setOutputData(1, this._value ? ( this._value.length || 0) : 0 );
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -899,6 +914,32 @@
|
|||||||
|
|
||||||
LiteGraph.registerNodeType("basic/array", ConstantArray);
|
LiteGraph.registerNodeType("basic/array", ConstantArray);
|
||||||
|
|
||||||
|
function SetArray()
|
||||||
|
{
|
||||||
|
this.addInput("arr", "array");
|
||||||
|
this.addInput("value", "");
|
||||||
|
this.addOutput("arr", "array");
|
||||||
|
this.properties = { index: 0 };
|
||||||
|
this.widget = this.addWidget("number","i",this.properties.index,"index");
|
||||||
|
}
|
||||||
|
|
||||||
|
SetArray.title = "Set Array";
|
||||||
|
SetArray.desc = "Sets index of array";
|
||||||
|
|
||||||
|
SetArray.prototype.onExecute = function() {
|
||||||
|
var arr = this.getInputData(0);
|
||||||
|
if(!arr)
|
||||||
|
return;
|
||||||
|
var v = this.getInputData(1);
|
||||||
|
if(v === undefined )
|
||||||
|
return;
|
||||||
|
if(this.properties.index)
|
||||||
|
arr[ Math.floor(this.properties.index) ] = v;
|
||||||
|
this.setOutputData(0,arr);
|
||||||
|
};
|
||||||
|
|
||||||
|
LiteGraph.registerNodeType("basic/set_array", SetArray );
|
||||||
|
|
||||||
function ArrayElement() {
|
function ArrayElement() {
|
||||||
this.addInput("array", "array,table,string");
|
this.addInput("array", "array,table,string");
|
||||||
this.addInput("index", "number");
|
this.addInput("index", "number");
|
||||||
@@ -921,8 +962,6 @@
|
|||||||
|
|
||||||
LiteGraph.registerNodeType("basic/array[]", ArrayElement);
|
LiteGraph.registerNodeType("basic/array[]", ArrayElement);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function TableElement() {
|
function TableElement() {
|
||||||
this.addInput("table", "table");
|
this.addInput("table", "table");
|
||||||
this.addInput("row", "number");
|
this.addInput("row", "number");
|
||||||
@@ -1010,10 +1049,38 @@
|
|||||||
|
|
||||||
LiteGraph.registerNodeType("basic/object_keys", ObjectKeys);
|
LiteGraph.registerNodeType("basic/object_keys", ObjectKeys);
|
||||||
|
|
||||||
|
|
||||||
|
function SetObject()
|
||||||
|
{
|
||||||
|
this.addInput("obj", "");
|
||||||
|
this.addInput("value", "");
|
||||||
|
this.addOutput("obj", "");
|
||||||
|
this.properties = { property: "" };
|
||||||
|
this.name_widget = this.addWidget("text","prop.",this.properties.property,"property");
|
||||||
|
}
|
||||||
|
|
||||||
|
SetObject.title = "Set Object";
|
||||||
|
SetObject.desc = "Adds propertiesrty to object";
|
||||||
|
|
||||||
|
SetObject.prototype.onExecute = function() {
|
||||||
|
var obj = this.getInputData(0);
|
||||||
|
if(!obj)
|
||||||
|
return;
|
||||||
|
var v = this.getInputData(1);
|
||||||
|
if(v === undefined )
|
||||||
|
return;
|
||||||
|
if(this.properties.property)
|
||||||
|
obj[ this.properties.property ] = v;
|
||||||
|
this.setOutputData(0,obj);
|
||||||
|
};
|
||||||
|
|
||||||
|
LiteGraph.registerNodeType("basic/set_object", SetObject );
|
||||||
|
|
||||||
|
|
||||||
function MergeObjects() {
|
function MergeObjects() {
|
||||||
this.addInput("A", "object");
|
this.addInput("A", "");
|
||||||
this.addInput("B", "object");
|
this.addInput("B", "");
|
||||||
this.addOutput("", "object");
|
this.addOutput("", "");
|
||||||
this._result = {};
|
this._result = {};
|
||||||
var that = this;
|
var that = this;
|
||||||
this.addWidget("button","clear","",function(){
|
this.addWidget("button","clear","",function(){
|
||||||
@@ -1281,9 +1348,7 @@
|
|||||||
this.addProperty("msg", "");
|
this.addProperty("msg", "");
|
||||||
this.addInput("", LiteGraph.EVENT);
|
this.addInput("", LiteGraph.EVENT);
|
||||||
var that = this;
|
var that = this;
|
||||||
this.widget = this.addWidget("text", "Text", "", function(v) {
|
this.widget = this.addWidget("text", "Text", "", "msg");
|
||||||
that.properties.msg = v;
|
|
||||||
});
|
|
||||||
this.widgets_up = true;
|
this.widgets_up = true;
|
||||||
this.size = [200, 30];
|
this.size = [200, 30];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,10 +3,21 @@
|
|||||||
var LiteGraph = global.LiteGraph;
|
var LiteGraph = global.LiteGraph;
|
||||||
|
|
||||||
function toString(a) {
|
function toString(a) {
|
||||||
|
if(a && a.constructor === Object)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
return JSON.stringify(a);
|
||||||
|
}
|
||||||
|
catch (err)
|
||||||
|
{
|
||||||
|
return String(a);
|
||||||
|
}
|
||||||
|
}
|
||||||
return String(a);
|
return String(a);
|
||||||
}
|
}
|
||||||
|
|
||||||
LiteGraph.wrapFunctionAsNode("string/toString", compare, [""], "String");
|
LiteGraph.wrapFunctionAsNode("string/toString", toString, [""], "String");
|
||||||
|
|
||||||
function compare(a, b) {
|
function compare(a, b) {
|
||||||
return a == b;
|
return a == b;
|
||||||
|
|||||||
Reference in New Issue
Block a user