# HtmlRenderEvent

A RenderEvent containing an HTML string.

## Signatures

```ts
export interface HtmlRenderEvent {
    readonly [RenderEventTypeId]: "html";
    readonly [HtmlRenderTransportBrand]: true;
    readonly html: string;
    readonly last: boolean;
    readonly toString: () => string;
    readonly valueOf: () => string;
}
```

```ts
export declare const HtmlRenderEvent: (html: string, last: boolean) => HtmlRenderEvent;
```

## Why

`HtmlRenderEvent` allows an HTML-producing renderer or stream to join Typed's
ordered SSR output without pretending its chunks are DOM nodes. This is the
HTML counterpart to `DomRenderEvent`, not a framework-specific adapter.

## Ownership and lifetime

The producing Fx owns chunk order, interruption, resource finalization, and
the decision to mark the final event. `last` is `true` only for the terminal
chunk. The event itself retains only its string and completion marker.

## Trust boundary

The HTML is branded renderer-owned transport. It is not sanitized and must
never be constructed from arbitrary application or user data. Ordinary
`html` template interpolations remain escaped; only a renderer that already
owns safe HTML serialization should call this constructor.

## Property: [[computed:[HtmlRenderTransportBrand]]]

Evidence that the string came from a renderer-owned serialization path.

## Property: [[computed:[HtmlRenderTransportBrand]]]: Why

Rejects structurally similar raw application objects at runtime.

## Property: [[computed:[HtmlRenderTransportBrand]]]: Ownership and lifetime

Immutable metadata; it does not sanitize or retain another value.

## Property: [[computed:[RenderEventTypeId]]]

HTML-output discriminant stored at the public RenderEvent key.

## Property: [[computed:[RenderEventTypeId]]]: Why

Separates server strings from DOM output.

## Property: [[computed:[RenderEventTypeId]]]: Ownership and lifetime

Immutable metadata owned by the event.

## Property: html

The rendered HTML string.

## Property: html: Why

Carries one ordered output chunk without pretending it is DOM.

## Property: html: Ownership and lifetime

The event owns the string; the producer owns stream ordering and cleanup.

## Property: last

Indicates if this is the last part of a chunked render.

## Property: last: Why

Ordered consumers can finalize one logical render without inspecting content.

## Property: last: Ownership and lifetime

Immutable producer-supplied metadata.

## Property: toString

Returns the HTML chunk for string-oriented consumers.

## Property: toString: Why

Integrates with ordinary serialization protocols.

## Property: toString: Ownership and lifetime

Returns the event-owned immutable string.

## Property: valueOf

Returns the HTML chunk as the event's primitive value.

## Property: valueOf: Why

Keeps HTML transport ergonomic without weakening its brand.

## Property: valueOf: Ownership and lifetime

Returns the event-owned immutable string.

## Examples

```ts
import { HtmlRenderEvent } from "@typed/template/RenderEvent"

const event = HtmlRenderEvent("<div>Hello</div>", true)

// Get the HTML string
const html = event.toString()

// Check if it's the last chunk
if (event.last) {
  console.log("Final chunk")
}
```

```ts
import { HtmlRenderEvent } from "@typed/template/RenderEvent"

// Create a single-chunk HTML event
const event = HtmlRenderEvent("<div>Hello</div>", true)

// Create a multi-chunk HTML event
const chunk1 = HtmlRenderEvent("<div>", false)
const chunk2 = HtmlRenderEvent("Hello", false)
const chunk3 = HtmlRenderEvent("</div>", true)
```
