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

@keyframe-engine/controller

v1.0.4

Published

@keyframe-engine/controller — Standard Animation Playback Controller

Readme

@keyframe-engine/controller

npm version License: MIT

@keyframe-engine/controller 是 Keyframe Engine 的播放控制器包,提供高精度帧控制、播放/暂停/Seek 状态管理、ApplyAligner 信号同步屏障,以及基于 Audio Clock Master 的双循环自适应收敛时钟算法。


核心功能

  • AnimationPlayer: 标准播放器,封装帧循环、timeScale 速率调节与事件监听 (frame, play, pause, seek, ended)。
  • Audio Clock Master (音频主时钟自适应收敛):
    • 漂移 < ±50ms: 双循环 timeScale 微调 (0.998 ~ 1.002) 丝滑对齐音视频。
    • 漂移 > ±100ms: 自动触发硬帧重锁定 (Hard Re-lock),防止累积脱节。
  • ApplyAligner (信号屏障闸门):
    • 提供 aligner.waitUntil(instanceId, condition).then(callback),实现跨对象事件触发与运行时挂起同步(类似于 JAnim 协程 Barrier)。

安装

pnpm add @keyframe-engine/controller @keyframe-engine/core

快速上手

import { Engine, Clip, Instance } from "@keyframe-engine/core";
import { controller } from "@keyframe-engine/controller";

const engine = new Engine();
// ... 初始化 engine、clips 与 instances

// 1. 创建播放器
const player = controller.createPlayer(engine, {
  fps: 60,
  timeScale: 1.0,
  duration: 5000,
});

// 2. 使用 ApplyAligner 设置运行期挂起等待屏障
const aligner = player.createAligner();
aligner.waitUntil("inst_1", { trigger: "onComplete" }).then(() => {
  console.log("inst_1 播放完成,触发后续逻辑!");
});

// 3. 监听帧更新事件
player.on("frame", (timeMs) => {
  const instances = engine.getEvaluatedInstances(timeMs);
  // 执行渲染绑定 ...
});

// 4. 开始播放
player.play();

许可证

MIT