from ralium._util import (
    FunctionType,
    ModuleType,
    Callable,
    Self,
    Any, 
    _RT
)

from ralium.window import Window

def _process_api_calldata(window: Window, calldata: list[Any]) -> list[Any]: ...

class WebApi:
    def __init__(self) -> None: ...
    def bridge(self, func: FunctionType, calldata: list[Any] | None = None) -> Any: ...

class WebBridge:
    def __init__(self, *functions: tuple[FunctionType]) -> None: ...
    def __str__(self) -> str: ...
    def new(self, function: FunctionType) -> None: ...
    def namespace(self, 
        alias: str, 
        *functions: tuple[FunctionType], 
        **named_functions: dict[str, FunctionType]
    ) -> None: ...
    def _function_template(self, name: str, string: str) -> str: ...
    
class WebApiNamespaceDict(dict):
    def add_namespace(self, namespace: ModuleType | dict[str, FunctionType]) -> None: ...

class WebApiFunctionDict(dict):
    def add_function(self, function: FunctionType) -> None: ...
    
class WebEngine:
    def __init__(self, window: Window) -> None: ...
    def __str__(self) -> str: ...

    @property
    def running(self) -> bool: ...
    def _init_server(self) -> tuple[int, Callable[..., _RT]]: ...
    def close(self) -> None: ...
    def create_api(engine: Self) -> WebApi: ...
    def create_event(self) -> Callable[..., _RT]: ...