Skip to content

🎥 Make videos programmatically with React

render entry

Jonny Burgera73521edaf47
diff --git a/packages/bundler/src/renderEntry.tsx b/packages/bundler/src/renderEntry.tsx
index f6d9809ea6..334fbc4e40 100644
--- a/packages/bundler/src/renderEntry.tsx
+++ b/packages/bundler/src/renderEntry.tsx
@@ -5,7 +5,11 @@ import type {render, unmountComponentAtNode} from 'react-dom';
// We support both, but Webpack chooses both of them and normalizes them to "react-dom/client",
// hence why we import the right thing all the time but need to differentiate here
import ReactDOM from 'react-dom/client';
-import type {AnyComposition, BundleState} from 'remotion';
+import type {
+ AnyComposition,
+ BundleState,
+ VideoConfigWithSerializedProps,
+} from 'remotion';
import {
continueRender,
delayRender,
@@ -272,7 +276,9 @@ if (typeof window !== 'undefined') {
return compositions;
};
- window.getStaticCompositions = () => {
+ window.getStaticCompositions = (): Promise<
+ VideoConfigWithSerializedProps[]
+ > => {
const compositions = getUnevaluatedComps();
const inputProps =
@@ -283,7 +289,7 @@ if (typeof window !== 'undefined') {
: getInputProps() ?? {};
return Promise.all(
- compositions.map(async (c) => {
+ compositions.map(async (c): Promise<VideoConfigWithSerializedProps> => {
const handle = delayRender(
`Running calculateMetadata() for composition ${c.id}. If you didn't want to evaluate this composition, use "selectComposition()" instead of "getCompositions()"`
);
diff --git a/packages/core/src/index.ts b/packages/core/src/index.ts
index 1d29938e34..1fcc45383f 100644
--- a/packages/core/src/index.ts
+++ b/packages/core/src/index.ts
@@ -8,6 +8,14 @@ import type {ClipRegion} from './NativeLayers.js';
import {Null} from './Null.js';
import type {VideoConfig} from './video-config.js';
+export type VideoConfigWithSerializedProps = Omit<
+ VideoConfig,
+ 'defaultProps' | 'props'
+> & {
+ serializedDefaultPropsWithCustomSchema: string;
+ serializedResolvedPropsWithCustomSchema: string;
+};
+
declare global {
interface Window {
remotion_renderReady: boolean;
@@ -16,18 +24,10 @@ declare global {
};
remotion_cancelledError: string | undefined;
remotion_getCompositionNames: () => string[];
- getStaticCompositions: () => Promise<
- (Omit<VideoConfig, 'defaultProps' | 'props'> & {
- serializedDefaultPropsWithCustomSchema: string;
- serializedResolvedPropsWithCustomSchema: string;
- })[]
- >;
- remotion_calculateComposition: (compId: string) => Promise<
- Omit<VideoConfig, 'defaultProps' | 'props'> & {
- serializedDefaultPropsWithCustomSchema: string;
- serializedResolvedPropsWithCustomSchema: string;
- }
- >;
+ getStaticCompositions: () => Promise<VideoConfigWithSerializedProps[]>;
+ remotion_calculateComposition: (
+ compId: string
+ ) => Promise<VideoConfigWithSerializedProps>;
remotion_setBundleMode: (bundleMode: BundleState) => void;
remotion_staticBase: string;
remotion_staticFiles: StaticFile[];