🎥 Make videos programmatically with React
allow floats as durationInFrames
Jonny Burgerabd65be6bf47
diff --git a/packages/core/src/Composition.tsx b/packages/core/src/Composition.tsxindex 469c5d85f9..82126eb1f9 100644--- a/packages/core/src/Composition.tsx+++ b/packages/core/src/Composition.tsx@@ -101,7 +101,8 @@ export const Composition = <T,>({validateDimension(height, 'height', 'of the <Composition/> component');validateDurationInFrames(durationInFrames,- 'of the <Composition/> component'+ 'of the <Composition/> component',+ false);validateFps(fps, 'as a prop of the <Composition/> component', false);diff --git a/packages/core/src/loop/index.tsx b/packages/core/src/loop/index.tsxindex d1b631e0ad..da982d8ff1 100644--- a/packages/core/src/loop/index.tsx+++ b/packages/core/src/loop/index.tsx@@ -25,7 +25,7 @@ export const Loop: React.FC<LoopProps> = ({...props}) => {const {durationInFrames: compDuration} = useVideoConfig();- validateDurationInFrames(durationInFrames, 'of the <Loop /> component');+ validateDurationInFrames(durationInFrames, 'of the <Loop /> component', true);if (typeof times !== 'number') {throw new TypeError(diff --git a/packages/core/src/series/index.tsx b/packages/core/src/series/index.tsxindex 33fba76ee3..7746982287 100644--- a/packages/core/src/series/index.tsx+++ b/packages/core/src/series/index.tsx@@ -83,7 +83,8 @@ const Series: FC<{) {validateDurationInFrames(durationInFramesProp,- `of a <Series.Sequence /> component`+ `of a <Series.Sequence /> component`,+ true);}diff --git a/packages/core/src/validation/validate-duration-in-frames.ts b/packages/core/src/validation/validate-duration-in-frames.tsindex bfdfc56739..00ce812279 100644--- a/packages/core/src/validation/validate-duration-in-frames.ts+++ b/packages/core/src/validation/validate-duration-in-frames.ts@@ -1,6 +1,7 @@export const validateDurationInFrames = (durationInFrames: number,- component: string+ component: string,+ allowFloats: boolean) => {if (typeof durationInFrames !== 'number') {throw new Error(@@ -14,9 +15,15 @@ export const validateDurationInFrames = ();}- if (durationInFrames % 1 !== 0) {+ if (!allowFloats && durationInFrames % 1 !== 0) {throw new TypeError(`The "durationInFrames" prop ${component} must be an integer, but got ${durationInFrames}.`);}++ if (!Number.isFinite(durationInFrames)) {+ throw new TypeError(+ `The "durationInFrames" prop ${component} must be finite, but got ${durationInFrames}.`+ );+ }};diff --git a/packages/lambda/src/functions/launch.ts b/packages/lambda/src/functions/launch.tsindex d93d1dd756..b6b0ae1d01 100644--- a/packages/lambda/src/functions/launch.ts+++ b/packages/lambda/src/functions/launch.ts@@ -183,7 +183,8 @@ const innerLaunchHandler = async (params: LambdaPayload, options: Options) => {});Internals.validateDurationInFrames(comp.durationInFrames,- 'passed to a Lambda render'+ 'passed to a Lambda render',+ false);Internals.validateFps(comp.fps, 'passed to a Lambda render', false);Internals.validateDimension(diff --git a/packages/player/src/Player.tsx b/packages/player/src/Player.tsxindex 8ef4e75231..888d82061c 100644--- a/packages/player/src/Player.tsx+++ b/packages/player/src/Player.tsx@@ -63,7 +63,7 @@ export type PlayerProps<T> = {initiallyShowControls?: number | boolean;renderPlayPauseButton?: RenderPlayPauseButton;renderFullscreenButton?: RenderFullscreenButton;- alwaysShowControls?: boolean;+ alwaysShowControls?: boolean;} & PropsIfHasProps<T> &CompProps<T>;@@ -109,7 +109,7 @@ const PlayerFn = <T,>(initiallyShowControls,renderFullscreenButton,renderPlayPauseButton,- alwaysShowControls = false,+ alwaysShowControls = false,...componentProps}: PlayerProps<T>,ref: MutableRefObject<PlayerRef>@@ -183,7 +183,8 @@ const PlayerFn = <T,>();Internals.validateDurationInFrames(durationInFrames,- 'of the <Player/> component'+ 'of the <Player/> component',+ false);Internals.validateFps(fps, 'as a prop of the <Player/> component', false);@@ -357,7 +358,7 @@ const PlayerFn = <T,>(initiallyShowControls={initiallyShowControls ?? true}renderFullscreen={renderFullscreenButton ?? null}renderPlayPauseButton={renderPlayPauseButton ?? null}- alwaysShowControls={alwaysShowControls}+ alwaysShowControls={alwaysShowControls}/></PlayerEventEmitterContext.Provider></Internals.Timeline.SetTimelineContext.Provider>diff --git a/packages/renderer/src/render-frames.ts b/packages/renderer/src/render-frames.tsindex e48673714e..8672f06253 100644--- a/packages/renderer/src/render-frames.ts+++ b/packages/renderer/src/render-frames.ts@@ -530,7 +530,8 @@ export const renderFrames = ();Internals.validateDurationInFrames(composition.durationInFrames,- 'in the `config` object passed to `renderFrames()`'+ 'in the `config` object passed to `renderFrames()`',+ false);if (options.quality !== undefined && options.imageFormat !== 'jpeg') {throw new Error(diff --git a/packages/renderer/src/render-still.ts b/packages/renderer/src/render-still.tsindex 60f7cdfdcf..5010091b4c 100644--- a/packages/renderer/src/render-still.ts+++ b/packages/renderer/src/render-still.ts@@ -105,7 +105,8 @@ const innerRenderStill = async ({);Internals.validateDurationInFrames(composition.durationInFrames,- 'in the `config` object passed to `renderStill()`'+ 'in the `config` object passed to `renderStill()`',+ false);validateNonNullImageFormat(imageFormat);Internals.validateFrame(frame, composition.durationInFrames);