@hyperframes/studio 0.7.96 → 0.7.98

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.
package/dist/index.html CHANGED
@@ -5,7 +5,7 @@
5
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0, viewport-fit=cover" />
6
6
  <link rel="icon" type="image/svg+xml" href="/favicon.svg" />
7
7
  <title>HyperFrames Studio</title>
8
- <script type="module" crossorigin src="/assets/index-YO-rhwSW.js"></script>
8
+ <script type="module" crossorigin src="/assets/index-jdiZjBHE.js"></script>
9
9
  <link rel="stylesheet" crossorigin href="/assets/index-tBPidglp.css">
10
10
  </head>
11
11
  <body>
package/dist/index.js CHANGED
@@ -24528,6 +24528,8 @@ var STUDIO_ORIGINAL_TRANSLATE_ATTR = "data-hf-studio-original-translate";
24528
24528
  var STUDIO_ORIGINAL_INLINE_TRANSLATE_ATTR = "data-hf-studio-original-inline-translate";
24529
24529
  var STUDIO_ORIGINAL_WIDTH_ATTR = "data-hf-studio-original-width";
24530
24530
  var STUDIO_ORIGINAL_HEIGHT_ATTR = "data-hf-studio-original-height";
24531
+ var STUDIO_ORIGINAL_BOX_WIDTH_ATTR = "data-hf-studio-original-box-width";
24532
+ var STUDIO_ORIGINAL_BOX_HEIGHT_ATTR = "data-hf-studio-original-box-height";
24531
24533
  var STUDIO_ORIGINAL_MIN_WIDTH_ATTR = "data-hf-studio-original-min-width";
24532
24534
  var STUDIO_ORIGINAL_MIN_HEIGHT_ATTR = "data-hf-studio-original-min-height";
24533
24535
  var STUDIO_ORIGINAL_MAX_WIDTH_ATTR = "data-hf-studio-original-max-width";
@@ -24858,6 +24860,12 @@ function restoreStaleStudioScaleResize(element) {
24858
24860
  element.removeAttribute(STUDIO_ORIGINAL_TRANSFORM_ORIGIN_ATTR);
24859
24861
  }
24860
24862
  function writeStudioBoxSizeVars(element, size) {
24863
+ if (!element.hasAttribute(STUDIO_ORIGINAL_BOX_WIDTH_ATTR)) {
24864
+ element.setAttribute(STUDIO_ORIGINAL_BOX_WIDTH_ATTR, String(element.offsetWidth));
24865
+ }
24866
+ if (!element.hasAttribute(STUDIO_ORIGINAL_BOX_HEIGHT_ATTR)) {
24867
+ element.setAttribute(STUDIO_ORIGINAL_BOX_HEIGHT_ATTR, String(element.offsetHeight));
24868
+ }
24861
24869
  if (!element.hasAttribute(STUDIO_BOX_SIZE_ATTR)) {
24862
24870
  element.setAttribute(STUDIO_ORIGINAL_WIDTH_ATTR, element.style.getPropertyValue("width"));
24863
24871
  element.setAttribute(STUDIO_ORIGINAL_HEIGHT_ATTR, element.style.getPropertyValue("height"));
@@ -25070,6 +25078,8 @@ function captureStudioBoxSize(element) {
25070
25078
  marker: element.getAttribute(STUDIO_BOX_SIZE_ATTR),
25071
25079
  originalWidth: element.getAttribute(STUDIO_ORIGINAL_WIDTH_ATTR),
25072
25080
  originalHeight: element.getAttribute(STUDIO_ORIGINAL_HEIGHT_ATTR),
25081
+ originalBoxWidth: element.getAttribute(STUDIO_ORIGINAL_BOX_WIDTH_ATTR),
25082
+ originalBoxHeight: element.getAttribute(STUDIO_ORIGINAL_BOX_HEIGHT_ATTR),
25073
25083
  originalMinWidth: element.getAttribute(STUDIO_ORIGINAL_MIN_WIDTH_ATTR),
25074
25084
  originalMinHeight: element.getAttribute(STUDIO_ORIGINAL_MIN_HEIGHT_ATTR),
25075
25085
  originalMaxWidth: element.getAttribute(STUDIO_ORIGINAL_MAX_WIDTH_ATTR),
@@ -25132,6 +25142,8 @@ function restoreStudioBoxSize(element, previous) {
25132
25142
  restoreAttribute(element, STUDIO_BOX_SIZE_ATTR, previous.marker);
25133
25143
  restoreAttribute(element, STUDIO_ORIGINAL_WIDTH_ATTR, previous.originalWidth);
25134
25144
  restoreAttribute(element, STUDIO_ORIGINAL_HEIGHT_ATTR, previous.originalHeight);
25145
+ restoreAttribute(element, STUDIO_ORIGINAL_BOX_WIDTH_ATTR, previous.originalBoxWidth);
25146
+ restoreAttribute(element, STUDIO_ORIGINAL_BOX_HEIGHT_ATTR, previous.originalBoxHeight);
25135
25147
  restoreAttribute(element, STUDIO_ORIGINAL_MIN_WIDTH_ATTR, previous.originalMinWidth);
25136
25148
  restoreAttribute(element, STUDIO_ORIGINAL_MIN_HEIGHT_ATTR, previous.originalMinHeight);
25137
25149
  restoreAttribute(element, STUDIO_ORIGINAL_MAX_WIDTH_ATTR, previous.originalMaxWidth);
@@ -25931,6 +25943,12 @@ function setElementGsapPosition(element, x, y) {
25931
25943
  gsap3.set(element, { x, y });
25932
25944
  return true;
25933
25945
  }
25946
+ function setElementGsapScale(element, x, y) {
25947
+ const gsap3 = gsapOf(element);
25948
+ if (!gsap3?.set) return false;
25949
+ gsap3.set(element, { scaleX: x, scaleY: y });
25950
+ return true;
25951
+ }
25934
25952
  function readElementGsapNumber(element, prop) {
25935
25953
  const value = Number(gsapOf(element)?.getProperty?.(element, prop));
25936
25954
  return Number.isFinite(value) ? value : null;
@@ -56698,6 +56716,9 @@ var BOX_SIZE_STYLE_PROPS = [
56698
56716
  var BOX_SIZE_ORIG_ATTRS = [
56699
56717
  [STUDIO_ORIGINAL_WIDTH_ATTR, "width"],
56700
56718
  [STUDIO_ORIGINAL_HEIGHT_ATTR, "height"],
56719
+ // Records a measurement rather than a style, so it restores nothing.
56720
+ [STUDIO_ORIGINAL_BOX_WIDTH_ATTR, ""],
56721
+ [STUDIO_ORIGINAL_BOX_HEIGHT_ATTR, ""],
56701
56722
  [STUDIO_ORIGINAL_MIN_WIDTH_ATTR, "min-width"],
56702
56723
  [STUDIO_ORIGINAL_MIN_HEIGHT_ATTR, "min-height"],
56703
56724
  [STUDIO_ORIGINAL_MAX_WIDTH_ATTR, "max-width"],
@@ -59528,6 +59549,21 @@ function synthesizeIdentityProps(source) {
59528
59549
  }
59529
59550
  return id;
59530
59551
  }
59552
+ function originalBoxSize(el, measuredAttr, inlineProperty) {
59553
+ const measured = Number.parseFloat(el?.getAttribute(measuredAttr) ?? "");
59554
+ if (Number.isFinite(measured) && measured > 0) return measured;
59555
+ const inline = Number.parseFloat(
59556
+ el?.getAttribute(`data-hf-studio-original-${inlineProperty}`) ?? ""
59557
+ );
59558
+ return Number.isFinite(inline) && inline > 0 ? inline : null;
59559
+ }
59560
+ function tweenUsesScaleLonghands(anim) {
59561
+ const isLonghand = (name) => name === "scaleX" || name === "scaleY";
59562
+ const inKeyframes = (anim?.keyframes?.keyframes ?? []).some(
59563
+ (frame) => Object.keys(frame.properties ?? {}).some(isLonghand)
59564
+ );
59565
+ return inKeyframes || Object.keys(anim?.properties ?? {}).some(isLonghand);
59566
+ }
59531
59567
  async function tryGsapResizeIntercept(selection, size, animations, iframe, commitMutation, fetchFallbackAnimations) {
59532
59568
  const fetchedAnimations = fetchFallbackAnimations ? await fetchFallbackAnimations() : [];
59533
59569
  const allKnownAnimations = [...animations, ...fetchedAnimations];
@@ -59596,13 +59632,13 @@ async function tryGsapResizeIntercept(selection, size, animations, iframe, commi
59596
59632
  let resizeProps;
59597
59633
  let scaleDraftEl = null;
59598
59634
  let scaleDraftDropPoint = null;
59635
+ let committedScale = null;
59599
59636
  let nonUniformScale = false;
59637
+ let useScaleLonghands = false;
59600
59638
  if (resizeGroup === "scale") {
59601
59639
  const el = iframe?.contentDocument?.querySelector(selector ?? "");
59602
- const origW = Number.parseFloat(el?.getAttribute("data-hf-studio-original-width") ?? "");
59603
- const origH = Number.parseFloat(el?.getAttribute("data-hf-studio-original-height") ?? "");
59604
- const cssW = Number.isFinite(origW) && origW > 0 ? origW : 200;
59605
- const cssH = Number.isFinite(origH) && origH > 0 ? origH : cssW;
59640
+ const cssW = originalBoxSize(el, STUDIO_ORIGINAL_BOX_WIDTH_ATTR, "width") ?? 200;
59641
+ const cssH = originalBoxSize(el, STUDIO_ORIGINAL_BOX_HEIGHT_ATTR, "height") ?? cssW;
59606
59642
  const rawLiveScaleX = readGsapProperty(iframe, selector ?? null, "scaleX") ?? 1;
59607
59643
  const rawLiveScaleY = readGsapProperty(iframe, selector ?? null, "scaleY") ?? 1;
59608
59644
  const liveScaleX = rawLiveScaleX > 0 ? rawLiveScaleX : 1;
@@ -59610,7 +59646,8 @@ async function tryGsapResizeIntercept(selection, size, animations, iframe, commi
59610
59646
  const newScaleX = roundTo3(size.width * liveScaleX / cssW);
59611
59647
  const newScaleY = roundTo3(size.height * liveScaleY / cssH);
59612
59648
  nonUniformScale = Math.abs(newScaleX - newScaleY) > 0.01;
59613
- resizeProps = nonUniformScale ? { scaleX: newScaleX, scaleY: newScaleY } : { scale: newScaleX };
59649
+ useScaleLonghands = nonUniformScale || tweenUsesScaleLonghands(anim);
59650
+ resizeProps = useScaleLonghands ? { scaleX: newScaleX, scaleY: newScaleY } : { scale: newScaleX };
59614
59651
  logResize("intercept-route", {
59615
59652
  route: "scale-tween",
59616
59653
  cssW,
@@ -59622,6 +59659,7 @@ async function tryGsapResizeIntercept(selection, size, animations, iframe, commi
59622
59659
  nonUniformScale
59623
59660
  });
59624
59661
  scaleDraftEl = el;
59662
+ committedScale = useScaleLonghands ? { x: newScaleX, y: newScaleY } : { x: newScaleX, y: newScaleX };
59625
59663
  if (el) {
59626
59664
  const dropRect = el.getBoundingClientRect();
59627
59665
  scaleDraftDropPoint = { x: dropRect.x, y: dropRect.y };
@@ -59636,46 +59674,57 @@ async function tryGsapResizeIntercept(selection, size, animations, iframe, commi
59636
59674
  if (!scaleDraftEl) return;
59637
59675
  clearStudioBoxSize(scaleDraftEl);
59638
59676
  if (!scaleDraftDropPoint || !selector) return;
59639
- const hasLivePositionTween = hasNonHoldTweenForElement(
59640
- iframe,
59641
- selector,
59642
- void 0,
59643
- POSITION_CHANNELS
59644
- );
59645
- if (hasLivePositionTween) {
59646
- logResize("scale-finalize", { skipped: "live-position-tween" });
59647
- return;
59677
+ if (committedScale) {
59678
+ setElementGsapScale(scaleDraftEl, committedScale.x, committedScale.y);
59648
59679
  }
59680
+ const gsapPos = readGsapPositionFromIframe(iframe, selector) ?? { x: 0, y: 0 };
59681
+ const { baseGsapX, baseGsapY } = computeDraggedGsapPosition(
59682
+ selection.element,
59683
+ { x: 0, y: 0 },
59684
+ gsapPos
59685
+ );
59686
+ const base2 = { x: baseGsapX, y: baseGsapY };
59687
+ setElementGsapPosition(scaleDraftEl, base2.x, base2.y);
59649
59688
  const post = scaleDraftEl.getBoundingClientRect();
59650
59689
  const residual = { x: scaleDraftDropPoint.x - post.x, y: scaleDraftDropPoint.y - post.y };
59651
59690
  if (!Number.isFinite(residual.x) || !Number.isFinite(residual.y)) return;
59652
- if (Math.abs(residual.x) < 0.5 && Math.abs(residual.y) < 0.5) return;
59653
- const gsapPos = readGsapPositionFromIframe(iframe, selector) ?? { x: 0, y: 0 };
59691
+ if (Math.abs(residual.x) < 0.5 && Math.abs(residual.y) < 0.5) {
59692
+ logResize("scale-finalize", { skipped: "already-on-drop-point", residual, base: base2 });
59693
+ return;
59694
+ }
59654
59695
  const corrected = {
59655
- x: Math.round(gsapPos.x + residual.x),
59656
- y: Math.round(gsapPos.y + residual.y)
59696
+ x: Math.round(base2.x + residual.x),
59697
+ y: Math.round(base2.y + residual.y)
59657
59698
  };
59658
59699
  logResize("scale-finalize", {
59659
59700
  dropPoint: scaleDraftDropPoint,
59660
59701
  post: { x: post.x, y: post.y },
59661
59702
  residual,
59662
59703
  gsapPos,
59704
+ base: base2,
59663
59705
  corrected
59664
59706
  });
59665
59707
  setElementGsapPosition(scaleDraftEl, corrected.x, corrected.y);
59666
59708
  const currentAnimations = fetchFallbackAnimations ? await fetchFallbackAnimations() : resolved?.animations ?? animations;
59667
- const existingSet = findExistingPositionWrite(currentAnimations, selector, selection.element);
59668
- await commitStaticGsapPosition(
59669
- selection,
59670
- { x: corrected.x - gsapPos.x, y: corrected.y - gsapPos.y },
59671
- gsapPos,
59672
- selector,
59673
- existingSet,
59674
- {
59709
+ const delta = { x: corrected.x - base2.x, y: corrected.y - base2.y };
59710
+ const positionTween = pickClosestToPlayhead(
59711
+ currentAnimations.filter(
59712
+ (a) => a.propertyGroup === "position" && !isInstantHold(a) && resolveTweenDuration(a) > 0
59713
+ )
59714
+ );
59715
+ if (positionTween) {
59716
+ logResize("scale-finalize", { route: "position-keyframe", tweenId: positionTween.id });
59717
+ await commitGsapPositionFromDrag(selection, positionTween, delta, base2, iframe, selector, {
59675
59718
  commitMutation,
59676
59719
  fetchAnimations: fetchFallbackAnimations
59677
- }
59678
- );
59720
+ });
59721
+ return;
59722
+ }
59723
+ const existingSet = findExistingPositionWrite(currentAnimations, selector, selection.element);
59724
+ await commitStaticGsapPosition(selection, delta, base2, selector, existingSet, {
59725
+ commitMutation,
59726
+ fetchAnimations: fetchFallbackAnimations
59727
+ });
59679
59728
  };
59680
59729
  if (!usePlayerStore.getState().autoKeyframeEnabled) {
59681
59730
  if (activeKeyframePct != null) setActiveKeyframePct(null);
@@ -59715,7 +59764,7 @@ async function tryGsapResizeIntercept(selection, size, animations, iframe, commi
59715
59764
  }
59716
59765
  }
59717
59766
  }
59718
- if ((outsideRange || nonUniformScale) && ts !== null) {
59767
+ if ((outsideRange || useScaleLonghands) && ts !== null) {
59719
59768
  const kfs = anim.keyframes?.keyframes ?? (() => {
59720
59769
  const fromProps = anim.method === "from" || anim.method === "fromTo" ? { ...anim.properties } : synthesizeIdentityProps(anim.properties);
59721
59770
  const toProps = anim.method === "from" ? synthesizeIdentityProps(anim.properties) : { ...anim.properties };