From b1ac27def9722a3f5f0cfafeca498c7259b60164 Mon Sep 17 00:00:00 2001 From: Ethanfel Date: Sun, 21 Jun 2026 18:48:26 +0200 Subject: [PATCH] feat: text gate server route + register TextGate Co-Authored-By: Claude Opus 4.8 --- __init__.py | 8 +++++--- gates/gate_server.py | 13 +++++++++++++ 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/__init__.py b/__init__.py index be141f7..17800b4 100644 --- a/__init__.py +++ b/__init__.py @@ -14,11 +14,13 @@ if __package__: NODE_DISPLAY_NAME_MAPPINGS as _LOADER_NAMES from .gates.gate import NODE_CLASS_MAPPINGS as _GATE_NODES, \ NODE_DISPLAY_NAME_MAPPINGS as _GATE_NAMES + from .gates.textgate import NODE_CLASS_MAPPINGS as _TEXT_NODES, \ + NODE_DISPLAY_NAME_MAPPINGS as _TEXT_NAMES from .gates import routes # noqa: F401 (registers aiohttp routes on import) - from .gates import gate_server # noqa: F401 (registers /datasete_gate/* routes) + from .gates import gate_server # noqa: F401 (registers /datasete_gate/* + text routes) - NODE_CLASS_MAPPINGS = {**_POOL_NODES, **_LOADER_NODES, **_GATE_NODES} - NODE_DISPLAY_NAME_MAPPINGS = {**_POOL_NAMES, **_LOADER_NAMES, **_GATE_NAMES} + NODE_CLASS_MAPPINGS = {**_POOL_NODES, **_LOADER_NODES, **_GATE_NODES, **_TEXT_NODES} + NODE_DISPLAY_NAME_MAPPINGS = {**_POOL_NAMES, **_LOADER_NAMES, **_GATE_NAMES, **_TEXT_NAMES} else: # pragma: no cover - exercised only under pytest collection NODE_CLASS_MAPPINGS = {} NODE_DISPLAY_NAME_MAPPINGS = {} diff --git a/gates/gate_server.py b/gates/gate_server.py index 43b020a..6dcce61 100644 --- a/gates/gate_server.py +++ b/gates/gate_server.py @@ -42,3 +42,16 @@ async def _mask(request): if node_id is not None: GateBus.put_mask(node_id, data) return web.json_response({}) + + +def send_text(node_id, text): + PromptServer.instance.send_sync( + "datasete-textgate-show", {"id": str(node_id), "text": text or ""} + ) + + +@routes.post("/datasete_text_gate/pass") +async def _text_pass(request): + post = await request.post() + GateBus.put_payload(post.get("id"), post.get("text", "")) + return web.json_response({})