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

@bietiaop/prender

v0.0.4

Published

无状态的基于 canvas 的 React 渲染器

Readme

Prender

基于 canvas 的无状态 React 渲染器,可以用于 NodeJS 的图片生成,不建议用于网页。

开始

安装依赖

需要 React 18 版本,暂不支持 19。

pnpm add @bietiaop/prender canvas react@18
pnpm add @types/react@18 --D

:::warning

安装 Canvas 需要 node-gyp 进行编译。

:::

如果你需要绘制 Echarts,需要安装 Echarts

npm install echarts

编写一个页面

import React from 'react';
import { View, Text } from '@bietiaop/prender';

export const App: React.FC = () => {
    return (
        <View style={{ marginTop: 20, padding: 10, backgroundColor: 'white', width: 460, border: '1px solid #ddd' }}>
            <Text style={{ fontSize: 20, marginBottom: 10 }}>多行文本布局示例</Text>
            <Text style={{ fontSize: 14, color: '#333', lineHeight: 22 }}>
                这是一段很长很长的文本,它将在这里演示自动换行的功能。当文本内容超出容器宽度时,它应该能优雅地切换到下一行,而不会溢出容器。这是所有现代UI框架都必须具备的基础能力。
            </Text>
            <Text style={{ fontSize: 14, color: '#333', lineHeight: 22, marginTop: 10, numberOfLines: 2 }}>
                这是一个关于省略号截断的例子。这段文字同样非常长,但是我们通过设置 numberOfLines 属性,将其限制在两行以内。如果内容超出了两行,那么在第二行的末尾就会出现一个省略号,像这样...
            </Text>
        </View>
    )
}

渲染

import React from 'react';
import path from 'path';
import { render } from '@bietiaop/prender';
import { App } from './app';

render(React.createElement(App), path.join(__dirname, './output/image.png'), 500, null, {
    createDir: true,
})

Echarts

如果想要渲染 Echarts,需要先安装 Echarts。

import React from 'react';
import { View, Text, Chart } from '@bietiaop/prender';
import * as echarts from 'echarts';
import type { EChartsOption } from 'echarts';

const chartOption: EChartsOption = {
  xAxis: {
    type: 'category',
    data: ['一月', '二月', '三月', '四月', '五月']
  },
  yAxis: {
    type: 'value'
  },
  series: [{
    data: [150, 230, 224, 218, 135],
    type: 'bar'
  }]
};

export const App: React.FC = () => {
    return (
        <View>
            <Text style={{ fontSize: 20, marginBottom: 10 }}>ECharts 图表示例</Text>
            <Chart
                style={{ width: 460, height: 300 }}
                option={chartOption}
                echarts={echarts}
            />
        </View>
    )
}