@hyperframes/studio 0.9.38 → 0.9.40
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-Dz2VdhdD.js → codec-BPK_2CLL.js} +1 -1
- package/dist/assets/{hyperframes-player-BkaWdGLq.js → hyperframes-player-D7qTTDIp.js} +1 -1
- package/dist/assets/{index-BJTCbv8z.css → index-4VGEAZyf.css} +1 -1
- package/dist/assets/{index-DsNxqAwr.js → index-CdA00Ybn.js} +145 -145
- package/dist/assets/{index-DONaC7VF.js → index-QS-DuxAU.js} +1 -1
- package/dist/assets/{pausedVideoDecoder-BGN2jKrN.js → pausedVideoDecoder-Byzz98Gb.js} +1 -1
- package/dist/{chunk-63DH4LRB.js → chunk-AV2PV7NE.js} +15 -68
- package/dist/chunk-FQ3VRKMC.js +148 -0
- package/dist/{chunk-YKBN653R.js → chunk-KF6YVXJP.js} +258 -1
- package/dist/{chunk-45KKBU63.js → chunk-VZ5MD32A.js} +1 -1
- package/dist/{domEditingLayers-7Q56QAU5.js → domEditingLayers-4KRREI5C.js} +2 -2
- package/dist/index.d.ts +3 -85
- package/dist/index.html +2 -2
- package/dist/index.js +321 -341
- package/dist/keys-CaWcxUST.d.ts +86 -0
- package/dist/keys.d.ts +1 -0
- package/dist/keys.js +11 -0
- package/dist/player.js +2 -2
- package/dist/styles.css +1 -1
- package/package.json +12 -8
- package/src/components/editor/DomEditGestureReadout.test.tsx +204 -20
- package/src/components/editor/DomEditGestureReadout.tsx +36 -18
- package/src/components/editor/InlineTextToolbar.tsx +2 -2
- package/src/components/editor/domEditGestureReadoutPlacement.ts +144 -0
- package/src/components/editor/domEditGestureReadoutState.ts +18 -8
- package/src/components/editor/domEditingDom.ts +23 -104
- package/src/components/editor/useDomEditCompositionRect.ts +13 -4
- package/src/components/editor/useDomEditOverlayGestures.ts +1 -1
- package/src/components/editor/usePreviewCompositionRect.test.tsx +39 -0
- package/src/hooks/elementPickerStyles.ts +53 -0
- package/src/hooks/useElementPicker.test.ts +83 -3
- package/src/hooks/useElementPicker.ts +27 -66
- package/src/keys.test.ts +53 -0
- package/src/keys.ts +11 -0
- package/src/player/components/Player.tsx +2 -0
- package/src/player/components/studioKeyDefaults.ts +68 -0
- package/src/player/components/studioShortcuts.ts +2 -67
- package/src/player/hooks/playbackAdapterResolution.ts +15 -0
- package/src/player/hooks/previewMessageRouter.manifest.test.ts +67 -0
- package/src/player/hooks/previewMessageRouter.ts +38 -8
- package/src/player/hooks/timelinePlayerTestHarness.ts +26 -1
- package/src/player/hooks/useShadowPreviewReload.ts +4 -1
- package/src/player/hooks/useTimelinePlayer.ts +5 -9
- package/src/player/lib/bridgePlayback.ts +156 -0
- package/src/player/lib/previewChannel.test.ts +260 -0
- package/src/player/lib/previewChannel.ts +115 -0
- package/src/player/lib/previewElements.test.ts +167 -0
- package/src/player/lib/previewElements.ts +117 -0
- package/src/player/sceneSwap.test.ts +12 -0
- package/src/player/sceneSwap.ts +2 -0
|
@@ -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-BPK_2CLL.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-BPK_2CLL.js";import{n as wi}from"./index-CdA00Ybn.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-CdA00Ybn.js";import{bw as G,bN as K,cH as Q,bE as X}from"./codec-BPK_2CLL.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};
|
|
@@ -45,11 +45,14 @@ function getSourceScopedSelectorIndex(doc, el, selector, sourceFile, resolveSour
|
|
|
45
45
|
}
|
|
46
46
|
|
|
47
47
|
// src/components/editor/domEditingDom.ts
|
|
48
|
-
import {
|
|
49
|
-
PREVIEW_VIDEO_FRAME_ATTR,
|
|
50
|
-
PREVIEW_VIDEO_CANVAS_ATTR
|
|
51
|
-
} from "@hyperframes/core/studio-preview-mark";
|
|
48
|
+
import { getLogicalOpacity } from "@hyperframes/core/studio-preview-mark";
|
|
52
49
|
import { COLOR_GRADING_SOURCE_HIDDEN_ATTR } from "@hyperframes/core/color-grading";
|
|
50
|
+
import {
|
|
51
|
+
buildStableSelector,
|
|
52
|
+
escapeCssString,
|
|
53
|
+
getPreferredClassSelector,
|
|
54
|
+
readElementSource
|
|
55
|
+
} from "@hyperframes/core/runtime/editing-port";
|
|
53
56
|
|
|
54
57
|
// src/components/editor/domEditingTypes.ts
|
|
55
58
|
var CURATED_STYLE_PROPERTIES = [
|
|
@@ -109,12 +112,6 @@ function isTextBearingTag(tagName) {
|
|
|
109
112
|
function isEditableTextLeaf(el) {
|
|
110
113
|
return isTextBearingTag(el.tagName.toLowerCase()) && el.children.length === 0;
|
|
111
114
|
}
|
|
112
|
-
function getLogicalOpacity(el, computed) {
|
|
113
|
-
const overlay = el.previousElementSibling;
|
|
114
|
-
if (el.hasAttribute(PREVIEW_VIDEO_FRAME_ATTR) && overlay?.localName === "canvas" && overlay.hasAttribute(PREVIEW_VIDEO_CANVAS_ATTR))
|
|
115
|
-
return el.ownerDocument.defaultView?.getComputedStyle(overlay).opacity ?? computed.opacity;
|
|
116
|
-
return computed.opacity;
|
|
117
|
-
}
|
|
118
115
|
function elementRendersItself(win, el) {
|
|
119
116
|
const computed = win.getComputedStyle(el);
|
|
120
117
|
if (computed.display === "none" || computed.visibility === "hidden") return false;
|
|
@@ -188,16 +185,13 @@ function setCompositionSourceMap(map) {
|
|
|
188
185
|
function getCompositionSourceMapRevision() {
|
|
189
186
|
return compositionSourceMapRevision;
|
|
190
187
|
}
|
|
191
|
-
function
|
|
192
|
-
|
|
193
|
-
const
|
|
194
|
-
|
|
195
|
-
return (authored ? compositionSourceMap.get(authored) : void 0) ?? (current ? compositionSourceMap.get(current) : void 0);
|
|
188
|
+
function resolveElementSourceFile(source, activeCompositionPath) {
|
|
189
|
+
const { file, compositionId, originalCompositionId } = source;
|
|
190
|
+
const mapped = compositionSourceMap.size ? (originalCompositionId ? compositionSourceMap.get(originalCompositionId) : void 0) ?? (compositionId ? compositionSourceMap.get(compositionId) : void 0) : void 0;
|
|
191
|
+
return file ?? mapped ?? activeCompositionPath ?? "index.html";
|
|
196
192
|
}
|
|
197
193
|
function getSourceFileForElement(el, activeCompositionPath) {
|
|
198
|
-
const
|
|
199
|
-
const ownerRoot = findClosestByAttribute(el, ["data-composition-id"]);
|
|
200
|
-
const sourceFile = sourceHost?.getAttribute("data-composition-file") ?? sourceHost?.getAttribute("data-composition-src") ?? ownerRoot?.getAttribute("data-composition-file") ?? ownerRoot?.getAttribute("data-composition-src") ?? sourceFromCompositionId(ownerRoot) ?? activeCompositionPath ?? "index.html";
|
|
194
|
+
const sourceFile = resolveElementSourceFile(readElementSource(el), activeCompositionPath);
|
|
201
195
|
return {
|
|
202
196
|
sourceFile,
|
|
203
197
|
compositionPath: sourceFile
|
|
@@ -221,39 +215,6 @@ function normalizeTimelineCompositionSource(value) {
|
|
|
221
215
|
}
|
|
222
216
|
return trimmed;
|
|
223
217
|
}
|
|
224
|
-
function escapeCssIdentifier(value) {
|
|
225
|
-
const css = globalThis.CSS;
|
|
226
|
-
if (typeof css?.escape === "function") return css.escape(value);
|
|
227
|
-
if (value === "-") return "\\-";
|
|
228
|
-
let escaped = "";
|
|
229
|
-
for (let index = 0; index < value.length; index += 1) {
|
|
230
|
-
const char = value[index] ?? "";
|
|
231
|
-
const code = char.charCodeAt(0);
|
|
232
|
-
if (code === 0) {
|
|
233
|
-
escaped += "\uFFFD";
|
|
234
|
-
continue;
|
|
235
|
-
}
|
|
236
|
-
const isDigit = code >= 48 && code <= 57;
|
|
237
|
-
const isUpperAlpha = code >= 65 && code <= 90;
|
|
238
|
-
const isLowerAlpha = code >= 97 && code <= 122;
|
|
239
|
-
const isControl = code >= 1 && code <= 31 || code === 127;
|
|
240
|
-
const isLeadingDigit = index === 0 && isDigit;
|
|
241
|
-
const isSecondDigitAfterDash = index === 1 && value.startsWith("-") && isDigit;
|
|
242
|
-
if (isControl || isLeadingDigit || isSecondDigitAfterDash) {
|
|
243
|
-
escaped += `\\${code.toString(16)} `;
|
|
244
|
-
continue;
|
|
245
|
-
}
|
|
246
|
-
if (isUpperAlpha || isLowerAlpha || isDigit || char === "-" || char === "_" || code >= 128) {
|
|
247
|
-
escaped += char;
|
|
248
|
-
continue;
|
|
249
|
-
}
|
|
250
|
-
escaped += `\\${char}`;
|
|
251
|
-
}
|
|
252
|
-
return escaped;
|
|
253
|
-
}
|
|
254
|
-
function escapeCssString(value) {
|
|
255
|
-
return value.replace(/\\/g, "\\\\").replace(/"/g, '\\"').replace(/\n/g, "\\a ").replace(/\r/g, "\\d ").replace(/\f/g, "\\c ");
|
|
256
|
-
}
|
|
257
218
|
function querySelectorAllSafely(doc, selector) {
|
|
258
219
|
try {
|
|
259
220
|
return Array.from(doc.querySelectorAll(selector));
|
|
@@ -264,20 +225,6 @@ function querySelectorAllSafely(doc, selector) {
|
|
|
264
225
|
function humanizeIdentifier(value) {
|
|
265
226
|
return value.replace(/\.html$/i, "").replace(/^compositions\//i, "").split("/").at(-1)?.replace(/[-_]+/g, " ").replace(/\b\w/g, (char) => char.toUpperCase()) ?? value;
|
|
266
227
|
}
|
|
267
|
-
function buildStableSelector(el) {
|
|
268
|
-
if (el.id) return `#${escapeCssIdentifier(el.id)}`;
|
|
269
|
-
const compositionId = el.getAttribute("data-composition-id");
|
|
270
|
-
if (compositionId) return `[data-composition-id="${escapeCssString(compositionId)}"]`;
|
|
271
|
-
const group = el.getAttribute("data-hf-group");
|
|
272
|
-
if (group) return `[data-hf-group="${escapeCssString(group)}"]`;
|
|
273
|
-
return getPreferredClassSelector(el);
|
|
274
|
-
}
|
|
275
|
-
function getPreferredClassSelector(el) {
|
|
276
|
-
const classes = Array.from(el.classList).map((value) => value.trim()).filter(Boolean);
|
|
277
|
-
if (classes.length === 0) return void 0;
|
|
278
|
-
const preferred = classes.find((value) => value !== "clip" && !value.startsWith("__hf-")) ?? classes[0];
|
|
279
|
-
return preferred ? `.${escapeCssIdentifier(preferred)}` : void 0;
|
|
280
|
-
}
|
|
281
228
|
function buildElementLabel(el) {
|
|
282
229
|
const compositionId = el.getAttribute("data-hf-original-composition-id") ?? el.getAttribute("data-composition-id");
|
|
283
230
|
if (compositionId && compositionId !== "main") {
|
|
@@ -1152,9 +1099,11 @@ export {
|
|
|
1152
1099
|
rgbToHsv,
|
|
1153
1100
|
hsvToRgb,
|
|
1154
1101
|
withSelectorIndexPass,
|
|
1102
|
+
getLogicalOpacity,
|
|
1103
|
+
buildStableSelector,
|
|
1104
|
+
escapeCssString,
|
|
1155
1105
|
isHtmlElement,
|
|
1156
1106
|
isEditableTextLeaf,
|
|
1157
|
-
getLogicalOpacity,
|
|
1158
1107
|
isElementVisibleThroughAncestors,
|
|
1159
1108
|
getCuratedComputedStyles,
|
|
1160
1109
|
getInlineStyles,
|
|
@@ -1164,9 +1113,7 @@ export {
|
|
|
1164
1113
|
getCompositionSourceMapRevision,
|
|
1165
1114
|
getSourceFileForElement,
|
|
1166
1115
|
normalizeTimelineCompositionSource,
|
|
1167
|
-
escapeCssString,
|
|
1168
1116
|
querySelectorAllSafely,
|
|
1169
|
-
buildStableSelector,
|
|
1170
1117
|
buildElementLabel,
|
|
1171
1118
|
getSelectorIndex,
|
|
1172
1119
|
parsePx,
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
// src/player/components/studioCombo.ts
|
|
2
|
+
var NAMED = /* @__PURE__ */ new Set([
|
|
3
|
+
"Space",
|
|
4
|
+
"ArrowLeft",
|
|
5
|
+
"ArrowRight",
|
|
6
|
+
"ArrowUp",
|
|
7
|
+
"ArrowDown",
|
|
8
|
+
"Home",
|
|
9
|
+
"End",
|
|
10
|
+
"PageUp",
|
|
11
|
+
"PageDown",
|
|
12
|
+
"Delete",
|
|
13
|
+
"Backspace",
|
|
14
|
+
"Escape",
|
|
15
|
+
"Enter",
|
|
16
|
+
"Tab"
|
|
17
|
+
]);
|
|
18
|
+
var SYMBOL = {
|
|
19
|
+
ArrowLeft: "\u2190",
|
|
20
|
+
ArrowRight: "\u2192",
|
|
21
|
+
ArrowUp: "\u2191",
|
|
22
|
+
ArrowDown: "\u2193",
|
|
23
|
+
Delete: "Del",
|
|
24
|
+
Backspace: "\u232B",
|
|
25
|
+
Escape: "Esc"
|
|
26
|
+
};
|
|
27
|
+
var MODIFIERS = /* @__PURE__ */ new Set(["mod", "cmd", "ctrl", "shift", "alt"]);
|
|
28
|
+
function parseCombo(text) {
|
|
29
|
+
const split = text.length > 1 ? text.slice(0, -1).lastIndexOf("+") : -1;
|
|
30
|
+
const tokens = split < 0 ? [] : text.slice(0, split).split("+").map((t) => t.toLowerCase());
|
|
31
|
+
const key = text.slice(split + 1);
|
|
32
|
+
const named = NAMED.has(key);
|
|
33
|
+
const symbol = !named && !/^[A-Za-z]$/.test(key);
|
|
34
|
+
if (tokens.some((t) => !MODIFIERS.has(t)) || !named && [...key].length !== 1) return null;
|
|
35
|
+
if (symbol && tokens.includes("shift")) return null;
|
|
36
|
+
const combo = {
|
|
37
|
+
mod: tokens.includes("mod"),
|
|
38
|
+
meta: tokens.includes("cmd"),
|
|
39
|
+
ctrl: tokens.includes("ctrl"),
|
|
40
|
+
shift: tokens.includes("shift"),
|
|
41
|
+
alt: tokens.includes("alt"),
|
|
42
|
+
key: named ? key : key.toLowerCase(),
|
|
43
|
+
named
|
|
44
|
+
};
|
|
45
|
+
return combo.alt && (combo.ctrl || combo.mod) ? null : combo;
|
|
46
|
+
}
|
|
47
|
+
function comboText(c) {
|
|
48
|
+
const mods = [
|
|
49
|
+
c.mod && "mod",
|
|
50
|
+
c.meta && "cmd",
|
|
51
|
+
c.ctrl && "ctrl",
|
|
52
|
+
c.alt && "alt",
|
|
53
|
+
c.shift && "shift"
|
|
54
|
+
];
|
|
55
|
+
return [...mods.filter(Boolean), c.key].join("+");
|
|
56
|
+
}
|
|
57
|
+
var namedMatches = (e, name) => e.code === name || e.key === (name === "Space" ? " " : name);
|
|
58
|
+
function charMatches(e, c) {
|
|
59
|
+
if (e.key.toLowerCase() === c.key) return true;
|
|
60
|
+
const code = /^[0-9]$/.test(c.key) ? `Digit${c.key}` : `Key${c.key.toUpperCase()}`;
|
|
61
|
+
return e.altKey && /^[a-z0-9]$/.test(c.key) && e.code === code;
|
|
62
|
+
}
|
|
63
|
+
function matchCombo(e, c) {
|
|
64
|
+
const symbol = !c.named && !/^[a-z]$/.test(c.key);
|
|
65
|
+
if (!symbol && !!e.shiftKey !== c.shift || !!e.altKey !== c.alt) return false;
|
|
66
|
+
const modsOk = c.mod ? e.metaKey || e.ctrlKey : !!e.metaKey === c.meta && !!e.ctrlKey === c.ctrl;
|
|
67
|
+
return modsOk && (c.named ? namedMatches(e, c.key) : charMatches(e, c));
|
|
68
|
+
}
|
|
69
|
+
function formatCombo(c) {
|
|
70
|
+
const mods = `${c.ctrl ? "\u2303" : ""}${c.alt ? "\u2325" : ""}${c.mod || c.meta ? "\u2318" : ""}${c.shift ? "\u21E7" : ""}`;
|
|
71
|
+
return mods + (SYMBOL[c.key] ?? (c.named ? c.key : c.key.toUpperCase()));
|
|
72
|
+
}
|
|
73
|
+
var comboClashKey = (c) => [c.mod || c.meta || c.ctrl, c.alt, c.shift, c.key].join("|");
|
|
74
|
+
|
|
75
|
+
// src/player/components/studioKeyDefaults.ts
|
|
76
|
+
var DEFAULT_STUDIO_KEYS = {
|
|
77
|
+
fullscreen: "f",
|
|
78
|
+
split: "s",
|
|
79
|
+
record: "r",
|
|
80
|
+
addKeyframe: "k",
|
|
81
|
+
audioGain: "g",
|
|
82
|
+
zoomSelection: "z",
|
|
83
|
+
mute: "m",
|
|
84
|
+
pause: "k",
|
|
85
|
+
shuttleBack: "j",
|
|
86
|
+
shuttleForward: "l",
|
|
87
|
+
inPoint: "i",
|
|
88
|
+
outPoint: "o",
|
|
89
|
+
seekToIn: "a",
|
|
90
|
+
seekToOut: "e",
|
|
91
|
+
selectTool: "v",
|
|
92
|
+
razorTool: "b",
|
|
93
|
+
selectLeftward: "[",
|
|
94
|
+
selectRightward: "]",
|
|
95
|
+
exitRazor: "a",
|
|
96
|
+
snap: "s",
|
|
97
|
+
grid: "g",
|
|
98
|
+
timelineSnap: "n",
|
|
99
|
+
playPause: "Space",
|
|
100
|
+
frameBack: "ArrowLeft",
|
|
101
|
+
frameForward: "ArrowRight",
|
|
102
|
+
frameBackTen: "shift+ArrowLeft",
|
|
103
|
+
frameForwardTen: "shift+ArrowRight",
|
|
104
|
+
loop: "shift+l",
|
|
105
|
+
clearInPoint: "shift+i",
|
|
106
|
+
clearOutPoint: "shift+o",
|
|
107
|
+
undo: "mod+z",
|
|
108
|
+
redo: "mod+shift+z",
|
|
109
|
+
redoAlt: "ctrl+y",
|
|
110
|
+
tabCompositions: "mod+1",
|
|
111
|
+
tabAssets: "mod+2",
|
|
112
|
+
group: "mod+g",
|
|
113
|
+
ungroup: "mod+shift+g",
|
|
114
|
+
copy: "mod+c",
|
|
115
|
+
paste: "mod+v",
|
|
116
|
+
cut: "mod+x",
|
|
117
|
+
duplicate: "mod+d",
|
|
118
|
+
linkToggle: "mod+l",
|
|
119
|
+
detachAudio: "alt+shift+d",
|
|
120
|
+
deleteLinked: "alt+Backspace",
|
|
121
|
+
deleteLinkedAlt: "alt+Delete",
|
|
122
|
+
deleteSelected: "Delete",
|
|
123
|
+
deleteSelectedAlt: "Backspace",
|
|
124
|
+
resetKeyframes: "Backspace",
|
|
125
|
+
nudgeLeft: "ArrowLeft",
|
|
126
|
+
nudgeRight: "ArrowRight",
|
|
127
|
+
nudgeUp: "ArrowUp",
|
|
128
|
+
nudgeDown: "ArrowDown",
|
|
129
|
+
nudgeLeftTen: "shift+ArrowLeft",
|
|
130
|
+
nudgeRightTen: "shift+ArrowRight",
|
|
131
|
+
nudgeUpTen: "shift+ArrowUp",
|
|
132
|
+
nudgeDownTen: "shift+ArrowDown",
|
|
133
|
+
captionSelectAll: "mod+a",
|
|
134
|
+
pickupClip: "Space",
|
|
135
|
+
pickupUp: "ArrowUp",
|
|
136
|
+
pickupDown: "ArrowDown",
|
|
137
|
+
pickupDrop: "Enter",
|
|
138
|
+
cancel: "Escape"
|
|
139
|
+
};
|
|
140
|
+
|
|
141
|
+
export {
|
|
142
|
+
parseCombo,
|
|
143
|
+
comboText,
|
|
144
|
+
matchCombo,
|
|
145
|
+
formatCombo,
|
|
146
|
+
comboClashKey,
|
|
147
|
+
DEFAULT_STUDIO_KEYS
|
|
148
|
+
};
|
|
@@ -5,7 +5,7 @@ import {
|
|
|
5
5
|
buildProjectApiPath,
|
|
6
6
|
splitTimelineElementKey,
|
|
7
7
|
studioApiFetch
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-AV2PV7NE.js";
|
|
9
9
|
|
|
10
10
|
// src/player/lib/time.ts
|
|
11
11
|
var STUDIO_PREVIEW_FPS = 30;
|
|
@@ -1689,6 +1689,94 @@ function isPreviewChanging() {
|
|
|
1689
1689
|
return changing() && !givenUp;
|
|
1690
1690
|
}
|
|
1691
1691
|
|
|
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, selector, properties) {
|
|
1769
|
+
const reply = await previewRequest(iframe, "computed-styles", { selector, properties });
|
|
1770
|
+
const styles = reply?.styles;
|
|
1771
|
+
if (typeof styles !== "object" || styles === null) return null;
|
|
1772
|
+
const read = {};
|
|
1773
|
+
for (const name of properties) {
|
|
1774
|
+
const value = Object.getOwnPropertyDescriptor(styles, name)?.value;
|
|
1775
|
+
if (typeof value === "string" && value) read[name] = value;
|
|
1776
|
+
}
|
|
1777
|
+
return read;
|
|
1778
|
+
}
|
|
1779
|
+
|
|
1692
1780
|
// src/player/sceneSwap.ts
|
|
1693
1781
|
var SCENES_SWAPPED = "hf-scenes-swapped";
|
|
1694
1782
|
var SCENE_SWAP_MS = 5e3;
|
|
@@ -1760,6 +1848,7 @@ function swapFreshly(swap, url, isCurrent, cancel, reloadWholeFilm, attempt = 0)
|
|
|
1760
1848
|
});
|
|
1761
1849
|
}
|
|
1762
1850
|
function sceneSwapFor(iframe) {
|
|
1851
|
+
if (previewFrameOpaque(iframe)) return null;
|
|
1763
1852
|
const win = iframe.contentWindow;
|
|
1764
1853
|
const swap = win?.__hfSwapScenes;
|
|
1765
1854
|
if (typeof swap !== "function") return null;
|
|
@@ -1818,6 +1907,160 @@ function applyPreviewVariablesToUrl(url) {
|
|
|
1818
1907
|
}
|
|
1819
1908
|
}
|
|
1820
1909
|
|
|
1910
|
+
// src/player/lib/runtimeProtocol.ts
|
|
1911
|
+
import {
|
|
1912
|
+
frameDisplayScale,
|
|
1913
|
+
inspectRuntimeProtocol,
|
|
1914
|
+
runtimeProtocolMetadata
|
|
1915
|
+
} from "@hyperframes/core/runtime/protocol";
|
|
1916
|
+
function createRuntimeControlMessage(action, payload = {}, fps = 30) {
|
|
1917
|
+
return {
|
|
1918
|
+
...payload,
|
|
1919
|
+
source: "hf-parent",
|
|
1920
|
+
type: "control",
|
|
1921
|
+
action,
|
|
1922
|
+
...runtimeProtocolMetadata(fps)
|
|
1923
|
+
};
|
|
1924
|
+
}
|
|
1925
|
+
function postRuntimeControlMessage(target, action, payload = {}, fps = 30) {
|
|
1926
|
+
target?.postMessage(createRuntimeControlMessage(action, payload, fps), "*");
|
|
1927
|
+
}
|
|
1928
|
+
function postFrameDisplayScale(iframe) {
|
|
1929
|
+
const scale = iframe && frameDisplayScale(iframe);
|
|
1930
|
+
if (scale) postRuntimeControlMessage(iframe.contentWindow, "set-display-scale", { scale });
|
|
1931
|
+
}
|
|
1932
|
+
function inspectStudioRuntimeMessage(value) {
|
|
1933
|
+
return inspectRuntimeProtocol(value, 30);
|
|
1934
|
+
}
|
|
1935
|
+
function dispatchRuntimeProtocolError(inspection) {
|
|
1936
|
+
if (inspection.status !== "unsupported") return;
|
|
1937
|
+
window.dispatchEvent(
|
|
1938
|
+
new CustomEvent("runtimeprotocolerror", {
|
|
1939
|
+
detail: {
|
|
1940
|
+
code: inspection.code,
|
|
1941
|
+
receivedVersion: inspection.receivedVersion
|
|
1942
|
+
}
|
|
1943
|
+
})
|
|
1944
|
+
);
|
|
1945
|
+
}
|
|
1946
|
+
function acceptStudioRuntimeMessage(value) {
|
|
1947
|
+
const inspection = inspectStudioRuntimeMessage(value);
|
|
1948
|
+
if (inspection.status !== "unsupported") return inspection;
|
|
1949
|
+
dispatchRuntimeProtocolError(inspection);
|
|
1950
|
+
return null;
|
|
1951
|
+
}
|
|
1952
|
+
function acceptedRuntimeMessageFps(value) {
|
|
1953
|
+
const inspection = inspectStudioRuntimeMessage(value);
|
|
1954
|
+
return inspection.status === "supported" ? inspection.fps : 30;
|
|
1955
|
+
}
|
|
1956
|
+
|
|
1957
|
+
// src/player/lib/bridgePlayback.ts
|
|
1958
|
+
var SEEK_CONFIRM_MS = 500;
|
|
1959
|
+
var LOWEST_FPS = 1;
|
|
1960
|
+
var mirrors = /* @__PURE__ */ new WeakMap();
|
|
1961
|
+
function mirrorOf(iframe) {
|
|
1962
|
+
const frame = iframe.contentWindow;
|
|
1963
|
+
if (!frame) return null;
|
|
1964
|
+
let mirror = mirrors.get(frame);
|
|
1965
|
+
if (!mirror) {
|
|
1966
|
+
mirror = {
|
|
1967
|
+
iframe,
|
|
1968
|
+
time: 0,
|
|
1969
|
+
duration: 0,
|
|
1970
|
+
playing: false,
|
|
1971
|
+
seekTo: null,
|
|
1972
|
+
seekUntil: 0,
|
|
1973
|
+
stageSize: null
|
|
1974
|
+
};
|
|
1975
|
+
mirrors.set(frame, mirror);
|
|
1976
|
+
}
|
|
1977
|
+
mirror.iframe = iframe;
|
|
1978
|
+
return mirror;
|
|
1979
|
+
}
|
|
1980
|
+
function watchPreviewFrame(iframe) {
|
|
1981
|
+
mirrorOf(iframe);
|
|
1982
|
+
}
|
|
1983
|
+
function previewStageSize(iframe) {
|
|
1984
|
+
const frame = iframe.contentWindow;
|
|
1985
|
+
return (frame && mirrors.get(frame)?.stageSize) ?? null;
|
|
1986
|
+
}
|
|
1987
|
+
function frameOrigins(iframe) {
|
|
1988
|
+
const sandbox = iframe.getAttribute("sandbox")?.toLowerCase().split(/\s+/);
|
|
1989
|
+
if (sandbox && !sandbox.includes("allow-same-origin")) return ["null"];
|
|
1990
|
+
const src = iframe.getAttribute("src");
|
|
1991
|
+
if (iframe.hasAttribute("srcdoc") || !src) return [window.location.origin];
|
|
1992
|
+
try {
|
|
1993
|
+
const url = new URL(src, window.location.href);
|
|
1994
|
+
if (url.protocol === "about:") return [window.location.origin];
|
|
1995
|
+
return [url.protocol === "data:" ? "null" : url.origin];
|
|
1996
|
+
} catch {
|
|
1997
|
+
return [];
|
|
1998
|
+
}
|
|
1999
|
+
}
|
|
2000
|
+
var finiteAtLeastZero = (value) => typeof value === "number" && Number.isFinite(value) && value >= 0;
|
|
2001
|
+
var finitePositive = (value) => finiteAtLeastZero(value) && value > 0;
|
|
2002
|
+
function confirmsSeek(currentTime, seekTo, fps) {
|
|
2003
|
+
if (fps === null) return Math.abs(currentTime - seekTo) <= 0.5 / LOWEST_FPS;
|
|
2004
|
+
return Math.abs(currentTime - Math.floor(seekTo * fps + 1e-9) / fps) < 0.5 / fps;
|
|
2005
|
+
}
|
|
2006
|
+
function runtimePost(data) {
|
|
2007
|
+
if (typeof data !== "object" || data === null) return null;
|
|
2008
|
+
const message = data;
|
|
2009
|
+
if (message.source !== "hf-preview") return null;
|
|
2010
|
+
const inspection = inspectStudioRuntimeMessage(message);
|
|
2011
|
+
if (inspection.status === "unsupported") return null;
|
|
2012
|
+
return { message, fps: inspection.status === "supported" ? inspection.fps : null };
|
|
2013
|
+
}
|
|
2014
|
+
function mirrorState(mirror, currentTime, playing, fps) {
|
|
2015
|
+
const { seekTo } = mirror;
|
|
2016
|
+
const waiting = seekTo !== null && performance.now() < mirror.seekUntil;
|
|
2017
|
+
if (waiting && !confirmsSeek(currentTime, seekTo, fps)) return;
|
|
2018
|
+
mirror.seekTo = null;
|
|
2019
|
+
mirror.time = currentTime;
|
|
2020
|
+
mirror.playing = playing;
|
|
2021
|
+
}
|
|
2022
|
+
function mirrorPost(mirror, message, fps) {
|
|
2023
|
+
if (message.type === "timeline" && finiteAtLeastZero(message.durationSeconds)) {
|
|
2024
|
+
mirror.duration = message.durationSeconds;
|
|
2025
|
+
} else if (message.type === "state" && finiteAtLeastZero(message.currentTime)) {
|
|
2026
|
+
mirrorState(mirror, message.currentTime, message.isPlaying === true, fps);
|
|
2027
|
+
} else if (message.type === "stage-size") {
|
|
2028
|
+
const { width, height } = message;
|
|
2029
|
+
if (finitePositive(width) && finitePositive(height)) mirror.stageSize = { width, height };
|
|
2030
|
+
}
|
|
2031
|
+
}
|
|
2032
|
+
function mirrorRuntimePlayback(event) {
|
|
2033
|
+
const mirror = event.source ? mirrors.get(event.source) : void 0;
|
|
2034
|
+
if (!mirror || !frameOrigins(mirror.iframe).includes(event.origin)) return;
|
|
2035
|
+
const post = runtimePost(event.data);
|
|
2036
|
+
if (post) mirrorPost(mirror, post.message, post.fps);
|
|
2037
|
+
}
|
|
2038
|
+
if (typeof window !== "undefined") window.addEventListener("message", mirrorRuntimePlayback);
|
|
2039
|
+
function bridgePlaybackAdapter(iframe) {
|
|
2040
|
+
const frame = iframe.contentWindow;
|
|
2041
|
+
const mirror = mirrorOf(iframe);
|
|
2042
|
+
if (!frame || !mirror) return null;
|
|
2043
|
+
const send = (action, payload) => postRuntimeControlMessage(frame, action, payload);
|
|
2044
|
+
return {
|
|
2045
|
+
play: () => {
|
|
2046
|
+
send("play");
|
|
2047
|
+
mirror.playing = true;
|
|
2048
|
+
},
|
|
2049
|
+
pause: () => {
|
|
2050
|
+
send("pause");
|
|
2051
|
+
mirror.playing = false;
|
|
2052
|
+
},
|
|
2053
|
+
// The bridge's seek takes no keepPlaying or settled option yet.
|
|
2054
|
+
seek: (time) => {
|
|
2055
|
+
send("seek", { timeSeconds: time });
|
|
2056
|
+
Object.assign(mirror, { time, seekTo: time, seekUntil: performance.now() + SEEK_CONFIRM_MS });
|
|
2057
|
+
},
|
|
2058
|
+
getTime: () => mirror.time,
|
|
2059
|
+
getDuration: () => mirror.duration,
|
|
2060
|
+
isPlaying: () => mirror.playing
|
|
2061
|
+
};
|
|
2062
|
+
}
|
|
2063
|
+
|
|
1821
2064
|
// src/player/components/Player.tsx
|
|
1822
2065
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
1823
2066
|
var playerModule = null;
|
|
@@ -2054,6 +2297,7 @@ var Player = forwardRef(
|
|
|
2054
2297
|
loadIdRef.current += 1;
|
|
2055
2298
|
player.setAttribute("src", src);
|
|
2056
2299
|
container.appendChild(player);
|
|
2300
|
+
watchPreviewFrame(iframe);
|
|
2057
2301
|
enableInteractiveIframe(player);
|
|
2058
2302
|
cleanup = () => {
|
|
2059
2303
|
iframe.removeEventListener("load", handleLoad);
|
|
@@ -2306,6 +2550,11 @@ export {
|
|
|
2306
2550
|
previewReloadBegun,
|
|
2307
2551
|
whileScriptWrites,
|
|
2308
2552
|
isPreviewChanging,
|
|
2553
|
+
previewFrameOpaque,
|
|
2554
|
+
setFrameLoopStart,
|
|
2555
|
+
previewSeekPainted,
|
|
2556
|
+
previewClipManifest,
|
|
2557
|
+
previewComputedStyles,
|
|
2309
2558
|
announcePreviewDocumentLoaded,
|
|
2310
2559
|
onPreviewDocumentLoaded,
|
|
2311
2560
|
onPreviewContentReplaced,
|
|
@@ -2315,5 +2564,13 @@ export {
|
|
|
2315
2564
|
supersededByNewerEdit,
|
|
2316
2565
|
swapFreshly,
|
|
2317
2566
|
sceneSwapFor,
|
|
2567
|
+
postRuntimeControlMessage,
|
|
2568
|
+
postFrameDisplayScale,
|
|
2569
|
+
inspectStudioRuntimeMessage,
|
|
2570
|
+
acceptStudioRuntimeMessage,
|
|
2571
|
+
acceptedRuntimeMessageFps,
|
|
2572
|
+
previewStageSize,
|
|
2573
|
+
frameOrigins,
|
|
2574
|
+
bridgePlaybackAdapter,
|
|
2318
2575
|
Player
|
|
2319
2576
|
};
|
|
@@ -19,7 +19,7 @@ import {
|
|
|
19
19
|
querySelectorAllSafely,
|
|
20
20
|
studioApiFetch,
|
|
21
21
|
withSelectorIndexPass
|
|
22
|
-
} from "./chunk-
|
|
22
|
+
} from "./chunk-AV2PV7NE.js";
|
|
23
23
|
|
|
24
24
|
// src/components/editor/domEditingLayers.ts
|
|
25
25
|
import { isClipHiddenByRuntime, PREVIEW_ONLY_ATTRS } from "@hyperframes/core/studio-preview-mark";
|
|
@@ -19,8 +19,8 @@ import {
|
|
|
19
19
|
resolveDomEditCapabilities,
|
|
20
20
|
resolveDomEditSelection,
|
|
21
21
|
serializeDomEditTextFields
|
|
22
|
-
} from "./chunk-
|
|
23
|
-
import "./chunk-
|
|
22
|
+
} from "./chunk-VZ5MD32A.js";
|
|
23
|
+
import "./chunk-AV2PV7NE.js";
|
|
24
24
|
import "./chunk-MLKGABMK.js";
|
|
25
25
|
export {
|
|
26
26
|
buildDefaultDomEditTextField,
|