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 🙏

© 2025 – Pkg Stats / Ryan Hefner

saber-h5

v0.0.8

Published

saber-h5

Readme

saber-h5

a simple ioc framework for canvas-h5.

npm install saber-h5

git clone https://github.com/Saber2pr/saber-h5.git

API

关于内置装饰器可以参考saber-ioc

关于 Canvas API 可以参考saber-canvas

关于 Vector2D API 可以参考saber-vector

Component 接口

所有需要渲染的组件必须实现此接口

属性

  1. node 节点实例(参考 saber-canvas/Node)

  2. children 子节点列表,只有加入到节点树的组件才会被渲染

  3. update 每帧调用一次,参数为时间间隔

export interface Component {
  node?: Node
  children?: Component[]
  update?(dt: number): void
}

createCanvas

构建并运行

createCanvas(AppConfig)(...Components)

Examples

@Injectable()
class Comp1 implements Component {
  constructor(@Inject('Node') public node: Node) {
    this.node
      .setSize(50, 50)
      .setColor('blue')
      .setPosition(100, 100)
  }

  update() {
    console.log('update1')
    this.node.setPosition(this.node.getPosition().add(v2(10, 10)))
  }
}

@Bootstrap
@Injectable()
class Comp2 implements Component {
  constructor(public Comp1: Comp1, @Inject('Node') public node: Node) {
    this.children = [Comp1]
    this.node.setSize(50, 50).setColor('red')
  }
  children: Component[]

  update(dt: number) {
    console.log('update2', dt)
  }
}

createCanvas({
  MaxWidth: 500,
  MaxHeight: 500,
  elementId: 'root',
  fps: 2
})(Comp1, Comp2)

start

npm install
npm start

npm run dev

Author: saber2pr