# switch_path_rev.py from server import PromptServer from comfy_execution.graph_utils import ExecutionBlocker class AnyType(str): """Wildcard type to accept any input/output type""" def __ne__(self, __value: object) -> bool: return False def __eq__(self, __value: object) -> bool: return True def __str__(self): return "*" ANY_TYPE = AnyType("*") class SwitchPathRev: @classmethod def INPUT_TYPES(cls): return { "required": { "state": ("BOOLEAN", {"default": True}), "input": (ANY_TYPE, {"lazy": True}), }, "hidden": {"unique_id": "UNIQUE_ID"}, } RETURN_TYPES = (ANY_TYPE, ANY_TYPE) RETURN_NAMES = ("on_true", "on_false") FUNCTION = "execute" CATEGORY = "flow control" def check_lazy_status(self, input=None, state=None, **kwargs): """Indique à ComfyUI quelles sorties sont nécessaires selon le state""" if state: return ["on_true"] # Besoin seulement de on_true else: return ["on_false"] # Besoin seulement de on_false def execute(self, state, input=None, unique_id=None, **kwargs): # Détermine les valeurs pour chaque sortie if state: on_true_output = input on_false_output = ExecutionBlocker(None) if input is not None else None active_path = "on_true" inactive_path = "on_false" else: on_true_output = ExecutionBlocker(None) if input is not None else None on_false_output = input active_path = "on_false" inactive_path = "on_true" # --- Affichage live sous le node --- if unique_id: try: html_text = ( f"State: {str(state).upper()}
" f"Active Output: {active_path}
" f"Inactive Output: {inactive_path}
" f"Lazy Skip: inactive branch blocked" ) PromptServer.instance.send_progress_text(html_text, unique_id) except Exception: pass return (on_true_output, on_false_output) # Node registration NODE_CLASS_MAPPINGS = { "SwitchPathRev": SwitchPathRev } NODE_DISPLAY_NAME_MAPPINGS = { "SwitchPathRev": "Switch Path Rev (1→2 Lazy)" } __all__ = ['NODE_CLASS_MAPPINGS', 'NODE_DISPLAY_NAME_MAPPINGS']