Source code for simvx.graphics.streaming

"""Web streaming backend: streams SimVX frames to browsers as JPEG over WebSocket.

Requires optional dependency::

    pip install simvx-graphics[streaming]   # aiohttp

Usage::

    from simvx.graphics.streaming import StreamingServer
"""

try:
    from .server import StreamingServer
except Exception:
    # Transitive deps (aiohttp) can raise non-ImportError at import time
    # on partially-broken installs, so the guard is intentionally broad. Fall through
    # to the friendly __getattr__ shim below so callers see the install hint instead
    # of a cryptic load error, but log it so a half-broken install is diagnosable.
    import logging

    logging.getLogger(__name__).debug("Streaming backend unavailable", exc_info=True)

__all__: list[str] = []
if "StreamingServer" in dir():
    __all__.append("StreamingServer")

if not __all__:
    _msg = "Streaming dependencies not installed. Install with: pip install simvx-graphics[streaming]"

    def __getattr__(name: str):
        raise ImportError(_msg)