From e1845e5dec6409633cac00937fdd77650ff08085 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miguel=20=C3=81ngel?= Date: Sun, 22 Nov 2026 03:57:31 +0000 Subject: [PATCH] fix(studio): a preview clip's track, start and length enter the timeline only as numbers (#8446) --- .../studio/src/player/lib/timelineDOM.test.ts | 33 +++++++++++++++++++ packages/studio/src/player/lib/timelineDOM.ts | 10 +++--- 2 files changed, 39 insertions(+), 4 deletions(-) diff --git a/packages/studio/src/player/lib/timelineDOM.test.ts b/packages/studio/src/player/lib/timelineDOM.test.ts index 4a15001769..449754ee03 100644 --- a/packages/studio/src/player/lib/timelineDOM.test.ts +++ b/packages/studio/src/player/lib/timelineDOM.test.ts @@ -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); + }); +}); diff --git a/packages/studio/src/player/lib/timelineDOM.ts b/packages/studio/src/player/lib/timelineDOM.ts index 7893426f1f..820e5b9bf0 100644 --- a/packages/studio/src/player/lib/timelineDOM.ts +++ b/packages/studio/src/player/lib/timelineDOM.ts @@ -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,