@clayzo/animation

中文文档
0.3.21发布于 2026/11/05SEE LICENSE IN LICENSE.mdTypeScriptES Module近 30 天下载 1.8万

The stable, typed authoring surface for Clayzo animation documents.

原始使用文档

@clayzo/animation

The stable, typed authoring surface for Clayzo animation documents.

npm install -D @clayzo/animation
import {
  ANIMATION_DOCUMENT_VERSION,
  assertValidAnimationDocument,
  constant,
  packageClayzoBundle,
  withComputedRevision,
  type AnimationDocument,
} from "@clayzo/animation";

const document = withComputedRevision({
  version: ANIMATION_DOCUMENT_VERSION,
  id: "example",
  revision: "",
  name: "Example",
  // canvas, timing, assets, compositions, components, markers, capabilities…
} as AnimationDocument);

assertValidAnimationDocument(document);
const portable = await packageClayzoBundle(document, { assetBytes: {} });

States are a state machine over markers:

import { stateMachine, withStateMachine } from "@clayzo/animation";

const button = withStateMachine(
  document,
  stateMachine({ initial: "idle" })
    .state("idle", { marker: "idle" })
    .state("hover", { marker: "hover", playback: "once" })
    .state("loading", { marker: "loading", playback: "loop" })
    .on("pointerenter", "idle", "hover", { hitArea: "button" })
    .on("pointerleave", "hover", "idle", { hitArea: "button" })
    .when("*", "loading", { input: "loading", operator: "eq", value: true }),
  { inputs: { loading: "boolean" }, hitAreas: { button: { nodeId: "button" } } },
);

This package intentionally contains document contracts, builder macros, validation, canonical serialization, revision stamping, and .clayzo packaging only. Rendering, evaluation, review, conversion, preview, and export are provided by the clayzo CLI and the renderer packages.

For playback, use @clayzo/webgl-player for the lightweight runtime or @clayzo/canvaskit-player for maximum fidelity. Playback never contacts Clayzo authentication services.

版本与发布记录

@clayzo/animation 共发布 21 个版本,首次发布于 2026/08/25;过去 12 个月发布了 21 个版本。

版本发布日期距今
0.3.21latest2026/11/055 天前
0.3.202026/10/2812 天前
0.3.192026/10/2416 天前
0.3.182026/10/2219 天前
0.3.172026/10/1724 天前
0.3.162026/10/081 个月前

关于 @clayzo/animation 的常见问题

@clayzo/animation 是什么?

The stable, typed authoring surface for Clayzo animation documents.

如何安装 @clayzo/animation?

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

@clayzo/animation 支持 TypeScript 吗?

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

@clayzo/animation 支持 ESM 还是 CommonJS?

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

@clayzo/animation 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=22.13。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@clayzo/animation 可以商用吗?

@clayzo/animation 使用 SEE LICENSE IN LICENSE.md 许可。许可条款写在包内的独立文件中,请阅读该文件确认可否商用。以上为概括,不构成法律意见,请以许可原文为准。

@clayzo/animation 的下载量有多少?

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

@clayzo/animation 还在维护吗?

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