mirror of
https://git.datalinker.icu/comfyanonymous/ComfyUI
synced 2026-09-06 21:47:04 +08:00
Co-authored-by: comfyanonymous <comfyanonymous@protonmail.com> Co-authored-by: AustinMroz <austinmroz@utexas.edu> Co-authored-by: comfyanonymous <121283862+comfyanonymous@users.noreply.github.com> Co-authored-by: Benjamin Lu <benceruleanlu@proton.me> Co-authored-by: Andrew Kvochko <kvochko@users.noreply.github.com> Co-authored-by: Pam <42671363+pamparamm@users.noreply.github.com> Co-authored-by: chaObserv <154517000+chaObserv@users.noreply.github.com> Co-authored-by: Yoland Yan <4950057+yoland68@users.noreply.github.com> Co-authored-by: guill <guill@users.noreply.github.com> Co-authored-by: Chenlei Hu <hcl@comfy.org> Co-authored-by: Terry Jia <terryjia88@gmail.com> Co-authored-by: Silver <65376327+silveroxides@users.noreply.github.com> Co-authored-by: Christian Byrne <cbyrne@comfy.org> Co-authored-by: catboxanon <122327233+catboxanon@users.noreply.github.com> Co-authored-by: liesen <liesen.dev@gmail.com> Co-authored-by: Kohaku-Blueleaf <59680068+KohakuBlueleaf@users.noreply.github.com> Co-authored-by: Robin Huang <robin.j.huang@gmail.com> Co-authored-by: thot-experiment <thot@thiic.cc> Co-authored-by: thot experiment <94414189+thot-experiment@users.noreply.github.com>
44 lines
1.1 KiB
Python
44 lines
1.1 KiB
Python
import json
|
|
from comfy.comfy_types.node_typing import IO
|
|
|
|
# Preview Any - original implement from
|
|
# https://github.com/rgthree/rgthree-comfy/blob/main/py/display_any.py
|
|
# upstream requested in https://github.com/Kosinkadink/rfcs/blob/main/rfcs/0000-corenodes.md#preview-nodes
|
|
class PreviewAny():
|
|
@classmethod
|
|
def INPUT_TYPES(cls):
|
|
return {
|
|
"required": {"source": (IO.ANY, {})},
|
|
}
|
|
|
|
RETURN_TYPES = ()
|
|
FUNCTION = "main"
|
|
OUTPUT_NODE = True
|
|
|
|
CATEGORY = "utils"
|
|
|
|
def main(self, source=None):
|
|
value = 'None'
|
|
if isinstance(source, str):
|
|
value = source
|
|
elif isinstance(source, (int, float, bool)):
|
|
value = str(source)
|
|
elif source is not None:
|
|
try:
|
|
value = json.dumps(source)
|
|
except Exception:
|
|
try:
|
|
value = str(source)
|
|
except Exception:
|
|
value = 'source exists, but could not be serialized.'
|
|
|
|
return {"ui": {"text": (value,)}}
|
|
|
|
NODE_CLASS_MAPPINGS = {
|
|
"PreviewAny": PreviewAny,
|
|
}
|
|
|
|
NODE_DISPLAY_NAME_MAPPINGS = {
|
|
"PreviewAny": "Preview Any",
|
|
}
|