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

@mini-dev/markdown-core

v0.0.1

Published

小程序里 LLM 流式 markdown 渲染库 —— 小程序 + 流式优先,性能是护城河

Readme

@mini-dev/markdown-core

小程序里 LLM 流式 Markdown 渲染库的核心包。增量解析 + Patch Diff + 局部 setData,避免逐 chunk 全量重渲染。

平台无关:core 只持端无关契约(PlatformAdapter / AdapterNode / MixedSegment 等类型),各端 adapter 独立成包。微信端见 @mini-dev/markdown-adapter-wechat;支付宝 / 抖音 adapter 可按同构各自独立成包。

1. 安装

npm i @mini-dev/markdown-core

小程序侧安装后在开发者工具执行「工具 → 构建 npm」,工具会读 package.json"miniprogram": "dist/cjs" 字段取产物。

2. 最小示例

const { createMarkdown } = require('@mini-dev/markdown-core');
const { createWeChatAdapter } = require('@mini-dev/markdown-adapter-wechat');

const md = createMarkdown();
const adapter = createWeChatAdapter();

// 静态渲染
const segments = adapter.irToMixedSegments(md.render(md.parse('# Hello\n\n正文')));

// 流式渲染
const stream = md.stream();
stream.on((patch) => {
  if (patch.kind === 'update') {
    // 异步回填:只替换 segments[patch.index]
  } else {
    // splice:按 [changedFrom, END) 整体替换
  }
});
stream.push('# Hel');
stream.push('lo\n\n正文');
stream.flush();

irToMixedSegments() 产出 rich-text / component / inline 三类段,页面模板按段分派(示例见仓库 sample-wechat/miniprogram/components/md-view/)。

3. 插件

md.use(plugin); // 或 createMarkdown({ plugins: [plugin] })

Plugin 一种形状收三个扩展点:rules(块解析规则)、transformPlugins(ast→ast)、rendererOverrides(渲染覆盖,同 type 折叠成 next 链)。

官方支持包:

4. 文档

5. License

MIT