bug fix: undo bug on unpack, change: end input of slice
Fixed a bug that occurred with Unpack on Undo. Fixed behavior of end inputs for Slice Nodes; if 0, it is treated as 0 and an empty list is returned. WIP: DisplayList node
This commit is contained in:
@@ -55,7 +55,6 @@ const dynamic_connection = (node, index, event, prefix = 'in_', type = '*', name
|
||||
* @returns {Set} Unique set of all types used in the workflow
|
||||
*/
|
||||
function getWorkflowTypes(app) {
|
||||
// 実装
|
||||
const types = new Set(["*", "STRING", "INT", "FLOAT", "BOOLEAN", "IMAGE", "LATENT", "MASK", "NOISE", "SAMPLER", "SIGMAS", "GUIDER", "MODEL", "CLIP", "VAE", "CONDITIONING"])
|
||||
app.graph._nodes.forEach(node => {
|
||||
node.inputs.forEach(slot => {
|
||||
@@ -69,6 +68,27 @@ function getWorkflowTypes(app) {
|
||||
}
|
||||
|
||||
|
||||
function renderTable(data, container) {
|
||||
container.innerHTML = "" // Clear previous content
|
||||
const table = document.createElement("table")
|
||||
table.className = "comfy-table"
|
||||
|
||||
// Add headers
|
||||
const headerRow = table.insertRow()
|
||||
headerRow.insertCell().textContent = "Index"
|
||||
headerRow.insertCell().textContent = "Value"
|
||||
|
||||
// Populate rows
|
||||
data.forEach((item) => {
|
||||
const row = table.insertRow()
|
||||
row.insertCell().textContent = item.index
|
||||
row.insertCell().textContent = item.value
|
||||
});
|
||||
|
||||
container.appendChild(table)
|
||||
}
|
||||
|
||||
|
||||
app.registerExtension({
|
||||
name: "godmt.ListUtils",
|
||||
async beforeRegisterNodeDef(nodeType, nodeData, app) {
|
||||
@@ -355,7 +375,7 @@ app.registerExtension({
|
||||
for (let i = cur_len; i < output_len; i++) {
|
||||
this.addOutput(`${_prefix}_${i + 1}`, origin_inputs[i].type)
|
||||
}
|
||||
for (let i = 0; i < cur_len; i++) {
|
||||
for (let i = 0; i < cur_len && i < output_len; i++) {
|
||||
this.outputs[i].type = origin_inputs[i].type
|
||||
}
|
||||
}
|
||||
@@ -468,6 +488,29 @@ app.registerExtension({
|
||||
}
|
||||
return r
|
||||
}
|
||||
} else if (nodeData.name === "GODMT_DisplayList") {
|
||||
const onNodeCreated = nodeType.prototype.onNodeCreated
|
||||
nodeData.input.required.input_list[1].widget = "LIST_TABLE";
|
||||
nodeType.prototype.onNodeCreated = function () {
|
||||
onNodeCreated ? onNodeCreated.apply(this, []) : undefined
|
||||
// this.showValueWidget = ListTableWidget(this, "list_table", ["STRING", {}], app).widget
|
||||
this.showValueWidget = ComfyWidgets["STRING"](this, "list_table", ["STRING", { multiline: true }], app).widget
|
||||
}
|
||||
const onExecuted = nodeType.prototype.onExecuted
|
||||
nodeType.prototype.onExecuted = function (message) {
|
||||
onExecuted === null || onExecuted === void 0 ? void 0 : onExecuted.apply(this, [message])
|
||||
try {
|
||||
const data = JSON.parse(message.text[0])
|
||||
console.log(data)
|
||||
let text = ""
|
||||
data.forEach(d => {
|
||||
text += d.index + " : " + d.value + "\n"
|
||||
})
|
||||
this.showValueWidget.value = text
|
||||
} catch (e) {
|
||||
console.error("Error parsing list data:", e)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import numpy as np
|
||||
import itertools
|
||||
import json
|
||||
import numbers
|
||||
from pathlib import Path
|
||||
|
||||
@@ -172,8 +173,6 @@ class ListSlice:
|
||||
def run(self, ANY: list, start: list[int], end: list[int]):
|
||||
start = start[0]
|
||||
end = end[0]
|
||||
if end == 0:
|
||||
return (ANY[start:], )
|
||||
return (ANY[start:end], )
|
||||
|
||||
|
||||
@@ -197,8 +196,6 @@ class BatchSlice:
|
||||
CATEGORY = "list_utils"
|
||||
|
||||
def run(self, LIST: list, start: int, end: int):
|
||||
if end == 0:
|
||||
return (LIST[start:], )
|
||||
return (LIST[start:end], )
|
||||
|
||||
|
||||
@@ -790,6 +787,36 @@ class ListDir:
|
||||
items.sort()
|
||||
return (items, items, len(items))
|
||||
|
||||
""" WIP
|
||||
class DisplayList:
|
||||
def __init__(self):
|
||||
pass
|
||||
|
||||
@classmethod
|
||||
def INPUT_TYPES(self):
|
||||
return {
|
||||
"required": {
|
||||
"input_list": (ANY_TYPE, {"forceInput": True}),
|
||||
},
|
||||
}
|
||||
|
||||
TITLE = "Display List"
|
||||
RETURN_TYPES = ("STRING",)
|
||||
RETURN_NAMES = ("table_output",)
|
||||
FUNCTION = "run"
|
||||
CATEGORY = "list_utils"
|
||||
OUTPUT_NODE = True
|
||||
|
||||
def run(self, input_list):
|
||||
# Convert list to a format for frontend (e.g., JSON)
|
||||
if type(input_list) is list:
|
||||
pass
|
||||
else:
|
||||
input_list = [input_list]
|
||||
table_data = [{"index": i, "value": item} for i, item in enumerate(input_list)]
|
||||
return { "ui": {"text": (json.dumps(table_data) ,)}, "result": (json.dumps(table_data), ) }
|
||||
"""
|
||||
|
||||
|
||||
class Exec:
|
||||
def __init__(self):
|
||||
|
||||
Reference in New Issue
Block a user