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

@yoga-canvas/core

v0.1.1

Published

Framework-agnostic Canvas layout engine powered by Yoga (flexbox). Supports H5 and WeChat Mini Program.

Downloads

123

Readme

@yoga-canvas/core

Framework-agnostic Canvas layout engine powered by Yoga (flexbox).
Supports H5 (browser) and WeChat Mini Program environments.

Installation

npm install @yoga-canvas/core
# or
pnpm add @yoga-canvas/core

Quick Start

import { createYogaCanvas, View, Text, Image } from '@yoga-canvas/core';

// 1. Define your layout using the declarative DSL
const layout = View({
  style: { width: 375, height: 667, flexDirection: 'column', padding: 16 },
  children: [
    Text({
      content: 'Hello Yoga Canvas!',
      style: { fontSize: 24, fontWeight: 'bold', color: '#1f2937' },
    }),
    View({
      style: { flexDirection: 'row', gap: 8, marginTop: 12 },
      children: [
        Image({
          src: 'https://example.com/photo.jpg',
          style: { width: 80, height: 80, borderRadius: 8 },
        }),
        View({
          style: { flex: 1, justifyContent: 'center' },
          children: [
            Text({
              content: 'A flexible canvas layout engine',
              style: { fontSize: 14, color: '#6b7280' },
            }),
          ],
        }),
      ],
    }),
  ],
});

// 2. Create and initialize the engine
const canvas = document.getElementById('my-canvas');
const yoga = createYogaCanvas(canvas, layout, {
  platform: 'h5',
  pixelRatio: window.devicePixelRatio,
  width: 375,
  height: 667,
});

await yoga.init();
yoga.render();

// 3. Use output APIs
const json = yoga.toJSON();           // Serialize to JSON
const dataUrl = await yoga.toDataURL(); // Export as image
const html = yoga.toDOMString();       // Export as HTML flex layout

Component DSL

| Component | Description | |-----------|-------------| | View({style, children}) | Container with flexbox layout | | Text({content, style}) | Text node with word wrapping | | Image({src, objectFit, style}) | Image node with cover/contain/fill | | ScrollView({scrollDirection, style, children}) | Scrollable container |

Style Properties

All components accept a unified style prop that merges:

  • Flex layoutwidth, height, flex, flexDirection, justifyContent, alignItems, gap, padding, margin, etc.
  • VisualbackgroundColor, borderColor, borderWidth, borderRadius, opacity, rotation
  • Text (Text only) — fontSize, fontWeight, color, lineHeight, textAlign

Shorthand padding / margin expand to all four edges.

Platform Support

| Platform | Adapter | Import | |----------|---------|--------| | Browser (H5) | H5Adapter | Built-in default | | WeChat Mini Program | WxAdapter | import { WxAdapter } from '@yoga-canvas/core' |

Instance API

// Rendering
yoga.render()
yoga.update(newLayout)

// Node tree
yoga.getNodeTree()
yoga.getNodeById(id)
yoga.getRootNode()

// Mutations
yoga.updateFlexStyle(nodeId, { flex: 2 })
yoga.addChild(parentId, Text({ content: 'new' }))
yoga.deleteNode(nodeId)
yoga.moveNode(nodeId, newParentId, index)

// Undo / Redo
yoga.undo()
yoga.redo()

// Export
yoga.toJSON()
yoga.loadJSON(json)
yoga.toDataURL()
yoga.toDOMString()

// Events
yoga.on('render', callback)
yoga.on('ready', callback)

// Lifecycle
yoga.destroy()

License

MIT