@hyperframes/studio 0.9.37 → 0.9.39

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.
Files changed (65) hide show
  1. package/dist/assets/{codec-BP7F-7Jx.js → codec-CY6KnWXa.js} +1 -1
  2. package/dist/assets/{hyperframes-player-_QnPoHup.js → hyperframes-player-B9-CuG_h.js} +1 -1
  3. package/dist/assets/{index-BJTCbv8z.css → index-4VGEAZyf.css} +1 -1
  4. package/dist/assets/{index-D6ePWUpc.js → index-Bjz2UaYv.js} +1 -1
  5. package/dist/assets/{index-tjhfci4N.js → index-_pkzoYYF.js} +166 -166
  6. package/dist/assets/{pausedVideoDecoder-B7U86zDa.js → pausedVideoDecoder-Dr7nKUUu.js} +1 -1
  7. package/dist/{chunk-63DH4LRB.js → chunk-44VRMER6.js} +2 -11
  8. package/dist/{chunk-45KKBU63.js → chunk-ATDO3YLX.js} +1 -1
  9. package/dist/chunk-FQ3VRKMC.js +148 -0
  10. package/dist/{chunk-YKBN653R.js → chunk-NBULUIWH.js} +252 -1
  11. package/dist/{domEditingLayers-7Q56QAU5.js → domEditingLayers-FRVHP6IB.js} +2 -2
  12. package/dist/index.d.ts +3 -85
  13. package/dist/index.html +2 -2
  14. package/dist/index.js +379 -400
  15. package/dist/keys-CaWcxUST.d.ts +86 -0
  16. package/dist/keys.d.ts +1 -0
  17. package/dist/keys.js +11 -0
  18. package/dist/player.js +2 -2
  19. package/dist/styles.css +1 -1
  20. package/package.json +12 -8
  21. package/src/components/editor/DomEditGestureReadout.test.tsx +204 -20
  22. package/src/components/editor/DomEditGestureReadout.tsx +36 -18
  23. package/src/components/editor/InlineTextToolbar.tsx +2 -2
  24. package/src/components/editor/domEditGestureReadoutPlacement.ts +144 -0
  25. package/src/components/editor/domEditGestureReadoutState.ts +18 -8
  26. package/src/components/editor/domEditingDom.ts +2 -15
  27. package/src/components/editor/propertyPanelFlatMediaSection.test.tsx +7 -36
  28. package/src/components/editor/propertyPanelFlatMediaSection.tsx +9 -32
  29. package/src/components/editor/useDomEditCompositionRect.ts +13 -4
  30. package/src/components/editor/useDomEditOverlayGestures.ts +1 -1
  31. package/src/components/editor/usePreviewCompositionRect.test.tsx +39 -0
  32. package/src/components/editor/useVolumeAutomation.test.tsx +0 -69
  33. package/src/components/editor/useVolumeAutomation.ts +0 -4
  34. package/src/hooks/elementPickerStyles.ts +53 -0
  35. package/src/hooks/gsapScriptCommitTypes.ts +2 -6
  36. package/src/hooks/timelineEditingHelpers.test.ts +39 -0
  37. package/src/hooks/timelineEditingHelpers.ts +13 -0
  38. package/src/hooks/useDomEditCommits.ts +4 -9
  39. package/src/hooks/useDomEditPersist.ts +2 -12
  40. package/src/hooks/useElementPicker.test.ts +83 -3
  41. package/src/hooks/useElementPicker.ts +27 -66
  42. package/src/hooks/useGsapScriptCommits.test.tsx +21 -0
  43. package/src/hooks/useGsapScriptCommits.ts +7 -3
  44. package/src/keys.test.ts +53 -0
  45. package/src/keys.ts +11 -0
  46. package/src/player/components/Player.test.ts +15 -0
  47. package/src/player/components/Player.tsx +6 -4
  48. package/src/player/components/audioGainApply.test.ts +13 -0
  49. package/src/player/components/audioGainApply.ts +0 -3
  50. package/src/player/components/studioKeyDefaults.ts +68 -0
  51. package/src/player/components/studioShortcuts.ts +2 -67
  52. package/src/player/hooks/playbackAdapterResolution.ts +15 -0
  53. package/src/player/hooks/previewMessageRouter.manifest.test.ts +67 -0
  54. package/src/player/hooks/previewMessageRouter.ts +38 -8
  55. package/src/player/hooks/timelinePlayerTestHarness.ts +27 -1
  56. package/src/player/hooks/useShadowPreviewReload.ts +24 -6
  57. package/src/player/hooks/useTimelinePlayer.shadowReload.test.ts +46 -0
  58. package/src/player/hooks/useTimelinePlayer.ts +5 -9
  59. package/src/player/lib/bridgePlayback.ts +156 -0
  60. package/src/player/lib/previewChannel.test.ts +260 -0
  61. package/src/player/lib/previewChannel.ts +100 -0
  62. package/src/player/sceneSwap.test.ts +12 -0
  63. package/src/player/sceneSwap.ts +2 -0
  64. package/src/utils/studioFileHistory.test.ts +29 -1
  65. package/src/utils/studioFileHistory.ts +24 -1
@@ -3,10 +3,7 @@
3
3
  * selector utilities, and composition source resolution.
4
4
  * No imports from other domEditing* modules — safe to import from anywhere.
5
5
  */
6
- import {
7
- PREVIEW_VIDEO_FRAME_ATTR,
8
- PREVIEW_VIDEO_CANVAS_ATTR,
9
- } from "@hyperframes/core/studio-preview-mark";
6
+ import { getLogicalOpacity } from "@hyperframes/core/studio-preview-mark";
10
7
  import { COLOR_GRADING_SOURCE_HIDDEN_ATTR } from "@hyperframes/core/color-grading";
11
8
  import { getSourceScopedSelectorIndex } from "../../utils/sourceScopedSelectorIndex";
12
9
  import { CURATED_STYLE_PROPERTIES } from "./domEditingTypes";
@@ -38,17 +35,7 @@ export function isEditableTextLeaf(el: HTMLElement): boolean {
38
35
  return isTextBearingTag(el.tagName.toLowerCase()) && el.children.length === 0;
39
36
  }
40
37
 
41
- /** The preview canvas keeps the source's authored opacity while its native pixels are hidden. */
42
- export function getLogicalOpacity(el: Element, computed: CSSStyleDeclaration): string {
43
- const overlay = el.previousElementSibling;
44
- if (
45
- el.hasAttribute(PREVIEW_VIDEO_FRAME_ATTR) &&
46
- overlay?.localName === "canvas" &&
47
- overlay.hasAttribute(PREVIEW_VIDEO_CANVAS_ATTR)
48
- )
49
- return el.ownerDocument.defaultView?.getComputedStyle(overlay).opacity ?? computed.opacity;
50
- return computed.opacity;
51
- }
38
+ export { getLogicalOpacity };
52
39
 
53
40
  /** Does this node render AT ALL, ignoring what it inherits? Sole owner of the
54
41
  * rule; the walk below only decides which nodes to ask it about. */
@@ -9,7 +9,6 @@ import type { DomEditSelection } from "./domEditing";
9
9
  import type { PatchOperation } from "../../utils/sourcePatcher";
10
10
  import { formatTimingValue } from "./propertyPanelHelpers";
11
11
  import { readMediaOffsetSeconds } from "@hyperframes/parsers/media-duration";
12
- import { audioGainToFaderPosition } from "@hyperframes/core/audio-gain";
13
12
 
14
13
  (globalThis as unknown as { IS_REACT_ACT_ENVIRONMENT: boolean }).IS_REACT_ACT_ENVIRONMENT = true;
15
14
 
@@ -183,7 +182,7 @@ describe("FlatMediaSection — volume/rate/media-start", () => {
183
182
  />,
184
183
  );
185
184
  });
186
- const volumeTrack = host.querySelector('[data-flat-slider-track="true"][aria-label="Gain"]')!;
185
+ const volumeTrack = host.querySelector('[data-flat-slider-track="true"][aria-label="Volume"]')!;
187
186
  Object.defineProperty(volumeTrack, "getBoundingClientRect", {
188
187
  value: () => ({ left: 0, width: 100, top: 0, height: 2, right: 100, bottom: 2 }),
189
188
  });
@@ -198,38 +197,10 @@ describe("FlatMediaSection — volume/rate/media-start", () => {
198
197
  act(() => root.unmount());
199
198
  });
200
199
 
201
- it("shows the clip's gain and its lane's level as two sliders", () => {
202
- const element = makeVideoElement({ dataAttributes: { volume: "0.5" } });
203
- const host = document.createElement("div");
204
- document.body.append(host);
205
- const root = createRoot(host);
206
- act(() => {
207
- root.render(
208
- <FlatMediaSection
209
- projectDir={null}
210
- element={element}
211
- styles={{}}
212
- onSetStyle={vi.fn()}
213
- onSetAttribute={vi.fn()}
214
- onSetHtmlAttribute={vi.fn()}
215
- onSetAttributeBatch={vi.fn()}
216
- volumeAutomated
217
- automatedVolumeValue={0.25}
218
- />,
219
- );
220
- });
221
- const [gain, volume] = host.querySelectorAll('[data-flat-slider-track="true"]');
222
- expect(labelsOf(host).slice(0, 2)).toEqual(["Gain", "Volume"]);
223
- expect(gain?.getAttribute("aria-valuenow")).toBe(String(audioGainToFaderPosition(0.5)));
224
- expect(volume?.getAttribute("aria-valuenow")).toBe(String(audioGainToFaderPosition(0.25)));
225
- act(() => root.unmount());
226
- });
227
-
228
200
  it.each([true, false])(
229
- "writes Volume through the lane, never data-volume (automated: %s)",
201
+ "Volume sets the whole clip's gain and never writes a keyframe (fade: %s)",
230
202
  (automated) => {
231
203
  const onSetAttribute = vi.fn();
232
- const onCommitVolumeAt = vi.fn();
233
204
  const element = makeVideoElement({ dataAttributes: { volume: "1" } });
234
205
  const host = document.createElement("div");
235
206
  document.body.append(host);
@@ -245,10 +216,12 @@ describe("FlatMediaSection — volume/rate/media-start", () => {
245
216
  onSetHtmlAttribute={vi.fn()}
246
217
  onSetAttributeBatch={vi.fn()}
247
218
  volumeAutomated={automated}
248
- onCommitVolumeAt={onCommitVolumeAt}
249
219
  />,
250
220
  );
251
221
  });
222
+ expect(labelsOf(host).filter((label) => label === "Volume" || label === "Gain")).toEqual([
223
+ "Volume",
224
+ ]);
252
225
  const volumeTrack = host.querySelector(
253
226
  '[data-flat-slider-track="true"][aria-label="Volume"]',
254
227
  )!;
@@ -259,9 +232,7 @@ describe("FlatMediaSection — volume/rate/media-start", () => {
259
232
  volumeTrack.dispatchEvent(new MouseEvent("pointerdown", { bubbles: true, clientX: 100 }));
260
233
  volumeTrack.dispatchEvent(new MouseEvent("pointerup", { bubbles: true, clientX: 100 }));
261
234
  });
262
- expect(onCommitVolumeAt).toHaveBeenCalledTimes(1);
263
- expect(onCommitVolumeAt.mock.calls[0][0]).toBeCloseTo(3.981072, 6);
264
- expect(onSetAttribute).not.toHaveBeenCalledWith("volume", expect.anything());
235
+ expect(onSetAttribute).toHaveBeenCalledWith("volume", "3.981072");
265
236
  act(() => root.unmount());
266
237
  },
267
238
  );
@@ -500,7 +471,7 @@ describe("FlatMediaSection — audio clips", () => {
500
471
  it("shows Fade in / Fade out rows for audio, and for video only when it carries audio", () => {
501
472
  const audio = renderWithRate(makeAudioElement());
502
473
  expect(labelsOf(audio.host)).toEqual(
503
- expect.arrayContaining(["Gain", "Volume", "Speed", "Media start", "Fade in", "Fade out"]),
474
+ expect.arrayContaining(["Volume", "Speed", "Media start", "Fade in", "Fade out"]),
504
475
  );
505
476
  act(() => audio.root.unmount());
506
477
 
@@ -52,8 +52,6 @@ export function FlatMediaSection({
52
52
  volumeAutomated,
53
53
  onAutomateVolume,
54
54
  onRemoveVolumeAutomation,
55
- onCommitVolumeAt,
56
- automatedVolumeValue,
57
55
  rate,
58
56
  }: {
59
57
  projectId?: string | null;
@@ -64,12 +62,10 @@ export function FlatMediaSection({
64
62
  onSetAttribute: (attr: string, value: string) => void | Promise<void>;
65
63
  onSetHtmlAttribute: (attr: string, value: string | null) => void | Promise<void>;
66
64
  onSetAttributeBatch: CommitDomAttributeBatch;
67
- /** A volume lane in the timeline drives the level; the Volume slider writes a keyframe. */
65
+ /** A volume lane in the timeline shapes the level over the clip; the Volume slider offsets all of it. */
68
66
  volumeAutomated?: boolean;
69
67
  onAutomateVolume?: () => void;
70
68
  onRemoveVolumeAutomation?: () => void;
71
- onCommitVolumeAt?: (v: number) => void;
72
- automatedVolumeValue?: number;
73
69
  /** Speed lane binding and presets; absent outside the Studio panel. */
74
70
  rate?: RateBinding;
75
71
  onRemoveBackground?: (
@@ -88,10 +84,7 @@ export function FlatMediaSection({
88
84
  const isVisualMedia = isVideo || isImage;
89
85
  const el = element.element;
90
86
 
91
- // Gain is `data-volume`, ahead of the effects; Volume is the lane's level at the
92
- // playhead, unity without one. What plays is gain times level, as in an editor.
93
87
  const gain = parseNumericValue(element.dataAttributes.volume ?? "") ?? 1;
94
- const volume = volumeAutomated && automatedVolumeValue !== undefined ? automatedVolumeValue : 1;
95
88
  const { mediaStart, mediaStartAttr } = readClipInPoint(element.dataAttributes);
96
89
  const constantRate = Number.parseFloat(element.dataAttributes["playback-rate"] ?? "1") || 1;
97
90
  const playbackRate =
@@ -242,25 +235,7 @@ export function FlatMediaSection({
242
235
  )}
243
236
  {(isVideo || isAudio) && (
244
237
  <>
245
- <FlatSlider
246
- label="Gain"
247
- value={audioGainToFaderPosition(gain)}
248
- min={AUDIO_GAIN_FADER_MIN}
249
- max={AUDIO_GAIN_FADER_MAX}
250
- tier={gain === 1 ? "default" : "explicitCustom"}
251
- displayValue={audioGainToText(gain)}
252
- centerTick
253
- onCommit={(next) =>
254
- void onSetAttribute("volume", formatAudioGain(audioFaderPositionToGain(next)))
255
- }
256
- onCommitText={(text) => {
257
- const next = parseGainInput(text);
258
- if (next === null) return false;
259
- void onSetAttribute("volume", formatAudioGain(next));
260
- return true;
261
- }}
262
- />
263
- {/* A commit writes a keyframe at the playhead, starting a lane when there is none. */}
238
+ {/* Volume is the whole clip's level (`data-volume`); a fade or keyframes ride on top of it. */}
264
239
  <div
265
240
  className="hf-volume-row flex items-center gap-1"
266
241
  data-volume-automated={volumeAutomated ? "" : undefined}
@@ -268,17 +243,19 @@ export function FlatMediaSection({
268
243
  <div className="min-w-0 flex-1">
269
244
  <FlatSlider
270
245
  label="Volume"
271
- value={audioGainToFaderPosition(volume)}
246
+ value={audioGainToFaderPosition(gain)}
272
247
  min={AUDIO_GAIN_FADER_MIN}
273
248
  max={AUDIO_GAIN_FADER_MAX}
274
- tier={volume === 1 ? "default" : "explicitCustom"}
275
- displayValue={audioGainToText(volume)}
249
+ tier={gain === 1 ? "default" : "explicitCustom"}
250
+ displayValue={audioGainToText(gain)}
276
251
  centerTick
277
- onCommit={(next) => onCommitVolumeAt?.(audioFaderPositionToGain(next))}
252
+ onCommit={(next) =>
253
+ void onSetAttribute("volume", formatAudioGain(audioFaderPositionToGain(next)))
254
+ }
278
255
  onCommitText={(text) => {
279
256
  const next = parseGainInput(text);
280
257
  if (next === null) return false;
281
- onCommitVolumeAt?.(next);
258
+ void onSetAttribute("volume", formatAudioGain(next));
282
259
  return true;
283
260
  }}
284
261
  />
@@ -1,6 +1,8 @@
1
1
  import { useState, type RefObject } from "react";
2
2
  import { useMountEffect } from "../../hooks/useMountEffect";
3
3
  import { subscribeOverlayFrame } from "./overlayFrameLoop";
4
+ import { previewStageSize } from "../../player/lib/bridgePlayback";
5
+ import { previewFrameOpaque } from "../../player/lib/previewChannel";
4
6
 
5
7
  export interface DomEditCompositionRect {
6
8
  left: number;
@@ -23,6 +25,16 @@ function sameRect(a: DomEditCompositionRect, b: DomEditCompositionRect): boolean
23
25
  );
24
26
  }
25
27
 
28
+ function declaredCompositionSize(iframe: HTMLIFrameElement): { width: number; height: number } {
29
+ if (previewFrameOpaque(iframe)) return previewStageSize(iframe) ?? { width: NaN, height: NaN };
30
+ const doc = iframe.contentDocument;
31
+ const root = doc?.querySelector<HTMLElement>("[data-composition-id]") ?? doc?.documentElement;
32
+ return {
33
+ width: Number.parseFloat(root?.getAttribute("data-width") ?? ""),
34
+ height: Number.parseFloat(root?.getAttribute("data-height") ?? ""),
35
+ };
36
+ }
37
+
26
38
  export function useDomEditCompositionRect({
27
39
  iframeRef,
28
40
  overlayRef,
@@ -50,10 +62,7 @@ export function useDomEditCompositionRect({
50
62
  const left = iRect.left - oRect.left;
51
63
  const top = iRect.top - oRect.top;
52
64
  if (iRect.width <= 0 || iRect.height <= 0) return;
53
- const doc = iframe.contentDocument;
54
- const root = doc?.querySelector<HTMLElement>("[data-composition-id]") ?? doc?.documentElement;
55
- const dw = Number.parseFloat(root?.getAttribute("data-width") ?? "");
56
- const dh = Number.parseFloat(root?.getAttribute("data-height") ?? "");
65
+ const { width: dw, height: dh } = declaredCompositionSize(iframe);
57
66
  const scaleX = dw > 0 ? iRect.width / dw : 1;
58
67
  const scaleY = dh > 0 ? iRect.height / dh : 1;
59
68
  const next = { left, top, width: iRect.width, height: iRect.height, scaleX, scaleY };
@@ -165,7 +165,7 @@ export function createDomEditOverlayGestureHandlers(opts: UseDomEditOverlayGestu
165
165
  actualAngle: g.actualRotation,
166
166
  snap: e.shiftKey,
167
167
  });
168
- readout.updateGestureReadoutAngle(g.readout, rotated.angle);
168
+ readout.updateGestureReadoutAngle(g.readout, rotated.angle, g.actualRotation);
169
169
  applyRotationDraft(sel.element, rotated.angle, g.plainRotation);
170
170
  return;
171
171
  }
@@ -9,6 +9,7 @@ import {
9
9
  type PreviewCompositionRect,
10
10
  } from "./usePreviewCompositionRect";
11
11
  import { usePlayerStore } from "../../player/store/playerStore";
12
+ import { watchPreviewFrame } from "../../player/lib/bridgePlayback";
12
13
 
13
14
  (globalThis as unknown as { IS_REACT_ACT_ENVIRONMENT: boolean }).IS_REACT_ACT_ENVIRONMENT = true;
14
15
 
@@ -103,4 +104,42 @@ describe("usePreviewCompositionRect", () => {
103
104
  });
104
105
  probe.unmount();
105
106
  });
107
+
108
+ it("scales an opaque frame by the size its runtime posts, only from the frame's own origin", async () => {
109
+ const frame = {};
110
+ Object.defineProperty(frame, "document", {
111
+ get: () => {
112
+ throw new DOMException("blocked", "SecurityError");
113
+ },
114
+ });
115
+ const iframe = boxed(document.createElement("iframe"), [110, 70, 960, 540]);
116
+ iframe.setAttribute("sandbox", "allow-scripts");
117
+ Object.defineProperty(iframe, "contentWindow", { value: frame });
118
+ Object.defineProperty(iframe, "contentDocument", { value: null });
119
+ watchPreviewFrame(iframe);
120
+ const stageSize = (width: number, origin: string) =>
121
+ window.dispatchEvent(
122
+ new MessageEvent("message", {
123
+ source: frame as Window,
124
+ origin,
125
+ data: { source: "hf-preview", type: "stage-size", width, height: 1080 },
126
+ }),
127
+ );
128
+ stageSize(1920, "null");
129
+ stageSize(960, window.location.origin);
130
+ const probe = mountProbe();
131
+ await act(async () => {
132
+ probe.setIframe(iframe);
133
+ await settle();
134
+ });
135
+ expect(probe.read()).toEqual({
136
+ left: 100,
137
+ top: 50,
138
+ width: 960,
139
+ height: 540,
140
+ scaleX: 0.5,
141
+ scaleY: 0.5,
142
+ });
143
+ probe.unmount();
144
+ });
106
145
  });
@@ -35,11 +35,6 @@ const volumeLane = (v: number) =>
35
35
  const writtenAutomation = (onSetAttributeQuiet: ReturnType<typeof vi.fn>) =>
36
36
  JSON.parse(String(onSetAttributeQuiet.mock.calls[0][1]));
37
37
 
38
- const writtenVolumePoints = (onSetAttributeQuiet: ReturnType<typeof vi.fn>) =>
39
- writtenAutomation(onSetAttributeQuiet).lanes.find(
40
- (l: { target: string }) => l.target === "volume",
41
- ).points;
42
-
43
38
  describe("useVolumeAutomation", () => {
44
39
  it("reports an unautomated track", () => {
45
40
  expect(bind({ volume: "0.55" }).binding.volumeAutomated).toBe(false);
@@ -103,70 +98,6 @@ describe("useVolumeAutomation", () => {
103
98
  expect(onSetAttributeQuiet).toHaveBeenCalledWith("data-automation", null);
104
99
  });
105
100
 
106
- it("writes a keyframe at the playhead instead of the flat attribute", () => {
107
- // The slider used to be disabled while automated; this is what replaces
108
- // that: a commit lands in the envelope, not on `data-volume`.
109
- const { binding, onSetAttributeQuiet } = bind(
110
- { volume: "0.4", automation: volumeLane(0.2), start: "0", duration: "10" },
111
- 5,
112
- );
113
- act(() => binding.onCommitVolumeAt(0.7));
114
- expect(writtenVolumePoints(onSetAttributeQuiet)).toEqual([
115
- { t: 0, v: 0.2 },
116
- { t: 5, v: 0.7 },
117
- ]);
118
- });
119
-
120
- it("clamps the playhead to the clip's own span, not the composition's", () => {
121
- // A playhead past the clip's end must still land the keyframe at the
122
- // clip's own last instant, not off the end of its automation lane.
123
- const { binding, onSetAttributeQuiet } = bind(
124
- { volume: "0.4", automation: volumeLane(0.2), start: "10", duration: "4" },
125
- 50,
126
- );
127
- act(() => binding.onCommitVolumeAt(0.9));
128
- expect(writtenVolumePoints(onSetAttributeQuiet)).toEqual([
129
- { t: 0, v: 0.2 },
130
- { t: 4, v: 0.9 },
131
- ]);
132
- });
133
-
134
- it("moves the existing point instead of stacking a new one when committing near it", () => {
135
- const { binding, onSetAttributeQuiet } = bind(
136
- { volume: "0.4", automation: volumeLane(0.2), start: "0", duration: "10" },
137
- 0,
138
- );
139
- act(() => binding.onCommitVolumeAt(0.9));
140
- expect(writtenVolumePoints(onSetAttributeQuiet)).toEqual([{ t: 0, v: 0.9 }]);
141
- });
142
-
143
- it("reports the envelope's own value at the playhead, not the static attribute", () => {
144
- const { binding } = bind(
145
- { volume: "0.4", automation: volumeLane(0.2), start: "0", duration: "10" },
146
- 0,
147
- );
148
- expect(binding.automatedVolumeValue).toBe(0.2);
149
- });
150
-
151
- it("translates to clip-local time, not composition time, for a clip that starts mid-timeline", () => {
152
- // start=10 keeps this inside the clip's own duration either way, so the
153
- // duration clamp can't mask a missing `currentTime - elStart` subtraction
154
- // the way start=0 cases elsewhere in this file do.
155
- const { binding, onSetAttributeQuiet } = bind(
156
- { volume: "0.4", automation: volumeLane(0.2), start: "10", duration: "20" },
157
- 15,
158
- );
159
- act(() => binding.onCommitVolumeAt(0.9));
160
- expect(writtenVolumePoints(onSetAttributeQuiet)).toEqual([
161
- { t: 0, v: 0.2 },
162
- { t: 5, v: 0.9 },
163
- ]);
164
- });
165
-
166
- it("reports no automated value when the track is not automated", () => {
167
- expect(bind({ volume: "0.4" }).binding.automatedVolumeValue).toBeUndefined();
168
- });
169
-
170
101
  it("reads an unreadable attribute as no automation", () => {
171
102
  expect(bind({ volume: "0.55", automation: "{not json" }).binding.volumeAutomated).toBe(false);
172
103
  });
@@ -49,8 +49,6 @@ export interface VolumeAutomationBinding {
49
49
  volumeAutomated: boolean;
50
50
  onAutomateVolume: () => void;
51
51
  onRemoveVolumeAutomation: () => void;
52
- onCommitVolumeAt: (v: number) => void;
53
- automatedVolumeValue: number | undefined;
54
52
  /** Speed: the `rate` lane, plus the CapCut-style presets that seed it. */
55
53
  rate: RateBinding;
56
54
  }
@@ -118,10 +116,8 @@ export function useVolumeAutomation(
118
116
  );
119
117
  return {
120
118
  volumeAutomated: volume.automated,
121
- automatedVolumeValue: volume.automatedValue,
122
119
  onAutomateVolume: volume.onAutomate,
123
120
  onRemoveVolumeAutomation: volume.onRemoveAutomation,
124
- onCommitVolumeAt: volume.onCommitAt,
125
121
  rate: {
126
122
  ...rate,
127
123
  canApplyPreset: elDuration > 0,
@@ -0,0 +1,53 @@
1
+ import { getLogicalOpacity } from "../components/editor/domEditingDom";
2
+
3
+ export const PICKED_STYLE_PROPERTIES = [
4
+ "position",
5
+ "top",
6
+ "left",
7
+ "right",
8
+ "bottom",
9
+ "width",
10
+ "height",
11
+ "margin-top",
12
+ "margin-right",
13
+ "margin-bottom",
14
+ "margin-left",
15
+ "padding-top",
16
+ "padding-right",
17
+ "padding-bottom",
18
+ "padding-left",
19
+ "font-size",
20
+ "font-weight",
21
+ "font-family",
22
+ "color",
23
+ "background-color",
24
+ "background",
25
+ "opacity",
26
+ "border-radius",
27
+ "transform",
28
+ "z-index",
29
+ ];
30
+
31
+ /** Read a subset of computed styles from an element in the iframe */
32
+ export function readComputedStyles(
33
+ iframe: HTMLIFrameElement,
34
+ selector: string,
35
+ ): Record<string, string> {
36
+ const styles: Record<string, string> = {};
37
+ try {
38
+ const doc = iframe.contentDocument;
39
+ const el = doc?.querySelector(selector);
40
+ if (!el) return styles;
41
+ const computed = iframe.contentWindow?.getComputedStyle(el);
42
+ if (!computed) return styles;
43
+
44
+ for (const prop of PICKED_STYLE_PROPERTIES) {
45
+ const val =
46
+ prop === "opacity" ? getLogicalOpacity(el, computed) : computed.getPropertyValue(prop);
47
+ if (val) styles[prop] = val;
48
+ }
49
+ } catch {
50
+ /* cross-origin */
51
+ }
52
+ return styles;
53
+ }
@@ -5,6 +5,7 @@ import type { PublishSdkSession } from "../utils/sdkCutover";
5
5
  import type { StudioEditInFlight } from "../utils/studioPendingEdits";
6
6
  import type { RuntimeTweenChange } from "./gsapRuntimePatch";
7
7
  import type { KeyframeUsageAction } from "../utils/keyframeUsage";
8
+ import type { RecordEditInput } from "../utils/studioFileHistory";
8
9
 
9
10
  /** The file a selection's GSAP write goes to. */
10
11
  export function gsapWriteFile(
@@ -108,12 +109,7 @@ export interface GsapScriptCommitsParams {
108
109
  activeCompPath: string | null;
109
110
  previewIframeRef: React.RefObject<HTMLIFrameElement | null>;
110
111
  editHistory: {
111
- recordEdit: (entry: {
112
- label: string;
113
- coalesceKey?: string;
114
- coalesceMs?: number;
115
- files: Record<string, { before: string; after: string }>;
116
- }) => Promise<void>;
112
+ recordEdit: (entry: RecordEditInput) => Promise<void>;
117
113
  };
118
114
  reloadPreview: () => void;
119
115
  onCacheInvalidate: () => void;
@@ -380,6 +380,23 @@ describe("persistTimelineBatchEdit", () => {
380
380
  expect(perMember).toContain('data-duration="9"');
381
381
  });
382
382
 
383
+ it("files the move under every clip it moved, by identity and by the name the clip wears", async () => {
384
+ stubReadFileContent(SOURCE);
385
+ const recordEdit = vi.fn(async () => {});
386
+ await persistTimelineBatchEdit({
387
+ ...batchInput([moveMember("a", 3, 0, 0), moveMember("b", 4, 1, 1)], []),
388
+ recordEdit,
389
+ });
390
+ expect(recordEdit).toHaveBeenCalledWith(
391
+ expect.objectContaining({
392
+ targets: [
393
+ { file: "index.html", id: "a", name: "a" },
394
+ { file: "index.html", id: "b", name: "b" },
395
+ ],
396
+ }),
397
+ );
398
+ });
399
+
383
400
  it("skips no-op members instead of aborting the batch (track-insert renumber)", async () => {
384
401
  // A track-insert renumber can include a member whose attributes already
385
402
  // hold the target values — its patch is string-identical. The batch must
@@ -492,6 +509,28 @@ describe("persistTimelineEdit", () => {
492
509
  expect([...pending]).toEqual(["index.html"]);
493
510
  });
494
511
 
512
+ it("files the edit under the clip it changed, by identity and by the name the clip wears", async () => {
513
+ vi.stubGlobal(
514
+ "fetch",
515
+ vi.fn(async () => ({ ok: true, json: async () => ({ content: SOURCE }) })),
516
+ );
517
+ const recordEdit = vi.fn(async () => {});
518
+ const element = el({ id: "a", tag: "video", domId: "a", start: 1, duration: 3 });
519
+ await persistTimelineEdit({
520
+ projectId: "p1",
521
+ element,
522
+ activeCompPath: "index.html",
523
+ label: "Move timeline clip",
524
+ buildPatches: (original, target) => buildTimelineMoveTimingPatch(original, target, 2, 3, 0),
525
+ writeProjectFile: async () => {},
526
+ recordEdit,
527
+ pendingTimelineEditPathRef: { current: new Set<string>() },
528
+ });
529
+ expect(recordEdit).toHaveBeenCalledWith(
530
+ expect.objectContaining({ targets: [{ file: "index.html", id: "a", name: "a" }] }),
531
+ );
532
+ });
533
+
495
534
  it("still throws for a clip the file does not hold", async () => {
496
535
  const { done, writes } = await runEdit("ghost", 2);
497
536
  await expect(done).rejects.toThrow("Unable to patch timeline element ghost in index.html");
@@ -23,8 +23,10 @@ import {
23
23
  } from "../player/lib/timelineElementHelpers";
24
24
  import { resolveTimelinePlaybackRate } from "../player/components/timelineGroupEditing";
25
25
  import {
26
+ editContextTarget,
26
27
  saveProjectFilesWithHistory,
27
28
  writeProjectFilesWithHistoryInQueue,
29
+ type EditContextTarget,
28
30
  type RecordEditInput,
29
31
  } from "../utils/studioFileHistory";
30
32
  import { serializeStudioFileMutations } from "../utils/studioFileMutationCoordinator";
@@ -140,6 +142,12 @@ export function buildPatchTarget(element: {
140
142
  return null;
141
143
  }
142
144
  export type PatchTarget = NonNullable<ReturnType<typeof buildPatchTarget>>;
145
+
146
+ /** A clip's entry in the history: how to find the element again, and the name the clip wears on the timeline. */
147
+ function timelineEditTarget(path: string, element: TimelineElement): EditContextTarget | null {
148
+ const patchTarget = buildPatchTarget(element);
149
+ return patchTarget && editContextTarget(path, { ...patchTarget, label: element.label });
150
+ }
143
151
  // The runtime re-reads data-start/data-duration from the DOM on each sync tick
144
152
  // (packages/core/src/runtime/init.ts:1324-1368), so attribute mutations here are
145
153
  // picked up automatically on the next frame without a rebind call.
@@ -354,6 +362,7 @@ export async function persistTimelineEdit(input: PersistTimelineEditInput): Prom
354
362
  await saveProjectFilesWithHistory({
355
363
  projectId: input.projectId,
356
364
  label: input.label,
365
+ targets: [editContextTarget(targetPath, { ...patchTarget, label: input.element.label })],
357
366
  coalesceKey: input.coalesceKey,
358
367
  coalesceMs: input.coalesceMs,
359
368
  files: {
@@ -457,6 +466,10 @@ export async function persistTimelineBatchEdit(
457
466
  await saveProjectFilesWithHistory({
458
467
  projectId: input.projectId,
459
468
  label: input.label,
469
+ targets: input.changes.flatMap((change) => {
470
+ const path = change.element.sourceFile || input.activeCompPath || "index.html";
471
+ return timelineEditTarget(path, change.element) ?? [];
472
+ }),
460
473
  coalesceKey: input.coalesceKey,
461
474
  coalesceMs: input.coalesceMs,
462
475
  files: Object.fromEntries([...changesByPath.keys()].map((path) => [path, buildFile(path)])),
@@ -1,4 +1,5 @@
1
1
  import { buildProjectApiPath } from "../utils/projectRouting";
2
+ import { editContextTarget } from "../utils/studioFileHistory";
2
3
  import { useCallback } from "react";
3
4
  import { findUnsafeDomPatchValues } from "@hyperframes/core/studio-api/finite-mutation";
4
5
  import { FONT_EXT } from "../utils/mediaTypes";
@@ -181,15 +182,9 @@ export function useDomEditCommits({
181
182
  targets: batches
182
183
  .filter((batch) => Object.hasOwn(files, batch.sourceFile))
183
184
  .flatMap((batch) =>
184
- batch.patches.map(({ target }) => ({
185
- file: batch.sourceFile,
186
- ...(target.id && { id: target.id }),
187
- ...(target.hfId && { hfId: target.hfId }),
188
- ...(target.selector && { selector: target.selector }),
189
- ...(target.selectorIndex !== undefined && {
190
- selectorIndex: target.selectorIndex,
191
- }),
192
- })),
185
+ batch.patches.map(({ target }) =>
186
+ editContextTarget(batch.sourceFile, target),
187
+ ),
193
188
  ),
194
189
  });
195
190
  }
@@ -20,7 +20,7 @@ import { countStudioManualEditSave } from "../components/editor/manualEditsDom";
20
20
  import type { CutoverResult } from "../utils/sdkCutover";
21
21
  import { reseekPreviewRuntime } from "./timelineTrackVisibility";
22
22
  import { serializeStudioFileMutations } from "../utils/studioFileMutationCoordinator";
23
- import { readProjectFileContent } from "../utils/studioFileHistory";
23
+ import { editContextTarget, readProjectFileContent } from "../utils/studioFileHistory";
24
24
 
25
25
  import type { RecordEditInput } from "../utils/studioFileHistory";
26
26
  export type { RecordEditInput } from "../utils/studioFileHistory";
@@ -160,17 +160,7 @@ export function useDomEditPersist({
160
160
 
161
161
  await editHistory.recordEdit({
162
162
  ...history,
163
- targets: [
164
- {
165
- file: targetPath,
166
- ...(selection.id && { id: selection.id }),
167
- ...(selection.hfId && { hfId: selection.hfId }),
168
- ...(selection.selector && { selector: selection.selector }),
169
- ...(selection.selectorIndex !== undefined && {
170
- selectorIndex: selection.selectorIndex,
171
- }),
172
- },
173
- ],
163
+ targets: [editContextTarget(targetPath, selection)],
174
164
  files: { [targetPath]: { before: originalContent, after: finalContent } },
175
165
  });
176
166
  return { patchData, patchedContent, finalContent };