From 6a95dfc9bbecdd48573888809eb4c923733939c4 Mon Sep 17 00:00:00 2001 From: pythongosssss <125205205+pythongosssss@users.noreply.github.com> Date: Sat, 14 Oct 2023 13:09:39 +0100 Subject: [PATCH] Add ws event handling --- web/extensions/core/groupNode.js | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/web/extensions/core/groupNode.js b/web/extensions/core/groupNode.js index a8da0b9ca..dda960e3c 100644 --- a/web/extensions/core/groupNode.js +++ b/web/extensions/core/groupNode.js @@ -1,4 +1,5 @@ import { app } from "../../scripts/app.js"; +import { api } from "../../scripts/api.js"; import { getWidgetType } from "../../scripts/widgets.js"; const IS_GROUP_NODE = Symbol(); @@ -295,6 +296,28 @@ const ext = { new ConvertToGroupAction().addOption(options, options.length); return options; }; + + api.addEventListener("executing", ({ detail }) => { + if (detail) { + const node = app.graph.getNodeById(detail); + if (!node) { + const split = detail.split(":"); + if (split.length === 2) { + api.dispatchEvent(new CustomEvent("executing", { detail: split[0] })); + } + } + } + }); + + api.addEventListener("executed", ({ detail }) => { + const node = app.graph.getNodeById(detail.node); + if (!node) { + const split = detail.node.split(":"); + if (split.length === 2) { + api.dispatchEvent(new CustomEvent("executed", { detail: { ...detail, node: split[0] } })); + } + } + }); }, async beforeConfigureGraph(graphData) { const groupNodes = graphData?.extra?.groupNodes; @@ -399,7 +422,7 @@ const ext = { } // Reconnect outputs - for (let outputId = 0; outputId < node.outputs.length; outputId++) { + for (let outputId = 0; outputId < node.outputs?.length; outputId++) { const output = node.outputs[outputId]; if (!output.links) continue; for (const l of output.links) { @@ -418,7 +441,7 @@ const ext = { return getExtraMenuOptions?.apply(this, arguments); }; - node.updateLink = function (link, innerNodes) { + node.updateLink = function (link) { // Replace the group node reference with the internal node link = { ...link }; const output = slots.outputs[link.origin_slot];