diff --git a/__init__.py b/__init__.py new file mode 100644 index 0000000..0958cd0 --- /dev/null +++ b/__init__.py @@ -0,0 +1,10 @@ +"""Top-level package for ComfyUI-Scripting-Tools.""" + +from .src import NODE_CLASS_MAPPINGS, NODE_DISPLAY_NAME_MAPPINGS + +__all__ = [ + "NODE_CLASS_MAPPINGS", + "NODE_DISPLAY_NAME_MAPPINGS" +] + +__version__ = "1.0.0" diff --git a/pyproject.toml b/pyproject.toml index d1df2e1..c375542 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -8,6 +8,8 @@ dependencies = ["# No external dependencies required"] [project.urls] Repository = "https://github.com/cluny85/ComfyUI-Scripting-Tools" # Used by Comfy Registry https://comfyregistry.org +bugs = "https://github.com/cluny85/ComfyUI-Scripting-Tools/issues" +homepage = "https://github.com/cluny85/ComfyUI-Scripting-Tools" [tool.comfy] PublisherId = "cluny85" diff --git a/src/__init__.py b/src/__init__.py index 3798da4..bdf118d 100644 --- a/src/__init__.py +++ b/src/__init__.py @@ -1,6 +1,20 @@ from .enhanced_uuid_generator import ( - NODE_CLASS_MAPPINGS, - NODE_DISPLAY_NAME_MAPPINGS, + NODE_CLASS_MAPPINGS as enhanced_mappings, + NODE_DISPLAY_NAME_MAPPINGS as enhanced_display_mappings, +) +from .uuid_generator_node import ( + NODE_CLASS_MAPPINGS as uuid_mappings, + NODE_DISPLAY_NAME_MAPPINGS as uuid_display_mappings, ) +# Merge the mappings +NODE_CLASS_MAPPINGS = { + **enhanced_mappings, + **uuid_mappings +} +NODE_DISPLAY_NAME_MAPPINGS = { + **enhanced_display_mappings, + **uuid_display_mappings +} + __all__ = ["NODE_CLASS_MAPPINGS", "NODE_DISPLAY_NAME_MAPPINGS"] diff --git a/src/enhanced_uuid_generator.py b/src/enhanced_uuid_generator.py index 2a9d04f..895e489 100644 --- a/src/enhanced_uuid_generator.py +++ b/src/enhanced_uuid_generator.py @@ -2,6 +2,25 @@ import uuid class EnhancedUUIDGeneratorNode: + @classmethod + def INPUT_TYPES(cls): + return { + "required": { + "uuid_type": (["UUID1", "UUID3", "UUID4", "UUID5"], {"default": "UUID4"}), + "namespace_type": (["DNS", "URL", "OID", "X500", "CUSTOM"], {"default": "DNS"}), + "name_string": ("STRING", {"default": "example.com"}), + "trigger": ("INT", {"default": 0, "min": 0, "max": 1}), + }, + "optional": { + "custom_namespace_uuid": ("STRING", {"default": ""}), + "prefix": ("STRING", {"default": ""}), + "suffix": ("STRING", {"default": ""}) + } + } + + RETURN_TYPES = ("STRING",) + FUNCTION = "generate_uuid_enhanced" + CATEGORY = "ComfyUI-Scripting-Tools" def get_namespace(self, namespace_type, custom_namespace_uuid_str): if namespace_type == "DNS": @@ -16,13 +35,9 @@ class EnhancedUUIDGeneratorNode: try: return uuid.UUID(custom_namespace_uuid_str) except ValueError: - raise ValueError( - "Invalid custom namespace UUID string." - ) + raise ValueError("Invalid custom namespace UUID string.") else: - raise ValueError( - "Invalid namespace type." - ) + raise ValueError("Invalid namespace type.") def generate_uuid_enhanced( self, @@ -34,25 +49,22 @@ class EnhancedUUIDGeneratorNode: suffix="", trigger=0, ): - if trigger == 0: - return None - - namespace = self.get_namespace(namespace_type, custom_namespace_uuid) - + # Siempre genera el UUID, ignora trigger if uuid_type == "UUID1": generated_uuid = uuid.uuid1() - elif uuid_type == "UUID3": - generated_uuid = uuid.uuid3(namespace, name_string) elif uuid_type == "UUID4": generated_uuid = uuid.uuid4() + elif uuid_type == "UUID3": + namespace = self.get_namespace(namespace_type, custom_namespace_uuid) + generated_uuid = uuid.uuid3(namespace, name_string) elif uuid_type == "UUID5": + namespace = self.get_namespace(namespace_type, custom_namespace_uuid) generated_uuid = uuid.uuid5(namespace, name_string) else: - raise ValueError( - "Invalid UUID type." - ) + raise ValueError("Invalid UUID type") - return f"{prefix}{generated_uuid}{suffix}" + result = f"{prefix}{str(generated_uuid)}{suffix}" + return (result,) # ComfyUI expects a tuple # --- Mapeo para que ComfyUI reconozca el nodo --- diff --git a/src/uuid_generator_node.py b/src/uuid_generator_node.py index 2c8dda8..d9ad3fc 100644 --- a/src/uuid_generator_node.py +++ b/src/uuid_generator_node.py @@ -45,7 +45,7 @@ class UUIDGeneratorNode: # Define the category where the node will appear in ComfyUI's menu CATEGORY = ( - "utils/text" + "ComfyUI-Scripting-Tools" ) # You can change "utils/text" to your preference # Indicates if this node is a final output node (like SaveImage)