@hyperframes/studio 0.9.53 → 0.9.55

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (30) hide show
  1. package/dist/assets/{hyperframes-player-z7r-N5fm.js → hyperframes-player-BroIQA4E.js} +1 -1
  2. package/dist/assets/{index-Dpo7Q_9-.js → index-Be7DZynj.js} +154 -154
  3. package/dist/assets/{index-2QPHxCxy.js → index-CiF0D62S.js} +1 -1
  4. package/dist/assets/{pausedVideoDecoder-BarDYEAf.js → pausedVideoDecoder-RXcvblHS.js} +1 -1
  5. package/dist/{chunk-F6EHWNZU.js → chunk-JMM2CSEL.js} +121 -94
  6. package/dist/{chunk-VHV2ZDKY.js → chunk-OOGQ5KCC.js} +7 -0
  7. package/dist/{chunk-GVW7AU57.js → chunk-UM4CLD4M.js} +1 -1
  8. package/dist/{domEditingLayers-SA5KLSSS.js → domEditingLayers-IHYA42AJ.js} +2 -2
  9. package/dist/index.d.ts +8 -2
  10. package/dist/index.html +1 -1
  11. package/dist/index.js +65 -21
  12. package/dist/player.d.ts +1 -0
  13. package/dist/player.js +2 -2
  14. package/package.json +8 -8
  15. package/src/components/editor/gsapLivePreview.test.ts +19 -0
  16. package/src/components/editor/gsapLivePreview.ts +2 -0
  17. package/src/components/editor/manualEditingAvailability.ts +7 -0
  18. package/src/components/nle/NLEPreview.test.ts +25 -0
  19. package/src/components/nle/NLEPreview.tsx +5 -0
  20. package/src/components/nle/PreviewPane.tsx +2 -0
  21. package/src/components/sidebar/CompositionsTab.tsx +4 -8
  22. package/src/hooks/gsapParsedTween.test.ts +19 -0
  23. package/src/hooks/gsapParsedTween.ts +3 -1
  24. package/src/hooks/useConsoleErrorCapture.test.tsx +69 -1
  25. package/src/hooks/useConsoleErrorCapture.ts +47 -11
  26. package/src/index.ts +1 -0
  27. package/src/player/components/Player.test.ts +55 -0
  28. package/src/player/components/Player.tsx +13 -4
  29. package/src/player/lib/frameToken.ts +20 -0
  30. package/src/player/lib/previewChannel.ts +10 -0
@@ -1,4 +1,4 @@
1
- import{n as an}from"./index-Dpo7Q_9-.js";/*!
1
+ import{n as an}from"./index-Be7DZynj.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{Input as V,ALL_FORMATS as G,UrlSource as K,VideoSampleSink as Q}from"./index-2QPHxCxy.js";import{l as X}from"./index-Dpo7Q_9-.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};
1
+ import{Input as V,ALL_FORMATS as G,UrlSource as K,VideoSampleSink as Q}from"./index-CiF0D62S.js";import{l as X}from"./index-Be7DZynj.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};
@@ -5,7 +5,7 @@ import {
5
5
  buildProjectApiPath,
6
6
  splitTimelineElementKey,
7
7
  studioApiFetch
8
- } from "./chunk-VHV2ZDKY.js";
8
+ } from "./chunk-OOGQ5KCC.js";
9
9
 
10
10
  // src/player/lib/time.ts
11
11
  var STUDIO_PREVIEW_FPS = 30;
@@ -1113,6 +1113,101 @@ function whenPreviewBooted(projectId) {
1113
1113
  });
1114
1114
  }
1115
1115
 
1116
+ // src/player/lib/previewChannel.ts
1117
+ import {
1118
+ createEditingPortClient
1119
+ } from "@hyperframes/core/runtime/editing-port";
1120
+ var clients = /* @__PURE__ */ new WeakMap();
1121
+ var loopStarts = /* @__PURE__ */ new WeakMap();
1122
+ function previewFrameOpaque(iframe) {
1123
+ const win = iframe.contentWindow;
1124
+ if (!win) return false;
1125
+ try {
1126
+ void win.document;
1127
+ return false;
1128
+ } catch {
1129
+ return true;
1130
+ }
1131
+ }
1132
+ function previewEditingClient(iframe) {
1133
+ const open = clients.get(iframe);
1134
+ if (open) return open;
1135
+ const client = createEditingPortClient({ iframe });
1136
+ clients.set(iframe, client);
1137
+ const onLoad = () => {
1138
+ client.dispose();
1139
+ if (clients.get(iframe) === client) clients.delete(iframe);
1140
+ };
1141
+ iframe.addEventListener("load", onLoad, { once: true });
1142
+ return client;
1143
+ }
1144
+ function setFrameLoopStart(iframe, seconds) {
1145
+ if (!previewFrameOpaque(iframe)) {
1146
+ try {
1147
+ iframe.contentWindow?.__hf?.setLoopStart?.(seconds);
1148
+ } catch {
1149
+ }
1150
+ return;
1151
+ }
1152
+ const client = previewEditingClient(iframe);
1153
+ if (loopStarts.has(client) && loopStarts.get(client) === seconds) return;
1154
+ loopStarts.set(client, seconds);
1155
+ client.request("set-loop-start", { seconds }).catch(() => {
1156
+ if (loopStarts.get(client) === seconds) loopStarts.delete(client);
1157
+ });
1158
+ }
1159
+ var AGENT_PROBE_MS = 1e3;
1160
+ async function agentConnected(client) {
1161
+ let timer;
1162
+ const probe = new Promise(
1163
+ (resolve) => timer = setTimeout(resolve, AGENT_PROBE_MS, false)
1164
+ );
1165
+ const connected = await Promise.race([
1166
+ client.ready.then(
1167
+ () => true,
1168
+ () => false
1169
+ ),
1170
+ probe
1171
+ ]);
1172
+ clearTimeout(timer);
1173
+ return connected;
1174
+ }
1175
+ async function previewRequest(iframe, kind, params, timeoutMs) {
1176
+ const client = previewEditingClient(iframe);
1177
+ if (!await agentConnected(client)) return null;
1178
+ return client.request(kind, params, { timeoutMs }).catch(() => null);
1179
+ }
1180
+ async function previewSeekPainted(iframe, timeoutMs) {
1181
+ await previewRequest(iframe, "wait-for-seek", {}, timeoutMs);
1182
+ }
1183
+ async function previewClipManifest(iframe) {
1184
+ const snapshot = await previewRequest(iframe, "runtime-snapshot", {});
1185
+ const manifest = snapshot?.clipManifest;
1186
+ if (typeof manifest !== "object" || manifest === null) return null;
1187
+ const { clips, durationInFrames } = manifest;
1188
+ if (!Array.isArray(clips) || typeof durationInFrames !== "number") return null;
1189
+ if (!Number.isFinite(durationInFrames)) return null;
1190
+ return manifest;
1191
+ }
1192
+ async function previewConsoleErrors(iframe, from) {
1193
+ const reply = await previewRequest(iframe, "console-errors", { from });
1194
+ const errors = reply?.errors;
1195
+ if (!Array.isArray(errors) || typeof reply?.truncated !== "boolean") return null;
1196
+ return { errors: errors.map(String), truncated: reply.truncated };
1197
+ }
1198
+ async function previewComputedStyles(iframe, target, properties) {
1199
+ const element = typeof target === "string" ? { selector: target } : { handle: target.handle };
1200
+ const reply = await previewRequest(iframe, "computed-styles", { ...element, properties });
1201
+ const styles = reply?.styles;
1202
+ if (typeof styles !== "object" || styles === null) return null;
1203
+ const read = {};
1204
+ for (const name of properties) {
1205
+ const value = Object.getOwnPropertyDescriptor(styles, name)?.value;
1206
+ if (typeof value === "string" && value) read[name] = value;
1207
+ }
1208
+ return read;
1209
+ }
1210
+
1116
1211
  // src/utils/studioFileVersion.ts
1117
1212
  var WRITE_TOKEN_TTL_MS = 5 * 6e4;
1118
1213
  var studioWriteTokens = /* @__PURE__ */ new Map();
@@ -1689,95 +1784,6 @@ function isPreviewChanging() {
1689
1784
  return changing() && !givenUp;
1690
1785
  }
1691
1786
 
1692
- // src/player/lib/previewChannel.ts
1693
- import {
1694
- createEditingPortClient
1695
- } from "@hyperframes/core/runtime/editing-port";
1696
- var clients = /* @__PURE__ */ new WeakMap();
1697
- var loopStarts = /* @__PURE__ */ new WeakMap();
1698
- function previewFrameOpaque(iframe) {
1699
- const win = iframe.contentWindow;
1700
- if (!win) return false;
1701
- try {
1702
- void win.document;
1703
- return false;
1704
- } catch {
1705
- return true;
1706
- }
1707
- }
1708
- function previewEditingClient(iframe) {
1709
- const open = clients.get(iframe);
1710
- if (open) return open;
1711
- const client = createEditingPortClient({ iframe });
1712
- clients.set(iframe, client);
1713
- const onLoad = () => {
1714
- client.dispose();
1715
- if (clients.get(iframe) === client) clients.delete(iframe);
1716
- };
1717
- iframe.addEventListener("load", onLoad, { once: true });
1718
- return client;
1719
- }
1720
- function setFrameLoopStart(iframe, seconds) {
1721
- if (!previewFrameOpaque(iframe)) {
1722
- try {
1723
- iframe.contentWindow?.__hf?.setLoopStart?.(seconds);
1724
- } catch {
1725
- }
1726
- return;
1727
- }
1728
- const client = previewEditingClient(iframe);
1729
- if (loopStarts.has(client) && loopStarts.get(client) === seconds) return;
1730
- loopStarts.set(client, seconds);
1731
- client.request("set-loop-start", { seconds }).catch(() => {
1732
- if (loopStarts.get(client) === seconds) loopStarts.delete(client);
1733
- });
1734
- }
1735
- var AGENT_PROBE_MS = 1e3;
1736
- async function agentConnected(client) {
1737
- let timer;
1738
- const probe = new Promise(
1739
- (resolve) => timer = setTimeout(resolve, AGENT_PROBE_MS, false)
1740
- );
1741
- const connected = await Promise.race([
1742
- client.ready.then(
1743
- () => true,
1744
- () => false
1745
- ),
1746
- probe
1747
- ]);
1748
- clearTimeout(timer);
1749
- return connected;
1750
- }
1751
- async function previewRequest(iframe, kind, params, timeoutMs) {
1752
- const client = previewEditingClient(iframe);
1753
- if (!await agentConnected(client)) return null;
1754
- return client.request(kind, params, { timeoutMs }).catch(() => null);
1755
- }
1756
- async function previewSeekPainted(iframe, timeoutMs) {
1757
- await previewRequest(iframe, "wait-for-seek", {}, timeoutMs);
1758
- }
1759
- async function previewClipManifest(iframe) {
1760
- const snapshot = await previewRequest(iframe, "runtime-snapshot", {});
1761
- const manifest = snapshot?.clipManifest;
1762
- if (typeof manifest !== "object" || manifest === null) return null;
1763
- const { clips, durationInFrames } = manifest;
1764
- if (!Array.isArray(clips) || typeof durationInFrames !== "number") return null;
1765
- if (!Number.isFinite(durationInFrames)) return null;
1766
- return manifest;
1767
- }
1768
- async function previewComputedStyles(iframe, target, properties) {
1769
- const element = typeof target === "string" ? { selector: target } : { handle: target.handle };
1770
- const reply = await previewRequest(iframe, "computed-styles", { ...element, properties });
1771
- const styles = reply?.styles;
1772
- if (typeof styles !== "object" || styles === null) return null;
1773
- const read = {};
1774
- for (const name of properties) {
1775
- const value = Object.getOwnPropertyDescriptor(styles, name)?.value;
1776
- if (typeof value === "string" && value) read[name] = value;
1777
- }
1778
- return read;
1779
- }
1780
-
1781
1787
  // src/player/sceneSwap.ts
1782
1788
  var SCENES_SWAPPED = "hf-scenes-swapped";
1783
1789
  var SCENE_SWAP_MS = 5e3;
@@ -2062,6 +2068,20 @@ function bridgePlaybackAdapter(iframe) {
2062
2068
  };
2063
2069
  }
2064
2070
 
2071
+ // src/player/lib/frameToken.ts
2072
+ var PREVIEW_PATH = /^(\/api\/projects\/[^/?#]+)\/preview(?:\/~[\w-]{43})?(?=[/?#]|$)/;
2073
+ function fetchFrameToken(frameTokenPath) {
2074
+ return studioApiFetch(frameTokenPath).then((res) => res.ok ? res.json() : null).then(
2075
+ (body) => typeof body?.token === "string" ? body.token : null
2076
+ ).catch(() => null);
2077
+ }
2078
+ async function previewUnderFrameToken(src) {
2079
+ const project = PREVIEW_PATH.exec(src)?.[1];
2080
+ if (!project) return src;
2081
+ const token = await fetchFrameToken(`${project}/frame-token`);
2082
+ return token ? src.replace(PREVIEW_PATH, `$1/preview/~${token}`) : src;
2083
+ }
2084
+
2065
2085
  // src/player/components/Player.tsx
2066
2086
  import { jsx, jsxs } from "react/jsx-runtime";
2067
2087
  var playerModule = null;
@@ -2132,6 +2152,12 @@ function hasUnloadedAssets(iframe, lastResult) {
2132
2152
  return lastResult;
2133
2153
  }
2134
2154
  }
2155
+ async function playerSrc(previewSource, opaque) {
2156
+ const url = new URL(previewSource, window.location.origin);
2157
+ applyPreviewVariablesToUrl(url);
2158
+ const src = url.pathname + url.search;
2159
+ return opaque ? previewUnderFrameToken(src) : src;
2160
+ }
2135
2161
  var runtimeBootedIn = (iframe) => iframe.contentWindow?.__playerReady === true;
2136
2162
  var Player = forwardRef(
2137
2163
  ({
@@ -2190,12 +2216,10 @@ var Player = forwardRef(
2190
2216
  if (!previewSource) return;
2191
2217
  let canceled = false;
2192
2218
  let cleanup;
2193
- void loadPlayerModule().then(() => {
2219
+ const opaque = host.sandboxOrigin === "opaque";
2220
+ void Promise.all([loadPlayerModule(), playerSrc(previewSource, opaque)]).then(([, src]) => {
2194
2221
  if (canceled) return;
2195
2222
  const player = document.createElement("hyperframes-player");
2196
- const srcUrl = new URL(previewSource, window.location.origin);
2197
- applyPreviewVariablesToUrl(srcUrl);
2198
- const src = srcUrl.pathname + srcUrl.search;
2199
2223
  const retryPreview = () => {
2200
2224
  retryCountRef.current += 1;
2201
2225
  const retryUrl = new URL(src, window.location.origin);
@@ -2288,6 +2312,7 @@ var Player = forwardRef(
2288
2312
  player.setAttribute("shader-loading", "player");
2289
2313
  player.setAttribute("low-power-idle", "");
2290
2314
  player.toggleAttribute("no-load-timeout", noLoadTimeout === true);
2315
+ player.toggleAttribute("sandbox-origin", opaque);
2291
2316
  player.setAttribute("width", String(portrait ? 1080 : 1920));
2292
2317
  player.setAttribute("height", String(portrait ? 1920 : 1080));
2293
2318
  player.style.width = "100%";
@@ -2557,6 +2582,7 @@ export {
2557
2582
  previewRequest,
2558
2583
  previewSeekPainted,
2559
2584
  previewClipManifest,
2585
+ previewConsoleErrors,
2560
2586
  previewComputedStyles,
2561
2587
  announcePreviewDocumentLoaded,
2562
2588
  onPreviewDocumentLoaded,
@@ -2575,5 +2601,6 @@ export {
2575
2601
  previewStageSize,
2576
2602
  frameOrigins,
2577
2603
  bridgePlaybackAdapter,
2604
+ fetchFrameToken,
2578
2605
  Player
2579
2606
  };
@@ -963,6 +963,7 @@ var manualEditingAvailability_exports = {};
963
963
  __export(manualEditingAvailability_exports, {
964
964
  STUDIO_API_SAME_ORIGIN_CREDENTIALS: () => STUDIO_API_SAME_ORIGIN_CREDENTIALS,
965
965
  STUDIO_FLAT_INSPECTOR_ENABLED: () => STUDIO_FLAT_INSPECTOR_ENABLED,
966
+ STUDIO_OPAQUE_PREVIEW_ENABLED: () => STUDIO_OPAQUE_PREVIEW_ENABLED,
966
967
  STUDIO_SDK_CUTOVER_ENABLED: () => STUDIO_SDK_CUTOVER_ENABLED,
967
968
  STUDIO_SDK_CUTOVER_FAMILIES: () => STUDIO_SDK_CUTOVER_FAMILIES,
968
969
  STUDIO_SDK_RESOLVER_SHADOW_ENABLED: () => STUDIO_SDK_RESOLVER_SHADOW_ENABLED,
@@ -1034,6 +1035,11 @@ var STUDIO_API_SAME_ORIGIN_CREDENTIALS = resolveStudioBooleanEnvFlag(
1034
1035
  ["VITE_STUDIO_API_SAME_ORIGIN_CREDENTIALS"],
1035
1036
  false
1036
1037
  );
1038
+ var STUDIO_OPAQUE_PREVIEW_ENABLED = resolveStudioBooleanEnvFlag(
1039
+ env,
1040
+ ["VITE_STUDIO_OPAQUE_PREVIEW_ENABLED"],
1041
+ false
1042
+ );
1037
1043
 
1038
1044
  // src/utils/studioApiFetch.ts
1039
1045
  var LOOPBACK_HOSTS = /* @__PURE__ */ new Set(["localhost", "127.0.0.1", "[::1]"]);
@@ -1122,6 +1128,7 @@ export {
1122
1128
  STUDIO_SDK_CUTOVER_FAMILIES,
1123
1129
  STUDIO_SDK_RESOLVER_SHADOW_ENABLED,
1124
1130
  STUDIO_FLAT_INSPECTOR_ENABLED,
1131
+ STUDIO_OPAQUE_PREVIEW_ENABLED,
1125
1132
  manualEditingAvailability_exports,
1126
1133
  studioApiFetch
1127
1134
  };
@@ -18,7 +18,7 @@ import {
18
18
  querySelectorAllSafely,
19
19
  studioApiFetch,
20
20
  withSelectorIndexPass
21
- } from "./chunk-VHV2ZDKY.js";
21
+ } from "./chunk-OOGQ5KCC.js";
22
22
 
23
23
  // src/components/editor/domEditingLayers.ts
24
24
  import { isClipHiddenByRuntime, PREVIEW_ONLY_ATTRS } from "@hyperframes/core/studio-preview-mark";
@@ -20,8 +20,8 @@ import {
20
20
  resolveDomEditCapabilities,
21
21
  resolveDomEditSelection,
22
22
  serializeDomEditTextFields
23
- } from "./chunk-GVW7AU57.js";
24
- import "./chunk-VHV2ZDKY.js";
23
+ } from "./chunk-UM4CLD4M.js";
24
+ import "./chunk-OOGQ5KCC.js";
25
25
  import "./chunk-MLKGABMK.js";
26
26
  export {
27
27
  buildDefaultDomEditTextField,
package/dist/index.d.ts CHANGED
@@ -4,7 +4,7 @@ import { RefObject, MutableRefObject, ReactNode, DragEventHandler, ComponentProp
4
4
  import { RuntimeTimelineClipIdentity, PlaybackHeldBy, HyperframePickerElementInfo } from '@hyperframes/core';
5
5
  import { GsapAnimation, ParsedGsap, PropertyGroupName } from '@hyperframes/core/gsap-parser';
6
6
  import { GsapAnimation as GsapAnimation$1, ArcPathSegment } from '@hyperframes/parsers/gsap-parser';
7
- import { EditingElementHandle, LayerKind } from '@hyperframes/core/runtime/editing-port';
7
+ import { EditingElementHandle, LayerKind, EditingPortClient } from '@hyperframes/core/runtime/editing-port';
8
8
  import { Composition } from '@hyperframes/sdk';
9
9
  import * as react_jsx_runtime from 'react/jsx-runtime';
10
10
  import { StudioKeys, StudioKeyAction } from './keys.js';
@@ -2264,6 +2264,7 @@ interface NLEPreviewProps extends Pick<NLEContextValue, "projectId" | "onIframeL
2264
2264
  /** Draws the picture edge to edge in this box, without Studio's inset band. */
2265
2265
  fillBox?: boolean;
2266
2266
  compositionSizeHint?: PreviewCompositionSize;
2267
+ sandboxOrigin?: "opaque";
2267
2268
  }
2268
2269
  declare const NLEPreview: react.NamedExoticComponent<NLEPreviewProps>;
2269
2270
 
@@ -2369,6 +2370,11 @@ interface PreviewIframeState {
2369
2370
  /** The one owner of "the live preview iframe element"; a promoted reload replaces it. */
2370
2371
  declare const usePreviewIframeStore: zustand.UseBoundStore<zustand.StoreApi<PreviewIframeState>>;
2371
2372
 
2373
+ /** A frame whose window refuses Studio's reads; one with no window has nothing to reach either way. */
2374
+ declare function previewFrameOpaque(iframe: HTMLIFrameElement): boolean;
2375
+ /** One client per frame load: the frame's next load disposes it. */
2376
+ declare function previewEditingClient(iframe: HTMLIFrameElement): EditingPortClient;
2377
+
2372
2378
  interface AudioGainDialogState {
2373
2379
  targetKeys: readonly string[] | null;
2374
2380
  open: (keys: readonly string[]) => void;
@@ -4411,4 +4417,4 @@ declare function buildStudioTools(depsRef: {
4411
4417
  readonly current: StudioAgentToolsDeps;
4412
4418
  }): ModelContextTool[];
4413
4419
 
4414
- export { type AgentModalAnchorPoint, type AgentPromptElementInfo, AskAgentModal, type AskAgentModalProps, AudioMeterStrip, type AudioMeterStripProps, AudioWaveform, type AudioWaveformProps, type BlockedTimelineEditIntent, type CanEditTimelineElement, ColorField, CompositionBreadcrumb, type CompositionDimensions, type CompositionLevel, CompositionThumbnail, ConnectedDomEditOverlay, type ConnectedDomEditOverlayProps, DEFAULT_SHORTCUT_SECTIONS, Dock, type DockController, type DomEditCapabilities, type DomEditCommitDeclineReason, type DomEditCommitOutcome, type DomEditGroupPathOffsetCommit, DomEditOverlay, type DomEditOverlayProps, DomEditProvider, type DomEditSelection, type DomEditZOrder, type DomGeometryCommits, type EditHistoryHandle, EditorShell, type EditorShellProps, type ExternalFileChangeBlockedState, type ExternalFileChangeCoordinatorHandle, ExternalFileConflictBanner, type FadeEdge, type FadeHandleBox, type FadeHandleClipBox, type FfmpegStatus, FileTree, GradientField, GridOverlay, ImageThumbnail, type ImageThumbnailProps, LayersPanel, type LayersPanelHost, type LinkShortcutCallbacks, type MarqueeBand, type MarqueeGestures, type MarqueeGesturesDeps, MarqueeOverlay, type MarqueeOverlayProps, type Rect$1 as MarqueeRect, type MarqueeSelectionMode, type ModelContextTool, NLEPreview, type PanelId, type PatchOperation, type PersistedRenderSettings, type PickedElement, type PlaybackHealth, PlayerControls, type PlayerHandle, type PlayerHandleElement, type PlayerHandleListener, type PlayerHandleTimeListener, type DomEditCompositionRect as PreviewCompositionRect, type PreviewCopies, type PreviewFacts, PreviewGuides, PreviewOverlayProvider, type PreviewOverlayProviderProps, type PreviewPromotion, type PreviewQualityChosenBy, PreviewReadOnlyProvider, type PreviewSnapPreferences, PropertyPanel, type RenderJob, RenderQueue, type RenderQueueProps, type ResolutionPreset, SNAP_THRESHOLD_PX, type ShortcutHint, type ShortcutSection, ShortcutsButton, type ShortcutsButtonProps, type SnapContext, type SnapEdge, type SnapGuide, SnapGuideOverlay, type SnapGuideOverlayProps, type SnapGuidesState, type Rect as SnapRect, type SnapResult, type SnapTarget, SnapToolbar, SourceEditor, type SpacingGuide, type StartRenderOptions, type StudioAgentToolsDeps, StudioApp, StudioFileConflictError, StudioKeyAction, StudioKeys, type StudioLookSnapshot, type StudioPendingEditsDrainResult, TRACK_H, type ThumbnailPriority, type ThumbnailStill, Timeline, TimelineClipMenu, type TimelineClipMenuItem, type TimelineClipRenderContext, type TimelineEditCallbacks, type TimelineEditOutcome, type TimelineEditPermission, TimelineEditPopover, TimelineEditProvider, type TimelineElement, TimelineEmptyStatePart, TimelineFrame, TimelineGapMenu, TimelineHistoryButtons, type TimelineHistoryButtonsProps, TimelineKeyframeMenu, TimelineLanes, TimelineOverlays, TimelinePane, type TimelinePaneProps, TimelinePlayhead, TimelineProvider, TimelineRazorGuide, TimelineRuler, TimelineShortcutHint, type TimelineTheme, type TimelineTimeRange$1 as TimelineTimeRange, TimelineToolbar, type TimelineToolbarProps, type TimelineTrackPadding, type TimelineZIndexReorderCommit, type ToolResult, type UseClipboardOptions, type UseDomEditSessionParams, type UseDomGeometryCommitOptions, type UseDomStyleCommitOptions, type UseEditHistoryActionsOptions, type UsePersistentEditHistoryOptions, type UsePreviewPersistenceParams, type UseProjectFileWriterOptions, type UseRenderClipContentOptions, type UseThumbnailStillOptions, type UseTimelineEditingOptions, VideoThumbnail, type ZOrderAction, announcePreviewDocumentLoaded, applyPatch, buildCompositionSnapTarget, buildGridSnapEdges, buildPickerAgentContextPreview, buildPickerAgentPrompt, buildShortcutSections, buildStudioTools, cancelNewestStudioWaitingPress, collectSnapContext, collectStudioLookScene, currentTimelineRange, dispatchLinkShortcut, displayTrackOrder, extractSnapTargets, fadeHandleBoxes, findElementBlock, flushStudioPendingEdits, formatTime, getPersistedRenderSettings, getStudioKeys, liveTime, mergeStyleIntoTag, openAudioGainDialog, parseStyleString, persistRenderSettings, resolveDomEditSelection, resolveEquidistanceGuides, resolveGuideLineRect, resolveIframe, resolveMarqueeMode, resolveSnapAdjustment, resolveSourceFile, revertNewestStudioPendingEdit, setStudioKeys, snapEngagedForTravel, studioKeyClash, useAudioGainDialogStore, useAudioMetersVisible, useClipboard, useCompositionStack, useDockLayoutStore, useDomEditSelectionContext, useDomEditSession, useDomEditZOrder, useDomGeometryCommit, useDomStyleCommit, useEditHistoryActions, useElementPicker, useLivePreviewIframe, useMarqueeGestures, usePersistentEditHistory, usePlayerHandle, usePlayerStore, usePreviewCompositionRect, usePreviewGuidesStore, usePreviewIframeStore, usePreviewOverlayContext, usePreviewPersistence, useProjectFileWriter, useRenderClipContent, useRenderQueue, useStudioKeys, useThumbnailStill, useTimelineContext, useTimelineEditing, useTimelinePlayer, zoomTimelineToRange };
4420
+ export { type AgentModalAnchorPoint, type AgentPromptElementInfo, AskAgentModal, type AskAgentModalProps, AudioMeterStrip, type AudioMeterStripProps, AudioWaveform, type AudioWaveformProps, type BlockedTimelineEditIntent, type CanEditTimelineElement, ColorField, CompositionBreadcrumb, type CompositionDimensions, type CompositionLevel, CompositionThumbnail, ConnectedDomEditOverlay, type ConnectedDomEditOverlayProps, DEFAULT_SHORTCUT_SECTIONS, Dock, type DockController, type DomEditCapabilities, type DomEditCommitDeclineReason, type DomEditCommitOutcome, type DomEditGroupPathOffsetCommit, DomEditOverlay, type DomEditOverlayProps, DomEditProvider, type DomEditSelection, type DomEditZOrder, type DomGeometryCommits, type EditHistoryHandle, EditorShell, type EditorShellProps, type ExternalFileChangeBlockedState, type ExternalFileChangeCoordinatorHandle, ExternalFileConflictBanner, type FadeEdge, type FadeHandleBox, type FadeHandleClipBox, type FfmpegStatus, FileTree, GradientField, GridOverlay, ImageThumbnail, type ImageThumbnailProps, LayersPanel, type LayersPanelHost, type LinkShortcutCallbacks, type MarqueeBand, type MarqueeGestures, type MarqueeGesturesDeps, MarqueeOverlay, type MarqueeOverlayProps, type Rect$1 as MarqueeRect, type MarqueeSelectionMode, type ModelContextTool, NLEPreview, type PanelId, type PatchOperation, type PersistedRenderSettings, type PickedElement, type PlaybackHealth, PlayerControls, type PlayerHandle, type PlayerHandleElement, type PlayerHandleListener, type PlayerHandleTimeListener, type DomEditCompositionRect as PreviewCompositionRect, type PreviewCopies, type PreviewFacts, PreviewGuides, PreviewOverlayProvider, type PreviewOverlayProviderProps, type PreviewPromotion, type PreviewQualityChosenBy, PreviewReadOnlyProvider, type PreviewSnapPreferences, PropertyPanel, type RenderJob, RenderQueue, type RenderQueueProps, type ResolutionPreset, SNAP_THRESHOLD_PX, type ShortcutHint, type ShortcutSection, ShortcutsButton, type ShortcutsButtonProps, type SnapContext, type SnapEdge, type SnapGuide, SnapGuideOverlay, type SnapGuideOverlayProps, type SnapGuidesState, type Rect as SnapRect, type SnapResult, type SnapTarget, SnapToolbar, SourceEditor, type SpacingGuide, type StartRenderOptions, type StudioAgentToolsDeps, StudioApp, StudioFileConflictError, StudioKeyAction, StudioKeys, type StudioLookSnapshot, type StudioPendingEditsDrainResult, TRACK_H, type ThumbnailPriority, type ThumbnailStill, Timeline, TimelineClipMenu, type TimelineClipMenuItem, type TimelineClipRenderContext, type TimelineEditCallbacks, type TimelineEditOutcome, type TimelineEditPermission, TimelineEditPopover, TimelineEditProvider, type TimelineElement, TimelineEmptyStatePart, TimelineFrame, TimelineGapMenu, TimelineHistoryButtons, type TimelineHistoryButtonsProps, TimelineKeyframeMenu, TimelineLanes, TimelineOverlays, TimelinePane, type TimelinePaneProps, TimelinePlayhead, TimelineProvider, TimelineRazorGuide, TimelineRuler, TimelineShortcutHint, type TimelineTheme, type TimelineTimeRange$1 as TimelineTimeRange, TimelineToolbar, type TimelineToolbarProps, type TimelineTrackPadding, type TimelineZIndexReorderCommit, type ToolResult, type UseClipboardOptions, type UseDomEditSessionParams, type UseDomGeometryCommitOptions, type UseDomStyleCommitOptions, type UseEditHistoryActionsOptions, type UsePersistentEditHistoryOptions, type UsePreviewPersistenceParams, type UseProjectFileWriterOptions, type UseRenderClipContentOptions, type UseThumbnailStillOptions, type UseTimelineEditingOptions, VideoThumbnail, type ZOrderAction, announcePreviewDocumentLoaded, applyPatch, buildCompositionSnapTarget, buildGridSnapEdges, buildPickerAgentContextPreview, buildPickerAgentPrompt, buildShortcutSections, buildStudioTools, cancelNewestStudioWaitingPress, collectSnapContext, collectStudioLookScene, currentTimelineRange, dispatchLinkShortcut, displayTrackOrder, extractSnapTargets, fadeHandleBoxes, findElementBlock, flushStudioPendingEdits, formatTime, getPersistedRenderSettings, getStudioKeys, liveTime, mergeStyleIntoTag, openAudioGainDialog, parseStyleString, persistRenderSettings, previewEditingClient, previewFrameOpaque, resolveDomEditSelection, resolveEquidistanceGuides, resolveGuideLineRect, resolveIframe, resolveMarqueeMode, resolveSnapAdjustment, resolveSourceFile, revertNewestStudioPendingEdit, setStudioKeys, snapEngagedForTravel, studioKeyClash, useAudioGainDialogStore, useAudioMetersVisible, useClipboard, useCompositionStack, useDockLayoutStore, useDomEditSelectionContext, useDomEditSession, useDomEditZOrder, useDomGeometryCommit, useDomStyleCommit, useEditHistoryActions, useElementPicker, useLivePreviewIframe, useMarqueeGestures, usePersistentEditHistory, usePlayerHandle, usePlayerStore, usePreviewCompositionRect, usePreviewGuidesStore, usePreviewIframeStore, usePreviewOverlayContext, usePreviewPersistence, useProjectFileWriter, useRenderClipContent, useRenderQueue, useStudioKeys, useThumbnailStill, useTimelineContext, useTimelineEditing, useTimelinePlayer, zoomTimelineToRange };
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-Dpo7Q_9-.js"></script>
17
+ <script type="module" crossorigin src="/assets/index-Be7DZynj.js"></script>
18
18
  <link rel="stylesheet" crossorigin href="/assets/index-CRiuMxyq.css">
19
19
  </head>
20
20
  <body>
package/dist/index.js CHANGED
@@ -25,6 +25,7 @@ import {
25
25
  createThumbnailRequestIdentity,
26
26
  createTimelineResetState,
27
27
  effectiveThumbnailMode,
28
+ fetchFrameToken,
28
29
  formatFrameTime,
29
30
  formatTime,
30
31
  frameOrigins,
@@ -59,6 +60,7 @@ import {
59
60
  postRuntimeControlMessage,
60
61
  previewClipManifest,
61
62
  previewComputedStyles,
63
+ previewConsoleErrors,
62
64
  previewEditingClient,
63
65
  previewFrameOpaque,
64
66
  previewReloadBegun,
@@ -89,7 +91,7 @@ import {
89
91
  whileScriptWrites,
90
92
  writeStudioUiPreferences,
91
93
  zoomToSelectedClips
92
- } from "./chunk-F6EHWNZU.js";
94
+ } from "./chunk-JMM2CSEL.js";
93
95
  import {
94
96
  Button,
95
97
  ContextMenu,
@@ -156,12 +158,13 @@ import {
156
158
  selectionTargetIndex,
157
159
  serializeDomEditTextFields,
158
160
  timelineElementLookup
159
- } from "./chunk-GVW7AU57.js";
161
+ } from "./chunk-UM4CLD4M.js";
160
162
  import {
161
163
  CURATED_STYLE_PROPERTIES,
162
164
  LAYER_REVEAL_PRIOR_POSITION_ATTR,
163
165
  LAYER_REVEAL_PRIOR_Z_ATTR,
164
166
  STUDIO_FLAT_INSPECTOR_ENABLED,
167
+ STUDIO_OPAQUE_PREVIEW_ENABLED,
165
168
  STUDIO_SDK_CUTOVER_ENABLED,
166
169
  STUDIO_SDK_CUTOVER_FAMILIES,
167
170
  STUDIO_SDK_RESOLVER_SHADOW_ENABLED,
@@ -230,7 +233,7 @@ import {
230
233
  toHexColor,
231
234
  withSelectorIndexPass,
232
235
  wrapTimeline
233
- } from "./chunk-VHV2ZDKY.js";
236
+ } from "./chunk-OOGQ5KCC.js";
234
237
  import {
235
238
  MediaFetchError,
236
239
  mediaUrlSourceOptions,
@@ -30722,7 +30725,8 @@ function withParsedStart(read2, live) {
30722
30725
  return moved ? { ...read2, start } : read2;
30723
30726
  }
30724
30727
  function findParsedTween(iframe, element, anim) {
30725
- const win = iframe?.contentWindow;
30728
+ if (!iframe || previewFrameOpaque(iframe)) return null;
30729
+ const win = iframe.contentWindow;
30726
30730
  const start = resolveTweenStart(anim);
30727
30731
  if (!win?.__timelines || start == null) return null;
30728
30732
  const steps = anim.keyframes?.keyframes.map((kf) => kf.properties) ?? [anim.properties];
@@ -34163,7 +34167,8 @@ var NLEPreview = memo24(function NLEPreview2({
34163
34167
  onStageRef,
34164
34168
  onCompositionSizeChange,
34165
34169
  fillBox,
34166
- compositionSizeHint
34170
+ compositionSizeHint,
34171
+ sandboxOrigin
34167
34172
  }) {
34168
34173
  const activeKey = getPreviewPlayerKey({ projectId, directUrl });
34169
34174
  const viewportRef = useRef56(null);
@@ -34496,6 +34501,7 @@ var NLEPreview = memo24(function NLEPreview2({
34496
34501
  },
34497
34502
  portrait,
34498
34503
  suppressLoadingOverlay: true,
34504
+ sandboxOrigin,
34499
34505
  style: { position: "absolute", inset: 0, zIndex: 0 }
34500
34506
  },
34501
34507
  `backdrop-${projectId}`
@@ -34519,6 +34525,7 @@ var NLEPreview = memo24(function NLEPreview2({
34519
34525
  portrait,
34520
34526
  suppressLoadingOverlay,
34521
34527
  loadingUi,
34528
+ sandboxOrigin,
34522
34529
  style: directUrl?.includes("/components/") ? { position: "absolute", inset: 0, zIndex: 1 } : void 0
34523
34530
  },
34524
34531
  `${activeKey}-${slot.gen}`
@@ -34536,6 +34543,7 @@ var NLEPreview = memo24(function NLEPreview2({
34536
34543
  portrait,
34537
34544
  suppressLoadingOverlay: true,
34538
34545
  noLoadTimeout: true,
34546
+ sandboxOrigin,
34539
34547
  style: SHADOW_IFRAME_STYLE
34540
34548
  },
34541
34549
  `${activeKey}-${slot.gen}`
@@ -35372,7 +35380,8 @@ function PreviewPane({
35372
35380
  directUrl,
35373
35381
  suppressLoadingOverlay: hasLoadedOnceRef.current,
35374
35382
  onStageRef: handleStageRef,
35375
- onCompositionSizeChange: setPreviewCompositionSize
35383
+ onCompositionSizeChange: setPreviewCompositionSize,
35384
+ sandboxOrigin: STUDIO_OPAQUE_PREVIEW_ENABLED ? "opaque" : void 0
35376
35385
  }
35377
35386
  ),
35378
35387
  previewDragOver && /* @__PURE__ */ jsx89("div", { className: "absolute inset-2 z-40 rounded-lg border-2 border-dashed border-studio-accent/50 bg-studio-accent/4 pointer-events-none" }),
@@ -39970,7 +39979,7 @@ function OffCanvasIndicators({
39970
39979
  const selectOffCanvas = async () => {
39971
39980
  const el = elements.current.get(r.key);
39972
39981
  if (!el) return;
39973
- const { resolveDomEditSelection: resolveDomEditSelection2 } = await import("./domEditingLayers-SA5KLSSS.js");
39982
+ const { resolveDomEditSelection: resolveDomEditSelection2 } = await import("./domEditingLayers-IHYA42AJ.js");
39974
39983
  const acp = activeCompositionPathRef.current ?? "index.html";
39975
39984
  const sel = await resolveDomEditSelection2(el, {
39976
39985
  activeCompositionPath: acp,
@@ -69970,6 +69979,7 @@ function MediaFadeSliders({
69970
69979
  function createGsapLivePreview(iframeRef) {
69971
69980
  return (el, props) => {
69972
69981
  const iframe = iframeRef.current;
69982
+ if (!iframe || previewFrameOpaque(iframe)) return;
69973
69983
  const win = iframe?.contentWindow;
69974
69984
  const node = findPreviewNode(iframe?.contentDocument, el);
69975
69985
  if (win?.gsap && node) win.gsap.set(node, props);
@@ -91824,7 +91834,11 @@ function useCaptionDetection({
91824
91834
 
91825
91835
  // src/hooks/useConsoleErrorCapture.ts
91826
91836
  import { useCallback as useCallback161, useEffect as useEffect137, useRef as useRef168, useState as useState134 } from "react";
91827
- import { STUDIO_PREVIEW_ERRORS } from "@hyperframes/core/studio-preview-mark";
91837
+ import {
91838
+ previewConsoleErrorText,
91839
+ STUDIO_PREVIEW_ERRORS
91840
+ } from "@hyperframes/core/studio-preview-mark";
91841
+ var SEALED_POLL_MS = 1e3;
91828
91842
  function useConsoleErrorCapture(previewIframe) {
91829
91843
  const [consoleErrors, setConsoleErrors] = useState134(null);
91830
91844
  const consoleErrorsRef = useRef168([]);
@@ -91838,7 +91852,39 @@ function useConsoleErrorCapture(previewIframe) {
91838
91852
  let patchedWin = null;
91839
91853
  let origConsoleError = null;
91840
91854
  let errorHandler = null;
91855
+ let stopSealedReads = null;
91856
+ const record2 = (texts) => {
91857
+ if (texts.length === 0) return;
91858
+ consoleErrorsRef.current = [
91859
+ ...consoleErrorsRef.current,
91860
+ ...texts.map((message) => ({ severity: "error", message }))
91861
+ ];
91862
+ setConsoleErrors([...consoleErrorsRef.current]);
91863
+ };
91864
+ const readSealedErrors = (iframe) => {
91865
+ let live = true;
91866
+ let read2 = 0;
91867
+ let timer;
91868
+ const poll = async () => {
91869
+ for (; ; ) {
91870
+ const page = await previewConsoleErrors(iframe, read2);
91871
+ if (!live) return;
91872
+ if (!page) break;
91873
+ read2 += page.errors.length;
91874
+ record2(page.errors);
91875
+ if (!page.truncated || page.errors.length === 0) break;
91876
+ }
91877
+ timer = setTimeout(poll, SEALED_POLL_MS);
91878
+ };
91879
+ void poll();
91880
+ return () => {
91881
+ live = false;
91882
+ clearTimeout(timer);
91883
+ };
91884
+ };
91841
91885
  const detachErrorCapture = () => {
91886
+ stopSealedReads?.();
91887
+ stopSealedReads = null;
91842
91888
  const win = patchedWin;
91843
91889
  if (!win) return;
91844
91890
  patchedWin = null;
@@ -91854,25 +91900,21 @@ function useConsoleErrorCapture(previewIframe) {
91854
91900
  const attachErrorCapture = () => {
91855
91901
  detachErrorCapture();
91856
91902
  resetErrors();
91903
+ if (previewFrameOpaque(previewIframe)) {
91904
+ stopSealedReads = readSealedErrors(previewIframe);
91905
+ return;
91906
+ }
91857
91907
  try {
91858
91908
  const win = previewIframe.contentWindow;
91859
91909
  if (!win) return;
91860
91910
  if (win.__hfErrorCapture) return;
91861
91911
  win.__hfErrorCapture = true;
91862
91912
  patchedWin = win;
91863
- const record2 = (texts) => {
91864
- if (texts.length === 0) return;
91865
- consoleErrorsRef.current = [
91866
- ...consoleErrorsRef.current,
91867
- ...texts.map((message) => ({ severity: "error", message }))
91868
- ];
91869
- setConsoleErrors([...consoleErrorsRef.current]);
91870
- };
91871
91913
  origConsoleError = win.console.error.bind(win.console);
91872
91914
  win.console.error = function(...args) {
91873
91915
  origConsoleError(...args);
91874
- const text3 = args.map((a) => a instanceof Error ? a.message : String(a)).join(" ");
91875
- if (!text3.includes("favicon")) record2([text3]);
91916
+ const text3 = previewConsoleErrorText(args);
91917
+ if (text3 !== null) record2([text3]);
91876
91918
  };
91877
91919
  errorHandler = (e) => record2([e.message || String(e)]);
91878
91920
  win.addEventListener("error", errorHandler);
@@ -96582,9 +96624,9 @@ function useFreshFrameToken(projectId, wanted) {
96582
96624
  useEffect151(() => {
96583
96625
  if (!wanted) return setKnown(void 0);
96584
96626
  let live = true;
96585
- void studioApiFetch(buildProjectApiPath(projectId, "/frame-token")).then((res) => res.ok ? res.json() : null).then(
96586
- (body) => typeof body?.token === "string" ? body.token : null
96587
- ).catch(() => null).then((token) => live && setKnown({ token }));
96627
+ void fetchFrameToken(buildProjectApiPath(projectId, "/frame-token")).then(
96628
+ (token) => live && setKnown({ token })
96629
+ );
96588
96630
  return () => {
96589
96631
  live = false;
96590
96632
  };
@@ -104771,6 +104813,8 @@ export {
104771
104813
  persistRenderSettings,
104772
104814
  playSeamTransitionLoop,
104773
104815
  popupSurface,
104816
+ previewEditingClient,
104817
+ previewFrameOpaque,
104774
104818
  resolveDomEditSelection,
104775
104819
  resolveEquidistanceGuides,
104776
104820
  resolveGuideLineRect,
package/dist/player.d.ts CHANGED
@@ -18,6 +18,7 @@ interface PlayerProps {
18
18
  suppressLoadingOverlay?: boolean;
19
19
  loadingUi?: "studio" | "host";
20
20
  noLoadTimeout?: boolean;
21
+ sandboxOrigin?: "opaque";
21
22
  }
22
23
  /**
23
24
  * Renders a composition preview using the <hyperframes-player> web component.