34 lines
1.1 KiB
Python
34 lines
1.1 KiB
Python
import re
|
|
# Add custom API routes, using router
|
|
# from aiohttp import web
|
|
# from server import PromptServer
|
|
|
|
# @PromptServer.instance.routes.get("/hello")
|
|
# async def get_hello(request):
|
|
# return web.json_response("hello")
|
|
|
|
|
|
# A dictionary that contains all nodes you want to export with their names
|
|
# NOTE: names should be globally unique
|
|
NODE_CLASS_MAPPINGS = {}
|
|
|
|
# A dictionary that contains the friendly/humanly readable titles for the nodes
|
|
NODE_DISPLAY_NAME_MAPPINGS = {}
|
|
|
|
def camel_to_spaced(s: str) -> str:
|
|
return re.sub(r'(?<=[a-z0-9])([A-Z])', r' \1', s)
|
|
|
|
def register_node(c):
|
|
assert not isinstance(c.RETURN_TYPES, str), "Error: string found instead of tuple."
|
|
assert not isinstance(c.RETURN_NAMES, str), "Error: string found instead of tuple."
|
|
NODE_CLASS_MAPPINGS[c.__name__] = c
|
|
NODE_DISPLAY_NAME_MAPPINGS[c.__name__] = camel_to_spaced(c.__name__)
|
|
return c
|
|
|
|
# Import all nodes
|
|
from .nodes import *
|
|
|
|
# Set the web directory, any .js file in that directory will be loaded by the frontend as a frontend extension
|
|
WEB_DIRECTORY = "./web"
|
|
|
|
__all__ = ['NODE_CLASS_MAPPINGS', 'NODE_DISPLAY_NAME_MAPPINGS', 'WEB_DIRECTORY'] |