@hyperframes/studio 0.9.33 → 0.9.35
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/{codec-qz1-OXLj.js → codec-GKrIfefq.js} +1 -1
- package/dist/assets/{hyperframes-player-2eG1zFX5.js → hyperframes-player-BUFkdSG-.js} +1 -1
- package/dist/assets/{index-DDmhnfrS.js → index-BzrZjoXW.js} +159 -159
- package/dist/assets/{index-DUveJ_YP.js → index-oGGylite.js} +1 -1
- package/dist/assets/{pausedVideoDecoder-CoHTKUjM.js → pausedVideoDecoder-VUkpOCb9.js} +1 -1
- package/dist/index.html +1 -1
- package/dist/index.js +45 -6
- package/package.json +8 -8
- package/src/components/share/QuickShare.test.tsx +55 -0
- package/src/components/share/QuickShare.tsx +6 -0
- package/src/components/share/QuickShareControls.tsx +22 -4
- package/src/components/share/localShareTelemetry.test.ts +8 -0
- package/src/components/share/useQuickShare.ts +8 -1
- package/src/components/sidebar/CompositionsTab.drag.test.tsx +9 -2
- package/src/components/sidebar/CompositionsTab.hoverPreview.test.tsx +30 -10
- package/src/components/sidebar/CompositionsTab.thumbnails.test.tsx +4 -2
- package/src/components/sidebar/CompositionsTab.tsx +28 -3
- package/src/components/sidebar/compositionsTabTestUtils.tsx +16 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{A as Ht,m as Ke,I as qt,v as le,p as Di,t as oe,b as Ni,a as m,w as Hi,B as we,F as yt,c as ce,d as K,e as Rt,f as Qe,r as vs,g as As,h as Ms,i as Is,j as qi,k as _e,l as Oi,s as Fs,n as $i,o as Bs,q as Be,u as gt,x as Ki,y as Rs,U as Ot,R as Ws,z as ve,C as Oe,D as Qi,V as $e,P as je,E as Gi,G as $t,T as Kt,M as Qt,H as zs,J as Us,K as Vs,L as Ls,N as Ds,O as ji,Q as Xi,S as Ns,W as Yi,X as Ee,Y as Hs,Z as qs,_ as Xe,$ as Os,a0 as $s,a1 as Ks,a2 as Qs,a3 as Gs,a4 as Zi,a5 as ft,a6 as Ji,a7 as es,a8 as ts,a9 as is,aa as ss,ab as js,ac as rs,ad as as,ae as Xs,af as ns,ag as Ys,ah as ht,ai as Jt,aj as bt,ak as Zs,al as w,am as ei,an as Js,ao as er,ap as tr,aq as Me,ar as ir,as as ti,at as Je,au as sr,av as rr,aw as ar,ax as nr,ay as or,az as ii,aA as cr,aB as ur,aC as Y,aD as dr,aE as si,aF as os,aG as ri,aH as cs,aI as us,aJ as _t,aK as Wt,aL as ai,aM as ni,aN as lr,aO as mr,aP as fr,aQ as hr,aR as pr,aS as lt,aT as gr,aU as wr,aV as Tr,aW as oi,aX as yr,aY as br,aZ as _r,a_ as ci,a$ as ui,b0 as di,b1 as Ne,b2 as li,b3 as kr,b4 as Sr,b5 as zt,b6 as et,b7 as tt,b8 as it,b9 as Cr,ba as mt,bb as xr,bc as be,bd as Ut,be as Vt,bf as st,bg as Re,bh as Fe,bi as ke,bj as Ue,bk as Ye,bl as Pr,bm as Ve,bn as We,bo as kt,bp as Er,bq as mi,br as vr,bs as Ar,bt as Lt,bu as Dt,bv as Mr,bw as Ir,bx as Fr,by as Br,bz as ze,bA as rt,bB as fi,bC as Rr,bD as hi,bE as pi,bF as gi,bG as Wr,bH as zr,bI as Ur,bJ as Vr,bK as Lr,bL as Dr}from"./codec-
|
|
1
|
+
import{A as Ht,m as Ke,I as qt,v as le,p as Di,t as oe,b as Ni,a as m,w as Hi,B as we,F as yt,c as ce,d as K,e as Rt,f as Qe,r as vs,g as As,h as Ms,i as Is,j as qi,k as _e,l as Oi,s as Fs,n as $i,o as Bs,q as Be,u as gt,x as Ki,y as Rs,U as Ot,R as Ws,z as ve,C as Oe,D as Qi,V as $e,P as je,E as Gi,G as $t,T as Kt,M as Qt,H as zs,J as Us,K as Vs,L as Ls,N as Ds,O as ji,Q as Xi,S as Ns,W as Yi,X as Ee,Y as Hs,Z as qs,_ as Xe,$ as Os,a0 as $s,a1 as Ks,a2 as Qs,a3 as Gs,a4 as Zi,a5 as ft,a6 as Ji,a7 as es,a8 as ts,a9 as is,aa as ss,ab as js,ac as rs,ad as as,ae as Xs,af as ns,ag as Ys,ah as ht,ai as Jt,aj as bt,ak as Zs,al as w,am as ei,an as Js,ao as er,ap as tr,aq as Me,ar as ir,as as ti,at as Je,au as sr,av as rr,aw as ar,ax as nr,ay as or,az as ii,aA as cr,aB as ur,aC as Y,aD as dr,aE as si,aF as os,aG as ri,aH as cs,aI as us,aJ as _t,aK as Wt,aL as ai,aM as ni,aN as lr,aO as mr,aP as fr,aQ as hr,aR as pr,aS as lt,aT as gr,aU as wr,aV as Tr,aW as oi,aX as yr,aY as br,aZ as _r,a_ as ci,a$ as ui,b0 as di,b1 as Ne,b2 as li,b3 as kr,b4 as Sr,b5 as zt,b6 as et,b7 as tt,b8 as it,b9 as Cr,ba as mt,bb as xr,bc as be,bd as Ut,be as Vt,bf as st,bg as Re,bh as Fe,bi as ke,bj as Ue,bk as Ye,bl as Pr,bm as Ve,bn as We,bo as kt,bp as Er,bq as mi,br as vr,bs as Ar,bt as Lt,bu as Dt,bv as Mr,bw as Ir,bx as Fr,by as Br,bz as ze,bA as rt,bB as fi,bC as Rr,bD as hi,bE as pi,bF as gi,bG as Wr,bH as zr,bI as Ur,bJ as Vr,bK as Lr,bL as Dr}from"./codec-GKrIfefq.js";import{bM as $n,bN as Kn,bO as Qn,bP as Gn,bQ as jn,bR as Xn,bS as Yn,bT as Zn,bU as Jn,bV as eo,bW as to,bX as io,bY as so,bZ as ro,b_ as ao,b$ as no,c0 as oo,c1 as co,c2 as uo,c3 as lo,c4 as mo,c5 as fo,c6 as ho,c7 as po,c8 as go,c9 as wo,ca as To,cb as yo,cc as bo,cd as _o,ce as ko,cf as So,cg as Co,ch as xo,ci as Po,cj as Eo,ck as vo,cl as Ao,cm as Mo,cn as Io,co as Fo,cp as Bo,cq as Ro,cr as Wo,cs as zo,ct as Uo,cu as Vo,cv as Lo,cw as Do,cx as No,cy as Ho,cz as qo,cA as Oo,cB as $o,cC as Ko,cD as Qo,cE as Go,cF as jo,cG as Xo,cH as Yo,cI as Zo,cJ as Jo,cK as ec,cL as tc,cM as ic,cN as sc,cO as rc,cP as ac,cQ as nc,cR as oc,cS as cc,cT as uc,cU as dc,cV as lc,cW as mc,cX as fc,cY as hc,cZ as pc,c_ as gc,c$ as wc,d0 as Tc,d1 as yc,d2 as bc,d3 as _c,d4 as kc,d5 as Sc,d6 as Cc,d7 as xc,d8 as Pc}from"./codec-GKrIfefq.js";import{n as wi}from"./index-BzrZjoXW.js";/*!
|
|
2
2
|
* Copyright (c) 2026-present, Vanilagy and contributors
|
|
3
3
|
*
|
|
4
4
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{l as V}from"./index-
|
|
1
|
+
import{l as V}from"./index-BzrZjoXW.js";import{bw as G,bN as K,cH as Q,bE as X}from"./codec-GKrIfefq.js";const x=1e-5,k=1e-9,T=h=>!h.variableFrameRate&&(h.frameRate??0)>0;function Y(h,i){const{sourceLead:r,inputLead:l,timeResolution:w,frameRate:p=0}=i;if(!T(i))return Math.max(l,h-r+l)+k;const d=Math.max(0,Math.floor((h-r)*p+k)),f=l+d/p;return(w>0?Math.round(f*w)/w:f)+x}function J(h,i,r){const{frameRate:l=0,sourceLead:w,inputLead:p}=r,d=T(r)?Math.round((h-p)*l)/l+w:h-p+w,f=Math.min(i,d);return{timestamp:f,duration:Math.max(T(r)?1/l:0,i-f+x)}}const E=64*1024*1024,M=4,Z=.5,$=2e3;async function q(h,i){if(!h.transparent)return h.sink.getSample(i);let r=null;try{for await(const l of h.sink.samplesAtTimestamps([i]))r==null||r.close(),r=l;return r}catch(l){throw r==null||r.close(),l}}function ot(h){const i=new Map,r=new Map,l=new Map,w=new Map,p=new Map;let d=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(([s])=>e.endsWith(s)).sort(([s],[a])=>a.length-s.length)[0])==null?void 0:n[1]},g=(t=E)=>{for(const[e,o]of p){if(d<=t)break;e.pins>0||(p.delete(e),o.cache.delete(e.timestamp),d-=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),d-=o.bytes,o.image.close();t.cache.clear(),t.canvas.width=t.canvas.height=0})();return t.transparent?new Promise((o,n)=>{const s=setTimeout(()=>{t.cancelReads(),o()},$);e.then(o,n).finally(()=>clearTimeout(s))}):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&&(i.delete(t.key),v(t))},1e4))},D=async t=>{const e=V("thumbnail"),o=new G({source:new Q(t,e),formats:K});l.set(o,e.cancelReads);try{const n=await o.getPrimaryVideoTrack();if(!n||f)throw new Error("Preview video unavailable");const[s,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()]),b=document.createElement("canvas");b.width=Math.max(1,Math.ceil(s));const z=F%180===0?m/S:S/m;return b.height=Math.max(1,Math.round(b.width/z)),{key:t,input:o,cancelReads:e.cancelReads,sink:new X(n),canvas:b,rotation:F,flip:B,width:s,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 i){if(i.size<M)break;const e=r.get(t);e&&e.users===0&&![...e.cache.values()].some(o=>o.pins>0)&&(i.delete(t),v(e))}if(i.size>=M)throw new Error("Preview decoder budget reached")},L=async t=>{const e=t;if((w.get(e)??0)>performance.now())throw new Error("Preview decoder cooling down");let o=i.get(e);o||(I(),o=D(t),i.set(e,o)),i.delete(e),i.set(e,o);let n;try{n=await o}catch(s){throw i.get(e)===o&&(i.delete(e),w.set(e,performance.now()+5e3)),s}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 s=n.value;let a=!1;try{if(R(t,o),s.timestamp>e+1e-6)return null;if(a=s.timestamp+s.duration>e+1e-6,a)return s}finally{a||s.close()}}},A=(t,e)=>(e.pins++,p.delete(e),p.set(e,t),e),W=async(t,e,o,n,s)=>{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(s.aborted||f||t.disposed)throw u.close(),s.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(g(E-c.bytes),d+c.bytes>E)throw u.close(),new Error("Preview frame budget reached");return t.cache.set(c.timestamp,c),p.set(c,t),d+=c.bytes,c},H=(t,e,o)=>!t.transparent&&!o.variableFrameRate&&(o.frameRate??0)>0&&e>t.lastTime+1e-6&&e-t.lastTime<=Z,N=async(t,e,o,n)=>{R(t,n);const s=[...t.cache.values()].find(m=>e>=m.timestamp-1e-6&&e<m.timestamp+m.duration-1e-6);if(s)return A(t,s);const a=Y(e,o),u=H(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(()=>{})}},U=(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}},C=async(t,e)=>{e.throwIfAborted();const o=t.source;if(!o)throw new Error("Preview source unavailable");const n=await L(o);try{const s=U(t,n),a=n.tail.then(()=>N(n,t.time,s,e));n.tail=a.then(()=>{},()=>{});const u=await a;let c=!1;return g(),{source:u.image,timestamp:u.timestamp,duration:u.duration,width:n.width,height:n.height,release(){c||(c=!0,u.pins--,g(),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=>C(a,e))),n=o.find(a=>a.status==="rejected"),s=o.flatMap(a=>a.status==="fulfilled"?[a.value]:[]);if(n||f||e.aborted){for(const a of s)a.release();throw n?n.reason:new DOMException("Preview cancelled","AbortError")}return s},async suspend(){const t=[...i.values()].map(e=>e.then(v).catch(()=>{}));i.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 i.values())t.then(v).catch(()=>{});i.clear(),w.clear()}}}}export{ot as createPausedVideoDecoder};
|
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-BzrZjoXW.js"></script>
|
|
18
18
|
<link rel="stylesheet" crossorigin href="/assets/index-BJTCbv8z.css">
|
|
19
19
|
</head>
|
|
20
20
|
<body>
|
package/dist/index.js
CHANGED
|
@@ -92060,6 +92060,7 @@ function useQuickShare(token, beforeShare) {
|
|
|
92060
92060
|
async function run(action) {
|
|
92061
92061
|
const signal = lifetime.current?.signal;
|
|
92062
92062
|
if (!signal || signal.aborted || working.current) return;
|
|
92063
|
+
track2({ event: "share_action_clicked", action: action.action });
|
|
92063
92064
|
setWorking(true);
|
|
92064
92065
|
setError(null);
|
|
92065
92066
|
setErrorCode(null);
|
|
@@ -92127,10 +92128,15 @@ function useQuickShare(token, beforeShare) {
|
|
|
92127
92128
|
setError("Couldn\u2019t copy. Open the shared page and copy its address.");
|
|
92128
92129
|
}
|
|
92129
92130
|
}
|
|
92131
|
+
const track2 = (event) => shareInteraction(token, event);
|
|
92130
92132
|
return {
|
|
92133
|
+
track: track2,
|
|
92131
92134
|
snapshot: snapshot3,
|
|
92132
92135
|
audience,
|
|
92133
|
-
setAudience
|
|
92136
|
+
setAudience: (value) => {
|
|
92137
|
+
setAudience(value);
|
|
92138
|
+
track2({ event: "share_audience_selected", audience: value });
|
|
92139
|
+
},
|
|
92134
92140
|
spaceId,
|
|
92135
92141
|
busy: busy2,
|
|
92136
92142
|
error,
|
|
@@ -92386,7 +92392,10 @@ function ShareSourceStatus({ model, snapshot: snapshot3 }) {
|
|
|
92386
92392
|
type: "checkbox",
|
|
92387
92393
|
checked: model.includeSource,
|
|
92388
92394
|
disabled: model.busy,
|
|
92389
|
-
onChange: (event) =>
|
|
92395
|
+
onChange: (event) => {
|
|
92396
|
+
model.setIncludeSource(event.target.checked);
|
|
92397
|
+
model.track({ event: "share_source_toggled", enabled: event.target.checked });
|
|
92398
|
+
}
|
|
92390
92399
|
}
|
|
92391
92400
|
),
|
|
92392
92401
|
/* @__PURE__ */ jsxs166("span", { children: [
|
|
@@ -92434,10 +92443,16 @@ function ShareLogin({ model }) {
|
|
|
92434
92443
|
] })
|
|
92435
92444
|
] });
|
|
92436
92445
|
}
|
|
92446
|
+
var PRICING_ORIGINS = ["https://hyperframes.dev", "https://dev.hyperframes.dev"];
|
|
92447
|
+
function isPricingPage(link) {
|
|
92448
|
+
if (!URL.canParse(link)) return false;
|
|
92449
|
+
const url = new URL(link);
|
|
92450
|
+
return PRICING_ORIGINS.includes(url.origin) && url.pathname === "/pricing";
|
|
92451
|
+
}
|
|
92437
92452
|
function SharePlan({ model, snapshot: snapshot3 }) {
|
|
92438
92453
|
const space = snapshot3.spaces.find((item) => item.id === model.spaceId);
|
|
92439
92454
|
const upgrade = space?.upgradeUrl;
|
|
92440
|
-
const allowed2 = upgrade &&
|
|
92455
|
+
const allowed2 = upgrade !== void 0 && upgrade !== null && isPricingPage(upgrade);
|
|
92441
92456
|
return /* @__PURE__ */ jsxs166("div", { className: "flex flex-wrap items-center justify-between gap-2 text-step-12", children: [
|
|
92442
92457
|
space && space.limit !== null && space.used !== null ? /* @__PURE__ */ jsxs166("span", { className: "text-text-3 tabular-nums", children: [
|
|
92443
92458
|
space.used,
|
|
@@ -92449,6 +92464,10 @@ function SharePlan({ model, snapshot: snapshot3 }) {
|
|
|
92449
92464
|
"a",
|
|
92450
92465
|
{
|
|
92451
92466
|
href: upgrade,
|
|
92467
|
+
onClick: () => model.track({
|
|
92468
|
+
event: "share_upgrade_clicked",
|
|
92469
|
+
reason: space.limit !== null && space.used !== null && space.used >= space.limit ? "project_limit" : "sharing_permissions"
|
|
92470
|
+
}),
|
|
92452
92471
|
target: "_blank",
|
|
92453
92472
|
rel: "noreferrer",
|
|
92454
92473
|
className: "inline-flex h-8 items-center gap-1 rounded-full px-2 font-semibold text-accent hover:bg-hover",
|
|
@@ -92523,6 +92542,7 @@ function QuickShareContent({
|
|
|
92523
92542
|
"a",
|
|
92524
92543
|
{
|
|
92525
92544
|
href: manageUrl,
|
|
92545
|
+
onClick: () => model.track({ event: "share_navigation_clicked", destination: "manage" }),
|
|
92526
92546
|
target: "_blank",
|
|
92527
92547
|
rel: "noreferrer",
|
|
92528
92548
|
className: "flex h-8 items-center rounded-full px-2 text-step-12 text-text-2 hover:bg-hover",
|
|
@@ -92533,6 +92553,7 @@ function QuickShareContent({
|
|
|
92533
92553
|
"a",
|
|
92534
92554
|
{
|
|
92535
92555
|
href: url,
|
|
92556
|
+
onClick: () => model.track({ event: "share_navigation_clicked", destination: "shared_page" }),
|
|
92536
92557
|
target: "_blank",
|
|
92537
92558
|
rel: "noreferrer",
|
|
92538
92559
|
className: "flex h-8 items-center rounded-full px-2 text-step-12 text-text-2 hover:bg-hover",
|
|
@@ -95828,6 +95849,24 @@ function resolveCompositionPreviewScale(input) {
|
|
|
95828
95849
|
function compositionPreviewUrl(projectId, comp) {
|
|
95829
95850
|
return buildProjectApiPath(projectId, `/preview/comp/${encodePreviewPath(comp)}`);
|
|
95830
95851
|
}
|
|
95852
|
+
function framePreviewUrl(projectId, comp, frameToken) {
|
|
95853
|
+
const tokenPrefix = frameToken ? `/~${frameToken}` : "";
|
|
95854
|
+
return buildProjectApiPath(projectId, `/preview${tokenPrefix}/comp/${encodePreviewPath(comp)}`);
|
|
95855
|
+
}
|
|
95856
|
+
function useFreshFrameToken(projectId, wanted) {
|
|
95857
|
+
const [known, setKnown] = useState151(void 0);
|
|
95858
|
+
useEffect150(() => {
|
|
95859
|
+
if (!wanted) return setKnown(void 0);
|
|
95860
|
+
let live = true;
|
|
95861
|
+
void studioApiFetch(buildProjectApiPath(projectId, "/frame-token")).then((res) => res.ok ? res.json() : null).then(
|
|
95862
|
+
(body) => typeof body?.token === "string" ? body.token : null
|
|
95863
|
+
).catch(() => null).then((token) => live && setKnown({ token }));
|
|
95864
|
+
return () => {
|
|
95865
|
+
live = false;
|
|
95866
|
+
};
|
|
95867
|
+
}, [projectId, wanted]);
|
|
95868
|
+
return known?.token;
|
|
95869
|
+
}
|
|
95831
95870
|
function compositionCardThumbnailUrl(projectId, comp, contentRevision) {
|
|
95832
95871
|
return buildCompositionThumbnailUrl({
|
|
95833
95872
|
previewUrl: compositionPreviewUrl(projectId, comp),
|
|
@@ -95913,7 +95952,7 @@ function CompCard({
|
|
|
95913
95952
|
setLivePreviewLoaded(false);
|
|
95914
95953
|
};
|
|
95915
95954
|
const name = comp.replace(/^compositions\//, "").replace(/\.html$/, "");
|
|
95916
|
-
const
|
|
95955
|
+
const frameToken = useFreshFrameToken(projectId, hovered);
|
|
95917
95956
|
const thumbnailUrl2 = compositionCardThumbnailUrl(projectId, comp, contentRevision);
|
|
95918
95957
|
const [thumbnailBox, nearViewport] = useNearViewport();
|
|
95919
95958
|
const timelineSessionEpoch = usePlayerStore((state) => state.timelineSessionEpoch);
|
|
@@ -96011,11 +96050,11 @@ function CompCard({
|
|
|
96011
96050
|
className: `absolute inset-0 h-full w-full object-contain transition-opacity ${livePreviewLoaded ? "opacity-0" : "opacity-100"}`
|
|
96012
96051
|
}
|
|
96013
96052
|
),
|
|
96014
|
-
hovered && /* @__PURE__ */ jsx231(
|
|
96053
|
+
hovered && frameToken !== void 0 && /* @__PURE__ */ jsx231(
|
|
96015
96054
|
"iframe",
|
|
96016
96055
|
{
|
|
96017
96056
|
ref: iframeRef,
|
|
96018
|
-
src:
|
|
96057
|
+
src: framePreviewUrl(projectId, comp, frameToken),
|
|
96019
96058
|
sandbox: OPAQUE_ORIGIN_SCRIPTS_ONLY_SANDBOX,
|
|
96020
96059
|
className: "absolute border-none pointer-events-none",
|
|
96021
96060
|
style: {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hyperframes/studio",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.35",
|
|
4
4
|
"description": "",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -60,12 +60,12 @@
|
|
|
60
60
|
"dockview-react": "8.3.1",
|
|
61
61
|
"gsap": "^3.13.0",
|
|
62
62
|
"mediabunny": "^1.65.2",
|
|
63
|
-
"@hyperframes/core": "0.9.
|
|
64
|
-
"@hyperframes/parsers": "0.9.
|
|
65
|
-
"@hyperframes/player": "0.9.
|
|
66
|
-
"@hyperframes/sdk": "0.9.
|
|
67
|
-
"@hyperframes/
|
|
68
|
-
"@hyperframes/
|
|
63
|
+
"@hyperframes/core": "0.9.35",
|
|
64
|
+
"@hyperframes/parsers": "0.9.35",
|
|
65
|
+
"@hyperframes/player": "0.9.35",
|
|
66
|
+
"@hyperframes/sdk": "0.9.35",
|
|
67
|
+
"@hyperframes/studio-server": "0.9.35",
|
|
68
|
+
"@hyperframes/shader-transitions": "0.9.35"
|
|
69
69
|
},
|
|
70
70
|
"devDependencies": {
|
|
71
71
|
"@tailwindcss/vite": "^4.3.3",
|
|
@@ -82,7 +82,7 @@
|
|
|
82
82
|
"vite": "^6.4.2",
|
|
83
83
|
"vitest": "^4.1.11",
|
|
84
84
|
"zustand": "^5.0.0",
|
|
85
|
-
"@hyperframes/producer": "0.9.
|
|
85
|
+
"@hyperframes/producer": "0.9.35"
|
|
86
86
|
},
|
|
87
87
|
"peerDependencies": {
|
|
88
88
|
"react": "19",
|
|
@@ -132,6 +132,10 @@ it("drains pending editor saves before creating or uploading", async () => {
|
|
|
132
132
|
await mount(save);
|
|
133
133
|
await choose("public");
|
|
134
134
|
await act(async () => button("Create share link")?.click());
|
|
135
|
+
expect(interaction).toHaveBeenCalledWith(token, {
|
|
136
|
+
event: "share_action_clicked",
|
|
137
|
+
action: "share",
|
|
138
|
+
});
|
|
135
139
|
expect(save).toHaveBeenCalledOnce();
|
|
136
140
|
expect(calls).toEqual([]);
|
|
137
141
|
await act(async () => resolveSave());
|
|
@@ -497,6 +501,25 @@ it.each(["free", "subscribed", null] as const)(
|
|
|
497
501
|
else expect(link).toBeUndefined();
|
|
498
502
|
},
|
|
499
503
|
);
|
|
504
|
+
it("keeps the plan link's entry so the pricing page can count where the visit came from", async () => {
|
|
505
|
+
snapshot.spaces[0]!.plan = "free";
|
|
506
|
+
snapshot.spaces[0]!.upgradeUrl = "https://hyperframes.dev/pricing?entry=local_studio_share";
|
|
507
|
+
await mount();
|
|
508
|
+
const link = [...host.querySelectorAll("a")].find((a) =>
|
|
509
|
+
a.textContent?.includes("Upgrade to Pro"),
|
|
510
|
+
);
|
|
511
|
+
expect(link?.href).toBe("https://hyperframes.dev/pricing?entry=local_studio_share");
|
|
512
|
+
});
|
|
513
|
+
it("refuses a look-alike pricing host even with a matching path", async () => {
|
|
514
|
+
snapshot.spaces[0]!.plan = "free";
|
|
515
|
+
snapshot.spaces[0]!.upgradeUrl =
|
|
516
|
+
"https://hyperframes.dev.evil.test/pricing?entry=local_studio_share";
|
|
517
|
+
await mount();
|
|
518
|
+
const link = [...host.querySelectorAll("a")].find((a) =>
|
|
519
|
+
a.textContent?.includes("Upgrade to Pro"),
|
|
520
|
+
);
|
|
521
|
+
expect(link).toBeUndefined();
|
|
522
|
+
});
|
|
500
523
|
it("refuses an upgrade destination outside the public pricing flow", async () => {
|
|
501
524
|
snapshot.spaces[0]!.plan = "free";
|
|
502
525
|
snapshot.spaces[0]!.upgradeUrl = "https://example.com/checkout";
|
|
@@ -620,3 +643,35 @@ it("discloses source scope and uploads files only after checking the option", as
|
|
|
620
643
|
{ action: "share", audience: "public", space: "team1", includeSource: true },
|
|
621
644
|
]);
|
|
622
645
|
});
|
|
646
|
+
|
|
647
|
+
it.each([0, 5])("counts upgrade intent with quota context (used=%s)", async (used) => {
|
|
648
|
+
snapshot.spaces[0]!.plan = "free";
|
|
649
|
+
snapshot.spaces[0]!.used = used;
|
|
650
|
+
snapshot.spaces[0]!.upgradeUrl = "https://hyperframes.dev/pricing";
|
|
651
|
+
await mount();
|
|
652
|
+
expect(interaction.mock.calls.filter(([, e]) => e.event === "share_upgrade_clicked")).toEqual([]);
|
|
653
|
+
const upgrade = host.querySelector<HTMLAnchorElement>(
|
|
654
|
+
'a[href="https://hyperframes.dev/pricing"]',
|
|
655
|
+
)!;
|
|
656
|
+
upgrade.addEventListener("click", (event) => event.preventDefault());
|
|
657
|
+
await act(async () => upgrade.click());
|
|
658
|
+
expect(interaction).toHaveBeenCalledWith(token, {
|
|
659
|
+
event: "share_upgrade_clicked",
|
|
660
|
+
reason: used === 5 ? "project_limit" : "sharing_permissions",
|
|
661
|
+
});
|
|
662
|
+
expect(calls).toEqual([]);
|
|
663
|
+
});
|
|
664
|
+
it("counts explicit audience, source and manage interactions without sending project data", async () => {
|
|
665
|
+
await mount();
|
|
666
|
+
await choose("invite");
|
|
667
|
+
await act(async () => host.querySelector<HTMLInputElement>('input[type="checkbox"]')!.click());
|
|
668
|
+
const manage = host.querySelector<HTMLAnchorElement>('a[href="https://hyperframes.dev/shares"]')!;
|
|
669
|
+
manage.addEventListener("click", (event) => event.preventDefault());
|
|
670
|
+
await act(async () => manage.click());
|
|
671
|
+
expect(interaction.mock.calls).toEqual([
|
|
672
|
+
[token, { event: "share_opened", link: "none" }],
|
|
673
|
+
[token, { event: "share_audience_selected", audience: "invite" }],
|
|
674
|
+
[token, { event: "share_source_toggled", enabled: true }],
|
|
675
|
+
[token, { event: "share_navigation_clicked", destination: "manage" }],
|
|
676
|
+
]);
|
|
677
|
+
});
|
|
@@ -81,6 +81,9 @@ export function QuickShareContent({
|
|
|
81
81
|
{manageUrl ? (
|
|
82
82
|
<a
|
|
83
83
|
href={manageUrl}
|
|
84
|
+
onClick={() =>
|
|
85
|
+
model.track({ event: "share_navigation_clicked", destination: "manage" })
|
|
86
|
+
}
|
|
84
87
|
target="_blank"
|
|
85
88
|
rel="noreferrer"
|
|
86
89
|
className="flex h-8 items-center rounded-full px-2 text-step-12 text-text-2 hover:bg-hover"
|
|
@@ -91,6 +94,9 @@ export function QuickShareContent({
|
|
|
91
94
|
{url ? (
|
|
92
95
|
<a
|
|
93
96
|
href={url}
|
|
97
|
+
onClick={() =>
|
|
98
|
+
model.track({ event: "share_navigation_clicked", destination: "shared_page" })
|
|
99
|
+
}
|
|
94
100
|
target="_blank"
|
|
95
101
|
rel="noreferrer"
|
|
96
102
|
className="flex h-8 items-center rounded-full px-2 text-step-12 text-text-2 hover:bg-hover"
|
|
@@ -179,7 +179,10 @@ export function ShareSourceStatus({ model, snapshot }: Props) {
|
|
|
179
179
|
type="checkbox"
|
|
180
180
|
checked={model.includeSource}
|
|
181
181
|
disabled={model.busy}
|
|
182
|
-
onChange={(event) =>
|
|
182
|
+
onChange={(event) => {
|
|
183
|
+
model.setIncludeSource(event.target.checked);
|
|
184
|
+
model.track({ event: "share_source_toggled", enabled: event.target.checked });
|
|
185
|
+
}}
|
|
183
186
|
/>
|
|
184
187
|
<span>
|
|
185
188
|
Include editable project files
|
|
@@ -236,12 +239,18 @@ export function ShareLogin({ model }: { model: QuickShareModel }) {
|
|
|
236
239
|
);
|
|
237
240
|
}
|
|
238
241
|
|
|
242
|
+
const PRICING_ORIGINS = ["https://hyperframes.dev", "https://dev.hyperframes.dev"];
|
|
243
|
+
|
|
244
|
+
function isPricingPage(link: string): boolean {
|
|
245
|
+
if (!URL.canParse(link)) return false;
|
|
246
|
+
const url = new URL(link);
|
|
247
|
+
return PRICING_ORIGINS.includes(url.origin) && url.pathname === "/pricing";
|
|
248
|
+
}
|
|
249
|
+
|
|
239
250
|
export function SharePlan({ model, snapshot }: Props) {
|
|
240
251
|
const space = snapshot.spaces.find((item) => item.id === model.spaceId);
|
|
241
252
|
const upgrade = space?.upgradeUrl;
|
|
242
|
-
const allowed =
|
|
243
|
-
upgrade &&
|
|
244
|
-
["https://hyperframes.dev/pricing", "https://dev.hyperframes.dev/pricing"].includes(upgrade);
|
|
253
|
+
const allowed = upgrade !== undefined && upgrade !== null && isPricingPage(upgrade);
|
|
245
254
|
return (
|
|
246
255
|
<div className="flex flex-wrap items-center justify-between gap-2 text-step-12">
|
|
247
256
|
{space && space.limit !== null && space.used !== null ? (
|
|
@@ -252,6 +261,15 @@ export function SharePlan({ model, snapshot }: Props) {
|
|
|
252
261
|
{space?.plan === "free" && allowed ? (
|
|
253
262
|
<a
|
|
254
263
|
href={upgrade}
|
|
264
|
+
onClick={() =>
|
|
265
|
+
model.track({
|
|
266
|
+
event: "share_upgrade_clicked",
|
|
267
|
+
reason:
|
|
268
|
+
space.limit !== null && space.used !== null && space.used >= space.limit
|
|
269
|
+
? "project_limit"
|
|
270
|
+
: "sharing_permissions",
|
|
271
|
+
})
|
|
272
|
+
}
|
|
255
273
|
target="_blank"
|
|
256
274
|
rel="noreferrer"
|
|
257
275
|
className="inline-flex h-8 items-center gap-1 rounded-full px-2 font-semibold text-accent hover:bg-hover"
|
|
@@ -20,3 +20,11 @@ it("obeys browser opt-out before calling the guarded local bridge", async () =>
|
|
|
20
20
|
}),
|
|
21
21
|
);
|
|
22
22
|
});
|
|
23
|
+
|
|
24
|
+
it("does not send upgrade clicks when telemetry is disabled", () => {
|
|
25
|
+
const fetch = vi.fn();
|
|
26
|
+
vi.stubGlobal("fetch", fetch);
|
|
27
|
+
policy.mockReturnValue(false);
|
|
28
|
+
shareInteraction("token", { event: "share_upgrade_clicked", reason: "project_limit" });
|
|
29
|
+
expect(fetch).not.toHaveBeenCalled();
|
|
30
|
+
});
|
|
@@ -3,6 +3,7 @@ import type {
|
|
|
3
3
|
LocalShareAction,
|
|
4
4
|
LocalShareAudience,
|
|
5
5
|
LocalShareJob,
|
|
6
|
+
LocalShareInteraction,
|
|
6
7
|
LocalShareSnapshot,
|
|
7
8
|
} from "@hyperframes/studio-server";
|
|
8
9
|
import { useMountEffect } from "../../hooks/useMountEffect";
|
|
@@ -106,6 +107,7 @@ export function useQuickShare(token: string, beforeShare?: () => Promise<void>)
|
|
|
106
107
|
async function run(action: LocalShareAction) {
|
|
107
108
|
const signal = lifetime.current?.signal;
|
|
108
109
|
if (!signal || signal.aborted || working.current) return;
|
|
110
|
+
track({ event: "share_action_clicked", action: action.action });
|
|
109
111
|
setWorking(true);
|
|
110
112
|
setError(null);
|
|
111
113
|
setErrorCode(null);
|
|
@@ -176,10 +178,15 @@ export function useQuickShare(token: string, beforeShare?: () => Promise<void>)
|
|
|
176
178
|
setError("Couldn’t copy. Open the shared page and copy its address.");
|
|
177
179
|
}
|
|
178
180
|
}
|
|
181
|
+
const track = (event: LocalShareInteraction) => shareInteraction(token, event);
|
|
179
182
|
return {
|
|
183
|
+
track,
|
|
180
184
|
snapshot,
|
|
181
185
|
audience,
|
|
182
|
-
setAudience
|
|
186
|
+
setAudience: (value: LocalShareAudience) => {
|
|
187
|
+
setAudience(value);
|
|
188
|
+
track({ event: "share_audience_selected", audience: value });
|
|
189
|
+
},
|
|
183
190
|
spaceId,
|
|
184
191
|
busy,
|
|
185
192
|
error,
|
|
@@ -3,7 +3,11 @@
|
|
|
3
3
|
import { act } from "react";
|
|
4
4
|
import { describe, expect, it, vi } from "vitest";
|
|
5
5
|
import { TIMELINE_COMPOSITION_MIME } from "../../utils/timelineCompositionDrop";
|
|
6
|
-
import {
|
|
6
|
+
import {
|
|
7
|
+
mountCompositionsTab,
|
|
8
|
+
settleFrameToken,
|
|
9
|
+
stubFrameTokenFetch,
|
|
10
|
+
} from "./compositionsTabTestUtils";
|
|
7
11
|
|
|
8
12
|
function mount(onSelect = vi.fn(), onAddToTimeline = vi.fn()) {
|
|
9
13
|
const host = mountCompositionsTab({ onSelect, onAddToTimeline });
|
|
@@ -13,15 +17,17 @@ function mount(onSelect = vi.fn(), onAddToTimeline = vi.fn()) {
|
|
|
13
17
|
}
|
|
14
18
|
|
|
15
19
|
describe("composition card drag", () => {
|
|
16
|
-
it("mounts one live preview only after sustained hover and removes it on leave", () => {
|
|
20
|
+
it("mounts one live preview only after sustained hover and removes it on leave", async () => {
|
|
17
21
|
vi.useFakeTimers();
|
|
18
22
|
const consoleError = vi.spyOn(console, "error").mockImplementation(() => {});
|
|
23
|
+
const tokenFetch = stubFrameTokenFetch();
|
|
19
24
|
try {
|
|
20
25
|
const { host, card } = mount();
|
|
21
26
|
act(() => {
|
|
22
27
|
card.dispatchEvent(new Event("pointerover", { bubbles: true }));
|
|
23
28
|
vi.advanceTimersByTime(300);
|
|
24
29
|
});
|
|
30
|
+
await settleFrameToken();
|
|
25
31
|
expect(host.querySelectorAll("iframe")).toHaveLength(1);
|
|
26
32
|
|
|
27
33
|
act(() => {
|
|
@@ -30,6 +36,7 @@ describe("composition card drag", () => {
|
|
|
30
36
|
expect(host.querySelector("iframe")).toBeNull();
|
|
31
37
|
expect(vi.getTimerCount()).toBe(0);
|
|
32
38
|
} finally {
|
|
39
|
+
tokenFetch.mockRestore();
|
|
33
40
|
consoleError.mockRestore();
|
|
34
41
|
vi.useRealTimers();
|
|
35
42
|
}
|
|
@@ -2,11 +2,16 @@
|
|
|
2
2
|
|
|
3
3
|
import { act } from "react";
|
|
4
4
|
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
|
5
|
-
import {
|
|
5
|
+
import {
|
|
6
|
+
FRAME_TOKEN,
|
|
7
|
+
mountCompositionsTab,
|
|
8
|
+
settleFrameToken,
|
|
9
|
+
stubFrameTokenFetch,
|
|
10
|
+
} from "./compositionsTabTestUtils";
|
|
6
11
|
|
|
7
12
|
type PostedControl = { source: string; type: string; action: string; muted?: boolean };
|
|
8
13
|
|
|
9
|
-
function hoverPreview() {
|
|
14
|
+
async function hoverPreview() {
|
|
10
15
|
const host = mountCompositionsTab();
|
|
11
16
|
const card = host.querySelector<HTMLElement>('[draggable="true"]');
|
|
12
17
|
if (!card) throw new Error("composition card did not render");
|
|
@@ -14,6 +19,7 @@ function hoverPreview() {
|
|
|
14
19
|
card.dispatchEvent(new Event("pointerover", { bubbles: true }));
|
|
15
20
|
vi.advanceTimersByTime(300);
|
|
16
21
|
});
|
|
22
|
+
await settleFrameToken();
|
|
17
23
|
const iframe = host.querySelector("iframe");
|
|
18
24
|
if (!iframe) throw new Error("hover preview did not mount");
|
|
19
25
|
// Stand-in for the frame's window. The document getter throws, as reading into
|
|
@@ -48,23 +54,37 @@ let consoleError: ReturnType<typeof vi.spyOn>;
|
|
|
48
54
|
beforeEach(() => {
|
|
49
55
|
vi.useFakeTimers();
|
|
50
56
|
consoleError = vi.spyOn(console, "error").mockImplementation(() => {});
|
|
57
|
+
stubFrameTokenFetch();
|
|
51
58
|
});
|
|
52
59
|
|
|
53
60
|
afterEach(() => {
|
|
61
|
+
vi.restoreAllMocks();
|
|
54
62
|
consoleError.mockRestore();
|
|
55
63
|
vi.useRealTimers();
|
|
56
64
|
});
|
|
57
65
|
|
|
58
66
|
describe("composition card hover preview", () => {
|
|
59
|
-
it("frames the composition in an opaque origin", () => {
|
|
60
|
-
const { iframe } = hoverPreview();
|
|
67
|
+
it("frames the composition in an opaque origin, at the project's token path", async () => {
|
|
68
|
+
const { iframe } = await hoverPreview();
|
|
69
|
+
expect(iframe.getAttribute("src")).toBe(
|
|
70
|
+
`/api/projects/demo/preview/~${FRAME_TOKEN}/comp/compositions/headline.html`,
|
|
71
|
+
);
|
|
61
72
|
expect(iframe.getAttribute("sandbox")).toBe("allow-scripts");
|
|
62
73
|
expect(iframe.sandbox.contains("allow-scripts")).toBe(true);
|
|
63
74
|
expect(iframe.sandbox.contains("allow-same-origin")).toBe(false);
|
|
64
75
|
});
|
|
65
76
|
|
|
66
|
-
it("
|
|
67
|
-
|
|
77
|
+
it("falls back to the plain path when the token is unavailable", async () => {
|
|
78
|
+
vi.restoreAllMocks();
|
|
79
|
+
stubFrameTokenFetch(null);
|
|
80
|
+
const { iframe } = await hoverPreview();
|
|
81
|
+
expect(iframe.getAttribute("src")).toBe(
|
|
82
|
+
"/api/projects/demo/preview/comp/compositions/headline.html",
|
|
83
|
+
);
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
it("plays muted over the runtime bridge once the runtime is listening", async () => {
|
|
87
|
+
const { frameWindow } = await hoverPreview();
|
|
68
88
|
expect(frameWindow.postMessage).not.toHaveBeenCalled();
|
|
69
89
|
|
|
70
90
|
fromFrame(frameWindow, { type: "ready" });
|
|
@@ -79,8 +99,8 @@ describe("composition card hover preview", () => {
|
|
|
79
99
|
}
|
|
80
100
|
});
|
|
81
101
|
|
|
82
|
-
it("sizes the stage from the runtime's timeline message", () => {
|
|
83
|
-
const { iframe, frameWindow } = hoverPreview();
|
|
102
|
+
it("sizes the stage from the runtime's timeline message", async () => {
|
|
103
|
+
const { iframe, frameWindow } = await hoverPreview();
|
|
84
104
|
expect([iframe.style.width, iframe.style.height]).toEqual(["1920px", "1080px"]);
|
|
85
105
|
|
|
86
106
|
fromFrame(frameWindow, { type: "timeline", compositionWidth: 1080, compositionHeight: 1920 });
|
|
@@ -88,8 +108,8 @@ describe("composition card hover preview", () => {
|
|
|
88
108
|
expect([iframe.style.width, iframe.style.height]).toEqual(["1080px", "1920px"]);
|
|
89
109
|
});
|
|
90
110
|
|
|
91
|
-
it("ignores runtime messages that come from another window", () => {
|
|
92
|
-
const { iframe, frameWindow } = hoverPreview();
|
|
111
|
+
it("ignores runtime messages that come from another window", async () => {
|
|
112
|
+
const { iframe, frameWindow } = await hoverPreview();
|
|
93
113
|
|
|
94
114
|
fromFrame({ postMessage: vi.fn() }, { type: "ready" });
|
|
95
115
|
fromFrame(window, { type: "timeline", compositionWidth: 640, compositionHeight: 640 });
|
|
@@ -8,7 +8,7 @@ import { TIMELINE_VIEWPORT_BUDGETS } from "../../player/lib/timelineViewportBudg
|
|
|
8
8
|
import { CompositionThumbnail } from "../../player/components/CompositionThumbnail";
|
|
9
9
|
import { usePlayerStore } from "../../player/store/playerStore";
|
|
10
10
|
import { renderPosterForNextOpen } from "../nle/PreviewPoster";
|
|
11
|
-
import { mountCompositionsTab } from "./compositionsTabTestUtils";
|
|
11
|
+
import { mountCompositionsTab, settleFrameToken } from "./compositionsTabTestUtils";
|
|
12
12
|
|
|
13
13
|
class DecodingImage {
|
|
14
14
|
onload: (() => void) | null = null;
|
|
@@ -247,7 +247,7 @@ describe("composition card thumbnails", () => {
|
|
|
247
247
|
expect(URL.revokeObjectURL).not.toHaveBeenCalledWith("blob:frame-2");
|
|
248
248
|
});
|
|
249
249
|
|
|
250
|
-
it("tell a hover preview how large it shows, so its videos are not copied at source size", () => {
|
|
250
|
+
it("tell a hover preview how large it shows, so its videos are not copied at source size", async () => {
|
|
251
251
|
vi.useFakeTimers();
|
|
252
252
|
try {
|
|
253
253
|
const host = mount();
|
|
@@ -258,6 +258,8 @@ describe("composition card thumbnails", () => {
|
|
|
258
258
|
);
|
|
259
259
|
});
|
|
260
260
|
act(() => vi.advanceTimersByTime(300));
|
|
261
|
+
renders.at(-1)!.answer(404); // the hover preview's frame-token request
|
|
262
|
+
await settleFrameToken();
|
|
261
263
|
const frame = host.querySelector("iframe")!;
|
|
262
264
|
const postMessage = vi.fn();
|
|
263
265
|
Object.defineProperty(frame, "contentWindow", { value: { postMessage } });
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { buildProjectApiPath } from "../../utils/projectRouting";
|
|
2
|
+
import { studioApiFetch } from "../../utils/studioApiFetch";
|
|
2
3
|
import { memo, useEffect, useLayoutEffect, useMemo, useRef, useState } from "react";
|
|
3
4
|
import { useThumbnailLease } from "../../hooks/useThumbnailLease";
|
|
4
5
|
import {
|
|
@@ -61,6 +62,30 @@ function compositionPreviewUrl(projectId: string, comp: string): string {
|
|
|
61
62
|
return buildProjectApiPath(projectId, `/preview/comp/${encodePreviewPath(comp)}`);
|
|
62
63
|
}
|
|
63
64
|
|
|
65
|
+
function framePreviewUrl(projectId: string, comp: string, frameToken: string | null): string {
|
|
66
|
+
const tokenPrefix = frameToken ? `/~${frameToken}` : "";
|
|
67
|
+
return buildProjectApiPath(projectId, `/preview${tokenPrefix}/comp/${encodePreviewPath(comp)}`);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
function useFreshFrameToken(projectId: string, wanted: boolean): string | null | undefined {
|
|
71
|
+
const [known, setKnown] = useState<{ token: string | null } | undefined>(undefined);
|
|
72
|
+
useEffect(() => {
|
|
73
|
+
if (!wanted) return setKnown(undefined);
|
|
74
|
+
let live = true;
|
|
75
|
+
void studioApiFetch(buildProjectApiPath(projectId, "/frame-token"))
|
|
76
|
+
.then((res) => (res.ok ? res.json() : null))
|
|
77
|
+
.then((body: { token?: unknown } | null) =>
|
|
78
|
+
typeof body?.token === "string" ? body.token : null,
|
|
79
|
+
)
|
|
80
|
+
.catch(() => null)
|
|
81
|
+
.then((token) => live && setKnown({ token }));
|
|
82
|
+
return () => {
|
|
83
|
+
live = false;
|
|
84
|
+
};
|
|
85
|
+
}, [projectId, wanted]);
|
|
86
|
+
return known?.token;
|
|
87
|
+
}
|
|
88
|
+
|
|
64
89
|
export function compositionCardThumbnailUrl(
|
|
65
90
|
projectId: string,
|
|
66
91
|
comp: string,
|
|
@@ -173,7 +198,7 @@ function CompCard({
|
|
|
173
198
|
setLivePreviewLoaded(false);
|
|
174
199
|
};
|
|
175
200
|
const name = comp.replace(/^compositions\//, "").replace(/\.html$/, "");
|
|
176
|
-
const
|
|
201
|
+
const frameToken = useFreshFrameToken(projectId, hovered);
|
|
177
202
|
const thumbnailUrl = compositionCardThumbnailUrl(projectId, comp, contentRevision);
|
|
178
203
|
const [thumbnailBox, nearViewport] = useNearViewport<HTMLDivElement>();
|
|
179
204
|
const timelineSessionEpoch = usePlayerStore((state) => state.timelineSessionEpoch);
|
|
@@ -287,10 +312,10 @@ function CompCard({
|
|
|
287
312
|
}`}
|
|
288
313
|
/>
|
|
289
314
|
)}
|
|
290
|
-
{hovered && (
|
|
315
|
+
{hovered && frameToken !== undefined && (
|
|
291
316
|
<iframe
|
|
292
317
|
ref={iframeRef}
|
|
293
|
-
src={
|
|
318
|
+
src={framePreviewUrl(projectId, comp, frameToken)}
|
|
294
319
|
sandbox={OPAQUE_ORIGIN_SCRIPTS_ONLY_SANDBOX}
|
|
295
320
|
className="absolute border-none pointer-events-none"
|
|
296
321
|
style={{
|