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 🙏

© 2024 – Pkg Stats / Ryan Hefner

@comall/work-in-progress

v1.1.3

Published

可视化协议转换 ReactElement 的基础库

Downloads

4

Readme

WorkInProgress

可视化协议转换 ReactElement 的基础库,并应用于任何基于 react-reconciler 实现的渲染器。

Class

WorkInProgress 构造函数接收一个组件Map,key为协议定义的名,value为组件。

new WorkInProgress({
  'view': View
});

WorkInProgress 实例方法:

  • transformIntoReactElement,接收 CoMallElement,返回 ReactElement
  • transformIntoCoMallElement 接收 ReactElement Tree,返回 CoMallElement
  • registerComponent 注册一个组件,参数为key,component

警告:Tree 层级被限制为三层,超过三层的 CoMallElement将会被忽略

WorkInProgress 使用案例可访问:WorkInProgress

Function

  • createCoMallElement 函数,创建并返回一个 CoMallElement。
createCoMallElement(
  type,
  [props],
  [...children]
)

创建并返回指定类型的新的 CoMallElement,其中type参数类型必须为字符串。

  • cloneCoMallElement 函数,以 CoMallElement 元素为样板克隆并返回新的 CoMallElement 元素。
cloneCoMallElement(
  element,
  [props],
  [...children]
)

返回元素的 props 是将新的 props 与原始元素的 props 浅层合并后的结果,新的子元素将取代现有的子元素。

  • createSnapshot 函数,传入一个 CoMallElement 元素,并返回一个 JSX 格式的快照,如 <CoMallElement><CoMallElement/>
createSnapshot(
  element
)
  • isValidCoMallElement 验证对象是否为 CoMall 元素,返回值为 truefalse
isValidCoMallElement(object)

Children

Children 提供了处理 props.children 不透明数据结构的实用方法。

  • Children.mapchildren 里的每一个节点上调用一个函数。

!!!警告:由于转换规则三层的限制,从根元素开始计算 child 需要应用在三层以内

const maps = Children.map(treeMock.props.children, (child) => {
  return (
    <View>
      <View>{child}</View>
    </View>
  );
});
  • Children.count 返回 children 中的组件数量
  • Children.only 验证 children 是否只有一个子节点

Distribute

数据分发容器,详细可访问:Distribute

技术分析