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

tona

v1.0.23

Published

<p align="center"> <img src="../../assets/tona.png" alt="Tona" width="100" /> </p>

Readme

tona

English | 中文

特性

  • 插件系统 - 可扩展的插件架构,用于构建模块化主题
  • 配置 API - 使用 defineOptions 实现类型安全的配置管理
  • 主题上下文 - 通过 createTheme 共享主题状态和工具
  • TypeScript 支持 - 包含完整的 TypeScript 定义
  • 轻量级 - 极小的运行时开销

安装

npm install tona
pnpm add tona
yarn add tona

使用

创建主题

import { createTheme } from 'tona'

const theme = createTheme()

// 使用插件
theme.use(myPlugin)

定义配置选项

import { defineOptions } from 'tona'

const getBackgroundOptions = defineOptions('bodyBackground', {
  enable: false,
  value: '',
  opacity: 0.85,
  repeat: false,
})

// 在主题中使用
const options = getBackgroundOptions(userConfig)

创建插件

import { defineOptions } from 'tona'

export function backgroundPlugin(theme, devOptions, pluginOptions) {
  const getBackgroundOptions = defineOptions('bodyBackground', {
    enable: false,
    value: '',
    opacity: 0.85,
    repeat: false,
  })

  const { enable, value, opacity, repeat } = getBackgroundOptions(devOptions)

  if (!enable) return

  const { opacitySelector } = Object.assign(
    {},
    { opacitySelector: '#main,#navigator' },
    pluginOptions,
  )

  setBackground(value, repeat)
  setOpacity(opacity, opacitySelector)
}

使用插件

import { createTheme } from 'tona'
import { backgroundPlugin } from './plugin'

const theme = createTheme()

theme.use(
  backgroundPlugin,
  {
    // 主题默认配置
    enable: true,
    value: '#ffb3cc',
    opacity: 0.85,
  },
  {
    // 插件配置
    opacitySelector: '#main',
  },
)

API 参考

createTheme()

创建具有上下文管理功能的新主题实例。

返回: ThemeInstance

defineOptions(key, defaults)

创建类型安全的配置获取器。

参数:

  • key - 配置键或键数组(用于别名)
  • defaults - 默认配置对象

返回: (options: any) => Config

相关包

文档

详细的文档和示例,请访问 Tona 文档