@codellyson/framely 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (209) hide show
  1. package/dist/AbsoluteFill.d.ts +18 -0
  2. package/dist/AbsoluteFill.d.ts.map +1 -0
  3. package/dist/AbsoluteFill.js +25 -0
  4. package/dist/AbsoluteFill.js.map +1 -0
  5. package/dist/Audio.d.ts +80 -0
  6. package/dist/Audio.d.ts.map +1 -0
  7. package/dist/Audio.js +221 -0
  8. package/dist/Audio.js.map +1 -0
  9. package/dist/Composition.d.ts +208 -0
  10. package/dist/Composition.d.ts.map +1 -0
  11. package/dist/Composition.js +210 -0
  12. package/dist/Composition.js.map +1 -0
  13. package/dist/Easing.d.ts +88 -0
  14. package/dist/Easing.d.ts.map +1 -0
  15. package/dist/Easing.js +266 -0
  16. package/dist/Easing.js.map +1 -0
  17. package/dist/ErrorBoundary.d.ts +35 -0
  18. package/dist/ErrorBoundary.d.ts.map +1 -0
  19. package/dist/ErrorBoundary.js +74 -0
  20. package/dist/ErrorBoundary.js.map +1 -0
  21. package/dist/Folder.d.ts +46 -0
  22. package/dist/Folder.d.ts.map +1 -0
  23. package/dist/Folder.js +44 -0
  24. package/dist/Folder.js.map +1 -0
  25. package/dist/Freeze.d.ts +35 -0
  26. package/dist/Freeze.d.ts.map +1 -0
  27. package/dist/Freeze.js +40 -0
  28. package/dist/Freeze.js.map +1 -0
  29. package/dist/IFrame.d.ts +28 -0
  30. package/dist/IFrame.d.ts.map +1 -0
  31. package/dist/IFrame.js +57 -0
  32. package/dist/IFrame.js.map +1 -0
  33. package/dist/Img.d.ts +36 -0
  34. package/dist/Img.d.ts.map +1 -0
  35. package/dist/Img.js +91 -0
  36. package/dist/Img.js.map +1 -0
  37. package/dist/Loop.d.ts +66 -0
  38. package/dist/Loop.d.ts.map +1 -0
  39. package/dist/Loop.js +79 -0
  40. package/dist/Loop.js.map +1 -0
  41. package/dist/Player.d.ts +118 -0
  42. package/dist/Player.d.ts.map +1 -0
  43. package/dist/Player.js +311 -0
  44. package/dist/Player.js.map +1 -0
  45. package/dist/Sequence.d.ts +25 -0
  46. package/dist/Sequence.d.ts.map +1 -0
  47. package/dist/Sequence.js +37 -0
  48. package/dist/Sequence.js.map +1 -0
  49. package/dist/Series.d.ts +52 -0
  50. package/dist/Series.d.ts.map +1 -0
  51. package/dist/Series.js +86 -0
  52. package/dist/Series.js.map +1 -0
  53. package/dist/Text.d.ts +129 -0
  54. package/dist/Text.d.ts.map +1 -0
  55. package/dist/Text.js +211 -0
  56. package/dist/Text.js.map +1 -0
  57. package/dist/Video.d.ts +75 -0
  58. package/dist/Video.d.ts.map +1 -0
  59. package/dist/Video.js +136 -0
  60. package/dist/Video.js.map +1 -0
  61. package/dist/config.d.ts +128 -0
  62. package/dist/config.d.ts.map +1 -0
  63. package/dist/config.js +243 -0
  64. package/dist/config.js.map +1 -0
  65. package/dist/context.d.ts +84 -0
  66. package/dist/context.d.ts.map +1 -0
  67. package/dist/context.js +131 -0
  68. package/dist/context.js.map +1 -0
  69. package/dist/delayRender.d.ts +130 -0
  70. package/dist/delayRender.d.ts.map +1 -0
  71. package/dist/delayRender.js +197 -0
  72. package/dist/delayRender.js.map +1 -0
  73. package/dist/getInputProps.d.ts +118 -0
  74. package/dist/getInputProps.d.ts.map +1 -0
  75. package/dist/getInputProps.js +181 -0
  76. package/dist/getInputProps.js.map +1 -0
  77. package/dist/hooks/useDelayRender.d.ts +52 -0
  78. package/dist/hooks/useDelayRender.d.ts.map +1 -0
  79. package/dist/hooks/useDelayRender.js +92 -0
  80. package/dist/hooks/useDelayRender.js.map +1 -0
  81. package/dist/hooks.d.ts +19 -0
  82. package/dist/hooks.d.ts.map +1 -0
  83. package/dist/hooks.js +17 -0
  84. package/dist/hooks.js.map +1 -0
  85. package/dist/index.d.ts +71 -0
  86. package/dist/index.d.ts.map +1 -0
  87. package/dist/index.js +65 -0
  88. package/dist/index.js.map +1 -0
  89. package/dist/interpolate.d.ts +80 -0
  90. package/dist/interpolate.d.ts.map +1 -0
  91. package/dist/interpolate.js +108 -0
  92. package/dist/interpolate.js.map +1 -0
  93. package/dist/interpolateColors.d.ts +50 -0
  94. package/dist/interpolateColors.d.ts.map +1 -0
  95. package/dist/interpolateColors.js +300 -0
  96. package/dist/interpolateColors.js.map +1 -0
  97. package/dist/makeTransform.d.ts +98 -0
  98. package/dist/makeTransform.d.ts.map +1 -0
  99. package/dist/makeTransform.js +287 -0
  100. package/dist/makeTransform.js.map +1 -0
  101. package/dist/measureSpring.d.ts +75 -0
  102. package/dist/measureSpring.d.ts.map +1 -0
  103. package/dist/measureSpring.js +108 -0
  104. package/dist/measureSpring.js.map +1 -0
  105. package/dist/noise.d.ts +110 -0
  106. package/dist/noise.d.ts.map +1 -0
  107. package/dist/noise.js +228 -0
  108. package/dist/noise.js.map +1 -0
  109. package/dist/preload.d.ts +145 -0
  110. package/dist/preload.d.ts.map +1 -0
  111. package/dist/preload.js +225 -0
  112. package/dist/preload.js.map +1 -0
  113. package/dist/registerRoot.d.ts +140 -0
  114. package/dist/registerRoot.d.ts.map +1 -0
  115. package/dist/registerRoot.js +238 -0
  116. package/dist/registerRoot.js.map +1 -0
  117. package/dist/shapes/Circle.d.ts +15 -0
  118. package/dist/shapes/Circle.d.ts.map +1 -0
  119. package/dist/shapes/Circle.js +11 -0
  120. package/dist/shapes/Circle.js.map +1 -0
  121. package/dist/shapes/Ellipse.d.ts +16 -0
  122. package/dist/shapes/Ellipse.d.ts.map +1 -0
  123. package/dist/shapes/Ellipse.js +11 -0
  124. package/dist/shapes/Ellipse.js.map +1 -0
  125. package/dist/shapes/Line.d.ts +15 -0
  126. package/dist/shapes/Line.d.ts.map +1 -0
  127. package/dist/shapes/Line.js +11 -0
  128. package/dist/shapes/Line.js.map +1 -0
  129. package/dist/shapes/Path.d.ts +20 -0
  130. package/dist/shapes/Path.d.ts.map +1 -0
  131. package/dist/shapes/Path.js +14 -0
  132. package/dist/shapes/Path.js.map +1 -0
  133. package/dist/shapes/Polygon.d.ts +15 -0
  134. package/dist/shapes/Polygon.d.ts.map +1 -0
  135. package/dist/shapes/Polygon.js +16 -0
  136. package/dist/shapes/Polygon.js.map +1 -0
  137. package/dist/shapes/Rect.d.ts +18 -0
  138. package/dist/shapes/Rect.d.ts.map +1 -0
  139. package/dist/shapes/Rect.js +11 -0
  140. package/dist/shapes/Rect.js.map +1 -0
  141. package/dist/shapes/Svg.d.ts +16 -0
  142. package/dist/shapes/Svg.d.ts.map +1 -0
  143. package/dist/shapes/Svg.js +15 -0
  144. package/dist/shapes/Svg.js.map +1 -0
  145. package/dist/shapes/index.d.ts +16 -0
  146. package/dist/shapes/index.d.ts.map +1 -0
  147. package/dist/shapes/index.js +9 -0
  148. package/dist/shapes/index.js.map +1 -0
  149. package/dist/shapes/usePathLength.d.ts +24 -0
  150. package/dist/shapes/usePathLength.d.ts.map +1 -0
  151. package/dist/shapes/usePathLength.js +32 -0
  152. package/dist/shapes/usePathLength.js.map +1 -0
  153. package/dist/staticFile.d.ts +47 -0
  154. package/dist/staticFile.d.ts.map +1 -0
  155. package/dist/staticFile.js +105 -0
  156. package/dist/staticFile.js.map +1 -0
  157. package/dist/templates/api.d.ts +26 -0
  158. package/dist/templates/api.d.ts.map +1 -0
  159. package/dist/templates/api.js +142 -0
  160. package/dist/templates/api.js.map +1 -0
  161. package/dist/templates/index.d.ts +7 -0
  162. package/dist/templates/index.d.ts.map +1 -0
  163. package/dist/templates/index.js +7 -0
  164. package/dist/templates/index.js.map +1 -0
  165. package/dist/templates/mockData.d.ts +7 -0
  166. package/dist/templates/mockData.d.ts.map +1 -0
  167. package/dist/templates/mockData.js +262 -0
  168. package/dist/templates/mockData.js.map +1 -0
  169. package/dist/templates/types.d.ts +104 -0
  170. package/dist/templates/types.d.ts.map +1 -0
  171. package/dist/templates/types.js +16 -0
  172. package/dist/templates/types.js.map +1 -0
  173. package/dist/transitions/TransitionSeries.d.ts +127 -0
  174. package/dist/transitions/TransitionSeries.d.ts.map +1 -0
  175. package/dist/transitions/TransitionSeries.js +190 -0
  176. package/dist/transitions/TransitionSeries.js.map +1 -0
  177. package/dist/transitions/index.d.ts +52 -0
  178. package/dist/transitions/index.d.ts.map +1 -0
  179. package/dist/transitions/index.js +31 -0
  180. package/dist/transitions/index.js.map +1 -0
  181. package/dist/transitions/presets/fade.d.ts +45 -0
  182. package/dist/transitions/presets/fade.d.ts.map +1 -0
  183. package/dist/transitions/presets/fade.js +56 -0
  184. package/dist/transitions/presets/fade.js.map +1 -0
  185. package/dist/transitions/presets/flip.d.ts +99 -0
  186. package/dist/transitions/presets/flip.d.ts.map +1 -0
  187. package/dist/transitions/presets/flip.js +153 -0
  188. package/dist/transitions/presets/flip.js.map +1 -0
  189. package/dist/transitions/presets/slide.d.ts +61 -0
  190. package/dist/transitions/presets/slide.d.ts.map +1 -0
  191. package/dist/transitions/presets/slide.js +116 -0
  192. package/dist/transitions/presets/slide.js.map +1 -0
  193. package/dist/transitions/presets/wipe.d.ts +69 -0
  194. package/dist/transitions/presets/wipe.d.ts.map +1 -0
  195. package/dist/transitions/presets/wipe.js +136 -0
  196. package/dist/transitions/presets/wipe.js.map +1 -0
  197. package/dist/transitions/presets/zoom.d.ts +76 -0
  198. package/dist/transitions/presets/zoom.d.ts.map +1 -0
  199. package/dist/transitions/presets/zoom.js +110 -0
  200. package/dist/transitions/presets/zoom.js.map +1 -0
  201. package/dist/useAudioData.d.ts +112 -0
  202. package/dist/useAudioData.d.ts.map +1 -0
  203. package/dist/useAudioData.js +183 -0
  204. package/dist/useAudioData.js.map +1 -0
  205. package/dist/useSpring.d.ts +79 -0
  206. package/dist/useSpring.d.ts.map +1 -0
  207. package/dist/useSpring.js +140 -0
  208. package/dist/useSpring.js.map +1 -0
  209. package/package.json +51 -0
@@ -0,0 +1,118 @@
1
+ /**
2
+ * Embeddable Player Component
3
+ *
4
+ * A drop-in video player for any React application.
5
+ * Renders Framely compositions with playback controls.
6
+ *
7
+ * Usage:
8
+ * import { Player } from '@framely/core';
9
+ *
10
+ * <Player
11
+ * component={MyVideoComponent}
12
+ * durationInFrames={300}
13
+ * fps={30}
14
+ * width={1920}
15
+ * height={1080}
16
+ * inputProps={{ title: 'Hello' }}
17
+ * />
18
+ */
19
+ import React from 'react';
20
+ /**
21
+ * The shape of the context value the Player injects into TimelineContext.
22
+ * Extends the base timeline fields with playback-specific properties
23
+ * (volume, playbackRate) that the Player manages internally.
24
+ */
25
+ export interface PlayerTimelineContextValue {
26
+ /** Current frame index (0-based). */
27
+ frame: number;
28
+ /** Frames per second. */
29
+ fps: number;
30
+ /** Composition width in pixels. */
31
+ width: number;
32
+ /** Composition height in pixels. */
33
+ height: number;
34
+ /** Total number of frames in the composition. */
35
+ durationInFrames: number;
36
+ /** Whether playback is currently active. */
37
+ playing: boolean;
38
+ /** Effective volume (0 when muted). */
39
+ volume: number;
40
+ /** Current playback rate multiplier. */
41
+ playbackRate: number;
42
+ }
43
+ /**
44
+ * Props accepted by the Player component.
45
+ *
46
+ * @typeParam T - The shape of the input props forwarded to the composition component.
47
+ */
48
+ export interface PlayerProps<T extends Record<string, unknown> = Record<string, unknown>> {
49
+ /** The composition component to render. */
50
+ component: React.ComponentType<T>;
51
+ /** Total number of frames in the composition. */
52
+ durationInFrames: number;
53
+ /** Frames per second. @default 30 */
54
+ fps?: number;
55
+ /** Composition width in pixels. @default 1920 */
56
+ width?: number;
57
+ /** Composition height in pixels. @default 1080 */
58
+ height?: number;
59
+ /** Props forwarded to the composition component. @default {} */
60
+ inputProps?: T;
61
+ /** Start playing automatically. @default false */
62
+ autoPlay?: boolean;
63
+ /** Loop playback when reaching the end. @default false */
64
+ loop?: boolean;
65
+ /** Show playback controls. @default true */
66
+ controls?: boolean;
67
+ /** Show frame counter in the controls bar. @default false */
68
+ showFrameCount?: boolean;
69
+ /** Initial frame to start on. @default 0 */
70
+ initialFrame?: number;
71
+ /** Additional inline styles for the outermost container. */
72
+ style?: React.CSSProperties;
73
+ /** CSS class name for the outermost container. */
74
+ className?: string;
75
+ /** Called whenever the current frame changes. */
76
+ onFrameChange?: (frame: number) => void;
77
+ /** Called when playback starts. */
78
+ onPlay?: () => void;
79
+ /** Called when playback pauses. */
80
+ onPause?: () => void;
81
+ /** Called when playback reaches the end (non-loop). */
82
+ onEnded?: () => void;
83
+ /** Called when an error occurs. */
84
+ onError?: (error: Error) => void;
85
+ }
86
+ /**
87
+ * Player component for rendering and playing Framely compositions.
88
+ */
89
+ export declare function Player<T extends Record<string, unknown> = Record<string, unknown>>({ component: Component, durationInFrames, fps, width, height, inputProps, autoPlay, loop, controls, showFrameCount, initialFrame, style, className, onFrameChange, onPlay, onPause, onEnded, onError, }: PlayerProps<T>): React.JSX.Element;
90
+ /**
91
+ * Props accepted by the Thumbnail component.
92
+ *
93
+ * @typeParam T - The shape of the input props forwarded to the composition component.
94
+ */
95
+ export interface ThumbnailProps<T extends Record<string, unknown> = Record<string, unknown>> {
96
+ /** The composition component to render. */
97
+ component: React.ComponentType<T>;
98
+ /** Frame index to render. @default 0 */
99
+ frame?: number;
100
+ /** Frames per second (used for timing hooks inside the component). @default 30 */
101
+ fps?: number;
102
+ /** Composition width in pixels. @default 1920 */
103
+ width?: number;
104
+ /** Composition height in pixels. @default 1080 */
105
+ height?: number;
106
+ /** Props forwarded to the composition component. @default {} */
107
+ inputProps?: T;
108
+ /** Additional inline styles for the container. */
109
+ style?: React.CSSProperties;
110
+ /** CSS class name for the container. */
111
+ className?: string;
112
+ }
113
+ /**
114
+ * Thumbnail component -- renders a single frame of a composition.
115
+ */
116
+ export declare function Thumbnail<T extends Record<string, unknown> = Record<string, unknown>>({ component: Component, frame, fps, width, height, inputProps, style, className, }: ThumbnailProps<T>): React.JSX.Element;
117
+ export default Player;
118
+ //# sourceMappingURL=Player.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Player.d.ts","sourceRoot":"","sources":["../src/Player.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,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,UAAU,CAAC,EAAE,CAAC,CAAC;IACf,kDAAkD;IAClD,KAAK,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC;IAC5B,wCAAwC;IACxC,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAID;;GAEG;AACH,wBAAgB,SAAS,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,EACrF,SAAS,EAAE,SAAS,EACpB,KAAS,EACT,GAAQ,EACR,KAAY,EACZ,MAAa,EACb,UAAoB,EACpB,KAAK,EACL,SAAS,GACV,EAAE,cAAc,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,GAAG,CAAC,OAAO,CA8CvC;AAED,eAAe,MAAM,CAAC"}
package/dist/Player.js ADDED
@@ -0,0 +1,311 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ /**
3
+ * Embeddable Player Component
4
+ *
5
+ * A drop-in video player for any React application.
6
+ * Renders Framely compositions with playback controls.
7
+ *
8
+ * Usage:
9
+ * import { Player } from '@framely/core';
10
+ *
11
+ * <Player
12
+ * component={MyVideoComponent}
13
+ * durationInFrames={300}
14
+ * fps={30}
15
+ * width={1920}
16
+ * height={1080}
17
+ * inputProps={{ title: 'Hello' }}
18
+ * />
19
+ */
20
+ import { useState, useEffect, useRef, useCallback, useMemo, } from 'react';
21
+ import { TimelineContext } from './context';
22
+ import { AbsoluteFill } from './AbsoluteFill';
23
+ // ─── Player Component ─────────────────────────────────────────────────────────
24
+ /**
25
+ * Player component for rendering and playing Framely compositions.
26
+ */
27
+ export function Player({ component: Component, durationInFrames, fps = 30, width = 1920, height = 1080, inputProps = {}, autoPlay = false, loop = false, controls = true, showFrameCount = false, initialFrame = 0, style, className, onFrameChange, onPlay, onPause, onEnded, onError, }) {
28
+ const [frame, setFrame] = useState(initialFrame);
29
+ const [playing, setPlaying] = useState(autoPlay);
30
+ const [volume, setVolume] = useState(1);
31
+ const [muted, setMuted] = useState(false);
32
+ const [fullscreen, setFullscreen] = useState(false);
33
+ const [playbackRate, setPlaybackRate] = useState(1);
34
+ const containerRef = useRef(null);
35
+ const animationRef = useRef(null);
36
+ const lastTimeRef = useRef(null);
37
+ // Calculate aspect ratio and scale
38
+ const aspectRatio = width / height;
39
+ // Animation loop
40
+ useEffect(() => {
41
+ if (!playing) {
42
+ if (animationRef.current) {
43
+ cancelAnimationFrame(animationRef.current);
44
+ animationRef.current = null;
45
+ }
46
+ return;
47
+ }
48
+ const frameDuration = 1000 / (fps * playbackRate);
49
+ lastTimeRef.current = performance.now();
50
+ const animate = (currentTime) => {
51
+ const elapsed = currentTime - (lastTimeRef.current ?? currentTime);
52
+ if (elapsed >= frameDuration) {
53
+ const framesToAdvance = Math.floor(elapsed / frameDuration);
54
+ lastTimeRef.current = currentTime - (elapsed % frameDuration);
55
+ setFrame((prevFrame) => {
56
+ let newFrame = prevFrame + framesToAdvance;
57
+ if (newFrame >= durationInFrames) {
58
+ if (loop) {
59
+ newFrame = newFrame % durationInFrames;
60
+ }
61
+ else {
62
+ setPlaying(false);
63
+ onEnded?.();
64
+ return durationInFrames - 1;
65
+ }
66
+ }
67
+ return newFrame;
68
+ });
69
+ }
70
+ animationRef.current = requestAnimationFrame(animate);
71
+ };
72
+ animationRef.current = requestAnimationFrame(animate);
73
+ return () => {
74
+ if (animationRef.current) {
75
+ cancelAnimationFrame(animationRef.current);
76
+ }
77
+ };
78
+ }, [playing, fps, durationInFrames, loop, playbackRate, onEnded]);
79
+ // Notify frame changes
80
+ useEffect(() => {
81
+ onFrameChange?.(frame);
82
+ }, [frame, onFrameChange]);
83
+ // Playback controls
84
+ const play = useCallback(() => {
85
+ if (frame >= durationInFrames - 1) {
86
+ setFrame(0);
87
+ }
88
+ setPlaying(true);
89
+ onPlay?.();
90
+ }, [frame, durationInFrames, onPlay]);
91
+ const pause = useCallback(() => {
92
+ setPlaying(false);
93
+ onPause?.();
94
+ }, [onPause]);
95
+ const toggle = useCallback(() => {
96
+ if (playing) {
97
+ pause();
98
+ }
99
+ else {
100
+ play();
101
+ }
102
+ }, [playing, play, pause]);
103
+ const seekTo = useCallback((targetFrame) => {
104
+ const clampedFrame = Math.max(0, Math.min(durationInFrames - 1, targetFrame));
105
+ setFrame(clampedFrame);
106
+ }, [durationInFrames]);
107
+ const seekToPercent = useCallback((percent) => {
108
+ const targetFrame = Math.floor((percent / 100) * durationInFrames);
109
+ seekTo(targetFrame);
110
+ }, [durationInFrames, seekTo]);
111
+ const toggleFullscreen = useCallback(() => {
112
+ if (!containerRef.current)
113
+ return;
114
+ if (!document.fullscreenElement) {
115
+ containerRef.current.requestFullscreen?.();
116
+ setFullscreen(true);
117
+ }
118
+ else {
119
+ document.exitFullscreen?.();
120
+ setFullscreen(false);
121
+ }
122
+ }, []);
123
+ // Keyboard shortcuts
124
+ useEffect(() => {
125
+ const handleKeyDown = (e) => {
126
+ const target = e.target;
127
+ if (target.tagName === 'INPUT' || target.tagName === 'TEXTAREA')
128
+ return;
129
+ switch (e.key) {
130
+ case ' ':
131
+ case 'k':
132
+ e.preventDefault();
133
+ toggle();
134
+ break;
135
+ case 'ArrowLeft':
136
+ e.preventDefault();
137
+ seekTo(frame - (e.shiftKey ? 10 : 1));
138
+ break;
139
+ case 'ArrowRight':
140
+ e.preventDefault();
141
+ seekTo(frame + (e.shiftKey ? 10 : 1));
142
+ break;
143
+ case 'Home':
144
+ e.preventDefault();
145
+ seekTo(0);
146
+ break;
147
+ case 'End':
148
+ e.preventDefault();
149
+ seekTo(durationInFrames - 1);
150
+ break;
151
+ case 'f':
152
+ e.preventDefault();
153
+ toggleFullscreen();
154
+ break;
155
+ case 'm':
156
+ e.preventDefault();
157
+ setMuted((m) => !m);
158
+ break;
159
+ case ',':
160
+ e.preventDefault();
161
+ if (!playing)
162
+ seekTo(frame - 1);
163
+ break;
164
+ case '.':
165
+ e.preventDefault();
166
+ if (!playing)
167
+ seekTo(frame + 1);
168
+ break;
169
+ }
170
+ };
171
+ window.addEventListener('keydown', handleKeyDown);
172
+ return () => window.removeEventListener('keydown', handleKeyDown);
173
+ }, [frame, playing, durationInFrames, toggle, seekTo, toggleFullscreen]);
174
+ // Timeline context value
175
+ const contextValue = useMemo(() => ({
176
+ frame,
177
+ fps,
178
+ width,
179
+ height,
180
+ durationInFrames,
181
+ playing,
182
+ volume: muted ? 0 : volume,
183
+ playbackRate,
184
+ }), [frame, fps, width, height, durationInFrames, playing, volume, muted, playbackRate]);
185
+ // Format time display
186
+ const formatTime = (f) => {
187
+ const totalSeconds = f / fps;
188
+ const minutes = Math.floor(totalSeconds / 60);
189
+ const seconds = Math.floor(totalSeconds % 60);
190
+ return `${minutes}:${seconds.toString().padStart(2, '0')}`;
191
+ };
192
+ const currentTime = formatTime(frame);
193
+ const totalTime = formatTime(durationInFrames);
194
+ const progress = (frame / (durationInFrames - 1)) * 100;
195
+ return (_jsxs("div", { ref: containerRef, className: className, style: {
196
+ position: 'relative',
197
+ width: '100%',
198
+ maxWidth: width,
199
+ backgroundColor: '#000',
200
+ ...style,
201
+ }, children: [_jsxs("div", { style: {
202
+ position: 'relative',
203
+ width: '100%',
204
+ paddingTop: `${(1 / aspectRatio) * 100}%`,
205
+ overflow: 'hidden',
206
+ }, children: [_jsx("div", { style: {
207
+ position: 'absolute',
208
+ top: 0,
209
+ left: 0,
210
+ width: '100%',
211
+ height: '100%',
212
+ }, children: _jsx(TimelineContext.Provider, { value: contextValue, children: _jsx(AbsoluteFill, { children: _jsx(Component, { ...inputProps }) }) }) }), _jsx("div", { onClick: toggle, style: {
213
+ position: 'absolute',
214
+ top: 0,
215
+ left: 0,
216
+ width: '100%',
217
+ height: '100%',
218
+ cursor: 'pointer',
219
+ } })] }), controls && (_jsxs("div", { style: {
220
+ display: 'flex',
221
+ alignItems: 'center',
222
+ gap: '8px',
223
+ padding: '8px 12px',
224
+ backgroundColor: 'rgba(0, 0, 0, 0.8)',
225
+ color: '#fff',
226
+ fontSize: '14px',
227
+ fontFamily: 'system-ui, sans-serif',
228
+ }, children: [_jsx("button", { onClick: toggle, style: {
229
+ background: 'none',
230
+ border: 'none',
231
+ color: '#fff',
232
+ cursor: 'pointer',
233
+ padding: '4px',
234
+ fontSize: '16px',
235
+ }, "aria-label": playing ? 'Pause' : 'Play', children: playing ? '\u23F8' : '\u25B6' }), _jsxs("span", { style: { minWidth: '80px', fontSize: '12px' }, children: [currentTime, " / ", totalTime] }), _jsx("div", { style: {
236
+ flex: 1,
237
+ height: '4px',
238
+ backgroundColor: 'rgba(255, 255, 255, 0.3)',
239
+ borderRadius: '2px',
240
+ cursor: 'pointer',
241
+ position: 'relative',
242
+ }, onClick: (e) => {
243
+ const rect = e.currentTarget.getBoundingClientRect();
244
+ const percent = ((e.clientX - rect.left) / rect.width) * 100;
245
+ seekToPercent(percent);
246
+ }, children: _jsx("div", { style: {
247
+ position: 'absolute',
248
+ left: 0,
249
+ top: 0,
250
+ height: '100%',
251
+ width: `${progress}%`,
252
+ backgroundColor: '#3b82f6',
253
+ borderRadius: '2px',
254
+ transition: 'width 0.1s',
255
+ } }) }), showFrameCount && (_jsxs("span", { style: { fontSize: '12px', opacity: 0.7 }, children: [frame, " / ", durationInFrames - 1] })), _jsx("button", { onClick: () => setMuted((m) => !m), style: {
256
+ background: 'none',
257
+ border: 'none',
258
+ color: '#fff',
259
+ cursor: 'pointer',
260
+ padding: '4px',
261
+ fontSize: '14px',
262
+ }, "aria-label": muted ? 'Unmute' : 'Mute', children: muted ? '\uD83D\uDD07' : '\uD83D\uDD0A' }), _jsxs("select", { value: playbackRate, onChange: (e) => setPlaybackRate(parseFloat(e.target.value)), style: {
263
+ background: 'transparent',
264
+ border: '1px solid rgba(255,255,255,0.3)',
265
+ color: '#fff',
266
+ padding: '2px 4px',
267
+ borderRadius: '4px',
268
+ fontSize: '12px',
269
+ cursor: 'pointer',
270
+ }, children: [_jsx("option", { value: "0.25", children: "0.25x" }), _jsx("option", { value: "0.5", children: "0.5x" }), _jsx("option", { value: "1", children: "1x" }), _jsx("option", { value: "1.5", children: "1.5x" }), _jsx("option", { value: "2", children: "2x" })] }), _jsx("button", { onClick: toggleFullscreen, style: {
271
+ background: 'none',
272
+ border: 'none',
273
+ color: '#fff',
274
+ cursor: 'pointer',
275
+ padding: '4px',
276
+ fontSize: '14px',
277
+ }, "aria-label": "Toggle fullscreen", children: fullscreen ? '\u26F6' : '\u26F6' })] }))] }));
278
+ }
279
+ // ─── Thumbnail Component ──────────────────────────────────────────────────────
280
+ /**
281
+ * Thumbnail component -- renders a single frame of a composition.
282
+ */
283
+ export function Thumbnail({ component: Component, frame = 0, fps = 30, width = 1920, height = 1080, inputProps = {}, style, className, }) {
284
+ const aspectRatio = width / height;
285
+ const contextValue = useMemo(() => ({
286
+ frame,
287
+ fps,
288
+ width,
289
+ height,
290
+ durationInFrames: frame + 1,
291
+ playing: false,
292
+ volume: 0,
293
+ playbackRate: 1,
294
+ }), [frame, fps, width, height]);
295
+ return (_jsx("div", { className: className, style: {
296
+ position: 'relative',
297
+ width: '100%',
298
+ maxWidth: width,
299
+ paddingTop: `${(1 / aspectRatio) * 100}%`,
300
+ overflow: 'hidden',
301
+ ...style,
302
+ }, children: _jsx("div", { style: {
303
+ position: 'absolute',
304
+ top: 0,
305
+ left: 0,
306
+ width: '100%',
307
+ height: '100%',
308
+ }, children: _jsx(TimelineContext.Provider, { value: contextValue, children: _jsx(AbsoluteFill, { children: _jsx(Component, { ...inputProps }) }) }) }) }));
309
+ }
310
+ export default Player;
311
+ //# sourceMappingURL=Player.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Player.js","sourceRoot":"","sources":["../src/Player.tsx"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAc,EACZ,QAAQ,EACR,SAAS,EACT,MAAM,EACN,WAAW,EACX,OAAO,GACR,MAAM,OAAO,CAAC;AACf,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,EAA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AS,CAA8D,EACrF,SAAS,EAAE,SAAS,EACpB,KAAK,GAAG,CAAC,EACT,GAAG,GAAG,EAAE,EACR,KAAK,GAAG,IAAI,EACZ,MAAM,GAAG,IAAI,EACb,UAAU,GAAG,EAAO,EACpB,KAAK,EACL,SAAS,GACS;IAClB,MAAM,WAAW,GAAW,KAAK,GAAG,MAAM,CAAC;IAE3C,MAAM,YAAY,GAAG,OAAO,CAC1B,GAAG,EAAE,CAAC,CAAC;QACL,KAAK;QACL,GAAG;QACH,KAAK;QACL,MAAM;QACN,gBAAgB,EAAE,KAAK,GAAG,CAAC;QAC3B,OAAO,EAAE,KAAK;QACd,MAAM,EAAE,CAAC;QACT,YAAY,EAAE,CAAC;KAChB,CAAC,EACF,CAAC,KAAK,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,CAAC,CAC5B,CAAC;IAEF,OAAO,CACL,cACE,SAAS,EAAE,SAAS,EACpB,KAAK,EAAE;YACL,QAAQ,EAAE,UAAU;YACpB,KAAK,EAAE,MAAM;YACb,QAAQ,EAAE,KAAK;YACf,UAAU,EAAE,GAAG,CAAC,CAAC,GAAG,WAAW,CAAC,GAAG,GAAG,GAAG;YACzC,QAAQ,EAAE,QAAQ;YAClB,GAAG,KAAK;SACT,YAED,cACE,KAAK,EAAE;gBACL,QAAQ,EAAE,UAAU;gBACpB,GAAG,EAAE,CAAC;gBACN,IAAI,EAAE,CAAC;gBACP,KAAK,EAAE,MAAM;gBACb,MAAM,EAAE,MAAM;aACf,YAED,KAAC,eAAe,CAAC,QAAQ,IAAC,KAAK,EAAE,YAAmB,YAClD,KAAC,YAAY,cACX,KAAC,SAAS,OAAK,UAAU,GAAI,GAChB,GACU,GACvB,GACF,CACP,CAAC;AACJ,CAAC;AAED,eAAe,MAAM,CAAC"}
@@ -0,0 +1,25 @@
1
+ import React from 'react';
2
+ export interface SequenceProps {
3
+ /** Frame at which this sequence starts (default: 0). */
4
+ from?: number;
5
+ /** How many frames this sequence lasts (defaults to rest of composition). */
6
+ durationInFrames?: number;
7
+ /** Optional label for debugging. */
8
+ name?: string;
9
+ /** 'absolute-fill' (default) positions the sequence to cover its parent; 'none' applies no layout. */
10
+ layout?: 'absolute-fill' | 'none';
11
+ /** Additional inline CSS styles applied to the wrapper div. */
12
+ style?: React.CSSProperties;
13
+ /** Additional CSS class name(s) applied to the wrapper div. */
14
+ className?: string;
15
+ /** Child elements rendered inside the sequence. */
16
+ children?: React.ReactNode;
17
+ }
18
+ /**
19
+ * Sequence offsets the timeline for its children.
20
+ *
21
+ * Children inside a Sequence see frame 0 when the parent timeline
22
+ * reaches `from`. The Sequence is hidden outside its active range.
23
+ */
24
+ export declare function Sequence({ from, durationInFrames: duration, name, style, layout, className, children, }: SequenceProps): React.ReactElement | null;
25
+ //# sourceMappingURL=Sequence.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Sequence.d.ts","sourceRoot":"","sources":["../src/Sequence.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAkB,MAAM,OAAO,CAAC;AAGvC,MAAM,WAAW,aAAa;IAC5B,wDAAwD;IACxD,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,6EAA6E;IAC7E,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,oCAAoC;IACpC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,sGAAsG;IACtG,MAAM,CAAC,EAAE,eAAe,GAAG,MAAM,CAAC;IAClC,+DAA+D;IAC/D,KAAK,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC;IAC5B,+DAA+D;IAC/D,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,mDAAmD;IACnD,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CAC5B;AAED;;;;;GAKG;AACH,wBAAgB,QAAQ,CAAC,EACvB,IAAQ,EACR,gBAAgB,EAAE,QAAQ,EAC1B,IAAI,EACJ,KAAK,EACL,MAAwB,EACxB,SAAS,EACT,QAAQ,GACT,EAAE,aAAa,GAAG,KAAK,CAAC,YAAY,GAAG,IAAI,CA6C3C"}
@@ -0,0 +1,37 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { useMemo } from 'react';
3
+ import TimelineContext, { useTimeline } from './context';
4
+ /**
5
+ * Sequence offsets the timeline for its children.
6
+ *
7
+ * Children inside a Sequence see frame 0 when the parent timeline
8
+ * reaches `from`. The Sequence is hidden outside its active range.
9
+ */
10
+ export function Sequence({ from = 0, durationInFrames: duration, name, style, layout = 'absolute-fill', className, children, }) {
11
+ const parent = useTimeline();
12
+ const actualDuration = duration ?? parent.durationInFrames - from;
13
+ // Calculate the child's local frame
14
+ const localFrame = parent.frame - from;
15
+ const contextValue = useMemo(() => ({
16
+ ...parent,
17
+ frame: localFrame,
18
+ durationInFrames: actualDuration,
19
+ playing: parent.playing ?? false,
20
+ }), [parent, localFrame, actualDuration]);
21
+ const containerStyle = layout === 'absolute-fill'
22
+ ? {
23
+ position: 'absolute',
24
+ top: 0,
25
+ left: 0,
26
+ right: 0,
27
+ bottom: 0,
28
+ ...style,
29
+ }
30
+ : style;
31
+ // Don't render if we're outside this sequence's range
32
+ if (localFrame < 0 || localFrame >= actualDuration) {
33
+ return null;
34
+ }
35
+ return (_jsx(TimelineContext.Provider, { value: contextValue, children: _jsx("div", { style: containerStyle, className: className, "data-sequence-name": name, children: children }) }));
36
+ }
37
+ //# sourceMappingURL=Sequence.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Sequence.js","sourceRoot":"","sources":["../src/Sequence.tsx"],"names":[],"mappings":";AAAA,OAAc,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AACvC,OAAO,eAAe,EAAE,EAAE,WAAW,EAA6B,MAAM,WAAW,CAAC;AAmBpF;;;;;GAKG;AACH,MAAM,UAAU,QAAQ,CAAC,EACvB,IAAI,GAAG,CAAC,EACR,gBAAgB,EAAE,QAAQ,EAC1B,IAAI,EACJ,KAAK,EACL,MAAM,GAAG,eAAe,EACxB,SAAS,EACT,QAAQ,GACM;IACd,MAAM,MAAM,GAAG,WAAW,EAA0B,CAAC;IACrD,MAAM,cAAc,GAAW,QAAQ,IAAI,MAAM,CAAC,gBAAgB,GAAG,IAAI,CAAC;IAE1E,oCAAoC;IACpC,MAAM,UAAU,GAAW,MAAM,CAAC,KAAK,GAAG,IAAI,CAAC;IAE/C,MAAM,YAAY,GAAyB,OAAO,CAChD,GAAG,EAAE,CAAC,CAAC;QACL,GAAG,MAAM;QACT,KAAK,EAAE,UAAU;QACjB,gBAAgB,EAAE,cAAc;QAChC,OAAO,EAAE,MAAM,CAAC,OAAO,IAAI,KAAK;KACjC,CAAC,EACF,CAAC,MAAM,EAAE,UAAU,EAAE,cAAc,CAAC,CACrC,CAAC;IAEF,MAAM,cAAc,GAClB,MAAM,KAAK,eAAe;QACxB,CAAC,CAAC;YACE,QAAQ,EAAE,UAAmB;YAC7B,GAAG,EAAE,CAAC;YACN,IAAI,EAAE,CAAC;YACP,KAAK,EAAE,CAAC;YACR,MAAM,EAAE,CAAC;YACT,GAAG,KAAK;SACT;QACH,CAAC,CAAC,KAAK,CAAC;IAEZ,sDAAsD;IACtD,IAAI,UAAU,GAAG,CAAC,IAAI,UAAU,IAAI,cAAc,EAAE,CAAC;QACnD,OAAO,IAAI,CAAC;IACd,CAAC;IAED,OAAO,CACL,KAAC,eAAe,CAAC,QAAQ,IAAC,KAAK,EAAE,YAAY,YAC3C,cACE,KAAK,EAAE,cAAc,EACrB,SAAS,EAAE,SAAS,wBACA,IAAI,YAEvB,QAAQ,GACL,GACmB,CAC5B,CAAC;AACJ,CAAC"}
@@ -0,0 +1,52 @@
1
+ import { type ReactNode, type CSSProperties, type ReactElement } from 'react';
2
+ /**
3
+ * Props for the Series.Sequence compound component.
4
+ */
5
+ export interface SeriesSequenceProps {
6
+ /** How many frames this sequence lasts (required unless last). */
7
+ durationInFrames: number;
8
+ /** Adjust timing: positive = delay, negative = overlap with previous. */
9
+ offset?: number;
10
+ /** Layout mode: 'absolute-fill' (default) positions the sequence absolutely, 'none' uses no special layout. */
11
+ layout?: 'absolute-fill' | 'none';
12
+ /** Additional CSS styles applied to the sequence container. */
13
+ style?: CSSProperties;
14
+ /** Optional label for debugging. */
15
+ name?: string;
16
+ /** Content to render inside this sequence. */
17
+ children?: ReactNode;
18
+ }
19
+ /**
20
+ * Props for the Series component.
21
+ */
22
+ export interface SeriesProps {
23
+ /** Series.Sequence elements to render sequentially. */
24
+ children: ReactNode;
25
+ }
26
+ /**
27
+ * Compound component type that includes Series.Sequence.
28
+ */
29
+ interface SeriesComponent {
30
+ (props: SeriesProps): ReactElement;
31
+ Sequence: (props: SeriesSequenceProps) => ReactElement | null;
32
+ }
33
+ /**
34
+ * Series renders children sequentially, auto-calculating `from` for each.
35
+ *
36
+ * Unlike Sequence (which requires explicit `from` values), Series automatically
37
+ * places each child one after another in the timeline.
38
+ *
39
+ * Usage:
40
+ * <Series>
41
+ * <Series.Sequence durationInFrames={60}>
42
+ * <Scene1 />
43
+ * </Series.Sequence>
44
+ * <Series.Sequence durationInFrames={90}>
45
+ * <Scene2 />
46
+ * </Series.Sequence>
47
+ * </Series>
48
+ */
49
+ declare const Series: SeriesComponent;
50
+ export { Series };
51
+ export default Series;
52
+ //# sourceMappingURL=Series.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Series.d.ts","sourceRoot":"","sources":["../src/Series.tsx"],"names":[],"mappings":"AAAA,OAAO,EAKL,KAAK,SAAS,EACd,KAAK,aAAa,EAClB,KAAK,YAAY,EAClB,MAAM,OAAO,CAAC;AAiBf;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,kEAAkE;IAClE,gBAAgB,EAAE,MAAM,CAAC;IACzB,yEAAyE;IACzE,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,+GAA+G;IAC/G,MAAM,CAAC,EAAE,eAAe,GAAG,MAAM,CAAC;IAClC,+DAA+D;IAC/D,KAAK,CAAC,EAAE,aAAa,CAAC;IACtB,oCAAoC;IACpC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,8CAA8C;IAC9C,QAAQ,CAAC,EAAE,SAAS,CAAC;CACtB;AAED;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,uDAAuD;IACvD,QAAQ,EAAE,SAAS,CAAC;CACrB;AAUD;;GAEG;AACH,UAAU,eAAe;IACvB,CAAC,KAAK,EAAE,WAAW,GAAG,YAAY,CAAC;IACnC,QAAQ,EAAE,CAAC,KAAK,EAAE,mBAAmB,KAAK,YAAY,GAAG,IAAI,CAAC;CAC/D;AAED;;;;;;;;;;;;;;;GAeG;AACH,QAAA,MAAM,MAAM,EAAE,eA4Bb,CAAC;AAoEF,OAAO,EAAE,MAAM,EAAE,CAAC;AAClB,eAAe,MAAM,CAAC"}