hyperframes-core
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseHyperFrames Core
HyperFrames 核心
HyperFrames renders video from HTML. A composition is an HTML file whose DOM declares timing with attributes, whose animation runtime is seekable, and whose media playback is owned by the framework.
data-*This skill is the technical contract. Other concerns live in sibling skills:
- — atomic motion rules + scene blueprints + per-runtime adapters (GSAP, Lottie, Three, Anime.js, CSS, WAAPI, TypeGPU)
hyperframes-animation - — palettes, typography, narration, beat planning, audio-reactive
hyperframes-creative - — TTS, Whisper transcribe, background removal, captions
hyperframes-media - — install blocks and components (
hyperframes-registry)hyperframes add - — dev loop commands (lint / validate / preview / render)
hyperframes-cli
For Tailwind v4 projects (), see — the browser-runtime contract is distinct from Studio's Tailwind v3 setup.
hyperframes init --tailwindreferences/tailwind.mdHyperFrames 基于 HTML 渲染视频。合成文件是一个 HTML 文件,其 DOM 通过 属性声明时序,动画运行时支持跳转,媒体播放由框架托管。
data-*本技能是技术契约。其他相关内容在同级技能中:
- — 原子运动规则 + 场景蓝图 + 各运行时适配器(GSAP、Lottie、Three、Anime.js、CSS、WAAPI、TypeGPU)
hyperframes-animation - — 调色板、排版、旁白、节拍规划、音频响应
hyperframes-creative - — TTS、Whisper 转写、背景移除、字幕
hyperframes-media - — 安装块与组件(
hyperframes-registry)hyperframes add - — 开发循环命令(lint / 验证 / 预览 / 渲染)
hyperframes-cli
针对Tailwind v4 项目(),请查看 —— 浏览器运行时契约与 Studio 的 Tailwind v3 配置不同。
hyperframes init --tailwindreferences/tailwind.mdRouting
导航
| Want to… | Read |
|---|---|
| See a minimal renderable composition | |
| Decide between monolithic single-file and modular sub-comp architecture | |
Structure a modular | |
| Pick a sub-comp archetype (content / driver-only / multi-scene merge / audio-reactive) | |
Look up a | |
Use | |
Pick a | |
Time a clip relative to another ( | |
Wire a sub-composition (host attributes, | |
Animate inside a sub-composition ( | |
Declare variables (types, extra options, defaults, | |
Place | |
Build a seekable timeline (paused, sync construction, | |
Avoid non-deterministic state (clocks, | |
Know what can / cannot be animated (visual-property allowlist; not | |
Fit text and prevent overflow ( | |
| Author full-frame motion with shared backgrounds | |
Work in a Tailwind v4 project ( | |
For animation runtime specifics (GSAP API, Lottie, Three.js, etc.) go to → .
hyperframes-animationadapters/<runtime>.md| 想要… | 阅读文档 |
|---|---|
| 查看最小可渲染合成示例 | |
| 在单体单文件和模块化子合成架构间做选择 | |
构建模块化 | |
| 选择子合成原型(内容型 / 仅驱动型 / 多场景合并 / 音频响应型) | |
查询 | |
正确使用 | |
选择 | |
相对于其他片段设置时序( | |
连接子合成(宿主属性、 | |
在子合成内制作动画(优先 | |
声明变量(类型、额外选项、默认值、CI 中的 | |
放置 | |
构建可跳转的时间轴(暂停、同步构建、 | |
避免非确定性状态(时钟、 | |
了解可/不可动画的属性(视觉属性白名单;不可动画 | |
适配文本并防止溢出( | |
| 制作带共享背景的全屏动画 | |
在 Tailwind v4 项目中开发( | |
如需了解动画运行时细节(GSAP API、Lottie、Three.js 等),请前往 → 。
hyperframes-animationadapters/<runtime>.mdComposition Structure
合成结构
Two root forms; they are not interchangeable.
- Standalone (the top-level ) — root
index.htmlsits directly in<div data-composition-id="…">. No<body>wrapper. Wrapping a standalone root in<template>hides all content from the browser and breaks rendering.<template> - Sub-composition (a file loaded via ) — root
data-composition-srcmust be wrapped in<div data-composition-id="…">. Without the wrapper the runtime cannot extract and mount it.<template>
⚠ Sub-composition transport rule: the runtime only clonescontents into the live DOM. Everything outside the template — including<template>and any<head>/<style>/<script>that lives in<link>— is discarded. Put<head>and<style>blocks inside<script>, not in<template>.<head>⚠ Host-id rule: in the host file,on the slot must exactly equal the inner template'sdata-composition-idand thedata-composition-idkey. Do not addwindow.__timelines["<id>"]/-mount/-slotsuffixes.-host
See for the file shape, host wiring, pitfall examples, and the pre-render verification checklist.
references/sub-compositions.md两种根形式,不可互换。
- 独立合成(顶级 )—— 根元素
index.html直接位于<div data-composition-id="…">中。不能用<body>包装。如果用<template>包装独立根元素,会将所有内容隐藏在浏览器外,导致渲染失败。<template> - 子合成(通过 加载的文件)—— 根元素
data-composition-src必须用<div data-composition-id="…">包装。没有包装的话,运行时无法提取并挂载它。<template>
⚠ 子合成传输规则:运行时仅克隆内容到活动 DOM 中。模板外的所有内容 —— 包括<template>以及<head>中的任何<head>/<style>/<script>—— 都会被丢弃。请将<link>和<style>块放在模板内部,而非<script>中。<head>⚠ 宿主ID规则:在宿主文件中,插槽上的必须完全匹配内部模板的data-composition-id以及data-composition-id的键。不要添加window.__timelines["<id>"]/-mount/-slot后缀。-host
有关文件结构、宿主连接、陷阱示例以及预渲染验证清单,请查看 。
references/sub-compositions.mdRoot must be sized (silent layout bug)
根元素必须设置尺寸(静默布局 bug)
The standalone root must establish an explicitly sized box, and every ancestor between it and a element must have a resolved height. If the root or an intermediate wrapper has no height, a flex/ content container collapses to ~0 and content piles into the top-left corner (often clipping the first glyph at x=0). , , and do not catch this — substitutes the authored / for a collapsed root and reports "0 layout issues."
height: 100%height:100%lintvalidateinspectinspectdata-widthdata-heighthtml
<body style="margin: 0">
<div
id="root"
data-composition-id="main"
data-width="1920"
data-height="1080"
data-duration="5"
style="position: relative; width: 1920px; height: 1080px; overflow: hidden"
>
<!-- Center robustly: position:absolute + inset:0 fills the sized root regardless of
intermediate wrappers; or use a flex container ONLY if its parent chain is sized. -->
<section
class="clip"
data-start="0"
data-duration="5"
data-track-index="1"
style="position: absolute; inset: 0; display: grid; place-items: center; padding: 120px 160px; box-sizing: border-box"
>
<h1>Title</h1>
</section>
</div>
</body>Keep the (≥80px) on the centering container — it is the title-safe margin that stops large type touching the frame edge. See .
paddingreferences/minimal-composition.md独立根元素必须建立一个明确设置尺寸的容器,且它与任何 元素之间的所有祖先元素都必须有已解析的高度。如果根元素或中间包装器没有设置高度,flex/ 的内容容器会折叠到约0高度,内容会堆积在左上角(通常会裁剪x=0处的第一个字符)。、 和 无法检测到这个问题 —— 会用已设置的 / 替代折叠的根元素,并显示“0个布局问题”。
height: 100%height:100%lintvalidateinspectinspectdata-widthdata-heighthtml
<body style="margin: 0">
<div
id="root"
data-composition-id="main"
data-width="1920"
data-height="1080"
data-duration="5"
style="position: relative; width: 1920px; height: 1080px; overflow: hidden"
>
<!-- 稳健居中:position:absolute + inset:0 会填充已设置尺寸的根元素,不受中间包装器影响;或者仅在父链已设置尺寸时使用flex容器。 -->
<section
class="clip"
data-start="0"
data-duration="5"
data-track-index="1"
style="position: absolute; inset: 0; display: grid; place-items: center; padding: 120px 160px; box-sizing: border-box"
>
<h1>Title</h1>
</section>
</div>
</body>请在居中容器上保留 (≥80px)—— 这是标题安全边距,可防止大字号文本触碰帧边缘。详情请查看 。
paddingreferences/minimal-composition.mdTimeline Contract (GSAP default)
时间轴契约(默认 GSAP)
Every composition registers exactly one GSAP timeline.
- Create with — the player owns playback.
gsap.timeline({ paused: true }) - Register at ; the key must exactly match the root's
window.__timelines["<composition-id>"]. Dot syntax (data-composition-id) is equivalent when the id is a valid identifier; use brackets if the id containswindow.__timelines.<id> = tl.- - Build the timeline synchronously during page load — not inside ,
async,setTimeout, or event handlers. The renderer samples after page load completes; any deferred timeline construction misses the sample.Promise - Render duration comes from on the root, not from GSAP timeline length. Do not pad the timeline with empty tweens to set duration.
data-duration - For sub-compositions, do not manually nest sub-timelines into the host (); the framework drives them independently.
master.add(sub)
For non-GSAP runtimes (Lottie / Three / WAAPI / CSS / Anime.js / TypeGPU), the equivalent contract lives in . See for the cross-runtime Animation Runtime Contract.
hyperframes-animation/adapters/<runtime>.mdreferences/determinism-rules.md每个合成仅注册一个 GSAP 时间轴。
- 使用 创建 —— 播放器托管播放。
gsap.timeline({ paused: true }) - 在 处注册;键必须完全匹配根元素的
window.__timelines["<composition-id>"]。当ID是有效标识符时,点语法(data-composition-id)等效;如果ID包含window.__timelines.<id> = tl,请使用方括号语法。- - 在页面加载期间同步构建时间轴 —— 不要在 、
async、setTimeout或事件处理程序中构建。渲染器会在页面加载完成后采样;任何延迟的时间轴构建都会错过采样。Promise - 渲染时长来自根元素的 ,而非 GSAP 时间轴长度。不要用空补间填充时间轴来设置时长。
data-duration - 对于子合成,不要手动将子时间轴嵌套到宿主时间轴中();框架会独立驱动它们。
master.add(sub)
对于非 GSAP 运行时(Lottie / Three / WAAPI / CSS / Anime.js / TypeGPU),对应的契约位于 。跨运行时的动画运行时契约请查看 。
hyperframes-animation/adapters/<runtime>.mdreferences/determinism-rules.mdNon-Negotiable Rules
不可协商规则
These break the renderer — or produce silent visual bugs that // do NOT catch (rules 3, 7-8). (Synchronous timeline construction is covered above in Timeline Contract.)
lintvalidateinspect- No /
Math.random()/Date.now()driving visuals — use a seeded PRNG.performance.now() - No . Use
repeat: -1—repeat: Math.max(0, Math.floor(duration / cycleDuration) - 1), notfloor(ceilovershootsceiland trips thedata-durationlint;gsap_repeat_ceil_overshootavoids a negative repeat = infinite).max(0, …) - /
<video>must be a direct child of the host root (<audio>) — never inside a sub-compindex.html, never inside a wrapper<template>; otherwise it is never decoded and renders blank/black (silent). The framework owns playback: no<div>/video.play()/audio.play(). A sub-comp cannot drive host elements (selector orcurrentTime = …), so animate host media from the main timeline at global time. SeequerySelector.references/variables-and-media.md - No on clip elements from later scenes (they are not in the DOM yet). Use
gsap.set()at or after the clip'stl.set(selector, vars, time).data-start - No animating /
display. Animatevisibility/ transforms; the clip lifecycle handles show/hide.opacity - No in body text. Let text wrap via
<br>.max-width - Transformed elements must be block-level + sized. /
transform/scaleXis a no-op on an inlinescaleY, and scaling an auto-width (0px) element shows nothing → invisible bars/fills. Give them<span>/display: block/flex-item and a realinline-block/width(e.g.heightinside a sized parent).width: 100% - Absolutely-positioned decoratives (badges, pills, tags) that pulse or overshoot (scale,
yoyo) need clearance at their peak size and must not straddle anback.outedge — else they overlap a neighbor or get clipped. Position for the largest frame, not the resting one.overflow: hidden
违反这些规则会导致渲染失败 —— 或产生**// 无法检测到的静默视觉 bug**(规则3、7-8)。(同步时间轴构建已在时间轴契约中说明。)
lintvalidateinspect- 不得使用 /
Math.random()/Date.now()驱动视觉效果 —— 使用种子式伪随机数生成器(PRNG)。performance.now() - 不得使用 。请使用
repeat: -1—— 必须用repeat: Math.max(0, Math.floor(duration / cycleDuration) - 1),不能用floor(ceil会超出ceil,触发data-duration检查错误;gsap_repeat_ceil_overshoot可避免负数重复导致无限循环)。max(0, …) - /
<video>必须是宿主根元素(<audio>)的直接子元素 —— 绝不能放在子合成的index.html内,也不能放在包装器<template>内;否则媒体永远不会解码,渲染为空白/黑屏(静默错误)。框架托管播放:禁止调用<div>/video.play()/audio.play()。子合成无法驱动宿主元素(通过选择器或currentTime = …),因此请在主时间轴上按全局时间为宿主媒体制作动画。详情请查看querySelector。references/variables-and-media.md - 不得从后期场景对片段元素调用 (这些元素尚未在 DOM 中)。请在片段的
gsap.set()时间点或之后使用data-start。tl.set(selector, vars, time) - 不得为 /
display设置动画。请为visibility/ 变换设置动画;片段生命周期会处理显示/隐藏。opacity - 正文文本中不得使用 。请通过
<br>让文本自动换行。max-width - 应用变换的元素必须是块级元素且已设置尺寸。/
transform/scaleX对内联scaleY无效,缩放自动宽度(0px)的元素会显示为空 → 不可见的条块/填充。请为它们设置<span>/display: block/flex-item 并指定实际的inline-block/width(例如,在已设置尺寸的父元素内使用height)。width: 100% - 绝对定位的装饰元素(徽章、胶囊、标签)如果有脉动或超出边界的动画(缩放、
yoyo),需要在最大尺寸时留有空间,且不得跨在back.out的边缘 —— 否则会与相邻元素重叠或被裁剪。请按最大帧尺寸定位,而非初始状态尺寸。overflow: hidden
Editing Existing Compositions
编辑现有合成
- Read the actual files before editing.
- Preserve unrelated timing, tracks, IDs, variables, and media paths.
- Match existing composition IDs and timeline registry keys.
- When adding a clip, choose a non-overlapping or intentionally adjust surrounding timing.
data-track-index - When adding a sub-composition, verify its internal before wiring the host.
data-composition-id
- 编辑前先阅读实际文件。
- 保留无关的时序、轨道、ID、变量和媒体路径。
- 匹配现有的合成ID和时间轴注册键。
- 添加片段时,选择不重叠的 或有意调整周围的时序。
data-track-index - 添加子合成时,在连接宿主前验证其内部的 。
data-composition-id
Validation
验证
Use for command details.
hyperframes-cli- passes (0 errors)
npx hyperframes lint - passes (0 console errors)
npx hyperframes validate - passes, or overflow is intentionally marked
npx hyperframes inspect - Projects with sub-compositions: and eyeball each frame
npx hyperframes snapshot --at <midpoints>
使用 获取命令详情。
hyperframes-cli- 检查通过(0错误)
npx hyperframes lint - 检查通过(0控制台错误)
npx hyperframes validate - 检查通过,或溢出已被标记为有意设置
npx hyperframes inspect - 包含子合成的项目:执行 并逐一检查每个帧
npx hyperframes snapshot --at <midpoints>