import type { MessagePartRef } from './message-part.js'; /** Ref type for the streaming message part element. */ export interface MarkdownStreamRef { /** * React ref to attach to the MessagePart component. * * Typed as `MessagePartRef`, not `HTMLElement`, because `` wants * `Ref` — so the hook's own documented usage, * ``, did not type-check. The import is * type-only, so `@colletdev/react/markdown-stream` still pulls in no wrapper * at runtime. */ ref: React.RefObject; /** * Initialize the streaming parser. * Clears content and shows a blinking cursor. */ startStream: () => Promise; /** * Feed markdown tokens into the streaming parser. * Tokens are rAF-batched for performance. */ appendTokens: (text: string) => void; /** * End the stream. Flushes remaining tokens, removes cursor, * then runs a final WASM sanitization pass. */ endStream: () => Promise; } /** * Hook for streaming markdown into a MessagePart element. * * @example * ```tsx * import { MessagePart, useMarkdownStream } from '@colletdev/react'; * * function StreamingMessage() { * const { ref, startStream, appendTokens, endStream } = useMarkdownStream(); * * async function handleSSE() { * await startStream(); * const source = new EventSource('/api/chat'); * source.onmessage = (e) => appendTokens(e.data); * source.addEventListener('done', async () => { * source.close(); * await endStream(); * }); * } * * return ; * } * ``` */ export declare function useMarkdownStream(): MarkdownStreamRef;