mirror of
https://github.com/heygen-com/hyperframes.git
synced 2026-11-25 16:37:32 +00:00
fix(studio): a preview clip's track, start and length enter the timeline only as numbers (#8446)
This commit is contained in:
@@ -956,3 +956,36 @@ describe("what the live clip list says a clip plays", () => {
|
||||
},
|
||||
);
|
||||
});
|
||||
|
||||
describe("createTimelineElementFromManifestClip — received clip numbers", () => {
|
||||
it("takes a preview clip's track, start and length only as numbers, so no writer puts their text in the file", () => {
|
||||
const clip = (track: unknown, start: unknown = 0, duration: unknown = 5) =>
|
||||
createTimelineElementFromManifestClip({
|
||||
clip: {
|
||||
id: "hero",
|
||||
label: "Hero",
|
||||
kind: "element",
|
||||
tagName: "div",
|
||||
start: start as number,
|
||||
duration: duration as number,
|
||||
track: track as number,
|
||||
compositionId: null,
|
||||
parentCompositionId: null,
|
||||
compositionSrc: null,
|
||||
assetUrl: null,
|
||||
},
|
||||
fallbackIndex: 0,
|
||||
});
|
||||
|
||||
const text = '1" onmouseover="alert(1)';
|
||||
const hostile = clip(text, text, text);
|
||||
expect([hostile.track, hostile.authoredTrack, hostile.start, hostile.duration]).toEqual([
|
||||
0, 0, 0, 0,
|
||||
]);
|
||||
const honest = clip(3, 1.5, 2);
|
||||
expect([honest.track, honest.authoredTrack, honest.start, honest.duration]).toEqual([
|
||||
3, 3, 1.5, 2,
|
||||
]);
|
||||
expect(clip(Number.NaN).track).toBe(0);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -17,6 +17,7 @@ import { readMasterFxChain } from "@hyperframes/core/audio-groups";
|
||||
import { linkScopeOf } from "@hyperframes/core/media-link";
|
||||
import { createRuntimeStartTimeResolver } from "@hyperframes/core/runtime/start-resolver";
|
||||
import { previewWithoutFrameToken } from "./frameToken";
|
||||
import { finiteNumber } from "../../components/editor/manualEditsParsing";
|
||||
import { groupInfoFor } from "./timelineGroupInfo";
|
||||
import { receivedTimelineText } from "./timelineText";
|
||||
import { transitionLabelsForDocument } from "./timelineTransitionMetadata";
|
||||
@@ -81,6 +82,7 @@ export function createTimelineElementFromManifestClip(params: {
|
||||
hostEl?: Element | null;
|
||||
}): TimelineElement {
|
||||
const { clip, fallbackIndex, doc } = params;
|
||||
const numericTrack = finiteNumber(clip.track) ?? 0;
|
||||
let hostEl = params.hostEl ?? null;
|
||||
const transitionLabels = doc
|
||||
? transitionLabelsForDocument(doc, (doc.defaultView as IframeWindow | null)?.__timelines)
|
||||
@@ -125,15 +127,15 @@ export function createTimelineElementFromManifestClip(params: {
|
||||
key: identity.key,
|
||||
kind: clip.kind,
|
||||
tag: resolveClipTag(clip),
|
||||
start: clip.start,
|
||||
duration: clip.duration,
|
||||
track: clip.track,
|
||||
start: finiteNumber(clip.start) ?? 0,
|
||||
duration: finiteNumber(clip.duration) ?? 0,
|
||||
track: numericTrack,
|
||||
// clip.track IS the authored data-track-index verbatim (the runtime honors
|
||||
// it; see parseAuthoredTrack in core/runtime/timeline.ts). Record it at this
|
||||
// translation boundary so later display-lane remaps (normalizeToZones,
|
||||
// expanded-child rows) can persist in AUTHORED space instead of
|
||||
// reconstructing it from lane occupants.
|
||||
authoredTrack: clip.track,
|
||||
authoredTrack: numericTrack,
|
||||
// Runtime-computed stacking context — authoritative; helpers read it, never
|
||||
// re-derive it.
|
||||
stackingContextId: clip.stackingContextId ?? null,
|
||||
|
||||
Reference in New Issue
Block a user