npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@generative-dom/string-renderer

v0.4.0

Published

Generative DOM string renderer — render streaming markdown to HTML string in Node.js via jsdom

Readme

@generative-dom/string-renderer

Render Generative DOM streaming markdown to an HTML string in Node.js using jsdom.

Useful for testing (snapshot assertions, streaming parity checks), CLI pipelines (.genui → HTML), and any server-side scenario where you need the final rendered HTML without a real browser.

Installation

npm install --save-dev @generative-dom/string-renderer

Usage

Batch render

import { renderToString } from "@generative-dom/string-renderer";
import { markdownPreset } from "@generative-dom/preset-markdown";

const html = renderToString("# Hello\n\nWorld.", {
  plugins: markdownPreset(),
});
// → '<h1>Hello</h1><p>World.</p>'

Streaming render (stateful)

import { StringRenderer } from "@generative-dom/string-renderer";

const r = new StringRenderer({ plugins: markdownPreset() });

r.push("## Hel");
r.push("lo\n\n");
r.flush();

console.log(r.html()); // → '<h2>Hel</h2><p>lo</p>'
r.destroy();

Replay a recorded LLM stream

import { playRecording, StringRenderer } from "@generative-dom/string-renderer";

const recording = {
  chunks: [
    { text: "## ", ts: 0 },
    { text: "Hello\n\n", ts: 200 },
  ],
};

// Fast mode — join all chunks, single push + flush
const html = playRecording(recording, { plugins, mode: "fast" });

// Stepped mode — push & flush after each chunk, returns an array of HTML snapshots
const steps = playRecording(recording, { plugins, mode: "stepped" });
// steps[0] → '<h2></h2>'   (incomplete heading)
// steps[1] → '<h2>Hello</h2>'   (complete)

Real-time replay (debugging)

import { playRecordingRealtime } from "@generative-dom/string-renderer";

const html = await playRecordingRealtime(recording, {
  plugins,
  onProgress: (html, index) => console.log(`#${index}: ${html.length} chars`),
});

API

renderToString(markdown, options)

| Param | Type | Default | Description | | ------------------------ | ----------------------- | ------- | ----------------------------------- | | markdown | string | — | Markdown text to render | | options.plugins | GenerativeDomPlugin[] | — | Plugin list | | options.debounceMs | number | 0 | Render debounce interval | | options.timingProvider | TimingProvider | — | For deterministic scheduler control |

Returns string — rendered HTML.

new StringRenderer(options)

| Method | Description | | -------------- | ------------------------------------------------- | | .push(chunk) | Feed the next chunk of markdown text | | .flush() | Force an immediate render of all buffered content | | .html() | Get current rendered HTML | | .destroy() | Clean up DOM and JSDOM window |

playRecording(recording, options)

| Mode | Returns | Behaviour | | ----------- | ---------- | ---------------------------------------------------------- | | 'fast' | string | Join all chunks, single push + flush | | 'stepped' | string[] | Push & flush after each chunk; one HTML snapshot per chunk |

playRecordingRealtime(recording, options)

Returns Promise<string>. Respects the ts timestamps — real-time delays between chunks.

Notes

  • Each StringRenderer creates its own isolated JSDOM instance to avoid cross-test pollution.
  • The renderToString helper creates and destroys a renderer per call — convenient but slightly slower than reusing a StringRenderer for multiple chunks.
  • For deterministic streaming tests pass a timingProvider (see the SC-2 tests in the checks/ workspace for an example).