@cutcraft/player 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +45 -86
- package/dist/engine.d.mts +2 -3
- package/dist/engine.mjs +1 -3
- package/dist/index.d.mts +60 -31
- package/dist/index.mjs +2168 -277
- package/dist/{nested-DSXA1q8d.mjs → render-DA1KFyei.mjs} +1643 -165
- package/dist/{nested-Bd4Y7qrF.d.mts → warn-GHM3SBI2.d.mts} +527 -355
- package/package.json +19 -12
- package/dist/backdrop-BqrzCzTB.d.mts +0 -131
- package/dist/frame-plan-BNwblf1s.mjs +0 -1074
- package/dist/layer-interiors-r4SeMbp2.d.mts +0 -8
- package/dist/overlays.d.mts +0 -201
- package/dist/overlays.mjs +0 -3
- package/dist/svg-element-BUXbz-U5.mjs +0 -1736
package/README.md
CHANGED
|
@@ -1,103 +1,62 @@
|
|
|
1
|
-
<p align="center"><img src="
|
|
1
|
+
<p align="center"><img src="https://raw.githubusercontent.com/prefix-tree/cutcraft/main/docs/public/logo.svg" width="64" alt="CutCraft"></p>
|
|
2
2
|
|
|
3
3
|
# @cutcraft/player
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
and
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
5
|
+
Plays a [CutCraft](https://prefix-tree.github.io/cutcraft/) video file in the browser. Footage is decoded with
|
|
6
|
+
WebCodecs through [mediabunny](https://mediabunny.dev) and drawn on one canvas, overlays are React DOM on top of it,
|
|
7
|
+
and Web Audio mixes the sound and keeps the time.
|
|
8
|
+
|
|
9
|
+
```sh
|
|
10
|
+
npm install @cutcraft/player @cutcraft/kit react react-dom
|
|
11
|
+
```
|
|
12
12
|
|
|
13
13
|
```tsx
|
|
14
14
|
import { collectModule, resolve } from "@cutcraft/kit";
|
|
15
15
|
import { Player } from "@cutcraft/player";
|
|
16
|
-
import
|
|
16
|
+
import "@cutcraft/player/fonts.css";
|
|
17
|
+
import * as file from "./video";
|
|
17
18
|
|
|
18
19
|
const state = resolve(collectModule(file), manifest);
|
|
20
|
+
|
|
19
21
|
<Player state={state} element={file.default(file.defaults)} media={{ interview: blob, bed: "/bed.ogg" }} controls />
|
|
20
22
|
```
|
|
21
23
|
|
|
22
|
-
`media` maps asset ids to Blobs or URLs
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
## What
|
|
26
|
-
|
|
27
|
-
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
fetches at high speeds and while scrubbing, one retained frame per freeze.
|
|
37
|
-
A playing tick never waits for a frame; a seek does. A trim or speed drag
|
|
38
|
-
updates the decoder in place rather than reopening it, and a paused preview
|
|
39
|
-
repaints each drag step with what is decoded, then fetches the exact frame
|
|
40
|
-
once the gesture has been quiet for 120 ms.
|
|
41
|
-
- **Compositing.** `buildFramePlan(state, t)` is pure and deterministic: tracks
|
|
42
|
-
in document order (the first track is the bottom), each clip with its
|
|
43
|
-
animated transform, crop, fit, opacity, blend, filter and mask; transitions
|
|
44
|
-
draw the incoming clip over the outgoing one; adjustments re-filter what is
|
|
45
|
-
below them. `CanvasPainter` executes it. Titles, shapes, SVG, stickers,
|
|
46
|
-
layers and captions are DOM elements positioned with the same matrix math.
|
|
47
|
-
- **Audio.** `buildAudioPlan` lists every audio-bearing chunk in a window with
|
|
48
|
-
its gain envelope (volume, fades, automation, ducking, keyframes, mute and
|
|
49
|
-
solo). `AudioEngine` schedules each chunk once per play session, 200 ms
|
|
50
|
-
ahead, as an `AudioBufferSourceNode` with the right offset, duration and
|
|
51
|
-
`playbackRate = clipSpeed × rate`, automated along a speed-key ramp and
|
|
52
|
-
split around freeze holds, which are silent; PCM is decoded per source range with
|
|
53
|
-
`AudioBufferSink` and cached. Pause stops everything; seek reschedules once.
|
|
54
|
-
- **Addressability.** Every DOM element carries `data-el` and `data-kind`; the
|
|
55
|
-
root carries `data-time` and `data-frame`; the canvas is
|
|
56
|
-
`[data-el="composition"]`.
|
|
57
|
-
- **Determinism.** `seekTo(t)` and `renderFrame(t)` draw the exact frame for
|
|
58
|
-
`t`, paused or playing. The exporter steps through frames with
|
|
59
|
-
`Compositor.step(t)`, which keeps every decoder streaming.
|
|
60
|
-
- **Looking at the result.** `captureSheet(times, { columns })` returns a
|
|
61
|
-
labelled contact sheet of those frames, the way an agent or a test checks
|
|
62
|
-
a cut without exporting.
|
|
24
|
+
`media` maps asset ids to Blobs or URLs, or you can pass your own `MediaResolver`. `element` is the rendered file; the
|
|
25
|
+
player needs it to draw what is inside each `<Layer>`.
|
|
26
|
+
|
|
27
|
+
## What you get
|
|
28
|
+
|
|
29
|
+
- Frame-exact seeking. `seekTo(t)` draws the frame for `t` whether the player is paused or playing.
|
|
30
|
+
- Smooth scrubbing and trimming. A drag repaints from frames already decoded, then fetches the exact frame once the
|
|
31
|
+
pointer rests.
|
|
32
|
+
- Playback from 0.25× to 4× and looped, with speed ramps and freeze frames and their sound.
|
|
33
|
+
- A clock that does not drift: time comes from `AudioContext.currentTime`.
|
|
34
|
+
- Every overlay carries `data-el` and `data-kind`, and the root carries `data-time` and `data-frame`, so tests and
|
|
35
|
+
agents can find things on screen.
|
|
36
|
+
- `captureSheet(times, { columns })` returns a labelled contact sheet of frames, a quick way to check a cut without
|
|
37
|
+
exporting it.
|
|
63
38
|
|
|
64
39
|
## API
|
|
65
40
|
|
|
66
|
-
`
|
|
67
|
-
`
|
|
68
|
-
|
|
69
|
-
`setState`, `attachCanvas`, `addEventListener` (`frameupdate`, `play`,
|
|
70
|
-
`pause`, `seeked`, `ended`, `ratechange`, `volumechange`, `error`),
|
|
71
|
-
`subscribeTime`, `dispose`. Every browser dependency is injectable
|
|
72
|
-
(`clock`, `audioOutput`, `frameSourceFactory`, `audioSourceFactory`,
|
|
73
|
-
`createCanvas`, `raf`, `setInterval`), which is how the unit tests run in jsdom.
|
|
74
|
-
|
|
75
|
-
React: `<Player>` with `controls`, `loop`, `autoPlay`, `initiallyMuted`,
|
|
76
|
-
`playbackRate`, `fit`, `onError`, `onFrame` and a `PlayerRef`; hooks
|
|
77
|
-
`usePlayer`, `useCompositionTime`, `useCompositionFrame`, `useLayerT`.
|
|
78
|
-
Mounting a Player installs the kit's `useT()` and `useLayer()`.
|
|
79
|
-
|
|
80
|
-
## Not rendered yet
|
|
81
|
-
|
|
82
|
-
Transition types other than crossfade, dips to black or white, wipe, slide and push (drawn as a crossfade), effects that
|
|
83
|
-
have no CSS filter equivalent (sharpen, glow, …; vignette and grain are drawn),
|
|
84
|
-
colour wheels, curves and LUTs, matte masks, audio effects, pitch correction,
|
|
85
|
-
3D text, most text animation presets (shown as a fade),
|
|
86
|
-
`background.mode: "blur"` under overlays that sit beneath the footage (the
|
|
87
|
-
plain colour), sticker packs and `file:` nested references. The
|
|
88
|
-
kit's `not-rendered` lint warning reports these in the file before anything
|
|
89
|
-
plays, from the same table (`RENDERED_*` in `@cutcraft/kit`) the player reads.
|
|
90
|
-
|
|
91
|
-
## Tests
|
|
41
|
+
`<Player>` takes `state`, `element`, `media`, `controls`, `loop`, `autoPlay`, `initiallyMuted`, `playbackRate`, `fit`,
|
|
42
|
+
`onError` and `onFrame`, and exposes a `PlayerRef`. Hooks: `usePlayer`, `useCompositionTime`, `useCompositionFrame`, `useLayerT`.
|
|
43
|
+
Mounting a player makes the kit's `useT()` and `useLayer()` return the current time.
|
|
92
44
|
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
45
|
+
`PlayerCore` is the same player without React: `play`, `pause`, `toggle`, `seekTo`, `seekToFrame`, `renderFrame`,
|
|
46
|
+
`captureSheet`, `getCurrentTime`, `getCurrentFrame`, `isPlaying`, `duration`, `playbackRate`, `loop`, `muted`,
|
|
47
|
+
`volume`, `setState`, `attachCanvas`, `subscribeTime`, `dispose`, and the events `frameupdate`, `play`, `pause`,
|
|
48
|
+
`seeked`, `ended`, `ratechange`, `volumechange` and `error`. Every browser dependency (clock, audio output, canvas,
|
|
49
|
+
decoders) can be swapped out, which is how its tests run in jsdom.
|
|
50
|
+
|
|
51
|
+
## What it draws
|
|
52
|
+
|
|
53
|
+
Every transition, effect and animation preset the kit accepts: a type the player does not draw is not offered. The few
|
|
54
|
+
remaining limits are in [What renders](https://prefix-tree.github.io/cutcraft/reference/rendering), and the kit's lint
|
|
55
|
+
flags them in the file.
|
|
56
|
+
|
|
57
|
+
## Docs
|
|
58
|
+
|
|
59
|
+
- [Player](https://prefix-tree.github.io/cutcraft/guide/player) and the [API reference](https://prefix-tree.github.io/cutcraft/reference/api)
|
|
60
|
+
- [Free code](https://prefix-tree.github.io/cutcraft/guide/free-code)
|
|
97
61
|
|
|
98
|
-
|
|
99
|
-
strip), `tone.ogg`, `logo.png` and `solid.webm` into `e2e/app/public/`, then
|
|
100
|
-
checks seek accuracy, real-time playback on the audio clock, rate changes,
|
|
101
|
-
crossfade blending, DOM overlays and `useT`, image clips, ended/loop and
|
|
102
|
-
determinism. It needs `ffmpeg` and Playwright's Chromium (pinned to 1.56.1 to
|
|
103
|
-
match the preinstalled browser).
|
|
62
|
+
MIT licensed.
|
package/dist/engine.d.mts
CHANGED
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
import { $ as
|
|
2
|
-
|
|
3
|
-
export { AUDIO_CACHE_S, AUDIO_CHUNK_S, AUDIO_PRIME_S, AnyCanvas, AssetSourceDeps, AssetSources, AudioOccurrence, AudioOutput, AudioSource, AudioSourceFactory, AudioSourceInfo, BackgroundGradient, Box, CanvasPainter, ClipDecoder, ClipRect, Clock, Compositor, CompositorDeps, CreateCanvas, Ctx2D, DUCK_ATTACK_S, DUCK_RELEASE_S, DecodeMode, DecoderPool, DrawOp, DrawRect, EASING_FN, ENVELOPE_STEP_S, EnvelopePoint, ErrorFrame, ErrorFrameSource, FRAME_EPS, FRAME_WAIT_MS, FilterResult, Frame, FrameIntercept, FramePlan, FrameSource, FrameSourceFactory, FrameSourceHooks, FrameSourceInfo, GainPoint, GraphicAnimation, IDENTITY, INPUT_IDLE_CLOSE_S, ImageFrame, ImageFrameSource, LOOKAHEAD_S, Layout, MAX_OPEN_INPUTS, MAX_RATE, MIN_RATE, MOUNT_AHEAD_S, ManualClock, MaskSpec, Matrix2D, MediaHandle, MediaResolver, MediabunnyAudioSource, MediabunnyFrameSource, MediabunnyInputs, Motion, OVERLAY_KINDS, PICK_EPS, PLAY_PRIME_TIMEOUT_MS, PaintInputs, PerformanceClock, PlayerErrorEvent, PlayerEvents, PostEffect, QUEUE_MAX, QUEUE_TARGET, REVERSE_WINDOW_FRAMES, REVERSE_WINDOW_S, ResolveNested, SCHEDULER_MS, SEEK_MODE_SPEED, SETTLE_MS, STILL, SampleFrame, ScheduledSource, TickOptions, TransitionRole, UNMOUNT_BEHIND_S, VisibleItem, animatedTransform, backdropTracks, backgroundCss, backgroundFill, blendOf, boundsOf, buildAudioPlan, buildFramePlan, buildGainEnvelope, captureWarnings, combine, compositionBackground, copyFrame, coversCanvas, cssTransform, defaultCreateCanvas, devWarn, duckIntervals, ease, effect, filterString, fitRect, frameIndex, frameTime, fromMap, hasKeyframes, isVisibleAt, keyframedValue, layerClock, layoutRect, localT, makeNestedResolver, matrixToCss, mediabunnyAudioSourceFactory, mediabunnyFrameSourceFactory, motionAt, multiply, nestedSourceTime, paintBackground, placementSourceTime, postEffects, rotate, roundedRect, scaleM, setMatrix, timecode, toResolver, traceMask, trackItems, transformMatrix, translate, visiblePlacements };
|
|
1
|
+
import { $ as motionAt, $t as MAX_OPEN_INPUTS, A as GainPoint, An as PlayerErrorEvent, At as ErrorFrameSource, B as buildFramePlan, Bt as DecodeMode, C as EASING_FN, Cn as EnvelopePoint, Ct as MediabunnyFrameSource, D as OVERLAY_KINDS, Dn as FrameSourceInfo, Dt as mediabunnyAudioSourceFactory, E as keyframedValue, En as FrameSourceFactory, Et as MediabunnyAudioSource, F as DrawOp, Ft as FontFaceSource, G as trackItems, Gt as AUDIO_PRIME_S, H as TransitionRole, Ht as AssetSources, I as FramePlan, It as addFontFaces, J as GraphicAnimation, Jt as ENVELOPE_STEP_S, K as visiblePlacements, Kt as DUCK_ATTACK_S, L as MaskSpec, Lt as loadFileFonts, M as buildGainEnvelope, Mn as ScheduledSource, Mt as ImageFrameSource, N as duckIntervals, Nt as copyFrame, O as backdropTracks, On as MediaHandle, Ot as MediabunnyInputs, P as BackgroundGradient, Pt as defaultCreateCanvas, Q as effect, Qt as LOOKAHEAD_S, R as ResolveNested, Rt as DecoderPool, S as timecode, Sn as Ctx2D, St as toResolver, T as hasKeyframes, Tn as FrameSource, Tt as mediabunnyFrameSourceFactory, U as VisibleItem, Ut as AUDIO_CACHE_S, V as compositionBackground, Vt as AssetSourceDeps, W as isVisibleAt, Wt as AUDIO_CHUNK_S, X as STILL, Xt as FRAME_WAIT_MS, Y as Motion, Yt as FRAME_EPS, Z as combine, Zt as INPUT_IDLE_CLOSE_S, _ as frameTime, _n as AudioSource, _t as PostEffect, a as backgroundCss, an as QUEUE_MAX, at as animatedTransform, b as nestedSourceTime, bn as Clock, bt as postEffects, c as paintBackground, cn as REVERSE_WINDOW_S, ct as fitRect, d as traceMask, dn as SETTLE_MS, dt as multiply, en as MAX_RATE, et as Box, f as Compositor, fn as UNMOUNT_BEHIND_S, ft as rotate, g as frameIndex, gn as AudioOutput, gt as FilterResult, h as makeNestedResolver, hn as AnyCanvas, ht as translate, i as PaintInputs, in as PLAY_PRIME_TIMEOUT_MS, it as Matrix2D, j as buildAudioPlan, jn as PlayerEvents, jt as ImageFrame, k as AudioOccurrence, kn as MediaResolver, kt as ErrorFrame, l as setMatrix, ln as SCHEDULER_MS, lt as layoutRect, m as TickOptions, mn as PerformanceClock, mt as transformMatrix, n as devWarn, nn as MOUNT_AHEAD_S, nt as IDENTITY, o as backgroundFill, on as QUEUE_TARGET, ot as boundsOf, p as CompositorDeps, pn as ManualClock, pt as scaleM, q as ClipRect, qt as DUCK_RELEASE_S, r as CanvasPainter, rn as PICK_EPS, rt as Layout, s as coversCanvas, sn as REVERSE_WINDOW_FRAMES, st as cssTransform, t as captureWarnings, tn as MIN_RATE, tt as DrawRect, u as roundedRect, un as SEEK_MODE_SPEED, ut as matrixToCss, v as layerClock, vn as AudioSourceFactory, vt as filterString, w as ease, wn as Frame, wt as SampleFrame, x as placementSourceTime, xn as CreateCanvas, xt as fromMap, y as localT, yn as AudioSourceInfo, yt as paramsAt, z as blendOf, zt as ClipDecoder } from "./warn-GHM3SBI2.mjs";
|
|
2
|
+
export { AUDIO_CACHE_S, AUDIO_CHUNK_S, AUDIO_PRIME_S, AnyCanvas, AssetSourceDeps, AssetSources, AudioOccurrence, AudioOutput, AudioSource, AudioSourceFactory, AudioSourceInfo, BackgroundGradient, Box, CanvasPainter, ClipDecoder, ClipRect, Clock, Compositor, CompositorDeps, CreateCanvas, Ctx2D, DUCK_ATTACK_S, DUCK_RELEASE_S, DecodeMode, DecoderPool, DrawOp, DrawRect, EASING_FN, ENVELOPE_STEP_S, EnvelopePoint, ErrorFrame, ErrorFrameSource, FRAME_EPS, FRAME_WAIT_MS, FilterResult, FontFaceSource, Frame, FramePlan, FrameSource, FrameSourceFactory, FrameSourceInfo, GainPoint, GraphicAnimation, IDENTITY, INPUT_IDLE_CLOSE_S, ImageFrame, ImageFrameSource, LOOKAHEAD_S, Layout, MAX_OPEN_INPUTS, MAX_RATE, MIN_RATE, MOUNT_AHEAD_S, ManualClock, MaskSpec, Matrix2D, MediaHandle, MediaResolver, MediabunnyAudioSource, MediabunnyFrameSource, MediabunnyInputs, Motion, OVERLAY_KINDS, PICK_EPS, PLAY_PRIME_TIMEOUT_MS, PaintInputs, PerformanceClock, PlayerErrorEvent, PlayerEvents, PostEffect, QUEUE_MAX, QUEUE_TARGET, REVERSE_WINDOW_FRAMES, REVERSE_WINDOW_S, ResolveNested, SCHEDULER_MS, SEEK_MODE_SPEED, SETTLE_MS, STILL, SampleFrame, ScheduledSource, TickOptions, TransitionRole, UNMOUNT_BEHIND_S, VisibleItem, addFontFaces, animatedTransform, backdropTracks, backgroundCss, backgroundFill, blendOf, boundsOf, buildAudioPlan, buildFramePlan, buildGainEnvelope, captureWarnings, combine, compositionBackground, copyFrame, coversCanvas, cssTransform, defaultCreateCanvas, devWarn, duckIntervals, ease, effect, filterString, fitRect, frameIndex, frameTime, fromMap, hasKeyframes, isVisibleAt, keyframedValue, layerClock, layoutRect, loadFileFonts, localT, makeNestedResolver, matrixToCss, mediabunnyAudioSourceFactory, mediabunnyFrameSourceFactory, motionAt, multiply, nestedSourceTime, paintBackground, paramsAt, placementSourceTime, postEffects, rotate, roundedRect, scaleM, setMatrix, timecode, toResolver, traceMask, trackItems, transformMatrix, translate, visiblePlacements };
|
package/dist/engine.mjs
CHANGED
|
@@ -1,3 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import { A as buildAudioPlan, C as ImageFrameSource, D as toResolver, E as fromMap, M as duckIntervals, O as ManualClock, S as ImageFrame, T as defaultCreateCanvas, _ as DecoderPool, a as backgroundFill, b as ErrorFrame, c as setMatrix, d as MediabunnyAudioSource, f as mediabunnyAudioSourceFactory, g as MediabunnyInputs, h as mediabunnyFrameSourceFactory, i as backgroundCss, j as buildGainEnvelope, k as PerformanceClock, l as roundedRect, m as SampleFrame, n as Compositor, o as coversCanvas, p as MediabunnyFrameSource, r as CanvasPainter, s as paintBackground, t as makeNestedResolver, u as traceMask, v as ClipDecoder, w as copyFrame, x as ErrorFrameSource, y as AssetSources } from "./nested-DSXA1q8d.mjs";
|
|
3
|
-
export { AUDIO_CACHE_S, AUDIO_CHUNK_S, AUDIO_PRIME_S, AssetSources, CanvasPainter, ClipDecoder, Compositor, DUCK_ATTACK_S, DUCK_RELEASE_S, DecoderPool, EASING_FN, ENVELOPE_STEP_S, ErrorFrame, ErrorFrameSource, FRAME_EPS, FRAME_WAIT_MS, IDENTITY, INPUT_IDLE_CLOSE_S, ImageFrame, ImageFrameSource, LOOKAHEAD_S, MAX_OPEN_INPUTS, MAX_RATE, MIN_RATE, MOUNT_AHEAD_S, ManualClock, MediabunnyAudioSource, MediabunnyFrameSource, MediabunnyInputs, OVERLAY_KINDS, PICK_EPS, PLAY_PRIME_TIMEOUT_MS, PerformanceClock, QUEUE_MAX, QUEUE_TARGET, REVERSE_WINDOW_FRAMES, REVERSE_WINDOW_S, SCHEDULER_MS, SEEK_MODE_SPEED, SETTLE_MS, STILL, SampleFrame, UNMOUNT_BEHIND_S, animatedTransform, backdropTracks, backgroundCss, backgroundFill, blendOf, boundsOf, buildAudioPlan, buildFramePlan, buildGainEnvelope, captureWarnings, combine, compositionBackground, copyFrame, coversCanvas, cssTransform, defaultCreateCanvas, devWarn, duckIntervals, ease, effect, filterString, fitRect, frameIndex, frameTime, fromMap, hasKeyframes, isVisibleAt, keyframedValue, layerClock, layoutRect, localT, makeNestedResolver, matrixToCss, mediabunnyAudioSourceFactory, mediabunnyFrameSourceFactory, motionAt, multiply, nestedSourceTime, paintBackground, placementSourceTime, postEffects, rotate, roundedRect, scaleM, setMatrix, timecode, toResolver, traceMask, trackItems, transformMatrix, translate, visiblePlacements };
|
|
1
|
+
export { Tt as AUDIO_CACHE_S, Et as AUDIO_CHUNK_S, Dt as AUDIO_PRIME_S, st as AssetSources, n as CanvasPainter, $ as ClipDecoder, t as Compositor, Ot as DUCK_ATTACK_S, kt as DUCK_RELEASE_S, Y as DecoderPool, yt as EASING_FN, At as ENVELOPE_STEP_S, ct as ErrorFrame, lt as ErrorFrameSource, jt as FRAME_EPS, Mt as FRAME_WAIT_MS, b as IDENTITY, Nt as INPUT_IDLE_CLOSE_S, ut as ImageFrame, dt as ImageFrameSource, Pt as LOOKAHEAD_S, Ft as MAX_OPEN_INPUTS, It as MAX_RATE, Lt as MIN_RATE, Rt as MOUNT_AHEAD_S, mt as ManualClock, G as MediabunnyAudioSource, H as MediabunnyFrameSource, V as MediabunnyInputs, L as OVERLAY_KINDS, zt as PICK_EPS, Bt as PLAY_PRIME_TIMEOUT_MS, ht as PerformanceClock, Vt as QUEUE_MAX, Ht as QUEUE_TARGET, Ut as REVERSE_WINDOW_FRAMES, Wt as REVERSE_WINDOW_S, Gt as SCHEDULER_MS, Kt as SEEK_MODE_SPEED, qt as SETTLE_MS, g as STILL, U as SampleFrame, Jt as UNMOUNT_BEHIND_S, q as addFontFaces, x as animatedTransform, R as backdropTracks, r as backgroundCss, i as backgroundFill, f as blendOf, S as boundsOf, gt as buildAudioPlan, p as buildFramePlan, _t as buildGainEnvelope, Ct as captureWarnings, _ as combine, m as compositionBackground, ft as copyFrame, a as coversCanvas, C as cssTransform, pt as defaultCreateCanvas, wt as devWarn, vt as duckIntervals, bt as ease, v as effect, P as filterString, w as fitRect, et as frameIndex, tt as frameTime, z as fromMap, xt as hasKeyframes, X as isVisibleAt, St as keyframedValue, nt as layerClock, T as layoutRect, J as loadFileFonts, rt as localT, d as makeNestedResolver, E as matrixToCss, K as mediabunnyAudioSourceFactory, W as mediabunnyFrameSourceFactory, y as motionAt, D as multiply, it as nestedSourceTime, o as paintBackground, F as paramsAt, at as placementSourceTime, I as postEffects, O as rotate, l as roundedRect, k as scaleM, s as setMatrix, ot as timecode, B as toResolver, u as traceMask, Z as trackItems, A as transformMatrix, j as translate, Q as visiblePlacements } from "./render-DA1KFyei.mjs";
|
package/dist/index.d.mts
CHANGED
|
@@ -1,24 +1,6 @@
|
|
|
1
|
-
import { $ as
|
|
2
|
-
import { A as visiblePlacements, C as scaleM, D as VisibleItem, E as TransitionRole, F as nestedSourceTime, I as placementSourceTime, L as timecode, M as frameTime, N as layerClock, O as isVisibleAt, P as localT, S as rotate, T as translate, _ as cssTransform, a as Motion, b as matrixToCss, c as effect, d as DrawRect, f as IDENTITY, g as boundsOf, h as animatedTransform, i as GraphicAnimation, j as frameIndex, k as trackItems, l as motionAt, m as Matrix2D, n as backdropTracks, o as STILL, p as Layout, r as ClipRect, s as combine, t as OVERLAY_KINDS, u as Box, v as fitRect, w as transformMatrix, x as multiply, y as layoutRect } from "./backdrop-BqrzCzTB.mjs";
|
|
3
|
-
import { t as indexLayerInteriors } from "./layer-interiors-r4SeMbp2.mjs";
|
|
1
|
+
import { $ as motionAt, $t as MAX_OPEN_INPUTS, A as GainPoint, An as PlayerErrorEvent, At as ErrorFrameSource, B as buildFramePlan, Bt as DecodeMode, C as EASING_FN, Cn as EnvelopePoint, Ct as MediabunnyFrameSource, D as OVERLAY_KINDS, Dn as FrameSourceInfo, Dt as mediabunnyAudioSourceFactory, E as keyframedValue, En as FrameSourceFactory, Et as MediabunnyAudioSource, F as DrawOp, Ft as FontFaceSource, G as trackItems, Gt as AUDIO_PRIME_S, H as TransitionRole, Ht as AssetSources, I as FramePlan, It as addFontFaces, J as GraphicAnimation, Jt as ENVELOPE_STEP_S, K as visiblePlacements, Kt as DUCK_ATTACK_S, L as MaskSpec, Lt as loadFileFonts, M as buildGainEnvelope, Mn as ScheduledSource, Mt as ImageFrameSource, N as duckIntervals, Nt as copyFrame, O as backdropTracks, On as MediaHandle, Ot as MediabunnyInputs, P as BackgroundGradient, Pt as defaultCreateCanvas, Q as effect, Qt as LOOKAHEAD_S, R as ResolveNested, Rt as DecoderPool, S as timecode, Sn as Ctx2D, St as toResolver, T as hasKeyframes, Tn as FrameSource, Tt as mediabunnyFrameSourceFactory, U as VisibleItem, Ut as AUDIO_CACHE_S, V as compositionBackground, Vt as AssetSourceDeps, W as isVisibleAt, Wt as AUDIO_CHUNK_S, X as STILL, Xt as FRAME_WAIT_MS, Y as Motion, Yt as FRAME_EPS, Z as combine, Zt as INPUT_IDLE_CLOSE_S, _ as frameTime, _n as AudioSource, _t as PostEffect, a as backgroundCss, an as QUEUE_MAX, at as animatedTransform, b as nestedSourceTime, bn as Clock, bt as postEffects, c as paintBackground, cn as REVERSE_WINDOW_S, ct as fitRect, d as traceMask, dn as SETTLE_MS, dt as multiply, en as MAX_RATE, et as Box, f as Compositor, fn as UNMOUNT_BEHIND_S, ft as rotate, g as frameIndex, gn as AudioOutput, gt as FilterResult, h as makeNestedResolver, hn as AnyCanvas, ht as translate, i as PaintInputs, in as PLAY_PRIME_TIMEOUT_MS, it as Matrix2D, j as buildAudioPlan, jn as PlayerEvents, jt as ImageFrame, k as AudioOccurrence, kn as MediaResolver, kt as ErrorFrame, l as setMatrix, ln as SCHEDULER_MS, lt as layoutRect, m as TickOptions, mn as PerformanceClock, mt as transformMatrix, n as devWarn, nn as MOUNT_AHEAD_S, nt as IDENTITY, o as backgroundFill, on as QUEUE_TARGET, ot as boundsOf, p as CompositorDeps, pn as ManualClock, pt as scaleM, q as ClipRect, qt as DUCK_RELEASE_S, r as CanvasPainter, rn as PICK_EPS, rt as Layout, s as coversCanvas, sn as REVERSE_WINDOW_FRAMES, st as cssTransform, t as captureWarnings, tn as MIN_RATE, tt as DrawRect, u as roundedRect, un as SEEK_MODE_SPEED, ut as matrixToCss, v as layerClock, vn as AudioSourceFactory, vt as filterString, w as ease, wn as Frame, wt as SampleFrame, x as placementSourceTime, xn as CreateCanvas, xt as fromMap, y as localT, yn as AudioSourceInfo, yt as paramsAt, z as blendOf, zt as ClipDecoder } from "./warn-GHM3SBI2.mjs";
|
|
4
2
|
import { LayerClock, ResolvedState } from "@cutcraft/kit";
|
|
5
3
|
import { CSSProperties, ReactNode } from "react";
|
|
6
|
-
/**
|
|
7
|
-
* `AudioContext.currentTime` while the context runs, the performance clock
|
|
8
|
-
* otherwise, with an offset captured at every state change so `now()` never
|
|
9
|
-
* jumps. Audio scheduling converts back with `toContextTime`.
|
|
10
|
-
*/
|
|
11
|
-
export declare class AudioContextClock implements Clock {
|
|
12
|
-
private readonly ctx;
|
|
13
|
-
private offset;
|
|
14
|
-
private wasRunning;
|
|
15
|
-
private lastNow;
|
|
16
|
-
constructor(ctx: BaseAudioContext);
|
|
17
|
-
get running(): boolean;
|
|
18
|
-
now(): number;
|
|
19
|
-
/** Audio context seconds for a clock time; exact while the context runs. */
|
|
20
|
-
toContextTime(clockTime: number): number;
|
|
21
|
-
}
|
|
22
4
|
/**
|
|
23
5
|
* Composition time as an anchor on the clock: `anchorTime + (now − anchorClock) × rate`.
|
|
24
6
|
* Every play, pause, seek and rate change re-anchors, so time is always derived from
|
|
@@ -110,6 +92,22 @@ export declare class WebAudioOutput implements AudioOutput {
|
|
|
110
92
|
private stop;
|
|
111
93
|
private disconnect;
|
|
112
94
|
}
|
|
95
|
+
/**
|
|
96
|
+
* `AudioContext.currentTime` while the context runs, the performance clock
|
|
97
|
+
* otherwise, with an offset captured at every state change so `now()` never
|
|
98
|
+
* jumps. Audio scheduling converts back with `toContextTime`.
|
|
99
|
+
*/
|
|
100
|
+
export declare class AudioContextClock implements Clock {
|
|
101
|
+
private readonly ctx;
|
|
102
|
+
private offset;
|
|
103
|
+
private wasRunning;
|
|
104
|
+
private lastNow;
|
|
105
|
+
constructor(ctx: BaseAudioContext);
|
|
106
|
+
get running(): boolean;
|
|
107
|
+
now(): number;
|
|
108
|
+
/** Audio context seconds for a clock time; exact while the context runs. */
|
|
109
|
+
toContextTime(clockTime: number): number;
|
|
110
|
+
}
|
|
113
111
|
export interface CaptureSheetOptions {
|
|
114
112
|
/** Cells per row; default 4, never more than the number of times. */
|
|
115
113
|
readonly columns?: number;
|
|
@@ -125,6 +123,13 @@ export interface PlayerOptions {
|
|
|
125
123
|
readonly loop?: boolean | undefined;
|
|
126
124
|
readonly initiallyMuted?: boolean | undefined;
|
|
127
125
|
readonly playbackRate?: number | undefined;
|
|
126
|
+
/** Load the file's fonts (`state.fonts`) into the page; default true. The export page loads them itself. */
|
|
127
|
+
readonly loadFonts?: boolean | undefined;
|
|
128
|
+
/**
|
|
129
|
+
* Re-render overlays for every change of time, not once per frame; default false. The export sets it to draw the
|
|
130
|
+
* moments inside a frame that motion blur averages.
|
|
131
|
+
*/
|
|
132
|
+
readonly exactTime?: boolean | undefined;
|
|
128
133
|
readonly resolveNested?: ResolveNested | undefined;
|
|
129
134
|
/** Test seams; the browser defaults are the audio-context clock, Web Audio and mediabunny. */
|
|
130
135
|
readonly clock?: Clock | undefined;
|
|
@@ -175,7 +180,15 @@ export declare class PlayerCore {
|
|
|
175
180
|
private _muted;
|
|
176
181
|
private _volume;
|
|
177
182
|
private disposed;
|
|
183
|
+
private fonts;
|
|
184
|
+
private fontsOf;
|
|
185
|
+
private readonly fontsWanted;
|
|
178
186
|
constructor(options: PlayerOptions);
|
|
187
|
+
/** Resolves once the file's fonts (`state.fonts`) have loaded; a face that fails is reported as an error event. */
|
|
188
|
+
/** Overlays follow every change of time, not each frame (`exactTime`). */
|
|
189
|
+
readonly exactTime: boolean;
|
|
190
|
+
get fontsReady(): Promise<void>;
|
|
191
|
+
private loadFonts;
|
|
179
192
|
get state(): ResolvedState;
|
|
180
193
|
get duration(): number;
|
|
181
194
|
get playbackRate(): number;
|
|
@@ -226,18 +239,17 @@ export declare class PlayerCore {
|
|
|
226
239
|
private emit;
|
|
227
240
|
private audioSource;
|
|
228
241
|
}
|
|
242
|
+
/**
|
|
243
|
+
* Walk the file's element tree the way the kit's `collect` does (fragments,
|
|
244
|
+
* vocabulary elements, pure helpers expanded by calling them) and record the
|
|
245
|
+
* children of every `<Layer id>`: the resolver drops them, the Player renders them.
|
|
246
|
+
*/
|
|
247
|
+
export declare function indexLayerInteriors(element: ReactNode): Map<string, ReactNode>;
|
|
248
|
+
/** Play/pause, scrubber, time readout, mute and rate. */
|
|
249
|
+
export declare function Controls(): import("react").JSX.Element;
|
|
229
250
|
export declare const PlayerContext: import("react").Context<PlayerCore | null>;
|
|
230
251
|
/** The layer's clock inside a `<Layer>`; null outside one. */
|
|
231
252
|
export declare const LayerContext: import("react").Context<LayerClock | null>;
|
|
232
|
-
export declare function usePlayer(): PlayerCore;
|
|
233
|
-
export declare function useCompositionTime(): number;
|
|
234
|
-
export declare function useCompositionFrame(): number;
|
|
235
|
-
/** What the kit's `useLayer()` and `useT()` delegate to while a Player is mounted. */
|
|
236
|
-
export declare function useLayerClock(): LayerClock;
|
|
237
|
-
/** 0..1 progress through the enclosing Layer. */
|
|
238
|
-
export declare function useLayerT(): number;
|
|
239
|
-
/** Installs the kit's layer hooks for the first mounted Player and removes them after the last unmounts. */
|
|
240
|
-
export declare function retainUseT(): () => void;
|
|
241
253
|
export interface DomLayerProps {
|
|
242
254
|
readonly state: ResolvedState;
|
|
243
255
|
readonly interiors: ReadonlyMap<string, ReactNode>;
|
|
@@ -251,6 +263,8 @@ export interface ElementCellProps {
|
|
|
251
263
|
state: ResolvedState;
|
|
252
264
|
time: number;
|
|
253
265
|
interior: ReactNode;
|
|
266
|
+
/** Re-render for any change of time, not only a new frame (the player's `exactTime`). */
|
|
267
|
+
exact?: boolean;
|
|
254
268
|
}
|
|
255
269
|
/**
|
|
256
270
|
* Whether two renders of an overlay would produce the same DOM. Placements
|
|
@@ -260,8 +274,23 @@ export interface ElementCellProps {
|
|
|
260
274
|
* composition box.
|
|
261
275
|
*/
|
|
262
276
|
export declare function sameElement(a: ElementCellProps, b: ElementCellProps): boolean;
|
|
263
|
-
/**
|
|
264
|
-
|
|
277
|
+
/**
|
|
278
|
+
* Holds the CSS animations under `root` at `seconds` past the layer's start: paused, and seeked there. They then
|
|
279
|
+
* follow the video's clock (play, pause, scrub both ways) and an export captures the same frame twice.
|
|
280
|
+
*
|
|
281
|
+
* Only CSS animations: their zero is the moment their element got the style, which inside a Layer is the layer's
|
|
282
|
+
* start. A Web Animation made with `element.animate()` or by a library keeps its own start and its owner's clock.
|
|
283
|
+
*/
|
|
284
|
+
export declare function holdCssAnimations(root: Element | null, seconds: number): void;
|
|
285
|
+
export declare function usePlayer(): PlayerCore;
|
|
286
|
+
export declare function useCompositionTime(): number;
|
|
287
|
+
export declare function useCompositionFrame(): number;
|
|
288
|
+
/** What the kit's `useLayer()` and `useT()` delegate to while a Player is mounted. */
|
|
289
|
+
export declare function useLayerClock(): LayerClock;
|
|
290
|
+
/** 0..1 progress through the enclosing Layer. */
|
|
291
|
+
export declare function useLayerT(): number;
|
|
292
|
+
/** Installs the kit's layer hooks for the first mounted Player and removes them after the last unmounts. */
|
|
293
|
+
export declare function retainUseT(): () => void;
|
|
265
294
|
export interface PlayerProps {
|
|
266
295
|
readonly state: ResolvedState;
|
|
267
296
|
readonly media: MediaResolver | Readonly<Record<string, Blob | string>>;
|
|
@@ -295,4 +324,4 @@ export type PlayerRef = Pick<PlayerCore, "play" | "pause" | "toggle" | "seekTo"
|
|
|
295
324
|
* `data-time` and `data-frame`; every element carries `data-el`/`data-kind`.
|
|
296
325
|
*/
|
|
297
326
|
export declare const Player: import("react").ForwardRefExoticComponent<PlayerProps & import("react").RefAttributes<PlayerRef>>;
|
|
298
|
-
export { AUDIO_CACHE_S, AUDIO_CHUNK_S, AUDIO_PRIME_S, AnyCanvas, AssetSourceDeps, AssetSources, AudioOccurrence, AudioOutput, AudioSource, AudioSourceFactory, AudioSourceInfo, BackgroundGradient, Box, CanvasPainter, ClipDecoder, ClipRect, Clock, Compositor, CompositorDeps, CreateCanvas, Ctx2D, DUCK_ATTACK_S, DUCK_RELEASE_S, DecodeMode, DecoderPool, DrawOp, DrawRect, EASING_FN, ENVELOPE_STEP_S, EnvelopePoint, ErrorFrame, ErrorFrameSource, FRAME_EPS, FRAME_WAIT_MS, FilterResult,
|
|
327
|
+
export { AUDIO_CACHE_S, AUDIO_CHUNK_S, AUDIO_PRIME_S, AnyCanvas, AssetSourceDeps, AssetSources, AudioOccurrence, AudioOutput, AudioSource, AudioSourceFactory, AudioSourceInfo, BackgroundGradient, Box, CanvasPainter, ClipDecoder, ClipRect, Clock, Compositor, CompositorDeps, CreateCanvas, Ctx2D, DUCK_ATTACK_S, DUCK_RELEASE_S, DecodeMode, DecoderPool, DrawOp, DrawRect, EASING_FN, ENVELOPE_STEP_S, EnvelopePoint, ErrorFrame, ErrorFrameSource, FRAME_EPS, FRAME_WAIT_MS, FilterResult, FontFaceSource, Frame, FramePlan, FrameSource, FrameSourceFactory, FrameSourceInfo, GainPoint, GraphicAnimation, IDENTITY, INPUT_IDLE_CLOSE_S, ImageFrame, ImageFrameSource, LOOKAHEAD_S, Layout, MAX_OPEN_INPUTS, MAX_RATE, MIN_RATE, MOUNT_AHEAD_S, ManualClock, MaskSpec, Matrix2D, MediaHandle, MediaResolver, MediabunnyAudioSource, MediabunnyFrameSource, MediabunnyInputs, Motion, OVERLAY_KINDS, PICK_EPS, PLAY_PRIME_TIMEOUT_MS, PaintInputs, PerformanceClock, PlayerErrorEvent, PlayerEvents, PostEffect, QUEUE_MAX, QUEUE_TARGET, REVERSE_WINDOW_FRAMES, REVERSE_WINDOW_S, ResolveNested, SCHEDULER_MS, SEEK_MODE_SPEED, SETTLE_MS, STILL, SampleFrame, ScheduledSource, TickOptions, TransitionRole, UNMOUNT_BEHIND_S, VisibleItem, addFontFaces, animatedTransform, backdropTracks, backgroundCss, backgroundFill, blendOf, boundsOf, buildAudioPlan, buildFramePlan, buildGainEnvelope, captureWarnings, combine, compositionBackground, copyFrame, coversCanvas, cssTransform, defaultCreateCanvas, devWarn, duckIntervals, ease, effect, filterString, fitRect, frameIndex, frameTime, fromMap, hasKeyframes, isVisibleAt, keyframedValue, layerClock, layoutRect, loadFileFonts, localT, makeNestedResolver, matrixToCss, mediabunnyAudioSourceFactory, mediabunnyFrameSourceFactory, motionAt, multiply, nestedSourceTime, paintBackground, paramsAt, placementSourceTime, postEffects, rotate, roundedRect, scaleM, setMatrix, timecode, toResolver, traceMask, trackItems, transformMatrix, translate, visiblePlacements };
|