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

@supernathaniel/runtime-react

v0.2.0

Published

React 16.14/18 Profiler instrumentation for @fp runtimes

Readme

@supernathaniel/runtime-react

React 渲染采集与离线分析:把每次 commit 耗时变成事件,把事件变成可读的渲染诊断。

提供什么

  • PerformanceProfiler:用 React.Profiler 包裹根节点,每次 commit 发出 react:commit 事件(actualDuration / baseDuration 等)。生产构建的 React 不触发 Profiler 回调,透明传递。
  • fpProfile(Component, meta):构建期 babel 注入(@supernathaniel/babel-plugin-fp-profiler)的运行时承接(docs/PROFILER_AUTOWRAP.md)。模块求值期检查 window.__fp?.runtime,不存在则 fail-open 原样返回组件(零包装零开销);存在时内部复用 PerformanceProfiler(react:commit 事件形状零改动),forwardRef 透传(ref 为空时不向被包组件传 ref)、displayName 按 §4.3 补全、自定义静态属性白名单反集式拷贝。
    • M1 commit attribution(docs/WHY_ATTRIBUTION.md V2-D2):录制窗内(迟绑定读 window.__fp?.isRecording?.(),API 缺席 = 关闭)把渲染触发证据并入同一条 react:commit 的 data.attribution——每次 render 创建不可变 candidate(预算内有界 diff 快照 + forwarded ref 恒等比较)并由「committed onRender 闭包」消费,boundaryInstanceId 按 mount 唯一,origin 区分 wrapper(父层传播)/ subtree(后代提交,无 prop 证据)。变化分类见 PropChangeKind(attribution.ts):比较 descriptor-only、预算有界(8 key / 64 字符 / 8 自有项;50 条/实例 + 2000 条/会话),Proxy/getter/自定义 prototype/异常/超预算一律降级 reference-change + comparisonSkipped,不执行用户代码、不落 props 值。非录制路径 O(1) 早退(只创建 token+闭包与 baseline 引用存储)。远程上传经 runtime-core uploadWhitelist 不放行该字段。
  • useRenderProbe:组件级渲染探针(只在 passive effect 发事件,props 引用比较过滤挂载/重放噪声)。
  • analyzeRenderEvents(events):离线分析 react:commit 事件流,产出 RenderAnalysis——CommitGroup / ComponentStat / RenderFinding(FindingLevel 分级),viewer 与 playground 共用。M2:repeat-render 只计数 wrapper-origin 与无归因提交(origin:subtree 子树自驱提交排除,排除数见 evidence.subtreeRendersExcluded),ComponentStat.originRenders 拆分提交来源;有归因组件逐次指名 props 变化时消解该 finding,零归因组件保持旧文案兼容。
  • 辅助:probeDevtoolsHook()(React DevTools hook 能力探测)、diffProps()、toCommitEvent()(commit → 事件的纯函数映射,可无渲染器测试)。

兼容性

  • React 16.14 与 React 18 双一等公民:类型按 @types/react@16(最小公分母),只用两版共有的公共 API;
  • react 永远是 peer 依赖(宿主单例);Fiber 私有 API 只允许出现在明确标记的适配层,不进公共契约;
  • commit 事件同步发出(在 commit 阶段):trace 保真优先。监听方若在 commit 阶段直接 setState 会造成无限循环——消费方需轮询缓冲或节流(范式见 playground App.tsx),并 memoize profiler 子树避免被动重渲染自产事件。

谁依赖它

umi-plugin(rootContainer 注入)、viewer / playground(渲染分析)。