# TemplateContext

Advanced per-template DOM rendering state used by renderer extensions.

## Signatures

```ts
export type TemplateContext<R = never> = {
    readonly document: Document;
    readonly renderQueue: RQ.RenderQueue;
    readonly disposables: Set<Disposable>;
    readonly eventSource: EventSource;
    readonly refCounter: IndexRefCounter;
    readonly scope: Scope.Closeable;
    readonly eventScope: Scope.Scope;
    readonly disposeEventHandlers: boolean;
    readonly values: ArrayLike<Renderable<unknown, any, any>>;
    readonly services: Context.Context<R | Scope.Scope>;
    readonly onCause: (cause: Cause.Cause<any>) => Effect.Effect<unknown>;
    readonly hydrateContext: HydrateContext | undefined;
};
```

## Why

The context gathers explicit Effect services, a forked child Scope, delegated
native events, queue policy, ref coordination, and optional hydration state
without relying on a hidden component tree.

## Ownership and lifetime

The child `scope` owns one-shot render setup. The surrounding `eventScope`
owns mounted dynamic parts, handler fibers, queued callbacks, and ref
finalizers until the rendered range is unmounted. Replaceable parts create
their own child event Scope so replacement disposes only that part.

## Examples

```ts
import type { TemplateContext } from "@typed/template/Render"

declare const context: TemplateContext
context.renderQueue
```
