🎥 Make videos programmatically with React
throws error when imageFormat gets passed
Patric Salvisbergcd6daaf35cf2
diff --git a/packages/core/src/test/offthread-props.test.tsx b/packages/core/src/test/offthread-props.test.tsxnew file mode 100644index 0000000000..d5279b76a5--- /dev/null+++ b/packages/core/src/test/offthread-props.test.tsx@@ -0,0 +1,16 @@+import {renderToString} from 'react-dom/server';+import {expect, test} from 'vitest';+import {OffthreadVideo} from '../video/index.js';++test('Passing imageFormat to OffthreadVideo should throw error', () => {+ expect(() => {+ renderToString(+ <OffthreadVideo+ src="http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4"+ imageFormat={'JPEG'}+ />+ );+ }).toThrow(+ `The \`<OffthreadVideo>\` tag does no longer accept \`imageFormat\`. Use \`transparent=true\` if you want to render a transparent video.`+ );+});diff --git a/packages/core/src/video/OffthreadVideo.tsx b/packages/core/src/video/OffthreadVideo.tsxindex 6789d59bbe..e6bb795fad 100644--- a/packages/core/src/video/OffthreadVideo.tsx+++ b/packages/core/src/video/OffthreadVideo.tsx@@ -27,6 +27,12 @@ export const OffthreadVideo: React.FC<);}+ if (props.imageFormat) {+ throw new TypeError(+ `The \`<OffthreadVideo>\` tag does no longer accept \`imageFormat\`. Use \`transparent=true\` if you want to render a transparent video.`+ );+ }+if (typeof startFrom !== 'undefined' || typeof endAt !== 'undefined') {validateStartFromProps(startFrom, endAt);diff --git a/packages/core/src/video/props.ts b/packages/core/src/video/props.tsindex af785fb002..78ffce3024 100644--- a/packages/core/src/video/props.ts+++ b/packages/core/src/video/props.ts@@ -1,6 +1,8 @@import type React from 'react';import type {VolumeProp} from '../volume-prop.js';+type ImageFormat = 'PNG |JPEG';+export type RemotionMainVideoProps = {startFrom?: number;endAt?: number;@@ -19,15 +21,25 @@ export type RemotionVideoProps = Omit<allowAmplificationDuringRender?: boolean;};-export type OffthreadVideoProps = {- src: string;- className?: string;- style?: React.CSSProperties;- volume?: VolumeProp;- playbackRate?: number;- muted?: boolean;- onError?: React.ReactEventHandler<HTMLVideoElement | HTMLImageElement>;- acceptableTimeShiftInSeconds?: number;- allowAmplificationDuringRender?: boolean;- transparent?: boolean;+type DeprecatedOffthreadVideoProps = {+ /**+ * @deprecated Use the `transparent` prop instead+ */+ imageFormat: never;};++export type OffthreadVideoProps = Omit<+ {+ src: string;+ className?: string;+ style?: React.CSSProperties;+ volume?: VolumeProp;+ playbackRate?: number;+ muted?: boolean;+ onError?: React.ReactEventHandler<HTMLVideoElement | HTMLImageElement>;+ acceptableTimeShiftInSeconds?: number;+ allowAmplificationDuringRender?: boolean;+ transparent?: boolean;+ } & DeprecatedOffthreadVideoProps,+ ImageFormat+>;