Provides wire-layer glue for the per-message `scrollAnchor` render hint, re-exporting the canonical constant and type alongside a wire-frame key and a validation parser so server and client code share a single source of truth. ## Key Components | Export | Kind | Description | |---|---|---| | `SCROLL_ANCHOR` | Re-export (const) | Canonical registry of valid scroll anchor values (`TOP`, `BOTTOM`) | | `ScrollAnchor` | Re-export (type) | TypeScript type derived from `SCROLL_ANCHOR` | | `SCROLL_ANCHOR_WIRE_KEY` | `const string` | Literal key `"scrollAnchor"` used on the metadata leading frame wire format | | `parseScrollAnchor` | `function` | Narrows an unknown wire value to `ScrollAnchor \| null` | ## Usage Example ```typescript import { SCROLL_ANCHOR, SCROLL_ANCHOR_WIRE_KEY, parseScrollAnchor, } from './scroll-anchor' // SERVER — emit into the metadata leading frame const metadataFrame = { ...(scrollAnchor ? { [SCROLL_ANCHOR_WIRE_KEY]: scrollAnchor } : {}), } // CLIENT — parse and validate incoming wire frame const parsed = parseScrollAnchor(frame[SCROLL_ANCHOR_WIRE_KEY]) if (parsed !== null) { // Safe to use: parsed is narrowed to ScrollAnchor applyScrollAnchor(parsed) // e.g. SCROLL_ANCHOR.TOP | SCROLL_ANCHOR.BOTTOM } // null is silently dropped by metadata-merge logic ``` ## Notes - Malformed or unrecognised wire values return `null` and are filtered out by metadata-merge logic — they never overwrite a previously valid anchor value. - Centralising `SCROLL_ANCHOR_WIRE_KEY` here means renaming the wire field requires a change in exactly one place.