SearchCtrlK

  • ↑↓navigate
  • ↵open
  • escclose

Can’t find it? Contact us

revealStream

Starts revealing root's content from nothing.

tsx
import { revealStream } from "@sdxc/ui/chat";

Usage

Starts revealing root's content from nothing. Text inside buttons and [data-stream-skip] is left whole, and whitespace between blocks is kept, so the finished reply is exactly the markup the server sent.

Signature

typescript
revealStream(root: HTMLElement, options?: StreamRevealOptions): StreamReveal

Returns the running reveal.

Parameters

ParameterTypeRequiredDescription
rootHTMLElementYesThe reply's element, already holding its final content.
optionsStreamRevealOptionsNoPace, completion callback and an abort signal.

Examples

tsx
revealStream(document.getElementById("reply-7")!, { onEnd: () => setIdle() })

The events, constants and types its module publishes, each imported from @sdxc/ui/chat too.

Interface

StreamRevealOptions

Options for revealStream.

MemberTypeRequiredDescription
intervalnumberNoMilliseconds between ticks. @default 32
onEnd(end: StreamRevealEnd) => voidNoCalled once, when the whole reply has shown or StreamReveal.stop ran.
signalAbortSignalNoStops the reveal where it is when aborted, as StreamReveal.stop does.
Interface

StreamReveal

A running reveal.

MemberTypeRequiredDescription
stopvoidYesFreezes the reply at what has shown; the rest of it stays out of the page.
Type

StreamRevealEnd

How a reveal finished.

typescript
type StreamRevealEnd = "done" | "stopped"
@sdxc/ui

Can’t find it? Contact us