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

@vte-js/compiler

v1.0.1

Published

Compiler for Vue Token Engine - generates agent.json and tokens.d.ts

Readme

@vte-js/compiler

Vue Token Engine 的编译器,生成 agent.json(AI 可读)和 tokens.d.ts(TypeScript 类型)。

安装

npm install @vte-js/compiler
# 或
pnpm add @vte-js/compiler

API

compile(options)

编译 token 文件,生成输出文件。

import { compile } from "@vte-js/compiler";

const result = await compile({
  tokenFile: "./design-tokens.ts",
  outputDir: "./dist",
  prefix: "tokens",  // 可选,默认 "tokens"
});

// 写入文件
fs.writeFileSync(result.agentJsonPath, JSON.stringify(result.agentJson, null, 2));
fs.writeFileSync(result.tokensDtsPath, result.tokensDts);

输出文件

agent.json

AI 可读的 token 信息文件,包含:

{
  "version": "1.0.0",
  "generatedAt": "2026-07-04T09:10:22.386Z",
  "tokens": {
    "semantic.color.primary": {
      "value": "#3b82f6",
      "original": "{primitive.blue.500}",
      "refs": ["primitive.blue.500"],
      "platform": {
        "web": "var(--vte-semantic-color-primary)",
        "mp": "#3b82f6",
        "rn": "#3b82f6"
      }
    }
  },
  "paths": ["semantic.color.primary", ...],
  "tree": { "semantic": { "color": { "primary": null } } },
  "stats": {
    "total": 11,
    "primitives": 7,
    "references": 4
  }
}

用途:

  • AI 工具读取后可理解可用 token
  • 变更追踪(通过 refs 字段)
  • 多平台值(web/mp/rn)

tokens.d.ts

TypeScript 类型声明文件:

// 所有合法的 token 路径
export type TokenPaths =
  | "semantic.color.primary"
  | "semantic.spacing.small"
  | ...;

// Token 映射类型
export interface TokenMap {
  "semantic.color.primary": "#3b82f6";
  ...
}

// Token 常量值
export const tokens = {
  semantic: {
    color: { primary: "#3b82f6" },
  },
} as const;

用途:

  • IDE 自动补全
  • 类型安全的 token 访问

类型说明

interface AgentToken {
  value: string;        // 解析后的值
  original: string;     // 原始值(可能是引用)
  refs: string[];       // 引用链
  platform: {
    web: string;        // CSS Variable 格式
    mp: string;         // 小程序格式(rpx)
    rn: number | string; // React Native 格式
  };
}

License

ISC