🎥 Make videos programmatically with React
`@remotion/transitions`: Don't allow layout="none" in 5.0 anymore
Jonny Burgercfb5797e270f
diff --git a/packages/core/src/Sequence.tsx b/packages/core/src/Sequence.tsxindex 034f2fbedb..5db611a1da 100644--- a/packages/core/src/Sequence.tsx+++ b/packages/core/src/Sequence.tsx@@ -25,44 +25,46 @@ import {useVideoConfig} from './use-video-config.js';import {Freeze} from './freeze.js';import {useCurrentFrame} from './use-current-frame';+export type AbsoluteFillLayout = {+ layout?: 'absolute-fill';+ premountFor?: number;+ style?: React.CSSProperties;+ className?: string;+};+export type LayoutAndStyle =- | {- layout?: 'absolute-fill';- premountFor?: number;- style?: React.CSSProperties;- className?: string;- }+ | AbsoluteFillLayout| {layout: 'none';};export type SequencePropsWithoutDuration = {- children: React.ReactNode;- width?: number;- height?: number;- from?: number;- name?: string;- showInTimeline?: boolean;+ readonly children: React.ReactNode;+ readonly width?: number;+ readonly height?: number;+ readonly from?: number;+ readonly name?: string;+ readonly showInTimeline?: boolean;/*** @deprecated For internal use only.*/- _remotionInternalLoopDisplay?: LoopDisplay;+ readonly _remotionInternalLoopDisplay?: LoopDisplay;/*** @deprecated For internal use only.*/- _remotionInternalPremountDisplay?: number | null;+ readonly _remotionInternalPremountDisplay?: number | null;/*** @deprecated For internal use only.*/- _remotionInternalStack?: string;+ readonly _remotionInternalStack?: string;/*** @deprecated For internal use only.*/- _remotionInternalIsPremounting?: boolean;+ readonly _remotionInternalIsPremounting?: boolean;} & LayoutAndStyle;export type SequenceProps = {- durationInFrames?: number;+ readonly durationInFrames?: number;} & SequencePropsWithoutDuration;const RegularSequenceRefForwardingFunction: React.ForwardRefRenderFunction<@@ -85,6 +87,7 @@ const RegularSequenceRefForwardingFunction: React.ForwardRefRenderFunction<ref,) => {const {layout = 'absolute-fill'} = other;+const [id] = useState(() => String(Math.random()));const parentSequence = useContext(SequenceContext);const {rootId} = useContext(TimelineContext);diff --git a/packages/core/src/index.ts b/packages/core/src/index.tsindex 459989e2db..5d856355bb 100644--- a/packages/core/src/index.ts+++ b/packages/core/src/index.ts@@ -131,6 +131,7 @@ export {export {prefetch, PrefetchOnProgress} from './prefetch.js';export {registerRoot} from './register-root.js';export {+ AbsoluteFillLayout,LayoutAndStyle,Sequence,SequenceProps,diff --git a/packages/docs/docs/transitions/transitionseries.mdx b/packages/docs/docs/transitions/transitionseries.mdxindex 4614a92905..1f1901ede6 100644--- a/packages/docs/docs/transitions/transitionseries.mdx+++ b/packages/docs/docs/transitions/transitionseries.mdx@@ -77,7 +77,7 @@ export const MyComp: React.FC = () => {### `<TransitionSeries>`-Inherits the [`from`](/docs/sequence#from), [`name`](/docs/sequence#name), [`className`](/docs/sequence#classname), [`style`](/docs/sequence#style) and [`layout`](/docs/sequence#layout) props from [`<Sequence>`](/docs/sequence).+Inherits the [`from`](/docs/sequence#from), [`name`](/docs/sequence#name), [`className`](/docs/sequence#classname), and [`style`](/docs/sequence#style) props from [`<Sequence>`](/docs/sequence).The `<TransitionSeries>` component can only contain `<TransitionSeries.Sequence>` and `<TransitionSeries.Transition>` components.diff --git a/packages/transitions/src/TransitionSeries.tsx b/packages/transitions/src/TransitionSeries.tsxindex 91283bb1a8..3b84faec87 100644--- a/packages/transitions/src/TransitionSeries.tsx+++ b/packages/transitions/src/TransitionSeries.tsx@@ -1,7 +1,12 @@import type {FC, PropsWithChildren} from 'react';import {Children, useMemo} from 'react';-import type {LayoutAndStyle, SequencePropsWithoutDuration} from 'remotion';+import type {+ AbsoluteFillLayout,+ LayoutAndStyle,+ SequencePropsWithoutDuration,+} from 'remotion';import {Internals, Sequence, useCurrentFrame, useVideoConfig} from 'remotion';+import {NoReactInternals} from 'remotion/no-react';import {flattenChildren} from './flatten-children.js';import {slide} from './presentations/slide.js';import type {TransitionSeriesTransitionProps} from './types.js';@@ -17,6 +22,11 @@ const TransitionSeriesTransition = function <return null;};+type LayoutBasedProps =+ true extends typeof NoReactInternals.ENABLE_V5_BREAKING_CHANGES+ ? AbsoluteFillLayout+ : LayoutAndStyle;+type SeriesSequenceProps = PropsWithChildren<{readonly durationInFrames: number;@@ -26,7 +36,7 @@ type SeriesSequenceProps = PropsWithChildren<* @deprecated For internal use only*/readonly stack?: string;- } & LayoutAndStyle &+ } & LayoutBasedProps &Pick<SequencePropsWithoutDuration, 'name'>>;@@ -321,10 +331,20 @@ const TransitionSeriesChildren: FC<{readonly children: React.ReactNode}> = ({const TransitionSeries: FC<SequencePropsWithoutDuration> & {Sequence: typeof SeriesSequence;Transition: typeof TransitionSeriesTransition;-} = ({children, name, ...otherProps}) => {+} = ({children, name, layout: passedLayout, ...otherProps}) => {const displayName = name ?? '<TransitionSeries>';+ const layout = passedLayout ?? 'absolute-fill';+ if (+ NoReactInternals.ENABLE_V5_BREAKING_CHANGES &&+ layout !== 'absolute-fill'+ ) {+ throw new TypeError(+ `The "layout" prop of <TransitionSeries /> is not supported anymore in v5. TransitionSeries' must be absolutely positioned.`,+ );+ }+return (- <Sequence name={displayName} {...otherProps}>+ <Sequence name={displayName} layout={layout} {...otherProps}><TransitionSeriesChildren>{children}</TransitionSeriesChildren></Sequence>);