yera.runtime.handlers.registry
Select a render target and construct its block-handler registry.
Console and notebook targets are detected from the process environment. Browser rendering is selected explicitly by supplying a web rendering context.
Symbols
detect_render_env
detect_render_env() → RenderEnvDetect the rendering environment for the current process.
Checks, in order: YERA_RENDERER env-var override, Jupyter kernel, Kitty-protocol terminal, then falls back to plain ANSI.
Returns
The detected RenderEnv.
EventHandlerRegistry
Maps block-type names to factories that construct their handlers.
Methods
EventHandlerRegistry.__init__
__init__(
factories: dict[str, HandlerFactory],
fallback: HandlerFactory,
)Initialize a registry from block-specific and fallback factories.
Parameters
Block types mapped to factories that create fresh handlers.
Factory used for block types absent from the mapping.
EventHandlerRegistry.create
create(
block_type: str,
) → BaseHandlerConstruct a fresh handler for a single block.
A handler's lifetime is one block: the router constructs it when the
block opens and discards it when the block ends. Handlers therefore
hold per-block state directly rather than resetting it in __enter__.
Parameters
The event block type to look up.
Returns
A new handler, or a new fallback handler if unregistered.
EventHandlerRegistry.build
build(
env: RenderEnv | None = None,
console: Console | None = None,
web_render: WebRenderContext | None = None,
) → EventHandlerRegistryBuild a registry for the given target, auto-detecting if unspecified.
Parameters
Force a target. Defaults to auto-detection (env var override, then Jupyter, then Kitty, then ANSI).
The rich console object to use when printing to screen etc.
The render context to use when handling events -> HTMX.
Returns
A registry populated with handlers for the selected environment.
Raises
If an unsupported rendering environment is requested.
RenderEnv
EnumIdentify console and notebook targets selected by environment detection.
Browser rendering is selected separately when the registry receives a web rendering context.