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

@actview/jsx

v1.0.3

Published

JSX runtime for Actview - custom JSX factory with real DOM rendering

Readme

@actview/jsx

Actview 的自定义 JSX 运行时,将 JSX 直接渲染为真实 DOM 元素。

安装

npm install @actview/jsx
# 或
pnpm add @actview/jsx

配置

TypeScript 配置

tsconfig.json 中添加:

{
  "compilerOptions": {
    "jsx": "react-jsx",
    "jsxImportSource": "@actview/jsx"
  }
}

Vite 配置(可选)

如果使用 Vite,它会自动使用 TypeScript 的 JSX 设置。

使用方法

基本元素

const element = <div class="container">Hello World</div>
document.body.appendChild(element)

事件处理

const button = (
  <button onClick={(e) => console.log('clicked!', e)}>
    点击我
  </button>
)

样式设置

// 字符串样式
<div style="color: red; font-size: 16px;">红色文字</div>

// 对象样式
<div style={{ color: 'blue', fontSize: '16px' }}>蓝色文字</div>

函数组件

function Greeting({ name }: { name: string }) {
  return <h1>你好, {name}!</h1>
}

const element = <Greeting name="世界" />

Fragment

import { Fragment } from '@actview/jsx'

function List() {
  return (
    <>
      <li>项目 1</li>
      <li>项目 2</li>
      <li>项目 3</li>
    </>
  )
}

条件渲染

const isLoggedIn = true

const element = (
  <div>
    {isLoggedIn ? <span>欢迎!</span> : <span>请登录</span>}
  </div>
)

列表渲染

const items = ['苹果', '香蕉', '樱桃']

const list = (
  <ul>
    {items.map(item => <li>{item}</li>)}
  </ul>
)

配合 @actview/core 使用

import { ref, compile } from '@actview/core'

const count = ref(0)

compile({
  selector: '#app',
  render: () => (
    <div>
      <p>计数: {count.value}</p>
      <button onClick={() => count.value++}>增加</button>
    </div>
  )
})

API

createElement(tag, props, ...children)

JSX 工厂函数,创建真实 DOM 元素。

function createElement(
  tag: string | Function,
  props: Record<string, any> | null,
  ...children: Child[]
): HTMLElement | DocumentFragment

Fragment

允许返回多个元素而无需包装器。

function Fragment(props: { children?: Child | Child[] }): DocumentFragment

导出项

| 导出 | 说明 | |------|------| | createElement | JSX 工厂函数 | | jsx | createElement 的别名 | | jsxs | createElement 的别名(静态子元素) | | jsxDEV | 开发模式 JSX 函数 | | Fragment | Fragment 组件 |

支持的 HTML 属性

通用属性

  • idclassclassName
  • style(字符串或对象)
  • 任何标准 HTML 属性

事件处理器

  • onClickonChangeonInputonSubmit
  • 任何 on* 属性都会转换为事件监听器

表单属性

  • valuecheckedplaceholderdisabledtype

类型定义

namespace JSX {
  type Element = HTMLElement | Text | DocumentFragment

  interface HTMLAttributes {
    id?: string
    class?: string
    className?: string
    style?: string | Partial<CSSStyleDeclaration>
    onClick?: (e: MouseEvent) => void
    onChange?: (e: Event) => void
    onInput?: (e: Event) => void
    onSubmit?: (e: Event) => void
    children?: any
    [key: string]: any
  }
}

License

MIT