revealStream
Starts revealing root's content from nothing.
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
revealStream(root: HTMLElement, options?: StreamRevealOptions): StreamRevealReturns the running reveal.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
root | HTMLElement | Yes | The reply's element, already holding its final content. |
options | StreamRevealOptions | No | Pace, completion callback and an abort signal. |
Examples
revealStream(document.getElementById("reply-7")!, { onEnd: () => setIdle() })Used with it
The events, constants and types its module publishes, each imported from @sdxc/ui/chat too.
Interface
StreamRevealOptions
Options for revealStream.
| Member | Type | Required | Description |
|---|---|---|---|
interval | number | No | Milliseconds between ticks. @default 32 |
onEnd | (end: StreamRevealEnd) => void | No | Called once, when the whole reply has shown or StreamReveal.stop ran. |
signal | AbortSignal | No | Stops the reveal where it is when aborted, as StreamReveal.stop does. |
Interface
StreamReveal
A running reveal.
| Member | Type | Required | Description |
|---|---|---|---|
stop | void | Yes | Freezes the reply at what has shown; the rest of it stays out of the page. |
Type
StreamRevealEnd
How a reveal finished.
type StreamRevealEnd = "done" | "stopped"