@hyperframes/studio 0.7.95 → 0.7.97
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/assets/{hyperframes-player-C1o3TZ1w.js → hyperframes-player-DNg-LGAV.js} +1 -1
- package/dist/assets/{index-4KcC7fDo.js → index-B1gZJoA_.js} +186 -186
- package/dist/assets/{index-DR4Dsw8D.js → index-CFvtejEa.js} +1 -1
- package/dist/assets/{index-Bl6x228Z.js → index-Cuz4bnUF.js} +1 -1
- package/dist/index.html +1 -1
- package/dist/index.js +82 -30
- package/dist/index.js.map +1 -1
- package/package.json +7 -7
- package/src/components/editor/manualEditsDom.ts +14 -0
- package/src/components/editor/manualEditsDomPatches.test.ts +21 -2
- package/src/components/editor/manualEditsDomPatches.ts +5 -0
- package/src/components/editor/manualEditsSnapshot.ts +6 -0
- package/src/components/editor/manualEditsTypes.ts +14 -0
- package/src/hooks/gsapResizeDropPoint.test.ts +394 -0
- package/src/hooks/gsapResizeIntercept.test.ts +198 -0
- package/src/hooks/gsapResizeIntercept.ts +143 -35
- package/src/telemetry/canary.test.ts +25 -0
- package/src/telemetry/canary.ts +14 -4
- package/src/utils/elementGsap.ts +14 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
import{g as P}from"./index-
|
|
1
|
+
import{g as P}from"./index-B1gZJoA_.js";function j(c,d){for(var s=0;s<d.length;s++){const a=d[s];if(typeof a!="string"&&!Array.isArray(a)){for(const i in a)if(i!=="default"&&!(i in c)){const l=Object.getOwnPropertyDescriptor(a,i);l&&Object.defineProperty(c,i,l.get?l:{enumerable:!0,get:()=>a[i]})}}}return Object.freeze(Object.defineProperty(c,Symbol.toStringTag,{value:"Module"}))}var v={},w;function k(){if(w)return v;w=1,Object.defineProperty(v,"__esModule",{value:!0}),v.default=d;var c=window.OfflineAudioContext||window.webkitOfflineAudioContext;function d(e){var r=a(e);return r.start(0),[i,y,O(e.sampleRate),s].reduce(function(t,o){return o(t)},r.buffer.getChannelData(0))}function s(e){return e.sort(function(r,t){return t.count-r.count}).splice(0,5)[0].tempo}function a(e){var r=e.length,t=e.numberOfChannels,o=e.sampleRate,n=new c(t,r,o),u=n.createBufferSource();u.buffer=e;var f=n.createBiquadFilter();return f.type="lowpass",u.connect(f),f.connect(n.destination),u}function i(e){for(var r=[],t=.9,o=.3,n=15;r.length<n&&t>=o;)r=l(e,t),t-=.05;if(r.length<n)throw new Error("Could not find enough samples for a reliable detection.");return r}function l(e,r){for(var t=[],o=0,n=e.length;o<n;o+=1)e[o]>r&&(t.push(o),o+=1e4);return t}function y(e){var r=[];return e.forEach(function(t,o){for(var n=function(x){var g=e[o+x]-t,_=r.some(function(h){if(h.interval===g)return h.count+=1});_||r.push({interval:g,count:1})},u=0;u<10;u+=1)n(u)}),r}function O(e){return function(r){var t=[];return r.forEach(function(o){if(o.interval!==0){for(var n=60/(o.interval/e);n<90;)n*=2;for(;n>180;)n/=2;n=Math.round(n);var u=t.some(function(f){if(f.tempo===n)return f.count+=o.count});u||t.push({tempo:n,count:o.count})}}),t}}return v}var p,b;function q(){return b||(b=1,p=k().default),p}var m=q();const A=P(m),D=j({__proto__:null,default:A},[m]);export{D as i};
|
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-
|
|
8
|
+
<script type="module" crossorigin src="/assets/index-B1gZJoA_.js"></script>
|
|
9
9
|
<link rel="stylesheet" crossorigin href="/assets/index-tBPidglp.css">
|
|
10
10
|
</head>
|
|
11
11
|
<body>
|
package/dist/index.js
CHANGED
|
@@ -1588,7 +1588,10 @@ function resolveCanary(name) {
|
|
|
1588
1588
|
}
|
|
1589
1589
|
function canaryEventProperties() {
|
|
1590
1590
|
return canaryFeatureProperties(
|
|
1591
|
-
CANARIES.map((c) =>
|
|
1591
|
+
CANARIES.map((c) => {
|
|
1592
|
+
const { enabled: enabled2, reason } = resolveCanary(c.name);
|
|
1593
|
+
return { name: c.name, enabled: enabled2, reason };
|
|
1594
|
+
})
|
|
1592
1595
|
);
|
|
1593
1596
|
}
|
|
1594
1597
|
|
|
@@ -24525,6 +24528,8 @@ var STUDIO_ORIGINAL_TRANSLATE_ATTR = "data-hf-studio-original-translate";
|
|
|
24525
24528
|
var STUDIO_ORIGINAL_INLINE_TRANSLATE_ATTR = "data-hf-studio-original-inline-translate";
|
|
24526
24529
|
var STUDIO_ORIGINAL_WIDTH_ATTR = "data-hf-studio-original-width";
|
|
24527
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";
|
|
24528
24533
|
var STUDIO_ORIGINAL_MIN_WIDTH_ATTR = "data-hf-studio-original-min-width";
|
|
24529
24534
|
var STUDIO_ORIGINAL_MIN_HEIGHT_ATTR = "data-hf-studio-original-min-height";
|
|
24530
24535
|
var STUDIO_ORIGINAL_MAX_WIDTH_ATTR = "data-hf-studio-original-max-width";
|
|
@@ -24855,6 +24860,12 @@ function restoreStaleStudioScaleResize(element) {
|
|
|
24855
24860
|
element.removeAttribute(STUDIO_ORIGINAL_TRANSFORM_ORIGIN_ATTR);
|
|
24856
24861
|
}
|
|
24857
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
|
+
}
|
|
24858
24869
|
if (!element.hasAttribute(STUDIO_BOX_SIZE_ATTR)) {
|
|
24859
24870
|
element.setAttribute(STUDIO_ORIGINAL_WIDTH_ATTR, element.style.getPropertyValue("width"));
|
|
24860
24871
|
element.setAttribute(STUDIO_ORIGINAL_HEIGHT_ATTR, element.style.getPropertyValue("height"));
|
|
@@ -25067,6 +25078,8 @@ function captureStudioBoxSize(element) {
|
|
|
25067
25078
|
marker: element.getAttribute(STUDIO_BOX_SIZE_ATTR),
|
|
25068
25079
|
originalWidth: element.getAttribute(STUDIO_ORIGINAL_WIDTH_ATTR),
|
|
25069
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),
|
|
25070
25083
|
originalMinWidth: element.getAttribute(STUDIO_ORIGINAL_MIN_WIDTH_ATTR),
|
|
25071
25084
|
originalMinHeight: element.getAttribute(STUDIO_ORIGINAL_MIN_HEIGHT_ATTR),
|
|
25072
25085
|
originalMaxWidth: element.getAttribute(STUDIO_ORIGINAL_MAX_WIDTH_ATTR),
|
|
@@ -25129,6 +25142,8 @@ function restoreStudioBoxSize(element, previous) {
|
|
|
25129
25142
|
restoreAttribute(element, STUDIO_BOX_SIZE_ATTR, previous.marker);
|
|
25130
25143
|
restoreAttribute(element, STUDIO_ORIGINAL_WIDTH_ATTR, previous.originalWidth);
|
|
25131
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);
|
|
25132
25147
|
restoreAttribute(element, STUDIO_ORIGINAL_MIN_WIDTH_ATTR, previous.originalMinWidth);
|
|
25133
25148
|
restoreAttribute(element, STUDIO_ORIGINAL_MIN_HEIGHT_ATTR, previous.originalMinHeight);
|
|
25134
25149
|
restoreAttribute(element, STUDIO_ORIGINAL_MAX_WIDTH_ATTR, previous.originalMaxWidth);
|
|
@@ -25928,6 +25943,12 @@ function setElementGsapPosition(element, x, y) {
|
|
|
25928
25943
|
gsap3.set(element, { x, y });
|
|
25929
25944
|
return true;
|
|
25930
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
|
+
}
|
|
25931
25952
|
function readElementGsapNumber(element, prop) {
|
|
25932
25953
|
const value = Number(gsapOf(element)?.getProperty?.(element, prop));
|
|
25933
25954
|
return Number.isFinite(value) ? value : null;
|
|
@@ -56695,6 +56716,9 @@ var BOX_SIZE_STYLE_PROPS = [
|
|
|
56695
56716
|
var BOX_SIZE_ORIG_ATTRS = [
|
|
56696
56717
|
[STUDIO_ORIGINAL_WIDTH_ATTR, "width"],
|
|
56697
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, ""],
|
|
56698
56722
|
[STUDIO_ORIGINAL_MIN_WIDTH_ATTR, "min-width"],
|
|
56699
56723
|
[STUDIO_ORIGINAL_MIN_HEIGHT_ATTR, "min-height"],
|
|
56700
56724
|
[STUDIO_ORIGINAL_MAX_WIDTH_ATTR, "max-width"],
|
|
@@ -59525,6 +59549,21 @@ function synthesizeIdentityProps(source) {
|
|
|
59525
59549
|
}
|
|
59526
59550
|
return id;
|
|
59527
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
|
+
}
|
|
59528
59567
|
async function tryGsapResizeIntercept(selection, size, animations, iframe, commitMutation, fetchFallbackAnimations) {
|
|
59529
59568
|
const fetchedAnimations = fetchFallbackAnimations ? await fetchFallbackAnimations() : [];
|
|
59530
59569
|
const allKnownAnimations = [...animations, ...fetchedAnimations];
|
|
@@ -59593,13 +59632,13 @@ async function tryGsapResizeIntercept(selection, size, animations, iframe, commi
|
|
|
59593
59632
|
let resizeProps;
|
|
59594
59633
|
let scaleDraftEl = null;
|
|
59595
59634
|
let scaleDraftDropPoint = null;
|
|
59635
|
+
let committedScale = null;
|
|
59596
59636
|
let nonUniformScale = false;
|
|
59637
|
+
let useScaleLonghands = false;
|
|
59597
59638
|
if (resizeGroup === "scale") {
|
|
59598
59639
|
const el = iframe?.contentDocument?.querySelector(selector ?? "");
|
|
59599
|
-
const
|
|
59600
|
-
const
|
|
59601
|
-
const cssW = Number.isFinite(origW) && origW > 0 ? origW : 200;
|
|
59602
|
-
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;
|
|
59603
59642
|
const rawLiveScaleX = readGsapProperty(iframe, selector ?? null, "scaleX") ?? 1;
|
|
59604
59643
|
const rawLiveScaleY = readGsapProperty(iframe, selector ?? null, "scaleY") ?? 1;
|
|
59605
59644
|
const liveScaleX = rawLiveScaleX > 0 ? rawLiveScaleX : 1;
|
|
@@ -59607,7 +59646,8 @@ async function tryGsapResizeIntercept(selection, size, animations, iframe, commi
|
|
|
59607
59646
|
const newScaleX = roundTo3(size.width * liveScaleX / cssW);
|
|
59608
59647
|
const newScaleY = roundTo3(size.height * liveScaleY / cssH);
|
|
59609
59648
|
nonUniformScale = Math.abs(newScaleX - newScaleY) > 0.01;
|
|
59610
|
-
|
|
59649
|
+
useScaleLonghands = nonUniformScale || tweenUsesScaleLonghands(anim);
|
|
59650
|
+
resizeProps = useScaleLonghands ? { scaleX: newScaleX, scaleY: newScaleY } : { scale: newScaleX };
|
|
59611
59651
|
logResize("intercept-route", {
|
|
59612
59652
|
route: "scale-tween",
|
|
59613
59653
|
cssW,
|
|
@@ -59619,6 +59659,7 @@ async function tryGsapResizeIntercept(selection, size, animations, iframe, commi
|
|
|
59619
59659
|
nonUniformScale
|
|
59620
59660
|
});
|
|
59621
59661
|
scaleDraftEl = el;
|
|
59662
|
+
committedScale = useScaleLonghands ? { x: newScaleX, y: newScaleY } : { x: newScaleX, y: newScaleX };
|
|
59622
59663
|
if (el) {
|
|
59623
59664
|
const dropRect = el.getBoundingClientRect();
|
|
59624
59665
|
scaleDraftDropPoint = { x: dropRect.x, y: dropRect.y };
|
|
@@ -59633,46 +59674,57 @@ async function tryGsapResizeIntercept(selection, size, animations, iframe, commi
|
|
|
59633
59674
|
if (!scaleDraftEl) return;
|
|
59634
59675
|
clearStudioBoxSize(scaleDraftEl);
|
|
59635
59676
|
if (!scaleDraftDropPoint || !selector) return;
|
|
59636
|
-
|
|
59637
|
-
|
|
59638
|
-
selector,
|
|
59639
|
-
void 0,
|
|
59640
|
-
POSITION_CHANNELS
|
|
59641
|
-
);
|
|
59642
|
-
if (hasLivePositionTween) {
|
|
59643
|
-
logResize("scale-finalize", { skipped: "live-position-tween" });
|
|
59644
|
-
return;
|
|
59677
|
+
if (committedScale) {
|
|
59678
|
+
setElementGsapScale(scaleDraftEl, committedScale.x, committedScale.y);
|
|
59645
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);
|
|
59646
59688
|
const post = scaleDraftEl.getBoundingClientRect();
|
|
59647
59689
|
const residual = { x: scaleDraftDropPoint.x - post.x, y: scaleDraftDropPoint.y - post.y };
|
|
59648
59690
|
if (!Number.isFinite(residual.x) || !Number.isFinite(residual.y)) return;
|
|
59649
|
-
if (Math.abs(residual.x) < 0.5 && Math.abs(residual.y) < 0.5)
|
|
59650
|
-
|
|
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
|
+
}
|
|
59651
59695
|
const corrected = {
|
|
59652
|
-
x: Math.round(
|
|
59653
|
-
y: Math.round(
|
|
59696
|
+
x: Math.round(base2.x + residual.x),
|
|
59697
|
+
y: Math.round(base2.y + residual.y)
|
|
59654
59698
|
};
|
|
59655
59699
|
logResize("scale-finalize", {
|
|
59656
59700
|
dropPoint: scaleDraftDropPoint,
|
|
59657
59701
|
post: { x: post.x, y: post.y },
|
|
59658
59702
|
residual,
|
|
59659
59703
|
gsapPos,
|
|
59704
|
+
base: base2,
|
|
59660
59705
|
corrected
|
|
59661
59706
|
});
|
|
59662
59707
|
setElementGsapPosition(scaleDraftEl, corrected.x, corrected.y);
|
|
59663
59708
|
const currentAnimations = fetchFallbackAnimations ? await fetchFallbackAnimations() : resolved?.animations ?? animations;
|
|
59664
|
-
const
|
|
59665
|
-
|
|
59666
|
-
|
|
59667
|
-
|
|
59668
|
-
|
|
59669
|
-
|
|
59670
|
-
|
|
59671
|
-
{
|
|
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, {
|
|
59672
59718
|
commitMutation,
|
|
59673
59719
|
fetchAnimations: fetchFallbackAnimations
|
|
59674
|
-
}
|
|
59675
|
-
|
|
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
|
+
});
|
|
59676
59728
|
};
|
|
59677
59729
|
if (!usePlayerStore.getState().autoKeyframeEnabled) {
|
|
59678
59730
|
if (activeKeyframePct != null) setActiveKeyframePct(null);
|
|
@@ -59712,7 +59764,7 @@ async function tryGsapResizeIntercept(selection, size, animations, iframe, commi
|
|
|
59712
59764
|
}
|
|
59713
59765
|
}
|
|
59714
59766
|
}
|
|
59715
|
-
if ((outsideRange ||
|
|
59767
|
+
if ((outsideRange || useScaleLonghands) && ts !== null) {
|
|
59716
59768
|
const kfs = anim.keyframes?.keyframes ?? (() => {
|
|
59717
59769
|
const fromProps = anim.method === "from" || anim.method === "fromTo" ? { ...anim.properties } : synthesizeIdentityProps(anim.properties);
|
|
59718
59770
|
const toProps = anim.method === "from" ? synthesizeIdentityProps(anim.properties) : { ...anim.properties };
|