Skip to content

🎥 Make videos programmatically with React

cool

Jonny Burgerfb6f65717738
diff --git a/packages/studio-server/src/codemods/update-sequence-props.ts b/packages/studio-server/src/codemods/update-sequence-props.ts
index 428d29c380..6995a17bd5 100644
--- a/packages/studio-server/src/codemods/update-sequence-props.ts
+++ b/packages/studio-server/src/codemods/update-sequence-props.ts
@@ -221,7 +221,7 @@ export const updateSequenceProps = async ({
input: string;
nodePath: SequenceNodePath;
updates: SequencePropUpdate[];
- schema?: SequenceSchema;
+ schema: SequenceSchema;
prettierConfigOverride?: Record<string, unknown> | null;
}): Promise<{
output: string;
diff --git a/packages/studio-server/src/preview-server/routes/save-sequence-props.ts b/packages/studio-server/src/preview-server/routes/save-sequence-props.ts
index 1f2c9a6b91..351de589eb 100644
--- a/packages/studio-server/src/preview-server/routes/save-sequence-props.ts
+++ b/packages/studio-server/src/preview-server/routes/save-sequence-props.ts
@@ -5,6 +5,7 @@ import type {
SaveSequencePropsRequest,
SaveSequencePropsResponse,
} from '@remotion/studio-shared';
+import {Internals} from 'remotion';
import {updateSequenceProps} from '../../codemods/update-sequence-props';
import {writeFileAndNotifyFileWatchers} from '../../file-watcher';
import type {ApiHandler} from '../api-types';
@@ -50,6 +51,7 @@ export const saveSequencePropsHandler: ApiHandler<
defaultValue !== null ? JSON.parse(defaultValue) : null,
},
],
+ schema: Internals.sequenceSchema,
});
const oldValueString = oldValueStrings[0];
diff --git a/packages/studio-server/src/test/code-shift.test.ts b/packages/studio-server/src/test/code-shift.test.ts
index c8ae0b7df1..5af3cd8391 100644
--- a/packages/studio-server/src/test/code-shift.test.ts
+++ b/packages/studio-server/src/test/code-shift.test.ts
@@ -1,4 +1,5 @@
import {expect, test} from 'bun:test';
+import {Internals} from 'remotion';
import {updateSequenceProps} from '../codemods/update-sequence-props';
import {lineColumnToNodePath} from './test-utils';
@@ -21,6 +22,7 @@ test('Should add style.scale to a Video component and format with prettier', asy
bracketSpacing: false,
useTabs: true,
},
+ schema: Internals.sequenceSchema,
});
const oldValueString = oldValueStrings[0];
diff --git a/packages/studio-server/src/test/update-nested-sequence-props.test.ts b/packages/studio-server/src/test/update-nested-sequence-props.test.ts
index 541358e2a0..cfe047f844 100644
--- a/packages/studio-server/src/test/update-nested-sequence-props.test.ts
+++ b/packages/studio-server/src/test/update-nested-sequence-props.test.ts
@@ -1,4 +1,5 @@
import {expect, test} from 'bun:test';
+import {Internals} from 'remotion';
import {updateSequenceProps} from '../codemods/update-sequence-props';
import {lineColumnToNodePath} from './test-utils';
@@ -20,6 +21,7 @@ test('updateSequenceProps should update a nested style property', async () => {
input: nestedInput,
nodePath: lineColumnToNodePath(nestedInput, 7),
updates: [{key: 'style.opacity', value: 0.8, defaultValue: null}],
+ schema: Internals.sequenceSchema,
});
const oldValueString = oldValueStrings[0];
@@ -33,6 +35,7 @@ test('updateSequenceProps should add a nested property to existing object', asyn
input: nestedInput,
nodePath: lineColumnToNodePath(nestedInput, 7),
updates: [{key: 'style.rotate', value: 45, defaultValue: null}],
+ schema: Internals.sequenceSchema,
});
const oldValueString = oldValueStrings[0];
@@ -48,6 +51,7 @@ test('updateSequenceProps should create style attribute when it does not exist',
input: nestedInput,
nodePath: lineColumnToNodePath(nestedInput, 8),
updates: [{key: 'style.opacity', value: 0.3, defaultValue: null}],
+ schema: Internals.sequenceSchema,
});
const oldValueString = oldValueStrings[0];
@@ -61,6 +65,7 @@ test('updateSequenceProps should remove nested property when value equals defaul
input: nestedInput,
nodePath: lineColumnToNodePath(nestedInput, 7),
updates: [{key: 'style.opacity', value: 1, defaultValue: 1}],
+ schema: Internals.sequenceSchema,
});
const oldValueString = oldValueStrings[0];
@@ -83,6 +88,7 @@ export const Example: React.FC = () => {
input: singlePropInput,
nodePath: lineColumnToNodePath(singlePropInput, 4),
updates: [{key: 'style.opacity', value: 1, defaultValue: 1}],
+ schema: Internals.sequenceSchema,
});
const oldValueString = oldValueStrings[0];
@@ -95,6 +101,7 @@ test('updateSequenceProps should report default as oldValueString for missing ne
input: nestedInput,
nodePath: lineColumnToNodePath(nestedInput, 8),
updates: [{key: 'style.opacity', value: 0.5, defaultValue: 1}],
+ schema: Internals.sequenceSchema,
});
const oldValueString = oldValueStrings[0];
diff --git a/packages/studio-server/src/test/update-sequence-props.test.ts b/packages/studio-server/src/test/update-sequence-props.test.ts
index 42c6b0fdff..d947982f61 100644
--- a/packages/studio-server/src/test/update-sequence-props.test.ts
+++ b/packages/studio-server/src/test/update-sequence-props.test.ts
@@ -1,4 +1,5 @@
import {expect, test} from 'bun:test';
+import {Internals} from 'remotion';
import {updateSequenceProps} from '../codemods/update-sequence-props';
import {lineColumnToNodePath} from './test-utils';
@@ -21,6 +22,7 @@ test('updateSequenceProps should update a number value', async () => {
input: lightLeakInput,
nodePath: lineColumnToNodePath(lightLeakInput, 8),
updates: [{key: 'hueShift', value: 90, defaultValue: null}],
+ schema: Internals.sequenceSchema,
});
const oldValueString = oldValueStrings[0];
@@ -35,6 +37,7 @@ test('updateSequenceProps should update durationInFrames', async () => {
input: lightLeakInput,
nodePath: lineColumnToNodePath(lightLeakInput, 9),
updates: [{key: 'durationInFrames', value: 120, defaultValue: null}],
+ schema: Internals.sequenceSchema,
});
const oldValueString = oldValueStrings[0];
@@ -49,6 +52,7 @@ test('updateSequenceProps should add a new attribute', async () => {
input: lightLeakInput,
nodePath: lineColumnToNodePath(lightLeakInput, 9),
updates: [{key: 'speed', value: 2, defaultValue: null}],
+ schema: Internals.sequenceSchema,
});
const oldValueString = oldValueStrings[0];
@@ -61,6 +65,7 @@ test('updateSequenceProps should remove attribute when value equals default', as
input: lightLeakInput,
nodePath: lineColumnToNodePath(lightLeakInput, 9),
updates: [{key: 'hueShift', value: 0, defaultValue: 0}],
+ schema: Internals.sequenceSchema,
});
const oldValueString = oldValueStrings[0];
@@ -75,6 +80,7 @@ test('updateSequenceProps should set boolean true as shorthand', async () => {
input: lightLeakInput,
nodePath: lineColumnToNodePath(lightLeakInput, 8),
updates: [{key: 'loop', value: true, defaultValue: false}],
+ schema: Internals.sequenceSchema,
});
// true booleans become shorthand: `loop` not `loop={true}`
@@ -87,6 +93,7 @@ test('updateSequenceProps should report oldValueString for computed expressions'
input: lightLeakInput,
nodePath: lineColumnToNodePath(lightLeakInput, 8),
updates: [{key: 'seed', value: 5, defaultValue: null}],
+ schema: Internals.sequenceSchema,
});
const oldValueString = oldValueStrings[0];
@@ -98,6 +105,7 @@ test('updateSequenceProps should report default as oldValueString for missing at
input: lightLeakInput,
nodePath: lineColumnToNodePath(lightLeakInput, 8),
updates: [{key: 'speed', value: 2, defaultValue: 1}],
+ schema: Internals.sequenceSchema,
});
const oldValueString = oldValueStrings[0];
@@ -110,6 +118,7 @@ test('updateSequenceProps should throw for non-existent nodePath', async () => {
input: lightLeakInput,
nodePath: ['program', 'body', 999],
updates: [{key: 'hueShift', value: 90, defaultValue: null}],
+ schema: Internals.sequenceSchema,
}),
).rejects.toThrow(
'Could not find a JSX element at the specified line to update',
diff --git a/packages/studio-shared/src/api-requests.ts b/packages/studio-shared/src/api-requests.ts
index 2efebd18ef..22d326a8c6 100644
--- a/packages/studio-shared/src/api-requests.ts
+++ b/packages/studio-shared/src/api-requests.ts
@@ -10,7 +10,7 @@ import type {
X264Preset,
} from '@remotion/renderer';
import type {HardwareAccelerationOption} from '@remotion/renderer/client';
-import type {_InternalTypes} from 'remotion';
+import type {_InternalTypes, SequenceSchema} from 'remotion';
import type {CanUpdateSequencePropStatus} from 'remotion';
import type {RecastCodemod, VisualControlChange} from './codemods';
import type {PackageManager} from './package-manager';
@@ -246,6 +246,7 @@ export type SaveSequencePropsRequest = {
value: string;
defaultValue: string | null;
observedKeys: string[];
+ schema: SequenceSchema;
};
export type SaveSequencePropsResponse =
diff --git a/packages/studio/src/components/Timeline/TimelineExpandedSection.tsx b/packages/studio/src/components/Timeline/TimelineExpandedSection.tsx
index e3af004928..f8795ad7a4 100644
--- a/packages/studio/src/components/Timeline/TimelineExpandedSection.tsx
+++ b/packages/studio/src/components/Timeline/TimelineExpandedSection.tsx
@@ -135,6 +135,10 @@ export const TimelineExpandedSection: React.FC<{
}
if (node.field) {
+ if (!sequence.controls) {
+ throw new Error('Sequence controls schema is not set');
+ }
+
return (
<TimelineFieldRow
field={node.field}
@@ -143,6 +147,7 @@ export const TimelineExpandedSection: React.FC<{
paddingLeft={paddingLeft}
nodePath={nodePath}
keysToObserve={keysToObserve}
+ schema={sequence.controls.schema}
/>
);
}
@@ -167,6 +172,7 @@ export const TimelineExpandedSection: React.FC<{
sequenceOffsetPx,
toggleTrack,
validatedLocation,
+ sequence.controls,
],
);
diff --git a/packages/studio/src/components/Timeline/TimelineFieldRow.tsx b/packages/studio/src/components/Timeline/TimelineFieldRow.tsx
index 5e3c3518cd..fb16a6a177 100644
--- a/packages/studio/src/components/Timeline/TimelineFieldRow.tsx
+++ b/packages/studio/src/components/Timeline/TimelineFieldRow.tsx
@@ -1,6 +1,6 @@
import type {SequenceNodePath} from '@remotion/studio-shared';
import React, {useCallback, useContext, useMemo} from 'react';
-import type {CanUpdateSequencePropStatus} from 'remotion';
+import type {CanUpdateSequencePropStatus, SequenceSchema} from 'remotion';
import {Internals} from 'remotion';
import type {CodePosition} from '../../error-overlay/react-overlay/utils/get-source-map';
import type {SchemaFieldInfo} from '../../helpers/timeline-layout';
@@ -36,6 +36,7 @@ export const TimelineFieldRow: React.FC<{
readonly paddingLeft: number;
readonly nodePath: SequenceNodePath | null;
readonly keysToObserve: string[];
+ readonly schema: SequenceSchema;
}> = ({
field,
overrideId,
@@ -43,6 +44,7 @@ export const TimelineFieldRow: React.FC<{
paddingLeft,
nodePath,
keysToObserve,
+ schema,
}) => {
const {
setDragOverrides,
@@ -95,6 +97,7 @@ export const TimelineFieldRow: React.FC<{
value: JSON.stringify(value),
defaultValue,
observedKeys: keysToObserve,
+ schema,
}).then((data) => {
if (data.success) {
if (data.newStatus.canUpdate) {
@@ -117,6 +120,7 @@ export const TimelineFieldRow: React.FC<{
propStatuses,
setCodeValues,
validatedLocation,
+ schema,
],
);