@hyperframes/studio 0.9.54 → 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.
- package/dist/assets/{hyperframes-player-Oju91F6x.js → hyperframes-player-BroIQA4E.js} +1 -1
- package/dist/assets/{index-B0VEzzD2.js → index-Be7DZynj.js} +5 -5
- package/dist/assets/{index-XEm_N45R.js → index-CiF0D62S.js} +1 -1
- package/dist/assets/{pausedVideoDecoder-p6zibxVM.js → pausedVideoDecoder-RXcvblHS.js} +1 -1
- package/dist/{chunk-K3IOYISK.js → chunk-JMM2CSEL.js} +1 -1
- package/dist/index.html +1 -1
- package/dist/index.js +1 -1
- package/dist/player.js +1 -1
- package/package.json +8 -8
- package/src/player/components/Player.test.ts +6 -0
- package/src/player/lib/frameToken.ts +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Input as V,ALL_FORMATS as G,UrlSource as K,VideoSampleSink as Q}from"./index-
|
|
1
|
+
import{Input as V,ALL_FORMATS as G,UrlSource as K,VideoSampleSink as Q}from"./index-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};
|
|
@@ -2069,7 +2069,7 @@ function bridgePlaybackAdapter(iframe) {
|
|
|
2069
2069
|
}
|
|
2070
2070
|
|
|
2071
2071
|
// src/player/lib/frameToken.ts
|
|
2072
|
-
var PREVIEW_PATH = /^(\/api\/projects\/[^/?#]+)\/preview(?=[/?#]|$)/;
|
|
2072
|
+
var PREVIEW_PATH = /^(\/api\/projects\/[^/?#]+)\/preview(?:\/~[\w-]{43})?(?=[/?#]|$)/;
|
|
2073
2073
|
function fetchFrameToken(frameTokenPath) {
|
|
2074
2074
|
return studioApiFetch(frameTokenPath).then((res) => res.ok ? res.json() : null).then(
|
|
2075
2075
|
(body) => typeof body?.token === "string" ? body.token : null
|
package/dist/index.html
CHANGED
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
document.documentElement.dataset.theme = "paper";
|
|
15
15
|
}
|
|
16
16
|
</script>
|
|
17
|
-
<script type="module" crossorigin src="/assets/index-
|
|
17
|
+
<script type="module" crossorigin src="/assets/index-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
package/dist/player.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hyperframes/studio",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.55",
|
|
4
4
|
"description": "",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -64,12 +64,12 @@
|
|
|
64
64
|
"dockview-react": "8.3.1",
|
|
65
65
|
"gsap": "^3.13.0",
|
|
66
66
|
"mediabunny": "^1.66.0",
|
|
67
|
-
"@hyperframes/
|
|
68
|
-
"@hyperframes/
|
|
69
|
-
"@hyperframes/
|
|
70
|
-
"@hyperframes/
|
|
71
|
-
"@hyperframes/
|
|
72
|
-
"@hyperframes/studio-server": "0.9.
|
|
67
|
+
"@hyperframes/player": "0.9.55",
|
|
68
|
+
"@hyperframes/core": "0.9.55",
|
|
69
|
+
"@hyperframes/sdk": "0.9.55",
|
|
70
|
+
"@hyperframes/shader-transitions": "0.9.55",
|
|
71
|
+
"@hyperframes/parsers": "0.9.55",
|
|
72
|
+
"@hyperframes/studio-server": "0.9.55"
|
|
73
73
|
},
|
|
74
74
|
"devDependencies": {
|
|
75
75
|
"@tailwindcss/vite": "^4.3.3",
|
|
@@ -86,7 +86,7 @@
|
|
|
86
86
|
"vite": "^6.4.5",
|
|
87
87
|
"vitest": "^4.1.12",
|
|
88
88
|
"zustand": "^5.0.0",
|
|
89
|
-
"@hyperframes/producer": "0.9.
|
|
89
|
+
"@hyperframes/producer": "0.9.55"
|
|
90
90
|
},
|
|
91
91
|
"peerDependencies": {
|
|
92
92
|
"react": "19",
|
|
@@ -218,6 +218,12 @@ describe("a host's sandbox origin", () => {
|
|
|
218
218
|
`/api/projects/demo/preview/~${token}/comp/scene.html`,
|
|
219
219
|
],
|
|
220
220
|
["/api/projects/demo/preview?_t=1", `/api/projects/demo/preview/~${token}?_t=1`],
|
|
221
|
+
// A reload starts from the frame's own src, which already carries a token, maybe a stale one.
|
|
222
|
+
[`/api/projects/demo/preview/~${token}?_t=2`, `/api/projects/demo/preview/~${token}?_t=2`],
|
|
223
|
+
[
|
|
224
|
+
`/api/projects/demo/preview/~${"S".repeat(43)}/comp/scene.html`,
|
|
225
|
+
`/api/projects/demo/preview/~${token}/comp/scene.html`,
|
|
226
|
+
],
|
|
221
227
|
])(
|
|
222
228
|
"seals an opaque preview of %s and loads it under its project's frame token",
|
|
223
229
|
async (directUrl, sealed) => {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { studioApiFetch } from "../../utils/studioApiFetch";
|
|
2
2
|
|
|
3
|
-
const PREVIEW_PATH = /^(\/api\/projects\/[^/?#]+)\/preview(?=[/?#]|$)/;
|
|
3
|
+
const PREVIEW_PATH = /^(\/api\/projects\/[^/?#]+)\/preview(?:\/~[\w-]{43})?(?=[/?#]|$)/;
|
|
4
4
|
|
|
5
5
|
export function fetchFrameToken(frameTokenPath: string): Promise<string | null> {
|
|
6
6
|
return studioApiFetch(frameTokenPath)
|