@clayzo/canvaskit-player

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

The full-fidelity Clayzo animation player. CanvasKit/Skia, draws everything the engine can express.

原始使用文档
文档目录3 节
  1. Where Skia comes from
  2. Fonts
  3. Choosing between the two renderers

@clayzo/canvaskit-player

The full-fidelity Clayzo player. CanvasKit — Skia compiled to WASM, the same build the video export runs — so it draws everything the engine can express.

npm i @clayzo/canvaskit-player
import { createPlayer } from '@clayzo/canvaskit-player';

const player = await createPlayer({ canvas, document });
player.play();

Same call as @clayzo/webgl-player, so swapping is one word in an import.

React and Next clients can use the optional client entrypoint:

import { ClayzoPlayer } from '@clayzo/canvaskit-player/react';

export function Hero() {
  return <ClayzoPlayer document={document} poster="/hero.poster.webp" posterTick={240} label="A cube folding into the logo" />;
}

It takes the same poster, posterTick, autoplay, reducedMotion, label, decorative and fallback props as @clayzo/webgl-player/react, and loads the player only as it comes near the viewport.

~2,535 KB brotli, most of it Skia. If that is affordable, this is the renderer to reach for: it is correct by construction, and what a viewer sees cannot drift from what an export produces, because they are the same code.

Where Skia comes from

Unlike the light renderer, an 8 MB binary cannot be baked into the bundle — base64 would be 10 MB of JavaScript to parse before the first frame. It is fetched instead, from a version-pinned CDN by default:

https://unpkg.com/[email protected]/bin/full

Pinned to an exact version deliberately. This renderer is written against that build's behaviour, and a CDN quietly serving a newer Skia is a fidelity change nobody asked for.

To self-host — behind a firewall, under a strict CSP, or simply not wanting a third-party dependency in your critical path:

npm i -D [email protected]
cp node_modules/canvaskit-wasm/bin/full/canvaskit.{js,wasm} public/canvaskit/
await createPlayer({ canvas, document, canvasKitUrl: '/canvaskit' });

Both files are required, and the full build specifically: Skottie ships only there, and documents with Lottie nodes need it.

Fonts

await createPlayer({
  canvas,
  document,
  onPrewarm: (result) => {
    if (result.unresolvedFamilies.length > 0) {
      console.warn('no font for:', result.unresolvedFamilies.join(', '));
    }
  },
});

Worth wiring up. A font no loader could supply does not throw and does not substitute — the text runs relying on it draw nothing at all. onPrewarm is the difference between catching that in development and shipping a blank headline.

Choosing between the two renderers

See @clayzo/animation's docs/renderers.md. Use this one when you cannot enumerate the documents in advance — a design tool, an editor preview, a gallery of user-authored work — or when @clayzo/webgl-player's checkCoverage says a document needs it.

版本与发布记录

@clayzo/canvaskit-player 共发布 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/canvaskit-player 的常见问题

@clayzo/canvaskit-player 是什么?

The full-fidelity Clayzo animation player. CanvasKit/Skia, draws everything the engine can express.

如何安装 @clayzo/canvaskit-player?

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

@clayzo/canvaskit-player 支持 TypeScript 吗?

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

@clayzo/canvaskit-player 支持 ESM 还是 CommonJS?

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

@clayzo/canvaskit-player 需要什么版本的 Node.js?

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

@clayzo/canvaskit-player 可以商用吗?

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

@clayzo/canvaskit-player 的下载量有多少?

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

@clayzo/canvaskit-player 还在维护吗?

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