@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
package/dist/index.js CHANGED
@@ -10,9 +10,12 @@ import {
10
10
  STUDIO_PREVIEW_FPS,
11
11
  TIMELINE_RANGE_MARGIN_PX,
12
12
  TIMELINE_VIEWPORT_BUDGETS,
13
+ acceptStudioRuntimeMessage,
14
+ acceptedRuntimeMessageFps,
13
15
  announcePreviewDocumentLoaded,
14
16
  announcePreviewPromoted,
15
17
  applyPreviewVariablesToUrl,
18
+ bridgePlaybackAdapter,
16
19
  clampTimelineZoomPercent,
17
20
  clampToDuration,
18
21
  collectElementPatches,
@@ -24,12 +27,14 @@ import {
24
27
  effectiveThumbnailMode,
25
28
  formatFrameTime,
26
29
  formatTime,
30
+ frameOrigins,
27
31
  frameToSeconds,
28
32
  getNextTimelineZoomPercent,
29
33
  getPinchTimelineZoomPercent,
30
34
  getTimelinePixelsPerSecond,
31
35
  getTimelineZoomPercent,
32
36
  giveUpOnPreviewChange,
37
+ inspectStudioRuntimeMessage,
33
38
  isFocusedEaseRequestCurrent,
34
39
  isPanelId,
35
40
  isPreviewBooted,
@@ -50,11 +55,19 @@ import {
50
55
  parsePreviewFacts,
51
56
  patchElements,
52
57
  positiveClipSpan,
58
+ postFrameDisplayScale,
59
+ postRuntimeControlMessage,
60
+ previewClipManifest,
61
+ previewComputedStyles,
62
+ previewFrameOpaque,
53
63
  previewReloadBegun,
64
+ previewSeekPainted,
65
+ previewStageSize,
54
66
  readStudioUiPreferences,
55
67
  requestPreviewReload,
56
68
  sceneSwapFor,
57
69
  secondsToFrame,
70
+ setFrameLoopStart,
58
71
  setPreviewReloading,
59
72
  stepFrameTime,
60
73
  studioExpectedFileVersion,
@@ -74,7 +87,7 @@ import {
74
87
  whileScriptWrites,
75
88
  writeStudioUiPreferences,
76
89
  zoomToSelectedClips
77
- } from "./chunk-YKBN653R.js";
90
+ } from "./chunk-NBULUIWH.js";
78
91
  import {
79
92
  Button,
80
93
  ContextMenu,
@@ -107,6 +120,14 @@ import {
107
120
  fieldText,
108
121
  popupSurface
109
122
  } from "./chunk-52AJB4PN.js";
123
+ import {
124
+ DEFAULT_STUDIO_KEYS,
125
+ comboClashKey,
126
+ comboText,
127
+ formatCombo,
128
+ matchCombo,
129
+ parseCombo
130
+ } from "./chunk-FQ3VRKMC.js";
110
131
  import {
111
132
  DOM_EDIT_LAYER_OBSERVER_INIT,
112
133
  buildDefaultDomEditTextField,
@@ -132,7 +153,7 @@ import {
132
153
  resolveAllVisualDomEditTargets,
133
154
  resolveDomEditSelection,
134
155
  serializeDomEditTextFields
135
- } from "./chunk-45KKBU63.js";
156
+ } from "./chunk-ATDO3YLX.js";
136
157
  import {
137
158
  LAYER_REVEAL_PRIOR_POSITION_ATTR,
138
159
  LAYER_REVEAL_PRIOR_Z_ATTR,
@@ -201,7 +222,7 @@ import {
201
222
  toHexColor,
202
223
  withSelectorIndexPass,
203
224
  wrapTimeline
204
- } from "./chunk-63DH4LRB.js";
225
+ } from "./chunk-44VRMER6.js";
205
226
  import {
206
227
  MediaFetchError,
207
228
  mediaUrlSourceOptions,
@@ -214,146 +235,6 @@ import { memo as memo35, useCallback as useCallback78 } from "react";
214
235
 
215
236
  // src/player/components/studioShortcuts.ts
216
237
  import { useSyncExternalStore } from "react";
217
-
218
- // src/player/components/studioCombo.ts
219
- var NAMED = /* @__PURE__ */ new Set([
220
- "Space",
221
- "ArrowLeft",
222
- "ArrowRight",
223
- "ArrowUp",
224
- "ArrowDown",
225
- "Home",
226
- "End",
227
- "PageUp",
228
- "PageDown",
229
- "Delete",
230
- "Backspace",
231
- "Escape",
232
- "Enter",
233
- "Tab"
234
- ]);
235
- var SYMBOL = {
236
- ArrowLeft: "\u2190",
237
- ArrowRight: "\u2192",
238
- ArrowUp: "\u2191",
239
- ArrowDown: "\u2193",
240
- Delete: "Del",
241
- Backspace: "\u232B",
242
- Escape: "Esc"
243
- };
244
- var MODIFIERS = /* @__PURE__ */ new Set(["mod", "cmd", "ctrl", "shift", "alt"]);
245
- function parseCombo(text3) {
246
- const split = text3.length > 1 ? text3.slice(0, -1).lastIndexOf("+") : -1;
247
- const tokens = split < 0 ? [] : text3.slice(0, split).split("+").map((t2) => t2.toLowerCase());
248
- const key2 = text3.slice(split + 1);
249
- const named = NAMED.has(key2);
250
- const symbol = !named && !/^[A-Za-z]$/.test(key2);
251
- if (tokens.some((t2) => !MODIFIERS.has(t2)) || !named && [...key2].length !== 1) return null;
252
- if (symbol && tokens.includes("shift")) return null;
253
- const combo = {
254
- mod: tokens.includes("mod"),
255
- meta: tokens.includes("cmd"),
256
- ctrl: tokens.includes("ctrl"),
257
- shift: tokens.includes("shift"),
258
- alt: tokens.includes("alt"),
259
- key: named ? key2 : key2.toLowerCase(),
260
- named
261
- };
262
- return combo.alt && (combo.ctrl || combo.mod) ? null : combo;
263
- }
264
- function comboText(c) {
265
- const mods = [
266
- c.mod && "mod",
267
- c.meta && "cmd",
268
- c.ctrl && "ctrl",
269
- c.alt && "alt",
270
- c.shift && "shift"
271
- ];
272
- return [...mods.filter(Boolean), c.key].join("+");
273
- }
274
- var namedMatches = (e, name) => e.code === name || e.key === (name === "Space" ? " " : name);
275
- function charMatches(e, c) {
276
- if (e.key.toLowerCase() === c.key) return true;
277
- const code = /^[0-9]$/.test(c.key) ? `Digit${c.key}` : `Key${c.key.toUpperCase()}`;
278
- return e.altKey && /^[a-z0-9]$/.test(c.key) && e.code === code;
279
- }
280
- function matchCombo(e, c) {
281
- const symbol = !c.named && !/^[a-z]$/.test(c.key);
282
- if (!symbol && !!e.shiftKey !== c.shift || !!e.altKey !== c.alt) return false;
283
- const modsOk = c.mod ? e.metaKey || e.ctrlKey : !!e.metaKey === c.meta && !!e.ctrlKey === c.ctrl;
284
- return modsOk && (c.named ? namedMatches(e, c.key) : charMatches(e, c));
285
- }
286
- function formatCombo(c) {
287
- const mods = `${c.ctrl ? "\u2303" : ""}${c.alt ? "\u2325" : ""}${c.mod || c.meta ? "\u2318" : ""}${c.shift ? "\u21E7" : ""}`;
288
- return mods + (SYMBOL[c.key] ?? (c.named ? c.key : c.key.toUpperCase()));
289
- }
290
- var comboClashKey = (c) => [c.mod || c.meta || c.ctrl, c.alt, c.shift, c.key].join("|");
291
-
292
- // src/player/components/studioShortcuts.ts
293
- var DEFAULT_STUDIO_KEYS = {
294
- fullscreen: "f",
295
- split: "s",
296
- record: "r",
297
- addKeyframe: "k",
298
- audioGain: "g",
299
- zoomSelection: "z",
300
- mute: "m",
301
- pause: "k",
302
- shuttleBack: "j",
303
- shuttleForward: "l",
304
- inPoint: "i",
305
- outPoint: "o",
306
- seekToIn: "a",
307
- seekToOut: "e",
308
- selectTool: "v",
309
- razorTool: "b",
310
- selectLeftward: "[",
311
- selectRightward: "]",
312
- exitRazor: "a",
313
- snap: "s",
314
- grid: "g",
315
- timelineSnap: "n",
316
- playPause: "Space",
317
- frameBack: "ArrowLeft",
318
- frameForward: "ArrowRight",
319
- frameBackTen: "shift+ArrowLeft",
320
- frameForwardTen: "shift+ArrowRight",
321
- loop: "shift+l",
322
- clearInPoint: "shift+i",
323
- clearOutPoint: "shift+o",
324
- undo: "mod+z",
325
- redo: "mod+shift+z",
326
- redoAlt: "ctrl+y",
327
- tabCompositions: "mod+1",
328
- tabAssets: "mod+2",
329
- group: "mod+g",
330
- ungroup: "mod+shift+g",
331
- copy: "mod+c",
332
- paste: "mod+v",
333
- cut: "mod+x",
334
- duplicate: "mod+d",
335
- linkToggle: "mod+l",
336
- detachAudio: "alt+shift+d",
337
- deleteLinked: "alt+Backspace",
338
- deleteLinkedAlt: "alt+Delete",
339
- deleteSelected: "Delete",
340
- deleteSelectedAlt: "Backspace",
341
- resetKeyframes: "Backspace",
342
- nudgeLeft: "ArrowLeft",
343
- nudgeRight: "ArrowRight",
344
- nudgeUp: "ArrowUp",
345
- nudgeDown: "ArrowDown",
346
- nudgeLeftTen: "shift+ArrowLeft",
347
- nudgeRightTen: "shift+ArrowRight",
348
- nudgeUpTen: "shift+ArrowUp",
349
- nudgeDownTen: "shift+ArrowDown",
350
- captionSelectAll: "mod+a",
351
- pickupClip: "Space",
352
- pickupUp: "ArrowUp",
353
- pickupDown: "ArrowDown",
354
- pickupDrop: "Enter",
355
- cancel: "Escape"
356
- };
357
238
  var SHARED_BY_DESIGN = [
358
239
  ["pause", "addKeyframe"],
359
240
  ["seekToIn", "exitRazor"],
@@ -17416,6 +17297,16 @@ function serializeStudioFileMutations(writer, targetPaths, task) {
17416
17297
  }
17417
17298
 
17418
17299
  // src/utils/studioFileHistory.ts
17300
+ function editContextTarget(file, target) {
17301
+ return {
17302
+ file,
17303
+ ...target.id && { id: target.id },
17304
+ ...target.hfId && { hfId: target.hfId },
17305
+ ...target.selector && { selector: target.selector },
17306
+ ...target.selectorIndex !== void 0 && { selectorIndex: target.selectorIndex },
17307
+ ...target.label && { name: target.label }
17308
+ };
17309
+ }
17419
17310
  async function readProjectFileContent(pid, path) {
17420
17311
  const response = await studioApiFetch(
17421
17312
  buildProjectApiPath(pid, `/files/${encodeURIComponent(path)}`)
@@ -17453,6 +17344,7 @@ async function saveServerRewriteWithHistory(input) {
17453
17344
  }
17454
17345
  async function writeProjectFilesWithHistoryInQueue({
17455
17346
  label,
17347
+ targets,
17456
17348
  coalesceKey,
17457
17349
  coalesceMs,
17458
17350
  files,
@@ -17477,7 +17369,13 @@ async function writeProjectFilesWithHistoryInQueue({
17477
17369
  await writeFile(path, snapshots[path].after, diskContent?.[path] ?? snapshots[path].before);
17478
17370
  writtenPaths.push(path);
17479
17371
  }
17480
- await recordEdit({ label, coalesceKey, coalesceMs, files: snapshots });
17372
+ await recordEdit({
17373
+ label,
17374
+ coalesceKey,
17375
+ coalesceMs,
17376
+ ...targets?.length && { targets },
17377
+ files: snapshots
17378
+ });
17481
17379
  } catch (error) {
17482
17380
  try {
17483
17381
  for (const path of writtenPaths.reverse()) {
@@ -18718,6 +18616,10 @@ function buildPatchTarget(element) {
18718
18616
  }
18719
18617
  return null;
18720
18618
  }
18619
+ function timelineEditTarget(path, element) {
18620
+ const patchTarget = buildPatchTarget(element);
18621
+ return patchTarget && editContextTarget(path, { ...patchTarget, label: element.label });
18622
+ }
18721
18623
  function findTimelineElementInIframe(iframe, element, activeCompositionPath = null) {
18722
18624
  try {
18723
18625
  const doc = iframe?.contentDocument;
@@ -18854,6 +18756,7 @@ async function persistTimelineEdit(input) {
18854
18756
  await saveProjectFilesWithHistory({
18855
18757
  projectId: input.projectId,
18856
18758
  label: input.label,
18759
+ targets: [editContextTarget(targetPath, { ...patchTarget, label: input.element.label })],
18857
18760
  coalesceKey: input.coalesceKey,
18858
18761
  coalesceMs: input.coalesceMs,
18859
18762
  files: {
@@ -18917,6 +18820,10 @@ async function persistTimelineBatchEdit(input) {
18917
18820
  await saveProjectFilesWithHistory({
18918
18821
  projectId: input.projectId,
18919
18822
  label: input.label,
18823
+ targets: input.changes.flatMap((change) => {
18824
+ const path = change.element.sourceFile || input.activeCompPath || "index.html";
18825
+ return timelineEditTarget(path, change.element) ?? [];
18826
+ }),
18920
18827
  coalesceKey: input.coalesceKey,
18921
18828
  coalesceMs: input.coalesceMs,
18922
18829
  files: Object.fromEntries([...changesByPath.keys()].map((path) => [path, buildFile(path)])),
@@ -25360,9 +25267,6 @@ async function requestNormalizePlan(projectId, el, fetchImpl = studioApiFetch) {
25360
25267
  // src/player/components/audioGainApply.ts
25361
25268
  var AUDIO_GAIN_LABEL = "Audio Gain";
25362
25269
  async function writeClipGains(edits, writers, label = AUDIO_GAIN_LABEL) {
25363
- if (edits.some(({ element }) => volumeLaneOwnsGain(element))) {
25364
- throw new Error(VOLUME_LANE_REFUSAL);
25365
- }
25366
25270
  const values = edits.map(({ element, gain }) => ({ element, value: formatAudioGain(gain) }));
25367
25271
  if (values.length > 1 && writers.onSetElementsAttributeQuiet) {
25368
25272
  throwUnlessSaved(await writers.onSetElementsAttributeQuiet(values, "data-volume", label));
@@ -29547,55 +29451,6 @@ function transitionLabelsForDocument(doc, timelines) {
29547
29451
  // src/player/lib/timelineIframeHelpers.ts
29548
29452
  import { readClipTiming } from "@hyperframes/core/composition-contract";
29549
29453
  import { createRuntimeStartTimeResolver } from "@hyperframes/core/runtime/start-resolver";
29550
-
29551
- // src/player/lib/runtimeProtocol.ts
29552
- import {
29553
- frameDisplayScale,
29554
- inspectRuntimeProtocol,
29555
- runtimeProtocolMetadata
29556
- } from "@hyperframes/core/runtime/protocol";
29557
- function createRuntimeControlMessage(action, payload = {}, fps = 30) {
29558
- return {
29559
- ...payload,
29560
- source: "hf-parent",
29561
- type: "control",
29562
- action,
29563
- ...runtimeProtocolMetadata(fps)
29564
- };
29565
- }
29566
- function postRuntimeControlMessage(target, action, payload = {}, fps = 30) {
29567
- target?.postMessage(createRuntimeControlMessage(action, payload, fps), "*");
29568
- }
29569
- function postFrameDisplayScale(iframe) {
29570
- const scale = iframe && frameDisplayScale(iframe);
29571
- if (scale) postRuntimeControlMessage(iframe.contentWindow, "set-display-scale", { scale });
29572
- }
29573
- function inspectStudioRuntimeMessage(value) {
29574
- return inspectRuntimeProtocol(value, 30);
29575
- }
29576
- function dispatchRuntimeProtocolError(inspection) {
29577
- if (inspection.status !== "unsupported") return;
29578
- window.dispatchEvent(
29579
- new CustomEvent("runtimeprotocolerror", {
29580
- detail: {
29581
- code: inspection.code,
29582
- receivedVersion: inspection.receivedVersion
29583
- }
29584
- })
29585
- );
29586
- }
29587
- function acceptStudioRuntimeMessage(value) {
29588
- const inspection = inspectStudioRuntimeMessage(value);
29589
- if (inspection.status !== "unsupported") return inspection;
29590
- dispatchRuntimeProtocolError(inspection);
29591
- return null;
29592
- }
29593
- function acceptedRuntimeMessageFps(value) {
29594
- const inspection = inspectStudioRuntimeMessage(value);
29595
- return inspection.status === "supported" ? inspection.fps : 30;
29596
- }
29597
-
29598
- // src/player/lib/timelineIframeHelpers.ts
29599
29454
  function normalizePreviewViewport(doc, win) {
29600
29455
  if (doc.documentElement) {
29601
29456
  doc.documentElement.style.overflow = "hidden";
@@ -31856,7 +31711,9 @@ function useShadowReloadRetry(generation, url, begin) {
31856
31711
  var SHADOW_READY_TIMEOUT_MS = 15e3;
31857
31712
  var SHADOW_READY_BUDGETS = 3;
31858
31713
  function restoreSeekPainted(iframe) {
31859
- const win = iframe?.contentWindow;
31714
+ if (!iframe) return void 0;
31715
+ if (previewFrameOpaque(iframe)) return previewSeekPainted(iframe, SHADOW_READY_TIMEOUT_MS);
31716
+ const win = iframe.contentWindow;
31860
31717
  return win?.__hfWaitForSeekCompletion?.().catch(() => {
31861
31718
  });
31862
31719
  }
@@ -31911,6 +31768,7 @@ function useShadowPreviewReload({
31911
31768
  const readyTimerRef = useRef49(void 0);
31912
31769
  const budgetsSpentRef = useRef49(0);
31913
31770
  const budgetGenRef = useRef49(null);
31771
+ const shadowFrameLeftPageRef = useRef49(false);
31914
31772
  const cancelPendingLoadRef = useRef49(() => {
31915
31773
  });
31916
31774
  const stopHoldRef = useRef49(() => {
@@ -31927,6 +31785,7 @@ function useShadowPreviewReload({
31927
31785
  const stopPendingShadow = useCallback40(() => {
31928
31786
  clearTimeout(readyTimerRef.current);
31929
31787
  budgetGenRef.current = null;
31788
+ shadowFrameLeftPageRef.current = false;
31930
31789
  cancelPendingLoadRef.current();
31931
31790
  stopHoldRef.current();
31932
31791
  pendingCommitRef.current = null;
@@ -32078,13 +31937,10 @@ function useShadowPreviewReload({
32078
31937
  },
32079
31938
  [promoteWhenReady]
32080
31939
  );
32081
- const setShadowIframeNode = useCallback40((node) => {
32082
- shadowIframeRef.current = node;
32083
- }, []);
32084
31940
  const armReadyTimer = useCallback40(
32085
31941
  (gen) => {
32086
31942
  clearTimeout(readyTimerRef.current);
32087
- if (isDocumentHidden()) return;
31943
+ if (isDocumentHidden() || shadowFrameLeftPageRef.current) return;
32088
31944
  let drew = false;
32089
31945
  let starved = false;
32090
31946
  requestAnimationFrame(() => {
@@ -32098,6 +31954,12 @@ function useShadowPreviewReload({
32098
31954
  logReload("shadow-starved", { gen });
32099
31955
  return;
32100
31956
  }
31957
+ const frame3 = shadowIframeRef.current;
31958
+ if (frame3 && !frame3.isConnected) {
31959
+ shadowFrameLeftPageRef.current = true;
31960
+ logReload("shadow-detached", { gen });
31961
+ return;
31962
+ }
32101
31963
  budgetsSpentRef.current += 1;
32102
31964
  if (budgetsSpentRef.current < SHADOW_READY_BUDGETS) {
32103
31965
  logReload("shadow-slow", { budgetsSpent: budgetsSpentRef.current });
@@ -32111,6 +31973,16 @@ function useShadowPreviewReload({
32111
31973
  );
32112
31974
  const armReadyTimerRef = useRef49(armReadyTimer);
32113
31975
  armReadyTimerRef.current = armReadyTimer;
31976
+ const setShadowIframeNode = useCallback40((node) => {
31977
+ shadowIframeRef.current = node;
31978
+ const gen = budgetGenRef.current;
31979
+ if (!node || !shadowFrameLeftPageRef.current || gen == null || gen !== shadowGenRef.current)
31980
+ return;
31981
+ shadowFrameLeftPageRef.current = false;
31982
+ budgetsSpentRef.current = 0;
31983
+ logReload("shadow-reattached", { gen });
31984
+ armReadyTimerRef.current(gen);
31985
+ }, []);
32114
31986
  const beginShadowReload = useCallback40(
32115
31987
  (url) => {
32116
31988
  retry.started();
@@ -32169,6 +32041,51 @@ function useShadowPreviewReload({
32169
32041
  };
32170
32042
  }
32171
32043
 
32044
+ // src/player/lib/pausedVideoProvider.ts
32045
+ var installed = /* @__PURE__ */ new WeakMap();
32046
+ function attachPausedVideoProvider(iframe, win) {
32047
+ if (!win.__hf?.setPausedVideoFrameProvider || !iframe.contentDocument) return;
32048
+ const previous = installed.get(iframe);
32049
+ const setter = win.__hf.setPausedVideoFrameProvider;
32050
+ if (previous?.document === iframe.contentDocument && previous.setter === setter) return;
32051
+ previous?.provider.dispose();
32052
+ let disposed = false;
32053
+ let decoder = null;
32054
+ const provider = {
32055
+ async decode(requests, signal) {
32056
+ signal.throwIfAborted();
32057
+ if (disposed) throw new DOMException("Preview disposed", "AbortError");
32058
+ decoder ??= import("./pausedVideoDecoder-W2SVMXDS.js").then(
32059
+ ({ createPausedVideoDecoder }) => createPausedVideoDecoder(iframe)
32060
+ );
32061
+ const actual = await decoder;
32062
+ if (disposed) {
32063
+ actual.dispose();
32064
+ throw new DOMException("Preview disposed", "AbortError");
32065
+ }
32066
+ return actual.decode(requests, signal);
32067
+ },
32068
+ async suspend() {
32069
+ const actual = await decoder?.catch(() => null);
32070
+ await actual?.suspend?.();
32071
+ },
32072
+ dispose() {
32073
+ if (disposed) return;
32074
+ disposed = true;
32075
+ void decoder?.then((actual) => actual.dispose()).catch(() => {
32076
+ });
32077
+ win.removeEventListener("pagehide", onPageHide);
32078
+ }
32079
+ };
32080
+ const onPageHide = () => {
32081
+ provider.dispose();
32082
+ installed.delete(iframe);
32083
+ };
32084
+ win.addEventListener("pagehide", onPageHide, { once: true });
32085
+ installed.set(iframe, { document: iframe.contentDocument, provider, setter });
32086
+ setter(provider);
32087
+ }
32088
+
32172
32089
  // src/player/hooks/playbackAdapterResolution.ts
32173
32090
  function pickTimelineAdapter(iframe, win, docDuration) {
32174
32091
  let fallback = null;
@@ -32216,6 +32133,13 @@ function resolvePlaybackAdapter(iframe, win, refs) {
32216
32133
  }
32217
32134
  return bestAdapter;
32218
32135
  }
32136
+ function resolveFramePlaybackAdapter(iframe, refs) {
32137
+ if (previewFrameOpaque(iframe)) return bridgePlaybackAdapter(iframe);
32138
+ const win = iframe.contentWindow;
32139
+ if (!win) return null;
32140
+ attachPausedVideoProvider(iframe, win);
32141
+ return resolvePlaybackAdapter(iframe, win, refs);
32142
+ }
32219
32143
 
32220
32144
  // src/player/hooks/useTimelinePlayerLoop.ts
32221
32145
  import { useCallback as useCallback41 } from "react";
@@ -32271,51 +32195,6 @@ function useTimelinePlayerLoop({
32271
32195
  return { startRAFLoop, stopRAFLoop, stopReverseLoop };
32272
32196
  }
32273
32197
 
32274
- // src/player/lib/pausedVideoProvider.ts
32275
- var installed = /* @__PURE__ */ new WeakMap();
32276
- function attachPausedVideoProvider(iframe, win) {
32277
- if (!win.__hf?.setPausedVideoFrameProvider || !iframe.contentDocument) return;
32278
- const previous = installed.get(iframe);
32279
- const setter = win.__hf.setPausedVideoFrameProvider;
32280
- if (previous?.document === iframe.contentDocument && previous.setter === setter) return;
32281
- previous?.provider.dispose();
32282
- let disposed = false;
32283
- let decoder = null;
32284
- const provider = {
32285
- async decode(requests, signal) {
32286
- signal.throwIfAborted();
32287
- if (disposed) throw new DOMException("Preview disposed", "AbortError");
32288
- decoder ??= import("./pausedVideoDecoder-W2SVMXDS.js").then(
32289
- ({ createPausedVideoDecoder }) => createPausedVideoDecoder(iframe)
32290
- );
32291
- const actual = await decoder;
32292
- if (disposed) {
32293
- actual.dispose();
32294
- throw new DOMException("Preview disposed", "AbortError");
32295
- }
32296
- return actual.decode(requests, signal);
32297
- },
32298
- async suspend() {
32299
- const actual = await decoder?.catch(() => null);
32300
- await actual?.suspend?.();
32301
- },
32302
- dispose() {
32303
- if (disposed) return;
32304
- disposed = true;
32305
- void decoder?.then((actual) => actual.dispose()).catch(() => {
32306
- });
32307
- win.removeEventListener("pagehide", onPageHide);
32308
- }
32309
- };
32310
- const onPageHide = () => {
32311
- provider.dispose();
32312
- installed.delete(iframe);
32313
- };
32314
- win.addEventListener("pagehide", onPageHide, { once: true });
32315
- installed.set(iframe, { document: iframe.contentDocument, provider, setter });
32316
- setter(provider);
32317
- }
32318
-
32319
32198
  // src/player/lib/playbackScrub.ts
32320
32199
  function scrubMusicAtSeek(iframe, nextTime) {
32321
32200
  const s = usePlayerStore.getState();
@@ -32615,14 +32494,27 @@ function enrichDue(lastTimelineMessage, enriched) {
32615
32494
  enriched.at = now2;
32616
32495
  return true;
32617
32496
  }
32497
+ function recoverClipManifest(deps, iframe, recovery) {
32498
+ if (recovery.asking) return;
32499
+ recovery.asking = true;
32500
+ previewClipManifest(iframe).then((manifest) => {
32501
+ const stillWanted = usePlayerStore.getState().elements.length === 0 && deps.iframeRef.current === iframe && !hasTimelinePerformanceFixtureLease();
32502
+ if (manifest && manifest.clips.length > 0 && stillWanted)
32503
+ deps.processTimelineMessageRef.current(manifest);
32504
+ }).catch(() => {
32505
+ }).finally(() => recovery.asking = false);
32506
+ }
32507
+ function recoverEmptyTimeline(deps, iframe, recovery) {
32508
+ if (iframe && previewFrameOpaque(iframe)) return recoverClipManifest(deps, iframe, recovery);
32509
+ const manifest = iframe?.contentWindow?.__clipManifest;
32510
+ if (manifest && manifest.clips.length > 0) {
32511
+ deps.processTimelineMessageRef.current(manifest);
32512
+ }
32513
+ }
32618
32514
  function handleStateMessage(deps, iframe, playingHoldsClipListPosts, enriched) {
32619
32515
  try {
32620
- if (usePlayerStore.getState().elements.length === 0) {
32621
- const manifest = iframe?.contentWindow?.__clipManifest;
32622
- if (manifest && manifest.clips.length > 0) {
32623
- deps.processTimelineMessageRef.current(manifest);
32624
- }
32625
- }
32516
+ if (usePlayerStore.getState().elements.length === 0)
32517
+ recoverEmptyTimeline(deps, iframe, enriched);
32626
32518
  if (!playingHoldsClipListPosts && enrichDue(deps.lastTimelineMessageRef.current, enriched)) {
32627
32519
  deps.enrichMissingCompositionsRef.current();
32628
32520
  }
@@ -32666,7 +32558,7 @@ function applyStoreReport(data) {
32666
32558
  }
32667
32559
  }
32668
32560
  function createPreviewMessageHandler(deps) {
32669
- const enriched = { at: 0 };
32561
+ const enriched = { at: 0, asking: false };
32670
32562
  return (e) => {
32671
32563
  const iframe = deps.iframeRef.current;
32672
32564
  const data = acceptedPreviewMessage(e, iframe);
@@ -32803,10 +32695,8 @@ function useTimelinePlayer({
32803
32695
  (overrideIframe) => {
32804
32696
  try {
32805
32697
  const iframe = overrideIframe !== void 0 ? overrideIframe : iframeRef.current;
32806
- const win = iframe?.contentWindow;
32807
- if (!iframe || !win) return null;
32808
- attachPausedVideoProvider(iframe, win);
32809
- const adapter = resolvePlaybackAdapter(iframe, win, {
32698
+ if (!iframe) return null;
32699
+ const adapter = resolveFramePlaybackAdapter(iframe, {
32810
32700
  cache: staticSeekAdapterRef,
32811
32701
  warned: staticSeekWarnedRef
32812
32702
  });
@@ -32818,10 +32708,7 @@ function useTimelinePlayer({
32818
32708
  []
32819
32709
  );
32820
32710
  const setLoopStart = useCallback42((seconds) => {
32821
- try {
32822
- iframeRef.current?.contentWindow?.__hf?.setLoopStart?.(seconds);
32823
- } catch {
32824
- }
32711
+ if (iframeRef.current) setFrameLoopStart(iframeRef.current, seconds);
32825
32712
  }, []);
32826
32713
  const { startRAFLoop, stopRAFLoop, stopReverseLoop } = useTimelinePlayerLoop({
32827
32714
  rafRef,
@@ -35112,6 +34999,15 @@ function sameRect(a, b) {
35112
34999
  const d = (k) => Math.abs(a[k] - b[k]);
35113
35000
  return d("left") < 0.5 && d("top") < 0.5 && d("width") < 0.5 && d("height") < 0.5 && d("scaleX") < 1e-3 && d("scaleY") < 1e-3;
35114
35001
  }
35002
+ function declaredCompositionSize(iframe) {
35003
+ if (previewFrameOpaque(iframe)) return previewStageSize(iframe) ?? { width: NaN, height: NaN };
35004
+ const doc = iframe.contentDocument;
35005
+ const root = doc?.querySelector("[data-composition-id]") ?? doc?.documentElement;
35006
+ return {
35007
+ width: Number.parseFloat(root?.getAttribute("data-width") ?? ""),
35008
+ height: Number.parseFloat(root?.getAttribute("data-height") ?? "")
35009
+ };
35010
+ }
35115
35011
  function useDomEditCompositionRect({
35116
35012
  iframeRef,
35117
35013
  overlayRef
@@ -35134,10 +35030,7 @@ function useDomEditCompositionRect({
35134
35030
  const left = iRect.left - oRect.left;
35135
35031
  const top = iRect.top - oRect.top;
35136
35032
  if (iRect.width <= 0 || iRect.height <= 0) return;
35137
- const doc = iframe.contentDocument;
35138
- const root = doc?.querySelector("[data-composition-id]") ?? doc?.documentElement;
35139
- const dw = Number.parseFloat(root?.getAttribute("data-width") ?? "");
35140
- const dh = Number.parseFloat(root?.getAttribute("data-height") ?? "");
35033
+ const { width: dw, height: dh } = declaredCompositionSize(iframe);
35141
35034
  const scaleX = dw > 0 ? iRect.width / dw : 1;
35142
35035
  const scaleY = dh > 0 ? iRect.height / dh : 1;
35143
35036
  const next = { left, top, width: iRect.width, height: iRect.height, scaleX, scaleY };
@@ -39252,7 +39145,7 @@ function OffCanvasIndicators({
39252
39145
  const selectOffCanvas = async () => {
39253
39146
  const el = elements.current.get(r.key);
39254
39147
  if (!el) return;
39255
- const { resolveDomEditSelection: resolveDomEditSelection2 } = await import("./domEditingLayers-7Q56QAU5.js");
39148
+ const { resolveDomEditSelection: resolveDomEditSelection2 } = await import("./domEditingLayers-FRVHP6IB.js");
39256
39149
  const acp = activeCompositionPathRef.current ?? "index.html";
39257
39150
  const sel = await resolveDomEditSelection2(el, {
39258
39151
  activeCompositionPath: acp,
@@ -39315,22 +39208,27 @@ function createGestureReadout(overlay, iframe, rect) {
39315
39208
  viewportWidth: window.innerWidth,
39316
39209
  viewportHeight: window.innerHeight,
39317
39210
  text: "",
39318
- rect
39211
+ rect,
39212
+ baseRect: rect
39319
39213
  };
39320
39214
  }
39321
- function updateGestureReadout(readout, rect, text3) {
39322
- if (!readout) return;
39215
+ function setReadout(readout, rect, text3) {
39323
39216
  const { basis } = readout;
39324
39217
  const x = (rect.left - (basis.iframeRect.left - basis.overlayRect.left)) / basis.rootScaleX;
39325
39218
  const y = (rect.top - (basis.iframeRect.top - basis.overlayRect.top)) / basis.rootScaleY;
39326
- readout.text = text3 ?? `Canvas X ${Math.round(x)} \xB7 Y ${Math.round(y)}`;
39219
+ readout.text = text3 ?? `X ${Math.round(x)} \xB7 Y ${Math.round(y)}`;
39327
39220
  readout.rect = rect;
39328
39221
  }
39329
- function updateGestureReadoutAngle(readout, angle) {
39330
- if (readout) updateGestureReadout(readout, readout.rect, `${Math.round(angle)}\xB0`);
39222
+ function updateGestureReadout(readout, rect, text3) {
39223
+ if (readout) setReadout(readout, { ...rect, angle: readout.baseRect.angle }, text3);
39224
+ }
39225
+ function updateGestureReadoutAngle(readout, angle, startAngle = 0) {
39226
+ if (!readout) return;
39227
+ const turned = (readout.baseRect.angle ?? 0) + angle - startAngle;
39228
+ setReadout(readout, { ...readout.baseRect, angle: turned }, `\u21BB ${Math.round(angle)}\xB0`);
39331
39229
  }
39332
39230
  function updateGestureReadoutSize(readout, rect, size) {
39333
- updateGestureReadout(readout, rect, `${Math.round(size.width)} \xD7 ${Math.round(size.height)}`);
39231
+ updateGestureReadout(readout, rect, `W ${Math.round(size.width)} \xB7 H ${Math.round(size.height)}`);
39334
39232
  }
39335
39233
 
39336
39234
  // src/components/editor/domEditResizeLocal.ts
@@ -41878,7 +41776,7 @@ function createDomEditOverlayGestureHandlers(opts) {
41878
41776
  actualAngle: g.actualRotation,
41879
41777
  snap: e.shiftKey
41880
41778
  });
41881
- updateGestureReadoutAngle(g.readout, rotated.angle);
41779
+ updateGestureReadoutAngle(g.readout, rotated.angle, g.actualRotation);
41882
41780
  applyRotationDraft(sel.element, rotated.angle, g.plainRotation);
41883
41781
  return;
41884
41782
  }
@@ -43464,7 +43362,7 @@ function InlineTextCaret({
43464
43362
  let side = "after";
43465
43363
  const update = () => setPlacement(composing ? null : placeAtCaret(element, iframe, color, side));
43466
43364
  const onKey = ({ key: key2 }) => {
43467
- if (!MODIFIERS2.has(key2)) side = SIDE_OF_KEY[key2] ?? "after";
43365
+ if (!MODIFIERS.has(key2)) side = SIDE_OF_KEY[key2] ?? "after";
43468
43366
  };
43469
43367
  const onPress = () => void (side = "after");
43470
43368
  const composition = (on) => () => {
@@ -43536,7 +43434,7 @@ function caretColorOf(element) {
43536
43434
  if (!style) return "currentColor";
43537
43435
  return style.caretColor && style.caretColor !== "auto" ? style.caretColor : style.color;
43538
43436
  }
43539
- var MODIFIERS2 = /* @__PURE__ */ new Set(["Shift", "Control", "Alt", "Meta"]);
43437
+ var MODIFIERS = /* @__PURE__ */ new Set(["Shift", "Control", "Alt", "Meta"]);
43540
43438
  var SIDE_OF_KEY = { End: "before" };
43541
43439
  function placeAtCaret(element, iframe, color, side) {
43542
43440
  const view = element.ownerDocument.defaultView;
@@ -44644,22 +44542,134 @@ function useOffCanvasIndicators({
44644
44542
 
44645
44543
  // src/components/editor/DomEditGestureReadout.tsx
44646
44544
  import { useRef as useRef76 } from "react";
44545
+
44546
+ // src/components/editor/domEditGestureReadoutPlacement.ts
44547
+ var GAP_PX2 = 8;
44548
+ var EDGE_PX = 4;
44549
+ var SNAP_TOOLBAR_BAND_PX = 36;
44550
+ var SNAP_TOOLBAR_WIDTH_PX = 180;
44551
+ var CHIP_HEIGHT_PX = 32;
44552
+ var CHAR_PX = 8;
44553
+ var CHIP_PADDING_PX = 36;
44554
+ var SIDES = ["below", "right", "left", "above"];
44555
+ function visibleBox(readout) {
44556
+ const bounds = readout.basis.overlayRect;
44557
+ const stage = readout.basis.iframeRect;
44558
+ const stageLeft = stage.left - bounds.left;
44559
+ const stageTop = stage.top - bounds.top;
44560
+ const minY = Math.max(0, -bounds.top, stageTop) + EDGE_PX;
44561
+ const maxX = Math.min(bounds.width, readout.viewportWidth - bounds.left, stageLeft + stage.width) - EDGE_PX;
44562
+ return {
44563
+ minX: Math.max(0, -bounds.left, stageLeft) + EDGE_PX,
44564
+ minY,
44565
+ toolbarBottom: minY + SNAP_TOOLBAR_BAND_PX,
44566
+ toolbarLeft: maxX - SNAP_TOOLBAR_WIDTH_PX,
44567
+ maxX,
44568
+ maxY: Math.min(bounds.height, readout.viewportHeight - bounds.top, stageTop + stage.height) - EDGE_PX
44569
+ };
44570
+ }
44571
+ function clearOfToolbar(box, right, top) {
44572
+ return right <= box.toolbarLeft || top >= box.toolbarBottom;
44573
+ }
44574
+ function paintedBox(rect) {
44575
+ const radians = (rect.angle ?? 0) * Math.PI / 180;
44576
+ const cos = Math.abs(Math.cos(radians));
44577
+ const sin = Math.abs(Math.sin(radians));
44578
+ const width = rect.width * cos + rect.height * sin;
44579
+ const height = rect.width * sin + rect.height * cos;
44580
+ return {
44581
+ ...rect,
44582
+ left: rect.left + (rect.width - width) / 2,
44583
+ top: rect.top + (rect.height - height) / 2,
44584
+ width,
44585
+ height
44586
+ };
44587
+ }
44588
+ function fitsBeside(box, x0, x1, top) {
44589
+ const inside = x0 >= box.minX && x1 <= box.maxX && top >= box.minY && top + CHIP_HEIGHT_PX <= box.maxY;
44590
+ return inside && clearOfToolbar(box, x1, top);
44591
+ }
44592
+ function chipSpots(readout, box, width) {
44593
+ const rect = paintedBox(readout.rect);
44594
+ const right = rect.left + rect.width;
44595
+ const bottom = rect.top + rect.height;
44596
+ const centre = rect.left + rect.width / 2;
44597
+ const middle = rect.top + rect.height / 2 - CHIP_HEIGHT_PX / 2;
44598
+ const toolbarBelow = readout.basis.overlayRect.top + rect.top - GAP_PX < TOOLBAR_HEIGHT_PX;
44599
+ const toolbarBand = toolbarBelow ? 0 : GAP_PX + TOOLBAR_HEIGHT_PX;
44600
+ return {
44601
+ below: {
44602
+ x: centre,
44603
+ y: bottom + GAP_PX2,
44604
+ fits: !toolbarBelow && bottom + GAP_PX2 + CHIP_HEIGHT_PX <= box.maxY
44605
+ },
44606
+ right: {
44607
+ x: right + GAP_PX2,
44608
+ y: middle,
44609
+ fits: fitsBeside(box, right + GAP_PX2, right + GAP_PX2 + width, middle)
44610
+ },
44611
+ left: {
44612
+ x: rect.left - GAP_PX2,
44613
+ y: middle,
44614
+ fits: fitsBeside(box, rect.left - GAP_PX2 - width, rect.left - GAP_PX2, middle)
44615
+ },
44616
+ above: { x: centre, y: rect.top - GAP_PX2 - toolbarBand - CHIP_HEIGHT_PX, fits: true }
44617
+ };
44618
+ }
44619
+ function chooseSide(kept, spots) {
44620
+ if (kept && spots[kept].fits) return kept;
44621
+ return SIDES.find((side) => spots[side].fits) ?? "above";
44622
+ }
44623
+ var TRANSFORMS = {
44624
+ below: "translateX(-50%)",
44625
+ above: "translateX(-50%)",
44626
+ left: "translateX(-100%)",
44627
+ right: "none"
44628
+ };
44629
+ function placeChip(readout, text3) {
44630
+ const box = visibleBox(readout);
44631
+ const width = text3.length * CHAR_PX + CHIP_PADDING_PX;
44632
+ const spots = chipSpots(readout, box, width);
44633
+ const side = chooseSide(readout.side, spots);
44634
+ const spot = spots[side];
44635
+ const centred = TRANSFORMS[side] === "translateX(-50%)";
44636
+ const left = centred ? Math.max(box.minX + width / 2, Math.min(box.maxX - width / 2, spot.x)) : spot.x;
44637
+ const chipRight = side === "right" ? left + width : side === "left" ? left : left + width / 2;
44638
+ const floor = clearOfToolbar(box, chipRight, box.minY) ? box.minY : box.toolbarBottom;
44639
+ const top = Math.min(box.maxY - CHIP_HEIGHT_PX, Math.max(floor, spot.y));
44640
+ return { side, left, top, transform: TRANSFORMS[side] };
44641
+ }
44642
+
44643
+ // src/components/editor/DomEditGestureReadout.tsx
44647
44644
  import { jsx as jsx111 } from "react/jsx-runtime";
44648
- function positionGestureReadout(label, gesture) {
44645
+ function positionGestureReadout(label, gesture, text3) {
44649
44646
  const readout = gesture.readout;
44650
44647
  if (!readout) return;
44651
- const bounds = readout.basis.overlayRect;
44652
- const rect = readout.rect;
44653
- const minX = Math.max(0, -bounds.left) + 4;
44654
- const minY = Math.max(0, -bounds.top) + 4;
44655
- const maxX = Math.min(bounds.width, readout.viewportWidth - bounds.left) - 4;
44656
- const maxY = Math.min(bounds.height, readout.viewportHeight - bounds.top) - 4;
44657
- const x = Math.max(minX, Math.min(maxX, rect.left + rect.width + 8));
44658
- const y = Math.max(minY, Math.min(maxY, rect.top - 8));
44659
- label.style.left = `${x}px`;
44660
- label.style.top = `${y}px`;
44661
- label.style.maxWidth = `${Math.max(0, maxX - minX)}px`;
44662
- label.style.transform = `translate(max(-100%, ${minX - x}px), max(-100%, ${minY - y}px))`;
44648
+ const placed = placeChip(readout, text3);
44649
+ readout.side = placed.side;
44650
+ label.style.left = `${placed.left}px`;
44651
+ label.style.top = `${placed.top}px`;
44652
+ label.style.transform = placed.transform;
44653
+ }
44654
+ function renderFields(label, text3) {
44655
+ const fields = text3.split(" \xB7 ").flatMap((field, index2) => {
44656
+ const [name = "", ...value] = field.split(" ");
44657
+ const cells = document.createElement("span");
44658
+ cells.className = "flex items-baseline gap-1.5";
44659
+ const key2 = document.createElement("span");
44660
+ key2.className = "text-text-4";
44661
+ key2.textContent = name;
44662
+ const figure = document.createElement("span");
44663
+ figure.className = "min-w-[4ch] text-right font-medium";
44664
+ figure.textContent = value.join(" ");
44665
+ cells.append(key2, figure);
44666
+ if (index2 === 0) return [cells];
44667
+ const divider = document.createElement("span");
44668
+ divider.className = "h-3.5 w-px bg-border";
44669
+ return [divider, cells];
44670
+ });
44671
+ label.replaceChildren(...fields);
44672
+ label.dataset.readoutText = text3;
44663
44673
  }
44664
44674
  function DomEditGestureReadout({ gestureRef }) {
44665
44675
  const labelRef = useRef76(null);
@@ -44673,9 +44683,9 @@ function DomEditGestureReadout({ gestureRef }) {
44673
44683
  label.style.display = "none";
44674
44684
  return;
44675
44685
  }
44676
- if (label.textContent !== text3) label.textContent = text3;
44677
- label.style.display = "block";
44678
- positionGestureReadout(label, gesture);
44686
+ if (label.dataset.readoutText !== text3) renderFields(label, text3);
44687
+ label.style.display = "flex";
44688
+ positionGestureReadout(label, gesture, text3);
44679
44689
  })
44680
44690
  );
44681
44691
  return /* @__PURE__ */ jsx111(
@@ -44684,7 +44694,7 @@ function DomEditGestureReadout({ gestureRef }) {
44684
44694
  ref: labelRef,
44685
44695
  "aria-hidden": "true",
44686
44696
  "data-dom-edit-gesture-readout": "true",
44687
- className: "pointer-events-none absolute z-50 overflow-hidden rounded bg-studio-surface px-2 py-1 font-mono text-xs whitespace-nowrap text-studio-text shadow-md",
44697
+ className: "pointer-events-none absolute z-50 flex h-8 items-center gap-2 rounded-lg border border-border bg-raised px-3 text-xs whitespace-nowrap text-studio-text tabular-nums shadow-[0_8px_24px_rgba(0,0,0,0.55)]",
44688
44698
  style: { display: "none" }
44689
44699
  }
44690
44700
  );
@@ -68681,10 +68691,8 @@ function useVolumeAutomation(element, currentTime, onSetAttributeQuiet, linkedSp
68681
68691
  );
68682
68692
  return {
68683
68693
  volumeAutomated: volume.automated,
68684
- automatedVolumeValue: volume.automatedValue,
68685
68694
  onAutomateVolume: volume.onAutomate,
68686
68695
  onRemoveVolumeAutomation: volume.onRemoveAutomation,
68687
- onCommitVolumeAt: volume.onCommitAt,
68688
68696
  rate: {
68689
68697
  ...rate,
68690
68698
  canApplyPreset: elDuration > 0,
@@ -68845,8 +68853,6 @@ function FlatMediaSection({
68845
68853
  volumeAutomated,
68846
68854
  onAutomateVolume,
68847
68855
  onRemoveVolumeAutomation,
68848
- onCommitVolumeAt,
68849
- automatedVolumeValue,
68850
68856
  rate
68851
68857
  }) {
68852
68858
  const track2 = useTrackDesignInput();
@@ -68856,7 +68862,6 @@ function FlatMediaSection({
68856
68862
  const isVisualMedia = isVideo || isImage;
68857
68863
  const el = element.element;
68858
68864
  const gain = parseNumericValue(element.dataAttributes.volume ?? "") ?? 1;
68859
- const volume = volumeAutomated && automatedVolumeValue !== void 0 ? automatedVolumeValue : 1;
68860
68865
  const { mediaStart, mediaStartAttr } = readClipInPoint(element.dataAttributes);
68861
68866
  const constantRate = Number.parseFloat(element.dataAttributes["playback-rate"] ?? "1") || 1;
68862
68867
  const playbackRate = rate?.automated && rate.automatedValue !== void 0 ? rate.automatedValue : constantRate;
@@ -68990,25 +68995,6 @@ function FlatMediaSection({
68990
68995
  ] })
68991
68996
  ] }),
68992
68997
  (isVideo || isAudio) && /* @__PURE__ */ jsxs139(Fragment48, { children: [
68993
- /* @__PURE__ */ jsx184(
68994
- FlatSlider,
68995
- {
68996
- label: "Gain",
68997
- value: audioGainToFaderPosition3(gain),
68998
- min: AUDIO_GAIN_FADER_MIN3,
68999
- max: AUDIO_GAIN_FADER_MAX3,
69000
- tier: gain === 1 ? "default" : "explicitCustom",
69001
- displayValue: audioGainToText3(gain),
69002
- centerTick: true,
69003
- onCommit: (next) => void onSetAttribute("volume", formatAudioGain4(audioFaderPositionToGain3(next))),
69004
- onCommitText: (text3) => {
69005
- const next = parseGainInput(text3);
69006
- if (next === null) return false;
69007
- void onSetAttribute("volume", formatAudioGain4(next));
69008
- return true;
69009
- }
69010
- }
69011
- ),
69012
68998
  /* @__PURE__ */ jsxs139(
69013
68999
  "div",
69014
69000
  {
@@ -69019,17 +69005,17 @@ function FlatMediaSection({
69019
69005
  FlatSlider,
69020
69006
  {
69021
69007
  label: "Volume",
69022
- value: audioGainToFaderPosition3(volume),
69008
+ value: audioGainToFaderPosition3(gain),
69023
69009
  min: AUDIO_GAIN_FADER_MIN3,
69024
69010
  max: AUDIO_GAIN_FADER_MAX3,
69025
- tier: volume === 1 ? "default" : "explicitCustom",
69026
- displayValue: audioGainToText3(volume),
69011
+ tier: gain === 1 ? "default" : "explicitCustom",
69012
+ displayValue: audioGainToText3(gain),
69027
69013
  centerTick: true,
69028
- onCommit: (next) => onCommitVolumeAt?.(audioFaderPositionToGain3(next)),
69014
+ onCommit: (next) => void onSetAttribute("volume", formatAudioGain4(audioFaderPositionToGain3(next))),
69029
69015
  onCommitText: (text3) => {
69030
69016
  const next = parseGainInput(text3);
69031
69017
  if (next === null) return false;
69032
- onCommitVolumeAt?.(next);
69018
+ void onSetAttribute("volume", formatAudioGain4(next));
69033
69019
  return true;
69034
69020
  }
69035
69021
  }
@@ -82522,17 +82508,7 @@ function useDomEditPersist({
82522
82508
  const finalContent2 = prepared.content;
82523
82509
  await editHistory.recordEdit({
82524
82510
  ...history2,
82525
- targets: [
82526
- {
82527
- file: targetPath,
82528
- ...selection.id && { id: selection.id },
82529
- ...selection.hfId && { hfId: selection.hfId },
82530
- ...selection.selector && { selector: selection.selector },
82531
- ...selection.selectorIndex !== void 0 && {
82532
- selectorIndex: selection.selectorIndex
82533
- }
82534
- }
82535
- ],
82511
+ targets: [editContextTarget(targetPath, selection)],
82536
82512
  files: { [targetPath]: { before: originalContent, after: finalContent2 } }
82537
82513
  });
82538
82514
  return { patchData: patchData2, patchedContent: patchedContent2, finalContent: finalContent2 };
@@ -83797,15 +83773,9 @@ function useDomEditCommits({
83797
83773
  coalesceMs: options.coalesceMs,
83798
83774
  files,
83799
83775
  targets: batches.filter((batch) => Object.hasOwn(files, batch.sourceFile)).flatMap(
83800
- (batch) => batch.patches.map(({ target }) => ({
83801
- file: batch.sourceFile,
83802
- ...target.id && { id: target.id },
83803
- ...target.hfId && { hfId: target.hfId },
83804
- ...target.selector && { selector: target.selector },
83805
- ...target.selectorIndex !== void 0 && {
83806
- selectorIndex: target.selectorIndex
83807
- }
83808
- }))
83776
+ (batch) => batch.patches.map(
83777
+ ({ target }) => editContextTarget(batch.sourceFile, target)
83778
+ )
83809
83779
  )
83810
83780
  });
83811
83781
  }
@@ -85343,12 +85313,13 @@ function useGsapScriptCommits({ projectIdRef, activeCompPath, previewIframeRef,
85343
85313
  const activeCompPathRef = useRef154(activeCompPath);
85344
85314
  activeCompPathRef.current = activeCompPath;
85345
85315
  const serializerRef = useRef154(createKeyedSerializer());
85346
- const recordMutationEdit = useCallback143(async (targetPath, result, options) => {
85316
+ const recordMutationEdit = useCallback143(async (targetPath, selection, result, options) => {
85347
85317
  if (result.before == null || result.after == null) return;
85348
85318
  await editHistory.recordEdit({
85349
85319
  label: options.label,
85350
85320
  coalesceKey: options.coalesceKey,
85351
85321
  coalesceMs: options.coalesceMs,
85322
+ targets: [editContextTarget(targetPath, selection)],
85352
85323
  files: { [targetPath]: { before: result.before, after: result.after } }
85353
85324
  });
85354
85325
  }, [editHistory]);
@@ -85366,7 +85337,7 @@ function useGsapScriptCommits({ projectIdRef, activeCompPath, previewIframeRef,
85366
85337
  }
85367
85338
  return;
85368
85339
  }
85369
- await recordMutationEdit(targetPath, result, options);
85340
+ await recordMutationEdit(targetPath, selection, result, options);
85370
85341
  const nestedFiles = await settleNestedReads(
85371
85342
  result.scriptText ? readNestedFiles(
85372
85343
  previewIframeRef.current,
@@ -103093,6 +103064,51 @@ function StudioApp({ readOnlyPreview = false, readOnlyPreviewReason } = {}) {
103093
103064
  // src/hooks/useElementPicker.ts
103094
103065
  import { useState as useState171, useCallback as useCallback198, useEffect as useEffect167, useRef as useRef196 } from "react";
103095
103066
 
103067
+ // src/hooks/elementPickerStyles.ts
103068
+ var PICKED_STYLE_PROPERTIES = [
103069
+ "position",
103070
+ "top",
103071
+ "left",
103072
+ "right",
103073
+ "bottom",
103074
+ "width",
103075
+ "height",
103076
+ "margin-top",
103077
+ "margin-right",
103078
+ "margin-bottom",
103079
+ "margin-left",
103080
+ "padding-top",
103081
+ "padding-right",
103082
+ "padding-bottom",
103083
+ "padding-left",
103084
+ "font-size",
103085
+ "font-weight",
103086
+ "font-family",
103087
+ "color",
103088
+ "background-color",
103089
+ "background",
103090
+ "opacity",
103091
+ "border-radius",
103092
+ "transform",
103093
+ "z-index"
103094
+ ];
103095
+ function readComputedStyles(iframe, selector) {
103096
+ const styles = {};
103097
+ try {
103098
+ const doc = iframe.contentDocument;
103099
+ const el = doc?.querySelector(selector);
103100
+ if (!el) return styles;
103101
+ const computed = iframe.contentWindow?.getComputedStyle(el);
103102
+ if (!computed) return styles;
103103
+ for (const prop of PICKED_STYLE_PROPERTIES) {
103104
+ const val = prop === "opacity" ? getLogicalOpacity(el, computed) : computed.getPropertyValue(prop);
103105
+ if (val) styles[prop] = val;
103106
+ }
103107
+ } catch {
103108
+ }
103109
+ return styles;
103110
+ }
103111
+
103096
103112
  // src/hooks/elementPickerHoverLabel.ts
103097
103113
  var LABEL_GAP_PX = 6;
103098
103114
  var LABEL_MAX_CHARS = 72;
@@ -103303,7 +103319,18 @@ function useElementPickerSession(iframeRef) {
103303
103319
  pickedElementRef.current = null;
103304
103320
  setPickedElement(null);
103305
103321
  }, []);
103306
- const windowsThatWerePrimary = useRef196(/* @__PURE__ */ new WeakSet());
103322
+ const originsOfWindowsThatWerePrimary = useRef196(/* @__PURE__ */ new WeakMap());
103323
+ const showPicked = useCallback198((next, iframe) => {
103324
+ pickedElementRef.current = next;
103325
+ setPickedElement(next);
103326
+ if (!previewFrameOpaque(iframe)) return;
103327
+ void previewComputedStyles(iframe, next.selector, PICKED_STYLE_PROPERTIES).then((styles) => {
103328
+ if (!styles || pickedElementRef.current !== next) return;
103329
+ const filled = { ...next, computedStyles: styles };
103330
+ pickedElementRef.current = filled;
103331
+ setPickedElement(filled);
103332
+ });
103333
+ }, []);
103307
103334
  useEffect167(() => {
103308
103335
  if (!isPickMode) return;
103309
103336
  const handleKeyDown = (event) => {
@@ -103323,10 +103350,11 @@ function useElementPickerSession(iframeRef) {
103323
103350
  const activeIframe = getActiveIframe();
103324
103351
  if (!activeIframe) return;
103325
103352
  if (!e.source) return;
103326
- if (e.source === iframeRef.current?.contentWindow)
103327
- windowsThatWerePrimary.current.add(e.source);
103328
- else if (e.source !== activeIframe.contentWindow && !windowsThatWerePrimary.current.has(e.source))
103329
- return;
103353
+ const primary = iframeRef.current;
103354
+ if (primary && e.source === primary.contentWindow)
103355
+ originsOfWindowsThatWerePrimary.current.set(e.source, frameOrigins(primary));
103356
+ const origins = e.source === activeIframe.contentWindow ? frameOrigins(activeIframe) : originsOfWindowsThatWerePrimary.current.get(e.source);
103357
+ if (!origins?.includes(e.origin)) return;
103330
103358
  if (data.type === "element-hovered") {
103331
103359
  if (e.source !== activeIframe.contentWindow || !isPickModeRef.current) return;
103332
103360
  const info = toHoverInfo(data.elementInfo);
@@ -103334,20 +103362,14 @@ function useElementPickerSession(iframeRef) {
103334
103362
  return;
103335
103363
  }
103336
103364
  if (data.type === "element-picked" && data.elementInfo) {
103337
- const next = toPickedElement(data.elementInfo, activeIframe);
103338
- pickedElementRef.current = next;
103339
- setPickedElement(next);
103365
+ showPicked(toPickedElement(data.elementInfo, activeIframe), activeIframe);
103340
103366
  pickStartSelectionRef.current = void 0;
103341
103367
  isPickModeRef.current = false;
103342
103368
  clearHover();
103343
103369
  setIsPickMode(false);
103344
103370
  } else if (data.type === "element-pick-candidates") {
103345
103371
  const el = data.candidates?.[data.selectedIndex ?? 0];
103346
- if (el) {
103347
- const next = toPickedElement(el, activeIframe);
103348
- pickedElementRef.current = next;
103349
- setPickedElement(next);
103350
- }
103372
+ if (el) showPicked(toPickedElement(el, activeIframe), activeIframe);
103351
103373
  }
103352
103374
  if (data.type === "pick-mode-cancelled") {
103353
103375
  cancelPick(false);
@@ -103583,49 +103605,6 @@ function patchByHfId(files, hfId, ownFile, op) {
103583
103605
  const before = path ? files[path] : void 0;
103584
103606
  return path && before ? { path, before, after: applyPatchByTarget(before, { hfId }, op) } : null;
103585
103607
  }
103586
- function readComputedStyles(iframe, selector) {
103587
- const styles = {};
103588
- try {
103589
- const doc = iframe.contentDocument;
103590
- const el = doc?.querySelector(selector);
103591
- if (!el) return styles;
103592
- const computed = iframe.contentWindow?.getComputedStyle(el);
103593
- if (!computed) return styles;
103594
- const props = [
103595
- "position",
103596
- "top",
103597
- "left",
103598
- "right",
103599
- "bottom",
103600
- "width",
103601
- "height",
103602
- "margin-top",
103603
- "margin-right",
103604
- "margin-bottom",
103605
- "margin-left",
103606
- "padding-top",
103607
- "padding-right",
103608
- "padding-bottom",
103609
- "padding-left",
103610
- "font-size",
103611
- "font-weight",
103612
- "font-family",
103613
- "color",
103614
- "background-color",
103615
- "background",
103616
- "opacity",
103617
- "border-radius",
103618
- "transform",
103619
- "z-index"
103620
- ];
103621
- for (const prop of props) {
103622
- const val = prop === "opacity" ? getLogicalOpacity(el, computed) : computed.getPropertyValue(prop);
103623
- if (val) styles[prop] = val;
103624
- }
103625
- } catch {
103626
- }
103627
- return styles;
103628
- }
103629
103608
 
103630
103609
  // src/utils/htmlEditor.ts
103631
103610
  function parseStyleString(style) {