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

extag

v0.5.7

Published

A Component-based and Event-driven JavaScript MVVM Library

Downloads

48

Readme

Extag

Extag是一个基于组件和事件驱动的JavaScript MVVM库,用于构建Web用户界面。Extag提供了一个由文本、元素、片段和组件构成的Shell层。其中,组件支持模板、数据绑定等,具有良好的可扩展性,能够更好地组织用户界面,管理数据状态。通过监听和派发自定义属性更改事件,内嵌在组件模板中的数据绑定表达式得以生效,从而能够动态地改变Shell层的内容。Shell层一旦发生变化,Extag就会通过ExtagDOM以异步批量的模式,将变化的部分渲染到真实的DOM层。

快速开始

使用script标签简单地引入Extag和ExtagDOM。

<script src="https://unpkg.com/extag/dist/extag.js"></script>
<script src="https://unpkg.com/extag-dom/dist/extag-dom.js"></script>

或通过npm安装后引入Extag和ExtagDOM。

import Extag from 'extag'
import ExtagDOM from 'extag-dom'
Extag.conf('view-engine', ExtagDOM);

一个简单的Extag例子如下:

<div id="hello"></div>
// 定义一个组件子类
class Hello extends Extag.Component {
  static get template() {
    return  `<div class="hello">
                <h1>Hello, @{ name }!</h1> 
            </div>`;
  }
  static get attributes() {
    return {name: 'World'};
  }
}
// 创建一个组件实例
const hello = new Hello();
// 附着到一个元素上
hello.attach(ExtagDOM.query('#hello')); // hello.attach(document.getElementById('hello'));

我们定义了一个Hello类,继承自Component。组件模板中使用了一个单向的数据绑定表达式 @{ name }。包裹在 @{ } 内的自定义的特性 name 是可绑定的,其默认值为'World'。创建一个Hello类的实例,附着到页面上的一个元素上,'Hello, World!' 的字样就会渲染到页面上。

数据绑定 & 事件监听

我们在标签上使用 @= 绑定属性和表达式,使用 += 连接事件和处理函数:

class Hello extends Extag.Component {
  static get template() {
    return  `<div class="hello">
                <h1>Hello, @{ state.name }!</h1>
                <input value@="state.name" input+="onInput">
            </div>`;
  }
  setup() {
    return {
      state: new Extag.Model({
        name: 'World'
      }),
      onInput: this.onInput.bind(this)
    }
  }
  onInput(event) {
    this.state.name = event.target.value;
  }
}

特别地,对于 class 和 style 的绑定,还可以是:

<a x:class="btn btn-next; disabled: @{page >= total};"
   x:style="margin: 5px; color: @{color}; font-size: @{fontSize}px;">
  下一页
</a>  

if条件 & for循环

<ul x:if="items != null">
  <li x:for="item of items">
    <span>@{ item.text }</span>
  </li>
</ul>

更多内容,请参阅文档。