@hyperframes/studio 0.9.22 → 0.9.23
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-DLDwVbqW.js → codec-DYZ1sJnW.js} +1 -1
- package/dist/assets/{hyperframes-player-C5DA6O5u.js → hyperframes-player-BOxJo7Nx.js} +1 -1
- package/dist/assets/{index-Buvugo_O.js → index-Ccf4_r8m.js} +101 -101
- package/dist/assets/{index-B6RxZt-8.js → index-DKEq8iSv.js} +1 -1
- package/dist/assets/{index-Bgfyny02.css → index-dsfjBidg.css} +1 -1
- package/dist/assets/pausedVideoDecoder-B65VVvs_.js +1 -0
- package/dist/{chunk-7HZGKFFU.js → chunk-J3VJE463.js} +1 -1
- package/dist/{chunk-AX6G6YL5.js → chunk-LRTUWOR4.js} +11 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.html +2 -2
- package/dist/index.js +3 -3
- package/dist/{pausedVideoDecoder-KBQXSWFQ.js → pausedVideoDecoder-W2SVMXDS.js} +22 -11
- package/dist/player.js +2 -2
- package/dist/styles.css +1 -1
- package/dist/ui.js +1 -1
- package/package.json +8 -8
- package/src/components/ui/Menu.test.tsx +8 -0
- package/src/components/ui/Menu.tsx +1 -1
- package/src/player/lib/pausedVideoDecoder.test.ts +74 -1
- package/src/player/lib/pausedVideoDecoder.ts +23 -12
- package/src/player/store/previewQualitySlice.test.ts +27 -0
- package/src/player/store/previewQualitySlice.ts +12 -0
- package/dist/assets/pausedVideoDecoder-BGKlQc66.js +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{l as V}from"./index-Ccf4_r8m.js";import{bw as G,bN as K,cH as Q,bE as X}from"./codec-DYZ1sJnW.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};
|
|
@@ -303,7 +303,7 @@ var popupSurface = cn(
|
|
|
303
303
|
var POPUP_LAYER = "z-200";
|
|
304
304
|
var menuPopup = cn(popupSurface, "min-w-36 p-1 shadow-menu");
|
|
305
305
|
var itemBase = cn(
|
|
306
|
-
"flex cursor-default select-none items-center justify-between gap-6 rounded-
|
|
306
|
+
"flex cursor-default select-none items-center justify-between gap-6 rounded-[calc(var(--radius-lg)+6px)] px-2 py-1.5",
|
|
307
307
|
"text-step-11 whitespace-nowrap text-text-1",
|
|
308
308
|
"outline-hidden transition-colors ease-out-quint duration-hover",
|
|
309
309
|
"data-[highlighted]:bg-hover data-[highlighted]:text-text-0",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
HyperframesLoader
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-J3VJE463.js";
|
|
4
4
|
import {
|
|
5
5
|
buildProjectApiPath,
|
|
6
6
|
splitTimelineElementKey,
|
|
@@ -587,6 +587,15 @@ function parsePreviewCopies(value) {
|
|
|
587
587
|
var optionalNumber = (n) => typeof n === "number" ? n : void 0;
|
|
588
588
|
var CLOCK_SOURCES = ["audio", "webaudio", "monotonic"];
|
|
589
589
|
var optionalClock = (clock) => CLOCK_SOURCES.find((known) => known === clock);
|
|
590
|
+
function parseHeldBy(value) {
|
|
591
|
+
if (value === null) return null;
|
|
592
|
+
if (typeof value !== "object") return void 0;
|
|
593
|
+
const { kind, readyState, networkState, fetchMs } = value;
|
|
594
|
+
if (kind !== "audio" && kind !== "video") return void 0;
|
|
595
|
+
if (typeof readyState !== "number" || typeof networkState !== "number") return void 0;
|
|
596
|
+
if (typeof fetchMs !== "number" && fetchMs !== null) return void 0;
|
|
597
|
+
return { kind, readyState, networkState, fetchMs };
|
|
598
|
+
}
|
|
590
599
|
function parsePlaybackHealth(value) {
|
|
591
600
|
if (typeof value !== "object" || value === null) return null;
|
|
592
601
|
const extra = value;
|
|
@@ -605,6 +614,7 @@ function parsePlaybackHealth(value) {
|
|
|
605
614
|
gapP50Ms: optionalNumber(extra.gapP50Ms),
|
|
606
615
|
gapP95Ms: optionalNumber(extra.gapP95Ms),
|
|
607
616
|
clockSource: optionalClock(extra.clockSource),
|
|
617
|
+
heldBy: parseHeldBy(extra.heldBy),
|
|
608
618
|
mode: "play"
|
|
609
619
|
};
|
|
610
620
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { Button, ButtonSize, ButtonVariant, ContextMenu, HyperframesLoader, HyperframesLoaderProps, HyperframesLogo, IconButton, Input, InputProps, Menu, MenuItem, MenuItemTone, MenuRadioGroup, MenuRadioItem, MenuSeparator, MenuShortcut, NumberField, NumberFieldProps, Popover, PopupPreviewState, PreviewState, Select, SelectOption, SelectProps, Slider, SliderProps, Tab, TabPanel, Tabs, TabsList, Toggle, ToggleProps, Tooltip, buttonBase, buttonSizes, buttonVariants, cn, fieldBase, fieldText, popupSurface } from './ui.js';
|
|
2
2
|
import * as react from 'react';
|
|
3
3
|
import { RefObject, MutableRefObject, ReactNode, DragEventHandler, ComponentProps, RefCallback, MouseEvent, CSSProperties, UIEvent, PointerEvent } from 'react';
|
|
4
|
-
import { RuntimeTimelineClipIdentity, HyperframePickerElementInfo } from '@hyperframes/core';
|
|
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
7
|
import { Composition } from '@hyperframes/sdk';
|
|
@@ -357,6 +357,7 @@ interface PlaybackHealth {
|
|
|
357
357
|
gapP50Ms?: number;
|
|
358
358
|
gapP95Ms?: number;
|
|
359
359
|
clockSource?: "audio" | "webaudio" | "monotonic";
|
|
360
|
+
heldBy?: PlaybackHeldBy | null;
|
|
360
361
|
mode: "play";
|
|
361
362
|
}
|
|
362
363
|
/** What the preview holds, counts and classes only, filled when asked for. */
|
package/dist/index.html
CHANGED
|
@@ -14,8 +14,8 @@
|
|
|
14
14
|
document.documentElement.dataset.theme = "paper";
|
|
15
15
|
}
|
|
16
16
|
</script>
|
|
17
|
-
<script type="module" crossorigin src="/assets/index-
|
|
18
|
-
<link rel="stylesheet" crossorigin href="/assets/index-
|
|
17
|
+
<script type="module" crossorigin src="/assets/index-Ccf4_r8m.js"></script>
|
|
18
|
+
<link rel="stylesheet" crossorigin href="/assets/index-dsfjBidg.css">
|
|
19
19
|
</head>
|
|
20
20
|
<body>
|
|
21
21
|
<div data-hf-id="hf-aph5" id="root"></div>
|
package/dist/index.js
CHANGED
|
@@ -74,7 +74,7 @@ import {
|
|
|
74
74
|
whileScriptWrites,
|
|
75
75
|
writeStudioUiPreferences,
|
|
76
76
|
zoomToSelectedClips
|
|
77
|
-
} from "./chunk-
|
|
77
|
+
} from "./chunk-LRTUWOR4.js";
|
|
78
78
|
import {
|
|
79
79
|
Button,
|
|
80
80
|
ContextMenu,
|
|
@@ -106,7 +106,7 @@ import {
|
|
|
106
106
|
fieldBase,
|
|
107
107
|
fieldText,
|
|
108
108
|
popupSurface
|
|
109
|
-
} from "./chunk-
|
|
109
|
+
} from "./chunk-J3VJE463.js";
|
|
110
110
|
import {
|
|
111
111
|
DOM_EDIT_LAYER_OBSERVER_INIT,
|
|
112
112
|
buildDefaultDomEditTextField,
|
|
@@ -32285,7 +32285,7 @@ function attachPausedVideoProvider(iframe, win) {
|
|
|
32285
32285
|
async decode(requests, signal) {
|
|
32286
32286
|
signal.throwIfAborted();
|
|
32287
32287
|
if (disposed) throw new DOMException("Preview disposed", "AbortError");
|
|
32288
|
-
decoder ??= import("./pausedVideoDecoder-
|
|
32288
|
+
decoder ??= import("./pausedVideoDecoder-W2SVMXDS.js").then(
|
|
32289
32289
|
({ createPausedVideoDecoder }) => createPausedVideoDecoder(iframe)
|
|
32290
32290
|
);
|
|
32291
32291
|
const actual = await decoder;
|
|
@@ -37,6 +37,7 @@ function previewPresentationTime(timestamp, requested, timing) {
|
|
|
37
37
|
var FRAME_BUDGET = 64 * 1024 * 1024;
|
|
38
38
|
var MAX_READERS = 4;
|
|
39
39
|
var NEARBY_FORWARD_SECONDS = 0.5;
|
|
40
|
+
var ALPHA_DRAIN_WAIT_MS = 2e3;
|
|
40
41
|
async function readSingleSample(reader, query) {
|
|
41
42
|
if (!reader.transparent) return reader.sink.getSample(query);
|
|
42
43
|
let selected = null;
|
|
@@ -84,18 +85,28 @@ function createPausedVideoDecoder(iframe) {
|
|
|
84
85
|
reader.disposed = true;
|
|
85
86
|
clearTimeout(reader.idleTimer);
|
|
86
87
|
if (opened.get(reader.key) === reader) opened.delete(reader.key);
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
88
|
+
const closing = (async () => {
|
|
89
|
+
if (reader.transparent) await reader.tail;
|
|
90
|
+
reader.cancelReads();
|
|
91
|
+
reader.input.dispose();
|
|
92
|
+
await closeIterator(reader).catch(() => {
|
|
93
|
+
});
|
|
94
|
+
for (const entry of reader.cache.values()) {
|
|
95
|
+
cacheOrder.delete(entry);
|
|
96
|
+
bytes -= entry.bytes;
|
|
97
|
+
entry.image.close();
|
|
98
|
+
}
|
|
99
|
+
reader.cache.clear();
|
|
100
|
+
reader.canvas.width = reader.canvas.height = 0;
|
|
101
|
+
})();
|
|
102
|
+
if (!reader.transparent) return closing;
|
|
103
|
+
return new Promise((resolve, reject) => {
|
|
104
|
+
const timeout = setTimeout(() => {
|
|
105
|
+
reader.cancelReads();
|
|
106
|
+
resolve();
|
|
107
|
+
}, ALPHA_DRAIN_WAIT_MS);
|
|
108
|
+
void closing.then(resolve, reject).finally(() => clearTimeout(timeout));
|
|
91
109
|
});
|
|
92
|
-
for (const entry of reader.cache.values()) {
|
|
93
|
-
cacheOrder.delete(entry);
|
|
94
|
-
bytes -= entry.bytes;
|
|
95
|
-
entry.image.close();
|
|
96
|
-
}
|
|
97
|
-
reader.cache.clear();
|
|
98
|
-
reader.canvas.width = reader.canvas.height = 0;
|
|
99
110
|
};
|
|
100
111
|
const scheduleIdle = (reader) => {
|
|
101
112
|
clearTimeout(reader.idleTimer);
|