yera.runtime.handlers.registry

Handler registry and render-environment detection for the Yera event rendering.

Symbols

def detect_render_env — Detect the rendering environment for the current process.
class EventHandlerRegistry — Maps block-type names to factories that construct their handlers.
class RenderEnv — Supported rendering environments for console output.

detect_render_env

detect_render_env() → RenderEnv

Detect 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

type: RenderEnv

The detected RenderEnv.

EventHandlerRegistry

Maps block-type names to factories that construct their handlers.

Methods

create — Construct a fresh handler for a single block.
build — Build a registry for the given target, auto-detecting if unspecified.

EventHandlerRegistry.create

create(
    block_type: str,
) → BaseHandler

Construct 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

block_type
type: str

The event block type to look up.

Returns

type: BaseHandler

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,
) → EventHandlerRegistry

Build a registry for the given target, auto-detecting if unspecified.

Parameters

env
type: RenderEnv | None = None

Force a target. Defaults to auto-detection (env var override, then Jupyter, then Kitty, then ANSI).

console
type: Console | None = None

The rich console object to use when printing to screen etc.

web_render
type: WebRenderContext | None = None

The render context to use when handling events -> HTMX.

RenderEnv

Inherits: Enum

Supported rendering environments for console output.