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

@fratercula/puffin

v0.3.0

Published

JSON Schema describes web component

Readme

Puffin

JSON Schema describes web component

Example

given

{
  "node": "div",
  "props": {
    "style": {
      "color": "red"
    }
  },
  "children": [
    {
      "node": "p",
      "children": {
        "node": "span",
        "children": "Text"
      }
    }
  ]
}

out

<div style="color: red">
  <p><span>Text</span></p>
</div>

Install

$ npm i @fratercula/puffin

Usage

simple

import React from 'react'
import { render } from 'react-dom'
import { C } from '@fratercula/puffin'

const schema = {
  "node": "p",
  "children": [
    {
      "node": "span",
      "children": "span"
    }
  ]
}

render((
  <C {...schema} />
), document.getElementById('root'))

use components

import React from 'react'
import { render } from 'react-dom'
import { C } from '@fratercula/puffin'
import * as antd from 'antd'

const schema = {
  "node": "Carousel", // antd Carousel
  "props": {
    "autoplay": true
  },
  "children": [
    {
      "node": "div",
      "children": 1
    },
    {
      "node": "div",
      "children": 2
    }
  ]
}

render((
  <C {...schema} components={antd} />
), document.getElementById('root'))

function callback

import React from 'react'
import { render } from 'react-dom'
import { C } from '@fratercula/puffin'
import * as antd from 'antd'

const schema = {
  "node": "Carousel", // antd Carousel
  "props": {
    "afterChange": ":afterChange", // :key
  },
  "children": [
    {
      "node": "div",
      "children": 2
    }
  ]
}

render((
  <C
    {...schema}
    components={antd}
    onEvent={(key, args) => {
      console.log(key, args)
    }}
  />
), document.getElementById('root'))

Schema

{
  /*
    first letter lowercase, it is HTML tag
    first letter uppercase, it is React component
    example: node: 'Tabs'
  */
  node: 'div',

  /*
    tag props or component props
    example: style: {}, src: 'img/path'
  */
  props: {},

  /*
    component recursive children
    array, object, string, boolean, number
    example: children: [{
      node: 'p',
      children: {
        node: 'span',
        children: 'span',
      },
    }]
  */
  children: [],
}

Helper

Puffin provides helper function p for parsing schema props

import { p } from '@fratercula/puffin'

const props = {
  style: {
    color: 'red',
  },
  tab: {
    node: 'Icon',
    props: {
      type: 'link',
    },
  },
}

const parsed = p(props)
/*
  {
    style: {
      color: 'red',
    },
    tab: (<Icon type="link" />)
  }
*/

basic

// given
{
  style: {
    color: 'red',
  },
  href: 'link/to',
}

// out
<... style="color: red" href="link/to" />

React component

// given
{
  tab: {
    node: 'Icon',
    props: {
      type: 'link',
    },
  },
}

// out
<... tab={(<Icon type="link" />)} />

function

// given
{
  tab: {
    arguments: ['text', 'record'],
    node: 'div',
    children: '${text}, ${record.name}',
  },
}

// out
<... tab={(text, record) => {
  return (<div>{`${text}, ${record.name}`}</div>)
}} />

callback function

import { C } from '@fratercula/puffin'

<C onEvent={(key, args) => console.log(key, args)} />

// given
{
  afterChange: ':afterChange', // :key
}

// out
<... afterChange={args => onEvent('afterChange', args)} />

Component

import React, { Component } from 'react'
import { Timeline } from 'antd'
import { C, p } from '@fratercula/puffin'

class Custom extends Component {
  static puffinParse = false // disable puffin parse data

  render() {
    const { props, children } = this.props
    const {
      pending,
      mode,
      other,
      ...rest
    } = props

    const parsed = p(other)

    return (
      <Timeline
        {...rest}
        pending={pending}
        mode={mode}
        other={parsed}
      >
        {
          children.map((item, i) => {
            const { props: childProps = {} } = item
            const { dot, color, ...childRest } = childProps
            const node = { ...item, prop: childRest, node: 'div' }

            return (
              <Timeline.Item
                key={i}
                color={color}
                dot={dot ? (<C {...dot} />) : undefined}
              >
                <C {...node} />
              </Timeline.Item>
            )
          })
        }
      </Timeline>
    )
  }
}

function Another({ node, props, children }) {
  // ...
}

Another.puffinParse = false // not parse, use origin data

export default { Custom, Another }

Development

# install `falco` global
$ npm i @fratercula/falco -g

# start
$ npm start

# build
$ npm run build

# lint
$ npm run lint

License

MIT

Relevance

Puffin