@dotcraft/avatar

中文文档
0.11.1发布于 2026/11/13Apache-2.0TypeScriptES Module零依赖构建来源已验证近 30 天下载 3182

Name-derived DotCraft avatars and React SVG animation components

原始使用文档
文档目录4 节
  1. Install
  2. Render an avatar
  3. Follow the pointer
  4. Collection

@dotcraft/avatar

Render a consistent DotCraft companion from an Agent name. React components require React 19; the package root works without React.

Install

npm install @dotcraft/avatar

Render an avatar

Import the stylesheet once in your application.

import { Avatar } from '@dotcraft/avatar/react'
import '@dotcraft/avatar/styles.css'

export function AgentIdentity() {
  return <Avatar name="Reviewer" size={36} label="Reviewer" />
}

Import deriveAppearance from @dotcraft/avatar when an application needs the same name-derived appearance without React.

Follow the pointer

useAvatarGaze turns the face of each avatar inside an element toward the pointer. Enable it only while the avatar is idle. Pass within to follow only inside an element, and reach to set how far from the avatar's centre, in CSS pixels, the gaze reaches its limit.

const face = useRef<HTMLSpanElement>(null)
useAvatarGaze(face, { enabled: state === 'idle' })

return <span ref={face}><Avatar name="Reviewer" size={60} state={state} motion="system" /></span>

Collection

An appearance fills five independent slots: head, face, hand, back, and skin. Every item in the registry carries a rarity (common to legendary), a series, and the zones it occupies; items that share a zone never appear together. Name derivation draws each slot's rarity with shared weights, so legendary items are rare but reachable. Use equip(appearance, slot, id) to change one slot and clear conflicting ones, and the catalog for display names, rarity chrome colors, and series labels.

Effects belong to items: paint skins such as chrome and holographic replace the body paint, glow items pulse, and koi circle the body. Effects animate only at 44px and above with motion enabled; smaller avatars render their static frame, and avatars at 20px and below drop face, hand, overlay-skin, and effect layers entirely. The model is specified in specs/features/avatar-system.md.

See the TypeScript SDK reference for the available entry points.

版本与发布记录

@dotcraft/avatar 共发布 47 个版本,首次发布于 2026/09/08;过去 12 个月发布了 47 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
0.11.1latest2026/11/13今天
0.11.02026/11/112 天前
0.10.52026/11/103 天前
0.10.42026/11/085 天前
0.10.32026/11/076 天前
0.10.22026/11/058 天前

关于 @dotcraft/avatar 的常见问题

@dotcraft/avatar 是什么?

Name-derived DotCraft avatars and React SVG animation components

如何安装 @dotcraft/avatar?

在项目目录运行 npm install @dotcraft/avatar,或使用 pnpm add / yarn add / bun add。

@dotcraft/avatar 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@dotcraft/avatar 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@dotcraft/avatar 可以商用吗?

@dotcraft/avatar 使用 Apache-2.0 许可。宽松许可:允许商业使用、修改和再分发,并附带明确的专利授权;分发时需保留许可与 NOTICE 文件,修改过的文件要注明改动。以上为概括,不构成法律意见,请以许可原文为准。

@dotcraft/avatar 的下载量有多少?

根据 npm 官方下载统计,@dotcraft/avatar 在 2026/10/13 – 2026/11/11 这 30 天内被下载 3,182 次,日均约 106 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@dotcraft/avatar 还在维护吗?

最新版本 0.11.1 发布于 2026/11/13(今天);至今共发布 47 个版本,其中过去 12 个月发布了 47 个;首次发布于 2026/09/08。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。