mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-02-02 22:37:32 +00:00
build
This commit is contained in:
@@ -3175,20 +3175,6 @@
|
||||
var size = out || new Float32Array([0, 0]);
|
||||
rows = Math.max(rows, 1);
|
||||
var font_size = LiteGraph.NODE_TEXT_SIZE; //although it should be graphcanvas.inner_text_font size
|
||||
size[1] = (this.constructor.slot_start_y || 0) + rows * LiteGraph.NODE_SLOT_HEIGHT;
|
||||
|
||||
var widgets_height = 0;
|
||||
if (this.widgets && this.widgets.length) {
|
||||
widgets_height = this.widgets.length * (LiteGraph.NODE_WIDGET_HEIGHT + 4) + 8;
|
||||
}
|
||||
|
||||
//compute height using widgets height
|
||||
if( this.widgets_up )
|
||||
size[1] = Math.max( size[1], widgets_height );
|
||||
else if( this.widgets_start_y != null )
|
||||
size[1] = Math.max( size[1], widgets_height + this.widgets_start_y );
|
||||
else
|
||||
size[1] += widgets_height;
|
||||
|
||||
var font_size = font_size;
|
||||
var title_width = compute_text_size(this.title);
|
||||
@@ -3223,6 +3209,27 @@
|
||||
size[0] = Math.max(size[0], LiteGraph.NODE_WIDTH * 1.5);
|
||||
}
|
||||
|
||||
size[1] = (this.constructor.slot_start_y || 0) + rows * LiteGraph.NODE_SLOT_HEIGHT;
|
||||
|
||||
var widgets_height = 0;
|
||||
if (this.widgets && this.widgets.length) {
|
||||
for (var i = 0, l = this.widgets.length; i < l; ++i) {
|
||||
if (this.widgets[i].computeSize)
|
||||
widgets_height += this.widgets[i].computeSize(size[0])[1] + 4;
|
||||
else
|
||||
widgets_height += LiteGraph.NODE_WIDGET_HEIGHT + 4;
|
||||
}
|
||||
widgets_height += 8;
|
||||
}
|
||||
|
||||
//compute height using widgets height
|
||||
if( this.widgets_up )
|
||||
size[1] = Math.max( size[1], widgets_height );
|
||||
else if( this.widgets_start_y != null )
|
||||
size[1] = Math.max( size[1], widgets_height + this.widgets_start_y );
|
||||
else
|
||||
size[1] += widgets_height;
|
||||
|
||||
if (this.onResize) {
|
||||
this.onResize(size);
|
||||
}
|
||||
@@ -5568,19 +5575,27 @@ LGraphNode.prototype.executeAction = function(action)
|
||||
this.resizing_node.inputs ? this.resizing_node.inputs.length : 0,
|
||||
this.resizing_node.outputs ? this.resizing_node.outputs.length : 0
|
||||
);
|
||||
var min_height =
|
||||
max_slots * LiteGraph.NODE_SLOT_HEIGHT +
|
||||
(this.resizing_node.widgets ? this.resizing_node.widgets.length : 0) * (LiteGraph.NODE_WIDGET_HEIGHT + 4) + 4;
|
||||
if (this.resizing_node.size[1] < min_height) {
|
||||
this.resizing_node.size[1] = min_height;
|
||||
}
|
||||
|
||||
if (this.resizing_node.size[0] < LiteGraph.NODE_MIN_WIDTH) {
|
||||
this.resizing_node.size[0] = LiteGraph.NODE_MIN_WIDTH;
|
||||
}
|
||||
|
||||
if (this.resizing_node.onResize) {
|
||||
this.resizing_node.onResize(this.resizing_node.size);
|
||||
}
|
||||
var widgets = this.resizing_node.widgets;
|
||||
var widgets_height = 0;
|
||||
if (widgets && widgets.length) {
|
||||
for (var i = 0, l = widgets.length; i < l; ++i) {
|
||||
if (widgets[i].computeSize)
|
||||
widgets_height += widgets[i].computeSize(this.resizing_node.size[0])[1] + 4;
|
||||
else
|
||||
widgets_height += LiteGraph.NODE_WIDGET_HEIGHT + 4;
|
||||
}
|
||||
widgets_height += 8;
|
||||
}
|
||||
|
||||
var min_height = max_slots * LiteGraph.NODE_SLOT_HEIGHT + widgets_height;
|
||||
if (this.resizing_node.size[1] < min_height) {
|
||||
this.resizing_node.size[1] = min_height;
|
||||
}
|
||||
|
||||
this.canvas.style.cursor = "se-resize";
|
||||
this.dirty_canvas = true;
|
||||
@@ -8418,7 +8433,7 @@ LGraphNode.prototype.executeAction = function(action)
|
||||
}
|
||||
break;
|
||||
}
|
||||
posY += H + 4;
|
||||
posY += (w.computeSize ? w.computeSize(width)[1] : H) + 4;
|
||||
ctx.globalAlpha = this.editor_alpha;
|
||||
|
||||
}
|
||||
@@ -8450,7 +8465,8 @@ LGraphNode.prototype.executeAction = function(action)
|
||||
var w = node.widgets[i];
|
||||
if(!w || w.disabled)
|
||||
continue;
|
||||
if ( w == active_widget || (x > 6 && x < width - 12 && y > w.last_y && y < w.last_y + LiteGraph.NODE_WIDGET_HEIGHT) ) {
|
||||
var widget_height = w.computeSize ? w.computeSize(width)[1] : LiteGraph.NODE_WIDGET_HEIGHT;
|
||||
if ( w == active_widget || (x > 6 && x < width - 12 && y > w.last_y && y < w.last_y + widget_height) ) {
|
||||
//inside widget
|
||||
switch (w.type) {
|
||||
case "button":
|
||||
@@ -8584,7 +8600,7 @@ LGraphNode.prototype.executeAction = function(action)
|
||||
break;
|
||||
default:
|
||||
if (w.mouse) {
|
||||
w.mouse(ctx, event, [x, y], node);
|
||||
this.dirty_canvas = w.mouse(event, [x, y], node);
|
||||
}
|
||||
break;
|
||||
} //end switch
|
||||
@@ -10084,25 +10100,30 @@ LGraphNode.prototype.executeAction = function(action)
|
||||
if (slot) {
|
||||
//on slot
|
||||
menu_info = [];
|
||||
if (
|
||||
slot &&
|
||||
slot.output &&
|
||||
slot.output.links &&
|
||||
slot.output.links.length
|
||||
) {
|
||||
menu_info.push({ content: "Disconnect Links", slot: slot });
|
||||
if (node.getSlotMenuOptions) {
|
||||
menu_info = node.getSlotMenuOptions(slot);
|
||||
} else {
|
||||
if (
|
||||
slot &&
|
||||
slot.output &&
|
||||
slot.output.links &&
|
||||
slot.output.links.length
|
||||
) {
|
||||
menu_info.push({ content: "Disconnect Links", slot: slot });
|
||||
}
|
||||
var _slot = slot.input || slot.output;
|
||||
menu_info.push(
|
||||
_slot.locked
|
||||
? "Cannot remove"
|
||||
: { content: "Remove Slot", slot: slot }
|
||||
);
|
||||
menu_info.push(
|
||||
_slot.nameLocked
|
||||
? "Cannot rename"
|
||||
: { content: "Rename Slot", slot: slot }
|
||||
);
|
||||
|
||||
}
|
||||
var _slot = slot.input || slot.output;
|
||||
menu_info.push(
|
||||
_slot.locked
|
||||
? "Cannot remove"
|
||||
: { content: "Remove Slot", slot: slot }
|
||||
);
|
||||
menu_info.push(
|
||||
_slot.nameLocked
|
||||
? "Cannot rename"
|
||||
: { content: "Rename Slot", slot: slot }
|
||||
);
|
||||
options.title =
|
||||
(slot.input ? slot.input.type : slot.output.type) || "*";
|
||||
if (slot.input && slot.input.type == LiteGraph.ACTION) {
|
||||
@@ -16650,6 +16671,7 @@ if (typeof exports != "undefined") {
|
||||
|
||||
(function(global) {
|
||||
var LiteGraph = global.LiteGraph;
|
||||
var LGraphCanvas = global.LGraphCanvas;
|
||||
|
||||
//Works with Litegl.js to create WebGL nodes
|
||||
global.LGraphTexture = null;
|
||||
@@ -23732,6 +23754,7 @@ function LGraphGeometryDisplace() {
|
||||
})(this);
|
||||
(function(global) {
|
||||
var LiteGraph = global.LiteGraph;
|
||||
var LGraphTexture = global.LGraphTexture;
|
||||
|
||||
//Works with Litegl.js to create WebGL nodes
|
||||
if (typeof GL != "undefined") {
|
||||
|
||||
1118
build/litegraph.min.js
vendored
1118
build/litegraph.min.js
vendored
File diff suppressed because it is too large
Load Diff
47
src/litegraph.d.ts
vendored
47
src/litegraph.d.ts
vendored
@@ -68,11 +68,12 @@ export interface IWidget<TValue = any, TOptions = any> {
|
||||
* https://github.com/jagenjo/litegraph.js/issues/76
|
||||
*/
|
||||
mouse?(
|
||||
ctx: undefined,
|
||||
event: MouseEvent,
|
||||
pos: Vector2,
|
||||
node: LGraphNode
|
||||
): void;
|
||||
): boolean;
|
||||
/** Called by `LGraphNode.computeSize` */
|
||||
computeSize?(width: number): [number, number];
|
||||
}
|
||||
export interface IButtonWidget extends IWidget<null, {}> {
|
||||
type: "button";
|
||||
@@ -433,6 +434,11 @@ export declare class LGraph {
|
||||
* @param node the instance of the node
|
||||
*/
|
||||
add(node: LGraphNode, skip_compute_order?: boolean): void;
|
||||
/**
|
||||
* Called when a new node is added
|
||||
* @param node the instance of the node
|
||||
*/
|
||||
onNodeAdded(node: LGraphNode): void;
|
||||
/** Removes a node from the graph */
|
||||
remove(node: LGraphNode): void;
|
||||
/** Returns a node by its id. */
|
||||
@@ -865,12 +871,12 @@ export declare class LGraphNode {
|
||||
|
||||
// https://github.com/jagenjo/litegraph.js/blob/master/guides/README.md#custom-node-appearance
|
||||
onDrawBackground?(
|
||||
canvas: HTMLCanvasElement,
|
||||
ctx: CanvasRenderingContext2D
|
||||
ctx: CanvasRenderingContext2D,
|
||||
canvas: HTMLCanvasElement
|
||||
): void;
|
||||
onDrawForeground?(
|
||||
canvas: HTMLCanvasElement,
|
||||
ctx: CanvasRenderingContext2D
|
||||
ctx: CanvasRenderingContext2D,
|
||||
canvas: HTMLCanvasElement
|
||||
): void;
|
||||
|
||||
// https://github.com/jagenjo/litegraph.js/blob/master/guides/README.md#custom-node-behaviour
|
||||
@@ -928,10 +934,23 @@ export declare class LGraphNode {
|
||||
onConnectInput?(
|
||||
inputIndex: number,
|
||||
type: INodeOutputSlot["type"],
|
||||
outputSlot: INodeOutputSlot
|
||||
outputSlot: INodeOutputSlot,
|
||||
_this: this,
|
||||
slotIndex: number
|
||||
): boolean;
|
||||
|
||||
/** a connection changed (new one or removed) (LiteGraph.INPUT or LiteGraph.OUTPUT, slot, true if connected, link_info, input_info or output_info ) */
|
||||
onConnectionsChange(
|
||||
type: number,
|
||||
slotIndex: number,
|
||||
isConnected: boolean,
|
||||
link: LLink,
|
||||
ioSlot: (INodeOutputSlot | INodeInputSlot)
|
||||
): void;
|
||||
|
||||
/** Called by `LGraphCanvas.processContextMenu` */
|
||||
getMenuOptions?(graphCanvas: LGraphCanvas): ContextMenuItem[];
|
||||
getSlotMenuOptions?(slot: INodeSlot): ContextMenuItem[];
|
||||
}
|
||||
|
||||
export type LGraphNodeConstructor<T extends LGraphNode = LGraphNode> = {
|
||||
@@ -1114,6 +1133,20 @@ export declare class LGraphCanvas {
|
||||
onDrawOverlay: ((ctx: CanvasRenderingContext2D) => void) | null;
|
||||
/** Called by `LGraphCanvas.processMouseDown` */
|
||||
onMouse: ((event: MouseEvent) => boolean) | null;
|
||||
/** Called by `LGraphCanvas.drawFrontCanvas` and `LGraphCanvas.drawLinkTooltip` */
|
||||
onDrawLinkTooltip: ((ctx: CanvasRenderingContext2D, link: LLink, _this: this) => void) | null;
|
||||
/** Called by `LGraphCanvas.selectNodes` */
|
||||
onNodeMoved: ((node: LGraphNode) => void) | null;
|
||||
/** Called by `LGraphCanvas.processNodeSelected` */
|
||||
onNodeSelected: ((node: LGraphNode) => void) | null;
|
||||
/** Called by `LGraphCanvas.deselectNode` */
|
||||
onNodeDeselected: ((node: LGraphNode) => void) | null;
|
||||
/** Called by `LGraphCanvas.processNodeDblClicked` */
|
||||
onShowNodePanel: ((node: LGraphNode) => void) | null;
|
||||
/** Called by `LGraphCanvas.processNodeDblClicked` */
|
||||
onNodeDblClicked: ((node: LGraphNode) => void) | null;
|
||||
/** Called by `LGraphCanvas.selectNodes` */
|
||||
onSelectionChange: ((nodes: Record<number, LGraphNode>) => void) | null;
|
||||
/** Called by `LGraphCanvas.showSearchBox` */
|
||||
onSearchBox:
|
||||
| ((
|
||||
|
||||
109
src/litegraph.js
109
src/litegraph.js
@@ -3173,20 +3173,6 @@
|
||||
var size = out || new Float32Array([0, 0]);
|
||||
rows = Math.max(rows, 1);
|
||||
var font_size = LiteGraph.NODE_TEXT_SIZE; //although it should be graphcanvas.inner_text_font size
|
||||
size[1] = (this.constructor.slot_start_y || 0) + rows * LiteGraph.NODE_SLOT_HEIGHT;
|
||||
|
||||
var widgets_height = 0;
|
||||
if (this.widgets && this.widgets.length) {
|
||||
widgets_height = this.widgets.length * (LiteGraph.NODE_WIDGET_HEIGHT + 4) + 8;
|
||||
}
|
||||
|
||||
//compute height using widgets height
|
||||
if( this.widgets_up )
|
||||
size[1] = Math.max( size[1], widgets_height );
|
||||
else if( this.widgets_start_y != null )
|
||||
size[1] = Math.max( size[1], widgets_height + this.widgets_start_y );
|
||||
else
|
||||
size[1] += widgets_height;
|
||||
|
||||
var font_size = font_size;
|
||||
var title_width = compute_text_size(this.title);
|
||||
@@ -3221,6 +3207,27 @@
|
||||
size[0] = Math.max(size[0], LiteGraph.NODE_WIDTH * 1.5);
|
||||
}
|
||||
|
||||
size[1] = (this.constructor.slot_start_y || 0) + rows * LiteGraph.NODE_SLOT_HEIGHT;
|
||||
|
||||
var widgets_height = 0;
|
||||
if (this.widgets && this.widgets.length) {
|
||||
for (var i = 0, l = this.widgets.length; i < l; ++i) {
|
||||
if (this.widgets[i].computeSize)
|
||||
widgets_height += this.widgets[i].computeSize(size[0])[1] + 4;
|
||||
else
|
||||
widgets_height += LiteGraph.NODE_WIDGET_HEIGHT + 4;
|
||||
}
|
||||
widgets_height += 8;
|
||||
}
|
||||
|
||||
//compute height using widgets height
|
||||
if( this.widgets_up )
|
||||
size[1] = Math.max( size[1], widgets_height );
|
||||
else if( this.widgets_start_y != null )
|
||||
size[1] = Math.max( size[1], widgets_height + this.widgets_start_y );
|
||||
else
|
||||
size[1] += widgets_height;
|
||||
|
||||
if (this.onResize) {
|
||||
this.onResize(size);
|
||||
}
|
||||
@@ -5566,19 +5573,27 @@ LGraphNode.prototype.executeAction = function(action)
|
||||
this.resizing_node.inputs ? this.resizing_node.inputs.length : 0,
|
||||
this.resizing_node.outputs ? this.resizing_node.outputs.length : 0
|
||||
);
|
||||
var min_height =
|
||||
max_slots * LiteGraph.NODE_SLOT_HEIGHT +
|
||||
(this.resizing_node.widgets ? this.resizing_node.widgets.length : 0) * (LiteGraph.NODE_WIDGET_HEIGHT + 4) + 4;
|
||||
if (this.resizing_node.size[1] < min_height) {
|
||||
this.resizing_node.size[1] = min_height;
|
||||
}
|
||||
|
||||
if (this.resizing_node.size[0] < LiteGraph.NODE_MIN_WIDTH) {
|
||||
this.resizing_node.size[0] = LiteGraph.NODE_MIN_WIDTH;
|
||||
}
|
||||
|
||||
if (this.resizing_node.onResize) {
|
||||
this.resizing_node.onResize(this.resizing_node.size);
|
||||
}
|
||||
var widgets = this.resizing_node.widgets;
|
||||
var widgets_height = 0;
|
||||
if (widgets && widgets.length) {
|
||||
for (var i = 0, l = widgets.length; i < l; ++i) {
|
||||
if (widgets[i].computeSize)
|
||||
widgets_height += widgets[i].computeSize(this.resizing_node.size[0])[1] + 4;
|
||||
else
|
||||
widgets_height += LiteGraph.NODE_WIDGET_HEIGHT + 4;
|
||||
}
|
||||
widgets_height += 8;
|
||||
}
|
||||
|
||||
var min_height = max_slots * LiteGraph.NODE_SLOT_HEIGHT + widgets_height;
|
||||
if (this.resizing_node.size[1] < min_height) {
|
||||
this.resizing_node.size[1] = min_height;
|
||||
}
|
||||
|
||||
this.canvas.style.cursor = "se-resize";
|
||||
this.dirty_canvas = true;
|
||||
@@ -8416,7 +8431,7 @@ LGraphNode.prototype.executeAction = function(action)
|
||||
}
|
||||
break;
|
||||
}
|
||||
posY += H + 4;
|
||||
posY += (w.computeSize ? w.computeSize(width)[1] : H) + 4;
|
||||
ctx.globalAlpha = this.editor_alpha;
|
||||
|
||||
}
|
||||
@@ -8448,7 +8463,8 @@ LGraphNode.prototype.executeAction = function(action)
|
||||
var w = node.widgets[i];
|
||||
if(!w || w.disabled)
|
||||
continue;
|
||||
if ( w == active_widget || (x > 6 && x < width - 12 && y > w.last_y && y < w.last_y + LiteGraph.NODE_WIDGET_HEIGHT) ) {
|
||||
var widget_height = w.computeSize ? w.computeSize(width)[1] : LiteGraph.NODE_WIDGET_HEIGHT;
|
||||
if ( w == active_widget || (x > 6 && x < width - 12 && y > w.last_y && y < w.last_y + widget_height) ) {
|
||||
//inside widget
|
||||
switch (w.type) {
|
||||
case "button":
|
||||
@@ -8582,7 +8598,7 @@ LGraphNode.prototype.executeAction = function(action)
|
||||
break;
|
||||
default:
|
||||
if (w.mouse) {
|
||||
w.mouse(ctx, event, [x, y], node);
|
||||
this.dirty_canvas = w.mouse(event, [x, y], node);
|
||||
}
|
||||
break;
|
||||
} //end switch
|
||||
@@ -10082,25 +10098,30 @@ LGraphNode.prototype.executeAction = function(action)
|
||||
if (slot) {
|
||||
//on slot
|
||||
menu_info = [];
|
||||
if (
|
||||
slot &&
|
||||
slot.output &&
|
||||
slot.output.links &&
|
||||
slot.output.links.length
|
||||
) {
|
||||
menu_info.push({ content: "Disconnect Links", slot: slot });
|
||||
if (node.getSlotMenuOptions) {
|
||||
menu_info = node.getSlotMenuOptions(slot);
|
||||
} else {
|
||||
if (
|
||||
slot &&
|
||||
slot.output &&
|
||||
slot.output.links &&
|
||||
slot.output.links.length
|
||||
) {
|
||||
menu_info.push({ content: "Disconnect Links", slot: slot });
|
||||
}
|
||||
var _slot = slot.input || slot.output;
|
||||
menu_info.push(
|
||||
_slot.locked
|
||||
? "Cannot remove"
|
||||
: { content: "Remove Slot", slot: slot }
|
||||
);
|
||||
menu_info.push(
|
||||
_slot.nameLocked
|
||||
? "Cannot rename"
|
||||
: { content: "Rename Slot", slot: slot }
|
||||
);
|
||||
|
||||
}
|
||||
var _slot = slot.input || slot.output;
|
||||
menu_info.push(
|
||||
_slot.locked
|
||||
? "Cannot remove"
|
||||
: { content: "Remove Slot", slot: slot }
|
||||
);
|
||||
menu_info.push(
|
||||
_slot.nameLocked
|
||||
? "Cannot rename"
|
||||
: { content: "Rename Slot", slot: slot }
|
||||
);
|
||||
options.title =
|
||||
(slot.input ? slot.input.type : slot.output.type) || "*";
|
||||
if (slot.input && slot.input.type == LiteGraph.ACTION) {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
(function(global) {
|
||||
var LiteGraph = global.LiteGraph;
|
||||
var LGraphTexture = global.LGraphTexture;
|
||||
|
||||
//Works with Litegl.js to create WebGL nodes
|
||||
if (typeof GL != "undefined") {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
(function(global) {
|
||||
var LiteGraph = global.LiteGraph;
|
||||
var LGraphCanvas = global.LGraphCanvas;
|
||||
|
||||
//Works with Litegl.js to create WebGL nodes
|
||||
global.LGraphTexture = null;
|
||||
|
||||
Reference in New Issue
Block a user