File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ import json
2+ from comfy .comfy_types .node_typing import IO
3+
4+ # Preview Any - original implement from
5+ # https://github.com/rgthree/rgthree-comfy/blob/main/py/display_any.py
6+ # upstream requested in https://github.com/Kosinkadink/rfcs/blob/main/rfcs/0000-corenodes.md#preview-nodes
7+ class PreviewAny ():
8+ @classmethod
9+ def INPUT_TYPES (cls ):
10+ return {
11+ "required" : {"source" : (IO .ANY , {})},
12+ }
13+
14+ RETURN_TYPES = ()
15+ FUNCTION = "main"
16+ OUTPUT_NODE = True
17+
18+ CATEGORY = "utils"
19+
20+ def main (self , source = None ):
21+ value = 'None'
22+ if isinstance (source , str ):
23+ value = source
24+ elif isinstance (source , (int , float , bool )):
25+ value = str (source )
26+ elif source is not None :
27+ try :
28+ value = json .dumps (source )
29+ except Exception :
30+ try :
31+ value = str (source )
32+ except Exception :
33+ value = 'source exists, but could not be serialized.'
34+
35+ return {"ui" : {"text" : (value ,)}}
36+
37+ NODE_CLASS_MAPPINGS = {
38+ "PreviewAny" : PreviewAny ,
39+ }
40+
41+ NODE_DISPLAY_NAME_MAPPINGS = {
42+ "PreviewAny" : "Preview Any" ,
43+ }
Original file line number Diff line number Diff line change @@ -2258,6 +2258,7 @@ def init_builtin_extra_nodes():
22582258 "nodes_optimalsteps.py" ,
22592259 "nodes_hidream.py" ,
22602260 "nodes_fresca.py" ,
2261+ "nodes_preview_any.py" ,
22612262 ]
22622263
22632264 api_nodes_dir = os .path .join (os .path .dirname (os .path .realpath (__file__ )), "comfy_api_nodes" )
You can’t perform that action at this time.
0 commit comments