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

universal-canvas-engine-wklzz

v0.1.2

Published

A universal canvas engine with adapters for Fabric, Skyline, etc.

Downloads

2

Readme

@universal-canvas/engine/ │ ├─ src/ │ ├─ index.ts # 对外统一暴露接口 │ ├─ adapters/ │ │ ├─ fabric.ts │ │ └─ skyline.ts │ ├─ types/ │ │ ├─ shape.ts │ │ └─ schema.ts # 新增:@universal-canvas/schema 类型定义 │ └─ plugins/ │ └─ plugin.ts │ ├─ dist/ # 编译后的文件 │ ├─ index.js │ ├─ adapters/ │ ├─ types/ │ └─ plugins/ │ ├─ docs/ # 文档目录 │ ├─ getting-started.md # 快速开始指南 │ ├─ api-reference.md # API 参考文档 │ └─ advanced-guide.md # 高级使用指南 │ ├─ examples/ # 示例代码 │ ├─ basic-example.html # 基础使用示例 │ ├─ plugin-example.html # 插件系统示例 │ └─ layer-example.html # 图层操作示例 │ ├─ package.json ├─ tsconfig.json ├─ README.md └─ .npmignore

@universal-canvas/engine

设计一套统一的Canvas API,支持多种Canvas实现,如Fabric.js和Skyline.js。

安装

npm install @universal-canvas/engine

文档

示例

使用 @universal-canvas/schema

从版本 0.1.0 开始,我们集成了 @universal-canvas/schema 包来提供标准化的类型定义。

安装

npm install @universal-canvas/schema

使用示例

import { CanvasSchema, CanvasElement, validateCanvas } from '@universal-canvas/engine';

// 创建符合Schema的画布数据
const canvasData: CanvasSchema = {
  canvas: {
    width: 800,
    height: 600,
    backgroundColor: '#ffffff'
  },
  metadata: {
    version: '1.0.0',
    createdAt: new Date().toISOString(),
    lastModified: new Date().toISOString()
  },
  elements: [
    {
      id: 'rect1',
      type: 'rectangle',
      x: 100,
      y: 100,
      width: 200,
      height: 150,
      color: '#ff0000'
    }
  ]
};

// 验证数据是否符合Schema
const validationResult = validateCanvas(canvasData);
if (validationResult.success) {
  console.log('数据验证通过');
} else {
  console.error('数据验证失败:', validationResult.error);
}

接口定义

interface ICanvasEngine {
    // 基础操作
    addShape(shape: Shape | ExtendedShape): void;
    removeShape(id: string): void;
    moveShape(id: string, x: number, y: number): void;
    resizeShape(id: string, width: number, height: number): void;
    setColor(id: string, color: string): void;

    // 绘制接口(按图层顺序绘制)
    draw(layers: (Shape[] | ExtendedShape[])[]): void;

    // 事件代理
    on(event: string, callback: Function): void;
    off(event: string, callback: Function): void;

    // 序列化 / 反序列化
    serialize(): string;
    deserialize(json: string): void;
}