@burnishdev/renderer
v0.4.1
Published
Streaming HTML renderer and component mapper for Burnish
Downloads
832
Maintainers
Readme
Install
npm install @burnishdev/rendererUsage
Parse a streaming chunk of LLM-generated HTML and append each element to the DOM as it arrives:
import {
findStreamElements,
appendStreamElement,
buildSanitizerConfig,
} from '@burnishdev/renderer';
import DOMPurify from 'dompurify';
const safeAttrs = buildSanitizerConfig();
const stack = [];
function onChunk(chunk, container) {
const elements = findStreamElements(chunk);
for (const el of elements) {
appendStreamElement(container, stack, el, safeAttrs, (html) =>
DOMPurify.sanitize(html, safeAttrs)
);
}
}Also exports inferComponent (map raw tool results to components), convertMarkdownToComponents (markdown fallback), and createValidator (validate component HTML).
What this is
The render engine for Burnish. It parses <burnish-*> tags out of a streaming byte stream, sanitizes them via a DOMPurify-compatible allowlist, and maps raw MCP tool results onto component suggestions. Used by both the demo UI and any app that wants to stream Burnish components from an LLM.
