Skip to content

🎥 Make videos programmatically with React

`@remotion/studio`: Remove `premountFor`, `styleWhilePremounting`, `styleWhilePostmounting` when changing to layout="none"

JonnyBurgerc8723ce3812d
diff --git a/packages/core/src/internals.ts b/packages/core/src/internals.ts
index a522dd5475..3208dd51b9 100644
--- a/packages/core/src/internals.ts
+++ b/packages/core/src/internals.ts
@@ -100,6 +100,7 @@ import {
import type {
SequenceFieldSchema,
SequenceSchema,
+ VisibleFieldSchema,
} from './sequence-field-schema.js';
import {sequenceSchema, sequenceStyleSchema} from './sequence-field-schema.js';
import type {
@@ -335,6 +336,7 @@ export type {
MediaVolumeContextValue,
RemotionEnvironment,
SequenceFieldSchema,
+ VisibleFieldSchema,
SequenceSchema,
SerializedJSONWithCustomFields,
SetMediaVolumeContextValue,
diff --git a/packages/core/src/sequence-field-schema.ts b/packages/core/src/sequence-field-schema.ts
index 36e47862db..544530db60 100644
--- a/packages/core/src/sequence-field-schema.ts
+++ b/packages/core/src/sequence-field-schema.ts
@@ -1,3 +1,7 @@
+export type HiddenFieldSchema = {
+ type: 'hidden';
+};
+
export type NumberFieldSchema = {
type: 'number';
min?: number;
@@ -34,13 +38,15 @@ export type EnumFieldSchema = {
variants: Record<string, SequenceSchema>;
};
-export type SequenceFieldSchema =
+export type VisibleFieldSchema =
| NumberFieldSchema
| BooleanFieldSchema
| RotationFieldSchema
| TranslateFieldSchema
| EnumFieldSchema;
+export type SequenceFieldSchema = VisibleFieldSchema | HiddenFieldSchema;
+
export type SequenceSchema = {[key: string]: SequenceFieldSchema};
export type SchemaKeysRecord<S extends SequenceSchema> = Record<
@@ -77,6 +83,17 @@ export const sequenceStyleSchema = {
default: 1,
description: 'Opacity',
},
+ premountFor: {
+ type: 'number',
+ default: 0,
+ description: 'Premount For',
+ },
+ styleWhilePremounted: {
+ type: 'hidden',
+ },
+ styleWhilePostmounted: {
+ type: 'hidden',
+ },
} as const satisfies SequenceSchema;
export const sequenceSchema = {
diff --git a/packages/core/src/use-schema.ts b/packages/core/src/use-schema.ts
index 9c6405fefc..fdb79b80f8 100644
--- a/packages/core/src/use-schema.ts
+++ b/packages/core/src/use-schema.ts
@@ -63,11 +63,16 @@ export const computeEffectiveSchemaValuesDotNotation = ({
const merged: Record<string, unknown> = {};
for (const key of Object.keys(currentValue)) {
const codeValueStatus = propStatus?.[key] ?? null;
+ const field = findFieldInSchema(schema, key);
+ if (field?.type === 'hidden') {
+ continue;
+ }
+
merged[key] = getEffectiveVisualModeValue({
codeValue: codeValueStatus,
runtimeValue: currentValue[key],
dragOverrideValue: overrideValues[key],
- defaultValue: findFieldInSchema(schema, key)?.default,
+ defaultValue: field?.default,
shouldResortToDefaultValueIfUndefined: false,
});
}
diff --git a/packages/studio-shared/src/schema-field-info.ts b/packages/studio-shared/src/schema-field-info.ts
index c34b8dcf39..a76f60436e 100644
--- a/packages/studio-shared/src/schema-field-info.ts
+++ b/packages/studio-shared/src/schema-field-info.ts
@@ -2,13 +2,14 @@ import type {
CodeValues,
DragOverrides,
SequenceControls,
- SequenceFieldSchema,
+ VisibleFieldSchema,
SequenceSchema,
GetDragOverrides,
GetCodeValues,
SequenceNodePath,
} from 'remotion';
import {Internals} from 'remotion';
+import {NoReactInternals} from 'remotion/no-react';
export type {CodeValues, DragOverrides, SequenceControls};
@@ -19,7 +20,7 @@ export type SchemaFieldInfo = {
supported: boolean;
rowHeight: number;
currentRuntimeValue: unknown;
- fieldSchema: SequenceFieldSchema;
+ fieldSchema: VisibleFieldSchema;
};
export const SCHEMA_FIELD_ROW_HEIGHT = 22;
@@ -58,19 +59,25 @@ export const getFieldsToShow = ({
(key) => valuesDotNotation[key],
);
- return Object.entries(activeSchema).map(([key, fieldSchema]) => {
- const typeName = fieldSchema.type;
- const supported = SUPPORTED_SCHEMA_TYPES.has(typeName);
- return {
- key,
- description: fieldSchema.description,
- typeName,
- supported,
- rowHeight: supported
- ? SCHEMA_FIELD_ROW_HEIGHT
- : UNSUPPORTED_FIELD_ROW_HEIGHT,
- currentRuntimeValue: currentRuntimeValueDotNotation[key],
- fieldSchema,
- };
- });
+ return Object.entries(activeSchema)
+ .map(([key, fieldSchema]) => {
+ const typeName = fieldSchema.type;
+ const supported = SUPPORTED_SCHEMA_TYPES.has(typeName);
+ if (typeName === 'hidden') {
+ return null;
+ }
+
+ return {
+ key,
+ description: fieldSchema.description,
+ typeName,
+ supported,
+ rowHeight: supported
+ ? SCHEMA_FIELD_ROW_HEIGHT
+ : UNSUPPORTED_FIELD_ROW_HEIGHT,
+ currentRuntimeValue: currentRuntimeValueDotNotation[key],
+ fieldSchema,
+ };
+ })
+ .filter(NoReactInternals.truthy);
};
diff --git a/packages/studio/src/helpers/timeline-layout.ts b/packages/studio/src/helpers/timeline-layout.ts
index 77b9c70708..266cc2aaee 100644
--- a/packages/studio/src/helpers/timeline-layout.ts
+++ b/packages/studio/src/helpers/timeline-layout.ts
@@ -11,6 +11,7 @@ import type {
GetDragOverrides,
TSequence,
} from 'remotion';
+import {NoReactInternals} from 'remotion/no-react';
import type {GetIsExpanded} from '../components/ExpandedTracksProvider';
import type {SequenceNodePathInfo} from './get-timeline-sequence-sort-key';
@@ -43,10 +44,18 @@ export const getEffectSchemaLabels = (
return [];
}
- return Object.entries(effect.definition.schema).map(([key, fieldSchema]) => ({
- key,
- description: fieldSchema.description,
- }));
+ return Object.entries(effect.definition.schema)
+ .map(([key, fieldSchema]) => {
+ if (fieldSchema.type === 'hidden') {
+ return null;
+ }
+
+ return {
+ key,
+ description: fieldSchema.description,
+ };
+ })
+ .filter(NoReactInternals.truthy);
};
export type TimelineTreeNode =