from typing import Protocol
from .page import PageOptions
from .components import COMPONENTS
from dataclasses import dataclass

@dataclass
class CtxEngine:
    """
    Base context for a page generated by an engine.

    Attributes:
        options (PageOptions): Configuration options for the page.
    """
    options: PageOptions


class Engine(Protocol):
    """
    Protocol that defines the interface for an engine responsible for generating
    pages and rendering components onto them.

    Implementations of this protocol should provide methods to create new pages
    and render components.
    """

    def new_page(self, options: PageOptions) -> CtxEngine:
        """
        Create a new page context based on the provided page options.

        Args:
            options (PageOptions): Configuration options for the page.

        Returns:
            CtxEngine: A new page context.
        """
        ...

    def make_component(self, ctx: CtxEngine, component: COMPONENTS):
        """
        Render a component onto the given page context.

        Args:
            ctx (CtxEngine): The page context to render the component onto.
            component (COMPONENTS): The component to render.
        """
        ...
