@rendiv/core 0.1.2 → 0.1.4

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.
@@ -1 +1 @@
1
- {"version":3,"file":"Loop.d.ts","sourceRoot":"","sources":["../../src/components/Loop.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAuB,KAAK,aAAa,EAAE,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAKvF,MAAM,WAAW,SAAS;IACxB,gBAAgB,EAAE,MAAM,CAAC;IACzB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,GAAG,eAAe,CAAC;IAClC,KAAK,CAAC,EAAE,aAAa,CAAC;IACtB,QAAQ,EAAE,SAAS,CAAC;CACrB;AAED,wBAAgB,IAAI,CAAC,EACnB,gBAAgB,EAChB,KAAgB,EAChB,MAAwB,EACxB,KAAK,EACL,QAAQ,GACT,EAAE,SAAS,GAAG,KAAK,CAAC,YAAY,GAAG,IAAI,CA6CvC;yBAnDe,IAAI"}
1
+ {"version":3,"file":"Loop.d.ts","sourceRoot":"","sources":["../../src/components/Loop.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAuB,KAAK,aAAa,EAAE,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAKvF,MAAM,WAAW,SAAS;IACxB,gBAAgB,EAAE,MAAM,CAAC;IACzB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,GAAG,eAAe,CAAC;IAClC,KAAK,CAAC,EAAE,aAAa,CAAC;IACtB,QAAQ,EAAE,SAAS,CAAC;CACrB;AAED,wBAAgB,IAAI,CAAC,EACnB,gBAAgB,EAChB,KAAgB,EAChB,MAAwB,EACxB,KAAK,EACL,QAAQ,GACT,EAAE,SAAS,GAAG,KAAK,CAAC,YAAY,GAAG,IAAI,CA8CvC;yBApDe,IAAI"}
@@ -5,6 +5,8 @@ export interface SequenceProps {
5
5
  name?: string;
6
6
  layout?: 'none' | 'absolute-fill';
7
7
  style?: CSSProperties;
8
+ /** Track index for z-ordering. Lower values render in front (track 0 = frontmost). */
9
+ trackIndex?: number;
8
10
  children: ReactNode;
9
11
  }
10
12
  export declare const Sequence: React.FC<SequenceProps>;
@@ -1 +1 @@
1
- {"version":3,"file":"Sequence.d.ts","sourceRoot":"","sources":["../../src/components/Sequence.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAyC,KAAK,aAAa,EAAE,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAKzG,MAAM,WAAW,aAAa;IAC5B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,GAAG,eAAe,CAAC;IAClC,KAAK,CAAC,EAAE,aAAa,CAAC;IACtB,QAAQ,EAAE,SAAS,CAAC;CACrB;AAED,eAAO,MAAM,QAAQ,EAAE,KAAK,CAAC,EAAE,CAAC,aAAa,CA0D5C,CAAC"}
1
+ {"version":3,"file":"Sequence.d.ts","sourceRoot":"","sources":["../../src/components/Sequence.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAyC,KAAK,aAAa,EAAE,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAOzG,MAAM,WAAW,aAAa;IAC5B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,GAAG,eAAe,CAAC;IAClC,KAAK,CAAC,EAAE,aAAa,CAAC;IACtB,sFAAsF;IACtF,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,SAAS,CAAC;CACrB;AAED,eAAO,MAAM,QAAQ,EAAE,KAAK,CAAC,EAAE,CAAC,aAAa,CAkG5C,CAAC"}
@@ -7,6 +7,8 @@ export interface SeriesSequenceProps {
7
7
  name?: string;
8
8
  layout?: 'none' | 'absolute-fill';
9
9
  style?: CSSProperties;
10
+ /** Track index for z-ordering. Lower values render in front (track 0 = frontmost). */
11
+ trackIndex?: number;
10
12
  children: ReactNode;
11
13
  }
12
14
  export interface SeriesProps {
@@ -1 +1 @@
1
- {"version":3,"file":"Series.d.ts","sourceRoot":"","sources":["../../src/components/Series.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAY,KAAK,aAAa,EAAE,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAG5E,MAAM,WAAW,mBAAmB;IAClC,gBAAgB,EAAE,MAAM,CAAC;IACzB,8EAA8E;IAC9E,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,6DAA6D;IAC7D,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,GAAG,eAAe,CAAC;IAClC,KAAK,CAAC,EAAE,aAAa,CAAC;IACtB,QAAQ,EAAE,SAAS,CAAC;CACrB;AAED,MAAM,WAAW,WAAW;IAC1B,QAAQ,EAAE,SAAS,CAAC;CACrB;AAED,iBAAS,cAAc,CAAC,MAAM,EAAE,mBAAmB,GAAG,KAAK,CAAC,SAAS,CAIpE;kBAJQ,cAAc;;;AAQvB,iBAAS,UAAU,CAAC,EAAE,QAAQ,EAAE,EAAE,WAAW,GAAG,KAAK,CAAC,YAAY,CAwDjE;kBAxDQ,UAAU;;;AA4DnB,eAAO,MAAM,MAAM;;CAEjB,CAAC"}
1
+ {"version":3,"file":"Series.d.ts","sourceRoot":"","sources":["../../src/components/Series.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAY,KAAK,aAAa,EAAE,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAG5E,MAAM,WAAW,mBAAmB;IAClC,gBAAgB,EAAE,MAAM,CAAC;IACzB,8EAA8E;IAC9E,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,6DAA6D;IAC7D,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,GAAG,eAAe,CAAC;IAClC,KAAK,CAAC,EAAE,aAAa,CAAC;IACtB,sFAAsF;IACtF,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,SAAS,CAAC;CACrB;AAED,MAAM,WAAW,WAAW;IAC1B,QAAQ,EAAE,SAAS,CAAC;CACrB;AAED,iBAAS,cAAc,CAAC,MAAM,EAAE,mBAAmB,GAAG,KAAK,CAAC,SAAS,CAIpE;kBAJQ,cAAc;;;AAQvB,iBAAS,UAAU,CAAC,EAAE,QAAQ,EAAE,EAAE,WAAW,GAAG,KAAK,CAAC,YAAY,CA0DjE;kBA1DQ,UAAU;;;AA8DnB,eAAO,MAAM,MAAM;;CAEjB,CAAC"}
@@ -1,5 +1,6 @@
1
1
  export interface SequenceContextValue {
2
2
  id: string | null;
3
+ namePath: string;
3
4
  from: number;
4
5
  durationInFrames: number;
5
6
  parentOffset: number;
@@ -1 +1 @@
1
- {"version":3,"file":"SequenceContext.d.ts","sourceRoot":"","sources":["../../src/context/SequenceContext.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,oBAAoB;IACnC,EAAE,EAAE,MAAM,GAAG,IAAI,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,gBAAgB,EAAE,MAAM,CAAC;IACzB,YAAY,EAAE,MAAM,CAAC;IACrB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,eAAO,MAAM,eAAe,+CAO1B,CAAC"}
1
+ {"version":3,"file":"SequenceContext.d.ts","sourceRoot":"","sources":["../../src/context/SequenceContext.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,oBAAoB;IACnC,EAAE,EAAE,MAAM,GAAG,IAAI,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,gBAAgB,EAAE,MAAM,CAAC;IACzB,YAAY,EAAE,MAAM,CAAC;IACrB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,eAAO,MAAM,eAAe,+CAQ1B,CAAC"}
@@ -1,6 +1,7 @@
1
1
  export interface TimelineEntry {
2
2
  id: string;
3
3
  name: string;
4
+ namePath: string;
4
5
  from: number;
5
6
  durationInFrames: number;
6
7
  parentId: string | null;
@@ -1 +1 @@
1
- {"version":3,"file":"TimelineRegistryContext.d.ts","sourceRoot":"","sources":["../../src/context/TimelineRegistryContext.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,aAAa;IAC5B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,gBAAgB,EAAE,MAAM,CAAC;IACzB,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;CACzB;AAED,MAAM,WAAW,4BAA4B;IAC3C,QAAQ,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,IAAI,CAAC;IACzC,UAAU,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;CAClC;AAED;;;GAGG;AACH,eAAO,MAAM,uBAAuB,8DAA2D,CAAC"}
1
+ {"version":3,"file":"TimelineRegistryContext.d.ts","sourceRoot":"","sources":["../../src/context/TimelineRegistryContext.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,aAAa;IAC5B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,gBAAgB,EAAE,MAAM,CAAC;IACzB,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;CACzB;AAED,MAAM,WAAW,4BAA4B;IAC3C,QAAQ,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,IAAI,CAAC;IACzC,UAAU,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;CAClC;AAED;;;GAGG;AACH,eAAO,MAAM,uBAAuB,8DAA2D,CAAC"}
package/dist/index.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("react"),b=require("react/jsx-runtime"),M=r.createContext({frame:0,playing:!1,playingRef:{current:!1}}),F=r.createContext({id:null,from:0,durationInFrames:1/0,parentOffset:0,accumulatedOffset:0,localOffset:0});function ae(){const e=r.useContext(M),t=r.useContext(F);return e.frame-t.accumulatedOffset}const j=r.createContext(null);function le(){const e=r.useContext(j);if(!e)throw new Error("useCompositionConfig() must be called inside a <Composition>, <Player>, or during rendering.");return e}const D=()=>{},z=r.createContext({compositions:[],registerComposition:D,unregisterComposition:D,currentCompositionId:null,setCurrentCompositionId:D,inputProps:{}}),O=r.createContext(null);function ue(e){const{registerComposition:t,unregisterComposition:n}=r.useContext(z),i=r.useContext(O);return r.useEffect(()=>(t({id:e.id,component:e.component,durationInFrames:e.durationInFrames,fps:e.fps,width:e.width,height:e.height,defaultProps:e.defaultProps??{},group:i,resolveConfig:e.resolveConfig,type:"composition"}),()=>n(e.id)),[e.id]),null}const fe={position:"absolute",top:0,left:0,right:0,bottom:0,width:"100%",height:"100%",display:"flex",flexDirection:"column"},V=r.forwardRef(({style:e,...t},n)=>b.jsx("div",{ref:n,style:{...fe,...e},...t}));V.displayName="Fill";const A=({from:e=0,durationInFrames:t=1/0,name:n,layout:i="absolute-fill",style:o,children:s})=>{const c=r.useContext(F),a=r.useContext(M),f=r.useId(),l=c.accumulatedOffset+e,h=a.frame;r.useEffect(()=>{if(typeof window>"u")return;const y=window;y.__RENDIV_TIMELINE_ENTRIES__||(y.__RENDIV_TIMELINE_ENTRIES__=new Map);const d=y.__RENDIV_TIMELINE_ENTRIES__,u=c.id,m={id:f,name:n??"Sequence",from:l,durationInFrames:t,parentId:u};return d.set(f,m),document.dispatchEvent(new CustomEvent("rendiv:timeline-sync")),()=>{d.delete(f),document.dispatchEvent(new CustomEvent("rendiv:timeline-sync"))}},[f,n,l,t]);const g=r.useMemo(()=>({id:f,from:l,durationInFrames:t,parentOffset:c.accumulatedOffset,accumulatedOffset:l,localOffset:e}),[f,l,t,c.accumulatedOffset,e]);if(h<l||h>=l+t)return null;const x=b.jsx(F.Provider,{value:g,children:s});return i==="none"?x:b.jsx(V,{style:o,children:x})};A.displayName="Sequence";function de(e){const{registerComposition:t,unregisterComposition:n}=r.useContext(z),i=r.useContext(O);return r.useEffect(()=>(t({id:e.id,component:e.component,durationInFrames:1,fps:30,width:e.width,height:e.height,defaultProps:e.defaultProps??{},group:i,type:"still"}),()=>n(e.id)),[e.id]),null}const J=({name:e,children:t})=>{const n=r.useContext(O),i=n?`${n}/${e}`:e;return b.jsx(O.Provider,{value:i,children:t})};J.displayName="Folder";function X(e){throw new Error("<Series.Sequence> can only be used as a direct child of <Series>.")}X.displayName="Series.Sequence";function K({children:e}){const t=r.Children.toArray(e);let n=0;const i=[];for(const o of t){if(!r.isValidElement(o))continue;if(o.type!==X)throw new Error("Only <Series.Sequence> elements are allowed as children of <Series>.");const{durationInFrames:s,offset:c=0,name:a,layout:f,style:l,children:h}=o.props,g=n+c;let x=a;if(!x){const y=r.Children.toArray(h);if(y.length>0){const d=y[0];if(r.isValidElement(d)&&typeof d.type!="string"){const u=d.type;x=u.displayName||u.name}}}i.push(b.jsx(A,{from:g,durationInFrames:s,name:x,layout:f,style:l,children:h},o.key??i.length)),n=g+s}return b.jsx(b.Fragment,{children:i})}K.displayName="Series";const me=Object.assign(K,{Sequence:X});function Q({durationInFrames:e,times:t=1/0,layout:n="absolute-fill",style:i,children:o}){const s=r.useContext(M),c=r.useContext(F),a=s.frame-c.accumulatedOffset;if(a<0||t!==1/0&&a>=e*t)return null;const f=a%e,l=r.useMemo(()=>({frame:f+c.accumulatedOffset,playing:s.playing,playingRef:s.playingRef}),[f,c.accumulatedOffset,s.playing,s.playingRef]),h=r.useMemo(()=>({id:null,from:c.accumulatedOffset,durationInFrames:e,parentOffset:c.accumulatedOffset,accumulatedOffset:c.accumulatedOffset,localOffset:0}),[c.accumulatedOffset,e]),g=b.jsx(M.Provider,{value:l,children:b.jsx(F.Provider,{value:h,children:o})});return n==="none"?g:b.jsx(V,{style:i,children:g})}Q.displayName="Loop";function Z({frame:e,children:t}){const n=r.useContext(M),i=r.useMemo(()=>({frame:e,playing:n.playing,playingRef:n.playingRef}),[e,n.playing,n.playingRef]);return b.jsx(M.Provider,{value:i,children:t})}Z.displayName="Freeze";let he=0;const N=new Map;function P(e,t){const n=++he,i=e??`Handle ${n}`,{timeoutInMilliseconds:o}=t??{};let s=null;return o!==void 0&&o>0&&(s=setTimeout(()=>{if(N.has(n))throw N.delete(n),new Error(`holdRender() timed out after ${o}ms (label: "${i}"). You can increase the timeout by passing a larger timeoutInMilliseconds to holdRender().`)},o)),N.set(n,{label:i,timeoutId:s}),n}function v(e){const t=N.get(e);if(!t)throw new Error(`releaseRender() was called with handle ${e}, but no corresponding holdRender() exists.`);t.timeoutId!==null&&clearTimeout(t.timeoutId),N.delete(e)}function ge(e){throw new Error(`Render cancelled: ${e}`)}function pe(){return N.size}function Ce(){return Array.from(N.values()).map(e=>e.label)}function ee({holdRenderTimeout:e=3e4,onLoad:t,onError:n,...i}){const o=r.useRef(null);r.useEffect(()=>{const a=P(`Loading <Img> with src="${i.src}"`,{timeoutInMilliseconds:e});return o.current=a,()=>{o.current!==null&&(v(o.current),o.current=null)}},[i.src,e]);const s=r.useCallback(a=>{o.current!==null&&(v(o.current),o.current=null),t==null||t(a)},[t]),c=r.useCallback(a=>{o.current!==null&&(v(o.current),o.current=null),n==null||n(a)},[n]);return b.jsx("img",{...i,onLoad:s,onError:c})}ee.displayName="Img";const q=r.createContext({environment:"studio"});function B({src:e,startFrom:t=0,endAt:n,volume:i=1,playbackRate:o=1,muted:s=!1,style:c,className:a,holdRenderTimeout:f=3e4,...l}){const h=r.useRef(null),g=r.useContext(M),x=r.useContext(F),y=r.useContext(j),{environment:d}=r.useContext(q),u=r.useRef(null),m=r.useRef(null),C=d==="rendering",w=(y==null?void 0:y.fps)??30,R=g.frame-x.accumulatedOffset,E=R+t,I=E/w;r.useEffect(()=>{const p=P(`Loading <Video> metadata for src="${e}"`,{timeoutInMilliseconds:f});return u.current=p,()=>{u.current!==null&&(v(u.current),u.current=null)}},[e,f]);const _=r.useCallback(()=>{u.current!==null&&(v(u.current),u.current=null)},[]),$=r.useCallback(()=>{u.current!==null&&(v(u.current),u.current=null)},[]);return r.useEffect(()=>{const p=h.current;p&&(p.volume=i,p.muted=s)},[i,s]),r.useEffect(()=>{const p=h.current;p&&(p.playbackRate=o)},[o]),r.useEffect(()=>{const p=h.current;if(p){if(n!==void 0&&E>=n){p.pause();return}if(C){if(p.pause(),m.current!==I){m.current=I;const S=P(`Seeking <Video> to ${I.toFixed(3)}s`,{timeoutInMilliseconds:f}),k=()=>{v(S),p.removeEventListener("seeked",k)};p.addEventListener("seeked",k),p.currentTime=I}}else Math.abs(p.currentTime-I)>.1&&(p.currentTime=I),g.playing&&p.paused?p.play().catch(()=>{}):!g.playing&&!p.paused&&p.pause()}},[R,C,I,g.playing,n,E,f]),b.jsx("video",{ref:h,src:e,preload:"auto",playsInline:!0,style:c,className:a,onLoadedMetadata:_,onError:$,...l})}B.displayName="Video";function te({src:e,startFrom:t=0,endAt:n,volume:i=1,playbackRate:o=1,muted:s=!1}){const c=r.useRef(null),a=r.useContext(M),f=r.useContext(F),l=r.useContext(j),{environment:h}=r.useContext(q),g=h==="rendering",x=(l==null?void 0:l.fps)??30,y=a.frame-f.accumulatedOffset,d=y+t,u=d/x;return r.useEffect(()=>{if(g)return;const m=c.current;if(!m)return;if(m.volume=i,m.muted=s,m.playbackRate=o,n!==void 0&&d>=n){m.pause();return}Math.abs(m.currentTime-u)>.1&&(m.currentTime=u),a.playing&&m.paused?m.play().catch(()=>{}):!a.playing&&!m.paused&&m.pause()},[y,g,u,a.playing,i,s,o,n,d]),g?null:b.jsx("audio",{ref:c,src:e,preload:"auto"})}te.displayName="Audio";function ne({src:e,width:t,height:n,style:i,className:o,holdRenderTimeout:s=3e4}){const c=r.useRef(null),a=r.useContext(M),f=r.useContext(F),l=r.useContext(j),h=r.useRef([]),g=r.useRef(null),[x,y]=r.useState(!1),d=(l==null?void 0:l.fps)??30,u=a.frame-f.accumulatedOffset;return r.useEffect(()=>{const m=P(`Loading <AnimatedImage> frames from "${e}"`,{timeoutInMilliseconds:s});g.current=m;let C=!1;async function w(){try{const E=await(await fetch(e)).blob();if(typeof ImageDecoder<"u"){const I=new ImageDecoder({data:await E.arrayBuffer(),type:E.type});await I.tracks.ready;const _=I.tracks.selectedTrack;if(!_)throw new Error("No image track found");const $=_.frameCount,p=[];for(let S=0;S<$;S++){const k=await I.decode({frameIndex:S}),se=await createImageBitmap(k.image),ce=(k.image.duration??1e5)/1e3;p.push({image:se,duration:ce}),k.image.close()}I.close(),C||(h.current=p,y(!0))}else{const I=await createImageBitmap(E);C||(h.current=[{image:I,duration:1/0}],y(!0))}}catch(R){console.error("AnimatedImage: failed to decode frames",R)}finally{g.current!==null&&(v(g.current),g.current=null)}}return w(),()=>{C=!0,g.current!==null&&(v(g.current),g.current=null)}},[e,s]),r.useEffect(()=>{if(!x||h.current.length===0)return;const m=c.current;if(!m)return;const C=m.getContext("2d");if(!C)return;const w=h.current,R=u/d*1e3;let E=0;for(const S of w)E+=S.duration;if(E<=0)return;const I=(R%E+E)%E;let _=0,$=0;for(let S=0;S<w.length;S++)if(_+=w[S].duration,I<_){$=S;break}const p=w[$];p&&(m.width=t??p.image.width,m.height=n??p.image.height,C.clearRect(0,0,m.width,m.height),C.drawImage(p.image,0,0,m.width,m.height))},[u,d,x,t,n]),b.jsx("canvas",{ref:c,width:t,height:n,style:i,className:o})}ne.displayName="AnimatedImage";function re({holdRenderTimeout:e=3e4,onLoad:t,onError:n,...i}){const o=r.useRef(null);r.useEffect(()=>{const a=P(`Loading <IFrame> with src="${i.src}"`,{timeoutInMilliseconds:e});return o.current=a,()=>{o.current!==null&&(v(o.current),o.current=null)}},[i.src,e]);const s=r.useCallback(a=>{o.current!==null&&(v(o.current),o.current=null),t==null||t(a)},[t]),c=r.useCallback(a=>{o.current!==null&&(v(o.current),o.current=null),n==null||n(a)},[n]);return b.jsx("iframe",{...i,onLoad:s,onError:c})}re.displayName="IFrame";function oe({src:e,startFrom:t=0,endAt:n,volume:i=1,playbackRate:o=1,muted:s=!1,style:c,className:a,holdRenderTimeout:f=3e4}){const l=r.useContext(M),h=r.useContext(F),g=r.useContext(j),{environment:x}=r.useContext(q),y=x==="rendering",d=(g==null?void 0:g.fps)??30,m=l.frame-h.accumulatedOffset+t,C=m/d;return y?b.jsx(ye,{src:e,currentTime:C,videoFrame:m,endAt:n,style:c,className:a,holdRenderTimeout:f}):b.jsx(B,{src:e,startFrom:t,endAt:n,volume:i,playbackRate:o,muted:s,style:c,className:a,holdRenderTimeout:f})}oe.displayName="OffthreadVideo";function ye({src:e,currentTime:t,videoFrame:n,endAt:i,style:o,className:s,holdRenderTimeout:c}){const[a,f]=r.useState(null),l=r.useRef(null),h=r.useRef(null);if(i!==void 0&&n>=i)return null;r.useEffect(()=>{const y=P(`Extracting <OffthreadVideo> frame at ${t.toFixed(3)}s from "${e}"`,{timeoutInMilliseconds:c});l.current=y;const d=new URLSearchParams({src:e,time:String(t)}),u=`${window.location.origin}/__offthread_video__?${d.toString()}`;let m=!1;return fetch(u).then(C=>{if(!C.ok)throw new Error(`OffthreadVideo: Failed to extract frame (HTTP ${C.status})`);return C.blob()}).then(C=>{if(m)return;h.current&&URL.revokeObjectURL(h.current);const w=URL.createObjectURL(C);h.current=w,f(w)}).catch(C=>{console.error("OffthreadVideo frame extraction error:",C),l.current!==null&&(v(l.current),l.current=null)}),()=>{m=!0,l.current!==null&&(v(l.current),l.current=null)}},[t,e,c]),r.useEffect(()=>()=>{h.current&&(URL.revokeObjectURL(h.current),h.current=null)},[]);const g=r.useCallback(()=>{l.current!==null&&(v(l.current),l.current=null)},[]),x=r.useCallback(()=>{l.current!==null&&(v(l.current),l.current=null)},[]);return a?b.jsx("img",{src:a,style:o,className:s,onLoad:g,onError:x,alt:""}):null}function xe(e,t){for(let n=1;n<t.length;n++)if(e<=t[n])return n-1;return t.length-2}function H(e,t,n,i,o,s){let c;return t===n?c=0:c=(e-t)/(n-t),s&&(c=s(c)),i+c*(o-i)}function L(e,t,n,i){if(t.length!==n.length)throw new Error(`inputRange (${t.length}) and outputRange (${n.length}) must have the same length.`);if(t.length<2)throw new Error("inputRange and outputRange must have at least 2 elements.");for(let f=1;f<t.length;f++)if(t[f]<t[f-1])throw new Error("inputRange must be monotonically non-decreasing.");const{easing:o,extrapolateLeft:s="extend",extrapolateRight:c="extend"}=i??{};if(e<t[0])return s==="clamp"?n[0]:s==="identity"?e:H(e,t[0],t[1],n[0],n[1],o);if(e>t[t.length-1]){if(c==="clamp")return n[n.length-1];if(c==="identity")return e;const f=t.length-1;return H(e,t[f-1],t[f],n[f-1],n[f],o)}const a=xe(e,t);return H(e,t[a],t[a+1],n[a],n[a+1],o)}function we(e,t,n,i,o,s,c){const a=-i*(e-n),f=-o*t,l=(a+f)/s,h=t+l*c;return{position:e+h*c,velocity:h}}function ie(e){const{frame:t,fps:n,config:i={},from:o=0,to:s=1,durationInFrames:c,durationRestThreshold:a=.005}=e,{damping:f=10,mass:l=1,stiffness:h=100,clampOvershoot:g=!1}=i;if(t<0)return o;if(c!==void 0&&t>=c)return s;const x=1/n,y=4,d=x/y;let u=o,m=0;for(let C=0;C<t;C++){for(let w=0;w<y;w++){const R=we(u,m,s,h,f,l,d);u=R.position,m=R.velocity}if(g&&(o<s?u=Math.min(u,s):u=Math.max(u,s),u===s&&(m=0)),Math.abs(u-s)<a&&Math.abs(m)<a)return s}return u}function be(e){const{fps:t,config:n,from:i=0,to:o=1,threshold:s=.005}=e,c=t*60;for(let a=0;a<c;a++){const f=ie({frame:a,fps:t,config:n,from:i,to:o,durationRestThreshold:s});if(Math.abs(f-o)<s)return a}return c}function T(e,t,n,i){const o=3*e,s=3*(n-e)-o,c=1-o-s,a=3*t,f=3*(i-t)-a,l=1-a-f;function h(d){return((c*d+s)*d+o)*d}function g(d){return((l*d+f)*d+a)*d}function x(d){return(3*c*d+2*s)*d+o}function y(d){let u=d;for(let w=0;w<8;w++){const R=h(u)-d;if(Math.abs(R)<1e-7)return u;const E=x(u);if(Math.abs(E)<1e-7)break;u-=R/E}let m=0,C=1;for(u=d;m<C;){const w=h(u);if(Math.abs(w-d)<1e-7)return u;d>w?m=u:C=u,u=(m+C)/2}return u}return d=>d<=0?0:d>=1?1:g(y(d))}const ve={linear:(e=>e),ease:T(.25,.1,.25,1),easeIn:T(.42,0,1,1),easeOut:T(0,0,.58,1),easeInOut:T(.42,0,.58,1),bezier:T,bounce:(e=>e<1/2.75?7.5625*e*e:e<2/2.75?7.5625*(e-=1.5/2.75)*e+.75:e<2.5/2.75?7.5625*(e-=2.25/2.75)*e+.9375:7.5625*(e-=2.625/2.75)*e+.984375),elastic:(e=1)=>{const t=.3/Math.max(e,.001);return n=>n<=0?0:n>=1?1:Math.pow(2,-10*n)*Math.sin((n-t/4)*(2*Math.PI)/t)+1},in:e=>e,out:e=>t=>1-e(1-t),inOut:e=>t=>t<.5?e(t*2)/2:1-e((1-t)*2)/2};function W(e){let t=e.replace("#","");t.length===3&&(t=t[0]+t[0]+t[1]+t[1]+t[2]+t[2]),t.length===6&&(t+="ff");const n=parseInt(t,16);return[n>>24&255,n>>16&255,n>>8&255,(n&255)/255]}function Y(e){const t=e.match(/rgba?\(\s*([\d.]+)\s*,\s*([\d.]+)\s*,\s*([\d.]+)(?:\s*,\s*([\d.]+))?\s*\)/);if(t)return[Number(t[1]),Number(t[2]),Number(t[3]),t[4]!==void 0?Number(t[4]):1];throw new Error(`Cannot parse color: ${e}`)}const G={black:"#000000",white:"#ffffff",red:"#ff0000",green:"#008000",blue:"#0000ff",yellow:"#ffff00",cyan:"#00ffff",magenta:"#ff00ff",orange:"#ffa500",purple:"#800080",pink:"#ffc0cb",gray:"#808080",grey:"#808080",transparent:"rgba(0,0,0,0)"};function Ee(e){const t=e.trim().toLowerCase();if(G[t]){const n=G[t];return n.startsWith("#")?W(n):Y(n)}if(t.startsWith("#"))return W(t);if(t.startsWith("rgb"))return Y(t);throw new Error(`Unsupported color format: ${e}`)}function Ie(e){const[t,n,i,o]=e;return o===1?`rgb(${Math.round(t)}, ${Math.round(n)}, ${Math.round(i)})`:`rgba(${Math.round(t)}, ${Math.round(n)}, ${Math.round(i)}, ${Number(o.toFixed(3))})`}function Re(e,t,n,i){if(t.length!==n.length)throw new Error("inputRange and outputRange must have the same length.");const o=n.map(Ee),s=L(e,t,o.map(l=>l[0]),i),c=L(e,t,o.map(l=>l[1]),i),a=L(e,t,o.map(l=>l[2]),i),f=L(e,t,o.map(l=>l[3]),i);return Ie([Math.max(0,Math.min(255,s)),Math.max(0,Math.min(255,c)),Math.max(0,Math.min(255,a)),Math.max(0,Math.min(1,f))])}let U=null;function Se(e){if(U!==null)throw new Error("setRootComponent() can only be called once.");U=e}function Me(){return U}function Fe(e){return`/${e.startsWith("/")?e.slice(1):e}`}function _e(){return typeof window<"u"&&window.__RENDIV_INPUT_PROPS__?window.__RENDIV_INPUT_PROPS__:{}}function Ne(){const{environment:e}=r.useContext(q);return{isStudio:e==="studio",isRendering:e==="rendering",isPlayer:e==="player"}}function Pe(){if(typeof window<"u"){const e=window.__RENDIV_ENVIRONMENT__;return{isStudio:e==="studio",isRendering:e==="rendering",isPlayer:e==="player"}}return{isStudio:!1,isRendering:!1,isPlayer:!1}}const $e=r.createContext(null);exports.AnimatedImage=ne;exports.Audio=te;exports.Composition=ue;exports.CompositionContext=j;exports.CompositionManagerContext=z;exports.Easing=ve;exports.Fill=V;exports.Folder=J;exports.FolderContext=O;exports.Freeze=Z;exports.IFrame=re;exports.Img=ee;exports.Loop=Q;exports.OffthreadVideo=oe;exports.RendivEnvironmentContext=q;exports.Sequence=A;exports.SequenceContext=F;exports.Series=me;exports.Still=de;exports.TimelineContext=M;exports.TimelineRegistryContext=$e;exports.Video=B;exports.abortRender=ge;exports.blendColors=Re;exports.getInputProps=_e;exports.getPendingHoldCount=pe;exports.getPendingHoldLabels=Ce;exports.getRendivEnvironment=Pe;exports.getRootComponent=Me;exports.getSpringDuration=be;exports.holdRender=P;exports.interpolate=L;exports.releaseRender=v;exports.setRootComponent=Se;exports.spring=ie;exports.staticFile=Fe;exports.useCompositionConfig=le;exports.useFrame=ae;exports.useRendivEnvironment=Ne;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("react"),v=require("react/jsx-runtime"),F=r.createContext({frame:0,playing:!1,playingRef:{current:!1}}),N=r.createContext({id:null,namePath:"",from:0,durationInFrames:1/0,parentOffset:0,accumulatedOffset:0,localOffset:0});function ce(){const e=r.useContext(F),t=r.useContext(N);return e.frame-t.accumulatedOffset}const T=r.createContext(null);function le(){const e=r.useContext(T);if(!e)throw new Error("useCompositionConfig() must be called inside a <Composition>, <Player>, or during rendering.");return e}const H=()=>{},z=r.createContext({compositions:[],registerComposition:H,unregisterComposition:H,currentCompositionId:null,setCurrentCompositionId:H,inputProps:{}}),O=r.createContext(null);function ue(e){const{registerComposition:t,unregisterComposition:n}=r.useContext(z),i=r.useContext(O);return r.useEffect(()=>(t({id:e.id,component:e.component,durationInFrames:e.durationInFrames,fps:e.fps,width:e.width,height:e.height,defaultProps:e.defaultProps??{},group:i,resolveConfig:e.resolveConfig,type:"composition"}),()=>n(e.id)),[e.id]),null}const fe={position:"absolute",top:0,left:0,right:0,bottom:0,width:"100%",height:"100%",display:"flex",flexDirection:"column"},q=r.forwardRef(({style:e,...t},n)=>v.jsx("div",{ref:n,style:{...fe,...e},...t}));q.displayName="Fill";const X=({from:e=0,durationInFrames:t=1/0,name:n,layout:i="absolute-fill",style:o,trackIndex:a=0,children:c})=>{const s=r.useContext(N),m=r.useContext(F),f=r.useContext(T),h=r.useId(),g=n??"Sequence",w=`${g}[${e}]`,y=f?`${f.id}/`:"",d=s.namePath?`${s.namePath}/${w}`:`${y}${w}`;let l=s.accumulatedOffset+e,p=t,x=a;if(typeof window<"u"){const b=window.__RENDIV_TIMELINE_OVERRIDES__,M=b==null?void 0:b.get(d);M&&(l=M.from,p=M.durationInFrames,M.trackIndex!==void 0&&(x=M.trackIndex))}const S=x!==void 0?1e4-x:void 0,I=m.frame;r.useEffect(()=>{if(typeof window>"u")return;const C=window;C.__RENDIV_TIMELINE_ENTRIES__||(C.__RENDIV_TIMELINE_ENTRIES__=new Map);const b=C.__RENDIV_TIMELINE_ENTRIES__,M=s.id,D={id:h,name:g,namePath:d,from:l,durationInFrames:p,parentId:M};return b.set(h,D),document.dispatchEvent(new CustomEvent("rendiv:timeline-sync")),()=>{b.delete(h),document.dispatchEvent(new CustomEvent("rendiv:timeline-sync"))}},[h,g,d,l,p]);const E=r.useMemo(()=>({id:h,namePath:d,from:l,durationInFrames:p,parentOffset:s.accumulatedOffset,accumulatedOffset:l,localOffset:e}),[h,d,l,p,s.accumulatedOffset,e]);if(I<l||I>=l+p)return null;const _=v.jsx(N.Provider,{value:E,children:c});if(i==="none")return _;const P=S!==void 0?{...o,zIndex:S}:o;return v.jsx(q,{style:P,children:_})};X.displayName="Sequence";function de(e){const{registerComposition:t,unregisterComposition:n}=r.useContext(z),i=r.useContext(O);return r.useEffect(()=>(t({id:e.id,component:e.component,durationInFrames:1,fps:30,width:e.width,height:e.height,defaultProps:e.defaultProps??{},group:i,type:"still"}),()=>n(e.id)),[e.id]),null}const J=({name:e,children:t})=>{const n=r.useContext(O),i=n?`${n}/${e}`:e;return v.jsx(O.Provider,{value:i,children:t})};J.displayName="Folder";function B(e){throw new Error("<Series.Sequence> can only be used as a direct child of <Series>.")}B.displayName="Series.Sequence";function K({children:e}){const t=r.Children.toArray(e);let n=0;const i=[];for(const o of t){if(!r.isValidElement(o))continue;if(o.type!==B)throw new Error("Only <Series.Sequence> elements are allowed as children of <Series>.");const{durationInFrames:a,offset:c=0,name:s,layout:m,style:f,trackIndex:h,children:g}=o.props,w=n+c;let y=s;if(!y){const d=r.Children.toArray(g);if(d.length>0){const u=d[0];if(r.isValidElement(u)&&typeof u.type!="string"){const l=u.type;y=l.displayName||l.name}}}i.push(v.jsx(X,{from:w,durationInFrames:a,name:y,layout:m,style:f,trackIndex:h,children:g},o.key??i.length)),n=w+a}return v.jsx(v.Fragment,{children:i})}K.displayName="Series";const me=Object.assign(K,{Sequence:B});function Q({durationInFrames:e,times:t=1/0,layout:n="absolute-fill",style:i,children:o}){const a=r.useContext(F),c=r.useContext(N),s=a.frame-c.accumulatedOffset;if(s<0||t!==1/0&&s>=e*t)return null;const m=s%e,f=r.useMemo(()=>({frame:m+c.accumulatedOffset,playing:a.playing,playingRef:a.playingRef}),[m,c.accumulatedOffset,a.playing,a.playingRef]),h=r.useMemo(()=>({id:null,namePath:c.namePath,from:c.accumulatedOffset,durationInFrames:e,parentOffset:c.accumulatedOffset,accumulatedOffset:c.accumulatedOffset,localOffset:0}),[c.namePath,c.accumulatedOffset,e]),g=v.jsx(F.Provider,{value:f,children:v.jsx(N.Provider,{value:h,children:o})});return n==="none"?g:v.jsx(q,{style:i,children:g})}Q.displayName="Loop";function ee({frame:e,children:t}){const n=r.useContext(F),i=r.useMemo(()=>({frame:e,playing:n.playing,playingRef:n.playingRef}),[e,n.playing,n.playingRef]);return v.jsx(F.Provider,{value:i,children:t})}ee.displayName="Freeze";let he=0;const $=new Map;function k(e,t){const n=++he,i=e??`Handle ${n}`,{timeoutInMilliseconds:o}=t??{};let a=null;return o!==void 0&&o>0&&(a=setTimeout(()=>{if($.has(n))throw $.delete(n),new Error(`holdRender() timed out after ${o}ms (label: "${i}"). You can increase the timeout by passing a larger timeoutInMilliseconds to holdRender().`)},o)),$.set(n,{label:i,timeoutId:a}),n}function R(e){const t=$.get(e);if(!t)throw new Error(`releaseRender() was called with handle ${e}, but no corresponding holdRender() exists.`);t.timeoutId!==null&&clearTimeout(t.timeoutId),$.delete(e)}function ge(e){throw new Error(`Render cancelled: ${e}`)}function pe(){return $.size}function Ce(){return Array.from($.values()).map(e=>e.label)}function te({holdRenderTimeout:e=3e4,onLoad:t,onError:n,...i}){const o=r.useRef(null);r.useEffect(()=>{const s=k(`Loading <Img> with src="${i.src}"`,{timeoutInMilliseconds:e});return o.current=s,()=>{o.current!==null&&(R(o.current),o.current=null)}},[i.src,e]);const a=r.useCallback(s=>{o.current!==null&&(R(o.current),o.current=null),t==null||t(s)},[t]),c=r.useCallback(s=>{o.current!==null&&(R(o.current),o.current=null),n==null||n(s)},[n]);return v.jsx("img",{...i,onLoad:a,onError:c})}te.displayName="Img";const V=r.createContext({environment:"studio"});function W({src:e,startFrom:t=0,endAt:n,volume:i=1,playbackRate:o=1,muted:a=!1,style:c,className:s,holdRenderTimeout:m=3e4,...f}){const h=r.useRef(null),g=r.useContext(F),w=r.useContext(N),y=r.useContext(T),{environment:d}=r.useContext(V),u=r.useRef(null),l=r.useRef(null),p=d==="rendering",x=(y==null?void 0:y.fps)??30,S=g.frame-w.accumulatedOffset,I=S+t,E=I/x;r.useEffect(()=>{const C=k(`Loading <Video> metadata for src="${e}"`,{timeoutInMilliseconds:m});return u.current=C,()=>{u.current!==null&&(R(u.current),u.current=null)}},[e,m]);const _=r.useCallback(()=>{u.current!==null&&(R(u.current),u.current=null)},[]),P=r.useCallback(()=>{u.current!==null&&(R(u.current),u.current=null)},[]);return r.useEffect(()=>{const C=h.current;C&&(C.volume=i,C.muted=a)},[i,a]),r.useEffect(()=>{const C=h.current;C&&(C.playbackRate=o)},[o]),r.useEffect(()=>{const C=h.current;if(C){if(n!==void 0&&I>=n){C.pause();return}if(p){if(C.pause(),l.current!==E){l.current=E;const b=k(`Seeking <Video> to ${E.toFixed(3)}s`,{timeoutInMilliseconds:m}),M=()=>{R(b),C.removeEventListener("seeked",M)};C.addEventListener("seeked",M),C.currentTime=E}}else Math.abs(C.currentTime-E)>.1&&(C.currentTime=E),g.playing&&C.paused?C.play().catch(()=>{}):!g.playing&&!C.paused&&C.pause()}},[S,p,E,g.playing,n,I,m]),v.jsx("video",{ref:h,src:e,preload:"auto",playsInline:!0,style:c,className:s,onLoadedMetadata:_,onError:P,...f})}W.displayName="Video";function ne({src:e,startFrom:t=0,endAt:n,volume:i=1,playbackRate:o=1,muted:a=!1}){const c=r.useRef(null),s=r.useContext(F),m=r.useContext(N),f=r.useContext(T),{environment:h}=r.useContext(V),g=h==="rendering",w=(f==null?void 0:f.fps)??30,y=s.frame-m.accumulatedOffset,d=y+t,u=d/w;return r.useEffect(()=>{if(g)return;const l=c.current;if(!l)return;if(l.volume=i,l.muted=a,l.playbackRate=o,n!==void 0&&d>=n){l.pause();return}Math.abs(l.currentTime-u)>.1&&(l.currentTime=u),s.playing&&l.paused?l.play().catch(()=>{}):!s.playing&&!l.paused&&l.pause()},[y,g,u,s.playing,i,a,o,n,d]),g?null:v.jsx("audio",{ref:c,src:e,preload:"auto"})}ne.displayName="Audio";function re({src:e,width:t,height:n,style:i,className:o,holdRenderTimeout:a=3e4}){const c=r.useRef(null),s=r.useContext(F),m=r.useContext(N),f=r.useContext(T),h=r.useRef([]),g=r.useRef(null),[w,y]=r.useState(!1),d=(f==null?void 0:f.fps)??30,u=s.frame-m.accumulatedOffset;return r.useEffect(()=>{const l=k(`Loading <AnimatedImage> frames from "${e}"`,{timeoutInMilliseconds:a});g.current=l;let p=!1;async function x(){try{const I=await(await fetch(e)).blob();if(typeof ImageDecoder<"u"){const E=new ImageDecoder({data:await I.arrayBuffer(),type:I.type});await E.tracks.ready;const _=E.tracks.selectedTrack;if(!_)throw new Error("No image track found");const P=_.frameCount,C=[];for(let b=0;b<P;b++){const M=await E.decode({frameIndex:b}),D=await createImageBitmap(M.image),ae=(M.image.duration??1e5)/1e3;C.push({image:D,duration:ae}),M.image.close()}E.close(),p||(h.current=C,y(!0))}else{const E=await createImageBitmap(I);p||(h.current=[{image:E,duration:1/0}],y(!0))}}catch(S){console.error("AnimatedImage: failed to decode frames",S)}finally{g.current!==null&&(R(g.current),g.current=null)}}return x(),()=>{p=!0,g.current!==null&&(R(g.current),g.current=null)}},[e,a]),r.useEffect(()=>{if(!w||h.current.length===0)return;const l=c.current;if(!l)return;const p=l.getContext("2d");if(!p)return;const x=h.current,S=u/d*1e3;let I=0;for(const b of x)I+=b.duration;if(I<=0)return;const E=(S%I+I)%I;let _=0,P=0;for(let b=0;b<x.length;b++)if(_+=x[b].duration,E<_){P=b;break}const C=x[P];C&&(l.width=t??C.image.width,l.height=n??C.image.height,p.clearRect(0,0,l.width,l.height),p.drawImage(C.image,0,0,l.width,l.height))},[u,d,w,t,n]),v.jsx("canvas",{ref:c,width:t,height:n,style:i,className:o})}re.displayName="AnimatedImage";function oe({holdRenderTimeout:e=3e4,onLoad:t,onError:n,...i}){const o=r.useRef(null);r.useEffect(()=>{const s=k(`Loading <IFrame> with src="${i.src}"`,{timeoutInMilliseconds:e});return o.current=s,()=>{o.current!==null&&(R(o.current),o.current=null)}},[i.src,e]);const a=r.useCallback(s=>{o.current!==null&&(R(o.current),o.current=null),t==null||t(s)},[t]),c=r.useCallback(s=>{o.current!==null&&(R(o.current),o.current=null),n==null||n(s)},[n]);return v.jsx("iframe",{...i,onLoad:a,onError:c})}oe.displayName="IFrame";function ie({src:e,startFrom:t=0,endAt:n,volume:i=1,playbackRate:o=1,muted:a=!1,style:c,className:s,holdRenderTimeout:m=3e4}){const f=r.useContext(F),h=r.useContext(N),g=r.useContext(T),{environment:w}=r.useContext(V),y=w==="rendering",d=(g==null?void 0:g.fps)??30,l=f.frame-h.accumulatedOffset+t,p=l/d;return y?v.jsx(ye,{src:e,currentTime:p,videoFrame:l,endAt:n,style:c,className:s,holdRenderTimeout:m}):v.jsx(W,{src:e,startFrom:t,endAt:n,volume:i,playbackRate:o,muted:a,style:c,className:s,holdRenderTimeout:m})}ie.displayName="OffthreadVideo";function ye({src:e,currentTime:t,videoFrame:n,endAt:i,style:o,className:a,holdRenderTimeout:c}){const[s,m]=r.useState(null),f=r.useRef(null),h=r.useRef(null);if(i!==void 0&&n>=i)return null;r.useEffect(()=>{const y=k(`Extracting <OffthreadVideo> frame at ${t.toFixed(3)}s from "${e}"`,{timeoutInMilliseconds:c});f.current=y;const d=new URLSearchParams({src:e,time:String(t)}),u=`${window.location.origin}/__offthread_video__?${d.toString()}`;let l=!1;return fetch(u).then(p=>{if(!p.ok)throw new Error(`OffthreadVideo: Failed to extract frame (HTTP ${p.status})`);return p.blob()}).then(p=>{if(l)return;h.current&&URL.revokeObjectURL(h.current);const x=URL.createObjectURL(p);h.current=x,m(x)}).catch(p=>{console.error("OffthreadVideo frame extraction error:",p),f.current!==null&&(R(f.current),f.current=null)}),()=>{l=!0,f.current!==null&&(R(f.current),f.current=null)}},[t,e,c]),r.useEffect(()=>()=>{h.current&&(URL.revokeObjectURL(h.current),h.current=null)},[]);const g=r.useCallback(()=>{f.current!==null&&(R(f.current),f.current=null)},[]),w=r.useCallback(()=>{f.current!==null&&(R(f.current),f.current=null)},[]);return s?v.jsx("img",{src:s,style:o,className:a,onLoad:g,onError:w,alt:""}):null}function xe(e,t){for(let n=1;n<t.length;n++)if(e<=t[n])return n-1;return t.length-2}function U(e,t,n,i,o,a){let c;return t===n?c=0:c=(e-t)/(n-t),a&&(c=a(c)),i+c*(o-i)}function L(e,t,n,i){if(t.length!==n.length)throw new Error(`inputRange (${t.length}) and outputRange (${n.length}) must have the same length.`);if(t.length<2)throw new Error("inputRange and outputRange must have at least 2 elements.");for(let m=1;m<t.length;m++)if(t[m]<t[m-1])throw new Error("inputRange must be monotonically non-decreasing.");const{easing:o,extrapolateLeft:a="extend",extrapolateRight:c="extend"}=i??{};if(e<t[0])return a==="clamp"?n[0]:a==="identity"?e:U(e,t[0],t[1],n[0],n[1],o);if(e>t[t.length-1]){if(c==="clamp")return n[n.length-1];if(c==="identity")return e;const m=t.length-1;return U(e,t[m-1],t[m],n[m-1],n[m],o)}const s=xe(e,t);return U(e,t[s],t[s+1],n[s],n[s+1],o)}function we(e,t,n,i,o,a,c){const s=-i*(e-n),m=-o*t,f=(s+m)/a,h=t+f*c;return{position:e+h*c,velocity:h}}function se(e){const{frame:t,fps:n,config:i={},from:o=0,to:a=1,durationInFrames:c,durationRestThreshold:s=.005}=e,{damping:m=10,mass:f=1,stiffness:h=100,clampOvershoot:g=!1}=i;if(t<0)return o;if(c!==void 0&&t>=c)return a;const w=1/n,y=4,d=w/y;let u=o,l=0;for(let p=0;p<t;p++){for(let x=0;x<y;x++){const S=we(u,l,a,h,m,f,d);u=S.position,l=S.velocity}if(g&&(o<a?u=Math.min(u,a):u=Math.max(u,a),u===a&&(l=0)),Math.abs(u-a)<s&&Math.abs(l)<s)return a}return u}function be(e){const{fps:t,config:n,from:i=0,to:o=1,threshold:a=.005}=e,c=t*60;for(let s=0;s<c;s++){const m=se({frame:s,fps:t,config:n,from:i,to:o,durationRestThreshold:a});if(Math.abs(m-o)<a)return s}return c}function j(e,t,n,i){const o=3*e,a=3*(n-e)-o,c=1-o-a,s=3*t,m=3*(i-t)-s,f=1-s-m;function h(d){return((c*d+a)*d+o)*d}function g(d){return((f*d+m)*d+s)*d}function w(d){return(3*c*d+2*a)*d+o}function y(d){let u=d;for(let x=0;x<8;x++){const S=h(u)-d;if(Math.abs(S)<1e-7)return u;const I=w(u);if(Math.abs(I)<1e-7)break;u-=S/I}let l=0,p=1;for(u=d;l<p;){const x=h(u);if(Math.abs(x-d)<1e-7)return u;d>x?l=u:p=u,u=(l+p)/2}return u}return d=>d<=0?0:d>=1?1:g(y(d))}const Ie={linear:(e=>e),ease:j(.25,.1,.25,1),easeIn:j(.42,0,1,1),easeOut:j(0,0,.58,1),easeInOut:j(.42,0,.58,1),bezier:j,bounce:(e=>e<1/2.75?7.5625*e*e:e<2/2.75?7.5625*(e-=1.5/2.75)*e+.75:e<2.5/2.75?7.5625*(e-=2.25/2.75)*e+.9375:7.5625*(e-=2.625/2.75)*e+.984375),elastic:(e=1)=>{const t=.3/Math.max(e,.001);return n=>n<=0?0:n>=1?1:Math.pow(2,-10*n)*Math.sin((n-t/4)*(2*Math.PI)/t)+1},in:e=>e,out:e=>t=>1-e(1-t),inOut:e=>t=>t<.5?e(t*2)/2:1-e((1-t)*2)/2};function Y(e){let t=e.replace("#","");t.length===3&&(t=t[0]+t[0]+t[1]+t[1]+t[2]+t[2]),t.length===6&&(t+="ff");const n=parseInt(t,16);return[n>>24&255,n>>16&255,n>>8&255,(n&255)/255]}function Z(e){const t=e.match(/rgba?\(\s*([\d.]+)\s*,\s*([\d.]+)\s*,\s*([\d.]+)(?:\s*,\s*([\d.]+))?\s*\)/);if(t)return[Number(t[1]),Number(t[2]),Number(t[3]),t[4]!==void 0?Number(t[4]):1];throw new Error(`Cannot parse color: ${e}`)}const G={black:"#000000",white:"#ffffff",red:"#ff0000",green:"#008000",blue:"#0000ff",yellow:"#ffff00",cyan:"#00ffff",magenta:"#ff00ff",orange:"#ffa500",purple:"#800080",pink:"#ffc0cb",gray:"#808080",grey:"#808080",transparent:"rgba(0,0,0,0)"};function ve(e){const t=e.trim().toLowerCase();if(G[t]){const n=G[t];return n.startsWith("#")?Y(n):Z(n)}if(t.startsWith("#"))return Y(t);if(t.startsWith("rgb"))return Z(t);throw new Error(`Unsupported color format: ${e}`)}function Ee(e){const[t,n,i,o]=e;return o===1?`rgb(${Math.round(t)}, ${Math.round(n)}, ${Math.round(i)})`:`rgba(${Math.round(t)}, ${Math.round(n)}, ${Math.round(i)}, ${Number(o.toFixed(3))})`}function Re(e,t,n,i){if(t.length!==n.length)throw new Error("inputRange and outputRange must have the same length.");const o=n.map(ve),a=L(e,t,o.map(f=>f[0]),i),c=L(e,t,o.map(f=>f[1]),i),s=L(e,t,o.map(f=>f[2]),i),m=L(e,t,o.map(f=>f[3]),i);return Ee([Math.max(0,Math.min(255,a)),Math.max(0,Math.min(255,c)),Math.max(0,Math.min(255,s)),Math.max(0,Math.min(1,m))])}let A=null;function Se(e){if(A!==null)throw new Error("setRootComponent() can only be called once.");A=e}function Me(){return A}function Fe(e){return`/${e.startsWith("/")?e.slice(1):e}`}function _e(){return typeof window<"u"&&window.__RENDIV_INPUT_PROPS__?window.__RENDIV_INPUT_PROPS__:{}}function Ne(){const{environment:e}=r.useContext(V);return{isStudio:e==="studio",isRendering:e==="rendering",isPlayer:e==="player"}}function Pe(){if(typeof window<"u"){const e=window.__RENDIV_ENVIRONMENT__;return{isStudio:e==="studio",isRendering:e==="rendering",isPlayer:e==="player"}}return{isStudio:!1,isRendering:!1,isPlayer:!1}}const $e=r.createContext(null);exports.AnimatedImage=re;exports.Audio=ne;exports.Composition=ue;exports.CompositionContext=T;exports.CompositionManagerContext=z;exports.Easing=Ie;exports.Fill=q;exports.Folder=J;exports.FolderContext=O;exports.Freeze=ee;exports.IFrame=oe;exports.Img=te;exports.Loop=Q;exports.OffthreadVideo=ie;exports.RendivEnvironmentContext=V;exports.Sequence=X;exports.SequenceContext=N;exports.Series=me;exports.Still=de;exports.TimelineContext=F;exports.TimelineRegistryContext=$e;exports.Video=W;exports.abortRender=ge;exports.blendColors=Re;exports.getInputProps=_e;exports.getPendingHoldCount=pe;exports.getPendingHoldLabels=Ce;exports.getRendivEnvironment=Pe;exports.getRootComponent=Me;exports.getSpringDuration=be;exports.holdRender=k;exports.interpolate=L;exports.releaseRender=R;exports.setRootComponent=Se;exports.spring=se;exports.staticFile=Fe;exports.useCompositionConfig=le;exports.useFrame=ce;exports.useRendivEnvironment=Ne;
package/dist/index.d.ts CHANGED
@@ -31,4 +31,5 @@ export { RendivEnvironmentContext, type RendivEnvironment, type RendivEnvironmen
31
31
  export { CompositionManagerContext, type CompositionManagerContextValue, type CompositionEntry, type ResolveConfigFunction, } from './context/CompositionManagerContext';
32
32
  export { FolderContext } from './context/FolderContext';
33
33
  export { TimelineRegistryContext, type TimelineRegistryContextValue, type TimelineEntry, } from './context/TimelineRegistryContext';
34
+ export { type TimelineOverride } from './types/timeline-override';
34
35
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1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