@editframe/elements

中文文档
0.60.37发布于 2026/10/31SEE LICENSE IN LICENSE-FULL.mdTypeScriptES Module近 30 天下载 7515

Editframe video composition custom elements (native Web Components).

原始使用文档
文档目录4 节
  1. Install
  2. Playback speed and source trims
  3. Audio fades
  4. Export

@editframe/elements

Web components SDK for building video compositions with Editframe.

Install

npm install @editframe/elements

Import the package once to register its custom elements:

import "@editframe/elements";

Playback speed and source trims

ef-video and ef-audio support playback-rate (JavaScript property playbackRate). The default is 1; supported rates are 0.25 through 4, inclusive. Audio keeps its pitch during playback and export.

<ef-configuration id="configuration">
  <ef-timegroup id="cut" mode="fixed" duration="4s"
    style="position: relative; width: 640px; height: 360px">
    <ef-video id="clip" src="/take.mp4" sourcein="2s" sourceout="10s"
      playback-rate="2" style="width: 100%; height: 100%"></ef-video>
  </ef-timegroup>
</ef-configuration>

This plays source seconds 2 through 10 in four composition seconds. sourcein/sourceout and trimstart/trimend refer to source time. Without an explicit leaf duration, the trimmed source duration is divided by the rate. An explicit leaf duration is in composition time and consumes duration × playbackRate source seconds, capped by the available media. Numeric seek times and currentTime are also in composition seconds.

Attach a controller explicitly for playback, then call play() from a user gesture:

const configuration = document.querySelector("#configuration");
const cut = document.querySelector("#cut");
const playback = configuration.attachPlayback(cut);

// In a play button's click handler:
playback.play();
// Seeking during playback keeps the controller playing from the new time.
await playback.seek(1.5);

Invalid or missing playback-rate attributes resolve to 1. Assigning an invalid playbackRate property value throws RangeError instead.

Audio fades

Set volumeAtTime as a JavaScript property on an audio or video element. It receives clip-local composition seconds: 0 is the start of the clip, regardless of its source trim or position in a parent timegroup. Return a multiplier from 0 to 1; it is multiplied by the element's volume. Finite values outside that range are clamped, and non-finite values use 1.

const clip = document.querySelector("#clip");
clip.volume = 0.8;
clip.volumeAtTime = (localTime) =>
  Math.max(0, Math.min(1, localTime / 0.25, (4 - localTime) / 0.25));

This fades a four-second clip in and out over a quarter-second. Export evaluates the envelope for each output audio sample; playback smooths volume updates. Keep the callback deterministic so seeking and exporting produce the same envelope. A callback is not an HTML attribute and cannot be serialized into a saved markup string.

Export

Create an isolated render clone to export without seeking the live composition. createRenderClone preserves volumeAtTime callbacks along with the media attributes.

import { createRenderClone, renderTimegroupToVideo } from "@editframe/elements";

const handle = await createRenderClone(document.querySelector("#cut"), {
  width: 640,
  height: 360,
  isolateMedia: true,
});
try {
  const result = await renderTimegroupToVideo(handle.clone, {
    width: 640,
    height: 360,
    fps: 30,
  });
  const mp4 = new Blob([result.buffer], { type: result.mimeType });
  // Save or upload mp4 using your application's export flow.
} finally {
  handle.dispose();
}

Export requires a browser with the relevant WebCodecs support. During development, a hot reload can leave custom elements from an older module instance; an export error beginning “Reload the page to export” means a full page reload is required.

Text capture preserves computed defaults such as line-height: normal, including resets inherited from a parent. You can still set an explicit line height for your design; 1.15 is not an SDK requirement. Font URLs in stylesheets resolve relative to the stylesheet that declares them, so those stylesheets and font files must be accessible to the rendering page.

See the documentation, composition skill, React bindings, and migration guide for more usage.

版本与发布记录

@editframe/elements 共发布 356 个版本,首次发布于 2024/05/11;过去 12 个月发布了 216 个版本。

版本发布日期距今
0.60.37latest2026/10/3113 天前
0.60.362026/10/3113 天前
0.60.342026/10/1727 天前
0.60.332026/10/131 个月前
0.60.312026/10/091 个月前
0.60.302026/10/091 个月前

其他发布通道:beta → 0.59.0-beta.25。

关于 @editframe/elements 的常见问题

@editframe/elements 是什么?

Editframe video composition custom elements (native Web Components).

如何安装 @editframe/elements?

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

@editframe/elements 支持 TypeScript 吗?

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

@editframe/elements 支持 ESM 还是 CommonJS?

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

@editframe/elements 可以商用吗?

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

@editframe/elements 的下载量有多少?

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

@editframe/elements 还在维护吗?

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