Publish workflows only if there's a related sink node in the graph

This commit is contained in:
Acly
2024-10-02 17:56:19 +02:00
parent 5a45172d02
commit fb847a5225
+34 -14
View File
@@ -1,20 +1,40 @@
import { app } from "/scripts/app.js";
import { api } from "/scripts/api.js";
(function() {
let publisherRegistered = false;
async function publishWorkflow(e) {
const prompt = await app.graphToPrompt();
await api.fetchApi("/api/etn/workflow/publish", {
method: "POST",
body: JSON.stringify({
name: "ComfyUI Web",
client_id: api.clientId,
workflow: prompt["output"]
}, null, 2)
});
}
app.registerExtension({
name: "external_tooling_nodes",
init() {
api.addEventListener('graphChanged', async (e) => {
const prompt = await app.graphToPrompt();
console.log('graphChanged', prompt);
api.fetchApi("/api/etn/workflow/publish", {
method: "POST",
body: JSON.stringify({
name: "ComfyUI Web",
client_id: api.clientId,
workflow: prompt["output"]
}, null, 2)
});
});
}
nodeCreated(node /*: ComfyNode */, app /*: ComfyApp */) {
if (publisherRegistered || node.comfyClass !== "ETN_KritaOutput") {
return;
}
console.log("nodeCreated");
api.addEventListener('graphChanged', publishWorkflow);
publisherRegistered = true;
},
setup(app) {
if (publisherRegistered) {
publishWorkflow(null);
}
},
});
})();