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

markstream-core

v1.0.3

Published

Framework-agnostic smooth streaming controller and streaming text state utilities for Markstream

Readme

markstream-core

Framework-agnostic smooth streaming controller and streaming text state utilities for Markstream.

This package extracts the core pacing algorithm and streaming text resolution logic shared across all Markstream framework packages (Vue 3, Vue 2, React, Angular, Svelte).

Installation

npm install markstream-core

API

createSmoothMarkdownStream

Factory API for a framework-agnostic streaming controller with snapshot + subscribe semantics.

import { createSmoothMarkdownStream } from 'markstream-core'

const controller = createSmoothMarkdownStream({ minCharsPerSecond: 40, maxCharsPerSecond: 1000 })

const unsubscribe = controller.subscribe(() => {
  const snapshot = controller.getSnapshot()
  updateUI(snapshot.visible)
  if (snapshot.final)
    onStreamDone()
})

controller.enqueue(chunk)
controller.finish()
controller.flush()
controller.pause()
controller.resume()
controller.destroy()
controller.dispose() // alias of destroy()
unsubscribe()

SmoothMarkdownStreamController is the public controller interface type returned by createSmoothMarkdownStream.

Options (SmoothMarkdownStreamOptions)

| Option | Default | Description | |---|---|---| | minCharsPerSecond | 40 | Minimum reveal speed | | maxCharsPerSecond | 1000 | Maximum reveal speed | | targetLatencyMs | 900 | Target latency for pacing calculation | | catchUpLatencyMs | 350 | Latency threshold for catch-up mode | | catchUpThreshold | 600 | Character backlog that triggers catch-up | | maxCommitFps | 30 | Maximum commits per second | | startDelayMs | 80 | Delay before first reveal | | maxCharsPerCommit | 80 | Maximum characters per animation frame | | flushOnFinish | false | Auto-flush when finish() is called |

resolveStreamingTextState

Resolves the next streaming text state for simple append detection.

import { resolveStreamingTextState } from 'markstream-core'

const result = resolveStreamingTextState({
  nextContent: 'hello world',
  previousContent: 'hello',
  typewriterEnabled: true,
})
// result = { settledContent: 'hello', streamedDelta: ' world', appended: true }

resolveStreamingTextUpdate

Extended resolver that handles React StrictMode replay guards and stream version resets.

import { resolveStreamingTextUpdate } from 'markstream-core'

const result = resolveStreamingTextUpdate({
  nextContent: 'hello world!',
  currentState: { settledContent: 'hello', streamedDelta: ' world' },
  typewriterEnabled: true,
})

Shiki Highlighting Helpers

markstream-core exports shared helpers used by Markstream adapters to normalize Shiki language and theme options before calling stream-markdown.

import {
  getHighlightRegistrationKey,
  getRegisterHighlightOptions,
  getRuntimeShikiRegistrationConfig,
  getShikiLangs,
  getShikiRendererOptions,
  getShikiThemes,
  normalizeShikiLanguage,
  registerHighlightOnce,
} from 'markstream-core'
  • getShikiLangs(langs) normalizes common Shiki language aliases, removes duplicates, and sorts the result because language preload order has no priority semantics.
  • getShikiThemes(themes) keeps valid string themes, removes duplicates, and preserves caller order so theme priority is not changed.
  • getRegisterHighlightOptions(themes, langs) and getShikiRendererOptions(themes, langs) return normalized options for registerHighlight() and createShikiStreamRenderer().
  • getHighlightRegistrationKey(themes, langs) returns a normalized key. Language order is stable for equivalent preload sets, while theme order is preserved because renderer theme priority is order-sensitive.
  • getRuntimeShikiRegistrationConfig(themes, langs, options) returns framework-neutral runtime config for adapters that may have a renderer without registerHighlight().
  • registerHighlightOnce(registerHighlight, opts, key) coalesces in-flight registrations for the same registerHighlight function and key.

Framework Adapters

  • Vue 3: useSmoothMarkdownStream in markstream-vue wraps the core controller with Vue reactivity.
  • React / Vue 2 / Angular / Svelte: Framework packages depend on markstream-core internally. Import core APIs directly from markstream-core when needed.

License

MIT