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

@flyteng/jsondataview

v0.0.2

Published

Embeddable JSON structure graph visualization SDK based on React Flow and Graphviz

Readme

@flyteng/jsondataview

将任意 JSON 展开为可交互图结构的嵌入式可视化 SDK(React Flow + Graphviz WASM)。

安装

npm install @flyteng/jsondataview

Peer Dependencies

宿主需自行安装:

  • react ^18
  • react-dom ^18
  • reactflow ^11
  • antd ^5
  • styled-components ^6

快速开始

<div id="jsonview_container" style="width:100%;height:600px;"></div>
import JsonCore from '@flyteng/jsondataview'

const view = new JsonCore({
  containerId: 'jsonview_container',
  defaultTheme: 'light',
  data: {
    name: 'demo',
    items: [{ id: 1 }, { id: 2 }],
  },
  onNodeClick: (node) => console.log(node),
  onError: (err) => console.error(err),
})

// 后续更新数据
await view.setData({ hello: ['world'] })
view.centerView()
view.setTheme('dark')

构造参数 (IJsonCoreOptions)

| 字段 | 类型 | 说明 | |------|------|------| | containerId | string | 挂载 DOM id(必填) | | data | unknown | 初始 JSON | | defaultTheme | 'light' \| 'dark' | 默认主题 | | drawerWidth / dawerWidth | number | 详情抽屉宽度,默认 360(后者为兼容拼写) | | menuList | INodeMenuItem[] | 自定义节点菜单 | | layoutOptions | Partial<ILayoutOptions> | Graphviz 布局参数 | | onMounted | (instance) => void | 画布就绪 | | onNodeClick / onEdgeClick | 回调 | 节点/边点击;未传 onNodeClick 时,点击节点会打开详情抽屉展示节点 JSON | | onDrawerClose | () => void | 详情抽屉关闭时回调 | | onThemeChange | (theme) => void | 主题切换 | | onError | (error: Error) => void | 布局/数据错误 | | 其他 on* | 可选 | 与历史 API 兼容 |

实例方法

| 方法 | 说明 | |------|------| | setData(data) | 设置 JSON 并重新布局(Promise) | | getData() | 获取当前 ReactFlow nodes | | getInstance() | 获取命令式 instance | | formatView() | 格式化视图 | | centerView() | 适应画布 | | setCenterByNode() | 定位到默认中心 | | setTheme('light'\|'dark') | 切换主题 | | openLoading() / closeLoading() | Loading | | destroy() | 卸载(新增) |

扩展

  • 自定义节点类型import { registerNodeType } from '@flyteng/jsondataview'
  • 布局参数:通过 layoutOptions 覆盖 rankdir / scale / ranksep 等(默认行为与历史版本一致)

开发

npm start          # Demo
npm test           # 单测
npm run build-sdk  # 产出 dist/

目录结构(源码)

src/
  api/         # 公开类型
  core/        # FlowCanvas / helpers
  layout/      # LayoutEngine(Graphviz WASM)
  transform/   # jsonToGraph
  nodes/       # 节点组件 + 注册表
  ui/          # 工具栏 / Loading / 菜单
  theme/       # 主题 token
  utils/       # 纯函数工具