mirror of
https://github.com/heygen-com/hyperframes.git
synced 2026-09-05 00:56:23 +00:00
* fix(core): dedupe the wet/dry mix math between delayFeedback and chorusLfo Both effect builders set wet.gain to the mix and dry.gain to its complement in identical two-line blocks; fallow kept re-flagging it as a 10-line clone on every unrelated change. Extracted setWetDryMix. * fix(core): remove the build-audio-fx-runtime.ts stray resurrected by a main merge An earlier merge with main brought this deleted file back (git's merge/delete handling on an unchanged-on-one-side file); package.json already points at build-inline-artifact.ts, so it sat unreachable and duplicating that file's config, both of which fallow flagged. * fix(studio): pull TimelineLanes under the 600-line cap TimelineLanes.tsx hit 620 lines. Extracted the three per-clip pointer gestures (resize-start, pointer-down move-arm, click/razor-split) into createClipGestureHandlers — one factory call per rendered clip instead of ~120 lines of inline handler bodies in the render loop. 529 lines now. * fix(studio): split the extracted pointerdown handler under the CRAP threshold Moving the ~120-line gesture logic into timelineClipGestureHandlers.ts concentrated it into two functions fallow flagged (onPointerDown at CRAP 63.6, onResizeStart at 31.6). Split the decision logic (which gesture a pointerdown implies) into a pure resolvePointerDownAction, then split its own intent-blocking check into isIntentBlocked. onResizeStart's guard moved into canStartResize. Every function now scores under 30. * fix(studio): drop the unused DomEditSelection import in PropertyPanelFlat CI caught it on PR #3026 (wa-12-panel-params); a later refactor in the stack removed the last use of the type here without removing the import. * fix(studio): close the typecheck and fallow gaps wa-18b-reschedule opened useAutomationLanes.ts's write() assumed gesture-scoped coalescing and a preview-only commit that useDomEditAttributeCommits.ts never grew — backported that option support from its own later commit so the two sides of the API agree. The paste path and its tests were missing the box selection's v0/v1 bounds a sibling commit added to AutomationSelection. The FX panel's carve controls still edited the six mechanism numbers (maxCutDb, bands, intelligibilityBias) after carveProfile() collapsed authoring to one Strength knob, so those fields no longer existed on HfCarveSettings; UI now edits strength, and analyseCarveBands is called with carveProfile(strength). Also closes fallow's complexity, dead-code and duplication findings on this PR's diff: extracted automationLaneDragMath.ts (pure group/point-move math) and useAutomationRangeDrag.ts (the marquee-select gesture) out of useAutomationLaneGestures.ts, pulled a couple of render-loop ternaries and a resolver into named functions, dropped an export nothing outside its file used, and shared a step-simplifier between audioCarve's two envelope builders. The edge-stretch vs. box-select priority test in TimelineAutomationLane.test was still pinning the pre-box-select rule (edge wins over a point sitting on it) that a sibling commit deliberately reversed — a point inside the box is now selected content, so grabbing it drags the group instead. Updated the test to the shipped rule instead of the old one. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> * fix(core): cap the via conic's weight so an edge-clamped via point can't NaN A via point pulled out past the segment (viaX: 5, viaY: -3) clamps to (0.999, 0.001) — exactly on the steady region's edge, where edge - viaX is 0. viaConic divided by that zero to get an infinite weight, and shapeVia turned Infinity into NaN a few steps later (Infinity - Infinity in the quadratic coefficient). NaN reaching setValueCurveAtTime silences the automated parameter for the rest of the render. Capped the weight at 1e6 instead of leaving it unbounded — past that point the arc already reads as touching the via point, so nothing visible is lost. Also hardened shapeVia's existing denominator guard (`<= 0`) to `!(> 0)`, since NaN fails the original comparison and fell through it. Review by Miga (PR #3208). * fix(studio-server): fingerprint the proactive waveform cache key too The route already keys the waveform cache on the asset's size and mtime as well as its path, so a rebuilt-in-place file gets fresh peaks instead of stale ones. generateWaveformCache — the proactive path that runs on upload — still called buildWaveformCacheKey with the path alone, so it wrote to a different key than the route reads from (making the pre-generated cache never found) and kept the exact collision bug this fingerprint exists to fix on its own path. Review by Miga (PR #3211). * style(docs): run oxfmt on the /hyperframes-audio skill docs Table column widths had drifted out of alignment with oxfmt's own rules, failing format:check and blocking the Preflight gate every downstream branch inherits. Whitespace only, no content change. * fix(core): stop \b from missing underscore-separated names, guard clipsOverlap's negative duration \b treats `_` as a word character, so \bbed\b never matched bed_01, music_bed_loop, or theme_song, and \bvo\b/\bvox\b/\btts\b had the same gap — an underscore-separated bed classified as "unknown" and could end up offered as its own carve source. Replaced the short hints with a boundary that actually excludes letters and digits on both sides. clipsOverlap computed end = start + duration without guarding sign, so a negative duration put end before start — an interval that does not describe anything, and one specific case showed it silently dropping a real overlap (a shorter, earlier broken end rejected a clip that genuinely contained the point). Duration clamps to zero instead: a clip cannot un-play time, and a zero-length clip at its start is the sane reading of "duration nobody wrote down as positive." Review by Miga (PR #3212). * fix(studio): widen PropertyPanel's resetModules render timeout again The 20s margin (already once widened for the same reason) is timing out in CI's full-monorepo Test run — the resetModules()+fresh-import render this test needs is uncached and competes with every other package's test suite for the same worker pool, and the same test passes in well under 2s standalone. Went to 45s rather than re-tuning to whatever number happens to clear the current CI load, since that number moves every time CI gains a package. * fix(studio): stop the single-candidate auto-apply carve firing twice Two auto-apply effects both fire when sourceOptions.length === 1: the multi-candidate effect only guards length === 0, so a single candidate passes it too, and the single-candidate effect passes its own guard right after — both compute the same sources list and both call setCarve, so the common case (one narrator, one bed) triggered two decodes, two FFT runs, and two concurrent attribute writes for one decision. The multi-candidate effect now defers to its sibling for exactly one candidate, which already has its own detailed handling for that case. Review by Miga (PR #3213). * feat(core): carve against every voice over a bed, always (#3212) * feat(core): carve against every voice over a bed, always dynamically A bed usually runs under a whole sequence — a narrator, an interview answer, a second presenter — and carving against one of them left the others fighting it. `source` becomes `sources`, and `mixCarveSources` sums every voice onto the BED's clock before anything is measured. That is what keeps one analysis sufficient: the chain is fixed, so there is no per-voice filter to switch between, and bands drawn from all the speech there is with envelopes that rise wherever any of it happens answer the actual question — where and when is speech masking this bed. Summed rather than averaged: two people talking at once mask more than either alone. Audio before the bed starts is dropped rather than folded in at zero, since it plays over nothing and shifting it would put a cut where there is no voice. `dynamic` is gone. A fixed depth thins the bed through every pause, and once both have been heard there is no reason to want it, so every carve follows the speech. Two helpers the panel and the headless script now share instead of each carrying a copy — two definitions of "what does this name suggest" drift, and then the two disagree about which track is the voice: - `classifyAudioName` reads a track's kind from its id and filename together. `unknown` is deliberately common: treating an unrecognised name as "not a voice" would hide the one track somebody needs to pick. - `clipsOverlap` keeps out a voice that never plays while the bed does. An unwritten duration counts as unbounded, not zero — refusing a clip whose length the composition leaves to the media would drop the commonest case there is. Files written before this still load: a single `source` reads as a one-voice list, a stored `dynamic` is ignored, and an absent attribute means the defaults whole. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> * fix(core): stop \b from missing underscore-separated names, guard clipsOverlap's negative duration \b treats `_` as a word character, so \bbed\b never matched bed_01, music_bed_loop, or theme_song, and \bvo\b/\bvox\b/\btts\b had the same gap — an underscore-separated bed classified as "unknown" and could end up offered as its own carve source. Replaced the short hints with a boundary that actually excludes letters and digits on both sides. clipsOverlap computed end = start + duration without guarding sign, so a negative duration put end before start — an interval that does not describe anything, and one specific case showed it silently dropping a real overlap (a shorter, earlier broken end rejected a clip that genuinely contained the point). Duration clamps to zero instead: a clip cannot un-play time, and a zero-length clip at its start is the sane reading of "duration nobody wrote down as positive." Review by Miga (PR #3212). --------- Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com> * fix(studio): port the carve UI off the removed source/dynamic fields #3212 (accidentally squash-merged into this branch instead of main) changed HfCarveSettings from a single `source` + `dynamic` toggle to a `sources` list with dynamic mode removed outright — the multi-voice UI consumer that goes with that shape lands in the very next PR, so this branch was left with a type that no longer matched its own code. Minimal port, not the multi-voice redesign that PR does properly: the "Listen to" picker and analyse() treat sources[0] as the one voice this UI still understands, and every dynamic-mode branch (the automated envelope lanes, the toggle, the checkbox) is gone along with the field — a carve is now always the static value the analysis computes, matching what the type change made permanent. Test suite trimmed the same way: the automation-lane and toggle tests covered behavior that no longer exists. --------- Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
269 lines
10 KiB
TypeScript
269 lines
10 KiB
TypeScript
import { useMemo, type MouseEvent as ReactMouseEvent, type RefObject } from "react";
|
|
import {
|
|
classifyPropertyGroup,
|
|
type GsapAnimation,
|
|
type PropertyGroupName,
|
|
} from "@hyperframes/core/gsap-parser";
|
|
import { toClipKeyframes } from "../../hooks/gsapShared";
|
|
import { synthesizeFlatTweenKeyframes } from "../../hooks/gsapTweenSynth";
|
|
import { TimelineDiamondLane, type TimelineDiamondKeyframe } from "./TimelineClipDiamonds";
|
|
import { LANE_H, getTimelineLaneTop } from "./timelineLayout";
|
|
import type { TimelineKeyframeTarget } from "./timelineKeyframeIdentity";
|
|
import { timelineLogicalRowCellId, timelinePropertyRowId } from "./timelineNavigationIdentity";
|
|
|
|
export interface TimelinePropertyLanesProps {
|
|
/**
|
|
* Id of the wrapper below, so the layer's disclosure caret can point
|
|
* `aria-controls` at the lanes a sighted user sees it reveal. Minted by
|
|
* TimelineLanes, which owns both this subtree and the caret's.
|
|
*/
|
|
id: string;
|
|
animations: readonly GsapAnimation[];
|
|
clipStart: number;
|
|
clipDuration: number;
|
|
clipLeftPx: number;
|
|
clipWidthPx: number;
|
|
accentColor: string;
|
|
isSelected: boolean;
|
|
currentPercentage: number;
|
|
elementId: string;
|
|
selectedKeyframes: ReadonlySet<string>;
|
|
rovingTargetId?: string | null;
|
|
onSelectSegment?: (target: TimelineKeyframeTarget) => void;
|
|
onClickKeyframe?: (target: TimelineKeyframeTarget) => void;
|
|
onShiftClickKeyframe?: (target: TimelineKeyframeTarget) => void;
|
|
onContextMenuKeyframe?: (e: ReactMouseEvent, target: TimelineKeyframeTarget) => void;
|
|
onMoveKeyframe?: (target: TimelineKeyframeTarget, toClipPercentage: number) => Promise<boolean>;
|
|
suppressClickRef?: RefObject<boolean>;
|
|
}
|
|
|
|
/**
|
|
* Keys that ride along in a tween's property bag without being animated: a
|
|
* transform modifier, Studio's internal endpoint marker, and GSAP's reserved
|
|
* `data`. Same exclusion list the parser's classifyTweenPropertyGroup applies —
|
|
* without it `{ x, transformOrigin }` would draw a spurious "Other" lane.
|
|
*/
|
|
const NON_ANIMATED_PROPERTIES = new Set(["transformOrigin", "_auto", "data"]);
|
|
|
|
function isAnimatedProperty(property: string): boolean {
|
|
return !NON_ANIMATED_PROPERTIES.has(property);
|
|
}
|
|
|
|
function hasGroupProperty(
|
|
properties: Record<string, number | string>,
|
|
group: PropertyGroupName,
|
|
): boolean {
|
|
return Object.keys(properties).some(
|
|
(property) => isAnimatedProperty(property) && classifyPropertyGroup(property) === group,
|
|
);
|
|
}
|
|
|
|
/** The tween's editable keyframes: its real keyframes, or the start→end pair
|
|
* synthesized for a flat tween. Empty for a tween that animates nothing. */
|
|
function animationKeyframes(animation: GsapAnimation) {
|
|
return animation.keyframes?.keyframes ?? synthesizeFlatTweenKeyframes(animation)?.keyframes ?? [];
|
|
}
|
|
|
|
/**
|
|
* Every property group a tween draws a lane for, classified PER PROPERTY.
|
|
* `animation.propertyGroup` is the parser's whole-tween verdict and is
|
|
* `undefined` for anything spanning more than one group — but `{ x, opacity }`
|
|
* is the canonical HyperFrames entrance tween, and reading that verdict gave it
|
|
* no caret, no reserved row and no diamonds. classifyPropertyGroup is total, so
|
|
* an unrecognised property still lands in "other" rather than vanishing.
|
|
*
|
|
* Single owner: the rendered lanes (sourceGroups) and the reserved row heights
|
|
* (computeLaneCounts) both count groups through here, or they drift.
|
|
*/
|
|
export function animationLaneGroups(animation: GsapAnimation): PropertyGroupName[] {
|
|
const groups = new Set<PropertyGroupName>();
|
|
for (const keyframe of animationKeyframes(animation)) {
|
|
for (const property of Object.keys(keyframe.properties)) {
|
|
if (isAnimatedProperty(property)) groups.add(classifyPropertyGroup(property));
|
|
}
|
|
}
|
|
return Array.from(groups);
|
|
}
|
|
|
|
/**
|
|
* Which tween a panel edit to `prop` belongs to.
|
|
*
|
|
* Matches on the groups the tween's KEYFRAMES animate, not on the parser's
|
|
* whole-tween `propertyGroup` verdict: that field is undefined for a legacy
|
|
* mixed tween such as `{ x, opacity }`, so matching it dropped every such
|
|
* tween and sent the edit to the selection's default animation instead, which
|
|
* is a different tween than the lane the user is looking at.
|
|
* {@link animationLaneGroups} is the single owner the rendered lanes count
|
|
* groups through, so resolving here through the same helper keeps the panel
|
|
* and the lanes on one answer.
|
|
*/
|
|
export function resolveAnimIdForProperty(
|
|
prop: string,
|
|
animations: readonly GsapAnimation[] | undefined,
|
|
fallbackAnimId: string | undefined,
|
|
): string {
|
|
const group = classifyPropertyGroup(prop);
|
|
const groupAnim = animations?.find((a) => animationLaneGroups(a).includes(group));
|
|
return groupAnim?.id ?? fallbackAnimId ?? "";
|
|
}
|
|
|
|
/** A tween contributes a property lane when it animates at least one property
|
|
* on at least one editable keyframe (real or synthesized). */
|
|
export function animationContributesLane(animation: GsapAnimation): boolean {
|
|
return animationLaneGroups(animation).length > 0;
|
|
}
|
|
|
|
function sourceGroups(animations: readonly GsapAnimation[]) {
|
|
const groups = new Map<PropertyGroupName, GsapAnimation[]>();
|
|
for (const animation of animations) {
|
|
for (const group of animationLaneGroups(animation)) {
|
|
const groupAnimations = groups.get(group) ?? [];
|
|
groupAnimations.push(animation);
|
|
groups.set(group, groupAnimations);
|
|
}
|
|
}
|
|
return groups;
|
|
}
|
|
|
|
/** Resolve the ease from THIS keyframe's own source tween. A lane can merge
|
|
* several tweens, so a shared lane-level fallback would label a segment with a
|
|
* different animation's ease than the one the ease editor targets (it routes
|
|
* by animationId). */
|
|
function keyframeEase(keyframe: { ease?: string }, animation: GsapAnimation): string | undefined {
|
|
return keyframe.ease ?? animation.keyframes?.easeEach ?? animation.ease;
|
|
}
|
|
|
|
/**
|
|
* One lane row per keyframe of `group`. The clip-% re-basing goes through the
|
|
* shared toClipKeyframes so lane rows land on the exact same percentage the
|
|
* keyframe cache writes: this file used to derive it inline and skipped that
|
|
* helper's rounding, which is the one precision every keyframe-cache writer has
|
|
* to agree on (selection keys embed the number).
|
|
*/
|
|
function groupKeyframes(
|
|
animations: readonly GsapAnimation[],
|
|
group: PropertyGroupName,
|
|
clipStart: number,
|
|
clipDuration: number,
|
|
): TimelineDiamondKeyframe[] {
|
|
const keyframes: TimelineDiamondKeyframe[] = [];
|
|
for (const animation of animations) {
|
|
const inGroup = animationKeyframes(animation).filter((keyframe) =>
|
|
hasGroupProperty(keyframe.properties, group),
|
|
);
|
|
for (const keyframe of toClipKeyframes(inGroup, animation, clipStart, clipDuration)) {
|
|
keyframes.push({
|
|
...keyframe,
|
|
// The LANE's group, not the tween's own classification: a mixed-property
|
|
// tween classifies to undefined yet still feeds every group it touches.
|
|
propertyGroup: group,
|
|
ease: keyframeEase(keyframe, animation),
|
|
});
|
|
}
|
|
}
|
|
return keyframes;
|
|
}
|
|
|
|
export function getTimelinePropertyLanes(
|
|
animations: readonly GsapAnimation[],
|
|
clipStart: number,
|
|
clipDuration: number,
|
|
) {
|
|
if (clipDuration <= 0) return [];
|
|
return Array.from(sourceGroups(animations), ([group, groupAnimations]) => ({
|
|
group,
|
|
animations: groupAnimations,
|
|
keyframes: groupKeyframes(groupAnimations, group, clipStart, clipDuration),
|
|
})).filter((lane) => lane.keyframes.length > 0);
|
|
}
|
|
|
|
export function TimelinePropertyLanes({
|
|
id,
|
|
animations,
|
|
clipStart,
|
|
clipDuration,
|
|
clipLeftPx,
|
|
clipWidthPx,
|
|
accentColor,
|
|
isSelected,
|
|
currentPercentage,
|
|
elementId,
|
|
selectedKeyframes,
|
|
rovingTargetId = null,
|
|
onSelectSegment,
|
|
onClickKeyframe,
|
|
onShiftClickKeyframe,
|
|
onContextMenuKeyframe,
|
|
onMoveKeyframe,
|
|
suppressClickRef,
|
|
}: TimelinePropertyLanesProps) {
|
|
// Memoized: TimelineDiamondLane is React.memo'd, and rebuilding the lanes (and
|
|
// a fresh keyframesData literal per lane) on every render would re-render every
|
|
// diamond in every expanded clip on each playhead tick.
|
|
const lanes = useMemo(
|
|
() =>
|
|
clipWidthPx < 20 || clipDuration <= 0
|
|
? []
|
|
: getTimelinePropertyLanes(animations, clipStart, clipDuration),
|
|
[animations, clipStart, clipDuration, clipWidthPx],
|
|
);
|
|
const laneData = useMemo(
|
|
() =>
|
|
lanes.map((lane) => ({
|
|
...lane,
|
|
keyframesData: { format: "percentage" as const, keyframes: lane.keyframes },
|
|
})),
|
|
[lanes],
|
|
);
|
|
|
|
// One STATIC wrapper, never `relative`: a static box establishes no containing
|
|
// block, so every absolutely-positioned lane below still resolves against the
|
|
// track-content div and the rendered geometry is byte-identical to the bare
|
|
// fragment this replaced. It is also rendered when there are no lanes at all
|
|
// (collapsed layer), so `id` stays resolvable in both disclosure states.
|
|
return (
|
|
<div id={id}>
|
|
{laneData.map(({ group, keyframesData }, laneIndex) => (
|
|
<div
|
|
key={group}
|
|
id={timelineLogicalRowCellId(id, timelinePropertyRowId(elementId, group), "content")}
|
|
role="group"
|
|
aria-label={`${group} keyframes`}
|
|
data-property-group={group}
|
|
data-timeline-element-id={elementId}
|
|
data-timeline-property-lane=""
|
|
data-timeline-lane-top={getTimelineLaneTop(laneIndex)}
|
|
className="absolute"
|
|
style={{
|
|
left: clipLeftPx,
|
|
top: getTimelineLaneTop(laneIndex),
|
|
width: clipWidthPx,
|
|
height: LANE_H,
|
|
}}
|
|
>
|
|
<TimelineDiamondLane
|
|
keyframesData={keyframesData}
|
|
clipWidthPx={clipWidthPx}
|
|
clipHeightPx={LANE_H}
|
|
accentColor={accentColor}
|
|
isSelected={isSelected}
|
|
currentPercentage={currentPercentage}
|
|
elementId={elementId}
|
|
clipStart={clipStart}
|
|
clipDuration={clipDuration}
|
|
selectedKeyframes={selectedKeyframes}
|
|
rovingTargetId={rovingTargetId}
|
|
onSelectSegment={onSelectSegment}
|
|
onClickKeyframe={onClickKeyframe}
|
|
onShiftClickKeyframe={onShiftClickKeyframe}
|
|
onContextMenuKeyframe={onContextMenuKeyframe}
|
|
onMoveKeyframe={onMoveKeyframe}
|
|
suppressClickRef={suppressClickRef}
|
|
groupAware
|
|
/>
|
|
</div>
|
|
))}
|
|
</div>
|
|
);
|
|
}
|