- StyleWeightNode: now takes style_id (not raw string) + weight,
outputs style_entry JSON {style_id, weight} and a preview weighted_value string
- StyleBlendNode: takes style_entry JSON slots (Autogrow), carries style_id
references so the blend can be saved as a mix; adds two combos:
on_duplicate: Skip (keep first|last) / Sum weights / Average weights
weight_mode: As-is / Normalize (sum 1.0) / Normalize (max 1.0) / Equal weights
outputs blend_json (array of {style_id,weight}) + assembled prompt string
- SaveMixNode (new): takes blend_json + name + mode combo (Create /
Update by name); writes or overwrites a mix in style_mixer_data.json
65 lines
2.2 KiB
Python
65 lines
2.2 KiB
Python
"""Top-level entry point for ComfyUI-ImmacStyleMixer."""
|
|
|
|
import os
|
|
import server
|
|
from aiohttp import web
|
|
import nodes
|
|
|
|
from comfy_api.latest import ComfyExtension, io
|
|
|
|
from .src.immac_tools.api import register_routes
|
|
from .src.immac_tools.style_mix_node import StyleMixNode
|
|
from .src.immac_tools.style_create_node import StyleCreateNode
|
|
from .src.immac_tools.style_modify_node import StyleModifyNode
|
|
from .src.immac_tools.style_pick_node import StylePickNode
|
|
from .src.immac_tools.style_weight_node import StyleWeightNode
|
|
from .src.immac_tools.style_blend_node import StyleBlendNode
|
|
from .src.immac_tools.save_mix_node import SaveMixNode
|
|
|
|
|
|
class ImmacStyleMixerExtension(ComfyExtension):
|
|
async def get_node_list(self) -> list[type[io.ComfyNode]]:
|
|
return [
|
|
StyleMixNode,
|
|
StyleCreateNode,
|
|
StyleModifyNode,
|
|
StylePickNode,
|
|
StyleWeightNode,
|
|
StyleBlendNode,
|
|
SaveMixNode,
|
|
]
|
|
|
|
|
|
async def comfy_entrypoint() -> ImmacStyleMixerExtension:
|
|
return ImmacStyleMixerExtension()
|
|
|
|
workspace_path = os.path.dirname(__file__)
|
|
dist_path = os.path.join(workspace_path, "dist", "immac_style_mixer")
|
|
dist_locales_path = os.path.join(workspace_path, "dist", "locales")
|
|
|
|
if os.path.exists(dist_path):
|
|
server.PromptServer.instance.app.add_routes([
|
|
web.static("/immac_style_mixer/", dist_path),
|
|
])
|
|
if os.path.exists(dist_locales_path):
|
|
server.PromptServer.instance.app.add_routes([
|
|
web.static("/locales/", dist_locales_path),
|
|
])
|
|
|
|
project_name = os.path.basename(workspace_path)
|
|
try:
|
|
from comfy_config import config_parser
|
|
project_config = config_parser.extract_node_configuration(workspace_path)
|
|
project_name = project_config.project.name
|
|
except Exception as e:
|
|
print(f"[ImmacStyleMixer] Could not load project config, using '{project_name}': {e}")
|
|
|
|
nodes.EXTENSION_WEB_DIRS[project_name] = os.path.join(workspace_path, "dist")
|
|
else:
|
|
print("[ImmacStyleMixer] Web dist directory not found — skipping static file registration.")
|
|
|
|
# Always register API routes (data endpoints work even before the UI is built)
|
|
register_routes(server.PromptServer.instance.app, workspace_path)
|
|
|
|
|