@hyperframes/studio 0.9.66 → 0.9.67
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-VGx6ow_e.js → hyperframes-player-DHYu0XuV.js} +1 -1
- package/dist/assets/{index-B8Xt_Oyw.js → index-BBKHfua5.js} +128 -128
- package/dist/assets/{index-BH18TdX9.js → index-DqND4rHq.js} +1 -1
- package/dist/assets/{pausedVideoDecoder-Bx3fGNkU.js → pausedVideoDecoder-B1FNXBMe.js} +1 -1
- package/dist/{chunk-ESTBKVCB.js → chunk-LR3VT3EF.js} +12 -0
- package/dist/index.html +1 -1
- package/dist/index.js +42 -19
- package/dist/player.js +1 -1
- package/package.json +8 -8
- package/src/components/editor/gsapLivePreview.sealed.test.ts +35 -0
- package/src/components/editor/gsapLivePreview.ts +6 -2
- package/src/hooks/gsapMutationClient.test.ts +32 -0
- package/src/hooks/gsapMutationClient.ts +6 -3
- package/src/hooks/timelineTimingSync.test.ts +1 -1
- package/src/hooks/useFreezeFrame.test.ts +3 -2
- package/src/hooks/useFreezeFrame.ts +2 -2
- package/src/hooks/useGroupCommits.ts +7 -2
- package/src/player/hooks/usePreviewFirstFrameTelemetry.sealed.test.ts +43 -0
- package/src/player/hooks/usePreviewFirstFrameTelemetry.ts +11 -7
- package/src/player/hooks/useTimelineSyncCallbacks.sealed.test.ts +37 -2
- package/src/player/hooks/useTimelineSyncCallbacks.ts +21 -11
- package/src/player/lib/previewChannel.ts +12 -0
- package/src/utils/studioSaveDiagnostics.ts +2 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Input as V,ALL_FORMATS as G,UrlSource as K,VideoSampleSink as Q}from"./index-
|
|
1
|
+
import{Input as V,ALL_FORMATS as G,UrlSource as K,VideoSampleSink as Q}from"./index-DqND4rHq.js";import{l as X}from"./index-BBKHfua5.js";const x=1e-5,k=1e-9,T=h=>!h.variableFrameRate&&(h.frameRate??0)>0;function Y(h,s){const{sourceLead:r,inputLead:l,timeResolution:d,frameRate:p=0}=s;if(!T(s))return Math.max(l,h-r+l)+k;const w=Math.max(0,Math.floor((h-r)*p+k)),f=l+w/p;return(d>0?Math.round(f*d)/d:f)+x}function J(h,s,r){const{frameRate:l=0,sourceLead:d,inputLead:p}=r,w=T(r)?Math.round((h-p)*l)/l+d:h-p+d,f=Math.min(s,w);return{timestamp:f,duration:Math.max(T(r)?1/l:0,s-f+x)}}const E=64*1024*1024,M=4,Z=.5,$=2e3;async function q(h,s){if(!h.transparent)return h.sink.getSample(s);let r=null;try{for await(const l of h.sink.samplesAtTimestamps([s]))r==null||r.close(),r=l;return r}catch(l){throw r==null||r.close(),l}}function ot(h){const s=new Map,r=new Map,l=new Map,d=new Map,p=new Map;let w=0,f=!1;const _=t=>{var o,n;let e=new URL(t,location.href).pathname;try{e=decodeURIComponent(e)}catch{}return(n=Object.entries(((o=h.contentWindow)==null?void 0:o.__HF_MEDIA_SOURCE_FACTS__)??{}).filter(([i])=>e.endsWith(i)).sort(([i],[a])=>a.length-i.length)[0])==null?void 0:n[1]},b=(t=E)=>{for(const[e,o]of p){if(w<=t)break;e.pins>0||(p.delete(e),o.cache.delete(e.timestamp),w-=e.bytes,e.image.close())}},v=async t=>{if(t.disposed)return;t.disposed=!0,clearTimeout(t.idleTimer),r.get(t.key)===t&&r.delete(t.key);const e=(async()=>{t.transparent&&await t.tail,t.cancelReads(),t.input.dispose(),await y(t).catch(()=>{});for(const o of t.cache.values())p.delete(o),w-=o.bytes,o.image.close();t.cache.clear(),t.canvas.width=t.canvas.height=0})();return t.transparent?new Promise((o,n)=>{const i=setTimeout(()=>{t.cancelReads(),o()},$);e.then(o,n).finally(()=>clearTimeout(i))}):e},P=t=>{clearTimeout(t.idleTimer),!(t.disposed||t.users>0||[...t.cache.values()].some(e=>e.pins>0))&&(t.idleTimer=setTimeout(()=>{t.users>0||[...t.cache.values()].some(e=>e.pins>0)||r.get(t.key)===t&&(s.delete(t.key),v(t))},1e4))},D=async t=>{const e=X("thumbnail"),o=new V({source:new K(t,e),formats:G});l.set(o,e.cancelReads);try{const n=await o.getPrimaryVideoTrack();if(!n||f)throw new Error("Preview video unavailable");const[i,a,u,c,m,S,F,B,j]=await Promise.all([n.getDisplayWidth(),n.getDisplayHeight(),n.getFirstTimestamp(),n.getTimeResolution(),n.getSquarePixelWidth(),n.getSquarePixelHeight(),n.getRotation(),n.getFlip(),n.canBeTransparent()]),g=document.createElement("canvas");g.width=Math.max(1,Math.ceil(i));const z=F%180===0?m/S:S/m;return g.height=Math.max(1,Math.round(g.width/z)),{key:t,input:o,cancelReads:e.cancelReads,sink:new Q(n),canvas:g,rotation:F,flip:B,width:i,height:a,lead:u,ticks:c,transparent:j,tail:Promise.resolve(),iterator:null,iteratorEnd:0,lastTime:-1/0,cache:new Map,users:0,disposed:!1}}catch(n){throw o.dispose(),e.cancelReads(),n}finally{l.delete(o)}},I=()=>{for(const[t]of s){if(s.size<M)break;const e=r.get(t);e&&e.users===0&&![...e.cache.values()].some(o=>o.pins>0)&&(s.delete(t),v(e))}if(s.size>=M)throw new Error("Preview decoder budget reached")},L=async t=>{const e=t;if((d.get(e)??0)>performance.now())throw new Error("Preview decoder cooling down");let o=s.get(e);o||(I(),o=D(t),s.set(e,o)),s.delete(e),s.set(e,o);let n;try{n=await o}catch(i){throw s.get(e)===o&&(s.delete(e),d.set(e,performance.now()+5e3)),i}if(f||n.disposed)throw new DOMException("Preview disposed","AbortError");return r.set(e,n),n.users++,clearTimeout(n.idleTimer),n},y=async t=>{const e=t.iterator;t.iterator=null,await(e==null?void 0:e.return())},R=(t,e)=>{if(e.throwIfAborted(),f||t.disposed)throw new Error("Preview disposed")},O=async(t,e,o)=>{for(t.iterator||(t.iteratorEnd=e+8,t.iterator=t.sink.samples(e,t.iteratorEnd));;){R(t,o);const n=await t.iterator.next();if(n.done)return null;const i=n.value;let a=!1;try{if(R(t,o),i.timestamp>e+1e-6)return null;if(a=i.timestamp+i.duration>e+1e-6,a)return i}finally{a||i.close()}}},A=(t,e)=>(e.pins++,p.delete(e),p.set(e,t),e),W=async(t,e,o,n,i)=>{const a=t.canvas.getContext("2d",{alpha:!0});if(!a)throw new Error("Preview canvas unavailable");a.clearRect(0,0,t.canvas.width,t.canvas.height),a.imageSmoothingQuality="high",e.drawWithFit(a,{fit:"fill",rotation:t.rotation,flip:t.flip});const u=await createImageBitmap(t.canvas);if(i.aborted||f||t.disposed)throw u.close(),i.throwIfAborted(),new Error("Preview disposed");const c={image:u,...J(e.timestamp,o,n),bytes:u.width*u.height*4,pins:1},m=t.cache.get(c.timestamp);if(m)return m.duration=Math.max(m.duration,c.duration),u.close(),A(t,m);if(b(E-c.bytes),w+c.bytes>E)throw u.close(),new Error("Preview frame budget reached");return t.cache.set(c.timestamp,c),p.set(c,t),w+=c.bytes,c},U=(t,e,o)=>!t.transparent&&!o.variableFrameRate&&(o.frameRate??0)>0&&e>t.lastTime+1e-6&&e-t.lastTime<=Z,C=async(t,e,o,n)=>{R(t,n);const i=[...t.cache.values()].find(m=>e>=m.timestamp-1e-6&&e<m.timestamp+m.duration-1e-6);if(i)return A(t,i);const a=Y(e,o),u=U(t,e,o);let c=null;try{if((!u||a>=t.iteratorEnd)&&await y(t),c=u?await O(t,a,n):null,c||(await y(t),c=await q(t,a)),!c)throw new Error("No preview frame at requested time");return R(t,n),t.lastTime=e,await W(t,c,e,o,n)}finally{c==null||c.close(),(n.aborted||f)&&await y(t).catch(()=>{})}},H=(t,e)=>{const o=_(t.source);return{frameRate:o==null?void 0:o.frameRate,variableFrameRate:o==null?void 0:o.variableFrameRate,sourceLead:e.lead,inputLead:e.lead,timeResolution:e.ticks}},N=async(t,e)=>{e.throwIfAborted();const o=t.source;if(!o)throw new Error("Preview source unavailable");const n=await L(o);try{const i=H(t,n),a=n.tail.then(()=>C(n,t.time,i,e));n.tail=a.then(()=>{},()=>{});const u=await a;let c=!1;return b(),{source:u.image,timestamp:u.timestamp,duration:u.duration,width:n.width,height:n.height,release(){c||(c=!0,u.pins--,b(),P(n))}}}finally{n.users--,P(n)}};return{async decode(t,e){if(f)throw new DOMException("Preview disposed","AbortError");if(new Set(t.map(({source:a})=>a)).size>M)throw new Error("Preview decoder budget reached");const o=await Promise.allSettled(t.map(a=>N(a,e))),n=o.find(a=>a.status==="rejected"),i=o.flatMap(a=>a.status==="fulfilled"?[a.value]:[]);if(n||f||e.aborted){for(const a of i)a.release();throw n?n.reason:new DOMException("Preview cancelled","AbortError")}return i},async suspend(){const t=[...s.values()].map(e=>e.then(v).catch(()=>{}));s.clear();for(const[e,o]of l)o(),e.dispose();await Promise.all(t)},dispose(){if(!f){f=!0;for(const[t,e]of l)e(),t.dispose();for(const t of s.values())t.then(v).catch(()=>{});s.clear(),d.clear()}}}}export{ot as createPausedVideoDecoder};
|
|
@@ -1197,6 +1197,17 @@ async function previewClipManifest(iframe) {
|
|
|
1197
1197
|
if (!Number.isFinite(durationInFrames)) return null;
|
|
1198
1198
|
return manifest;
|
|
1199
1199
|
}
|
|
1200
|
+
async function previewClipParents(iframe) {
|
|
1201
|
+
const snapshot = await previewRequest(iframe, "runtime-snapshot", {});
|
|
1202
|
+
const pairs = snapshot?.clipParents;
|
|
1203
|
+
const parents = /* @__PURE__ */ new Map();
|
|
1204
|
+
if (!Array.isArray(pairs)) return parents;
|
|
1205
|
+
for (const pair of pairs) {
|
|
1206
|
+
if (Array.isArray(pair) && typeof pair[0] === "string" && typeof pair[1] === "string")
|
|
1207
|
+
parents.set(pair[0], pair[1]);
|
|
1208
|
+
}
|
|
1209
|
+
return parents;
|
|
1210
|
+
}
|
|
1200
1211
|
async function previewConsoleErrors(iframe, from) {
|
|
1201
1212
|
const reply = await previewRequest(iframe, "console-errors", { from });
|
|
1202
1213
|
const errors = reply?.errors;
|
|
@@ -2603,6 +2614,7 @@ export {
|
|
|
2603
2614
|
previewRequest,
|
|
2604
2615
|
previewSeekPainted,
|
|
2605
2616
|
previewClipManifest,
|
|
2617
|
+
previewClipParents,
|
|
2606
2618
|
previewConsoleErrors,
|
|
2607
2619
|
previewComputedStyles,
|
|
2608
2620
|
previewDocumentCopy,
|
package/dist/index.html
CHANGED
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
document.documentElement.dataset.theme = "paper";
|
|
15
15
|
}
|
|
16
16
|
</script>
|
|
17
|
-
<script type="module" crossorigin src="/assets/index-
|
|
17
|
+
<script type="module" crossorigin src="/assets/index-BBKHfua5.js"></script>
|
|
18
18
|
<link rel="stylesheet" crossorigin href="/assets/index-CRiuMxyq.css">
|
|
19
19
|
</head>
|
|
20
20
|
<body>
|
package/dist/index.js
CHANGED
|
@@ -59,6 +59,7 @@ import {
|
|
|
59
59
|
postFrameDisplayScale,
|
|
60
60
|
postRuntimeControlMessage,
|
|
61
61
|
previewClipManifest,
|
|
62
|
+
previewClipParents,
|
|
62
63
|
previewComputedStyles,
|
|
63
64
|
previewConsoleErrors,
|
|
64
65
|
previewDocumentCopy,
|
|
@@ -92,7 +93,7 @@ import {
|
|
|
92
93
|
whileScriptWrites,
|
|
93
94
|
writeStudioUiPreferences,
|
|
94
95
|
zoomToSelectedClips
|
|
95
|
-
} from "./chunk-
|
|
96
|
+
} from "./chunk-LR3VT3EF.js";
|
|
96
97
|
import {
|
|
97
98
|
Button,
|
|
98
99
|
ContextMenu,
|
|
@@ -10658,6 +10659,7 @@ function heldFileMessage(body, path) {
|
|
|
10658
10659
|
return null;
|
|
10659
10660
|
}
|
|
10660
10661
|
}
|
|
10662
|
+
var withStatus = (words, response) => `${words} (${response.status})`;
|
|
10661
10663
|
async function heldFileWordsOf(response, path) {
|
|
10662
10664
|
return heldFileMessage(
|
|
10663
10665
|
await response.clone().text().catch(() => ""),
|
|
@@ -18730,7 +18732,7 @@ async function rollbackOwnedMutation(projectId, targetPath, expected, restore2)
|
|
|
18730
18732
|
);
|
|
18731
18733
|
if (!response.ok) {
|
|
18732
18734
|
throw new Error(
|
|
18733
|
-
await heldFileWordsOf(response, targetPath) ?? `Failed to restore ${targetPath}
|
|
18735
|
+
await heldFileWordsOf(response, targetPath) ?? withStatus(`Failed to restore ${targetPath}`, response)
|
|
18734
18736
|
);
|
|
18735
18737
|
}
|
|
18736
18738
|
const result = await response.json();
|
|
@@ -18778,7 +18780,9 @@ async function postOwnedGsapMutation(route, projectId, filePath, body, fallback)
|
|
|
18778
18780
|
const held2 = response.ok ? null : await heldFileWordsOf(response, filePath);
|
|
18779
18781
|
const payload = await response.json().catch(() => null);
|
|
18780
18782
|
if (!response.ok) {
|
|
18781
|
-
throw new GsapPreviewConvergenceError(
|
|
18783
|
+
throw new GsapPreviewConvergenceError(
|
|
18784
|
+
held2 ?? withStatus(readMutationError(payload, fallback), response)
|
|
18785
|
+
);
|
|
18782
18786
|
}
|
|
18783
18787
|
return readMutationStatus(payload);
|
|
18784
18788
|
}
|
|
@@ -31145,6 +31149,13 @@ function resolveTimelineTotalDuration(input) {
|
|
|
31145
31149
|
sanitizeDurationSeconds(input.authoredRootDurationSeconds)
|
|
31146
31150
|
);
|
|
31147
31151
|
}
|
|
31152
|
+
function openClipParents(iframe) {
|
|
31153
|
+
try {
|
|
31154
|
+
return clipTreeParentMap(iframe?.contentWindow ?? null);
|
|
31155
|
+
} catch {
|
|
31156
|
+
return /* @__PURE__ */ new Map();
|
|
31157
|
+
}
|
|
31158
|
+
}
|
|
31148
31159
|
function useTimelineSyncCallbacks({
|
|
31149
31160
|
iframeRef,
|
|
31150
31161
|
probeIntervalRef,
|
|
@@ -31164,13 +31175,12 @@ function useTimelineSyncCallbacks({
|
|
|
31164
31175
|
hostOwnsDeadline
|
|
31165
31176
|
}) {
|
|
31166
31177
|
const applyTimelineMessage = useCallback38(
|
|
31167
|
-
(data, iframeDoc) => {
|
|
31178
|
+
(data, iframeDoc, parentMap) => {
|
|
31168
31179
|
const clipCompositionIds = new Set(data.clips.map((c) => c.compositionId).filter(Boolean));
|
|
31169
31180
|
const filtered = data.clips.filter(
|
|
31170
31181
|
(clip) => !clip.parentCompositionId || !clipCompositionIds.has(clip.parentCompositionId)
|
|
31171
31182
|
);
|
|
31172
31183
|
try {
|
|
31173
|
-
const parentMap = clipTreeParentMap(iframeRef.current?.contentWindow ?? null);
|
|
31174
31184
|
const domClipChildren = collectSubCompositionDomChildren(iframeDoc, data.clips, parentMap);
|
|
31175
31185
|
usePlayerStore.getState().setClipParentMap(parentMap);
|
|
31176
31186
|
usePlayerStore.getState().setDomClipChildren(domClipChildren);
|
|
@@ -31191,7 +31201,7 @@ function useTimelineSyncCallbacks({
|
|
|
31191
31201
|
syncTimelineElements
|
|
31192
31202
|
);
|
|
31193
31203
|
},
|
|
31194
|
-
[
|
|
31204
|
+
[syncTimelineElements]
|
|
31195
31205
|
);
|
|
31196
31206
|
const timelineReads = useRef47(0);
|
|
31197
31207
|
const processTimelineMessage = useCallback38(
|
|
@@ -31201,13 +31211,15 @@ function useTimelineSyncCallbacks({
|
|
|
31201
31211
|
const iframe = iframeRef.current;
|
|
31202
31212
|
const read3 = ++timelineReads.current;
|
|
31203
31213
|
if (!iframe || !previewFrameOpaque(iframe)) {
|
|
31204
|
-
applyTimelineMessage(data, safeContentDocument(iframe));
|
|
31214
|
+
applyTimelineMessage(data, safeContentDocument(iframe), openClipParents(iframe));
|
|
31205
31215
|
return;
|
|
31206
31216
|
}
|
|
31207
|
-
void previewDocumentCopy(iframe).then(
|
|
31208
|
-
|
|
31209
|
-
|
|
31210
|
-
|
|
31217
|
+
void Promise.all([previewDocumentCopy(iframe), previewClipParents(iframe)]).then(
|
|
31218
|
+
([doc, parents]) => {
|
|
31219
|
+
if (read3 === timelineReads.current && iframeRef.current === iframe)
|
|
31220
|
+
applyTimelineMessage(data, doc, parents);
|
|
31221
|
+
}
|
|
31222
|
+
);
|
|
31211
31223
|
},
|
|
31212
31224
|
[iframeRef, applyTimelineMessage]
|
|
31213
31225
|
);
|
|
@@ -34924,13 +34936,15 @@ function usePreviewFirstFrameTelemetry(previewSlots) {
|
|
|
34924
34936
|
const reportKey = `${slot.role}:${slot.gen}:${loadId}`;
|
|
34925
34937
|
if (reportedPaintsRef.current.has(reportKey)) return;
|
|
34926
34938
|
reportedPaintsRef.current.add(reportKey);
|
|
34927
|
-
const
|
|
34928
|
-
trackPreviewFirstFrame({
|
|
34929
|
-
duration_ms:
|
|
34930
|
-
composition_seconds: readTimelineDurationFromDocument(
|
|
34931
|
-
...
|
|
34939
|
+
const durationMs = Math.max(0, Math.round(performance.now() - startedAt2));
|
|
34940
|
+
const report = (doc) => trackPreviewFirstFrame({
|
|
34941
|
+
duration_ms: durationMs,
|
|
34942
|
+
composition_seconds: readTimelineDurationFromDocument(doc),
|
|
34943
|
+
...readPreviewComplexity(doc),
|
|
34932
34944
|
studio_version: getBrowserSystemMeta().studio_version
|
|
34933
34945
|
});
|
|
34946
|
+
if (previewFrameOpaque(iframe)) void previewDocumentCopy(iframe).then(report);
|
|
34947
|
+
else report(iframe.contentDocument);
|
|
34934
34948
|
},
|
|
34935
34949
|
[]
|
|
34936
34950
|
);
|
|
@@ -71057,7 +71071,11 @@ function MediaFadeSliders({
|
|
|
71057
71071
|
function createGsapLivePreview(iframeRef) {
|
|
71058
71072
|
return (el, props) => {
|
|
71059
71073
|
const iframe = iframeRef.current;
|
|
71060
|
-
if (!iframe
|
|
71074
|
+
if (!iframe) return;
|
|
71075
|
+
if (previewFrameOpaque(iframe)) {
|
|
71076
|
+
if (el.handle) void previewRequest(iframe, "gsap-set", { handle: el.handle, props });
|
|
71077
|
+
return;
|
|
71078
|
+
}
|
|
71061
71079
|
const win = iframe?.contentWindow;
|
|
71062
71080
|
const node = findPreviewNode(iframe?.contentDocument, el);
|
|
71063
71081
|
if (win?.gsap && node) win.gsap.set(node, props);
|
|
@@ -80313,7 +80331,7 @@ async function requestFreezeFrame(input) {
|
|
|
80313
80331
|
const held2 = response.ok ? null : await heldFileWordsOf(response, input.path);
|
|
80314
80332
|
const body = await response.json().catch(() => null);
|
|
80315
80333
|
if (!response.ok || !isFreezeFrameResponse(body)) {
|
|
80316
|
-
throw new Error(held2 ?? errorOf(body) ??
|
|
80334
|
+
throw new Error(held2 ?? withStatus(errorOf(body) ?? "Freeze frame failed", response));
|
|
80317
80335
|
}
|
|
80318
80336
|
return body;
|
|
80319
80337
|
}
|
|
@@ -86064,7 +86082,12 @@ async function commitStructuralMutation(pid, targetPath, route, body, label, dep
|
|
|
86064
86082
|
const held2 = await heldFileWordsOf(mutateResponse, targetPath);
|
|
86065
86083
|
if (held2) throw new Error(held2);
|
|
86066
86084
|
const errBody = await mutateResponse.json().catch(() => null);
|
|
86067
|
-
throw new Error(
|
|
86085
|
+
throw new Error(
|
|
86086
|
+
withStatus(
|
|
86087
|
+
errBody?.error ?? `Failed to ${label.toLowerCase()} in ${targetPath}`,
|
|
86088
|
+
mutateResponse
|
|
86089
|
+
)
|
|
86090
|
+
);
|
|
86068
86091
|
}
|
|
86069
86092
|
result = await mutateResponse.json();
|
|
86070
86093
|
return { disk: typeof result.content === "string" ? result.content : originalContent };
|
package/dist/player.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hyperframes/studio",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.67",
|
|
4
4
|
"description": "",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -64,12 +64,12 @@
|
|
|
64
64
|
"dockview-react": "8.3.1",
|
|
65
65
|
"gsap": "^3.13.0",
|
|
66
66
|
"mediabunny": "^1.66.0",
|
|
67
|
-
"@hyperframes/core": "0.9.
|
|
68
|
-
"@hyperframes/player": "0.9.
|
|
69
|
-
"@hyperframes/
|
|
70
|
-
"@hyperframes/
|
|
71
|
-
"@hyperframes/
|
|
72
|
-
"@hyperframes/
|
|
67
|
+
"@hyperframes/core": "0.9.67",
|
|
68
|
+
"@hyperframes/player": "0.9.67",
|
|
69
|
+
"@hyperframes/parsers": "0.9.67",
|
|
70
|
+
"@hyperframes/studio-server": "0.9.67",
|
|
71
|
+
"@hyperframes/shader-transitions": "0.9.67",
|
|
72
|
+
"@hyperframes/sdk": "0.9.67"
|
|
73
73
|
},
|
|
74
74
|
"devDependencies": {
|
|
75
75
|
"@tailwindcss/vite": "^4.3.3",
|
|
@@ -86,7 +86,7 @@
|
|
|
86
86
|
"vite": "^6.4.5",
|
|
87
87
|
"vitest": "^4.1.12",
|
|
88
88
|
"zustand": "^5.0.0",
|
|
89
|
-
"@hyperframes/producer": "0.9.
|
|
89
|
+
"@hyperframes/producer": "0.9.67"
|
|
90
90
|
},
|
|
91
91
|
"peerDependencies": {
|
|
92
92
|
"react": "19",
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
// @vitest-environment happy-dom
|
|
2
|
+
import { expect, it, vi } from "vitest";
|
|
3
|
+
|
|
4
|
+
const { previewRequest } = vi.hoisted(() => ({
|
|
5
|
+
previewRequest: vi.fn(async () => ({ applied: true })),
|
|
6
|
+
}));
|
|
7
|
+
vi.mock("../../player/lib/previewChannel", async (importOriginal) => ({
|
|
8
|
+
...(await importOriginal<typeof import("../../player/lib/previewChannel")>()),
|
|
9
|
+
previewFrameOpaque: () => true,
|
|
10
|
+
previewRequest,
|
|
11
|
+
}));
|
|
12
|
+
|
|
13
|
+
import { createGsapLivePreview } from "./gsapLivePreview";
|
|
14
|
+
import type { DomEditSelection } from "./domEditingTypes";
|
|
15
|
+
|
|
16
|
+
it("sends a sealed preview's dragged values to the frame through the editing port", () => {
|
|
17
|
+
const iframe = document.createElement("iframe");
|
|
18
|
+
const preview = createGsapLivePreview({ current: iframe });
|
|
19
|
+
|
|
20
|
+
preview({ handle: "0123456789abcdef:7" } as DomEditSelection, { rotationY: 30 });
|
|
21
|
+
|
|
22
|
+
expect(previewRequest).toHaveBeenCalledExactlyOnceWith(iframe, "gsap-set", {
|
|
23
|
+
handle: "0123456789abcdef:7",
|
|
24
|
+
props: { rotationY: 30 },
|
|
25
|
+
});
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
it("sends nothing for a sealed selection the frame never named", () => {
|
|
29
|
+
previewRequest.mockClear();
|
|
30
|
+
const preview = createGsapLivePreview({ current: document.createElement("iframe") });
|
|
31
|
+
|
|
32
|
+
preview({ id: "card" } as DomEditSelection, { x: 10 });
|
|
33
|
+
|
|
34
|
+
expect(previewRequest).not.toHaveBeenCalled();
|
|
35
|
+
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { DomEditSelection } from "./domEditingTypes";
|
|
2
2
|
import { findPreviewNode } from "./domEditingElement";
|
|
3
|
-
import { previewFrameOpaque } from "../../player/lib/previewChannel";
|
|
3
|
+
import { previewFrameOpaque, previewRequest } from "../../player/lib/previewChannel";
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Build the "live preview" callback the 3D-transform sub-view fires while a
|
|
@@ -13,7 +13,11 @@ import { previewFrameOpaque } from "../../player/lib/previewChannel";
|
|
|
13
13
|
export function createGsapLivePreview(iframeRef: { readonly current: HTMLIFrameElement | null }) {
|
|
14
14
|
return (el: DomEditSelection, props: Record<string, number>) => {
|
|
15
15
|
const iframe = iframeRef.current;
|
|
16
|
-
if (!iframe
|
|
16
|
+
if (!iframe) return;
|
|
17
|
+
if (previewFrameOpaque(iframe)) {
|
|
18
|
+
if (el.handle) void previewRequest(iframe, "gsap-set", { handle: el.handle, props });
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
17
21
|
const win = iframe?.contentWindow as
|
|
18
22
|
| { gsap?: { set: (t: Element, v: Record<string, number>) => void } }
|
|
19
23
|
| null
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { afterEach, describe, expect, it, vi } from "vitest";
|
|
2
|
+
import { GsapPreviewConvergenceError, postGsapMutation } from "./gsapMutationClient";
|
|
3
|
+
|
|
4
|
+
afterEach(() => vi.unstubAllGlobals());
|
|
5
|
+
|
|
6
|
+
const refuse = (status: number, body: unknown) =>
|
|
7
|
+
vi.stubGlobal(
|
|
8
|
+
"fetch",
|
|
9
|
+
vi.fn(async () => new Response(JSON.stringify(body), { status })),
|
|
10
|
+
);
|
|
11
|
+
|
|
12
|
+
describe("postGsapMutation", () => {
|
|
13
|
+
// fails without the fix: a refused mutation threw the server's words without its status.
|
|
14
|
+
it("a refused mutation keeps the server's words and its status", async () => {
|
|
15
|
+
refuse(400, { error: "No tween at that index" });
|
|
16
|
+
const refused = postGsapMutation(
|
|
17
|
+
"p",
|
|
18
|
+
"index.html",
|
|
19
|
+
{ op: "update" },
|
|
20
|
+
"Couldn't save animation",
|
|
21
|
+
);
|
|
22
|
+
await expect(refused).rejects.toBeInstanceOf(GsapPreviewConvergenceError);
|
|
23
|
+
await expect(refused).rejects.toThrow("No tween at that index (400)");
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
it("a refusal with no words of its own keeps the fallback and the status", async () => {
|
|
27
|
+
refuse(500, {});
|
|
28
|
+
await expect(
|
|
29
|
+
postGsapMutation("p", "index.html", { op: "update" }, "Couldn't save animation"),
|
|
30
|
+
).rejects.toThrow("Couldn't save animation (500)");
|
|
31
|
+
});
|
|
32
|
+
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { studioWriteHeaders } from "../utils/studioFileVersion";
|
|
2
2
|
import { studioApiFetch } from "../utils/studioApiFetch";
|
|
3
|
-
import { heldFileWordsOf } from "../utils/studioSaveDiagnostics";
|
|
3
|
+
import { heldFileWordsOf, withStatus } from "../utils/studioSaveDiagnostics";
|
|
4
4
|
|
|
5
5
|
export class GsapPreviewConvergenceError extends Error {}
|
|
6
6
|
export class GsapOwnershipProtocolError extends GsapPreviewConvergenceError {}
|
|
@@ -43,7 +43,8 @@ export async function rollbackOwnedMutation(
|
|
|
43
43
|
);
|
|
44
44
|
if (!response.ok) {
|
|
45
45
|
throw new Error(
|
|
46
|
-
(await heldFileWordsOf(response, targetPath)) ??
|
|
46
|
+
(await heldFileWordsOf(response, targetPath)) ??
|
|
47
|
+
withStatus(`Failed to restore ${targetPath}`, response),
|
|
47
48
|
);
|
|
48
49
|
}
|
|
49
50
|
const result = (await response.json()) as { restored?: unknown; conflict?: unknown };
|
|
@@ -127,7 +128,9 @@ async function postOwnedGsapMutation(
|
|
|
127
128
|
const held = response.ok ? null : await heldFileWordsOf(response, filePath);
|
|
128
129
|
const payload: unknown = await response.json().catch(() => null);
|
|
129
130
|
if (!response.ok) {
|
|
130
|
-
throw new GsapPreviewConvergenceError(
|
|
131
|
+
throw new GsapPreviewConvergenceError(
|
|
132
|
+
held ?? withStatus(readMutationError(payload, fallback), response),
|
|
133
|
+
);
|
|
131
134
|
}
|
|
132
135
|
return readMutationStatus(payload);
|
|
133
136
|
}
|
|
@@ -778,7 +778,7 @@ describe("foldGsapMutationIntoHistory — owned GSAP transaction", () => {
|
|
|
778
778
|
expect(reloadPreview).toHaveBeenCalledTimes(1);
|
|
779
779
|
expect(consoleError).toHaveBeenCalledWith(
|
|
780
780
|
expect.stringContaining("GSAP"),
|
|
781
|
-
expect.objectContaining({ message: "Failed to restore index.html" }),
|
|
781
|
+
expect.objectContaining({ message: "Failed to restore index.html (503)" }),
|
|
782
782
|
);
|
|
783
783
|
});
|
|
784
784
|
|
|
@@ -51,11 +51,12 @@ describe("requestFreezeFrame", () => {
|
|
|
51
51
|
});
|
|
52
52
|
});
|
|
53
53
|
|
|
54
|
-
|
|
54
|
+
// fails without the fix: the server's words came through without its status, so the failure could not be named.
|
|
55
|
+
it("surfaces the server's error with its status", async () => {
|
|
55
56
|
stubFetch({ status: 400, body: { error: "Move the playhead inside a video clip to freeze" } });
|
|
56
57
|
await expect(
|
|
57
58
|
requestFreezeFrame({ projectId: "p", path: "index.html", element, playhead: 7 }),
|
|
58
|
-
).rejects.toThrow("Move the playhead inside a video clip to freeze");
|
|
59
|
+
).rejects.toThrow("Move the playhead inside a video clip to freeze (400)");
|
|
59
60
|
});
|
|
60
61
|
|
|
61
62
|
it("names the file and why when the file is read-only", async () => {
|
|
@@ -7,7 +7,7 @@ import { markStudioWriteToken } from "../utils/studioFileVersion";
|
|
|
7
7
|
import { serializeStudioFileMutations } from "../utils/studioFileMutationCoordinator";
|
|
8
8
|
import type { RecordEditInput } from "../utils/studioFileHistory";
|
|
9
9
|
import { studioApiFetch } from "../utils/studioApiFetch";
|
|
10
|
-
import { heldFileWordsOf } from "../utils/studioSaveDiagnostics";
|
|
10
|
+
import { heldFileWordsOf, withStatus } from "../utils/studioSaveDiagnostics";
|
|
11
11
|
|
|
12
12
|
type ProjectFileWriter = (path: string, content: string, expectedContent?: string) => Promise<void>;
|
|
13
13
|
|
|
@@ -77,7 +77,7 @@ export async function requestFreezeFrame(input: {
|
|
|
77
77
|
const held = response.ok ? null : await heldFileWordsOf(response, input.path);
|
|
78
78
|
const body: unknown = await response.json().catch(() => null);
|
|
79
79
|
if (!response.ok || !isFreezeFrameResponse(body)) {
|
|
80
|
-
throw new Error(held ?? errorOf(body) ??
|
|
80
|
+
throw new Error(held ?? withStatus(errorOf(body) ?? "Freeze frame failed", response));
|
|
81
81
|
}
|
|
82
82
|
return body;
|
|
83
83
|
}
|
|
@@ -17,7 +17,7 @@ import {
|
|
|
17
17
|
} from "../utils/studioHelpers";
|
|
18
18
|
import type { TimelineElement } from "../player";
|
|
19
19
|
import { studioApiFetch } from "../utils/studioApiFetch";
|
|
20
|
-
import { heldFileWordsOf } from "../utils/studioSaveDiagnostics";
|
|
20
|
+
import { heldFileWordsOf, withStatus } from "../utils/studioSaveDiagnostics";
|
|
21
21
|
|
|
22
22
|
interface UseGroupCommitsParams extends DomEditCommitBaseParams {
|
|
23
23
|
/** Resync the SDK session after a server-side write (the wrapper/unwrap changes
|
|
@@ -148,7 +148,12 @@ async function commitStructuralMutation(
|
|
|
148
148
|
const errBody = (await mutateResponse.json().catch(() => null)) as {
|
|
149
149
|
error?: string;
|
|
150
150
|
} | null;
|
|
151
|
-
throw new Error(
|
|
151
|
+
throw new Error(
|
|
152
|
+
withStatus(
|
|
153
|
+
errBody?.error ?? `Failed to ${label.toLowerCase()} in ${targetPath}`,
|
|
154
|
+
mutateResponse,
|
|
155
|
+
),
|
|
156
|
+
);
|
|
152
157
|
}
|
|
153
158
|
result = (await mutateResponse.json()) as { content?: string; groupId?: string };
|
|
154
159
|
return { disk: typeof result.content === "string" ? result.content : originalContent };
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
// @vitest-environment happy-dom
|
|
2
|
+
|
|
3
|
+
import { act, createElement } from "react";
|
|
4
|
+
import { createRoot } from "react-dom/client";
|
|
5
|
+
import { afterEach, expect, it, vi } from "vitest";
|
|
6
|
+
import { sealedPreviewFrame } from "../lib/sealedPreviewFrame.test-helpers";
|
|
7
|
+
import { usePreviewFirstFrameTelemetry } from "./usePreviewFirstFrameTelemetry";
|
|
8
|
+
|
|
9
|
+
const firstFrames = vi.hoisted(() => [] as Array<Record<string, unknown>>);
|
|
10
|
+
vi.mock("../../telemetry/events", () => ({
|
|
11
|
+
trackPreviewFirstFrame: (props: Record<string, unknown>) => firstFrames.push(props),
|
|
12
|
+
}));
|
|
13
|
+
|
|
14
|
+
(globalThis as unknown as { IS_REACT_ACT_ENVIRONMENT: boolean }).IS_REACT_ACT_ENVIRONMENT = true;
|
|
15
|
+
|
|
16
|
+
afterEach(() => {
|
|
17
|
+
document.body.innerHTML = "";
|
|
18
|
+
firstFrames.length = 0;
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
// fails without the fix: a sealed frame's document read as null, so the event said 0 clips and 0 seconds.
|
|
22
|
+
it("reports a sealed preview's clips and length on its first frame", async () => {
|
|
23
|
+
document.body.innerHTML = `<div data-composition-id="main" data-duration="6">
|
|
24
|
+
<div id="title" class="clip" data-start="0" data-duration="2"></div>
|
|
25
|
+
<video id="shot" class="clip" data-start="2" data-duration="4" src="shot.mp4"></video>
|
|
26
|
+
</div>`;
|
|
27
|
+
const slot = { gen: 1, role: "live" as const };
|
|
28
|
+
let report: ReturnType<typeof usePreviewFirstFrameTelemetry> | undefined;
|
|
29
|
+
function Harness() {
|
|
30
|
+
report = usePreviewFirstFrameTelemetry([slot]);
|
|
31
|
+
return null;
|
|
32
|
+
}
|
|
33
|
+
act(() => createRoot(document.createElement("div")).render(createElement(Harness)));
|
|
34
|
+
|
|
35
|
+
report!(slot, { iframe: sealedPreviewFrame().iframe, startedAt: performance.now(), loadId: 1 });
|
|
36
|
+
|
|
37
|
+
await vi.waitFor(() => expect(firstFrames).toHaveLength(1));
|
|
38
|
+
expect(firstFrames[0]).toMatchObject({
|
|
39
|
+
composition_seconds: 6,
|
|
40
|
+
clip_count: 2,
|
|
41
|
+
media_clip_count: 1,
|
|
42
|
+
});
|
|
43
|
+
});
|
|
@@ -4,6 +4,7 @@ import { readTimelineDurationFromDocument } from "../lib/timelineElementHelpers"
|
|
|
4
4
|
import type { PreviewIframeSlot } from "./useTimelineSyncCallbacks";
|
|
5
5
|
import { trackPreviewFirstFrame } from "../../telemetry/events";
|
|
6
6
|
import { getBrowserSystemMeta } from "../../telemetry/system";
|
|
7
|
+
import { previewDocumentCopy, previewFrameOpaque } from "../lib/previewChannel";
|
|
7
8
|
|
|
8
9
|
export function readPreviewComplexity(doc: Document | null | undefined): {
|
|
9
10
|
clip_count: number;
|
|
@@ -38,13 +39,16 @@ export function usePreviewFirstFrameTelemetry(previewSlots: PreviewIframeSlot[])
|
|
|
38
39
|
const reportKey = `${slot.role}:${slot.gen}:${loadId}`;
|
|
39
40
|
if (reportedPaintsRef.current.has(reportKey)) return;
|
|
40
41
|
reportedPaintsRef.current.add(reportKey);
|
|
41
|
-
const
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
42
|
+
const durationMs = Math.max(0, Math.round(performance.now() - startedAt));
|
|
43
|
+
const report = (doc: Document | null) =>
|
|
44
|
+
trackPreviewFirstFrame({
|
|
45
|
+
duration_ms: durationMs,
|
|
46
|
+
composition_seconds: readTimelineDurationFromDocument(doc),
|
|
47
|
+
...readPreviewComplexity(doc),
|
|
48
|
+
studio_version: getBrowserSystemMeta().studio_version,
|
|
49
|
+
});
|
|
50
|
+
if (previewFrameOpaque(iframe)) void previewDocumentCopy(iframe).then(report);
|
|
51
|
+
else report(iframe.contentDocument);
|
|
48
52
|
},
|
|
49
53
|
[],
|
|
50
54
|
);
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
import { act, createElement } from "react";
|
|
4
4
|
import { createRoot } from "react-dom/client";
|
|
5
|
-
import { afterEach, expect, it, vi } from "vitest";
|
|
6
|
-
import type
|
|
5
|
+
import { afterEach, expect, it, onTestFinished, vi } from "vitest";
|
|
6
|
+
import { usePlayerStore, type TimelineElement } from "../store/playerStore";
|
|
7
7
|
import { useTimelineSyncCallbacks } from "./useTimelineSyncCallbacks";
|
|
8
8
|
import { sealedPreviewFrame } from "../lib/sealedPreviewFrame.test-helpers";
|
|
9
9
|
|
|
@@ -69,3 +69,38 @@ it("binds a sealed preview's timeline row to its element, as an open preview doe
|
|
|
69
69
|
audioGroup: "voice",
|
|
70
70
|
});
|
|
71
71
|
});
|
|
72
|
+
|
|
73
|
+
// fails without the fix: reading the frame's `__clipTree` threw, so a sealed scene's children and parents stayed empty.
|
|
74
|
+
it("fills a sealed scene's children and the runtime's clip parents", async () => {
|
|
75
|
+
document.body.innerHTML = `<div data-composition-id="main" data-composition-file="index.html">
|
|
76
|
+
<div id="scene" data-composition-id="scene" data-composition-file="scene.html" data-start="0" data-duration="2">
|
|
77
|
+
<h1 id="title">Title</h1>
|
|
78
|
+
</div>
|
|
79
|
+
</div>`;
|
|
80
|
+
(window as unknown as { __clipTree: unknown }).__clipTree = {
|
|
81
|
+
roots: [
|
|
82
|
+
{ id: "scene", parentId: null, children: [{ id: "cue", parentId: "scene", children: [] }] },
|
|
83
|
+
],
|
|
84
|
+
};
|
|
85
|
+
onTestFinished(() => delete (window as unknown as { __clipTree?: unknown }).__clipTree);
|
|
86
|
+
usePlayerStore.getState().setClipParentMap(new Map());
|
|
87
|
+
usePlayerStore.getState().setDomClipChildren([]);
|
|
88
|
+
const { process } = processWith(sealedPreviewFrame().iframe);
|
|
89
|
+
|
|
90
|
+
process({
|
|
91
|
+
clips: [
|
|
92
|
+
{
|
|
93
|
+
...boxClip,
|
|
94
|
+
id: "scene",
|
|
95
|
+
label: "scene",
|
|
96
|
+
kind: "composition",
|
|
97
|
+
tagName: "div",
|
|
98
|
+
compositionId: "scene",
|
|
99
|
+
},
|
|
100
|
+
],
|
|
101
|
+
durationInFrames: 60,
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
await vi.waitFor(() => expect(usePlayerStore.getState().clipParentMap.get("cue")).toBe("scene"));
|
|
105
|
+
expect(usePlayerStore.getState().domClipChildren.map((child) => child.id)).toContain("title");
|
|
106
|
+
});
|