Fix 'Add Comfy Action' Sub Menu item

This commit is contained in:
rgthree
2023-09-06 23:54:55 -04:00
parent a698a335aa
commit ace25204cc
6 changed files with 24 additions and 20 deletions
+2 -1
View File
@@ -1,6 +1,7 @@
import { app } from "../../scripts/app.js";
import { BaseAnyInputConnectedNode } from "./base_any_input_connected_node.js";
import { NodeTypesString } from "./constants.js";
import { addMenuItem } from "./utils.js";
const MODE_ALWAYS = 0;
const MODE_MUTE = 2;
const MODE_BYPASS = 4;
@@ -217,7 +218,7 @@ FastActionsButton['@shortcutModifier'] = { type: 'combo', values: ['ctrl', 'alt'
FastActionsButton['@shortcutKey'] = { type: 'string' };
FastActionsButton.collapsible = false;
app.registerExtension({
name: "rgthree.FastButtonAction",
name: "rgthree.FastActionsButton",
registerCustomNodes() {
FastActionsButton.setUp(FastActionsButton);
},
-5
View File
@@ -125,11 +125,6 @@ export function getConnectionPosForLayout(node, isInput, slotNumber, out) {
console.log('No connection found.. weird', isInput, slotNumber);
return out;
}
if (cxn.hidden) {
out[0] = node.pos[0] - 100000;
out[1] = node.pos[1] - 100000;
return out;
}
if (cxn.disabled) {
if (cxn.color_on !== '#666665') {
cxn._color_on_org = cxn._color_on_org || cxn.color_on;
+4 -3
View File
@@ -6,6 +6,8 @@ import { RgthreeBaseNode } from "./base_node.js";
import { NodeTypesString } from "./constants.js";
import { ComfyApp, ComfyWidget } from "./typings/comfy.js";
import type {IWidget, LGraph, LGraphNode, SerializedLGraphNode} from './typings/litegraph.js';
import type {Constructor} from './typings/index.js'
import { addMenuItem } from "./utils.js";
const MODE_ALWAYS = 0;
const MODE_MUTE = 2;
@@ -279,10 +281,9 @@ class FastActionsButton extends BaseAnyInputConnectedNode {
}
static override setUp<T extends BaseAnyInputConnectedNode>(clazz: new(...args: any[]) => T) {
static override setUp<T extends BaseAnyInputConnectedNode>(clazz: Constructor<T>) {
BaseAnyInputConnectedNode.setUp(clazz);
// @ts-ignore: Fix incorrect litegraph typings.
addMenuItem(clazz, app, {
name: '➕ Append a Comfy Action',
callback: (nodeArg: LGraphNode) => {
@@ -296,7 +297,7 @@ class FastActionsButton extends BaseAnyInputConnectedNode {
app.registerExtension({
name: "rgthree.FastButtonAction",
name: "rgthree.FastActionsButton",
registerCustomNodes() {
FastActionsButton.setUp(FastActionsButton);
},
+2
View File
@@ -0,0 +1,2 @@
export type Constructor<T> = new(...args: any[]) => T;
+7 -6
View File
@@ -1,5 +1,6 @@
import type {ComfyApp} from './typings/comfy';
import {Vector2, LGraphCanvas as TLGraphCanvas, ContextMenuItem, LLink, LGraph, IContextMenuOptions, ContextMenu, LGraphNode as TLGraphNode, LiteGraph as TLiteGraph} from './typings/litegraph.js';
import type {Constructor} from './typings/index.js'
// @ts-ignore
import {api} from '../../scripts/api.js';
@@ -47,7 +48,7 @@ interface MenuConfig {
subMenuOptions?: string[];
}
export function addMenuItem(node: typeof LGraphNode, _app: ComfyApp, config: MenuConfig) {
export function addMenuItem(node: Constructor<TLGraphNode>, _app: ComfyApp, config: MenuConfig) {
const oldGetExtraMenuOptions = node.prototype.getExtraMenuOptions;
node.prototype.getExtraMenuOptions = function(canvas: TLGraphCanvas, menuOptions: ContextMenuItem[]) {
oldGetExtraMenuOptions && oldGetExtraMenuOptions.apply(this, [canvas, menuOptions]);
@@ -162,11 +163,11 @@ export function getConnectionPosForLayout(node: TLGraphNode, isInput: boolean, s
}
// Experimental; doesn't work without node.clip_area set (so it won't draw outside),
// but litegraph.core inexplicably clips the title off which we want... so, no go.
if (cxn.hidden) {
out[0] = node.pos[0] - 100000
out[1] = node.pos[1] - 100000
return out
}
// if (cxn.hidden) {
// out[0] = node.pos[0] - 100000
// out[1] = node.pos[1] - 100000
// return out
// }
if (cxn.disabled) {
// Let's store the original colors if have them and haven't yet overridden
if (cxn.color_on !== '#666665') {
+9 -5
View File
@@ -2,10 +2,14 @@
"compilerOptions": {
"target": "es2019",
"module": "ESNext",
"typeRoots": [
"./ts/typings",
],
"outDir": "./js/",
// "typeRoots": [
// "./ts/typings",
// ],
"baseUrl": "./",
"paths": {
"*": ["ts/typings/*"],
},
"outDir": "js/",
"removeComments": true,
"strict": true,
"noImplicitAny": true,
@@ -28,7 +32,7 @@
"skipLibCheck": true,
},
"include": [
"ts/*.ts",
"ts/*.ts", "ts/typings/index.d.ts",
],
"exclude": [
"**/*.spec.ts",