Skip to content

🎥 Make videos programmatically with React

`@remotion/studio`: Make keyframed values updateable (#8019)

Jonny Burgerf14adeed11b5
diff --git a/packages/core/src/get-effective-visual-mode-value.ts b/packages/core/src/get-effective-visual-mode-value.ts
index 30c7b96d2b..c4f7ecff13 100644
--- a/packages/core/src/get-effective-visual-mode-value.ts
+++ b/packages/core/src/get-effective-visual-mode-value.ts
@@ -1,4 +1,4 @@
-import type {CanUpdateSequencePropStatusTrue} from './use-schema';
+import type {CanUpdaterSequencePropStatusStatic} from './use-schema';
export const getEffectiveVisualModeValue = ({
codeValue,
@@ -6,7 +6,7 @@ export const getEffectiveVisualModeValue = ({
defaultValue,
shouldResortToDefaultValueIfUndefined = false,
}: {
- codeValue: CanUpdateSequencePropStatusTrue;
+ codeValue: CanUpdaterSequencePropStatusStatic;
dragOverrideValue: unknown;
defaultValue: unknown;
shouldResortToDefaultValueIfUndefined: boolean;
diff --git a/packages/core/src/internals.ts b/packages/core/src/internals.ts
index 7f9c78a5b4..10c10b10bc 100644
--- a/packages/core/src/internals.ts
+++ b/packages/core/src/internals.ts
@@ -183,9 +183,9 @@ import {
useMediaInTimeline,
} from './use-media-in-timeline.js';
import type {
+ CanUpdaterSequencePropStatusStatic,
CanUpdateSequencePropStatusFalse,
CanUpdateSequencePropStatusKeyframed,
- CanUpdateSequencePropStatusTrue,
GetCodeValues,
GetDragOverrides,
GetEffectCodeValues,
@@ -384,13 +384,13 @@ export type {
CanUpdateEffectPropsResponse,
CanUpdateEffectPropsResponseFalse,
CanUpdateEffectPropsResponseTrue,
+ CanUpdaterSequencePropStatusStatic,
CanUpdateSequencePropsResponse,
CanUpdateSequencePropsResponseFalse,
CanUpdateSequencePropsResponseTrue,
CanUpdateSequencePropStatus,
CanUpdateSequencePropStatusFalse,
CanUpdateSequencePropStatusKeyframed,
- CanUpdateSequencePropStatusTrue,
CodeValues,
CompositionManagerContext,
CompProps,
diff --git a/packages/core/src/test/interpolate-keyframed-status.test.ts b/packages/core/src/test/interpolate-keyframed-status.test.ts
index b394b570e1..7f0c737497 100644
--- a/packages/core/src/test/interpolate-keyframed-status.test.ts
+++ b/packages/core/src/test/interpolate-keyframed-status.test.ts
@@ -5,8 +5,9 @@ test('interpolates linear numeric keyframes', () => {
const result = interpolateKeyframedStatus({
frame: 30,
status: {
- canUpdate: false,
- reason: 'keyframed',
+ canUpdate: true,
+ codeValue: undefined,
+ keyframed: true,
interpolationFunction: 'interpolate',
keyframes: [
{frame: 0, value: 0},
@@ -24,8 +25,9 @@ test('clamps when extrapolation is clamp', () => {
const result = interpolateKeyframedStatus({
frame: 120,
status: {
- canUpdate: false,
- reason: 'keyframed',
+ canUpdate: true,
+ codeValue: undefined,
+ keyframed: true,
interpolationFunction: 'interpolate',
keyframes: [
{frame: 0, value: 0},
@@ -43,8 +45,9 @@ test('posterizes the frame before interpolating numeric keyframes', () => {
const result = interpolateKeyframedStatus({
frame: 17,
status: {
- canUpdate: false,
- reason: 'keyframed',
+ canUpdate: true,
+ codeValue: undefined,
+ keyframed: true,
interpolationFunction: 'interpolate',
keyframes: [
{frame: 0, value: 0},
@@ -62,8 +65,9 @@ test('returns single keyframe value', () => {
const result = interpolateKeyframedStatus({
frame: 100,
status: {
- canUpdate: false,
- reason: 'keyframed',
+ canUpdate: true,
+ codeValue: undefined,
+ keyframed: true,
interpolationFunction: 'interpolate',
keyframes: [{frame: 0, value: 7}],
easing: [],
@@ -78,8 +82,9 @@ test('interpolates colors', () => {
const result = interpolateKeyframedStatus({
frame: 30,
status: {
- canUpdate: false,
- reason: 'keyframed',
+ canUpdate: true,
+ codeValue: undefined,
+ keyframed: true,
interpolationFunction: 'interpolateColors',
keyframes: [
{frame: 0, value: '#000000'},
@@ -98,8 +103,9 @@ test('posterizes the frame before interpolating color keyframes', () => {
const result = interpolateKeyframedStatus({
frame: 17,
status: {
- canUpdate: false,
- reason: 'keyframed',
+ canUpdate: true,
+ codeValue: undefined,
+ keyframed: true,
interpolationFunction: 'interpolateColors',
keyframes: [
{frame: 0, value: 'black'},
@@ -117,8 +123,9 @@ test('uses bezier easing', () => {
const result = interpolateKeyframedStatus({
frame: 30,
status: {
- canUpdate: false,
- reason: 'keyframed',
+ canUpdate: true,
+ codeValue: undefined,
+ keyframed: true,
interpolationFunction: 'interpolate',
keyframes: [
{frame: 0, value: 0},
@@ -137,8 +144,9 @@ test('interpolates scale strings component-wise', () => {
const result = interpolateKeyframedStatus({
frame: 30,
status: {
- canUpdate: false,
- reason: 'keyframed',
+ canUpdate: true,
+ codeValue: undefined,
+ keyframed: true,
interpolationFunction: 'interpolate',
keyframes: [
{frame: 0, value: 2},
diff --git a/packages/core/src/use-schema.ts b/packages/core/src/use-schema.ts
index bafd3998ec..a886911b76 100644
--- a/packages/core/src/use-schema.ts
+++ b/packages/core/src/use-schema.ts
@@ -11,9 +11,10 @@ import type {
SequencePropsSubscriptionKey,
} from './SequenceManager.js';
-export type CanUpdateSequencePropStatusTrue = {
+export type CanUpdaterSequencePropStatusStatic = {
canUpdate: true;
codeValue: unknown;
+ keyframed: false;
};
export type CanUpdateSequencePropStatusKeyframe = {
@@ -40,8 +41,9 @@ export type CanUpdateSequencePropStatusComputed = {
};
export type CanUpdateSequencePropStatusKeyframed = {
- canUpdate: false;
- reason: 'keyframed';
+ canUpdate: true;
+ codeValue: unknown;
+ keyframed: true;
interpolationFunction: CanUpdateSequencePropStatusInterpolationFunction;
keyframes: CanUpdateSequencePropStatusKeyframe[];
easing: CanUpdateSequencePropStatusEasing[];
@@ -50,11 +52,11 @@ export type CanUpdateSequencePropStatusKeyframed = {
};
export type CanUpdateSequencePropStatusFalse =
- | CanUpdateSequencePropStatusComputed
- | CanUpdateSequencePropStatusKeyframed;
+ CanUpdateSequencePropStatusComputed;
export type CanUpdateSequencePropStatus =
- | CanUpdateSequencePropStatusTrue
+ | CanUpdaterSequencePropStatusStatic
+ | CanUpdateSequencePropStatusKeyframed
| CanUpdateSequencePropStatusFalse;
export type DragOverrides = Record<string, Record<string, unknown>>;
@@ -79,6 +81,12 @@ export type GetEffectDragOverrides = (
effectIndex: number,
) => Record<string, unknown>;
+export const isKeyframedStatus = (
+ status: CanUpdateSequencePropStatus | null,
+): status is CanUpdateSequencePropStatusKeyframed => {
+ return status !== null && status.canUpdate && 'keyframes' in status;
+};
+
const findFieldInSchema = (
schema: SequenceSchema,
key: string,
@@ -129,8 +137,8 @@ export const computeEffectiveSchemaValuesDotNotation = ({
let value: unknown;
if (codeValueStatus === null) {
value = currentValue[key];
- } else if (codeValueStatus.canUpdate === false) {
- if (codeValueStatus.reason === 'keyframed' && frame !== null) {
+ } else if (isKeyframedStatus(codeValueStatus)) {
+ if (frame !== null) {
const interpolated = interpolateKeyframedStatus({
frame,
status: codeValueStatus,
@@ -139,6 +147,8 @@ export const computeEffectiveSchemaValuesDotNotation = ({
} else {
value = currentValue[key];
}
+ } else if (codeValueStatus.canUpdate === false) {
+ value = currentValue[key];
} else {
value = getEffectiveVisualModeValue({
codeValue: codeValueStatus,
diff --git a/packages/studio-server/src/preview-server/routes/can-update-effect-props.ts b/packages/studio-server/src/preview-server/routes/can-update-effect-props.ts
index b883cee6bd..d12f2fe3b2 100644
--- a/packages/studio-server/src/preview-server/routes/can-update-effect-props.ts
+++ b/packages/studio-server/src/preview-server/routes/can-update-effect-props.ts
@@ -158,7 +158,7 @@ const getPropsFromObjectExpression = ({
) as ObjectProperty | undefined;
if (!prop) {
- out[key] = {canUpdate: true, codeValue: undefined};
+ out[key] = {canUpdate: true, codeValue: undefined, keyframed: false};
continue;
}
@@ -171,6 +171,7 @@ const getPropsFromObjectExpression = ({
out[key] = {
canUpdate: true,
codeValue: extractStaticValue(valueExpr),
+ keyframed: false,
};
}
@@ -225,7 +226,11 @@ export const computeEffectPropStatus = ({
if (call.arguments.length === 0) {
const emptyProps: Record<string, CanUpdateSequencePropStatus> = {};
for (const key of keys) {
- emptyProps[key] = {canUpdate: true, codeValue: undefined};
+ emptyProps[key] = {
+ canUpdate: true,
+ codeValue: undefined,
+ keyframed: false,
+ };
}
return {
diff --git a/packages/studio-server/src/preview-server/routes/can-update-sequence-props.ts b/packages/studio-server/src/preview-server/routes/can-update-sequence-props.ts
index 17582953cb..2e6bdbd4d1 100644
--- a/packages/studio-server/src/preview-server/routes/can-update-sequence-props.ts
+++ b/packages/studio-server/src/preview-server/routes/can-update-sequence-props.ts
@@ -28,8 +28,7 @@ import {JsxElementNotFoundAtLocationError} from '../jsx-element-not-found-at-loc
import {computeEffectPropStatus} from './can-update-effect-props';
type CanUpdatePropStatus = CanUpdateSequencePropStatus;
-type ComputedPropStatus = Extract<CanUpdatePropStatus, {canUpdate: false}>;
-type KeyframedPropStatus = Extract<ComputedPropStatus, {reason: 'keyframed'}>;
+type KeyframedPropStatus = Extract<CanUpdatePropStatus, {keyframed: true}>;
type PropKeyframes = KeyframedPropStatus['keyframes'];
type PropEasing = KeyframedPropStatus['easing'];
type PropClamping = KeyframedPropStatus['clamping'];
@@ -478,8 +477,9 @@ export const getComputedStatus = (node: Expression): CanUpdatePropStatus => {
}
return {
- canUpdate: false,
- reason: 'keyframed',
+ canUpdate: true,
+ codeValue: undefined,
+ keyframed: true,
interpolationFunction: interpolation.interpolationFunction,
keyframes: interpolation.keyframes,
easing: interpolation.easing,
@@ -510,7 +510,7 @@ const getPropsStatus = (
const {value} = attr as JSXAttribute;
if (!value) {
- props[name] = {canUpdate: true, codeValue: true};
+ props[name] = {canUpdate: true, codeValue: true, keyframed: false};
continue;
}
@@ -518,6 +518,7 @@ const getPropsStatus = (
props[name] = {
canUpdate: true,
codeValue: (value as {value: string}).value,
+ keyframed: false,
};
continue;
}
@@ -537,6 +538,7 @@ const getPropsStatus = (
props[name] = {
canUpdate: true,
codeValue: extractStaticValue(expression),
+ keyframed: false,
};
continue;
}
@@ -658,7 +660,7 @@ const getNestedPropStatus = (
if (!attr || !attr.value) {
// Parent attribute doesn't exist, nested prop can be added
- return {canUpdate: true, codeValue: undefined};
+ return {canUpdate: true, codeValue: undefined, keyframed: false};
}
if (attr.value.type !== 'JSXExpressionContainer') {
@@ -684,7 +686,7 @@ const getNestedPropStatus = (
if (!prop) {
// Property not set in the object, can be added
- return {canUpdate: true, codeValue: undefined};
+ return {canUpdate: true, codeValue: undefined, keyframed: false};
}
const propValue = prop.value as Expression;
@@ -697,7 +699,7 @@ const getNestedPropStatus = (
return {canUpdate: false, reason: 'computed'};
}
- return {canUpdate: true, codeValue};
+ return {canUpdate: true, codeValue, keyframed: false};
};
const computeEffectsForJsx = ({
@@ -739,7 +741,11 @@ const computeSequenceOnlyPropsRecord = ({
} else if (key in allProps) {
filteredProps[key] = allProps[key];
} else {
- filteredProps[key] = {canUpdate: true, codeValue: undefined};
+ filteredProps[key] = {
+ canUpdate: true,
+ codeValue: undefined,
+ keyframed: false,
+ };
}
}
diff --git a/packages/studio-server/src/test/compute-effect-props-status.test.ts b/packages/studio-server/src/test/compute-effect-props-status.test.ts
index 761cfba4c5..dfc9283205 100644
--- a/packages/studio-server/src/test/compute-effect-props-status.test.ts
+++ b/packages/studio-server/src/test/compute-effect-props-status.test.ts
@@ -43,8 +43,16 @@ test('computeEffectPropStatus reports static props as canUpdate=true with codeVa
throw new Error('expected canUpdate true');
}
- expect(result.props.color).toEqual({canUpdate: true, codeValue: 'red'});
- expect(result.props.opacity).toEqual({canUpdate: true, codeValue: 0.5});
+ expect(result.props.color).toEqual({
+ canUpdate: true,
+ codeValue: 'red',
+ keyframed: false,
+ });
+ expect(result.props.opacity).toEqual({
+ canUpdate: true,
+ codeValue: 0.5,
+ keyframed: false,
+ });
expect(result.importPath).toBe('@remotion/effects/tint');
});
@@ -64,7 +72,11 @@ test('computeEffectPropStatus reports computed props', () => {
}
expect(result.props.color).toEqual({canUpdate: false, reason: 'computed'});
- expect(result.props.opacity).toEqual({canUpdate: true, codeValue: 0.5});
+ expect(result.props.opacity).toEqual({
+ canUpdate: true,
+ codeValue: 0.5,
+ keyframed: false,
+ });
});
test('computeEffectPropStatus reports keyframes for inline interpolated effect props', () => {
@@ -85,8 +97,9 @@ test('computeEffectPropStatus reports keyframes for inline interpolated effect p
}
expect(result.props.amount).toEqual({
- canUpdate: false,
- reason: 'keyframed',
+ canUpdate: true,
+ codeValue: undefined,
+ keyframed: true,
interpolationFunction: 'interpolate',
keyframes: [
{frame: 0, value: 0.2},
@@ -113,8 +126,16 @@ test('computeEffectPropStatus reports unset props as undefined codeValue', () =>
throw new Error('expected canUpdate true');
}
- expect(result.props.color).toEqual({canUpdate: true, codeValue: 'red'});
- expect(result.props.opacity).toEqual({canUpdate: true, codeValue: undefined});
+ expect(result.props.color).toEqual({
+ canUpdate: true,
+ codeValue: 'red',
+ keyframed: false,
+ });
+ expect(result.props.opacity).toEqual({
+ canUpdate: true,
+ codeValue: undefined,
+ keyframed: false,
+ });
});
test('computeEffectPropStatus flags non-call expressions', () => {
@@ -189,5 +210,6 @@ test('computeEffectPropStatus treats zero-arg effect as editable with undefined
expect(result.props.amount).toEqual({
canUpdate: true,
codeValue: undefined,
+ keyframed: false,
});
});
diff --git a/packages/studio-server/src/test/compute-sequence-props-status.test.ts b/packages/studio-server/src/test/compute-sequence-props-status.test.ts
index 19d3d86543..996e188275 100644
--- a/packages/studio-server/src/test/compute-sequence-props-status.test.ts
+++ b/packages/studio-server/src/test/compute-sequence-props-status.test.ts
@@ -47,12 +47,18 @@ test('canUpdateSequenceProps should flag computed props', () => {
expect(result.props.durationInFrames).toEqual({
canUpdate: true,
codeValue: 60,
+ keyframed: false,
+ });
+ expect(result.props.hueShift).toEqual({
+ canUpdate: true,
+ codeValue: 30,
+ keyframed: false,
});
- expect(result.props.hueShift).toEqual({canUpdate: true, codeValue: 30});
expect(result.props.seed).toEqual({canUpdate: false, reason: 'computed'});
expect(result.props.nonExistentProp).toEqual({
canUpdate: true,
codeValue: undefined,
+ keyframed: false,
});
});
@@ -78,8 +84,9 @@ export const Example: React.FC = () => {
if (!result.canUpdate) throw new Error('Expected canUpdate to be true');
expect(result.props.color).toEqual({
- canUpdate: false,
- reason: 'keyframed',
+ canUpdate: true,
+ codeValue: undefined,
+ keyframed: true,
interpolationFunction: 'interpolateColors',
keyframes: [
{frame: 0, value: 'red'},
@@ -125,10 +132,12 @@ test('computeSequencePropsStatus should detect static nested props', () => {
expect(result.props['style.opacity']).toEqual({
canUpdate: true,
codeValue: 0.5,
+ keyframed: false,
});
expect(result.props['style.scale']).toEqual({
canUpdate: true,
codeValue: 2,
+ keyframed: false,
});
});
@@ -154,6 +163,7 @@ test('computeSequencePropsStatus should flag computed nested props', () => {
expect(result.props['style.scale']).toEqual({
canUpdate: true,
codeValue: 2,
+ keyframed: false,
});
});
@@ -193,6 +203,7 @@ test('computeSequencePropsStatus should report unset nested props as undefined',
expect(result.props['style.rotate']).toEqual({
canUpdate: true,
codeValue: undefined,
+ keyframed: false,
});
});
@@ -212,6 +223,7 @@ test('computeSequencePropsStatus should report unset when parent attribute missi
expect(result.props['style.opacity']).toEqual({
canUpdate: true,
codeValue: undefined,
+ keyframed: false,
});
});
@@ -229,8 +241,9 @@ test('computeSequencePropsStatus should return keyframes for interpolated style
if (!result.canUpdate) throw new Error('Expected canUpdate to be true');
expect(result.props['style.scale']).toEqual({
- canUpdate: false,
- reason: 'keyframed',
+ canUpdate: true,
+ codeValue: undefined,
+ keyframed: true,
interpolationFunction: 'interpolate',
keyframes: [
{frame: 0, value: 2},
@@ -269,8 +282,9 @@ export const Example: React.FC = () => {
if (!result.canUpdate) throw new Error('Expected canUpdate to be true');
expect(result.props['style.scale']).toEqual({
- canUpdate: false,
- reason: 'keyframed',
+ canUpdate: true,
+ codeValue: undefined,
+ keyframed: true,
interpolationFunction: 'interpolate',
keyframes: [
{frame: 0, value: 1},
@@ -309,8 +323,9 @@ export const Example: React.FC = () => {
if (!result.canUpdate) throw new Error('Expected canUpdate to be true');
expect(result.props['style.scale']).toEqual({
- canUpdate: false,
- reason: 'keyframed',
+ canUpdate: true,
+ codeValue: undefined,
+ keyframed: true,
interpolationFunction: 'interpolate',
keyframes: [
{frame: 0, value: 1},
@@ -345,8 +360,9 @@ export const Example: React.FC = () => {
if (!result.canUpdate) throw new Error('Expected canUpdate to be true');
expect(result.props.color).toEqual({
- canUpdate: false,
- reason: 'keyframed',
+ canUpdate: true,
+ codeValue: undefined,
+ keyframed: true,
interpolationFunction: 'interpolateColors',
keyframes: [
{frame: 0, value: 'red'},
diff --git a/packages/studio-server/src/test/update-keyframes.test.ts b/packages/studio-server/src/test/update-keyframes.test.ts
index d3e2348a79..491957f7a4 100644
--- a/packages/studio-server/src/test/update-keyframes.test.ts
+++ b/packages/studio-server/src/test/update-keyframes.test.ts
@@ -206,8 +206,9 @@ export default CenteredSolid;
effects: [],
});
expect(status.props.width).toEqual({
- canUpdate: false,
- reason: 'keyframed',
+ canUpdate: true,
+ codeValue: undefined,
+ keyframed: true,
interpolationFunction: 'interpolate',
keyframes: [{frame: 11, value: 240}],
easing: [],
@@ -264,6 +265,7 @@ test('updateSequenceKeyframes converts the last keyframe to a static value', asy
expect(status.props['style.scale']).toEqual({
canUpdate: true,
codeValue: 320,
+ keyframed: false,
});
});
@@ -314,6 +316,7 @@ test('updateSequenceKeyframes converts the last color keyframe to a static value
expect(status.props.color).toEqual({
canUpdate: true,
codeValue: 'blue',
+ keyframed: false,
});
});
diff --git a/packages/studio-shared/src/optimistic-add-keyframe.ts b/packages/studio-shared/src/optimistic-add-keyframe.ts
index 9dda078ee0..64392cebc4 100644
--- a/packages/studio-shared/src/optimistic-add-keyframe.ts
+++ b/packages/studio-shared/src/optimistic-add-keyframe.ts
@@ -21,12 +21,43 @@ const addKeyframeToPropStatus = ({
frame: number;
value: unknown;
}): CanUpdateSequencePropStatus => {
+ if ('keyframes' in status) {
+ const existingIndex = status.keyframes.findIndex(
+ (kf) => kf.frame === frame,
+ );
+ if (existingIndex !== -1) {
+ const updatedKeyframes = status.keyframes.map((keyframe, index) =>
+ index === existingIndex ? {frame, value} : keyframe,
+ );
+
+ return {
+ ...status,
+ keyframes: updatedKeyframes,
+ };
+ }
+
+ const keyframes = [...status.keyframes, {frame, value}].sort(
+ (first, second) => first.frame - second.frame,
+ );
+ const easing = [...status.easing];
+ while (easing.length < keyframes.length - 1) {
+ easing.push('linear');
+ }
+
+ return {
+ ...status,
+ keyframes,
+ easing,
+ };
+ }
+
if (status.canUpdate) {
const staticValue = status.codeValue ?? value;
return {
- canUpdate: false,
- reason: 'keyframed',
+ canUpdate: true,
+ codeValue: undefined,
+ keyframed: true,
interpolationFunction: getInterpolationFunction(staticValue, value),
keyframes: [{frame, value}],
easing: [],
@@ -35,35 +66,7 @@ const addKeyframeToPropStatus = ({
};
}
- if (status.reason !== 'keyframed') {
- return status;
- }
-
- const existingIndex = status.keyframes.findIndex((kf) => kf.frame === frame);
- if (existingIndex !== -1) {
- const updatedKeyframes = status.keyframes.map((keyframe, index) =>
- index === existingIndex ? {frame, value} : keyframe,
- );
-
- return {
- ...status,
- keyframes: updatedKeyframes,
- };
- }
-
- const keyframes = [...status.keyframes, {frame, value}].sort(
- (first, second) => first.frame - second.frame,
- );
- const easing = [...status.easing];
- while (easing.length < keyframes.length - 1) {
- easing.push('linear');
- }
-
- return {
- ...status,
- keyframes,
- easing,
- };
+ return status;
};
export const optimisticAddSequenceKeyframe = ({
diff --git a/packages/studio-shared/src/optimistic-delete-keyframe.ts b/packages/studio-shared/src/optimistic-delete-keyframe.ts
index e90d026164..584845aaf4 100644
--- a/packages/studio-shared/src/optimistic-delete-keyframe.ts
+++ b/packages/studio-shared/src/optimistic-delete-keyframe.ts
@@ -10,11 +10,7 @@ const removeKeyframeFromPropStatus = ({
status: CanUpdateSequencePropStatus;
frame: number;
}): CanUpdateSequencePropStatus => {
- if (status.canUpdate) {
- return status;
- }
-
- if (status.reason !== 'keyframed') {
+ if (!('keyframes' in status)) {
return status;
}
@@ -28,6 +24,7 @@ const removeKeyframeFromPropStatus = ({
return {
canUpdate: true,
codeValue: status.keyframes[index].value,
+ keyframed: false,
};
}
diff --git a/packages/studio-shared/src/optimistic-update-for-code-values.ts b/packages/studio-shared/src/optimistic-update-for-code-values.ts
index 8bfcc9762a..b92a369383 100644
--- a/packages/studio-shared/src/optimistic-update-for-code-values.ts
+++ b/packages/studio-shared/src/optimistic-update-for-code-values.ts
@@ -22,7 +22,7 @@ export const optimisticUpdateForCodeValues = ({
const props: Record<string, CanUpdateSequencePropStatus> = {
...previous.props,
- [fieldKey]: {canUpdate: true, codeValue: value},
+ [fieldKey]: {canUpdate: true, codeValue: value, keyframed: false},
};
if (schema[fieldKey]?.type === 'enum') {
diff --git a/packages/studio-shared/src/optimistic-update-for-effect-code-values.ts b/packages/studio-shared/src/optimistic-update-for-effect-code-values.ts
index 86ab01474f..e2080a668f 100644
--- a/packages/studio-shared/src/optimistic-update-for-effect-code-values.ts
+++ b/packages/studio-shared/src/optimistic-update-for-effect-code-values.ts
@@ -37,7 +37,7 @@ export const optimisticUpdateForEffectCodeValues = ({
const props: Record<string, CanUpdateSequencePropStatus> = {
...target.props,
- [fieldKey]: {canUpdate: true, codeValue: value},
+ [fieldKey]: {canUpdate: true, codeValue: value, keyframed: false},
};
if (schema[fieldKey]?.type === 'enum') {
diff --git a/packages/studio-shared/src/test/optimistic-add-keyframe.test.ts b/packages/studio-shared/src/test/optimistic-add-keyframe.test.ts
index 832371987c..1d21e868c9 100644
--- a/packages/studio-shared/src/test/optimistic-add-keyframe.test.ts
+++ b/packages/studio-shared/src/test/optimistic-add-keyframe.test.ts
@@ -12,6 +12,7 @@ test('optimisticAddSequenceKeyframe converts a static prop to a single keyframe'
opacity: {
canUpdate: true,
codeValue: 0.5,
+ keyframed: false,
},
},
effects: [],
@@ -29,7 +30,7 @@ test('optimisticAddSequenceKeyframe converts a static prop to a single keyframe'
}
const status = updated.props.opacity;
- if (!status || status.canUpdate || status.reason !== 'keyframed') {
+ if (!status || !status.canUpdate || !('keyframes' in status)) {
throw new Error('expected keyframed status');
}
@@ -42,8 +43,9 @@ test('optimisticAddSequenceKeyframe appends a keyframe to an existing interpolat
canUpdate: true,
props: {
scale: {
- canUpdate: false,
- reason: 'keyframed',
+ canUpdate: true,
+ codeValue: undefined,
+ keyframed: true,
interpolationFunction: 'interpolate',
keyframes: [
{frame: 0, value: 1},
@@ -69,7 +71,7 @@ test('optimisticAddSequenceKeyframe appends a keyframe to an existing interpolat
}
const status = updated.props.scale;
- if (!status || status.canUpdate || status.reason !== 'keyframed') {
+ if (!status || !status.canUpdate || !('keyframes' in status)) {
throw new Error('expected keyframed status');
}
@@ -93,8 +95,9 @@ test('optimisticAddEffectKeyframe appends a keyframe on the target effect', () =
importPath: null,
props: {
amount: {
- canUpdate: false,
- reason: 'keyframed',
+ canUpdate: true,
+ codeValue: undefined,
+ keyframed: true,
interpolationFunction: 'interpolate',
keyframes: [{frame: 0, value: 0.2}],
easing: [],
@@ -124,7 +127,7 @@ test('optimisticAddEffectKeyframe appends a keyframe on the target effect', () =
}
const status = effect.props.amount;
- if (!status || status.canUpdate || status.reason !== 'keyframed') {
+ if (!status || !status.canUpdate || !('keyframes' in status)) {
throw new Error('expected keyframed status');
}
@@ -148,6 +151,7 @@ test('optimisticAddEffectKeyframe converts a static prop to a single keyframe',
amount: {
canUpdate: true,
codeValue: 0.2,
+ keyframed: false,
},
},
},
@@ -172,7 +176,7 @@ test('optimisticAddEffectKeyframe converts a static prop to a single keyframe',
}
const status = effect.props.amount;
- if (!status || status.canUpdate || status.reason !== 'keyframed') {
+ if (!status || !status.canUpdate || !('keyframes' in status)) {
throw new Error('expected keyframed status');
}
diff --git a/packages/studio-shared/src/test/optimistic-delete-keyframe.test.ts b/packages/studio-shared/src/test/optimistic-delete-keyframe.test.ts
index 7684f2e77e..0bfee79457 100644
--- a/packages/studio-shared/src/test/optimistic-delete-keyframe.test.ts
+++ b/packages/studio-shared/src/test/optimistic-delete-keyframe.test.ts
@@ -12,8 +12,9 @@ test('optimisticDeleteSequenceKeyframe removes the matching keyframe and an easi
canUpdate: true,
props: {
'style.opacity': {
- canUpdate: false,
- reason: 'keyframed',
+ canUpdate: true,
+ codeValue: undefined,
+ keyframed: true,
interpolationFunction: 'interpolate',
keyframes: [
{frame: 0, value: 0},
@@ -39,7 +40,7 @@ test('optimisticDeleteSequenceKeyframe removes the matching keyframe and an easi
}
const status = updated.props['style.opacity'];
- if (status.canUpdate || status.reason !== 'keyframed') {
+ if (!status.canUpdate || !('keyframes' in status)) {
throw new Error('expected keyframed status');
}
@@ -55,8 +56,9 @@ test('optimisticDeleteSequenceKeyframe converts the last keyframe to a static va
canUpdate: true,
props: {
width: {
- canUpdate: false,
- reason: 'keyframed',
+ canUpdate: true,
+ codeValue: undefined,
+ keyframed: true,
interpolationFunction: 'interpolate',
keyframes: [{frame: 12, value: 320}],
easing: [],
@@ -80,6 +82,7 @@ test('optimisticDeleteSequenceKeyframe converts the last keyframe to a static va
expect(updated.props.width).toEqual({
canUpdate: true,
codeValue: 320,
+ keyframed: false,
});
});
@@ -88,8 +91,9 @@ test('optimisticDeleteSequenceKeyframe is a no-op when no keyframe matches', ()
canUpdate: true,
props: {
'style.opacity': {
- canUpdate: false,
- reason: 'keyframed',
+ canUpdate: true,
+ codeValue: undefined,
+ keyframed: true,
interpolationFunction: 'interpolate',
keyframes: [{frame: 0, value: 0}],
easing: [],
@@ -131,8 +135,9 @@ test('optimisticDeleteSequenceKeyframes deletes multiple keyframes in one pass',
canUpdate: true,
props: {
width: {
- canUpdate: false,
- reason: 'keyframed',
+ canUpdate: true,
+ codeValue: undefined,
+ keyframed: true,
interpolationFunction: 'interpolate',
keyframes: [
{frame: 0, value: 100},
@@ -160,7 +165,7 @@ test('optimisticDeleteSequenceKeyframes deletes multiple keyframes in one pass',
}
const status = updated.props.width;
- if (status.canUpdate || status.reason !== 'keyframed') {
+ if (!status.canUpdate || !('keyframes' in status)) {
throw new Error('expected keyframed status');
}
@@ -180,8 +185,9 @@ test('optimisticDeleteEffectKeyframe removes the matching keyframe on the target
importPath: null,
props: {
amount: {
- canUpdate: false,
- reason: 'keyframed',
+ canUpdate: true,
+ codeValue: undefined,
+ keyframed: true,
interpolationFunction: 'interpolate',
keyframes: [
{frame: 0, value: 0},
@@ -213,7 +219,7 @@ test('optimisticDeleteEffectKeyframe removes the matching keyframe on the target
}
const status = effect.props.amount;
- if (status.canUpdate || status.reason !== 'keyframed') {
+ if (!status.canUpdate || !('keyframes' in status)) {
throw new Error('expected keyframed status');
}
@@ -233,8 +239,9 @@ test('optimisticDeleteEffectKeyframe converts the last keyframe on the target ef
importPath: null,
props: {
amount: {
- canUpdate: false,
- reason: 'keyframed',
+ canUpdate: true,
+ codeValue: undefined,
+ keyframed: true,
interpolationFunction: 'interpolate',
keyframes: [{frame: 40, value: 0.6}],
easing: [],
@@ -265,6 +272,7 @@ test('optimisticDeleteEffectKeyframe converts the last keyframe on the target ef
expect(effect.props.amount).toEqual({
canUpdate: true,
codeValue: 0.6,
+ keyframed: false,
});
});
@@ -297,8 +305,9 @@ test('optimisticDeleteEffectKeyframes deletes multiple keyframes in one pass', (
importPath: null,
props: {
amount: {
- canUpdate: false,
- reason: 'keyframed',
+ canUpdate: true,
+ codeValue: undefined,
+ keyframed: true,
interpolationFunction: 'interpolate',
keyframes: [
{frame: 0, value: 0},
@@ -332,7 +341,7 @@ test('optimisticDeleteEffectKeyframes deletes multiple keyframes in one pass', (
}
const status = effect.props.amount;
- if (status.canUpdate || status.reason !== 'keyframed') {
+ if (!status.canUpdate || !('keyframes' in status)) {
throw new Error('expected keyframed status');
}
diff --git a/packages/studio-shared/src/test/optimistic-update-for-code-values.test.ts b/packages/studio-shared/src/test/optimistic-update-for-code-values.test.ts
index 9ac51c3377..54345aeb6c 100644
--- a/packages/studio-shared/src/test/optimistic-update-for-code-values.test.ts
+++ b/packages/studio-shared/src/test/optimistic-update-for-code-values.test.ts
@@ -10,6 +10,7 @@ test('optimisticUpdateForCodeValues should return the correct response', () => {
'style.opacity': {
canUpdate: true,
codeValue: 0.5,
+ keyframed: false,
},
},
effects: [],
@@ -27,6 +28,7 @@ test('optimisticUpdateForCodeValues should return the correct response', () => {
'style.opacity': {
canUpdate: true,
codeValue: 0.6,
+ keyframed: false,
},
},
effects: [],
@@ -44,6 +46,7 @@ test('optimisticUpdateForCodeValues should return the correct response', () => {
layout: {
canUpdate: true,
codeValue: 'none',
+ keyframed: false,
},
},
effects: [],
diff --git a/packages/studio-shared/src/test/optimistic-update-for-effect-code-values.test.ts b/packages/studio-shared/src/test/optimistic-update-for-effect-code-values.test.ts
index 8e5e2d95ad..04d02aa39d 100644
--- a/packages/studio-shared/src/test/optimistic-update-for-effect-code-values.test.ts
+++ b/packages/studio-shared/src/test/optimistic-update-for-effect-code-values.test.ts
@@ -11,8 +11,8 @@ test('optimisticUpdateForEffectCodeValues updates the matching effect prop', ()
canUpdate: true,
effectIndex: 0,
props: {
- color: {canUpdate: true, codeValue: 'red'},
- opacity: {canUpdate: true, codeValue: 0.5},
+ color: {canUpdate: true, codeValue: 'red', keyframed: false},
+ opacity: {canUpdate: true, codeValue: 0.5, keyframed: false},
},
callee: 'tint',
importPath: null,
@@ -37,8 +37,16 @@ test('optimisticUpdateForEffectCodeValues updates the matching effect prop', ()
throw new Error('expected effect canUpdate true');
}
- expect(effect.props.opacity).toEqual({canUpdate: true, codeValue: 0.8});
- expect(effect.props.color).toEqual({canUpdate: true, codeValue: 'red'});
+ expect(effect.props.opacity).toEqual({
+ canUpdate: true,
+ codeValue: 0.8,
+ keyframed: false,
+ });
+ expect(effect.props.color).toEqual({
+ canUpdate: true,
+ codeValue: 'red',
+ keyframed: false,
+ });
});
test('optimisticUpdateForEffectCodeValues is a no-op when sequence is not updateable', () => {
@@ -87,7 +95,7 @@ test('optimisticUpdateForEffectCodeValues applies when effect props are unset (z
callee: 'tint',
importPath: null,
props: {
- amount: {canUpdate: true, codeValue: undefined},
+ amount: {canUpdate: true, codeValue: undefined, keyframed: false},
},
},
],
@@ -110,5 +118,9 @@ test('optimisticUpdateForEffectCodeValues applies when effect props are unset (z
throw new Error('expected effect canUpdate true');
}
- expect(effect.props.amount).toEqual({canUpdate: true, codeValue: 0.5});
+ expect(effect.props.amount).toEqual({
+ canUpdate: true,
+ codeValue: 0.5,
+ keyframed: false,
+ });
});
diff --git a/packages/studio-shared/src/test/schema-field-info.test.ts b/packages/studio-shared/src/test/schema-field-info.test.ts
index 1d5b88cb8e..9705f8dec6 100644
--- a/packages/studio-shared/src/test/schema-field-info.test.ts
+++ b/packages/studio-shared/src/test/schema-field-info.test.ts
@@ -61,7 +61,11 @@ test('getEffectFieldsToShow uses the active enum variant', () => {
importPath: null,
effectIndex: 0,
props: {
- colorMode: {canUpdate: true, codeValue: 'source'},
+ colorMode: {
+ canUpdate: true,
+ codeValue: 'source',
+ keyframed: false,
+ },
},
},
],
diff --git a/packages/studio/src/components/SelectedOutlineOverlay.tsx b/packages/studio/src/components/SelectedOutlineOverlay.tsx
index 5ef0ee73b5..1d85b283cb 100644
--- a/packages/studio/src/components/SelectedOutlineOverlay.tsx
+++ b/packages/studio/src/components/SelectedOutlineOverlay.tsx
@@ -1,6 +1,6 @@
import React, {useContext, useEffect, useMemo, useRef, useState} from 'react';
import type {
- CanUpdateSequencePropStatusTrue,
+ CanUpdaterSequencePropStatusStatic,
CodeValues,
GetEffectDragOverrides,
OverrideIdToNodePaths,
@@ -54,7 +54,7 @@ type UvCoordinateFieldSchema = Extract<
type SelectedOutlineUvHandle = {
readonly clientId: string;
- readonly codeValue: CanUpdateSequencePropStatusTrue;
+ readonly codeValue: CanUpdaterSequencePropStatusStatic;
readonly effectIndex: number;
readonly fieldDefault: UvCoordinate | undefined;
readonly fieldKey: string;
@@ -72,7 +72,7 @@ type SelectedOutlineTarget = {
};
type SelectedOutlineDragTarget = {
- readonly codeValue: CanUpdateSequencePropStatusTrue;
+ readonly codeValue: CanUpdaterSequencePropStatusStatic;
readonly clientId: string;
readonly fieldDefault: string | undefined;
readonly nodePath: SequencePropsSubscriptionKey;
@@ -523,7 +523,7 @@ const getSelectedUvHandles = ({
}
const propStatus = effectStatus.props[fieldKey];
- if (!propStatus?.canUpdate) {
+ if (!propStatus?.canUpdate || propStatus.keyframed) {
continue;
}
@@ -1008,7 +1008,8 @@ export const SelectedOutlineOverlay: React.FC<{
previewServerState.type === 'connected' &&
controls !== null &&
fieldSchema?.type === 'translate' &&
- codeValue?.canUpdate === true;
+ codeValue?.canUpdate === true &&
+ codeValue.keyframed === false;
return {
key,
diff --git a/packages/studio/src/components/Timeline/TimelineClipboardKeybindings.tsx b/packages/studio/src/components/Timeline/TimelineClipboardKeybindings.tsx
index aa6ae222d1..a21ba3afc0 100644
--- a/packages/studio/src/components/Timeline/TimelineClipboardKeybindings.tsx
+++ b/packages/studio/src/components/Timeline/TimelineClipboardKeybindings.tsx
@@ -110,21 +110,13 @@ export const getPasteEffectsTarget = (
};
};
-type CopyableEffectStatus = {
- readonly canUpdate: true;
- readonly callee: string;
- readonly importPath: string | null;
- readonly props: Record<
- string,
- | {
- readonly canUpdate: true;
- readonly codeValue?: unknown;
- }
- | {
- readonly canUpdate: false;
- }
- >;
-};
+type CopyableEffectStatus = React.ContextType<
+ typeof Internals.VisualModeCodeValuesContext
+>['codeValues'][string] extends infer TCodeValue
+ ? TCodeValue extends {canUpdate: true; effects: readonly unknown[]}
+ ? Extract<TCodeValue['effects'][number], {canUpdate: true}>
+ : never
+ : never;
const effectStatusToSnapshot = (
effect: CopyableEffectStatus,
@@ -139,6 +131,10 @@ const effectStatusToSnapshot = (
return null;
}
+ if (prop.keyframed) {
+ return null;
+ }
+
if (prop.codeValue !== undefined) {
params[key] = prop.codeValue;
}
@@ -151,7 +147,7 @@ const effectStatusToSnapshot = (
};
};
-const getSnapshotsFromSelection = ({
+export const getSnapshotsFromSelection = ({
selection,
codeValues,
}: {
diff --git a/packages/studio/src/components/Timeline/TimelineEffectPropItem.tsx b/packages/studio/src/components/Timeline/TimelineEffectPropItem.tsx
index 07d622fc11..fbe53847e3 100644
--- a/packages/studio/src/components/Timeline/TimelineEffectPropItem.tsx
+++ b/packages/studio/src/components/Timeline/TimelineEffectPropItem.tsx
@@ -1,6 +1,10 @@
import {optimisticUpdateForEffectCodeValues} from '@remotion/studio-shared';
import React, {useCallback, useContext, useMemo} from 'react';
-import type {SequencePropsSubscriptionKey} from 'remotion';
+import type {
+ CanUpdateSequencePropStatus,
+ CanUpdateSequencePropStatusKeyframed,
+ SequencePropsSubscriptionKey,
+} from 'remotion';
import {Internals} from 'remotion';
import type {CodePosition} from '../../error-overlay/react-overlay/utils/get-source-map';
import {StudioServerConnectionCtx} from '../../helpers/client-id';
@@ -27,6 +31,12 @@ import {useTimelineRowSelection} from './TimelineSelection';
const fieldRowBase: React.CSSProperties = {};
+const isKeyframedStatus = (
+ status: CanUpdateSequencePropStatus,
+): status is CanUpdateSequencePropStatusKeyframed => {
+ return 'keyframes' in status;
+};
+
const Value: React.FC<{
readonly field: EffectSchemaFieldInfo;
readonly nodePath: SequencePropsSubscriptionKey;
@@ -183,22 +193,22 @@ const Value: React.FC<{
);
}
- if (propStatus === null || !propStatus.canUpdate) {
- if (propStatus?.reason === 'keyframed') {
- return (
- <TimelineKeyframedValue
- field={field}
- propStatus={propStatus}
- keyframeDisplayOffset={keyframeDisplayOffset}
- />
- );
- }
+ if (propStatus === null) {
+ return null;
+ }
- if (propStatus?.reason === 'computed') {
- return <UnsupportedStatus label={getComputedStatusLabel(propStatus)} />;
- }
+ if (isKeyframedStatus(propStatus)) {
+ return (
+ <TimelineKeyframedValue
+ field={field}
+ propStatus={propStatus}
+ keyframeDisplayOffset={keyframeDisplayOffset}
+ />
+ );
+ }
- return null;
+ if (!propStatus.canUpdate) {
+ return <UnsupportedStatus label={getComputedStatusLabel(propStatus)} />;
}
const effectiveValue = Internals.getEffectiveVisualModeValue({
diff --git a/packages/studio/src/components/Timeline/TimelineKeyframeControls.tsx b/packages/studio/src/components/Timeline/TimelineKeyframeControls.tsx
index e238854826..2d70b08c14 100644
--- a/packages/studio/src/components/Timeline/TimelineKeyframeControls.tsx
+++ b/packages/studio/src/components/Timeline/TimelineKeyframeControls.tsx
@@ -1,6 +1,7 @@
import React, {useCallback, useContext, useMemo} from 'react';
import type {
CanUpdateSequencePropStatus,
+ CanUpdateSequencePropStatusKeyframed,
SequencePropsSubscriptionKey,
SequenceSchema,
} from 'remotion';
@@ -48,6 +49,12 @@ const navButtonStyle: React.CSSProperties = {
width: 14,
};
+const isKeyframedStatus = (
+ status: CanUpdateSequencePropStatus,
+): status is CanUpdateSequencePropStatusKeyframed => {
+ return 'keyframes' in status;
+};
+
const diamondButtonStyle: React.CSSProperties = {
...navButtonStyle,
background: 'none',
@@ -75,6 +82,14 @@ const getCurrentKeyframeValue = ({
defaultValue: unknown;
dragOverrideValue: unknown;
}): unknown | null => {
+ if (isKeyframedStatus(propStatus)) {
+ const keyframedStatus = propStatus as CanUpdateSequencePropStatusKeyframed;
+ return Internals.interpolateKeyframedStatus({
+ frame: jsxFrame,
+ status: keyframedStatus,
+ });
+ }
+
if (propStatus.canUpdate) {
return Internals.getEffectiveVisualModeValue({
codeValue: propStatus,
@@ -84,13 +99,6 @@ const getCurrentKeyframeValue = ({
});
}
- if (propStatus.reason === 'keyframed') {
- return Internals.interpolateKeyframedStatus({
- frame: jsxFrame,
- status: propStatus,
- });
- }
-
return null;
};
@@ -109,11 +117,7 @@ export const shouldShowTimelineKeyframeControls = ({
return true;
}
- return (
- SELECTION_ENABLED &&
- !propStatus.canUpdate &&
- propStatus.reason === 'keyframed'
- );
+ return SELECTION_ENABLED && isKeyframedStatus(propStatus);
};
export const TimelineKeyframeControls: React.FC<{
@@ -155,11 +159,14 @@ export const TimelineKeyframeControls: React.FC<{
);
const hasKeyframeAtCurrentFrame = useMemo(() => {
- if (propStatus.canUpdate || propStatus.reason === 'computed') {
+ if (!isKeyframedStatus(propStatus)) {
return false;
}
- return hasKeyframeAtSourceFrame(propStatus.keyframes, jsxFrame);
+ return hasKeyframeAtSourceFrame(
+ (propStatus as CanUpdateSequencePropStatusKeyframed).keyframes,
+ jsxFrame,
+ );
}, [jsxFrame, propStatus]);
const currentKeyframeValue = useMemo(
@@ -186,8 +193,7 @@ export const TimelineKeyframeControls: React.FC<{
const canAddKeyframe =
fieldSchema?.type !== 'scale' || typeof currentKeyframeValue === 'number';
const canToggleKeyframe =
- (propStatus.canUpdate || propStatus.reason === 'keyframed') &&
- (hasKeyframeAtCurrentFrame || canAddKeyframe);
+ propStatus.canUpdate && (hasKeyframeAtCurrentFrame || canAddKeyframe);
const seekToDisplayFrame = useCallback(
(frame: number) => {
@@ -227,11 +233,7 @@ export const TimelineKeyframeControls: React.FC<{
return;
}
- if (
- hasKeyframeAtCurrentFrame &&
- !propStatus.canUpdate &&
- propStatus.reason === 'keyframed'
- ) {
+ if (hasKeyframeAtCurrentFrame && isKeyframedStatus(propStatus)) {
if (effectIndex === null) {
await callDeleteSequenceKeyframe({
fileName,
diff --git a/packages/studio/src/components/Timeline/TimelineKeyframedValue.tsx b/packages/studio/src/components/Timeline/TimelineKeyframedValue.tsx
index aed2ceadbd..7ef3683b52 100644
--- a/packages/studio/src/components/Timeline/TimelineKeyframedValue.tsx
+++ b/packages/studio/src/components/Timeline/TimelineKeyframedValue.tsx
@@ -1,7 +1,7 @@
import React, {useMemo} from 'react';
import type {
- CanUpdateSequencePropStatusKeyframed,
- CanUpdateSequencePropStatusTrue,
+ CanUpdateSequencePropStatus,
+ CanUpdaterSequencePropStatusStatic,
} from 'remotion';
import {Internals} from 'remotion';
import type {SchemaFieldInfo} from '../../helpers/timeline-layout';
@@ -17,13 +17,17 @@ const noopAsync = () => Promise.resolve();
export const TimelineKeyframedValue: React.FC<{
readonly field: SchemaFieldInfo;
- readonly propStatus: CanUpdateSequencePropStatusKeyframed;
+ readonly propStatus: CanUpdateSequencePropStatus;
readonly keyframeDisplayOffset: number;
}> = ({field, propStatus, keyframeDisplayOffset}) => {
const timelinePosition = Internals.Timeline.useTimelinePosition();
const jsxFrame = timelinePosition - keyframeDisplayOffset;
const computedValue = useMemo(() => {
+ if (!('keyframes' in propStatus)) {
+ return null;
+ }
+
const raw = Internals.interpolateKeyframedStatus({
frame: jsxFrame,
status: propStatus,
@@ -35,10 +39,11 @@ export const TimelineKeyframedValue: React.FC<{
return raw;
}, [jsxFrame, propStatus]);
- const fakeStatus: CanUpdateSequencePropStatusTrue = useMemo(
+ const fakeStatus: CanUpdaterSequencePropStatusStatic = useMemo(
() => ({
canUpdate: true,
codeValue: computedValue,
+ keyframed: false,
}),
[computedValue],
);
diff --git a/packages/studio/src/components/Timeline/TimelineSchemaField.tsx b/packages/studio/src/components/Timeline/TimelineSchemaField.tsx
index 37c77ab772..a904be8cfc 100644
--- a/packages/studio/src/components/Timeline/TimelineSchemaField.tsx
+++ b/packages/studio/src/components/Timeline/TimelineSchemaField.tsx
@@ -1,7 +1,7 @@
import React from 'react';
import type {
CanUpdateSequencePropStatusFalse,
- CanUpdateSequencePropStatusTrue,
+ CanUpdaterSequencePropStatusStatic,
} from 'remotion';
import type {
SchemaFieldInfo,
@@ -49,7 +49,7 @@ export const TimelineNonEditableStatus: React.FC<{
return null;
}
- if (propStatus.reason === 'computed' || propStatus.reason === 'keyframed') {
+ if (propStatus.reason === 'computed') {
return (
<span style={unsupportedLabel}>{getComputedStatusLabel(propStatus)}</span>
);
@@ -61,7 +61,7 @@ export const TimelineFieldValue: React.FC<{
readonly onSave: TimelineFieldOnSave;
readonly onDragValueChange: TimelineFieldOnDragValueChange;
readonly onDragEnd: () => void;
- readonly propStatus: CanUpdateSequencePropStatusTrue;
+ readonly propStatus: CanUpdaterSequencePropStatusStatic;
readonly effectiveValue: unknown;
}> = ({
field,
diff --git a/packages/studio/src/components/Timeline/TimelineSequencePropItem.tsx b/packages/studio/src/components/Timeline/TimelineSequencePropItem.tsx
index a446cf4b87..0ff929db49 100644
--- a/packages/studio/src/components/Timeline/TimelineSequencePropItem.tsx
+++ b/packages/studio/src/components/Timeline/TimelineSequencePropItem.tsx
@@ -1,6 +1,8 @@
import React, {useCallback, useContext, useMemo} from 'react';
import type {
- CanUpdateSequencePropStatusTrue,
+ CanUpdaterSequencePropStatusStatic,
+ CanUpdateSequencePropStatus,
+ CanUpdateSequencePropStatusKeyframed,
SequencePropsSubscriptionKey,
SequenceSchema,
} from 'remotion';
@@ -34,12 +36,18 @@ import {useTimelineRowSelection} from './TimelineSelection';
const fieldRowBase: React.CSSProperties = {};
+const isKeyframedStatus = (
+ status: CanUpdateSequencePropStatus,
+): status is CanUpdateSequencePropStatusKeyframed => {
+ return 'keyframes' in status;
+};
+
const Value: React.FC<{
readonly field: SchemaFieldInfo;
readonly nodePath: SequencePropsSubscriptionKey;
readonly validatedLocation: CodePosition;
readonly schema: SequenceSchema;
- readonly codeValue: CanUpdateSequencePropStatusTrue;
+ readonly codeValue: CanUpdaterSequencePropStatusStatic;
}> = ({field, nodePath, validatedLocation, schema, codeValue}) => {
const {getDragOverrides} = useContext(
Internals.VisualModeDragOverridesContext,
@@ -307,7 +315,15 @@ export const TimelineSequencePropItem: React.FC<{
selected={selection.selected}
label={field.description ?? field.key}
/>
- {codeValue.canUpdate ? (
+ {isKeyframedStatus(codeValue) ? (
+ <div style={timelineFieldValueColumnStyle}>
+ <TimelineKeyframedValue
+ field={field}
+ propStatus={codeValue}
+ keyframeDisplayOffset={keyframeDisplayOffset}
+ />
+ </div>
+ ) : codeValue.canUpdate ? (
<div style={timelineFieldValueColumnStyle}>
<Value
field={field}
@@ -317,14 +333,6 @@ export const TimelineSequencePropItem: React.FC<{
codeValue={codeValue}
/>
</div>
- ) : codeValue.reason === 'keyframed' ? (
- <div style={timelineFieldValueColumnStyle}>
- <TimelineKeyframedValue
- field={field}
- propStatus={codeValue}
- keyframeDisplayOffset={keyframeDisplayOffset}
- />
- </div>
) : (
<div style={timelineFieldValueColumnStyle}>
<TimelineNonEditableStatus propStatus={codeValue} />
diff --git a/packages/studio/src/components/Timeline/get-timeline-keyframes.ts b/packages/studio/src/components/Timeline/get-timeline-keyframes.ts
index 15be11d1f9..b3aa446485 100644
--- a/packages/studio/src/components/Timeline/get-timeline-keyframes.ts
+++ b/packages/studio/src/components/Timeline/get-timeline-keyframes.ts
@@ -3,9 +3,9 @@ import type {
CanUpdateSequencePropStatusFalse,
} from 'remotion';
-export const getComputedStatusLabel = (
+export const getComputedStatusLabel: (
propStatus: CanUpdateSequencePropStatusFalse,
-): string => {
+) => string = (propStatus) => {
if (propStatus.reason === 'computed') {
return 'computed';
}
@@ -17,21 +17,28 @@ export const getTimelineKeyframes = (
propStatus: CanUpdateSequencePropStatus | null | undefined,
keyframeDisplayOffset = 0,
): {frame: number; value: unknown}[] => {
- if (!propStatus || propStatus.canUpdate) {
+ if (!propStatus) {
return [];
}
- if (propStatus.reason === 'computed') {
+ if (!propStatus.canUpdate) {
return [];
}
- const {keyframes} = propStatus;
- if (keyframeDisplayOffset === 0) {
- return keyframes;
+ if ('keyframes' in propStatus) {
+ const {keyframes} = propStatus as Extract<
+ CanUpdateSequencePropStatus,
+ {keyframes: unknown}
+ >;
+ if (keyframeDisplayOffset === 0) {
+ return keyframes;
+ }
+
+ return keyframes.map((keyframe) => ({
+ ...keyframe,
+ frame: keyframe.frame + keyframeDisplayOffset,
+ }));
}
- return keyframes.map((keyframe) => ({
- ...keyframe,
- frame: keyframe.frame + keyframeDisplayOffset,
- }));
+ return [];
};
diff --git a/packages/studio/src/test/timeline-keyframes.test.ts b/packages/studio/src/test/timeline-keyframes.test.ts
index bc05f16efb..5b0668bbf6 100644
--- a/packages/studio/src/test/timeline-keyframes.test.ts
+++ b/packages/studio/src/test/timeline-keyframes.test.ts
@@ -114,8 +114,9 @@ test('keyframe display offsets follow the parent sequence context', () => {
expect(
getTimelineKeyframes(
{
- canUpdate: false,
- reason: 'keyframed',
+ canUpdate: true,
+ codeValue: undefined,
+ keyframed: true,
interpolationFunction: 'interpolate',
keyframes: [
{frame: 0, value: 2},
diff --git a/packages/studio/src/test/timeline-selection.test.ts b/packages/studio/src/test/timeline-selection.test.ts
index f548edb54b..14d1ef2af6 100644
--- a/packages/studio/src/test/timeline-selection.test.ts
+++ b/packages/studio/src/test/timeline-selection.test.ts
@@ -20,6 +20,7 @@ import {isDuplicatableSequenceRowSelection} from '../components/Timeline/duplica
import {getTimelinePropResetTargets} from '../components/Timeline/reset-selected-timeline-props';
import {
getPasteEffectsTarget,
+ getSnapshotsFromSelection,
type PasteEffectsTarget,
} from '../components/Timeline/TimelineClipboardKeybindings';
import {
@@ -143,6 +144,53 @@ test('pasting effects treats effect selections on one sequence as one target', (
} satisfies PasteEffectsTarget);
});
+test('copying a keyframed effect is blocked', () => {
+ const effectNodePathInfo = makeNodePathInfo(
+ ['body', 0],
+ ['effects', '0'],
+ true,
+ [['0']],
+ );
+ const nodePath = effectNodePathInfo.sequenceSubscriptionKey;
+ const codeValues = {
+ [Internals.makeSequencePropsSubscriptionKey(nodePath)]: {
+ canUpdate: true,
+ props: {},
+ effects: [
+ {
+ canUpdate: true,
+ callee: 'effect',
+ importPath: '@remotion/effect',
+ effectIndex: 0,
+ props: {
+ intensity: {
+ canUpdate: true,
+ codeValue: 10,
+ keyframed: true,
+ interpolationFunction: 'interpolate',
+ keyframes: [{frame: 0, value: 10}],
+ easing: ['linear'],
+ clamping: {left: 'clamp', right: 'clamp'},
+ posterize: undefined,
+ },
+ },
+ },
+ ],
+ },
+ } satisfies CodeValues;
+
+ expect(
+ getSnapshotsFromSelection({
+ selection: {
+ type: 'sequence-effect',
+ nodePathInfo: effectNodePathInfo,
+ i: 0,
+ },
+ codeValues,
+ }),
+ ).toBe(null);
+});
+
test('Timeline top drag should not be enabled', () => {
expect(TIMELINE_TOP_DRAG).toBe(false);
});
@@ -294,8 +342,8 @@ test('Backspace reset targets multiple selected sequence props', () => {
[Internals.makeSequencePropsSubscriptionKey(nodePath)]: {
canUpdate: true,
props: {
- opacity: {canUpdate: true, codeValue: 0.5},
- 'style.rotate': {canUpdate: true, codeValue: '45deg'},
+ opacity: {canUpdate: true, codeValue: 0.5, keyframed: false},
+ 'style.rotate': {canUpdate: true, codeValue: '45deg', keyframed: false},
},
effects: [],
},
@@ -340,7 +388,7 @@ test('Selected outline dragging applies the same delta to all selected sequences
startY: 20,
target: {
clientId: 'client',
- codeValue: {canUpdate: true, codeValue: '10px 20px'},
+ codeValue: {canUpdate: true, codeValue: '10px 20px', keyframed: false},
fieldDefault: '0px 0px',
nodePath: firstNodePath,
schema,
@@ -353,7 +401,7 @@ test('Selected outline dragging applies the same delta to all selected sequences
startY: 3,
target: {
clientId: 'client',
- codeValue: {canUpdate: true, codeValue: '-5px 3px'},
+ codeValue: {canUpdate: true, codeValue: '-5px 3px', keyframed: false},
fieldDefault: '0px 0px',
nodePath: secondNodePath,
schema,
@@ -415,7 +463,7 @@ test('Backspace reset targets selected effect props', () => {
importPath: null,
effectIndex: 0,
props: {
- intensity: {canUpdate: true, codeValue: 10},
+ intensity: {canUpdate: true, codeValue: 10, keyframed: false},
},
},
],