Added Pandas Load JSON and Pandas Save JSON nodes.

This commit is contained in:
HowToSD
2025-02-16 18:44:51 -08:00
parent 0aa9586d8b
commit 24c1450c4c
6 changed files with 157 additions and 1 deletions
+36
View File
@@ -0,0 +1,36 @@
/*
This code is based on
https://github.com/pythongosssss/ComfyUI-Custom-Scripts/blob/main/web/js/showText.js
See credit/credit.md for the full license.
*/
import { app } from "../../../scripts/app.js";
import { ComfyWidgets } from "../../../scripts/widgets.js";
// Displays input text on a node
app.registerExtension({
name: "HowToSD.SaveJSON",
async beforeRegisterNodeDef(nodeType, nodeData, app) {
if (nodeData.name === "PandasSaveJSON") { // This needs to match NODE_CLASS_MAPPINGS in Python
function populate(text) {
// No op as we are not updating the node's UI for now.
}
// When the node is executed we will be sent the input text, display this in the widget
const onExecuted = nodeType.prototype.onExecuted;
nodeType.prototype.onExecuted = function (message) {
onExecuted?.apply(this, arguments);
populate.call(this, message.text);
};
const onConfigure = nodeType.prototype.onConfigure;
nodeType.prototype.onConfigure = function () {
onConfigure?.apply(this, arguments);
if (this.widgets_values?.length) {
populate.call(this, this.widgets_values.slice(+this.widgets_values.length > 1));
}
};
}
},
});