@hyperframes/studio 0.9.65 → 0.9.66

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 (54) hide show
  1. package/dist/assets/hyperframes-player-VGx6ow_e.js +573 -0
  2. package/dist/assets/{index-tvLrzMBv.js → index-B8Xt_Oyw.js} +180 -180
  3. package/dist/assets/{index-CAjz3b83.js → index-BH18TdX9.js} +1 -1
  4. package/dist/assets/{pausedVideoDecoder-xC5IGkfB.js → pausedVideoDecoder-Bx3fGNkU.js} +1 -1
  5. package/dist/{chunk-VDDEXNVX.js → chunk-ESTBKVCB.js} +8 -0
  6. package/dist/index.html +1 -1
  7. package/dist/index.js +355 -142
  8. package/dist/player.js +1 -1
  9. package/package.json +8 -8
  10. package/src/captions/components/CaptionOverlay.sealed.test.ts +2 -25
  11. package/src/components/editor/LayersPanel.opaque.test.ts +4 -29
  12. package/src/components/editor/domEditOverlayCrop.ts +78 -15
  13. package/src/components/editor/domEditOverlayCropFrameLift.test.ts +64 -0
  14. package/src/components/editor/gsapMoveSealedPreview.test.ts +3 -23
  15. package/src/components/editor/previewDrafts.test.ts +13 -39
  16. package/src/components/editor/previewDrafts.ts +2 -0
  17. package/src/components/editor/previewGestureStartRead.test.ts +59 -21
  18. package/src/components/editor/previewGestureStartRead.ts +9 -0
  19. package/src/components/editor/previewLayers.test.ts +3 -20
  20. package/src/components/editor/previewOverlayRects.test.ts +3 -20
  21. package/src/components/editor/previewPointerTargets.test.ts +3 -20
  22. package/src/components/editor/previewSelection.test.ts +51 -35
  23. package/src/components/editor/previewSelection.ts +17 -0
  24. package/src/components/editor/useColorGradingController.sealed.test.ts +5 -30
  25. package/src/components/editor/useMotionPathData.sealed.test.ts +2 -29
  26. package/src/components/nle/NLEContext.drillDown.test.ts +85 -0
  27. package/src/components/nle/NLEContext.tsx +21 -23
  28. package/src/components/nle/NLEPreview.test.ts +18 -3
  29. package/src/components/nle/NLEPreview.tsx +10 -1
  30. package/src/components/nle/audioSealedPreview.test.ts +5 -32
  31. package/src/hooks/appHotkeysDispatch.ts +38 -1
  32. package/src/hooks/domEditCommits.sealed.test.ts +191 -0
  33. package/src/hooks/domStyleCommit.ts +18 -7
  34. package/src/hooks/gsapResizeIntercept.ts +7 -2
  35. package/src/hooks/useAppHotkeys.previewForwarding.test.tsx +134 -0
  36. package/src/hooks/useAppHotkeys.ts +36 -1
  37. package/src/hooks/useDomEditAttributeCommits.ts +43 -19
  38. package/src/hooks/useEnableKeyframes.sealed.test.ts +2 -29
  39. package/src/hooks/useSlideshowTabState.test.ts +47 -3
  40. package/src/hooks/useSlideshowTabState.ts +32 -16
  41. package/src/player/hooks/timelinePlayerTestHarness.ts +2 -1
  42. package/src/player/hooks/usePlaybackKeyboard.ts +1 -1
  43. package/src/player/hooks/useTimelineSyncCallbacks.sealed.test.ts +2 -29
  44. package/src/player/lib/previewChannel.test.ts +10 -0
  45. package/src/player/lib/previewChannel.ts +9 -0
  46. package/src/player/lib/previewElements.test.ts +34 -1
  47. package/src/player/lib/previewElements.ts +99 -16
  48. package/src/player/lib/sealedPreviewFrame.test-helpers.ts +38 -0
  49. package/src/player/lib/timelineIframeHelpers.ts +1 -1
  50. package/src/utils/blockInstaller.test.ts +82 -48
  51. package/src/utils/blockInstaller.ts +6 -14
  52. package/src/utils/previewCompositionSize.test.ts +61 -0
  53. package/src/utils/previewCompositionSize.ts +21 -1
  54. package/dist/assets/hyperframes-player-Dscc6yHD.js +0 -573
package/dist/index.js CHANGED
@@ -92,7 +92,7 @@ import {
92
92
  whileScriptWrites,
93
93
  writeStudioUiPreferences,
94
94
  zoomToSelectedClips
95
- } from "./chunk-VDDEXNVX.js";
95
+ } from "./chunk-ESTBKVCB.js";
96
96
  import {
97
97
  Button,
98
98
  ContextMenu,
@@ -5421,6 +5421,7 @@ var previewStandInHandle = (standIn) => standIns.get(standIn)?.handle;
5421
5421
  function registerPreviewStandIn(standIn, iframe, handle) {
5422
5422
  standIns.set(standIn, { iframe, handle });
5423
5423
  }
5424
+ var previewStandIn = (standIn) => standIns.get(standIn);
5424
5425
  function queueFor(iframe) {
5425
5426
  let queue2 = queues.get(iframe);
5426
5427
  if (!queue2) {
@@ -5474,37 +5475,43 @@ import {
5474
5475
  import {
5475
5476
  EDITING_ELEMENT_HANDLE,
5476
5477
  MAX_DESCRIBE_HANDLES as MAX_DESCRIBE_HANDLES2,
5478
+ MAX_DRAFT_PX,
5477
5479
  MAX_ELEMENT_ENTRIES,
5480
+ MAX_ELEMENT_TEXT,
5478
5481
  MAX_ELEMENT_VALUE,
5479
5482
  MAX_GEOMETRY_CHILDREN,
5480
- MAX_SNAP_TARGETS
5483
+ MAX_SNAP_TARGETS,
5484
+ MAX_SOURCE_GROUPS
5481
5485
  } from "@hyperframes/core/runtime/editing-port";
5482
5486
  var isFields = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
5483
5487
  var isHandle = (value) => typeof value === "string" && EDITING_ELEMENT_HANDLE.test(value);
5484
5488
  var isText = (value) => typeof value === "string";
5485
- var isTextOrNull = (value) => value === null || typeof value === "string";
5489
+ var isValue = (value) => isText(value) && value.length <= MAX_ELEMENT_VALUE;
5490
+ var isLongText = (value) => isText(value) && value.length <= MAX_ELEMENT_TEXT;
5491
+ var isValueOrNull = (value) => value === null || isValue(value);
5492
+ var isEntries = (value) => Array.isArray(value) && value.length <= MAX_ELEMENT_ENTRIES;
5486
5493
  var isCount = (value) => Number.isSafeInteger(value) && value >= 0;
5487
- var isSource = (value) => isFields(value) && isTextOrNull(value.file) && isTextOrNull(value.compositionId) && isTextOrNull(value.originalCompositionId);
5488
- var isTextRecord = (value) => isFields(value) && Object.values(value).every(isText);
5494
+ var isSource = (value) => isFields(value) && isValueOrNull(value.file) && isValueOrNull(value.compositionId) && isValueOrNull(value.originalCompositionId);
5495
+ var isStyles = (value) => isFields(value) && isEntries(Object.keys(value)) && Object.entries(value).every(([name, style]) => isValue(name) && isValue(style));
5489
5496
  function hasPlainFields(value) {
5490
5497
  const { matchesBefore, attributes, children } = value;
5491
- const groupsOk = matchesBefore === null || Array.isArray(matchesBefore) && matchesBefore.every((g) => isFields(g) && isSource(g.source) && isCount(g.count));
5492
- const attributesOk = Array.isArray(attributes) && attributes.every((a) => Array.isArray(a) && a.length === 2 && a.every(isText));
5493
- const childrenOk = Array.isArray(children) && children.every((c) => isFields(c) && (isHandle(c.handle) || isText(c.text)));
5498
+ const groupsOk = matchesBefore === null || Array.isArray(matchesBefore) && matchesBefore.length <= MAX_SOURCE_GROUPS && matchesBefore.every((g) => isFields(g) && isSource(g.source) && isCount(g.count));
5499
+ const attributesOk = isEntries(attributes) && attributes.every((a) => Array.isArray(a) && a.length === 2 && a.every(isValue));
5500
+ const childrenOk = isEntries(children) && children.every((c) => isFields(c) && (isHandle(c.handle) || isLongText(c.text)));
5494
5501
  return groupsOk && attributesOk && childrenOk && typeof value.truncated === "boolean";
5495
5502
  }
5496
5503
  var isRect = (value) => isFields(value) && [value.x, value.y, value.width, value.height].every(Number.isFinite);
5497
5504
  function readHit(value) {
5498
- if (!isFields(value) || !isHandle(value.handle) || !isText(value.tag)) return null;
5505
+ if (!isFields(value) || !isHandle(value.handle) || !isValue(value.tag)) return null;
5499
5506
  return isRect(value.rect) ? value : null;
5500
5507
  }
5501
5508
  function readPreviewElement(value) {
5502
5509
  if (!readHit(value) || !isFields(value)) return null;
5503
5510
  if (value.parent !== null && !isHandle(value.parent)) return null;
5504
- if (value.label !== void 0 && !isText(value.label)) return null;
5505
- if (!isTextOrNull(value.id) || !isTextOrNull(value.selector)) return null;
5511
+ if (value.label !== void 0 && !isValue(value.label)) return null;
5512
+ if (!isValueOrNull(value.id) || !isValueOrNull(value.selector)) return null;
5506
5513
  if (!isSource(value.source) || typeof value.locked !== "boolean") return null;
5507
- if (!isTextRecord(value.inlineStyles) || !isText(value.text)) return null;
5514
+ if (!isStyles(value.inlineStyles) || !isLongText(value.text)) return null;
5508
5515
  return hasPlainFields(value) ? value : null;
5509
5516
  }
5510
5517
  async function previewElementsAtPoint(iframe, x, y) {
@@ -5559,7 +5566,7 @@ var isSizeOrNull = (value) => value === null || Number.isFinite(value) && value
5559
5566
  var CORNERS = ["nw", "ne", "se", "sw"];
5560
5567
  var isCorners = (value) => value === null || isFields(value) && CORNERS.every((corner) => isPoint(value[corner]));
5561
5568
  var isSourceBox = (value) => value === null || isFields(value) && Number.isFinite(value.width) && Number.isFinite(value.height) && isSizeOrNull(value.declaredWidth) && isSizeOrNull(value.declaredHeight);
5562
- var isClipPath = (value) => value === null || isText(value) && value.length <= MAX_ELEMENT_VALUE;
5569
+ var isClipPath = isValueOrNull;
5563
5570
  var isBox = (value) => isFields(value) && isRect(value.rect) && Number.isFinite(value.angle) && isCorners(value.corners) && isSourceBox(value.source) && isClipPath(value.clipPath);
5564
5571
  var readGeometry = (value) => {
5565
5572
  if (!isBox(value) || !isFields(value) || typeof value.visible !== "boolean") return null;
@@ -5582,11 +5589,14 @@ async function previewGeometry(iframe, handles, children) {
5582
5589
  }
5583
5590
  var isFlag = (value) => typeof value === "boolean";
5584
5591
  var isFiniteFields = (value, keys) => isFields(value) && keys.every((key) => Number.isFinite(value[key]));
5592
+ var isLayout = (value) => isFields(value) && [value.width, value.height].every(
5593
+ (side) => Number.isFinite(side) && side >= 0 && side <= MAX_DRAFT_PX
5594
+ );
5585
5595
  var readGestureStart = (value) => {
5586
5596
  if (!readGeometry(value) || !isFields(value)) return null;
5587
5597
  const { layout, move, gsap: gsap3 } = value;
5588
5598
  const valid = [
5589
- isFiniteFields(layout, ["width", "height"]),
5599
+ isLayout(layout),
5590
5600
  move === null || isFiniteFields(move, ["a", "b", "c", "d"]),
5591
5601
  gsap3 === null || isFields(gsap3) && isFiniteFields(gsap3, ["x", "y"]) && isFlag(gsap3.moving)
5592
5602
  ];
@@ -5612,15 +5622,54 @@ async function previewLayers(iframe, group, offset = 0) {
5612
5622
  if (typeof missingGroup !== "boolean") return null;
5613
5623
  return layers.every(isLayer) ? { layers, truncated, missingGroup } : null;
5614
5624
  }
5625
+ var isEditEntries = (value, priority = false) => Array.isArray(value) && value.every(
5626
+ (entry3) => Array.isArray(entry3) && isText(entry3[0]) && (entry3[1] === null || isText(entry3[1])) && (entry3.length === 2 || priority && entry3.length === 3 && entry3[2] === "important")
5627
+ );
5628
+ var latestWriters = /* @__PURE__ */ new WeakMap();
5629
+ function editPreviewElement(iframe, handle, edit) {
5630
+ const send3 = (styles, attributes) => previewRequest(iframe, "edit-element", { handle, styles, attributes });
5631
+ const writers = latestWriters.get(iframe) ?? /* @__PURE__ */ new Map();
5632
+ latestWriters.set(iframe, writers);
5633
+ const self = /* @__PURE__ */ Symbol("edit");
5634
+ const key = (part, name) => `${handle} ${part} ${name}`;
5635
+ for (const [name] of edit.styles ?? []) writers.set(key("style", name), self);
5636
+ for (const [name] of edit.attributes ?? []) writers.set(key("attr", name), self);
5637
+ const reply = send3(edit.styles ?? [], edit.attributes ?? []);
5638
+ return {
5639
+ drawn: reply.then((before) => before?.applied === true),
5640
+ restore(names) {
5641
+ const owns = (part, name) => (!names || names.includes(name)) && writers.get(key(part, name)) === self;
5642
+ void reply.then((before) => {
5643
+ if (!before?.applied || !isEditEntries(before.styles, true)) return;
5644
+ if (!isEditEntries(before.attributes)) return;
5645
+ const styles = before.styles.filter(([name]) => owns("style", name));
5646
+ const attributes = before.attributes.filter(([name]) => owns("attr", name));
5647
+ if (styles.length || attributes.length) void send3(styles, attributes);
5648
+ });
5649
+ }
5650
+ };
5651
+ }
5652
+ var SEALED_DRAW_WAIT_MS = 300;
5653
+ function afterSealedDraw(edit, save) {
5654
+ if (!edit) return save(true);
5655
+ let timer;
5656
+ const late = new Promise((resolve2) => {
5657
+ timer = setTimeout(resolve2, SEALED_DRAW_WAIT_MS, false);
5658
+ });
5659
+ return Promise.race([edit.drawn, late]).then((drawn) => {
5660
+ clearTimeout(timer);
5661
+ return save(drawn);
5662
+ });
5663
+ }
5615
5664
 
5616
5665
  // src/hooks/gsapSnapshotReply.ts
5617
5666
  var isText2 = (value) => typeof value === "string" && value.length <= MAX_SNAPSHOT_TEXT;
5618
- var isTextOrNull2 = (value) => value === null || isText2(value);
5667
+ var isTextOrNull = (value) => value === null || isText2(value);
5619
5668
  var isNumber = (value) => typeof value === "number" && Number.isFinite(value);
5620
5669
  var isNumberOrNull = (value) => value === null || isNumber(value);
5621
5670
  var isList = (value, max) => Array.isArray(value) && value.length <= max;
5622
5671
  function readGsapSnapshot(value) {
5623
- if (!isFields(value) || !isNumberOrNull(value.time) || !isTextOrNull2(value.defaultEase))
5672
+ if (!isFields(value) || !isNumberOrNull(value.time) || !isTextOrNull(value.defaultEase))
5624
5673
  return null;
5625
5674
  const budget = { tweens: MAX_SNAPSHOT_TWEENS, fields: MAX_SNAPSHOT_FIELDS };
5626
5675
  const { timelines, targets } = value;
@@ -5628,7 +5677,7 @@ function readGsapSnapshot(value) {
5628
5677
  return ok ? value : null;
5629
5678
  }
5630
5679
  function isTimeline(value, budget) {
5631
- return isFields(value) && isText2(value.id) && isNumberOrNull(value.time) && isTextOrNull2(value.defaultEase) && isList(value.tweens, MAX_SNAPSHOT_TWEENS) && value.tweens.every((tween) => isTween(tween, budget));
5680
+ return isFields(value) && isText2(value.id) && isNumberOrNull(value.time) && isTextOrNull(value.defaultEase) && isList(value.tweens, MAX_SNAPSHOT_TWEENS) && value.tweens.every((tween) => isTween(tween, budget));
5632
5681
  }
5633
5682
  function isTween(value, budget) {
5634
5683
  if ((budget.tweens -= 1) < 0 || !isFields(value)) return false;
@@ -34115,6 +34164,13 @@ var useAssetPreviewStore = create7((set) => ({
34115
34164
 
34116
34165
  // src/components/nle/NLEContext.tsx
34117
34166
  import { jsx as jsx80 } from "react/jsx-runtime";
34167
+ async function hostCompositionSrc(iframe, compId) {
34168
+ const selector = `[data-composition-id="${CSS.escape(compId)}"][data-composition-src]`;
34169
+ const handle = (await queryPreviewElements(iframe, selector))?.matches[0]?.handle;
34170
+ if (!handle) return void 0;
34171
+ const [host] = await describePreviewElements(iframe, [handle]) ?? [];
34172
+ return host?.attributes.find(([name]) => name === "data-composition-src")?.[1] || void 0;
34173
+ }
34118
34174
  function shouldDisableTimelineWhileCompositionLoading(compositionLoading) {
34119
34175
  return compositionLoading;
34120
34176
  }
@@ -34198,25 +34254,12 @@ function NLEProvider({
34198
34254
  if (!element.compositionSrc) return;
34199
34255
  usePlayerStore.getState().setSelectedElementId(null);
34200
34256
  const compId = element.id;
34201
- let resolvedPath = compIdToSrc.get(compId);
34202
- if (!resolvedPath) {
34203
- try {
34204
- const doc = iframeRef_.current?.contentDocument;
34205
- if (doc) {
34206
- const host = doc.querySelector(
34207
- `[data-composition-id="${CSS.escape(compId)}"][data-composition-src]`
34208
- );
34209
- if (host) {
34210
- resolvedPath = host.getAttribute("data-composition-src") || void 0;
34211
- }
34212
- }
34213
- } catch {
34214
- }
34215
- }
34216
- drillDown({
34217
- id: compId,
34218
- compositionSrc: resolvedPath ?? element.compositionSrc
34219
- });
34257
+ const known = compIdToSrc.get(compId);
34258
+ const iframe = iframeRef_.current;
34259
+ const resolve2 = known || !iframe ? Promise.resolve(known) : hostCompositionSrc(iframe, compId);
34260
+ void resolve2.then(
34261
+ (resolvedPath) => drillDown({ id: compId, compositionSrc: resolvedPath ?? element.compositionSrc })
34262
+ );
34220
34263
  },
34221
34264
  [compIdToSrc, drillDown, iframeRef_]
34222
34265
  );
@@ -34392,7 +34435,15 @@ function usePlayerHandle() {
34392
34435
  }
34393
34436
 
34394
34437
  // src/utils/previewCompositionSize.ts
34438
+ var isPositive = (value) => typeof value === "number" && Number.isFinite(value) && value > 0;
34439
+ function readyPlayerCompositionSize(iframe) {
34440
+ const player = resolvePreviewPlayerHost(iframe);
34441
+ if (!player?.ready) return null;
34442
+ const { compositionWidth: width, compositionHeight: height } = player;
34443
+ return isPositive(width) && isPositive(height) ? { width, height } : null;
34444
+ }
34395
34445
  function readPreviewCompositionSize(iframe) {
34446
+ if (iframe && previewFrameOpaque(iframe)) return readyPlayerCompositionSize(iframe);
34396
34447
  try {
34397
34448
  const doc = iframe?.contentDocument;
34398
34449
  const root = doc?.querySelector("[data-composition-id][data-width][data-height]") ?? doc?.querySelector("[data-width][data-height]");
@@ -35087,6 +35138,14 @@ var NLEPreview = memo24(function NLEPreview2({
35087
35138
  useEffect42(() => {
35088
35139
  onCompositionSizeChangeRef.current?.(compositionSize);
35089
35140
  }, [compositionSize]);
35141
+ const showLive = poster.onLiveReadyToShowChange;
35142
+ const onLiveReadyToShowChange = useCallback49(
35143
+ (ready) => {
35144
+ showLive(ready);
35145
+ if (ready) updateCompositionSizeFromPreview();
35146
+ },
35147
+ [showLive, updateCompositionSizeFromPreview]
35148
+ );
35090
35149
  const setPreviewIframeRef = useCallback49(
35091
35150
  (node) => {
35092
35151
  previewIframeRef.current = node;
@@ -35368,7 +35427,7 @@ var NLEPreview = memo24(function NLEPreview2({
35368
35427
  applyInitialZoom();
35369
35428
  },
35370
35429
  onCompositionLoadingChange,
35371
- onReadyToShowChange: poster.onLiveReadyToShowChange,
35430
+ onReadyToShowChange: onLiveReadyToShowChange,
35372
35431
  onPreviewError: poster.onPreviewError,
35373
35432
  onPainted: (details) => reportPreviewFirstFrame(slot, details),
35374
35433
  portrait,
@@ -39003,6 +39062,7 @@ function buildInsetClipPathValue(insetPx, radiusValue) {
39003
39062
  }
39004
39063
 
39005
39064
  // src/components/editor/domEditOverlayCrop.ts
39065
+ import { MAX_DRAFT_PX as MAX_DRAFT_PX2, MAX_ELEMENT_VALUE as MAX_ELEMENT_VALUE2 } from "@hyperframes/core/runtime/editing-port";
39006
39066
  function cropRectFromInsets(rect, insets, scaleX, scaleY) {
39007
39067
  const sx = scaleX > 0 ? scaleX : 1;
39008
39068
  const sy = scaleY > 0 ? scaleY : 1;
@@ -39016,13 +39076,42 @@ function cropRectFromInsets(rect, insets, scaleX, scaleY) {
39016
39076
  };
39017
39077
  }
39018
39078
  var cropLifts = /* @__PURE__ */ new WeakMap();
39079
+ var UNLIFT_TRIES = 3;
39019
39080
  function liftSelector(element) {
39020
39081
  const quote = (value) => `"${value.replace(/["\\]/g, "\\$&")}"`;
39021
39082
  const hfId = element.getAttribute("data-hf-id");
39022
39083
  if (hfId) return `[data-hf-id=${quote(hfId)}]`;
39023
39084
  return element.id ? `[id=${quote(element.id)}]` : null;
39024
39085
  }
39086
+ function unliftInFrame(element, record2, tries = UNLIFT_TRIES) {
39087
+ const target = previewStandIn(element);
39088
+ if (!target) return;
39089
+ void previewRequest(target.iframe, "crop-lift", { handle: target.handle, lift: false }).then(
39090
+ (reply) => {
39091
+ if (cropLifts.get(element) !== record2) return;
39092
+ if (reply?.lifted === false) cropLifts.delete(element);
39093
+ else if (tries > 1) unliftInFrame(element, record2, tries - 1);
39094
+ }
39095
+ );
39096
+ }
39097
+ function liftInFrame(element) {
39098
+ const target = previewStandIn(element);
39099
+ if (!target) return false;
39100
+ const record2 = { rule: null, sheetClip: frameClipPaths.get(element)?.computed ?? "" };
39101
+ cropLifts.set(element, record2);
39102
+ void previewRequest(target.iframe, "crop-lift", { handle: target.handle, lift: true }).then(
39103
+ (reply) => {
39104
+ if (cropLifts.get(element) !== record2 || !reply) return;
39105
+ if (!reply.lifted) cropLifts.delete(element);
39106
+ else if (typeof reply.clipPath === "string" && reply.clipPath.length <= MAX_ELEMENT_VALUE2)
39107
+ record2.sheetClip = reply.clipPath.trim();
39108
+ }
39109
+ );
39110
+ return true;
39111
+ }
39025
39112
  function liftElementCrop(element) {
39113
+ const held2 = cropLifts.get(element);
39114
+ if (held2 && !held2.dropped || liftInFrame(element)) return;
39026
39115
  const selector = liftSelector(element);
39027
39116
  if (!selector || cropLifts.has(element)) return;
39028
39117
  const doc = element.ownerDocument;
@@ -39032,28 +39121,49 @@ function liftElementCrop(element) {
39032
39121
  cropLifts.set(element, { rule });
39033
39122
  }
39034
39123
  function dropElementCropLift(element) {
39035
- cropLifts.get(element)?.rule.remove();
39036
- cropLifts.delete(element);
39124
+ const lift = cropLifts.get(element);
39125
+ if (!lift || lift.dropped) return;
39126
+ if (lift.rule) {
39127
+ lift.rule.remove();
39128
+ cropLifts.delete(element);
39129
+ return;
39130
+ }
39131
+ lift.dropped = true;
39132
+ unliftInFrame(element, lift);
39037
39133
  }
39038
39134
  function isElementCropLifted(element) {
39039
- return cropLifts.has(element);
39040
- }
39041
- var computedClipPath = (element) => element.ownerDocument.defaultView?.getComputedStyle(element).clipPath.trim() || "";
39042
- function readElementClipPath(element) {
39043
- const inline = element.style.getPropertyValue("clip-path").trim();
39044
39135
  const lift = cropLifts.get(element);
39045
- if (inline || !lift) return inline || computedClipPath(element);
39046
- if (lift.sheetClip === void 0) {
39136
+ return !!lift && !lift.dropped;
39137
+ }
39138
+ var frameClipPaths = /* @__PURE__ */ new WeakMap();
39139
+ function rememberFrameClipPath(element, inline, computed) {
39140
+ frameClipPaths.set(element, { inline: inline.trim(), computed: computed.trim() });
39141
+ }
39142
+ var computedClipPath = (element) => {
39143
+ const view = element.ownerDocument.defaultView;
39144
+ if (!view) return frameClipPaths.get(element)?.computed ?? "";
39145
+ return view.getComputedStyle(element).clipPath.trim();
39146
+ };
39147
+ function sheetClipUnder(element, lift) {
39148
+ if (lift.sheetClip === void 0 && lift.rule) {
39047
39149
  const { parentNode, nextSibling } = lift.rule;
39048
39150
  lift.rule.remove();
39049
39151
  lift.sheetClip = computedClipPath(element);
39050
39152
  parentNode?.insertBefore(lift.rule, nextSibling);
39051
39153
  }
39052
- return lift.sheetClip;
39154
+ return lift.sheetClip ?? "";
39155
+ }
39156
+ function readElementClipPath(element) {
39157
+ const inline = element.style.getPropertyValue("clip-path").trim() || frameClipPaths.get(element)?.inline;
39158
+ if (inline) return inline;
39159
+ const lift = cropLifts.get(element);
39160
+ return lift && !lift.dropped ? sheetClipUnder(element, lift) : computedClipPath(element);
39053
39161
  }
39054
39162
  function parseCropClipPath(value) {
39055
39163
  if (!value || value === "none") return { top: 0, right: 0, bottom: 0, left: 0, radius: 0 };
39056
- return parseInsetClipPathSides(value);
39164
+ const sides = parseInsetClipPathSides(value);
39165
+ const sane = sides && Object.values(sides).every((side) => Math.abs(side) <= MAX_DRAFT_PX2);
39166
+ return sane ? sides : null;
39057
39167
  }
39058
39168
  function readElementCropInsets(element) {
39059
39169
  return parseCropClipPath(readElementClipPath(element));
@@ -39605,7 +39715,7 @@ async function measurePreviewVisibleRects(iframe, overlayEl, handles) {
39605
39715
  import { resolveEditingAffordances } from "@hyperframes/core/editing";
39606
39716
  import {
39607
39717
  MAX_ELEMENT_ENTRIES as MAX_ELEMENT_ENTRIES2,
39608
- MAX_ELEMENT_VALUE as MAX_ELEMENT_VALUE2
39718
+ MAX_ELEMENT_VALUE as MAX_ELEMENT_VALUE3
39609
39719
  } from "@hyperframes/core/runtime/editing-port";
39610
39720
 
39611
39721
  // src/hooks/draggedGsapPosition.ts
@@ -39884,7 +39994,7 @@ function readable(element) {
39884
39994
  return probe2;
39885
39995
  }
39886
39996
  var attr = (element, name) => element.attributes.find(([key]) => key === name)?.[1] ?? null;
39887
- var mayBeCut = (value) => value.length >= MAX_ELEMENT_VALUE2 || value.startsWith("data:") && value.endsWith(",");
39997
+ var mayBeCut = (value) => value.length >= MAX_ELEMENT_VALUE3 || value.startsWith("data:") && value.endsWith(",");
39888
39998
  function valuesWhole(element) {
39889
39999
  if (!element.truncated) return true;
39890
40000
  const styles = Object.values(element.inlineStyles);
@@ -40022,6 +40132,11 @@ async function resolvePreviewSelection(iframe, target, options) {
40022
40132
  .../* @__PURE__ */ new Set([...CURATED_STYLE_PROPERTIES, ...TRANSLATE_PX_PROPERTIES])
40023
40133
  ]);
40024
40134
  if (!styles) return null;
40135
+ rememberFrameClipPath(
40136
+ element,
40137
+ current2.inlineStyles["clip-path"] ?? "",
40138
+ styles["clip-path"] ?? ""
40139
+ );
40025
40140
  rememberFrameTranslate(
40026
40141
  element,
40027
40142
  translatePx(styles.translate ?? "none", (p) => styles[p] ?? ""),
@@ -40135,6 +40250,10 @@ async function findPointerTargets(iframe, clientX, clientY) {
40135
40250
  const described = handles.length ? await describePreviewElements(iframe, handles) : [];
40136
40251
  return (described ?? []).filter((element) => element !== null);
40137
40252
  }
40253
+ function editSealedSelection(iframe, selection, edit) {
40254
+ if (!iframe || !selection.handle || !previewFrameOpaque(iframe)) return null;
40255
+ return editPreviewElement(iframe, selection.handle, edit);
40256
+ }
40138
40257
  var selectionElementLive = (selection) => selection.handle !== void 0 || selection.element.isConnected;
40139
40258
 
40140
40259
  // src/components/editor/previewLayers.ts
@@ -42863,8 +42982,15 @@ function editMoment(stamp) {
42863
42982
  }
42864
42983
 
42865
42984
  // src/components/editor/previewGestureStartRead.ts
42985
+ var startLayouts = /* @__PURE__ */ new Map();
42986
+ var gestureStartLayout = (handle) => startLayouts.get(handle) ?? null;
42866
42987
  async function measurePreviewGestureStart(iframe, overlayEl, handles) {
42867
42988
  const reply = await previewGestureStart(iframe, handles);
42989
+ startLayouts.clear();
42990
+ reply?.elements.forEach((start, i) => {
42991
+ const { width = 0, height = 0 } = start?.layout ?? {};
42992
+ if (width >= 1 && height >= 1) startLayouts.set(handles[i], { width, height });
42993
+ });
42868
42994
  const scale = reply && computeOverlayRootScale(overlayEl, iframe, null);
42869
42995
  if (!reply || !scale) return null;
42870
42996
  const { iframeRect, overlayRect, rootScaleX: sx, rootScaleY: sy } = scale;
@@ -76387,7 +76513,7 @@ var FileTree = memo43(function FileTree2({
76387
76513
  });
76388
76514
 
76389
76515
  // src/App.tsx
76390
- import { useState as useState172, useCallback as useCallback197, useRef as useRef195, useMemo as useMemo91 } from "react";
76516
+ import { useState as useState173, useCallback as useCallback197, useRef as useRef195, useMemo as useMemo91 } from "react";
76391
76517
 
76392
76518
  // src/hooks/useStableHandlers.ts
76393
76519
  import { useRef as useRef122 } from "react";
@@ -84656,6 +84782,7 @@ async function commitDomStyles(context, selection, stylesInEitherCase) {
84656
84782
  }
84657
84783
  let editedElement = null;
84658
84784
  const previousInline = /* @__PURE__ */ new Map();
84785
+ let sealedEdit = null;
84659
84786
  return runReportedDomEditCommit({
84660
84787
  capture: () => {
84661
84788
  const el = doc ? findElementForSelection(doc, selection, activeCompPath) : null;
@@ -84665,21 +84792,30 @@ async function commitDomStyles(context, selection, stylesInEitherCase) {
84665
84792
  previousInline.set(property, el.style.getPropertyValue(property));
84666
84793
  },
84667
84794
  apply: () => {
84668
- if (!editedElement) return;
84795
+ if (!editedElement) {
84796
+ sealedEdit = editSealedSelection(previewIframeRef.current, selection, {
84797
+ styles: liveStyles
84798
+ });
84799
+ return;
84800
+ }
84669
84801
  for (const [property, value] of liveStyles) editedElement.style.setProperty(property, value);
84670
84802
  if (fontFamily !== void 0 && doc) {
84671
84803
  injectPreviewGoogleFont(doc, fontFamily);
84672
84804
  if (importedFont) injectPreviewImportedFont(doc, importedFont);
84673
84805
  }
84674
84806
  },
84675
- persist: () => persistDomEditOperations(selection, operations, {
84676
- label: "Edit layer style",
84677
- // Inline styles are already live, so a reload would only blank the preview.
84678
- skipRefresh: true,
84679
- importedFont: importedFont ?? void 0
84680
- }),
84807
+ persist: () => afterSealedDraw(
84808
+ sealedEdit,
84809
+ (drawn) => persistDomEditOperations(selection, operations, {
84810
+ label: "Edit layer style",
84811
+ // Live styles skip the reload; a sealed frame reloads to load a new font.
84812
+ skipRefresh: drawn && !(sealedEdit && fontFamily !== void 0),
84813
+ importedFont: importedFont ?? void 0
84814
+ })
84815
+ ),
84681
84816
  shouldRevert: ownsAny,
84682
84817
  revert: () => {
84818
+ sealedEdit?.restore(owned.filter(({ isLatest }) => isLatest()).map((o) => o.property));
84683
84819
  const el = editedElement;
84684
84820
  if (!el) return;
84685
84821
  for (const { property, isLatest } of owned) {
@@ -84762,6 +84898,7 @@ function useDomEditAttributeCommits({
84762
84898
  const op = { type: "attribute", property: attr2, value };
84763
84899
  let editedElement = null;
84764
84900
  let previousValue = null;
84901
+ let sealedEdit = null;
84765
84902
  await runDomEditCommit({
84766
84903
  capture: () => {
84767
84904
  const captured = captureAttributeElement(
@@ -84775,18 +84912,26 @@ function useDomEditAttributeCommits({
84775
84912
  previousValue = captured.previousValue;
84776
84913
  },
84777
84914
  apply: () => {
84778
- if (!editedElement) return;
84779
84915
  const nextValue = value === null || value === "" ? null : value;
84916
+ if (!editedElement) {
84917
+ const attributes = [[fullAttr, nextValue]];
84918
+ sealedEdit = editSealedSelection(iframe, domEditSelection, { attributes });
84919
+ return;
84920
+ }
84780
84921
  setOrRemovePreviewAttribute(editedElement, fullAttr, nextValue);
84781
84922
  },
84782
84923
  persist: options.previewOnly ? async () => {
84783
- } : () => persistDomEditOperations(domEditSelection, [op], {
84784
- label: options.label,
84785
- coalesceKey: commitKey,
84786
- skipRefresh: options.skipRefresh
84787
- }),
84924
+ } : () => afterSealedDraw(
84925
+ sealedEdit,
84926
+ (drawn) => persistDomEditOperations(domEditSelection, [op], {
84927
+ label: options.label,
84928
+ coalesceKey: commitKey,
84929
+ skipRefresh: options.skipRefresh && drawn
84930
+ })
84931
+ ),
84788
84932
  shouldRevert: () => isLatestCommit(),
84789
84933
  revert: () => {
84934
+ sealedEdit?.restore();
84790
84935
  if (!editedElement) return;
84791
84936
  setOrRemovePreviewAttribute(editedElement, fullAttr, previousValue);
84792
84937
  },
@@ -84822,6 +84967,7 @@ function useDomEditAttributeCommits({
84822
84967
  commitKey
84823
84968
  );
84824
84969
  let captured = null;
84970
+ let sealedEdit = null;
84825
84971
  let landed = false;
84826
84972
  await runDomEditCommit({
84827
84973
  capture: () => {
@@ -84833,19 +84979,30 @@ function useDomEditAttributeCommits({
84833
84979
  );
84834
84980
  },
84835
84981
  apply: () => {
84836
- if (!captured) return;
84982
+ if (!captured) {
84983
+ const attributes = entries.map(({ fullAttr, value }) => [
84984
+ fullAttr,
84985
+ value
84986
+ ]);
84987
+ sealedEdit = editSealedSelection(iframe, selection, { attributes });
84988
+ return;
84989
+ }
84837
84990
  for (const entry3 of entries) {
84838
84991
  setOrRemovePreviewAttribute(captured.element, entry3.fullAttr, entry3.value);
84839
84992
  }
84840
84993
  },
84841
- persist: () => persistDomEditOperations(selection, ops, {
84842
- label: options.label,
84843
- coalesceKey: commitKey,
84844
- skipRefresh: options.skipRefresh,
84845
- prepareContent: options.prepareContent
84846
- }),
84994
+ persist: () => afterSealedDraw(
84995
+ sealedEdit,
84996
+ (drawn) => persistDomEditOperations(selection, ops, {
84997
+ label: options.label,
84998
+ coalesceKey: commitKey,
84999
+ skipRefresh: options.skipRefresh && drawn,
85000
+ prepareContent: options.prepareContent
85001
+ })
85002
+ ),
84847
85003
  shouldRevert: (error) => isLatestCommit() && !(error instanceof DomEditPersistPreparedWriteError),
84848
85004
  revert: () => {
85005
+ sealedEdit?.restore();
84849
85006
  if (!captured) return;
84850
85007
  for (const entry3 of entries) {
84851
85008
  setOrRemovePreviewAttribute(
@@ -84955,6 +85112,7 @@ function useDomEditAttributeCommits({
84955
85112
  const op = { type: "html-attribute", property: attr2, value };
84956
85113
  let editedElement = null;
84957
85114
  let previousValue = null;
85115
+ let sealedEdit = null;
84958
85116
  await runDomEditCommit({
84959
85117
  capture: () => {
84960
85118
  const captured = captureAttributeElement(
@@ -84968,12 +85126,13 @@ function useDomEditAttributeCommits({
84968
85126
  previousValue = captured.previousValue;
84969
85127
  },
84970
85128
  apply: () => {
84971
- if (!editedElement) return;
84972
- setOrRemovePreviewAttribute(
84973
- editedElement,
84974
- attr2,
84975
- resolveOptimisticAttributeValue(attr2, value)
84976
- );
85129
+ const optimistic = resolveOptimisticAttributeValue(attr2, value);
85130
+ if (!editedElement) {
85131
+ const attributes = [[attr2, optimistic]];
85132
+ sealedEdit = editSealedSelection(iframe, domEditSelection, { attributes });
85133
+ return;
85134
+ }
85135
+ setOrRemovePreviewAttribute(editedElement, attr2, optimistic);
84977
85136
  },
84978
85137
  persist: () => persistDomEditOperations(domEditSelection, [op], {
84979
85138
  label: `Edit ${attr2}`,
@@ -84982,6 +85141,7 @@ function useDomEditAttributeCommits({
84982
85141
  }),
84983
85142
  shouldRevert: () => isLatestCommit(),
84984
85143
  revert: () => {
85144
+ sealedEdit?.restore();
84985
85145
  if (!editedElement) return;
84986
85146
  setOrRemovePreviewAttribute(editedElement, attr2, previousValue);
84987
85147
  },
@@ -88693,8 +88853,9 @@ async function tryGsapResizeIntercept(selection, size, animations, iframe, commi
88693
88853
  let useScaleLonghands = false;
88694
88854
  if (resizeGroup === "scale") {
88695
88855
  const el = iframe?.contentDocument?.querySelector(selector ?? "");
88696
- const cssW = originalBoxSize(el, STUDIO_ORIGINAL_BOX_WIDTH_ATTR, "width") ?? 200;
88697
- const cssH = originalBoxSize(el, STUDIO_ORIGINAL_BOX_HEIGHT_ATTR, "height") ?? cssW;
88856
+ const started = selection.handle ? gestureStartLayout(selection.handle) : null;
88857
+ const cssW = originalBoxSize(el, STUDIO_ORIGINAL_BOX_WIDTH_ATTR, "width") ?? (started?.width || 200);
88858
+ const cssH = originalBoxSize(el, STUDIO_ORIGINAL_BOX_HEIGHT_ATTR, "height") ?? (started?.height || cssW);
88698
88859
  const rawLiveScaleX = readGsapProperty(iframe, selector ?? null, "scaleX") ?? 1;
88699
88860
  const rawLiveScaleY = readGsapProperty(iframe, selector ?? null, "scaleY") ?? 1;
88700
88861
  const liveScaleX = rawLiveScaleX > 0 ? rawLiveScaleX : 1;
@@ -91219,19 +91380,9 @@ function useStudioExternalFileChanges({
91219
91380
  import { useCallback as useCallback157, useMemo as useMemo76, useRef as useRef164, useState as useState135 } from "react";
91220
91381
 
91221
91382
  // src/utils/blockInstaller.ts
91222
- function getMaxZIndexFromIframe(iframe) {
91223
- try {
91224
- const doc = iframe?.contentDocument;
91225
- if (!doc) return 0;
91226
- let max = 0;
91227
- for (const el of doc.body.querySelectorAll("*")) {
91228
- const z = parseInt(getComputedStyle(el).zIndex, 10);
91229
- if (Number.isFinite(z) && z > max) max = z;
91230
- }
91231
- return max;
91232
- } catch {
91233
- return 0;
91234
- }
91383
+ async function previewMaxZIndex(iframe) {
91384
+ const zIndex = iframe ? (await previewRequest(iframe, "max-z-index", {}))?.zIndex : void 0;
91385
+ return Number.isSafeInteger(zIndex) && zIndex >= 0 ? zIndex : 0;
91235
91386
  }
91236
91387
  function buildUniqueCompositionId(baseName, existingIds) {
91237
91388
  const idSet = new Set(existingIds);
@@ -91358,6 +91509,7 @@ async function addBlockToProject(opts) {
91358
91509
  timelineElements: relevantElements,
91359
91510
  currentTime: opts.currentTime ?? 0
91360
91511
  });
91512
+ const zIndex = await previewMaxZIndex(opts.previewIframe ?? null) + 1;
91361
91513
  let hostId = "";
91362
91514
  const insertHost = (originalContent) => {
91363
91515
  const { width, height } = resolveTimelineAssetCompositionSize(originalContent);
@@ -91372,7 +91524,7 @@ async function addBlockToProject(opts) {
91372
91524
  height,
91373
91525
  left: visualPosition ? Math.round(visualPosition.left) : 0,
91374
91526
  top: visualPosition ? Math.round(visualPosition.top) : 0,
91375
- zIndex: getMaxZIndexFromIframe(opts.previewIframe ?? null) + 1
91527
+ zIndex
91376
91528
  });
91377
91529
  return extendRootDurationInSource(
91378
91530
  insertTimelineAssetIntoSource(originalContent, subComposition),
@@ -91619,6 +91771,36 @@ function dispatchClipboardKey(event, cb) {
91619
91771
  }
91620
91772
  return true;
91621
91773
  }
91774
+ var APP_HOTKEY_ACTIONS = [
91775
+ "undo",
91776
+ "redo",
91777
+ "redoAlt",
91778
+ "tabCompositions",
91779
+ "tabAssets",
91780
+ "group",
91781
+ "ungroup",
91782
+ "copy",
91783
+ "paste",
91784
+ "cut",
91785
+ "duplicate",
91786
+ "zoomSelection",
91787
+ "fullscreen",
91788
+ "split",
91789
+ "audioGain",
91790
+ "razorTool",
91791
+ "selectTool",
91792
+ "selectLeftward",
91793
+ "selectRightward",
91794
+ "cancel",
91795
+ "deleteSelected",
91796
+ "deleteSelectedAlt",
91797
+ "resetKeyframes",
91798
+ "record",
91799
+ "linkToggle",
91800
+ "detachAudio",
91801
+ "deleteLinked",
91802
+ "deleteLinkedAlt"
91803
+ ];
91622
91804
  function dispatchModifierKey(event, _key, cb) {
91623
91805
  if (!shouldIgnoreHistoryShortcut(event.target)) {
91624
91806
  const handled = handleUndoRedoKey(
@@ -91850,6 +92032,7 @@ function fromShown(files, shown3) {
91850
92032
  }
91851
92033
 
91852
92034
  // src/hooks/useAppHotkeys.ts
92035
+ import { createEditingPortClient } from "@hyperframes/core/runtime/editing-port";
91853
92036
  function iframeContentWindow(iframe) {
91854
92037
  try {
91855
92038
  return iframe?.contentWindow ?? null;
@@ -91857,6 +92040,24 @@ function iframeContentWindow(iframe) {
91857
92040
  return null;
91858
92041
  }
91859
92042
  }
92043
+ function forwardSealedFrameKeys2(iframe, onKeyDown) {
92044
+ const client = createEditingPortClient({ iframe });
92045
+ const watch = (combos) => void client.request("watch-keys", { combos }).catch(() => {
92046
+ });
92047
+ const watchApp = () => watch(APP_HOTKEY_ACTIONS.map(getStudioKey));
92048
+ watchApp();
92049
+ const stopRebinds = subscribeStudioKeys(watchApp);
92050
+ const focused = () => iframe.ownerDocument.hasFocus() && iframe.ownerDocument.activeElement === iframe;
92051
+ const stopKeys = client.onKey((key) => {
92052
+ if (key.type === "keydown" && focused()) onKeyDown(new KeyboardEvent(key.type, key));
92053
+ });
92054
+ return () => {
92055
+ stopRebinds();
92056
+ stopKeys();
92057
+ void client.request("watch-keys", { combos: [] }).catch(() => {
92058
+ }).finally(() => client.dispose());
92059
+ };
92060
+ }
91860
92061
  function safeAddListener(t2, type, h, capture = false) {
91861
92062
  try {
91862
92063
  t2?.addEventListener(type, h, capture);
@@ -91980,6 +92181,10 @@ function useAppHotkeys({
91980
92181
  (iframe) => {
91981
92182
  previewHistoryCleanupRef.current?.();
91982
92183
  previewHistoryCleanupRef.current = null;
92184
+ if (iframe && previewFrameOpaque(iframe)) {
92185
+ previewHistoryCleanupRef.current = forwardSealedFrameKeys2(iframe, handleAppKeyDown);
92186
+ return;
92187
+ }
91983
92188
  const win = iframeContentWindow(iframe);
91984
92189
  if (!win) return;
91985
92190
  const appHandler = handleAppKeyDown;
@@ -103005,26 +103210,34 @@ function useSlideshowPersist({
103005
103210
  }
103006
103211
 
103007
103212
  // src/hooks/useSlideshowTabState.ts
103008
- import { useMemo as useMemo89 } from "react";
103213
+ import { useEffect as useEffect162, useMemo as useMemo89, useState as useState169 } from "react";
103009
103214
  import { SLIDESHOW_ISLAND_TYPE as SLIDESHOW_ISLAND_TYPE2, slideshowIslandRegex as slideshowIslandRegex2 } from "@hyperframes/core/slideshow";
103215
+ function isSceneEntry(value) {
103216
+ if (!value || typeof value !== "object") return false;
103217
+ const s = value;
103218
+ return typeof s.id === "string" && typeof s.label === "string" && Number.isFinite(s.start) && Number.isFinite(s.duration);
103219
+ }
103010
103220
  function useSlideshowTabState(params) {
103011
103221
  const { editingFileContent, previewIframeRef, refreshKey, slideshowVisible } = params;
103012
103222
  const isSlideshowComposition = useMemo89(() => {
103013
103223
  if (!editingFileContent || !editingFileContent.includes(SLIDESHOW_ISLAND_TYPE2)) return false;
103014
103224
  return slideshowIslandRegex2("i").test(editingFileContent);
103015
103225
  }, [editingFileContent]);
103016
- const slideshowScenes = useMemo89(() => {
103017
- try {
103018
- const win = previewIframeRef.current?.contentWindow;
103019
- return (win?.__clipManifest?.scenes ?? []).map((s) => ({
103020
- id: s.id,
103021
- label: s.label,
103022
- start: s.start,
103023
- duration: s.duration
103024
- }));
103025
- } catch {
103026
- return [];
103027
- }
103226
+ const [slideshowScenes, setSlideshowScenes] = useState169([]);
103227
+ useEffect162(() => {
103228
+ const iframe = previewIframeRef.current;
103229
+ if (!iframe) return setSlideshowScenes([]);
103230
+ let current2 = true;
103231
+ void previewClipManifest(iframe).then((manifest) => {
103232
+ if (!current2) return;
103233
+ const scenes = Array.isArray(manifest?.scenes) ? manifest.scenes : [];
103234
+ setSlideshowScenes(
103235
+ scenes.filter(isSceneEntry).map((s) => ({ id: s.id, label: s.label, start: s.start, duration: s.duration }))
103236
+ );
103237
+ });
103238
+ return () => {
103239
+ current2 = false;
103240
+ };
103028
103241
  }, [previewIframeRef, slideshowVisible, refreshKey]);
103029
103242
  return { isSlideshowComposition, slideshowScenes };
103030
103243
  }
@@ -103074,7 +103287,7 @@ function DesignPanelPromoteProvider({
103074
103287
  }
103075
103288
 
103076
103289
  // src/hooks/useRemoveBackground.ts
103077
- import { useCallback as useCallback190, useEffect as useEffect162, useRef as useRef191 } from "react";
103290
+ import { useCallback as useCallback190, useEffect as useEffect163, useRef as useRef191 } from "react";
103078
103291
 
103079
103292
  // src/components/studioMediaJobs.ts
103080
103293
  var MEDIA_JOB_RECONNECT_TIMEOUT_MS = 15e3;
@@ -103181,7 +103394,7 @@ function waitForMediaJob(jobId, onProgress, signal) {
103181
103394
  // src/hooks/useRemoveBackground.ts
103182
103395
  function useRemoveBackground(projectId, refreshFileTree, showToast) {
103183
103396
  const abortRef = useRef191(null);
103184
- useEffect162(
103397
+ useEffect163(
103185
103398
  () => () => {
103186
103399
  abortRef.current?.abort();
103187
103400
  },
@@ -103647,7 +103860,7 @@ function useStudioSidePanels(left, right, projectId) {
103647
103860
  }
103648
103861
 
103649
103862
  // src/components/TimelineToolbar.tsx
103650
- import { memo as memo63, useEffect as useEffect164, useRef as useRef192 } from "react";
103863
+ import { memo as memo63, useEffect as useEffect165, useRef as useRef192 } from "react";
103651
103864
  import {
103652
103865
  ArrowsOutLineHorizontal,
103653
103866
  FrameCorners as FrameCorners2,
@@ -103658,7 +103871,7 @@ import {
103658
103871
  } from "@phosphor-icons/react";
103659
103872
 
103660
103873
  // src/hooks/useKeyframeKeyboard.ts
103661
- import { useEffect as useEffect163, useCallback as useCallback193 } from "react";
103874
+ import { useEffect as useEffect164, useCallback as useCallback193 } from "react";
103662
103875
  import { isTypingTarget as isTypingTarget9 } from "@hyperframes/core/typing-target";
103663
103876
  function useKeyframeKeyboard({ enabled, onAddKeyframe }) {
103664
103877
  const handler = useCallback193(
@@ -103672,7 +103885,7 @@ function useKeyframeKeyboard({ enabled, onAddKeyframe }) {
103672
103885
  },
103673
103886
  [enabled, onAddKeyframe]
103674
103887
  );
103675
- useEffect163(() => {
103888
+ useEffect164(() => {
103676
103889
  if (!enabled) return;
103677
103890
  window.addEventListener("keydown", handler, { capture: true });
103678
103891
  return () => window.removeEventListener("keydown", handler, { capture: true });
@@ -103848,7 +104061,7 @@ function TimelineToolPicker({ showSelectAroundPlayhead = true }) {
103848
104061
  }
103849
104062
 
103850
104063
  // src/components/LinkedSelectionToggle.tsx
103851
- import { useCallback as useCallback194, useState as useState169 } from "react";
104064
+ import { useCallback as useCallback194, useState as useState170 } from "react";
103852
104065
  import { createPortal as createPortal16 } from "react-dom";
103853
104066
  import { LinkSimple } from "@phosphor-icons/react";
103854
104067
  import { Fragment as Fragment72, jsx as jsx262, jsxs as jsxs208 } from "react/jsx-runtime";
@@ -103891,7 +104104,7 @@ function SyncIndicatorMenu({ x, y, onClose }) {
103891
104104
  function LinkedSelectionToggle() {
103892
104105
  const linkedSelection = useLinkedClipPreferences((s) => s.linkedSelection);
103893
104106
  const setLinkedSelection = useLinkedClipPreferences((s) => s.setLinkedSelection);
103894
- const [menuAt, setMenuAt] = useState169(null);
104107
+ const [menuAt, setMenuAt] = useState170(null);
103895
104108
  const closeMenu = useCallback194(() => setMenuAt(null), []);
103896
104109
  return /* @__PURE__ */ jsxs208(Fragment72, { children: [
103897
104110
  /* @__PURE__ */ jsx262(
@@ -104028,10 +104241,10 @@ var TimelineToolbar = memo63(function TimelineToolbar2({
104028
104241
  enabled: showKeyframes && Boolean(onToggleKeyframe),
104029
104242
  onAddKeyframe: onToggleKeyframe
104030
104243
  });
104031
- useEffect164(() => {
104244
+ useEffect165(() => {
104032
104245
  if (!showKeyframes) setAutoKeyframeEnabled(false);
104033
104246
  }, [showKeyframes, setAutoKeyframeEnabled]);
104034
- useEffect164(() => {
104247
+ useEffect165(() => {
104035
104248
  const onKeyDown = (e) => {
104036
104249
  if (!matchesKey(e, "timelineSnap")) return;
104037
104250
  if (isTypingTarget10(e.target)) return;
@@ -104334,7 +104547,7 @@ function StudioSplash({ waiting }) {
104334
104547
  }
104335
104548
 
104336
104549
  // src/hooks/useServerConnection.ts
104337
- import { useEffect as useEffect165, useState as useState170 } from "react";
104550
+ import { useEffect as useEffect166, useState as useState171 } from "react";
104338
104551
  async function resolveHashProject(id) {
104339
104552
  try {
104340
104553
  const res = await studioApiFetch(`/api/projects/${encodeURIComponent(id)}`);
@@ -104364,9 +104577,9 @@ function reportHashVerdict(stage, verdict) {
104364
104577
  });
104365
104578
  }
104366
104579
  function useServerConnection() {
104367
- const [projectId, setProjectId] = useState170(null);
104368
- const [resolving, setResolving] = useState170(true);
104369
- const [waitingForServer, setWaitingForServer] = useState170(false);
104580
+ const [projectId, setProjectId] = useState171(null);
104581
+ const [resolving, setResolving] = useState171(true);
104582
+ const [waitingForServer, setWaitingForServer] = useState171(false);
104370
104583
  useMountEffect(() => {
104371
104584
  const hashProjectId = parseProjectIdFromHash(window.location.hash);
104372
104585
  let cancelled = false;
@@ -104408,7 +104621,7 @@ function useServerConnection() {
104408
104621
  if (retryTimer !== null) clearTimeout(retryTimer);
104409
104622
  };
104410
104623
  });
104411
- useEffect165(() => {
104624
+ useEffect166(() => {
104412
104625
  const onHashChange = () => {
104413
104626
  const next = parseProjectIdFromHash(window.location.hash);
104414
104627
  if (!next || next === projectId) return;
@@ -104434,9 +104647,9 @@ function useServerConnection() {
104434
104647
  }
104435
104648
 
104436
104649
  // src/hooks/useStudioSessionStart.ts
104437
- import { useEffect as useEffect166 } from "react";
104650
+ import { useEffect as useEffect167 } from "react";
104438
104651
  function useStudioSessionStart(projectId, resolving, waitingForServer) {
104439
- useEffect166(() => {
104652
+ useEffect167(() => {
104440
104653
  if (resolving || waitingForServer || hasFiredSessionStart()) return;
104441
104654
  markSessionStartFired();
104442
104655
  trackStudioSessionStart({ has_project: projectId != null });
@@ -104460,10 +104673,10 @@ function useTimelineAddAtPlayhead(addAsset, addComposition, projectId) {
104460
104673
  }
104461
104674
 
104462
104675
  // src/hooks/useActiveComposition.ts
104463
- import { useState as useState171 } from "react";
104676
+ import { useState as useState172 } from "react";
104464
104677
 
104465
104678
  // src/hooks/useHydrateActiveCompPathFromUrl.ts
104466
- import { useEffect as useEffect167 } from "react";
104679
+ import { useEffect as useEffect168 } from "react";
104467
104680
  function useHydrateActiveCompPathFromUrl({
104468
104681
  hydrated,
104469
104682
  fileTreeLoaded,
@@ -104472,7 +104685,7 @@ function useHydrateActiveCompPathFromUrl({
104472
104685
  setActiveCompPath,
104473
104686
  setHydrated
104474
104687
  }) {
104475
- useEffect167(() => {
104688
+ useEffect168(() => {
104476
104689
  if (hydrated) return;
104477
104690
  if (!fileTreeLoaded) return;
104478
104691
  const nextCompPath = normalizeStudioCompositionPath(
@@ -104485,7 +104698,7 @@ function useHydrateActiveCompPathFromUrl({
104485
104698
  }
104486
104699
 
104487
104700
  // src/hooks/useAutoOpenRootComposition.ts
104488
- import { useEffect as useEffect168, useRef as useRef193 } from "react";
104701
+ import { useEffect as useEffect169, useRef as useRef193 } from "react";
104489
104702
  function useAutoOpenRootComposition({
104490
104703
  projectId,
104491
104704
  activeCompPath,
@@ -104494,7 +104707,7 @@ function useAutoOpenRootComposition({
104494
104707
  onSelectComposition
104495
104708
  }) {
104496
104709
  const settledForProjectRef = useRef193(void 0);
104497
- useEffect168(() => {
104710
+ useEffect169(() => {
104498
104711
  if (settledForProjectRef.current === projectId) return;
104499
104712
  if (!activeCompPathHydrated) return;
104500
104713
  if (activeCompPath !== null) {
@@ -104564,8 +104777,8 @@ function useActiveComposition({
104564
104777
  setEditingFile,
104565
104778
  showToast
104566
104779
  }) {
104567
- const [activeCompPath, setActiveCompPath] = useState171(null);
104568
- const [activeCompPathHydrated, setActiveCompPathHydrated] = useState171(
104780
+ const [activeCompPath, setActiveCompPath] = useState172(null);
104781
+ const [activeCompPathHydrated, setActiveCompPathHydrated] = useState172(
104569
104782
  () => isHydratedFromUrlState(initialUrlStateRef.current)
104570
104783
  );
104571
104784
  useResetSelectionOnProjectSwitch({
@@ -104605,12 +104818,12 @@ function StudioApp({ readOnlyPreview = false, readOnlyPreviewReason } = {}) {
104605
104818
  const { projectId, resolving, waitingForServer } = useServerConnection();
104606
104819
  const initialUrlStateRef = useRef195(readStudioUrlStateFromWindow());
104607
104820
  useStudioSessionStart(projectId, resolving, waitingForServer);
104608
- const [compIdToSrc, setCompIdToSrc] = useState172(/* @__PURE__ */ new Map());
104821
+ const [compIdToSrc, setCompIdToSrc] = useState173(/* @__PURE__ */ new Map());
104609
104822
  const previewIframe = useOwnPreviewIframe();
104610
- const [compositionLoading, setCompositionLoading] = useState172(true);
104611
- const [refreshKey, setRefreshKeyState] = useState172(0);
104823
+ const [compositionLoading, setCompositionLoading] = useState173(true);
104824
+ const [refreshKey, setRefreshKeyState] = useState173(0);
104612
104825
  const [previewDocumentVersion, refreshPreviewDocumentVersion] = usePreviewDocumentVersion();
104613
- const [blockPreview, setBlockPreview] = useState172(null);
104826
+ const [blockPreview, setBlockPreview] = useState173(null);
104614
104827
  const previewIframeRef = useRef195(null);
104615
104828
  const captionEditMode = useCaptionStore((s) => s.isEditMode);
104616
104829
  const captionHasSelection = useCaptionStore((s) => s.selectedSegmentIds.size > 0);
@@ -105115,7 +105328,7 @@ function StudioApp({ readOnlyPreview = false, readOnlyPreviewReason } = {}) {
105115
105328
  }
105116
105329
 
105117
105330
  // src/hooks/useElementPicker.ts
105118
- import { useState as useState173, useCallback as useCallback198, useEffect as useEffect169, useRef as useRef196 } from "react";
105331
+ import { useState as useState174, useCallback as useCallback198, useEffect as useEffect170, useRef as useRef196 } from "react";
105119
105332
 
105120
105333
  // src/hooks/elementPickerStyles.ts
105121
105334
  var PICKED_STYLE_PROPERTIES = [
@@ -105317,7 +105530,7 @@ function useActivePickerIframe(iframeRef, isPickModeRef, clearHover) {
105317
105530
  [clearHover, iframeRef, isPickModeRef]
105318
105531
  );
105319
105532
  const renderedActiveIframe = getActiveIframe();
105320
- useEffect169(() => {
105533
+ useEffect170(() => {
105321
105534
  const previous = lastRenderedActiveIframeRef.current;
105322
105535
  if (previous !== renderedActiveIframe) {
105323
105536
  clearHover();
@@ -105332,8 +105545,8 @@ function useActivePickerIframe(iframeRef, isPickModeRef, clearHover) {
105332
105545
  return { activeIframeRef, getActiveIframe, setActiveIframe };
105333
105546
  }
105334
105547
  function useElementPickerSession(iframeRef) {
105335
- const [isPickMode, setIsPickMode] = useState173(false);
105336
- const [pickedElement, setPickedElement] = useState173(null);
105548
+ const [isPickMode, setIsPickMode] = useState174(false);
105549
+ const [pickedElement, setPickedElement] = useState174(null);
105337
105550
  const isPickModeRef = useRef196(false);
105338
105551
  const pickedElementRef = useRef196(null);
105339
105552
  pickedElementRef.current = pickedElement;
@@ -105384,7 +105597,7 @@ function useElementPickerSession(iframeRef) {
105384
105597
  setPickedElement(filled);
105385
105598
  });
105386
105599
  }, []);
105387
- useEffect169(() => {
105600
+ useEffect170(() => {
105388
105601
  if (!isPickMode) return;
105389
105602
  const handleKeyDown = (event) => {
105390
105603
  if (event.key !== "Escape" || event.defaultPrevented || event.isComposing || elementOwnsEscape(event.target))
@@ -105768,7 +105981,7 @@ function findElementBlock(html2, elementId2) {
105768
105981
  }
105769
105982
 
105770
105983
  // src/hooks/useDomStyleCommit.ts
105771
- import { useCallback as useCallback199, useMemo as useMemo92, useRef as useRef197, useState as useState174 } from "react";
105984
+ import { useCallback as useCallback199, useMemo as useMemo92, useRef as useRef197, useState as useState175 } from "react";
105772
105985
  var noop = () => {
105773
105986
  };
105774
105987
  function useDomStyleCommit({
@@ -105781,7 +105994,7 @@ function useDomStyleCommit({
105781
105994
  }) {
105782
105995
  const projectIdRef = useRef197(projectId);
105783
105996
  projectIdRef.current = projectId;
105784
- const [queue2] = useState174(createDomEditSaveQueue);
105997
+ const [queue2] = useState175(createDomEditSaveQueue);
105785
105998
  useMountEffect(() => () => queue2.destroy());
105786
105999
  const versions = useRef197(/* @__PURE__ */ new Map()).current;
105787
106000
  const editHistory = useMemo92(() => ({ recordEdit }), [recordEdit]);
@@ -105816,7 +106029,7 @@ function useDomStyleCommit({
105816
106029
  }
105817
106030
 
105818
106031
  // src/hooks/useDomGeometryCommit.ts
105819
- import { useCallback as useCallback200, useMemo as useMemo93, useRef as useRef198, useState as useState175 } from "react";
106032
+ import { useCallback as useCallback200, useMemo as useMemo93, useRef as useRef198, useState as useState176 } from "react";
105820
106033
  var noop2 = () => {
105821
106034
  };
105822
106035
  var NO_SELECTED_ANIMATIONS = [];
@@ -105844,7 +106057,7 @@ function useDomGeometryCommit({
105844
106057
  showToast,
105845
106058
  writeProjectFile
105846
106059
  });
105847
- const [queue2] = useState175(createDomEditSaveQueue);
106060
+ const [queue2] = useState176(createDomEditSaveQueue);
105848
106061
  useMountEffect(() => () => queue2.destroy());
105849
106062
  const persistDomEditOperations = useDomEditPersist({
105850
106063
  activeCompPath,